/**
 * Interface of the server (auto-generated code)
 */
import { z as zod } from "zod";

import {ZodLong} from "./long";
import {ZodUUIDGenericDataSoftDelete, ZodUUIDGenericDataSoftDeleteWrite } from "./uuid-generic-data-soft-delete";

export const ZodData = ZodUUIDGenericDataSoftDelete.extend({
	/**
	 * Sha512 of the data
	 */
	sha512: zod.string().max(128),
	/**
	 * Mime -type of the media
	 */
	mimeType: zod.string().max(128),
	/**
	 * Size in Byte of the data
	 */
	size: ZodLong,

});

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;
	}
}
export const ZodDataWrite = ZodUUIDGenericDataSoftDeleteWrite.extend({
	/**
	 * Sha512 of the data
	 */
	sha512: zod.string().max(128).optional(),
	/**
	 * Mime -type of the media
	 */
	mimeType: zod.string().max(128).optional(),
	/**
	 * Size in Byte of the data
	 */
	size: ZodLong.optional(),

});

export type DataWrite = zod.infer<typeof ZodDataWrite>;

export function isDataWrite(data: any): data is DataWrite {
	try {
		ZodDataWrite.parse(data);
		return true;
	} catch (e: any) {
		console.log(`Fail to parse data type='ZodDataWrite' error=${e}`);
		return false;
	}
}
