47 lines
1.0 KiB
TypeScript
47 lines
1.0 KiB
TypeScript
/**
|
|
* Interface of the server (auto-generated code)
|
|
*/
|
|
import { z as zod } from "zod";
|
|
|
|
import {ZodLong} from "./long";
|
|
import {ZodGenericTiming} from "./generic-timing";
|
|
|
|
export const ZodGenericData = ZodGenericTiming.extend({
|
|
/**
|
|
* Unique Id of the object
|
|
*/
|
|
id: ZodLong.readonly(),
|
|
|
|
});
|
|
|
|
export type GenericData = zod.infer<typeof ZodGenericData>;
|
|
|
|
export function isGenericData(data: any): data is GenericData {
|
|
try {
|
|
ZodGenericData.parse(data);
|
|
return true;
|
|
} catch (e: any) {
|
|
console.log(`Fail to parse data type='ZodGenericData' error=${e}`);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
export const ZodGenericDataWrite = ZodGenericData.omit({
|
|
id: true,
|
|
createdAt: true,
|
|
updatedAt: true,
|
|
|
|
}).partial();
|
|
|
|
export type GenericDataWrite = zod.infer<typeof ZodGenericDataWrite>;
|
|
|
|
export function isGenericDataWrite(data: any): data is GenericDataWrite {
|
|
try {
|
|
ZodGenericDataWrite.parse(data);
|
|
return true;
|
|
} catch (e: any) {
|
|
console.log(`Fail to parse data type='ZodGenericDataWrite' error=${e}`);
|
|
return false;
|
|
}
|
|
}
|