@coveo/platform-client
Version:
The main goal of this package is to provide an easy to configure and straightforward way of querying Coveo Cloud APIs using JavaScript.
77 lines • 3.19 kB
JavaScript
import API from '../../APICore.js';
import Ressource from '../Resource.js';
export default class SchemaService extends Ressource {
api;
serverlessApi;
static baseUrl = `/rest/organizations/${API.orgPlaceholder}/schema/sources`;
constructor(api, serverlessApi) {
super(api, serverlessApi);
this.api = api;
this.serverlessApi = serverlessApi;
}
/**
* Retrieve entities from the targeted instance
* (can be matches of a given query)
* @param sourceType
* @param [parameters]
* @returns schemaEntities
*/
getEntities(sourceType, parameters) {
return this.api.get(this.buildPath(`${SchemaService.baseUrl}/${sourceType}/entities`, parameters));
}
/**
* Retrieve the entity of matching ID from the targeted instance
* @param sourceType
* @param entityId
* @param [parameters]
* @returns simpleSchemaEntity
*/
getEntity(sourceType, entityId, parameters) {
return this.api.get(this.buildPath(`${SchemaService.baseUrl}/${sourceType}/entities/${entityId}`, parameters));
}
/**
* Retrieve the fields of the given entity from the targeted instance
* @param sourceType
* @param entityId
* @param [parameters]
* @returns schemaEntityFields
*/
getFields(sourceType, entityId, parameters) {
return this.api.get(this.buildPath(`${SchemaService.baseUrl}/${sourceType}/entities/${entityId}/fields`, parameters));
}
delete(sourceId) {
return this.api.delete(`${SchemaService.baseUrl}/${sourceId}`);
}
get(sourceId) {
return this.api.get(`${SchemaService.baseUrl}/${sourceId}`);
}
update(sourceId, source, options) {
return this.api.put(this.buildPath(`${SchemaService.baseUrl}/${sourceId}`, options), source);
}
create(source, options) {
return this.api.post(this.buildPath(SchemaService.baseUrl, options), source);
}
translateToSpecificObjectsToGet(sourceType, genericObjectsToGet) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return this.api.post(`${SchemaService.baseUrl}/${sourceType}/translate/specific`, genericObjectsToGet);
}
translateToSpecificObjectsToGetWithFields(sourceType, genericObjectsToGet, parameters) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return this.api.post(this.buildPath(`${SchemaService.baseUrl}/${sourceType}/translate/specificWithFields`, parameters), genericObjectsToGet);
}
translateToGenericObjectsToGet(sourceType, specificObjectsToGet) {
return this.api.post(`${SchemaService.baseUrl}/${sourceType}/translate/generic`, specificObjectsToGet);
}
/**
* Retrieve the default objectsToGet of the given sourceType
* @param sourceType
* @returns ObjectsToGet
*/
getDefaultObjectsToGet(sourceType) {
return this.api.get(`${SchemaService.baseUrl}/${sourceType}/defaultObjectsToGet`);
}
validateSlackToken(accessToken) {
return this.api.post(`${SchemaService.baseUrl}/SLACK/validateToken?accessToken=${accessToken}`);
}
}
//# sourceMappingURL=SchemaService.js.map