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.

37 lines 1.7 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Environment = exports.Region = void 0; const regionPlaceholder = '{region}'; var Region; (function (Region) { Region["US"] = "us"; Region["EU"] = "eu"; Region["AU"] = "au"; Region["CA"] = "ca"; })(Region || (exports.Region = Region = {})); var Environment; (function (Environment) { Environment["dev"] = "dev"; Environment["stg"] = "stg"; Environment["prod"] = "production"; Environment["hipaa"] = "hipaa"; })(Environment || (exports.Environment = Environment = {})); const endpointTemplates = { [Environment.dev]: `https://platformdev${regionPlaceholder}.cloud.coveo.com`, [Environment.stg]: `https://platformstg${regionPlaceholder}.cloud.coveo.com`, [Environment.prod]: `https://platform${regionPlaceholder}.cloud.coveo.com`, [Environment.hipaa]: 'https://platformhipaa.cloud.coveo.com', }; const serverlessEndpointTemplates = { [Environment.dev]: `https://apidev${regionPlaceholder}.cloud.coveo.com`, [Environment.stg]: `https://apistg${regionPlaceholder}.cloud.coveo.com`, [Environment.prod]: `https://api${regionPlaceholder}.cloud.coveo.com`, [Environment.hipaa]: 'https://apihipaa.cloud.coveo.com', }; exports.default = (environment = Environment.prod, region = Region.US, isServerlessHost = false) => { const regionSuffix = region === Region.US ? '' : `-${region}`; const matcher = new RegExp(regionPlaceholder, 'g'); const template = isServerlessHost ? serverlessEndpointTemplates[environment] : endpointTemplates[environment]; return template?.replace(matcher, regionSuffix) ?? ''; }; //# sourceMappingURL=Endpoints.js.map