diff --git a/src/schemas/export/job.schema.ts b/src/schemas/export/job.schema.ts index f37ba63..b142602 100644 --- a/src/schemas/export/job.schema.ts +++ b/src/schemas/export/job.schema.ts @@ -1,13 +1,18 @@ import { z } from 'zod'; import { CORE_VALIDATIONS, TileFormatStrategy, TileOutputFormat } from '../../constants'; import { polygonPartsEntityNameSchema } from '../ingestion'; -import { urlsArraySchema } from '../core'; import { callbackExportResponseSchema, cleanupDataSchema, roiFeatureCollectionSchema, fileNamesTemplatesSchema } from './export.schema'; +export const callbackUrlSchema = z.object({ + url: z.string().url(), +}); + +export const callbackUrlsArraySchema = z.array(callbackUrlSchema); // TODO: remove when all services use the same callback schema( currently ingestion uses urlsArraySchema and export uses callbackUrlSchema) + export const exportInputParamsSchema = z.object({ crs: z.string(z.literal('EPSG:4326')), roi: roiFeatureCollectionSchema, - callbackUrls: urlsArraySchema.optional(), + callbackUrls: callbackUrlsArraySchema.optional(), }); export const exportAdditionalParamsSchema = z diff --git a/src/schemas/ingestion/index.ts b/src/schemas/ingestion/index.ts index 18d408c..0efefdb 100644 --- a/src/schemas/ingestion/index.ts +++ b/src/schemas/ingestion/index.ts @@ -7,3 +7,4 @@ export * from './task.schema'; export * from './layerNameFormats.schema'; export * from './callback.schema'; export * from './validationTask.schema'; +export * from './product.schema'; diff --git a/src/schemas/ingestion/product.schema.ts b/src/schemas/ingestion/product.schema.ts new file mode 100644 index 0000000..215eca0 --- /dev/null +++ b/src/schemas/ingestion/product.schema.ts @@ -0,0 +1,7 @@ +import z from 'zod'; +import { featureSchema, multiPolygonSchema, polygonSchema } from '../core'; + +export const productFeatureSchema = featureSchema(z.union([polygonSchema, multiPolygonSchema]), z.object({}).passthrough()) + .array() + .length(1, 'product shapefile must contain a single feature') + .transform((features) => features[0]);