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
12 changes: 12 additions & 0 deletions src/constants/core/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,15 @@ export const CORE_VALIDATIONS = {

export const HASH_ALGORITHMS = ['XXH64'] as const;
export type HashAlgorithm = (typeof HASH_ALGORITHMS)[number];

export const MAX_ZOOM_LEVEL = 22;

/* eslint-disable @typescript-eslint/naming-convention */
export const SourceType = {
S3: 'S3',
GPKG: 'GPKG',
FS: 'FS',
} as const;
/* eslint-enable @typescript-eslint/naming-convention */

export type SourceType = (typeof SourceType)[keyof typeof SourceType];
7 changes: 0 additions & 7 deletions src/constants/export/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,11 @@ export const TileFormatStrategy = {
MIXED: 'mixed',
} as const;

export const SourceType = {
S3: 'S3',
GPKG: 'GPKG',
FS: 'FS',
} as const;

export const ExportFinalizeType = {
Full_Processing: 'FullProcessing',
Error_Callback: 'ErrorCallback',
} as const;

export type TileFormatStrategy = (typeof TileFormatStrategy)[keyof typeof TileFormatStrategy];
export type SourceType = (typeof SourceType)[keyof typeof SourceType];
export type ExportFinalizeType = (typeof ExportFinalizeType)[keyof typeof ExportFinalizeType];
/* eslint-disable @typescript-eslint/naming-convention */
29 changes: 29 additions & 0 deletions src/schemas/core/tile.schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { z } from 'zod';
import { MAX_ZOOM_LEVEL, SourceType, TileOutputFormat } from '../../constants';

export const tileRangeSchema = z.object({
zoom: z.number().int().min(0).max(MAX_ZOOM_LEVEL),
minX: z.number().int().min(0),
maxX: z.number().int().min(0),
minY: z.number().int().min(0),
maxY: z.number().int().min(0),
});

export const tilesDeletionParamsBaseSchema = z.object({
tilesPath: z.string().min(1), // Base path for the tiles to be deleted
ranges: z.array(tileRangeSchema).min(1), // Array of tile ranges to be deleted
Comment thread
razbroc marked this conversation as resolved.
fileExtension: z
.literal(TileOutputFormat.PNG)
.transform((val) => val.toLowerCase())
.or(z.literal(TileOutputFormat.JPEG).transform((val) => val.toLowerCase())), // File extension of the tiles (e.g., 'png', 'jpeg')
});

export const s3TilesDeletionParamsSchema = tilesDeletionParamsBaseSchema.extend({
sourceProvider: z.literal(SourceType.S3),
});

export const fsTilesDeletionParamsSchema = tilesDeletionParamsBaseSchema.extend({
sourceProvider: z.literal(SourceType.FS),
});

export const tilesDeletionParamsSchema = z.discriminatedUnion('sourceProvider', [s3TilesDeletionParamsSchema, fsTilesDeletionParamsSchema]);
5 changes: 5 additions & 0 deletions src/types/core/tile.type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import z from 'zod';
import { tileRangeSchema, tilesDeletionParamsSchema } from '../../schemas/core/tile.schema';

export type TilesDeletionParams = z.infer<typeof tilesDeletionParamsSchema>;
export type TileRange = z.infer<typeof tileRangeSchema>;
Loading