@basemaps/lambda-tiler 6.16.1 → 6.20.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 (158) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/LICENSE +2 -2
  3. package/build/__test__/tile.style.json.test.d.ts +2 -0
  4. package/build/__test__/tile.style.json.test.d.ts.map +1 -0
  5. package/build/__test__/tile.style.json.test.js +33 -0
  6. package/build/__test__/xyz.test.js +35 -34
  7. package/build/cli/dump.js +2 -2
  8. package/build/index.d.ts.map +1 -1
  9. package/build/index.js +10 -0
  10. package/build/routes/esri/rest.d.ts +10 -0
  11. package/build/routes/esri/rest.d.ts.map +1 -0
  12. package/build/routes/esri/rest.js +87 -0
  13. package/build/routes/imagery.d.ts +10 -0
  14. package/build/routes/imagery.d.ts.map +1 -0
  15. package/build/routes/imagery.js +50 -0
  16. package/build/routes/response.d.ts +4 -0
  17. package/build/routes/response.d.ts.map +1 -0
  18. package/build/routes/response.js +3 -0
  19. package/build/routes/tile.d.ts +0 -20
  20. package/build/routes/tile.d.ts.map +1 -1
  21. package/build/routes/tile.js +11 -164
  22. package/build/routes/tile.json.d.ts +10 -0
  23. package/build/routes/tile.json.d.ts.map +1 -0
  24. package/build/routes/tile.json.js +31 -0
  25. package/build/routes/tile.style.json.d.ts +10 -0
  26. package/build/routes/tile.style.json.d.ts.map +1 -0
  27. package/build/routes/tile.style.json.js +74 -0
  28. package/build/routes/tile.wmts.d.ts +9 -0
  29. package/build/routes/tile.wmts.d.ts.map +1 -0
  30. package/build/routes/tile.wmts.js +57 -0
  31. package/build/routes/tile.xyz.d.ts +13 -0
  32. package/build/routes/tile.xyz.d.ts.map +1 -0
  33. package/build/routes/tile.xyz.js +28 -0
  34. package/build/tile.set.raster.d.ts +2 -0
  35. package/build/tile.set.raster.d.ts.map +1 -1
  36. package/build/tile.set.raster.js +3 -1
  37. package/build/tile.set.vector.js +1 -1
  38. package/dist/index.js +10580 -9573
  39. package/dist/node_modules/color/README.md +7 -7
  40. package/dist/node_modules/color/index.js +173 -158
  41. package/dist/node_modules/color/package.json +18 -16
  42. package/dist/node_modules/color-convert/conversions.js +281 -310
  43. package/dist/node_modules/color-convert/index.js +27 -24
  44. package/dist/node_modules/color-convert/package.json +16 -14
  45. package/dist/node_modules/color-convert/route.js +22 -22
  46. package/dist/node_modules/color-name/package.json +17 -14
  47. package/dist/node_modules/color-string/index.js +2 -2
  48. package/dist/node_modules/color-string/package.json +10 -10
  49. package/dist/node_modules/decompress-response/index.d.ts +14 -21
  50. package/dist/node_modules/decompress-response/index.js +34 -16
  51. package/dist/node_modules/decompress-response/license +1 -1
  52. package/dist/node_modules/decompress-response/package.json +23 -17
  53. package/dist/node_modules/decompress-response/readme.md +2 -6
  54. package/dist/node_modules/detect-libc/package.json +0 -1
  55. package/dist/node_modules/mimic-response/index.d.ts +2 -2
  56. package/dist/node_modules/mimic-response/index.js +41 -2
  57. package/dist/node_modules/mimic-response/package.json +17 -17
  58. package/dist/node_modules/mimic-response/readme.md +22 -1
  59. package/dist/node_modules/node-abi/.circleci/config.yml +63 -0
  60. package/dist/node_modules/node-abi/.releaserc.json +9 -0
  61. package/dist/node_modules/node-abi/abi_registry.json +39 -4
  62. package/dist/node_modules/node-abi/index.js +5 -2
  63. package/dist/node_modules/node-abi/package.json +17 -16
  64. package/dist/node_modules/node-abi/test/index.js +7 -15
  65. package/dist/node_modules/node-addon-api/README.md +2 -2
  66. package/dist/node_modules/node-addon-api/except.gypi +20 -11
  67. package/dist/node_modules/node-addon-api/napi-inl.h +734 -196
  68. package/dist/node_modules/node-addon-api/napi.h +420 -164
  69. package/dist/node_modules/node-addon-api/noexcept.gypi +21 -11
  70. package/dist/node_modules/node-addon-api/package.json +43 -14
  71. package/dist/node_modules/node-addon-api/tools/clang-format.js +18 -17
  72. package/dist/node_modules/node-addon-api/tools/eslint-format.js +71 -0
  73. package/dist/node_modules/prebuild-install/CHANGELOG.md +24 -7
  74. package/dist/node_modules/prebuild-install/README.md +24 -4
  75. package/dist/node_modules/prebuild-install/asset.js +10 -10
  76. package/dist/node_modules/prebuild-install/bin.js +13 -13
  77. package/dist/node_modules/prebuild-install/download.js +22 -22
  78. package/dist/node_modules/prebuild-install/log.js +4 -4
  79. package/dist/node_modules/prebuild-install/node_modules/detect-libc/LICENSE +201 -0
  80. package/dist/node_modules/prebuild-install/node_modules/detect-libc/README.md +160 -0
  81. package/dist/node_modules/prebuild-install/node_modules/detect-libc/index.d.ts +11 -0
  82. package/dist/node_modules/prebuild-install/node_modules/detect-libc/lib/detect-libc.js +178 -0
  83. package/dist/node_modules/prebuild-install/node_modules/detect-libc/lib/process.js +16 -0
  84. package/dist/node_modules/prebuild-install/node_modules/detect-libc/package.json +71 -0
  85. package/dist/node_modules/prebuild-install/package.json +18 -19
  86. package/dist/node_modules/prebuild-install/proxy.js +10 -10
  87. package/dist/node_modules/prebuild-install/rc.js +12 -12
  88. package/dist/node_modules/prebuild-install/util.js +14 -14
  89. package/dist/node_modules/semver/package.json +1 -0
  90. package/dist/node_modules/sharp/README.md +2 -2
  91. package/dist/node_modules/sharp/binding.gyp +12 -9
  92. package/dist/node_modules/sharp/build/Release/sharp-linux-x64.node +0 -0
  93. package/dist/node_modules/sharp/install/dll-copy.js +6 -6
  94. package/dist/node_modules/sharp/install/libvips.js +4 -8
  95. package/dist/node_modules/sharp/lib/channel.js +11 -7
  96. package/dist/node_modules/sharp/lib/colour.js +42 -1
  97. package/dist/node_modules/sharp/lib/constructor.js +18 -31
  98. package/dist/node_modules/sharp/lib/input.js +45 -3
  99. package/dist/node_modules/sharp/lib/is.js +19 -5
  100. package/dist/node_modules/sharp/lib/libvips.js +4 -19
  101. package/dist/node_modules/sharp/lib/operation.js +28 -5
  102. package/dist/node_modules/sharp/lib/output.js +147 -16
  103. package/dist/node_modules/sharp/lib/sharp.js +31 -0
  104. package/dist/node_modules/sharp/lib/utility.js +3 -2
  105. package/dist/node_modules/sharp/package.json +32 -23
  106. package/dist/node_modules/sharp/src/common.cc +67 -11
  107. package/dist/node_modules/sharp/src/common.h +25 -5
  108. package/dist/node_modules/sharp/src/libvips/cplusplus/VConnection.cpp +0 -26
  109. package/dist/node_modules/sharp/src/libvips/cplusplus/VImage.cpp +54 -16
  110. package/dist/node_modules/sharp/src/libvips/cplusplus/VInterpolate.cpp +0 -13
  111. package/dist/node_modules/sharp/src/libvips/cplusplus/vips-operators.cpp +185 -1
  112. package/dist/node_modules/sharp/src/metadata.cc +14 -0
  113. package/dist/node_modules/sharp/src/metadata.h +1 -0
  114. package/dist/node_modules/sharp/src/operations.cc +29 -3
  115. package/dist/node_modules/sharp/src/operations.h +13 -2
  116. package/dist/node_modules/sharp/src/pipeline.cc +103 -35
  117. package/dist/node_modules/sharp/src/pipeline.h +23 -3
  118. package/dist/node_modules/sharp/src/utilities.cc +1 -1
  119. package/dist/node_modules/sharp/vendor/{8.10.6 → 8.11.3/linux-x64}/THIRD-PARTY-NOTICES.md +2 -3
  120. package/dist/node_modules/sharp/vendor/{8.10.6 → 8.11.3/linux-x64}/lib/libvips-cpp.so.42 +0 -0
  121. package/dist/node_modules/sharp/vendor/{8.10.6 → 8.11.3/linux-x64}/platform.json +0 -0
  122. package/dist/node_modules/sharp/vendor/8.11.3/linux-x64/versions.json +30 -0
  123. package/dist/node_modules/simple-get/.github/dependabot.yml +15 -0
  124. package/dist/node_modules/simple-get/.github/workflows/ci.yml +23 -0
  125. package/dist/node_modules/simple-get/README.md +17 -3
  126. package/dist/node_modules/simple-get/index.js +9 -0
  127. package/dist/node_modules/simple-get/package.json +27 -13
  128. package/dist/package-lock.json +54 -54
  129. package/dist/package.json +11 -11
  130. package/package.json +12 -12
  131. package/src/__test__/tile.style.json.test.ts +40 -0
  132. package/src/__test__/xyz.test.ts +43 -41
  133. package/src/cli/dump.ts +2 -2
  134. package/src/index.ts +10 -0
  135. package/src/routes/esri/rest.ts +90 -0
  136. package/src/routes/imagery.ts +52 -0
  137. package/src/routes/response.ts +4 -0
  138. package/src/routes/tile.json.ts +44 -0
  139. package/src/routes/tile.style.json.ts +77 -0
  140. package/src/routes/tile.ts +11 -186
  141. package/src/routes/tile.wmts.ts +59 -0
  142. package/src/routes/tile.xyz.ts +30 -0
  143. package/src/tile.set.raster.ts +4 -1
  144. package/src/tile.set.vector.ts +1 -1
  145. package/tsconfig.tsbuildinfo +1 -1
  146. package/dist/node_modules/color-name/.eslintrc.json +0 -43
  147. package/dist/node_modules/color-name/test.js +0 -7
  148. package/dist/node_modules/node-abi/.travis.yml +0 -17
  149. package/dist/node_modules/node-abi/node_modules/semver/CHANGELOG.md +0 -39
  150. package/dist/node_modules/node-abi/node_modules/semver/LICENSE +0 -15
  151. package/dist/node_modules/node-abi/node_modules/semver/README.md +0 -412
  152. package/dist/node_modules/node-abi/node_modules/semver/bin/semver +0 -160
  153. package/dist/node_modules/node-abi/node_modules/semver/package.json +0 -60
  154. package/dist/node_modules/node-abi/node_modules/semver/range.bnf +0 -16
  155. package/dist/node_modules/node-abi/node_modules/semver/semver.js +0 -1483
  156. package/dist/node_modules/node-addon-api/CHANGELOG.md +0 -722
  157. package/dist/node_modules/sharp/build/Release/sharp.node +0 -0
  158. package/dist/node_modules/sharp/vendor/8.10.6/versions.json +0 -31
package/CHANGELOG.md CHANGED
@@ -3,6 +3,55 @@
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.20.0](https://github.com/linz/basemaps/compare/v6.19.0...v6.20.0) (2022-02-01)
7
+
8
+
9
+ ### Features
10
+
11
+ * **lambda-tiler:** allow relative sprites and glyphs ([#2071](https://github.com/linz/basemaps/issues/2071)) ([a283157](https://github.com/linz/basemaps/commit/a283157f6b11fd9f6168edd19e9d5624f52d0325))
12
+ * **lambda-tiler:** wip esri vectortileserver interface for vector tiles ([#2041](https://github.com/linz/basemaps/issues/2041)) ([0549d68](https://github.com/linz/basemaps/commit/0549d688ae44c20bd8dce0281988c7ba258fdacb))
13
+
14
+
15
+
16
+
17
+
18
+ # [6.19.0](https://github.com/linz/basemaps/compare/v6.18.1...v6.19.0) (2021-12-20)
19
+
20
+
21
+ ### Bug Fixes
22
+
23
+ * **lambda-tiler:** remove the host check to add api keys for all stylejson sources. ([#2032](https://github.com/linz/basemaps/issues/2032)) ([beab64c](https://github.com/linz/basemaps/commit/beab64c7f747dd5c1be06877b05b1173a95b1537))
24
+
25
+
26
+ ### Features
27
+
28
+ * **lambda-tiler:** compress geojson output to prevent overflowing lambda ([#2034](https://github.com/linz/basemaps/issues/2034)) ([5d48524](https://github.com/linz/basemaps/commit/5d48524c0bf03c40e85cd661fd7f609bbdeed3dd))
29
+ * **tiler:** expose some of the metadata geojson via a /v1/imagery endpoint ([#2033](https://github.com/linz/basemaps/issues/2033)) ([b471209](https://github.com/linz/basemaps/commit/b471209a381dfdab1a25be4882e464c8ddea9064))
30
+
31
+
32
+
33
+
34
+
35
+ # [6.18.0](https://github.com/linz/basemaps/compare/v6.17.0...v6.18.0) (2021-12-14)
36
+
37
+ **Note:** Version bump only for package @basemaps/lambda-tiler
38
+
39
+
40
+
41
+
42
+
43
+ # [6.17.0](https://github.com/linz/basemaps/compare/v6.16.1...v6.17.0) (2021-12-05)
44
+
45
+
46
+ ### Features
47
+
48
+ * **lambda-tiler:** Stop caching for the stylejson. ([#2011](https://github.com/linz/basemaps/issues/2011)) ([f29ae16](https://github.com/linz/basemaps/commit/f29ae16cd0b858fd9929a8cbcefa1c5113687bc9))
49
+ * **landing:** use topographic name not topolike ([#2008](https://github.com/linz/basemaps/issues/2008)) ([a281d87](https://github.com/linz/basemaps/commit/a281d874ae8211447282ad41dd497e96689ceb88))
50
+
51
+
52
+
53
+
54
+
6
55
  ## [6.16.1](https://github.com/linz/basemaps/compare/v6.16.0...v6.16.1) (2021-11-30)
7
56
 
8
57
  **Note:** Version bump only for package @basemaps/lambda-tiler
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
- Basemaps MIT Licence
1
+ MIT License
2
2
 
3
- Crown copyright (c) 2020, Land Information New Zealand on behalf of the New Zealand Government.
3
+ Crown copyright (c), Toitū Te Whenua Land Information New Zealand on behalf of the New Zealand Government.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=tile.style.json.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tile.style.json.test.d.ts","sourceRoot":"","sources":["../../src/__test__/tile.style.json.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,33 @@
1
+ import { Env } from '@basemaps/shared';
2
+ import o from 'ospec';
3
+ import { convertRelativeUrl } from '../routes/tile.style.json.js';
4
+ o.spec('TileStyleJson', () => {
5
+ const host = 'https://tiles.test';
6
+ let originalHost;
7
+ o.beforeEach(() => {
8
+ originalHost = process.env[Env.PublicUrlBase];
9
+ process.env[Env.PublicUrlBase] = host;
10
+ });
11
+ o.afterEach(() => {
12
+ process.env[Env.PublicUrlBase] = originalHost;
13
+ });
14
+ o('should not convert empty urls', () => {
15
+ o(convertRelativeUrl()).equals('');
16
+ o(convertRelativeUrl('')).equals('');
17
+ o(convertRelativeUrl(undefined)).equals('');
18
+ });
19
+ o('should only convert relative urls', () => {
20
+ o(convertRelativeUrl('/foo')).equals('https://tiles.test/foo');
21
+ o(convertRelativeUrl('/bar/baz/')).equals('https://tiles.test/bar/baz/');
22
+ });
23
+ o('should only convert with api keys', () => {
24
+ o(convertRelativeUrl('/foo', 'abc')).equals('https://tiles.test/foo?api=abc');
25
+ o(convertRelativeUrl('/bar/baz/', 'abc')).equals('https://tiles.test/bar/baz/?api=abc');
26
+ });
27
+ o('should convert with other query params', () => {
28
+ o(convertRelativeUrl('/foo?bar=baz', 'abc')).equals('https://tiles.test/foo?bar=baz&api=abc');
29
+ });
30
+ o('should not convert full urls', () => {
31
+ o(convertRelativeUrl('https://foo.com/foo?bar=baz', 'abc')).equals('https://foo.com/foo?bar=baz');
32
+ });
33
+ });
@@ -2,16 +2,18 @@ import { TileMatrixSets } from '@basemaps/geo';
2
2
  import { Config, Env, LogConfig, VNodeParser } from '@basemaps/shared';
3
3
  import { round } from '@basemaps/test/build/rounding.js';
4
4
  import o from 'ospec';
5
+ import sinon from 'sinon';
5
6
  import { handleRequest } from '../index.js';
6
- import { TileComposer } from '../routes/tile.js';
7
7
  import { TileEtag } from '../routes/tile.etag.js';
8
8
  import { TileSets } from '../tile.set.cache.js';
9
+ import { TileComposer } from '../tile.set.raster.js';
9
10
  import { FakeTileSet, mockRequest, Provider } from './xyz.util.js';
10
- import sinon from 'sinon';
11
11
  const sandbox = sinon.createSandbox();
12
12
  const TileSetNames = ['aerial', 'aerial@head', 'aerial@beta', '01E7PJFR9AMQFJ05X9G7FQ3XMW'];
13
13
  /* eslint-disable @typescript-eslint/explicit-function-return-type */
14
14
  o.spec('LambdaXyz', () => {
15
+ const host = 'https://tiles.test';
16
+ const origPublicUrlBase = process.env[Env.PublicUrlBase];
15
17
  /** Generate mock ALBEvent */
16
18
  let rasterMock = o.spy();
17
19
  const generateMock = o.spy(() => 'foo');
@@ -21,6 +23,7 @@ o.spec('LambdaXyz', () => {
21
23
  const apiKey = 'd01f7w7rnhdzg0p7fyrc9v9ard1';
22
24
  const apiKeyHeader = { 'x-linz-api-key': 'd01f7w7rnhdzg0p7fyrc9v9ard1' };
23
25
  o.beforeEach(() => {
26
+ process.env[Env.PublicUrlBase] = host;
24
27
  LogConfig.disable();
25
28
  // tileMock = o.spy(() => tileMockData) as any;
26
29
  rasterMock = o.spy(() => {
@@ -45,6 +48,7 @@ o.spec('LambdaXyz', () => {
45
48
  TileSets.cache.clear();
46
49
  TileComposer.compose = origCompose;
47
50
  TileEtag.generate = origTileEtag;
51
+ process.env[Env.PublicUrlBase] = origPublicUrlBase;
48
52
  sandbox.restore();
49
53
  });
50
54
  o('should export handler', async () => {
@@ -115,11 +119,8 @@ o.spec('LambdaXyz', () => {
115
119
  }
116
120
  });
117
121
  o.spec('WMTSCapabilities', () => {
118
- const origPublicUrlBase = process.env[Env.PublicUrlBase];
119
- o.after(() => {
120
- process.env[Env.PublicUrlBase] = origPublicUrlBase;
121
- });
122
122
  o('should 304 if a xml is not modified', async () => {
123
+ delete process.env[Env.PublicUrlBase];
123
124
  o.timeout(1000);
124
125
  const key = 'NuirTK8fozzCJV1iG1FznmdHhKvk6WaWuDhhEA1d40c=';
125
126
  const request = mockRequest('/v1/tiles/WMTSCapabilities.xml', 'get', {
@@ -137,8 +138,6 @@ o.spec('LambdaXyz', () => {
137
138
  });
138
139
  o('should serve WMTSCapabilities for tile_set', async () => {
139
140
  var _a;
140
- console.log('\n\nTestStart');
141
- process.env[Env.PublicUrlBase] = 'https://tiles.test';
142
141
  const request = mockRequest('/v1/tiles/aerial@beta/WMTSCapabilities.xml', 'get', apiKeyHeader);
143
142
  const res = await handleRequest(request);
144
143
  o(res.status).equals(200);
@@ -153,12 +152,9 @@ o.spec('LambdaXyz', () => {
153
152
  });
154
153
  });
155
154
  o.spec('tileJson', () => {
156
- const origPublicUrlBase = process.env[Env.PublicUrlBase];
157
- o.after(() => {
158
- process.env[Env.PublicUrlBase] = origPublicUrlBase;
159
- });
160
155
  o('should 304 if a json is not modified', async () => {
161
- const key = 'XecTdbcdjCyzB1MHOOQbrOkD2TTJ0ORh4JuXqhxXEE0=';
156
+ // delete process.env[Env.PublicUrlBase];
157
+ const key = 'BBfQpNXA3Q90jlFrLSOZhxbvfOh7OpN1OEE+BylpbHw=';
162
158
  const request = mockRequest('/v1/tiles/tile.json', 'get', { 'if-none-match': key, ...apiKeyHeader });
163
159
  const res = await handleRequest(request);
164
160
  if (res.status === 200) {
@@ -169,17 +165,27 @@ o.spec('LambdaXyz', () => {
169
165
  o(rasterMock.calls.length).equals(0);
170
166
  o(request.logContext['cache']).deepEquals({ key, match: key, hit: true });
171
167
  });
168
+ o('should 200 if a invalid etag is given', async () => {
169
+ var _a;
170
+ const key = 'ABCXecTdbcdjCyzB1MHOOQbrOkD2TTJ0ORh4JuXqhxXEE0=';
171
+ const request = mockRequest('/v1/tiles/tile.json', 'get', { 'if-none-match': key, ...apiKeyHeader });
172
+ const res = await handleRequest(request);
173
+ o(res.status).equals(200);
174
+ o(res.header('etag')).equals('BBfQpNXA3Q90jlFrLSOZhxbvfOh7OpN1OEE+BylpbHw=');
175
+ const out = JSON.parse(Buffer.from((_a = res.body) !== null && _a !== void 0 ? _a : '', 'base64').toString());
176
+ o(out.tiles[0].startsWith('https://tiles.test/v1/tiles/tile.json/undefined/{z}/{x}/{y}.pbf?api=')).equals(true);
177
+ o(request.logContext['cache']).deepEquals(undefined);
178
+ });
172
179
  o('should serve tile json for tile_set', async () => {
173
180
  var _a;
174
- process.env[Env.PublicUrlBase] = 'https://tiles.test';
175
- const request = mockRequest('/v1/tiles/topolike/Google/tile.json', 'get', apiKeyHeader);
181
+ const request = mockRequest('/v1/tiles/topographic/Google/tile.json', 'get', apiKeyHeader);
176
182
  const res = await handleRequest(request);
177
183
  o(res.status).equals(200);
178
184
  o(res.header('content-type')).equals('application/json');
179
185
  o(res.header('cache-control')).equals('max-age=120');
180
186
  const body = Buffer.from((_a = res.body) !== null && _a !== void 0 ? _a : '', 'base64').toString();
181
187
  o(JSON.parse(body)).deepEquals({
182
- tiles: [`https://tiles.test/v1/tiles/topolike/Google/{z}/{x}/{y}.pbf?api=${apiKey}`],
188
+ tiles: [`https://tiles.test/v1/tiles/topographic/Google/{z}/{x}/{y}.pbf?api=${apiKey}`],
183
189
  minzoom: 0,
184
190
  maxzoom: 15,
185
191
  format: 'pbf',
@@ -188,38 +194,31 @@ o.spec('LambdaXyz', () => {
188
194
  });
189
195
  });
190
196
  o.spec('styleJson', () => {
191
- const origPublicUrlBase = process.env[Env.PublicUrlBase];
192
- o.after(() => {
193
- process.env[Env.PublicUrlBase] = origPublicUrlBase;
194
- });
195
197
  o('should not found style json', async () => {
196
- process.env[Env.PublicUrlBase] = 'https://tiles.test';
197
- const request = mockRequest('/v1/tiles/topolike/Google/style/topolike.json', 'get', apiKeyHeader);
198
+ const request = mockRequest('/v1/tiles/topographic/Google/style/topographic.json', 'get', apiKeyHeader);
198
199
  sandbox.stub(Config.Style, 'get').resolves(null);
199
200
  const res = await handleRequest(request);
200
201
  o(res.status).equals(404);
201
202
  });
202
203
  o('should serve style json', async () => {
203
204
  var _a;
204
- const host = 'https://tiles.test';
205
- process.env[Env.PublicUrlBase] = host;
206
- const request = mockRequest('/v1/tiles/topolike/Google/style/topolike.json', 'get', apiKeyHeader);
205
+ const request = mockRequest('/v1/tiles/topographic/Google/style/topographic.json', 'get', apiKeyHeader);
207
206
  const fakeStyle = {
208
207
  version: 8,
209
208
  id: 'test',
210
- name: 'topolike',
209
+ name: 'topographic',
211
210
  sources: {
212
211
  basemaps_vector: {
213
212
  type: 'vector',
214
- url: `${host}/vector`,
213
+ url: `/vector`,
215
214
  },
216
215
  basemaps_raster: {
217
216
  type: 'raster',
218
- tiles: [`${host}/raster`],
217
+ tiles: [`/raster`],
219
218
  },
220
219
  basemaps_raster_encode: {
221
220
  type: 'raster',
222
- tiles: [`${host}/raster/{z}/{x}/{y}.webp`], // Shouldn't encode the {}
221
+ tiles: [`/raster/{z}/{x}/{y}.webp`], // Shouldn't encode the {}
223
222
  },
224
223
  test_vector: {
225
224
  type: 'vector',
@@ -243,20 +242,20 @@ o.spec('LambdaXyz', () => {
243
242
  minzoom: 0,
244
243
  },
245
244
  ],
246
- glyphs: 'glyphs',
247
- sprite: 'sprite',
245
+ glyphs: '/glyphs',
246
+ sprite: '/sprite',
248
247
  metadata: { id: 'test' },
249
248
  };
250
249
  const fakeRecord = {
251
- id: 'st_topolike_production',
252
- name: 'topolike',
250
+ id: 'st_topographic_production',
251
+ name: 'topographic',
253
252
  style: fakeStyle,
254
253
  };
255
254
  sandbox.stub(Config.Style, 'get').resolves(fakeRecord);
256
255
  const res = await handleRequest(request);
257
256
  o(res.status).equals(200);
258
257
  o(res.header('content-type')).equals('application/json');
259
- o(res.header('cache-control')).equals('max-age=120');
258
+ o(res.header('cache-control')).equals('no-store');
260
259
  const body = Buffer.from((_a = res.body) !== null && _a !== void 0 ? _a : '', 'base64').toString();
261
260
  fakeStyle.sources.basemaps_vector = {
262
261
  type: 'vector',
@@ -270,6 +269,8 @@ o.spec('LambdaXyz', () => {
270
269
  type: 'raster',
271
270
  tiles: [`${host}/raster/{z}/{x}/{y}.webp?api=${apiKey}`],
272
271
  };
272
+ fakeStyle.sprite = `${host}/sprite`;
273
+ fakeStyle.glyphs = `${host}/glyphs`;
273
274
  o(JSON.parse(body)).deepEquals(fakeStyle);
274
275
  });
275
276
  });
package/build/cli/dump.js CHANGED
@@ -3,7 +3,7 @@ import { LogConfig } from '@basemaps/shared';
3
3
  import { ImageFormat } from '@basemaps/tiler';
4
4
  import { LambdaAlbRequest } from '@linzjs/lambda';
5
5
  import { promises as fs } from 'fs';
6
- import { TileRoute } from '../routes/tile.js';
6
+ import { tileXyz } from '../routes/tile.xyz.js';
7
7
  import { TileSets } from '../tile.set.cache.js';
8
8
  import { TileSetLocal } from './tile.set.local.js';
9
9
  const xyz = { x: 0, y: 0, z: 0 };
@@ -36,7 +36,7 @@ async function main() {
36
36
  httpMethod: 'get',
37
37
  path: `/v1/tiles/${tileSet.fullName}/${tileMatrix.identifier}/${xyz.z}/${xyz.x}/${xyz.y}.${ext}`,
38
38
  }, {}, logger);
39
- const tileData = await TileRoute.tile(ctx);
39
+ const tileData = await tileXyz(ctx);
40
40
  const headers = {};
41
41
  for (const [key, value] of tileData.headers)
42
42
  headers[key] = value;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAM,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAe3E,wBAAsB,aAAa,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAavF;AAED,eAAO,MAAM,OAAO,2LAA0C,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAM,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAoB3E,wBAAsB,aAAa,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAkBvF;AAED,eAAO,MAAM,OAAO,2LAA0C,CAAC"}
package/build/index.js CHANGED
@@ -4,11 +4,16 @@ import { Ping, Version } from './routes/api.js';
4
4
  import { Health } from './routes/health.js';
5
5
  import { Tiles } from './routes/tile.js';
6
6
  import { Router } from './router.js';
7
+ import { createHash } from 'crypto';
8
+ import { Imagery } from './routes/imagery.js';
9
+ import { Esri } from './routes/esri/rest.js';
7
10
  const app = new Router();
8
11
  app.get('ping', Ping);
9
12
  app.get('health', Health);
10
13
  app.get('version', Version);
11
14
  app.get('tiles', Tiles);
15
+ app.get('imagery', Imagery);
16
+ app.get('esri', Esri);
12
17
  let slowTimer = null;
13
18
  export async function handleRequest(req) {
14
19
  // Warn if a request takes more than 10 seconds to process
@@ -18,6 +23,11 @@ export async function handleRequest(req) {
18
23
  slowTimer.unref();
19
24
  req.set('name', 'LambdaTiler');
20
25
  try {
26
+ const apiKey = Router.apiKey(req);
27
+ if (apiKey != null) {
28
+ const apiKeyHash = createHash('sha256').update(apiKey).digest('base64');
29
+ req.set('api', apiKeyHash);
30
+ }
21
31
  return await app.handle(req);
22
32
  }
23
33
  finally {
@@ -0,0 +1,10 @@
1
+ import { TileMatrixSet } from '@basemaps/geo';
2
+ import { LambdaHttpRequest, LambdaHttpResponse } from '@linzjs/lambda';
3
+ export declare function vectorTileServer(req: LambdaHttpRequest, layerId: string, tms: TileMatrixSet): Promise<LambdaHttpResponse>;
4
+ /**
5
+ * /v1/esri/services/:layerId/VectorTileServer
6
+ *
7
+ * @example http://localhost:5000/v1/esri/services/topographic/VectorTileServer
8
+ */
9
+ export declare function Esri(req: LambdaHttpRequest): Promise<LambdaHttpResponse>;
10
+ //# sourceMappingURL=rest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rest.d.ts","sourceRoot":"","sources":["../../../src/routes/esri/rest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,aAAa,EAAE,MAAM,eAAe,CAAC;AAEzD,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAKvE,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,iBAAiB,EACtB,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,aAAa,GACjB,OAAO,CAAC,kBAAkB,CAAC,CAiD7B;AAED;;;;GAIG;AACH,wBAAsB,IAAI,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAsB9E"}
@@ -0,0 +1,87 @@
1
+ import { GoogleTms } from '@basemaps/geo';
2
+ import { tileXyzFromPath } from '@basemaps/shared';
3
+ import { LambdaHttpResponse } from '@linzjs/lambda';
4
+ import { Router } from '../../router.js';
5
+ import { TileSets } from '../../tile.set.cache.js';
6
+ import { NotFound } from '../response.js';
7
+ export async function vectorTileServer(req, layerId, tms) {
8
+ if (tms.identifier !== GoogleTms.identifier)
9
+ return NotFound;
10
+ const extent = {
11
+ xmin: tms.extent.x,
12
+ ymin: tms.extent.y,
13
+ xmax: tms.extent.right,
14
+ ymax: tms.extent.bottom,
15
+ // TODO where is wkid from
16
+ spatialReference: { wkid: 102100, latestWkid: tms.projection.code },
17
+ };
18
+ const res = new LambdaHttpResponse(200, 'ok');
19
+ res.json({
20
+ currentVersion: 10.4,
21
+ name: layerId,
22
+ capabilities: 'TilesOnly',
23
+ type: 'indexedVector',
24
+ tileMap: 'tilemap',
25
+ defaultStyles: 'resources/styles',
26
+ tiles: ['tiles/{z}/{x}/{y}.pbf'],
27
+ exportTilesAllowed: false,
28
+ maxExportTilesCount: 0,
29
+ initialExtent: extent,
30
+ fullExtent: extent,
31
+ minScale: tms.zooms[0].scaleDenominator,
32
+ maxScale: tms.zooms[tms.zooms.length - 1].scaleDenominator,
33
+ tileInfo: {
34
+ // TODO are all the pbf 256x256?
35
+ rows: 256,
36
+ cols: 256,
37
+ dpi: 96,
38
+ format: 'pbf',
39
+ origin: { x: tms.extent.x, y: tms.extent.bottom },
40
+ spatialReference: { wkid: 102100, latestWkid: tms.projection.code },
41
+ lods: tms.zooms.map((c, i) => {
42
+ return {
43
+ level: i,
44
+ scale: c.scaleDenominator,
45
+ resolution: c.scaleDenominator * 0.28e-3,
46
+ };
47
+ }),
48
+ },
49
+ resourceInfo: {
50
+ styleVersion: 8,
51
+ tileCompression: 'gzip',
52
+ cacheInfo: { storageInfo: { packetSize: 128, storageFormat: 'compactV2' } },
53
+ },
54
+ });
55
+ return res;
56
+ }
57
+ /**
58
+ * /v1/esri/services/:layerId/VectorTileServer
59
+ *
60
+ * @example http://localhost:5000/v1/esri/services/topographic/VectorTileServer
61
+ */
62
+ export async function Esri(req) {
63
+ const { rest } = Router.action(req);
64
+ if (rest[0] !== 'services')
65
+ return NotFound;
66
+ const layerId = rest[1];
67
+ if (layerId == null)
68
+ return NotFound;
69
+ const serviceId = rest[2];
70
+ if (serviceId !== 'VectorTileServer')
71
+ return NotFound;
72
+ if (rest.length === 3)
73
+ return vectorTileServer(req, layerId, GoogleTms);
74
+ if (rest[rest.length - 1].endsWith('.pbf')) {
75
+ const generatedPath = [layerId, GoogleTms.identifier, ...rest.slice(rest.length - 3)];
76
+ const xyz = tileXyzFromPath(generatedPath);
77
+ if (xyz == null)
78
+ return NotFound;
79
+ req.timer.start('tileset:load');
80
+ const tileSet = await TileSets.get(xyz.name, xyz.tileMatrix);
81
+ req.timer.end('tileset:load');
82
+ if (tileSet == null)
83
+ return NotFound;
84
+ return await tileSet.tile(req, xyz);
85
+ }
86
+ return new LambdaHttpResponse(200, 'ok');
87
+ }
@@ -0,0 +1,10 @@
1
+ import { LambdaHttpRequest, LambdaHttpResponse } from '@linzjs/lambda';
2
+ /**
3
+ * Get metadata around the imagery such as the source bounding box or the bounding box of the COGS
4
+ *
5
+ * @example
6
+ * - /v1/imagery/:imageryId/source.geojson
7
+ * - /v1/imagery/:imageryId/covering.geojson
8
+ */
9
+ export declare function Imagery(req: LambdaHttpRequest): Promise<LambdaHttpResponse>;
10
+ //# sourceMappingURL=imagery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"imagery.d.ts","sourceRoot":"","sources":["../../src/routes/imagery.ts"],"names":[],"mappings":"AAEA,OAAO,EAAc,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAgBnF;;;;;;GAMG;AACH,wBAAsB,OAAO,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CA0BjF"}
@@ -0,0 +1,50 @@
1
+ import { Config } from '@basemaps/config';
2
+ import { fsa } from '@basemaps/shared';
3
+ import { HttpHeader, LambdaHttpResponse } from '@linzjs/lambda';
4
+ import { createHash } from 'crypto';
5
+ import { promisify } from 'util';
6
+ import { gzip } from 'zlib';
7
+ import { Router } from '../router.js';
8
+ import { NotModified } from './response.js';
9
+ import { TileEtag } from './tile.etag.js';
10
+ const gzipP = promisify(gzip);
11
+ function isAllowedFile(f) {
12
+ if (f.endsWith('.geojson'))
13
+ return true;
14
+ if (f.endsWith('.json'))
15
+ return true;
16
+ return false;
17
+ }
18
+ /**
19
+ * Get metadata around the imagery such as the source bounding box or the bounding box of the COGS
20
+ *
21
+ * @example
22
+ * - /v1/imagery/:imageryId/source.geojson
23
+ * - /v1/imagery/:imageryId/covering.geojson
24
+ */
25
+ export async function Imagery(req) {
26
+ const { rest } = Router.action(req);
27
+ const [imageryId, requestType] = rest;
28
+ if (!isAllowedFile(requestType))
29
+ return new LambdaHttpResponse(404, 'Not found');
30
+ const imagery = await Config.Imagery.get(imageryId);
31
+ if (imagery == null)
32
+ return new LambdaHttpResponse(404, 'Not found');
33
+ const targetPath = fsa.join(imagery.uri, requestType);
34
+ try {
35
+ const buf = await fsa.read(targetPath);
36
+ const cacheKey = createHash('sha256').update(buf).digest('base64');
37
+ if (TileEtag.isNotModified(req, cacheKey))
38
+ return NotModified;
39
+ const response = new LambdaHttpResponse(200, 'ok');
40
+ response.header(HttpHeader.ETag, cacheKey);
41
+ response.header(HttpHeader.ContentEncoding, 'gzip');
42
+ response.buffer(await gzipP(buf), 'application/json');
43
+ req.set('bytes', buf.byteLength);
44
+ return response;
45
+ }
46
+ catch (e) {
47
+ req.log.warn({ targetPath }, 'ImageryMetadata:Failed');
48
+ return new LambdaHttpResponse(404, 'Not found');
49
+ }
50
+ }
@@ -0,0 +1,4 @@
1
+ import { LambdaHttpResponse } from '@linzjs/lambda';
2
+ export declare const NotFound: LambdaHttpResponse;
3
+ export declare const NotModified: LambdaHttpResponse;
4
+ //# sourceMappingURL=response.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../src/routes/response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,eAAO,MAAM,QAAQ,oBAA2C,CAAC;AACjE,eAAO,MAAM,WAAW,oBAA8C,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { LambdaHttpResponse } from '@linzjs/lambda';
2
+ export const NotFound = new LambdaHttpResponse(404, 'Not Found');
3
+ export const NotModified = new LambdaHttpResponse(304, 'Not modified');
@@ -1,23 +1,3 @@
1
- import { TileMatrixSet } from '@basemaps/geo';
2
1
  import { LambdaHttpRequest, LambdaHttpResponse } from '@linzjs/lambda';
3
- import { TileMakerSharp } from '@basemaps/tiler-sharp';
4
- import { TileSetRaster } from '../tile.set.raster.js';
5
- export declare const TileComposer: TileMakerSharp;
6
- export declare const NotFound: LambdaHttpResponse;
7
- export declare const NotModified: LambdaHttpResponse;
8
- export interface TileJson {
9
- tiles: string[];
10
- minzoom: number;
11
- maxzoom: number;
12
- format: string;
13
- tilejson: string;
14
- }
15
- export declare const TileRoute: {
16
- tile(req: LambdaHttpRequest): Promise<LambdaHttpResponse>;
17
- wmtsLoadTileSets(name: string, tileMatrix: TileMatrixSet | null): Promise<TileSetRaster[]>;
18
- wmts(req: LambdaHttpRequest): Promise<LambdaHttpResponse>;
19
- tileJson(req: LambdaHttpRequest): Promise<LambdaHttpResponse>;
20
- styleJson(req: LambdaHttpRequest, fileName: string): Promise<LambdaHttpResponse>;
21
- };
22
2
  export declare function Tiles(req: LambdaHttpRequest): Promise<LambdaHttpResponse>;
23
3
  //# sourceMappingURL=tile.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tile.d.ts","sourceRoot":"","sources":["../../src/routes/tile.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAc,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEnF,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAIvD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAQtD,eAAO,MAAM,YAAY,gBAA0B,CAAC;AAEpD,eAAO,MAAM,QAAQ,oBAA2C,CAAC;AACjE,eAAO,MAAM,WAAW,oBAA8C,CAAC;AAEvE,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,SAAS;cACJ,iBAAiB,GAAG,QAAQ,kBAAkB,CAAC;2BAelC,MAAM,cAAc,aAAa,GAAG,IAAI,GAAG,QAAQ,aAAa,EAAE,CAAC;cAUhF,iBAAiB,GAAG,QAAQ,kBAAkB,CAAC;kBAiC3C,iBAAiB,GAAG,QAAQ,kBAAkB,CAAC;mBA8B9C,iBAAiB,YAAY,MAAM,GAAG,QAAQ,kBAAkB,CAAC;CA8DvF,CAAC;AACF,wBAAsB,KAAK,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAgB/E"}
1
+ {"version":3,"file":"tile.d.ts","sourceRoot":"","sources":["../../src/routes/tile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAUvE,wBAAsB,KAAK,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAY/E"}