@fragno-dev/core 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +16 -16
- package/CHANGELOG.md +6 -0
- package/dist/api/api.d.ts +1 -1
- package/dist/api/fragment-builder.d.ts +3 -3
- package/dist/api/fragment-instantiation.d.ts +3 -3
- package/dist/api/route.d.ts +2 -2
- package/dist/{api-CoCkNi6h.d.ts → api-BWN97TOr.d.ts} +2 -2
- package/dist/api-BWN97TOr.d.ts.map +1 -0
- package/dist/client/client.d.ts +3 -3
- package/dist/client/client.js +1 -1
- package/dist/client/client.svelte.d.ts +3 -3
- package/dist/client/client.svelte.js +1 -1
- package/dist/client/react.d.ts +3 -3
- package/dist/client/react.js +1 -1
- package/dist/client/solid.d.ts +3 -3
- package/dist/client/solid.js +1 -1
- package/dist/client/vanilla.d.ts +3 -3
- package/dist/client/vanilla.js +1 -1
- package/dist/client/vue.d.ts +3 -3
- package/dist/client/vue.js +5 -5
- package/dist/client/vue.js.map +1 -1
- package/dist/{client-DJfCJiHK.js → client-C5LsYHEI.js} +12 -5
- package/dist/client-C5LsYHEI.js.map +1 -0
- package/dist/{fragment-builder-8-tiECi5.d.ts → fragment-builder-MGr68GNb.d.ts} +10 -9
- package/dist/fragment-builder-MGr68GNb.d.ts.map +1 -0
- package/dist/mod.d.ts +3 -3
- package/dist/{route-mGLYSUvD.d.ts → route-Bl9Zr1Yv.d.ts} +2 -2
- package/dist/{route-mGLYSUvD.d.ts.map → route-Bl9Zr1Yv.d.ts.map} +1 -1
- package/dist/test/test.d.ts +3 -3
- package/package.json +1 -1
- package/src/api/internal/path-type.test.ts +7 -7
- package/src/api/internal/path.ts +1 -1
- package/src/client/client-types.test.ts +4 -4
- package/src/client/client.test.ts +77 -0
- package/src/client/client.ts +31 -12
- package/dist/api-CoCkNi6h.d.ts.map +0 -1
- package/dist/client-DJfCJiHK.js.map +0 -1
- package/dist/fragment-builder-8-tiECi5.d.ts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-C5LsYHEI.js","names":["names: string[]","builtSegments: string[]","#code","#status","parameters: Record<string, string>","firstItem: StandardSchemaV1.InferOutput<TOutputSchema> | null","items: StandardSchemaV1.InferOutput<TOutputSchema>[]","lines","#publicConfig","#fragmentConfig","#fetcherConfig","#cache","#createFetcherStore","#createMutatorStore","#invalidateKeys","#getFetcher","#getFetcherOptions","#createRouteQueryHook","#createRouteQueryMutator","response: Response","mutatorStore: FragnoClientMutatorData<\n NonGetHTTPMethod,\n TPath,\n TInputSchema,\n TOutputSchema,\n TErrorCode,\n TQueryParameters\n >[\"mutatorStore\"]","#invalidate","fragmentConfig: FragnoFragmentSharedConfig<FlattenRouteFactories<TRoutesOrFactories>>"],"sources":["../src/api/internal/path.ts","../src/client/client-error.ts","../src/util/content-type.ts","../src/client/internal/ndjson-streaming.ts","../src/util/nanostores.ts","../src/client/internal/fetcher-merge.ts","../src/client/client.ts"],"sourcesContent":["// Helper type to split a string by '/'\ntype SplitPath<T extends string> = T extends `${infer First}/${infer Rest}`\n ? First extends \"\"\n ? SplitPath<Rest>\n : [First, ...SplitPath<Rest>]\n : T extends \"\"\n ? []\n : [T];\n\n// Helper type to extract parameter name from a single segment\ntype ExtractParam<T extends string> = T extends `:${infer Name}`\n ? Name\n : T extends `**:${infer Name}`\n ? Name\n : T extends \"**\"\n ? \"**\"\n : never;\n\n// Helper type to extract all parameter names from path segments\ntype ExtractParamsFromSegments<T extends readonly string[]> = T extends readonly [\n infer First,\n ...infer Rest,\n]\n ? First extends string\n ? Rest extends readonly string[]\n ? ExtractParam<First> | ExtractParamsFromSegments<Rest>\n : ExtractParam<First>\n : never\n : never;\n\n/**\n * Type helper to extract path parameters from a const string path\n *\n * Supports:\n * - Regular paths: \"/path\" -> never\n * - Named parameters: \"/path/:name\" -> \"name\"\n * - Wildcard paths: \"/path/foo/**\" -> \"**\"\n * - Named wildcard paths: \"/path/foo/**:name\" -> \"name\"\n * - String (narrows): string -> never\n */\nexport type ExtractPathParams<T extends string, ValueType = string> =\n ExtractParamsFromSegments<SplitPath<T>> extends never\n ? Record<string, never>\n : Record<ExtractParamsFromSegments<SplitPath<T>>, ValueType>;\n\n/**\n * Same as @see ExtractPathParams, but returns `Record<string, ValueType>` when a string is\n * passed in.\n */\nexport type ExtractPathParamsOrWiden<T extends string, ValueType = string> = string extends T\n ? Record<string, ValueType>\n : ExtractPathParams<T, ValueType>;\n\n// TODO: MaybeExtractPathParamsOrWiden<string> --> undefined, should that be Record<string, string>?\n/**\n * Same as @see ExtractPathParamsOrWiden, but returns `undefined` when no path parameters in the\n * const.\n */\nexport type MaybeExtractPathParamsOrWiden<T extends string, ValueType = string> =\n HasPathParams<T> extends true ? ExtractPathParamsOrWiden<T, ValueType> : undefined;\n\n// Alternative version that returns the parameter names as a union type\nexport type ExtractPathParamNames<T extends string> = ExtractParamsFromSegments<SplitPath<T>>;\n\n// Helper type to extract parameter names as an ordered tuple from path segments\ntype ExtractParamNamesAsTuple<T extends readonly string[]> = T extends readonly [\n infer First,\n ...infer Rest,\n]\n ? First extends string\n ? Rest extends readonly string[]\n ? ExtractParam<First> extends never\n ? ExtractParamNamesAsTuple<Rest>\n : [ExtractParam<First>, ...ExtractParamNamesAsTuple<Rest>]\n : ExtractParam<First> extends never\n ? []\n : [ExtractParam<First>]\n : []\n : [];\n\n// Type to convert ExtractPathParamNames result to a string tuple with the same number of elements\nexport type ExtractPathParamNamesAsTuple<T extends string> = ExtractParamNamesAsTuple<SplitPath<T>>;\n\n// Helper type to create labeled tuple from parameter names\ntype CreateLabeledTuple<T extends readonly string[], ElementType = string> = T extends readonly [\n infer First,\n ...infer Rest,\n]\n ? First extends string\n ? Rest extends readonly string[]\n ? [{ [K in First]: ElementType }[First], ...CreateLabeledTuple<Rest, ElementType>]\n : [{ [K in First]: ElementType }[First]]\n : []\n : [];\n\n// Type to convert path parameters to a labeled tuple\nexport type ExtractPathParamsAsLabeledTuple<\n T extends string,\n ElementType = string,\n> = CreateLabeledTuple<ExtractParamNamesAsTuple<SplitPath<T>>, ElementType>;\n\n// Type to check if a path has parameters\nexport type HasPathParams<T extends string> = ExtractPathParamNames<T> extends never ? false : true;\n\n/**\n * Creates a query parameters type where the specified keys are hints (optional)\n * and additional string keys are also allowed.\n *\n * This allows for flexible query parameter typing where:\n * - All hinted parameters are optional\n * - Additional parameters beyond the hints are allowed\n * - Values can be of any specified type (defaults to string)\n *\n * @example\n * ```ts\n * type MyQuery = QueryParamsHint<\"page\" | \"limit\", string>;\n * // Allows: { page?: string, limit?: string, [key: string]: string }\n *\n * const query1: MyQuery = {}; // Valid - no params required\n * const query2: MyQuery = { page: \"1\" }; // Valid - hinted param\n * const query3: MyQuery = { page: \"1\", sort: \"asc\" }; // Valid - additional param\n * ```\n */\nexport type QueryParamsHint<TQueryParameters extends string, ValueType = string> = Partial<\n Record<TQueryParameters, ValueType>\n> &\n Record<string, ValueType | undefined>;\n\n// Runtime utilities\n\n/**\n * Extract parameter names from a path pattern at runtime.\n * Examples:\n * - \"/users/:id\" => [\"id\"]\n * - \"/files/**\" => [\"**\"]\n * - \"/files/**:rest\" => [\"rest\"]\n */\nexport function extractPathParams<TPath extends string>(\n pathPattern: TPath,\n): ExtractPathParamNames<TPath>[] {\n const segments = pathPattern.split(\"/\").filter((s) => s.length > 0);\n const names: string[] = [];\n\n for (const segment of segments) {\n if (segment.startsWith(\":\")) {\n names.push(segment.slice(1));\n continue;\n }\n\n if (segment === \"**\") {\n names.push(\"**\");\n continue;\n }\n\n if (segment.startsWith(\"**:\")) {\n names.push(segment.slice(3));\n continue;\n }\n }\n\n return names as ExtractPathParamNames<TPath>[];\n}\n\n/**\n * Match an actual path against a path pattern and return extracted params.\n *\n * Notes and limitations:\n * - Named segment \":name\" captures a single path segment.\n * - Wildcard \"**\" or \"**:name\" greedily captures the remainder of the path and\n * should be placed at the end of the pattern.\n * - If the path does not match the pattern, an empty object is returned.\n */\nexport function matchPathParams<TPath extends string>(\n pathPattern: TPath,\n actualPath: string,\n): ExtractPathParams<TPath> {\n const patternSegments = pathPattern.split(\"/\").filter((s) => s.length > 0);\n const actualSegments = actualPath.split(\"/\").filter((s) => s.length > 0);\n\n const params: Record<string, string> = {};\n\n let i = 0;\n let j = 0;\n\n while (i < patternSegments.length && j < actualSegments.length) {\n const patternSegment = patternSegments[i];\n const actualSegment = actualSegments[j];\n\n if (patternSegment.startsWith(\":\")) {\n const name = patternSegment.slice(1);\n params[name] = decodeURIComponent(actualSegment);\n i += 1;\n j += 1;\n continue;\n }\n\n if (patternSegment === \"**\") {\n const remainder = actualSegments.slice(j).join(\"/\");\n params[\"**\"] = remainder ? decodeURIComponent(remainder) : \"\";\n // Wildcard consumes the rest; pattern should end here\n i = patternSegments.length;\n j = actualSegments.length;\n break;\n }\n\n if (patternSegment.startsWith(\"**:\")) {\n const name = patternSegment.slice(3);\n const remainder = actualSegments.slice(j).join(\"/\");\n params[name] = remainder ? decodeURIComponent(remainder) : \"\";\n // Wildcard consumes the rest; pattern should end here\n i = patternSegments.length;\n j = actualSegments.length;\n break;\n }\n\n // Literal segment must match exactly\n if (patternSegment === actualSegment) {\n i += 1;\n j += 1;\n continue;\n }\n\n // Mismatch\n return {} as ExtractPathParams<TPath>;\n }\n\n // If there are remaining pattern segments\n while (i < patternSegments.length) {\n const remaining = patternSegments[i];\n if (remaining === \"**\") {\n params[\"**\"] = \"\";\n i += 1;\n continue;\n }\n if (remaining.startsWith(\":\")) {\n const name = remaining.slice(1);\n params[name] = \"\";\n i += 1;\n continue;\n }\n if (remaining.startsWith(\"**:\")) {\n const name = remaining.slice(3);\n params[name] = \"\";\n i += 1;\n continue;\n }\n // Non-parameter remaining segment without corresponding actual segment → mismatch\n return {} as ExtractPathParams<TPath>;\n }\n\n // If there are remaining actual segments without pattern to match → mismatch\n if (j < actualSegments.length) {\n return {} as ExtractPathParams<TPath>;\n }\n\n return params as ExtractPathParams<TPath>;\n}\n\n/**\n * Build a concrete path by replacing placeholders in a path pattern with values.\n *\n * Supports the same placeholder syntax as the matcher:\n * - Named parameter \":name\" is URL-encoded as a single segment\n * - Anonymous wildcard \"**\" inserts the remainder as-is (slashes preserved)\n * - Named wildcard \"**:name\" inserts the remainder from the named key\n *\n * Examples:\n * - buildPath(\"/users/:id\", { id: \"123\" }) => \"/users/123\"\n * - buildPath(\"/files/**\", { \"**\": \"a/b\" }) => \"/files/a/b\"\n * - buildPath(\"/files/**:rest\", { rest: \"a/b\" }) => \"/files/a/b\"\n */\nexport function buildPath<TPath extends string>(\n pathPattern: TPath,\n params: ExtractPathParams<TPath>,\n): string {\n const patternSegments = pathPattern.split(\"/\");\n\n const builtSegments: string[] = [];\n\n for (const segment of patternSegments) {\n if (segment.length === 0) {\n // Preserve leading/trailing/duplicate slashes\n builtSegments.push(\"\");\n continue;\n }\n\n if (segment.startsWith(\":\")) {\n const name = segment.slice(1);\n const value = (params as Record<string, string | undefined>)[name];\n if (value === undefined) {\n throw new Error(`Missing value for path parameter :${name}`);\n }\n builtSegments.push(encodeURIComponent(value));\n continue;\n }\n\n if (segment === \"**\") {\n const value = (params as Record<string, string | undefined>)[\"**\"];\n if (value === undefined) {\n throw new Error(\"Missing value for path wildcard **\");\n }\n builtSegments.push(value);\n continue;\n }\n\n if (segment.startsWith(\"**:\")) {\n const name = segment.slice(3);\n const value = (params as Record<string, string | undefined>)[name];\n if (value === undefined) {\n throw new Error(`Missing value for path wildcard **:${name}`);\n }\n builtSegments.push(value);\n continue;\n }\n\n // Literal segment\n builtSegments.push(segment);\n }\n\n // Join with '/'. Empty segments preserve leading/trailing slashes\n return builtSegments.join(\"/\");\n}\n","import type { StatusCode } from \"../http/http-status\";\n\nexport type FragnoErrorOptions = {\n cause?: Error | unknown;\n};\n\n/**\n * Base error class for all Fragno client errors.\n */\nexport abstract class FragnoClientError<TCode extends string = string> extends Error {\n readonly #code: TCode;\n\n constructor(message: string, code: TCode, options: FragnoErrorOptions = {}) {\n super(message, { cause: options.cause });\n this.name = \"FragnoClientError\";\n this.#code = code;\n }\n\n get code(): TCode | (string & {}) {\n return this.#code;\n }\n}\n\nexport class FragnoClientFetchError extends FragnoClientError<\n \"NO_BODY\" | \"NETWORK_ERROR\" | \"ABORT_ERROR\"\n> {\n constructor(\n message: string,\n code: \"NO_BODY\" | \"NETWORK_ERROR\" | \"ABORT_ERROR\",\n options: FragnoErrorOptions = {},\n ) {\n super(message, code, options);\n this.name = \"FragnoClientFetchError\";\n }\n\n static fromUnknownFetchError(error: unknown): FragnoClientFetchError {\n if (!(error instanceof Error)) {\n return new FragnoClientFetchNetworkError(\"Network request failed\", { cause: error });\n }\n\n if (error.name === \"AbortError\") {\n return new FragnoClientFetchAbortError(\"Request was aborted\", { cause: error });\n }\n\n return new FragnoClientFetchNetworkError(\"Network request failed\", { cause: error });\n }\n}\n\n/**\n * Error thrown when a network request fails (e.g., no internet connection, DNS failure).\n */\nexport class FragnoClientFetchNetworkError extends FragnoClientFetchError {\n constructor(message: string = \"Network request failed\", options: FragnoErrorOptions = {}) {\n super(message, \"NETWORK_ERROR\", options);\n this.name = \"FragnoClientFetchNetworkError\";\n }\n}\n\n/**\n * Error thrown when a request is aborted (e.g., user cancels request, timeout).\n */\nexport class FragnoClientFetchAbortError extends FragnoClientFetchError {\n constructor(message: string = \"Request was aborted\", options: FragnoErrorOptions = {}) {\n super(message, \"ABORT_ERROR\", options);\n this.name = \"FragnoClientFetchAbortError\";\n }\n}\n\n/**\n * Error thrown when the API result is unexpected, e.g. no json is returned.\n */\nexport class FragnoClientUnknownApiError extends FragnoClientError<\"UNKNOWN_API_ERROR\"> {\n readonly #status: StatusCode;\n\n constructor(\n message: string = \"Unknown API error\",\n status: StatusCode,\n options: FragnoErrorOptions = {},\n ) {\n super(message, \"UNKNOWN_API_ERROR\", options);\n this.name = \"FragnoClientUnknownApiError\";\n this.#status = status;\n }\n\n get status(): StatusCode {\n return this.#status;\n }\n}\n\nexport class FragnoClientApiError<\n TErrorCode extends string = string,\n> extends FragnoClientError<TErrorCode> {\n readonly #status: StatusCode;\n\n constructor(\n { message, code }: { message: string; code: TErrorCode },\n status: StatusCode,\n options: FragnoErrorOptions = {},\n ) {\n super(message, code, options);\n this.name = \"FragnoClientApiError\";\n this.#status = status;\n }\n\n get status(): StatusCode {\n return this.#status;\n }\n\n /**\n * The error code returned by the API.\n *\n * The type is `TErrorCode` (the set of known error codes for this route), but may also be a string\n * for forward compatibility with future error codes.\n */\n get code(): TErrorCode | (string & {}) {\n return super.code as TErrorCode | (string & {});\n }\n\n static async fromResponse<TErrorCode extends string = string>(\n response: Response,\n ): Promise<FragnoClientApiError<TErrorCode> | FragnoClientUnknownApiError> {\n const unknown = await response.json();\n const status = response.status as StatusCode;\n\n if (!(\"message\" in unknown || \"code\" in unknown)) {\n return new FragnoClientUnknownApiError(\"Unknown API error\", status);\n }\n\n if (!(typeof unknown.message === \"string\" && typeof unknown.code === \"string\")) {\n return new FragnoClientUnknownApiError(\"Unknown API error\", status);\n }\n\n return new FragnoClientApiError(\n {\n message: unknown.message,\n code: unknown.code as TErrorCode,\n },\n status,\n );\n }\n}\n","/**\n * Represents a parsed content-type header\n */\nexport interface ParsedContentType {\n /** The main type (e.g., \"application\", \"text\", \"image\") */\n type: string;\n /** The subtype (e.g., \"json\", \"html\", \"png\") */\n subtype: string;\n /** The full media type (e.g., \"application/json\") */\n mediaType: string;\n /** Additional parameters like charset, boundary, etc. */\n parameters: Record<string, string>;\n}\n\n/**\n * Parses a content-type header string into its components\n *\n * @param contentType - The content-type header value to parse\n * @returns A ParsedContentType object or null if the input is invalid\n *\n * @example\n * ```ts\n * const { type, subtype, mediaType, parameters }\n * = parseContentType(\"application/json; charset=utf-8\");\n * console.assert(type === \"application\");\n * console.assert(subtype === \"json\");\n * console.assert(mediaType === \"application/json\");\n * console.assert(parameters[\"charset\"] === \"utf-8\");\n */\nexport function parseContentType(contentType: string | null | undefined): ParsedContentType | null {\n if (!contentType || typeof contentType !== \"string\") {\n return null;\n }\n\n const trimmed = contentType.trim();\n if (!trimmed) {\n return null;\n }\n\n const parts = trimmed.split(\";\").map((part) => part.trim());\n const mediaType = parts[0];\n\n if (!mediaType) {\n return null;\n }\n\n const typeParts = mediaType.split(\"/\");\n if (typeParts.length !== 2) {\n return null;\n }\n\n const [type, subtype] = typeParts.map((part) => part.trim().toLowerCase());\n\n if (!type || !subtype) {\n return null;\n }\n\n const parameters: Record<string, string> = {};\n\n for (let i = 1; i < parts.length; i++) {\n const param = parts[i];\n const equalIndex = param.indexOf(\"=\");\n\n if (equalIndex > 0) {\n const key = param.slice(0, equalIndex).trim().toLowerCase();\n let value = param.slice(equalIndex + 1).trim();\n\n if (value.startsWith('\"') && value.endsWith('\"')) {\n value = value.slice(1, -1);\n }\n\n if (key) {\n parameters[key] = value;\n }\n }\n }\n\n return {\n type,\n subtype,\n mediaType: `${type}/${subtype}`,\n parameters,\n };\n}\n","import type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport {\n FragnoClientError,\n FragnoClientFetchError,\n FragnoClientFetchAbortError,\n FragnoClientUnknownApiError,\n} from \"../client-error\";\n\n/**\n * Creates a promise that rejects when the abort signal is triggered\n */\nfunction createAbortPromise(abortSignal: AbortSignal): Promise<never> {\n return new Promise<never>((_, reject) => {\n const abortHandler = () => {\n reject(new FragnoClientFetchAbortError(\"Operation was aborted\"));\n };\n\n if (abortSignal.aborted) {\n abortHandler();\n } else {\n abortSignal.addEventListener(\"abort\", abortHandler, { once: true });\n }\n });\n}\n\n/**\n * Result of NDJSON streaming that includes the first item and a promise for the streaming continuation\n */\nexport interface NdjsonStreamingResult<T> {\n firstItem: T;\n streamingPromise: Promise<T[]>;\n}\n\nexport interface NdjsonStreamingStore<\n TOutputSchema extends StandardSchemaV1,\n TErrorCode extends string,\n> {\n setData(value: StandardSchemaV1.InferOutput<TOutputSchema>): void;\n setError(value: FragnoClientError<TErrorCode>): void;\n}\n\n/**\n * Handles NDJSON streaming responses by returning the first item from the fetcher\n * and then continuing to stream updates via the store's mutate method.\n *\n * This makes it so that we can wait until the first chunk before updating the store, if we did\n * not do this, `loading` would briefly be false before the first item would be populated in the\n * result.\n *\n * @param response - The fetch Response object containing the NDJSON stream\n * @param store - The fetcher store to update with streaming data\n * @param abortSignal - Optional AbortSignal to cancel the streaming operation\n * @returns A promise that resolves to an object containing the first item and a streaming promise\n */\nexport async function handleNdjsonStreamingFirstItem<\n TOutputSchema extends StandardSchemaV1,\n TErrorCode extends string,\n>(\n response: Response,\n store?: NdjsonStreamingStore<TOutputSchema, TErrorCode>,\n options: { abortSignal?: AbortSignal } = {},\n): Promise<NdjsonStreamingResult<StandardSchemaV1.InferOutput<TOutputSchema>>> {\n if (!response.body) {\n throw new FragnoClientFetchError(\"Streaming response has no body\", \"NO_BODY\");\n }\n\n const { abortSignal } = options;\n\n if (abortSignal?.aborted) {\n throw new FragnoClientFetchAbortError(\"Operation was aborted\");\n }\n\n const decoder = new TextDecoder();\n const reader = response.body.getReader();\n let buffer = \"\";\n let firstItem: StandardSchemaV1.InferOutput<TOutputSchema> | null = null;\n const items: StandardSchemaV1.InferOutput<TOutputSchema>[] = [];\n\n try {\n // Read until we get the first item\n while (firstItem === null) {\n // Check for abort signal before each read\n if (abortSignal?.aborted) {\n reader.releaseLock();\n throw new FragnoClientFetchAbortError(\"Operation was aborted\");\n }\n\n const { done, value } = await (abortSignal\n ? Promise.race([reader.read(), createAbortPromise(abortSignal)])\n : reader.read());\n\n if (done) {\n break;\n }\n\n // Decode the chunk and add to buffer\n buffer += decoder.decode(value, { stream: true });\n\n // Process complete lines\n const lines = buffer.split(\"\\n\");\n buffer = lines.pop() || \"\"; // Keep incomplete line in buffer\n\n for (const line of lines) {\n if (!line.trim()) {\n continue;\n }\n\n try {\n const jsonObject = JSON.parse(line) as StandardSchemaV1.InferOutput<TOutputSchema>;\n items.push(jsonObject);\n\n if (firstItem === null) {\n firstItem = jsonObject;\n // We don't call store.setKey here for the first item\n // The caller will handle it via the return value\n\n // Start background streaming for remaining items and return the promise\n const streamingPromise = continueStreaming(\n reader,\n decoder,\n buffer,\n items,\n store,\n abortSignal,\n );\n return {\n firstItem,\n streamingPromise,\n };\n }\n } catch (parseError) {\n throw new FragnoClientUnknownApiError(\"Failed to parse NDJSON line\", 500, {\n cause: parseError,\n });\n }\n }\n }\n\n // If we get here and haven't returned a first item, the stream was empty\n if (firstItem === null) {\n reader.releaseLock();\n throw new FragnoClientUnknownApiError(\"NDJSON stream contained no valid items\", 500);\n }\n\n // This should never be reached, but TypeScript needs it\n reader.releaseLock();\n throw new FragnoClientFetchError(\"Unexpected end of stream processing\", \"NO_BODY\");\n } catch (error) {\n // Handle errors during streaming\n if (error instanceof FragnoClientError) {\n store?.setError(error);\n throw error;\n } else {\n // TODO: Not sure about the typing here\n const clientError = new FragnoClientUnknownApiError(\"Unknown streaming error\", 500, {\n cause: error,\n }) as unknown as FragnoClientError<TErrorCode>;\n store?.setError(clientError);\n throw clientError;\n }\n }\n}\n\n/**\n * Continues streaming the remaining items in the background\n */\n// FIXME: Shitty code\nasync function continueStreaming<TOutputSchema extends StandardSchemaV1, TErrorCode extends string>(\n reader: ReadableStreamDefaultReader<Uint8Array>,\n decoder: TextDecoder,\n initialBuffer: string,\n items: StandardSchemaV1.InferOutput<TOutputSchema>[],\n store?: NdjsonStreamingStore<TOutputSchema, TErrorCode>,\n abortSignal?: AbortSignal,\n): Promise<StandardSchemaV1.InferOutput<TOutputSchema>[]> {\n let buffer = initialBuffer;\n\n try {\n while (true) {\n // Check for abort signal before each read\n if (abortSignal?.aborted) {\n throw new FragnoClientFetchAbortError(\"Operation was aborted\");\n }\n\n const { done, value } = await (abortSignal\n ? Promise.race([reader.read(), createAbortPromise(abortSignal)])\n : reader.read());\n\n if (done) {\n // Process any remaining buffer content\n if (buffer.trim()) {\n const lines = buffer.split(\"\\n\");\n for (const line of lines) {\n if (!line.trim()) {\n continue;\n }\n\n try {\n const jsonObject = JSON.parse(line) as StandardSchemaV1.InferOutput<TOutputSchema>;\n items.push(jsonObject);\n store?.setData([...items]);\n } catch (parseError) {\n throw new FragnoClientUnknownApiError(\"Failed to parse NDJSON line\", 400, {\n cause: parseError,\n });\n }\n }\n }\n break;\n }\n\n // Decode the chunk and add to buffer\n buffer += decoder.decode(value, { stream: true });\n\n // Process complete lines\n const lines = buffer.split(\"\\n\");\n buffer = lines.pop() || \"\"; // Keep incomplete line in buffer\n\n for (const line of lines) {\n if (!line.trim()) {\n continue;\n }\n\n try {\n const jsonObject = JSON.parse(line) as StandardSchemaV1.InferOutput<TOutputSchema>;\n items.push(jsonObject);\n store?.setData([...items]);\n } catch (parseError) {\n throw new FragnoClientUnknownApiError(\"Failed to parse NDJSON line\", 400, {\n cause: parseError,\n });\n }\n }\n }\n } catch (error) {\n if (error instanceof FragnoClientError) {\n store?.setError(error);\n } else {\n const clientError = new FragnoClientUnknownApiError(\"Unknown streaming error\", 400, {\n cause: error,\n }) as unknown as FragnoClientError<TErrorCode>;\n store?.setError(clientError);\n throw clientError;\n }\n\n throw error;\n } finally {\n reader.releaseLock();\n }\n\n return items;\n}\n","import type { ReadableAtom } from \"nanostores\";\n\ntype MaybeAtom<T> = T | ReadableAtom<T>;\n\n/**\n * Normalizes a value that could be a plain value, an Atom, or a Vue Ref to a plain value.\n */\nexport function unwrapAtom<T>(value: MaybeAtom<T>): T {\n // Check if it's an Atom (has .get method)\n if (value && typeof value === \"object\" && \"get\" in value && typeof value.get === \"function\") {\n return value.get();\n }\n\n return value as T;\n}\n\n/**\n * Normalizes an object where values can be plain values, Atoms, or Vue Refs.\n * Returns a new object with all values normalized to plain values.\n */\nexport function unwrapObject<T>(\n params: Record<string, MaybeAtom<T>> | undefined,\n): Record<string, T> | undefined {\n if (!params) {\n return undefined;\n }\n\n return Object.fromEntries(Object.entries(params).map(([key, value]) => [key, unwrapAtom(value)]));\n}\n\nexport function isReadableAtom(value: unknown): value is ReadableAtom<unknown> {\n if (!value) {\n return false;\n }\n\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n\n if (!(\"get\" in value) || typeof value.get !== \"function\") {\n return false;\n }\n\n if (!(\"lc\" in value) || typeof value.lc !== \"number\") {\n return false;\n }\n\n if (!(\"notify\" in value) || typeof value.notify !== \"function\") {\n return false;\n }\n\n if (!(\"off\" in value) || typeof value.off !== \"function\") {\n return false;\n }\n\n if (!(\"subscribe\" in value) || typeof value.subscribe !== \"function\") {\n return false;\n }\n\n if (!(\"value\" in value)) {\n return false;\n }\n\n return true;\n}\n","import type { FetcherConfig } from \"../../api/fragment-instantiation\";\n\n/**\n * Merge two fetcher configurations, with user config taking precedence.\n * If user provides a custom function, it takes full precedence.\n * Otherwise, deep merge RequestInit options.\n */\nexport function mergeFetcherConfigs(\n authorConfig?: FetcherConfig,\n userConfig?: FetcherConfig,\n): FetcherConfig | undefined {\n // If user provides custom function, it takes full precedence\n if (userConfig?.type === \"function\") {\n return userConfig;\n }\n\n if (!userConfig && authorConfig?.type === \"function\") {\n return authorConfig;\n }\n\n // Deep merge RequestInit options\n const authorOpts = authorConfig?.type === \"options\" ? authorConfig.options : {};\n const userOpts = userConfig?.type === \"options\" ? userConfig.options : {};\n\n // If both are empty, return undefined\n if (Object.keys(authorOpts).length === 0 && Object.keys(userOpts).length === 0) {\n return undefined;\n }\n\n return {\n type: \"options\",\n options: {\n ...authorOpts,\n ...userOpts,\n headers: mergeHeaders(authorOpts.headers, userOpts.headers),\n },\n };\n}\n\n/**\n * Merge headers from author and user configs.\n * User headers override author headers.\n */\nfunction mergeHeaders(author?: HeadersInit, user?: HeadersInit): HeadersInit | undefined {\n if (!author && !user) {\n return undefined;\n }\n\n // Convert to Headers objects and merge\n const merged = new Headers(author);\n new Headers(user).forEach((value, key) => merged.set(key, value));\n\n // If no headers after merge, return undefined\n if (merged.keys().next().done) {\n return undefined;\n }\n\n return merged;\n}\n","import { nanoquery, type FetcherStore, type MutatorStore } from \"@nanostores/query\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport { computed, task, type ReadableAtom, type Store } from \"nanostores\";\nimport type { FragnoRouteConfig, HTTPMethod, NonGetHTTPMethod } from \"../api/api\";\nimport {\n buildPath,\n extractPathParams,\n type ExtractPathParams,\n type ExtractPathParamsOrWiden,\n type MaybeExtractPathParamsOrWiden,\n} from \"../api/internal/path\";\nimport { getMountRoute } from \"../api/internal/route\";\nimport { RequestInputContext } from \"../api/request-input-context\";\nimport { RequestOutputContext } from \"../api/request-output-context\";\nimport type {\n FetcherConfig,\n FragnoFragmentSharedConfig,\n FragnoPublicClientConfig,\n} from \"../api/fragment-instantiation\";\nimport { FragnoClientApiError, FragnoClientError, FragnoClientFetchError } from \"./client-error\";\nimport type { InferOr } from \"../util/types-util\";\nimport { parseContentType } from \"../util/content-type\";\nimport {\n handleNdjsonStreamingFirstItem,\n type NdjsonStreamingStore,\n} from \"./internal/ndjson-streaming\";\nimport { addStore, getInitialData, SSR_ENABLED } from \"../util/ssr\";\nimport { unwrapObject } from \"../util/nanostores\";\nimport type { FragmentDefinition } from \"../api/fragment-builder\";\nimport {\n type AnyRouteOrFactory,\n type FlattenRouteFactories,\n resolveRouteFactories,\n} from \"../api/route\";\nimport { mergeFetcherConfigs } from \"./internal/fetcher-merge\";\n\n/**\n * Symbols used to identify hook types\n */\nconst GET_HOOK_SYMBOL = Symbol(\"fragno-get-hook\");\nconst MUTATOR_HOOK_SYMBOL = Symbol(\"fragno-mutator-hook\");\nconst STORE_SYMBOL = Symbol(\"fragno-store\");\n\n/**\n * Extract only GET routes from a library config's routes array\n */\nexport type ExtractGetRoutes<\n T extends readonly FragnoRouteConfig<\n HTTPMethod,\n string,\n StandardSchemaV1 | undefined,\n StandardSchemaV1 | undefined,\n string,\n string\n >[],\n> = {\n [K in keyof T]: T[K] extends FragnoRouteConfig<\n infer Method,\n infer Path,\n infer Input,\n infer Output,\n infer ErrorCode,\n infer QueryParams\n >\n ? Method extends \"GET\"\n ? FragnoRouteConfig<Method, Path, Input, Output, ErrorCode, QueryParams>\n : never\n : never;\n}[number][];\n\n/**\n * Extract the path from a route configuration for a given method\n */\nexport type ExtractRoutePath<\n T extends readonly FragnoRouteConfig<\n HTTPMethod,\n string,\n StandardSchemaV1 | undefined,\n StandardSchemaV1 | undefined,\n string,\n string\n >[],\n TExpectedMethod extends HTTPMethod = HTTPMethod,\n> = {\n [K in keyof T]: T[K] extends FragnoRouteConfig<\n infer Method,\n infer Path,\n StandardSchemaV1 | undefined,\n StandardSchemaV1 | undefined,\n string,\n string\n >\n ? Method extends TExpectedMethod\n ? Path\n : never\n : never;\n}[number];\n\nexport type ExtractGetRoutePaths<\n T extends readonly FragnoRouteConfig<\n HTTPMethod,\n string,\n StandardSchemaV1 | undefined,\n StandardSchemaV1 | undefined,\n string,\n string\n >[],\n> = ExtractRoutePath<T, \"GET\">;\n\nexport type ExtractNonGetRoutePaths<\n T extends readonly FragnoRouteConfig<\n HTTPMethod,\n string,\n StandardSchemaV1 | undefined,\n StandardSchemaV1 | undefined,\n string,\n string\n >[],\n> = ExtractRoutePath<T, NonGetHTTPMethod>;\n\n/**\n * Extract the route configuration type(s) for a given path from a routes array.\n * Optionally narrow by HTTP method via the third type parameter.\n *\n * Defaults to extracting all methods for the matching path, producing a union\n * if multiple methods exist for the same path.\n */\nexport type ExtractRouteByPath<\n TRoutes extends readonly FragnoRouteConfig<\n HTTPMethod,\n string,\n StandardSchemaV1 | undefined,\n StandardSchemaV1 | undefined,\n string,\n string\n >[],\n TPath extends string,\n TMethod extends HTTPMethod = HTTPMethod,\n> = {\n [K in keyof TRoutes]: TRoutes[K] extends FragnoRouteConfig<\n infer M,\n TPath,\n infer Input,\n infer Output,\n infer ErrorCode,\n infer QueryParams\n >\n ? M extends TMethod\n ? FragnoRouteConfig<M, TPath, Input, Output, ErrorCode, QueryParams>\n : never\n : never;\n}[number];\n\n/**\n * Extract the output schema type for a specific route path from a routes array\n */\nexport type ExtractOutputSchemaForPath<\n TRoutes extends readonly FragnoRouteConfig<\n HTTPMethod,\n string,\n StandardSchemaV1 | undefined,\n StandardSchemaV1 | undefined\n >[],\n TPath extends string,\n> = {\n [K in keyof TRoutes]: TRoutes[K] extends FragnoRouteConfig<\n infer Method,\n TPath,\n StandardSchemaV1 | undefined,\n infer Output\n >\n ? Method extends \"GET\"\n ? Output\n : never\n : never;\n}[number];\n\n/**\n * Check if a path exists as a GET route in the routes array\n */\nexport type IsValidGetRoutePath<\n TRoutes extends readonly FragnoRouteConfig<\n HTTPMethod,\n string,\n StandardSchemaV1 | undefined,\n StandardSchemaV1 | undefined,\n string,\n string\n >[],\n TPath extends string,\n> = TPath extends ExtractGetRoutePaths<TRoutes> ? true : false;\n\n/**\n * Utility type to ensure only valid GET route paths can be used\n */\nexport type ValidateGetRoutePath<\n TRoutes extends readonly FragnoRouteConfig<\n HTTPMethod,\n string,\n StandardSchemaV1 | undefined,\n StandardSchemaV1 | undefined,\n string,\n string\n >[],\n TPath extends string,\n> =\n TPath extends ExtractGetRoutePaths<TRoutes>\n ? TPath\n : `Error: Path '${TPath}' is not a valid GET route. Available GET routes: ${ExtractGetRoutePaths<TRoutes>}`;\n\n/**\n * Helper type to check if a routes array has any GET routes\n */\nexport type HasGetRoutes<\n T extends readonly FragnoRouteConfig<\n HTTPMethod,\n string,\n StandardSchemaV1 | undefined,\n StandardSchemaV1 | undefined,\n string,\n string\n >[],\n> = ExtractGetRoutePaths<T> extends never ? false : true;\n\nexport type ObjectContainingStoreField<T extends object> = T extends Store\n ? T\n : {\n [K in keyof T]: T[K] extends Store ? { [P in K]: T[P] } & Partial<Omit<T, K>> : never;\n }[keyof T] extends never\n ? never\n : T;\n\nexport type FragnoStoreData<T extends object> = {\n obj: T;\n [STORE_SYMBOL]: true;\n};\n\nexport type FragnoClientHookData<\n TMethod extends HTTPMethod,\n TPath extends string,\n TOutputSchema extends StandardSchemaV1,\n TErrorCode extends string,\n TQueryParameters extends string,\n> = {\n route: FragnoRouteConfig<\n TMethod,\n TPath,\n StandardSchemaV1 | undefined,\n TOutputSchema,\n TErrorCode,\n TQueryParameters\n >;\n query(args?: {\n path?: MaybeExtractPathParamsOrWiden<TPath, string>;\n query?: Record<TQueryParameters, string | undefined>;\n }): Promise<StandardSchemaV1.InferOutput<TOutputSchema>>;\n store(args?: {\n path?: MaybeExtractPathParamsOrWiden<TPath, string | ReadableAtom<string>>;\n query?: Record<TQueryParameters, string | undefined | ReadableAtom<string | undefined>>;\n }): FetcherStore<StandardSchemaV1.InferOutput<TOutputSchema>, FragnoClientError<TErrorCode>>;\n [GET_HOOK_SYMBOL]: true;\n} & {\n // Phantom field that preserves the specific TOutputSchema type parameter\n // in the structural type. This makes the type covariant, allowing more\n // specific schema types (like z.ZodString) to be assigned to variables\n // typed with more general schema types (like StandardSchemaV1<any, any>)\n readonly _outputSchema?: TOutputSchema;\n};\n\nexport type FragnoClientMutatorData<\n TMethod extends NonGetHTTPMethod,\n TPath extends string,\n TInputSchema extends StandardSchemaV1 | undefined,\n TOutputSchema extends StandardSchemaV1 | undefined,\n TErrorCode extends string,\n TQueryParameters extends string,\n> = {\n route: FragnoRouteConfig<\n TMethod,\n TPath,\n TInputSchema,\n TOutputSchema,\n TErrorCode,\n TQueryParameters\n >;\n\n mutateQuery(args?: {\n body?: InferOr<TInputSchema, undefined>;\n path?: MaybeExtractPathParamsOrWiden<TPath, string>;\n query?: Record<TQueryParameters, string | undefined>;\n }): Promise<InferOr<TOutputSchema, undefined>>;\n\n mutatorStore: MutatorStore<\n {\n body?: InferOr<TInputSchema, undefined>;\n path?: MaybeExtractPathParamsOrWiden<TPath, string | ReadableAtom<string>>;\n query?: Record<TQueryParameters, string | undefined | ReadableAtom<string | undefined>>;\n },\n InferOr<TOutputSchema, undefined>,\n FragnoClientError<TErrorCode>\n >;\n [MUTATOR_HOOK_SYMBOL]: true;\n} & {\n readonly _inputSchema?: TInputSchema;\n readonly _outputSchema?: TOutputSchema;\n};\n\nexport function buildUrl<TPath extends string>(\n config: {\n baseUrl?: string;\n mountRoute: string;\n path: TPath;\n },\n params: {\n pathParams?: Record<string, string | ReadableAtom<string>>;\n queryParams?: Record<string, string | undefined | ReadableAtom<string | undefined>>;\n },\n): string {\n const { baseUrl = \"\", mountRoute, path } = config;\n const { pathParams, queryParams } = params ?? {};\n\n const normalizedPathParams = unwrapObject(pathParams) as ExtractPathParams<TPath, string>;\n const normalizedQueryParams = unwrapObject(queryParams) ?? {};\n\n // Filter out undefined values to prevent URLSearchParams from converting them to string \"undefined\"\n const filteredQueryParams = Object.fromEntries(\n Object.entries(normalizedQueryParams).filter(([_, value]) => value !== undefined),\n ) as Record<string, string>;\n\n const searchParams = new URLSearchParams(filteredQueryParams);\n const builtPath = buildPath(path, normalizedPathParams ?? {});\n const search = searchParams.toString() ? `?${searchParams.toString()}` : \"\";\n return `${baseUrl}${mountRoute}${builtPath}${search}`;\n}\n\n/**\n * This method returns an array, which can be passed directly to nanostores.\n *\n * The returned array is always: path, pathParams (In order they appear in the path), queryParams (In alphabetical order)\n * Missing pathParams are replaced with \"<missing>\".\n * Atoms with undefined values are wrapped in computed atoms that map undefined to \"\" to avoid nanoquery treating the key as incomplete.\n * @param path\n * @param params\n * @returns\n */\nexport function getCacheKey<TMethod extends HTTPMethod, TPath extends string>(\n method: TMethod,\n path: TPath,\n params?: {\n pathParams?: Record<string, string | ReadableAtom<string>>;\n queryParams?: Record<string, string | undefined | ReadableAtom<string | undefined>>;\n },\n): (string | ReadableAtom<string>)[] {\n if (!params) {\n return [method, path];\n }\n\n const { pathParams, queryParams } = params;\n\n const pathParamNames = extractPathParams(path);\n const pathParamValues = pathParamNames.map((name) => pathParams?.[name] ?? \"<missing>\");\n\n const queryParamValues = queryParams\n ? Object.keys(queryParams)\n .sort()\n .map((key) => {\n const value = queryParams[key];\n // If it's an atom, wrap it to convert undefined to \"\"\n if (value && typeof value === \"object\" && \"get\" in value) {\n return computed(value as ReadableAtom<string | undefined>, (v) => v ?? \"\");\n }\n // Plain string value (or undefined)\n return value ?? \"\";\n })\n : [];\n\n return [method, path, ...pathParamValues, ...queryParamValues];\n}\n\nfunction isStreamingResponse(response: Response): false | \"ndjson\" | \"octet-stream\" {\n const contentType = parseContentType(response.headers.get(\"content-type\"));\n\n if (!contentType) {\n // Always assume 'normal' JSON by default.\n return false;\n }\n\n const isChunked = response.headers.get(\"transfer-encoding\") === \"chunked\";\n\n if (!isChunked) {\n return false;\n }\n\n if (contentType.subtype === \"octet-stream\") {\n // TODO(Wilco): This is not actually supported properly\n return \"octet-stream\";\n }\n\n if (contentType.subtype === \"x-ndjson\") {\n return \"ndjson\";\n }\n\n return false;\n}\n\n// Type guard to check if a hook is a GET hook\nexport function isGetHook<\n TPath extends string,\n TOutputSchema extends StandardSchemaV1,\n TErrorCode extends string,\n TQueryParameters extends string,\n>(\n hook: unknown,\n): hook is FragnoClientHookData<\"GET\", TPath, TOutputSchema, TErrorCode, TQueryParameters> {\n return (\n typeof hook === \"object\" &&\n hook !== null &&\n GET_HOOK_SYMBOL in hook &&\n hook[GET_HOOK_SYMBOL] === true\n );\n}\n\n// Type guard to check if a hook is a mutator\nexport function isMutatorHook<\n TMethod extends NonGetHTTPMethod,\n TPath extends string,\n TInputSchema extends StandardSchemaV1 | undefined,\n TOutputSchema extends StandardSchemaV1 | undefined,\n TErrorCode extends string,\n TQueryParameters extends string,\n>(\n hook: unknown,\n): hook is FragnoClientMutatorData<\n TMethod,\n TPath,\n TInputSchema,\n TOutputSchema,\n TErrorCode,\n TQueryParameters\n> {\n return (\n typeof hook === \"object\" &&\n hook !== null &&\n MUTATOR_HOOK_SYMBOL in hook &&\n hook[MUTATOR_HOOK_SYMBOL] === true\n );\n}\n\nexport function isStore<TStore extends Store>(obj: unknown): obj is FragnoStoreData<TStore> {\n return (\n typeof obj === \"object\" && obj !== null && STORE_SYMBOL in obj && obj[STORE_SYMBOL] === true\n );\n}\n\ntype OnErrorRetryFn = (opts: {\n error: unknown;\n key: string;\n retryCount: number;\n}) => number | undefined;\n\nexport type CreateHookOptions = {\n /**\n * A function that will be called when an error occurs. Implements an exponential backoff strategy\n * when left undefined. When null, retries will be disabled. The number returned (> 0) by the\n * callback will determine in how many ms to retry next.\n */\n onErrorRetry?: OnErrorRetryFn | null;\n};\n\ntype OnInvalidateFn<TPath extends string> = (\n invalidate: <TInnerPath extends string>(\n method: HTTPMethod,\n path: TInnerPath,\n params: {\n pathParams?: MaybeExtractPathParamsOrWiden<TInnerPath, string>;\n queryParams?: Record<string, string>;\n },\n ) => void,\n params: {\n pathParams: MaybeExtractPathParamsOrWiden<TPath, string>;\n queryParams?: Record<string, string>;\n },\n) => void;\n\nexport type CacheLine = {\n data: unknown;\n error: unknown;\n retryCount: number;\n created: number;\n expires: number;\n};\n\nexport class ClientBuilder<\n TRoutes extends readonly FragnoRouteConfig<\n HTTPMethod,\n string,\n StandardSchemaV1 | undefined,\n StandardSchemaV1 | undefined,\n string,\n string\n >[],\n TFragmentConfig extends FragnoFragmentSharedConfig<TRoutes>,\n> {\n #publicConfig: FragnoPublicClientConfig;\n #fragmentConfig: TFragmentConfig;\n #fetcherConfig?: FetcherConfig;\n\n #cache = new Map<string, CacheLine>();\n\n #createFetcherStore;\n #createMutatorStore;\n #invalidateKeys;\n\n constructor(publicConfig: FragnoPublicClientConfig, fragmentConfig: TFragmentConfig) {\n this.#publicConfig = publicConfig;\n this.#fragmentConfig = fragmentConfig;\n this.#fetcherConfig = publicConfig.fetcherConfig;\n\n const [createFetcherStore, createMutatorStore, { invalidateKeys }] = nanoquery({\n cache: this.#cache,\n });\n this.#createFetcherStore = createFetcherStore;\n this.#createMutatorStore = createMutatorStore;\n this.#invalidateKeys = invalidateKeys;\n }\n\n get cacheEntries(): Readonly<Record<string, CacheLine>> {\n return Object.fromEntries(this.#cache.entries());\n }\n\n createStore<const T extends object>(obj: T): FragnoStoreData<T> {\n return { obj: obj, [STORE_SYMBOL]: true };\n }\n\n /**\n * Build a URL for a custom backend call using the configured baseUrl and mountRoute.\n * Useful for fragment authors who need to make custom fetch calls.\n */\n buildUrl<TPath extends string>(\n path: TPath,\n params?: {\n path?: MaybeExtractPathParamsOrWiden<TPath, string>;\n query?: Record<string, string>;\n },\n ): string {\n const baseUrl = this.#publicConfig.baseUrl ?? \"\";\n const mountRoute = getMountRoute(this.#fragmentConfig);\n\n return buildUrl(\n { baseUrl, mountRoute, path },\n { pathParams: params?.path, queryParams: params?.query },\n );\n }\n\n /**\n * Get the configured fetcher function for custom backend calls.\n * Returns fetch with merged options applied.\n */\n getFetcher(): {\n fetcher: typeof fetch;\n defaultOptions: RequestInit | undefined;\n } {\n return {\n fetcher: this.#getFetcher(),\n defaultOptions: this.#getFetcherOptions(),\n };\n }\n\n #getFetcher(): typeof fetch {\n if (this.#fetcherConfig?.type === \"function\") {\n return this.#fetcherConfig.fetcher;\n }\n return fetch;\n }\n\n #getFetcherOptions(): RequestInit | undefined {\n if (this.#fetcherConfig?.type === \"options\") {\n return this.#fetcherConfig.options;\n }\n return undefined;\n }\n\n createHook<TPath extends ExtractGetRoutePaths<TFragmentConfig[\"routes\"]>>(\n path: ValidateGetRoutePath<TFragmentConfig[\"routes\"], TPath>,\n options?: CreateHookOptions,\n ): FragnoClientHookData<\n \"GET\",\n TPath,\n NonNullable<ExtractRouteByPath<TFragmentConfig[\"routes\"], TPath>[\"outputSchema\"]>,\n NonNullable<ExtractRouteByPath<TFragmentConfig[\"routes\"], TPath>[\"errorCodes\"]>[number],\n NonNullable<ExtractRouteByPath<TFragmentConfig[\"routes\"], TPath>[\"queryParameters\"]>[number]\n > {\n const route = this.#fragmentConfig.routes.find(\n (\n r,\n ): r is FragnoRouteConfig<\n \"GET\",\n TPath,\n StandardSchemaV1 | undefined,\n StandardSchemaV1,\n string,\n string\n > => r.path === path && r.method === \"GET\" && r.outputSchema !== undefined,\n );\n\n if (!route) {\n throw new Error(`Route '${path}' not found or is not a GET route with an output schema.`);\n }\n\n return this.#createRouteQueryHook(route, options);\n }\n\n createMutator<TPath extends ExtractNonGetRoutePaths<TFragmentConfig[\"routes\"]>>(\n method: NonGetHTTPMethod,\n path: TPath,\n onInvalidate?: OnInvalidateFn<TPath>,\n ): FragnoClientMutatorData<\n NonGetHTTPMethod, // TODO: This can be any Method, but should be related to TPath\n TPath,\n ExtractRouteByPath<TFragmentConfig[\"routes\"], TPath>[\"inputSchema\"],\n ExtractRouteByPath<TFragmentConfig[\"routes\"], TPath>[\"outputSchema\"],\n NonNullable<ExtractRouteByPath<TFragmentConfig[\"routes\"], TPath>[\"errorCodes\"]>[number],\n NonNullable<ExtractRouteByPath<TFragmentConfig[\"routes\"], TPath>[\"queryParameters\"]>[number]\n > {\n type TRoute = ExtractRouteByPath<TFragmentConfig[\"routes\"], TPath>;\n\n const route = this.#fragmentConfig.routes.find(\n (\n r,\n ): r is FragnoRouteConfig<\n NonGetHTTPMethod,\n TPath,\n TRoute[\"inputSchema\"],\n TRoute[\"outputSchema\"],\n string,\n string\n > => r.method !== \"GET\" && r.path === path && r.method === method,\n );\n\n if (!route) {\n throw new Error(\n `Route '${path}' not found or is a GET route with an input and output schema.`,\n );\n }\n\n return this.#createRouteQueryMutator(route, onInvalidate);\n }\n\n #createRouteQueryHook<\n TPath extends string,\n TInputSchema extends StandardSchemaV1 | undefined,\n TOutputSchema extends StandardSchemaV1,\n TErrorCode extends string,\n TQueryParameters extends string,\n >(\n route: FragnoRouteConfig<\n \"GET\",\n TPath,\n TInputSchema,\n TOutputSchema,\n TErrorCode,\n TQueryParameters\n >,\n options: CreateHookOptions = {},\n ): FragnoClientHookData<\"GET\", TPath, TOutputSchema, TErrorCode, TQueryParameters> {\n if (route.method !== \"GET\") {\n throw new Error(\n `Only GET routes are supported for hooks. Route '${route.path}' is a ${route.method} route.`,\n );\n }\n\n if (!route.outputSchema) {\n throw new Error(\n `Output schema is required for GET routes. Route '${route.path}' has no output schema.`,\n );\n }\n\n const baseUrl = this.#publicConfig.baseUrl ?? \"\";\n const mountRoute = getMountRoute(this.#fragmentConfig);\n const fetcher = this.#getFetcher();\n const fetcherOptions = this.#getFetcherOptions();\n\n async function callServerSideHandler(params: {\n pathParams?: Record<string, string | ReadableAtom<string>>;\n queryParams?: Record<string, string | undefined | ReadableAtom<string | undefined>>;\n }): Promise<Response> {\n const { pathParams, queryParams } = params ?? {};\n\n const normalizedPathParams = unwrapObject(pathParams) as ExtractPathParams<TPath, string>;\n const normalizedQueryParams = unwrapObject(queryParams) ?? {};\n\n // Filter out undefined values to prevent URLSearchParams from converting them to string \"undefined\"\n const filteredQueryParams = Object.fromEntries(\n Object.entries(normalizedQueryParams).filter(([_, value]) => value !== undefined),\n ) as Record<string, string>;\n\n const searchParams = new URLSearchParams(filteredQueryParams);\n\n const result = await route.handler(\n RequestInputContext.fromSSRContext({\n method: route.method,\n path: route.path,\n pathParams: normalizedPathParams,\n searchParams,\n }),\n new RequestOutputContext(route.outputSchema),\n );\n\n return result;\n }\n\n async function executeQuery(params?: {\n pathParams?: Record<string, string | ReadableAtom<string>>;\n queryParams?: Record<string, string | undefined | ReadableAtom<string | undefined>>;\n }): Promise<Response> {\n const { pathParams, queryParams } = params ?? {};\n\n if (typeof window === \"undefined\") {\n return task(async () => callServerSideHandler({ pathParams, queryParams }));\n }\n\n const url = buildUrl({ baseUrl, mountRoute, path: route.path }, { pathParams, queryParams });\n\n let response: Response;\n try {\n response = fetcherOptions ? await fetcher(url, fetcherOptions) : await fetcher(url);\n } catch (error) {\n throw FragnoClientFetchError.fromUnknownFetchError(error);\n }\n\n if (!response.ok) {\n throw await FragnoClientApiError.fromResponse<TErrorCode>(response);\n }\n\n return response;\n }\n\n return {\n route,\n store: (args) => {\n const { path, query } = args ?? {};\n\n const key = getCacheKey(route.method, route.path, {\n pathParams: path,\n queryParams: query,\n });\n\n const store = this.#createFetcherStore<\n StandardSchemaV1.InferOutput<TOutputSchema>,\n FragnoClientError<TErrorCode>\n >(key, {\n fetcher: async (): Promise<StandardSchemaV1.InferOutput<TOutputSchema>> => {\n if (SSR_ENABLED) {\n const initialData = getInitialData(\n key.map((d) => (typeof d === \"string\" ? d : d.get())).join(\"\"),\n );\n\n if (initialData) {\n return initialData;\n }\n }\n\n const response = await executeQuery({ pathParams: path, queryParams: query });\n const isStreaming = isStreamingResponse(response);\n\n if (!isStreaming) {\n return response.json() as Promise<StandardSchemaV1.InferOutput<TOutputSchema>>;\n }\n\n if (typeof window === \"undefined\") {\n return [];\n }\n\n if (isStreaming === \"ndjson\") {\n const storeAdapter: NdjsonStreamingStore<TOutputSchema, TErrorCode> = {\n setData: (value) => {\n store.set({\n ...store.get(),\n loading: !(Array.isArray(value) && value.length > 0),\n data: value as InferOr<TOutputSchema, undefined>,\n });\n },\n setError: (value) => {\n store.set({\n ...store.get(),\n error: value,\n });\n },\n };\n\n // Start streaming in background and return first item\n const { firstItem } = await handleNdjsonStreamingFirstItem(response, storeAdapter);\n return [firstItem];\n }\n\n if (isStreaming === \"octet-stream\") {\n // TODO(Wilco): Implement this\n throw new Error(\"Octet-stream streaming is not supported.\");\n }\n\n throw new Error(\"Unreachable\");\n },\n\n onErrorRetry: options?.onErrorRetry,\n dedupeTime: Infinity,\n });\n\n if (typeof window === \"undefined\") {\n addStore(store);\n }\n\n return store;\n },\n query: async (args) => {\n const { path, query } = args ?? {};\n\n const response = await executeQuery({ pathParams: path, queryParams: query });\n\n const isStreaming = isStreamingResponse(response);\n\n if (!isStreaming) {\n return (await response.json()) as StandardSchemaV1.InferOutput<TOutputSchema>;\n }\n\n if (isStreaming === \"ndjson\") {\n const { streamingPromise } = await handleNdjsonStreamingFirstItem(response);\n // Resolves once the stream is done\n return await streamingPromise;\n }\n\n if (isStreaming === \"octet-stream\") {\n // TODO(Wilco): Implement this\n throw new Error(\"Octet-stream streaming is not supported.\");\n }\n\n throw new Error(\"Unreachable\");\n },\n [GET_HOOK_SYMBOL]: true,\n };\n }\n\n #createRouteQueryMutator<\n TPath extends string,\n TInputSchema extends StandardSchemaV1 | undefined,\n TOutputSchema extends StandardSchemaV1 | undefined,\n TErrorCode extends string,\n TQueryParameters extends string,\n >(\n route: FragnoRouteConfig<\n NonGetHTTPMethod,\n TPath,\n TInputSchema,\n TOutputSchema,\n TErrorCode,\n TQueryParameters\n >,\n onInvalidate: OnInvalidateFn<TPath> = (invalidate, params) =>\n invalidate(\"GET\", route.path, params),\n ): FragnoClientMutatorData<\n NonGetHTTPMethod,\n TPath,\n TInputSchema,\n TOutputSchema,\n TErrorCode,\n TQueryParameters\n > {\n const method = route.method;\n\n const baseUrl = this.#publicConfig.baseUrl ?? \"\";\n const mountRoute = getMountRoute(this.#fragmentConfig);\n const fetcher = this.#getFetcher();\n const fetcherOptions = this.#getFetcherOptions();\n\n async function executeMutateQuery({\n body,\n path,\n query,\n }: {\n body?: InferOr<TInputSchema, undefined>;\n path?: ExtractPathParamsOrWiden<TPath, string>;\n query?: Record<string, string>;\n }): Promise<Response> {\n if (typeof window === \"undefined\") {\n return task(async () =>\n route.handler(\n RequestInputContext.fromSSRContext({\n inputSchema: route.inputSchema,\n method,\n path: route.path,\n pathParams: (path ?? {}) as ExtractPathParams<TPath, string>,\n searchParams: new URLSearchParams(query),\n body,\n }),\n new RequestOutputContext(route.outputSchema),\n ),\n );\n }\n\n const url = buildUrl(\n { baseUrl, mountRoute, path: route.path },\n { pathParams: path, queryParams: query },\n );\n\n let response: Response;\n try {\n const requestOptions: RequestInit = {\n ...fetcherOptions,\n method,\n body: body !== undefined ? JSON.stringify(body) : undefined,\n };\n response = await fetcher(url, requestOptions);\n } catch (error) {\n throw FragnoClientFetchError.fromUnknownFetchError(error);\n }\n\n if (!response.ok) {\n throw await FragnoClientApiError.fromResponse<TErrorCode>(response);\n }\n\n return response;\n }\n\n const mutatorStore: FragnoClientMutatorData<\n NonGetHTTPMethod,\n TPath,\n TInputSchema,\n TOutputSchema,\n TErrorCode,\n TQueryParameters\n >[\"mutatorStore\"] = this.#createMutatorStore(\n async ({ data }) => {\n if (typeof window === \"undefined\") {\n // TODO(Wilco): Handle server-side rendering.\n }\n\n const { body, path, query } = data as {\n body?: InferOr<TInputSchema, undefined>;\n path?: ExtractPathParamsOrWiden<TPath, string>;\n query?: Record<string, string>;\n };\n\n if (typeof body === \"undefined\" && route.inputSchema !== undefined) {\n throw new Error(\"Body is required.\");\n }\n\n const response = await executeMutateQuery({ body, path, query });\n\n onInvalidate(this.#invalidate.bind(this), {\n pathParams: (path ?? {}) as MaybeExtractPathParamsOrWiden<TPath, string>,\n queryParams: query,\n });\n\n if (response.status === 201 || response.status === 204) {\n return undefined;\n }\n\n const isStreaming = isStreamingResponse(response);\n\n if (!isStreaming) {\n return response.json();\n }\n\n if (typeof window === \"undefined\") {\n return [];\n }\n\n if (isStreaming === \"ndjson\") {\n const storeAdapter: NdjsonStreamingStore<NonNullable<TOutputSchema>, TErrorCode> = {\n setData: (value) => {\n mutatorStore.set({\n ...mutatorStore.get(),\n loading: !(Array.isArray(value) && value.length > 0),\n data: value as InferOr<TOutputSchema, undefined>,\n });\n },\n setError: (value) => {\n mutatorStore.set({\n ...mutatorStore.get(),\n error: value,\n });\n },\n };\n\n // Start streaming in background and return first item\n const { firstItem } = await handleNdjsonStreamingFirstItem(response, storeAdapter);\n\n // Return the first item immediately. The streaming will continue in the background\n return [firstItem];\n }\n\n if (isStreaming === \"octet-stream\") {\n // TODO(Wilco): Implement this\n throw new Error(\"Octet-stream streaming is not supported.\");\n }\n\n throw new Error(\"Unreachable\");\n },\n {\n onError: (error) => {\n console.error(\"Error in mutatorStore\", error);\n },\n },\n );\n\n const mutateQuery = (async (data) => {\n // TypeScript infers the fields to not exist, even though they might\n const { body, path, query } = data as {\n body?: InferOr<TInputSchema, undefined>;\n path?: ExtractPathParamsOrWiden<TPath, string>;\n query?: Record<string, string>;\n };\n\n if (typeof body === \"undefined\" && route.inputSchema !== undefined) {\n throw new Error(\"Body is required for mutateQuery\");\n }\n\n const response = await executeMutateQuery({ body, path, query });\n\n if (response.status === 201 || response.status === 204) {\n return undefined;\n }\n\n const isStreaming = isStreamingResponse(response);\n\n if (!isStreaming) {\n return response.json();\n }\n\n if (isStreaming === \"ndjson\") {\n const { streamingPromise } = await handleNdjsonStreamingFirstItem(response);\n // Resolves once the stream is done, i.e. we block until done\n return await streamingPromise;\n }\n\n if (isStreaming === \"octet-stream\") {\n throw new Error(\"Octet-stream streaming is not supported for mutations\");\n }\n\n throw new Error(\"Unreachable\");\n }) satisfies FragnoClientMutatorData<\n NonGetHTTPMethod,\n TPath,\n TInputSchema,\n TOutputSchema,\n TErrorCode,\n TQueryParameters\n >[\"mutateQuery\"];\n\n return {\n route,\n mutateQuery,\n mutatorStore,\n [MUTATOR_HOOK_SYMBOL]: true,\n };\n }\n\n #invalidate<TPath extends string>(\n method: HTTPMethod,\n path: TPath,\n params: {\n pathParams?: MaybeExtractPathParamsOrWiden<TPath, string>;\n queryParams?: Record<string, string>;\n },\n ) {\n const prefixArray = getCacheKey(method, path, {\n pathParams: params?.pathParams,\n queryParams: params?.queryParams,\n });\n\n const prefix = prefixArray.map((k) => (typeof k === \"string\" ? k : k.get())).join(\"\");\n\n this.#invalidateKeys((key) => key.startsWith(prefix));\n }\n}\n\nexport function createClientBuilder<\n TConfig,\n TDeps,\n TServices extends Record<string, unknown>,\n const TRoutesOrFactories extends readonly AnyRouteOrFactory[],\n const TAdditionalContext extends Record<string, unknown>,\n>(\n fragmentBuilder: {\n definition: FragmentDefinition<TConfig, TDeps, TServices, TAdditionalContext>;\n },\n publicConfig: FragnoPublicClientConfig,\n routesOrFactories: TRoutesOrFactories,\n authorFetcherConfig?: FetcherConfig,\n): ClientBuilder<\n FlattenRouteFactories<TRoutesOrFactories>,\n FragnoFragmentSharedConfig<FlattenRouteFactories<TRoutesOrFactories>>\n> {\n const definition = fragmentBuilder.definition;\n\n // For client-side, we resolve route factories with dummy context\n // This will be removed by the bundle plugin anyway\n const dummyContext = {\n config: {} as TConfig,\n deps: {} as TDeps,\n services: {} as TServices,\n };\n\n const routes = resolveRouteFactories(dummyContext, routesOrFactories);\n\n const fragmentConfig: FragnoFragmentSharedConfig<FlattenRouteFactories<TRoutesOrFactories>> = {\n name: definition.name,\n routes,\n };\n\n const mountRoute = publicConfig.mountRoute ?? `/${definition.name}`;\n const mergedFetcherConfig = mergeFetcherConfigs(authorFetcherConfig, publicConfig.fetcherConfig);\n const fullPublicConfig = {\n ...publicConfig,\n mountRoute,\n fetcherConfig: mergedFetcherConfig,\n };\n\n return new ClientBuilder(fullPublicConfig, fragmentConfig);\n}\n\nexport * from \"./client-error\";\nexport type { FetcherConfig };\n"],"mappings":";;;;;;;;;;;;;;AAyIA,SAAgB,kBACd,aACgC;CAChC,MAAM,WAAW,YAAY,MAAM,IAAI,CAAC,QAAQ,MAAM,EAAE,SAAS,EAAE;CACnE,MAAMA,QAAkB,EAAE;AAE1B,MAAK,MAAM,WAAW,UAAU;AAC9B,MAAI,QAAQ,WAAW,IAAI,EAAE;AAC3B,SAAM,KAAK,QAAQ,MAAM,EAAE,CAAC;AAC5B;;AAGF,MAAI,YAAY,MAAM;AACpB,SAAM,KAAK,KAAK;AAChB;;AAGF,MAAI,QAAQ,WAAW,MAAM,EAAE;AAC7B,SAAM,KAAK,QAAQ,MAAM,EAAE,CAAC;AAC5B;;;AAIJ,QAAO;;;;;;;;;;;;;;;AA+GT,SAAgB,UACd,aACA,QACQ;CACR,MAAM,kBAAkB,YAAY,MAAM,IAAI;CAE9C,MAAMC,gBAA0B,EAAE;AAElC,MAAK,MAAM,WAAW,iBAAiB;AACrC,MAAI,QAAQ,WAAW,GAAG;AAExB,iBAAc,KAAK,GAAG;AACtB;;AAGF,MAAI,QAAQ,WAAW,IAAI,EAAE;GAC3B,MAAM,OAAO,QAAQ,MAAM,EAAE;GAC7B,MAAM,QAAS,OAA8C;AAC7D,OAAI,UAAU,OACZ,OAAM,IAAI,MAAM,qCAAqC,OAAO;AAE9D,iBAAc,KAAK,mBAAmB,MAAM,CAAC;AAC7C;;AAGF,MAAI,YAAY,MAAM;GACpB,MAAM,QAAS,OAA8C;AAC7D,OAAI,UAAU,OACZ,OAAM,IAAI,MAAM,qCAAqC;AAEvD,iBAAc,KAAK,MAAM;AACzB;;AAGF,MAAI,QA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a,cAAc;AAOhG,QAAO,IAAI,cANc;EACvB,GAAG;EACH;EACA,eAAe;EAChB,EAE0C,eAAe"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { d as InferOrUnknown, f as StatusCode, g as MaybeExtractPathParamsOrWiden, l as OutputContext, n as HTTPMethod, o as RouteHandlerInputOptions, p as MutableRequestState, r as NonGetHTTPMethod, t as FragnoRouteConfig, u as InferOr } from "./api-
|
|
2
|
-
import { n as AnyRouteOrFactory, r as FlattenRouteFactories, t as AnyFragnoRouteConfig } from "./route-
|
|
1
|
+
import { d as InferOrUnknown, f as StatusCode, g as MaybeExtractPathParamsOrWiden, l as OutputContext, n as HTTPMethod, o as RouteHandlerInputOptions, p as MutableRequestState, r as NonGetHTTPMethod, t as FragnoRouteConfig, u as InferOr } from "./api-BWN97TOr.js";
|
|
2
|
+
import { n as AnyRouteOrFactory, r as FlattenRouteFactories, t as AnyFragnoRouteConfig } from "./route-Bl9Zr1Yv.js";
|
|
3
3
|
import { ReadableAtom, Store } from "nanostores";
|
|
4
4
|
import { FetcherStore, MutatorStore } from "@nanostores/query";
|
|
5
5
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
@@ -110,11 +110,11 @@ type FragnoClientHookData<TMethod extends HTTPMethod, TPath extends string, TOut
|
|
|
110
110
|
route: FragnoRouteConfig<TMethod, TPath, StandardSchemaV1 | undefined, TOutputSchema, TErrorCode, TQueryParameters>;
|
|
111
111
|
query(args?: {
|
|
112
112
|
path?: MaybeExtractPathParamsOrWiden<TPath, string>;
|
|
113
|
-
query?: Record<TQueryParameters, string>;
|
|
113
|
+
query?: Record<TQueryParameters, string | undefined>;
|
|
114
114
|
}): Promise<StandardSchemaV1.InferOutput<TOutputSchema>>;
|
|
115
115
|
store(args?: {
|
|
116
116
|
path?: MaybeExtractPathParamsOrWiden<TPath, string | ReadableAtom<string>>;
|
|
117
|
-
query?: Record<TQueryParameters, string | ReadableAtom<string>>;
|
|
117
|
+
query?: Record<TQueryParameters, string | undefined | ReadableAtom<string | undefined>>;
|
|
118
118
|
}): FetcherStore<StandardSchemaV1.InferOutput<TOutputSchema>, FragnoClientError<TErrorCode>>;
|
|
119
119
|
[GET_HOOK_SYMBOL]: true;
|
|
120
120
|
} & {
|
|
@@ -125,12 +125,12 @@ type FragnoClientMutatorData<TMethod extends NonGetHTTPMethod, TPath extends str
|
|
|
125
125
|
mutateQuery(args?: {
|
|
126
126
|
body?: InferOr<TInputSchema, undefined>;
|
|
127
127
|
path?: MaybeExtractPathParamsOrWiden<TPath, string>;
|
|
128
|
-
query?: Record<TQueryParameters, string>;
|
|
128
|
+
query?: Record<TQueryParameters, string | undefined>;
|
|
129
129
|
}): Promise<InferOr<TOutputSchema, undefined>>;
|
|
130
130
|
mutatorStore: MutatorStore<{
|
|
131
131
|
body?: InferOr<TInputSchema, undefined>;
|
|
132
132
|
path?: MaybeExtractPathParamsOrWiden<TPath, string | ReadableAtom<string>>;
|
|
133
|
-
query?: Record<TQueryParameters, string | ReadableAtom<string>>;
|
|
133
|
+
query?: Record<TQueryParameters, string | undefined | ReadableAtom<string | undefined>>;
|
|
134
134
|
}, InferOr<TOutputSchema, undefined>, FragnoClientError<TErrorCode>>;
|
|
135
135
|
[MUTATOR_HOOK_SYMBOL]: true;
|
|
136
136
|
} & {
|
|
@@ -143,20 +143,21 @@ declare function buildUrl<TPath extends string>(config: {
|
|
|
143
143
|
path: TPath;
|
|
144
144
|
}, params: {
|
|
145
145
|
pathParams?: Record<string, string | ReadableAtom<string>>;
|
|
146
|
-
queryParams?: Record<string, string | ReadableAtom<string>>;
|
|
146
|
+
queryParams?: Record<string, string | undefined | ReadableAtom<string | undefined>>;
|
|
147
147
|
}): string;
|
|
148
148
|
/**
|
|
149
149
|
* This method returns an array, which can be passed directly to nanostores.
|
|
150
150
|
*
|
|
151
151
|
* The returned array is always: path, pathParams (In order they appear in the path), queryParams (In alphabetical order)
|
|
152
152
|
* Missing pathParams are replaced with "<missing>".
|
|
153
|
+
* Atoms with undefined values are wrapped in computed atoms that map undefined to "" to avoid nanoquery treating the key as incomplete.
|
|
153
154
|
* @param path
|
|
154
155
|
* @param params
|
|
155
156
|
* @returns
|
|
156
157
|
*/
|
|
157
158
|
declare function getCacheKey<TMethod extends HTTPMethod, TPath extends string>(method: TMethod, path: TPath, params?: {
|
|
158
159
|
pathParams?: Record<string, string | ReadableAtom<string>>;
|
|
159
|
-
queryParams?: Record<string, string | ReadableAtom<string>>;
|
|
160
|
+
queryParams?: Record<string, string | undefined | ReadableAtom<string | undefined>>;
|
|
160
161
|
}): (string | ReadableAtom<string>)[];
|
|
161
162
|
declare function isGetHook<TPath extends string, TOutputSchema extends StandardSchemaV1, TErrorCode extends string, TQueryParameters extends string>(hook: unknown): hook is FragnoClientHookData<"GET", TPath, TOutputSchema, TErrorCode, TQueryParameters>;
|
|
162
163
|
declare function isMutatorHook<TMethod extends NonGetHTTPMethod, TPath extends string, TInputSchema extends StandardSchemaV1 | undefined, TOutputSchema extends StandardSchemaV1 | undefined, TErrorCode extends string, TQueryParameters extends string>(hook: unknown): hook is FragnoClientMutatorData<TMethod, TPath, TInputSchema, TOutputSchema, TErrorCode, TQueryParameters>;
|
|
@@ -405,4 +406,4 @@ declare class FragmentBuilder<const TConfig, const TDeps = {}, const TServices e
|
|
|
405
406
|
declare function defineFragment<TConfig = {}>(name: string): FragmentBuilder<TConfig, {}, {}, {}>;
|
|
406
407
|
//#endregion
|
|
407
408
|
export { createClientBuilder as A, FragnoClientUnknownApiError as B, FragnoClientMutatorData as C, ObjectContainingStoreField as D, IsValidGetRoutePath as E, FragnoClientApiError as F, FragnoClientError as I, FragnoClientFetchAbortError as L, isGetHook as M, isMutatorHook as N, ValidateGetRoutePath as O, isStore as P, FragnoClientFetchError as R, FragnoClientHookData as S, HasGetRoutes as T, FragnoErrorOptions as V, ExtractGetRoutes as _, FetcherConfig as a, ExtractRouteByPath as b, FragnoPublicClientConfig as c, instantiatedFragmentFakeSymbol as d, FragnoResponse as f, ExtractGetRoutePaths as g, CreateHookOptions as h, AnyFragnoFragmentSharedConfig as i, getCacheKey as j, buildUrl as k, FragnoPublicConfig as l, ClientBuilder as m, FragmentDefinition as n, FragnoFragmentSharedConfig as o, CacheLine as p, defineFragment as r, FragnoInstantiatedFragment as s, FragmentBuilder as t, createFragment as u, ExtractNonGetRoutePaths as v, FragnoStoreData as w, ExtractRoutePath as x, ExtractOutputSchemaForPath as y, FragnoClientFetchNetworkError as z };
|
|
408
|
-
//# sourceMappingURL=fragment-builder-
|
|
409
|
+
//# sourceMappingURL=fragment-builder-MGr68GNb.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fragment-builder-MGr68GNb.d.ts","names":[],"sources":["../src/client/client-error.ts","../src/client/client.ts","../src/api/request-middleware.ts","../src/api/fragno-response.ts","../src/api/fragment-instantiation.ts","../src/api/fragment-builder.ts"],"sourcesContent":[],"mappings":";;;;;;;KAEY,kBAAA;UACF;;;;;AADE,uBAOU,iBANP,CAAA,cAAA,MAAA,GAAA,MAAA,CAAA,SAMgE,KAAA,CANhE;EAMO,CAAA,OAAA;EAGe,WAAA,CAAA,OAAA,EAAA,MAAA,EAAA,IAAA,EAAA,KAAA,EAAA,OAAA,CAAA,EAAgB,kBAAhB;EAAgB,IAAA,IAAA,CAAA,CAAA,EAMvC,KANuC,GAAA,CAAA,MAAA,GAAA,CAAA,CAAA,CAAA;;AAH0B,cAclE,sBAAA,SAA+B,iBAdmC,CAAA,SAAA,GAAA,eAAA,GAAA,aAAA,CAAA,CAAA;EAAK,WAAA,CAAA,OAAA,EAAA,MAAA,EAAA,IAAA,EAAA,SAAA,GAAA,eAAA,GAAA,aAAA,EAAA,OAAA,CAAA,EAoBvE,kBApBuE;EAcvE,OAAA,qBAAuB,CAAA,KAAA,EAAA,OAAA,CAAA,EAYY,sBAZZ;;;;;AA4BvB,cAAA,6BAAA,SAAsC,sBAAA,CAAA;EAUtC,WAAA,CAAA,OAAA,CAAA,EAAA,MAA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cvE,YAAA,EKamC,kBLbZ;EAMvB,CAAA,GKO0D,kBLP1D,EAAA,GKQJ,QLRI,CAAA,EKSR,eLTQ,CKSQ,OLTR,EKSiB,QLTjB,EAAA,CAAA,CAAA,EKS+B,kBLT/B,CAAA;EAMmC,YAAA,CAAA,qBKiBZ,MLjBY,CAAA,MAAA,EAAA,OAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,OAAA,EAAA;IAZJ,MAAA,EKgC5B,OLhC4B;IAAiB,YAAA,EKiCvC,kBLjCuC;IA4BhD,IAAA,EKMC,KLND;EAUA,CAAA,GKHH,kBLGG,EAAA,GKFJ,YLEgC,CAAA,EKDpC,eLE2D,CKF3C,OLC4B,EKDnB,KLCmB,EKDZ,YLCkC,EKDpB,kBLCoB,CAAA;AAUvE;AAKY,iBKDI,cLCJ,CAAA,UAAA,CAAA,CAAA,CAAA,CAAA,IAAA,EAAA,MAAA,CAAA,EKDgD,eLChD,CKDgE,OLChE,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA"}
|
package/dist/mod.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as FragnoRouteConfig } from "./api-
|
|
2
|
-
import { a as RouteFactoryContext, i as RouteFactory, n as AnyRouteOrFactory, o as defineRoute, r as FlattenRouteFactories, s as defineRoutes } from "./route-
|
|
3
|
-
import { c as FragnoPublicClientConfig, l as FragnoPublicConfig, n as FragmentDefinition, o as FragnoFragmentSharedConfig, r as defineFragment, s as FragnoInstantiatedFragment, t as FragmentBuilder, u as createFragment } from "./fragment-builder-
|
|
1
|
+
import { t as FragnoRouteConfig } from "./api-BWN97TOr.js";
|
|
2
|
+
import { a as RouteFactoryContext, i as RouteFactory, n as AnyRouteOrFactory, o as defineRoute, r as FlattenRouteFactories, s as defineRoutes } from "./route-Bl9Zr1Yv.js";
|
|
3
|
+
import { c as FragnoPublicClientConfig, l as FragnoPublicConfig, n as FragmentDefinition, o as FragnoFragmentSharedConfig, r as defineFragment, s as FragnoInstantiatedFragment, t as FragmentBuilder, u as createFragment } from "./fragment-builder-MGr68GNb.js";
|
|
4
4
|
export { type AnyRouteOrFactory, type FlattenRouteFactories, FragmentBuilder, type FragmentDefinition, type FragnoFragmentSharedConfig, type FragnoInstantiatedFragment, type FragnoPublicClientConfig, type FragnoPublicConfig, type FragnoRouteConfig, type RouteFactory, type RouteFactoryContext, createFragment, defineFragment, defineRoute, defineRoutes };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as HTTPMethod, t as FragnoRouteConfig } from "./api-
|
|
1
|
+
import { n as HTTPMethod, t as FragnoRouteConfig } from "./api-BWN97TOr.js";
|
|
2
2
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
3
3
|
|
|
4
4
|
//#region src/api/route.d.ts
|
|
@@ -23,4 +23,4 @@ declare function defineRoutes<TConfig = {}, TDeps = {}, TServices = {}>(): {
|
|
|
23
23
|
};
|
|
24
24
|
//#endregion
|
|
25
25
|
export { RouteFactoryContext as a, resolveRouteFactories as c, RouteFactory as i, AnyRouteOrFactory as n, defineRoute as o, FlattenRouteFactories as r, defineRoutes as s, AnyFragnoRouteConfig as t };
|
|
26
|
-
//# sourceMappingURL=route-
|
|
26
|
+
//# sourceMappingURL=route-Bl9Zr1Yv.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route-
|
|
1
|
+
{"version":3,"file":"route-Bl9Zr1Yv.d.ts","names":[],"sources":["../src/api/route.ts"],"sourcesContent":[],"mappings":";;;;KAIY,oBAAA,GAAuB,kBAAkB;UAEpC;EAFL,MAAA,EAGF,OAHE;EAEK,IAAA,EAET,KAFS;EACP,QAAA,EAEE,SAFF;;AAEE,KAGA,YAHA,CAAA,OAAA,EAAA,KAAA,EAAA,SAAA,EAAA,kBAAA,SAOe,iBAPf,CAQR,UARQ,EAAA,MAAA,EAUR,gBAVQ,GAAA,SAAA,EAWR,gBAXQ,GAAA,SAAA,E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as HTTPMethod, o as RouteHandlerInputOptions, t as FragnoRouteConfig } from "../api-
|
|
2
|
-
import { n as AnyRouteOrFactory, r as FlattenRouteFactories } from "../route-
|
|
3
|
-
import { b as ExtractRouteByPath, f as FragnoResponse, l as FragnoPublicConfig, n as FragmentDefinition, x as ExtractRoutePath } from "../fragment-builder-
|
|
1
|
+
import { d as InferOrUnknown, n as HTTPMethod, o as RouteHandlerInputOptions, t as FragnoRouteConfig } from "../api-BWN97TOr.js";
|
|
2
|
+
import { n as AnyRouteOrFactory, r as FlattenRouteFactories } from "../route-Bl9Zr1Yv.js";
|
|
3
|
+
import { b as ExtractRouteByPath, f as FragnoResponse, l as FragnoPublicConfig, n as FragmentDefinition, x as ExtractRoutePath } from "../fragment-builder-MGr68GNb.js";
|
|
4
4
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
5
5
|
|
|
6
6
|
//#region src/test/test.d.ts
|
package/package.json
CHANGED
|
@@ -446,39 +446,39 @@ test("MaybeExtractPathParamsOrWiden type tests", () => {
|
|
|
446
446
|
test("QueryParamsHint type tests", () => {
|
|
447
447
|
// Basic usage with string union
|
|
448
448
|
expectTypeOf<QueryParamsHint<"page" | "limit">>().toEqualTypeOf<
|
|
449
|
-
Partial<Record<"page" | "limit", string>> & Record<string, string>
|
|
449
|
+
Partial<Record<"page" | "limit", string>> & Record<string, string | undefined>
|
|
450
450
|
>();
|
|
451
451
|
|
|
452
452
|
// Single parameter hint
|
|
453
453
|
expectTypeOf<QueryParamsHint<"search">>().toEqualTypeOf<
|
|
454
|
-
Partial<Record<"search", string>> & Record<string, string>
|
|
454
|
+
Partial<Record<"search", string>> & Record<string, string | undefined>
|
|
455
455
|
>();
|
|
456
456
|
|
|
457
457
|
// Empty hint (never) - should still allow any string keys
|
|
458
458
|
expectTypeOf<QueryParamsHint<never>>().toEqualTypeOf<
|
|
459
|
-
Partial<Record<never, string>> & Record<string, string>
|
|
459
|
+
Partial<Record<never, string>> & Record<string, string | undefined>
|
|
460
460
|
>();
|
|
461
461
|
|
|
462
462
|
// With custom value type
|
|
463
463
|
expectTypeOf<QueryParamsHint<"page" | "limit", number>>().toEqualTypeOf<
|
|
464
|
-
Partial<Record<"page" | "limit", number>> & Record<string, number>
|
|
464
|
+
Partial<Record<"page" | "limit", number>> & Record<string, number | undefined>
|
|
465
465
|
>();
|
|
466
466
|
|
|
467
467
|
// With boolean value type
|
|
468
468
|
expectTypeOf<QueryParamsHint<"enabled" | "debug", boolean>>().toEqualTypeOf<
|
|
469
|
-
Partial<Record<"enabled" | "debug", boolean>> & Record<string, boolean>
|
|
469
|
+
Partial<Record<"enabled" | "debug", boolean>> & Record<string, boolean | undefined>
|
|
470
470
|
>();
|
|
471
471
|
|
|
472
472
|
// With union value type
|
|
473
473
|
type StringOrNumber = string | number;
|
|
474
474
|
expectTypeOf<QueryParamsHint<"value", StringOrNumber>>().toEqualTypeOf<
|
|
475
|
-
Partial<Record<"value", StringOrNumber>> & Record<string, StringOrNumber>
|
|
475
|
+
Partial<Record<"value", StringOrNumber>> & Record<string, StringOrNumber | undefined>
|
|
476
476
|
>();
|
|
477
477
|
|
|
478
478
|
// With custom object type
|
|
479
479
|
type CustomType = { raw: string; parsed: boolean };
|
|
480
480
|
expectTypeOf<QueryParamsHint<"data", CustomType>>().toEqualTypeOf<
|
|
481
|
-
Partial<Record<"data", CustomType>> & Record<string, CustomType>
|
|
481
|
+
Partial<Record<"data", CustomType>> & Record<string, CustomType | undefined>
|
|
482
482
|
>();
|
|
483
483
|
});
|
|
484
484
|
|
package/src/api/internal/path.ts
CHANGED
|
@@ -124,7 +124,7 @@ export type HasPathParams<T extends string> = ExtractPathParamNames<T> extends n
|
|
|
124
124
|
export type QueryParamsHint<TQueryParameters extends string, ValueType = string> = Partial<
|
|
125
125
|
Record<TQueryParameters, ValueType>
|
|
126
126
|
> &
|
|
127
|
-
Record<string, ValueType>;
|
|
127
|
+
Record<string, ValueType | undefined>;
|
|
128
128
|
|
|
129
129
|
// Runtime utilities
|
|
130
130
|
|
|
@@ -417,7 +417,7 @@ describe("FragnoClientMutatorData", () => {
|
|
|
417
417
|
(args?: {
|
|
418
418
|
body?: undefined;
|
|
419
419
|
path?: Record<"id", string> | undefined;
|
|
420
|
-
query?: Record<string, string>;
|
|
420
|
+
query?: Record<string, string | undefined>;
|
|
421
421
|
}) => Promise<undefined>
|
|
422
422
|
>();
|
|
423
423
|
});
|
|
@@ -437,7 +437,7 @@ describe("FragnoClientMutatorData", () => {
|
|
|
437
437
|
(args?: {
|
|
438
438
|
body?: undefined;
|
|
439
439
|
path?: Record<"id", string> | undefined;
|
|
440
|
-
query?: Record<string, string>;
|
|
440
|
+
query?: Record<string, string | undefined>;
|
|
441
441
|
}) => Promise<{
|
|
442
442
|
id: number;
|
|
443
443
|
name: string;
|
|
@@ -465,7 +465,7 @@ describe("FragnoClientMutatorData", () => {
|
|
|
465
465
|
}
|
|
466
466
|
| undefined;
|
|
467
467
|
path?: Record<"id", string> | undefined;
|
|
468
|
-
query?: Record<string, string>;
|
|
468
|
+
query?: Record<string, string | undefined>;
|
|
469
469
|
}) => Promise<undefined>
|
|
470
470
|
>();
|
|
471
471
|
});
|
|
@@ -486,7 +486,7 @@ describe("FragnoClientMutatorData", () => {
|
|
|
486
486
|
(args?: {
|
|
487
487
|
body?: undefined;
|
|
488
488
|
path?: Record<"id", string> | undefined;
|
|
489
|
-
query?: Record<"id" | "name", string>;
|
|
489
|
+
query?: Record<"id" | "name", string | undefined>;
|
|
490
490
|
}) => Promise<undefined>
|
|
491
491
|
>();
|
|
492
492
|
});
|
|
@@ -445,6 +445,83 @@ describe("hook parameter reactivity", () => {
|
|
|
445
445
|
}
|
|
446
446
|
});
|
|
447
447
|
|
|
448
|
+
test("should react to optional query parameters", async () => {
|
|
449
|
+
const testFragment = defineFragment("test-fragment");
|
|
450
|
+
const testRoutes = [
|
|
451
|
+
defineRoute({
|
|
452
|
+
method: "GET",
|
|
453
|
+
path: "/users",
|
|
454
|
+
queryParameters: ["thing"],
|
|
455
|
+
outputSchema: z.array(z.object({ id: z.number(), name: z.string(), suffix: z.string() })),
|
|
456
|
+
handler: async (_ctx, { json }) => json([{ id: 1, name: "John", suffix: "default" }]),
|
|
457
|
+
}),
|
|
458
|
+
] as const;
|
|
459
|
+
|
|
460
|
+
vi.mocked(global.fetch).mockImplementation(async (input) => {
|
|
461
|
+
assert(typeof input === "string");
|
|
462
|
+
|
|
463
|
+
const url = new URL(input);
|
|
464
|
+
const thing = url.searchParams.get("thing");
|
|
465
|
+
|
|
466
|
+
const suffix = thing ? `with-${thing}` : "without-thing";
|
|
467
|
+
|
|
468
|
+
return {
|
|
469
|
+
headers: new Headers(),
|
|
470
|
+
ok: true,
|
|
471
|
+
json: async () => [{ id: 1, name: "John", suffix }],
|
|
472
|
+
} as Response;
|
|
473
|
+
});
|
|
474
|
+
|
|
475
|
+
const cb = createClientBuilder(testFragment, clientConfig, testRoutes);
|
|
476
|
+
const useUsers = cb.createHook("/users");
|
|
477
|
+
|
|
478
|
+
// This atom with string | undefined type should be accepted by the query parameter
|
|
479
|
+
const thingAtom = atom<string | undefined>("initial");
|
|
480
|
+
|
|
481
|
+
const store = useUsers.store({ query: { thing: thingAtom } });
|
|
482
|
+
|
|
483
|
+
const itt = createAsyncIteratorFromCallback(store.listen);
|
|
484
|
+
|
|
485
|
+
{
|
|
486
|
+
const { value } = await itt.next();
|
|
487
|
+
expect(value).toEqual({
|
|
488
|
+
loading: true,
|
|
489
|
+
promise: expect.any(Promise),
|
|
490
|
+
data: undefined,
|
|
491
|
+
error: undefined,
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
{
|
|
496
|
+
const { value } = await itt.next();
|
|
497
|
+
expect(value).toEqual({
|
|
498
|
+
loading: false,
|
|
499
|
+
data: [{ id: 1, name: "John", suffix: "with-initial" }],
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
// Change thing to another value
|
|
504
|
+
thingAtom.set(undefined);
|
|
505
|
+
|
|
506
|
+
{
|
|
507
|
+
const { value } = await itt.next();
|
|
508
|
+
expect(value).toEqual({
|
|
509
|
+
loading: true,
|
|
510
|
+
promise: expect.any(Promise),
|
|
511
|
+
data: undefined,
|
|
512
|
+
error: undefined,
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
{
|
|
517
|
+
const { value } = await itt.next();
|
|
518
|
+
expect(value).toEqual({
|
|
519
|
+
loading: false,
|
|
520
|
+
data: [{ id: 1, name: "John", suffix: "without-thing" }],
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
});
|
|
524
|
+
|
|
448
525
|
test("should react to combined path and query parameters", async () => {
|
|
449
526
|
const testFragment = defineFragment("test-fragment");
|
|
450
527
|
const testRoutes = [
|