π₯π₯π₯ Open-source Jira, Linear, Monday, and ClickUp alternative. Plane is a modern project management platform to manage tasks, sprints, docs, and triage.
TypeScript boardsbug-trackerdjangodockerganttissue-trackerjirajira-alternativekanbanlinearpostgresqlproduct-managementproject-managementproject-planningpythonreactredistypesciptvitework-management
[WEB-3066] refactor: replace Space Services with Services Package (#6353)
Prateek Shouryaade4d290f5e0
diff --git a/packages/services/src/api.service.ts b/packages/services/src/api.service.tsindex 3574424daf..91d635b0a5 100644--- a/packages/services/src/api.service.ts+++ b/packages/services/src/api.service.ts@@ -34,7 +34,19 @@ export abstract class APIService {(error) => {if (error.response && error.response.status === 401) {const currentPath = window.location.pathname;- window.location.replace(`/${currentPath ? `?next_path=${currentPath}` : ``}`);+ let prefix = "";+ let updatedPath = currentPath;++ // Check for special path prefixes+ if (currentPath.startsWith("/god-mode")) {+ prefix = "/god-mode";+ updatedPath = currentPath.replace("/god-mode", "");+ } else if (currentPath.startsWith("/spaces")) {+ prefix = "/spaces";+ updatedPath = currentPath.replace("/spaces", "");+ }++ window.location.replace(`${prefix}${updatedPath ? `?next_path=${updatedPath}` : ""}`);}return Promise.reject(error);}diff --git a/packages/services/src/auth/index.ts b/packages/services/src/auth/index.tsindex 2ab33e86ab..340b36856d 100644--- a/packages/services/src/auth/index.ts+++ b/packages/services/src/auth/index.ts@@ -1 +1,2 @@export * from "./auth.service";+export * from "./sites-auth.service";diff --git a/packages/services/src/auth/sites-auth.service.ts b/packages/services/src/auth/sites-auth.service.tsnew file mode 100644index 0000000000..638a7b6f26--- /dev/null+++ b/packages/services/src/auth/sites-auth.service.ts@@ -0,0 +1,49 @@+import { API_BASE_URL } from "@plane/constants";+// types+import { IEmailCheckData, IEmailCheckResponse } from "@plane/types";+// services+import { APIService } from "../api.service";++/**+ * Service class for handling authentication-related operations for Plane space application+ * Provides methods for user authentication, password management, and session handling+ * @extends {APIService}+ * @remarks This service is only available for plane sites+ */+export class SitesAuthService extends APIService {+ /**+ * Creates an instance of SitesAuthService+ * Initializes with the base API URL+ */+ constructor(BASE_URL?: string) {+ super(BASE_URL || API_BASE_URL);+ }++ /**+ * Checks if an email exists in the system+ * @param {IEmailCheckData} data - Email data to verify+ * @returns {Promise<IEmailCheckResponse>} Response indicating email status+ * @throws {Error} Throws response data if the request fails+ */+ async emailCheck(data: IEmailCheckData): Promise<IEmailCheckResponse> {+ return this.post("/auth/spaces/email-check/", data, { headers: {} })+ .then((response) => response?.data)+ .catch((error) => {+ throw error?.response?.data;+ });+ }++ /**+ * Generates a unique code for magic link authentication+ * @param {{ email: string }} data - Object containing the email address+ * @returns {Promise<any>} Response containing the generated unique code+ * @throws {Error} Throws response data if the request fails+ */+ async generateUniqueCode(data: { email: string }): Promise<any> {+ return this.post("/auth/spaces/magic-generate/", data, { headers: {} })+ .then((response) => response?.data)+ .catch((error) => {+ throw error?.response?.data;+ });+ }+}diff --git a/packages/services/src/cycle/index.ts b/packages/services/src/cycle/index.tsindex 5956023cbd..6f5dbc6799 100644--- a/packages/services/src/cycle/index.ts+++ b/packages/services/src/cycle/index.ts@@ -2,3 +2,4 @@ export * from "./cycle-analytics.service";export * from "./cycle-archive.service";export * from "./cycle-operations.service";export * from "./cycle.service";+export * from "./sites-cycle.service";diff --git a/packages/services/src/cycle/sites-cycle.service.ts b/packages/services/src/cycle/sites-cycle.service.tsnew file mode 100644index 0000000000..99cf361a75--- /dev/null+++ b/packages/services/src/cycle/sites-cycle.service.ts@@ -0,0 +1,31 @@+// plane imports+import { API_BASE_URL } from "@plane/constants";+import { TPublicCycle } from "@plane/types";+// api service+import { APIService } from "../api.service";++/**+ * Service class for managing cycles within plane sites application.+ * Extends APIService to handle HTTP requests to the cycle-related endpoints.+ * @extends {APIService}+ * @remarks This service is only available for plane sites+ */+export class SitesCycleService extends APIService {+ constructor(BASE_URL?: string) {+ super(BASE_URL || API_BASE_URL);+ }++ /**+ * Retrieves list of cycles for a specific anchor.+ * @param anchor - The anchor identifier for the published entity+ * @returns {Promise<TPublicCycle[]>} The list of cycles+ * @throws {Error} If the request fails+ */+ async list(anchor: string): Promise<TPublicCycle[]> {+ return this.get(`/api/public/anchor/${anchor}/cycles/`)+ .then((response) => response?.data)+ .catch((error) => {+ throw error?.response?.data;+ });+ }+}diff --git a/space/core/services/file-upload.service.ts b/packages/services/src/file/file-upload.service.tssimilarity index 55%rename from space/core/services/file-upload.service.tsrename to packages/services/src/file/file-upload.service.tsindex 09e95f3c0f..a2e5ce5e6e 100644--- a/space/core/services/file-upload.service.ts+++ b/packages/services/src/file/file-upload.service.ts@@ -1,7 +1,12 @@import axios from "axios";-// services-import { APIService } from "@/services/api.service";+// api service+import { APIService } from "../api.service";+/**+ * Service class for handling file upload operations+ * Handles file uploads+ * @extends {APIService}+ */export class FileUploadService extends APIService {private cancelSource: any;@@ -9,7 +14,17 @@ export class FileUploadService extends APIService {super("");}- async uploadFile(url: string, data: FormData): Promise<void> {+ /**+ * Uploads a file to the specified signed URL+ * @param {string} url - The URL to upload the file to+ * @param {FormData} data - The form data to upload+ * @returns {Promise<void>} Promise resolving to void+ * @throws {Error} If the request fails+ */+ async uploadFile(+ url: string,+ data: FormData,+ ): Promise<void> {this.cancelSource = axios.CancelToken.source();return this.post(url, data, {headers: {@@ -28,7 +43,10 @@ export class FileUploadService extends APIService {});}+ /**+ * Cancels the upload+ */cancelUpload() {this.cancelSource.cancel("Upload canceled");}-}+}\ No newline at end of filediff --git a/packages/services/src/file/file.service.ts b/packages/services/src/file/file.service.tsnew file mode 100644index 0000000000..59c054faf1--- /dev/null+++ b/packages/services/src/file/file.service.ts@@ -0,0 +1,67 @@+// plane imports+import { API_BASE_URL } from "@plane/constants";+// api service+import { APIService } from "../api.service";+// helpers+import { getAssetIdFromUrl } from "./helper";++/**+ * Service class for managing file operations within plane applications.+ * Extends APIService to handle HTTP requests to the file-related endpoints.+ * @extends {APIService}+ */+export class FileService extends APIService {+ /**+ * Creates an instance of FileService+ * @param {string} BASE_URL - The base URL for API requests+ */+ constructor(BASE_URL?: string) {+ super(BASE_URL || API_BASE_URL);+ }++ /**+ * Deletes a new asset+ * @param {string} assetPath - The asset path+ * @returns {Promise<void>} Promise resolving to void+ * @throws {Error} If the request fails+ */+ async deleteNewAsset(assetPath: string): Promise<void> {+ return this.delete(assetPath)+ .then((response) => response?.data)+ .catch((error) => {+ throw error?.response?.data;+ });+ }++ /**+ * Deletes an old editor asset+ * @param {string} workspaceId - The workspace identifier+ * @param {string} src - The asset source+ * @returns {Promise<any>} Promise resolving to void+ * @throws {Error} If the request fails+ */+ async deleteOldEditorAsset(workspaceId: string, src: string): Promise<any> {+ const assetKey = getAssetIdFromUrl(src);+ return this.delete(`/api/workspaces/file-assets/${workspaceId}/${assetKey}/`)+ .then((response) => response?.status)+ .catch((error) => {+ throw error?.response?.data;+ });+ }++ /**+ * Restores an old editor asset+ * @param {string} workspaceId - The workspace identifier+ * @param {string} src - The asset source+ * @returns {Promise<void>} Promise resolving to void+ * @throws {Error} If the request fails+ */+ async restoreOldEditorAsset(workspaceId: string, src: string): Promise<void> {+ const assetKey = getAssetIdFromUrl(src);+ return this.post(`/api/workspaces/file-assets/${workspaceId}/${assetKey}/restore/`)+ .then((response) => response?.data)+ .catch((error) => {+ throw error?.response?.data;+ });+ }+}diff --git a/packages/services/src/file/helper.ts b/packages/services/src/file/helper.tsnew file mode 100644index 0000000000..f2361290c0--- /dev/null+++ b/packages/services/src/file/helper.ts@@ -0,0 +1,36 @@+import { TFileMetaDataLite, TFileSignedURLResponse } from "@plane/types";++/**+ * @description from the provided signed URL response, generate a payload to be used to upload the file+ * @param {TFileSignedURLResponse} signedURLResponse+ * @param {File} file+ * @returns {FormData} file upload request payload+ */+export const generateFileUploadPayload = (signedURLResponse: TFileSignedURLResponse, file: File): FormData => {+ const formData = new FormData();+ Object.entries(signedURLResponse.upload_data.fields).forEach(([key, value]) => formData.append(key, value));+ formData.append("file", file);+ return formData;+};++/**+ * @description returns the necessary file meta data to upload a file+ * @param {File} file+ * @returns {TFileMetaDataLite} payload with file info+ */+export const getFileMetaDataForUpload = (file: File): TFileMetaDataLite => ({+ name: file.name,+ size: file.size,+ type: file.type,+});++/**+ * @description this function returns the assetId from the asset source+ * @param {string} src+ * @returns {string} assetId+ */+export const getAssetIdFromUrl = (src: string): string => {+ const sourcePaths = src.split("/");+ const assetUrl = sourcePaths[sourcePaths.length - 1];+ return assetUrl;+};diff --git a/packages/services/src/file/index.ts b/packages/services/src/file/index.tsnew file mode 100644index 0000000000..439db5ac71--- /dev/null+++ b/packages/services/src/file/index.ts@@ -0,0 +1,3 @@+export * from "./file-upload.service";+export * from "./sites-file.service";+export * from "./file.service";diff --git a/space/core/services/file.service.ts b/packages/services/src/file/sites-file.service.tssimilarity index 54%rename from space/core/services/file.service.tsrename to packages/services/src/file/sites-file.service.tsindex 0b4807affb..2d606a09ef 100644--- a/space/core/services/file.service.ts+++ b/packages/services/src/file/sites-file.service.ts@@ -1,22 +1,40 @@+// plane importsimport { API_BASE_URL } from "@plane/constants";+// local servicesimport { TFileEntityInfo, TFileSignedURLResponse } from "@plane/types";+import { FileUploadService } from "./file-upload.service";// helpers-import { generateFileUploadPayload, getAssetIdFromUrl, getFileMetaDataForUpload } from "@/helpers/file.helper";-// services-import { APIService } from "@/services/api.service";-import { FileUploadService } from "@/services/file-upload.service";+import { FileService } from "./file.service";+import { generateFileUploadPayload, getAssetIdFromUrl, getFileMetaDataForUpload } from "./helper";-export class FileService extends APIService {+/**+ * Service class for managing file operations within plane sites application.+ * Extends FileService to manage file-related operations.+ * @extends {FileService}+ * @remarks This service is only available for plane sites+ */+export class SitesFileService extends FileService {private cancelSource: any;fileUploadService: FileUploadService;- constructor() {- super(API_BASE_URL);+ /**+ * Creates an instance of SitesFileService+ * @param {string} BASE_URL - The base URL for API requests+ */+ constructor(BASE_URL?: string) {+ super(BASE_URL || API_BASE_URL);this.cancelUpload = this.cancelUpload.bind(this);// servicesthis.fileUploadService = new FileUploadService();}+ /**+ * Updates the upload status of an asset+ * @param {string} anchor - The anchor identifier+ * @param {string} assetId - The asset identifier+ * @returns {Promise<void>} Promise resolving to void+ * @throws {Error} If the request fails+ */private async updateAssetUploadStatus(anchor: string, assetId: string): Promise<void> {return this.patch(`/api/public/assets/v2/anchor/${anchor}/${assetId}/`).then((response) => response?.data)@@ -25,6 +43,14 @@ export class FileService extends APIService {});}+ /**+ * Updates the upload status of multiple assets+ * @param {string} anchor - The anchor identifier+ * @param {string} entityId - The entity identifier+ * @param {Object} data - The data payload+ * @returns {Promise<void>} Promise resolving to void+ * @throws {Error} If the request fails+ */async updateBulkAssetsUploadStatus(anchor: string,entityId: string,@@ -39,6 +65,14 @@ export class FileService extends APIService {});}+ /**+ * Uploads a file to the specified anchor+ * @param {string} anchor - The anchor identifier+ * @param {TFileEntityInfo} data - The data payload+ * @param {File} file - The file to upload+ * @returns {Promise<TFileSignedURLResponse>} Promise resolving to the signed URL response+ * @throws {Error} If the request fails+ */async uploadAsset(anchor: string, data: TFileEntityInfo, file: File): Promise<TFileSignedURLResponse> {const fileMetaData = getFileMetaDataForUpload(file);return this.post(`/api/public/assets/v2/anchor/${anchor}/`, {@@ -57,23 +91,13 @@ export class FileService extends APIService {});}- async deleteNewAsset(assetPath: string): Promise<void> {- return this.delete(assetPath)- .then((response) => response?.data)- .catch((error) => {- throw error?.response?.data;- });- }-- async deleteOldEditorAsset(workspaceId: string, src: string): Promise<any> {- const assetKey = getAssetIdFromUrl(src);- return this.delete(`/api/workspaces/file-assets/${workspaceId}/${assetKey}/`)- .then((response) => response?.status)- .catch((error) => {- throw error?.response?.data;- });- }-+ /**+ * Restores a new asset+ * @param {string} workspaceSlug - The workspace slug+ * @param {string} src - The asset source+ * @returns {Promise<void>} Promise resolving to void+ * @throws {Error} If the request fails+ */async restoreNewAsset(workspaceSlug: string, src: string): Promise<void> {// remove the last slash and get the asset idconst assetId = getAssetIdFromUrl(src);@@ -84,16 +108,10 @@ export class FileService extends APIService {});}- async restoreOldEditorAsset(workspaceId: string, src: string): Promise<void> {- const assetKey = getAssetIdFromUrl(src);- return this.post(`/api/workspaces/file-assets/${workspaceId}/${assetKey}/restore/`)- .then((response) => response?.data)- .catch((error) => {- throw error?.response?.data;- });- }-+ /**+ * Cancels the upload+ */cancelUpload() {- this.cancelSource.cancel("Upload cancelled");+ this.cancelSource.cancelUpload();}}diff --git a/packages/services/src/index.ts b/packages/services/src/index.tsindex 677aa28e7a..3c49084628 100644--- a/packages/services/src/index.ts+++ b/packages/services/src/index.ts@@ -10,3 +10,7 @@ export * from "./module";export * from "./user";export * from "./project";export * from "./workspace";+export * from "./file";+export * from "./label";+export * from "./state";+export * from "./issue";diff --git a/packages/services/src/issue/index.ts b/packages/services/src/issue/index.tsnew file mode 100644index 0000000000..79d4537cd2--- /dev/null+++ b/packages/services/src/issue/index.ts@@ -0,0 +1 @@+export * from "./sites-issue.service";diff --git a/packages/services/src/issue/sites-issue.service.ts b/packages/services/src/issue/sites-issue.service.tsnew file mode 100644index 0000000000..9b6aa772e4--- /dev/null+++ b/packages/services/src/issue/sites-issue.service.ts@@ -0,0 +1,244 @@+// plane imports+import { API_BASE_URL } from "@plane/constants";+import { IPublicIssue, TIssuePublicComment, TPublicIssuesResponse } from "@plane/types";+// api service+import { APIService } from "../api.service";++/**+ * Service class for managing issues within plane sites application+ * Extends the APIService class to handle HTTP requests to the issue-related endpoints+ * @extends {APIService}+ * @remarks This service is only available for plane sites+ */+export class SitesIssueService extends APIService {+ constructor(BASE_URL?: string) {+ super(BASE_URL || API_BASE_URL);+ }++ /**+ * Retrieves a paginated list of issues for a specific anchor+ * @param {string} anchor - The anchor identifier+ * @param {any} params - Optional query parameters+ * @returns {Promise<TPublicIssuesResponse>} Promise resolving to a paginated list of issues+ * @throws {Error} If the API request fails+ */+ async list(anchor: string, params: any): Promise<TPublicIssuesResponse> {+ return this.get(`/api/public/anchor/${anchor}/issues/`, {+ params,+ })+ .then((response) => response?.data)+ .catch((error) => {+ throw error?.response;+ });+ }++ /**+ * Retrieves details of a specific issue+ * @param {string} anchor - The anchor identifier+ * @param {string} issueID - The issue identifier+ * @returns {Promise<IPublicIssue>} Promise resolving to the issue details+ * @throws {Error} If the API request fails+ */+ async retrieve(anchor: string, issueID: string): Promise<IPublicIssue> {+ return this.get(`/api/public/anchor/${anchor}/issues/${issueID}/`)+ .then((response) => response?.data)+ .catch((error) => {+ throw error?.response;+ });+ }++ /**+ * Retrieves the votes associated with a specific issue+ * @param {string} anchor - The anchor identifier+ * @param {string} issueID - The issue identifier+ * @returns {Promise<any>} Promise resolving to the votes+ * @throws {Error} If the API request fails+ */+ async listVotes(anchor: string, issueID: string): Promise<any> {+ return this.get(`/api/public/anchor/${anchor}/issues/${issueID}/votes/`)+ .then((response) => response?.data)+ .catch((error) => {+ throw error?.response;+ });+ }++ /**+ * Creates a new vote for a specific issue+ * @param {string} anchor - The anchor identifier+ * @param {string} issueID - The issue identifier+ * @param {any} data - The vote data+ * @returns {Promise<any>} Promise resolving to the created vote+ * @throws {Error} If the API request fails+ */+ async addVote(anchor: string, issueID: string, data: any): Promise<any> {+ return this.post(`/api/public/anchor/${anchor}/issues/${issueID}/votes/`, data)+ .then((response) => response?.data)+ .catch((error) => {+ throw error?.response;+ });+ }++ /**+ * Deletes a vote for a specific issue+ * @param {string} anchor - The anchor identifier+ * @param {string} issueID - The issue identifier+ * @returns {Promise<any>} Promise resolving to the deletion response+ * @throws {Error} If the API request fails+ */+ async removeVote(anchor: string, issueID: string): Promise<any> {+ return this.delete(`/api/public/anchor/${anchor}/issues/${issueID}/votes/`)+ .then((response) => response?.data)+ .catch((error) => {+ throw error?.response;+ });+ }++ /**+ * Retrieves the reactions associated with a specific issue+ * @param {string} anchor - The anchor identifier+ * @param {string} issueID - The issue identifier+ * @returns {Promise<any>} Promise resolving to the reactions+ * @throws {Error} If the API request fails+ */+ async listReactions(anchor: string, issueID: string): Promise<any> {+ return this.get(`/api/public/anchor/${anchor}/issues/${issueID}/reactions/`)+ .then((response) => response?.data)+ .catch((error) => {+ throw error?.response;+ });+ }++ /**+ * Creates a new reaction for a specific issue+ * @param {string} anchor - The anchor identifier+ * @param {string} issueID - The issue identifier+ * @param {any} data - The reaction data+ * @returns {Promise<any>} Promise resolving to the created reaction+ * @throws {Error} If the API request fails+ */+ async addReaction(anchor: string, issueID: string, data: any): Promise<any> {+ return this.post(`/api/public/anchor/${anchor}/issues/${issueID}/reactions/`, data)+ .then((response) => response?.data)+ .catch((error) => {+ throw error?.response;+ });+ }++ /**+ * Deletes a reaction for a specific issue+ * @param {string} anchor - The anchor identifier+ * @param {string} issueID - The issue identifier+ * @param {string} reactionId - The reaction identifier+ * @returns {Promise<any>} Promise resolving to the deletion response+ * @throws {Error} If the API request fails+ */+ async removeReaction(anchor: string, issueID: string, reactionId: string): Promise<any> {+ return this.delete(`/api/public/anchor/${anchor}/issues/${issueID}/reactions/${reactionId}/`)+ .then((response) => response?.data)+ .catch((error) => {+ throw error?.response;+ });+ }++ /**+ * Retrieves the comments associated with a specific issue+ * @param {string} anchor - The anchor identifier+ * @param {string} issueID - The issue identifier+ * @returns {Promise<any>} Promise resolving to the comments+ * @throws {Error} If the API request fails+ */+ async listComments(anchor: string, issueID: string): Promise<any> {+ return this.get(`/api/public/anchor/${anchor}/issues/${issueID}/comments/`)+ .then((response) => response?.data)+ .catch((error) => {+ throw error?.response;+ });+ }++ /**+ * Creates a new comment for a specific issue+ * @param {string} anchor - The anchor identifier+ * @param {string} issueID - The issue identifier+ * @param {any} data - The comment data+ * @returns {Promise<TIssuePublicComment>} Promise resolving to the created comment+ * @throws {Error} If the API request fails+ */+ async addComment(anchor: string, issueID: string, data: any): Promise<TIssuePublicComment> {+ return this.post(`/api/public/anchor/${anchor}/issues/${issueID}/comments/`, data)+ .then((response) => response?.data)+ .catch((error) => {+ throw error?.response;+ });+ }++ /**+ * Updates a comment for a specific issue+ * @param {string} anchor - The anchor identifier+ * @param {string} issueID - The issue identifier+ * @param {string} commentId - The comment identifier+ * @param {any} data - The updated comment data+ * @returns {Promise<any>} Promise resolving to the updated comment+ * @throws {Error} If the API request fails+ */+ async updateComment(anchor: string, issueID: string, commentId: string, data: any): Promise<any> {+ return this.patch(`/api/public/anchor/${anchor}/issues/${issueID}/comments/${commentId}/`, data)+ .then((response) => response?.data)+ .catch((error) => {+ throw error?.response;+ });+ }++ /**+ * Deletes a comment for a specific issue+ * @param {string} anchor - The anchor identifier+ * @param {string} issueID - The issue identifier+ * @param {string} commentId - The comment identifier+ * @returns {Promise<any>} Promise resolving to the deletion response+ * @throws {Error} If the API request fails+ */+ async removeComment(anchor: string, issueID: string, commentId: string): Promise<any> {+ return this.delete(`/api/public/anchor/${anchor}/issues/${issueID}/comments/${commentId}/`)+ .then((response) => response?.data)+ .catch((error) => {+ throw error?.response;+ });+ }++ /**+ * Creates a new reaction for a specific comment+ * @param {string} anchor - The anchor identifier+ * @param {string} commentId - The comment identifier+ * @param {any} data - The reaction data+ * @returns {Promise<any>} Promise resolving to the created reaction+ * @throws {Error} If the API request fails+ */+ async addCommentReaction(+ anchor: string,+ commentId: string,+ data: {+ reaction: string;+ }+ ): Promise<any> {+ return this.post(`/api/public/anchor/${anchor}/comments/${commentId}/reactions/`, data)+ .then((response) => response?.data)+ .catch((error) => {+ throw error?.response;+ });+ }++ /**+ * Deletes a reaction for a specific comment+ * @param {string} anchor - The anchor identifier+ * @param {string} commentId - The comment identifier+ * @param {string} reactionHex - The reaction identifier+ * @returns {Promise<any>} Promise resolving to the deletion response+ * @throws {Error} If the API request fails+ */+ async removeCommentReaction(anchor: string, commentId: string, reactionHex: string): Promise<any> {+ return this.delete(`/api/public/anchor/${anchor}/comments/${commentId}/reactions/${reactionHex}/`)+ .then((response) => response?.data)+ .catch((error) => {+ throw error?.response;+ });+ }+}diff --git a/packages/services/src/label/index.ts b/packages/services/src/label/index.tsnew file mode 100644index 0000000000..5bf89fa968--- /dev/null+++ b/packages/services/src/label/index.ts@@ -0,0 +1 @@+export * from "./sites-label.service";diff --git a/packages/services/src/label/sites-label.service.ts b/packages/services/src/label/sites-label.service.tsnew file mode 100644index 0000000000..60ad96271a--- /dev/null+++ b/packages/services/src/label/sites-label.service.ts@@ -0,0 +1,31 @@+// plane imports+import { API_BASE_URL } from "@plane/constants";+import { IIssueLabel } from "@plane/types";+// api service+import { APIService } from "../api.service";++/**+ * Service class for managing labels within plane sites application.+ * Extends APIService to handle HTTP requests to the label-related endpoints.+ * @extends {APIService}+ * @remarks This service is only available for plane sites+ */+export class SitesLabelService extends APIService {+ constructor(BASE_URL?: string) {+ super(BASE_URL || API_BASE_URL);+ }++ /**+ * Retrieves a list of labels for a specific anchor.+ * @param {string} anchor - The anchor identifier+ * @returns {Promise<IIssueLabel[]>} The list of labels+ * @throws {Error} If the API request fails+ */+ async list(anchor: string): Promise<IIssueLabel[]> {+ return this.get(`/api/public/anchor/${anchor}/labels/`)+ .then((response) => response?.data)+ .catch((error) => {+ throw error?.response?.data;+ });+ }+}diff --git a/packages/services/src/module/index.ts b/packages/services/src/module/index.tsindex 8f08f92b83..ad49212285 100644--- a/packages/services/src/module/index.ts+++ b/packages/services/src/module/index.ts@@ -1,3 +1,4 @@export * from "./link.service";export * from "./module.service";export * from "./operations.service";+export * from "./sites-module.service";diff --git a/packages/services/src/module/sites-module.service.ts b/packages/services/src/module/sites-module.service.tsnew file mode 100644index 0000000000..333535ac38--- /dev/null+++ b/packages/services/src/module/sites-module.service.ts@@ -0,0 +1,31 @@+// plane imports+import { API_BASE_URL } from "@plane/constants";+// api service+import { TPublicModule } from "@plane/types";+import { APIService } from "../api.service";++/**+ * Service class for managing modules within plane sites application.+ * Extends APIService to handle HTTP requests to the module-related endpoints.+ * @extends {APIService}+ * @remarks This service is only available for plane sites+ */+export class SitesModuleService extends APIService {+ constructor(BASE_URL?: string) {+ super(BASE_URL || API_BASE_URL);+ }++ /**+ * Retrieves a list of modules for a specific anchor.+ * @param {string} anchor - The anchor identifier+ * @returns {Promise<TPublicModule[]>} The list of modules+ * @throws {Error} If the API request fails+ */+ async list(anchor: string): Promise<TPublicModule[]> {+ return this.get(`/api/public/anchor/${anchor}/modules/`)+ .then((response) => response?.data)+ .catch((error) => {+ throw error?.response?.data;+ });+ }+}diff --git a/packages/services/src/project/index.ts b/packages/services/src/project/index.tsindex a470a73286..4cc54d2c20 100644--- a/packages/services/src/project/index.ts+++ b/packages/services/src/project/index.ts@@ -1 +1,2 @@-export * from "./view.service";\ No newline at end of file+export * from "./view.service";+export * from "./sites-publish.service";diff --git a/packages/services/src/project/sites-publish.service.ts b/packages/services/src/project/sites-publish.service.tsnew file mode 100644index 0000000000..52d42f5ee4--- /dev/null+++ b/packages/services/src/project/sites-publish.service.ts@@ -0,0 +1,46 @@+// plane imports+import { API_BASE_URL } from "@plane/constants";+import { TProjectPublishSettings } from "@plane/types";+// api service+import { APIService } from "../api.service";++/**+ * Service class for managing project publish operations within plane sites application.+ * Extends APIService to handle HTTP requests to the project publish-related endpoints.+ * @extends {APIService}+ * @remarks This service is only available for plane sites+ */+export class SitesProjectPublishService extends APIService {+ constructor(BASE_URL?: string) {+ super(BASE_URL || API_BASE_URL);+ }++ /**+ * Retrieves publish settings for a specific anchor.+ * @param {string} anchor - The anchor identifier+ * @returns {Promise<TProjectPublishSettings>} The publish settings+ * @throws {Error} If the API request fails+ */+ async retrieveSettingsByAnchor(anchor: string): Promise<TProjectPublishSettings> {+ return this.get(`/api/public/anchor/${anchor}/settings/`)+ .then((response) => response?.data)+ .catch((error) => {+ throw error?.response;+ });+ }++ /**+ * Retrieves publish settings for a specific project.+ * @param {string} workspaceSlug - The workspace slug+ * @param {string} projectID - The project identifier+ * @returns {Promise<TProjectPublishSettings>} The publish settings+ * @throws {Error} If the API request fails+ */+ async retrieveSettingsByProjectId(workspaceSlug: string, projectID: string): Promise<TProjectPublishSettings> {+ return this.get(`/api/public/workspaces/${workspaceSlug}/projects/${projectID}/anchor/`)+ .then((response) => response?.data)+ .catch((error) => {+ throw error?.response;+ });+ }+}diff --git a/packages/services/src/state/index.ts b/packages/services/src/state/index.tsnew file mode 100644index 0000000000..5b49aad0eb--- /dev/null+++ b/packages/services/src/state/index.ts@@ -0,0 +1 @@+export * from "./sites-state.service";diff --git a/packages/services/src/state/sites-state.service.ts b/packages/services/src/state/sites-state.service.tsnew file mode 100644index 0000000000..98ff466d04--- /dev/null+++ b/packages/services/src/state/sites-state.service.ts@@ -0,0 +1,31 @@+// plane imports+import { API_BASE_URL } from "@plane/constants";+import { IState } from "@plane/types";+// api service+import { APIService } from "../api.service";++/**+ * Service class for managing states within plane sites application.+ * Extends APIService to handle HTTP requests to the state-related endpoints.+ * @extends {APIService}+ * @remarks This service is only available for plane sites+ */+export class SitesStateService extends APIService {+ constructor(BASE_URL?: string) {+ super(BASE_URL || API_BASE_URL);+ }++ /**+ * Retrieves a list of states for a specific anchor.+ * @param {string} anchor - The anchor identifier+ * @returns {Promise<IState[]>} The list of states+ * @throws {Error} If the API request fails+ */+ async list(anchor: string): Promise<IState[]> {+ return this.get(`/api/public/anchor/${anchor}/states/`)+ .then((response) => response?.data)+ .catch((error) => {+ throw error?.response?.data;+ });+ }+}diff --git a/packages/services/src/user/index.ts b/packages/services/src/user/index.tsindex c738d93ee8..f01a1a47bd 100644--- a/packages/services/src/user/index.ts+++ b/packages/services/src/user/index.ts@@ -1,2 +1,3 @@export * from "./favorite.service";export * from "./user.service";+export * from "./sites-member.service";diff --git a/packages/services/src/user/sites-member.service.ts b/packages/services/src/user/sites-member.service.tsnew file mode 100644index 0000000000..45cb80626b--- /dev/null+++ b/packages/services/src/user/sites-member.service.ts@@ -0,0 +1,31 @@+// plane imports+import { API_BASE_URL } from "@plane/constants";+import { TPublicMember } from "@plane/types";+// api service+import { APIService } from "../api.service";++/**+ * Service class for managing members operations within plane sites application.+ * Extends APIService to handle HTTP requests to the member-related endpoints.+ * @extends {APIService}+ * @remarks This service is only available for plane sites+ */+export class SitesMemberService extends APIService {+ constructor(BASE_URL?: string) {+ super(BASE_URL || API_BASE_URL);+ }++ /**+ * Retrieves a list of members for a specific anchor.+ * @param {string} anchor - The anchor identifier+ * @returns {Promise<TPublicMember[]>} The list of members+ * @throws {Error} If the API request fails+ */+ async list(anchor: string): Promise<TPublicMember[]> {+ return this.get(`/api/public/anchor/${anchor}/members/`)+ .then((response) => response?.data)+ .catch((error) => {+ throw error?.response?.data;+ });+ }+}diff --git a/packages/services/src/user/user.service.ts b/packages/services/src/user/user.service.tsindex 016c2e7e67..c302b1d4f1 100644--- a/packages/services/src/user/user.service.ts+++ b/packages/services/src/user/user.service.ts@@ -1,6 +1,6 @@// plane importsimport { API_BASE_URL } from "@plane/constants";-import type { IUser } from "@plane/types";+import type { IUser, TUserProfile } from "@plane/types";// api serviceimport { APIService } from "../api.service";@@ -18,6 +18,60 @@ export class UserService extends APIService {super(BASE_URL || API_BASE_URL);}+ /**+ * Retrieves the current user details+ * @returns {Promise<IUser>} Promise resolving to the current user details\+ * @remarks This method uses the validateStatus: null option to bypass interceptors for unauthorized errors.+ */+ async me(): Promise<IUser> {+ return this.get("/api/users/me/", { validateStatus: null })+ .then((response) => response?.data)+ .catch((error) => {+ throw error?.response;+ });+ }++ /**+ * Updates the current user details+ * @param {Partial<IUser>} data Data to update the user with+ * @returns {Promise<IUser>} Promise resolving to the updated user details+ * @throws {Error} If the API request fails+ */+ async update(data: Partial<IUser>): Promise<IUser> {+ return this.patch("/api/users/me/", data)+ .then((response) => response?.data)+ .catch((error) => {+ throw error?.response?.data;+ });+ }++ /**+ * Retrieves the current user's profile details+ * @returns {Promise<TUserProfile>} Promise resolving to the current user's profile details+ * @throws {Error} If the API request fails+ */+ async profile(): Promise<TUserProfile> {+ return this.get("/api/users/me/profile/")+ .then((response) => response?.data)+ .catch((error) => {+ throw error?.response;+ });+ }++ /**+ * Updates the current user's profile details+ * @param {Partial<TUserProfile>} data Data to update the user's profile with+ * @returns {Promise<TUserProfile>} Promise resolving to the updated user's profile details+ * @throws {Error} If the API request fails+ */+ async updateProfile(data: Partial<TUserProfile>): Promise<TUserProfile> {+ return this.patch("/api/users/me/profile/", data)+ .then((response) => response?.data)+ .catch((error) => {+ throw error?.response;+ });+ }+/*** Retrieves the current instance admin details* @returns {Promise<IUser>} Promise resolving to the current instance admin detailsdiff --git a/packages/types/src/auth.d.ts b/packages/types/src/auth.d.tsindex 576ac45b6e..65000c5032 100644--- a/packages/types/src/auth.d.ts+++ b/packages/types/src/auth.d.ts@@ -7,6 +7,7 @@ export interface IEmailCheckData {export interface IEmailCheckResponse {status: "MAGIC_CODE" | "CREDENTIAL";existing: boolean;+ is_password_autoset: boolean;}export interface ILoginTokenResponse {diff --git a/packages/types/src/cycle/cycle.d.ts b/packages/types/src/cycle/cycle.d.tsindex 1c2fa273aa..0aa3fc2804 100644--- a/packages/types/src/cycle/cycle.d.ts+++ b/packages/types/src/cycle/cycle.d.ts@@ -132,3 +132,9 @@ export type CycleDateCheckData = {export type TCycleEstimateType = "issues" | "points";export type TCyclePlotType = "burndown" | "burnup";++export type TPublicCycle = {+ id: string;+ name: string;+ status: string;+};diff --git a/packages/types/src/issues/activity/issue_comment.d.ts b/packages/types/src/issues/activity/issue_comment.d.tsindex f361ea7201..aef5134c67 100644--- a/packages/types/src/issues/activity/issue_comment.d.ts+++ b/packages/types/src/issues/activity/issue_comment.d.ts@@ -37,3 +37,30 @@ export type TIssueCommentMap = {export type TIssueCommentIdMap = {[issue_id: string]: string[];};++export type TIssuePublicComment = {+ actor_detail: ActorDetail;+ access: string;+ actor: string;+ attachments: any[];+ comment_html: string;+ comment_reactions: {+ actor_detail: ActorDetail;+ comment: string;+ id: string;+ reaction: string;+ }[];+ comment_stripped: string;+ created_at: Date;+ created_by: string;+ id: string;+ is_member: boolean;+ issue: string;+ issue_detail: IssueDetail;+ project: string;+ project_detail: ProjectDetail;+ updated_at: Date;+ updated_by: string;+ workspace: string;+ workspace_detail: IWorkspaceLite;+};diff --git a/packages/types/src/issues/issue.d.ts b/packages/types/src/issues/issue.d.tsindex 6fd160e77f..e38810004b 100644--- a/packages/types/src/issues/issue.d.ts+++ b/packages/types/src/issues/issue.d.ts@@ -2,8 +2,8 @@ import { EIssueServiceType } from "@plane/constants";import { TIssuePriorities } from "../issues";import { TIssueAttachment } from "./issue_attachment";import { TIssueLink } from "./issue_link";-import { TIssueReaction } from "./issue_reaction";-import { TIssueRelationTypes } from "@/plane-web/types";+import { TIssueReaction, IIssuePublicReaction, IPublicVote } from "./issue_reaction";+import { TIssueRelationTypes, TIssuePublicComment } from "@/plane-web/types";// new issue structure types@@ -118,12 +118,65 @@ export type TBulkOperationsPayload = {properties: Partial<TBulkIssueProperties>;};-export type TIssueDetailWidget =- | "sub-issues"- | "relations"- | "links"- | "attachments";+export type TIssueDetailWidget = "sub-issues" | "relations" | "links" | "attachments";++export type TIssueServiceType = EIssueServiceType.ISSUES | EIssueServiceType.EPICS;++export interface IPublicIssue+ extends Pick<+ TIssue,+ | "description_html"+ | "created_at"+ | "updated_at"+ | "created_by"+ | "id"+ | "name"+ | "priority"+ | "state_id"+ | "project_id"+ | "sequence_id"+ | "sort_order"+ | "start_date"+ | "target_date"+ | "cycle_id"+ | "module_ids"+ | "label_ids"+ | "assignee_ids"+ | "attachment_count"+ | "sub_issues_count"+ | "link_count"+ | "estimate_point"+ > {+ comments: TIssuePublicComment[];+ reaction_items: IIssuePublicReaction[];+ vote_items: IPublicVote[];+}++type TPublicIssueResponseResults =+ | IPublicIssue[]+ | {+ [key: string]: {+ results:+ | IPublicIssue[]+ | {+ [key: string]: {+ results: IPublicIssue[];+ total_results: number;+ };+ };+ total_results: number;+ };+ };-export type TIssueServiceType =- | EIssueServiceType.ISSUES- | EIssueServiceType.EPICS;+export type TPublicIssuesResponse = {+ grouped_by: string;+ next_cursor: string;+ prev_cursor: string;+ next_page_results: boolean;+ prev_page_results: boolean;+ total_count: number;+ count: number;+ total_pages: number;+ extra_stats: null;+ results: TPublicIssueResponseResults;+};diff --git a/packages/types/src/issues/issue_reaction.d.ts b/packages/types/src/issues/issue_reaction.d.tsindex 7fba8cd9c5..49c971f4af 100644--- a/packages/types/src/issues/issue_reaction.d.ts+++ b/packages/types/src/issues/issue_reaction.d.ts@@ -1,3 +1,5 @@+import { IUserLite } from "../users";+export type TIssueReaction = {actor: string;id: string;@@ -5,6 +7,11 @@ export type TIssueReaction = {reaction: string;};+export interface IIssuePublicReaction {+ actor_details: IUserLite;+ reaction: string;+}+export type TIssueReactionMap = {[reaction_id: string]: TIssueReaction;};@@ -12,3 +19,8 @@ export type TIssueReactionMap = {export type TIssueReactionIdMap = {[issue_id: string]: { [reaction: string]: string[] };};++export interface IPublicVote {+ vote: -1 | 1;+ actor_details: IUserLite;+}diff --git a/packages/types/src/module/modules.d.ts b/packages/types/src/module/modules.d.tsindex fa77a6a414..ce845e60de 100644--- a/packages/types/src/module/modules.d.ts+++ b/packages/types/src/module/modules.d.ts@@ -117,3 +117,8 @@ export type SelectModuleType =| undefined;export type TModulePlotType = "burndown" | "points";++export type TPublicModule = {+ id: string;+ name: string;+};diff --git a/packages/types/src/users.d.ts b/packages/types/src/users.d.tsindex c562e7c246..e5140fdef1 100644--- a/packages/types/src/users.d.ts+++ b/packages/types/src/users.d.ts@@ -182,6 +182,17 @@ export interface IUserEmailNotificationSettings {export type TProfileViews = "assigned" | "created" | "subscribed";+export type TPublicMember = {+ id: string;+ member: string;+ member__avatar: string;+ member__first_name: string;+ member__last_name: string;+ member__display_name: string;+ project: string;+ workspace: string;+};+// export interface ICurrentUser {// id: readonly string;// avatar: string;diff --git a/space/app/[workspaceSlug]/[projectId]/page.ts b/space/app/[workspaceSlug]/[projectId]/page.tsindex 1f8b8345d0..5fbb835dcd 100644--- a/space/app/[workspaceSlug]/[projectId]/page.ts+++ b/space/app/[workspaceSlug]/[projectId]/page.ts@@ -1,10 +1,9 @@import { notFound, redirect } from "next/navigation";-// types+// plane imports+import { SitesProjectPublishService } from "@plane/services";import { TProjectPublishSettings } from "@plane/types";-// services-import PublishService from "@/services/publish.service";-const publishService = new PublishService();+const publishService = new SitesProjectPublishService();type Props = {params: {@@ -22,7 +21,7 @@ export default async function IssuesPage(props: Props) {let response: TProjectPublishSettings | undefined = undefined;try {- response = await publishService.fetchAnchorFromProjectDetails(workspaceSlug, projectId);+ response = await publishService.retrieveSettingsByProjectId(workspaceSlug, projectId);} catch (error) {// redirect to 404 page on errornotFound();diff --git a/space/core/components/account/auth-forms/auth-root.tsx b/space/core/components/account/auth-forms/auth-root.tsxindex afa3bd3a5e..2ce944a258 100644--- a/space/core/components/account/auth-forms/auth-root.tsx+++ b/space/core/components/account/auth-forms/auth-root.tsx@@ -3,6 +3,8 @@import React, { FC, useEffect, useState } from "react";import { observer } from "mobx-react";import { useSearchParams } from "next/navigation";+// plane imports+import { SitesAuthService } from "@plane/services";import { IEmailCheckData } from "@plane/types";// componentsimport {@@ -23,12 +25,10 @@ import {} from "@/helpers/authentication.helper";// hooksimport { useInstance } from "@/hooks/store";-// services-import { AuthService } from "@/services/auth.service";// typesimport { EAuthModes, EAuthSteps } from "@/types/auth";-const authService = new AuthService();+const authService = new SitesAuthService();export const AuthRoot: FC = observer(() => {// router paramsdiff --git a/space/core/components/account/auth-forms/password.tsx b/space/core/components/account/auth-forms/password.tsxindex 5f0384f9bb..08ff7f1421 100644--- a/space/core/components/account/auth-forms/password.tsx+++ b/space/core/components/account/auth-forms/password.tsx@@ -3,14 +3,14 @@import React, { useEffect, useMemo, useRef, useState } from "react";import { observer } from "mobx-react";import { Eye, EyeOff, XCircle } from "lucide-react";+// plane importsimport { API_BASE_URL } from "@plane/constants";+import { AuthService } from "@plane/services";import { Button, Input, Spinner } from "@plane/ui";// componentsimport { PasswordStrengthMeter } from "@/components/account";// helpersimport { E_PASSWORD_STRENGTH, getPasswordStrength } from "@/helpers/password.helper";-// services-import { AuthService } from "@/services/auth.service";// typesimport { EAuthModes, EAuthSteps } from "@/types/auth";diff --git a/space/core/components/account/auth-forms/unique-code.tsx b/space/core/components/account/auth-forms/unique-code.tsxindex f16796d058..750b52ccda 100644--- a/space/core/components/account/auth-forms/unique-code.tsx+++ b/space/core/components/account/auth-forms/unique-code.tsx@@ -2,12 +2,12 @@import React, { useEffect, useState } from "react";import { CircleCheck, XCircle } from "lucide-react";+// plane importsimport { API_BASE_URL } from "@plane/constants";+import { AuthService } from "@plane/services";import { Button, Input, Spinner } from "@plane/ui";// hooksimport useTimer from "@/hooks/use-timer";-// services-import { AuthService } from "@/services/auth.service";// typesimport { EAuthModes } from "@/types/auth";diff --git a/space/core/components/issues/navbar/user-avatar.tsx b/space/core/components/issues/navbar/user-avatar.tsxindex 4c41677fc7..0d07064782 100644--- a/space/core/components/issues/navbar/user-avatar.tsx+++ b/space/core/components/issues/navbar/user-avatar.tsx@@ -7,15 +7,15 @@ import { usePathname, useSearchParams } from "next/navigation";import { usePopper } from "react-popper";import { LogOut } from "lucide-react";import { Popover, Transition } from "@headlessui/react";+// plane importsimport { API_BASE_URL } from "@plane/constants";+import { AuthService } from "@plane/services";import { Avatar, Button } from "@plane/ui";// helpersimport { getFileURL } from "@/helpers/file.helper";import { queryParamGenerator } from "@/helpers/query-param-generator";// hooksimport { useUser } from "@/hooks/store";-// services-import { AuthService } from "@/services/auth.service";const authService = new AuthService();diff --git a/space/core/components/issues/peek-overview/comment/add-comment.tsx b/space/core/components/issues/peek-overview/comment/add-comment.tsxindex 3623f39864..9712b64e69 100644--- a/space/core/components/issues/peek-overview/comment/add-comment.tsx+++ b/space/core/components/issues/peek-overview/comment/add-comment.tsx@@ -3,21 +3,19 @@import React, { useRef, useState } from "react";import { observer } from "mobx-react";import { useForm, Controller } from "react-hook-form";-// editor+// plane importsimport { EditorRefApi } from "@plane/editor";-// ui+import { SitesFileService } from "@plane/services";+import { TIssuePublicComment } from "@plane/types";import { TOAST_TYPE, setToast } from "@plane/ui";// editor componentsimport { LiteTextEditor } from "@/components/editor/lite-text-editor";// hooksimport { useIssueDetails, usePublish, useUser } from "@/hooks/store";// services-import { FileService } from "@/services/file.service";-const fileService = new FileService();-// types-import { Comment } from "@/types/issue";+const fileService = new SitesFileService();-const defaultValues: Partial<Comment> = {+const defaultValues: Partial<TIssuePublicComment> = {comment_html: "",};@@ -43,9 +41,9 @@ export const AddComment: React.FC<Props> = observer((props) => {watch,formState: { isSubmitting },reset,- } = useForm<Comment>({ defaultValues });+ } = useForm<TIssuePublicComment>({ defaultValues });- const onSubmit = async (formData: Comment) => {+ const onSubmit = async (formData: TIssuePublicComment) => {if (!anchor || !issueId || isSubmitting || !formData.comment_html) return;await addIssueComment(anchor, issueId, formData)diff --git a/space/core/components/issues/peek-overview/comment/comment-detail-card.tsx b/space/core/components/issues/peek-overview/comment/comment-detail-card.tsxindex 1b228dfb3e..e229ac21e8 100644--- a/space/core/components/issues/peek-overview/comment/comment-detail-card.tsx+++ b/space/core/components/issues/peek-overview/comment/comment-detail-card.tsx@@ -3,8 +3,10 @@ import { observer } from "mobx-react";import { Controller, useForm } from "react-hook-form";import { Check, MessageSquare, MoreVertical, X } from "lucide-react";import { Menu, Transition } from "@headlessui/react";-// components+// plane importsimport { EditorRefApi } from "@plane/editor";+import { TIssuePublicComment } from "@plane/types";+// componentsimport { LiteTextEditor, LiteTextReadOnlyEditor } from "@/components/editor";import { CommentReactions } from "@/components/issues/peek-overview";// helpers@@ -13,12 +15,10 @@ import { getFileURL } from "@/helpers/file.helper";// hooksimport { useIssueDetails, usePublish, useUser } from "@/hooks/store";import useIsInIframe from "@/hooks/use-is-in-iframe";-// types-import { Comment } from "@/types/issue";type Props = {anchor: string;- comment: Comment;+ comment: TIssuePublicComment;};export const CommentCard: React.FC<Props> = observer((props) => {@@ -48,7 +48,7 @@ export const CommentCard: React.FC<Props> = observer((props) => {deleteIssueComment(anchor, peekId, comment.id);};- const handleCommentUpdate = async (formData: Comment) => {+ const handleCommentUpdate = async (formData: TIssuePublicComment) => {if (!anchor || !peekId) return;updateIssueComment(anchor, peekId, comment.id, formData);setIsEditing(false);diff --git a/space/core/hooks/use-mention.tsx b/space/core/hooks/use-mention.tsxindex 9e33f7d904..e3819d805c 100644--- a/space/core/hooks/use-mention.tsx+++ b/space/core/hooks/use-mention.tsx@@ -1,13 +1,12 @@import { useRef, useEffect } from "react";import useSWR from "swr";-// types+// plane imports+import { UserService } from "@plane/services";import { IUser } from "@plane/types";-// services-import { UserService } from "@/services/user.service";export const useMention = () => {const userService = new UserService();- const { data: user, isLoading: userDataLoading } = useSWR("currentUser", async () => userService.currentUser());+ const { data: user, isLoading: userDataLoading } = useSWR("currentUser", async () => userService.me());const userRef = useRef<IUser | undefined>();diff --git a/space/core/services/api.service.ts b/space/core/services/api.service.tsdeleted file mode 100644index ff5af7acad..0000000000--- a/space/core/services/api.service.ts+++ /dev/null@@ -1,54 +0,0 @@-/* eslint-disable @typescript-eslint/no-explicit-any */-import axios, { AxiosInstance } from "axios";-// store-// import { rootStore } from "@/lib/store-context";--export abstract class APIService {- protected baseURL: string | undefined;- private axiosInstance: AxiosInstance;-- constructor(baseURL: string | undefined) {- this.baseURL = baseURL;- this.axiosInstance = axios.create({- baseURL: baseURL || "",- withCredentials: true,- });-- this.setupInterceptors();- }-- private setupInterceptors() {- // this.axiosInstance.interceptors.response.use(- // (response) => response,- // (error) => {- // const store = rootStore;- // if (error.response && error.response.status === 401 && store.user.data) store.user.reset();- // return Promise.reject(error);- // }- // );- }-- get(url: string, params = {}) {- return this.axiosInstance.get(url, params);- }-- post(url: string, data = {}, config = {}) {- return this.axiosInstance.post(url, data, config);- }-- put(url: string, data = {}, config = {}) {- return this.axiosInstance.put(url, data, config);- }-- patch(url: string, data = {}, config = {}) {- return this.axiosInstance.patch(url, data, config);- }-- delete(url: string, data?: any, config = {}) {- return this.axiosInstance.delete(url, { data, ...config });- }-- request(config = {}) {- return this.axiosInstance(config);- }-}diff --git a/space/core/services/auth.service.ts b/space/core/services/auth.service.tsdeleted file mode 100644index 3bbfd149e6..0000000000--- a/space/core/services/auth.service.ts+++ /dev/null@@ -1,35 +0,0 @@-import { API_BASE_URL } from "@plane/constants";-// services-import { APIService } from "@/services/api.service";-// types-import { ICsrfTokenData, IEmailCheckData, IEmailCheckResponse } from "@/types/auth";--export class AuthService extends APIService {- constructor() {- super(API_BASE_URL);- }-- async requestCSRFToken(): Promise<ICsrfTokenData> {- return this.get("/auth/get-csrf-token/")- .then((response) => response.data)- .catch((error) => {- throw error;- });- }-- async emailCheck(data: IEmailCheckData): Promise<IEmailCheckResponse> {- return this.post("/auth/spaces/email-check/", data, { headers: {} })- .then((response) => response?.data)- .catch((error) => {- throw error?.response?.data;- });- }-- async generateUniqueCode(data: { email: string }): Promise<void> {- return this.post("/auth/spaces/magic-generate/", data, { headers: {} })- .then((response) => response?.data)- .catch((error) => {- throw error?.response?.data;- });- }-}diff --git a/space/core/services/cycle.service.ts b/space/core/services/cycle.service.tsdeleted file mode 100644index 7d4ff9a10f..0000000000--- a/space/core/services/cycle.service.ts+++ /dev/null@@ -1,19 +0,0 @@-import { API_BASE_URL } from "@plane/constants";-// services-import { APIService } from "@/services/api.service";-// types-import { TPublicCycle } from "@/types/cycle";--export class CycleService extends APIService {- constructor() {- super(API_BASE_URL);- }-- async getCycles(anchor: string): Promise<TPublicCycle[]> {- return this.get(`/api/public/anchor/${anchor}/cycles/`)- .then((response) => response?.data)- .catch((error) => {- throw error?.response?.data;- });- }-}diff --git a/space/core/services/instance.service.ts b/space/core/services/instance.service.tsdeleted file mode 100644index 100929955e..0000000000--- a/space/core/services/instance.service.ts+++ /dev/null@@ -1,18 +0,0 @@-import { API_BASE_URL } from "@plane/constants";-import type { IInstanceInfo } from "@plane/types";-// services-import { APIService } from "@/services/api.service";--export class InstanceService extends APIService {- constructor() {- super(API_BASE_URL);- }-- async getInstanceInfo(): Promise<IInstanceInfo> {- return this.get("/api/instances/")- .then((response) => response.data)- .catch((error) => {- throw error;- });- }-}diff --git a/space/core/services/issue.service.ts b/space/core/services/issue.service.tsdeleted file mode 100644index 8ec67ee45f..0000000000--- a/space/core/services/issue.service.ts+++ /dev/null@@ -1,133 +0,0 @@-import { API_BASE_URL } from "@plane/constants";-// services-import { APIService } from "@/services/api.service";-// types-import { Comment, TIssuesResponse, IIssue } from "@/types/issue";--class IssueService extends APIService {- constructor() {- super(API_BASE_URL);- }-- async fetchPublicIssues(anchor: string, params: any): Promise<TIssuesResponse> {- return this.get(`/api/public/anchor/${anchor}/issues/`, {- params,- })- .then((response) => response?.data)- .catch((error) => {- throw error?.response;- });- }-- async getIssueById(anchor: string, issueID: string): Promise<IIssue> {- return this.get(`/api/public/anchor/${anchor}/issues/${issueID}/`)- .then((response) => response?.data)- .catch((error) => {- throw error?.response;- });- }-- async getIssueVotes(anchor: string, issueID: string): Promise<any> {- return this.get(`/api/public/anchor/${anchor}/issues/${issueID}/votes/`)- .then((response) => response?.data)- .catch((error) => {- throw error?.response;- });- }-- async createIssueVote(anchor: string, issueID: string, data: any): Promise<any> {- return this.post(`/api/public/anchor/${anchor}/issues/${issueID}/votes/`, data)- .then((response) => response?.data)- .catch((error) => {- throw error?.response;- });- }-- async deleteIssueVote(anchor: string, issueID: string): Promise<any> {- return this.delete(`/api/public/anchor/${anchor}/issues/${issueID}/votes/`)- .then((response) => response?.data)- .catch((error) => {- throw error?.response;- });- }-- async getIssueReactions(anchor: string, issueID: string): Promise<any> {- return this.get(`/api/public/anchor/${anchor}/issues/${issueID}/reactions/`)- .then((response) => response?.data)- .catch((error) => {- throw error?.response;- });- }-- async createIssueReaction(anchor: string, issueID: string, data: any): Promise<any> {- return this.post(`/api/public/anchor/${anchor}/issues/${issueID}/reactions/`, data)- .then((response) => response?.data)- .catch((error) => {- throw error?.response;- });- }-- async deleteIssueReaction(anchor: string, issueID: string, reactionId: string): Promise<any> {- return this.delete(`/api/public/anchor/${anchor}/issues/${issueID}/reactions/${reactionId}/`)- .then((response) => response?.data)- .catch((error) => {- throw error?.response;- });- }-- async getIssueComments(anchor: string, issueID: string): Promise<any> {- return this.get(`/api/public/anchor/${anchor}/issues/${issueID}/comments/`)- .then((response) => response?.data)- .catch((error) => {- throw error?.response;- });- }-- async createIssueComment(anchor: string, issueID: string, data: any): Promise<Comment> {- return this.post(`/api/public/anchor/${anchor}/issues/${issueID}/comments/`, data)- .then((response) => response?.data)- .catch((error) => {- throw error?.response;- });- }-- async updateIssueComment(anchor: string, issueID: string, commentId: string, data: any): Promise<any> {- return this.patch(`/api/public/anchor/${anchor}/issues/${issueID}/comments/${commentId}/`, data)- .then((response) => response?.data)- .catch((error) => {- throw error?.response;- });- }-- async deleteIssueComment(anchor: string, issueID: string, commentId: string): Promise<any> {- return this.delete(`/api/public/anchor/${anchor}/issues/${issueID}/comments/${commentId}/`)- .then((response) => response?.data)- .catch((error) => {- throw error?.response;- });- }-- async createCommentReaction(- anchor: string,- commentId: string,- data: {- reaction: string;- }- ): Promise<any> {- return this.post(`/api/public/anchor/${anchor}/comments/${commentId}/reactions/`, data)- .then((response) => response?.data)- .catch((error) => {- throw error?.response;- });- }-- async deleteCommentReaction(anchor: string, commentId: string, reactionHex: string): Promise<any> {- return this.delete(`/api/public/anchor/${anchor}/comments/${commentId}/reactions/${reactionHex}/`)- .then((response) => response?.data)- .catch((error) => {- throw error?.response;- });- }-}--export default IssueService;diff --git a/space/core/services/label.service.ts b/space/core/services/label.service.tsdeleted file mode 100644index 3b5585578b..0000000000--- a/space/core/services/label.service.ts+++ /dev/null@@ -1,18 +0,0 @@-import { API_BASE_URL } from "@plane/constants";-import { IIssueLabel } from "@plane/types";-// services-import { APIService } from "./api.service";--export class LabelService extends APIService {- constructor() {- super(API_BASE_URL);- }-- async getLabels(anchor: string): Promise<IIssueLabel[]> {- return this.get(`/api/public/anchor/${anchor}/labels/`)- .then((response) => response?.data)- .catch((error) => {- throw error?.response?.data;- });- }-}diff --git a/space/core/services/member.service.ts b/space/core/services/member.service.tsdeleted file mode 100644index 9de19455b1..0000000000--- a/space/core/services/member.service.ts+++ /dev/null@@ -1,19 +0,0 @@-import { API_BASE_URL } from "@plane/constants";-// services-import { APIService } from "@/services/api.service";-// types-import { TPublicMember } from "@/types/member";--export class MemberService extends APIService {- constructor() {- super(API_BASE_URL);- }-- async getAnchorMembers(anchor: string): Promise<TPublicMember[]> {- return this.get(`/api/public/anchor/${anchor}/members/`)- .then((response) => response?.data)- .catch((error) => {- throw error?.response?.data;- });- }-}diff --git a/space/core/services/module.service.ts b/space/core/services/module.service.tsdeleted file mode 100644index 30d6ebecf1..0000000000--- a/space/core/services/module.service.ts+++ /dev/null@@ -1,19 +0,0 @@-import { API_BASE_URL } from "@plane/constants";-// services-import { APIService } from "@/services/api.service";-// types-import { TPublicModule } from "@/types/modules";--export class ModuleService extends APIService {- constructor() {- super(API_BASE_URL);- }-- async getModules(anchor: string): Promise<TPublicModule[]> {- return this.get(`/api/public/anchor/${anchor}/modules/`)- .then((response) => response?.data)- .catch((error) => {- throw error?.response?.data;- });- }-}diff --git a/space/core/services/project-member.service.ts b/space/core/services/project-member.service.tsdeleted file mode 100644index bac52e7513..0000000000--- a/space/core/services/project-member.service.ts+++ /dev/null@@ -1,26 +0,0 @@-import { API_BASE_URL } from "@plane/constants";-import type { IProjectMember, IProjectMembership } from "@plane/types";-// services-import { APIService } from "@/services/api.service";--export class ProjectMemberService extends APIService {- constructor() {- super(API_BASE_URL);- }-- async fetchProjectMembers(anchor: string): Promise<IProjectMembership[]> {- return this.get(`/api/anchor/${anchor}/members/`)- .then((response) => response?.data)- .catch((error) => {- throw error?.response?.data;- });- }-- async getProjectMember(anchor: string, memberID: string): Promise<IProjectMember> {- return this.get(`/api/anchor/${anchor}/members/${memberID}/`)- .then((response) => response?.data)- .catch((error) => {- throw error?.response?.data;- });- }-}diff --git a/space/core/services/publish.service.ts b/space/core/services/publish.service.tsdeleted file mode 100644index 3da72f59a9..0000000000--- a/space/core/services/publish.service.ts+++ /dev/null@@ -1,28 +0,0 @@-import { API_BASE_URL } from "@plane/constants";-import { TProjectPublishSettings } from "@plane/types";-// services-import { APIService } from "@/services/api.service";--class PublishService extends APIService {- constructor() {- super(API_BASE_URL);- }-- async fetchPublishSettings(anchor: string): Promise<TProjectPublishSettings> {- return this.get(`/api/public/anchor/${anchor}/settings/`)- .then((response) => response?.data)- .catch((error) => {- throw error?.response;- });- }-- async fetchAnchorFromProjectDetails(workspaceSlug: string, projectID: string): Promise<TProjectPublishSettings> {- return this.get(`/api/public/workspaces/${workspaceSlug}/projects/${projectID}/anchor/`)- .then((response) => response?.data)- .catch((error) => {- throw error?.response;- });- }-}--export default PublishService;diff --git a/space/core/services/state.service.ts b/space/core/services/state.service.tsdeleted file mode 100644index b877ac530c..0000000000--- a/space/core/services/state.service.ts+++ /dev/null@@ -1,18 +0,0 @@-import { API_BASE_URL } from "@plane/constants";-import { IState } from "@plane/types";-// services-import { APIService } from "./api.service";--export class StateService extends APIService {- constructor() {- super(API_BASE_URL);- }-- async getStates(anchor: string): Promise<IState[]> {- return this.get(`/api/public/anchor/${anchor}/states/`)- .then((response) => response?.data)- .catch((error) => {- throw error?.response?.data;- });- }-}diff --git a/space/core/services/user.service.ts b/space/core/services/user.service.tsdeleted file mode 100644index a00b1a3507..0000000000--- a/space/core/services/user.service.ts+++ /dev/null@@ -1,41 +0,0 @@-import { API_BASE_URL } from "@plane/constants";-import { IUser, TUserProfile } from "@plane/types";-// services-import { APIService } from "@/services/api.service";--export class UserService extends APIService {- constructor() {- super(API_BASE_URL);- }-- async currentUser(): Promise<IUser> {- return this.get("/api/users/me/")- .then((response) => response?.data)- .catch((error) => {- throw error?.response;- });- }-- async updateUser(data: Partial<IUser>): Promise<IUser> {- return this.patch("/api/users/me/", data)- .then((response) => response?.data)- .catch((error) => {- throw error?.response?.data;- });- }-- async getCurrentUserProfile(): Promise<TUserProfile> {- return this.get("/api/users/me/profile/")- .then((response) => response?.data)- .catch((error) => {- throw error?.response;- });- }- async updateCurrentUserProfile(data: Partial<TUserProfile>): Promise<TUserProfile> {- return this.patch("/api/users/me/profile/", data)- .then((response) => response?.data)- .catch((error) => {- throw error?.response;- });- }-}diff --git a/space/core/store/cycle.store.ts b/space/core/store/cycle.store.tsindex a7310290bf..57af963ae6 100644--- a/space/core/store/cycle.store.ts+++ b/space/core/store/cycle.store.ts@@ -1,6 +1,8 @@import { action, makeObservable, observable, runInAction } from "mobx";+// plane imports+import { SitesCycleService } from "@plane/services";import { TPublicCycle } from "@/types/cycle";-import { CycleService } from "../services/cycle.service";+// storeimport { CoreRootStore } from "./root.store";export interface ICycleStore {@@ -14,7 +16,7 @@ export interface ICycleStore {export class CycleStore implements ICycleStore {cycles: TPublicCycle[] | undefined = undefined;- cycleService: CycleService;+ cycleService: SitesCycleService;rootStore: CoreRootStore;constructor(_rootStore: CoreRootStore) {@@ -24,14 +26,14 @@ export class CycleStore implements ICycleStore {// fetch actionfetchCycles: action,});- this.cycleService = new CycleService();+ this.cycleService = new SitesCycleService();this.rootStore = _rootStore;}getCycleById = (cycleId: string | undefined) => this.cycles?.find((cycle) => cycle.id === cycleId);fetchCycles = async (anchor: string) => {- const cyclesResponse = await this.cycleService.getCycles(anchor);+ const cyclesResponse = await this.cycleService.list(anchor);runInAction(() => {this.cycles = cyclesResponse;});diff --git a/space/core/store/helpers/base-issues.store.ts b/space/core/store/helpers/base-issues.store.tsindex 7abfa324a8..867f2962c8 100644--- a/space/core/store/helpers/base-issues.store.ts+++ b/space/core/store/helpers/base-issues.store.ts@@ -5,9 +5,9 @@ import uniq from "lodash/uniq";import update from "lodash/update";import { action, makeObservable, observable, runInAction } from "mobx";import { computedFn } from "mobx-utils";-// plane constants+// plane importsimport { ALL_ISSUES } from "@plane/constants";-// types+import { SitesIssueService } from "@plane/services";import {TIssueGroupByOptions,TGroupedIssues,@@ -19,8 +19,7 @@ import {TGroupedIssueCount,TPaginationData,} from "@plane/types";-// services-import IssueService from "@/services/issue.service";+// typesimport { IIssue, TIssuesResponse } from "@/types/issue";import { CoreRootStore } from "../root.store";// constants@@ -98,7 +97,7 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore {setLoader: action.bound,});this.rootIssueStore = _rootStore;- this.issueService = new IssueService();+ this.issueService = new SitesIssueService();}getIssueIds = (groupId?: string, subGroupId?: string) => {diff --git a/space/core/store/instance.store.ts b/space/core/store/instance.store.tsindex 970824404d..4b6c5a22ef 100644--- a/space/core/store/instance.store.ts+++ b/space/core/store/instance.store.ts@@ -1,9 +1,8 @@import set from "lodash/set";import { observable, action, makeObservable, runInAction } from "mobx";-// types+// plane imports+import { InstanceService } from "@plane/services";import { IInstance, IInstanceConfig } from "@plane/types";-// services-import { InstanceService } from "@/services/instance.service";// storeimport { CoreRootStore } from "@/store/root.store";@@ -59,7 +58,7 @@ export class InstanceStore implements IInstanceStore {try {this.isLoading = true;this.error = undefined;- const instanceInfo = await this.instanceService.getInstanceInfo();+ const instanceInfo = await this.instanceService.info();runInAction(() => {this.isLoading = false;this.instance = instanceInfo.instance;diff --git a/space/core/store/issue-detail.store.ts b/space/core/store/issue-detail.store.tsindex 9abed29668..7158369460 100644--- a/space/core/store/issue-detail.store.ts+++ b/space/core/store/issue-detail.store.ts@@ -3,16 +3,14 @@ import set from "lodash/set";import { makeObservable, observable, action, runInAction } from "mobx";import { computedFn } from "mobx-utils";import { v4 as uuidv4 } from "uuid";-// plane types-import { TFileSignedURLResponse } from "@plane/types";+// plane imports+import { SitesFileService, SitesIssueService } from "@plane/services";+import { TFileSignedURLResponse, TIssuePublicComment } from "@plane/types";import { EFileAssetType } from "@plane/types/src/enums";-// services-import { FileService } from "@/services/file.service";-import IssueService from "@/services/issue.service";// storeimport { CoreRootStore } from "@/store/root.store";// types-import { Comment, IIssue, IPeekMode, IVote } from "@/types/issue";+import { IIssue, IPeekMode, IVote } from "@/types/issue";export interface IIssueDetailStore {loader: boolean;@@ -32,7 +30,7 @@ export interface IIssueDetailStore {// issue actionsfetchIssueDetails: (anchor: string, issueID: string) => void;// comment actions- addIssueComment: (anchor: string, issueID: string, data: any) => Promise<Comment>;+ addIssueComment: (anchor: string, issueID: string, data: any) => Promise<TIssuePublicComment>;updateIssueComment: (anchor: string, issueID: string, commentID: string, data: any) => Promise<any>;deleteIssueComment: (anchor: string, issueID: string, commentID: string) => void;uploadCommentAsset: (file: File, anchor: string, commentID?: string) => Promise<TFileSignedURLResponse>;@@ -59,8 +57,8 @@ export class IssueDetailStore implements IIssueDetailStore {// root storerootStore: CoreRootStore;// services- issueService: IssueService;- fileService: FileService;+ issueService: SitesIssueService;+ fileService: SitesFileService;constructor(_rootStore: CoreRootStore) {makeObservable(this, {@@ -91,8 +89,8 @@ export class IssueDetailStore implements IIssueDetailStore {removeIssueVote: action,});this.rootStore = _rootStore;- this.issueService = new IssueService();- this.fileService = new FileService();+ this.issueService = new SitesIssueService();+ this.fileService = new SitesFileService();}setPeekId = (issueID: string | null) => {@@ -123,7 +121,7 @@ export class IssueDetailStore implements IIssueDetailStore {*/fetchIssueById = async (anchorId: string, issueId: string) => {try {- const issueDetails = await this.issueService.getIssueById(anchorId, issueId);+ const issueDetails = await this.issueService.retrieve(anchorId, issueId);runInAction(() => {set(this.details, [issueId], issueDetails);@@ -146,7 +144,7 @@ export class IssueDetailStore implements IIssueDetailStore {this.error = null;const issueDetails = await this.fetchIssueById(anchor, issueID);- const commentsResponse = await this.issueService.getIssueComments(anchor, issueID);+ const commentsResponse = await this.issueService.listComments(anchor, issueID);if (issueDetails) {runInAction(() => {@@ -168,7 +166,7 @@ export class IssueDetailStore implements IIssueDetailStore {addIssueComment = async (anchor: string, issueID: string, data: any) => {try {const issueDetails = this.getIssueById(issueID);- const issueCommentResponse = await this.issueService.createIssueComment(anchor, issueID, data);+ const issueCommentResponse = await this.issueService.addComment(anchor, issueID, data);if (issueDetails) {runInAction(() => {set(this.details, [issueID, "comments"], [...(issueDetails?.comments ?? []), issueCommentResponse]);@@ -196,9 +194,9 @@ export class IssueDetailStore implements IIssueDetailStore {};});- await this.issueService.updateIssueComment(anchor, issueID, commentID, data);+ await this.issueService.updateComment(anchor, issueID, commentID, data);} catch (error) {- const issueComments = await this.issueService.getIssueComments(anchor, issueID);+ const issueComments = await this.issueService.listComments(anchor, issueID);runInAction(() => {this.details = {@@ -214,7 +212,7 @@ export class IssueDetailStore implements IIssueDetailStore {deleteIssueComment = async (anchor: string, issueID: string, commentID: string) => {try {- await this.issueService.deleteIssueComment(anchor, issueID, commentID);+ await this.issueService.removeComment(anchor, issueID, commentID);const remainingComments = this.details[issueID].comments.filter((c) => c.id != commentID);runInAction(() => {this.details = {@@ -288,11 +286,11 @@ export class IssueDetailStore implements IIssueDetailStore {};});- await this.issueService.createCommentReaction(anchor, commentID, {+ await this.issueService.addCommentReaction(anchor, commentID, {reaction: reactionHex,});} catch (error) {- const issueComments = await this.issueService.getIssueComments(anchor, issueID);+ const issueComments = await this.issueService.listComments(anchor, issueID);runInAction(() => {this.details = {@@ -324,9 +322,9 @@ export class IssueDetailStore implements IIssueDetailStore {};});- await this.issueService.deleteCommentReaction(anchor, commentID, reactionHex);+ await this.issueService.removeCommentReaction(anchor, commentID, reactionHex);} catch (error) {- const issueComments = await this.issueService.getIssueComments(anchor, issueID);+ const issueComments = await this.issueService.listComments(anchor, issueID);runInAction(() => {this.details = {@@ -356,12 +354,12 @@ export class IssueDetailStore implements IIssueDetailStore {);});- await this.issueService.createIssueReaction(anchor, issueID, {+ await this.issueService.addReaction(anchor, issueID, {reaction: reactionHex,});} catch (error) {console.log("Failed to add issue vote");- const issueReactions = await this.issueService.getIssueReactions(anchor, issueID);+ const issueReactions = await this.issueService.listReactions(anchor, issueID);runInAction(() => {set(this.details, [issueID, "reaction_items"], issueReactions);});@@ -378,10 +376,10 @@ export class IssueDetailStore implements IIssueDetailStore {set(this.details, [issueID, "reaction_items"], newReactions);});- await this.issueService.deleteIssueReaction(anchor, issueID, reactionHex);+ await this.issueService.removeReaction(anchor, issueID, reactionHex);} catch (error) {console.log("Failed to remove issue reaction");- const reactions = await this.issueService.getIssueReactions(anchor, issueID);+ const reactions = await this.issueService.listReactions(anchor, issueID);runInAction(() => {set(this.details, [issueID, "reaction_items"], reactions);});@@ -410,10 +408,10 @@ export class IssueDetailStore implements IIssueDetailStore {});});- await this.issueService.createIssueVote(anchor, issueID, data);+ await this.issueService.addVote(anchor, issueID, data);} catch (error) {console.log("Failed to add issue vote");- const issueVotes = await this.issueService.getIssueVotes(anchor, issueID);+ const issueVotes = await this.issueService.listVotes(anchor, issueID);runInAction(() => {set(this.details, [issueID, "vote_items"], issueVotes);@@ -431,10 +429,10 @@ export class IssueDetailStore implements IIssueDetailStore {set(this.details, [issueID, "vote_items"], newVotes);});- await this.issueService.deleteIssueVote(anchor, issueID);+ await this.issueService.removeVote(anchor, issueID);} catch (error) {console.log("Failed to remove issue vote");- const issueVotes = await this.issueService.getIssueVotes(anchor, issueID);+ const issueVotes = await this.issueService.listVotes(anchor, issueID);runInAction(() => {set(this.details, [issueID, "vote_items"], issueVotes);diff --git a/space/core/store/issue.store.ts b/space/core/store/issue.store.tsindex ca5154df7a..c65e84d11a 100644--- a/space/core/store/issue.store.ts+++ b/space/core/store/issue.store.ts@@ -1,8 +1,7 @@import { action, makeObservable, runInAction } from "mobx";-// types+// plane imports+import { SitesIssueService } from "@plane/services";import { IssuePaginationOptions, TLoader } from "@plane/types";-// services-import IssueService from "@/services/issue.service";// storeimport { CoreRootStore } from "@/store/root.store";// types@@ -24,7 +23,7 @@ export class IssueStore extends BaseIssuesStore implements IIssueStore {// root storerootStore: CoreRootStore;// services- issueService: IssueService;+ issueService: SitesIssueService;constructor(_rootStore: CoreRootStore) {super(_rootStore);@@ -36,7 +35,7 @@ export class IssueStore extends BaseIssuesStore implements IIssueStore {});this.rootStore = _rootStore;- this.issueService = new IssueService();+ this.issueService = new SitesIssueService();}/**@@ -59,7 +58,7 @@ export class IssueStore extends BaseIssuesStore implements IIssueStore {const params = this.rootStore.issueFilter.getFilterParams(options, anchor, undefined, undefined, undefined);- const response = await this.issueService.fetchPublicIssues(anchor, params);+ const response = await this.issueService.list(anchor, params);// after fetching issues, call the base method to process the response furtherthis.onfetchIssues(response, options);@@ -86,7 +85,7 @@ export class IssueStore extends BaseIssuesStore implements IIssueStore {subGroupId);// call the fetch issues API with the params for next page in issues- const response = await this.issueService.fetchPublicIssues(anchor, params);+ const response = await this.issueService.list(anchor, params);// after the next page of issues are fetched, call the base method to process the responsethis.onfetchNexIssues(response, groupId, subGroupId);diff --git a/space/core/store/label.store.ts b/space/core/store/label.store.tsindex e705aa4d2a..e51e59f4e1 100644--- a/space/core/store/label.store.ts+++ b/space/core/store/label.store.ts@@ -1,7 +1,9 @@import set from "lodash/set";import { action, computed, makeObservable, observable, runInAction } from "mobx";+// plane imports+import { SitesLabelService } from "@plane/services";import { IIssueLabel } from "@plane/types";-import { LabelService } from "@/services/label.service";+// storeimport { CoreRootStore } from "./root.store";export interface IIssueLabelStore {@@ -16,7 +18,7 @@ export interface IIssueLabelStore {export class LabelStore implements IIssueLabelStore {labelMap: Record<string, IIssueLabel> = {};- labelService: LabelService;+ labelService: SitesLabelService;rootStore: CoreRootStore;constructor(_rootStore: CoreRootStore) {@@ -28,7 +30,7 @@ export class LabelStore implements IIssueLabelStore {// fetch actionfetchLabels: action,});- this.labelService = new LabelService();+ this.labelService = new SitesLabelService();this.rootStore = _rootStore;}@@ -51,7 +53,7 @@ export class LabelStore implements IIssueLabelStore {};fetchLabels = async (anchor: string) => {- const labelsResponse = await this.labelService.getLabels(anchor);+ const labelsResponse = await this.labelService.list(anchor);runInAction(() => {this.labelMap = {};for (const label of labelsResponse) {diff --git a/space/core/store/members.store.ts b/space/core/store/members.store.tsindex 3de021e2c7..1328f52599 100644--- a/space/core/store/members.store.ts+++ b/space/core/store/members.store.ts@@ -1,7 +1,9 @@import set from "lodash/set";import { action, computed, makeObservable, observable, runInAction } from "mobx";+// plane imports+import { SitesMemberService } from "@plane/services";+import { TPublicMember } from "@/types/member";-import { MemberService } from "../services/member.service";import { CoreRootStore } from "./root.store";export interface IIssueMemberStore {@@ -16,7 +18,7 @@ export interface IIssueMemberStore {export class MemberStore implements IIssueMemberStore {memberMap: Record<string, TPublicMember> = {};- memberService: MemberService;+ memberService: SitesMemberService;rootStore: CoreRootStore;constructor(_rootStore: CoreRootStore) {@@ -28,7 +30,7 @@ export class MemberStore implements IIssueMemberStore {// fetch actionfetchMembers: action,});- this.memberService = new MemberService();+ this.memberService = new SitesMemberService();this.rootStore = _rootStore;}@@ -52,7 +54,7 @@ export class MemberStore implements IIssueMemberStore {fetchMembers = async (anchor: string) => {try {- const membersResponse = await this.memberService.getAnchorMembers(anchor);+ const membersResponse = await this.memberService.list(anchor);runInAction(() => {this.memberMap = {};for (const member of membersResponse) {diff --git a/space/core/store/module.store.ts b/space/core/store/module.store.tsindex 6da1ab1f80..c996b3a33e 100644--- a/space/core/store/module.store.ts+++ b/space/core/store/module.store.ts@@ -1,7 +1,10 @@import set from "lodash/set";import { action, computed, makeObservable, observable, runInAction } from "mobx";+// plane imports+import { SitesModuleService } from "@plane/services";+// typesimport { TPublicModule } from "@/types/modules";-import { ModuleService } from "../services/module.service";+// root storeimport { CoreRootStore } from "./root.store";export interface IIssueModuleStore {@@ -16,7 +19,7 @@ export interface IIssueModuleStore {export class ModuleStore implements IIssueModuleStore {moduleMap: Record<string, TPublicModule> = {};- moduleService: ModuleService;+ moduleService: SitesModuleService;rootStore: CoreRootStore;constructor(_rootStore: CoreRootStore) {@@ -28,7 +31,7 @@ export class ModuleStore implements IIssueModuleStore {// fetch actionfetchModules: action,});- this.moduleService = new ModuleService();+ this.moduleService = new SitesModuleService();this.rootStore = _rootStore;}@@ -52,7 +55,7 @@ export class ModuleStore implements IIssueModuleStore {fetchModules = async (anchor: string) => {try {- const modulesResponse = await this.moduleService.getModules(anchor);+ const modulesResponse = await this.moduleService.list(anchor);runInAction(() => {this.moduleMap = {};for (const issueModule of modulesResponse) {diff --git a/space/core/store/profile.store.ts b/space/core/store/profile.store.tsindex 5e001a875e..5523e8dadd 100644--- a/space/core/store/profile.store.ts+++ b/space/core/store/profile.store.ts@@ -1,9 +1,8 @@import set from "lodash/set";import { action, makeObservable, observable, runInAction } from "mobx";-// types+// plane imports+import { UserService } from "@plane/services";import { TUserProfile } from "@plane/types";-// services-import { UserService } from "@/services/user.service";// storeimport { CoreRootStore } from "@/store/root.store";@@ -85,7 +84,7 @@ export class ProfileStore implements IProfileStore {this.isLoading = true;this.error = undefined;});- const userProfile = await this.userService.getCurrentUserProfile();+ const userProfile = await this.userService.profile();runInAction(() => {this.isLoading = false;this.data = userProfile;@@ -116,7 +115,7 @@ export class ProfileStore implements IProfileStore {if (this.data) set(this.data, userKey, data[userKey]);});}- const userProfile = await this.userService.updateCurrentUserProfile(data);+ const userProfile = await this.userService.updateProfile(data);return userProfile;} catch (error) {if (currentUserProfileData) {diff --git a/space/core/store/publish/publish_list.store.ts b/space/core/store/publish/publish_list.store.tsindex d4a59f62d5..60f705b008 100644--- a/space/core/store/publish/publish_list.store.ts+++ b/space/core/store/publish/publish_list.store.ts@@ -1,9 +1,8 @@import set from "lodash/set";import { makeObservable, observable, runInAction, action } from "mobx";-// types+// plane imports+import { SitesProjectPublishService } from "@plane/services";import { TProjectPublishSettings } from "@plane/types";-// services-import PublishService from "@/services/publish.service";// storeimport { PublishStore } from "@/store/publish/publish.store";import { CoreRootStore } from "@/store/root.store";@@ -29,7 +28,7 @@ export class PublishListStore implements IPublishListStore {fetchPublishSettings: action,});// services- this.publishService = new PublishService();+ this.publishService = new SitesProjectPublishService();}/**@@ -37,7 +36,7 @@ export class PublishListStore implements IPublishListStore {* @param {string} anchor*/fetchPublishSettings = async (anchor: string) => {- const response = await this.publishService.fetchPublishSettings(anchor);+ const response = await this.publishService.retrieveSettingsByAnchor(anchor);runInAction(() => {if (response.anchor) {set(this.publishMap, [response.anchor], new PublishStore(this.rootStore, response));diff --git a/space/core/store/state.store.ts b/space/core/store/state.store.tsindex aff22a22a8..655cdee5dc 100644--- a/space/core/store/state.store.ts+++ b/space/core/store/state.store.ts@@ -1,8 +1,11 @@import clone from "lodash/clone";import { action, computed, makeObservable, observable, runInAction } from "mobx";+// plane imports+import { SitesStateService } from "@plane/services";import { IState } from "@plane/types";+// helpersimport { sortStates } from "@/helpers/state.helper";-import { StateService } from "@/services/state.service";+// storeimport { CoreRootStore } from "./root.store";export interface IStateStore {@@ -18,7 +21,7 @@ export interface IStateStore {export class StateStore implements IStateStore {states: IState[] | undefined = undefined;- stateService: StateService;+ stateService: SitesStateService;rootStore: CoreRootStore;constructor(_rootStore: CoreRootStore) {@@ -30,7 +33,7 @@ export class StateStore implements IStateStore {// fetch actionfetchStates: action,});- this.stateService = new StateService();+ this.stateService = new SitesStateService();this.rootStore = _rootStore;}@@ -42,7 +45,7 @@ export class StateStore implements IStateStore {getStateById = (stateId: string | undefined) => this.states?.find((state) => state.id === stateId);fetchStates = async (anchor: string) => {- const statesResponse = await this.stateService.getStates(anchor);+ const statesResponse = await this.stateService.list(anchor);runInAction(() => {this.states = statesResponse;});diff --git a/space/core/store/user.store.ts b/space/core/store/user.store.tsindex 6616b10b09..6765961f54 100644--- a/space/core/store/user.store.ts+++ b/space/core/store/user.store.ts@@ -1,10 +1,8 @@import set from "lodash/set";import { action, computed, makeObservable, observable, runInAction } from "mobx";-// types+// plane imports+import { UserService } from "@plane/services";import { IUser } from "@plane/types";-// services-import { AuthService } from "@/services/auth.service";-import { UserService } from "@/services/user.service";// store typesimport { ProfileStore, IProfileStore } from "@/store/profile.store";// store@@ -45,14 +43,12 @@ export class UserStore implements IUserStore {profile: IProfileStore;// serviceuserService: UserService;- authService: AuthService;constructor(private store: CoreRootStore) {// storesthis.profile = new ProfileStore(store);// servicethis.userService = new UserService();- this.authService = new AuthService();// observablesmakeObservable(this, {// observables@@ -95,7 +91,7 @@ export class UserStore implements IUserStore {if (this.data === undefined) this.isLoading = true;this.error = undefined;});- const user = await this.userService.currentUser();+ const user = await this.userService.me();if (user && user?.id) {await this.profile.fetchUserProfile();runInAction(() => {@@ -137,7 +133,7 @@ export class UserStore implements IUserStore {if (this.data) set(this.data, userKey, data[userKey]);});}- const user = await this.userService.updateUser(data);+ const user = await this.userService.update(data);return user;} catch (error) {if (currentUserData) {diff --git a/space/core/types/issue.d.ts b/space/core/types/issue.d.tsindex 3041a188d0..d57dd84de3 100644--- a/space/core/types/issue.d.ts+++ b/space/core/types/issue.d.ts@@ -1,4 +1,4 @@-import { IWorkspaceLite, TIssue, TIssuePriorities, TStateGroups } from "@plane/types";+import { IWorkspaceLite, TIssue, TIssuePriorities, TStateGroups, TIssuePublicComment } from "@plane/types";export type TIssueLayout = "list" | "kanban" | "calendar" | "spreadsheet" | "gantt";export type TIssueLayoutOptions = {@@ -58,7 +58,7 @@ export interface IIssue| "link_count"| "estimate_point"> {- comments: Comment[];+ comments: TIssuePublicComment[];reaction_items: IIssueReaction[];vote_items: IVote[];}@@ -106,33 +106,6 @@ export interface IVote {actor_details: ActorDetail;}-export interface Comment {- actor_detail: ActorDetail;- access: string;- actor: string;- attachments: any[];- comment_html: string;- comment_reactions: {- actor_detail: ActorDetail;- comment: string;- id: string;- reaction: string;- }[];- comment_stripped: string;- created_at: Date;- created_by: string;- id: string;- is_member: boolean;- issue: string;- issue_detail: IssueDetail;- project: string;- project_detail: ProjectDetail;- updated_at: Date;- updated_by: string;- workspace: string;- workspace_detail: IWorkspaceLite;-}-export interface IIssueReaction {actor_details: ActorDetail;reaction: string;diff --git a/space/helpers/editor.helper.ts b/space/helpers/editor.helper.tsindex 15891cfb1b..52d83ccc9c 100644--- a/space/helpers/editor.helper.ts+++ b/space/helpers/editor.helper.ts@@ -1,12 +1,11 @@// plane internalimport { MAX_FILE_SIZE } from "@plane/constants";import { TFileHandler } from "@plane/editor";-+import { SitesFileService } from "@plane/services";// helpersimport { getFileURL } from "@/helpers/file.helper";// services-import { FileService } from "@/services/file.service";-const fileService = new FileService();+const sitesFileService = new SitesFileService();/*** @description generate the file source using assetId@@ -42,19 +41,19 @@ export const getEditorFileHandlers = (args: TArgs): TFileHandler => {upload: uploadFile,delete: async (src: string) => {if (src?.startsWith("http")) {- await fileService.deleteOldEditorAsset(workspaceId, src);+ await sitesFileService.deleteOldEditorAsset(workspaceId, src);} else {- await fileService.deleteNewAsset(getEditorAssetSrc(anchor, src) ?? "");+ await sitesFileService.deleteNewAsset(getEditorAssetSrc(anchor, src) ?? "");}},restore: async (src: string) => {if (src?.startsWith("http")) {- await fileService.restoreOldEditorAsset(workspaceId, src);+ await sitesFileService.restoreOldEditorAsset(workspaceId, src);} else {- await fileService.restoreNewAsset(anchor, src);+ await sitesFileService.restoreNewAsset(anchor, src);}},- cancel: fileService.cancelUpload,+ cancel: sitesFileService.cancelUpload,validation: {maxFileSize: MAX_FILE_SIZE,},diff --git a/space/package.json b/space/package.jsonindex e8109d35bb..8de70c7541 100644--- a/space/package.json+++ b/space/package.json@@ -22,6 +22,7 @@"@plane/editor": "*","@plane/types": "*","@plane/ui": "*",+ "@plane/services": "*","@sentry/nextjs": "^8.32.0","axios": "^1.7.9","clsx": "^2.0.0",