@flotiq/flotiq-astro-sdk
Version:
Astro collection generator for connecting with Flotiq CMS
26 lines (25 loc) • 872 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateZodSchema = generateZodSchema;
const property_types_1 = require("./property-types");
function generateZodSchema(schemas, propertiesConfig, required, order) {
return `
z.object({
id: z.string(),
${order.map((property) => {
return `${property}: ${(0, property_types_1.getTypeForProperty)(schemas[property], propertiesConfig[property], required, property)}`;
})},
internal: z.object({
createdAt: z.coerce.date(),
updatedAt: z.coerce.date(),
deletedAt: z.string().optional(),
publishedAt: z.coerce.date().optional(),
contentType: z.string(),
objectTitle: z.string(),
latestVersion: z.number(),
status: z.string(),
publicVersion: z.number(),
}),
})
`;
}