-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/MLX-451-add-new-endpoint-to-platform-client' of…
… github.com:coveo/platform-client into feature/MLX-451-add-new-endpoint-to-platform-client
- Loading branch information
Showing
20 changed files
with
1,819 additions
and
1,111 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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,77 @@ | ||
import API from '../../APICore.js'; | ||
import {PageModel} from '../BaseInterfaces.js'; | ||
import Resource from '../Resource.js'; | ||
import {ResourceModel, ResourceParams} from '../Resources/index.js'; | ||
import {ListProjectParams, ProjectModel, BaseProjectModel, ProjectResourceType} from './ProjectInterfaces.js'; | ||
|
||
export default class Project extends Resource { | ||
static baseUrl = `/rest/organizations/${API.orgPlaceholder}/projects`; | ||
|
||
/** | ||
* Returns a paginated list of projects. | ||
* | ||
* @param {ListProjectParams} params | ||
* @returns {Promise<PageModel<ProjectModel>>} A paginated list of projects | ||
*/ | ||
list(params?: ListProjectParams): Promise<PageModel<ProjectModel>> { | ||
return this.api.get<PageModel<ProjectModel>>(this.buildPath(Project.baseUrl, params)); | ||
} | ||
|
||
/** | ||
* Creates and returns a new project. | ||
* | ||
* @param {ProjectModel} project | ||
* @returns {Promise<ProjectModel>} The newly created project | ||
*/ | ||
create(project: BaseProjectModel): Promise<ProjectModel> { | ||
return this.api.post<ProjectModel>(this.buildPath(Project.baseUrl), project); | ||
} | ||
|
||
/** | ||
* Updates a project with the model sent and returns the updated project. | ||
* | ||
* @param {string} projectId | ||
* @param {ProjectModel} updateProjectModel | ||
* @returns {Promise<ProjectModel>} The updated project | ||
*/ | ||
update(projectId: string, updateProjectModel: ProjectModel): Promise<ProjectModel> { | ||
return this.api.put<ProjectModel>(this.buildPath(`${Project.baseUrl}/${projectId}`), updateProjectModel); | ||
} | ||
|
||
/** | ||
* Returns a project. | ||
* | ||
* @param {string} projectId | ||
* @returns {Promise<ProjectModel>} The project specified by the provided id | ||
*/ | ||
get(projectId: string): Promise<ProjectModel> { | ||
return this.api.get<ProjectModel>(this.buildPath(`${Project.baseUrl}/${projectId}`)); | ||
} | ||
|
||
/** | ||
* Deletes a project. | ||
* | ||
* @param {string} projectId | ||
*/ | ||
delete(projectId: string): Promise<void> { | ||
return this.api.delete(this.buildPath(`${Project.baseUrl}/${projectId}`)); | ||
} | ||
|
||
/** | ||
* Returns a paginated list of resources associated to a project. | ||
* | ||
* @param projectId | ||
* @param resourceType | ||
* @param {ResourceParams} params | ||
* @returns {Promise<PageModel<ResourceModel>>} A paginated list of resources associated to a project. | ||
*/ | ||
listResources( | ||
projectId: string, | ||
resourceType: ProjectResourceType, | ||
params?: ResourceParams, | ||
): Promise<PageModel<ResourceModel>> { | ||
return this.api.get<PageModel<ResourceModel>>( | ||
this.buildPath(`${Project.baseUrl}/${projectId}/resources/${resourceType}`, params), | ||
); | ||
} | ||
} |
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,117 @@ | ||
import {Paginated} from '../BaseInterfaces.js'; | ||
import {SortingOrder} from '../Enums.js'; | ||
|
||
export enum ProjectSortBy { | ||
name = 'NAME', | ||
createdBy = 'CREATED_BY', | ||
createdDate = 'CREATED_DATE', | ||
updatedBy = 'UPDATED_BY', | ||
updatedDate = 'UPDATED_DATE', | ||
} | ||
|
||
export const projectResourceTypes = [ | ||
'CATALOG', | ||
'CASE_ASSIST', | ||
'CRAWLING_MODULE', | ||
'EXTENSION', | ||
'IN_PRODUCT_EXPERIENCE', | ||
'INSIGHT_PANEL', | ||
'ML_MODEL', | ||
'QUERY_PIPELINE', | ||
'SEARCH_HUB', | ||
'SEARCH_PAGE', | ||
'SECURITY_PROVIDER', | ||
'SOURCE', | ||
'UA_REPORT', | ||
]; | ||
|
||
export type ProjectResourceType = (typeof projectResourceTypes)[number]; | ||
|
||
export enum ProjectType { | ||
Commerce = 'COMMERCE', | ||
Other = 'OTHER', | ||
Service = 'SERVICE', | ||
Website = 'WEBSITE', | ||
Workplace = 'WORKPLACE', | ||
} | ||
|
||
export interface BaseProjectModel { | ||
/** | ||
* The name of the project. | ||
*/ | ||
name: string; | ||
/** | ||
* The description of the project. | ||
*/ | ||
description: string; | ||
/** | ||
* The type of the project. | ||
*/ | ||
type: ProjectType; | ||
/** | ||
* The list of usernames that will be points of contact for the project. | ||
* | ||
* @example: ['[email protected]', '[email protected]'] | ||
*/ | ||
pointsOfContact?: string[]; | ||
/** | ||
* The resources associated to the project. | ||
* | ||
* @example: {'SOURCE': ['sourceId1', 'sourceId2']} | ||
*/ | ||
resources?: Record<ProjectResourceType, string[]>; | ||
} | ||
|
||
export interface ProjectModel extends BaseProjectModel { | ||
/** | ||
* The unique identifier of the project. | ||
*/ | ||
id: string; | ||
/** | ||
* The email of the user that created the project. | ||
* | ||
* @example: '[email protected]' | ||
*/ | ||
createdBy: string; | ||
/** | ||
* The date of the project's creation. | ||
* Note: ISO-8601 format | ||
* | ||
* @example: '2023-06-21T14:59:26.850Z' | ||
*/ | ||
createdDate: string; | ||
/** | ||
* The email of the user that last updated the project. | ||
* | ||
* @example: '[email protected]' | ||
*/ | ||
updatedBy: string; | ||
/** | ||
* The date of the project's last update. | ||
* Note: ISO-8601 format | ||
* | ||
* @example: '2023-06-21T14:59:26.850Z' | ||
*/ | ||
updatedDate: string; | ||
} | ||
|
||
export interface ListProjectParams extends Paginated { | ||
/** | ||
* The query filter to match. | ||
* This allows you to search according to the project name. | ||
* | ||
* By default, results are not required to match a specific query filter. | ||
*/ | ||
filter?: string; | ||
/** | ||
* The sorting criteria to apply on the results. | ||
* | ||
*/ | ||
sortBy?: ProjectSortBy; | ||
/** | ||
* The sorting order to apply on the results. | ||
* | ||
* @example: 'ASC' | ||
*/ | ||
order?: SortingOrder; | ||
} |
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,2 @@ | ||
export * from './Project.js'; | ||
export * from './ProjectInterfaces.js'; |
Oops, something went wrong.