@basemaps/lambda-tiler 6.35.0 → 6.37.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 (66) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/build/__tests__/config.data.js +1 -1
  3. package/build/__tests__/config.data.js.map +1 -1
  4. package/build/index.d.ts +1 -1
  5. package/build/index.d.ts.map +1 -1
  6. package/build/routes/__tests__/fonts.test.js +16 -12
  7. package/build/routes/__tests__/fonts.test.js.map +1 -1
  8. package/build/routes/__tests__/memory.fs.d.ts +1 -13
  9. package/build/routes/__tests__/memory.fs.d.ts.map +1 -1
  10. package/build/routes/__tests__/memory.fs.js +0 -59
  11. package/build/routes/__tests__/memory.fs.js.map +1 -1
  12. package/build/routes/__tests__/sprites.test.js +6 -11
  13. package/build/routes/__tests__/sprites.test.js.map +1 -1
  14. package/build/routes/__tests__/tile.json.test.js +1 -1
  15. package/build/routes/__tests__/tile.json.test.js.map +1 -1
  16. package/build/routes/fonts.js +1 -1
  17. package/build/routes/fonts.js.map +1 -1
  18. package/build/routes/tile.xyz.raster.d.ts +4 -1
  19. package/build/routes/tile.xyz.raster.d.ts.map +1 -1
  20. package/build/routes/tile.xyz.raster.js +19 -8
  21. package/build/routes/tile.xyz.raster.js.map +1 -1
  22. package/build/util/__test__/config.loader.test.js +1 -1
  23. package/build/util/__test__/config.loader.test.js.map +1 -1
  24. package/build/util/assets.provider.d.ts.map +1 -1
  25. package/build/util/assets.provider.js +2 -6
  26. package/build/util/assets.provider.js.map +1 -1
  27. package/build/util/config.loader.d.ts.map +1 -1
  28. package/build/util/config.loader.js +9 -2
  29. package/build/util/config.loader.js.map +1 -1
  30. package/build/util/source.cache.d.ts +1 -1
  31. package/build/util/source.cache.d.ts.map +1 -1
  32. package/build/util/validate.d.ts +1 -1
  33. package/build/util/validate.d.ts.map +1 -1
  34. package/build/wmts.capability.d.ts +2 -0
  35. package/build/wmts.capability.d.ts.map +1 -1
  36. package/build/wmts.capability.js +3 -1
  37. package/build/wmts.capability.js.map +1 -1
  38. package/dist/index.js +64 -62
  39. package/dist/node_modules/.package-lock.json +13 -10
  40. package/dist/node_modules/minimist/.eslintrc +54 -0
  41. package/dist/node_modules/minimist/.github/FUNDING.yml +12 -0
  42. package/dist/node_modules/minimist/.nycrc +14 -0
  43. package/dist/node_modules/minimist/CHANGELOG.md +212 -0
  44. package/dist/node_modules/minimist/{readme.markdown → README.md} +20 -1
  45. package/dist/node_modules/minimist/package.json +39 -9
  46. package/dist/node_modules/node-abi/abi_registry.json +15 -1
  47. package/dist/node_modules/node-abi/package.json +1 -1
  48. package/dist/node_modules/semver/classes/range.js +3 -0
  49. package/dist/node_modules/semver/index.js +81 -41
  50. package/dist/node_modules/semver/package.json +21 -10
  51. package/dist/package-lock.json +23 -20
  52. package/dist/package.json +1 -1
  53. package/package.json +11 -11
  54. package/src/__tests__/config.data.ts +1 -1
  55. package/src/routes/__tests__/fonts.test.ts +17 -17
  56. package/src/routes/__tests__/memory.fs.ts +0 -62
  57. package/src/routes/__tests__/sprites.test.ts +7 -11
  58. package/src/routes/__tests__/tile.json.test.ts +1 -1
  59. package/src/routes/fonts.ts +1 -1
  60. package/src/routes/tile.xyz.raster.ts +25 -10
  61. package/src/util/__test__/config.loader.test.ts +1 -1
  62. package/src/util/assets.provider.ts +2 -5
  63. package/src/util/config.loader.ts +8 -2
  64. package/src/wmts.capability.ts +4 -1
  65. package/tsconfig.tsbuildinfo +1 -1
  66. package/dist/node_modules/minimist/.travis.yml +0 -8
@@ -1,24 +1,20 @@
1
1
  {
2
2
  "name": "semver",
3
- "version": "7.3.7",
3
+ "version": "7.3.8",
4
4
  "description": "The semantic version parser used by npm.",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "test": "tap",
8
8
  "snap": "tap",
9
- "preversion": "npm test",
10
- "postversion": "npm publish",
11
- "postpublish": "git push origin --follow-tags",
12
9
  "lint": "eslint \"**/*.js\"",
13
10
  "postlint": "template-oss-check",
14
11
  "lintfix": "npm run lint -- --fix",
15
- "prepublishOnly": "git push origin --follow-tags",
16
12
  "posttest": "npm run lint",
17
13
  "template-oss-apply": "template-oss-apply --force"
18
14
  },
19
15
  "devDependencies": {
20
16
  "@npmcli/eslint-config": "^3.0.1",
21
- "@npmcli/template-oss": "3.3.2",
17
+ "@npmcli/template-oss": "4.4.4",
22
18
  "tap": "^16.0.0"
23
19
  },
24
20
  "license": "ISC",
@@ -31,6 +27,7 @@
31
27
  },
32
28
  "files": [
33
29
  "bin/",
30
+ "lib/",
34
31
  "classes/",
35
32
  "functions/",
36
33
  "internal/",
@@ -41,7 +38,11 @@
41
38
  ],
42
39
  "tap": {
43
40
  "check-coverage": true,
44
- "coverage-map": "map.js"
41
+ "coverage-map": "map.js",
42
+ "nyc-arg": [
43
+ "--exclude",
44
+ "tap-snapshots/**"
45
+ ]
45
46
  },
46
47
  "engines": {
47
48
  "node": ">=10"
@@ -52,17 +53,18 @@
52
53
  "author": "GitHub Inc.",
53
54
  "templateOSS": {
54
55
  "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
55
- "version": "3.3.2",
56
+ "version": "4.4.4",
56
57
  "engines": ">=10",
58
+ "content": "./scripts",
57
59
  "ciVersions": [
58
60
  "10.0.0",
59
61
  "10.x",
60
62
  "12.x",
61
63
  "14.x",
62
- "16.x"
64
+ "16.x",
65
+ "18.x"
63
66
  ],
64
67
  "distPaths": [
65
- "bin/",
66
68
  "classes/",
67
69
  "functions/",
68
70
  "internal/",
@@ -70,6 +72,15 @@
70
72
  "index.js",
71
73
  "preload.js",
72
74
  "range.bnf"
75
+ ],
76
+ "allowPaths": [
77
+ "/classes/",
78
+ "/functions/",
79
+ "/internal/",
80
+ "/ranges/",
81
+ "/index.js",
82
+ "/preload.js",
83
+ "/range.bnf"
73
84
  ]
74
85
  }
75
86
  }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@basemaps/lambda-tiler",
3
- "version": "6.35.0",
3
+ "version": "6.37.0",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@basemaps/lambda-tiler",
9
- "version": "6.35.0",
9
+ "version": "6.37.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "sharp": "0.30.7"
@@ -222,9 +222,12 @@
222
222
  }
223
223
  },
224
224
  "node_modules/minimist": {
225
- "version": "1.2.6",
226
- "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz",
227
- "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q=="
225
+ "version": "1.2.7",
226
+ "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.7.tgz",
227
+ "integrity": "sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g==",
228
+ "funding": {
229
+ "url": "https://github.com/sponsors/ljharb"
230
+ }
228
231
  },
229
232
  "node_modules/mkdirp-classic": {
230
233
  "version": "0.5.3",
@@ -237,9 +240,9 @@
237
240
  "integrity": "sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg=="
238
241
  },
239
242
  "node_modules/node-abi": {
240
- "version": "3.24.0",
241
- "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.24.0.tgz",
242
- "integrity": "sha512-YPG3Co0luSu6GwOBsmIdGW6Wx0NyNDLg/hriIyDllVsNwnI6UeqaWShxC3lbH4LtEQUgoLP3XR1ndXiDAWvmRw==",
243
+ "version": "3.30.0",
244
+ "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.30.0.tgz",
245
+ "integrity": "sha512-qWO5l3SCqbwQavymOmtTVuCWZE23++S+rxyoHjXqUmPyzRcaoI4lA2gO55/drddGnedAyjA7sk76SfQ5lfUMnw==",
243
246
  "dependencies": {
244
247
  "semver": "^7.3.5"
245
248
  },
@@ -341,9 +344,9 @@
341
344
  ]
342
345
  },
343
346
  "node_modules/semver": {
344
- "version": "7.3.7",
345
- "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz",
346
- "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==",
347
+ "version": "7.3.8",
348
+ "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz",
349
+ "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==",
347
350
  "dependencies": {
348
351
  "lru-cache": "^6.0.0"
349
352
  },
@@ -632,9 +635,9 @@
632
635
  "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ=="
633
636
  },
634
637
  "minimist": {
635
- "version": "1.2.6",
636
- "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz",
637
- "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q=="
638
+ "version": "1.2.7",
639
+ "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.7.tgz",
640
+ "integrity": "sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g=="
638
641
  },
639
642
  "mkdirp-classic": {
640
643
  "version": "0.5.3",
@@ -647,9 +650,9 @@
647
650
  "integrity": "sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg=="
648
651
  },
649
652
  "node-abi": {
650
- "version": "3.24.0",
651
- "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.24.0.tgz",
652
- "integrity": "sha512-YPG3Co0luSu6GwOBsmIdGW6Wx0NyNDLg/hriIyDllVsNwnI6UeqaWShxC3lbH4LtEQUgoLP3XR1ndXiDAWvmRw==",
653
+ "version": "3.30.0",
654
+ "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.30.0.tgz",
655
+ "integrity": "sha512-qWO5l3SCqbwQavymOmtTVuCWZE23++S+rxyoHjXqUmPyzRcaoI4lA2gO55/drddGnedAyjA7sk76SfQ5lfUMnw==",
653
656
  "requires": {
654
657
  "semver": "^7.3.5"
655
658
  }
@@ -722,9 +725,9 @@
722
725
  "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ=="
723
726
  },
724
727
  "semver": {
725
- "version": "7.3.7",
726
- "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz",
727
- "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==",
728
+ "version": "7.3.8",
729
+ "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz",
730
+ "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==",
728
731
  "requires": {
729
732
  "lru-cache": "^6.0.0"
730
733
  }
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@basemaps/lambda-tiler",
3
- "version": "6.35.0",
3
+ "version": "6.37.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/linz/basemaps.git",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@basemaps/lambda-tiler",
3
- "version": "6.35.0",
3
+ "version": "6.37.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/linz/basemaps.git",
@@ -22,13 +22,13 @@
22
22
  "types": "./build/index.d.ts",
23
23
  "license": "MIT",
24
24
  "dependencies": {
25
- "@basemaps/config": "^6.35.0",
26
- "@basemaps/geo": "^6.32.1",
27
- "@basemaps/shared": "^6.35.0",
28
- "@basemaps/tiler": "^6.35.0",
29
- "@basemaps/tiler-sharp": "^6.35.0",
30
- "@chunkd/fs": "^8.5.1",
31
- "@cogeotiff/core": "^7.0.0",
25
+ "@basemaps/config": "^6.37.0",
26
+ "@basemaps/geo": "^6.37.0",
27
+ "@basemaps/shared": "^6.37.0",
28
+ "@basemaps/tiler": "^6.37.0",
29
+ "@basemaps/tiler-sharp": "^6.37.0",
30
+ "@chunkd/fs": "^10.0.2",
31
+ "@cogeotiff/core": "^7.2.0",
32
32
  "@cotar/core": "^5.4.0",
33
33
  "@linzjs/geojson": "^6.32.1",
34
34
  "@linzjs/lambda": "^4.0.0",
@@ -51,12 +51,12 @@
51
51
  "bundle": "./bundle.sh"
52
52
  },
53
53
  "devDependencies": {
54
- "@basemaps/attribution": "^6.32.1",
54
+ "@basemaps/attribution": "^6.37.0",
55
+ "@chunkd/source-memory": "^10.0.0",
55
56
  "@types/aws-lambda": "^8.10.75",
56
- "@types/node": "^17.0.34",
57
57
  "@types/pixelmatch": "^5.0.0",
58
58
  "@types/sharp": "^0.30.3",
59
59
  "pretty-json-log": "^1.0.0"
60
60
  },
61
- "gitHead": "dcebd7149ab318ea979b5d1ba34a9f82fc41b935"
61
+ "gitHead": "98c97100161b159272c1826c4e668b3e805ec214"
62
62
  }
@@ -10,7 +10,7 @@ import {
10
10
  } from '@basemaps/config';
11
11
  import { ImageFormat, VectorFormat } from '@basemaps/geo';
12
12
  import { fsa } from '@basemaps/shared';
13
- import { FsMemory } from '../routes/__tests__/memory.fs.js';
13
+ import { FsMemory } from '@chunkd/source-memory';
14
14
 
15
15
  export const TileSetAerial: ConfigTileSetRaster = {
16
16
  id: 'ts_aerial',
@@ -1,28 +1,32 @@
1
1
  import { base58, ConfigProviderMemory } from '@basemaps/config';
2
- import { Env, getDefaultConfig } from '@basemaps/shared';
2
+ import { getDefaultConfig } from '@basemaps/shared';
3
3
  import { fsa } from '@chunkd/fs';
4
4
  import o from 'ospec';
5
+ import { createSandbox } from 'sinon';
5
6
  import { handler } from '../../index.js';
6
7
  import { CachedConfig } from '../../util/config.cache.js';
8
+ import { ConfigLoader } from '../../util/config.loader.js';
7
9
  import { CoSources } from '../../util/source.cache.js';
8
10
  import { Api, mockRequest, mockUrlRequest } from '../../__tests__/xyz.util.js';
9
11
  import { fontList } from '../fonts.js';
10
- import { FsMemory } from './memory.fs.js';
12
+ import { FsMemory } from '@chunkd/source-memory';
11
13
 
12
14
  o.spec('/v1/fonts', () => {
13
15
  const memory = new FsMemory();
16
+ const sandbox = createSandbox();
17
+ const config = new ConfigProviderMemory();
18
+
14
19
  o.before(() => {
15
20
  fsa.register('memory://', memory);
16
21
  });
17
- const assetLocation = process.env[Env.AssetLocation];
18
22
 
19
23
  o.beforeEach(() => {
20
- process.env[Env.AssetLocation] = 'memory://config';
21
- getDefaultConfig().assets = 'memory://';
24
+ config.assets = 'memory://';
25
+ sandbox.stub(ConfigLoader, 'getDefaultConfig').resolves(config);
22
26
  });
23
27
 
24
28
  o.afterEach(() => {
25
- getDefaultConfig().assets = assetLocation;
29
+ sandbox.restore();
26
30
  CachedConfig.cache.clear();
27
31
  CoSources.cache.clear();
28
32
  memory.files.clear();
@@ -34,7 +38,7 @@ o.spec('/v1/fonts', () => {
34
38
  });
35
39
 
36
40
  o('should return a list of fonts found', async () => {
37
- await fsa.write('memory://fonts.json', Buffer.from(JSON.stringify(['Roboto Black', 'Roboto Thin'])));
41
+ await fsa.write('memory://fonts/fonts.json', Buffer.from(JSON.stringify(['Roboto Black', 'Roboto Thin'])));
38
42
  const res = await fontList(mockRequest('/v1/fonts.json'));
39
43
  o(res.status).equals(200);
40
44
  o(res.header('content-type')).equals('application/json');
@@ -44,7 +48,6 @@ o.spec('/v1/fonts', () => {
44
48
 
45
49
  o('should get the correct font', async () => {
46
50
  await fsa.write('memory://fonts/Roboto Thin/0-255.pbf', Buffer.from(''));
47
-
48
51
  const res255 = await handler.router.handle(mockRequest('/v1/fonts/Roboto Thin/0-255.pbf'));
49
52
  o(res255.status).equals(200);
50
53
  o(res255.header('content-type')).equals('application/x-protobuf');
@@ -58,7 +61,6 @@ o.spec('/v1/fonts', () => {
58
61
 
59
62
  o('should get the correct utf8 font', async () => {
60
63
  await fsa.write('memory://fonts/🦄 🌈/0-255.pbf', Buffer.from(''));
61
-
62
64
  const res255 = await handler.router.handle(mockRequest('/v1/fonts/🦄 🌈/0-255.pbf'));
63
65
  o(res255.status).equals(200);
64
66
  o(res255.header('content-type')).equals('application/x-protobuf');
@@ -74,14 +76,12 @@ o.spec('/v1/fonts', () => {
74
76
  });
75
77
 
76
78
  o('should get the correct utf8 font with default assets', async () => {
77
- const cfgBundle = new ConfigProviderMemory();
78
- await fsa.write('memory://linz-basemaps/bar.json', JSON.stringify(cfgBundle.toJson()));
79
- await fsa.write('memory://config/fonts/🦄 🌈/0-255.pbf', Buffer.from(''));
80
-
81
- const configLocation = base58.encode(Buffer.from('memory://linz-basemaps/bar.json'));
82
- const res255 = await handler.router.handle(
83
- mockUrlRequest('/v1/fonts/🦄 🌈/0-255.pbf', `?config=${configLocation}`, Api.header),
84
- );
79
+ getDefaultConfig().assets = undefined;
80
+ sandbox
81
+ .stub(config.ConfigBundle, 'get')
82
+ .resolves({ id: 'cb_latest', name: 'latest', path: 'latest', hash: 'hash', assets: 'memory://' });
83
+ await fsa.write('memory://fonts/Roboto Thin/0-255.pbf', Buffer.from(''));
84
+ const res255 = await handler.router.handle(mockRequest('/v1/fonts/Roboto Thin/0-255.pbf'));
85
85
  o(res255.status).equals(200);
86
86
  o(res255.header('content-type')).equals('application/x-protobuf');
87
87
  o(res255.header('content-encoding')).equals(undefined);
@@ -1,4 +1,3 @@
1
- import { ChunkSource, CompositeError, FileInfo, FileSystem } from '@chunkd/core';
2
1
  import { Readable } from 'stream';
3
2
 
4
3
  export async function toBuffer(stream: Readable): Promise<Buffer> {
@@ -14,64 +13,3 @@ export function toReadable(r: string | Buffer | Readable): Readable {
14
13
  if (typeof r === 'string') r = Buffer.from(r);
15
14
  return Readable.from(r);
16
15
  }
17
-
18
- // TODO this should be provided by @chunkd/fs as it already provides a memory source
19
- export class FsMemory implements FileSystem {
20
- protocol = 'memory';
21
-
22
- files: Map<string, Buffer> = new Map();
23
-
24
- async read(filePath: string): Promise<Buffer> {
25
- const data = this.files.get(filePath);
26
- if (data == null) throw new CompositeError('Not found', 404, new Error());
27
- return data;
28
- }
29
-
30
- stream(filePath: string): Readable {
31
- const buf = this.files.get(filePath);
32
- if (buf == null) throw new CompositeError('Not found', 404, new Error());
33
- return toReadable(buf);
34
- }
35
-
36
- async write(filePath: string, buffer: string | Buffer | Readable): Promise<void> {
37
- if (typeof buffer === 'string') {
38
- this.files.set(filePath, Buffer.from(buffer));
39
- return;
40
- }
41
- if (Buffer.isBuffer(buffer)) {
42
- this.files.set(filePath, buffer);
43
- return;
44
- }
45
- const buf = await toBuffer(buffer);
46
- this.files.set(filePath, buf);
47
- }
48
-
49
- async *list(filePath: string): AsyncGenerator<string> {
50
- for (const file of this.files.keys()) {
51
- if (file.startsWith(filePath)) yield file;
52
- }
53
- }
54
-
55
- async *details(filePath: string): AsyncGenerator<FileInfo> {
56
- for await (const file of this.list(filePath)) {
57
- const data = await this.head(file);
58
- if (data == null) continue;
59
- yield data;
60
- }
61
- }
62
-
63
- async exists(filePath: string): Promise<boolean> {
64
- const dat = await this.head(filePath);
65
- return dat != null;
66
- }
67
-
68
- async head(filePath: string): Promise<FileInfo | null> {
69
- const buf = this.files.get(filePath);
70
- if (buf == null) return null;
71
- return { path: filePath, size: buf.length };
72
- }
73
-
74
- source(): ChunkSource {
75
- throw new Error('Method not implemented.');
76
- }
77
- }
@@ -1,35 +1,31 @@
1
- import { Env, getDefaultConfig } from '@basemaps/shared';
1
+ import { ConfigProviderMemory } from '@basemaps/config';
2
2
  import { fsa } from '@chunkd/fs';
3
3
  import o from 'ospec';
4
4
  import { createSandbox } from 'sinon';
5
5
  import { gunzipSync, gzipSync } from 'zlib';
6
6
  import { handler } from '../../index.js';
7
+ import { ConfigLoader } from '../../util/config.loader.js';
7
8
  import { mockRequest } from '../../__tests__/xyz.util.js';
8
- import { FsMemory } from './memory.fs.js';
9
+ import { FsMemory } from '@chunkd/source-memory';
9
10
 
10
11
  o.spec('/v1/sprites', () => {
11
12
  const memory = new FsMemory();
12
13
  const sandbox = createSandbox();
14
+ const config = new ConfigProviderMemory();
15
+
13
16
  o.before(() => {
14
17
  fsa.register('memory://', memory);
15
18
  });
16
- const assetLocation = process.env[Env.AssetLocation];
17
19
 
18
20
  o.beforeEach(() => {
19
- process.env[Env.AssetLocation] = 'memory://';
20
- getDefaultConfig().assets = 'memory://';
21
+ config.assets = 'memory://';
22
+ sandbox.stub(ConfigLoader, 'getDefaultConfig').resolves(config);
21
23
  });
22
24
 
23
25
  o.afterEach(() => {
24
- getDefaultConfig().assets = assetLocation;
25
26
  memory.files.clear();
26
27
  sandbox.restore();
27
28
  });
28
- o('should return 404 if no assets defined', async () => {
29
- delete process.env[Env.AssetLocation];
30
- const res404 = await handler.router.handle(mockRequest('/v1/sprites/topographic.json'));
31
- o(res404.status).equals(404);
32
- });
33
29
 
34
30
  o('should fetch a json document', async () => {
35
31
  await Promise.all([
@@ -8,7 +8,7 @@ import { ConfigLoader } from '../../util/config.loader.js';
8
8
  import { CoSources } from '../../util/source.cache.js';
9
9
  import { FakeData } from '../../__tests__/config.data.js';
10
10
  import { Api, mockRequest, mockUrlRequest } from '../../__tests__/xyz.util.js';
11
- import { FsMemory } from './memory.fs.js';
11
+ import { FsMemory } from '@chunkd/source-memory';
12
12
 
13
13
  o.spec('/v1/tiles/:tileSet/:tileMatrix/tile.json', () => {
14
14
  const config = new ConfigProviderMemory();
@@ -12,5 +12,5 @@ export async function fontGet(req: LambdaHttpRequest<FontGet>): Promise<LambdaHt
12
12
  }
13
13
 
14
14
  export async function fontList(req: LambdaHttpRequest): Promise<LambdaHttpResponse> {
15
- return assetProvider.serve(req, 'fonts.json', 'application/json');
15
+ return assetProvider.serve(req, path.join('fonts', 'fonts.json'), 'application/json');
16
16
  }
@@ -4,6 +4,7 @@ import { Env, fsa } from '@basemaps/shared';
4
4
  import { Tiler } from '@basemaps/tiler';
5
5
  import { TileMakerSharp } from '@basemaps/tiler-sharp';
6
6
  import { CogTiff } from '@cogeotiff/core';
7
+ import { Cotar } from '@cotar/core';
7
8
  import { HttpHeader, LambdaHttpRequest, LambdaHttpResponse } from '@linzjs/lambda';
8
9
  import pLimit from 'p-limit';
9
10
  import { ConfigLoader } from '../util/config.loader.js';
@@ -20,13 +21,15 @@ export function getTiffName(name: string): string {
20
21
  return `${name}.tiff`;
21
22
  }
22
23
 
24
+ export type CloudArchive = CogTiff | Cotar;
25
+
23
26
  export const TileComposer = new TileMakerSharp(256);
24
27
 
25
28
  const DefaultResizeKernel = { in: 'lanczos3', out: 'lanczos3' } as const;
26
29
  const DefaultBackground = { r: 0, g: 0, b: 0, alpha: 0 };
27
30
 
28
31
  export const TileXyzRaster = {
29
- async getTiffsForTile(req: LambdaHttpRequest, tileSet: ConfigTileSetRaster, xyz: TileXyz): Promise<string[]> {
32
+ async getAssetsForTile(req: LambdaHttpRequest, tileSet: ConfigTileSetRaster, xyz: TileXyz): Promise<string[]> {
30
33
  const config = await ConfigLoader.load(req);
31
34
  const imagery = await getAllImagery(config, tileSet.layers, [xyz.tileMatrix.projection]);
32
35
 
@@ -55,6 +58,12 @@ export const TileXyzRaster = {
55
58
  }
56
59
  if (!tileBounds.intersects(Bounds.fromJson(img.bounds))) continue;
57
60
 
61
+ // FIXME is this meant to be >= <=
62
+ if (img.overviews && img.overviews.maxZoom >= filterZoom && img.overviews.minZoom <= filterZoom) {
63
+ output.push(fsa.join(img.uri, img.overviews.path));
64
+ continue;
65
+ }
66
+
58
67
  for (const c of img.files) {
59
68
  if (!tileBounds.intersects(Bounds.fromJson(c))) continue;
60
69
  const tiffPath = fsa.join(img.uri, getTiffName(c.name));
@@ -67,26 +76,32 @@ export const TileXyzRaster = {
67
76
  async tile(req: LambdaHttpRequest, tileSet: ConfigTileSetRaster, xyz: TileXyz): Promise<LambdaHttpResponse> {
68
77
  if (xyz.tileType === VectorFormat.MapboxVectorTiles) return NotFound();
69
78
 
70
- const tiffPaths = await this.getTiffsForTile(req, tileSet, xyz);
71
- const cacheKey = Etag.key(tiffPaths);
79
+ const assetPaths = await this.getAssetsForTile(req, tileSet, xyz);
80
+ const cacheKey = Etag.key(assetPaths);
72
81
  if (Etag.isNotModified(req, cacheKey)) return NotModified();
73
82
 
74
- const toLoad: Promise<CogTiff | null>[] = [];
75
- for (const tiffPath of tiffPaths) {
83
+ const toLoad: Promise<CloudArchive | null>[] = [];
84
+ for (const assetPath of assetPaths) {
76
85
  toLoad.push(
77
- LoadingQueue(() => {
78
- return CoSources.getCog(tiffPath).catch((error) => {
79
- req.log.warn({ error, tiff: tiffPath }, 'TiffLoadFailed');
86
+ LoadingQueue((): Promise<CloudArchive | null> => {
87
+ if (assetPath.endsWith('.tar.co')) {
88
+ return CoSources.getCotar(assetPath).catch((error) => {
89
+ req.log.warn({ error, tiff: assetPath }, 'Load:Cotar:Failed');
90
+ return null;
91
+ });
92
+ }
93
+ return CoSources.getCog(assetPath).catch((error) => {
94
+ req.log.warn({ error, tiff: assetPath }, 'Load:Tiff:Failed');
80
95
  return null;
81
96
  });
82
97
  }),
83
98
  );
84
99
  }
85
100
 
86
- const tiffs = (await Promise.all(toLoad)).filter((f) => f != null) as CogTiff[];
101
+ const assets = (await Promise.all(toLoad)).filter((f) => f != null) as CloudArchive[];
87
102
 
88
103
  const tiler = new Tiler(xyz.tileMatrix);
89
- const layers = await tiler.tile(tiffs, xyz.tile.x, xyz.tile.y, xyz.tile.z);
104
+ const layers = await tiler.tile(assets, xyz.tile.x, xyz.tile.y, xyz.tile.z);
90
105
 
91
106
  const res = await TileComposer.compose({
92
107
  layers,
@@ -3,7 +3,7 @@ import { fsa } from '@basemaps/shared';
3
3
  import { LambdaHttpResponse } from '@linzjs/lambda';
4
4
  import o from 'ospec';
5
5
  import { createSandbox } from 'sinon';
6
- import { FsMemory } from '../../routes/__tests__/memory.fs.js';
6
+ import { FsMemory } from '@chunkd/source-memory';
7
7
  import { FakeData } from '../../__tests__/config.data.js';
8
8
  import { Api, mockRequest, mockUrlRequest } from '../../__tests__/xyz.util.js';
9
9
  import { CachedConfig } from '../config.cache.js';
@@ -1,4 +1,3 @@
1
- import { Env } from '@basemaps/shared';
2
1
  import { fsa } from '@chunkd/fs';
3
2
  import { LambdaHttpResponse, LambdaHttpRequest, HttpHeader } from '@linzjs/lambda';
4
3
  import { ConfigLoader } from './config.loader.js';
@@ -46,11 +45,9 @@ export class AssetProvider {
46
45
  */
47
46
  async serve(req: LambdaHttpRequest, file: string, contentType: string): Promise<LambdaHttpResponse> {
48
47
  const config = await ConfigLoader.load(req);
49
- let assetLocation = Env.get(Env.AssetLocation);
50
48
  if (config == null) return NotFound();
51
- if (config.assets != null) assetLocation = config.assets;
52
- if (assetLocation == null) return NotFound();
53
- const buf = await assetProvider.get(assetLocation, file);
49
+ if (config.assets == null) return NotFound();
50
+ const buf = await assetProvider.get(config.assets, file);
54
51
  if (buf == null) return NotFound();
55
52
  const cacheKey = Etag.key(buf);
56
53
  if (Etag.isNotModified(req, cacheKey)) return NotModified();
@@ -6,13 +6,19 @@ import { CachedConfig } from './config.cache.js';
6
6
  import { getDefaultConfig } from '@basemaps/shared';
7
7
 
8
8
  // FIXME load this from process.env COG BUCKETS?
9
- const SafeBuckets = new Set(['linz-workflow-artifacts', 'linz-basemaps']);
9
+ const SafeBuckets = new Set(['linz-workflow-artifacts', 'linz-basemaps', 'linz-basemaps-staging']);
10
10
  const SafeProtocols = new Set(['s3', 'memory']);
11
11
 
12
12
  export class ConfigLoader {
13
13
  /** Exposed for testing */
14
14
  static async getDefaultConfig(): Promise<BasemapsConfigProvider> {
15
- return getDefaultConfig();
15
+ const config = getDefaultConfig();
16
+ if (config.assets == null) {
17
+ const cb = await config.ConfigBundle.get(config.ConfigBundle.id('latest'));
18
+ if (cb == null) throw new LambdaHttpResponse(400, 'Unable to get lastest config bundle for asset.');
19
+ config.assets = cb.assets;
20
+ }
21
+ return config;
16
22
  }
17
23
 
18
24
  /** Lookup the config path from a request and return a standardized location */
@@ -64,6 +64,9 @@ export class WmtsCapabilities {
64
64
  formats: ImageFormat[];
65
65
  isIndividualLayers = false;
66
66
 
67
+ minZoom = 0;
68
+ maxZoom = 32;
69
+
67
70
  constructor(params: WmtsCapabilitiesParams) {
68
71
  this.httpBase = params.httpBase;
69
72
  this.provider = params.provider;
@@ -267,7 +270,7 @@ export class WmtsCapabilities {
267
270
  V('ows:Identifier', tms.identifier),
268
271
  V('ows:SupportedCRS', tms.projection.toUrn()),
269
272
  tms.def.wellKnownScaleSet ? V('WellKnownScaleSet', tms.def.wellKnownScaleSet) : null,
270
- ...tms.def.tileMatrix.map((c) => {
273
+ ...tms.def.tileMatrix.slice(this.minZoom, this.maxZoom).map((c) => {
271
274
  return V('TileMatrix', [
272
275
  V('ows:Identifier', c.identifier),
273
276
  V('ScaleDenominator', c.scaleDenominator),