This commit is contained in:
DCCONSTRUCTIONS
2026-04-18 18:39:25 +03:00
commit 3ba092b60c
4944 changed files with 497564 additions and 0 deletions
@@ -0,0 +1,12 @@
/**
* Copyright (c) 2023-present Plane Software, Inc. and contributors
* SPDX-License-Identifier: AGPL-3.0-only
* See the LICENSE file for details.
*/
export * from "./invitation.service";
export * from "./member.service";
export * from "./notification.service";
export * from "./view.service";
export * from "./workspace.service";
export * from "./instance-workspace.service";
@@ -0,0 +1,71 @@
/**
* Copyright (c) 2023-present Plane Software, Inc. and contributors
* SPDX-License-Identifier: AGPL-3.0-only
* See the LICENSE file for details.
*/
import { API_BASE_URL } from "@plane/constants";
import type { IWorkspace, TWorkspacePaginationInfo } from "@plane/types";
import { APIService } from "../api.service";
/**
* Service class for managing instance workspaces
* Handles CRUD operations on instance workspaces
* @extends APIService
*/
export class InstanceWorkspaceService extends APIService {
/**
* Constructor for InstanceWorkspaceService
* @param BASE_URL - Base URL for API requests
*/
constructor(BASE_URL?: string) {
super(BASE_URL || API_BASE_URL);
}
/**
* Retrieves a paginated list of workspaces for the current instance
* @param {string} nextPageCursor - Optional cursor to retrieve the next page of results
* @returns {Promise<TWorkspacePaginationInfo>} Promise resolving to a paginated list of workspaces
* @throws {Error} If the API request fails
*/
async list(nextPageCursor?: string): Promise<TWorkspacePaginationInfo> {
return this.get(`/api/instances/workspaces/`, {
params: {
cursor: nextPageCursor,
},
})
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
/**
* Checks if a workspace slug is available
* @param {string} slug - The workspace slug to check
* @returns {Promise<any>} Promise resolving to slug availability status
* @throws {Error} If the API request fails
*/
async slugCheck(slug: string): Promise<any> {
const params = new URLSearchParams({ slug });
return this.get(`/api/instances/workspace-slug-check/?${params.toString()}`)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
/**
* Creates a new workspace
* @param {Partial<IWorkspace>} data - Workspace data for creation
* @returns {Promise<IWorkspace>} Promise resolving to the created workspace
* @throws {Error} If the API request fails
*/
async create(data: Partial<IWorkspace>): Promise<IWorkspace> {
return this.post("/api/instances/workspaces/", data)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
}
@@ -0,0 +1,123 @@
/**
* Copyright (c) 2023-present Plane Software, Inc. and contributors
* SPDX-License-Identifier: AGPL-3.0-only
* See the LICENSE file for details.
*/
import { API_BASE_URL } from "@plane/constants";
import type { IWorkspaceMemberInvitation, IWorkspaceBulkInviteFormData, IWorkspaceMember } from "@plane/types";
import { APIService } from "../api.service";
/**
* Service class for managing workspace invitations
* Handles operations related to inviting users to workspaces and managing invitations
* @extends {APIService}
*/
export class WorkspaceInvitationService extends APIService {
constructor(BASE_URL?: string) {
super(BASE_URL || API_BASE_URL);
}
/**
* Retrieves all workspace invitations for the current user
* @returns {Promise<IWorkspaceMemberInvitation[]>} Promise resolving to array of workspace invitations
* @throws {Error} If the API request fails
*/
async userInvitations(): Promise<IWorkspaceMemberInvitation[]> {
return this.get("/api/users/me/workspaces/invitations/")
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
/**
* Retrieves all invitations for a specific workspace
* @param {string} workspaceSlug - The unique slug identifier for the workspace
* @returns {Promise<IWorkspaceMemberInvitation[]>} Promise resolving to array of workspace invitations
* @throws {Error} If the API request fails
*/
async workspaceInvitations(workspaceSlug: string): Promise<IWorkspaceMemberInvitation[]> {
return this.get(`/api/workspaces/${workspaceSlug}/invitations/`)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
/**
* Sends bulk invitations to users for a workspace
* @param {string} workspaceSlug - The unique slug identifier for the workspace
* @param {IWorkspaceBulkInviteFormData} data - Bulk invitation data containing user information
* @returns {Promise<any>} Promise resolving to the invitation response
* @throws {Error} If the API request fails
*/
async invite(workspaceSlug: string, data: IWorkspaceBulkInviteFormData): Promise<any> {
return this.post(`/api/workspaces/${workspaceSlug}/invitations/`, data)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
/**
* Update Invitation
* @param workspaceSlug
* @param invitationId
* @param data
* @returns
*/
async update(workspaceSlug: string, invitationId: string, data: Partial<IWorkspaceMember>): Promise<any> {
return this.patch(`/api/workspaces/${workspaceSlug}/invitations/${invitationId}/`, data)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
/**
* Delete Workspace invitation
* @param workspaceSlug
* @param invitationId
* @returns
*/
async destroy(workspaceSlug: string, invitationId: string): Promise<any> {
return this.delete(`/api/workspaces/${workspaceSlug}/invitations/${invitationId}/`)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
/**
* Accepts an invitation to join a workspace
* @param {string} workspaceSlug - The unique slug identifier for the workspace
* @param {string} invitationId - The unique identifier for the invitation
* @param {any} data - Additional data required for joining the workspace
* @returns {Promise<any>} Promise resolving to the join response
* @throws {Error} If the API request fails
*/
async join(workspaceSlug: string, invitationId: string, data: any): Promise<any> {
return this.post(`/api/workspaces/${workspaceSlug}/invitations/${invitationId}/join/`, data, {
headers: {},
})
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
/**
* Accepts multiple workspace invitations at once
* @param {any} data - Data containing information about invitations to accept
* @returns {Promise<any>} Promise resolving to the bulk join response
* @throws {Error} If the API request fails
*/
async joinMany(data: any): Promise<any> {
return this.post("/api/users/me/workspaces/invitations/", data)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
}
@@ -0,0 +1,98 @@
/**
* Copyright (c) 2023-present Plane Software, Inc. and contributors
* SPDX-License-Identifier: AGPL-3.0-only
* See the LICENSE file for details.
*/
import { API_BASE_URL } from "@plane/constants";
import type { IWorkspaceMemberMe, IWorkspaceMember, IUserProjectsRole } from "@plane/types";
import { APIService } from "../api.service";
/**
* Service class for managing workspace members
* Handles operations related to workspace membership, including member information,
* updates, deletions, and role management
* @extends {APIService}
*/
export class WorkspaceMemberService extends APIService {
/**
* Creates an instance of WorkspaceMemberService
* @param {string} baseUrl - The base URL for API requests
*/
constructor(BASE_URL?: string) {
super(BASE_URL || API_BASE_URL);
}
/**
* Retrieves current user's information for a specific workspace
* @param {string} workspaceSlug - The unique slug identifier for the workspace
* @returns {Promise<IWorkspaceMemberMe>} Promise resolving to current user's workspace member information
* @throws {Error} If the API request fails
*/
async myInfo(workspaceSlug: string): Promise<IWorkspaceMemberMe> {
return this.get(`/api/workspaces/${workspaceSlug}/workspace-members/me/`)
.then((response) => response?.data)
.catch((error) => {
throw error?.response;
});
}
/**
* Retrieves all members of a specific workspace
* @param {string} workspaceSlug - The unique slug identifier for the workspace
* @returns {Promise<IWorkspaceMember[]>} Promise resolving to array of workspace members
* @throws {Error} If the API request fails
*/
async list(workspaceSlug: string): Promise<IWorkspaceMember[]> {
return this.get(`/api/workspaces/${workspaceSlug}/members/`)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
/**
* Updates a workspace member's information
* @param {string} workspaceSlug - The unique slug identifier for the workspace
* @param {string} memberId - The unique identifier for the member
* @param {Partial<IWorkspaceMember>} data - Updated member data
* @returns {Promise<IWorkspaceMember>} Promise resolving to the updated member information
* @throws {Error} If the API request fails
*/
async update(workspaceSlug: string, memberId: string, data: Partial<IWorkspaceMember>): Promise<IWorkspaceMember> {
return this.patch(`/api/workspaces/${workspaceSlug}/members/${memberId}/`, data)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
/**
* Removes a member from a workspace
* @param {string} workspaceSlug - The unique slug identifier for the workspace
* @param {string} memberId - The unique identifier for the member to remove
* @returns {Promise<any>} Promise resolving to the deletion response
* @throws {Error} If the API request fails
*/
async destroy(workspaceSlug: string, memberId: string): Promise<any> {
return this.delete(`/api/workspaces/${workspaceSlug}/members/${memberId}/`)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
/**
* Retrieves the current user's project roles within a workspace
* @param {string} workspaceSlug - The unique slug identifier for the workspace
* @returns {Promise<IUserProjectsRole>} Promise resolving to user's project roles
* @throws {Error} If the API request fails
*/
async getWorkspaceUserProjectsRole(workspaceSlug: string): Promise<IUserProjectsRole> {
return this.get(`/api/users/me/workspaces/${workspaceSlug}/project-roles/`)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
}
@@ -0,0 +1,143 @@
/**
* Copyright (c) 2023-present Plane Software, Inc. and contributors
* SPDX-License-Identifier: AGPL-3.0-only
* See the LICENSE file for details.
*/
import { API_BASE_URL } from "@plane/constants";
import type {
TUnreadNotificationsCount,
TNotificationPaginatedInfo,
TNotification,
TNotificationPaginatedInfoQueryParams,
} from "@plane/types";
// services
import { APIService } from "../api.service";
export class WorkspaceNotificationService extends APIService {
constructor(BASE_URL?: string) {
super(BASE_URL || API_BASE_URL);
}
/**
* Retrieves the count of unread notifications for a workspace
* @param {string} workspaceSlug - The unique identifier for the workspace
* @returns {Promise<TUnreadNotificationsCount | undefined>} The count of unread notifications
*/
async getUnreadCount(workspaceSlug: string): Promise<TUnreadNotificationsCount | undefined> {
return this.get(`/api/workspaces/${workspaceSlug}/users/notifications/unread/`)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
/**
* Retrieves paginated notifications for a workspace
* @param {string} workspaceSlug - The unique identifier for the workspace
* @param {TNotificationPaginatedInfoQueryParams} params - Query parameters for pagination and filtering
* @returns {Promise<TNotificationPaginatedInfo | undefined>} Paginated list of notifications
*/
async list(
workspaceSlug: string,
params: TNotificationPaginatedInfoQueryParams
): Promise<TNotificationPaginatedInfo | undefined> {
return this.get(`/api/workspaces/${workspaceSlug}/users/notifications`, { params })
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
/**
* Updates a specific notification by ID
* @param {string} workspaceSlug - The unique identifier for the workspace
* @param {string} notificationId - The unique identifier for the notification
* @param {Partial<TNotification>} data - The notification data to update
* @returns {Promise<TNotification | undefined>} The updated notification
*/
async update(
workspaceSlug: string,
notificationId: string,
data: Partial<TNotification>
): Promise<TNotification | undefined> {
return this.patch(`/api/workspaces/${workspaceSlug}/users/notifications/${notificationId}/`, data)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
/**
* Marks a notification as read
* @param {string} workspaceSlug - The unique identifier for the workspace
* @param {string} notificationId - The unique identifier for the notification
* @returns {Promise<TNotification | undefined>} The updated notification
*/
async markAsRead(workspaceSlug: string, notificationId: string): Promise<TNotification | undefined> {
return this.post(`/api/workspaces/${workspaceSlug}/users/notifications/${notificationId}/read/`)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
/**
* Marks a notification as unread
* @param {string} workspaceSlug - The unique identifier for the workspace
* @param {string} notificationId - The unique identifier for the notification
* @returns {Promise<TNotification | undefined>} The updated notification
*/
async markAsUnread(workspaceSlug: string, notificationId: string): Promise<TNotification | undefined> {
return this.delete(`/api/workspaces/${workspaceSlug}/users/notifications/${notificationId}/read/`)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
/**
* Archives a notification
* @param {string} workspaceSlug - The unique identifier for the workspace
* @param {string} notificationId - The unique identifier for the notification
* @returns {Promise<TNotification | undefined>} The updated notification
*/
async archive(workspaceSlug: string, notificationId: string): Promise<TNotification | undefined> {
return this.post(`/api/workspaces/${workspaceSlug}/users/notifications/${notificationId}/archive/`)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
/**
* Unarchives a notification
* @param {string} workspaceSlug - The unique identifier for the workspace
* @param {string} notificationId - The unique identifier for the notification
* @returns {Promise<TNotification | undefined>} The updated notification
*/
async unarchive(workspaceSlug: string, notificationId: string): Promise<TNotification | undefined> {
return this.delete(`/api/workspaces/${workspaceSlug}/users/notifications/${notificationId}/archive/`)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
/**
* Marks all notifications as read based on filter criteria
* @param {string} workspaceSlug - The unique identifier for the workspace
* @param {TNotificationPaginatedInfoQueryParams} data - Filter criteria for notifications to mark as read
* @returns {Promise<TNotification | undefined>} The result of the operation
*/
async markAllAsRead(
workspaceSlug: string,
data: TNotificationPaginatedInfoQueryParams
): Promise<TNotification | undefined> {
return this.post(`/api/workspaces/${workspaceSlug}/users/notifications/mark-all-read/`, data)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
}
@@ -0,0 +1,73 @@
/**
* Copyright (c) 2023-present Plane Software, Inc. and contributors
* SPDX-License-Identifier: AGPL-3.0-only
* See the LICENSE file for details.
*/
import { API_BASE_URL } from "@plane/constants";
import type { IWorkspaceView, TIssuesResponse } from "@plane/types";
import { APIService } from "../api.service";
export class WorkspaceViewService extends APIService {
/**
* Creates an instance of WorkspaceViewService
* @param {string} baseUrl - The base URL for API requests
*/
constructor(BASE_URL?: string) {
super(BASE_URL || API_BASE_URL);
}
async create(workspaceSlug: string, data: Partial<IWorkspaceView>): Promise<IWorkspaceView> {
return this.post(`/api/workspaces/${workspaceSlug}/views/`, data)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
async update(workspaceSlug: string, viewId: string, data: Partial<IWorkspaceView>): Promise<IWorkspaceView> {
return this.patch(`/api/workspaces/${workspaceSlug}/views/${viewId}/`, data)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
async destroy(workspaceSlug: string, viewId: string): Promise<any> {
return this.delete(`/api/workspaces/${workspaceSlug}/views/${viewId}/`)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
async list(workspaceSlug: string): Promise<IWorkspaceView[]> {
return this.get(`/api/workspaces/${workspaceSlug}/views/`)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
async retrieve(workspaceSlug: string, viewId: string): Promise<IWorkspaceView> {
return this.get(`/api/workspaces/${workspaceSlug}/views/${viewId}/`)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
async getViewIssues(workspaceSlug: string, params: any, config = {}): Promise<TIssuesResponse> {
return this.get(
`/api/workspaces/${workspaceSlug}/issues/`,
{
params,
},
config
)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
}
@@ -0,0 +1,147 @@
/**
* Copyright (c) 2023-present Plane Software, Inc. and contributors
* SPDX-License-Identifier: AGPL-3.0-only
* See the LICENSE file for details.
*/
import { API_BASE_URL } from "@plane/constants";
import type { IWorkspace, ILastActiveWorkspaceDetails, IWorkspaceSearchResults } from "@plane/types";
import { APIService } from "../api.service";
/**
* Service class for managing workspace operations
* Handles CRUD operations and various workspace-related functionalities
* @extends {APIService}
*/
export class WorkspaceService extends APIService {
/**
* Creates an instance of WorkspaceService
* @param {string} baseUrl - The base URL for API requests
*/
constructor(BASE_URL?: string) {
super(BASE_URL || API_BASE_URL);
}
/**
* Retrieves all workspaces for the current user
* @returns {Promise<IWorkspace[]>} Promise resolving to an array of workspaces
* @throws {Error} If the API request fails
*/
async list(): Promise<IWorkspace[]> {
return this.get("/api/users/me/workspaces/")
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
/**
* Retrieves details of a specific workspace
* @param {string} workspaceSlug - The unique slug identifier for the workspace
* @returns {Promise<IWorkspace>} Promise resolving to workspace details
* @throws {Error} If the API request fails
*/
async retrieve(workspaceSlug: string): Promise<IWorkspace> {
return this.get(`/api/workspaces/${workspaceSlug}/`)
.then((response) => response?.data)
.catch((error) => {
throw error?.response;
});
}
/**
* Creates a new workspace
* @param {Partial<IWorkspace>} data - Workspace data for creation
* @returns {Promise<IWorkspace>} Promise resolving to the created workspace
* @throws {Error} If the API request fails
*/
async create(data: Partial<IWorkspace>): Promise<IWorkspace> {
return this.post("/api/workspaces/", data)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
/**
* Updates an existing workspace
* @param {string} workspaceSlug - The unique slug identifier for the workspace
* @param {Partial<IWorkspace>} data - Updated workspace data
* @returns {Promise<IWorkspace>} Promise resolving to the updated workspace
* @throws {Error} If the API request fails
*/
async update(workspaceSlug: string, data: Partial<IWorkspace>): Promise<IWorkspace> {
return this.patch(`/api/workspaces/${workspaceSlug}/`, data)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
/**
* Deletes a workspace
* @param {string} workspaceSlug - The unique slug identifier for the workspace
* @returns {Promise<any>} Promise resolving to the deletion response
* @throws {Error} If the API request fails
*/
async destroy(workspaceSlug: string): Promise<any> {
return this.delete(`/api/workspaces/${workspaceSlug}/`)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
/**
* Retrieves information about the user's last visited workspace
* @returns {Promise<ILastActiveWorkspaceDetails>} Promise resolving to last active workspace details
* @throws {Error} If the API request fails
*/
async lastVisited(): Promise<ILastActiveWorkspaceDetails> {
return this.get("/api/users/last-visited-workspace/")
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
/**
* Checks if a workspace slug is available
* @param {string} slug - The workspace slug to check
* @returns {Promise<any>} Promise resolving to slug availability status
* @throws {Error} If the API request fails
*/
async slugCheck(slug: string): Promise<any> {
return this.get(`/api/workspace-slug-check/?slug=${slug}`)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
/**
* Searches within a workspace
* @param {string} workspaceSlug - The unique slug identifier for the workspace
* @param {Object} params - Search parameters
* @param {string} [params.project_id] - Optional project ID to scope the search
* @param {string} params.search - Search query string
* @param {boolean} params.workspace_search - Whether to search across the entire workspace
* @returns {Promise<IWorkspaceSearchResults>} Promise resolving to search results
* @throws {Error} If the API request fails
*/
async search(
workspaceSlug: string,
params: {
project_id?: string;
search: string;
workspace_search: boolean;
}
): Promise<IWorkspaceSearchResults> {
return this.get(`/api/workspaces/${workspaceSlug}/search/`, {
params,
})
.then((res) => res?.data)
.catch((error) => {
throw error?.response?.data;
});
}
}