Files
cfw-autumn/shared/api/entities/crud/createEntityParams.ts
John Yeo 90287e6308 latest
2026-02-19 13:24:33 +00:00

38 lines
1.0 KiB
TypeScript

import { z } from "zod/v4";
import { CustomerDataSchema } from "../../common/customerData.js";
export const CreateEntityParamsV0Schema = z.object({
id: z
.preprocess(
(val) => (typeof val === "number" ? String(val) : val),
z.string(),
)
.nullable()
.meta({
description: "The ID of the entity",
}),
name: z.string().nullish().meta({
description: "The name of the entity",
}),
feature_id: z.string().meta({
description: "The ID of the feature this entity is associated with",
}),
customer_data: CustomerDataSchema.optional().meta({
description:
"Customer attributes used to resolve the customer when customer_id is not provided.",
}),
});
export const CreateEntityParamsV1Schema = CreateEntityParamsV0Schema.omit({
id: true,
}).extend({
customer_id: z.string().meta({
description: "The ID of the customer to create the entity for.",
}),
entity_id: z.string().meta({
description: "The ID of the entity.",
}),
});
export type CreateEntityParams = z.infer<typeof CreateEntityParamsV0Schema>;