177 lines
3.8 KiB
TypeScript
177 lines
3.8 KiB
TypeScript
/**
|
|
* Interface of the server (auto-generated code)
|
|
*/
|
|
import { z as zod } from "zod";
|
|
|
|
import {ZodObjectId} from "./object-id";
|
|
import {ZodLong} from "./long";
|
|
import {ZodInteger} from "./integer";
|
|
import {ZodIsoDate} from "./iso-date";
|
|
import {ZodGenericDataSoftDelete, ZodGenericDataSoftDeleteUpdate , ZodGenericDataSoftDeleteCreate } from "./generic-data-soft-delete";
|
|
|
|
export const ZodMedia = ZodGenericDataSoftDelete.extend({
|
|
/**
|
|
* Name of the media (this represent the title)
|
|
*/
|
|
name: zod.string().max(256),
|
|
/**
|
|
* Description of the media
|
|
*/
|
|
description: zod.string().max(8192).optional(),
|
|
/**
|
|
* Foreign Key Id of the data
|
|
*/
|
|
dataId: ZodObjectId,
|
|
/**
|
|
* 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(),
|
|
/**
|
|
* Creation years of the media
|
|
*/
|
|
datePublication: ZodIsoDate.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 ZodMediaUpdate = ZodGenericDataSoftDeleteUpdate.extend({
|
|
/**
|
|
* Name of the media (this represent the title)
|
|
*/
|
|
name: zod.string().max(256),
|
|
/**
|
|
* Description of the media
|
|
*/
|
|
description: zod.string().max(8192).nullable().optional(),
|
|
/**
|
|
* Foreign Key Id of the data
|
|
*/
|
|
dataId: ZodObjectId,
|
|
/**
|
|
* 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(),
|
|
/**
|
|
* Creation years of the media
|
|
*/
|
|
datePublication: ZodIsoDate.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 MediaUpdate = zod.infer<typeof ZodMediaUpdate>;
|
|
|
|
export function isMediaUpdate(data: any): data is MediaUpdate {
|
|
try {
|
|
ZodMediaUpdate.parse(data);
|
|
return true;
|
|
} catch (e: any) {
|
|
console.log(`Fail to parse data type='ZodMediaUpdate' error=${e}`);
|
|
return false;
|
|
}
|
|
}
|
|
export const ZodMediaCreate = ZodGenericDataSoftDeleteCreate.extend({
|
|
/**
|
|
* Name of the media (this represent the title)
|
|
*/
|
|
name: zod.string().max(256),
|
|
/**
|
|
* Description of the media
|
|
*/
|
|
description: zod.string().max(8192).nullable().optional(),
|
|
/**
|
|
* Foreign Key Id of the data
|
|
*/
|
|
dataId: ZodObjectId,
|
|
/**
|
|
* 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(),
|
|
/**
|
|
* Creation years of the media
|
|
*/
|
|
datePublication: ZodIsoDate.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 MediaCreate = zod.infer<typeof ZodMediaCreate>;
|
|
|
|
export function isMediaCreate(data: any): data is MediaCreate {
|
|
try {
|
|
ZodMediaCreate.parse(data);
|
|
return true;
|
|
} catch (e: any) {
|
|
console.log(`Fail to parse data type='ZodMediaCreate' error=${e}`);
|
|
return false;
|
|
}
|
|
}
|