UNPKG

@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.

81 lines 3.42 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const APICore_js_1 = tslib_1.__importDefault(require("../../APICore.js")); const Resource_js_1 = tslib_1.__importDefault(require("../Resource.js")); class SchemaService extends Resource_js_1.default { api; serverlessApi; static baseUrl = `/rest/organizations/${APICore_js_1.default.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}`); } } exports.default = SchemaService; //# sourceMappingURL=SchemaService.js.map