UNPKG

@kubb/plugin-react-query

Version:

React Query hooks generator plugin for Kubb, creating type-safe API client hooks from OpenAPI specifications for React applications.

1,322 lines (1,311 loc) 57.1 kB
import { t as __name } from "./chunk--u3MIqq1.js"; import { isAllOptional, isOptional } from "@kubb/oas"; import { getComments, getPathParams } from "@kubb/plugin-oas/utils"; import { File, Function as Function$1, FunctionParams, Type } from "@kubb/react-fabric"; import { Fragment, jsx, jsxs } from "@kubb/react-fabric/jsx-runtime"; import { Client } from "@kubb/plugin-client/components"; //#region ../../internals/utils/src/casing.ts /** * Shared implementation for camelCase and PascalCase conversion. * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons) * and capitalizes each word according to `pascal`. * * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are. */ function toCamelOrPascal(text, pascal) { return text.trim().replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/(\d)([a-z])/g, "$1 $2").split(/[\s\-_./\\:]+/).filter(Boolean).map((word, i) => { if (word.length > 1 && word === word.toUpperCase()) return word; if (i === 0 && !pascal) return word.charAt(0).toLowerCase() + word.slice(1); return word.charAt(0).toUpperCase() + word.slice(1); }).join("").replace(/[^a-zA-Z0-9]/g, ""); } /** * Splits `text` on `.` and applies `transformPart` to each segment. * The last segment receives `isLast = true`, all earlier segments receive `false`. * Segments are joined with `/` to form a file path. */ function applyToFileParts(text, transformPart) { const parts = text.split("."); return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/"); } /** * Converts `text` to camelCase. * When `isFile` is `true`, dot-separated segments are each cased independently and joined with `/`. * * @example * camelCase('hello-world') // 'helloWorld' * camelCase('pet.petId', { isFile: true }) // 'pet/petId' */ function camelCase(text, { isFile, prefix = "", suffix = "" } = {}) { if (isFile) return applyToFileParts(text, (part, isLast) => camelCase(part, isLast ? { prefix, suffix } : {})); return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false); } /** * Converts `text` to PascalCase. * When `isFile` is `true`, the last dot-separated segment is PascalCased and earlier segments are camelCased. * * @example * pascalCase('hello-world') // 'HelloWorld' * pascalCase('pet.petId', { isFile: true }) // 'pet/PetId' */ function pascalCase(text, { isFile, prefix = "", suffix = "" } = {}) { if (isFile) return applyToFileParts(text, (part, isLast) => isLast ? pascalCase(part, { prefix, suffix }) : camelCase(part)); return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true); } //#endregion //#region ../../internals/utils/src/object.ts /** * Converts a dot-notation path or string array into an optional-chaining accessor expression. * * @example * getNestedAccessor('pagination.next.id', 'lastPage') * // → "lastPage?.['pagination']?.['next']?.['id']" */ function getNestedAccessor(param, accessor) { const parts = Array.isArray(param) ? param : param.split("."); if (parts.length === 0 || parts.length === 1 && parts[0] === "") return void 0; return `${accessor}?.['${`${parts.join("']?.['")}']`}`; } //#endregion //#region ../../internals/utils/src/reserved.ts /** * Returns `true` when `name` is a syntactically valid JavaScript variable name. */ function isValidVarName(name) { try { new Function(`var ${name}`); } catch { return false; } return true; } //#endregion //#region ../../internals/utils/src/urlPath.ts /** * Parses and transforms an OpenAPI/Swagger path string into various URL formats. * * @example * const p = new URLPath('/pet/{petId}') * p.URL // '/pet/:petId' * p.template // '`/pet/${petId}`' */ var URLPath = class { /** The raw OpenAPI/Swagger path string, e.g. `/pet/{petId}`. */ path; #options; constructor(path, options = {}) { this.path = path; this.#options = options; } /** Converts the OpenAPI path to Express-style colon syntax, e.g. `/pet/{petId}` → `/pet/:petId`. */ get URL() { return this.toURLPath(); } /** Returns `true` when `path` is a fully-qualified URL (e.g. starts with `https://`). */ get isURL() { try { return !!new URL(this.path).href; } catch { return false; } } /** * Converts the OpenAPI path to a TypeScript template literal string. * * @example * new URLPath('/pet/{petId}').template // '`/pet/${petId}`' * new URLPath('/account/monetary-accountID').template // '`/account/${monetaryAccountId}`' */ get template() { return this.toTemplateString(); } /** Returns the path and its extracted params as a structured `URLObject`, or as a stringified expression when `stringify` is set. */ get object() { return this.toObject(); } /** Returns a map of path parameter names, or `undefined` when the path has no parameters. */ get params() { return this.getParams(); } #transformParam(raw) { const param = isValidVarName(raw) ? raw : camelCase(raw); return this.#options.casing === "camelcase" ? camelCase(param) : param; } /** Iterates over every `{param}` token in `path`, calling `fn` with the raw token and transformed name. */ #eachParam(fn) { for (const match of this.path.matchAll(/\{([^}]+)\}/g)) { const raw = match[1]; fn(raw, this.#transformParam(raw)); } } toObject({ type = "path", replacer, stringify } = {}) { const object = { url: type === "path" ? this.toURLPath() : this.toTemplateString({ replacer }), params: this.getParams() }; if (stringify) { if (type === "template") return JSON.stringify(object).replaceAll("'", "").replaceAll(`"`, ""); if (object.params) return `{ url: '${object.url}', params: ${JSON.stringify(object.params).replaceAll("'", "").replaceAll(`"`, "")} }`; return `{ url: '${object.url}' }`; } return object; } /** * Converts the OpenAPI path to a TypeScript template literal string. * An optional `replacer` can transform each extracted parameter name before interpolation. * * @example * new URLPath('/pet/{petId}').toTemplateString() // '`/pet/${petId}`' */ toTemplateString({ prefix = "", replacer } = {}) { return `\`${prefix}${this.path.split(/\{([^}]+)\}/).map((part, i) => { if (i % 2 === 0) return part; const param = this.#transformParam(part); return `\${${replacer ? replacer(param) : param}}`; }).join("")}\``; } /** * Extracts all `{param}` segments from the path and returns them as a key-value map. * An optional `replacer` transforms each parameter name in both key and value positions. * Returns `undefined` when no path parameters are found. */ getParams(replacer) { const params = {}; this.#eachParam((_raw, param) => { const key = replacer ? replacer(param) : param; params[key] = key; }); return Object.keys(params).length > 0 ? params : void 0; } /** Converts the OpenAPI path to Express-style colon syntax, e.g. `/pet/{petId}` → `/pet/:petId`. */ toURLPath() { return this.path.replace(/\{([^}]+)\}/g, ":$1"); } }; //#endregion //#region ../../internals/tanstack-query/src/components/MutationKey.tsx function getParams$10({}) { return FunctionParams.factory({}); } __name(getParams$10, "getParams"); const getTransformer$1 = /* @__PURE__ */ __name(({ operation, casing }) => { return [`{ url: '${new URLPath(operation.path, { casing }).toURLPath()}' }`]; }, "getTransformer"); function MutationKey({ name, typeSchemas, pathParamsType, paramsCasing, operation, typeName, transformer = getTransformer$1 }) { const params = getParams$10({ pathParamsType, typeSchemas }); const keys = transformer({ operation, schemas: typeSchemas, casing: paramsCasing }); return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx(Function$1.Arrow, { name, export: true, params: params.toConstructor(), singleLine: true, children: `[${keys.join(", ")}] as const` }) }), /* @__PURE__ */ jsx(File.Source, { name: typeName, isExportable: true, isIndexable: true, isTypeOnly: true, children: /* @__PURE__ */ jsx(Type, { name: typeName, export: true, children: `ReturnType<typeof ${name}>` }) })] }); } MutationKey.getParams = getParams$10; MutationKey.getTransformer = getTransformer$1; //#endregion //#region ../../internals/tanstack-query/src/components/QueryKey.tsx function getParams$9({ pathParamsType, paramsCasing, typeSchemas }) { return FunctionParams.factory({ pathParams: typeSchemas.pathParams?.name ? { mode: pathParamsType === "object" ? "object" : "inlineSpread", children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }) } : void 0, data: typeSchemas.request?.name ? { type: typeSchemas.request?.name, optional: isOptional(typeSchemas.request?.schema) } : void 0, params: typeSchemas.queryParams?.name ? { type: typeSchemas.queryParams?.name, optional: isOptional(typeSchemas.queryParams?.schema) } : void 0 }); } __name(getParams$9, "getParams"); const getTransformer = ({ operation, schemas, casing }) => { return [ new URLPath(operation.path, { casing }).toObject({ type: "path", stringify: true }), schemas.queryParams?.name ? "...(params ? [params] : [])" : void 0, schemas.request?.name ? "...(data ? [data] : [])" : void 0 ].filter(Boolean); }; function QueryKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer = getTransformer }) { const params = getParams$9({ pathParamsType, typeSchemas, paramsCasing }); const keys = transformer({ operation, schemas: typeSchemas, casing: paramsCasing }); return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx(Function$1.Arrow, { name, export: true, params: params.toConstructor(), singleLine: true, children: `[${keys.join(", ")}] as const` }) }), /* @__PURE__ */ jsx(File.Source, { name: typeName, isExportable: true, isIndexable: true, isTypeOnly: true, children: /* @__PURE__ */ jsx(Type, { name: typeName, export: true, children: `ReturnType<typeof ${name}>` }) })] }); } QueryKey.getParams = getParams$9; QueryKey.getTransformer = getTransformer; //#endregion //#region src/components/QueryOptions.tsx function getParams$8({ paramsType, paramsCasing, pathParamsType, typeSchemas }) { if (paramsType === "object") { const children = { ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }), data: typeSchemas.request?.name ? { type: typeSchemas.request?.name, optional: isOptional(typeSchemas.request?.schema) } : void 0, params: typeSchemas.queryParams?.name ? { type: typeSchemas.queryParams?.name, optional: isOptional(typeSchemas.queryParams?.schema) } : void 0, headers: typeSchemas.headerParams?.name ? { type: typeSchemas.headerParams?.name, optional: isOptional(typeSchemas.headerParams?.schema) } : void 0 }; const allChildrenAreOptional = Object.values(children).every((child) => !child || child.optional); return FunctionParams.factory({ data: { mode: "object", children, default: allChildrenAreOptional ? "{}" : void 0 }, config: { type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }", default: "{}" } }); } return FunctionParams.factory({ pathParams: typeSchemas.pathParams?.name ? { mode: pathParamsType === "object" ? "object" : "inlineSpread", children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }), default: isAllOptional(typeSchemas.pathParams?.schema) ? "{}" : void 0 } : void 0, data: typeSchemas.request?.name ? { type: typeSchemas.request?.name, optional: isOptional(typeSchemas.request?.schema) } : void 0, params: typeSchemas.queryParams?.name ? { type: typeSchemas.queryParams?.name, optional: isOptional(typeSchemas.queryParams?.schema) } : void 0, headers: typeSchemas.headerParams?.name ? { type: typeSchemas.headerParams?.name, optional: isOptional(typeSchemas.headerParams?.schema) } : void 0, config: { type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }", default: "{}" } }); } __name(getParams$8, "getParams"); function QueryOptions({ name, clientName, dataReturnType, typeSchemas, paramsCasing, paramsType, pathParamsType, queryKeyName }) { const params = getParams$8({ paramsType, paramsCasing, pathParamsType, typeSchemas }); const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`; const TError = typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"; const clientParams = Client.getParams({ typeSchemas, paramsCasing, paramsType, pathParamsType, isConfigurable: true }); const queryKeyParams = QueryKey.getParams({ pathParamsType, typeSchemas, paramsCasing }); const enabled = Object.entries(queryKeyParams.flatParams).map(([key, item]) => { return item && !item.optional && !item.default ? key : void 0; }).filter(Boolean).join("&& "); const enabledText = enabled ? `enabled: !!(${enabled}),` : ""; return /* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx(Function$1, { name, export: true, params: params.toConstructor(), children: ` const queryKey = ${queryKeyName}(${queryKeyParams.toCall()}) return queryOptions<${TData}, ResponseErrorConfig<${TError}>, ${TData}, typeof queryKey>({ ${enabledText} queryKey, queryFn: async ({ signal }) => { return ${clientName}(${clientParams.toCall({ transformName(name) { if (name === "config") return "{ ...config, signal: config.signal ?? signal }"; return name; } })}) }, }) ` }) }); } QueryOptions.getParams = getParams$8; //#endregion //#region src/components/InfiniteQuery.tsx function getParams$7({ paramsType, paramsCasing, pathParamsType, typeSchemas, pageParamGeneric }) { if (paramsType === "object") { const children = { ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }), data: typeSchemas.request?.name ? { type: typeSchemas.request?.name, optional: isOptional(typeSchemas.request?.schema) } : void 0, params: typeSchemas.queryParams?.name ? { type: typeSchemas.queryParams?.name, optional: isOptional(typeSchemas.queryParams?.schema) } : void 0, headers: typeSchemas.headerParams?.name ? { type: typeSchemas.headerParams?.name, optional: isOptional(typeSchemas.headerParams?.schema) } : void 0 }; const allChildrenAreOptional = Object.values(children).every((child) => !child || child.optional); return FunctionParams.factory({ data: { mode: "object", children, default: allChildrenAreOptional ? "{}" : void 0 }, options: { type: ` { query?: Partial<InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryKey, ${pageParamGeneric}>> & { client?: QueryClient }, client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"} } `, default: "{}" } }); } return FunctionParams.factory({ pathParams: typeSchemas.pathParams?.name ? { mode: pathParamsType === "object" ? "object" : "inlineSpread", children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }), default: isAllOptional(typeSchemas.pathParams?.schema) ? "{}" : void 0 } : void 0, data: typeSchemas.request?.name ? { type: typeSchemas.request?.name, optional: isOptional(typeSchemas.request?.schema) } : void 0, params: typeSchemas.queryParams?.name ? { type: typeSchemas.queryParams?.name, optional: isOptional(typeSchemas.queryParams?.schema) } : void 0, headers: typeSchemas.headerParams?.name ? { type: typeSchemas.headerParams?.name, optional: isOptional(typeSchemas.headerParams?.schema) } : void 0, options: { type: ` { query?: Partial<InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryKey, ${pageParamGeneric}>> & { client?: QueryClient }, client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"} } `, default: "{}" } }); } __name(getParams$7, "getParams"); function InfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas, operation, initialPageParam, queryParam, customOptions }) { const responseType = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`; const errorType = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`; const isInitialPageParamDefined = initialPageParam !== void 0 && initialPageParam !== null; const fallbackPageParamType = typeof initialPageParam === "number" ? "number" : typeof initialPageParam === "string" ? initialPageParam.includes(" as ") ? (() => { const parts = initialPageParam.split(" as "); return parts[parts.length - 1] ?? "unknown"; })() : "string" : typeof initialPageParam === "boolean" ? "boolean" : "unknown"; const queryParamType = queryParam && typeSchemas.queryParams?.name ? `${typeSchemas.queryParams?.name}['${queryParam}']` : void 0; const pageParamType = queryParamType ? isInitialPageParamDefined ? `NonNullable<${queryParamType}>` : queryParamType : fallbackPageParamType; const returnType = "UseInfiniteQueryResult<TData, TError> & { queryKey: TQueryKey }"; const generics = [ `TQueryFnData = ${responseType}`, `TError = ${errorType}`, "TData = InfiniteData<TQueryFnData>", `TQueryKey extends QueryKey = ${queryKeyTypeName}`, `TPageParam = ${pageParamType}` ]; const queryKeyParams = QueryKey.getParams({ pathParamsType, typeSchemas, paramsCasing }); const queryOptionsParams = QueryOptions.getParams({ paramsType, pathParamsType, typeSchemas, paramsCasing }); const params = getParams$7({ paramsCasing, paramsType, pathParamsType, typeSchemas, pageParamGeneric: "TPageParam" }); const queryOptions = `${queryOptionsName}(${queryOptionsParams.toCall()})`; return /* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx(Function$1, { name, export: true, generics: generics.join(", "), params: params.toConstructor(), JSDoc: { comments: getComments(operation) }, children: ` const { query: queryConfig = {}, client: config = {} } = options ?? {} const { client: queryClient, ...resolvedOptions } = queryConfig const queryKey = resolvedOptions?.queryKey ?? ${queryKeyName}(${queryKeyParams.toCall()}) ${customOptions ? `const customOptions = ${customOptions.name}({ hookName: '${name}', operationId: '${operation.getOperationId()}' })` : ""} const query = useInfiniteQuery({ ...${queryOptions},${customOptions ? "\n...customOptions," : ""} ...resolvedOptions, queryKey, } as unknown as InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, queryClient) as ${returnType} query.queryKey = queryKey as TQueryKey return query ` }) }); } InfiniteQuery.getParams = getParams$7; //#endregion //#region src/components/InfiniteQueryOptions.tsx function getParams$6({ paramsType, paramsCasing, pathParamsType, typeSchemas }) { if (paramsType === "object") { const children = { ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }), data: typeSchemas.request?.name ? { type: typeSchemas.request?.name, optional: isOptional(typeSchemas.request?.schema) } : void 0, params: typeSchemas.queryParams?.name ? { type: typeSchemas.queryParams?.name, optional: isOptional(typeSchemas.queryParams?.schema) } : void 0, headers: typeSchemas.headerParams?.name ? { type: typeSchemas.headerParams?.name, optional: isOptional(typeSchemas.headerParams?.schema) } : void 0 }; const allChildrenAreOptional = Object.values(children).every((child) => !child || child.optional); return FunctionParams.factory({ data: { mode: "object", children, default: allChildrenAreOptional ? "{}" : void 0 }, config: { type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }", default: "{}" } }); } return FunctionParams.factory({ pathParams: typeSchemas.pathParams?.name ? { mode: pathParamsType === "object" ? "object" : "inlineSpread", children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }), default: isAllOptional(typeSchemas.pathParams?.schema) ? "{}" : void 0 } : void 0, data: typeSchemas.request?.name ? { type: typeSchemas.request?.name, optional: isOptional(typeSchemas.request?.schema) } : void 0, params: typeSchemas.queryParams?.name ? { type: typeSchemas.queryParams?.name, optional: isOptional(typeSchemas.queryParams?.schema) } : void 0, headers: typeSchemas.headerParams?.name ? { type: typeSchemas.headerParams?.name, optional: isOptional(typeSchemas.headerParams?.schema) } : void 0, config: { type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }", default: "{}" } }); } __name(getParams$6, "getParams"); function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam, nextParam, previousParam, typeSchemas, paramsCasing, paramsType, dataReturnType, pathParamsType, queryParam, queryKeyName }) { const queryFnDataType = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`; const errorType = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`; const isInitialPageParamDefined = initialPageParam !== void 0 && initialPageParam !== null; const fallbackPageParamType = typeof initialPageParam === "number" ? "number" : typeof initialPageParam === "string" ? initialPageParam.includes(" as ") ? (() => { const parts = initialPageParam.split(" as "); return parts[parts.length - 1] ?? "unknown"; })() : "string" : typeof initialPageParam === "boolean" ? "boolean" : "unknown"; const queryParamType = queryParam && typeSchemas.queryParams?.name ? `${typeSchemas.queryParams?.name}['${queryParam}']` : void 0; const pageParamType = queryParamType ? isInitialPageParamDefined ? `NonNullable<${queryParamType}>` : queryParamType : fallbackPageParamType; const params = getParams$6({ paramsType, paramsCasing, pathParamsType, typeSchemas }); const clientParams = Client.getParams({ paramsCasing, typeSchemas, paramsType, pathParamsType, isConfigurable: true }); const queryKeyParams = QueryKey.getParams({ pathParamsType, typeSchemas, paramsCasing }); const hasNewParams = nextParam !== void 0 || previousParam !== void 0; let getNextPageParamExpr; let getPreviousPageParamExpr; if (hasNewParams) { if (nextParam) { const accessor = getNestedAccessor(nextParam, "lastPage"); if (accessor) getNextPageParamExpr = `getNextPageParam: (lastPage) => ${accessor}`; } if (previousParam) { const accessor = getNestedAccessor(previousParam, "firstPage"); if (accessor) getPreviousPageParamExpr = `getPreviousPageParam: (firstPage) => ${accessor}`; } } else if (cursorParam) { getNextPageParamExpr = `getNextPageParam: (lastPage) => lastPage['${cursorParam}']`; getPreviousPageParamExpr = `getPreviousPageParam: (firstPage) => firstPage['${cursorParam}']`; } else { if (dataReturnType === "full") getNextPageParamExpr = "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage.data) && lastPage.data.length === 0 ? undefined : lastPageParam + 1"; else getNextPageParamExpr = "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage) && lastPage.length === 0 ? undefined : lastPageParam + 1"; getPreviousPageParamExpr = "getPreviousPageParam: (_firstPage, _allPages, firstPageParam) => firstPageParam <= 1 ? undefined : firstPageParam - 1"; } const queryOptions = [ `initialPageParam: ${typeof initialPageParam === "string" ? JSON.stringify(initialPageParam) : initialPageParam}`, getNextPageParamExpr, getPreviousPageParamExpr ].filter(Boolean); const infiniteOverrideParams = queryParam && typeSchemas.queryParams?.name ? ` params = { ...(params ?? {}), ['${queryParam}']: pageParam as unknown as ${typeSchemas.queryParams?.name}['${queryParam}'], } as ${typeSchemas.queryParams?.name}` : ""; const enabled = Object.entries(queryKeyParams.flatParams).map(([key, item]) => { return item && !item.optional && !item.default ? key : void 0; }).filter(Boolean).join("&& "); const enabledText = enabled ? `enabled: !!(${enabled}),` : ""; if (infiniteOverrideParams) return /* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx(Function$1, { name, export: true, params: params.toConstructor(), children: ` const queryKey = ${queryKeyName}(${queryKeyParams.toCall()}) return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${queryFnDataType}>, typeof queryKey, ${pageParamType}>({ ${enabledText} queryKey, queryFn: async ({ signal, pageParam }) => { ${infiniteOverrideParams} return ${clientName}(${clientParams.toCall({ transformName(name) { if (name === "config") return "{ ...config, signal: config.signal ?? signal }"; return name; } })}) }, ${queryOptions.join(",\n")} }) ` }) }); return /* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx(Function$1, { name, export: true, params: params.toConstructor(), children: ` const queryKey = ${queryKeyName}(${queryKeyParams.toCall()}) return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${queryFnDataType}>, typeof queryKey, ${pageParamType}>({ ${enabledText} queryKey, queryFn: async ({ signal }) => { return ${clientName}(${clientParams.toCall({ transformName(name) { if (name === "config") return "{ ...config, signal: config.signal ?? signal }"; return name; } })}) }, ${queryOptions.join(",\n")} }) ` }) }); } InfiniteQueryOptions.getParams = getParams$6; //#endregion //#region src/components/MutationOptions.tsx function getParams$5({ typeSchemas }) { return FunctionParams.factory({ config: { type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }", default: "{}" } }); } __name(getParams$5, "getParams"); function MutationOptions({ name, clientName, dataReturnType, typeSchemas, paramsCasing, paramsType, pathParamsType, mutationKeyName }) { const params = getParams$5({ typeSchemas }); const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`; const TError = typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"; const clientParams = Client.getParams({ typeSchemas, paramsCasing, paramsType, pathParamsType, isConfigurable: true }); const mutationKeyParams = MutationKey.getParams({ pathParamsType, typeSchemas }); const mutationParams = FunctionParams.factory({ ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }), data: typeSchemas.request?.name ? { type: typeSchemas.request?.name, optional: isOptional(typeSchemas.request?.schema) } : void 0, params: typeSchemas.queryParams?.name ? { type: typeSchemas.queryParams?.name, optional: isOptional(typeSchemas.queryParams?.schema) } : void 0, headers: typeSchemas.headerParams?.name ? { type: typeSchemas.headerParams?.name, optional: isOptional(typeSchemas.headerParams?.schema) } : void 0 }); const dataParams = FunctionParams.factory({ data: { mode: "object", children: Object.entries(mutationParams.params).reduce((acc, [key, value]) => { if (value) acc[key] = { ...value, type: void 0 }; return acc; }, {}) } }); const TRequest = mutationParams.toConstructor(); return /* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx(Function$1, { name, export: true, params: params.toConstructor(), generics: ["TContext = unknown"], children: ` const mutationKey = ${mutationKeyName}(${mutationKeyParams.toCall()}) return mutationOptions<${TData}, ResponseErrorConfig<${TError}>, ${TRequest ? `{${TRequest}}` : "void"}, TContext>({ mutationKey, mutationFn: async(${dataParams.toConstructor()}) => { return ${clientName}(${clientParams.toCall()}) }, }) ` }) }); } MutationOptions.getParams = getParams$5; //#endregion //#region src/components/Mutation.tsx function getParams$4({ paramsCasing, dataReturnType, typeSchemas }) { const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`; const pathParams = getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }); const TRequest = FunctionParams.factory({ ...pathParams, data: typeSchemas.request?.name ? { type: typeSchemas.request?.name, optional: isOptional(typeSchemas.request?.schema) } : void 0, params: typeSchemas.queryParams?.name ? { type: typeSchemas.queryParams?.name, optional: isOptional(typeSchemas.queryParams?.schema) } : void 0, headers: typeSchemas.headerParams?.name ? { type: typeSchemas.headerParams?.name, optional: isOptional(typeSchemas.headerParams?.schema) } : void 0 }).toConstructor(); const generics = [ TData, `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`, TRequest ? `{${TRequest}}` : "void", "TContext" ].join(", "); return FunctionParams.factory({ options: { type: ` { mutation?: UseMutationOptions<${generics}> & { client?: QueryClient }, client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"}, } `, default: "{}" } }); } __name(getParams$4, "getParams"); function Mutation({ name, mutationOptionsName, paramsCasing, pathParamsType, dataReturnType, typeSchemas, operation, mutationKeyName, customOptions }) { const mutationKeyParams = MutationKey.getParams({ pathParamsType, typeSchemas }); const params = getParams$4({ paramsCasing, pathParamsType, dataReturnType, typeSchemas }); const mutationParams = FunctionParams.factory({ ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }), data: typeSchemas.request?.name ? { type: typeSchemas.request?.name, optional: isOptional(typeSchemas.request?.schema) } : void 0, params: typeSchemas.queryParams?.name ? { type: typeSchemas.queryParams?.name, optional: isOptional(typeSchemas.queryParams?.schema) } : void 0, headers: typeSchemas.headerParams?.name ? { type: typeSchemas.headerParams?.name, optional: isOptional(typeSchemas.headerParams?.schema) } : void 0 }); const mutationOptionsParams = MutationOptions.getParams({ typeSchemas }); const TRequest = mutationParams.toConstructor(); const generics = [ dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`, `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`, TRequest ? `{${TRequest}}` : "void", "TContext" ].join(", "); const returnType = `UseMutationResult<${generics}>`; const mutationOptions = `${mutationOptionsName}(${mutationOptionsParams.toCall()})`; return /* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx(Function$1, { name, export: true, params: params.toConstructor(), JSDoc: { comments: getComments(operation) }, generics: ["TContext"], children: ` const { mutation = {}, client: config = {} } = options ?? {} const { client: queryClient, ...mutationOptions } = mutation; const mutationKey = mutationOptions.mutationKey ?? ${mutationKeyName}(${mutationKeyParams.toCall()}) const baseOptions = ${mutationOptions} as UseMutationOptions<${generics}> ${customOptions ? `const customOptions = ${customOptions.name}({ hookName: '${name}', operationId: '${operation.getOperationId()}' }) as UseMutationOptions<${generics}>` : ""} return useMutation<${generics}>({ ...baseOptions,${customOptions ? "\n...customOptions," : ""} mutationKey, ...mutationOptions, }, queryClient) as ${returnType} ` }) }); } //#endregion //#region src/components/Query.tsx function getParams$3({ paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas }) { const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`; const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`; if (paramsType === "object") { const children = { ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }), data: typeSchemas.request?.name ? { type: typeSchemas.request?.name, optional: isOptional(typeSchemas.request?.schema) } : void 0, params: typeSchemas.queryParams?.name ? { type: typeSchemas.queryParams?.name, optional: isOptional(typeSchemas.queryParams?.schema) } : void 0, headers: typeSchemas.headerParams?.name ? { type: typeSchemas.headerParams?.name, optional: isOptional(typeSchemas.headerParams?.schema) } : void 0 }; const allChildrenAreOptional = Object.values(children).every((child) => !child || child.optional); return FunctionParams.factory({ data: { mode: "object", children, default: allChildrenAreOptional ? "{}" : void 0 }, options: { type: ` { query?: Partial<QueryObserverOptions<${[ TData, TError, "TData", "TQueryData", "TQueryKey" ].join(", ")}>> & { client?: QueryClient }, client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"} } `, default: "{}" } }); } return FunctionParams.factory({ pathParams: typeSchemas.pathParams?.name ? { mode: pathParamsType === "object" ? "object" : "inlineSpread", children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }), default: isAllOptional(typeSchemas.pathParams?.schema) ? "{}" : void 0 } : void 0, data: typeSchemas.request?.name ? { type: typeSchemas.request?.name, optional: isOptional(typeSchemas.request?.schema) } : void 0, params: typeSchemas.queryParams?.name ? { type: typeSchemas.queryParams?.name, optional: isOptional(typeSchemas.queryParams?.schema) } : void 0, headers: typeSchemas.headerParams?.name ? { type: typeSchemas.headerParams?.name, optional: isOptional(typeSchemas.headerParams?.schema) } : void 0, options: { type: ` { query?: Partial<QueryObserverOptions<${[ TData, TError, "TData", "TQueryData", "TQueryKey" ].join(", ")}>> & { client?: QueryClient }, client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"} } `, default: "{}" } }); } __name(getParams$3, "getParams"); function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas, operation, customOptions }) { const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`; const returnType = `UseQueryResult<${["TData", `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`].join(", ")}> & { queryKey: TQueryKey }`; const generics = [ `TData = ${TData}`, `TQueryData = ${TData}`, `TQueryKey extends QueryKey = ${queryKeyTypeName}` ]; const queryKeyParams = QueryKey.getParams({ pathParamsType, typeSchemas, paramsCasing }); const queryOptionsParams = QueryOptions.getParams({ paramsType, pathParamsType, typeSchemas, paramsCasing }); const params = getParams$3({ paramsCasing, paramsType, pathParamsType, dataReturnType, typeSchemas }); const queryOptions = `${queryOptionsName}(${queryOptionsParams.toCall()})`; return /* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx(Function$1, { name, export: true, generics: generics.join(", "), params: params.toConstructor(), JSDoc: { comments: getComments(operation) }, children: ` const { query: queryConfig = {}, client: config = {} } = options ?? {} const { client: queryClient, ...resolvedOptions } = queryConfig const queryKey = resolvedOptions?.queryKey ?? ${queryKeyName}(${queryKeyParams.toCall()}) ${customOptions ? `const customOptions = ${customOptions.name}({ hookName: '${name}', operationId: '${operation.getOperationId()}' })` : ""} const query = useQuery({ ...${queryOptions},${customOptions ? "\n...customOptions," : ""} ...resolvedOptions, queryKey, } as unknown as QueryObserverOptions, queryClient) as ${returnType} query.queryKey = queryKey as TQueryKey return query ` }) }); } Query.getParams = getParams$3; //#endregion //#region src/components/SuspenseInfiniteQuery.tsx function getParams$2({ paramsType, paramsCasing, pathParamsType, typeSchemas, pageParamGeneric }) { if (paramsType === "object") { const children = { ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }), data: typeSchemas.request?.name ? { type: typeSchemas.request?.name, optional: isOptional(typeSchemas.request?.schema) } : void 0, params: typeSchemas.queryParams?.name ? { type: typeSchemas.queryParams?.name, optional: isOptional(typeSchemas.queryParams?.schema) } : void 0, headers: typeSchemas.headerParams?.name ? { type: typeSchemas.headerParams?.name, optional: isOptional(typeSchemas.headerParams?.schema) } : void 0 }; const allChildrenAreOptional = Object.values(children).every((child) => !child || child.optional); return FunctionParams.factory({ data: { mode: "object", children, default: allChildrenAreOptional ? "{}" : void 0 }, options: { type: ` { query?: Partial<UseSuspenseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, ${pageParamGeneric}>> & { client?: QueryClient }, client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"} } `, default: "{}" } }); } return FunctionParams.factory({ pathParams: typeSchemas.pathParams?.name ? { mode: pathParamsType === "object" ? "object" : "inlineSpread", children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }), default: isAllOptional(typeSchemas.pathParams?.schema) ? "{}" : void 0 } : void 0, data: typeSchemas.request?.name ? { type: typeSchemas.request?.name, optional: isOptional(typeSchemas.request?.schema) } : void 0, params: typeSchemas.queryParams?.name ? { type: typeSchemas.queryParams?.name, optional: isOptional(typeSchemas.queryParams?.schema) } : void 0, headers: typeSchemas.headerParams?.name ? { type: typeSchemas.headerParams?.name, optional: isOptional(typeSchemas.headerParams?.schema) } : void 0, options: { type: ` { query?: Partial<UseSuspenseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, ${pageParamGeneric}>> & { client?: QueryClient }, client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"} } `, default: "{}" } }); } __name(getParams$2, "getParams"); function SuspenseInfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas, operation, customOptions, initialPageParam, queryParam }) { const responseType = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`; const errorType = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`; const isInitialPageParamDefined = initialPageParam !== void 0 && initialPageParam !== null; const fallbackPageParamType = typeof initialPageParam === "number" ? "number" : typeof initialPageParam === "string" ? initialPageParam.includes(" as ") ? (() => { const parts = initialPageParam.split(" as "); return parts[parts.length - 1] ?? "unknown"; })() : "string" : typeof initialPageParam === "boolean" ? "boolean" : "unknown"; const queryParamType = queryParam && typeSchemas.queryParams?.name ? `${typeSchemas.queryParams?.name}['${queryParam}']` : void 0; const pageParamType = queryParamType ? isInitialPageParamDefined ? `NonNullable<${queryParamType}>` : queryParamType : fallbackPageParamType; const returnType = "UseSuspenseInfiniteQueryResult<TData, TError> & { queryKey: TQueryKey }"; const generics = [ `TQueryFnData = ${responseType}`, `TError = ${errorType}`, "TData = InfiniteData<TQueryFnData>", `TQueryKey extends QueryKey = ${queryKeyTypeName}`, `TPageParam = ${pageParamType}` ]; const queryKeyParams = QueryKey.getParams({ pathParamsType, typeSchemas, paramsCasing }); const queryOptionsParams = QueryOptions.getParams({ paramsType, pathParamsType, typeSchemas, paramsCasing }); const params = getParams$2({ paramsCasing, paramsType, pathParamsType, typeSchemas, pageParamGeneric: "TPageParam" }); const queryOptions = `${queryOptionsName}(${queryOptionsParams.toCall()})`; return /* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx(Function$1, { name, export: true, generics: generics.join(", "), params: params.toConstructor(), JSDoc: { comments: getComments(operation) }, children: ` const { query: queryConfig = {}, client: config = {} } = options ?? {} const { client: queryClient, ...resolvedOptions } = queryConfig const queryKey = resolvedOptions?.queryKey ?? ${queryKeyName}(${queryKeyParams.toCall()}) ${customOptions ? `const customOptions = ${customOptions.name}({ hookName: '${name}', operationId: '${operation.getOperationId()}' })` : ""} const query = useSuspenseInfiniteQuery({ ...${queryOptions},${customOptions ? "\n...customOptions," : ""} ...resolvedOptions, queryKey, } as unknown as UseSuspenseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, queryClient) as ${returnType} query.queryKey = queryKey as TQueryKey return query ` }) }); } SuspenseInfiniteQuery.getParams = getParams$2; //#endregion //#region src/components/SuspenseInfiniteQueryOptions.tsx function getParams$1({ paramsType, paramsCasing, pathParamsType, typeSchemas }) { if (paramsType === "object") { const children = { ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }), data: typeSchemas.request?.name ? { type: typeSchemas.request?.name, optional: isOptional(typeSchemas.request?.schema) } : void 0, params: typeSchemas.queryParams?.name ? { type: typeSchemas.queryParams?.name, optional: isOptional(typeSchemas.queryParams?.schema) } : void 0, headers: typeSchemas.headerParams?.name ? { type: typeSchemas.headerParams?.name, optional: isOptional(typeSchemas.headerParams?.schema) } : void 0 }; const allChildrenAreOptional = Object.values(children).every((child) => !child || child.optional); return FunctionParams.factory({ data: { mode: "object", children, default: allChildrenAreOptional ? "{}" : void 0 }, config: { type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }", default: "{}" } }); } return FunctionParams.factory({ pathParams: typeSchemas.pathParams?.name ? { mode: pathParamsType === "object" ? "object" : "inlineSpread", children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }), default: isAllOptional(typeSchemas.pathParams?.schema) ? "{}" : void 0 } : void 0, data: typeSchemas.request?.name ? { type: typeSchemas.request?.name, optional: isOptional(typeSchemas.request?.schema) } : void 0, params: typeSchemas.queryParams?.name ? { type: typeSchemas.queryParams?.name, optional: isOptional(typeSchemas.queryParams?.schema) } : void 0, headers: typeSchemas.headerParams?.name ? { type: typeSchemas.headerParams?.name, optional: isOptional(typeSchemas.headerParams?.schema) } : void 0, config: { type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }", default: "{}" } }); } __name(getParams$1, "getParams"); function SuspenseInfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam, nextParam, previousParam, typeSchemas, paramsCasing, paramsType, dataReturnType, pathParamsType, queryParam, queryKeyName }) { const queryFnDataType = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`; const errorType = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`; const isInitialPageParamDefined = initialPageParam !== void 0 && initialPageParam !== null; const fallbackPageParamType = typeof initialPageParam === "number" ? "number" : typeof initialPageParam === "string" ? initialPageParam.includes(" as ") ? (() => { const parts = initialPageParam.split(" as "); return parts[parts.length - 1] ?? "unknown"; })() : "string" : typeof initialPageParam === "boolean" ? "boolean" : "unknown"; const queryParamType = queryParam && typeSchemas.queryParams?.name ? `${typeSchemas.queryParams?.name}['${queryParam}']` : void 0; const pageParamType = queryParamType ? isInitialPageParamDefined ? `NonNullable<${queryParamType}>` : queryParamType : fallbackPageParamType; const params = getParams$1({ paramsType, paramsCasing, pathParamsType, typeSchemas }); const clientParams = Client.getParams({ paramsCasing, typeSchemas, paramsType, pathParamsType, isConfigurable: true }); const queryKeyParams = QueryKey.getParams({ pathParamsType, typeSchemas, paramsCasing }); const hasNewParams = nextParam !== void 0 || previousParam !== void 0; let getNextPageParamExpr; let getPreviousPageParamExpr; if (hasNewParams) { if (nextParam) { const accessor = getNestedAccessor(nextParam, "lastPage"); if (accessor) getNextPageParamExpr = `getNextPageParam: (lastPage) => ${accessor}`; } if (previousParam) { const accessor = getNestedAccessor(previousParam, "firstPage"); if (accessor) getPreviousPageParamExpr = `getPreviousPageParam: (firstPage) => ${accessor}`; } } else if (cursorParam) { getNextPageParamExpr = `getNextPageParam: (lastPage) => lastPage['${cursorParam}']`; getPreviousPageParamExpr = `getPreviousPageParam: (firstPage) => firstPage['${cursorParam}']`; } else { if (dataReturnType === "full") getNextPageParamExpr = "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage.data) && lastPage.data.length === 0 ? undefined : lastPageParam + 1"; else getNextPageParamExpr = "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage) && lastPage.length === 0 ? undefined : lastPageParam + 1"; getPreviousPageParamExpr = "getPreviousPageParam: (_firstPage, _allPages, firstPageParam) => firstPageParam <= 1 ? undefined : firstPageParam - 1"; } const queryOptions = [ `initialPageParam: ${typeof initialPageParam === "string" ? JSON.stringify(initialPageParam) : initialPageParam}`, getNextPageParamExpr, getPreviousPageParamExpr ].filter(Boolean); const infiniteOverrideParams = queryParam && typeSchemas.queryParams?.name ? ` params = { ...(params ?? {}), ['${queryParam}']: pageParam as unknown as ${typeSchemas.queryParams?.name}['${queryParam}'], } as ${typeSchemas.queryParams?.name}` : ""; const enabled = Object.entries(queryKeyParams.flatParams).map(([key, item]) => { return item && !item.optional && !item.default ? key : void 0; }).filter(Boolean).join("&& "); const enabledText = enabled ? `enabled: !!(${enabled}),` : ""; if (infiniteOverrideParams) return /* @__PURE__ *