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,358 lines (1,324 loc) 162 kB
import { z } from 'zod'; import * as _tanstack_query_core from '@tanstack/query-core'; import * as _tanstack_react_query from '@tanstack/react-query'; /** * @fileoverview WSDOT Date Validation for TanStack Query * * This module provides Zod schema validation for WSDOT date formats, * including the specialized "/Date(timestamp)/" format used by WSDOT/WSF * APIs and standard ISO-8601 dates. It handles both validation and * transformation to JavaScript Date objects. */ /** * WSDOT date validation and transformation schema * * This Zod schema handles both WSDOT's "/Date(timestamp)/" format and * standard ISO-8601 dates. It validates the input format and transforms * it to a JavaScript Date object for consistent handling. */ declare const zWsdotDate: () => z.ZodPipe<z.ZodString, z.ZodTransform<Date, string>>; /** * @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 * the nature of the transportation data. Each strategy includes appropriate * stale time, garbage collection time, and refetch intervals. */ type CacheStrategy = "REALTIME" | "FREQUENT" | "MODERATE" | "STATIC"; /** * 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"; /** * Function type for fetching data from URLs * * This type defines the interface for fetch strategies that can retrieve * data from URLs and return it as a string. Used by both JSONP and native * fetch implementations. */ type FetchStrategy = (url: string) => Promise<string>; /** * Cache strategy configurations for different data update frequencies * * These strategies define how frequently data should be refreshed based on * the nature of the transportation data. Each strategy includes appropriate * stale time, garbage collection time, refetch intervals, and retry settings. * * The four core strategies cover all transportation API use cases: * - REALTIME: For frequently updating data (5-second updates) * - FREQUENT: For data that updates every few minutes (5-minute updates) * - MODERATE: For data that updates hourly * - STATIC: For rarely changing data (daily updates) */ declare const cacheStrategies: { readonly REALTIME: { readonly staleTime: number; readonly gcTime: number; readonly refetchInterval: number; readonly retry: 2; readonly retryDelay: number; }; readonly FREQUENT: { readonly staleTime: number; readonly gcTime: number; readonly refetchInterval: number; readonly retry: 3; readonly retryDelay: number; }; readonly MODERATE: { readonly staleTime: number; readonly gcTime: number; readonly refetchInterval: number; readonly retry: 3; readonly retryDelay: number; }; readonly STATIC: { readonly staleTime: number; readonly gcTime: number; readonly refetchInterval: number; readonly retry: 2; readonly retryDelay: number; }; }; /** * Creates TanStack Query options with the specified cache strategy * * This function creates a query options factory that can be used with * TanStack Query hooks. It combines the API function, query key, and * cache strategy to create properly configured query options. * * @template TInput - The input parameters type * @template TOutput - The output response type * @param apiFunction - The API function to call for data fetching * @param queryKey - Base query key array (params will be appended) * @param cacheStrategy - Cache strategy to use for this query * @returns Function that accepts parameters and returns query options * @example * ```typescript * const useScheduleQuery = createQueryOptions( * getSchedule, * ["wsf-schedule", "get-schedule"], * "FREQUENT" * ); * const queryOptions = useScheduleQuery({ terminalId: 1 }); * ``` */ declare function createQueryOptions<TInput, TOutput>(apiFunction: (params: TInput) => Promise<TOutput>, queryKey: string[], cacheStrategy: CacheStrategy): (params: TInput) => _tanstack_query_core.OmitKeyof<_tanstack_react_query.UseQueryOptions<TOutput, Error, TOutput, (string | TInput)[]>, "queryFn"> & { queryFn?: _tanstack_query_core.QueryFunction<TOutput, (string | TInput)[], never> | undefined; } & { queryKey: (string | TInput)[] & { [dataTagSymbol]: TOutput; [dataTagErrorSymbol]: Error; }; }; /** * @fileoverview URL Builder for WS-Dottie API Requests * * This module provides comprehensive URL building functionality for WS-Dottie API requests, * including parameter encoding, template parameter replacement, API key injection, * and proper URL construction for both WSDOT and WSF APIs. * * Key features: * - Template parameter replacement (e.g., {terminalId} -> actual value) * - Automatic date conversion to .NET format for WSDOT APIs * - API key injection with correct parameter names per service * - URL cleanup to remove empty parameters * - Support for both WSDOT (/traffic/) and WSF (/ferries/) endpoints */ /** * Builds a complete API URL with template parameter replacement * * This function constructs a complete URL for API requests by combining * the base domain, endpoint path, and replacing template parameters in the URL. * It handles template parameter replacement (e.g., {terminalId} -> actual value), * automatic date conversion to string format, and URL cleanup. * * @param endpoint - The API endpoint path with optional template parameters (e.g., "/ferries/schedule/{terminalId}") * @param params - Optional parameters for template replacement and query string construction * @returns Complete URL object ready for further processing (API key injection) * @example * ```typescript * buildUrlWithParams("/ferries/api/schedule/rest/schedule/{tripDate}/{routeId}", { * tripDate: new Date("2024-01-01") * routeId: 1, * }); * // Returns: URL object with processed endpoint and parameters * ``` */ declare const buildUrlWithParams: (endpoint: string, params?: Record<string, unknown>) => string; /** * Injects the appropriate API key into a URL based on the service type * * This function determines whether the URL is for WSDOT or WSF API and injects * the correct API key parameter name. WSDOT uses "accesscode" while WSF uses * "apiaccesscode" as the parameter name. * * @param url - The URL object to inject the API key into * @returns The same URL object with the API key parameter added * @example * ```typescript * const url = new URL("/traffic/api/ferries/schedule", "http://www.wsdot.wa.gov"); * const urlWithKey = buildUrlWithApiKey(url); * // URL now includes: ?accesscode=YOUR_API_KEY * ``` */ declare const buildUrlWithApiKey: (url: string) => string; /** * @fileoverview Environment Detection Utilities for WS-Dottie * * This module provides environment detection capabilities to determine * the runtime environment (web browser, server, or test) and configure * appropriate fetch strategies. It includes detection for test environments, * web browsers, and JSONP forcing for testing purposes. */ /** * Supported environment types for WS-Dottie * * Defines the three main runtime environments that WS-Dottie can operate in, * each with different capabilities and constraints. */ type EnvironmentType = "web" | "server" | "test"; /** * Detects if the code is running in a test environment * * This function checks for various indicators that suggest the code is * running in a test environment, including NODE_ENV, VITEST, and Jest * worker indicators. * * @returns True if running in a test environment, false otherwise */ declare const isTestEnvironment: () => boolean; /** * Detects if the code is running in a web browser environment * * This function checks for the presence of browser-specific globals * (window and document) to determine if the code is running in a browser. * * @returns True if running in a web browser, false otherwise */ declare const isWebEnvironment: () => boolean; /** * Checks if JSONP should be forced for testing purposes * * This function checks the FORCE_JSONP environment variable to determine * if JSONP should be used even in non-browser environments for testing. * * @returns True if JSONP should be forced, false otherwise */ declare const shouldForceJsonp: () => boolean; /** * Gets the current environment type * * This function determines the current runtime environment by checking * test environment first, then web environment, defaulting to server. * * @returns The current environment type */ declare const getEnvironmentType: () => EnvironmentType; /** * @fileoverview Simple Endpoint System * * A simple, unified endpoint system that eliminates complexity and duplication. * * This module provides the core endpoint definition system for the WS-Dottie API * library. It includes type definitions, factory functions, and discovery * utilities that work together to create a consistent endpoint management * system across all API modules. */ /** * Simple endpoint definition interface for client files * * This interface defines the structure that client modules use to describe * their API endpoints. It includes all the necessary information for * validation, caching, and URL generation. */ interface EndpointDefinition<I, O> { /** Unique identifier in format "api/function" */ id: string; /** HTTP endpoint URL template */ endpoint: string; /** Zod schema for input validation */ inputSchema: z.ZodSchema<I>; /** Zod schema for output validation */ outputSchema: z.ZodSchema<O>; /** Optional sample parameters for testing */ sampleParams?: Partial<I> | (() => Promise<Partial<I>>); /** Cache strategy */ cacheStrategy: CacheStrategy; } /** * Runtime endpoint interface with computed properties * * This interface extends EndpointDefinition with computed properties that are * automatically generated by the defineEndpoint factory function. These * properties include API group name, function name, and complete URL template. */ interface Endpoint<I, O> extends EndpointDefinition<I, O> { /** API group name (computed from id) */ api: string; /** Function name (computed from id) */ functionName: string; /** Complete URL template with domain */ urlTemplate: string; } /** * Type alias for an array of endpoints with unknown input/output types * * This type is used throughout the system when the specific input/output * types are not known or needed, such as in discovery and testing functions. */ type Endpoints = Endpoint<unknown, unknown>[]; /** * Type alias for endpoints grouped by API name * * This type represents the nested structure returned by discoverEndpoints(), * where endpoints are organized by their API group name for easier * organization and processing. */ type EndpointsByApi = Record<string, Endpoints>; /** * Creates a complete endpoint configuration object with computed properties * * This factory function takes a basic endpoint configuration and enriches it * with computed properties like API group name, function name, and complete * URL template. It automatically extracts the API and function names from * the endpoint ID and combines the domain with the endpoint path. * * @template I - The input parameters type for the endpoint * @template O - The output response type for the endpoint * @param config - Basic endpoint configuration object * @param config.id - Unique identifier in format "api/function" * @param config.endpoint - HTTP endpoint URL template relative to base domain * @param config.inputSchema - Zod schema for input parameter validation * @param config.outputSchema - Zod schema for output response validation * @param config.sampleParams - Optional sample parameters for testing * @param config.cacheStrategy - Cache strategy for TanStack Query integration * @returns Complete endpoint object with all computed properties */ declare function defineEndpoint<I, O>(config: { id: string; endpoint: string; inputSchema: z.ZodSchema<I>; outputSchema: z.ZodSchema<O>; sampleParams?: Partial<I> | (() => Promise<Partial<I>>); cacheStrategy: CacheStrategy; }): Endpoint<I, O>; declare const discoverEndpoints: () => EndpointsByApi; /** * Gets all endpoints as a flat array * * This is a convenience function that flattens the nested structure returned * by discoverEndpoints() into a single array. Useful when you need to iterate * over all endpoints regardless of their API grouping. * * @returns Array of all endpoints from all APIs */ declare const getAllEndpoints: () => Endpoints; /** * @fileoverview Core Fetching Logic for WS-Dottie * * This module provides the core data fetching functionality for WS-Dottie, * including both validated (fetchZod) and unvalidated (fetchNative) APIs. * It handles URL building, request execution, response parsing, and logging * with automatic .NET date conversion for native fetch operations. */ /** * Main data fetching API with Zod validation * * This function provides type-safe data fetching with both input and output * validation using Zod schemas. It validates input parameters before making * the request and validates the response data before returning it. * * @template TInput - The input parameters type * @template TOutput - The output response type * @param endpoint - Complete endpoint object containing schemas and configuration * @param params - Optional input parameters to validate * @param logMode - Optional logging mode * @returns Promise resolving to validated response data */ declare const fetchZod: <TInput = never, TOutput = unknown>(endpoint: Endpoint<TInput, TOutput>, params?: TInput, logMode?: LoggingMode) => Promise<TOutput>; /** * Native fetch API with automatic .NET date conversion * * This function provides unvalidated access to Washington State transportation * APIs with automatic conversion of .NET datetime strings to JavaScript Date * objects. No Zod validation is performed on input or output, making it * suitable for quick prototyping or when you need raw API access. * * @template TInput - The input parameters type * @template TOutput - The output response type * @param endpoint - Complete endpoint object containing configuration * @param params - Optional input parameters * @param logMode - Optional logging mode * @returns Promise resolving to response data with .NET dates converted */ declare const fetchNative$1: <TInput = never, TOutput = unknown>(endpoint: Endpoint<TInput, TOutput>, params?: TInput, logMode?: LoggingMode) => Promise<TOutput>; /** * @fileoverview Fetch Strategies for WS-Dottie * * This module provides different fetch strategies for different runtime * environments. It includes JSONP for browser environments (to handle CORS) * and native fetch for server environments, with automatic strategy selection * based on the current environment. */ /** * Selects the appropriate fetch strategy based on environment * * This function automatically selects the best fetch strategy based on * the current runtime environment: * - Test environments: Native fetch (simpler for testing) * - Web browsers: JSONP (bypasses CORS restrictions) * - Server environments: Native fetch * - Override: FORCE_JSONP=true for JSONP testing * * @returns The appropriate fetch strategy function */ declare const selectFetchStrategy: () => FetchStrategy; /** * JSONP fetch strategy for browser environments * * This strategy handles CORS restrictions by using JSONP callbacks instead * of direct HTTP requests. It creates a script tag with a callback parameter * and handles the response through a global callback function. * * @param url - The URL to fetch data from * @returns Promise resolving to the response data as a JSON string */ declare const fetchJsonp: (url: string) => Promise<string>; /** * Native fetch strategy for server environments * * This strategy uses the standard fetch API available in Node.js and * modern browsers. It performs standard HTTP requests and handles * response status codes appropriately. * * @param url - The URL to fetch data from * @returns Promise resolving to the response data as a string * @throws Error if the response is not ok (status >= 400) */ declare const fetchNative: (url: string) => Promise<string>; /** * @fileoverview Simplified Error Handling for WS-Dottie * * This module provides streamlined error handling for WS-Dottie API operations, * focusing on preserving actual error information while providing useful context. * It includes a simple ApiError class that passes through real error messages * while adding relevant context for debugging and logging. */ /** * Context information for error reporting * * Contains additional context about errors that occurred during * API operations, useful for debugging and error reporting. */ interface ErrorContext { /** The URL that was being accessed when the error occurred */ url?: string; /** HTTP status code if available */ status?: number; /** The API endpoint that was being called */ endpoint?: string; /** Timestamp when the error occurred */ timestamp: Date; } /** * API error type for strongly-typed error handling * * A POJO (Plain Old JavaScript Object) that represents API errors with * context information. This approach is more functional and aligns with * modern TypeScript patterns while preserving the original error messages * for better debugging. */ interface ApiError { /** Error name for type identification */ readonly name: "ApiError"; /** Human-readable error message (preserves original error) */ readonly message: string; /** HTTP status code if available */ readonly status?: number; /** Additional context information about the error */ readonly context: ErrorContext; } /** * Creates a standardized API error from various error types * * This function preserves the original error messages while adding useful * context information. It handles Zod validation errors, network errors, * and other common error scenarios by passing through the actual error * information rather than trying to categorize or rewrite it. * * @param error - The original error to convert * @param endpoint - The API endpoint where the error occurred * @returns Standardized ApiError POJO */ declare const createApiError: (error: unknown, endpoint: string) => ApiError; /** * Type guard to check if an error is an ApiError * * @param error - The error to check * @returns True if the error is an ApiError, false otherwise */ declare const isApiError: (error: unknown) => error is ApiError; /** * @fileoverview Configuration Management for WS-Dottie * * This module provides configuration management for WS-Dottie API operations, * including API key and domain configuration with runtime modification * capability. It supports environment variable configuration and runtime * updates for different deployment scenarios. */ /** * Configuration interface for WS-Dottie * * Defines the structure for WS-Dottie configuration including API key * and domain settings. */ interface WsdotConfig { /** WSDOT API access token for authentication */ apiKey: string; /** Base domain for API requests */ domain: string; } /** * Configuration manager object * * This object provides a convenient interface for accessing and * modifying WS-Dottie configuration settings. */ declare const configManager: { getApiKey: () => string; getDomain: () => string; setApiKey: (apiKey: string) => void; setDomain: (domain: string) => void; }; /** * @fileoverview Date Utilities for WS-Dottie * * This module provides date conversion utilities specifically designed for * handling WSDOT/WSF API date formats. It includes conversion from .NET * datetime strings to JavaScript Date objects and various date formatting * utilities for API requests and responses. */ /** * Converts a WSDOT .NET timestamp string to a JavaScript Date object * * This function parses WSDOT's .NET datetime format ("/Date(timestamp)/") * and converts it to a JavaScript Date object. It handles both positive * and negative timestamps, as well as timezone offsets. * * The parsing logic: * - Extracts timestamp from position 6 to 6 characters from the end * - Handles timezone separators (+ or - after timestamp) * - Validates the resulting timestamp number * * @param dateString - The WSDOT date string to convert * @returns JavaScript Date object or null if parsing fails * @example * ```typescript * wsdotDateTimeToJSDate("/Date(1757451301100-0700)/") // Returns Date object * wsdotDateTimeToJSDate("/Date(-2208945600000-0800)/") // Returns Date object * wsdotDateTimeToJSDate("invalid") // Returns null * ``` */ declare const wsdotDateTimeToJSDate: (dateString: string) => Date | null; /** * Converts a JavaScript Date to ISO date stamp (YYYY-MM-DD) * * This function formats a JavaScript Date object as an ISO date string * in YYYY-MM-DD format, which is commonly used in API requests. * * @param date - The JavaScript Date object to convert * @returns ISO date string in YYYY-MM-DD format * @example * ```typescript * jsDateToYyyyMmDd(new Date(2024, 0, 15)) // Returns "2024-01-15" * ``` */ declare const jsDateToYyyyMmDd: (date: Date) => string; /** * Date helper functions for runtime evaluation * * These functions return Date objects when called, ensuring they are * evaluated at runtime rather than build time. This is useful for * generating dynamic dates in API requests and sample data. */ declare const datesHelper: { /** Returns tomorrow's date */ readonly tomorrow: () => Date; /** Returns the day after tomorrow's date */ readonly dayAfterTomorrow: () => Date; /** Returns today's date */ readonly today: () => Date; /** Returns yesterday's date */ readonly yesterday: () => Date; /** Returns August 1, 2025 (start of month for sample data) */ readonly startOfMonth: () => Date; /** Returns August 31, 2025 (end of month for sample data) */ readonly endOfMonth: () => Date; }; /** * @fileoverview Simplified Logging Utility for WS-Dottie * * This module provides a simplified logging interface for WS-Dottie with * environment-aware debug logging and specialized API call logging. * Focused on essential functionality used by the core library. */ /** * Simple logging utility for WS-Dottie * * Provides basic logging functions with environment-aware debug logging. * Debug logging is automatically disabled in production environments. */ declare const logger: { /** Debug logging (disabled in production) */ debug: (message: string) => void; /** General information logging */ info: (message: string) => void; /** Warning message logging */ warn: (message: string) => void; /** Error message logging */ error: (message: string) => void; }; /** * Logs API call information in a single line format * * Simplified API call logging for the core fetching functionality. * Used only by fetchCore.ts for basic API operation monitoring. * * @param endpoint - The full API endpoint path (will extract endpoint name internally) * @param params - Parameters being sent to the endpoint */ declare const logApiCall: (endpoint: string, params?: unknown) => void; /** * Logs API call results with performance metrics * * Simplified API result logging for the core fetching functionality. * Provides basic performance metrics including duration and response size. * * @param jsonData - The parsed JSON response data (will calculate object count internally) * @param startTime - The timestamp when the request started (will calculate duration internally) * @param responseSize - Response size in bytes */ declare const logApiResults: (jsonData: unknown, startTime: number, responseSize: number) => void; /** * @module WSDOT — Border Crossings API * @description Border crossing wait times and related metadata for WSDOT border crossings. * * Provides: * - Current wait times for supported border crossings * - Crossing metadata including location, direction, and names * * Data includes: * - Crossing name, reported time (JS Date), estimated wait time (minutes) * - Optional location details (coordinates, road name, milepost) * * @functions * - getBorderCrossings: Returns an array of border crossing data * * @input * - getBorderCrossings: {} * * @output * - getBorderCrossings: BorderCrossings * - BorderCrossingData fields: * - CrossingName: Crossing name * - Time: Report time (JS Date) * - WaitTime: Estimated wait time in minutes * - BorderCrossingLocation: Optional location details or null * - BorderCrossingLocation fields: * - Description: Location description * - Direction: Direction of travel (nullable) * - Latitude: Latitude in decimal degrees * - Longitude: Longitude in decimal degrees * - MilePost: Highway milepost * - RoadName: Highway/road name * * @baseType * - BorderCrossingData: Border crossing report with optional location * - BorderCrossingLocation: Location details for a border crossing * * @cli * - getBorderCrossings: node dist/cli.mjs getBorderCrossings * * @exampleResponse * { * "BorderCrossingLocation": { * "Description": "I-5 General Purpose", * "Direction": null, * "Latitude": 49.004776, * "Longitude": -122.756964, * "MilePost": 0, * "RoadName": "005" * }, * "CrossingName": "I5", * "Time": "2025-09-03T21:00:00.000Z", * "WaitTime": 20 * } * * @see https://wsdot.wa.gov/traffic/api/Documentation/group___border_crossings.html */ /** Input schema for getBorderCrossings */ declare const borderCrossingsInput: z.ZodObject<{}, z.core.$strict>; type BorderCrossingsInput = z.infer<typeof borderCrossingsInput>; declare const getBorderCrossings: Endpoint<Record<string, never>, { BorderCrossingLocation: { Description: string | null; RoadName: string | null; Direction: string | null; MilePost: number; Latitude: number; Longitude: number; } | null; CrossingName: string | null; Time: Date; WaitTime: number; }[]>; /** * @module WSDOT — Bridge Clearances API * @description Bridge height and clearance information across all WSDOT routes. * * Provides: * - Vertical clearance maximum/minimum by bridge/structure for all routes * - Crossing metadata, structure identifiers, and location * * Data includes: * - Structure IDs, route/location metadata, clearances (feet/inches), update timestamps (JS Date) * * @functions * - getBridgeClearances: Returns all bridge clearance data * * @input * - getBridgeClearances: {} * * @output * - getBridgeClearances: BridgeDataGISArray * - BridgeDataGIS fields: * - APILastUpdate: API last update time (JS Date) * - BridgeNumber: Bridge number (nullable) * - ControlEntityGuid: Control entity GUID * - CrossingDescription: Crossing description (nullable) * - CrossingLocationId: Crossing location identifier * - CrossingRecordGuid: Crossing record GUID * - InventoryDirection: Inventory direction (nullable) * - Latitude: Latitude in decimal degrees * - LocationGuid: Location GUID * - Longitude: Longitude in decimal degrees * - RouteDate: Route date (JS Date) * - SRMP: State Route Mile Post * - SRMPAheadBackIndicator: Ahead/back indicator (nullable) * - StateRouteID: State route identifier (nullable) * - StateStructureId: State structure identifier (nullable) * - VerticalClearanceMaximumFeetInch: Max clearance in feet/inches (nullable) * - VerticalClearanceMaximumInches: Max clearance in inches * - VerticalClearanceMinimumFeetInch: Min clearance in feet/inches (nullable) * - VerticalClearanceMinimumInches: Min clearance in inches * * @baseType * - BridgeDataGIS: Bridge clearance record * * @cli * - getBridgeClearances: node dist/cli.mjs getBridgeClearances * * @exampleResponse * { * "APILastUpdate": "2025-09-03T10:30:02.200Z", * "BridgeNumber": "5/629A", * "ControlEntityGuid": "88ba5341-b39c-43c9-95a5-bc9584b2d798", * "CrossingDescription": "I-5 RAMPS UNDER BROADWAY AVE", * "CrossingLocationId": 6192, * "CrossingRecordGuid": "9b764b55-9fc1-4448-8b0b-3f35b83d6f5f", * "InventoryDirection": "I", * "Latitude": 47.961343, * "LocationGuid": "dad9f2c9-ae79-4efb-8f3e-587e402e0f80", * "Longitude": -122.200516, * "RouteDate": "2016-12-31T08:00:00.000Z", * "SRMP": 0, * "SRMPAheadBackIndicator": "A", * "StateRouteID": "005S119195", * "StateStructureId": "0003842B", * "VerticalClearanceMaximumFeetInch": "14 ft 5 in", * "VerticalClearanceMaximumInches": 173, * "VerticalClearanceMinimumFeetInch": "14 ft 1 in", * "VerticalClearanceMinimumInches": 169 * } * * @see https://wsdot.wa.gov/traffic/api/Documentation/class_clearance.html */ /** Input schema for getBridgeClearances */ declare const bridgeClearancesInput: z.ZodObject<{}, z.core.$strict>; type BridgeClearancesInput = z.infer<typeof bridgeClearancesInput>; /** * @module WSDOT — Bridge Clearances API * @description Bridge height and clearance information by WSDOT route. * * Provides: * - Vertical clearance maximum/minimum by bridge/structure for a specific route * - Crossing metadata, structure identifiers, and location * * Data includes: * - Structure IDs, route/location metadata, clearances (feet/inches), update timestamps (JS Date) * * @functions * - getBridgeClearancesByRoute: Returns bridge clearance data for a specific route * * @input * - getBridgeClearancesByRoute: * - route: WSDOT route string (e.g., "005") * * @output * - getBridgeClearancesByRoute: BridgeDataGISArray * - BridgeDataGIS fields: * - APILastUpdate: API last update time (JS Date) * - BridgeNumber: Bridge number (nullable) * - ControlEntityGuid: Control entity GUID * - CrossingDescription: Crossing description (nullable) * - CrossingLocationId: Crossing location identifier * - CrossingRecordGuid: Crossing record GUID * - InventoryDirection: Inventory direction (nullable) * - Latitude: Latitude in decimal degrees * - LocationGuid: Location GUID * - Longitude: Longitude in decimal degrees * - RouteDate: Route date (JS Date) * - SRMP: State Route Mile Post * - SRMPAheadBackIndicator: Ahead/back indicator (nullable) * - StateRouteID: State route identifier (nullable) * - StateStructureId: State structure identifier (nullable) * - VerticalClearanceMaximumFeetInch: Max clearance in feet/inches (nullable) * - VerticalClearanceMaximumInches: Max clearance in inches * - VerticalClearanceMinimumFeetInch: Min clearance in feet/inches (nullable) * - VerticalClearanceMinimumInches: Min clearance in inches * * @baseType * - BridgeDataGIS: Bridge clearance record * * @cli * - getBridgeClearancesByRoute: node dist/cli.mjs getBridgeClearancesByRoute '{"route": "005"}' * * @exampleResponse * { * "APILastUpdate": "2025-09-03T10:30:02.200Z", * "BridgeNumber": "5/629A", * "ControlEntityGuid": "88ba5341-b39c-43c9-95a5-bc9584b2d798", * "CrossingDescription": "I-5 RAMPS UNDER BROADWAY AVE", * "CrossingLocationId": 6192, * "CrossingRecordGuid": "9b764b55-9fc1-4448-8b0b-3f35b83d6f5f", * "InventoryDirection": "I", * "Latitude": 47.961343, * "LocationGuid": "dad9f2c9-ae79-4efb-8f3e-587e402e0f80", * "Longitude": -122.200516, * "RouteDate": "2016-12-31T08:00:00.000Z", * "SRMP": 0, * "SRMPAheadBackIndicator": "A", * "StateRouteID": "005S119195", * "StateStructureId": "0003842B", * "VerticalClearanceMaximumFeetInch": "14 ft 5 in", * "VerticalClearanceMaximumInches": 173, * "VerticalClearanceMinimumFeetInch": "14 ft 1 in", * "VerticalClearanceMinimumInches": 169 * } * * @see https://wsdot.wa.gov/traffic/api/Documentation/class_clearance.html */ /** Input schema for getBridgeClearancesByRoute */ declare const bridgeClearancesByRouteInput: z.ZodObject<{ route: z.ZodString; }, z.core.$strip>; type BridgeClearancesByRouteInput = z.infer<typeof bridgeClearancesByRouteInput>; declare const getBridgeClearances: Endpoint<Record<string, never>, { APILastUpdate: Date; BridgeNumber: string | null; ControlEntityGuid: string; CrossingDescription: string | null; CrossingLocationId: number; CrossingRecordGuid: string; InventoryDirection: "I" | "D" | "B" | "i" | "d" | "b" | null; Latitude: number; LocationGuid: string; Longitude: number; RouteDate: Date; SRMP: number; SRMPAheadBackIndicator: string | null; StateRouteID: string | null; StateStructureId: string | null; VerticalClearanceMaximumFeetInch: string | null; VerticalClearanceMaximumInches: number; VerticalClearanceMinimumFeetInch: string | null; VerticalClearanceMinimumInches: number; }[]>; declare const getBridgeClearancesByRoute: Endpoint<{ route: string; }, { APILastUpdate: Date; BridgeNumber: string | null; ControlEntityGuid: string; CrossingDescription: string | null; CrossingLocationId: number; CrossingRecordGuid: string; InventoryDirection: "I" | "D" | "B" | "i" | "d" | "b" | null; Latitude: number; LocationGuid: string; Longitude: number; RouteDate: Date; SRMP: number; SRMPAheadBackIndicator: string | null; StateRouteID: string | null; StateStructureId: string | null; VerticalClearanceMaximumFeetInch: string | null; VerticalClearanceMaximumInches: number; VerticalClearanceMinimumFeetInch: string | null; VerticalClearanceMinimumInches: number; }[]>; /** * @module WSDOT — Commercial Vehicle Restrictions API * @description Commercial vehicle bridge/load restrictions and related metadata. * * Provides: * - Statewide commercial vehicle restrictions (no UniqueID) * - Locations, dates, load limits, and descriptive metadata * * Data includes: * - Restriction types and comments, bridge/route identifiers, dates (JS Date), roadway location * * @functions * - getCommercialVehicleRestrictions: Returns commercial vehicle restrictions (no IDs) * * @input * - getCommercialVehicleRestrictions: {} * * @output * - getCommercialVehicleRestrictions: CommercialVehicleRestrictions * - CommercialVehicleRestriction fields: * - BLMaxAxle: BL maximum axle weight (nullable) * - BridgeName: Bridge name * - BridgeNumber: Bridge number * - CL8MaxAxle: CL-8 maximum axle weight (nullable) * - DateEffective: Effective date (JS Date) * - DateExpires: Expiration date (JS Date) * - DatePosted: Date posted (JS Date) * - EndRoadwayLocation: End location information * - IsDetourAvailable: Whether detour is available * - IsExceptionsAllowed: Whether exceptions are allowed * - IsPermanentRestriction: Whether restriction is permanent * - IsWarning: Whether warning only * - LocationDescription: Location description * - LocationName: Location name * - RestrictionComment: Restriction comment * - RestrictionType: Restriction type code * - State: State code * - StateRouteID: State route identifier * - VehicleType: Vehicle type description * - CommercialVehicleRestrictionRoadwayLocation fields: * - Description: Location description (nullable) * - Direction: Direction (nullable) * - Latitude: Latitude in decimal degrees * - Longitude: Longitude in decimal degrees * - MilePost: Highway milepost * - RoadName: Highway/road name * * @baseType * - CommercialVehicleRestriction: Restriction record * - CommercialVehicleRestrictionRoadwayLocation: Roadway location details * * @cli * - getCommercialVehicleRestrictions: node dist/cli.mjs getCommercialVehicleRestrictions * * @exampleResponse * { * "BLMaxAxle": 20000, * "BridgeName": "Teanaway River", * "BridgeNumber": "10/142", * "CL8MaxAxle": 20000, * "DateEffective": "2011-10-18T07:00:00.000Z", * "DateExpires": "2075-12-31T08:00:00.000Z", * "DatePosted": "2011-10-18T22:12:00.000Z", * "EndRoadwayLocation": { * "Description": null, * "Direction": "Both", * "Latitude": 0, * "Longitude": 0, * "MilePost": 0, * "RoadName": "SR 10" * }, * "IsDetourAvailable": false, * "IsExceptionsAllowed": false, * "IsPermanentRestriction": false, * "IsWarning": false, * "LocationDescription": "SR 10, MP 89.33 both directions-20,000 lbs limitation", * "LocationName": "1.3 E Jct SR 970", * "RestrictionComment": "BL =20,000 lbs, CL-8 =20,000 lbs, SA = 40,000 lbs.", * "RestrictionType": 0, * "State": "WA", * "StateRouteID": "10", * "VehicleType": "" * } * * @see https://wsdot.wa.gov/traffic/api/Documentation/group___commercial_vehicle.html */ /** Input schema for getCommercialVehicleRestrictions */ declare const commercialVehicleRestrictionsInput: z.ZodObject<{}, z.core.$strict>; type CommercialVehicleRestrictionsInput = z.infer<typeof commercialVehicleRestrictionsInput>; /** * @module WSDOT — Commercial Vehicle Restrictions API (With ID) * @description Commercial vehicle bridge/load restrictions and related metadata with UniqueID. * * Provides: * - Statewide commercial vehicle restrictions including UniqueID * - Locations, dates, load limits, and descriptive metadata * * Data includes: * - Restriction types and comments, bridge/route identifiers, dates (JS Date), roadway location * - UniqueID for each restriction * * @functions * - getCommercialVehicleRestrictionsWithId: Returns restrictions including UniqueID * * @input * - getCommercialVehicleRestrictionsWithId: {} * * @output * - getCommercialVehicleRestrictionsWithId: CommercialVehicleRestrictionsWithId * - CommercialVehicleRestrictionWithId fields: * - BLMaxAxle: BL maximum axle weight (nullable) * - BridgeName: Bridge name * - BridgeNumber: Bridge number * - CL8MaxAxle: CL-8 maximum axle weight (nullable) * - DateEffective: Effective date (JS Date) * - DateExpires: Expiration date (JS Date) * - DatePosted: Date posted (JS Date) * - EndRoadwayLocation: End location information * - IsDetourAvailable: Whether detour is available * - IsExceptionsAllowed: Whether exceptions are allowed * - IsPermanentRestriction: Whether restriction is permanent * - IsWarning: Whether warning only * - LocationDescription: Location description * - LocationName: Location name * - RestrictionComment: Restriction comment * - RestrictionType: Restriction type code * - State: State code * - StateRouteID: State route identifier * - VehicleType: Vehicle type description * - UniqueID: Unique restriction identifier * - CommercialVehicleRestrictionRoadwayLocation fields: * - Description: Location description (nullable) * - Direction: Direction (nullable) * - Latitude: Latitude in decimal degrees * - Longitude: Longitude in decimal degrees * - MilePost: Highway milepost * - RoadName: Highway/road name * * @baseType * - CommercialVehicleRestrictionWithId: Restriction record with UniqueID * - CommercialVehicleRestrictionRoadwayLocation: Roadway location details * * @cli * - getCommercialVehicleRestrictionsWithId: node dist/cli.mjs getCommercialVehicleRestrictionsWithId * * @exampleResponse * { * "BLMaxAxle": 20000, * "BridgeName": "Teanaway River", * "BridgeNumber": "10/142", * "CL8MaxAxle": 20000, * "DateEffective": "2011-10-18T07:00:00.000Z", * "DateExpires": "2075-12-31T08:00:00.000Z", * "DatePosted": "2011-10-18T22:12:00.000Z", * "EndRoadwayLocation": { * "Description": null, * "Direction": "Both", * "Latitude": 0, * "Longitude": 0, * "MilePost": 0, * "RoadName": "SR 10" * }, * "IsDetourAvailable": false, * "IsExceptionsAllowed": false, * "IsPermanentRestriction": false, * "IsWarning": false, * "LocationDescription": "SR 10, MP 89.33 both directions-20,000 lbs limitation", * "LocationName": "1.3 E Jct SR 970", * "RestrictionComment": "BL =20,000 lbs, CL-8 =20,000 lbs, SA = 40,000 lbs.", * "RestrictionType": 0, * "State": "WA", * "StateRouteID": "10", * "VehicleType": "", * "UniqueID": "B-WA-010-1" * } * * @see https://wsdot.wa.gov/traffic/api/Documentation/group___commercial_vehicle.html */ /** Input schema for getCommercialVehicleRestrictionsWithId */ declare const commercialVehicleRestrictionsWithIdInput: z.ZodObject<{}, z.core.$strict>; type CommercialVehicleRestrictionsWithIdInput = z.infer<typeof commercialVehicleRestrictionsWithIdInput>; declare const getCommercialVehicleRestrictions: Endpoint<Record<string, never>, { BLMaxAxle: number | null; BridgeName: string | null; BridgeNumber: string | null; CL8MaxAxle: number | null; DateEffective: Date; DateExpires: Date; DatePosted: Date; EndRoadwayLocation: { Description: string | null; RoadName: string | null; Direction: string | null; MilePost: number; Latitude: number; Longitude: number; } | null; IsDetourAvailable: boolean; IsExceptionsAllowed: boolean; IsPermanentRestriction: boolean; IsWarning: boolean; Latitude: number; LocationDescription: string | null; LocationName: string | null; Longitude: number; MaximumGrossVehicleWeightInPounds: number | null; RestrictionComment: string | null; RestrictionHeightInInches: number | null; RestrictionLengthInInches: number | null; RestrictionType: 0 | 1; RestrictionWeightInPounds: number | null; RestrictionWidthInInches: number | null; SAMaxAxle: number | null; StartRoadwayLocation: { Description: string | null; RoadName: string | null; Direction: string | null; MilePost: number; Latitude: number; Longitude: number; } | null; State: string | null; StateRouteID: string | null; TDMaxAxle: number | null; VehicleType: string | null; UniqueID?: string | undefined; }[]>; declare const getCommercialVehicleRestrictionsWithId: Endpoint<Record<string, never>, { BLMaxAxle: number | null; BridgeName: string | null; BridgeNumber: string | null; CL8MaxAxle: number | null; DateEffective: Date; DateExpires: Date; DatePosted: Date; EndRoadwayLocation: { Description: string | null; RoadName: string | null; Direction: string | null; MilePost: number; Latitude: number; Longitude: number; } | null; IsDetourAvailable: boolean; IsExceptionsAllowed: boolean; IsPermanentRestriction: boolean; IsWarning: boolean; Latitude: number; LocationDescription: string | null; LocationName: string | null; Longitude: number; MaximumGrossVehicleWeightInPounds: number | null; RestrictionComment: string | null; RestrictionHeightInInches: number | null; RestrictionLengthInInches: number | null; RestrictionType: 0 | 1; RestrictionWeightInPounds: number | null; RestrictionWidthInInches: number | null; SAMaxAxle: number | null; StartRoadwayLocation: { Description: string | null; RoadName: string | null; Direction: string | null; MilePost: number; Latitude: number; Longitude: number; } | null; State: string | null; StateRouteID: string | null; TDMaxAxle: number | null; VehicleType: string | null; UniqueID: string | null; }[]>; /** * @module WSDOT — Highway Alerts API * @description Single highway alert by ID including construction, incidents, and travel impacts. * * Provides: * - Single alert by ID * * Data includes: * - Alert identifiers, categories, status, headline/extended descriptions, start/end times (JS Date), roadway locations * * @functions * - getAlert: Returns a single alert by ID * * @input * - getAlert: * - AlertID: Alert identifier * * @output * - getAlert: HighwayAlert * - HighwayAlert fields: * - AlertID: Alert identifier * - County: County name (nullable) * - EndRoadwayLocation: End location details * - EndTime: End time (JS Date, nullable) * - EventCategory: Event category * - EventStatus: Event status * - ExtendedDescription: Extended description (nullable) * - HeadlineDescription: Headline description * - LastUpdatedTime: Last update time (JS Date) * - Priority: Priority * - Region: Region name * - StartRoadwayLocation: Start location details * - StartTime: Start time (JS Date) * - HighwayAlertRoadwayLocation fields: * - Description: Location description (nullable) * - Direction: Direction (nullable) * - Latitude: Latitude (may be 0 when not available) * - Longitude: Longitude (may be 0 when not available) * - MilePost: Highway milepost (may be 0 when not available) * - RoadName: Highway/road name (nullable) * * @baseType * - HighwayAlert: Highway alert record * - HighwayAlertRoadwayLocation: Roadway location details * * @cli * - getAlert: node dist/cli.mjs getAlert '{"AlertID": 1}' * * @exampleResponse * { * "AlertID": 661208, * "County": null, * "EndRoadwayLocation": { * "Description": null, * "Direction": "S", * "Latitude": 47.578503696, * "Longitude": -122.174652622, * "MilePost": 11, * "RoadName": "405" * }, * "EndTime": "2025-09-05T12:00:00.000Z", * "EventCategory": "Construction", * "EventStatus": "Open", * "ExtendedDescription": "", * "HeadlineDescription": "Up to two lanes of southbound I-405 from milepost 12 to milepost 11 will be closed nighty, 9 p.m. Tuesday, Sept. 2 – 5 a.m. Friday, Sept. 5.", * "LastUpdatedTime": "2025-08-29T19:35:05.540Z", * "Priority": "Low", * "Region": "Northwest", * "StartRoadwayLocation": { * "Description": null, * "Direction": "S", * "Latitude": 47.591955273, * "Longitude": -122.181281785, * "MilePost": 12, * "RoadName": "405" * }, * "StartTime": "2025-09-02T07:00:00.000Z" * } * * @see https://wsdot.wa.gov/traffic/api/Documentation/group___highway_alerts.html */ /** Input schema for getAlert */ declare const alertInput: z.ZodObject<{ AlertID: z.ZodNumber; }, z.core.$strip>; type AlertInput = z.infer<typeof alertInput>; /** * @module WSDOT — Highway Alerts API * @description Active highway alerts including construction, incidents, and travel impacts. * * Provides: * - All active alerts * * Data includes: * - Alert identifiers, categories, status, headline/extended descriptions, start/end times (JS Date), roadway locations * * @functions * - getAlerts: Returns all active alerts * * @input * - getAlerts: {} * * @output * - getAlerts: HighwayAlerts * - HighwayAlert fields: * - AlertID: Alert identifier * - County: County name (nullable) * - EndRoadwayLocation: End location details * - EndTime: End time (JS Date, nullable) * - EventCategory: Event category * - EventStatus: Event status * - ExtendedDescription: Extended description (nullable) * - HeadlineDescription: Headline description * - LastUpdatedTime: Last update time (JS Date) * - Priority: Priority * - Region: Region name * - StartRoadwayLocation: Start location details * - StartTime: Start time (JS Date) * - HighwayAlertRoadwayLocation fields: * - Description: Location description (nullable) * - Direction: Direction (nullable) * - Latitude: Latitude (may be 0 when not available) * - Longitude: Longitude (may be 0 when not available) * - MilePost: Highway milepost (may be 0 when not available) * - RoadName: Highway/road name (nullable) * * @baseType * - HighwayAlert: Highway alert record * - HighwayAlertRoadwayLocation: Roadway location details * * @cli * - getAlerts: node dist/cli.mjs getAlerts * * @exampleResponse * { * "AlertID": 661208, * "County": null, * "EndRoadwayLocation": { * "Description": null, * "Direction": "S", * "Latitude": 47.578503696, * "Longitude": -122.174652622, * "MilePost": 11, * "RoadName": "405" * }, * "EndTime": "2025-09-05T12:00:00.000Z", * "EventCategory": "Construction", * "EventStatus": "Open", * "ExtendedDescription": "", * "HeadlineDescription": "Up to two lanes of southbound I-405 from milepost 12 to milepost 11 will be closed nighty, 9 p.m. Tuesday, Sept. 2 – 5 a.m. Friday, Sept. 5.", * "LastUpdatedTime": "2025-08-29T19:35:05.540Z", * "Priority": "Low", * "Region": "Northwest", * "StartRoadwayLocation": { * "Description": null, * "Direction": "S", * "Latitude": 47.591955273, * "Longitude": -122.181281785, * "MilePost": 12, * "RoadName": "405" * }, * "StartTime": "2025-09-02T07:00:00.000Z" * } * * @see https://wsdot.wa.gov/traffic/api/Documentation/group___highway_alerts.html */ /** Input schema for getAlerts */ declare const alertsInput: z.ZodObject<{}, z.core.$strict>; type AlertsInput = z.infer<typeof alertsInput>; /** * @module WSDO