@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.
Files changed (70) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/build/__test__/api.path.test.js +57 -60
  3. package/build/__test__/api.test.js +29 -32
  4. package/build/__test__/env.test.js +9 -12
  5. package/build/__test__/util.test.js +36 -39
  6. package/build/__test__/vdom.parse.test.js +18 -21
  7. package/build/__test__/vdom.test.js +29 -32
  8. package/build/api.js +6 -10
  9. package/build/api.path.d.ts.map +1 -1
  10. package/build/api.path.js +15 -23
  11. package/build/aws/aws.dynamo.table.d.ts.map +1 -1
  12. package/build/aws/aws.dynamo.table.js +1 -2
  13. package/build/cli/__test__/git.tag.test.js +7 -10
  14. package/build/cli/api.key.js +4 -9
  15. package/build/cli/git.tag.js +4 -8
  16. package/build/composite.error.d.ts +1 -7
  17. package/build/composite.error.d.ts.map +1 -1
  18. package/build/composite.error.js +1 -13
  19. package/build/const.d.ts.map +1 -1
  20. package/build/const.js +3 -6
  21. package/build/file/__test__/file.local.test.js +19 -19
  22. package/build/file/__test__/file.operator.test.helper.d.ts.map +1 -1
  23. package/build/file/__test__/file.operator.test.helper.js +17 -21
  24. package/build/file/file.config.d.ts.map +1 -1
  25. package/build/file/file.config.js +2 -7
  26. package/build/file/index.d.ts +3 -3
  27. package/build/file/index.d.ts.map +1 -1
  28. package/build/file/index.js +14 -23
  29. package/build/index.d.ts +13 -14
  30. package/build/index.d.ts.map +1 -1
  31. package/build/index.js +18 -35
  32. package/build/log.d.ts +0 -3
  33. package/build/log.d.ts.map +1 -1
  34. package/build/log.js +6 -16
  35. package/build/logger.fatal.error.d.ts.map +1 -1
  36. package/build/logger.fatal.error.js +1 -5
  37. package/build/proj/__test__/projection.test.js +30 -33
  38. package/build/proj/__test__/projection.tile.matrix.set.test.js +130 -78
  39. package/build/proj/__test__/test.util.d.ts.map +1 -1
  40. package/build/proj/__test__/test.util.js +10 -17
  41. package/build/proj/citm2000.js +1 -4
  42. package/build/proj/nztm2000.js +1 -4
  43. package/build/proj/projection.d.ts +44 -33
  44. package/build/proj/projection.d.ts.map +1 -1
  45. package/build/proj/projection.js +84 -53
  46. package/build/proj/tile.set.name.d.ts.map +1 -1
  47. package/build/proj/tile.set.name.js +3 -7
  48. package/build/util.d.ts.map +1 -1
  49. package/build/util.js +5 -13
  50. package/build/vdom.d.ts.map +1 -1
  51. package/build/vdom.js +4 -11
  52. package/build/vdom.parse.d.ts +1 -1
  53. package/build/vdom.parse.d.ts.map +1 -1
  54. package/build/vdom.parse.js +5 -10
  55. package/package.json +12 -8
  56. package/build/__test__/aws.init.test.d.ts +0 -2
  57. package/build/__test__/aws.init.test.d.ts.map +0 -1
  58. package/build/__test__/aws.init.test.js +0 -9
  59. package/build/aws/api.key.table.d.ts +0 -29
  60. package/build/aws/api.key.table.d.ts.map +0 -1
  61. package/build/aws/api.key.table.js +0 -38
  62. package/build/aws/credentials.d.ts +0 -21
  63. package/build/aws/credentials.d.ts.map +0 -1
  64. package/build/aws/credentials.js +0 -42
  65. package/build/aws/index.d.ts +0 -18
  66. package/build/aws/index.d.ts.map +0 -1
  67. package/build/aws/index.js +0 -38
  68. package/build/aws/object.cache.d.ts +0 -6
  69. package/build/aws/object.cache.d.ts.map +0 -1
  70. 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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const geo_1 = require("@basemaps/geo");
5
- const tiler_1 = require("@basemaps/tiler");
6
- const ospec_1 = tslib_1.__importDefault(require("ospec"));
7
- const api_path_1 = require("../api.path");
8
- ospec_1.default.spec('api.path', () => {
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
- ospec_1.default('should support only known extensions', () => {
14
- ospec_1.default(api_path_1.tileXyzFromPath(['aerial', 'NZTM2000Quad', '10', '3456', '5432.FAKE'])).deepEquals(null);
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(tiler_1.ImageFormat)) {
17
- ospec_1.default('should support image format:' + ext, () => {
13
+ for (const ext of Object.values(ImageFormat)) {
14
+ o('should support image format:' + ext, () => {
18
15
  var _a;
19
- ospec_1.default((_a = api_path_1.tileXyzFromPath(['aerial', 'NZTM2000Quad', '10', '3456', '5432.' + ext])) === null || _a === void 0 ? void 0 : _a.ext).equals(ext);
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
- ospec_1.default('should be case insensitive for file names', () => {
23
- ospec_1.default(api_path_1.tileWmtsFromPath(['aerial', 'NZTM2000Quad', 'wmtsCapabilities.XML'])).deepEquals({
24
- type: api_path_1.TileType.WMTS,
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: geo_1.Nztm2000QuadTms,
23
+ tileMatrix: Nztm2000QuadTms,
27
24
  });
28
25
  });
29
- ospec_1.default('should parse tiles from path', () => {
30
- ospec_1.default(api_path_1.tileXyzFromPath(['aerial', 'EPSG:3857', '10', '3456', '5432.webp'])).deepEquals({
31
- type: api_path_1.TileType.Tile,
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: geo_1.GoogleTms,
30
+ tileMatrix: GoogleTms,
34
31
  x: 3456,
35
32
  y: 5432,
36
33
  z: 10,
37
- ext: tiler_1.ImageFormat.WEBP,
34
+ ext: ImageFormat.WEBP,
38
35
  });
39
- ospec_1.default(api_path_1.tileXyzFromPath([])).equals(null);
40
- ospec_1.default(api_path_1.tileXyzFromPath(['aerial', 'EPSG:3857', '10', '3456'])).equals(null);
41
- ospec_1.default(api_path_1.tileXyzFromPath(['aerial', 'NZTM2000Quad', '10', '3456', '5432.webp'])).deepEquals({
42
- type: api_path_1.TileType.Tile,
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: geo_1.Nztm2000QuadTms,
41
+ tileMatrix: Nztm2000QuadTms,
45
42
  x: 3456,
46
43
  y: 5432,
47
44
  z: 10,
48
- ext: tiler_1.ImageFormat.WEBP,
45
+ ext: ImageFormat.WEBP,
49
46
  });
50
47
  });
51
- ospec_1.default('should parse vector tiles', () => {
52
- ospec_1.default(api_path_1.tileXyzFromPath(['aerial', 'NZTM2000Quad', '10', '3456', '5432.pbf'])).deepEquals({
53
- type: api_path_1.TileType.Tile,
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: geo_1.Nztm2000QuadTms,
52
+ tileMatrix: Nztm2000QuadTms,
56
53
  x: 3456,
57
54
  y: 5432,
58
55
  z: 10,
59
- ext: api_path_1.VectorFormat.MapboxVectorTiles,
56
+ ext: VectorFormat.MapboxVectorTiles,
60
57
  });
61
58
  });
62
59
  });
63
- ospec_1.default('tileWmtsFromPath', () => {
64
- ospec_1.default(api_path_1.tileWmtsFromPath(['aerial', 'EPSG:3857', 'WMTSCapabilities.xml'])).deepEquals({
65
- type: api_path_1.TileType.WMTS,
60
+ o('tileWmtsFromPath', () => {
61
+ o(tileWmtsFromPath(['aerial', 'EPSG:3857', 'WMTSCapabilities.xml'])).deepEquals({
62
+ type: TileType.WMTS,
66
63
  name: 'aerial',
67
- tileMatrix: geo_1.GoogleTms,
64
+ tileMatrix: GoogleTms,
68
65
  });
69
- ospec_1.default(api_path_1.tileWmtsFromPath(['aerial', 'EPSG:2193', 'WMTSCapabilities.xml'])).deepEquals({
70
- type: api_path_1.TileType.WMTS,
66
+ o(tileWmtsFromPath(['aerial', 'EPSG:2193', 'WMTSCapabilities.xml'])).deepEquals({
67
+ type: TileType.WMTS,
71
68
  name: 'aerial',
72
- tileMatrix: geo_1.Nztm2000Tms,
69
+ tileMatrix: Nztm2000Tms,
73
70
  });
74
- ospec_1.default(api_path_1.tileWmtsFromPath(['aerial', 'NZTM2000', 'WMTSCapabilities.xml'])).deepEquals({
75
- type: api_path_1.TileType.WMTS,
71
+ o(tileWmtsFromPath(['aerial', 'NZTM2000', 'WMTSCapabilities.xml'])).deepEquals({
72
+ type: TileType.WMTS,
76
73
  name: 'aerial',
77
- tileMatrix: geo_1.Nztm2000Tms,
74
+ tileMatrix: Nztm2000Tms,
78
75
  });
79
- ospec_1.default(api_path_1.tileWmtsFromPath(['aerial', 'WebMercatorQuad', 'WMTSCapabilities.xml'])).deepEquals({
80
- type: api_path_1.TileType.WMTS,
76
+ o(tileWmtsFromPath(['aerial', 'WebMercatorQuad', 'WMTSCapabilities.xml'])).deepEquals({
77
+ type: TileType.WMTS,
81
78
  name: 'aerial',
82
- tileMatrix: geo_1.GoogleTms,
79
+ tileMatrix: GoogleTms,
83
80
  });
84
- ospec_1.default(api_path_1.tileWmtsFromPath(['aerial', 'NZTM2000Quad', 'WMTSCapabilities.xml'])).deepEquals({
85
- type: api_path_1.TileType.WMTS,
81
+ o(tileWmtsFromPath(['aerial', 'NZTM2000Quad', 'WMTSCapabilities.xml'])).deepEquals({
82
+ type: TileType.WMTS,
86
83
  name: 'aerial',
87
- tileMatrix: geo_1.Nztm2000QuadTms,
84
+ tileMatrix: Nztm2000QuadTms,
88
85
  });
89
- ospec_1.default(api_path_1.tileWmtsFromPath([])).deepEquals({
90
- type: api_path_1.TileType.WMTS,
86
+ o(tileWmtsFromPath([])).deepEquals({
87
+ type: TileType.WMTS,
91
88
  name: '',
92
89
  tileMatrix: null,
93
90
  });
94
91
  });
95
- ospec_1.default('tileAttributionFromPath', () => {
96
- ospec_1.default(api_path_1.tileAttributionFromPath(['aerial', 'EPSG:3857', 'attribution.json'])).deepEquals({
97
- type: api_path_1.TileType.Attribution,
92
+ o('tileAttributionFromPath', () => {
93
+ o(tileAttributionFromPath(['aerial', 'EPSG:3857', 'attribution.json'])).deepEquals({
94
+ type: TileType.Attribution,
98
95
  name: 'aerial',
99
- tileMatrix: geo_1.GoogleTms,
96
+ tileMatrix: GoogleTms,
100
97
  });
101
- ospec_1.default(api_path_1.tileAttributionFromPath([])).equals(null);
102
- ospec_1.default(api_path_1.tileAttributionFromPath(['aerial', 'attribution.json'])).equals(null);
98
+ o(tileAttributionFromPath([])).equals(null);
99
+ o(tileAttributionFromPath(['aerial', 'attribution.json'])).equals(null);
103
100
  });
104
101
  });
@@ -1,48 +1,45 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const ospec_1 = tslib_1.__importDefault(require("ospec"));
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
- ospec_1.default.beforeEach(() => {
6
+ o.beforeEach(() => {
10
7
  localStorage.getItem = () => null;
11
8
  localStorage.setItem = () => undefined;
12
9
  global.localStorage = localStorage;
13
10
  });
14
- ospec_1.default.afterEach(() => {
11
+ o.afterEach(() => {
15
12
  delete global.localStorage;
16
13
  });
17
- ospec_1.default('should generate a ulid with prefix', () => {
18
- const apiKey = api_1.getApiKey();
19
- ospec_1.default(apiKey.startsWith('c')).equals(true);
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
- ospec_1.default(ulid_1.decodeTime(ulidKey) > 0).equals(true);
18
+ o(decodeTime(ulidKey) > 0).equals(true);
22
19
  });
23
- ospec_1.default('should get valid api keys from localStorage', () => {
24
- localStorage.getItem = ospec_1.default.spy(() => 'foo');
25
- ospec_1.default(api_1.getApiKey()).notEquals('foo');
26
- localStorage.getItem = ospec_1.default.spy(() => '01ebpv4fgbxqnff6kdc184bx0j');
27
- ospec_1.default(api_1.getApiKey()).notEquals('01ebpv4fgbxqnff6kdc184bx0j');
28
- const newKey = 'c' + ulid_1.ulid().toLowerCase();
29
- localStorage.getItem = ospec_1.default.spy(() => newKey);
30
- ospec_1.default(api_1.getApiKey()).equals(newKey);
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
- ospec_1.default('should generate new keys after they expire', () => {
33
- const setSpy = ospec_1.default.spy();
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() - api_1.OneDayMs * 31;
37
- const fakeUlid = 'c' + ulid_1.encodeTime(oldDate, 10) + ulid_1.ulid().slice(10);
38
- localStorage.getItem = ospec_1.default.spy(() => fakeUlid.toLowerCase());
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 = ulid_1.decodeTime(fakeUlid.slice(1).toUpperCase());
41
- ospec_1.default(t - oldDate < 1000).equals(true);
42
- const newApiKey = api_1.getApiKey();
43
- ospec_1.default(setSpy.args).deepEquals(['api-key', newApiKey]);
44
- ospec_1.default(newApiKey).notEquals(fakeUlid.toLocaleLowerCase());
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
- ospec_1.default(Date.now() - ulid_1.decodeTime(newApiKey.slice(1).toUpperCase()) < 1000).equals(true);
43
+ o(Date.now() - decodeTime(newApiKey.slice(1).toUpperCase()) < 1000).equals(true);
47
44
  });
48
45
  });
@@ -1,15 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const const_1 = require("../const");
5
- const ospec_1 = tslib_1.__importDefault(require("ospec"));
6
- ospec_1.default.spec('Environment', () => {
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
- ospec_1.default('should default from environment var', () => {
12
- delete process.env[const_1.Env.TiffConcurrency];
13
- ospec_1.default(const_1.Env.getNumber(const_1.Env.TiffConcurrency, -1)).equals(-1);
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const ospec_1 = tslib_1.__importDefault(require("ospec"));
5
- const util_1 = require("../util");
6
- ospec_1.default.spec('util', () => {
7
- ospec_1.default('extractYearRangeFromName', () => {
8
- ospec_1.default(util_1.extractYearRangeFromName('2013')).deepEquals([2013, 2014]);
9
- ospec_1.default(util_1.extractYearRangeFromName('abc2017def')).deepEquals([2017, 2018]);
10
- ospec_1.default(util_1.extractYearRangeFromName('2019_abc')).deepEquals([2019, 2020]);
11
- ospec_1.default(util_1.extractYearRangeFromName('12019_abc')).deepEquals([-1, -1]);
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
- ospec_1.default('titleizeImageryName', () => {
17
- ospec_1.default(util_1.titleizeImageryName('palmerston-north_urban_2016-17_12-125m_RGBA')).equals('Palmerston-north urban 2016-17 12.125m RGBA');
18
- ospec_1.default(util_1.titleizeImageryName('palmerston-north_urban_2016-17_12-125_RGBA')).equals('Palmerston-north urban 2016-17 12-125 RGBA');
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
- ospec_1.default('s3ToVsis3', () => {
21
- ospec_1.default(util_1.s3ToVsis3('s3://rest/of/path')).equals('/vsis3/rest/of/path');
22
- ospec_1.default(util_1.s3ToVsis3('s3:/rest/of/path')).equals('s3:/rest/of/path');
23
- ospec_1.default(util_1.s3ToVsis3('/s3://rest/of/path')).equals('/s3://rest/of/path');
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
- ospec_1.default.spec('getUrlHost', () => {
26
- ospec_1.default("should normalize referer's", () => {
27
- ospec_1.default(util_1.getUrlHost('https://127.0.0.244/')).equals('127.0.0.244');
28
- ospec_1.default(util_1.getUrlHost('https://foo.d/')).equals('foo.d');
29
- ospec_1.default(util_1.getUrlHost('https://foo.d/bar/baz.html?q=1234')).equals('foo.d');
30
- ospec_1.default(util_1.getUrlHost('http://foo.d/bar/baz.html?q=1234')).equals('foo.d');
31
- ospec_1.default(util_1.getUrlHost('http://basemaps.linz.govt.nz/?p=2193')).equals('basemaps.linz.govt.nz');
32
- ospec_1.default(util_1.getUrlHost('s3://foo/bar/baz')).equals('foo');
33
- ospec_1.default(util_1.getUrlHost('http://localhost:12344/bar/baz')).equals('localhost');
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
- ospec_1.default('should normalize www.foo.com and foo.com ', () => {
36
- ospec_1.default(util_1.getUrlHost('https://www.foo.com/')).equals('foo.com');
37
- ospec_1.default(util_1.getUrlHost('https://bar.foo.com/')).equals('bar.foo.com');
38
- ospec_1.default(util_1.getUrlHost('https://www3.foo.com/')).equals('www3.foo.com');
39
- ospec_1.default(util_1.getUrlHost('https://foo.com/')).equals('foo.com');
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
- ospec_1.default('should not die with badly formatted urls', () => {
42
- ospec_1.default(util_1.getUrlHost('foo/bar')).equals('foo/bar');
43
- ospec_1.default(util_1.getUrlHost('some weird text')).equals('some weird text');
44
- ospec_1.default(util_1.getUrlHost(undefined)).equals(undefined);
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
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
- ospec_1.default.spec('VDOM Parser', () => {
64
- ospec_1.default('should base basic dom', async () => {
65
- const node = await vdom_parse_1.VNodeParser.parse('<div></div>');
66
- ospec_1.default(node.toString()).equals('<div />');
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
- ospec_1.default('should base basic attrs', async () => {
69
- const node = await vdom_parse_1.VNodeParser.parse('<div class="foo" style="height:5px"></div>');
70
- ospec_1.default(node.attrs).deepEquals({ class: 'foo', style: 'height:5px' });
71
- ospec_1.default(node.toString()).equals('<div class="foo" style="height:5px" />');
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
- ospec_1.default('should parse children', async () => {
74
- const node = await vdom_parse_1.VNodeParser.parse('<div><span>Hello</span></div>');
75
- ospec_1.default(node.tag).equals('div');
76
- ospec_1.default(node.children.length).equals(1);
77
- ospec_1.default(node.children[0].toString()).equals('<span>Hello</span>');
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
- ospec_1.default('should parse a vrt', async () => {
80
- const node = await vdom_parse_1.VNodeParser.parse(VrtExample);
81
- ospec_1.default(node.toString()).equals(VrtExample);
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const ospec_1 = tslib_1.__importDefault(require("ospec"));
5
- const vdom_1 = require("../vdom");
6
- ospec_1.default.spec('VDom', () => {
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
- ospec_1.default(tn.text).equals('text');
12
- ospec_1.default(res.toString()).equals('<div>text</div>');
8
+ o(tn.text).equals('text');
9
+ o(res.toString()).equals('<div>text</div>');
13
10
  });
14
- ospec_1.default('should create nodes', () => {
15
- const res = vdom_1.V('div', {}, vdom_1.V('b', [vdom_1.V('span', { style: 'color:red' }, 'text')]));
16
- ospec_1.default(res.toString()).equals('<div>\n <b>\n <span style="color:red">text</span>\n </b>\n</div>');
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
- ospec_1.default('should get set textContent', () => {
19
- const span = vdom_1.V('span', { style: 'color:red' }, 'in span');
20
- const res = vdom_1.V('div', {}, vdom_1.V('b', [span, 'more text', vdom_1.V('b')]));
21
- ospec_1.default(span.textContent).equals('in span');
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
- ospec_1.default(res.textContent).equals('changedmore text');
20
+ o(res.textContent).equals('changedmore text');
24
21
  res.textContent = 'replace';
25
- ospec_1.default(res.textContent).equals('replace');
26
- ospec_1.default(res.children.length).equals(1);
27
- ospec_1.default(res.children[0] instanceof vdom_1.VNodeText).equals(true);
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
- ospec_1.default.spec('find tags', () => {
30
- const iNode = vdom_1.V('i', 'two');
31
- const res = vdom_1.V('div', {}, vdom_1.V('b', [vdom_1.V('i', 'one'), vdom_1.V('span', { style: 'color:red' }, ['text', iNode]), vdom_1.V('b'), vdom_1.V('b')]));
32
- ospec_1.default('tags', () => {
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
- ospec_1.default(bees.length).equals(3);
35
- ospec_1.default(bees[0].children.length).equals(4);
31
+ o(bees.length).equals(3);
32
+ o(bees[0].children.length).equals(4);
36
33
  });
37
- ospec_1.default('find', () => {
38
- ospec_1.default(res.find('b', 'i', 'i')).equals(null);
39
- ospec_1.default(res.find('b', 'span', 'i')).equals(iNode);
40
- ospec_1.default(res.find('i')).notEquals(iNode);
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
- "use strict";
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
- exports.OneDayMs = 24 * 60 * 60 * 1000;
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 * exports.OneDayMs;
5
+ const ApiKeyExpireMs = 30 * OneDayMs;
9
6
  function newApiKey() {
10
- const newKey = 'c' + ulid_1.ulid().toLowerCase();
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 = ulid_1.decodeTime(apiKey.slice(1).toUpperCase());
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;
@@ -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;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,EAAE,CAA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