@elastic/ems-client 7.17.2 → 7.17.4
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 +8 -14
- package/.buildkite/build.sh +3 -0
- package/.buildkite/compare_dependencies.js +67 -0
- package/.buildkite/pipeline.yml +3 -1
- package/.github/workflows/backport.yml +24 -0
- package/CHANGELOG.md +11 -18
- package/eslint.config.mjs +25 -0
- package/package.json +37 -32
- package/src/ems_client.ts +11 -10
- package/src/tms_service.ts +1 -2
- package/target/ems_client.d.ts +4 -2
- package/target/node/ems_client.js +1 -1
- package/target/node/tms_service.js +1 -2
- package/target/web/ems_client.js +15 -15
- package/target/web/file_layer.js +1 -1
- package/target/web/tms_service.js +16 -17
- package/test/__snapshots__/ems_client.test.ts.snap +24 -24
- package/test/ems_client_util.ts +1 -1
- package/.eslintignore +0 -1
- package/.eslintrc +0 -18
- package/target/ems_client.js +0 -318
- package/target/ems_service.js +0 -47
- package/target/file_layer.js +0 -176
- package/target/index.js +0 -16
- package/target/tms_service.js +0 -409
- package/target/utils.js +0 -86
package/.backportrc.json
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
"
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"checked": true
|
|
11
|
-
}
|
|
12
|
-
],
|
|
13
|
-
"labels": [
|
|
14
|
-
"backport"
|
|
15
|
-
]
|
|
2
|
+
"repoOwner": "elastic",
|
|
3
|
+
"repoName": "ems-file-service",
|
|
4
|
+
"targetBranches": ["7.17"],
|
|
5
|
+
"targetPRLabels": ["backport"],
|
|
6
|
+
"commitConflicts": true,
|
|
7
|
+
"autoMerge": true,
|
|
8
|
+
"autoMergeMethod": "squash",
|
|
9
|
+
"fork": false
|
|
16
10
|
}
|
package/.buildkite/build.sh
CHANGED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
3
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
4
|
+
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
5
|
+
* 2.0.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/* Script that will check the current package.json dependencies
|
|
9
|
+
against Kibana (using BUILDKITE_BRANCH to determine the branch)
|
|
10
|
+
and exits with a 1 status code if, for any shared dependency,
|
|
11
|
+
EMS Client is behind */
|
|
12
|
+
|
|
13
|
+
const fs = require('node:fs');
|
|
14
|
+
const semver = require('semver');
|
|
15
|
+
|
|
16
|
+
const DEFAULT_BRANCH = 'main';
|
|
17
|
+
const branch = process.env.KIBANA_BRANCH || DEFAULT_BRANCH;
|
|
18
|
+
const kibanaPackageUrl = `https://raw.githubusercontent.com/elastic/kibana/${branch}/package.json`;
|
|
19
|
+
|
|
20
|
+
const processDependency = function (dependency, srcDeps, dstDeps, dstDevDeps) {
|
|
21
|
+
if (!(dependency in dstDeps) && !(dependency in dstDevDeps)) {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
const source = srcDeps[dependency].replace('^', '');
|
|
25
|
+
const destination = dstDeps[dependency] || dstDevDeps[dependency];
|
|
26
|
+
|
|
27
|
+
if (semver.satisfies(source, destination)) {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if ( dependency in dstDevDeps){
|
|
32
|
+
console.log(`⚠ ${dependency}: ${source} vs ${destination}`);
|
|
33
|
+
return true
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
console.log(`🛑 ${dependency}: ${source} vs ${destination}`);
|
|
37
|
+
return false;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const main = async function () {
|
|
41
|
+
const kibanaPackage = await fetch(kibanaPackageUrl);
|
|
42
|
+
const kibanaPackageJson = await kibanaPackage.json();
|
|
43
|
+
const kibanaDeps = kibanaPackageJson['dependencies'];
|
|
44
|
+
const kibanaDevDeps = kibanaPackageJson['devDependencies'];
|
|
45
|
+
|
|
46
|
+
const emsClientPackageJson = JSON.parse(fs.readFileSync('package.json'));
|
|
47
|
+
const emsClientDeps = {
|
|
48
|
+
...emsClientPackageJson['dependencies'],
|
|
49
|
+
// ...emsClientPackageJson['devDependencies']
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
console.log(`ems-client@${emsClientPackageJson['version']}`);
|
|
53
|
+
console.log(`kibana@${kibanaPackageJson['version']}`);
|
|
54
|
+
|
|
55
|
+
const results = Object.keys(emsClientDeps).map((dep) =>
|
|
56
|
+
processDependency(dep, emsClientDeps, kibanaDeps, kibanaDevDeps)
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
process.exit(results.every(r => r) ? 0 : 1);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
main()
|
|
63
|
+
.then(console.log)
|
|
64
|
+
.catch((error) => {
|
|
65
|
+
console.error(error);
|
|
66
|
+
process.exit(1);
|
|
67
|
+
});
|
package/.buildkite/pipeline.yml
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
agents:
|
|
2
|
-
image: "docker.elastic.co/ci-agent-images/ems/buildkite-agent-node20:0.
|
|
2
|
+
image: "docker.elastic.co/ci-agent-images/ems/buildkite-agent-node20:0.5@sha256:01d63c1c1e9895e410a8b50c0eb0ce8e986c354085a11ed1d00355a12935ac5e"
|
|
3
3
|
cpu: "2"
|
|
4
4
|
memory: "2G"
|
|
5
5
|
|
|
6
6
|
steps:
|
|
7
7
|
- label: ":hammer_and_wrench: Test and build"
|
|
8
8
|
command: ".buildkite/build.sh"
|
|
9
|
+
env:
|
|
10
|
+
KIBANA_BRANCH: "7.17"
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
name: Automatic backport action
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request_target:
|
|
5
|
+
types: ["labeled", "closed"]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
backport:
|
|
9
|
+
name: Backport PR
|
|
10
|
+
if: github.event.pull_request.merged == true && !(contains(github.event.pull_request.labels.*.name, 'backport'))
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- name: Backport Action
|
|
14
|
+
uses: sorenlouv/backport-github-action@ad888e978060bc1b2798690dd9d03c4036560947 # v9.5.1
|
|
15
|
+
with:
|
|
16
|
+
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
17
|
+
|
|
18
|
+
- name: Info log
|
|
19
|
+
if: ${{ success() }}
|
|
20
|
+
run: cat ~/.backport/backport.info.log
|
|
21
|
+
|
|
22
|
+
- name: Debug log
|
|
23
|
+
if: ${{ failure() }}
|
|
24
|
+
run: cat ~/.backport/backport.debug.log
|
package/CHANGELOG.md
CHANGED
|
@@ -3,46 +3,48 @@ All notable changes to this project will be documented in this file.
|
|
|
3
3
|
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
5
5
|
|
|
6
|
-
## [7.17.
|
|
6
|
+
## [7.17.4] - 2024-12-16
|
|
7
|
+
|
|
8
|
+
### Changed
|
|
9
|
+
- Update dependencies (search PRs for `is:pr label:7.17.4,dependencies`)
|
|
7
10
|
|
|
8
|
-
## Changed
|
|
9
11
|
|
|
12
|
+
## [7.17.3] - 2024-07-10
|
|
13
|
+
### Changed
|
|
14
|
+
- Update dependencies #243
|
|
15
|
+
|
|
16
|
+
## [7.17.2] - 2024-07-05
|
|
17
|
+
## Changed
|
|
10
18
|
- Update dependencies #218 #219 #220 #221 #236 #237
|
|
11
19
|
|
|
12
20
|
## [7.17.1] - 2023-11-09
|
|
13
|
-
|
|
14
21
|
### Changed
|
|
15
|
-
|
|
16
22
|
- Default EMS version is 7.17
|
|
17
23
|
- Upgrade dependencies #138 #162 #165 #169 #172 #173 !76 #184 #191 #198 #205
|
|
18
24
|
- Migration from Jenkins to Buildkite for automatic testing #163 #199
|
|
19
25
|
- Upgrade to Node 20 #208
|
|
20
26
|
|
|
21
27
|
## [7.16.0] - 2021-10-13
|
|
22
|
-
|
|
23
28
|
### Changed
|
|
24
29
|
- Default EMS version is 7.16
|
|
25
30
|
- Update dependencies using `yarn upgrade`
|
|
26
31
|
- Better error handling for HTTP responses
|
|
27
32
|
|
|
28
33
|
## [7.15.1] - 2021-09-01
|
|
29
|
-
|
|
30
34
|
### Changed
|
|
31
35
|
- Unpinned `semver` dependency [#77](https://github.com/elastic/ems-client/pull/77)
|
|
32
36
|
|
|
33
37
|
## [7.15.0] - 2021-08-12
|
|
34
|
-
|
|
35
38
|
### Changed
|
|
36
39
|
- Default EMS version is 7.15
|
|
37
40
|
- Updated dependencies via `yarn upgrade`
|
|
38
41
|
- Fix linting issues
|
|
42
|
+
|
|
39
43
|
## [7.14.0] - 2021-06-15
|
|
40
44
|
### Added
|
|
41
|
-
|
|
42
45
|
- New getters for optional field metadata `alias`, `regex`, and `values` #69
|
|
43
46
|
|
|
44
47
|
### Changed
|
|
45
|
-
|
|
46
48
|
- Default EMS version is 7.14
|
|
47
49
|
- **Breaking change** @elastic/ems-client is now licensed under the Elastic License v2. See the LICENSE.txt file in this repository #64
|
|
48
50
|
|
|
@@ -56,7 +58,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
|
56
58
|
- Updated dependencies using `yarn upgrade` and #44 #50
|
|
57
59
|
- Add functions to get specific file formats #53
|
|
58
60
|
|
|
59
|
-
|
|
60
61
|
## [7.10.0] - 2020-08-17
|
|
61
62
|
### Changed
|
|
62
63
|
- Default EMS version is 7.10
|
|
@@ -83,7 +84,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
|
83
84
|
- Convert source code to Typescript
|
|
84
85
|
- Added better linting with eslint and prettier
|
|
85
86
|
|
|
86
|
-
|
|
87
87
|
## [7.8.1] - 2020-04-06
|
|
88
88
|
### Fixed
|
|
89
89
|
- Correctly handle API urls that end in slashes
|
|
@@ -118,12 +118,10 @@ always needed and in fact breaks some client-side use of this lib
|
|
|
118
118
|
- Correctly handle API urls that end in slashes
|
|
119
119
|
|
|
120
120
|
## [7.6.0] - 2020-01-13
|
|
121
|
-
|
|
122
121
|
### Added
|
|
123
122
|
- Two new parameters were introduced, `tileApiUrl` and `fileApiUrl`. These should be used instead of `manifestServiceUrl`. These parameters should be set to their respective domains (e.g. `https://tiles.maps.elastic.co`, `https://vector.maps.elastic.co`). [#13](https://github.com/elastic/ems-client/pull/13)
|
|
124
123
|
|
|
125
124
|
### Changed
|
|
126
|
-
|
|
127
125
|
- Starting with v7.6, new Elastic Maps Service (EMS) versions will be released with every matching major and minor release of the Elastic Stack. New releases of ems-client will also be released to match the EMS versions.
|
|
128
126
|
|
|
129
127
|
- Handle relative URLs in EMS v7.6 manifests.
|
|
@@ -136,7 +134,6 @@ always needed and in fact breaks some client-side use of this lib
|
|
|
136
134
|
- Remove paragraph element from html attribution [#15](https://github.com/elastic/ems-client/pull/15)
|
|
137
135
|
|
|
138
136
|
## [7.2.1] - 2019-12-11
|
|
139
|
-
|
|
140
137
|
### Fixed
|
|
141
138
|
- Inject correct attribution into vector tile sources [#14](https://github.com/elastic/ems-client/pull/14/files)
|
|
142
139
|
|
|
@@ -147,17 +144,13 @@ Bump version to match the corresponding Elastic Maps Service version. This relea
|
|
|
147
144
|
### Fixed
|
|
148
145
|
- Update browser entry point that was pointing to an incorrect path, which fell back to the main entry
|
|
149
146
|
|
|
150
|
-
|
|
151
147
|
## [1.0.2] - 2019-10-15
|
|
152
|
-
|
|
153
148
|
### Fixed
|
|
154
149
|
- Transpile the browser-side assets to be IE compatible.
|
|
155
150
|
|
|
156
151
|
## [1.0.1] - 2019-08-27
|
|
157
|
-
|
|
158
152
|
### Fixed
|
|
159
153
|
- Downgrade node-fetch dependency to fix fetch error
|
|
160
154
|
|
|
161
155
|
## [1.0.0] - 2019-08-26
|
|
162
|
-
|
|
163
156
|
- Initial release. Compatible with Elastic Maps Service v7.2.0.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
import eslint from '@eslint/js';
|
|
4
|
+
import tseslint from 'typescript-eslint';
|
|
5
|
+
import globals from 'globals';
|
|
6
|
+
|
|
7
|
+
export default tseslint.config(
|
|
8
|
+
eslint.configs.recommended,
|
|
9
|
+
...tseslint.configs.recommended,
|
|
10
|
+
{
|
|
11
|
+
ignores: ["target","*.config.js",".buildkite"]
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
files: ['**/*.{ts,tsx,mts,cts}'],
|
|
15
|
+
rules: {
|
|
16
|
+
'no-undef': 'off',
|
|
17
|
+
'@typescript-eslint/ban-types': 'off'
|
|
18
|
+
},
|
|
19
|
+
"languageOptions": {
|
|
20
|
+
"globals": {
|
|
21
|
+
...globals.node
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
);
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elastic/ems-client",
|
|
3
|
-
"version": "7.17.
|
|
3
|
+
"version": "7.17.4",
|
|
4
4
|
"description": "JavaScript client library for the Elastic Maps Service",
|
|
5
5
|
"main": "target/node/index.js",
|
|
6
6
|
"browser": "target/web/index.js",
|
|
7
7
|
"types": "target/index.d.ts",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"prelint": "tsc --noEmit",
|
|
10
|
-
"lint": "
|
|
10
|
+
"lint": "prettier --check src/* && eslint .",
|
|
11
11
|
"pretest": "yarn lint",
|
|
12
12
|
"test": "jest",
|
|
13
13
|
"build": "tsc --emitDeclarationOnly && yarn build-web && yarn build-node",
|
|
@@ -35,38 +35,43 @@
|
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@types/geojson": "
|
|
39
|
-
"@types/
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"topojson-client": "^3.1.0"
|
|
38
|
+
"@types/geojson": "7946.0.15",
|
|
39
|
+
"@types/topojson-client": "3.1.5",
|
|
40
|
+
"lodash": "4.17.21",
|
|
41
|
+
"lru-cache": "4.1.5",
|
|
42
|
+
"node-fetch": "2.7.0",
|
|
43
|
+
"semver": "7.6.3",
|
|
44
|
+
"topojson-client": "3.1.0"
|
|
46
45
|
},
|
|
47
46
|
"devDependencies": {
|
|
48
|
-
"@babel/cli": "
|
|
49
|
-
"@babel/core": "
|
|
50
|
-
"@babel/plugin-proposal-class-properties": "
|
|
51
|
-
"@babel/preset-env": "
|
|
52
|
-
"@babel/preset-typescript": "
|
|
53
|
-
"@
|
|
54
|
-
"@
|
|
55
|
-
"@types/
|
|
56
|
-
"@types/
|
|
57
|
-
"@types/
|
|
58
|
-
"@
|
|
59
|
-
"@
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"eslint-plugin
|
|
64
|
-
"
|
|
65
|
-
"jest": "
|
|
66
|
-
"
|
|
67
|
-
"prettier": "
|
|
68
|
-
"
|
|
69
|
-
"
|
|
47
|
+
"@babel/cli": "7.26.4",
|
|
48
|
+
"@babel/core": "7.26.0",
|
|
49
|
+
"@babel/plugin-proposal-class-properties": "7.18.6",
|
|
50
|
+
"@babel/preset-env": "7.26.0",
|
|
51
|
+
"@babel/preset-typescript": "7.26.0",
|
|
52
|
+
"@eslint/core": "0.9.1",
|
|
53
|
+
"@eslint/js": "9.17.0",
|
|
54
|
+
"@types/eslint__js": "8.42.3",
|
|
55
|
+
"@types/jest": "29.5.14",
|
|
56
|
+
"@types/lodash": "4.17.13",
|
|
57
|
+
"@types/lru-cache": "5.1.1",
|
|
58
|
+
"@types/node": "20.17.10",
|
|
59
|
+
"@types/node-fetch": "2.6.12",
|
|
60
|
+
"@types/semver": "7.5.8",
|
|
61
|
+
"@types/topojson-specification": "1.0.5",
|
|
62
|
+
"@typescript-eslint/eslint-plugin": "8.18.1",
|
|
63
|
+
"@typescript-eslint/parser": "8.18.1",
|
|
64
|
+
"babel-jest": "29.7.0",
|
|
65
|
+
"eslint": "9.17.0",
|
|
66
|
+
"eslint-config-prettier": "9.1.0",
|
|
67
|
+
"eslint-plugin-prettier": "5.2.1",
|
|
68
|
+
"globals": "15.14.0",
|
|
69
|
+
"husky": "9.1.7",
|
|
70
|
+
"jest": "29.7.0",
|
|
71
|
+
"prettier": "3.4.2",
|
|
72
|
+
"ts-jest": "29.2.5",
|
|
73
|
+
"typescript": "5.7.2",
|
|
74
|
+
"typescript-eslint": "8.18.1"
|
|
70
75
|
},
|
|
71
76
|
"engines": {
|
|
72
77
|
"node": ">=18 <=20"
|
package/src/ems_client.ts
CHANGED
|
@@ -15,6 +15,7 @@ import { format as formatUrl, parse as parseUrl, UrlObject } from 'url';
|
|
|
15
15
|
import { toAbsoluteUrl } from './utils';
|
|
16
16
|
import { ParsedUrlQueryInput } from 'querystring';
|
|
17
17
|
import LRUCache from 'lru-cache';
|
|
18
|
+
import { RequestInfo } from 'node-fetch';
|
|
18
19
|
|
|
19
20
|
const DEFAULT_EMS_VERSION = '7.17';
|
|
20
21
|
|
|
@@ -96,10 +97,10 @@ type BaseClientConfig = {
|
|
|
96
97
|
tileApiUrl: string;
|
|
97
98
|
fileApiUrl: string;
|
|
98
99
|
emsVersion?: string;
|
|
99
|
-
htmlSanitizer?:
|
|
100
|
+
htmlSanitizer?: (x: string) => string;
|
|
100
101
|
language?: string;
|
|
101
102
|
landingPageUrl?: string;
|
|
102
|
-
fetchFunction:
|
|
103
|
+
fetchFunction: (url: RequestInfo) => Promise<Response>;
|
|
103
104
|
proxyPath?: string;
|
|
104
105
|
cacheSize?: number;
|
|
105
106
|
};
|
|
@@ -204,8 +205,8 @@ export class EMSClient {
|
|
|
204
205
|
readonly EMS_LOAD_TIMEOUT = 32000;
|
|
205
206
|
private _queryParams: QueryParams;
|
|
206
207
|
private readonly _appVersion: string;
|
|
207
|
-
private readonly _fetchFunction:
|
|
208
|
-
private readonly _sanitizer:
|
|
208
|
+
private readonly _fetchFunction: (url: RequestInfo) => Promise<Response>;
|
|
209
|
+
private readonly _sanitizer: (x: string) => string;
|
|
209
210
|
private readonly _manifestServiceUrl?: string;
|
|
210
211
|
private readonly _fileApiUrl: string;
|
|
211
212
|
private readonly _tileApiUrl: string;
|
|
@@ -218,11 +219,11 @@ export class EMSClient {
|
|
|
218
219
|
/**
|
|
219
220
|
* these methods are assigned outside the constructor
|
|
220
221
|
*/
|
|
221
|
-
private _getMainCatalog!:
|
|
222
|
-
private _getDefaultTMSCatalog!:
|
|
223
|
-
private _getDefaultFileCatalog!:
|
|
224
|
-
private _loadTMSServices!:
|
|
225
|
-
private _loadFileLayers!:
|
|
222
|
+
private _getMainCatalog!: () => Promise<EmsCatalogManifest>;
|
|
223
|
+
private _getDefaultTMSCatalog!: () => Promise<EmsTmsCatalog>;
|
|
224
|
+
private _getDefaultFileCatalog!: () => Promise<EmsFileCatalog>;
|
|
225
|
+
private _loadTMSServices!: () => Promise<TMSService[]>;
|
|
226
|
+
private _loadFileLayers!: () => Promise<FileLayer[]>;
|
|
226
227
|
|
|
227
228
|
constructor(config: ClientConfig | DeprecatedClientConfig) {
|
|
228
229
|
// Remove kbnVersion in 8.0
|
|
@@ -300,7 +301,7 @@ export class EMSClient {
|
|
|
300
301
|
*/
|
|
301
302
|
addQueryParams(additionalQueryParams: { [key: string]: string }): void {
|
|
302
303
|
for (const key in additionalQueryParams) {
|
|
303
|
-
if (
|
|
304
|
+
if (Object.prototype.hasOwnProperty.call(additionalQueryParams, key)) {
|
|
304
305
|
if (additionalQueryParams[key] !== this._queryParams[key]) {
|
|
305
306
|
//changes detected.
|
|
306
307
|
this._queryParams = _.assign({}, this._queryParams, additionalQueryParams);
|
package/src/tms_service.ts
CHANGED
|
@@ -252,13 +252,12 @@ export class TMSService extends AbstractEmsService {
|
|
|
252
252
|
vectorFormats = this._getFormats(formatType, this._emsClient.getDefaultLocale());
|
|
253
253
|
}
|
|
254
254
|
if (!vectorFormats.length) {
|
|
255
|
-
// eslint-disable-next-line max-len
|
|
256
255
|
throw new Error(
|
|
257
256
|
`Cannot find ${formatType} tile layer for locale ${this._emsClient.getLocale()} or ${this._emsClient.getDefaultLocale()}`
|
|
258
257
|
);
|
|
259
258
|
}
|
|
260
259
|
const defaultStyle = vectorFormats[0];
|
|
261
|
-
if (defaultStyle &&
|
|
260
|
+
if (defaultStyle && Object.prototype.hasOwnProperty.call(defaultStyle, 'url')) {
|
|
262
261
|
return defaultStyle.url;
|
|
263
262
|
}
|
|
264
263
|
}
|
package/target/ems_client.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { TMSService } from './tms_service';
|
|
2
2
|
import { EMSFormatType, FileLayer } from './file_layer';
|
|
3
3
|
import { FeatureCollection } from 'geojson';
|
|
4
|
+
import { Response } from 'node-fetch';
|
|
5
|
+
import { RequestInfo } from 'node-fetch';
|
|
4
6
|
type LocalizedStrings = {
|
|
5
7
|
[key: string]: string;
|
|
6
8
|
};
|
|
@@ -10,10 +12,10 @@ type BaseClientConfig = {
|
|
|
10
12
|
tileApiUrl: string;
|
|
11
13
|
fileApiUrl: string;
|
|
12
14
|
emsVersion?: string;
|
|
13
|
-
htmlSanitizer?:
|
|
15
|
+
htmlSanitizer?: (x: string) => string;
|
|
14
16
|
language?: string;
|
|
15
17
|
landingPageUrl?: string;
|
|
16
|
-
fetchFunction:
|
|
18
|
+
fetchFunction: (url: RequestInfo) => Promise<Response>;
|
|
17
19
|
proxyPath?: string;
|
|
18
20
|
cacheSize?: number;
|
|
19
21
|
};
|
|
@@ -167,7 +167,7 @@ class EMSClient {
|
|
|
167
167
|
*/
|
|
168
168
|
addQueryParams(additionalQueryParams) {
|
|
169
169
|
for (const key in additionalQueryParams) {
|
|
170
|
-
if (
|
|
170
|
+
if (Object.prototype.hasOwnProperty.call(additionalQueryParams, key)) {
|
|
171
171
|
if (additionalQueryParams[key] !== this._queryParams[key]) {
|
|
172
172
|
//changes detected.
|
|
173
173
|
this._queryParams = _lodash.default.assign({}, this._queryParams, additionalQueryParams);
|
|
@@ -184,11 +184,10 @@ class TMSService extends _ems_service.AbstractEmsService {
|
|
|
184
184
|
vectorFormats = this._getFormats(formatType, this._emsClient.getDefaultLocale());
|
|
185
185
|
}
|
|
186
186
|
if (!vectorFormats.length) {
|
|
187
|
-
// eslint-disable-next-line max-len
|
|
188
187
|
throw new Error(`Cannot find ${formatType} tile layer for locale ${this._emsClient.getLocale()} or ${this._emsClient.getDefaultLocale()}`);
|
|
189
188
|
}
|
|
190
189
|
const defaultStyle = vectorFormats[0];
|
|
191
|
-
if (defaultStyle &&
|
|
190
|
+
if (defaultStyle && Object.prototype.hasOwnProperty.call(defaultStyle, 'url')) {
|
|
192
191
|
return defaultStyle.url;
|
|
193
192
|
}
|
|
194
193
|
}
|
package/target/web/ems_client.js
CHANGED
|
@@ -161,7 +161,7 @@ export var EMSClient = /*#__PURE__*/function () {
|
|
|
161
161
|
}, {
|
|
162
162
|
key: "getManifest",
|
|
163
163
|
value: (function () {
|
|
164
|
-
var _getManifest = _asyncToGenerator(
|
|
164
|
+
var _getManifest = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(endpointUrl) {
|
|
165
165
|
var url, response;
|
|
166
166
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
167
167
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -225,7 +225,7 @@ export var EMSClient = /*#__PURE__*/function () {
|
|
|
225
225
|
key: "addQueryParams",
|
|
226
226
|
value: function addQueryParams(additionalQueryParams) {
|
|
227
227
|
for (var _key in additionalQueryParams) {
|
|
228
|
-
if (
|
|
228
|
+
if (Object.prototype.hasOwnProperty.call(additionalQueryParams, _key)) {
|
|
229
229
|
if (additionalQueryParams[_key] !== this._queryParams[_key]) {
|
|
230
230
|
//changes detected.
|
|
231
231
|
this._queryParams = _.assign({}, this._queryParams, additionalQueryParams);
|
|
@@ -238,7 +238,7 @@ export var EMSClient = /*#__PURE__*/function () {
|
|
|
238
238
|
}, {
|
|
239
239
|
key: "getMainManifest",
|
|
240
240
|
value: function () {
|
|
241
|
-
var _getMainManifest = _asyncToGenerator(
|
|
241
|
+
var _getMainManifest = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
242
242
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
243
243
|
while (1) switch (_context2.prev = _context2.next) {
|
|
244
244
|
case 0:
|
|
@@ -260,7 +260,7 @@ export var EMSClient = /*#__PURE__*/function () {
|
|
|
260
260
|
}, {
|
|
261
261
|
key: "getDefaultFileManifest",
|
|
262
262
|
value: function () {
|
|
263
|
-
var _getDefaultFileManifest = _asyncToGenerator(
|
|
263
|
+
var _getDefaultFileManifest = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
264
264
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
265
265
|
while (1) switch (_context3.prev = _context3.next) {
|
|
266
266
|
case 0:
|
|
@@ -282,7 +282,7 @@ export var EMSClient = /*#__PURE__*/function () {
|
|
|
282
282
|
}, {
|
|
283
283
|
key: "getDefaultTMSManifest",
|
|
284
284
|
value: function () {
|
|
285
|
-
var _getDefaultTMSManifest = _asyncToGenerator(
|
|
285
|
+
var _getDefaultTMSManifest = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
286
286
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
287
287
|
while (1) switch (_context4.prev = _context4.next) {
|
|
288
288
|
case 0:
|
|
@@ -304,7 +304,7 @@ export var EMSClient = /*#__PURE__*/function () {
|
|
|
304
304
|
}, {
|
|
305
305
|
key: "getFileLayers",
|
|
306
306
|
value: function () {
|
|
307
|
-
var _getFileLayers = _asyncToGenerator(
|
|
307
|
+
var _getFileLayers = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
308
308
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
309
309
|
while (1) switch (_context5.prev = _context5.next) {
|
|
310
310
|
case 0:
|
|
@@ -326,7 +326,7 @@ export var EMSClient = /*#__PURE__*/function () {
|
|
|
326
326
|
}, {
|
|
327
327
|
key: "getTMSServices",
|
|
328
328
|
value: function () {
|
|
329
|
-
var _getTMSServices = _asyncToGenerator(
|
|
329
|
+
var _getTMSServices = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
330
330
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
331
331
|
while (1) switch (_context6.prev = _context6.next) {
|
|
332
332
|
case 0:
|
|
@@ -386,7 +386,7 @@ export var EMSClient = /*#__PURE__*/function () {
|
|
|
386
386
|
}, {
|
|
387
387
|
key: "findFileLayerById",
|
|
388
388
|
value: function () {
|
|
389
|
-
var _findFileLayerById = _asyncToGenerator(
|
|
389
|
+
var _findFileLayerById = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(id) {
|
|
390
390
|
var fileLayers, i;
|
|
391
391
|
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
392
392
|
while (1) switch (_context7.prev = _context7.next) {
|
|
@@ -424,7 +424,7 @@ export var EMSClient = /*#__PURE__*/function () {
|
|
|
424
424
|
}, {
|
|
425
425
|
key: "findTMSServiceById",
|
|
426
426
|
value: function () {
|
|
427
|
-
var _findTMSServiceById = _asyncToGenerator(
|
|
427
|
+
var _findTMSServiceById = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(id) {
|
|
428
428
|
var tmsServices, i;
|
|
429
429
|
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
430
430
|
while (1) switch (_context8.prev = _context8.next) {
|
|
@@ -490,7 +490,7 @@ export var EMSClient = /*#__PURE__*/function () {
|
|
|
490
490
|
}, {
|
|
491
491
|
key: "_getManifestWithParams",
|
|
492
492
|
value: function () {
|
|
493
|
-
var _getManifestWithParams2 = _asyncToGenerator(
|
|
493
|
+
var _getManifestWithParams2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(url) {
|
|
494
494
|
var extendedUrl;
|
|
495
495
|
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
496
496
|
while (1) switch (_context9.prev = _context9.next) {
|
|
@@ -516,7 +516,7 @@ export var EMSClient = /*#__PURE__*/function () {
|
|
|
516
516
|
value: function _invalidateSettings() {
|
|
517
517
|
var _this2 = this;
|
|
518
518
|
this._cache.reset();
|
|
519
|
-
this._getMainCatalog = _.once(
|
|
519
|
+
this._getMainCatalog = _.once(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
520
520
|
var services;
|
|
521
521
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
522
522
|
while (1) switch (_context10.prev = _context10.next) {
|
|
@@ -553,7 +553,7 @@ export var EMSClient = /*#__PURE__*/function () {
|
|
|
553
553
|
}
|
|
554
554
|
}, _callee10);
|
|
555
555
|
})));
|
|
556
|
-
this._getDefaultTMSCatalog = _.once(
|
|
556
|
+
this._getDefaultTMSCatalog = _.once(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
557
557
|
var catalogue, firstService, url;
|
|
558
558
|
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
559
559
|
while (1) switch (_context11.prev = _context11.next) {
|
|
@@ -584,7 +584,7 @@ export var EMSClient = /*#__PURE__*/function () {
|
|
|
584
584
|
}
|
|
585
585
|
}, _callee11);
|
|
586
586
|
})));
|
|
587
|
-
this._getDefaultFileCatalog = _.once(
|
|
587
|
+
this._getDefaultFileCatalog = _.once(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
588
588
|
var catalogue, firstService, url;
|
|
589
589
|
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
590
590
|
while (1) switch (_context12.prev = _context12.next) {
|
|
@@ -617,7 +617,7 @@ export var EMSClient = /*#__PURE__*/function () {
|
|
|
617
617
|
})));
|
|
618
618
|
|
|
619
619
|
//Cache the actual instances of TMSService as these in turn cache sub-manifests for the style-files
|
|
620
|
-
this._loadTMSServices = _.once(
|
|
620
|
+
this._loadTMSServices = _.once(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
621
621
|
var tmsManifest;
|
|
622
622
|
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
623
623
|
while (1) switch (_context13.prev = _context13.next) {
|
|
@@ -635,7 +635,7 @@ export var EMSClient = /*#__PURE__*/function () {
|
|
|
635
635
|
}
|
|
636
636
|
}, _callee13);
|
|
637
637
|
})));
|
|
638
|
-
this._loadFileLayers = _.once(
|
|
638
|
+
this._loadFileLayers = _.once(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
|
639
639
|
var fileManifest;
|
|
640
640
|
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
641
641
|
while (1) switch (_context14.prev = _context14.next) {
|
package/target/web/file_layer.js
CHANGED
|
@@ -45,7 +45,7 @@ export var FileLayer = /*#__PURE__*/function (_AbstractEmsService) {
|
|
|
45
45
|
return _createClass(FileLayer, [{
|
|
46
46
|
key: "getGeoJson",
|
|
47
47
|
value: function () {
|
|
48
|
-
var _getGeoJson = _asyncToGenerator(
|
|
48
|
+
var _getGeoJson = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
49
49
|
var cachedGeoJson, format, fetchUrl, geojson, fetchedJson, _meta$feature_collect, meta, featureCollectionPath;
|
|
50
50
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
51
51
|
while (1) switch (_context.prev = _context.next) {
|