import { z } from 'zod'; import { ListSchema } from './common'; const textStyleSchema = z.object({ fontFamily: z.string(), fontSize: z.string().or(z.array(z.string())), fontWeight: z.string(), lineHeight: z.string().or(z.array(z.string())), }); const headingStyleScheme = textStyleSchema.extend({ textTransform: z.string(), }); // OrderForm Zod types are not present in backend, // since they're targeting APIs from the subscriptions-service (python) export const OrderFormSchema = z.object({ id: z.number(), defaultServiceConditions: z.string(), defaultProductId: z.string().nullable(), title: z.string(), logoUrl: z.string(), faviconUrl: z.string(), customHeadHtml: z.string(), termsAndConditionsUrl: z.string(), privacyStatementUrl: z.string(), websiteUrl: z.string(), defaultCountry: z.string(), availableCountries: z.string().array(), theme: z.object({ textStyles: z.object({ heading1: headingStyleScheme, heading2: headingStyleScheme, heading3: headingStyleScheme, heading4: headingStyleScheme, body1: textStyleSchema, body2: textStyleSchema, body3: textStyleSchema, body4a: textStyleSchema, body4b: textStyleSchema, body5a: textStyleSchema, body5b: textStyleSchema, caption: textStyleSchema, }), colors: z.object({ primary: z.string(), secondary: z.string(), active: z.string(), /* @deprecated Use `errorText` instead */ error: z.string().optional(), errorText: z.string(), errorBackground: z.string(), success: z.string(), }), components: z.object({ button: z.object({ borderRadius: z.string(), }), input: z.object({ borderWidth: z.string(), }), stepLink: z.object({ textDecoration: z.string(), }), }), }), copy: z.object({ newsletterDescription: z.string(), successTitle: z.string(), successDescription: z.string(), }), }); export const OrderFormHalSchema = OrderFormSchema.pick({ id: true, defaultProductId: true, defaultServiceConditions: true, logoUrl: true, faviconUrl: true, customHeadHtml: true, termsAndConditionsUrl: true, privacyStatementUrl: true, websiteUrl: true, defaultCountry: true, availableCountries: true, title: true, theme: true, copy: true, }).extend({ _links: z.object({ self: z.object({ href: z.string(), }), defaultProduct: z .object({ href: z.string().nullish(), }) .nullish(), }), }); export type OrderFormHalSchemaType = z.infer; export const OrderFormHalListSchema = ListSchema.extend({ _embedded: z.object({ orderForms: z.array(OrderFormHalSchema), }), }); export type OrderFormHalListSchemaType = z.infer; export const OrderFormCreateInputSchema = OrderFormSchema.pick({ defaultServiceConditions: true, theme: true, }); export type OrderFormCreateInput = z.infer; export const OrderFormUpdateInputSchema = OrderFormSchema.pick({ defaultServiceConditions: true, theme: true, }); export type OrderFormUpdateInput = z.infer;