@elastic/ems-client 7.15.0 → 8.1.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.
- package/CHANGELOG.md +25 -0
- package/package.json +3 -2
- package/src/ems_client.ts +14 -12
- package/src/file_layer.ts +0 -1
- package/src/index.ts +1 -1
- package/src/tms_service.ts +31 -53
- package/target/index.d.ts +1 -1
- package/target/node/ems_client.js +11 -10
- package/target/node/file_layer.js +1 -2
- package/target/node/index.js +16 -4
- package/target/node/tms_service.js +22 -19
- package/target/tms_service.d.ts +10 -30
- package/target/web/ems_client.js +29 -21
- package/target/web/file_layer.js +1 -2
- package/target/web/index.js +1 -1
- package/target/web/tms_service.js +42 -41
- package/test/ems_client.test.ts +2 -2
- package/api-extractor.json +0 -364
- package/etc/ems-client.api.md +0 -154
- package/target/ems_client.js +0 -443
- package/target/ems_service.js +0 -76
- package/target/file_layer.js +0 -123
- package/target/index.js +0 -28
- package/target/origin.js +0 -24
- package/target/tms_service.js +0 -429
- package/target/tsdoc-metadata.json +0 -11
- package/target/utils.js +0 -42
package/etc/ems-client.api.md
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
## API Report File for "@elastic/ems-client"
|
|
2
|
-
|
|
3
|
-
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
|
4
|
-
|
|
5
|
-
```ts
|
|
6
|
-
|
|
7
|
-
// @public (undocumented)
|
|
8
|
-
export class EMSClient {
|
|
9
|
-
// Warning: (ae-forgotten-export) The symbol "ClientConfig" needs to be exported by the entry point index.d.ts
|
|
10
|
-
// Warning: (ae-forgotten-export) The symbol "DeprecatedClientConfig" needs to be exported by the entry point index.d.ts
|
|
11
|
-
constructor(config: ClientConfig | DeprecatedClientConfig);
|
|
12
|
-
addQueryParams(additionalQueryParams: {
|
|
13
|
-
[key: string]: string;
|
|
14
|
-
}): void;
|
|
15
|
-
// (undocumented)
|
|
16
|
-
readonly EMS_LOAD_TIMEOUT = 32000;
|
|
17
|
-
// (undocumented)
|
|
18
|
-
extendUrlWithParams(url: string): string;
|
|
19
|
-
// (undocumented)
|
|
20
|
-
findFileLayerById(id: string): Promise<FileLayer | undefined>;
|
|
21
|
-
// (undocumented)
|
|
22
|
-
findTMSServiceById(id: string): Promise<TMSService | undefined>;
|
|
23
|
-
// Warning: (ae-forgotten-export) The symbol "EmsFileCatalog" needs to be exported by the entry point index.d.ts
|
|
24
|
-
//
|
|
25
|
-
// (undocumented)
|
|
26
|
-
getDefaultFileManifest(): Promise<EmsFileCatalog>;
|
|
27
|
-
// (undocumented)
|
|
28
|
-
getDefaultLocale(): string;
|
|
29
|
-
// Warning: (ae-forgotten-export) The symbol "EmsTmsCatalog" needs to be exported by the entry point index.d.ts
|
|
30
|
-
//
|
|
31
|
-
// (undocumented)
|
|
32
|
-
getDefaultTMSManifest(): Promise<EmsTmsCatalog>;
|
|
33
|
-
// (undocumented)
|
|
34
|
-
getFileApiUrl(): string;
|
|
35
|
-
// (undocumented)
|
|
36
|
-
getFileLayers(): Promise<FileLayer[]>;
|
|
37
|
-
// (undocumented)
|
|
38
|
-
getLandingPageUrl(): string;
|
|
39
|
-
// (undocumented)
|
|
40
|
-
getLocale(): string;
|
|
41
|
-
// Warning: (ae-forgotten-export) The symbol "EmsCatalogManifest" needs to be exported by the entry point index.d.ts
|
|
42
|
-
//
|
|
43
|
-
// (undocumented)
|
|
44
|
-
getMainManifest(): Promise<EmsCatalogManifest>;
|
|
45
|
-
getManifest<T>(manifestUrl: string): Promise<T>;
|
|
46
|
-
// (undocumented)
|
|
47
|
-
getTileApiUrl(): string;
|
|
48
|
-
// (undocumented)
|
|
49
|
-
getTMSServices(): Promise<TMSService[]>;
|
|
50
|
-
// (undocumented)
|
|
51
|
-
getValueInLanguage(i18nObject: {
|
|
52
|
-
[language: string]: string;
|
|
53
|
-
}): string;
|
|
54
|
-
// (undocumented)
|
|
55
|
-
sanitizeHtml(html: string): string;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Warning: (ae-forgotten-export) The symbol "AbstractEmsService" needs to be exported by the entry point index.d.ts
|
|
59
|
-
//
|
|
60
|
-
// @public (undocumented)
|
|
61
|
-
export class FileLayer extends AbstractEmsService {
|
|
62
|
-
constructor(config: FileLayerConfig, emsClient: EMSClient, proxyPath: string);
|
|
63
|
-
// Warning: (ae-forgotten-export) The symbol "FileLayerConfig" needs to be exported by the entry point index.d.ts
|
|
64
|
-
//
|
|
65
|
-
// (undocumented)
|
|
66
|
-
protected readonly _config: FileLayerConfig;
|
|
67
|
-
// (undocumented)
|
|
68
|
-
getApiUrl(): string;
|
|
69
|
-
// (undocumented)
|
|
70
|
-
getCreatedAt(): string;
|
|
71
|
-
// (undocumented)
|
|
72
|
-
getDefaultFormatMeta(): {
|
|
73
|
-
[key: string]: string;
|
|
74
|
-
} | undefined;
|
|
75
|
-
// (undocumented)
|
|
76
|
-
getDefaultFormatType(): string;
|
|
77
|
-
// (undocumented)
|
|
78
|
-
getDefaultFormatUrl(): string;
|
|
79
|
-
// (undocumented)
|
|
80
|
-
getDisplayName(): string;
|
|
81
|
-
// (undocumented)
|
|
82
|
-
getEMSHotLink(): string;
|
|
83
|
-
// (undocumented)
|
|
84
|
-
getFields(): FileLayerConfig['fields'];
|
|
85
|
-
// (undocumented)
|
|
86
|
-
getFieldsInLanguage(): {
|
|
87
|
-
type: string;
|
|
88
|
-
name: string;
|
|
89
|
-
description: string;
|
|
90
|
-
}[];
|
|
91
|
-
// (undocumented)
|
|
92
|
-
getId(): string;
|
|
93
|
-
// (undocumented)
|
|
94
|
-
hasId(id: string): boolean;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// @public (undocumented)
|
|
98
|
-
export const ORIGIN: {
|
|
99
|
-
EMS: string;
|
|
100
|
-
KIBANA_YML: string;
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
// @public (undocumented)
|
|
104
|
-
export class TMSService extends AbstractEmsService {
|
|
105
|
-
constructor(config: TMSServiceConfig, emsClient: EMSClient, proxyPath: string);
|
|
106
|
-
// Warning: (ae-forgotten-export) The symbol "TMSServiceConfig" needs to be exported by the entry point index.d.ts
|
|
107
|
-
//
|
|
108
|
-
// (undocumented)
|
|
109
|
-
protected readonly _config: TMSServiceConfig;
|
|
110
|
-
// (undocumented)
|
|
111
|
-
getApiUrl(): string;
|
|
112
|
-
// Warning: (ae-forgotten-export) The symbol "EmsRasterStyle" needs to be exported by the entry point index.d.ts
|
|
113
|
-
//
|
|
114
|
-
// (undocumented)
|
|
115
|
-
getDefaultRasterStyle(): Promise<EmsRasterStyle | undefined>;
|
|
116
|
-
// (undocumented)
|
|
117
|
-
getDisplayName(): string;
|
|
118
|
-
// (undocumented)
|
|
119
|
-
getId(): string;
|
|
120
|
-
// (undocumented)
|
|
121
|
-
getMaxZoom(): Promise<number | undefined>;
|
|
122
|
-
// (undocumented)
|
|
123
|
-
getMinZoom(): Promise<number | undefined>;
|
|
124
|
-
// (undocumented)
|
|
125
|
-
getSpriteSheetJsonPath(isRetina?: boolean): Promise<string>;
|
|
126
|
-
// (undocumented)
|
|
127
|
-
getSpriteSheetMeta(isRetina?: boolean): Promise<{
|
|
128
|
-
png: string;
|
|
129
|
-
json: EmsSpriteSheet;
|
|
130
|
-
} | undefined>;
|
|
131
|
-
// (undocumented)
|
|
132
|
-
getSpriteSheetPngPath(isRetina?: boolean): Promise<string>;
|
|
133
|
-
// (undocumented)
|
|
134
|
-
getUrlTemplate(): Promise<string>;
|
|
135
|
-
// (undocumented)
|
|
136
|
-
getUrlTemplateForVector(sourceId: string): Promise<string>;
|
|
137
|
-
// Warning: (ae-forgotten-export) The symbol "EmsVectorStyle" needs to be exported by the entry point index.d.ts
|
|
138
|
-
//
|
|
139
|
-
// (undocumented)
|
|
140
|
-
getVectorStyleSheet(): Promise<EmsVectorStyle | undefined>;
|
|
141
|
-
// (undocumented)
|
|
142
|
-
getVectorStyleSheetRaw(): Promise<EmsVectorStyle | undefined>;
|
|
143
|
-
// (undocumented)
|
|
144
|
-
hasId(id: string): boolean;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
// Warnings were encountered during analysis:
|
|
149
|
-
//
|
|
150
|
-
// target/tms_service.d.ts:66:9 - (ae-forgotten-export) The symbol "EmsSpriteSheet" needs to be exported by the entry point index.d.ts
|
|
151
|
-
|
|
152
|
-
// (No @packageDocumentation comment for this package)
|
|
153
|
-
|
|
154
|
-
```
|
package/target/ems_client.js
DELETED
|
@@ -1,443 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Licensed to Elasticsearch B.V. under one or more contributor
|
|
4
|
-
* license agreements. See the NOTICE file distributed with
|
|
5
|
-
* this work for additional information regarding copyright
|
|
6
|
-
* ownership. Elasticsearch B.V. licenses this file to you under
|
|
7
|
-
* the Apache License, Version 2.0 (the "License"); you may
|
|
8
|
-
* not use this file except in compliance with the License.
|
|
9
|
-
* You may obtain a copy of the License at
|
|
10
|
-
*
|
|
11
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
*
|
|
13
|
-
* Unless required by applicable law or agreed to in writing,
|
|
14
|
-
* software distributed under the License is distributed on an
|
|
15
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
16
|
-
* KIND, either express or implied. See the License for the
|
|
17
|
-
* specific language governing permissions and limitations
|
|
18
|
-
* under the License.
|
|
19
|
-
*/
|
|
20
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
21
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
22
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
23
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
24
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
25
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
26
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
30
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
31
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
32
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
33
|
-
function step(op) {
|
|
34
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
35
|
-
while (_) try {
|
|
36
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
37
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
38
|
-
switch (op[0]) {
|
|
39
|
-
case 0: case 1: t = op; break;
|
|
40
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
41
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
42
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
43
|
-
default:
|
|
44
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
45
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
46
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
47
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
48
|
-
if (t[2]) _.ops.pop();
|
|
49
|
-
_.trys.pop(); continue;
|
|
50
|
-
}
|
|
51
|
-
op = body.call(thisArg, _);
|
|
52
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
53
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
57
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
58
|
-
};
|
|
59
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
60
|
-
var lodash_1 = __importDefault(require("lodash"));
|
|
61
|
-
var tms_service_1 = require("./tms_service");
|
|
62
|
-
var file_layer_1 = require("./file_layer");
|
|
63
|
-
var semver_1 = __importDefault(require("semver"));
|
|
64
|
-
var url_1 = require("url");
|
|
65
|
-
var utils_1 = require("./utils");
|
|
66
|
-
var DEFAULT_EMS_VERSION = '7.9';
|
|
67
|
-
/**
|
|
68
|
-
* plugins cannot have upstream dependencies on core/*-kibana.
|
|
69
|
-
* Work-around by copy-pasting modifyUrl routine here.
|
|
70
|
-
* @param url
|
|
71
|
-
* @param block
|
|
72
|
-
*/
|
|
73
|
-
function modifyUrlLocal(url, block) {
|
|
74
|
-
var parsed = url_1.parse(url, true);
|
|
75
|
-
// copy over the most specific version of each
|
|
76
|
-
// property. By default, the parsed url includes
|
|
77
|
-
// several conflicting properties (like path and
|
|
78
|
-
// pathname + search, or search and query) and keeping
|
|
79
|
-
// track of which property is actually used when they
|
|
80
|
-
// are formatted is harder than necessary
|
|
81
|
-
var meaningfulParts = {
|
|
82
|
-
protocol: parsed.protocol,
|
|
83
|
-
slashes: parsed.slashes,
|
|
84
|
-
auth: parsed.auth,
|
|
85
|
-
hostname: parsed.hostname,
|
|
86
|
-
port: parsed.port,
|
|
87
|
-
pathname: parsed.pathname,
|
|
88
|
-
query: parsed.query || {},
|
|
89
|
-
hash: parsed.hash,
|
|
90
|
-
};
|
|
91
|
-
// the block modifies the meaningfulParts object, or returns a new one
|
|
92
|
-
var modifiedParts = block(meaningfulParts) || meaningfulParts;
|
|
93
|
-
// format the modified/replaced meaningfulParts back into a url
|
|
94
|
-
return url_1.format({
|
|
95
|
-
protocol: modifiedParts.protocol,
|
|
96
|
-
slashes: modifiedParts.slashes,
|
|
97
|
-
auth: modifiedParts.auth,
|
|
98
|
-
hostname: modifiedParts.hostname,
|
|
99
|
-
port: modifiedParts.port,
|
|
100
|
-
pathname: modifiedParts.pathname,
|
|
101
|
-
query: modifiedParts.query,
|
|
102
|
-
hash: modifiedParts.hash,
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
var extendUrl = function (url, props) {
|
|
106
|
-
return modifyUrlLocal(url, function (parsed) { return lodash_1.default.merge(parsed, props); });
|
|
107
|
-
};
|
|
108
|
-
/**
|
|
109
|
-
* Unescape a url template that was escaped by encodeURI() so leaflet
|
|
110
|
-
* will be able to correctly locate the variables in the template
|
|
111
|
-
* @param {String} url
|
|
112
|
-
* @return {String}
|
|
113
|
-
*/
|
|
114
|
-
var unescapeTemplateVars = function (url) {
|
|
115
|
-
var ENCODED_TEMPLATE_VARS_RE = /%7B(\w+?)%7D/g;
|
|
116
|
-
return url.replace(ENCODED_TEMPLATE_VARS_RE, function (total, varName) { return "{" + varName + "}"; });
|
|
117
|
-
};
|
|
118
|
-
//this is not the default locale from Kibana, but the default locale supported by the Elastic Maps Service
|
|
119
|
-
var DEFAULT_LANGUAGE = 'en';
|
|
120
|
-
var EMSClient = /** @class */ (function () {
|
|
121
|
-
function EMSClient(config) {
|
|
122
|
-
this.EMS_LOAD_TIMEOUT = 32000;
|
|
123
|
-
// Remove kbnVersion in 8.0
|
|
124
|
-
if ('kbnVersion' in config) {
|
|
125
|
-
console.warn('The "kbnVersion" parameter for ems-client is deprecated. Please use "appVersion" instead.');
|
|
126
|
-
this._appVersion = config.kbnVersion;
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
this._appVersion = config.appVersion;
|
|
130
|
-
}
|
|
131
|
-
this._queryParams = {
|
|
132
|
-
elastic_tile_service_tos: 'agree',
|
|
133
|
-
my_app_name: config.appName || 'kibana',
|
|
134
|
-
my_app_version: this._appVersion,
|
|
135
|
-
};
|
|
136
|
-
this._sanitizer = config.htmlSanitizer ? config.htmlSanitizer : function (x) { return x; };
|
|
137
|
-
this._manifestServiceUrl = config.manifestServiceUrl;
|
|
138
|
-
this._tileApiUrl = config.tileApiUrl;
|
|
139
|
-
this._fileApiUrl = config.fileApiUrl;
|
|
140
|
-
this._emsVersion = this._getEmsVersion(config.emsVersion);
|
|
141
|
-
this._emsLandingPageUrl = config.landingPageUrl || '';
|
|
142
|
-
this._language = config.language || DEFAULT_LANGUAGE;
|
|
143
|
-
this._fetchFunction = config.fetchFunction;
|
|
144
|
-
this._proxyPath = config.proxyPath || '';
|
|
145
|
-
this._invalidateSettings();
|
|
146
|
-
}
|
|
147
|
-
EMSClient.prototype.getDefaultLocale = function () {
|
|
148
|
-
return DEFAULT_LANGUAGE;
|
|
149
|
-
};
|
|
150
|
-
EMSClient.prototype.getLocale = function () {
|
|
151
|
-
return this._language;
|
|
152
|
-
};
|
|
153
|
-
EMSClient.prototype.getValueInLanguage = function (i18nObject) {
|
|
154
|
-
if (!i18nObject) {
|
|
155
|
-
return '';
|
|
156
|
-
}
|
|
157
|
-
return i18nObject[this._language] ? i18nObject[this._language] : i18nObject[DEFAULT_LANGUAGE];
|
|
158
|
-
};
|
|
159
|
-
/**
|
|
160
|
-
* this internal method is overridden by the tests to simulate custom manifest.
|
|
161
|
-
*/
|
|
162
|
-
EMSClient.prototype.getManifest = function (manifestUrl) {
|
|
163
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
164
|
-
var url, result, _a, e_1;
|
|
165
|
-
return __generator(this, function (_b) {
|
|
166
|
-
switch (_b.label) {
|
|
167
|
-
case 0:
|
|
168
|
-
_b.trys.push([0, 5, , 6]);
|
|
169
|
-
url = extendUrl(manifestUrl, { query: this._queryParams });
|
|
170
|
-
return [4 /*yield*/, this._fetchWithTimeout(url)];
|
|
171
|
-
case 1:
|
|
172
|
-
result = _b.sent();
|
|
173
|
-
if (!result) return [3 /*break*/, 3];
|
|
174
|
-
return [4 /*yield*/, result.json()];
|
|
175
|
-
case 2:
|
|
176
|
-
_a = _b.sent();
|
|
177
|
-
return [3 /*break*/, 4];
|
|
178
|
-
case 3:
|
|
179
|
-
_a = null;
|
|
180
|
-
_b.label = 4;
|
|
181
|
-
case 4: return [2 /*return*/, _a];
|
|
182
|
-
case 5:
|
|
183
|
-
e_1 = _b.sent();
|
|
184
|
-
if (!e_1) {
|
|
185
|
-
e_1 = new Error('Unknown error');
|
|
186
|
-
}
|
|
187
|
-
if (!(e_1 instanceof Error)) {
|
|
188
|
-
e_1 = new Error(e_1.data || "status " + (e_1.statusText || e_1.status));
|
|
189
|
-
}
|
|
190
|
-
throw new Error("Unable to retrieve manifest from " + manifestUrl + ": " + e_1.message);
|
|
191
|
-
case 6: return [2 /*return*/];
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
});
|
|
195
|
-
};
|
|
196
|
-
/**
|
|
197
|
-
* Add optional query-parameters to all requests
|
|
198
|
-
*
|
|
199
|
-
* @param additionalQueryParams
|
|
200
|
-
*/
|
|
201
|
-
EMSClient.prototype.addQueryParams = function (additionalQueryParams) {
|
|
202
|
-
for (var key in additionalQueryParams) {
|
|
203
|
-
if (additionalQueryParams.hasOwnProperty(key)) {
|
|
204
|
-
if (additionalQueryParams[key] !== this._queryParams[key]) {
|
|
205
|
-
//changes detected.
|
|
206
|
-
this._queryParams = lodash_1.default.assign({}, this._queryParams, additionalQueryParams);
|
|
207
|
-
this._invalidateSettings();
|
|
208
|
-
break;
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
};
|
|
213
|
-
EMSClient.prototype.getMainManifest = function () {
|
|
214
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
215
|
-
return __generator(this, function (_a) {
|
|
216
|
-
switch (_a.label) {
|
|
217
|
-
case 0: return [4 /*yield*/, this._getMainCatalog()];
|
|
218
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
219
|
-
}
|
|
220
|
-
});
|
|
221
|
-
});
|
|
222
|
-
};
|
|
223
|
-
EMSClient.prototype.getDefaultFileManifest = function () {
|
|
224
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
225
|
-
return __generator(this, function (_a) {
|
|
226
|
-
switch (_a.label) {
|
|
227
|
-
case 0: return [4 /*yield*/, this._getDefaultFileCatalog()];
|
|
228
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
229
|
-
}
|
|
230
|
-
});
|
|
231
|
-
});
|
|
232
|
-
};
|
|
233
|
-
EMSClient.prototype.getDefaultTMSManifest = function () {
|
|
234
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
235
|
-
return __generator(this, function (_a) {
|
|
236
|
-
switch (_a.label) {
|
|
237
|
-
case 0: return [4 /*yield*/, this._getDefaultTMSCatalog()];
|
|
238
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
239
|
-
}
|
|
240
|
-
});
|
|
241
|
-
});
|
|
242
|
-
};
|
|
243
|
-
EMSClient.prototype.getFileLayers = function () {
|
|
244
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
245
|
-
return __generator(this, function (_a) {
|
|
246
|
-
switch (_a.label) {
|
|
247
|
-
case 0: return [4 /*yield*/, this._loadFileLayers()];
|
|
248
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
});
|
|
252
|
-
};
|
|
253
|
-
EMSClient.prototype.getTMSServices = function () {
|
|
254
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
255
|
-
return __generator(this, function (_a) {
|
|
256
|
-
switch (_a.label) {
|
|
257
|
-
case 0: return [4 /*yield*/, this._loadTMSServices()];
|
|
258
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
259
|
-
}
|
|
260
|
-
});
|
|
261
|
-
});
|
|
262
|
-
};
|
|
263
|
-
EMSClient.prototype.getTileApiUrl = function () {
|
|
264
|
-
return this._tileApiUrl;
|
|
265
|
-
};
|
|
266
|
-
EMSClient.prototype.getFileApiUrl = function () {
|
|
267
|
-
return this._fileApiUrl;
|
|
268
|
-
};
|
|
269
|
-
EMSClient.prototype.getLandingPageUrl = function () {
|
|
270
|
-
return this._emsLandingPageUrl;
|
|
271
|
-
};
|
|
272
|
-
EMSClient.prototype.sanitizeHtml = function (html) {
|
|
273
|
-
return this._sanitizer(html);
|
|
274
|
-
};
|
|
275
|
-
EMSClient.prototype.extendUrlWithParams = function (url) {
|
|
276
|
-
return unescapeTemplateVars(extendUrl(url, {
|
|
277
|
-
query: this._queryParams,
|
|
278
|
-
}));
|
|
279
|
-
};
|
|
280
|
-
EMSClient.prototype.findFileLayerById = function (id) {
|
|
281
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
282
|
-
var fileLayers, i;
|
|
283
|
-
return __generator(this, function (_a) {
|
|
284
|
-
switch (_a.label) {
|
|
285
|
-
case 0: return [4 /*yield*/, this.getFileLayers()];
|
|
286
|
-
case 1:
|
|
287
|
-
fileLayers = _a.sent();
|
|
288
|
-
for (i = 0; i < fileLayers.length; i++) {
|
|
289
|
-
if (fileLayers[i].hasId(id)) {
|
|
290
|
-
return [2 /*return*/, fileLayers[i]];
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
return [2 /*return*/];
|
|
294
|
-
}
|
|
295
|
-
});
|
|
296
|
-
});
|
|
297
|
-
};
|
|
298
|
-
EMSClient.prototype.findTMSServiceById = function (id) {
|
|
299
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
300
|
-
var tmsServices, i;
|
|
301
|
-
return __generator(this, function (_a) {
|
|
302
|
-
switch (_a.label) {
|
|
303
|
-
case 0: return [4 /*yield*/, this.getTMSServices()];
|
|
304
|
-
case 1:
|
|
305
|
-
tmsServices = _a.sent();
|
|
306
|
-
for (i = 0; i < tmsServices.length; i++) {
|
|
307
|
-
if (tmsServices[i].hasId(id)) {
|
|
308
|
-
return [2 /*return*/, tmsServices[i]];
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
return [2 /*return*/];
|
|
312
|
-
}
|
|
313
|
-
});
|
|
314
|
-
});
|
|
315
|
-
};
|
|
316
|
-
EMSClient.prototype._getEmsVersion = function (version) {
|
|
317
|
-
var userVersion = semver_1.default.valid(semver_1.default.coerce(version));
|
|
318
|
-
var semverVersion = userVersion ? userVersion : semver_1.default.coerce(DEFAULT_EMS_VERSION);
|
|
319
|
-
if (semverVersion) {
|
|
320
|
-
return "v" + semver_1.default.major(semverVersion) + "." + semver_1.default.minor(semverVersion);
|
|
321
|
-
}
|
|
322
|
-
else {
|
|
323
|
-
throw new Error("Invalid version: " + version);
|
|
324
|
-
}
|
|
325
|
-
};
|
|
326
|
-
EMSClient.prototype._fetchWithTimeout = function (url) {
|
|
327
|
-
var _this = this;
|
|
328
|
-
return new Promise(function (resolve, reject) {
|
|
329
|
-
var timer = setTimeout(function () { return reject(new Error("Request to " + url + " timed out")); }, _this.EMS_LOAD_TIMEOUT);
|
|
330
|
-
_this._fetchFunction(url).then(function (response) {
|
|
331
|
-
clearTimeout(timer);
|
|
332
|
-
resolve(response);
|
|
333
|
-
}, function (err) {
|
|
334
|
-
clearTimeout(timer);
|
|
335
|
-
reject(err);
|
|
336
|
-
});
|
|
337
|
-
});
|
|
338
|
-
};
|
|
339
|
-
EMSClient.prototype._getManifestWithParams = function (url) {
|
|
340
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
341
|
-
var extendedUrl;
|
|
342
|
-
return __generator(this, function (_a) {
|
|
343
|
-
switch (_a.label) {
|
|
344
|
-
case 0:
|
|
345
|
-
extendedUrl = this.extendUrlWithParams(url);
|
|
346
|
-
return [4 /*yield*/, this.getManifest(extendedUrl)];
|
|
347
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
348
|
-
}
|
|
349
|
-
});
|
|
350
|
-
});
|
|
351
|
-
};
|
|
352
|
-
EMSClient.prototype._invalidateSettings = function () {
|
|
353
|
-
var _this = this;
|
|
354
|
-
this._getMainCatalog = lodash_1.default.once(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
355
|
-
var services;
|
|
356
|
-
return __generator(this, function (_a) {
|
|
357
|
-
switch (_a.label) {
|
|
358
|
-
case 0:
|
|
359
|
-
if (!this._manifestServiceUrl) return [3 /*break*/, 2];
|
|
360
|
-
console.warn("The \"manifestServiceUrl\" parameter is deprecated in v7.6.0.\n Consider using \"tileApiUrl\" and \"fileApiUrl\" instead.");
|
|
361
|
-
return [4 /*yield*/, this._getManifestWithParams(this._manifestServiceUrl)];
|
|
362
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
363
|
-
case 2:
|
|
364
|
-
services = [];
|
|
365
|
-
if (this._tileApiUrl) {
|
|
366
|
-
services.push({
|
|
367
|
-
type: 'tms',
|
|
368
|
-
manifest: utils_1.toAbsoluteUrl(this._tileApiUrl, this._emsVersion + "/manifest"),
|
|
369
|
-
});
|
|
370
|
-
}
|
|
371
|
-
if (this._fileApiUrl) {
|
|
372
|
-
services.push({
|
|
373
|
-
type: 'file',
|
|
374
|
-
manifest: utils_1.toAbsoluteUrl(this._fileApiUrl, this._emsVersion + "/manifest"),
|
|
375
|
-
});
|
|
376
|
-
}
|
|
377
|
-
return [2 /*return*/, { services: services }];
|
|
378
|
-
}
|
|
379
|
-
});
|
|
380
|
-
}); });
|
|
381
|
-
this._getDefaultTMSCatalog = lodash_1.default.once(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
382
|
-
var catalogue, firstService, url;
|
|
383
|
-
return __generator(this, function (_a) {
|
|
384
|
-
switch (_a.label) {
|
|
385
|
-
case 0: return [4 /*yield*/, this._getMainCatalog()];
|
|
386
|
-
case 1:
|
|
387
|
-
catalogue = _a.sent();
|
|
388
|
-
firstService = catalogue.services.find(function (service) { return service.type === 'tms'; });
|
|
389
|
-
if (!firstService) {
|
|
390
|
-
return [2 /*return*/, { services: [] }];
|
|
391
|
-
}
|
|
392
|
-
url = this._proxyPath + firstService.manifest;
|
|
393
|
-
return [4 /*yield*/, this.getManifest(url)];
|
|
394
|
-
case 2: return [2 /*return*/, _a.sent()];
|
|
395
|
-
}
|
|
396
|
-
});
|
|
397
|
-
}); });
|
|
398
|
-
this._getDefaultFileCatalog = lodash_1.default.once(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
399
|
-
var catalogue, firstService, url;
|
|
400
|
-
return __generator(this, function (_a) {
|
|
401
|
-
switch (_a.label) {
|
|
402
|
-
case 0: return [4 /*yield*/, this._getMainCatalog()];
|
|
403
|
-
case 1:
|
|
404
|
-
catalogue = _a.sent();
|
|
405
|
-
firstService = catalogue.services.find(function (service) { return service.type === 'file'; });
|
|
406
|
-
if (!firstService) {
|
|
407
|
-
return [2 /*return*/, { layers: [] }];
|
|
408
|
-
}
|
|
409
|
-
url = this._proxyPath + firstService.manifest;
|
|
410
|
-
return [4 /*yield*/, this.getManifest(url)];
|
|
411
|
-
case 2: return [2 /*return*/, _a.sent()];
|
|
412
|
-
}
|
|
413
|
-
});
|
|
414
|
-
}); });
|
|
415
|
-
//Cache the actual instances of TMSService as these in turn cache sub-manifests for the style-files
|
|
416
|
-
this._loadTMSServices = lodash_1.default.once(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
417
|
-
var tmsManifest;
|
|
418
|
-
var _this = this;
|
|
419
|
-
return __generator(this, function (_a) {
|
|
420
|
-
switch (_a.label) {
|
|
421
|
-
case 0: return [4 /*yield*/, this._getDefaultTMSCatalog()];
|
|
422
|
-
case 1:
|
|
423
|
-
tmsManifest = _a.sent();
|
|
424
|
-
return [2 /*return*/, tmsManifest.services.map(function (serviceConfig) { return new tms_service_1.TMSService(serviceConfig, _this, _this._proxyPath); })];
|
|
425
|
-
}
|
|
426
|
-
});
|
|
427
|
-
}); });
|
|
428
|
-
this._loadFileLayers = lodash_1.default.once(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
429
|
-
var fileManifest;
|
|
430
|
-
var _this = this;
|
|
431
|
-
return __generator(this, function (_a) {
|
|
432
|
-
switch (_a.label) {
|
|
433
|
-
case 0: return [4 /*yield*/, this._getDefaultFileCatalog()];
|
|
434
|
-
case 1:
|
|
435
|
-
fileManifest = _a.sent();
|
|
436
|
-
return [2 /*return*/, fileManifest.layers.map(function (layerConfig) { return new file_layer_1.FileLayer(layerConfig, _this, _this._proxyPath); })];
|
|
437
|
-
}
|
|
438
|
-
});
|
|
439
|
-
}); });
|
|
440
|
-
};
|
|
441
|
-
return EMSClient;
|
|
442
|
-
}());
|
|
443
|
-
exports.EMSClient = EMSClient;
|
package/target/ems_service.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Licensed to Elasticsearch B.V. under one or more contributor
|
|
4
|
-
* license agreements. See the NOTICE file distributed with
|
|
5
|
-
* this work for additional information regarding copyright
|
|
6
|
-
* ownership. Elasticsearch B.V. licenses this file to you under
|
|
7
|
-
* the Apache License, Version 2.0 (the "License"); you may
|
|
8
|
-
* not use this file except in compliance with the License.
|
|
9
|
-
* You may obtain a copy of the License at
|
|
10
|
-
*
|
|
11
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
*
|
|
13
|
-
* Unless required by applicable law or agreed to in writing,
|
|
14
|
-
* software distributed under the License is distributed on an
|
|
15
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
16
|
-
* KIND, either express or implied. See the License for the
|
|
17
|
-
* specific language governing permissions and limitations
|
|
18
|
-
* under the License.
|
|
19
|
-
*/
|
|
20
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
var origin_1 = require("./origin");
|
|
22
|
-
var utils_1 = require("./utils");
|
|
23
|
-
var AbstractEmsService = /** @class */ (function () {
|
|
24
|
-
function AbstractEmsService(config, emsClient, proxyPath) {
|
|
25
|
-
var _this = this;
|
|
26
|
-
/**
|
|
27
|
-
* Checks if url is absolute. If not, prepend the basePath.
|
|
28
|
-
*/
|
|
29
|
-
this._getAbsoluteUrl = function (url) {
|
|
30
|
-
if (/^https?:\/\//.test(url)) {
|
|
31
|
-
return url;
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
return utils_1.toAbsoluteUrl(_this.getApiUrl(), url);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
this._config = config;
|
|
38
|
-
this._emsClient = emsClient;
|
|
39
|
-
this._proxyPath = proxyPath;
|
|
40
|
-
}
|
|
41
|
-
AbstractEmsService.prototype.getAttributions = function () {
|
|
42
|
-
var _this = this;
|
|
43
|
-
return this._config.attribution.map(function (attribution) {
|
|
44
|
-
var url = _this._emsClient.getValueInLanguage(attribution.url);
|
|
45
|
-
var label = _this._emsClient.getValueInLanguage(attribution.label);
|
|
46
|
-
return {
|
|
47
|
-
url: url,
|
|
48
|
-
label: label,
|
|
49
|
-
};
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
AbstractEmsService.prototype.getHTMLAttribution = function () {
|
|
53
|
-
var _this = this;
|
|
54
|
-
var attributions = this._config.attribution.map(function (attribution) {
|
|
55
|
-
var url = _this._emsClient.getValueInLanguage(attribution.url);
|
|
56
|
-
var label = _this._emsClient.getValueInLanguage(attribution.label);
|
|
57
|
-
var html = url ? "<a rel=\"noreferrer noopener\" href=\"" + url + "\">" + label + "</a>" : label;
|
|
58
|
-
return _this._emsClient.sanitizeHtml(html);
|
|
59
|
-
});
|
|
60
|
-
return attributions.join(' | '); //!!!this is the current convention used in Kibana
|
|
61
|
-
};
|
|
62
|
-
AbstractEmsService.prototype.getMarkdownAttribution = function () {
|
|
63
|
-
var _this = this;
|
|
64
|
-
var attributions = this._config.attribution.map(function (attribution) {
|
|
65
|
-
var url = _this._emsClient.getValueInLanguage(attribution.url);
|
|
66
|
-
var label = _this._emsClient.getValueInLanguage(attribution.label);
|
|
67
|
-
return "[" + label + "](" + url + ")";
|
|
68
|
-
});
|
|
69
|
-
return attributions.join('|');
|
|
70
|
-
};
|
|
71
|
-
AbstractEmsService.prototype.getOrigin = function () {
|
|
72
|
-
return origin_1.ORIGIN.EMS;
|
|
73
|
-
};
|
|
74
|
-
return AbstractEmsService;
|
|
75
|
-
}());
|
|
76
|
-
exports.AbstractEmsService = AbstractEmsService;
|