From 32a4bdcd4b11c0982dba9e34887007eab9e0f464 Mon Sep 17 00:00:00 2001 From: vitaligi <54726763+vitaligi@users.noreply.github.com> Date: Mon, 6 Jul 2026 17:21:17 +0300 Subject: [PATCH 1/4] refactor: handle resource deletion --- src/schemas/core/index.ts | 1 + src/schemas/core/storage.schema.ts | 13 +++++++++++++ src/schemas/deletion/task.schema.ts | 28 +++++++++++++++------------- src/types/core/index.ts | 1 + src/types/core/storage.type.ts | 6 ++++++ src/types/deletion/task.type.ts | 5 ++--- 6 files changed, 38 insertions(+), 16 deletions(-) create mode 100644 src/schemas/core/storage.schema.ts create mode 100644 src/types/core/storage.type.ts diff --git a/src/schemas/core/index.ts b/src/schemas/core/index.ts index 6438621..ee5ad72 100644 --- a/src/schemas/core/index.ts +++ b/src/schemas/core/index.ts @@ -8,3 +8,4 @@ export * from './link.schema'; export * from './file.schema'; export * from './polygonParts.schema'; export * from './tile.schema'; +export * from './storage.schema'; diff --git a/src/schemas/core/storage.schema.ts b/src/schemas/core/storage.schema.ts new file mode 100644 index 0000000..998ff87 --- /dev/null +++ b/src/schemas/core/storage.schema.ts @@ -0,0 +1,13 @@ +import { z } from 'zod'; +import { SourceType } from '../../constants/core/constants'; + +export const fsStorageSchema = z.object({ + sourceProvider: z.literal(SourceType.FS), +}); + +export const s3StorageSchema = z.object({ + sourceProvider: z.literal(SourceType.S3), + bucket: z.string().min(1), +}); + +export const storageSchema = z.discriminatedUnion('sourceProvider', [fsStorageSchema, s3StorageSchema]); diff --git a/src/schemas/deletion/task.schema.ts b/src/schemas/deletion/task.schema.ts index b5371fb..473b10a 100644 --- a/src/schemas/deletion/task.schema.ts +++ b/src/schemas/deletion/task.schema.ts @@ -12,19 +12,21 @@ export const deleteTaskParamsSchema = z }) .describe('deleteTaskParamsSchema'); -export const deletionParamsBaseSchema = z.object({ - sourceProvider: sourceProviderSchema, - bucket: z.string().optional(), +export const fsStorageSchema = z.object({ + sourceProvider: z.literal(SourceType.FS), }); -export const layerTilesDeletionParamsSchema = deletionParamsBaseSchema - .extend({ - catalogId: z.string().uuid(), - }) - .describe('layerTilesDeletionParamsSchema'); +export const s3StorageSchema = z.object({ + sourceProvider: z.literal(SourceType.S3), + bucket: z.string().min(1), +}); -export const artifactsDeletionParamsSchema = deletionParamsBaseSchema - .extend({ - paths: z.array(z.string().min(1)).min(1), // explicit thumbnail/legend object keys (s3) or file paths (fs) - }) - .describe('artifactsDeletionParamsSchema'); +export const storageSchema = z.discriminatedUnion('sourceProvider', [fsStorageSchema, s3StorageSchema]); + +export const deleteStoredResourcesParamsBaseSchema = z.object({ + paths: z.array(z.string().min(1)).min(1), +}); + +export const deleteStoredResourcesParamsSchema = deleteStoredResourcesParamsBaseSchema + .and(storageSchema) + .describe('deleteStoredResourcesParamsSchema'); diff --git a/src/types/core/index.ts b/src/types/core/index.ts index b27df06..53328de 100644 --- a/src/types/core/index.ts +++ b/src/types/core/index.ts @@ -8,3 +8,4 @@ export * from './file.type'; export * from './callback.type'; export * from './polygonParts.type'; export * from './tile.type'; +export * from './storage.type'; diff --git a/src/types/core/storage.type.ts b/src/types/core/storage.type.ts new file mode 100644 index 0000000..ebb6bb6 --- /dev/null +++ b/src/types/core/storage.type.ts @@ -0,0 +1,6 @@ +import type { z } from 'zod'; +import type { fsStorageSchema, s3StorageSchema, storageSchema } from '../../schemas'; + +export type FsStorage = z.infer; +export type S3Storage = z.infer; +export type Storage = z.infer; diff --git a/src/types/deletion/task.type.ts b/src/types/deletion/task.type.ts index afe8c6e..0a1e256 100644 --- a/src/types/deletion/task.type.ts +++ b/src/types/deletion/task.type.ts @@ -1,6 +1,5 @@ import z from 'zod'; -import { deleteTaskParamsSchema, layerTilesDeletionParamsSchema, artifactsDeletionParamsSchema } from '../../schemas/deletion/task.schema'; +import { deleteTaskParamsSchema, deleteStoredResourcesParamsSchema } from '../../schemas/deletion/task.schema'; export type DeleteTaskParams = z.infer; -export type LayerTilesDeletionParams = z.infer; -export type ArtifactsDeletionParams = z.infer; +export type DeleteStoredResourcesParams = z.infer; From 7d9705e5a2fcd82221c28b10c21720752a3fc8ce Mon Sep 17 00:00:00 2001 From: vitaligi <54726763+vitaligi@users.noreply.github.com> Date: Mon, 6 Jul 2026 17:42:20 +0300 Subject: [PATCH 2/4] fix: remove duplicate export --- src/schemas/deletion/task.schema.ts | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/schemas/deletion/task.schema.ts b/src/schemas/deletion/task.schema.ts index 473b10a..3d089d1 100644 --- a/src/schemas/deletion/task.schema.ts +++ b/src/schemas/deletion/task.schema.ts @@ -1,5 +1,6 @@ import { z } from 'zod'; import { SourceType } from '../../constants/core/constants'; +import { storageSchema } from '../core'; export const sourceProviderSchema = z.union([z.literal(SourceType.S3), z.literal(SourceType.FS)]); @@ -12,17 +13,6 @@ export const deleteTaskParamsSchema = z }) .describe('deleteTaskParamsSchema'); -export const fsStorageSchema = z.object({ - sourceProvider: z.literal(SourceType.FS), -}); - -export const s3StorageSchema = z.object({ - sourceProvider: z.literal(SourceType.S3), - bucket: z.string().min(1), -}); - -export const storageSchema = z.discriminatedUnion('sourceProvider', [fsStorageSchema, s3StorageSchema]); - export const deleteStoredResourcesParamsBaseSchema = z.object({ paths: z.array(z.string().min(1)).min(1), }); From eb6f141ac2be1adb4c3b1c315ef5760718efd06c Mon Sep 17 00:00:00 2001 From: vitaligi <54726763+vitaligi@users.noreply.github.com> Date: Tue, 7 Jul 2026 10:45:51 +0300 Subject: [PATCH 3/4] refactor: remove unused schema --- src/schemas/deletion/task.schema.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/schemas/deletion/task.schema.ts b/src/schemas/deletion/task.schema.ts index 3d089d1..27c89dc 100644 --- a/src/schemas/deletion/task.schema.ts +++ b/src/schemas/deletion/task.schema.ts @@ -1,9 +1,6 @@ import { z } from 'zod'; -import { SourceType } from '../../constants/core/constants'; import { storageSchema } from '../core'; -export const sourceProviderSchema = z.union([z.literal(SourceType.S3), z.literal(SourceType.FS)]); - export const deleteTaskParamsSchema = z .object({ deleteFromCatalog: z.boolean().default(false), From b21a83e8d3231a1d892e9e5516db21f9484d1d5a Mon Sep 17 00:00:00 2001 From: vitaligi <54726763+vitaligi@users.noreply.github.com> Date: Tue, 7 Jul 2026 10:59:57 +0300 Subject: [PATCH 4/4] refactor: rename sourceProvider to storageProvider --- src/schemas/core/storage.schema.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/schemas/core/storage.schema.ts b/src/schemas/core/storage.schema.ts index 998ff87..d56f4c3 100644 --- a/src/schemas/core/storage.schema.ts +++ b/src/schemas/core/storage.schema.ts @@ -2,12 +2,12 @@ import { z } from 'zod'; import { SourceType } from '../../constants/core/constants'; export const fsStorageSchema = z.object({ - sourceProvider: z.literal(SourceType.FS), + storageProvider: z.literal(SourceType.FS), }); export const s3StorageSchema = z.object({ - sourceProvider: z.literal(SourceType.S3), + storageProvider: z.literal(SourceType.S3), bucket: z.string().min(1), }); -export const storageSchema = z.discriminatedUnion('sourceProvider', [fsStorageSchema, s3StorageSchema]); +export const storageSchema = z.discriminatedUnion('storageProvider', [fsStorageSchema, s3StorageSchema]);