import { z } from 'zod'; import { ListSchema } from './common'; export const itemTypes = ['productions', 'venues', 'events'] as const; export type ItemType = (typeof itemTypes)[number]; export const CollectionGroupSchema = z.object({ id: z.string(), createdAt: z.string(), // this differs from backend, backend needs to be adjusted in the future updatedAt: z.string(), // this differs from backend, backend needs to be adjusted in the future }); export const CollectionGroupHalSchema = CollectionGroupSchema.extend({ _links: z.object({ self: z.object({ href: z.string(), }), collections: z.object({ href: z.string(), }), }), }); export const CollectionSchema = z.object({ id: z.string(), collectionGroupId: z.string(), createdAt: z.string(), // this differs from backend, backend needs to be adjusted in the future updatedAt: z.string(), // this differs from backend, backend needs to be adjusted in the future }); export const CollectionHalSchema = CollectionSchema.extend({ _links: z.object({ self: z.object({ href: z.string(), }), collectionGroup: z.object({ href: z.string(), }), }), _embedded: z .object({ collectionGroup: CollectionGroupHalSchema.optional(), }) .optional(), }); export type CollectionHalSchemaType = z.infer; export const CollectionCreateInputSchema = CollectionHalSchema.extend({ collectionGroupId: z.string(), }).pick({ id: true, collectionGroupId: true, }); export type CollectionCreateInput = z.infer; export const CollectionHalListSchema = ListSchema.extend({ _embedded: z.object({ collections: z.array(CollectionHalSchema), }), }); export type CollectionHalListSchemaType = z.infer< typeof CollectionHalListSchema >; export const CollectionAddItemInputSchema = z.object({ collectionId: z.string(), itemType: z.enum(itemTypes), itemId: z.string(), }); export type CollectionAddItemInput = z.infer< typeof CollectionAddItemInputSchema >; export const CollectionRemoveItemInputSchema = z.object({ collectionId: z.string(), itemType: z.enum(itemTypes), itemId: z.string(), }); export type CollectionRemoveItemInput = z.infer< typeof CollectionRemoveItemInputSchema >; export type CollectionGroupHalSchemaType = z.infer< typeof CollectionGroupHalSchema >; export const CollectionGroupCreateInputSchema = CollectionGroupHalSchema.pick({ id: true, }); export type CollectionGroupCreateInput = z.infer< typeof CollectionGroupCreateInputSchema >; export const CollectionGroupHalListSchema = ListSchema.extend({ _embedded: z.object({ collectionGroups: z.array(CollectionGroupHalSchema), }), }); export type CollectionGroupHalListSchemaType = z.infer< typeof CollectionGroupHalListSchema >;