ws-dottie
Version:
Your friendly TypeScript companion for Washington State transportation APIs - WSDOT and WSF data with smart caching and React Query integration
1 lines • 3.98 kB
Source Map (JSON)
{"version":3,"sources":["../src/apis/shared/zDotnetDateSchema.ts","../src/apis/shared/cacheFlushDate.ts"],"names":["zDotnetDate","isDotnetDateString","init_zDotnetDateSchema","__esmMin","init_dateUtils","init_zod","z","value","val","date","wsdotDateTimeToJSDate","cacheFlushDateInputSchema","cacheFlushDateOutputSchema","init_cacheFlushDate"],"mappings":"iIAAA,IAiBaA,CAAAA,CAqBPC,EAtCNC,CAAAA,CAAAC,CAAAA,CAAA,KAQAC,CAAAA,EAAAA,CACAC,CAAAA,EAAAA,CAQaL,EAAc,IACzBM,GAAAA,CACG,QAAO,CACP,MAAA,CAAQC,GAAUN,CAAAA,CAAmBM,CAAK,EAAG,CAC5C,OAAA,CAAS,6DACX,CAAC,CAAA,CACA,UAAWC,CAAAA,EAAQ,CAClB,IAAMC,CAAAA,CAAOC,GAAAA,CAAsBF,EAAI,OAAA,CAAQ,OAAA,CAAS,GAAG,CAAC,CAAA,CAC5D,GAAI,CAACC,CAAAA,CAAM,MAAM,IAAI,KAAA,CAAM,8BAA8BD,CAAG,CAAA,CAAE,EAC9D,OAAOC,CACT,CAAC,CAAA,CAWCR,CAAAA,CAAsBM,GAC1BA,CAAAA,CAAM,MAAA,EAAU,KACfA,CAAAA,CAAM,UAAA,CAAW,QAAQ,CAAA,EAAKA,CAAAA,CAAM,WAAW,UAAU,CAAA,CAAA,GACzDA,EAAM,QAAA,CAAS,IAAI,GAAKA,CAAAA,CAAM,QAAA,CAAS,MAAM,CAAA,EAAA,CAAA,ECzChD,IAgBaI,EAYAC,CAAAA,CA5BbC,CAAAA,CAAAV,EAAA,IAAA,CAQAE,CAAAA,EAAAA,CACAH,IAOaS,CAAAA,CAA4BL,GAAAA,CACtC,OAAO,EAAE,EACT,QAAA,CAAS,iDAAiD,EAUhDM,CAAAA,CAA6BZ,CAAAA,GACvC,QAAA,EAAS,CACT,SACC,kGACF,EAAA,CAAA","file":"chunk-NTLB7E5P.mjs","sourcesContent":["/**\n * @fileoverview .NET Date Validation for TanStack Query\n *\n * This module provides Zod schema validation for .NET date formats,\n * including the specialized \"/Date(timestamp)/\" format used by .NET\n * APIs. It handles validation and transformation to JavaScript Date objects.\n */\n\nimport { wsdotDateTimeToJSDate } from \"@/shared/utils/dateUtils\";\nimport { z } from \"@/shared/zod\";\n\n/**\n * .NET date validation and transformation schema\n *\n * This Zod schema handles .NET's \"/Date(timestamp)/\" format only.\n * It validates the input format and transforms it to a JavaScript Date object.\n */\nexport const zDotnetDate = () =>\n z\n .string()\n .refine((value) => isDotnetDateString(value), {\n message: \"Invalid date format. Expected .NET /Date(timestamp)/ format\",\n })\n .transform((val) => {\n const date = wsdotDateTimeToJSDate(val.replace(/\\\\\\//g, \"/\"));\n if (!date) throw new Error(`Failed to parse .NET date: ${val}`);\n return date;\n });\n\n/**\n * Type guard for .NET date format\n *\n * This function checks if a string matches the .NET \"/Date(timestamp)/\"\n * format, including escaped versions that may appear in JSON responses.\n *\n * @param value - The string to check\n * @returns True if the string matches .NET date format\n */\nconst isDotnetDateString = (value: string): boolean =>\n value.length >= 19 &&\n (value.startsWith(\"/Date(\") || value.startsWith(\"\\\\/Date(\")) &&\n (value.endsWith(\")/\") || value.endsWith(\")\\\\/\"));\n","/**\n * @fileoverview Shared schemas for cache flush date endpoints\n *\n * This module provides reusable input and output schemas for cache flush date\n * endpoints across all WSF APIs (wsf-fares, wsf-schedule, wsf-terminals, wsf-vessels).\n */\n\nimport type { z as zod } from \"zod\";\nimport { z } from \"@/shared/zod\";\nimport { zDotnetDate } from \"./zDotnetDateSchema\";\n\n/**\n * Shared input schema for cache flush date endpoints\n *\n * All cache flush date endpoints accept no parameters, so this is an empty object.\n */\nexport const cacheFlushDateInputSchema = z\n .object({})\n .describe(\"Input parameters for cache flush date endpoint.\");\n\nexport type CacheFlushDateInput = zod.infer<typeof cacheFlushDateInputSchema>;\n\n/**\n * Shared output schema for cache flush date endpoints\n *\n * Returns an optional UTC datetime indicating when static endpoint data was\n * last updated. Used for cache invalidation purposes.\n */\nexport const cacheFlushDateOutputSchema = zDotnetDate()\n .optional()\n .describe(\n \"UTC datetime when static endpoint data was last updated, or undefined if no update has occurred.\"\n );\n\nexport type CacheFlushDateOutput = zod.infer<typeof cacheFlushDateOutputSchema>;\n"]}