@elastic/ems-client 7.16.0 → 7.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.backportrc.json CHANGED
@@ -1,5 +1,16 @@
1
1
  {
2
2
  "upstream": "elastic/ems-client",
3
- "branches": [{ "name": "7.x", "checked": true }, "7.2", "7.6", "7.7", "7.8", "7.9"],
4
- "labels": ["backport"]
3
+ "branches": [
4
+ {
5
+ "name": "8.4",
6
+ "checked": true
7
+ },
8
+ {
9
+ "name": "7.17",
10
+ "checked": true
11
+ }
12
+ ],
13
+ "labels": [
14
+ "backport"
15
+ ]
5
16
  }
@@ -0,0 +1,16 @@
1
+ #
2
+ # Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ # or more contributor license agreements. Licensed under the Elastic License;
4
+ # you may not use this file except in compliance with the Elastic License.
5
+ #
6
+
7
+ set -eu
8
+
9
+ echo "--- :yarn: Installing dependencies"
10
+ yarn install
11
+
12
+ echo "--- :alembic: Running tests"
13
+ yarn test
14
+
15
+ echo "--- :gear: Building"
16
+ yarn build
@@ -0,0 +1,8 @@
1
+ agents:
2
+ image: "docker.elastic.co/ci-agent-images/ems/buildkite-agent-node20:0.1"
3
+ cpu: "2"
4
+ memory: "2G"
5
+
6
+ steps:
7
+ - label: ":hammer_and_wrench: Test and build"
8
+ command: ".buildkite/build.sh"
@@ -0,0 +1,30 @@
1
+ {
2
+ "jobs": [
3
+ {
4
+ "repoOwner": "elastic",
5
+ "repoName": "ems-client",
6
+ "enabled": true,
7
+ "pipeline_slug": "ems-client",
8
+ "allow_org_users": true,
9
+ "allowed_repo_permissions": [
10
+ "admin",
11
+ "write"
12
+ ],
13
+ "allowed_list": [
14
+ "dependabot"
15
+ ],
16
+ "build_on_commit": true,
17
+ "build_on_comment": true,
18
+ "trigger_comment_regex": "^(?:(?:buildkite\\W+)?(?:build|test)\\W+(?:this|it))",
19
+ "always_trigger_comment_regex": "^(?:(?:buildkite\\W+)?(?:build|test)\\W+(?:this|it))",
20
+ "skip_ci_labels": [
21
+ "skip-ci"
22
+ ],
23
+ "skip_ci_on_only_changed": [
24
+ "\\.md$",
25
+ "^.ci/.+\\.yml$",
26
+ "^\\.buildkite/pull_requests\\.json$"
27
+ ]
28
+ }
29
+ ]
30
+ }
package/.nvmrc ADDED
@@ -0,0 +1 @@
1
+ lts/iron
package/CHANGELOG.md CHANGED
@@ -3,6 +3,15 @@ All notable changes to this project will be documented in this file.
3
3
 
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
5
5
 
6
+ ## [7.17.1] - 2023-11-09
7
+
8
+ ### Changed
9
+
10
+ - Default EMS version is 7.17
11
+ - Upgrade dependencies #138 #162 #165 #169 #172 #173 !76 #184 #191 #198 #205
12
+ - Migration from Jenkins to Buildkite for automatic testing #163 #199
13
+ - Upgrade to Node 20 #208
14
+
6
15
  ## [7.16.0] - 2021-10-13
7
16
 
8
17
  ### Changed
@@ -0,0 +1,68 @@
1
+ ---
2
+ # yaml-language-server: $schema=https://json.schemastore.org/catalog-info.json
3
+ apiVersion: backstage.io/v1alpha1
4
+ kind: Component
5
+ metadata:
6
+ name: ems-client
7
+ description: JavaScript library to interact with the Elastic Maps Service
8
+
9
+ annotations:
10
+ backstage.io/source-location: url:https://github.com/elastic/ems-client/
11
+ github.com/project-slug: elastic/ems-client
12
+ github.com/team-slug: elastic/ems
13
+ buildkite.com/project-slug: elastic/ems-client
14
+
15
+ tags:
16
+ - nodejs
17
+ - ems
18
+ - kibana
19
+
20
+ links:
21
+ - title: Releases (npm)
22
+ url: https://www.npmjs.com/@elastic/ems-client
23
+ - title: Documentation
24
+ url: https://github.com/elastic/ems-client/blob/master/README.md
25
+ - title: EMS License
26
+ url: https://www.elastic.co/elastic-maps-service-terms
27
+
28
+ spec:
29
+ type: library
30
+ owner: group:ems
31
+ lifecycle: production
32
+ ---
33
+ # yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/e57ee3bed7a6f73077a3f55a38e76e40ec87a7cf/rre.schema.json
34
+ apiVersion: backstage.io/v1alpha1
35
+ kind: Resource
36
+ metadata:
37
+ name: buildkite-pipeline-ems-client
38
+ description: Buildkite Pipeline for ems-client
39
+ links:
40
+ - title: Pipeline
41
+ url: https://buildkite.com/elastic/ems-client
42
+
43
+ spec:
44
+ type: buildkite-pipeline
45
+ owner: group:ems
46
+ system: buildkite
47
+ implementation:
48
+ apiVersion: buildkite.elastic.dev/v1
49
+ kind: Pipeline
50
+ metadata:
51
+ name: EMS Client
52
+ description: Pipeline to run the EMS Client tests suite on
53
+ spec:
54
+ repository: elastic/ems-client
55
+ pipeline_file: ".buildkite/pipeline.yml"
56
+ default_branch: master
57
+ env:
58
+ ELASTIC_PR_COMMENTS_ENABLED: 'true'
59
+ teams: # Who has access to the pipeline.
60
+ ems: {}
61
+ everyone:
62
+ access_level: READ_ONLY
63
+ provider_settings:
64
+ publish_commit_status: true
65
+ schedules:
66
+ Weekly build on master branch:
67
+ cronline: "@weekly"
68
+ message: "Weekly tests and build"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elastic/ems-client",
3
- "version": "7.16.0",
3
+ "version": "7.17.1",
4
4
  "description": "JavaScript client library for the Elastic Maps Service",
5
5
  "main": "target/node/index.js",
6
6
  "browser": "target/web/index.js",
@@ -35,13 +35,13 @@
35
35
  }
36
36
  },
37
37
  "dependencies": {
38
- "@types/geojson": "^7946.0.7",
38
+ "@types/geojson": "^7946.0.10",
39
39
  "@types/lru-cache": "^5.1.0",
40
- "@types/topojson-client": "^3.0.0",
40
+ "@types/topojson-client": "^3.1.1",
41
41
  "@types/topojson-specification": "^1.0.1",
42
42
  "lodash": "^4.17.15",
43
43
  "lru-cache": "^6.0.0",
44
- "semver": "^7.3.2",
44
+ "semver": "7.5.4",
45
45
  "topojson-client": "^3.1.0"
46
46
  },
47
47
  "devDependencies": {
@@ -66,6 +66,9 @@
66
66
  "node-fetch": "^2.6.1",
67
67
  "prettier": "^2.0.5",
68
68
  "ts-jest": "^26.2.0",
69
- "typescript": "^3.9.2"
69
+ "typescript": "4.6.3"
70
+ },
71
+ "engines": {
72
+ "node": ">=18 <=20"
70
73
  }
71
74
  }
package/src/ems_client.ts CHANGED
@@ -16,7 +16,7 @@ import { toAbsoluteUrl } from './utils';
16
16
  import { ParsedUrlQueryInput } from 'querystring';
17
17
  import LRUCache from 'lru-cache';
18
18
 
19
- const DEFAULT_EMS_VERSION = '7.16';
19
+ const DEFAULT_EMS_VERSION = '7.17';
20
20
 
21
21
  type URLMeaningfulParts = {
22
22
  auth?: string | null;
@@ -4,27 +4,23 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.EMSClient = void 0;
7
-
8
7
  var _lodash = _interopRequireDefault(require("lodash"));
9
-
10
8
  var _tms_service = require("./tms_service");
11
-
12
9
  var _file_layer = require("./file_layer");
13
-
14
10
  var _semver = _interopRequireDefault(require("semver"));
15
-
16
11
  var _url = require("url");
17
-
18
12
  var _utils = require("./utils");
19
-
20
13
  var _lruCache = _interopRequireDefault(require("lru-cache"));
21
-
22
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
-
24
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
25
-
26
- const DEFAULT_EMS_VERSION = '7.16';
27
-
15
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
16
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
17
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /*
18
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
19
+ * or more contributor license agreements. Licensed under the Elastic License
20
+ * 2.0; you may not use this file except in compliance with the Elastic License
21
+ * 2.0.
22
+ */
23
+ const DEFAULT_EMS_VERSION = '7.17';
28
24
  /**
29
25
  * plugins cannot have upstream dependencies on core/*-kibana.
30
26
  * Work-around by copy-pasting modifyUrl routine here.
@@ -32,13 +28,14 @@ const DEFAULT_EMS_VERSION = '7.16';
32
28
  * @param block
33
29
  */
34
30
  function modifyUrlLocal(url, block) {
35
- const parsed = (0, _url.parse)(url, true); // copy over the most specific version of each
31
+ const parsed = (0, _url.parse)(url, true);
32
+
33
+ // copy over the most specific version of each
36
34
  // property. By default, the parsed url includes
37
35
  // several conflicting properties (like path and
38
36
  // pathname + search, or search and query) and keeping
39
37
  // track of which property is actually used when they
40
38
  // are formatted is harder than necessary
41
-
42
39
  const meaningfulParts = {
43
40
  protocol: parsed.protocol,
44
41
  slashes: parsed.slashes,
@@ -48,10 +45,12 @@ function modifyUrlLocal(url, block) {
48
45
  pathname: parsed.pathname,
49
46
  query: parsed.query || {},
50
47
  hash: parsed.hash
51
- }; // the block modifies the meaningfulParts object, or returns a new one
48
+ };
52
49
 
53
- const modifiedParts = block(meaningfulParts) || meaningfulParts; // format the modified/replaced meaningfulParts back into a url
50
+ // the block modifies the meaningfulParts object, or returns a new one
51
+ const modifiedParts = block(meaningfulParts) || meaningfulParts;
54
52
 
53
+ // format the modified/replaced meaningfulParts back into a url
55
54
  return (0, _url.format)({
56
55
  protocol: modifiedParts.protocol,
57
56
  slashes: modifiedParts.slashes,
@@ -63,65 +62,43 @@ function modifyUrlLocal(url, block) {
63
62
  hash: modifiedParts.hash
64
63
  });
65
64
  }
66
-
67
65
  const extendUrl = (url, props) => modifyUrlLocal(url, parsed => _lodash.default.merge(parsed, props));
66
+
68
67
  /**
69
68
  * Unescape a url template that was escaped by encodeURI() so leaflet
70
69
  * will be able to correctly locate the variables in the template
71
70
  * @param {String} url
72
71
  * @return {String}
73
72
  */
74
-
75
-
76
73
  const unescapeTemplateVars = url => {
77
74
  const ENCODED_TEMPLATE_VARS_RE = /%7B(\w+?)%7D/g;
78
75
  return url.replace(ENCODED_TEMPLATE_VARS_RE, (total, varName) => `{${varName}}`);
79
76
  };
80
-
81
77
  //this is not the default locale from Kibana, but the default locale supported by the Elastic Maps Service
82
78
  const DEFAULT_LANGUAGE = 'en';
83
-
84
79
  class EMSClient {
85
- /**
86
- * these methods are assigned outside the constructor
87
- */
88
80
  constructor(config) {
89
81
  _defineProperty(this, "EMS_LOAD_TIMEOUT", 32000);
90
-
91
82
  _defineProperty(this, "_queryParams", void 0);
92
-
93
83
  _defineProperty(this, "_appVersion", void 0);
94
-
95
84
  _defineProperty(this, "_fetchFunction", void 0);
96
-
97
85
  _defineProperty(this, "_sanitizer", void 0);
98
-
99
86
  _defineProperty(this, "_manifestServiceUrl", void 0);
100
-
101
87
  _defineProperty(this, "_fileApiUrl", void 0);
102
-
103
88
  _defineProperty(this, "_tileApiUrl", void 0);
104
-
105
89
  _defineProperty(this, "_emsVersion", void 0);
106
-
107
90
  _defineProperty(this, "_emsLandingPageUrl", void 0);
108
-
109
91
  _defineProperty(this, "_language", void 0);
110
-
111
92
  _defineProperty(this, "_proxyPath", void 0);
112
-
113
93
  _defineProperty(this, "_cache", void 0);
114
-
94
+ /**
95
+ * these methods are assigned outside the constructor
96
+ */
115
97
  _defineProperty(this, "_getMainCatalog", void 0);
116
-
117
98
  _defineProperty(this, "_getDefaultTMSCatalog", void 0);
118
-
119
99
  _defineProperty(this, "_getDefaultFileCatalog", void 0);
120
-
121
100
  _defineProperty(this, "_loadTMSServices", void 0);
122
-
123
101
  _defineProperty(this, "_loadFileLayers", void 0);
124
-
125
102
  // Remove kbnVersion in 8.0
126
103
  if ('kbnVersion' in config) {
127
104
  console.warn('The "kbnVersion" parameter for ems-client is deprecated. Please use "appVersion" instead.');
@@ -129,7 +106,6 @@ class EMSClient {
129
106
  } else {
130
107
  this._appVersion = config.appVersion;
131
108
  }
132
-
133
109
  this._queryParams = {
134
110
  elastic_tile_service_tos: 'agree',
135
111
  my_app_name: config.appName || 'kibana',
@@ -147,41 +123,33 @@ class EMSClient {
147
123
  this._cache = new _lruCache.default({
148
124
  max: config.cacheSize || 10
149
125
  });
150
-
151
126
  this._invalidateSettings();
152
127
  }
153
-
154
128
  getDefaultLocale() {
155
129
  return DEFAULT_LANGUAGE;
156
130
  }
157
-
158
131
  getLocale() {
159
132
  return this._language;
160
133
  }
161
-
162
134
  getValueInLanguage(i18nObject) {
163
135
  if (!i18nObject) {
164
136
  return '';
165
137
  }
166
-
167
138
  return i18nObject[this._language] ? i18nObject[this._language] : i18nObject[DEFAULT_LANGUAGE];
168
139
  }
140
+
169
141
  /**
170
142
  * this internal method is overridden by the tests to simulate custom manifest.
171
143
  */
172
-
173
-
174
144
  async getManifest(endpointUrl) {
175
145
  try {
176
146
  const url = extendUrl(endpointUrl, {
177
147
  query: this._queryParams
178
148
  });
179
149
  const response = await this._fetchWithTimeout(url);
180
-
181
150
  if (!response.ok) {
182
151
  throw new Error(response.statusText);
183
152
  }
184
-
185
153
  return response ? await response.json() : null;
186
154
  } catch (e) {
187
155
  if (e instanceof Error) {
@@ -191,116 +159,91 @@ class EMSClient {
191
159
  }
192
160
  }
193
161
  }
162
+
194
163
  /**
195
164
  * Add optional query-parameters to all requests
196
165
  *
197
166
  * @param additionalQueryParams
198
167
  */
199
-
200
-
201
168
  addQueryParams(additionalQueryParams) {
202
169
  for (const key in additionalQueryParams) {
203
170
  if (additionalQueryParams.hasOwnProperty(key)) {
204
171
  if (additionalQueryParams[key] !== this._queryParams[key]) {
205
172
  //changes detected.
206
173
  this._queryParams = _lodash.default.assign({}, this._queryParams, additionalQueryParams);
207
-
208
174
  this._invalidateSettings();
209
-
210
175
  break;
211
176
  }
212
177
  }
213
178
  }
214
179
  }
215
-
216
180
  async getMainManifest() {
217
181
  return await this._getMainCatalog();
218
182
  }
219
-
220
183
  async getDefaultFileManifest() {
221
184
  return await this._getDefaultFileCatalog();
222
185
  }
223
-
224
186
  async getDefaultTMSManifest() {
225
187
  return await this._getDefaultTMSCatalog();
226
188
  }
227
-
228
189
  async getFileLayers() {
229
190
  return await this._loadFileLayers();
230
191
  }
231
-
232
192
  async getTMSServices() {
233
193
  return await this._loadTMSServices();
234
194
  }
235
-
236
195
  cacheGeoJson(layerId, geoJson) {
237
196
  this._cache.set(layerId, geoJson);
238
-
239
197
  return;
240
198
  }
241
-
242
199
  getCachedGeoJson(layerId) {
243
200
  return this._cache.get(layerId);
244
201
  }
245
-
246
202
  getTileApiUrl() {
247
203
  return this._tileApiUrl;
248
204
  }
249
-
250
205
  getFileApiUrl() {
251
206
  return this._fileApiUrl;
252
207
  }
253
-
254
208
  getLandingPageUrl() {
255
209
  return this._emsLandingPageUrl;
256
210
  }
257
-
258
211
  sanitizeHtml(html) {
259
212
  return this._sanitizer(html);
260
213
  }
261
-
262
214
  extendUrlWithParams(url) {
263
215
  return unescapeTemplateVars(extendUrl(url, {
264
216
  query: this._queryParams
265
217
  }));
266
218
  }
267
-
268
219
  async findFileLayerById(id) {
269
220
  const fileLayers = await this.getFileLayers();
270
-
271
221
  for (let i = 0; i < fileLayers.length; i++) {
272
222
  if (fileLayers[i].hasId(id)) {
273
223
  return fileLayers[i];
274
224
  }
275
225
  }
276
226
  }
277
-
278
227
  async findTMSServiceById(id) {
279
228
  const tmsServices = await this.getTMSServices();
280
-
281
229
  for (let i = 0; i < tmsServices.length; i++) {
282
230
  if (tmsServices[i].hasId(id)) {
283
231
  return tmsServices[i];
284
232
  }
285
233
  }
286
234
  }
287
-
288
235
  _getEmsVersion(version) {
289
236
  const userVersion = _semver.default.valid(_semver.default.coerce(version));
290
-
291
237
  const semverVersion = userVersion ? userVersion : _semver.default.coerce(DEFAULT_EMS_VERSION);
292
-
293
238
  if (semverVersion) {
294
239
  return `v${_semver.default.major(semverVersion)}.${_semver.default.minor(semverVersion)}`;
295
240
  } else {
296
241
  throw new Error(`Invalid version: ${version}`);
297
242
  }
298
243
  }
299
-
300
244
  _fetchWithTimeout(url) {
301
245
  return new Promise((resolve, reject) => {
302
246
  const timer = setTimeout(() => reject(new Error(`Request to ${url} timed out`)), this.EMS_LOAD_TIMEOUT);
303
-
304
247
  this._fetchFunction(url).then(response => {
305
248
  clearTimeout(timer);
306
249
  resolve(response);
@@ -310,15 +253,12 @@ class EMSClient {
310
253
  });
311
254
  });
312
255
  }
313
-
314
256
  async _getManifestWithParams(url) {
315
257
  const extendedUrl = this.extendUrlWithParams(url);
316
258
  return await this.getManifest(extendedUrl);
317
259
  }
318
-
319
260
  _invalidateSettings() {
320
261
  this._cache.reset();
321
-
322
262
  this._getMainCatalog = _lodash.default.once(async () => {
323
263
  // Preserve manifestServiceUrl parameter for backwards compatibility with EMS v7.2
324
264
  if (this._manifestServiceUrl) {
@@ -327,21 +267,18 @@ class EMSClient {
327
267
  return await this._getManifestWithParams(this._manifestServiceUrl);
328
268
  } else {
329
269
  const services = [];
330
-
331
270
  if (this._tileApiUrl) {
332
271
  services.push({
333
272
  type: 'tms',
334
273
  manifest: (0, _utils.toAbsoluteUrl)(this._tileApiUrl, `${this._emsVersion}/manifest`)
335
274
  });
336
275
  }
337
-
338
276
  if (this._fileApiUrl) {
339
277
  services.push({
340
278
  type: 'file',
341
279
  manifest: (0, _utils.toAbsoluteUrl)(this._fileApiUrl, `${this._emsVersion}/manifest`)
342
280
  });
343
281
  }
344
-
345
282
  return {
346
283
  services: services
347
284
  };
@@ -350,30 +287,27 @@ class EMSClient {
350
287
  this._getDefaultTMSCatalog = _lodash.default.once(async () => {
351
288
  const catalogue = await this._getMainCatalog();
352
289
  const firstService = catalogue.services.find(service => service.type === 'tms');
353
-
354
290
  if (!firstService) {
355
291
  return {
356
292
  services: []
357
293
  };
358
294
  }
359
-
360
295
  const url = this._proxyPath + firstService.manifest;
361
296
  return await this.getManifest(url);
362
297
  });
363
298
  this._getDefaultFileCatalog = _lodash.default.once(async () => {
364
299
  const catalogue = await this._getMainCatalog();
365
300
  const firstService = catalogue.services.find(service => service.type === 'file');
366
-
367
301
  if (!firstService) {
368
302
  return {
369
303
  layers: []
370
304
  };
371
305
  }
372
-
373
306
  const url = this._proxyPath + firstService.manifest;
374
307
  return await this.getManifest(url);
375
- }); //Cache the actual instances of TMSService as these in turn cache sub-manifests for the style-files
308
+ });
376
309
 
310
+ //Cache the actual instances of TMSService as these in turn cache sub-manifests for the style-files
377
311
  this._loadTMSServices = _lodash.default.once(async () => {
378
312
  const tmsManifest = await this._getDefaultTMSCatalog();
379
313
  return tmsManifest.services.map(serviceConfig => new _tms_service.TMSService(serviceConfig, this, this._proxyPath));
@@ -383,7 +317,5 @@ class EMSClient {
383
317
  return fileManifest.layers.map(layerConfig => new _file_layer.FileLayer(layerConfig, this, this._proxyPath));
384
318
  });
385
319
  }
386
-
387
320
  }
388
-
389
321
  exports.EMSClient = EMSClient;
@@ -4,21 +4,24 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.AbstractEmsService = void 0;
7
-
8
7
  var _origin = require("./origin");
9
-
10
8
  var _utils = require("./utils");
11
-
12
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
13
-
9
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
10
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
11
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /*
12
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
13
+ * or more contributor license agreements. Licensed under the Elastic License
14
+ * 2.0; you may not use this file except in compliance with the Elastic License
15
+ * 2.0.
16
+ */
14
17
  class AbstractEmsService {
15
18
  constructor(config, emsClient, proxyPath) {
16
19
  _defineProperty(this, "_emsClient", void 0);
17
-
18
20
  _defineProperty(this, "_config", void 0);
19
-
20
21
  _defineProperty(this, "_proxyPath", void 0);
21
-
22
+ /**
23
+ * Checks if url is absolute. If not, prepend the basePath.
24
+ */
22
25
  _defineProperty(this, "_getAbsoluteUrl", url => {
23
26
  if (/^https?:\/\//.test(url)) {
24
27
  return url;
@@ -26,45 +29,30 @@ class AbstractEmsService {
26
29
  return (0, _utils.toAbsoluteUrl)(this.getApiUrl(), url);
27
30
  }
28
31
  });
29
-
30
32
  this._config = config;
31
33
  this._emsClient = emsClient;
32
34
  this._proxyPath = proxyPath;
33
35
  }
34
-
35
36
  getAttributions() {
36
37
  return this._config.attribution.map(attribution => {
37
38
  const url = this._emsClient.getValueInLanguage(attribution.url);
38
-
39
39
  const label = this._emsClient.getValueInLanguage(attribution.label);
40
-
41
40
  return {
42
41
  url: url,
43
42
  label: label
44
43
  };
45
44
  });
46
45
  }
47
-
48
46
  getMarkdownAttribution() {
49
47
  const attributions = this._config.attribution.map(attribution => {
50
48
  const url = this._emsClient.getValueInLanguage(attribution.url);
51
-
52
49
  const label = this._emsClient.getValueInLanguage(attribution.label);
53
-
54
50
  return `[${label}](${url})`;
55
51
  });
56
-
57
52
  return attributions.join('|');
58
53
  }
59
-
60
54
  getOrigin() {
61
55
  return _origin.ORIGIN.EMS;
62
56
  }
63
- /**
64
- * Checks if url is absolute. If not, prepend the basePath.
65
- */
66
-
67
-
68
57
  }
69
-
70
58
  exports.AbstractEmsService = AbstractEmsService;