@elastic/ems-client 7.15.1 → 7.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.backportrc.json +13 -2
- package/.buildkite/build.sh +16 -0
- package/.buildkite/pipeline.yml +8 -0
- package/.buildkite/pull-requests.json +30 -0
- package/.nvmrc +1 -0
- package/CHANGELOG.md +16 -0
- package/catalog-info.yaml +68 -0
- package/package.json +8 -5
- package/src/ems_client.ts +14 -12
- package/src/file_layer.ts +0 -1
- package/target/node/ems_client.js +33 -100
- package/target/node/ems_service.js +11 -23
- package/target/node/file_layer.js +18 -64
- package/target/node/index.js +6 -10
- package/target/node/origin.js +3 -4
- package/target/node/tms_service.js +16 -64
- package/target/node/utils.js +0 -3
- package/target/web/ems_client.js +300 -432
- package/target/web/ems_service.js +10 -26
- package/target/web/file_layer.js +62 -118
- package/target/web/index.js +1 -0
- package/target/web/origin.js +1 -0
- package/target/web/tms_service.js +367 -540
- package/target/web/utils.js +0 -2
- package/.ci/jobs/defaults.yml +0 -67
- package/.ci/jobs/elastic+ems-client+master.yml +0 -18
- package/.ci/jobs/elastic+ems-client+pull-request.yml +0 -18
- 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/target/file_layer.js
DELETED
|
@@ -1,123 +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 __extends = (this && this.__extends) || (function () {
|
|
21
|
-
var extendStatics = function (d, b) {
|
|
22
|
-
extendStatics = Object.setPrototypeOf ||
|
|
23
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
24
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
25
|
-
return extendStatics(d, b);
|
|
26
|
-
};
|
|
27
|
-
return function (d, b) {
|
|
28
|
-
extendStatics(d, b);
|
|
29
|
-
function __() { this.constructor = d; }
|
|
30
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
31
|
-
};
|
|
32
|
-
})();
|
|
33
|
-
var __assign = (this && this.__assign) || function () {
|
|
34
|
-
__assign = Object.assign || function(t) {
|
|
35
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
36
|
-
s = arguments[i];
|
|
37
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
38
|
-
t[p] = s[p];
|
|
39
|
-
}
|
|
40
|
-
return t;
|
|
41
|
-
};
|
|
42
|
-
return __assign.apply(this, arguments);
|
|
43
|
-
};
|
|
44
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
45
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
46
|
-
};
|
|
47
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
-
var url_1 = __importDefault(require("url"));
|
|
49
|
-
var ems_service_1 = require("./ems_service");
|
|
50
|
-
var FileLayer = /** @class */ (function (_super) {
|
|
51
|
-
__extends(FileLayer, _super);
|
|
52
|
-
function FileLayer(config, emsClient, proxyPath) {
|
|
53
|
-
var _this = _super.call(this, config, emsClient, proxyPath) || this;
|
|
54
|
-
_this._config = config;
|
|
55
|
-
return _this;
|
|
56
|
-
}
|
|
57
|
-
FileLayer.prototype.getFields = function () {
|
|
58
|
-
return this._config.fields;
|
|
59
|
-
};
|
|
60
|
-
FileLayer.prototype.getFieldsInLanguage = function () {
|
|
61
|
-
var _this = this;
|
|
62
|
-
return this.getFields().map(function (field) {
|
|
63
|
-
return {
|
|
64
|
-
type: field.type,
|
|
65
|
-
name: field.id,
|
|
66
|
-
description: _this._emsClient.getValueInLanguage(field.label),
|
|
67
|
-
};
|
|
68
|
-
});
|
|
69
|
-
};
|
|
70
|
-
FileLayer.prototype.getDisplayName = function () {
|
|
71
|
-
var layerName = this._emsClient.getValueInLanguage(this._config.layer_name);
|
|
72
|
-
return layerName ? layerName : '';
|
|
73
|
-
};
|
|
74
|
-
FileLayer.prototype.getId = function () {
|
|
75
|
-
return this._config.layer_id;
|
|
76
|
-
};
|
|
77
|
-
FileLayer.prototype.hasId = function (id) {
|
|
78
|
-
var matchesLegacyId = this._config.legacy_ids.indexOf(id) >= 0;
|
|
79
|
-
return this._config.layer_id === id || matchesLegacyId;
|
|
80
|
-
};
|
|
81
|
-
FileLayer.prototype.getEMSHotLink = function () {
|
|
82
|
-
var landingPageString = this._emsClient.getLandingPageUrl();
|
|
83
|
-
var urlObject = url_1.default.parse(landingPageString, true);
|
|
84
|
-
urlObject.hash = "file/" + this.getId();
|
|
85
|
-
urlObject.query = __assign(__assign({}, urlObject.query), { locale: this._emsClient.getLocale() });
|
|
86
|
-
return url_1.default.format(urlObject);
|
|
87
|
-
};
|
|
88
|
-
FileLayer.prototype.getDefaultFormatType = function () {
|
|
89
|
-
var format = this._getDefaultFormat();
|
|
90
|
-
return format.type;
|
|
91
|
-
};
|
|
92
|
-
FileLayer.prototype.getDefaultFormatMeta = function () {
|
|
93
|
-
var format = this._getDefaultFormat();
|
|
94
|
-
if ('meta' in format) {
|
|
95
|
-
return format.meta;
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
FileLayer.prototype.getDefaultFormatUrl = function () {
|
|
102
|
-
var format = this._getDefaultFormat();
|
|
103
|
-
var url = this._proxyPath + this._getAbsoluteUrl(format.url);
|
|
104
|
-
return this._emsClient.extendUrlWithParams(url);
|
|
105
|
-
};
|
|
106
|
-
FileLayer.prototype.getCreatedAt = function () {
|
|
107
|
-
return this._config.created_at;
|
|
108
|
-
};
|
|
109
|
-
FileLayer.prototype.getApiUrl = function () {
|
|
110
|
-
return this._emsClient.getFileApiUrl();
|
|
111
|
-
};
|
|
112
|
-
FileLayer.prototype._getDefaultFormat = function () {
|
|
113
|
-
var defaultFormat = this._config.formats.find(function (format) {
|
|
114
|
-
return format.legacy_default;
|
|
115
|
-
});
|
|
116
|
-
if (defaultFormat) {
|
|
117
|
-
return defaultFormat;
|
|
118
|
-
}
|
|
119
|
-
return this._config.formats[0];
|
|
120
|
-
};
|
|
121
|
-
return FileLayer;
|
|
122
|
-
}(ems_service_1.AbstractEmsService));
|
|
123
|
-
exports.FileLayer = FileLayer;
|
package/target/index.js
DELETED
|
@@ -1,28 +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 ems_client_1 = require("./ems_client");
|
|
22
|
-
exports.EMSClient = ems_client_1.EMSClient;
|
|
23
|
-
var origin_1 = require("./origin");
|
|
24
|
-
exports.ORIGIN = origin_1.ORIGIN;
|
|
25
|
-
var file_layer_1 = require("./file_layer");
|
|
26
|
-
exports.FileLayer = file_layer_1.FileLayer;
|
|
27
|
-
var tms_service_1 = require("./tms_service");
|
|
28
|
-
exports.TMSService = tms_service_1.TMSService;
|
package/target/origin.js
DELETED
|
@@ -1,24 +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
|
-
exports.ORIGIN = {
|
|
22
|
-
EMS: 'elastic_maps_service',
|
|
23
|
-
KIBANA_YML: 'self_hosted',
|
|
24
|
-
};
|
package/target/tms_service.js
DELETED
|
@@ -1,429 +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 __extends = (this && this.__extends) || (function () {
|
|
21
|
-
var extendStatics = function (d, b) {
|
|
22
|
-
extendStatics = Object.setPrototypeOf ||
|
|
23
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
24
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
25
|
-
return extendStatics(d, b);
|
|
26
|
-
};
|
|
27
|
-
return function (d, b) {
|
|
28
|
-
extendStatics(d, b);
|
|
29
|
-
function __() { this.constructor = d; }
|
|
30
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
31
|
-
};
|
|
32
|
-
})();
|
|
33
|
-
var __assign = (this && this.__assign) || function () {
|
|
34
|
-
__assign = Object.assign || function(t) {
|
|
35
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
36
|
-
s = arguments[i];
|
|
37
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
38
|
-
t[p] = s[p];
|
|
39
|
-
}
|
|
40
|
-
return t;
|
|
41
|
-
};
|
|
42
|
-
return __assign.apply(this, arguments);
|
|
43
|
-
};
|
|
44
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
45
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
46
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
47
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
48
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
49
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
50
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
51
|
-
});
|
|
52
|
-
};
|
|
53
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
54
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
55
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
56
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
57
|
-
function step(op) {
|
|
58
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
59
|
-
while (_) try {
|
|
60
|
-
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;
|
|
61
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
62
|
-
switch (op[0]) {
|
|
63
|
-
case 0: case 1: t = op; break;
|
|
64
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
65
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
66
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
67
|
-
default:
|
|
68
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
69
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
70
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
71
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
72
|
-
if (t[2]) _.ops.pop();
|
|
73
|
-
_.trys.pop(); continue;
|
|
74
|
-
}
|
|
75
|
-
op = body.call(thisArg, _);
|
|
76
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
77
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
81
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
82
|
-
};
|
|
83
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
84
|
-
var lodash_1 = __importDefault(require("lodash"));
|
|
85
|
-
var ems_service_1 = require("./ems_service");
|
|
86
|
-
var TMSService = /** @class */ (function (_super) {
|
|
87
|
-
__extends(TMSService, _super);
|
|
88
|
-
function TMSService(config, emsClient, proxyPath) {
|
|
89
|
-
var _this = _super.call(this, config, emsClient, proxyPath) || this;
|
|
90
|
-
_this._getRasterStyleJson = lodash_1.default.once(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
91
|
-
var rasterUrl, url;
|
|
92
|
-
return __generator(this, function (_a) {
|
|
93
|
-
rasterUrl = this._getStyleUrlForLocale('raster');
|
|
94
|
-
if (rasterUrl) {
|
|
95
|
-
url = this._proxyPath + this._getAbsoluteUrl(rasterUrl);
|
|
96
|
-
return [2 /*return*/, this._emsClient.getManifest(this._emsClient.extendUrlWithParams(url))];
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
return [2 /*return*/];
|
|
100
|
-
}
|
|
101
|
-
return [2 /*return*/];
|
|
102
|
-
});
|
|
103
|
-
}); });
|
|
104
|
-
_this._getVectorStyleJsonRaw = lodash_1.default.once(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
105
|
-
var vectorUrl, url, vectorJson;
|
|
106
|
-
return __generator(this, function (_a) {
|
|
107
|
-
switch (_a.label) {
|
|
108
|
-
case 0:
|
|
109
|
-
vectorUrl = this._getStyleUrlForLocale('vector');
|
|
110
|
-
if (!vectorUrl) return [3 /*break*/, 2];
|
|
111
|
-
url = this._proxyPath + this._getAbsoluteUrl(vectorUrl);
|
|
112
|
-
return [4 /*yield*/, this._emsClient.getManifest(this._emsClient.extendUrlWithParams(url))];
|
|
113
|
-
case 1:
|
|
114
|
-
vectorJson = _a.sent();
|
|
115
|
-
return [2 /*return*/, __assign({}, vectorJson)];
|
|
116
|
-
case 2: return [2 /*return*/];
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
}); });
|
|
120
|
-
_this._getVectorStyleJsonInlined = lodash_1.default.once(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
121
|
-
var vectorJson, inlinedSources, sources, _i, _a, sourceName, url, sourceUrl, extendedUrl, sourceJson, extendedTileUrls, htmlAttribution, _b, _c;
|
|
122
|
-
var _this = this;
|
|
123
|
-
return __generator(this, function (_d) {
|
|
124
|
-
switch (_d.label) {
|
|
125
|
-
case 0: return [4 /*yield*/, this._getVectorStyleJsonRaw()];
|
|
126
|
-
case 1:
|
|
127
|
-
vectorJson = _d.sent();
|
|
128
|
-
if (!vectorJson) return [3 /*break*/, 9];
|
|
129
|
-
inlinedSources = {};
|
|
130
|
-
sources = vectorJson.sources;
|
|
131
|
-
_i = 0, _a = Object.getOwnPropertyNames(sources);
|
|
132
|
-
_d.label = 2;
|
|
133
|
-
case 2:
|
|
134
|
-
if (!(_i < _a.length)) return [3 /*break*/, 6];
|
|
135
|
-
sourceName = _a[_i];
|
|
136
|
-
url = sources[sourceName].url;
|
|
137
|
-
sourceUrl = this._proxyPath + this._getAbsoluteUrl(url);
|
|
138
|
-
extendedUrl = this._emsClient.extendUrlWithParams(sourceUrl);
|
|
139
|
-
return [4 /*yield*/, this._emsClient.getManifest(extendedUrl)];
|
|
140
|
-
case 3:
|
|
141
|
-
sourceJson = _d.sent();
|
|
142
|
-
extendedTileUrls = sourceJson.tiles.map(function (tileUrl) {
|
|
143
|
-
var url = _this._proxyPath + _this._getAbsoluteUrl(tileUrl);
|
|
144
|
-
return _this._emsClient.extendUrlWithParams(url);
|
|
145
|
-
});
|
|
146
|
-
return [4 /*yield*/, this.getHTMLAttribution()];
|
|
147
|
-
case 4:
|
|
148
|
-
htmlAttribution = _d.sent();
|
|
149
|
-
inlinedSources[sourceName] = __assign(__assign({}, sourceJson), { type: 'vector', attribution: htmlAttribution, tiles: extendedTileUrls });
|
|
150
|
-
_d.label = 5;
|
|
151
|
-
case 5:
|
|
152
|
-
_i++;
|
|
153
|
-
return [3 /*break*/, 2];
|
|
154
|
-
case 6:
|
|
155
|
-
_b = [__assign({}, vectorJson)];
|
|
156
|
-
_c = { sources: inlinedSources };
|
|
157
|
-
return [4 /*yield*/, this._getSpriteSheetRootPath()];
|
|
158
|
-
case 7:
|
|
159
|
-
_c.sprite = _d.sent();
|
|
160
|
-
return [4 /*yield*/, this._getUrlTemplateForGlyphs()];
|
|
161
|
-
case 8: return [2 /*return*/, __assign.apply(void 0, _b.concat([(_c.glyphs = _d.sent(), _c)]))];
|
|
162
|
-
case 9: return [2 /*return*/];
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
}); });
|
|
166
|
-
_this._config = config;
|
|
167
|
-
return _this;
|
|
168
|
-
}
|
|
169
|
-
TMSService.prototype.getDefaultRasterStyle = function () {
|
|
170
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
171
|
-
var tileJson, tiles;
|
|
172
|
-
var _this = this;
|
|
173
|
-
return __generator(this, function (_a) {
|
|
174
|
-
switch (_a.label) {
|
|
175
|
-
case 0: return [4 /*yield*/, this._getRasterStyleJson()];
|
|
176
|
-
case 1:
|
|
177
|
-
tileJson = _a.sent();
|
|
178
|
-
if (tileJson) {
|
|
179
|
-
tiles = tileJson.tiles.map(function (tile) { return _this._proxyPath + _this._getAbsoluteUrl(tile); });
|
|
180
|
-
return [2 /*return*/, __assign(__assign({}, tileJson), { tiles: tiles })];
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
return [2 /*return*/];
|
|
184
|
-
}
|
|
185
|
-
return [2 /*return*/];
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
};
|
|
190
|
-
TMSService.prototype.getUrlTemplate = function () {
|
|
191
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
192
|
-
var tileJson, directUrl;
|
|
193
|
-
return __generator(this, function (_a) {
|
|
194
|
-
switch (_a.label) {
|
|
195
|
-
case 0: return [4 /*yield*/, this._getRasterStyleJson()];
|
|
196
|
-
case 1:
|
|
197
|
-
tileJson = _a.sent();
|
|
198
|
-
if (tileJson) {
|
|
199
|
-
directUrl = this._proxyPath + this._getAbsoluteUrl(tileJson.tiles[0]);
|
|
200
|
-
return [2 /*return*/, this._emsClient.extendUrlWithParams(directUrl)];
|
|
201
|
-
}
|
|
202
|
-
else {
|
|
203
|
-
return [2 /*return*/, ''];
|
|
204
|
-
}
|
|
205
|
-
return [2 /*return*/];
|
|
206
|
-
}
|
|
207
|
-
});
|
|
208
|
-
});
|
|
209
|
-
};
|
|
210
|
-
TMSService.prototype.getUrlTemplateForVector = function (sourceId) {
|
|
211
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
212
|
-
var tileJson, directUrl;
|
|
213
|
-
return __generator(this, function (_a) {
|
|
214
|
-
switch (_a.label) {
|
|
215
|
-
case 0: return [4 /*yield*/, this._getVectorStyleJsonInlined()];
|
|
216
|
-
case 1:
|
|
217
|
-
tileJson = _a.sent();
|
|
218
|
-
if (!tileJson) {
|
|
219
|
-
return [2 /*return*/, ''];
|
|
220
|
-
}
|
|
221
|
-
if (tileJson.sources[sourceId] && tileJson.sources[sourceId].tiles) {
|
|
222
|
-
directUrl = this._proxyPath + this._getAbsoluteUrl(tileJson.sources[sourceId].tiles[0]);
|
|
223
|
-
return [2 /*return*/, this._emsClient.extendUrlWithParams(directUrl)];
|
|
224
|
-
}
|
|
225
|
-
else {
|
|
226
|
-
return [2 /*return*/, ''];
|
|
227
|
-
}
|
|
228
|
-
return [2 /*return*/];
|
|
229
|
-
}
|
|
230
|
-
});
|
|
231
|
-
});
|
|
232
|
-
};
|
|
233
|
-
TMSService.prototype.getVectorStyleSheet = 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._getVectorStyleJsonInlined()];
|
|
238
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
239
|
-
}
|
|
240
|
-
});
|
|
241
|
-
});
|
|
242
|
-
};
|
|
243
|
-
TMSService.prototype.getVectorStyleSheetRaw = 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._getVectorStyleJsonRaw()];
|
|
248
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
});
|
|
252
|
-
};
|
|
253
|
-
TMSService.prototype.getSpriteSheetMeta = function (isRetina) {
|
|
254
|
-
if (isRetina === void 0) { isRetina = false; }
|
|
255
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
256
|
-
var metaUrl, spritePngs, metaUrlExtended, jsonMeta;
|
|
257
|
-
return __generator(this, function (_a) {
|
|
258
|
-
switch (_a.label) {
|
|
259
|
-
case 0: return [4 /*yield*/, this.getSpriteSheetJsonPath(isRetina)];
|
|
260
|
-
case 1:
|
|
261
|
-
metaUrl = _a.sent();
|
|
262
|
-
return [4 /*yield*/, this.getSpriteSheetPngPath(isRetina)];
|
|
263
|
-
case 2:
|
|
264
|
-
spritePngs = _a.sent();
|
|
265
|
-
if (!(metaUrl && spritePngs)) return [3 /*break*/, 4];
|
|
266
|
-
metaUrlExtended = this._emsClient.extendUrlWithParams(metaUrl);
|
|
267
|
-
return [4 /*yield*/, this._emsClient.getManifest(metaUrlExtended)];
|
|
268
|
-
case 3:
|
|
269
|
-
jsonMeta = _a.sent();
|
|
270
|
-
return [2 /*return*/, {
|
|
271
|
-
png: spritePngs,
|
|
272
|
-
json: jsonMeta,
|
|
273
|
-
}];
|
|
274
|
-
case 4: return [2 /*return*/];
|
|
275
|
-
}
|
|
276
|
-
});
|
|
277
|
-
});
|
|
278
|
-
};
|
|
279
|
-
TMSService.prototype.getSpriteSheetJsonPath = function (isRetina) {
|
|
280
|
-
if (isRetina === void 0) { isRetina = false; }
|
|
281
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
282
|
-
var spriteSheetRootPath, suffix;
|
|
283
|
-
return __generator(this, function (_a) {
|
|
284
|
-
switch (_a.label) {
|
|
285
|
-
case 0: return [4 /*yield*/, this._getSpriteSheetRootPath()];
|
|
286
|
-
case 1:
|
|
287
|
-
spriteSheetRootPath = _a.sent();
|
|
288
|
-
if (spriteSheetRootPath) {
|
|
289
|
-
suffix = isRetina ? '@2x' : '';
|
|
290
|
-
return [2 /*return*/, spriteSheetRootPath + suffix + '.json'];
|
|
291
|
-
}
|
|
292
|
-
else {
|
|
293
|
-
return [2 /*return*/, ''];
|
|
294
|
-
}
|
|
295
|
-
return [2 /*return*/];
|
|
296
|
-
}
|
|
297
|
-
});
|
|
298
|
-
});
|
|
299
|
-
};
|
|
300
|
-
TMSService.prototype.getSpriteSheetPngPath = function (isRetina) {
|
|
301
|
-
if (isRetina === void 0) { isRetina = false; }
|
|
302
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
303
|
-
var spriteSheetRootPath, suffix;
|
|
304
|
-
return __generator(this, function (_a) {
|
|
305
|
-
switch (_a.label) {
|
|
306
|
-
case 0: return [4 /*yield*/, this._getSpriteSheetRootPath()];
|
|
307
|
-
case 1:
|
|
308
|
-
spriteSheetRootPath = _a.sent();
|
|
309
|
-
if (spriteSheetRootPath) {
|
|
310
|
-
suffix = isRetina ? '@2x' : '';
|
|
311
|
-
return [2 /*return*/, spriteSheetRootPath + suffix + '.png'];
|
|
312
|
-
}
|
|
313
|
-
else {
|
|
314
|
-
return [2 /*return*/, ''];
|
|
315
|
-
}
|
|
316
|
-
return [2 /*return*/];
|
|
317
|
-
}
|
|
318
|
-
});
|
|
319
|
-
});
|
|
320
|
-
};
|
|
321
|
-
TMSService.prototype.getDisplayName = function () {
|
|
322
|
-
return this._emsClient.getValueInLanguage(this._config.name);
|
|
323
|
-
};
|
|
324
|
-
TMSService.prototype.getMinZoom = function () {
|
|
325
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
326
|
-
var tileJson;
|
|
327
|
-
return __generator(this, function (_a) {
|
|
328
|
-
switch (_a.label) {
|
|
329
|
-
case 0: return [4 /*yield*/, this._getRasterStyleJson()];
|
|
330
|
-
case 1:
|
|
331
|
-
tileJson = _a.sent();
|
|
332
|
-
if (tileJson) {
|
|
333
|
-
return [2 /*return*/, tileJson.minzoom];
|
|
334
|
-
}
|
|
335
|
-
else {
|
|
336
|
-
return [2 /*return*/];
|
|
337
|
-
}
|
|
338
|
-
return [2 /*return*/];
|
|
339
|
-
}
|
|
340
|
-
});
|
|
341
|
-
});
|
|
342
|
-
};
|
|
343
|
-
TMSService.prototype.getMaxZoom = function () {
|
|
344
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
345
|
-
var tileJson;
|
|
346
|
-
return __generator(this, function (_a) {
|
|
347
|
-
switch (_a.label) {
|
|
348
|
-
case 0: return [4 /*yield*/, this._getRasterStyleJson()];
|
|
349
|
-
case 1:
|
|
350
|
-
tileJson = _a.sent();
|
|
351
|
-
if (tileJson) {
|
|
352
|
-
return [2 /*return*/, tileJson.maxzoom];
|
|
353
|
-
}
|
|
354
|
-
else {
|
|
355
|
-
return [2 /*return*/];
|
|
356
|
-
}
|
|
357
|
-
return [2 /*return*/];
|
|
358
|
-
}
|
|
359
|
-
});
|
|
360
|
-
});
|
|
361
|
-
};
|
|
362
|
-
TMSService.prototype.getId = function () {
|
|
363
|
-
return this._config.id;
|
|
364
|
-
};
|
|
365
|
-
TMSService.prototype.hasId = function (id) {
|
|
366
|
-
return this._config.id === id;
|
|
367
|
-
};
|
|
368
|
-
TMSService.prototype.getApiUrl = function () {
|
|
369
|
-
return this._emsClient.getTileApiUrl();
|
|
370
|
-
};
|
|
371
|
-
TMSService.prototype._getStyleUrlForLocale = function (formatType) {
|
|
372
|
-
var vectorFormats = this._getFormats(formatType, this._emsClient.getLocale());
|
|
373
|
-
if (!vectorFormats.length) {
|
|
374
|
-
//fallback to default locale
|
|
375
|
-
vectorFormats = this._getFormats(formatType, this._emsClient.getDefaultLocale());
|
|
376
|
-
}
|
|
377
|
-
if (!vectorFormats.length) {
|
|
378
|
-
// eslint-disable-next-line max-len
|
|
379
|
-
throw new Error("Cannot find " + formatType + " tile layer for locale " + this._emsClient.getLocale() + " or " + this._emsClient.getDefaultLocale());
|
|
380
|
-
}
|
|
381
|
-
var defaultStyle = vectorFormats[0];
|
|
382
|
-
if (defaultStyle && defaultStyle.hasOwnProperty('url')) {
|
|
383
|
-
return defaultStyle.url;
|
|
384
|
-
}
|
|
385
|
-
};
|
|
386
|
-
TMSService.prototype._getFormats = function (formatType, locale) {
|
|
387
|
-
return this._config.formats.filter(function (format) { return format.locale === locale && format.format === formatType; });
|
|
388
|
-
};
|
|
389
|
-
TMSService.prototype._getSpriteSheetRootPath = function () {
|
|
390
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
391
|
-
var vectorStyleJson;
|
|
392
|
-
return __generator(this, function (_a) {
|
|
393
|
-
switch (_a.label) {
|
|
394
|
-
case 0: return [4 /*yield*/, this._getVectorStyleJsonRaw()];
|
|
395
|
-
case 1:
|
|
396
|
-
vectorStyleJson = _a.sent();
|
|
397
|
-
if (vectorStyleJson) {
|
|
398
|
-
return [2 /*return*/, this._proxyPath + this._getAbsoluteUrl(vectorStyleJson.sprite)];
|
|
399
|
-
}
|
|
400
|
-
else {
|
|
401
|
-
return [2 /*return*/, ''];
|
|
402
|
-
}
|
|
403
|
-
return [2 /*return*/];
|
|
404
|
-
}
|
|
405
|
-
});
|
|
406
|
-
});
|
|
407
|
-
};
|
|
408
|
-
TMSService.prototype._getUrlTemplateForGlyphs = function () {
|
|
409
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
410
|
-
var vectorStyleJson;
|
|
411
|
-
return __generator(this, function (_a) {
|
|
412
|
-
switch (_a.label) {
|
|
413
|
-
case 0: return [4 /*yield*/, this._getVectorStyleJsonRaw()];
|
|
414
|
-
case 1:
|
|
415
|
-
vectorStyleJson = _a.sent();
|
|
416
|
-
if (vectorStyleJson) {
|
|
417
|
-
return [2 /*return*/, this._proxyPath + this._getAbsoluteUrl(vectorStyleJson.glyphs)];
|
|
418
|
-
}
|
|
419
|
-
else {
|
|
420
|
-
return [2 /*return*/, ''];
|
|
421
|
-
}
|
|
422
|
-
return [2 /*return*/];
|
|
423
|
-
}
|
|
424
|
-
});
|
|
425
|
-
});
|
|
426
|
-
};
|
|
427
|
-
return TMSService;
|
|
428
|
-
}(ems_service_1.AbstractEmsService));
|
|
429
|
-
exports.TMSService = TMSService;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
|
2
|
-
// It should be published with your NPM package. It should not be tracked by Git.
|
|
3
|
-
{
|
|
4
|
-
"tsdocVersion": "0.12",
|
|
5
|
-
"toolPackages": [
|
|
6
|
-
{
|
|
7
|
-
"packageName": "@microsoft/api-extractor",
|
|
8
|
-
"packageVersion": "7.9.2"
|
|
9
|
-
}
|
|
10
|
-
]
|
|
11
|
-
}
|
package/target/utils.js
DELETED
|
@@ -1,42 +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
|
-
/**
|
|
22
|
-
* Resolves a target URL path relative to the host.
|
|
23
|
-
* This is specifically useed by the Kibana proxy re-routing.
|
|
24
|
-
* It also handles trailing slashes in tileApiUrl and fileApiUrl parameters.
|
|
25
|
-
*/
|
|
26
|
-
function toAbsoluteUrl(host, path) {
|
|
27
|
-
if (!host) {
|
|
28
|
-
return path;
|
|
29
|
-
}
|
|
30
|
-
var hostEndWithSlash = host[host.length - 1] === '/';
|
|
31
|
-
var pathStartsWithSlash = path[0] === '/';
|
|
32
|
-
if (hostEndWithSlash === true && pathStartsWithSlash === true) {
|
|
33
|
-
return host + path.slice(1);
|
|
34
|
-
}
|
|
35
|
-
else if (hostEndWithSlash !== pathStartsWithSlash) {
|
|
36
|
-
return host + path;
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
return host + '/' + path;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
exports.toAbsoluteUrl = toAbsoluteUrl;
|