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 • 44.3 kB
Source Map (JSON)
{"version":3,"sources":["../../src/cli/execution.ts","../../src/cli/types.ts","../../src/cli/ui.ts","../../src/cli/validation.ts","../../src/cli/cli.ts","../../src/cli/fetch-dottie.ts"],"names":["init_fetching","executeApiRequest","endpoint","params","options","validate","fetchMode","logMode","fetchDottie","getStrategyDescription","useJsonp","useValidation","CLI_CONSTANTS","handleError","error","functionName","message","isApiError","pc","addErrorContext","getApiErrorTip","extractErrorMessage","getGenericErrorTip","displayCollisionError","endpointName","matchingEndpoints","ep","displayFunctionNotFound","availableFunctions","endpointsFlat","func","outputResult","result","outputConciseArray","colorizedOutput","colorizeValue","truncatedLines","itemsToShow","item","index","isLast","colorizedItem","value","key","val","setupConsoleSuppression","isQuiet","originalLog","originalError","generateExamples","generateHelpText","_toolName","_examples","functionList","endpointDef","description","ex","processParameters","userParams","sampleParams","shouldSuppressOutput","mode","setupCli","program","Command","consoleControl","handleListOption","validateFunctionName","findEndpoint","validatedParams","executeRequest","consoleRestore","api","parseFunctionName","trimmed","separatorIndex","allEndpoints","strategy"],"mappings":";myCASAA,GAAAA,EAAAA,CAiBO,IAAMC,CAAAA,CAAoB,MAC/BC,CAAAA,CACAC,CAAAA,CACAC,IACqB,CAErB,IAAMC,CAAAA,CAAWD,CAAAA,CAAQ,UAAA,GAAe,KAAA,CAClCE,CAAAA,CAAaF,CAAAA,CAAQ,KAAA,EAAS,KAAA,CAAS,OAAA,CAAU,QAAA,CAIjDG,CAAAA,CAAU,OAAA,CAAQ,IAAI,QAAA,GAAa,MAAA,CAAS,MAAA,CAAS,MAAA,CAE3D,OAAOC,CAAAA,CAAY,CACjB,QAAA,CAAAN,CAAAA,CACA,MAAA,CAAAC,CAAAA,CACA,SAAA,CAAAG,CAAAA,CACA,OAAA,CAAAC,EACA,QAAA,CAAAF,CACF,CAAC,CACH,CAAA,CAQaI,CAAAA,CAA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AAQ,IAAA,CAAK,CAAC,GAElB,CAEA,OAAKvB,MACHqE,CAAAA,EAAe,CACf5C,EAAwBZ,CAAY,CAAA,CACpC,QAAQ,IAAA,CAAK,CAAC,GAGTb,GACT,CAAA,CAgBMoE,EAAiB,MACrBpE,CAAAA,CACAC,EACAC,CAAAA,CACA0C,CAAAA,GACqB,CACrB,GAAI,CAACA,CAAAA,CAAS,CACZ,IAAM+B,CAAAA,CAAWpE,EAAuBL,CAAO,CAAA,CAC/C,QAAQ,KAAA,CAAM,CAAA,kBAAA,EAAcF,CAAAA,CAAS,YAAY,CAAA,EAAA,EAAK2E,CAAQ,MAAM,EACtE,CAEA,OAAO,MAAM5E,CAAAA,CAAkBC,EAAUC,CAAAA,CAAaC,CAAO,CAC/D,CAAA,CC5NA0D,CAAAA,EAAS","file":"fetch-dottie.mjs","sourcesContent":["/**\n * @fileoverview API Request Execution for WS-Dottie CLI\n *\n * This module handles the execution of API requests with different fetch strategies\n * based on CLI options. It provides a single function that uses the new fetchDottie\n * function with appropriate options based on the --jsonp and --no-validation flags.\n */\n\nimport type { Endpoint } from \"@/apis/types\";\nimport { fetchDottie } from \"@/shared/fetching\";\nimport type { CliOptions } from \"./types\";\n\n/**\n * Executes API requests using the new fetchDottie function with CLI options\n *\n * This function uses the unified fetchDottie function with options derived from\n * the --jsonp and --no-validation flags, providing a single interface that can\n * handle all fetch strategies.\n *\n * @template I - The input parameters type for the endpoint\n * @template O - The output response type for the endpoint\n * @param endpoint - Endpoint definition with schemas and configuration\n * @param params - Parameters to send with the request\n * @param options - CLI options including transport and validation flags\n * @returns Promise resolving to API response data\n */\nexport const executeApiRequest = async <I, O>(\n endpoint: Endpoint<I, O>,\n params: I,\n options: CliOptions\n): Promise<unknown> => {\n // Commander.js converts --no-validation to validation: false\n const validate = options.validation !== false;\n const fetchMode = (options.jsonp ?? false) ? \"jsonp\" : \"native\";\n\n // Use \"none\" logging mode during tests to avoid interfering with JSON parsing\n // In normal usage, this will be overridden by the CLI options\n const logMode = process.env.NODE_ENV === \"test\" ? \"none\" : \"info\";\n\n return fetchDottie({\n endpoint,\n params,\n fetchMode,\n logMode,\n validate,\n });\n};\n\n/**\n * Gets a human-readable description of the fetch strategy based on options\n *\n * @param options - CLI options containing transport and validation flags\n * @returns String description of the strategy being used\n */\nexport const getStrategyDescription = (options: CliOptions): string => {\n const useJsonp = options.jsonp ?? false;\n // Commander.js converts --no-validation to validation: false\n const useValidation = options.validation !== false;\n\n if (useJsonp && useValidation) return \"JSONP + validation\";\n if (useJsonp && !useValidation) return \"JSONP (no validation)\";\n if (!useJsonp && useValidation) return \"native + validation\";\n return \"native (no validation)\";\n};\n","/**\n * @fileoverview CLI Types and Constants for WS-Dottie\n *\n * This module provides type definitions and constants used throughout the\n * WS-Dottie CLI tools. It includes interfaces for CLI options, parameter\n * types, and utility constants for consistent behavior across all CLI tools.\n */\n\n/**\n * CLI constants used throughout the command-line tools\n *\n * These constants provide consistent values and patterns used across\n * all CLI tools for parameter parsing, output control, and validation.\n */\nexport const CLI_CONSTANTS = {\n /** Array of quiet mode option names */\n QUIET_MODES: [\"quiet\", \"silent\"] as const,\n /** Default empty JSON parameters string */\n DEFAULT_PARAMS: \"{}\",\n} as const;\n\n/**\n * CLI options interface\n *\n * Defines the available command-line options for WS-Dottie CLI tools.\n * These options control output formatting, verbosity, behavior, and fetch strategy.\n */\nexport interface CliOptions {\n /** Pretty-print JSON output with 2-space indentation */\n pretty?: boolean;\n /** Quiet mode: suppress debug output and verbose messages */\n quiet?: boolean;\n /** Silent mode: suppress all output except final JSON result */\n silent?: boolean;\n /** Truncate output to first N lines */\n limit?: number;\n /** List all available endpoints and exit */\n list?: boolean;\n /** Use JSONP instead of native fetch (for browser environments) */\n jsonp?: boolean;\n /** Validation flag (set by Commander.js when --no-validation is used) */\n validation?: boolean;\n /** Concise array output: brackets on own lines, items indented and compact */\n concise?: boolean;\n}\n\n/**\n * Type for CLI parameters - represents user input parameters\n *\n * This type represents the parameters passed to API functions from the\n * command line. It's a flexible record type that can contain any\n * key-value pairs that match the expected API parameter structure.\n */\nexport type CliParams = Record<string, unknown>;\n","/**\n * @fileoverview UI and Output Utilities for WS-Dottie CLI\n *\n * This module provides user interface and output utilities for WS-Dottie\n * command-line tools. It includes error handling, output formatting,\n * console control, and help text generation functionality.\n *\n * ## Key Features\n *\n * - **Error Handling**: Comprehensive error handling with helpful context and tips\n * - **Output Formatting**: Pretty-printing, truncation, and formatting options\n * - **Console Control**: Suppression and restoration of console output\n * - **Help Generation**: Dynamic help text with examples and function listings\n * - **User Feedback**: Colored output and informative messages\n */\n\nimport pc from \"picocolors\";\nimport { endpointsFlat } from \"@/apis\";\nimport type { ApiError } from \"@/shared/fetching\";\nimport { isApiError } from \"@/shared/fetching\";\nimport type { CliOptions } from \"./types\";\n\n/**\n * Handles errors with consistent formatting and helpful context\n *\n * This function provides comprehensive error handling for CLI tools, including\n * error message extraction, context-specific tips, and appropriate exit codes.\n * It handles both ApiError instances and generic errors with different\n * formatting and context information.\n *\n * @param error - The error to handle (can be any type)\n * @param functionName - Name of the function that caused the error\n * @throws Never returns, always exits process with code 1\n */\nexport const handleError = (error: unknown, functionName: string): never => {\n // Extract message based on error type - use the actual error message\n const message = isApiError(error)\n ? error.message\n : error instanceof Error\n ? error.message\n : String(error);\n\n console.error(pc.red(`❌ Error calling ${functionName}:`));\n console.error(pc.yellow(message));\n\n // Add context based on error type\n addErrorContext(error);\n\n // Add stack trace in debug mode for generic errors\n if (\n error instanceof Error &&\n !isApiError(error) &&\n error.stack &&\n process.env.NODE_ENV === \"development\"\n ) {\n console.error(pc.gray(error.stack));\n }\n\n process.exit(1);\n};\n\n/**\n * Adds helpful context based on error type\n *\n * This function analyzes the error type and provides context-specific tips\n * to help users resolve common issues. It handles both ApiError instances\n * and generic errors with appropriate guidance.\n *\n * @param error - The error to add context for\n */\nconst addErrorContext = (error: unknown): void => {\n if (isApiError(error)) {\n // Provide context based on HTTP status codes\n getApiErrorTip(error);\n return;\n }\n\n // Generic error context\n const message = extractErrorMessage(error);\n getGenericErrorTip(message);\n};\n\n/**\n * Extracts the error message from an unknown error type.\n * @param error - The error to extract the message from.\n * @returns The extracted error message as a string.\n */\nconst extractErrorMessage = (error: unknown): string => {\n return isApiError(error)\n ? error.message\n : error instanceof Error\n ? error.message\n : String(error);\n};\n\n/**\n * Provides context-specific tips for API errors based on status codes or message content.\n * @param error - The ApiError instance.\n */\nconst getApiErrorTip = (error: ApiError): void => {\n if (error.status && error.status >= 400) {\n if (error.status === 404) {\n console.error(\n pc.gray(\"💡 Tip: Check if the endpoint or parameters are correct\")\n );\n } else if (error.status >= 500) {\n console.error(\n pc.gray(\n \"💡 Tip: The API server may be experiencing issues. Try again later\"\n )\n );\n } else if (error.status === 401 || error.status === 403) {\n console.error(pc.gray(\"💡 Tip: Check your API access permissions\"));\n } else {\n console.error(\n pc.gray(\"💡 Tip: Check your request parameters and try again\")\n );\n }\n } else if (error.message.includes(\"timeout\")) {\n console.error(\n pc.gray(\"💡 Tip: The request timed out. Check your internet connection\")\n );\n } else if (\n error.message.includes(\"network\") ||\n error.message.includes(\"fetch\")\n ) {\n console.error(pc.gray(\"💡 Tip: Check your internet connection\"));\n }\n};\n\n/**\n * Provides context-specific tips for generic errors based on message content.\n * @param message - The error message string.\n */\nconst getGenericErrorTip = (message: string): void => {\n if (message.includes(\"Invalid JSON parameters\")) {\n console.error(pc.gray(\"💡 Tip: Ensure your parameters are valid JSON\"));\n } else if (\n message.includes(\"Parameter validation failed\") ||\n message.includes(\"Validation failed\")\n ) {\n console.error(\n pc.gray(\n \"💡 Tip: Check the function documentation for required parameters\"\n )\n );\n } else if (message.includes(\"not found\")) {\n console.error(pc.gray(\"💡 Tip: Use --help to see available functions\"));\n }\n};\n\n/**\n * Displays collision error when multiple endpoints have the same name\n *\n * This function provides a helpful error message when a requested function\n * name matches multiple endpoints, showing the user how to use namespace\n * syntax to disambiguate.\n *\n * @param endpointName - The endpoint name that has collisions\n * @param matchingEndpoints - Array of endpoints that match the name\n */\nexport const displayCollisionError = (\n endpointName: string,\n matchingEndpoints: Array<{\n api: { name: string };\n functionName: string;\n urlTemplate: string;\n }>\n): void => {\n console.error(\n pc.red(`❌ Multiple endpoints found with name '${endpointName}':`)\n );\n console.error(pc.yellow(\"Please use a fully-qualified name:\"));\n console.error();\n\n matchingEndpoints.forEach((ep) => {\n console.error(pc.cyan(` ${ep.api}:${endpointName}`));\n console.error(pc.gray(` → ${ep.urlTemplate}`));\n });\n\n console.error();\n console.error(\n pc.gray(\n \"💡 Tip: Use the format 'api:endpoint' to specify which endpoint you want\"\n )\n );\n};\n\n/**\n * Displays function not found error with list of available functions\n *\n * This function provides a helpful error message when a requested function\n * is not found, including a list of all available functions to help users\n * find the correct function name.\n *\n * @param functionName - The function name that was not found\n */\nexport const displayFunctionNotFound = (functionName: string): void => {\n const allEndpoints = endpointsFlat;\n const availableFunctions = allEndpoints.map((ep) => ep.functionName);\n console.error(pc.red(`❌ Function '${functionName}' not found`));\n console.error(pc.yellow(\"Available functions:\"));\n availableFunctions.forEach((func) => {\n console.error(pc.gray(` ${func}`));\n });\n};\n\n/**\n * Outputs result with formatting based on CLI options\n *\n * This function formats and outputs the API response data according to\n * the specified CLI options, including pretty-printing and truncation.\n * Now uses colorized output by default in all cases.\n *\n * @param result - The result data to output\n * @param options - CLI options controlling output format (pretty, head, etc.)\n */\nexport const outputResult = (result: unknown, options: CliOptions): void => {\n // Apply limit to array results if specified\n let outputResult = result;\n if (options.limit && options.limit > 0 && Array.isArray(result)) {\n outputResult = result.slice(0, options.limit);\n }\n\n // Handle concise output for arrays\n if (options.concise && Array.isArray(outputResult)) {\n outputConciseArray(outputResult, options);\n return;\n }\n\n // Use colorized output in all cases\n const colorizedOutput = colorizeValue(outputResult);\n\n if (options.limit && options.limit > 0 && !Array.isArray(result)) {\n // For non-array results, limit by lines (original behavior)\n const lines = colorizedOutput.split(\"\\n\");\n const truncatedLines = lines.slice(0, options.limit);\n console.log(truncatedLines.join(\"\\n\"));\n } else {\n console.log(colorizedOutput);\n }\n};\n\n/**\n * Outputs array in concise format: brackets on own lines, items indented and compact\n * Colors are automatically handled by picocolors based on TTY detection\n *\n * @param result - Array of items to output\n * @param options - CLI options controlling output format\n */\nconst outputConciseArray = (result: unknown[], options: CliOptions): void => {\n // Apply limit if specified\n const itemsToShow =\n options.limit && options.limit > 0\n ? result.slice(0, options.limit)\n : result;\n\n console.log(\"[\");\n itemsToShow.forEach((item, index) => {\n const isLast = index === itemsToShow.length - 1;\n const colorizedItem = colorizeValue(item);\n console.log(` ${colorizedItem}${isLast ? \"\" : \",\"}`);\n });\n console.log(\"]\");\n};\n\n/**\n * Recursively colorizes a JavaScript value using picocolors\n * Handles all JSON types: objects, arrays, strings, numbers, booleans, null, and dates\n *\n * @param value - Value to colorize\n * @returns Colorized string representation\n */\nconst colorizeValue = (value: unknown): string => {\n // Handle null first (typeof null === 'object')\n if (value === null) return pc.yellow(\"null\");\n\n // Handle Date objects specifically\n if (value instanceof Date) {\n return pc.green(`\"${value.toISOString()}\"`);\n }\n\n // Handle arrays before objects (Array.isArray needed since typeof array === 'object')\n if (Array.isArray(value)) {\n const items = value.map(colorizeValue);\n return `[${items.join(\",\")}]`;\n }\n\n switch (typeof value) {\n case \"string\":\n return pc.green(`\"${value}\"`);\n case \"number\":\n return pc.cyan(String(value));\n case \"boolean\":\n return pc.yellow(String(value));\n case \"object\": {\n const entries = Object.entries(value).map(\n ([key, val]) => `${pc.gray(`\"${key}\"`)}:${colorizeValue(val)}`\n );\n return `{${entries.join(\",\")}}`;\n }\n default:\n return String(value);\n }\n};\n\n/**\n * Sets up console suppression for quiet modes\n *\n * This function provides console output suppression for quiet and silent modes.\n * It returns an object with a restore method to re-enable console output\n * when needed.\n *\n * @param isQuiet - Whether to suppress console output\n * @returns Object with restore method to re-enable console output\n */\nexport const setupConsoleSuppression = (isQuiet: boolean) => {\n if (!isQuiet) return { restore: () => {} };\n\n const originalLog = console.log;\n const originalError = console.error;\n\n // Suppress all console output\n console.log = console.error = () => {};\n\n return {\n restore: () => {\n console.log = originalLog;\n console.error = originalError;\n },\n };\n};\n\n/**\n * Generates default CLI examples for a given tool name\n *\n * This function creates a set of example commands that demonstrate common\n * usage patterns for WS-Dottie CLI tools. It includes both basic and\n * advanced examples to help users understand the tool's capabilities.\n *\n * @param toolName - Name of the CLI tool (e.g., \"fetch-dottie\", \"fetch-native\")\n * @param additionalExamples - Additional examples to include\n * @returns Array of example command strings\n */\nexport const generateDefaultExamples = (\n toolName: string,\n additionalExamples: string[] = []\n): string[] => {\n const baseExamples = [\n `${toolName} getBorderCrossings`,\n `${toolName} getBridgeClearances '{\"route\": \"005\"}'`,\n `${toolName} fareLineItems '{\"originTerminalId\": 7, \"destinationTerminalId\": 3, \"date\": \"2025-01-27\"}'`,\n `${toolName} vesselLocationsById # Uses default vesselId: 1`,\n `${toolName} getBorderCrossings --no-validation`,\n ];\n\n return [...baseExamples, ...additionalExamples];\n};\n\n/**\n * Generates CLI examples showing different fetch strategies\n *\n * This function creates examples that demonstrate the different fetch strategies\n * available in the CLI tool, including native/JSONP and validation options.\n *\n * @returns Array of example command strings\n */\nexport const generateExamples = (): string[] => {\n return [\n \"# Default: native fetch with validation\",\n \"fetch-dottie vesselBasics\",\n \"\",\n \"# Using namespace syntax for disambiguation\",\n \"fetch-dottie wsf-fares:cacheFlushDate\",\n \"fetch-dottie wsf-schedule:cacheFlushDate\",\n \"\",\n \"# Native fetch without validation (faster, raw data)\",\n \"fetch-dottie vesselBasics --no-validation\",\n \"\",\n \"# JSONP with validation (browser environments)\",\n \"fetch-dottie vesselBasics --jsonp\",\n \"\",\n \"# JSONP without validation (browser environments, raw data)\",\n \"fetch-dottie vesselBasics --jsonp --no-validation\",\n \"\",\n \"# With parameters and pretty printing\",\n 'fetch-dottie fareLineItems \\'{\"originTerminalId\": 7, \"destinationTerminalId\": 3}\\' --pretty',\n \"\",\n \"# Quiet mode for scripting\",\n \"fetch-dottie getBorderCrossings --quiet\",\n ];\n};\n\n/**\n * Generates help text with strategy examples and available functions\n *\n * This function creates comprehensive help text for the CLI tool,\n * including examples of different fetch strategies and a list of all available functions.\n *\n * @param toolName - Name of the CLI tool\n * @param examples - Array of example commands to include\n * @returns Formatted help text string\n */\nexport const generateHelpText = (\n _toolName: string,\n _examples: string[] = []\n): string => {\n const functionList = endpointsFlat\n .map((endpointDef) => {\n const functionName = endpointDef.functionName;\n const api = endpointDef.api;\n const description = `${api} - ${functionName}`;\n return ` ${pc.cyan(functionName)} - ${description}`;\n })\n .join(\"\\n\");\n\n const exampleList = _examples.length > 0 ? _examples : generateExamples();\n\n return `\nExamples:\n${exampleList.map((ex) => ` ${ex}`).join(\"\\n\")}\n\nFunction Names:\n Simple: fetch-dottie vesselBasics\n Namespace: fetch-dottie wsf-fares:cacheFlushDate (for disambiguation)\n\nFetch Strategies:\n Default: Native fetch with Zod validation (recommended)\n --no-validation: Disable validation for faster, raw data access\n --jsonp: Use JSONP for browser environments (bypasses CORS)\n --jsonp --no-validation: JSONP without validation (browser, raw data)\n\nAvailable functions:\n${functionList}\n\nFor more information about parameters, see the ws-dottie documentation.\n`;\n};\n","/**\n * @fileoverview Parameter Processing for WS-Dottie CLI\n *\n * This module provides parameter processing utilities for the CLI tool,\n * including JSON parsing with date coercion and default value application.\n * Validation is handled by the fetching layer, not here.\n */\n\nimport type { Endpoint } from \"@/apis/types\";\nimport type { CliParams } from \"./types\";\n\n/**\n * Processes parameters from command line input\n *\n * This function handles the parameter processing workflow:\n * 1. Parses JSON parameters (no special date coercion needed)\n * 2. Applies default values from endpoint sample parameters\n *\n * Note: Parameter validation is handled by the fetching layer,\n * not in the CLI. This keeps concerns properly separated.\n *\n * @template I - The input parameters type for the endpoint\n * @template O - The output response type for the endpoint\n * @param params - JSON string of parameters from command line\n * @param endpoint - Endpoint definition containing defaults\n * @returns Processed parameters object ready for API calls\n * @throws Error if parameters are invalid JSON\n */\nexport const processParameters = <I, O>(\n params: string,\n endpoint: Endpoint<I, O>\n): CliParams => {\n // Parse JSON parameters (no special coercion needed for string dates)\n const userParams = (() => {\n // Handle empty string or undefined parameters\n if (!params || params.trim() === \"\") {\n return {};\n }\n try {\n return JSON.parse(params);\n } catch (error) {\n throw new Error(`Invalid JSON parameters: ${error}`);\n }\n })();\n\n // Apply defaults only if no parameters are provided\n const sampleParams = endpoint.sampleParams || {};\n const paramsWithDefaults =\n Object.keys(userParams).length > 0\n ? userParams\n : { ...sampleParams, ...userParams };\n\n return paramsWithDefaults as CliParams;\n};\n","#!/usr/bin/env node\n\n/**\n * @fileoverview CLI Setup and Command Handling for WS-Dottie\n *\n * This module provides the main CLI setup and command handling for the fetch-dottie\n * command-line tool, including support for transport and validation flags.\n */\n\nimport { Command } from \"commander\";\nimport pc from \"picocolors\";\nimport { endpointsFlat } from \"@/apis\";\nimport type { Endpoint, EndpointParams, EndpointResponse } from \"@/apis/types\";\nimport { executeApiRequest, getStrategyDescription } from \"./execution\";\nimport { CLI_CONSTANTS, type CliOptions, type CliParams } from \"./types\";\nimport {\n displayCollisionError,\n displayFunctionNotFound,\n generateHelpText,\n handleError,\n outputResult,\n setupConsoleSuppression,\n} from \"./ui\";\nimport { processParameters } from \"./validation\";\n\n/**\n * Determines if output should be suppressed based on CLI options\n *\n * This function checks if any quiet modes are enabled or if the limit option\n * is specified, which would suppress normal output in favor of truncated results.\n *\n * @param options - CLI options object containing quiet/silent flags and limit count\n * @returns True if output should be suppressed, false otherwise\n */\nconst shouldSuppressOutput = (options: CliOptions): boolean =>\n CLI_CONSTANTS.QUIET_MODES.some((mode) => options[mode]) || !!options.limit;\n\n/**\n * Sets up and runs the CLI tool\n */\nexport const setupCli = (): void => {\n const program = new Command();\n\n program\n .name(\"fetch-dottie\")\n .description(\n \"WSDOT/WSF API client with configurable transport and validation\"\n )\n .argument(\"[function-name]\", \"Name of the function to call\")\n .argument(\n \"[params]\",\n \"JSON string of parameters\",\n CLI_CONSTANTS.DEFAULT_PARAMS\n )\n .option(\"--list\", \"List all available endpoints\")\n .option(\"--pretty\", \"Pretty-print JSON output with 2-space indentation\")\n .option(\n \"--concise\",\n \"Concise array output: brackets on own lines, items indented and compact\"\n )\n .option(\"--quiet\", \"Quiet mode: suppress debug output and verbose messages\")\n .option(\n \"--silent\",\n \"Silent mode: suppress all output except final JSON result\"\n )\n .option(\n \"--limit <number>\",\n \"Truncate output to first N lines (equivalent to --quiet | jq . | head -N)\",\n (value) => parseInt(value, 10)\n )\n .option(\n \"--jsonp\",\n \"Use JSONP instead of native fetch (for browser environments)\"\n )\n .option(\n \"--no-validation\",\n \"Disable Zod validation (use raw fetch with .NET date conversion)\"\n )\n .addHelpText(\"after\", generateHelpText(\"fetch-dottie\"));\n\n program.action(\n async (functionName: string, params: string, options: CliOptions) => {\n const isQuiet = shouldSuppressOutput(options);\n const consoleControl = setupConsoleSuppression(isQuiet);\n\n try {\n // Handle --list option\n if (options.list) {\n handleListOption(consoleControl.restore);\n }\n\n // Only validate function name if not listing endpoints\n if (!options.list) {\n validateFunctionName(functionName);\n }\n\n // Parse function name and find endpoint\n const endpoint = findEndpoint(functionName, consoleControl.restore);\n\n // Process parameters\n const validatedParams = processParameters(params, endpoint);\n\n // Execute request\n const result = await executeRequest(\n endpoint,\n validatedParams,\n options,\n isQuiet\n );\n\n // Output result\n consoleControl.restore();\n outputResult(result, options);\n } catch (error) {\n consoleControl.restore();\n handleError(error, functionName);\n }\n }\n );\n\n program.parse();\n};\n\n/**\n * Handles the --list option, displaying all available endpoints and then exiting.\n * @param consoleRestore - Function to restore the console output.\n */\nconst handleListOption = (consoleRestore: () => void): void => {\n consoleRestore();\n const allEndpoints = endpointsFlat;\n const functionList = endpointsFlat\n .map((endpointDef) => {\n const { functionName, api } = endpointDef;\n const description = `${api} - ${functionName}`;\n return ` ${pc.cyan(functionName)} - ${description}`;\n })\n .join(\"\\n\");\n\n console.log(\"Available endpoints:\");\n console.log(functionList);\n process.exit(0);\n};\n\n/**\n * Parses function name to extract API namespace and endpoint name\n *\n * This function handles both namespace syntax (api:endpoint) and simple\n * endpoint names. It returns an object with the parsed components.\n *\n * @param functionName - The function name to parse (e.g., \"api:endpoint\" or \"endpoint\")\n * @returns Object with api and endpoint properties\n */\nconst parseFunctionName = (\n functionName: string\n): { api?: string; endpoint: string } => {\n const trimmed = functionName.trim();\n const separatorIndex = trimmed.indexOf(\":\");\n\n if (separatorIndex === -1) {\n // No namespace, just endpoint name\n return { endpoint: trimmed };\n }\n\n // Has namespace\n const api = trimmed.substring(0, separatorIndex);\n const endpoint = trimmed.substring(separatorIndex + 1);\n\n return { api, endpoint };\n};\n\n/**\n * Validates function name format and exits if invalid\n *\n * This function performs basic validation on the function name parameter,\n * ensuring it's a non-empty string. If validation fails, it displays\n * helpful error messages and exits the process.\n *\n * @param functionName - The function name to validate\n * @throws Exits process with code 1 if function name is invalid\n */\nconst validateFunctionName = (functionName: string): void => {\n if (\n !functionName ||\n typeof functionName !== \"string\" ||\n functionName.trim() === \"\"\n ) {\n console.error(pc.red(\"❌ Function name is required\"));\n console.error(pc.gray(\"💡 Tip: Use --help to see available functions\"));\n process.exit(1);\n }\n};\n\n/**\n * Finds an endpoint based on the function name, handling namespaces and collisions.\n * Exits the process with an error if the function is not found or if there are collisions.\n *\n * @param functionName - The function name provided by the user.\n * @param consoleRestore - Function to restore the console output.\n * @returns The found Endpoint object.\n */\nconst findEndpoint = (\n functionName: string,\n consoleRestore: () => void\n): Endpoint<EndpointParams, EndpointResponse> => {\n const { api, endpoint: endpointName } = parseFunctionName(functionName);\n const allEndpoints = endpointsFlat;\n\n let endpoint: Endpoint<EndpointParams, EndpointResponse> | undefined;\n\n if (api) {\n // Namespace specified - find exact match\n endpoint = allEndpoints.find(\n (ep) => ep.api.name === api && ep.functionName === endpointName\n );\n } else {\n // No namespace - check for collisions\n const matchingEndpoints = allEndpoints.filter(\n (ep) => ep.functionName === endpointName\n );\n\n if (matchingEndpoints.length === 0) {\n // No matches found\n endpoint = undefined;\n } else if (matchingEndpoints.length === 1) {\n // Single match - use it\n endpoint = matchingEndpoints[0];\n } else {\n // Multiple matches - show collision error\n consoleRestore();\n displayCollisionError(endpointName, matchingEndpoints);\n process.exit(1);\n }\n }\n\n if (!endpoint) {\n consoleRestore();\n displayFunctionNotFound(functionName);\n process.exit(1);\n }\n\n return endpoint;\n};\n\n/**\n * Executes the API request with appropriate logging\n *\n * This function handles the execution of API requests with conditional\n * logging based on the quiet mode setting.\n *\n * @template I - The input parameters type for the endpoint\n * @template O - The output response type for the endpoint\n * @param endpoint - Endpoint definition with function name, endpoint URL, and input schema\n * @param params - Validated parameters to send with the request\n * @param options - CLI options for request configuration\n * @param isQuiet - Whether to suppress logging output\n * @returns Promise resolving to the API response data\n */\nconst executeRequest = async <I, O>(\n endpoint: Endpoint<I, O>,\n params: CliParams,\n options: CliOptions,\n isQuiet: boolean\n): Promise<unknown> => {\n if (!isQuiet) {\n const strategy = getStrategyDescription(options);\n console.error(`🔍 Calling ${endpoint.functionName} (${strategy})...`);\n }\n\n return await executeApiRequest(endpoint, params as I, options);\n};\n","#!/usr/bin/env node\n\n/**\n * @fileoverview Fetch-Dottie CLI Tool Entry Point\n *\n * This module provides the main entry point for the fetch-dottie command-line tool\n * for accessing WSDOT/WSF APIs with configurable transport and validation options.\n *\n * ## Features\n *\n * - **Transport Control**: Choose between native fetch and JSONP via --jsonp flag\n * - **Validation Control**: Choose validation level via --no-validation flag\n * - **Type-Safe API Access**: Full TypeScript type safety with Zod validation (default)\n * - **Data Transformation**: Automatic validation and transformation of API responses\n * - **Comprehensive Error Handling**: Detailed error messages with helpful context\n * - **Flexible Output**: Support for pretty-printing, quiet mode, and output truncation\n * - **Date Handling**: Support for YYYY-MM-DD date strings in API parameters\n *\n * ## Usage\n *\n * ```bash\n * fetch-dottie <function-name> [params] [options]\n * ```\n *\n * @example\n * ```bash\n * # Default: native fetch with validation\n * fetch-dottie vesselBasics\n *\n * # Native fetch without validation\n * fetch-dottie vesselBasics --no-validation\n *\n * # JSONP with validation (browser environments)\n * fetch-dottie vesselBasics --jsonp\n *\n * # JSONP without validation (browser environments)\n * fetch-dottie vesselBasics --jsonp --no-validation\n *\n * # List all available functions\n * fetch-dottie --list\n *\n * # Pretty-print output\n * fetch-dottie vesselBasics --pretty\n * ```\n */\n\nimport { setupCli } from \"./cli\";\n\n// Setup and run the CLI tool\nsetupCli();\n"]}