@elastic/ems-client 8.3.3 → 8.4.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 +5 -17
- 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 +12 -0
- package/CONTRIBUTING.md +18 -0
- package/catalog-info.yaml +68 -0
- package/package.json +7 -4
- package/src/ems_client.ts +1 -2
- package/src/tms_service.ts +5 -1
- package/target/node/ems_client.js +24 -92
- package/target/node/ems_service.js +11 -21
- package/target/node/file_layer.js +17 -62
- package/target/node/index.js +0 -4
- package/target/node/tms_service.js +33 -99
- package/target/node/utils.js +8 -10
- package/target/tms_service.d.ts +1 -1
- package/target/web/ems_client.js +297 -438
- package/target/web/ems_service.js +10 -26
- package/target/web/file_layer.js +62 -117
- package/target/web/index.js +1 -0
- package/target/web/tms_service.js +448 -651
- package/target/web/utils.js +10 -8
- 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 -19
|
@@ -4,19 +4,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.AbstractEmsService = void 0;
|
|
7
|
-
|
|
8
7
|
var _utils = require("./utils");
|
|
9
|
-
|
|
10
|
-
function
|
|
11
|
-
|
|
8
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
10
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /*
|
|
11
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
12
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
13
|
+
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
14
|
+
* 2.0.
|
|
15
|
+
*/
|
|
12
16
|
class AbstractEmsService {
|
|
13
17
|
constructor(config, emsClient, proxyPath) {
|
|
14
18
|
_defineProperty(this, "_emsClient", void 0);
|
|
15
|
-
|
|
16
19
|
_defineProperty(this, "_config", void 0);
|
|
17
|
-
|
|
18
20
|
_defineProperty(this, "_proxyPath", void 0);
|
|
19
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Checks if url is absolute. If not, prepend the basePath.
|
|
23
|
+
*/
|
|
20
24
|
_defineProperty(this, "_getAbsoluteUrl", url => {
|
|
21
25
|
if (/^https?:\/\//.test(url)) {
|
|
22
26
|
return url;
|
|
@@ -24,41 +28,27 @@ class AbstractEmsService {
|
|
|
24
28
|
return (0, _utils.toAbsoluteUrl)(this.getApiUrl(), url);
|
|
25
29
|
}
|
|
26
30
|
});
|
|
27
|
-
|
|
28
31
|
this._config = config;
|
|
29
32
|
this._emsClient = emsClient;
|
|
30
33
|
this._proxyPath = proxyPath;
|
|
31
34
|
}
|
|
32
|
-
|
|
33
35
|
getAttributions() {
|
|
34
36
|
return this._config.attribution.map(attribution => {
|
|
35
37
|
const url = this._emsClient.getValueInLanguage(attribution.url);
|
|
36
|
-
|
|
37
38
|
const label = this._emsClient.getValueInLanguage(attribution.label);
|
|
38
|
-
|
|
39
39
|
return {
|
|
40
40
|
url: url,
|
|
41
41
|
label: label
|
|
42
42
|
};
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
|
-
|
|
46
45
|
getMarkdownAttribution() {
|
|
47
46
|
const attributions = this._config.attribution.map(attribution => {
|
|
48
47
|
const url = this._emsClient.getValueInLanguage(attribution.url);
|
|
49
|
-
|
|
50
48
|
const label = this._emsClient.getValueInLanguage(attribution.label);
|
|
51
|
-
|
|
52
49
|
return `[${label}](${url})`;
|
|
53
50
|
});
|
|
54
|
-
|
|
55
51
|
return attributions.join('|');
|
|
56
52
|
}
|
|
57
|
-
/**
|
|
58
|
-
* Checks if url is absolute. If not, prepend the basePath.
|
|
59
|
-
*/
|
|
60
|
-
|
|
61
|
-
|
|
62
53
|
}
|
|
63
|
-
|
|
64
54
|
exports.AbstractEmsService = AbstractEmsService;
|
|
@@ -4,74 +4,59 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.FileLayer = exports.EMSFormatType = void 0;
|
|
7
|
-
|
|
8
7
|
var _url = _interopRequireDefault(require("url"));
|
|
9
|
-
|
|
10
8
|
var _ems_service = require("./ems_service");
|
|
11
|
-
|
|
12
9
|
var topojson = _interopRequireWildcard(require("topojson-client"));
|
|
13
|
-
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
|
-
|
|
10
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
11
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
18
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
13
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
14
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
15
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /*
|
|
16
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
17
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
18
|
+
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
19
|
+
* 2.0.
|
|
20
|
+
*/
|
|
21
|
+
let EMSFormatType = exports.EMSFormatType = /*#__PURE__*/function (EMSFormatType) {
|
|
26
22
|
EMSFormatType["geojson"] = "geojson";
|
|
27
23
|
EMSFormatType["topojson"] = "topojson";
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
return EMSFormatType;
|
|
25
|
+
}({});
|
|
30
26
|
class FileLayer extends _ems_service.AbstractEmsService {
|
|
31
27
|
constructor(config, emsClient, proxyPath) {
|
|
32
28
|
super(config, emsClient, proxyPath);
|
|
33
|
-
|
|
34
29
|
_defineProperty(this, "_config", void 0);
|
|
35
|
-
|
|
36
30
|
this._config = config;
|
|
37
31
|
}
|
|
38
|
-
|
|
39
32
|
async getGeoJson() {
|
|
40
33
|
const cachedGeoJson = this._emsClient.getCachedGeoJson(this.getId());
|
|
41
|
-
|
|
42
34
|
if (cachedGeoJson) {
|
|
43
35
|
return cachedGeoJson;
|
|
44
36
|
}
|
|
45
|
-
|
|
46
37
|
const format = this.getDefaultFormatType();
|
|
47
38
|
const fetchUrl = this.getDefaultFormatUrl();
|
|
48
39
|
let geojson;
|
|
49
40
|
const fetchedJson = await this._emsClient.getManifest(fetchUrl);
|
|
50
|
-
|
|
51
41
|
if (fetchedJson) {
|
|
52
42
|
if (format === 'geojson') {
|
|
53
43
|
geojson = fetchedJson;
|
|
54
44
|
} else if (format === 'topojson') {
|
|
55
45
|
const meta = this.getDefaultFormatMeta();
|
|
56
|
-
const featureCollectionPath =
|
|
57
|
-
|
|
46
|
+
const featureCollectionPath = meta?.feature_collection_path ?? 'data';
|
|
47
|
+
// @ts-expect-error see https://github.com/DefinitelyTyped/DefinitelyTyped/pull/52156
|
|
58
48
|
geojson = topojson.feature(fetchedJson, featureCollectionPath);
|
|
59
49
|
} else {
|
|
60
50
|
return;
|
|
61
51
|
}
|
|
62
|
-
|
|
63
52
|
this._emsClient.cacheGeoJson(this.getId(), geojson);
|
|
64
|
-
|
|
65
53
|
return geojson;
|
|
66
54
|
}
|
|
67
|
-
|
|
68
55
|
return;
|
|
69
56
|
}
|
|
70
|
-
|
|
71
57
|
getFields() {
|
|
72
58
|
return this._config.fields;
|
|
73
59
|
}
|
|
74
|
-
|
|
75
60
|
getFieldsInLanguage() {
|
|
76
61
|
return this.getFields().map(field => {
|
|
77
62
|
return {
|
|
@@ -81,84 +66,61 @@ class FileLayer extends _ems_service.AbstractEmsService {
|
|
|
81
66
|
};
|
|
82
67
|
});
|
|
83
68
|
}
|
|
84
|
-
|
|
85
69
|
getDisplayName() {
|
|
86
70
|
const layerName = this._emsClient.getValueInLanguage(this._config.layer_name);
|
|
87
|
-
|
|
88
71
|
return layerName ? layerName : '';
|
|
89
72
|
}
|
|
90
|
-
|
|
91
73
|
getId() {
|
|
92
74
|
return this._config.layer_id;
|
|
93
75
|
}
|
|
94
|
-
|
|
95
76
|
hasId(id) {
|
|
96
77
|
const matchesLegacyId = this._config.legacy_ids.indexOf(id) >= 0;
|
|
97
78
|
return this._config.layer_id === id || matchesLegacyId;
|
|
98
79
|
}
|
|
99
|
-
|
|
100
80
|
getEMSHotLink() {
|
|
101
81
|
const landingPageString = this._emsClient.getLandingPageUrl();
|
|
102
|
-
|
|
103
82
|
const urlObject = _url.default.parse(landingPageString, true);
|
|
104
|
-
|
|
105
83
|
urlObject.hash = `file/${this.getId()}`;
|
|
106
|
-
urlObject.query = {
|
|
84
|
+
urlObject.query = {
|
|
85
|
+
...urlObject.query,
|
|
107
86
|
locale: this._emsClient.getLocale()
|
|
108
87
|
};
|
|
109
88
|
return _url.default.format(urlObject);
|
|
110
89
|
}
|
|
111
|
-
|
|
112
90
|
getDefaultFormatType() {
|
|
113
91
|
const format = this._getDefaultFormat();
|
|
114
|
-
|
|
115
92
|
return format.type;
|
|
116
93
|
}
|
|
117
|
-
|
|
118
94
|
getFormatOfType(type) {
|
|
119
95
|
const format = this._getFormatOfType(type);
|
|
120
|
-
|
|
121
96
|
return format.type;
|
|
122
97
|
}
|
|
123
|
-
|
|
124
98
|
getDefaultFormatMeta() {
|
|
125
99
|
const format = this._getDefaultFormat();
|
|
126
|
-
|
|
127
100
|
return this._getFormatMeta(format);
|
|
128
101
|
}
|
|
129
|
-
|
|
130
102
|
getFormatOfTypeMeta(type) {
|
|
131
103
|
const format = this._getFormatOfType(type);
|
|
132
|
-
|
|
133
104
|
return this._getFormatMeta(format);
|
|
134
105
|
}
|
|
135
|
-
|
|
136
106
|
getDefaultFormatUrl() {
|
|
137
107
|
const format = this._getDefaultFormat();
|
|
138
|
-
|
|
139
108
|
return this._getFormatUrl(format);
|
|
140
109
|
}
|
|
141
|
-
|
|
142
110
|
getFormatOfTypeUrl(type) {
|
|
143
111
|
const format = this._getFormatOfType(type);
|
|
144
|
-
|
|
145
112
|
return this._getFormatUrl(format);
|
|
146
113
|
}
|
|
147
|
-
|
|
148
114
|
getCreatedAt() {
|
|
149
115
|
return this._config.created_at;
|
|
150
116
|
}
|
|
151
|
-
|
|
152
117
|
getApiUrl() {
|
|
153
118
|
return this._emsClient.getFileApiUrl();
|
|
154
119
|
}
|
|
155
|
-
|
|
156
120
|
_getFormatUrl(format) {
|
|
157
121
|
const url = this._proxyPath + this._getAbsoluteUrl(format.url);
|
|
158
|
-
|
|
159
122
|
return this._emsClient.extendUrlWithParams(url);
|
|
160
123
|
}
|
|
161
|
-
|
|
162
124
|
_getFormatMeta(format) {
|
|
163
125
|
if ('meta' in format) {
|
|
164
126
|
return format.meta;
|
|
@@ -166,27 +128,20 @@ class FileLayer extends _ems_service.AbstractEmsService {
|
|
|
166
128
|
return;
|
|
167
129
|
}
|
|
168
130
|
}
|
|
169
|
-
|
|
170
131
|
_getDefaultFormat() {
|
|
171
132
|
const defaultFormat = this._config.formats.find(format => {
|
|
172
133
|
return format.legacy_default;
|
|
173
134
|
});
|
|
174
|
-
|
|
175
135
|
if (defaultFormat) {
|
|
176
136
|
return defaultFormat;
|
|
177
137
|
}
|
|
178
|
-
|
|
179
138
|
return this._config.formats[0];
|
|
180
139
|
}
|
|
181
|
-
|
|
182
140
|
_getFormatOfType(type) {
|
|
183
141
|
const requestedFormat = this._config.formats.find(format => {
|
|
184
142
|
return format.type === type;
|
|
185
143
|
});
|
|
186
|
-
|
|
187
144
|
return requestedFormat || this._getDefaultFormat();
|
|
188
145
|
}
|
|
189
|
-
|
|
190
146
|
}
|
|
191
|
-
|
|
192
147
|
exports.FileLayer = FileLayer;
|
package/target/node/index.js
CHANGED
|
@@ -45,11 +45,7 @@ Object.defineProperty(exports, "blendMode", {
|
|
|
45
45
|
return _utils.blendMode;
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
|
-
|
|
49
48
|
var _ems_client = require("./ems_client");
|
|
50
|
-
|
|
51
49
|
var _file_layer = require("./file_layer");
|
|
52
|
-
|
|
53
50
|
var _tms_service = require("./tms_service");
|
|
54
|
-
|
|
55
51
|
var _utils = require("./utils");
|