UNPKG

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 9.11 kB
{"version":3,"sources":["../src/apis/shared/zDotnetDateSchema.ts","../src/apis/shared/cacheFlushDate.ts","../src/apis/shared/roadwayLocationSchema.ts","../src/apis/shared/zIsoDateStringSchema.ts","../src/apis/shared/index.ts"],"names":["zDotnetDate","isDotnetDateString","init_zDotnetDateSchema","__esmMin","init_dateUtils","init_zod","z","value","val","date","wsdotDateTimeToJSDate","cacheFlushDateInputSchema","cacheFlushDateOutputSchema","init_cacheFlushDate","roadwayLocationSchema","init_roadwayLocationSchema","zIsoDateString","isISODateString","init_zIsoDateStringSchema","init_shared"],"mappings":"wIAAA,IAiBaA,CAAAA,CAqBPC,CAAAA,CAtCNC,CAAAA,CAAAC,CAAAA,CAAA,IAAA,CAQAC,CAAAA,EAAAA,CACAC,GAAAA,EAAAA,CAQaL,CAAAA,CAAc,IACzBM,GAAAA,CACG,MAAA,EAAO,CACP,MAAA,CAAQC,GAAUN,CAAAA,CAAmBM,CAAK,CAAA,CAAG,CAC5C,OAAA,CAAS,6DACX,CAAC,CAAA,CACA,SAAA,CAAWC,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,CAAA,2BAAA,EAA8BD,CAAG,CAAA,CAAE,CAAA,CAC9D,OAAOC,CACT,CAAC,CAAA,CAWCR,CAAAA,CAAsBM,CAAAA,EAC1BA,CAAAA,CAAM,MAAA,EAAU,EAAA,GACfA,CAAAA,CAAM,UAAA,CAAW,QAAQ,CAAA,EAAKA,CAAAA,CAAM,UAAA,CAAW,UAAU,CAAA,CAAA,GACzDA,CAAAA,CAAM,QAAA,CAAS,IAAI,CAAA,EAAKA,CAAAA,CAAM,QAAA,CAAS,MAAM,CAAA,E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A,EAAQ,CAClB,IAAMC,CAAAA,CAAO,IAAI,IAAA,CAAKD,CAAG,CAAA,CACzB,GAAI,MAAA,CAAO,KAAA,CAAMC,CAAAA,CAAK,OAAA,EAAS,CAAA,CAC7B,MAAM,IAAI,KAAA,CAAM,CAAA,0BAAA,EAA6BD,CAAG,CAAA,CAAE,CAAA,CACpD,OAAOC,CACT,CAAC,CAAA,CAWCQ,CAAAA,CAAmBV,CAAAA,EAA2B,CAGlD,GAAI,CADF,2EACY,IAAA,CAAKA,CAAK,CAAA,CAAG,CAEzB,IAAME,CAAAA,CAAO,IAAI,IAAA,CAAKF,CAAK,CAAA,CAC3B,OAAO,CAAC,MAAA,CAAO,KAAA,CAAME,CAAAA,CAAK,OAAA,EAAS,CACrC,CACA,OAAO,KACT,EAAA,CAAA,EC/CA,IAAAU,CAAAA,CAAAhB,CAAAA,CAAA,IAAA,CAOAU,CAAAA,EAAAA,CAMAE,CAAAA,EAAAA,CAIAb,CAAAA,EAAAA,CACAgB,CAAAA,GAAAA,CAAAA","file":"chunk-IZZORSYV.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","import { z } from \"@/shared/zod\";\n\n/**\n * Roadway location information including route, milepost, coordinates, and direction.\n */\nexport const roadwayLocationSchema = z\n .object({\n Description: z\n .string()\n .nullable()\n .describe(\n \"Human-readable description of the roadway location, such as interchange names or cross streets.\"\n ),\n Direction: z\n .string()\n .nullable()\n .describe(\n \"Traffic direction designation: N, S, B, NB, or SB, indicating which side of the highway is affected.\"\n ),\n Latitude: z\n .number()\n .describe(\"Latitude of the roadway location in decimal degrees.\"),\n Longitude: z\n .number()\n .describe(\"Longitude of the roadway location in decimal degrees.\"),\n MilePost: z\n .number()\n .describe(\n \"Milepost marker along the highway corridor, with 0 indicating route terminus.\"\n ),\n RoadName: z\n .string()\n .nullable()\n .describe(\n \"Highway or route designation code, such as '005' for I-5 or '090' for I-90.\"\n ),\n })\n .describe(\n \"Roadway location information including route, milepost, coordinates, and direction.\"\n );\n\nexport type RoadwayLocation = z.infer<typeof roadwayLocationSchema>;\n","/**\n * @fileoverview ISO Date String Validation for TanStack Query\n *\n * This module provides Zod schema validation for ISO date format strings,\n * including standard ISO-8601 date formats. It handles validation and\n * transformation to JavaScript Date objects.\n */\n\nimport { z } from \"@/shared/zod\";\n\n/**\n * ISO date string validation and transformation schema\n *\n * This Zod schema handles ISO date formats (e.g., \"2024-01-01T12:00:00.000Z\").\n * It validates the input format and transforms it to a JavaScript Date object.\n */\nexport const zIsoDateString = () =>\n z\n .string()\n .refine((value) => isISODateString(value), {\n message: \"Invalid date format. Expected ISO date string format\",\n })\n .transform((val) => {\n const date = new Date(val);\n if (Number.isNaN(date.getTime()))\n throw new Error(`Failed to parse ISO date: ${val}`);\n return date;\n });\n\n/**\n * Type guard for ISO date format\n *\n * This function checks if a string matches the ISO-8601 date format\n * with optional time and timezone information.\n *\n * @param value - The string to check\n * @returns True if the string matches ISO-8601 date format\n */\nconst isISODateString = (value: string): boolean => {\n const isoRegex =\n /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d{1,3})?)?(Z|[+-]\\d{2}:\\d{2})?$/;\n if (!isoRegex.test(value)) {\n // Try basic date parsing as fallback\n const date = new Date(value);\n return !Number.isNaN(date.getTime());\n }\n return true;\n};\n","/**\n * @fileoverview Shared API schemas and utilities\n *\n * This module exports shared schemas and utilities used across multiple\n * WSDOT API endpoints.\n */\n\nexport {\n type CacheFlushDateInput,\n type CacheFlushDateOutput,\n cacheFlushDateInputSchema,\n cacheFlushDateOutputSchema,\n} from \"./cacheFlushDate\";\nexport {\n type RoadwayLocation,\n roadwayLocationSchema,\n} from \"./roadwayLocationSchema\";\nexport { zDotnetDate } from \"./zDotnetDateSchema\";\nexport { zIsoDateString } from \"./zIsoDateStringSchema\";\n"]}