Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/schemas/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ export * from './link.schema';
export * from './file.schema';
export * from './polygonParts.schema';
export * from './tile.schema';
export * from './storage.schema';
13 changes: 13 additions & 0 deletions src/schemas/core/storage.schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { z } from 'zod';
import { SourceType } from '../../constants/core/constants';

export const fsStorageSchema = z.object({
storageProvider: z.literal(SourceType.FS),
});

export const s3StorageSchema = z.object({
storageProvider: z.literal(SourceType.S3),
bucket: z.string().min(1),
});

export const storageSchema = z.discriminatedUnion('storageProvider', [fsStorageSchema, s3StorageSchema]);
23 changes: 6 additions & 17 deletions src/schemas/deletion/task.schema.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { z } from 'zod';
import { SourceType } from '../../constants/core/constants';

export const sourceProviderSchema = z.union([z.literal(SourceType.S3), z.literal(SourceType.FS)]);
import { storageSchema } from '../core';

export const deleteTaskParamsSchema = z
.object({
Expand All @@ -12,19 +10,10 @@ export const deleteTaskParamsSchema = z
})
.describe('deleteTaskParamsSchema');

export const deletionParamsBaseSchema = z.object({
sourceProvider: sourceProviderSchema,
bucket: z.string().optional(),
export const deleteStoredResourcesParamsBaseSchema = z.object({
paths: z.array(z.string().min(1)).min(1),
});

export const layerTilesDeletionParamsSchema = deletionParamsBaseSchema
.extend({
catalogId: z.string().uuid(),
})
.describe('layerTilesDeletionParamsSchema');

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 deleteStoredResourcesParamsSchema = deleteStoredResourcesParamsBaseSchema
.and(storageSchema)
.describe('deleteStoredResourcesParamsSchema');
1 change: 1 addition & 0 deletions src/types/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ export * from './file.type';
export * from './callback.type';
export * from './polygonParts.type';
export * from './tile.type';
export * from './storage.type';
6 changes: 6 additions & 0 deletions src/types/core/storage.type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { z } from 'zod';
import type { fsStorageSchema, s3StorageSchema, storageSchema } from '../../schemas';

export type FsStorage = z.infer<typeof fsStorageSchema>;
export type S3Storage = z.infer<typeof s3StorageSchema>;
export type Storage = z.infer<typeof storageSchema>;
5 changes: 2 additions & 3 deletions src/types/deletion/task.type.ts
Original file line number Diff line number Diff line change
@@ -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<typeof deleteTaskParamsSchema>;
export type LayerTilesDeletionParams = z.infer<typeof layerTilesDeletionParamsSchema>;
export type ArtifactsDeletionParams = z.infer<typeof artifactsDeletionParamsSchema>;
export type DeleteStoredResourcesParams = z.infer<typeof deleteStoredResourcesParamsSchema>;
Loading