-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WEB-3066] refactor: replace Space Services with Services Package
- Loading branch information
1 parent
ac14d57
commit de7f9de
Showing
66 changed files
with
989 additions
and
623 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from "./auth.service"; | ||
export * from "./sites-auth.service"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from "./file-upload.service"; | ||
export * from "./sites-file.service"; | ||
export * from "./file.service"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.