From d9f5324ec6cdacd81a25f401954b798d778bf5fb Mon Sep 17 00:00:00 2001 From: razbroc Date: Wed, 26 Nov 2025 14:48:06 +0200 Subject: [PATCH 1/4] refactor: consolidate callback URL schemas and update imports --- src/schemas/core/callback.schema.ts | 10 ---------- src/schemas/core/index.ts | 1 + src/schemas/core/link.schema.ts | 11 +++++++++++ src/schemas/export/job.schema.ts | 4 ++-- src/schemas/ingestion/callback.schema.ts | 2 +- src/schemas/ingestion/job.schema.ts | 4 ++-- src/schemas/ingestion/task.schema.ts | 2 ++ src/types/export/export.type.ts | 6 +++--- 8 files changed, 22 insertions(+), 18 deletions(-) create mode 100644 src/schemas/core/link.schema.ts diff --git a/src/schemas/core/callback.schema.ts b/src/schemas/core/callback.schema.ts index e095f17..db3a587 100644 --- a/src/schemas/core/callback.schema.ts +++ b/src/schemas/core/callback.schema.ts @@ -2,16 +2,6 @@ import z from 'zod'; import { OperationStatus } from '@map-colonies/mc-priority-queue'; import { rasterProductTypeSchema, resourceIdSchema, versionSchema } from './job.schema'; -export const callbackUrlSchema = z.string().url(); - -export const callbackUrlsArraySchema = z.array(callbackUrlSchema); - -export const fileMetadataSchema = z.object({ - fileName: z.string().min(1), - fileSize: z.number().nonnegative(), - url: callbackUrlSchema, -}); - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type export const createCallbackResponseSchema = (dataSchema?: z.ZodType) => { return z.object({ diff --git a/src/schemas/core/index.ts b/src/schemas/core/index.ts index 0ffd356..82892e3 100644 --- a/src/schemas/core/index.ts +++ b/src/schemas/core/index.ts @@ -4,3 +4,4 @@ export * from './task.schema'; export * from './mime.schema'; export * from './aggregation.schema'; export * from './callback.schema'; +export * from './link.schema'; diff --git a/src/schemas/core/link.schema.ts b/src/schemas/core/link.schema.ts new file mode 100644 index 0000000..ef1f5ef --- /dev/null +++ b/src/schemas/core/link.schema.ts @@ -0,0 +1,11 @@ +import z from 'zod'; + +export const urlSchema = z.string().url(); + +export const urlsArraySchema = z.array(urlSchema); + +export const fileMetadataSchema = z.object({ + fileName: z.string().min(1), + fileSize: z.number().nonnegative(), + url: urlSchema, +}); diff --git a/src/schemas/export/job.schema.ts b/src/schemas/export/job.schema.ts index aafd996..9af476f 100644 --- a/src/schemas/export/job.schema.ts +++ b/src/schemas/export/job.schema.ts @@ -1,13 +1,13 @@ import { z } from 'zod'; import { CORE_VALIDATIONS, TileFormatStrategy, TileOutputFormat } from '../../constants'; import { polygonPartsEntityNameSchema } from '../ingestion'; -import { callbackUrlsArraySchema } from '../core/callback.schema'; +import { urlsArraySchema } from '../core/'; import { callbackExportResponseSchema, cleanupDataSchema, roiFeatureCollectionSchema, fileNamesTemplatesSchema } from './export.schema'; export const exportInputParamsSchema = z.object({ crs: z.string(z.literal('EPSG:4326')), roi: roiFeatureCollectionSchema, - callbackUrls: callbackUrlsArraySchema.optional(), + callbackUrls: urlsArraySchema.optional(), }); export const exportAdditionalParamsSchema = z diff --git a/src/schemas/ingestion/callback.schema.ts b/src/schemas/ingestion/callback.schema.ts index 74d9899..8c87c20 100644 --- a/src/schemas/ingestion/callback.schema.ts +++ b/src/schemas/ingestion/callback.schema.ts @@ -1,5 +1,5 @@ import z from 'zod'; -import { fileMetadataSchema } from '../core'; +import { fileMetadataSchema } from '../core/'; //#region Validation diff --git a/src/schemas/ingestion/job.schema.ts b/src/schemas/ingestion/job.schema.ts index edd1569..a2d1cc7 100644 --- a/src/schemas/ingestion/job.schema.ts +++ b/src/schemas/ingestion/job.schema.ts @@ -1,6 +1,6 @@ import z from 'zod'; import { CORE_VALIDATIONS } from '../../constants'; -import { callbackUrlsArraySchema } from '../core/callback.schema'; +import { urlsArraySchema } from '../core'; import { newAdditionalParamsSchema, swapUpdateAdditionalParamsSchema, updateAdditionalParamsSchema } from './additionalParams.schema'; import { inputFilesSchema } from './inputFiles.schema'; import { newRasterLayerMetadataSchema, updateRasterLayerMetadataSchema } from './metadata.schema'; @@ -18,7 +18,7 @@ export const ingestionBaseJobParamsSchema = z .object({ inputFiles: inputFilesSchema, ingestionResolution: ingestionResolutionSchema, - callbackUrls: callbackUrlsArraySchema.optional(), + callbackUrls: urlsArraySchema.optional(), }) .describe('ingestionBaseJobParamsSchema'); diff --git a/src/schemas/ingestion/task.schema.ts b/src/schemas/ingestion/task.schema.ts index 7f7af7d..4830cbd 100644 --- a/src/schemas/ingestion/task.schema.ts +++ b/src/schemas/ingestion/task.schema.ts @@ -1,4 +1,5 @@ import z from 'zod'; +import { fileMetadataSchema } from '../core'; export const ingestionNewFinalizeTaskParamsSchema = z .object({ @@ -22,6 +23,7 @@ export const ingestionSwapUpdateTaskParamsSchema = ingestionUpdateFinalizeTaskPa export const ingestionValidationTaskParamsSchema = z .object({ + links: fileMetadataSchema.optional(), isValid: z.boolean(), }) .describe('ingestionValidationTaskParamsSchema'); diff --git a/src/types/export/export.type.ts b/src/types/export/export.type.ts index 4028013..2084d9e 100644 --- a/src/types/export/export.type.ts +++ b/src/types/export/export.type.ts @@ -10,14 +10,14 @@ import { linksSchema, roiPropertiesSchema, } from '../../schemas/export/export.schema'; -import { callbackUrlsArraySchema, callbackUrlSchema } from '../../schemas/core/callback.schema'; +import { urlsArraySchema, urlSchema } from '../../schemas/core'; export type RoiProperties = z.infer; export type RoiFeature = Feature; export type RoiFeatureCollection = FeatureCollection; -export type CallbackUrl = z.infer; -export type CallbackUrlsTargetArray = z.infer; +export type CallbackUrl = z.infer; +export type CallbackUrlsTargetArray = z.infer; export type CallbackExportResponse = z.infer; export type CallbacksStatus = z.infer; From 5c16fb15d459ca6e6821a4d993744847e27dd9e7 Mon Sep 17 00:00:00 2001 From: razbroc Date: Wed, 26 Nov 2025 16:47:26 +0200 Subject: [PATCH 2/4] feat: add links.type.ts for FileMetadata type definition --- src/types/core/index.ts | 1 + src/types/core/links.type.ts | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 src/types/core/links.type.ts diff --git a/src/types/core/index.ts b/src/types/core/index.ts index 59f0ebe..b052b0f 100644 --- a/src/types/core/index.ts +++ b/src/types/core/index.ts @@ -3,3 +3,4 @@ export * from './task.type'; export * from './metadata.type'; export * from './layer.type'; export * from './part.type'; +export * from './links.type'; diff --git a/src/types/core/links.type.ts b/src/types/core/links.type.ts new file mode 100644 index 0000000..fce216a --- /dev/null +++ b/src/types/core/links.type.ts @@ -0,0 +1,4 @@ +import { z } from 'zod'; +import { fileMetadataSchema } from '../../schemas'; + +export type FileMetadata = z.infer; From 5989d501d05f3db792a8961515196bdc8b0c254f Mon Sep 17 00:00:00 2001 From: razbroc Date: Sun, 30 Nov 2025 11:29:13 +0200 Subject: [PATCH 3/4] feat: add fileMetadataSchema and update link schema; refactor types --- src/schemas/core/file.schema.ts | 8 ++++++++ src/schemas/core/index.ts | 1 + src/schemas/core/link.schema.ts | 9 ++------- src/schemas/ingestion/task.schema.ts | 2 +- src/types/core/index.ts | 2 +- src/types/core/link.type.ts | 7 +++++++ src/types/core/links.type.ts | 4 ---- src/types/export/export.type.ts | 3 --- 8 files changed, 20 insertions(+), 16 deletions(-) create mode 100644 src/schemas/core/file.schema.ts create mode 100644 src/types/core/link.type.ts delete mode 100644 src/types/core/links.type.ts diff --git a/src/schemas/core/file.schema.ts b/src/schemas/core/file.schema.ts new file mode 100644 index 0000000..30359a6 --- /dev/null +++ b/src/schemas/core/file.schema.ts @@ -0,0 +1,8 @@ +import z from 'zod'; +import { urlSchema } from './link.schema'; + +export const fileMetadataSchema = z.object({ + fileName: z.string().min(1), + fileSize: z.number().nonnegative().int().describe('File size in bytes'), + url: urlSchema, +}); diff --git a/src/schemas/core/index.ts b/src/schemas/core/index.ts index 82892e3..3a73c9e 100644 --- a/src/schemas/core/index.ts +++ b/src/schemas/core/index.ts @@ -5,3 +5,4 @@ export * from './mime.schema'; export * from './aggregation.schema'; export * from './callback.schema'; export * from './link.schema'; +export * from './file.schema'; diff --git a/src/schemas/core/link.schema.ts b/src/schemas/core/link.schema.ts index ef1f5ef..5adb789 100644 --- a/src/schemas/core/link.schema.ts +++ b/src/schemas/core/link.schema.ts @@ -1,11 +1,6 @@ import z from 'zod'; +import { CORE_VALIDATIONS } from '../../constants'; -export const urlSchema = z.string().url(); +export const urlSchema = z.string().regex(new RegExp(CORE_VALIDATIONS.url.pattern)); export const urlsArraySchema = z.array(urlSchema); - -export const fileMetadataSchema = z.object({ - fileName: z.string().min(1), - fileSize: z.number().nonnegative(), - url: urlSchema, -}); diff --git a/src/schemas/ingestion/task.schema.ts b/src/schemas/ingestion/task.schema.ts index 4830cbd..9a9d18d 100644 --- a/src/schemas/ingestion/task.schema.ts +++ b/src/schemas/ingestion/task.schema.ts @@ -23,7 +23,7 @@ export const ingestionSwapUpdateTaskParamsSchema = ingestionUpdateFinalizeTaskPa export const ingestionValidationTaskParamsSchema = z .object({ - links: fileMetadataSchema.optional(), + link: fileMetadataSchema.optional(), isValid: z.boolean(), }) .describe('ingestionValidationTaskParamsSchema'); diff --git a/src/types/core/index.ts b/src/types/core/index.ts index b052b0f..bd4373a 100644 --- a/src/types/core/index.ts +++ b/src/types/core/index.ts @@ -3,4 +3,4 @@ export * from './task.type'; export * from './metadata.type'; export * from './layer.type'; export * from './part.type'; -export * from './links.type'; +export * from './link.type'; diff --git a/src/types/core/link.type.ts b/src/types/core/link.type.ts new file mode 100644 index 0000000..87b6f3c --- /dev/null +++ b/src/types/core/link.type.ts @@ -0,0 +1,7 @@ +import { z } from 'zod'; +import { fileMetadataSchema, urlsArraySchema, urlSchema } from '../../schemas'; + +export type FileMetadata = z.infer; + +export type CallbackUrl = z.infer; +export type CallbackUrlsTargetArray = z.infer; diff --git a/src/types/core/links.type.ts b/src/types/core/links.type.ts deleted file mode 100644 index fce216a..0000000 --- a/src/types/core/links.type.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { z } from 'zod'; -import { fileMetadataSchema } from '../../schemas'; - -export type FileMetadata = z.infer; diff --git a/src/types/export/export.type.ts b/src/types/export/export.type.ts index 2084d9e..5c9a3bf 100644 --- a/src/types/export/export.type.ts +++ b/src/types/export/export.type.ts @@ -10,14 +10,11 @@ import { linksSchema, roiPropertiesSchema, } from '../../schemas/export/export.schema'; -import { urlsArraySchema, urlSchema } from '../../schemas/core'; export type RoiProperties = z.infer; export type RoiFeature = Feature; export type RoiFeatureCollection = FeatureCollection; -export type CallbackUrl = z.infer; -export type CallbackUrlsTargetArray = z.infer; export type CallbackExportResponse = z.infer; export type CallbacksStatus = z.infer; From 4da14404f95a8e768206478294148b69b4f48e57 Mon Sep 17 00:00:00 2001 From: razbroc Date: Sun, 30 Nov 2025 11:53:13 +0200 Subject: [PATCH 4/4] fix: update import paths for consistency in job and callback schemas --- src/schemas/export/job.schema.ts | 2 +- src/schemas/ingestion/callback.schema.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/schemas/export/job.schema.ts b/src/schemas/export/job.schema.ts index 9af476f..f37ba63 100644 --- a/src/schemas/export/job.schema.ts +++ b/src/schemas/export/job.schema.ts @@ -1,7 +1,7 @@ import { z } from 'zod'; import { CORE_VALIDATIONS, TileFormatStrategy, TileOutputFormat } from '../../constants'; import { polygonPartsEntityNameSchema } from '../ingestion'; -import { urlsArraySchema } from '../core/'; +import { urlsArraySchema } from '../core'; import { callbackExportResponseSchema, cleanupDataSchema, roiFeatureCollectionSchema, fileNamesTemplatesSchema } from './export.schema'; export const exportInputParamsSchema = z.object({ diff --git a/src/schemas/ingestion/callback.schema.ts b/src/schemas/ingestion/callback.schema.ts index 8c87c20..74d9899 100644 --- a/src/schemas/ingestion/callback.schema.ts +++ b/src/schemas/ingestion/callback.schema.ts @@ -1,5 +1,5 @@ import z from 'zod'; -import { fileMetadataSchema } from '../core/'; +import { fileMetadataSchema } from '../core'; //#region Validation