Files
cfw-autumn/shared/api/customers/crud/createCustomerParams.ts
2026-02-19 17:32:43 +00:00

61 lines
1.5 KiB
TypeScript

import {
CreateCustomerInternalOptionsSchema,
CustomerDataSchema,
} from "@api/common/customerData";
import { CustomerIdSchema } from "@api/common/customerId";
import { EntityDataSchema } from "@api/common/entityData";
import { queryStringArray } from "@api/common/queryHelpers";
import {
CustomerExpandArraySchema,
CustomerExpandEnum,
} from "@api/customers/components/customerExpand/customerExpand";
import { z } from "zod/v4";
export const CreateCustomerQuerySchema = z.object({
expand: queryStringArray(CustomerExpandEnum).optional(),
with_autumn_id: z.boolean().default(false).meta({
internal: true,
}),
});
// Create Customer Params (based on handlePostCustomer logic)
export const CreateCustomerParamsV0Schema = z
.object({
id: CustomerIdSchema.nullable(),
...CustomerDataSchema.shape,
})
.extend({
expand: CustomerExpandArraySchema.optional(),
entity_id: z.string().optional().meta({
internal: true,
}),
entity_data: EntityDataSchema.optional().meta({
internal: true,
}),
with_autumn_id: z.boolean().default(false).meta({
internal: true,
}),
internal_options: CreateCustomerInternalOptionsSchema.optional().meta({
internal: true,
}),
});
export const CreateCustomerParamsV1Schema = z
.object({
customer_id: CustomerIdSchema.nullable(),
...CreateCustomerParamsV0Schema.shape,
})
.omit({
id: true,
});
export type CreateCustomerParamsV0 = z.infer<
typeof CreateCustomerParamsV0Schema
>;
export type CreateCustomerParamsV0Input = z.input<
typeof CreateCustomerParamsV0Schema
>;