Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 14601d0f36 | |||
| 866eb5ac17 |
@@ -0,0 +1,30 @@
|
||||
import { TProjectPublishSettings } from "@plane/types";
|
||||
import { APIService } from "../api.service";
|
||||
|
||||
/**
|
||||
* Service class for managing project publish operations within plane core application.
|
||||
* Extends APIService to handle HTTP requests to the project publish-related endpoints.
|
||||
* @extends {APIService}
|
||||
* @remarks This service is only available for plane core
|
||||
*/
|
||||
export abstract class CoreProjectPublishService extends APIService {
|
||||
constructor(BASE_URL: string) {
|
||||
super(BASE_URL);
|
||||
}
|
||||
|
||||
async retrieve(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;
|
||||
});
|
||||
}
|
||||
|
||||
async retrieveSettings(anchor: string): Promise<TProjectPublishSettings> {
|
||||
return this.get(`/api/public/anchor/${anchor}/settings/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { CoreProjectPublishService } from "./core.service";
|
||||
|
||||
export abstract class ExtendedProjectPublishService extends CoreProjectPublishService {
|
||||
constructor(baseUrl: string) {
|
||||
super(baseUrl);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import { API_BASE_URL } from "@plane/constants";
|
||||
import { ExtendedProjectPublishService } from "./extended.service";
|
||||
|
||||
export class ProjectPublishService extends ExtendedProjectPublishService {
|
||||
constructor() {
|
||||
super(API_BASE_URL);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
import { IProjectView } from "@plane/types";
|
||||
import { APIService } from "../api.service";
|
||||
|
||||
export class CoreProjectViewService extends APIService {
|
||||
constructor(baseUrl: string) {
|
||||
super(baseUrl);
|
||||
}
|
||||
|
||||
async create(workspaceSlug: string, projectId: string, data: Partial<IProjectView>): Promise<any> {
|
||||
return this.post(`/api/workspaces/${workspaceSlug}/projects/${projectId}/views/`, data)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
|
||||
async update(workspaceSlug: string, projectId: string, viewId: string, data: Partial<IProjectView>): Promise<any> {
|
||||
return this.patch(`/api/workspaces/${workspaceSlug}/projects/${projectId}/views/${viewId}/`, data)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
|
||||
async destroy(workspaceSlug: string, projectId: string, viewId: string): Promise<any> {
|
||||
return this.delete(`/api/workspaces/${workspaceSlug}/projects/${projectId}/views/${viewId}/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
|
||||
async list(workspaceSlug: string, projectId: string): Promise<IProjectView[]> {
|
||||
return this.get(`/api/workspaces/${workspaceSlug}/projects/${projectId}/views/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
|
||||
async retrieve(workspaceSlug: string, projectId: string, viewId: string): Promise<IProjectView> {
|
||||
return this.get(`/api/workspaces/${workspaceSlug}/projects/${projectId}/views/${viewId}/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
|
||||
async getWorksItems(workspaceSlug: string, projectId: string, viewId: string): Promise<any> {
|
||||
return this.get(`/api/workspaces/${workspaceSlug}/projects/${projectId}/views/${viewId}/issues/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
|
||||
async addToFavorites(workspaceSlug: string, projectId: string, viewId: string): Promise<any> {
|
||||
return this.post(`/api/workspaces/${workspaceSlug}/projects/${projectId}/user-favorite-views/`, { view: viewId })
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
|
||||
async removeFromFavorites(workspaceSlug: string, projectId: string, viewId: string): Promise<any> {
|
||||
return this.delete(`/api/workspaces/${workspaceSlug}/projects/${projectId}/user-favorite-views/${viewId}/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { CoreProjectViewService } from "./core.service";
|
||||
|
||||
export class ExtendedProjectViewService extends CoreProjectViewService {
|
||||
constructor(baseUrl: string) {
|
||||
super(baseUrl);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import { API_BASE_URL } from "@plane/constants";
|
||||
import { ExtendedProjectViewService } from "./extended.service";
|
||||
|
||||
export class ProjectViewService extends ExtendedProjectViewService {
|
||||
constructor(baseUrl?: string) {
|
||||
super(baseUrl || API_BASE_URL);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
import { TProject, TProjectAnalyticsCountParams, TProjectAnalyticsCount } from "@plane/types";
|
||||
import { APIService } from "../api.service";
|
||||
|
||||
export class CoreProjectService extends APIService {
|
||||
constructor(BASE_URL: string) {
|
||||
super(BASE_URL);
|
||||
}
|
||||
|
||||
async create(workspaceSlug: string, data: Partial<TProject>): Promise<TProject> {
|
||||
return this.post(`/api/workspaces/${workspaceSlug}/projects/`, data)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response;
|
||||
});
|
||||
}
|
||||
|
||||
async checkIdentifierAvailability(workspaceSlug: string, identifier: string): Promise<any> {
|
||||
return this.get(`/api/workspaces/${workspaceSlug}/project-identifiers/`, {
|
||||
params: {
|
||||
name: identifier,
|
||||
},
|
||||
})
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
|
||||
list(workspaceSlug: string): Promise<TProject[]> {
|
||||
return this.get(`/api/workspaces/${workspaceSlug}/projects/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
|
||||
retrieve(workspaceSlug: string, projectId: string): Promise<TProject> {
|
||||
return this.get(`/api/workspaces/${workspaceSlug}/projects/${projectId}/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
|
||||
stats(workspaceSlug: string, params?: TProjectAnalyticsCountParams): Promise<TProjectAnalyticsCount[]> {
|
||||
return this.get(`/api/workspaces/${workspaceSlug}/project-stats/`, {
|
||||
params,
|
||||
})
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
|
||||
update(workspaceSlug: string, projectId: string, data: Partial<TProject>): Promise<TProject> {
|
||||
return this.patch(`/api/workspaces/${workspaceSlug}/projects/${projectId}/`, data)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
|
||||
destroy(workspaceSlug: string, projectId: string): Promise<any> {
|
||||
return this.delete(`/api/workspaces/${workspaceSlug}/projects/${projectId}/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
|
||||
addToFavorites(workspaceSlug: string, project: string): Promise<any> {
|
||||
return this.post(`/api/workspaces/${workspaceSlug}/user-favorite-projects/`, { project })
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
|
||||
removeFromFavorites(workspaceSlug: string, projectId: string): Promise<any> {
|
||||
return this.delete(`/api/workspaces/${workspaceSlug}/user-favorite-projects/${projectId}/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { CoreProjectService } from "./core.service";
|
||||
|
||||
export class ExtendedProjectService extends CoreProjectService {
|
||||
constructor(BASE_URL: string) {
|
||||
super(BASE_URL);
|
||||
}
|
||||
}
|
||||
@@ -1,2 +1,8 @@
|
||||
export * from "./view.service";
|
||||
export * from "./sites-publish.service";
|
||||
import { API_BASE_URL } from "@plane/constants";
|
||||
import { ExtendedProjectService } from "./extended.service";
|
||||
|
||||
export class ProjectService extends ExtendedProjectService {
|
||||
constructor() {
|
||||
super(API_BASE_URL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
// 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;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
// plane imports
|
||||
import { API_BASE_URL } from "@plane/constants";
|
||||
// api services
|
||||
import { APIService } from "../api.service";
|
||||
|
||||
export class ProjectViewService extends APIService {
|
||||
/**
|
||||
* Creates an instance of ProjectViewService
|
||||
* @param {string} baseUrl - The base URL for API requests
|
||||
*/
|
||||
constructor(BASE_URL?: string) {
|
||||
super(BASE_URL || API_BASE_URL);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
import { IState } from "@plane/types";
|
||||
import { APIService } from "../api.service";
|
||||
|
||||
export class CoreStateService extends APIService {
|
||||
constructor(baseUrl: string) {
|
||||
super(baseUrl);
|
||||
}
|
||||
|
||||
async anchorStates(anchor: string): Promise<IState[]> {
|
||||
return this.get(`/api/public/anchor/${anchor}/states/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
|
||||
async list(workspaceSlug: string, projectId: string): Promise<IState[]> {
|
||||
return this.get(`/api/workspaces/${workspaceSlug}/projects/${projectId}/states/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
|
||||
async retrieve(workspaceSlug: string, projectId: string, stateId: string): Promise<IState> {
|
||||
return this.get(`/api/workspaces/${workspaceSlug}/projects/${projectId}/states/${stateId}/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
|
||||
async create(workspaceSlug: string, projectId: string, data: Partial<IState>): Promise<IState> {
|
||||
return this.post(`/api/workspaces/${workspaceSlug}/projects/${projectId}/states/`, data)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
|
||||
async update(workspaceSlug: string, projectId: string, stateId: string, data: Partial<IState>): Promise<IState> {
|
||||
return this.patch(`/api/workspaces/${workspaceSlug}/projects/${projectId}/states/${stateId}/`, data)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
|
||||
async destroy(workspaceSlug: string, projectId: string, stateId: string): Promise<IState> {
|
||||
return this.delete(`/api/workspaces/${workspaceSlug}/projects/${projectId}/states/${stateId}/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { CoreStateService } from "./core.service";
|
||||
|
||||
export class ExtendedStateService extends CoreStateService {
|
||||
constructor(baseUrl: string) {
|
||||
super(baseUrl);
|
||||
}
|
||||
}
|
||||
@@ -1 +1,8 @@
|
||||
export * from "./sites-state.service";
|
||||
import { API_BASE_URL } from "@plane/constants";
|
||||
import { ExtendedStateService } from "./extended.service";
|
||||
|
||||
export class StateService extends ExtendedStateService {
|
||||
constructor() {
|
||||
super(API_BASE_URL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
// 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;
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user