UNPKG

ws-dottie

Version:

Your friendly TypeScript companion for Washington State transportation APIs - WSDOT and WSF data with smart caching and React Query integration

52 lines (48 loc) 1.82 kB
import { z } from 'zod'; /** * @fileoverview Simplified Shared Types for WS-Dottie * * Consolidated type definitions without over-engineering. */ /** * Cache strategies for different data update frequencies * * These strategies define how frequently data should be refreshed based on * nature of transportation data. Each strategy includes appropriate * stale time, garbage collection time, and refetch intervals. */ type CacheStrategy = "REALTIME" | "FREQUENT" | "MODERATE" | "STATIC"; /** * Minimal endpoint interface for fetching operations * * Contains only the fields necessary for making API requests, * excluding housekeeping metadata used elsewhere in the system. */ interface FetchEndpoint<I, O> { /** Complete URL template with domain for building requests */ urlTemplate: string; /** Endpoint path for logging and error messages */ endpoint: string; /** Zod schema for input validation (optional - excluded in lite builds) */ inputSchema?: z.ZodSchema<I>; /** Zod schema for output validation (optional - excluded in lite builds) */ outputSchema?: z.ZodSchema<O>; } /** * Logging verbosity levels for WS-Dottie * * Controls the amount of logging output during API operations. * - none: No logging output * - info: Basic information about API calls and results * - debug: Detailed logging including performance metrics */ type LoggingMode = "none" | "info" | "debug"; /** * Fetch strategy for data fetching * * Defines the underlying transport mechanism used to fetch data. * - native: Uses standard fetch API (works in Node.js and modern browsers) * - jsonp: Uses JSONP callbacks (browser-only, bypasses CORS) */ type FetchStrategy = "native" | "jsonp"; export type { CacheStrategy as C, FetchEndpoint as F, LoggingMode as L, FetchStrategy as a };