@basemaps/lambda-tiler 7.4.0 → 7.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/build/__tests__/config.data.d.ts +2 -0
- package/build/__tests__/config.data.js +24 -1
- package/build/__tests__/config.data.js.map +1 -1
- package/build/__tests__/index.test.js +1 -2
- package/build/__tests__/index.test.js.map +1 -1
- package/build/__tests__/tile.style.json.test.js +2 -2
- package/build/__tests__/tile.style.json.test.js.map +1 -1
- package/build/__tests__/wmts.capability.test.js +5 -2
- package/build/__tests__/wmts.capability.test.js.map +1 -1
- package/build/__tests__/xyz.util.js.map +1 -1
- package/build/cli/render.preview.js +5 -2
- package/build/cli/render.preview.js.map +1 -1
- package/build/cli/render.tile.js +1 -1
- package/build/cli/render.tile.js.map +1 -1
- package/build/index.js +1 -1
- package/build/index.js.map +1 -1
- package/build/routes/__tests__/attribution.test.js +1 -1
- package/build/routes/__tests__/attribution.test.js.map +1 -1
- package/build/routes/__tests__/health.test.js +1 -1
- package/build/routes/__tests__/health.test.js.map +1 -1
- package/build/routes/__tests__/imagery.test.js.map +1 -1
- package/build/routes/__tests__/memory.fs.d.ts +0 -2
- package/build/routes/__tests__/memory.fs.js +1 -1
- package/build/routes/__tests__/memory.fs.js.map +1 -1
- package/build/routes/__tests__/preview.index.test.js +1 -1
- package/build/routes/__tests__/preview.index.test.js.map +1 -1
- package/build/routes/__tests__/tile.json.test.js.map +1 -1
- package/build/routes/__tests__/tile.style.json.test.js +144 -11
- package/build/routes/__tests__/tile.style.json.test.js.map +1 -1
- package/build/routes/__tests__/wmts.test.js +18 -2
- package/build/routes/__tests__/wmts.test.js.map +1 -1
- package/build/routes/attribution.d.ts +0 -1
- package/build/routes/config.js +1 -1
- package/build/routes/config.js.map +1 -1
- package/build/routes/health.d.ts +0 -1
- package/build/routes/ping.js +2 -2
- package/build/routes/ping.js.map +1 -1
- package/build/routes/preview.index.js +2 -1
- package/build/routes/preview.index.js.map +1 -1
- package/build/routes/preview.js +5 -3
- package/build/routes/preview.js.map +1 -1
- package/build/routes/sprites.js.map +1 -1
- package/build/routes/tile.style.json.d.ts +2 -2
- package/build/routes/tile.style.json.js +61 -10
- package/build/routes/tile.style.json.js.map +1 -1
- package/build/routes/tile.wmts.js +1 -0
- package/build/routes/tile.wmts.js.map +1 -1
- package/build/routes/tile.xyz.raster.d.ts +0 -1
- package/build/routes/tile.xyz.raster.js +6 -5
- package/build/routes/tile.xyz.raster.js.map +1 -1
- package/build/routes/version.js +2 -2
- package/build/routes/version.js.map +1 -1
- package/build/util/__test__/config.loader.test.js +12 -12
- package/build/util/__test__/config.loader.test.js.map +1 -1
- package/build/util/assets.provider.d.ts +0 -2
- package/build/util/config.cache.d.ts +0 -1
- package/build/util/config.cache.js.map +1 -1
- package/build/util/cotar.serve.d.ts +0 -2
- package/build/util/source.cache.d.ts +0 -1
- package/build/util/source.cache.js +5 -4
- package/build/util/source.cache.js.map +1 -1
- package/build/util/validate.js +1 -1
- package/build/util/validate.js.map +1 -1
- package/build/wmts.capability.d.ts +8 -4
- package/build/wmts.capability.js +18 -8
- package/build/wmts.capability.js.map +1 -1
- package/package.json +10 -10
- package/src/__tests__/config.data.ts +31 -2
- package/src/__tests__/index.test.ts +2 -3
- package/src/__tests__/tile.style.json.test.ts +2 -5
- package/src/__tests__/wmts.capability.test.ts +13 -10
- package/src/__tests__/xyz.util.ts +4 -4
- package/src/cli/render.preview.ts +5 -2
- package/src/cli/render.tile.ts +1 -1
- package/src/routes/__tests__/attribution.test.ts +7 -7
- package/src/routes/__tests__/health.test.ts +3 -3
- package/src/routes/__tests__/imagery.test.ts +1 -1
- package/src/routes/__tests__/memory.fs.ts +2 -2
- package/src/routes/__tests__/preview.index.test.ts +3 -3
- package/src/routes/__tests__/tile.json.test.ts +1 -1
- package/src/routes/__tests__/tile.style.json.test.ts +175 -15
- package/src/routes/__tests__/wmts.test.ts +23 -3
- package/src/routes/config.ts +1 -1
- package/src/routes/ping.ts +2 -2
- package/src/routes/preview.index.ts +2 -1
- package/src/routes/preview.ts +7 -5
- package/src/routes/sprites.ts +1 -1
- package/src/routes/tile.style.json.ts +73 -9
- package/src/routes/tile.wmts.ts +1 -0
- package/src/routes/tile.xyz.raster.ts +8 -6
- package/src/routes/version.ts +2 -2
- package/src/util/__test__/config.loader.test.ts +17 -20
- package/src/util/config.cache.ts +2 -1
- package/src/util/source.cache.ts +6 -4
- package/src/util/validate.ts +1 -1
- package/src/wmts.capability.ts +17 -9
- package/tsconfig.json +10 -10
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -42,11 +42,11 @@ describe('ConfigLoader', () => {
|
|
|
42
42
|
mockUrlRequest('/v1/tiles/🦄 🌈/NZTM2000Quad/tile.json', `?config=notapath`, Api.header),
|
|
43
43
|
)
|
|
44
44
|
.then(() => null)
|
|
45
|
-
.catch((e) => e);
|
|
45
|
+
.catch((e) => e as LambdaHttpResponse);
|
|
46
46
|
|
|
47
47
|
assert.equal(error instanceof LambdaHttpResponse, true);
|
|
48
|
-
assert.equal(
|
|
49
|
-
assert.equal(
|
|
48
|
+
assert.equal(error?.status, 400);
|
|
49
|
+
assert.equal(error?.statusDescription, 'Invalid configuration location protocol:file:');
|
|
50
50
|
});
|
|
51
51
|
|
|
52
52
|
it('should Not working with wrong protocol', async () => {
|
|
@@ -54,11 +54,11 @@ describe('ConfigLoader', () => {
|
|
|
54
54
|
mockUrlRequest('/v1/tiles/🦄 🌈/NZTM2000Quad/tile.json', `?config=memory1://linz-basemaps/config`, Api.header),
|
|
55
55
|
)
|
|
56
56
|
.then(() => null)
|
|
57
|
-
.catch((e) => e);
|
|
57
|
+
.catch((e) => e as LambdaHttpResponse);
|
|
58
58
|
|
|
59
59
|
assert.equal(error instanceof LambdaHttpResponse, true);
|
|
60
|
-
assert.equal(
|
|
61
|
-
assert.equal(
|
|
60
|
+
assert.equal(error?.status, 400);
|
|
61
|
+
assert.equal(error?.statusDescription, 'Invalid configuration location protocol:memory1:');
|
|
62
62
|
});
|
|
63
63
|
|
|
64
64
|
it('should Not working with wrong s3 bucket', async () => {
|
|
@@ -66,28 +66,25 @@ describe('ConfigLoader', () => {
|
|
|
66
66
|
mockUrlRequest('/v1/tiles/🦄 🌈/NZTM2000Quad/tile.json', `?config=s3://wrong-bucket/config`, Api.header),
|
|
67
67
|
)
|
|
68
68
|
.then(() => null)
|
|
69
|
-
.catch((e) => e);
|
|
69
|
+
.catch((e) => e as LambdaHttpResponse);
|
|
70
70
|
|
|
71
71
|
assert.equal(error instanceof LambdaHttpResponse, true);
|
|
72
|
-
assert.equal(
|
|
73
|
-
assert.equal(
|
|
74
|
-
(error as LambdaHttpResponse).statusDescription,
|
|
75
|
-
'Bucket: "wrong-bucket" is not a allowed bucket location',
|
|
76
|
-
);
|
|
72
|
+
assert.equal(error?.status, 400);
|
|
73
|
+
assert.equal(error?.statusDescription, 'Bucket: "wrong-bucket" is not a allowed bucket location');
|
|
77
74
|
});
|
|
78
75
|
|
|
79
76
|
const location = new URL('memory://linz-basemaps/config.json');
|
|
80
77
|
|
|
81
78
|
it('should Not working with no file in the path', async () => {
|
|
82
79
|
const error = await ConfigLoader.load(
|
|
83
|
-
mockUrlRequest('/v1/tiles/🦄 🌈/NZTM2000Quad/tile.json', `?config=${location}`, Api.header),
|
|
80
|
+
mockUrlRequest('/v1/tiles/🦄 🌈/NZTM2000Quad/tile.json', `?config=${location.href}`, Api.header),
|
|
84
81
|
)
|
|
85
82
|
.then(() => null)
|
|
86
|
-
.catch((e) => e);
|
|
83
|
+
.catch((e) => e as LambdaHttpResponse);
|
|
87
84
|
|
|
88
85
|
assert.equal(error instanceof LambdaHttpResponse, true);
|
|
89
|
-
assert.equal(
|
|
90
|
-
assert.equal(
|
|
86
|
+
assert.equal(error?.status, 400);
|
|
87
|
+
assert.equal(error?.statusDescription, `Invalid config location at ${location.href}`);
|
|
91
88
|
});
|
|
92
89
|
|
|
93
90
|
it('should get expected config file', async () => {
|
|
@@ -96,7 +93,7 @@ describe('ConfigLoader', () => {
|
|
|
96
93
|
await fsa.write(location, Buffer.from(JSON.stringify(expectedConfig.toJson())));
|
|
97
94
|
|
|
98
95
|
const provider = await ConfigLoader.load(
|
|
99
|
-
mockUrlRequest('/v1/tiles/🦄 🌈/NZTM2000Quad/tile.json', `?config=${location}`, Api.header),
|
|
96
|
+
mockUrlRequest('/v1/tiles/🦄 🌈/NZTM2000Quad/tile.json', `?config=${location.href}`, Api.header),
|
|
100
97
|
);
|
|
101
98
|
|
|
102
99
|
assert.deepEqual(await provider.Imagery.get('aerial'), await expectedConfig.Imagery.get('aerial'));
|
|
@@ -124,10 +121,10 @@ describe('ConfigLoader', () => {
|
|
|
124
121
|
mockUrlRequest('/v1/tiles/🦄 🌈/NZTM2000Quad/tile.json', `?config=${deletedLocation}`, Api.header),
|
|
125
122
|
)
|
|
126
123
|
.then(() => null)
|
|
127
|
-
.catch((e) => e);
|
|
124
|
+
.catch((e) => e as LambdaHttpResponse);
|
|
128
125
|
|
|
129
126
|
assert.equal(error instanceof LambdaHttpResponse, true);
|
|
130
|
-
assert.equal(
|
|
131
|
-
assert.equal(
|
|
127
|
+
assert.equal(error?.status, 400);
|
|
128
|
+
assert.equal(error?.statusDescription, `Invalid config location at ${deletedLocation}`);
|
|
132
129
|
});
|
|
133
130
|
});
|
package/src/util/config.cache.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ConfigBundled, ConfigProviderMemory } from '@basemaps/config';
|
|
2
2
|
import { fsa } from '@basemaps/shared';
|
|
3
|
+
import { FsError } from '@chunkd/fs';
|
|
3
4
|
|
|
4
5
|
import { SwappingLru } from './swapping.lru.js';
|
|
5
6
|
|
|
@@ -15,7 +16,7 @@ class LruConfig {
|
|
|
15
16
|
return configProvider;
|
|
16
17
|
})
|
|
17
18
|
.catch((e) => {
|
|
18
|
-
if (e.code === 404) return null;
|
|
19
|
+
if ((e as FsError).code === 404) return null;
|
|
19
20
|
throw e;
|
|
20
21
|
});
|
|
21
22
|
}
|
package/src/util/source.cache.ts
CHANGED
|
@@ -20,7 +20,9 @@ class LruStrutObj<T extends LruStrut> {
|
|
|
20
20
|
ob: T;
|
|
21
21
|
constructor(ob: T) {
|
|
22
22
|
this.ob = ob;
|
|
23
|
-
if (this.ob._value == null)
|
|
23
|
+
if (this.ob._value == null) {
|
|
24
|
+
void this.ob.value.then((c) => (this.ob._value = c));
|
|
25
|
+
}
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
size = 1;
|
|
@@ -37,7 +39,7 @@ export class SourceCache {
|
|
|
37
39
|
|
|
38
40
|
if (existing != null) {
|
|
39
41
|
if (existing.type === 'cog') return existing.value;
|
|
40
|
-
throw new Error(`Existing object of type: ${existing.type} made for location: ${location}`);
|
|
42
|
+
throw new Error(`Existing object of type: ${existing.type} made for location: ${location.href}`);
|
|
41
43
|
}
|
|
42
44
|
const value = Tiff.create(fsa.source(location));
|
|
43
45
|
this.cache.set(location.href, new LruStrutObj({ type: 'cog', value }));
|
|
@@ -48,8 +50,8 @@ export class SourceCache {
|
|
|
48
50
|
const existing = this.cache.get(location.href)?.ob;
|
|
49
51
|
|
|
50
52
|
if (existing != null) {
|
|
51
|
-
if (existing.type === 'cotar') return existing.value
|
|
52
|
-
throw new Error(`Existing object of type: ${existing.type} made for location: ${location}`);
|
|
53
|
+
if (existing.type === 'cotar') return existing.value;
|
|
54
|
+
throw new Error(`Existing object of type: ${existing.type} made for location: ${location.href}`);
|
|
53
55
|
}
|
|
54
56
|
const value = Cotar.fromTar(fsa.source(location));
|
|
55
57
|
this.cache.set(location.href, new LruStrutObj({ type: 'cotar', value }));
|
package/src/util/validate.ts
CHANGED
|
@@ -138,7 +138,7 @@ export const Validate = {
|
|
|
138
138
|
}
|
|
139
139
|
// If the tileset has pipelines defined the user MUST specify which one
|
|
140
140
|
if (tileSet.outputs) {
|
|
141
|
-
throw new LambdaHttpResponse(404, 'TileSet needs pipeline: ' + tileSet.outputs.map((f) => f.name));
|
|
141
|
+
throw new LambdaHttpResponse(404, 'TileSet needs pipeline: ' + tileSet.outputs.map((f) => f.name).join(', '));
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
// Generate a default RGBA configuration
|
package/src/wmts.capability.ts
CHANGED
|
@@ -38,14 +38,15 @@ export interface WmtsBuilderParams {
|
|
|
38
38
|
apiKey?: string;
|
|
39
39
|
/** Config location */
|
|
40
40
|
config?: string | null;
|
|
41
|
-
/**
|
|
42
|
-
|
|
41
|
+
/** Default pipeline to use */
|
|
42
|
+
pipeline?: string;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
export class WmtsBuilder {
|
|
46
46
|
httpBase: string;
|
|
47
47
|
apiKey?: string;
|
|
48
48
|
config?: string | null;
|
|
49
|
+
pipeline?: string;
|
|
49
50
|
filters?: Record<string, string | undefined>;
|
|
50
51
|
|
|
51
52
|
/** All the imagery used by the tileSet and tileMatrixes */
|
|
@@ -58,7 +59,7 @@ export class WmtsBuilder {
|
|
|
58
59
|
this.httpBase = params.httpBase;
|
|
59
60
|
this.apiKey = params.apiKey;
|
|
60
61
|
this.config = params.config;
|
|
61
|
-
this.
|
|
62
|
+
this.pipeline = params.pipeline;
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
addImagery(...imagery: ConfigImagery[]): void {
|
|
@@ -153,17 +154,17 @@ export class WmtsBuilder {
|
|
|
153
154
|
return V('Style', { isDefault: 'true' }, [V('ows:Title', 'Default Style'), V('ows:Identifier', 'default')]);
|
|
154
155
|
}
|
|
155
156
|
|
|
156
|
-
buildResourceUrl(tileSetId: string, suffix: string
|
|
157
|
+
buildResourceUrl(tileSetId: string, suffix: string): VNodeElement {
|
|
157
158
|
return V('ResourceURL', {
|
|
158
159
|
format: 'image/' + suffix,
|
|
159
160
|
resourceType: 'tile',
|
|
160
|
-
template: this.buildTileUrl(tileSetId, suffix
|
|
161
|
+
template: this.buildTileUrl(tileSetId, suffix),
|
|
161
162
|
});
|
|
162
163
|
}
|
|
163
164
|
|
|
164
|
-
buildTileUrl(tileSetId: string, suffix: string
|
|
165
|
-
|
|
166
|
-
|
|
165
|
+
buildTileUrl(tileSetId: string, suffix: string): string {
|
|
166
|
+
// TODO this should restrict the output formats to supported formats in pipelines
|
|
167
|
+
const query = { api: this.apiKey, config: this.config, pipeline: this.pipeline };
|
|
167
168
|
|
|
168
169
|
return [
|
|
169
170
|
this.httpBase,
|
|
@@ -239,6 +240,8 @@ export interface WmtsCapabilitiesParams {
|
|
|
239
240
|
formats: ImageFormat[];
|
|
240
241
|
/** Specific layers to add to the WMTS */
|
|
241
242
|
layers?: ConfigLayer[];
|
|
243
|
+
/** Default output pipeline to use */
|
|
244
|
+
pipeline?: string | null;
|
|
242
245
|
}
|
|
243
246
|
|
|
244
247
|
/**
|
|
@@ -277,6 +280,10 @@ export class WmtsCapabilities extends WmtsBuilder {
|
|
|
277
280
|
this.provider = provider;
|
|
278
281
|
}
|
|
279
282
|
|
|
283
|
+
addPipeline(pipeline: string): void {
|
|
284
|
+
this.pipeline = pipeline;
|
|
285
|
+
}
|
|
286
|
+
|
|
280
287
|
toProviderVNode(provider?: WmtsProvider): VNodeElement[] | [] {
|
|
281
288
|
if (provider == null) return [];
|
|
282
289
|
const { serviceIdentification, serviceProvider } = provider;
|
|
@@ -338,7 +345,7 @@ export class WmtsCapabilities extends WmtsBuilder {
|
|
|
338
345
|
this.buildStyle(),
|
|
339
346
|
...this.buildFormats(),
|
|
340
347
|
...this.buildTileMatrixLink(tileSet),
|
|
341
|
-
...this.getFormats().map((fmt) => this.buildResourceUrl(layerNameId, fmt
|
|
348
|
+
...this.getFormats().map((fmt) => this.buildResourceUrl(layerNameId, fmt)),
|
|
342
349
|
]);
|
|
343
350
|
}
|
|
344
351
|
|
|
@@ -408,5 +415,6 @@ export class WmtsCapabilities extends WmtsBuilder {
|
|
|
408
415
|
this.addTileSet(params.tileSet);
|
|
409
416
|
this.addLayers(params.layers);
|
|
410
417
|
this.addProvider(params.provider);
|
|
418
|
+
if (params.pipeline) this.addPipeline(params.pipeline);
|
|
411
419
|
}
|
|
412
420
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"extends": "../../tsconfig.base.json",
|
|
3
3
|
"compilerOptions": {
|
|
4
|
-
"
|
|
5
|
-
"
|
|
4
|
+
"outDir": "./build",
|
|
5
|
+
"rootDir": "./src"
|
|
6
6
|
},
|
|
7
|
-
"include": ["src
|
|
7
|
+
"include": ["src"],
|
|
8
8
|
"references": [
|
|
9
|
-
{ "path": "../config" },
|
|
10
|
-
{ "path": "../config-loader/" },
|
|
11
|
-
{ "path": "../shared" },
|
|
12
|
-
{ "path": "../geo" },
|
|
13
|
-
{ "path": "../tiler" },
|
|
14
|
-
{ "path": "../tiler-sharp" },
|
|
15
|
-
{ "path": "../attribution" }
|
|
9
|
+
{ "path": "../config/tsconfig.json" },
|
|
10
|
+
{ "path": "../config-loader/tsconfig.json" },
|
|
11
|
+
{ "path": "../shared/tsconfig.json" },
|
|
12
|
+
{ "path": "../geo/tsconfig.json" },
|
|
13
|
+
{ "path": "../tiler/tsconfig.json" },
|
|
14
|
+
{ "path": "../tiler-sharp/tsconfig.json" },
|
|
15
|
+
{ "path": "../attribution/tsconfig.json" }
|
|
16
16
|
]
|
|
17
17
|
}
|