-
Notifications
You must be signed in to change notification settings - Fork 2.6k
[WEB-3066] refactor: replace Space Services with Services Package #6353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.