@basemaps/shared 6.7.0 → 6.11.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 +61 -0
- package/build/__test__/api.path.test.js +57 -60
- package/build/__test__/api.test.js +29 -32
- package/build/__test__/env.test.js +9 -12
- package/build/__test__/util.test.js +36 -39
- package/build/__test__/vdom.parse.test.js +18 -21
- package/build/__test__/vdom.test.js +29 -32
- package/build/api.js +6 -10
- package/build/api.path.d.ts.map +1 -1
- package/build/api.path.js +15 -23
- package/build/aws/aws.dynamo.table.d.ts.map +1 -1
- package/build/aws/aws.dynamo.table.js +1 -2
- package/build/cli/__test__/git.tag.test.js +7 -10
- package/build/cli/api.key.js +4 -9
- package/build/cli/git.tag.js +4 -8
- package/build/composite.error.d.ts +1 -7
- package/build/composite.error.d.ts.map +1 -1
- package/build/composite.error.js +1 -13
- package/build/const.d.ts.map +1 -1
- package/build/const.js +3 -6
- package/build/file/__test__/file.local.test.js +19 -19
- package/build/file/__test__/file.operator.test.helper.d.ts.map +1 -1
- package/build/file/__test__/file.operator.test.helper.js +17 -21
- package/build/file/file.config.d.ts.map +1 -1
- package/build/file/file.config.js +2 -7
- package/build/file/index.d.ts +3 -3
- package/build/file/index.d.ts.map +1 -1
- package/build/file/index.js +14 -23
- package/build/index.d.ts +13 -14
- package/build/index.d.ts.map +1 -1
- package/build/index.js +18 -35
- package/build/log.d.ts +0 -3
- package/build/log.d.ts.map +1 -1
- package/build/log.js +6 -16
- package/build/logger.fatal.error.d.ts.map +1 -1
- package/build/logger.fatal.error.js +1 -5
- package/build/proj/__test__/projection.test.js +30 -33
- package/build/proj/__test__/projection.tile.matrix.set.test.js +130 -78
- package/build/proj/__test__/test.util.d.ts.map +1 -1
- package/build/proj/__test__/test.util.js +10 -17
- package/build/proj/citm2000.js +1 -4
- package/build/proj/nztm2000.js +1 -4
- package/build/proj/projection.d.ts +44 -33
- package/build/proj/projection.d.ts.map +1 -1
- package/build/proj/projection.js +84 -53
- package/build/proj/tile.set.name.d.ts.map +1 -1
- package/build/proj/tile.set.name.js +3 -7
- package/build/util.d.ts.map +1 -1
- package/build/util.js +5 -13
- package/build/vdom.d.ts.map +1 -1
- package/build/vdom.js +4 -11
- package/build/vdom.parse.d.ts +1 -1
- package/build/vdom.parse.d.ts.map +1 -1
- package/build/vdom.parse.js +5 -10
- package/package.json +12 -8
- package/build/__test__/aws.init.test.d.ts +0 -2
- package/build/__test__/aws.init.test.d.ts.map +0 -1
- package/build/__test__/aws.init.test.js +0 -9
- package/build/aws/api.key.table.d.ts +0 -29
- package/build/aws/api.key.table.d.ts.map +0 -1
- package/build/aws/api.key.table.js +0 -38
- package/build/aws/credentials.d.ts +0 -21
- package/build/aws/credentials.d.ts.map +0 -1
- package/build/aws/credentials.js +0 -42
- package/build/aws/index.d.ts +0 -18
- package/build/aws/index.d.ts.map +0 -1
- package/build/aws/index.js +0 -38
- package/build/aws/object.cache.d.ts +0 -6
- package/build/aws/object.cache.d.ts.map +0 -1
- package/build/aws/object.cache.js +0 -17
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,67 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [6.11.0](https://github.com/linz/basemaps/compare/v6.10.1...v6.11.0) (2021-10-03)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **server:** use the lambda handler directly ([#1870](https://github.com/linz/basemaps/issues/1870)) ([408ff56](https://github.com/linz/basemaps/commit/408ff5654cc04aae35d05eb5bbc47a51f99ec5b2))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [6.10.0](https://github.com/linz/basemaps/compare/v6.9.1...v6.10.0) (2021-09-22)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* correctly bundle with esm modules ([#1858](https://github.com/linz/basemaps/issues/1858)) ([708a22e](https://github.com/linz/basemaps/commit/708a22ec1006c25cf2c057b75f61cc813e943aac))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
|
|
27
|
+
* replace s3fs with chunkd/fs ([#1859](https://github.com/linz/basemaps/issues/1859)) ([9b6f2d3](https://github.com/linz/basemaps/commit/9b6f2d3609c336f96c2ae32246f241cb396e71c8))
|
|
28
|
+
* switch to esm modules ([#1857](https://github.com/linz/basemaps/issues/1857)) ([75bdff8](https://github.com/linz/basemaps/commit/75bdff8da35104f10f6b6ecf58a2c6006245af6e))
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
## [6.9.1](https://github.com/linz/basemaps/compare/v6.9.0...v6.9.1) (2021-09-09)
|
|
35
|
+
|
|
36
|
+
**Note:** Version bump only for package @basemaps/shared
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
# [6.9.0](https://github.com/linz/basemaps/compare/v6.8.0...v6.9.0) (2021-09-09)
|
|
43
|
+
|
|
44
|
+
**Note:** Version bump only for package @basemaps/shared
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
# [6.8.0](https://github.com/linz/basemaps/compare/v6.7.0...v6.8.0) (2021-09-01)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
### Bug Fixes
|
|
54
|
+
|
|
55
|
+
* **proj:** wrap lat lon bounds into the world bounds ([#1828](https://github.com/linz/basemaps/issues/1828)) ([617faf8](https://github.com/linz/basemaps/commit/617faf85d2252746de649c1bf5c41b16dfe085ba))
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
### Features
|
|
59
|
+
|
|
60
|
+
* **config:** enable configuration to be stored in memory rather than dynamodb ([#1817](https://github.com/linz/basemaps/issues/1817)) ([eb56f26](https://github.com/linz/basemaps/commit/eb56f2633c99c5372710ae12fc128a9e7fa7ed7d))
|
|
61
|
+
* **config:** enable swapping of configuration providers dynamically ([#1818](https://github.com/linz/basemaps/issues/1818)) ([e548ae5](https://github.com/linz/basemaps/commit/e548ae5219c7a5c6d5c6ed80c9f41c9637c3b554))
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
6
67
|
# [6.7.0](https://github.com/linz/basemaps/compare/v6.6.1...v6.7.0) (2021-08-15)
|
|
7
68
|
|
|
8
69
|
**Note:** Version bump only for package @basemaps/shared
|
|
@@ -1,104 +1,101 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
ospec_1.default.spec('tileXyzFromPath', () => {
|
|
10
|
-
ospec_1.default('should be case sensitive for tile matrix ids', () => {
|
|
11
|
-
ospec_1.default(api_path_1.tileXyzFromPath(['aerial', 'NZTM2000quad', '10', '3456', '5432.webp'])).deepEquals(null);
|
|
1
|
+
import { GoogleTms, Nztm2000Tms, Nztm2000QuadTms } from '@basemaps/geo';
|
|
2
|
+
import { ImageFormat } from '@basemaps/tiler';
|
|
3
|
+
import o from 'ospec';
|
|
4
|
+
import { tileAttributionFromPath, TileType, tileWmtsFromPath, tileXyzFromPath, VectorFormat } from '../api.path.js';
|
|
5
|
+
o.spec('api.path', () => {
|
|
6
|
+
o.spec('tileXyzFromPath', () => {
|
|
7
|
+
o('should be case sensitive for tile matrix ids', () => {
|
|
8
|
+
o(tileXyzFromPath(['aerial', 'NZTM2000quad', '10', '3456', '5432.webp'])).deepEquals(null);
|
|
12
9
|
});
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
o('should support only known extensions', () => {
|
|
11
|
+
o(tileXyzFromPath(['aerial', 'NZTM2000Quad', '10', '3456', '5432.FAKE'])).deepEquals(null);
|
|
15
12
|
});
|
|
16
|
-
for (const ext of Object.values(
|
|
17
|
-
|
|
13
|
+
for (const ext of Object.values(ImageFormat)) {
|
|
14
|
+
o('should support image format:' + ext, () => {
|
|
18
15
|
var _a;
|
|
19
|
-
|
|
16
|
+
o((_a = tileXyzFromPath(['aerial', 'NZTM2000Quad', '10', '3456', '5432.' + ext])) === null || _a === void 0 ? void 0 : _a.ext).equals(ext);
|
|
20
17
|
});
|
|
21
18
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
type:
|
|
19
|
+
o('should be case insensitive for file names', () => {
|
|
20
|
+
o(tileWmtsFromPath(['aerial', 'NZTM2000Quad', 'wmtsCapabilities.XML'])).deepEquals({
|
|
21
|
+
type: TileType.WMTS,
|
|
25
22
|
name: 'aerial',
|
|
26
|
-
tileMatrix:
|
|
23
|
+
tileMatrix: Nztm2000QuadTms,
|
|
27
24
|
});
|
|
28
25
|
});
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
type:
|
|
26
|
+
o('should parse tiles from path', () => {
|
|
27
|
+
o(tileXyzFromPath(['aerial', 'EPSG:3857', '10', '3456', '5432.webp'])).deepEquals({
|
|
28
|
+
type: TileType.Tile,
|
|
32
29
|
name: 'aerial',
|
|
33
|
-
tileMatrix:
|
|
30
|
+
tileMatrix: GoogleTms,
|
|
34
31
|
x: 3456,
|
|
35
32
|
y: 5432,
|
|
36
33
|
z: 10,
|
|
37
|
-
ext:
|
|
34
|
+
ext: ImageFormat.WEBP,
|
|
38
35
|
});
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
type:
|
|
36
|
+
o(tileXyzFromPath([])).equals(null);
|
|
37
|
+
o(tileXyzFromPath(['aerial', 'EPSG:3857', '10', '3456'])).equals(null);
|
|
38
|
+
o(tileXyzFromPath(['aerial', 'NZTM2000Quad', '10', '3456', '5432.webp'])).deepEquals({
|
|
39
|
+
type: TileType.Tile,
|
|
43
40
|
name: 'aerial',
|
|
44
|
-
tileMatrix:
|
|
41
|
+
tileMatrix: Nztm2000QuadTms,
|
|
45
42
|
x: 3456,
|
|
46
43
|
y: 5432,
|
|
47
44
|
z: 10,
|
|
48
|
-
ext:
|
|
45
|
+
ext: ImageFormat.WEBP,
|
|
49
46
|
});
|
|
50
47
|
});
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
type:
|
|
48
|
+
o('should parse vector tiles', () => {
|
|
49
|
+
o(tileXyzFromPath(['aerial', 'NZTM2000Quad', '10', '3456', '5432.pbf'])).deepEquals({
|
|
50
|
+
type: TileType.Tile,
|
|
54
51
|
name: 'aerial',
|
|
55
|
-
tileMatrix:
|
|
52
|
+
tileMatrix: Nztm2000QuadTms,
|
|
56
53
|
x: 3456,
|
|
57
54
|
y: 5432,
|
|
58
55
|
z: 10,
|
|
59
|
-
ext:
|
|
56
|
+
ext: VectorFormat.MapboxVectorTiles,
|
|
60
57
|
});
|
|
61
58
|
});
|
|
62
59
|
});
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
type:
|
|
60
|
+
o('tileWmtsFromPath', () => {
|
|
61
|
+
o(tileWmtsFromPath(['aerial', 'EPSG:3857', 'WMTSCapabilities.xml'])).deepEquals({
|
|
62
|
+
type: TileType.WMTS,
|
|
66
63
|
name: 'aerial',
|
|
67
|
-
tileMatrix:
|
|
64
|
+
tileMatrix: GoogleTms,
|
|
68
65
|
});
|
|
69
|
-
|
|
70
|
-
type:
|
|
66
|
+
o(tileWmtsFromPath(['aerial', 'EPSG:2193', 'WMTSCapabilities.xml'])).deepEquals({
|
|
67
|
+
type: TileType.WMTS,
|
|
71
68
|
name: 'aerial',
|
|
72
|
-
tileMatrix:
|
|
69
|
+
tileMatrix: Nztm2000Tms,
|
|
73
70
|
});
|
|
74
|
-
|
|
75
|
-
type:
|
|
71
|
+
o(tileWmtsFromPath(['aerial', 'NZTM2000', 'WMTSCapabilities.xml'])).deepEquals({
|
|
72
|
+
type: TileType.WMTS,
|
|
76
73
|
name: 'aerial',
|
|
77
|
-
tileMatrix:
|
|
74
|
+
tileMatrix: Nztm2000Tms,
|
|
78
75
|
});
|
|
79
|
-
|
|
80
|
-
type:
|
|
76
|
+
o(tileWmtsFromPath(['aerial', 'WebMercatorQuad', 'WMTSCapabilities.xml'])).deepEquals({
|
|
77
|
+
type: TileType.WMTS,
|
|
81
78
|
name: 'aerial',
|
|
82
|
-
tileMatrix:
|
|
79
|
+
tileMatrix: GoogleTms,
|
|
83
80
|
});
|
|
84
|
-
|
|
85
|
-
type:
|
|
81
|
+
o(tileWmtsFromPath(['aerial', 'NZTM2000Quad', 'WMTSCapabilities.xml'])).deepEquals({
|
|
82
|
+
type: TileType.WMTS,
|
|
86
83
|
name: 'aerial',
|
|
87
|
-
tileMatrix:
|
|
84
|
+
tileMatrix: Nztm2000QuadTms,
|
|
88
85
|
});
|
|
89
|
-
|
|
90
|
-
type:
|
|
86
|
+
o(tileWmtsFromPath([])).deepEquals({
|
|
87
|
+
type: TileType.WMTS,
|
|
91
88
|
name: '',
|
|
92
89
|
tileMatrix: null,
|
|
93
90
|
});
|
|
94
91
|
});
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
type:
|
|
92
|
+
o('tileAttributionFromPath', () => {
|
|
93
|
+
o(tileAttributionFromPath(['aerial', 'EPSG:3857', 'attribution.json'])).deepEquals({
|
|
94
|
+
type: TileType.Attribution,
|
|
98
95
|
name: 'aerial',
|
|
99
|
-
tileMatrix:
|
|
96
|
+
tileMatrix: GoogleTms,
|
|
100
97
|
});
|
|
101
|
-
|
|
102
|
-
|
|
98
|
+
o(tileAttributionFromPath([])).equals(null);
|
|
99
|
+
o(tileAttributionFromPath(['aerial', 'attribution.json'])).equals(null);
|
|
103
100
|
});
|
|
104
101
|
});
|
|
@@ -1,48 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const api_1 = require("../api");
|
|
6
|
-
const ulid_1 = require("ulid");
|
|
7
|
-
ospec_1.default.spec('ApiKey', () => {
|
|
1
|
+
import o from 'ospec';
|
|
2
|
+
import { getApiKey, OneDayMs } from '../api.js';
|
|
3
|
+
import { ulid, decodeTime, encodeTime } from 'ulid';
|
|
4
|
+
o.spec('ApiKey', () => {
|
|
8
5
|
const localStorage = { getItem: () => null, setItem: () => undefined };
|
|
9
|
-
|
|
6
|
+
o.beforeEach(() => {
|
|
10
7
|
localStorage.getItem = () => null;
|
|
11
8
|
localStorage.setItem = () => undefined;
|
|
12
9
|
global.localStorage = localStorage;
|
|
13
10
|
});
|
|
14
|
-
|
|
11
|
+
o.afterEach(() => {
|
|
15
12
|
delete global.localStorage;
|
|
16
13
|
});
|
|
17
|
-
|
|
18
|
-
const apiKey =
|
|
19
|
-
|
|
14
|
+
o('should generate a ulid with prefix', () => {
|
|
15
|
+
const apiKey = getApiKey();
|
|
16
|
+
o(apiKey.startsWith('c')).equals(true);
|
|
20
17
|
const ulidKey = apiKey.slice(1).toUpperCase();
|
|
21
|
-
|
|
18
|
+
o(decodeTime(ulidKey) > 0).equals(true);
|
|
22
19
|
});
|
|
23
|
-
|
|
24
|
-
localStorage.getItem =
|
|
25
|
-
|
|
26
|
-
localStorage.getItem =
|
|
27
|
-
|
|
28
|
-
const newKey = 'c' +
|
|
29
|
-
localStorage.getItem =
|
|
30
|
-
|
|
20
|
+
o('should get valid api keys from localStorage', () => {
|
|
21
|
+
localStorage.getItem = o.spy(() => 'foo');
|
|
22
|
+
o(getApiKey()).notEquals('foo');
|
|
23
|
+
localStorage.getItem = o.spy(() => '01ebpv4fgbxqnff6kdc184bx0j');
|
|
24
|
+
o(getApiKey()).notEquals('01ebpv4fgbxqnff6kdc184bx0j');
|
|
25
|
+
const newKey = 'c' + ulid().toLowerCase();
|
|
26
|
+
localStorage.getItem = o.spy(() => newKey);
|
|
27
|
+
o(getApiKey()).equals(newKey);
|
|
31
28
|
});
|
|
32
|
-
|
|
33
|
-
const setSpy =
|
|
29
|
+
o('should generate new keys after they expire', () => {
|
|
30
|
+
const setSpy = o.spy();
|
|
34
31
|
localStorage.setItem = setSpy;
|
|
35
32
|
// Generate a key that is about 31 days old
|
|
36
|
-
const oldDate = Date.now() -
|
|
37
|
-
const fakeUlid = 'c' +
|
|
38
|
-
localStorage.getItem =
|
|
33
|
+
const oldDate = Date.now() - OneDayMs * 31;
|
|
34
|
+
const fakeUlid = 'c' + encodeTime(oldDate, 10) + ulid().slice(10);
|
|
35
|
+
localStorage.getItem = o.spy(() => fakeUlid.toLowerCase());
|
|
39
36
|
// the fake ulid should be able to be decoded too
|
|
40
|
-
const t =
|
|
41
|
-
|
|
42
|
-
const newApiKey =
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
const t = decodeTime(fakeUlid.slice(1).toUpperCase());
|
|
38
|
+
o(t - oldDate < 1000).equals(true);
|
|
39
|
+
const newApiKey = getApiKey();
|
|
40
|
+
o(setSpy.args).deepEquals(['api-key', newApiKey]);
|
|
41
|
+
o(newApiKey).notEquals(fakeUlid.toLocaleLowerCase());
|
|
45
42
|
// new key should be made recently (within 1second)
|
|
46
|
-
|
|
43
|
+
o(Date.now() - decodeTime(newApiKey.slice(1).toUpperCase()) < 1000).equals(true);
|
|
47
44
|
});
|
|
48
45
|
});
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
ospec_1.default('should load a number from environment var', () => {
|
|
8
|
-
process.env[const_1.Env.TiffConcurrency] = '5';
|
|
9
|
-
ospec_1.default(const_1.Env.getNumber(const_1.Env.TiffConcurrency, -1)).equals(5);
|
|
1
|
+
import { Env } from '../const.js';
|
|
2
|
+
import o from 'ospec';
|
|
3
|
+
o.spec('Environment', () => {
|
|
4
|
+
o('should load a number from environment var', () => {
|
|
5
|
+
process.env[Env.TiffConcurrency] = '5';
|
|
6
|
+
o(Env.getNumber(Env.TiffConcurrency, -1)).equals(5);
|
|
10
7
|
});
|
|
11
|
-
|
|
12
|
-
delete process.env[
|
|
13
|
-
|
|
8
|
+
o('should default from environment var', () => {
|
|
9
|
+
delete process.env[Env.TiffConcurrency];
|
|
10
|
+
o(Env.getNumber(Env.TiffConcurrency, -1)).equals(-1);
|
|
14
11
|
});
|
|
15
12
|
});
|
|
@@ -1,47 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
ospec_1.default(util_1.extractYearRangeFromName('2019_abc2020')).deepEquals([2019, 2021]);
|
|
13
|
-
ospec_1.default(util_1.extractYearRangeFromName('2020_abc2019')).deepEquals([2019, 2021]);
|
|
14
|
-
ospec_1.default(util_1.extractYearRangeFromName('2020-23abc')).deepEquals([2020, 2024]);
|
|
1
|
+
import o from 'ospec';
|
|
2
|
+
import { extractYearRangeFromName, getUrlHost, s3ToVsis3, titleizeImageryName } from '../util.js';
|
|
3
|
+
o.spec('util', () => {
|
|
4
|
+
o('extractYearRangeFromName', () => {
|
|
5
|
+
o(extractYearRangeFromName('2013')).deepEquals([2013, 2014]);
|
|
6
|
+
o(extractYearRangeFromName('abc2017def')).deepEquals([2017, 2018]);
|
|
7
|
+
o(extractYearRangeFromName('2019_abc')).deepEquals([2019, 2020]);
|
|
8
|
+
o(extractYearRangeFromName('12019_abc')).deepEquals([-1, -1]);
|
|
9
|
+
o(extractYearRangeFromName('2019_abc2020')).deepEquals([2019, 2021]);
|
|
10
|
+
o(extractYearRangeFromName('2020_abc2019')).deepEquals([2019, 2021]);
|
|
11
|
+
o(extractYearRangeFromName('2020-23abc')).deepEquals([2020, 2024]);
|
|
15
12
|
});
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
o('titleizeImageryName', () => {
|
|
14
|
+
o(titleizeImageryName('palmerston-north_urban_2016-17_12-125m_RGBA')).equals('Palmerston-north urban 2016-17 12.125m RGBA');
|
|
15
|
+
o(titleizeImageryName('palmerston-north_urban_2016-17_12-125_RGBA')).equals('Palmerston-north urban 2016-17 12-125 RGBA');
|
|
19
16
|
});
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
o('s3ToVsis3', () => {
|
|
18
|
+
o(s3ToVsis3('s3://rest/of/path')).equals('/vsis3/rest/of/path');
|
|
19
|
+
o(s3ToVsis3('s3:/rest/of/path')).equals('s3:/rest/of/path');
|
|
20
|
+
o(s3ToVsis3('/s3://rest/of/path')).equals('/s3://rest/of/path');
|
|
24
21
|
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
22
|
+
o.spec('getUrlHost', () => {
|
|
23
|
+
o("should normalize referer's", () => {
|
|
24
|
+
o(getUrlHost('https://127.0.0.244/')).equals('127.0.0.244');
|
|
25
|
+
o(getUrlHost('https://foo.d/')).equals('foo.d');
|
|
26
|
+
o(getUrlHost('https://foo.d/bar/baz.html?q=1234')).equals('foo.d');
|
|
27
|
+
o(getUrlHost('http://foo.d/bar/baz.html?q=1234')).equals('foo.d');
|
|
28
|
+
o(getUrlHost('http://basemaps.linz.govt.nz/?p=2193')).equals('basemaps.linz.govt.nz');
|
|
29
|
+
o(getUrlHost('s3://foo/bar/baz')).equals('foo');
|
|
30
|
+
o(getUrlHost('http://localhost:12344/bar/baz')).equals('localhost');
|
|
34
31
|
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
o('should normalize www.foo.com and foo.com ', () => {
|
|
33
|
+
o(getUrlHost('https://www.foo.com/')).equals('foo.com');
|
|
34
|
+
o(getUrlHost('https://bar.foo.com/')).equals('bar.foo.com');
|
|
35
|
+
o(getUrlHost('https://www3.foo.com/')).equals('www3.foo.com');
|
|
36
|
+
o(getUrlHost('https://foo.com/')).equals('foo.com');
|
|
40
37
|
});
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
o('should not die with badly formatted urls', () => {
|
|
39
|
+
o(getUrlHost('foo/bar')).equals('foo/bar');
|
|
40
|
+
o(getUrlHost('some weird text')).equals('some weird text');
|
|
41
|
+
o(getUrlHost(undefined)).equals(undefined);
|
|
45
42
|
});
|
|
46
43
|
});
|
|
47
44
|
});
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const ospec_1 = tslib_1.__importDefault(require("ospec"));
|
|
5
|
-
const vdom_parse_1 = require("../vdom.parse");
|
|
1
|
+
import o from 'ospec';
|
|
2
|
+
import { VNodeParser } from '../vdom.parse.js';
|
|
6
3
|
const VrtExample = `
|
|
7
4
|
<VRTDataset rasterXSize="36000" rasterYSize="3600">
|
|
8
5
|
<SRS dataAxisToSRSAxisMapping="2,1">PROJCS["NZGD2000 / New Zealand Transverse Mercator 2000",GEOGCS["NZGD2000",DATUM["New_Zealand_Geodetic_Datum_2000",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6167"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4167"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",173],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",1600000],PARAMETER["false_northing",10000000],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Northing",NORTH],AXIS["Easting",EAST],AUTHORITY["EPSG","2193"]]</SRS>
|
|
@@ -60,24 +57,24 @@ const VrtExample = `
|
|
|
60
57
|
</VRTRasterBand>
|
|
61
58
|
</VRTDataset>
|
|
62
59
|
`.trim();
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const node = await
|
|
66
|
-
|
|
60
|
+
o.spec('VDOM Parser', () => {
|
|
61
|
+
o('should base basic dom', async () => {
|
|
62
|
+
const node = await VNodeParser.parse('<div></div>');
|
|
63
|
+
o(node.toString()).equals('<div />');
|
|
67
64
|
});
|
|
68
|
-
|
|
69
|
-
const node = await
|
|
70
|
-
|
|
71
|
-
|
|
65
|
+
o('should base basic attrs', async () => {
|
|
66
|
+
const node = await VNodeParser.parse('<div class="foo" style="height:5px"></div>');
|
|
67
|
+
o(node.attrs).deepEquals({ class: 'foo', style: 'height:5px' });
|
|
68
|
+
o(node.toString()).equals('<div class="foo" style="height:5px" />');
|
|
72
69
|
});
|
|
73
|
-
|
|
74
|
-
const node = await
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
70
|
+
o('should parse children', async () => {
|
|
71
|
+
const node = await VNodeParser.parse('<div><span>Hello</span></div>');
|
|
72
|
+
o(node.tag).equals('div');
|
|
73
|
+
o(node.children.length).equals(1);
|
|
74
|
+
o(node.children[0].toString()).equals('<span>Hello</span>');
|
|
78
75
|
});
|
|
79
|
-
|
|
80
|
-
const node = await
|
|
81
|
-
|
|
76
|
+
o('should parse a vrt', async () => {
|
|
77
|
+
const node = await VNodeParser.parse(VrtExample);
|
|
78
|
+
o(node.toString()).equals(VrtExample);
|
|
82
79
|
});
|
|
83
80
|
});
|
|
@@ -1,43 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
ospec_1.default('should create text nodes', () => {
|
|
8
|
-
const res = vdom_1.V('div', 'text');
|
|
9
|
-
ospec_1.default(res instanceof vdom_1.VNode).equals(true);
|
|
1
|
+
import o from 'ospec';
|
|
2
|
+
import { V, VNode, VNodeText } from '../vdom.js';
|
|
3
|
+
o.spec('VDom', () => {
|
|
4
|
+
o('should create text nodes', () => {
|
|
5
|
+
const res = V('div', 'text');
|
|
6
|
+
o(res instanceof VNode).equals(true);
|
|
10
7
|
const tn = res.children[0];
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
o(tn.text).equals('text');
|
|
9
|
+
o(res.toString()).equals('<div>text</div>');
|
|
13
10
|
});
|
|
14
|
-
|
|
15
|
-
const res =
|
|
16
|
-
|
|
11
|
+
o('should create nodes', () => {
|
|
12
|
+
const res = V('div', {}, V('b', [V('span', { style: 'color:red' }, 'text')]));
|
|
13
|
+
o(res.toString()).equals('<div>\n <b>\n <span style="color:red">text</span>\n </b>\n</div>');
|
|
17
14
|
});
|
|
18
|
-
|
|
19
|
-
const span =
|
|
20
|
-
const res =
|
|
21
|
-
|
|
15
|
+
o('should get set textContent', () => {
|
|
16
|
+
const span = V('span', { style: 'color:red' }, 'in span');
|
|
17
|
+
const res = V('div', {}, V('b', [span, 'more text', V('b')]));
|
|
18
|
+
o(span.textContent).equals('in span');
|
|
22
19
|
span.textContent = 'changed';
|
|
23
|
-
|
|
20
|
+
o(res.textContent).equals('changedmore text');
|
|
24
21
|
res.textContent = 'replace';
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
o(res.textContent).equals('replace');
|
|
23
|
+
o(res.children.length).equals(1);
|
|
24
|
+
o(res.children[0] instanceof VNodeText).equals(true);
|
|
28
25
|
});
|
|
29
|
-
|
|
30
|
-
const iNode =
|
|
31
|
-
const res =
|
|
32
|
-
|
|
26
|
+
o.spec('find tags', () => {
|
|
27
|
+
const iNode = V('i', 'two');
|
|
28
|
+
const res = V('div', {}, V('b', [V('i', 'one'), V('span', { style: 'color:red' }, ['text', iNode]), V('b'), V('b')]));
|
|
29
|
+
o('tags', () => {
|
|
33
30
|
const bees = Array.from(res.tags('b'));
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
o(bees.length).equals(3);
|
|
32
|
+
o(bees[0].children.length).equals(4);
|
|
36
33
|
});
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
o('find', () => {
|
|
35
|
+
o(res.find('b', 'i', 'i')).equals(null);
|
|
36
|
+
o(res.find('b', 'span', 'i')).equals(iNode);
|
|
37
|
+
o(res.find('i')).notEquals(iNode);
|
|
41
38
|
});
|
|
42
39
|
});
|
|
43
40
|
});
|
package/build/api.js
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getApiKey = exports.OneDayMs = void 0;
|
|
4
|
-
const ulid_1 = require("ulid");
|
|
1
|
+
import { ulid, decodeTime } from 'ulid';
|
|
5
2
|
const hasLocalStorage = () => typeof localStorage !== 'undefined';
|
|
6
|
-
|
|
3
|
+
export const OneDayMs = 24 * 60 * 60 * 1000;
|
|
7
4
|
/** Generate a new api key for the user every 30 days */
|
|
8
|
-
const ApiKeyExpireMs = 30 *
|
|
5
|
+
const ApiKeyExpireMs = 30 * OneDayMs;
|
|
9
6
|
function newApiKey() {
|
|
10
|
-
const newKey = 'c' +
|
|
7
|
+
const newKey = 'c' + ulid().toLowerCase();
|
|
11
8
|
if (hasLocalStorage())
|
|
12
9
|
localStorage.setItem('api-key', newKey);
|
|
13
10
|
return newKey;
|
|
14
11
|
}
|
|
15
|
-
function getApiKey() {
|
|
12
|
+
export function getApiKey() {
|
|
16
13
|
if (!hasLocalStorage())
|
|
17
14
|
return newApiKey();
|
|
18
15
|
const apiKey = localStorage.getItem('api-key');
|
|
@@ -21,7 +18,7 @@ function getApiKey() {
|
|
|
21
18
|
if (!apiKey.startsWith('c'))
|
|
22
19
|
return newApiKey();
|
|
23
20
|
try {
|
|
24
|
-
const keyCreatedAt =
|
|
21
|
+
const keyCreatedAt = decodeTime(apiKey.slice(1).toUpperCase());
|
|
25
22
|
if (Date.now() - ApiKeyExpireMs < keyCreatedAt)
|
|
26
23
|
return apiKey;
|
|
27
24
|
return newApiKey();
|
|
@@ -31,4 +28,3 @@ function getApiKey() {
|
|
|
31
28
|
return newApiKey();
|
|
32
29
|
}
|
|
33
30
|
}
|
|
34
|
-
exports.getApiKey = getApiKey;
|
package/build/api.path.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.path.d.ts","sourceRoot":"","sources":["../src/api.path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,IAAI,EAAkB,aAAa,EAAE,MAAM,eAAe,CAAC;AAC1E,OAAO,EAAkB,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9D,MAAM,WAAW,UAAU;
|
|
1
|
+
{"version":3,"file":"api.path.d.ts","sourceRoot":"","sources":["../src/api.path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,IAAI,EAAkB,aAAa,EAAE,MAAM,eAAe,CAAC;AAC1E,OAAO,EAAkB,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9D,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,oBAAY,QAAQ;IAClB,IAAI,SAAS;IACb,IAAI,SAAS;IACb,WAAW,gBAAgB;CAC5B;AACD,oBAAY,YAAY;IACtB,iBAAiB,QAAQ;CAC1B;AAED,oBAAY,QAAQ,GAAG,WAAW,GAAG,YAAY,GAAG,mBAAmB,CAAC;AAExE,UAAU,cAAc;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,aAAa,CAAC;CAC3B;AAED,MAAM,WAAW,WAAY,SAAQ,IAAI,EAAE,cAAc;IACvD,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC;IACpB,GAAG,EAAE,WAAW,GAAG,YAAY,CAAC;CACjC;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,aAAa,GAAG,IAAI,CAAC;CAClC;AAED,MAAM,WAAW,mBAAoB,SAAQ,cAAc;IACzD,IAAI,EAAE,QAAQ,CAAC,WAAW,CAAC;CAC5B;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE;IAAE,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,KAAK,IAAI,CAAA;CAAE,EAAE,IAAI,EAAE,QAAQ,GAAG,IAAI,CAIxG;AAQD,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,WAAW,GAAG,IAAI,CAoBlE;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,mBAAmB,GAAG,IAAI,CAQlF;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,YAAY,GAAG,IAAI,CAWpE;AAED;;IAEI;AACJ,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,QAAQ,GAAG,IAAI,CAM5D"}
|