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
10 changes: 0 additions & 10 deletions src/schemas/core/callback.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <T>(dataSchema?: z.ZodType<T>) => {
return z.object({
Expand Down
8 changes: 8 additions & 0 deletions src/schemas/core/file.schema.ts
Original file line number Diff line number Diff line change
@@ -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,
});
2 changes: 2 additions & 0 deletions src/schemas/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ export * from './task.schema';
export * from './mime.schema';
export * from './aggregation.schema';
export * from './callback.schema';
export * from './link.schema';
export * from './file.schema';
6 changes: 6 additions & 0 deletions src/schemas/core/link.schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import z from 'zod';
import { CORE_VALIDATIONS } from '../../constants';

export const urlSchema = z.string().regex(new RegExp(CORE_VALIDATIONS.url.pattern));

export const urlsArraySchema = z.array(urlSchema);
4 changes: 2 additions & 2 deletions src/schemas/export/job.schema.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/schemas/ingestion/job.schema.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -18,7 +18,7 @@ export const ingestionBaseJobParamsSchema = z
.object({
inputFiles: inputFilesSchema,
ingestionResolution: ingestionResolutionSchema,
callbackUrls: callbackUrlsArraySchema.optional(),
callbackUrls: urlsArraySchema.optional(),
})
.describe('ingestionBaseJobParamsSchema');

Expand Down
2 changes: 2 additions & 0 deletions src/schemas/ingestion/task.schema.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import z from 'zod';
import { fileMetadataSchema } from '../core';

export const ingestionNewFinalizeTaskParamsSchema = z
.object({
Expand All @@ -22,6 +23,7 @@ export const ingestionSwapUpdateTaskParamsSchema = ingestionUpdateFinalizeTaskPa

export const ingestionValidationTaskParamsSchema = z
.object({
link: fileMetadataSchema.optional(),
isValid: z.boolean(),
})
.describe('ingestionValidationTaskParamsSchema');
1 change: 1 addition & 0 deletions src/types/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export * from './task.type';
export * from './metadata.type';
export * from './layer.type';
export * from './part.type';
export * from './link.type';
7 changes: 7 additions & 0 deletions src/types/core/link.type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { z } from 'zod';
import { fileMetadataSchema, urlsArraySchema, urlSchema } from '../../schemas';

export type FileMetadata = z.infer<typeof fileMetadataSchema>;

export type CallbackUrl = z.infer<typeof urlSchema>;
export type CallbackUrlsTargetArray = z.infer<typeof urlsArraySchema>;
3 changes: 0 additions & 3 deletions src/types/export/export.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@ import {
linksSchema,
roiPropertiesSchema,
} from '../../schemas/export/export.schema';
import { callbackUrlsArraySchema, callbackUrlSchema } from '../../schemas/core/callback.schema';

export type RoiProperties = z.infer<typeof roiPropertiesSchema>;
export type RoiFeature = Feature<Polygon | MultiPolygon, RoiProperties>;
export type RoiFeatureCollection = FeatureCollection<Polygon | MultiPolygon, RoiProperties>;

export type CallbackUrl = z.infer<typeof callbackUrlSchema>;
export type CallbackUrlsTargetArray = z.infer<typeof callbackUrlsArraySchema>;
export type CallbackExportResponse = z.infer<typeof callbackExportResponseSchema>;
export type CallbacksStatus = z.infer<typeof callbacksStatus>;

Expand Down