import { JsonSchemaForLlmSchema } from "./json-schemas.js";
import { z } from "@hono/zod-openapi";

//#region src/validation/extend-schemas.ts
const NameSchema = z.string().trim().nonempty("Name is required").max(256).openapi("NameSchema");
const DescriptionSchema = z.string().trim().nullish().openapi("DescriptionSchema");
/**
* Used in z.transform()
*/
function transformToJson(value, ctx) {
	try {
		return JSON.parse(value);
	} catch {
		ctx.addIssue({
			code: "custom",
			message: "Invalid JSON syntax"
		});
		return z.NEVER;
	}
}
const DataComponentExtendSchema = {
	name: NameSchema,
	description: DescriptionSchema,
	props: JsonSchemaForLlmSchema
};
const ArtifactComponentExtendSchema = {
	name: NameSchema,
	description: DescriptionSchema,
	props: JsonSchemaForLlmSchema.nullable()
};

//#endregion
export { ArtifactComponentExtendSchema, DataComponentExtendSchema, DescriptionSchema, NameSchema, transformToJson };