@elastic/ems-client 8.5.2 → 8.6.0

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.
@@ -45,7 +45,7 @@ export var FileLayer = /*#__PURE__*/function (_AbstractEmsService) {
45
45
  return _createClass(FileLayer, [{
46
46
  key: "getGeoJson",
47
47
  value: function () {
48
- var _getGeoJson = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
48
+ var _getGeoJson = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
49
49
  var cachedGeoJson, format, fetchUrl, geojson, fetchedJson, _meta$feature_collect, meta, featureCollectionPath;
50
50
  return _regeneratorRuntime().wrap(function _callee$(_context) {
51
51
  while (1) switch (_context.prev = _context.next) {
@@ -40,7 +40,7 @@ export var TMSService = /*#__PURE__*/function (_AbstractEmsService) {
40
40
  _classCallCheck(this, TMSService);
41
41
  _this = _callSuper(this, TMSService, [config, emsClient, proxyPath]);
42
42
  _defineProperty(_this, "_config", void 0);
43
- _defineProperty(_this, "_getRasterStyleJson", _.once( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
43
+ _defineProperty(_this, "_getRasterStyleJson", _.once(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
44
44
  var rasterUrl, url;
45
45
  return _regeneratorRuntime().wrap(function _callee$(_context) {
46
46
  while (1) switch (_context.prev = _context.next) {
@@ -60,7 +60,7 @@ export var TMSService = /*#__PURE__*/function (_AbstractEmsService) {
60
60
  }
61
61
  }, _callee);
62
62
  }))));
63
- _defineProperty(_this, "_getVectorStyleJsonRaw", _.once( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
63
+ _defineProperty(_this, "_getVectorStyleJsonRaw", _.once(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
64
64
  var vectorUrl, url, vectorJson;
65
65
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
66
66
  while (1) switch (_context2.prev = _context2.next) {
@@ -84,7 +84,7 @@ export var TMSService = /*#__PURE__*/function (_AbstractEmsService) {
84
84
  }
85
85
  }, _callee2);
86
86
  }))));
87
- _defineProperty(_this, "_getVectorStyleJsonInlined", _.once( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
87
+ _defineProperty(_this, "_getVectorStyleJsonInlined", _.once(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
88
88
  var vectorJson, inlinedSources, sources, _iterator, _step, _sourceName, url, _sourceJson$tiles, sourceUrl, extendedUrl, sourceJson, tiles;
89
89
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
90
90
  while (1) switch (_context3.prev = _context3.next) {
@@ -180,7 +180,7 @@ export var TMSService = /*#__PURE__*/function (_AbstractEmsService) {
180
180
  return _createClass(TMSService, [{
181
181
  key: "getDefaultRasterStyle",
182
182
  value: function () {
183
- var _getDefaultRasterStyle = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
183
+ var _getDefaultRasterStyle = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
184
184
  var _this2 = this;
185
185
  var tileJson, tiles;
186
186
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
@@ -216,7 +216,7 @@ export var TMSService = /*#__PURE__*/function (_AbstractEmsService) {
216
216
  }, {
217
217
  key: "getUrlTemplate",
218
218
  value: function () {
219
- var _getUrlTemplate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
219
+ var _getUrlTemplate = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
220
220
  var tileJson, directUrl;
221
221
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
222
222
  while (1) switch (_context5.prev = _context5.next) {
@@ -247,7 +247,7 @@ export var TMSService = /*#__PURE__*/function (_AbstractEmsService) {
247
247
  }, {
248
248
  key: "getUrlTemplateForVector",
249
249
  value: function () {
250
- var _getUrlTemplateForVector = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(sourceId) {
250
+ var _getUrlTemplateForVector = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(sourceId) {
251
251
  var _tileJson$sources$sou;
252
252
  var tileJson, url, directUrl;
253
253
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
@@ -280,7 +280,7 @@ export var TMSService = /*#__PURE__*/function (_AbstractEmsService) {
280
280
  }, {
281
281
  key: "getVectorStyleSheet",
282
282
  value: function () {
283
- var _getVectorStyleSheet = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
283
+ var _getVectorStyleSheet = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
284
284
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
285
285
  while (1) switch (_context7.prev = _context7.next) {
286
286
  case 0:
@@ -302,7 +302,7 @@ export var TMSService = /*#__PURE__*/function (_AbstractEmsService) {
302
302
  }, {
303
303
  key: "getVectorStyleSheetRaw",
304
304
  value: function () {
305
- var _getVectorStyleSheetRaw = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
305
+ var _getVectorStyleSheetRaw = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
306
306
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
307
307
  while (1) switch (_context8.prev = _context8.next) {
308
308
  case 0:
@@ -324,7 +324,7 @@ export var TMSService = /*#__PURE__*/function (_AbstractEmsService) {
324
324
  }, {
325
325
  key: "getSpriteSheetMeta",
326
326
  value: function () {
327
- var _getSpriteSheetMeta = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
327
+ var _getSpriteSheetMeta = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
328
328
  var isRetina,
329
329
  metaUrl,
330
330
  spritePngs,
@@ -372,7 +372,7 @@ export var TMSService = /*#__PURE__*/function (_AbstractEmsService) {
372
372
  }, {
373
373
  key: "getSpriteSheetJsonPath",
374
374
  value: function () {
375
- var _getSpriteSheetJsonPath = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
375
+ var _getSpriteSheetJsonPath = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
376
376
  var isRetina,
377
377
  spriteSheetRootPath,
378
378
  suffix,
@@ -407,7 +407,7 @@ export var TMSService = /*#__PURE__*/function (_AbstractEmsService) {
407
407
  }, {
408
408
  key: "getSpriteSheetPngPath",
409
409
  value: function () {
410
- var _getSpriteSheetPngPath = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
410
+ var _getSpriteSheetPngPath = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
411
411
  var isRetina,
412
412
  spriteSheetRootPath,
413
413
  suffix,
@@ -447,7 +447,7 @@ export var TMSService = /*#__PURE__*/function (_AbstractEmsService) {
447
447
  }, {
448
448
  key: "getMinZoom",
449
449
  value: function () {
450
- var _getMinZoom = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
450
+ var _getMinZoom = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
451
451
  var format,
452
452
  _ref4,
453
453
  sources,
@@ -511,7 +511,7 @@ export var TMSService = /*#__PURE__*/function (_AbstractEmsService) {
511
511
  }, {
512
512
  key: "getMaxZoom",
513
513
  value: function () {
514
- var _getMaxZoom = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
514
+ var _getMaxZoom = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
515
515
  var format,
516
516
  _ref6,
517
517
  sources,
@@ -613,7 +613,7 @@ export var TMSService = /*#__PURE__*/function (_AbstractEmsService) {
613
613
  }, {
614
614
  key: "_getSpriteSheetRootPath",
615
615
  value: function () {
616
- var _getSpriteSheetRootPath2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
616
+ var _getSpriteSheetRootPath2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
617
617
  var vectorStyleJson;
618
618
  return _regeneratorRuntime().wrap(function _callee14$(_context14) {
619
619
  while (1) switch (_context14.prev = _context14.next) {
@@ -643,7 +643,7 @@ export var TMSService = /*#__PURE__*/function (_AbstractEmsService) {
643
643
  }, {
644
644
  key: "_getUrlTemplateForGlyphs",
645
645
  value: function () {
646
- var _getUrlTemplateForGlyphs2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
646
+ var _getUrlTemplateForGlyphs2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
647
647
  var vectorStyleJson;
648
648
  return _regeneratorRuntime().wrap(function _callee15$(_context15) {
649
649
  while (1) switch (_context15.prev = _context15.next) {
@@ -929,4 +929,16 @@ _defineProperty(TMSService, "colorOperationDefaults", [{
929
929
  style: 'dark_map',
930
930
  operation: 'dodge',
931
931
  percentage: 0.25
932
+ }, {
933
+ style: 'high_contrast',
934
+ operation: 'screen',
935
+ percentage: 0.25
936
+ }, {
937
+ style: 'road_map_desaturated_v9',
938
+ operation: 'screen',
939
+ percentage: 0.25
940
+ }, {
941
+ style: 'dark_map_v9',
942
+ operation: 'dodge',
943
+ percentage: 0.25
932
944
  }]);
@@ -42,7 +42,7 @@ export function getEMSClient(options = {}) {
42
42
 
43
43
  const getManifestMock = jest
44
44
  .spyOn(emsClient, 'getManifest')
45
- .mockImplementation(async (url: string): Promise<Object | unknown> => {
45
+ .mockImplementation(async (url: string): Promise<object | unknown> => {
46
46
  //simulate network calls
47
47
  if (url.startsWith('https://foobar')) {
48
48
  return EMS_CATALOGUE;
@@ -1,318 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.EMSClient = exports.LATEST_API_URL_PATH = void 0;
16
- /*
17
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
18
- * or more contributor license agreements. Licensed under the Elastic License
19
- * 2.0; you may not use this file except in compliance with the Elastic License
20
- * 2.0.
21
- */
22
- const lodash_1 = __importDefault(require("lodash"));
23
- const tms_service_1 = require("./tms_service");
24
- const file_layer_1 = require("./file_layer");
25
- const coerce_1 = __importDefault(require("semver/functions/coerce"));
26
- const valid_1 = __importDefault(require("semver/functions/valid"));
27
- const major_1 = __importDefault(require("semver/functions/major"));
28
- const minor_1 = __importDefault(require("semver/functions/minor"));
29
- const url_1 = require("url");
30
- const utils_1 = require("./utils");
31
- const lru_cache_1 = __importDefault(require("lru-cache"));
32
- const REST_API_REGEX = /\d{4}-\d{2}-\d{2}/;
33
- exports.LATEST_API_URL_PATH = 'latest';
34
- /**
35
- * plugins cannot have upstream dependencies on core/*-kibana.
36
- * Work-around by copy-pasting modifyUrl routine here.
37
- * @param url
38
- * @param block
39
- */
40
- function modifyUrlLocal(url, block) {
41
- const parsed = (0, url_1.parse)(url, true);
42
- // copy over the most specific version of each
43
- // property. By default, the parsed url includes
44
- // several conflicting properties (like path and
45
- // pathname + search, or search and query) and keeping
46
- // track of which property is actually used when they
47
- // are formatted is harder than necessary
48
- const meaningfulParts = {
49
- protocol: parsed.protocol,
50
- slashes: parsed.slashes,
51
- auth: parsed.auth,
52
- hostname: parsed.hostname,
53
- port: parsed.port,
54
- pathname: parsed.pathname,
55
- query: parsed.query || {},
56
- hash: parsed.hash,
57
- };
58
- // the block modifies the meaningfulParts object, or returns a new one
59
- const modifiedParts = block(meaningfulParts) || meaningfulParts;
60
- // format the modified/replaced meaningfulParts back into a url
61
- return (0, url_1.format)({
62
- protocol: modifiedParts.protocol,
63
- slashes: modifiedParts.slashes,
64
- auth: modifiedParts.auth,
65
- hostname: modifiedParts.hostname,
66
- port: modifiedParts.port,
67
- pathname: modifiedParts.pathname,
68
- query: modifiedParts.query,
69
- hash: modifiedParts.hash,
70
- });
71
- }
72
- const extendUrl = (url, props) => modifyUrlLocal(url, (parsed) => lodash_1.default.merge(parsed, props));
73
- /**
74
- * Unescape a url template that was escaped by encodeURI() so leaflet
75
- * will be able to correctly locate the variables in the template
76
- * @param {String} url
77
- * @return {String}
78
- */
79
- const unescapeTemplateVars = (url) => {
80
- const ENCODED_TEMPLATE_VARS_RE = /%7B(\w+?)%7D/g;
81
- return url.replace(ENCODED_TEMPLATE_VARS_RE, (total, varName) => `{${varName}}`);
82
- };
83
- //this is not the default locale from Kibana, but the default locale supported by the Elastic Maps Service
84
- const DEFAULT_LANGUAGE = 'en';
85
- class EMSClient {
86
- constructor(config) {
87
- this.EMS_LOAD_TIMEOUT = 32000;
88
- this._isRestApi = false;
89
- // Remove kbnVersion in 8.0
90
- if ('kbnVersion' in config) {
91
- console.warn('The "kbnVersion" parameter for ems-client is deprecated. Please use "appVersion" instead.');
92
- this._appVersion = config.kbnVersion;
93
- }
94
- else {
95
- this._appVersion = config.appVersion;
96
- }
97
- this._queryParams = {
98
- elastic_tile_service_tos: 'agree',
99
- my_app_name: config.appName || 'kibana',
100
- my_app_version: this._appVersion,
101
- };
102
- this._sanitizer = config.htmlSanitizer ? config.htmlSanitizer : (x) => x;
103
- this._tileApiUrl = config.tileApiUrl;
104
- this._fileApiUrl = config.fileApiUrl;
105
- this._emsVersion = this._getEmsVersion(config.emsVersion);
106
- this._isRestApi = this._emsVersion == config.emsVersion;
107
- this._emsLandingPageUrl = config.landingPageUrl || '';
108
- this._language = config.language || DEFAULT_LANGUAGE;
109
- this._fetchFunction = config.fetchFunction;
110
- this._proxyPath = config.proxyPath || '';
111
- this._cache = new lru_cache_1.default({
112
- max: config.cacheSize || 10,
113
- });
114
- this._invalidateSettings();
115
- }
116
- getDefaultLocale() {
117
- return DEFAULT_LANGUAGE;
118
- }
119
- getLocale() {
120
- return this._language;
121
- }
122
- getValueInLanguage(i18nObject) {
123
- if (!i18nObject) {
124
- return '';
125
- }
126
- return i18nObject[this._language] ? i18nObject[this._language] : i18nObject[DEFAULT_LANGUAGE];
127
- }
128
- /**
129
- * this internal method is overridden by the tests to simulate custom manifest.
130
- */
131
- getManifest(endpointUrl) {
132
- return __awaiter(this, void 0, void 0, function* () {
133
- try {
134
- const url = extendUrl(endpointUrl, { query: this._queryParams });
135
- const response = yield this._fetchWithTimeout(url);
136
- if (!response.ok) {
137
- throw new Error(response.statusText);
138
- }
139
- if (response) {
140
- return (yield response.json());
141
- }
142
- else {
143
- throw new Error('Response not found');
144
- }
145
- }
146
- catch (e) {
147
- if (e instanceof Error) {
148
- throw e;
149
- }
150
- else {
151
- throw new Error('Unknown error');
152
- }
153
- }
154
- });
155
- }
156
- /**
157
- * Add optional query-parameters to all requests
158
- *
159
- * @param additionalQueryParams
160
- */
161
- addQueryParams(additionalQueryParams) {
162
- for (const key in additionalQueryParams) {
163
- if (Object.prototype.hasOwnProperty.call(additionalQueryParams, key)) {
164
- if (additionalQueryParams[key] !== this._queryParams[key]) {
165
- //changes detected.
166
- this._queryParams = lodash_1.default.assign({}, this._queryParams, additionalQueryParams);
167
- this._invalidateSettings();
168
- break;
169
- }
170
- }
171
- }
172
- }
173
- getMainManifest() {
174
- return __awaiter(this, void 0, void 0, function* () {
175
- return yield this._getMainCatalog();
176
- });
177
- }
178
- getDefaultFileManifest() {
179
- return __awaiter(this, void 0, void 0, function* () {
180
- return yield this._getDefaultFileCatalog();
181
- });
182
- }
183
- getDefaultTMSManifest() {
184
- return __awaiter(this, void 0, void 0, function* () {
185
- return yield this._getDefaultTMSCatalog();
186
- });
187
- }
188
- getFileLayers() {
189
- return __awaiter(this, void 0, void 0, function* () {
190
- return yield this._loadFileLayers();
191
- });
192
- }
193
- getTMSServices() {
194
- return __awaiter(this, void 0, void 0, function* () {
195
- return yield this._loadTMSServices();
196
- });
197
- }
198
- cacheGeoJson(layerId, geoJson) {
199
- this._cache.set(layerId, geoJson);
200
- return;
201
- }
202
- getCachedGeoJson(layerId) {
203
- return this._cache.get(layerId);
204
- }
205
- getEmsVersion() {
206
- return this._emsVersion;
207
- }
208
- getTileApiUrl() {
209
- return this._tileApiUrl;
210
- }
211
- getFileApiUrl() {
212
- return this._fileApiUrl;
213
- }
214
- getLandingPageUrl() {
215
- return this._emsLandingPageUrl;
216
- }
217
- sanitizeHtml(html) {
218
- return this._sanitizer(html);
219
- }
220
- extendUrlWithParams(url) {
221
- return unescapeTemplateVars(extendUrl(url, {
222
- query: this._queryParams,
223
- }));
224
- }
225
- findFileLayerById(id) {
226
- return __awaiter(this, void 0, void 0, function* () {
227
- const fileLayers = yield this.getFileLayers();
228
- for (let i = 0; i < fileLayers.length; i++) {
229
- if (fileLayers[i].hasId(id)) {
230
- return fileLayers[i];
231
- }
232
- }
233
- });
234
- }
235
- findTMSServiceById(id) {
236
- return __awaiter(this, void 0, void 0, function* () {
237
- const tmsServices = yield this.getTMSServices();
238
- for (let i = 0; i < tmsServices.length; i++) {
239
- if (tmsServices[i].hasId(id)) {
240
- return tmsServices[i];
241
- }
242
- }
243
- });
244
- }
245
- _getEmsVersion(version) {
246
- if (version === null || version === void 0 ? void 0 : version.match(REST_API_REGEX)) {
247
- return version;
248
- }
249
- const semverVersion = (0, valid_1.default)((0, coerce_1.default)(version));
250
- if (semverVersion) {
251
- return `v${(0, major_1.default)(semverVersion)}.${(0, minor_1.default)(semverVersion)}`;
252
- }
253
- else {
254
- throw new Error(`Invalid version: ${version}`);
255
- }
256
- }
257
- _fetchWithTimeout(url) {
258
- return new Promise((resolve, reject) => {
259
- const timer = setTimeout(() => reject(new Error(`Request to ${url} timed out`)), this.EMS_LOAD_TIMEOUT);
260
- this._fetchFunction(url).then((response) => {
261
- clearTimeout(timer);
262
- resolve(response);
263
- }, (err) => {
264
- clearTimeout(timer);
265
- reject(err);
266
- });
267
- });
268
- }
269
- _invalidateSettings() {
270
- this._cache.reset();
271
- this._getMainCatalog = lodash_1.default.once(() => __awaiter(this, void 0, void 0, function* () {
272
- const services = [];
273
- if (this._tileApiUrl) {
274
- const version = this._isRestApi ? exports.LATEST_API_URL_PATH : this._emsVersion;
275
- services.push({
276
- type: 'tms',
277
- manifest: (0, utils_1.toAbsoluteUrl)(this._tileApiUrl, `${version}/manifest`),
278
- });
279
- }
280
- if (this._fileApiUrl) {
281
- const version = this._isRestApi ? exports.LATEST_API_URL_PATH : this._emsVersion;
282
- services.push({
283
- type: 'file',
284
- manifest: (0, utils_1.toAbsoluteUrl)(this._fileApiUrl, `${version}/manifest`),
285
- });
286
- }
287
- return { services: services };
288
- }));
289
- this._getDefaultTMSCatalog = lodash_1.default.once(() => __awaiter(this, void 0, void 0, function* () {
290
- const catalogue = yield this._getMainCatalog();
291
- const firstService = catalogue.services.find((service) => service.type === 'tms');
292
- if (!firstService) {
293
- return { services: [] };
294
- }
295
- const url = this._proxyPath + firstService.manifest;
296
- return yield this.getManifest(url);
297
- }));
298
- this._getDefaultFileCatalog = lodash_1.default.once(() => __awaiter(this, void 0, void 0, function* () {
299
- const catalogue = yield this._getMainCatalog();
300
- const firstService = catalogue.services.find((service) => service.type === 'file');
301
- if (!firstService) {
302
- return { layers: [] };
303
- }
304
- const url = this._proxyPath + firstService.manifest;
305
- return yield this.getManifest(url);
306
- }));
307
- //Cache the actual instances of TMSService as these in turn cache sub-manifests for the style-files
308
- this._loadTMSServices = lodash_1.default.once(() => __awaiter(this, void 0, void 0, function* () {
309
- const tmsManifest = yield this._getDefaultTMSCatalog();
310
- return tmsManifest.services.map((serviceConfig) => new tms_service_1.TMSService(serviceConfig, this, this._proxyPath));
311
- }));
312
- this._loadFileLayers = lodash_1.default.once(() => __awaiter(this, void 0, void 0, function* () {
313
- const fileManifest = yield this._getDefaultFileCatalog();
314
- return fileManifest.layers.map((layerConfig) => new file_layer_1.FileLayer(layerConfig, this, this._proxyPath));
315
- }));
316
- }
317
- }
318
- exports.EMSClient = EMSClient;
@@ -1,47 +0,0 @@
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.AbstractEmsService = void 0;
10
- const utils_1 = require("./utils");
11
- class AbstractEmsService {
12
- constructor(config, emsClient, proxyPath) {
13
- /**
14
- * Checks if url is absolute. If not, prepend the basePath.
15
- */
16
- this._getAbsoluteUrl = (url) => {
17
- if (/^https?:\/\//.test(url)) {
18
- return url;
19
- }
20
- else {
21
- return (0, utils_1.toAbsoluteUrl)(this.getApiUrl(), url);
22
- }
23
- };
24
- this._config = config;
25
- this._emsClient = emsClient;
26
- this._proxyPath = proxyPath;
27
- }
28
- getAttributions() {
29
- return this._config.attribution.map((attribution) => {
30
- const url = this._emsClient.getValueInLanguage(attribution.url);
31
- const label = this._emsClient.getValueInLanguage(attribution.label);
32
- return {
33
- url: url,
34
- label: label,
35
- };
36
- });
37
- }
38
- getMarkdownAttribution() {
39
- const attributions = this._config.attribution.map((attribution) => {
40
- const url = this._emsClient.getValueInLanguage(attribution.url);
41
- const label = this._emsClient.getValueInLanguage(attribution.label);
42
- return `[${label}](${url})`;
43
- });
44
- return attributions.join('|');
45
- }
46
- }
47
- exports.AbstractEmsService = AbstractEmsService;