From b668bfdae7c4059088ca48defc4ee199647b65ed Mon Sep 17 00:00:00 2001 From: almog8k Date: Wed, 19 Nov 2025 16:16:01 +0200 Subject: [PATCH] feat: adding valdiation aggreagted errors schemas+type --- src/schemas/core/callback.schema.ts | 4 ++-- src/schemas/ingestion/callback.schema.ts | 2 +- .../ingestion/validationTask.schema.ts | 21 +++++++++++++++++++ src/types/ingestion/task.type.ts | 2 ++ 4 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 src/schemas/ingestion/validationTask.schema.ts diff --git a/src/schemas/core/callback.schema.ts b/src/schemas/core/callback.schema.ts index 68f2b47..e095f17 100644 --- a/src/schemas/core/callback.schema.ts +++ b/src/schemas/core/callback.schema.ts @@ -7,9 +7,9 @@ export const callbackUrlSchema = z.string().url(); export const callbackUrlsArraySchema = z.array(callbackUrlSchema); export const fileMetadataSchema = z.object({ - name: z.string(), + fileName: z.string().min(1), + fileSize: z.number().nonnegative(), url: callbackUrlSchema, - size: z.number(), }); // eslint-disable-next-line @typescript-eslint/explicit-function-return-type diff --git a/src/schemas/ingestion/callback.schema.ts b/src/schemas/ingestion/callback.schema.ts index a2a40f0..74d9899 100644 --- a/src/schemas/ingestion/callback.schema.ts +++ b/src/schemas/ingestion/callback.schema.ts @@ -6,7 +6,7 @@ import { fileMetadataSchema } from '../core'; export const validationTaskCallbackDataSchema = z .object({ isValid: z.boolean(), - sourceName: z.string(), + sourceName: z.string().min(1), links: fileMetadataSchema.array().optional(), }) .describe('validationTaskCallbackDataSchema'); diff --git a/src/schemas/ingestion/validationTask.schema.ts b/src/schemas/ingestion/validationTask.schema.ts new file mode 100644 index 0000000..7efeec2 --- /dev/null +++ b/src/schemas/ingestion/validationTask.schema.ts @@ -0,0 +1,21 @@ +import z from 'zod'; + +export const counterSchema = z.number().min(0).describe('A non-negative integer counter'); + +export const thresholdCheckSchema = z.object({ + exceeded: z.boolean().describe('Indicates if the threshold has been exceeded'), + count: counterSchema, +}); + +export const featuresErrorCountSchema = z.object({ + geometryValidity: counterSchema.describe('Number of features with invalid geometry'), + vertices: counterSchema.describe('Number of features exceeding the maximum allowed vertices'), + metadata: counterSchema.describe('Number of features with invalid or missing metadata'), + resolution: counterSchema.describe('Number of features not matching the required resolution'), +}); + +export const validationAggregatedErrorsSchema = z.object({ + errorsCount: featuresErrorCountSchema.describe('Aggregated count of validation errors'), + smallHoles: thresholdCheckSchema.describe('Small holes threshold check result'), + smallGeometries: thresholdCheckSchema.describe('Small geometries threshold check result'), +}); diff --git a/src/types/ingestion/task.type.ts b/src/types/ingestion/task.type.ts index ad09535..065b747 100644 --- a/src/types/ingestion/task.type.ts +++ b/src/types/ingestion/task.type.ts @@ -5,6 +5,7 @@ import { ingestionUpdateFinalizeTaskParamsSchema, ingestionValidationTaskParamsSchema, } from '../../schemas'; +import { validationAggregatedErrorsSchema } from '../../schemas/ingestion/validationTask.schema'; //#region IngestionFinalizeTaskParams export type IngestionNewFinalizeTaskParams = z.infer; @@ -14,4 +15,5 @@ export type IngestionSwapUpdateFinalizeTaskParams = z.infer; +export type ValidationAggregatedErrors = z.infer; //#endregion