41 lines
923 B
TypeScript
41 lines
923 B
TypeScript
/**
|
|
* Interface of the server (auto-generated code)
|
|
*/
|
|
import { z as zod } from "zod";
|
|
|
|
import {ZodOIDGenericDataSoftDelete, ZodOIDGenericDataSoftDeleteUpdate , ZodOIDGenericDataSoftDeleteCreate } from "./oid-generic-data-soft-delete";
|
|
import {ZodObjectId} from "./object-id";
|
|
import {ZodLong} from "./long";
|
|
|
|
export const ZodData = ZodOIDGenericDataSoftDelete.extend({
|
|
/**
|
|
* Sha512 of the data
|
|
*/
|
|
sha512: zod.string().max(512).readonly(),
|
|
/**
|
|
* Mime -type of the media
|
|
*/
|
|
mimeType: zod.string().max(512).readonly(),
|
|
/**
|
|
* Size in Byte of the data
|
|
*/
|
|
size: ZodLong.readonly(),
|
|
/**
|
|
* Unique ObjectID of the object
|
|
*/
|
|
oid: ZodObjectId.readonly(),
|
|
|
|
});
|
|
|
|
export type Data = zod.infer<typeof ZodData>;
|
|
|
|
export function isData(data: any): data is Data {
|
|
try {
|
|
ZodData.parse(data);
|
|
return true;
|
|
} catch (e: any) {
|
|
console.log(`Fail to parse data type='ZodData' error=${e}`);
|
|
return false;
|
|
}
|
|
}
|