From 43bc5f1f6eeb30d08584b7cb8ec08231b173a5fe Mon Sep 17 00:00:00 2001 From: alebinson Date: Wed, 4 Nov 2026 15:13:41 +0200 Subject: [PATCH 1/2] feat: schemas --- package-lock.json | 13 +++++++- package.json | 3 +- src/index.ts | 1 + src/schemas/index.ts | 1 + .../serving-proxy/capability.schema.ts | 31 +++++++++++++++++++ 5 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 src/schemas/index.ts create mode 100644 src/schemas/serving-proxy/capability.schema.ts diff --git a/package-lock.json b/package-lock.json index 086b21c..fdfdcf7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -37,7 +37,8 @@ "ts-jest": "^26.4.4", "ts-node": "^9.1.1", "typedoc": "^0.24.7", - "typescript": "^4.2.4" + "typescript": "^4.2.4", + "zod": "~3.25.76" } }, "node_modules/@75lb/deep-merge": { @@ -12827,6 +12828,16 @@ "funding": { "url": "https://github.com/sponsors/sindresorhus" } + }, + "node_modules/zod": { + "version": "3.25.76", + "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz", + "integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/colinhacks" + } } } } diff --git a/package.json b/package.json index d0640b2..51ed661 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,8 @@ "ts-jest": "^26.4.4", "ts-node": "^9.1.1", "typedoc": "^0.24.7", - "typescript": "^4.2.4" + "typescript": "^4.2.4", + "zod": "~3.25.76" }, "dependencies": { "@types/geojson": "^7946.0.16", diff --git a/src/index.ts b/src/index.ts index 52f0d6a..30facbc 100644 --- a/src/index.ts +++ b/src/index.ts @@ -11,3 +11,4 @@ export * from './enums/geo/epsg'; export * from './helpers/mime'; export * from './types/countryTranslation'; export * from './interfaces'; +export * from './schemas'; diff --git a/src/schemas/index.ts b/src/schemas/index.ts new file mode 100644 index 0000000..8d81526 --- /dev/null +++ b/src/schemas/index.ts @@ -0,0 +1 @@ +export * from './serving-proxy/capability.schema'; diff --git a/src/schemas/serving-proxy/capability.schema.ts b/src/schemas/serving-proxy/capability.schema.ts new file mode 100644 index 0000000..473dad2 --- /dev/null +++ b/src/schemas/serving-proxy/capability.schema.ts @@ -0,0 +1,31 @@ +import { z } from 'zod'; + +export const StyleSchema = z.object({ + value: z.string().min(1).describe('Style identifier value'), + isDefault: z.string().min(1).nullable().describe('Whether this style is the default style'), +}); + +export const TileMatrixSetSchema = z.object({ + tileMatrixSetID: z.string().min(1).describe('Identifier of the TileMatrixSet'), + tileMatrixLabels: z.array(z.string().min(1)).min(1).describe('TileMatrix identifier per level'), +}); + +export const ResourceURLSchema = z.object({ + format: z.string().min(1).describe('MIME type of the resource'), + resourceType: z.string().min(1).describe('Type of the resource, e.g. tile'), + template: z.string().min(1).describe('URL template for the resource'), +}); + +export const CapabilitySchema = z.object({ + id: z.string().min(1).describe('Layer identifier'), + style: z.array(StyleSchema).min(1).describe('Styles available for the layer'), + format: z.array(z.string().min(1)).min(1).describe('MIME types supported by the layer'), + tileMatrixSet: z.array(TileMatrixSetSchema).min(1).describe('TileMatrixSets available for the layer'), + url: z.array(ResourceURLSchema).min(1).describe('Resource URLs available for the layer'), +}); + +// Inferred TypeScript types +export type Style = z.infer; +export type TileMatrixSet = z.infer; +export type ResourceURL = z.infer; +export type Capability = z.infer; From 233d46dcd8115b6f1c9a7ed1409a8119563a1f05 Mon Sep 17 00:00:00 2001 From: alebinson Date: Wed, 4 Nov 2026 15:19:01 +0200 Subject: [PATCH 2/2] chore: lint --- src/schemas/serving-proxy/capability.schema.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/schemas/serving-proxy/capability.schema.ts b/src/schemas/serving-proxy/capability.schema.ts index 473dad2..247d061 100644 --- a/src/schemas/serving-proxy/capability.schema.ts +++ b/src/schemas/serving-proxy/capability.schema.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/naming-convention */ import { z } from 'zod'; export const StyleSchema = z.object({