@elastic/ems-client 7.16.0 → 7.17.2

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.
@@ -5,7 +5,7 @@ export declare enum EMSFormatType {
5
5
  geojson = "geojson",
6
6
  topojson = "topojson"
7
7
  }
8
- export declare type EMSFormatTypeStrings = keyof typeof EMSFormatType;
8
+ export type EMSFormatTypeStrings = keyof typeof EMSFormatType;
9
9
  export declare class FileLayer extends AbstractEmsService {
10
10
  protected readonly _config: FileLayerConfig;
11
11
  constructor(config: FileLayerConfig, emsClient: EMSClient, proxyPath: string);
@@ -0,0 +1,176 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
4
+ * or more contributor license agreements. Licensed under the Elastic License
5
+ * 2.0; you may not use this file except in compliance with the Elastic License
6
+ * 2.0.
7
+ */
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
20
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
21
+ }) : function(o, v) {
22
+ o["default"] = v;
23
+ });
24
+ var __importStar = (this && this.__importStar) || function (mod) {
25
+ if (mod && mod.__esModule) return mod;
26
+ var result = {};
27
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
28
+ __setModuleDefault(result, mod);
29
+ return result;
30
+ };
31
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
32
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
33
+ return new (P || (P = Promise))(function (resolve, reject) {
34
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
35
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
36
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
37
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
38
+ });
39
+ };
40
+ var __importDefault = (this && this.__importDefault) || function (mod) {
41
+ return (mod && mod.__esModule) ? mod : { "default": mod };
42
+ };
43
+ Object.defineProperty(exports, "__esModule", { value: true });
44
+ exports.FileLayer = exports.EMSFormatType = void 0;
45
+ const url_1 = __importDefault(require("url"));
46
+ const ems_service_1 = require("./ems_service");
47
+ const topojson = __importStar(require("topojson-client"));
48
+ var EMSFormatType;
49
+ (function (EMSFormatType) {
50
+ EMSFormatType["geojson"] = "geojson";
51
+ EMSFormatType["topojson"] = "topojson";
52
+ })(EMSFormatType || (exports.EMSFormatType = EMSFormatType = {}));
53
+ class FileLayer extends ems_service_1.AbstractEmsService {
54
+ constructor(config, emsClient, proxyPath) {
55
+ super(config, emsClient, proxyPath);
56
+ this._config = config;
57
+ }
58
+ getGeoJson() {
59
+ return __awaiter(this, void 0, void 0, function* () {
60
+ var _a;
61
+ const cachedGeoJson = this._emsClient.getCachedGeoJson(this.getId());
62
+ if (cachedGeoJson) {
63
+ return cachedGeoJson;
64
+ }
65
+ const format = this.getDefaultFormatType();
66
+ const fetchUrl = this.getDefaultFormatUrl();
67
+ let geojson;
68
+ const fetchedJson = yield this._emsClient.getManifest(fetchUrl);
69
+ if (fetchedJson) {
70
+ if (format === 'geojson') {
71
+ geojson = fetchedJson;
72
+ }
73
+ else if (format === 'topojson') {
74
+ const meta = this.getDefaultFormatMeta();
75
+ const featureCollectionPath = (_a = meta === null || meta === void 0 ? void 0 : meta.feature_collection_path) !== null && _a !== void 0 ? _a : 'data';
76
+ // @ts-expect-error see https://github.com/DefinitelyTyped/DefinitelyTyped/pull/52156
77
+ geojson = topojson.feature(fetchedJson, featureCollectionPath);
78
+ }
79
+ else {
80
+ return;
81
+ }
82
+ this._emsClient.cacheGeoJson(this.getId(), geojson);
83
+ return geojson;
84
+ }
85
+ return;
86
+ });
87
+ }
88
+ getFields() {
89
+ return this._config.fields;
90
+ }
91
+ getFieldsInLanguage() {
92
+ return this.getFields().map((field) => {
93
+ return {
94
+ type: field.type,
95
+ name: field.id,
96
+ description: this._emsClient.getValueInLanguage(field.label),
97
+ };
98
+ });
99
+ }
100
+ getDisplayName() {
101
+ const layerName = this._emsClient.getValueInLanguage(this._config.layer_name);
102
+ return layerName ? layerName : '';
103
+ }
104
+ getId() {
105
+ return this._config.layer_id;
106
+ }
107
+ hasId(id) {
108
+ const matchesLegacyId = this._config.legacy_ids.indexOf(id) >= 0;
109
+ return this._config.layer_id === id || matchesLegacyId;
110
+ }
111
+ getEMSHotLink() {
112
+ const landingPageString = this._emsClient.getLandingPageUrl();
113
+ const urlObject = url_1.default.parse(landingPageString, true);
114
+ urlObject.hash = `file/${this.getId()}`;
115
+ urlObject.query = Object.assign(Object.assign({}, urlObject.query), { locale: this._emsClient.getLocale() });
116
+ return url_1.default.format(urlObject);
117
+ }
118
+ getDefaultFormatType() {
119
+ const format = this._getDefaultFormat();
120
+ return format.type;
121
+ }
122
+ getFormatOfType(type) {
123
+ const format = this._getFormatOfType(type);
124
+ return format.type;
125
+ }
126
+ getDefaultFormatMeta() {
127
+ const format = this._getDefaultFormat();
128
+ return this._getFormatMeta(format);
129
+ }
130
+ getFormatOfTypeMeta(type) {
131
+ const format = this._getFormatOfType(type);
132
+ return this._getFormatMeta(format);
133
+ }
134
+ getDefaultFormatUrl() {
135
+ const format = this._getDefaultFormat();
136
+ return this._getFormatUrl(format);
137
+ }
138
+ getFormatOfTypeUrl(type) {
139
+ const format = this._getFormatOfType(type);
140
+ return this._getFormatUrl(format);
141
+ }
142
+ getCreatedAt() {
143
+ return this._config.created_at;
144
+ }
145
+ getApiUrl() {
146
+ return this._emsClient.getFileApiUrl();
147
+ }
148
+ _getFormatUrl(format) {
149
+ const url = this._proxyPath + this._getAbsoluteUrl(format.url);
150
+ return this._emsClient.extendUrlWithParams(url);
151
+ }
152
+ _getFormatMeta(format) {
153
+ if ('meta' in format) {
154
+ return format.meta;
155
+ }
156
+ else {
157
+ return;
158
+ }
159
+ }
160
+ _getDefaultFormat() {
161
+ const defaultFormat = this._config.formats.find((format) => {
162
+ return format.legacy_default;
163
+ });
164
+ if (defaultFormat) {
165
+ return defaultFormat;
166
+ }
167
+ return this._config.formats[0];
168
+ }
169
+ _getFormatOfType(type) {
170
+ const requestedFormat = this._config.formats.find((format) => {
171
+ return format.type === type;
172
+ });
173
+ return requestedFormat || this._getDefaultFormat();
174
+ }
175
+ }
176
+ exports.FileLayer = FileLayer;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
4
+ * or more contributor license agreements. Licensed under the Elastic License
5
+ * 2.0; you may not use this file except in compliance with the Elastic License
6
+ * 2.0.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.TMSService = exports.FileLayer = exports.LATEST_API_URL_PATH = exports.EMSClient = void 0;
10
+ var ems_client_1 = require("./ems_client");
11
+ Object.defineProperty(exports, "EMSClient", { enumerable: true, get: function () { return ems_client_1.EMSClient; } });
12
+ Object.defineProperty(exports, "LATEST_API_URL_PATH", { enumerable: true, get: function () { return ems_client_1.LATEST_API_URL_PATH; } });
13
+ var file_layer_1 = require("./file_layer");
14
+ Object.defineProperty(exports, "FileLayer", { enumerable: true, get: function () { return file_layer_1.FileLayer; } });
15
+ var tms_service_1 = require("./tms_service");
16
+ Object.defineProperty(exports, "TMSService", { enumerable: true, get: function () { return tms_service_1.TMSService; } });
@@ -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
- 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
-
14
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
16
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
17
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
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(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
10
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
11
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
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;