@elastic/ems-client 8.4.1 → 8.5.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/.github/CODEOWNERS +2 -0
- package/CHANGELOG.md +18 -5
- package/CONTRIBUTING.md +4 -5
- package/docs/openapi/Makefile +35 -0
- package/docs/openapi/README.md +41 -0
- package/docs/openapi/components/attribution.yaml +19 -0
- package/docs/openapi/components/examples/file_service_200.json +1 -0
- package/docs/openapi/components/examples/file_service_404.xml +1 -0
- package/docs/openapi/components/examples/tile_service_200.json +1 -0
- package/docs/openapi/components/examples/tile_service_404.html +10 -0
- package/docs/openapi/ems_file_service/bundled.json +533 -0
- package/docs/openapi/ems_file_service/bundled.yaml +347 -0
- package/docs/openapi/ems_file_service/entrypoint.yaml +152 -0
- package/docs/openapi/ems_tile_service/bundled.json +307 -0
- package/docs/openapi/ems_tile_service/bundled.yaml +195 -0
- package/docs/openapi/ems_tile_service/entrypoint.yaml +92 -0
- package/package.json +1 -1
- package/src/ems_client.ts +37 -32
- package/src/index.ts +1 -1
- package/target/ems_client.d.ts +3 -2
- package/target/index.d.ts +1 -1
- package/target/node/ems_client.js +34 -34
- package/target/node/index.js +6 -0
- package/target/web/ems_client.js +68 -89
- package/target/web/index.js +1 -1
- package/test/ems_client.test.ts +33 -0
package/src/ems_client.ts
CHANGED
|
@@ -9,13 +9,19 @@ import { TMSService } from './tms_service';
|
|
|
9
9
|
import { EMSFormatType, FileLayer } from './file_layer';
|
|
10
10
|
import { FeatureCollection } from 'geojson';
|
|
11
11
|
import { Response } from 'node-fetch';
|
|
12
|
-
|
|
12
|
+
|
|
13
|
+
import semverCoerce from 'semver/functions/coerce';
|
|
14
|
+
import semverValid from 'semver/functions/valid';
|
|
15
|
+
import semverMajor from 'semver/functions/major';
|
|
16
|
+
import semverMinor from 'semver/functions/minor';
|
|
17
|
+
|
|
13
18
|
import { format as formatUrl, parse as parseUrl, UrlObject } from 'url';
|
|
14
19
|
import { toAbsoluteUrl } from './utils';
|
|
15
20
|
import { ParsedUrlQueryInput } from 'querystring';
|
|
16
21
|
import LRUCache from 'lru-cache';
|
|
17
22
|
|
|
18
|
-
const
|
|
23
|
+
const REST_API_REGEX = /\d{4}-\d{2}-\d{2}/;
|
|
24
|
+
export const LATEST_API_URL_PATH = 'latest';
|
|
19
25
|
|
|
20
26
|
type URLMeaningfulParts = {
|
|
21
27
|
auth?: string | null;
|
|
@@ -205,7 +211,6 @@ export class EMSClient {
|
|
|
205
211
|
private readonly _appVersion: string;
|
|
206
212
|
private readonly _fetchFunction: Function;
|
|
207
213
|
private readonly _sanitizer: Function;
|
|
208
|
-
private readonly _manifestServiceUrl?: string;
|
|
209
214
|
private readonly _fileApiUrl: string;
|
|
210
215
|
private readonly _tileApiUrl: string;
|
|
211
216
|
private readonly _emsVersion: string;
|
|
@@ -213,6 +218,7 @@ export class EMSClient {
|
|
|
213
218
|
private readonly _language: string;
|
|
214
219
|
private readonly _proxyPath: string;
|
|
215
220
|
private readonly _cache: LRUCache<string, FeatureCollection>;
|
|
221
|
+
private readonly _isRestApi: boolean = false;
|
|
216
222
|
|
|
217
223
|
/**
|
|
218
224
|
* these methods are assigned outside the constructor
|
|
@@ -241,10 +247,12 @@ export class EMSClient {
|
|
|
241
247
|
};
|
|
242
248
|
|
|
243
249
|
this._sanitizer = config.htmlSanitizer ? config.htmlSanitizer : (x: string) => x;
|
|
244
|
-
this._manifestServiceUrl = config.manifestServiceUrl;
|
|
245
250
|
this._tileApiUrl = config.tileApiUrl;
|
|
246
251
|
this._fileApiUrl = config.fileApiUrl;
|
|
252
|
+
|
|
247
253
|
this._emsVersion = this._getEmsVersion(config.emsVersion);
|
|
254
|
+
this._isRestApi = this._emsVersion == config.emsVersion;
|
|
255
|
+
|
|
248
256
|
this._emsLandingPageUrl = config.landingPageUrl || '';
|
|
249
257
|
this._language = config.language || DEFAULT_LANGUAGE;
|
|
250
258
|
|
|
@@ -339,6 +347,10 @@ export class EMSClient {
|
|
|
339
347
|
return this._cache.get(layerId);
|
|
340
348
|
}
|
|
341
349
|
|
|
350
|
+
getEmsVersion(): string {
|
|
351
|
+
return this._emsVersion;
|
|
352
|
+
}
|
|
353
|
+
|
|
342
354
|
getTileApiUrl(): string {
|
|
343
355
|
return this._tileApiUrl;
|
|
344
356
|
}
|
|
@@ -382,10 +394,13 @@ export class EMSClient {
|
|
|
382
394
|
}
|
|
383
395
|
|
|
384
396
|
private _getEmsVersion(version: string | undefined): string {
|
|
385
|
-
|
|
386
|
-
|
|
397
|
+
if (version?.match(REST_API_REGEX)) {
|
|
398
|
+
return version;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
const semverVersion = semverValid(semverCoerce(version));
|
|
387
402
|
if (semverVersion) {
|
|
388
|
-
return `v${
|
|
403
|
+
return `v${semverMajor(semverVersion)}.${semverMinor(semverVersion)}`;
|
|
389
404
|
} else {
|
|
390
405
|
throw new Error(`Invalid version: ${version}`);
|
|
391
406
|
}
|
|
@@ -410,35 +425,25 @@ export class EMSClient {
|
|
|
410
425
|
});
|
|
411
426
|
}
|
|
412
427
|
|
|
413
|
-
private async _getManifestWithParams<T>(url: string): Promise<T> {
|
|
414
|
-
const extendedUrl = this.extendUrlWithParams(url);
|
|
415
|
-
return await this.getManifest(extendedUrl);
|
|
416
|
-
}
|
|
417
|
-
|
|
418
428
|
private _invalidateSettings(): void {
|
|
419
429
|
this._cache.reset();
|
|
420
430
|
this._getMainCatalog = _.once(async (): Promise<EmsCatalogManifest> => {
|
|
421
|
-
|
|
422
|
-
if (this.
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
services.push({
|
|
436
|
-
type: 'file',
|
|
437
|
-
manifest: toAbsoluteUrl(this._fileApiUrl, `${this._emsVersion}/manifest`),
|
|
438
|
-
});
|
|
439
|
-
}
|
|
440
|
-
return { services: services };
|
|
431
|
+
const services = [];
|
|
432
|
+
if (this._tileApiUrl) {
|
|
433
|
+
const version = this._isRestApi ? LATEST_API_URL_PATH : this._emsVersion;
|
|
434
|
+
services.push({
|
|
435
|
+
type: 'tms',
|
|
436
|
+
manifest: toAbsoluteUrl(this._tileApiUrl, `${version}/manifest`),
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
if (this._fileApiUrl) {
|
|
440
|
+
const version = this._isRestApi ? LATEST_API_URL_PATH : this._emsVersion;
|
|
441
|
+
services.push({
|
|
442
|
+
type: 'file',
|
|
443
|
+
manifest: toAbsoluteUrl(this._fileApiUrl, `${version}/manifest`),
|
|
444
|
+
});
|
|
441
445
|
}
|
|
446
|
+
return { services: services };
|
|
442
447
|
});
|
|
443
448
|
|
|
444
449
|
this._getDefaultTMSCatalog = _.once(async (): Promise<EmsTmsCatalog> => {
|
package/src/index.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* 2.0.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
export { EMSClient, FileLayerField } from './ems_client';
|
|
8
|
+
export { EMSClient, FileLayerField, LATEST_API_URL_PATH } from './ems_client';
|
|
9
9
|
export { FileLayer } from './file_layer';
|
|
10
10
|
export { TMSService, EmsSprite, EmsSpriteSheet } from './tms_service';
|
|
11
11
|
export { blendMode } from './utils';
|
package/target/ems_client.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { TMSService } from './tms_service';
|
|
2
2
|
import { EMSFormatType, FileLayer } from './file_layer';
|
|
3
3
|
import { FeatureCollection } from 'geojson';
|
|
4
|
+
export declare const LATEST_API_URL_PATH = "latest";
|
|
4
5
|
declare type LocalizedStrings = {
|
|
5
6
|
[key: string]: string;
|
|
6
7
|
};
|
|
@@ -95,7 +96,6 @@ export declare class EMSClient {
|
|
|
95
96
|
private readonly _appVersion;
|
|
96
97
|
private readonly _fetchFunction;
|
|
97
98
|
private readonly _sanitizer;
|
|
98
|
-
private readonly _manifestServiceUrl?;
|
|
99
99
|
private readonly _fileApiUrl;
|
|
100
100
|
private readonly _tileApiUrl;
|
|
101
101
|
private readonly _emsVersion;
|
|
@@ -103,6 +103,7 @@ export declare class EMSClient {
|
|
|
103
103
|
private readonly _language;
|
|
104
104
|
private readonly _proxyPath;
|
|
105
105
|
private readonly _cache;
|
|
106
|
+
private readonly _isRestApi;
|
|
106
107
|
/**
|
|
107
108
|
* these methods are assigned outside the constructor
|
|
108
109
|
*/
|
|
@@ -136,6 +137,7 @@ export declare class EMSClient {
|
|
|
136
137
|
getTMSServices(): Promise<TMSService[]>;
|
|
137
138
|
cacheGeoJson(layerId: string, geoJson: FeatureCollection): void;
|
|
138
139
|
getCachedGeoJson(layerId: string): FeatureCollection<import("geojson").Geometry, import("geojson").GeoJsonProperties> | undefined;
|
|
140
|
+
getEmsVersion(): string;
|
|
139
141
|
getTileApiUrl(): string;
|
|
140
142
|
getFileApiUrl(): string;
|
|
141
143
|
getLandingPageUrl(): string;
|
|
@@ -145,7 +147,6 @@ export declare class EMSClient {
|
|
|
145
147
|
findTMSServiceById(id: string): Promise<TMSService | undefined>;
|
|
146
148
|
private _getEmsVersion;
|
|
147
149
|
private _fetchWithTimeout;
|
|
148
|
-
private _getManifestWithParams;
|
|
149
150
|
private _invalidateSettings;
|
|
150
151
|
}
|
|
151
152
|
export {};
|
package/target/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { EMSClient, FileLayerField } from './ems_client';
|
|
1
|
+
export { EMSClient, FileLayerField, LATEST_API_URL_PATH } from './ems_client';
|
|
2
2
|
export { FileLayer } from './file_layer';
|
|
3
3
|
export { TMSService, EmsSprite, EmsSpriteSheet } from './tms_service';
|
|
4
4
|
export { blendMode } from './utils';
|
|
@@ -3,11 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.EMSClient = void 0;
|
|
6
|
+
exports.LATEST_API_URL_PATH = exports.EMSClient = void 0;
|
|
7
7
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
8
8
|
var _tms_service = require("./tms_service");
|
|
9
9
|
var _file_layer = require("./file_layer");
|
|
10
|
-
var
|
|
10
|
+
var _coerce = _interopRequireDefault(require("semver/functions/coerce"));
|
|
11
|
+
var _valid = _interopRequireDefault(require("semver/functions/valid"));
|
|
12
|
+
var _major = _interopRequireDefault(require("semver/functions/major"));
|
|
13
|
+
var _minor = _interopRequireDefault(require("semver/functions/minor"));
|
|
11
14
|
var _url = require("url");
|
|
12
15
|
var _utils = require("./utils");
|
|
13
16
|
var _lruCache = _interopRequireDefault(require("lru-cache"));
|
|
@@ -20,7 +23,8 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
|
|
|
20
23
|
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
21
24
|
* 2.0.
|
|
22
25
|
*/
|
|
23
|
-
const
|
|
26
|
+
const REST_API_REGEX = /\d{4}-\d{2}-\d{2}/;
|
|
27
|
+
const LATEST_API_URL_PATH = exports.LATEST_API_URL_PATH = 'latest';
|
|
24
28
|
/**
|
|
25
29
|
* plugins cannot have upstream dependencies on core/*-kibana.
|
|
26
30
|
* Work-around by copy-pasting modifyUrl routine here.
|
|
@@ -83,7 +87,6 @@ class EMSClient {
|
|
|
83
87
|
_defineProperty(this, "_appVersion", void 0);
|
|
84
88
|
_defineProperty(this, "_fetchFunction", void 0);
|
|
85
89
|
_defineProperty(this, "_sanitizer", void 0);
|
|
86
|
-
_defineProperty(this, "_manifestServiceUrl", void 0);
|
|
87
90
|
_defineProperty(this, "_fileApiUrl", void 0);
|
|
88
91
|
_defineProperty(this, "_tileApiUrl", void 0);
|
|
89
92
|
_defineProperty(this, "_emsVersion", void 0);
|
|
@@ -91,6 +94,7 @@ class EMSClient {
|
|
|
91
94
|
_defineProperty(this, "_language", void 0);
|
|
92
95
|
_defineProperty(this, "_proxyPath", void 0);
|
|
93
96
|
_defineProperty(this, "_cache", void 0);
|
|
97
|
+
_defineProperty(this, "_isRestApi", false);
|
|
94
98
|
/**
|
|
95
99
|
* these methods are assigned outside the constructor
|
|
96
100
|
*/
|
|
@@ -112,10 +116,10 @@ class EMSClient {
|
|
|
112
116
|
my_app_version: this._appVersion
|
|
113
117
|
};
|
|
114
118
|
this._sanitizer = config.htmlSanitizer ? config.htmlSanitizer : x => x;
|
|
115
|
-
this._manifestServiceUrl = config.manifestServiceUrl;
|
|
116
119
|
this._tileApiUrl = config.tileApiUrl;
|
|
117
120
|
this._fileApiUrl = config.fileApiUrl;
|
|
118
121
|
this._emsVersion = this._getEmsVersion(config.emsVersion);
|
|
122
|
+
this._isRestApi = this._emsVersion == config.emsVersion;
|
|
119
123
|
this._emsLandingPageUrl = config.landingPageUrl || '';
|
|
120
124
|
this._language = config.language || DEFAULT_LANGUAGE;
|
|
121
125
|
this._fetchFunction = config.fetchFunction;
|
|
@@ -199,6 +203,9 @@ class EMSClient {
|
|
|
199
203
|
getCachedGeoJson(layerId) {
|
|
200
204
|
return this._cache.get(layerId);
|
|
201
205
|
}
|
|
206
|
+
getEmsVersion() {
|
|
207
|
+
return this._emsVersion;
|
|
208
|
+
}
|
|
202
209
|
getTileApiUrl() {
|
|
203
210
|
return this._tileApiUrl;
|
|
204
211
|
}
|
|
@@ -233,10 +240,12 @@ class EMSClient {
|
|
|
233
240
|
}
|
|
234
241
|
}
|
|
235
242
|
_getEmsVersion(version) {
|
|
236
|
-
|
|
237
|
-
|
|
243
|
+
if (version?.match(REST_API_REGEX)) {
|
|
244
|
+
return version;
|
|
245
|
+
}
|
|
246
|
+
const semverVersion = (0, _valid.default)((0, _coerce.default)(version));
|
|
238
247
|
if (semverVersion) {
|
|
239
|
-
return `v${
|
|
248
|
+
return `v${(0, _major.default)(semverVersion)}.${(0, _minor.default)(semverVersion)}`;
|
|
240
249
|
} else {
|
|
241
250
|
throw new Error(`Invalid version: ${version}`);
|
|
242
251
|
}
|
|
@@ -253,36 +262,27 @@ class EMSClient {
|
|
|
253
262
|
});
|
|
254
263
|
});
|
|
255
264
|
}
|
|
256
|
-
async _getManifestWithParams(url) {
|
|
257
|
-
const extendedUrl = this.extendUrlWithParams(url);
|
|
258
|
-
return await this.getManifest(extendedUrl);
|
|
259
|
-
}
|
|
260
265
|
_invalidateSettings() {
|
|
261
266
|
this._cache.reset();
|
|
262
267
|
this._getMainCatalog = _lodash.default.once(async () => {
|
|
263
|
-
|
|
264
|
-
if (this.
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
services.push({
|
|
278
|
-
type: 'file',
|
|
279
|
-
manifest: (0, _utils.toAbsoluteUrl)(this._fileApiUrl, `${this._emsVersion}/manifest`)
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
return {
|
|
283
|
-
services: services
|
|
284
|
-
};
|
|
268
|
+
const services = [];
|
|
269
|
+
if (this._tileApiUrl) {
|
|
270
|
+
const version = this._isRestApi ? LATEST_API_URL_PATH : this._emsVersion;
|
|
271
|
+
services.push({
|
|
272
|
+
type: 'tms',
|
|
273
|
+
manifest: (0, _utils.toAbsoluteUrl)(this._tileApiUrl, `${version}/manifest`)
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
if (this._fileApiUrl) {
|
|
277
|
+
const version = this._isRestApi ? LATEST_API_URL_PATH : this._emsVersion;
|
|
278
|
+
services.push({
|
|
279
|
+
type: 'file',
|
|
280
|
+
manifest: (0, _utils.toAbsoluteUrl)(this._fileApiUrl, `${version}/manifest`)
|
|
281
|
+
});
|
|
285
282
|
}
|
|
283
|
+
return {
|
|
284
|
+
services: services
|
|
285
|
+
};
|
|
286
286
|
});
|
|
287
287
|
this._getDefaultTMSCatalog = _lodash.default.once(async () => {
|
|
288
288
|
const catalogue = await this._getMainCatalog();
|
package/target/node/index.js
CHANGED
|
@@ -33,6 +33,12 @@ Object.defineProperty(exports, "FileLayerField", {
|
|
|
33
33
|
return _ems_client.FileLayerField;
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
|
+
Object.defineProperty(exports, "LATEST_API_URL_PATH", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _ems_client.LATEST_API_URL_PATH;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
36
42
|
Object.defineProperty(exports, "TMSService", {
|
|
37
43
|
enumerable: true,
|
|
38
44
|
get: function () {
|
package/target/web/ems_client.js
CHANGED
|
@@ -17,11 +17,15 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
|
17
17
|
import _ from 'lodash';
|
|
18
18
|
import { TMSService } from './tms_service';
|
|
19
19
|
import { FileLayer } from './file_layer';
|
|
20
|
-
import
|
|
20
|
+
import semverCoerce from 'semver/functions/coerce';
|
|
21
|
+
import semverValid from 'semver/functions/valid';
|
|
22
|
+
import semverMajor from 'semver/functions/major';
|
|
23
|
+
import semverMinor from 'semver/functions/minor';
|
|
21
24
|
import { format as formatUrl, parse as parseUrl } from 'url';
|
|
22
25
|
import { toAbsoluteUrl } from './utils';
|
|
23
26
|
import LRUCache from 'lru-cache';
|
|
24
|
-
var
|
|
27
|
+
var REST_API_REGEX = /\d{4}-\d{2}-\d{2}/;
|
|
28
|
+
export var LATEST_API_URL_PATH = 'latest';
|
|
25
29
|
/**
|
|
26
30
|
* plugins cannot have upstream dependencies on core/*-kibana.
|
|
27
31
|
* Work-around by copy-pasting modifyUrl routine here.
|
|
@@ -91,7 +95,6 @@ export var EMSClient = /*#__PURE__*/function () {
|
|
|
91
95
|
_defineProperty(this, "_appVersion", void 0);
|
|
92
96
|
_defineProperty(this, "_fetchFunction", void 0);
|
|
93
97
|
_defineProperty(this, "_sanitizer", void 0);
|
|
94
|
-
_defineProperty(this, "_manifestServiceUrl", void 0);
|
|
95
98
|
_defineProperty(this, "_fileApiUrl", void 0);
|
|
96
99
|
_defineProperty(this, "_tileApiUrl", void 0);
|
|
97
100
|
_defineProperty(this, "_emsVersion", void 0);
|
|
@@ -99,6 +102,7 @@ export var EMSClient = /*#__PURE__*/function () {
|
|
|
99
102
|
_defineProperty(this, "_language", void 0);
|
|
100
103
|
_defineProperty(this, "_proxyPath", void 0);
|
|
101
104
|
_defineProperty(this, "_cache", void 0);
|
|
105
|
+
_defineProperty(this, "_isRestApi", false);
|
|
102
106
|
/**
|
|
103
107
|
* these methods are assigned outside the constructor
|
|
104
108
|
*/
|
|
@@ -122,10 +126,10 @@ export var EMSClient = /*#__PURE__*/function () {
|
|
|
122
126
|
this._sanitizer = config.htmlSanitizer ? config.htmlSanitizer : function (x) {
|
|
123
127
|
return x;
|
|
124
128
|
};
|
|
125
|
-
this._manifestServiceUrl = config.manifestServiceUrl;
|
|
126
129
|
this._tileApiUrl = config.tileApiUrl;
|
|
127
130
|
this._fileApiUrl = config.fileApiUrl;
|
|
128
131
|
this._emsVersion = this._getEmsVersion(config.emsVersion);
|
|
132
|
+
this._isRestApi = this._emsVersion == config.emsVersion;
|
|
129
133
|
this._emsLandingPageUrl = config.landingPageUrl || '';
|
|
130
134
|
this._language = config.language || DEFAULT_LANGUAGE;
|
|
131
135
|
this._fetchFunction = config.fetchFunction;
|
|
@@ -354,6 +358,11 @@ export var EMSClient = /*#__PURE__*/function () {
|
|
|
354
358
|
value: function getCachedGeoJson(layerId) {
|
|
355
359
|
return this._cache.get(layerId);
|
|
356
360
|
}
|
|
361
|
+
}, {
|
|
362
|
+
key: "getEmsVersion",
|
|
363
|
+
value: function getEmsVersion() {
|
|
364
|
+
return this._emsVersion;
|
|
365
|
+
}
|
|
357
366
|
}, {
|
|
358
367
|
key: "getTileApiUrl",
|
|
359
368
|
value: function getTileApiUrl() {
|
|
@@ -460,10 +469,12 @@ export var EMSClient = /*#__PURE__*/function () {
|
|
|
460
469
|
}, {
|
|
461
470
|
key: "_getEmsVersion",
|
|
462
471
|
value: function _getEmsVersion(version) {
|
|
463
|
-
|
|
464
|
-
|
|
472
|
+
if (version !== null && version !== void 0 && version.match(REST_API_REGEX)) {
|
|
473
|
+
return version;
|
|
474
|
+
}
|
|
475
|
+
var semverVersion = semverValid(semverCoerce(version));
|
|
465
476
|
if (semverVersion) {
|
|
466
|
-
return "v".concat(
|
|
477
|
+
return "v".concat(semverMajor(semverVersion), ".").concat(semverMinor(semverVersion));
|
|
467
478
|
} else {
|
|
468
479
|
throw new Error("Invalid version: ".concat(version));
|
|
469
480
|
}
|
|
@@ -485,171 +496,139 @@ export var EMSClient = /*#__PURE__*/function () {
|
|
|
485
496
|
});
|
|
486
497
|
});
|
|
487
498
|
}
|
|
488
|
-
}, {
|
|
489
|
-
key: "_getManifestWithParams",
|
|
490
|
-
value: function () {
|
|
491
|
-
var _getManifestWithParams2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(url) {
|
|
492
|
-
var extendedUrl;
|
|
493
|
-
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
494
|
-
while (1) switch (_context9.prev = _context9.next) {
|
|
495
|
-
case 0:
|
|
496
|
-
extendedUrl = this.extendUrlWithParams(url);
|
|
497
|
-
_context9.next = 3;
|
|
498
|
-
return this.getManifest(extendedUrl);
|
|
499
|
-
case 3:
|
|
500
|
-
return _context9.abrupt("return", _context9.sent);
|
|
501
|
-
case 4:
|
|
502
|
-
case "end":
|
|
503
|
-
return _context9.stop();
|
|
504
|
-
}
|
|
505
|
-
}, _callee9, this);
|
|
506
|
-
}));
|
|
507
|
-
function _getManifestWithParams(_x4) {
|
|
508
|
-
return _getManifestWithParams2.apply(this, arguments);
|
|
509
|
-
}
|
|
510
|
-
return _getManifestWithParams;
|
|
511
|
-
}()
|
|
512
499
|
}, {
|
|
513
500
|
key: "_invalidateSettings",
|
|
514
501
|
value: function _invalidateSettings() {
|
|
515
502
|
var _this2 = this;
|
|
516
503
|
this._cache.reset();
|
|
517
|
-
this._getMainCatalog = _.once( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
518
|
-
var services;
|
|
519
|
-
return _regeneratorRuntime().wrap(function
|
|
520
|
-
while (1) switch (
|
|
504
|
+
this._getMainCatalog = _.once( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
505
|
+
var services, version, _version;
|
|
506
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
507
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
521
508
|
case 0:
|
|
522
|
-
if (!_this2._manifestServiceUrl) {
|
|
523
|
-
_context10.next = 7;
|
|
524
|
-
break;
|
|
525
|
-
}
|
|
526
|
-
console.warn("The \"manifestServiceUrl\" parameter is deprecated in v7.6.0.\n Consider using \"tileApiUrl\" and \"fileApiUrl\" instead.");
|
|
527
|
-
_context10.next = 4;
|
|
528
|
-
return _this2._getManifestWithParams(_this2._manifestServiceUrl);
|
|
529
|
-
case 4:
|
|
530
|
-
return _context10.abrupt("return", _context10.sent);
|
|
531
|
-
case 7:
|
|
532
509
|
services = [];
|
|
533
510
|
if (_this2._tileApiUrl) {
|
|
511
|
+
version = _this2._isRestApi ? LATEST_API_URL_PATH : _this2._emsVersion;
|
|
534
512
|
services.push({
|
|
535
513
|
type: 'tms',
|
|
536
|
-
manifest: toAbsoluteUrl(_this2._tileApiUrl, "".concat(
|
|
514
|
+
manifest: toAbsoluteUrl(_this2._tileApiUrl, "".concat(version, "/manifest"))
|
|
537
515
|
});
|
|
538
516
|
}
|
|
539
517
|
if (_this2._fileApiUrl) {
|
|
518
|
+
_version = _this2._isRestApi ? LATEST_API_URL_PATH : _this2._emsVersion;
|
|
540
519
|
services.push({
|
|
541
520
|
type: 'file',
|
|
542
|
-
manifest: toAbsoluteUrl(_this2._fileApiUrl, "".concat(
|
|
521
|
+
manifest: toAbsoluteUrl(_this2._fileApiUrl, "".concat(_version, "/manifest"))
|
|
543
522
|
});
|
|
544
523
|
}
|
|
545
|
-
return
|
|
524
|
+
return _context9.abrupt("return", {
|
|
546
525
|
services: services
|
|
547
526
|
});
|
|
548
|
-
case
|
|
527
|
+
case 4:
|
|
549
528
|
case "end":
|
|
550
|
-
return
|
|
529
|
+
return _context9.stop();
|
|
551
530
|
}
|
|
552
|
-
},
|
|
531
|
+
}, _callee9);
|
|
553
532
|
})));
|
|
554
|
-
this._getDefaultTMSCatalog = _.once( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
533
|
+
this._getDefaultTMSCatalog = _.once( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
555
534
|
var catalogue, firstService, url;
|
|
556
|
-
return _regeneratorRuntime().wrap(function
|
|
557
|
-
while (1) switch (
|
|
535
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
536
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
558
537
|
case 0:
|
|
559
|
-
|
|
538
|
+
_context10.next = 2;
|
|
560
539
|
return _this2._getMainCatalog();
|
|
561
540
|
case 2:
|
|
562
|
-
catalogue =
|
|
541
|
+
catalogue = _context10.sent;
|
|
563
542
|
firstService = catalogue.services.find(function (service) {
|
|
564
543
|
return service.type === 'tms';
|
|
565
544
|
});
|
|
566
545
|
if (firstService) {
|
|
567
|
-
|
|
546
|
+
_context10.next = 6;
|
|
568
547
|
break;
|
|
569
548
|
}
|
|
570
|
-
return
|
|
549
|
+
return _context10.abrupt("return", {
|
|
571
550
|
services: []
|
|
572
551
|
});
|
|
573
552
|
case 6:
|
|
574
553
|
url = _this2._proxyPath + firstService.manifest;
|
|
575
|
-
|
|
554
|
+
_context10.next = 9;
|
|
576
555
|
return _this2.getManifest(url);
|
|
577
556
|
case 9:
|
|
578
|
-
return
|
|
557
|
+
return _context10.abrupt("return", _context10.sent);
|
|
579
558
|
case 10:
|
|
580
559
|
case "end":
|
|
581
|
-
return
|
|
560
|
+
return _context10.stop();
|
|
582
561
|
}
|
|
583
|
-
},
|
|
562
|
+
}, _callee10);
|
|
584
563
|
})));
|
|
585
|
-
this._getDefaultFileCatalog = _.once( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
564
|
+
this._getDefaultFileCatalog = _.once( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
586
565
|
var catalogue, firstService, url;
|
|
587
|
-
return _regeneratorRuntime().wrap(function
|
|
588
|
-
while (1) switch (
|
|
566
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
567
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
589
568
|
case 0:
|
|
590
|
-
|
|
569
|
+
_context11.next = 2;
|
|
591
570
|
return _this2._getMainCatalog();
|
|
592
571
|
case 2:
|
|
593
|
-
catalogue =
|
|
572
|
+
catalogue = _context11.sent;
|
|
594
573
|
firstService = catalogue.services.find(function (service) {
|
|
595
574
|
return service.type === 'file';
|
|
596
575
|
});
|
|
597
576
|
if (firstService) {
|
|
598
|
-
|
|
577
|
+
_context11.next = 6;
|
|
599
578
|
break;
|
|
600
579
|
}
|
|
601
|
-
return
|
|
580
|
+
return _context11.abrupt("return", {
|
|
602
581
|
layers: []
|
|
603
582
|
});
|
|
604
583
|
case 6:
|
|
605
584
|
url = _this2._proxyPath + firstService.manifest;
|
|
606
|
-
|
|
585
|
+
_context11.next = 9;
|
|
607
586
|
return _this2.getManifest(url);
|
|
608
587
|
case 9:
|
|
609
|
-
return
|
|
588
|
+
return _context11.abrupt("return", _context11.sent);
|
|
610
589
|
case 10:
|
|
611
590
|
case "end":
|
|
612
|
-
return
|
|
591
|
+
return _context11.stop();
|
|
613
592
|
}
|
|
614
|
-
},
|
|
593
|
+
}, _callee11);
|
|
615
594
|
})));
|
|
616
595
|
|
|
617
596
|
//Cache the actual instances of TMSService as these in turn cache sub-manifests for the style-files
|
|
618
|
-
this._loadTMSServices = _.once( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
597
|
+
this._loadTMSServices = _.once( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
619
598
|
var tmsManifest;
|
|
620
|
-
return _regeneratorRuntime().wrap(function
|
|
621
|
-
while (1) switch (
|
|
599
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
600
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
622
601
|
case 0:
|
|
623
|
-
|
|
602
|
+
_context12.next = 2;
|
|
624
603
|
return _this2._getDefaultTMSCatalog();
|
|
625
604
|
case 2:
|
|
626
|
-
tmsManifest =
|
|
627
|
-
return
|
|
605
|
+
tmsManifest = _context12.sent;
|
|
606
|
+
return _context12.abrupt("return", tmsManifest.services.map(function (serviceConfig) {
|
|
628
607
|
return new TMSService(serviceConfig, _this2, _this2._proxyPath);
|
|
629
608
|
}));
|
|
630
609
|
case 4:
|
|
631
610
|
case "end":
|
|
632
|
-
return
|
|
611
|
+
return _context12.stop();
|
|
633
612
|
}
|
|
634
|
-
},
|
|
613
|
+
}, _callee12);
|
|
635
614
|
})));
|
|
636
|
-
this._loadFileLayers = _.once( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
615
|
+
this._loadFileLayers = _.once( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
637
616
|
var fileManifest;
|
|
638
|
-
return _regeneratorRuntime().wrap(function
|
|
639
|
-
while (1) switch (
|
|
617
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
618
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
640
619
|
case 0:
|
|
641
|
-
|
|
620
|
+
_context13.next = 2;
|
|
642
621
|
return _this2._getDefaultFileCatalog();
|
|
643
622
|
case 2:
|
|
644
|
-
fileManifest =
|
|
645
|
-
return
|
|
623
|
+
fileManifest = _context13.sent;
|
|
624
|
+
return _context13.abrupt("return", fileManifest.layers.map(function (layerConfig) {
|
|
646
625
|
return new FileLayer(layerConfig, _this2, _this2._proxyPath);
|
|
647
626
|
}));
|
|
648
627
|
case 4:
|
|
649
628
|
case "end":
|
|
650
|
-
return
|
|
629
|
+
return _context13.stop();
|
|
651
630
|
}
|
|
652
|
-
},
|
|
631
|
+
}, _callee13);
|
|
653
632
|
})));
|
|
654
633
|
}
|
|
655
634
|
}]);
|
package/target/web/index.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* 2.0.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
export { EMSClient, FileLayerField } from './ems_client';
|
|
8
|
+
export { EMSClient, FileLayerField, LATEST_API_URL_PATH } from './ems_client';
|
|
9
9
|
export { FileLayer } from './file_layer';
|
|
10
10
|
export { TMSService, EmsSprite, EmsSpriteSheet } from './tms_service';
|
|
11
11
|
export { blendMode } from './utils';
|