import { z } from 'zod'; /** * Zod schema for the ExpoToken model. * Defines the structure and validation rules for this data type. * This is the shape used in application code - what developers interact with. */ export const expoToken = z.lazy(() => { return z.object({ createdAt: z.string(), deviceToken: z.string().min(1), discardedAt: z.string().optional().nullable(), id: z.string(), updatedAt: z.string().optional().nullable(), }); }); /** * * @typedef {ExpoToken} expoToken * @property {string} - The timestamp when the token was created. * @property {string} - The Expo push token returned by the Expo client. * @property {string} - The timestamp when the token was discarded, if applicable. * @property {string} - The unique identifier for the token. * @property {string} - The timestamp when the token metadata last changed. */ export type ExpoToken = z.infer; /** * Zod schema for mapping API responses to the ExpoToken application shape. * Handles any property name transformations from the API schema. * If property names match the API schema exactly, this is identical to the application shape. */ export const expoTokenResponse = z.lazy(() => { return z .object({ created_at: z.string(), device_token: z.string().min(1), discarded_at: z.string().optional().nullable(), id: z.string(), updated_at: z.string().optional().nullable(), }) .transform((data) => ({ createdAt: data['created_at'], deviceToken: data['device_token'], discardedAt: data['discarded_at'], id: data['id'], updatedAt: data['updated_at'], })); }); /** * Zod schema for mapping the ExpoToken application shape to API requests. * Handles any property name transformations required by the API schema. * If property names match the API schema exactly, this is identical to the application shape. */ export const expoTokenRequest = z.lazy(() => { return z .object({ createdAt: z.string(), deviceToken: z.string().min(1), discardedAt: z.string().optional().nullable(), id: z.string(), updatedAt: z.string().optional().nullable(), }) .transform((data) => ({ created_at: data['createdAt'], device_token: data['deviceToken'], discarded_at: data['discardedAt'], id: data['id'], updated_at: data['updatedAt'], })); });