126 lines
2.7 KiB
TypeScript

/**
* Interface of the server (auto-generated code)
*/
import { z as zod } from "zod";
import {ZodObjectId} from "./object-id";
import {ZodUUID} from "./uuid";
import {ZodLong} from "./long";
import {ZodInteger} from "./integer";
import {ZodGenericDataSoftDelete, ZodGenericDataSoftDeleteWrite } from "./generic-data-soft-delete";
export const ZodMedia = ZodGenericDataSoftDelete.extend({
/**
* Name of the media (this represent the title)
*/
name: zod.string(),
/**
* Description of the media
*/
description: zod.string().optional(),
/**
* Foreign Key Id of the data
*/
dataId: ZodObjectId,
dataIdOld: ZodUUID.optional(),
/**
* Type of the media
*/
typeId: ZodLong.optional(),
/**
* Series reference of the media
*/
seriesId: ZodLong.optional(),
/**
* Season reference of the media
*/
seasonId: ZodLong.optional(),
/**
* Episode Id
*/
episode: ZodInteger.optional(),
date: ZodInteger.optional(),
/**
* Creation years of the media
*/
time: ZodInteger.optional(),
/**
* Limitation Age of the media
*/
ageLimit: ZodInteger.optional(),
/**
* List of Id of the specific covers
*/
covers: zod.array(ZodObjectId).optional(),
});
export type Media = zod.infer<typeof ZodMedia>;
export function isMedia(data: any): data is Media {
try {
ZodMedia.parse(data);
return true;
} catch (e: any) {
console.log(`Fail to parse data type='ZodMedia' error=${e}`);
return false;
}
}
export const ZodMediaWrite = ZodGenericDataSoftDeleteWrite.extend({
/**
* Name of the media (this represent the title)
*/
name: zod.string().optional(),
/**
* Description of the media
*/
description: zod.string().nullable().optional(),
/**
* Foreign Key Id of the data
*/
dataId: ZodObjectId.optional(),
dataIdOld: ZodUUID.nullable().optional(),
/**
* Type of the media
*/
typeId: ZodLong.nullable().optional(),
/**
* Series reference of the media
*/
seriesId: ZodLong.nullable().optional(),
/**
* Season reference of the media
*/
seasonId: ZodLong.nullable().optional(),
/**
* Episode Id
*/
episode: ZodInteger.nullable().optional(),
date: ZodInteger.nullable().optional(),
/**
* Creation years of the media
*/
time: ZodInteger.nullable().optional(),
/**
* Limitation Age of the media
*/
ageLimit: ZodInteger.nullable().optional(),
/**
* List of Id of the specific covers
*/
covers: zod.array(ZodObjectId).nullable().optional(),
});
export type MediaWrite = zod.infer<typeof ZodMediaWrite>;
export function isMediaWrite(data: any): data is MediaWrite {
try {
ZodMediaWrite.parse(data);
return true;
} catch (e: any) {
console.log(`Fail to parse data type='ZodMediaWrite' error=${e}`);
return false;
}
}