/** * Shared error mapping helpers for registry and auth client implementations. * * Provides reusable predicates and mappers for converting generated client * errors (RegistryClientError, HttpClientError, SchemaError) to AppError. * * @experimental This API is unstable and may change without notice. * @packageDocumentation */ import * as HttpClientError from "effect/unstable/http/HttpClientError"; import { type AppError } from "../app-error/index.js"; import type { SuggestedAction } from "../cli-runtime/suggested-action.js"; import type { RegistryClientError } from "./__generated__/registry-client.js"; /** * Safely read a string field from an unknown object. */ export declare const getString: (obj: unknown, field: string) => string | undefined; /** * Create a type predicate that matches a specific RegistryClientError tag. * * Usage: * ```ts * Effect.catchIf(isRegistryClientError("ExtensionsGet404"), ...) * ``` */ export declare const isRegistryClientError: (tag: Tag) => (e: unknown) => e is RegistryClientError; /** * Type predicate for HttpClientError. */ export declare const isHttpClientError: (e: unknown) => e is HttpClientError.HttpClientError; /** * Type predicate matching HttpClientErrors that are reasonable to retry: * transport-level failures (ECONNREFUSED, DNS, etc.) and 5xx status codes. * Deterministic failures — encode errors, invalid URLs, decode errors, * 4xx statuses — are excluded so they fail fast. */ export declare const isTransientHttpClientError: (e: unknown) => e is HttpClientError.HttpClientError; /** * Type predicate for SchemaError from effect/Schema. */ export declare const isSchemaError: (e: unknown) => boolean; /** * Build user-facing suggestions for network errors. * Detects localhost+HTTPS mismatches and provides targeted guidance. */ export declare const buildNetworkSuggestions: (baseUrl: string) => ReadonlyArray; /** * Build diagnostic details array for network errors. * Detects localhost+HTTPS protocol mismatch. */ export declare const buildNetworkDiagnosis: (baseUrl: string) => ReadonlyArray; /** * Safely read the _tag from an unknown value. */ export declare const getTag: (e: unknown) => string | undefined; /** * Check if an unknown value is a RegistryClientError (has _tag, request, response fields). */ export declare const isAnyRegistryClientError: (e: unknown) => e is RegistryClientError; /** * Check if an unknown value has a _tag ending with the given suffix. */ export declare const hasTagSuffix: (e: unknown, suffix: string) => boolean; /** * Map an HttpClientError to an AppError with network error codes. */ export declare const mapNetworkError: (error: HttpClientError.HttpClientError, message: string, baseUrl: string) => AppError; /** * Map an input Schema encode error to an AppError. */ export declare const mapInputSchemaError: (error: unknown, message: string) => AppError; /** * Map a response Schema decode error to an AppError. */ export declare const mapResponseSchemaError: (error: unknown, message: string) => AppError; export declare const mapSchemaError: (error: unknown, message: string) => AppError; /** * Map a RegistryClientError to an AppError for unexpected status codes. */ export declare const mapUnexpectedStatusError: (error: RegistryClientError, _message: string) => AppError; //# sourceMappingURL=error-mapping.d.ts.map