chore: common services package (#6255)
* fix: initial services package setup * fix: services packages updates * fix: services changes * fix: merge conflicts * chore: file structuring * fix: import fixes
This commit is contained in:
parent
1ee0661ac1
commit
043f4eaa5e
47 changed files with 2345 additions and 10 deletions
5
packages/services/src/workspace/index.ts
Normal file
5
packages/services/src/workspace/index.ts
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
export * from "./invitation.service";
|
||||
export * from "./member.service";
|
||||
export * from "./notification.service";
|
||||
export * from "./view.service";
|
||||
export * from "./workspace.service";
|
||||
117
packages/services/src/workspace/invitation.service.ts
Normal file
117
packages/services/src/workspace/invitation.service.ts
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
import { API_BASE_URL } from "@plane/constants";
|
||||
import { 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;
|
||||
});
|
||||
}
|
||||
}
|
||||
92
packages/services/src/workspace/member.service.ts
Normal file
92
packages/services/src/workspace/member.service.ts
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
import { API_BASE_URL } from "@plane/constants";
|
||||
import { 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;
|
||||
});
|
||||
}
|
||||
}
|
||||
137
packages/services/src/workspace/notification.service.ts
Normal file
137
packages/services/src/workspace/notification.service.ts
Normal file
|
|
@ -0,0 +1,137 @@
|
|||
import { API_BASE_URL } from "@plane/constants";
|
||||
import {
|
||||
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;
|
||||
});
|
||||
}
|
||||
}
|
||||
67
packages/services/src/workspace/view.service.ts
Normal file
67
packages/services/src/workspace/view.service.ts
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
import { API_BASE_URL } from "@plane/constants";
|
||||
import { 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;
|
||||
});
|
||||
}
|
||||
}
|
||||
141
packages/services/src/workspace/workspace.service.ts
Normal file
141
packages/services/src/workspace/workspace.service.ts
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
import { API_BASE_URL } from "@plane/constants";
|
||||
import { 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;
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue