@kubb/plugin-solid-query 3.17.0 → 3.17.1
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/dist/{components-LAcBpjX8.cjs → components-CCkbce4B.cjs} +4 -3
- package/dist/components-CCkbce4B.cjs.map +1 -0
- package/dist/{components-CNM6UaoG.js → components-DteoGXDw.js} +4 -3
- package/dist/components-DteoGXDw.js.map +1 -0
- package/dist/components.cjs +1 -1
- package/dist/components.d.cts +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/components.js +1 -1
- package/dist/{generators-DU74wsZY.js → generators-D4zsCZ8Y.js} +3 -3
- package/dist/{generators-DU74wsZY.js.map → generators-D4zsCZ8Y.js.map} +1 -1
- package/dist/{generators-DS71XOIi.cjs → generators-yp4-76zC.cjs} +3 -3
- package/dist/{generators-DS71XOIi.cjs.map → generators-yp4-76zC.cjs.map} +1 -1
- package/dist/generators.cjs +2 -2
- package/dist/generators.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/generators.js +2 -2
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/{types-C4Kxe-X1.d.ts → types-Ci_4FqMj.d.ts} +54 -54
- package/dist/{types-DULzisVA.d.cts → types-DLEwjVmP.d.cts} +54 -54
- package/package.json +9 -9
- package/src/components/Query.tsx +4 -4
- package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +2 -1
- package/src/generators/__snapshots__/clientGetImportPath.ts +2 -1
- package/src/generators/__snapshots__/findByTags.ts +2 -1
- package/src/generators/__snapshots__/findByTagsObject.ts +2 -1
- package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +2 -1
- package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +2 -1
- package/src/generators/__snapshots__/findByTagsWithZod.ts +2 -1
- package/src/generators/__snapshots__/postAsQuery.ts +2 -1
- package/dist/components-CNM6UaoG.js.map +0 -1
- package/dist/components-LAcBpjX8.cjs.map +0 -1
|
@@ -21,9 +21,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
21
|
}) : target, mod));
|
|
22
22
|
|
|
23
23
|
//#endregion
|
|
24
|
-
const __kubb_react = __toESM(require("@kubb/react"));
|
|
25
24
|
const __kubb_oas = __toESM(require("@kubb/oas"));
|
|
26
25
|
const __kubb_plugin_oas_utils = __toESM(require("@kubb/plugin-oas/utils"));
|
|
26
|
+
const __kubb_react = __toESM(require("@kubb/react"));
|
|
27
27
|
const __kubb_core_utils = __toESM(require("@kubb/core/utils"));
|
|
28
28
|
const __kubb_react_jsx_runtime = __toESM(require("@kubb/react/jsx-runtime"));
|
|
29
29
|
const __kubb_plugin_client_components = __toESM(require("@kubb/plugin-client/components"));
|
|
@@ -321,7 +321,8 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsC
|
|
|
321
321
|
params: params.toConstructor(),
|
|
322
322
|
JSDoc: { comments: (0, __kubb_plugin_oas_utils.getComments)(operation) },
|
|
323
323
|
children: `
|
|
324
|
-
const { query:
|
|
324
|
+
const { query: queryConfig = {}, client: config = {} } = options ?? {}
|
|
325
|
+
const { client: queryClient, ...queryOptions } = queryConfig
|
|
325
326
|
const queryKey = queryOptions?.queryKey ?? ${queryKeyName}(${queryKeyParams.toCall()})
|
|
326
327
|
|
|
327
328
|
const query = createQuery(() => ({
|
|
@@ -363,4 +364,4 @@ Object.defineProperty(exports, '__toESM', {
|
|
|
363
364
|
return __toESM;
|
|
364
365
|
}
|
|
365
366
|
});
|
|
366
|
-
//# sourceMappingURL=components-
|
|
367
|
+
//# sourceMappingURL=components-CCkbce4B.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components-CCkbce4B.cjs","names":["getParams","FunctionParams","getTransformer: Transformer","URLPath","File","Function","Type","getParams","FunctionParams","Client","File","Function","FunctionParams","File","Function"],"sources":["../src/components/QueryKey.tsx","../src/components/QueryOptions.tsx","../src/components/Query.tsx"],"sourcesContent":["import { URLPath } from '@kubb/core/utils'\nimport { getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams, Type } from '@kubb/react'\n\nimport { type Operation, isOptional } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport type { ReactNode } from 'react'\nimport type { PluginSolidQuery, Transformer } from '../types'\n\ntype Props = {\n name: string\n typeName: string\n typeSchemas: OperationSchemas\n operation: Operation\n paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n transformer: Transformer | undefined\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ pathParamsType, paramsCasing, typeSchemas }: GetParamsProps) {\n return FunctionParams.factory({\n pathParams: {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n },\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n })\n}\n\nconst getTransformer: Transformer = ({ operation, schemas, casing }) => {\n const path = new URLPath(operation.path, { casing })\n const keys = [\n path.toObject({\n type: 'path',\n stringify: true,\n }),\n schemas.queryParams?.name ? '...(params ? [params] : [])' : undefined,\n schemas.request?.name ? '...(data ? [data] : [])' : undefined,\n ].filter(Boolean)\n\n return keys\n}\n\nexport function QueryKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer = getTransformer }: Props): ReactNode {\n const params = getParams({ pathParamsType, paramsCasing, typeSchemas })\n const keys = transformer({\n operation,\n schemas: typeSchemas,\n casing: paramsCasing,\n })\n\n return (\n <>\n <File.Source name={name} isExportable isIndexable>\n <Function.Arrow name={name} export params={params.toConstructor()} singleLine>\n {`[${keys.join(', ')}] as const`}\n </Function.Arrow>\n </File.Source>\n <File.Source name={typeName} isExportable isIndexable isTypeOnly>\n <Type name={typeName} export>\n {`ReturnType<typeof ${name}>`}\n </Type>\n </File.Source>\n </>\n )\n}\n\nQueryKey.getParams = getParams\nQueryKey.getTransformer = getTransformer\n","import { getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams } from '@kubb/react'\n\nimport type { ReactNode } from 'react'\n\nimport { isOptional } from '@kubb/oas'\nimport { Client } from '@kubb/plugin-client/components'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport type { PluginSolidQuery } from '../types.ts'\nimport { QueryKey } from './QueryKey.tsx'\n\ntype Props = {\n name: string\n clientName: string\n queryKeyName: string\n typeSchemas: OperationSchemas\n paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']\n paramsType: PluginSolidQuery['resolvedOptions']['paramsType']\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n dataReturnType: PluginSolidQuery['resolvedOptions']['client']['dataReturnType']\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']\n paramsType: PluginSolidQuery['resolvedOptions']['paramsType']\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }: GetParamsProps) {\n if (paramsType === 'object') {\n return FunctionParams.factory({\n data: {\n mode: 'object',\n children: {\n ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n },\n },\n config: {\n type: typeSchemas.request?.name\n ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }`\n : 'Partial<RequestConfig> & { client?: typeof fetch }',\n default: '{}',\n },\n })\n }\n\n return FunctionParams.factory({\n pathParams: typeSchemas.pathParams?.name\n ? {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n optional: isOptional(typeSchemas.pathParams?.schema),\n }\n : undefined,\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n config: {\n type: typeSchemas.request?.name\n ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }`\n : 'Partial<RequestConfig> & { client?: typeof fetch }',\n default: '{}',\n },\n })\n}\n\nexport function QueryOptions({ name, clientName, typeSchemas, paramsCasing, paramsType, dataReturnType, pathParamsType, queryKeyName }: Props): ReactNode {\n const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`\n const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`\n\n const params = getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas })\n const clientParams = Client.getParams({\n paramsCasing,\n typeSchemas,\n paramsType,\n pathParamsType,\n isConfigurable: true,\n })\n const queryKeyParams = QueryKey.getParams({\n pathParamsType,\n paramsCasing,\n typeSchemas,\n })\n\n const enabled = Object.entries(queryKeyParams.flatParams)\n .map(([key, item]) => (item && !item.optional ? key : undefined))\n .filter(Boolean)\n .join('&& ')\n\n const enabledText = enabled ? `enabled: !!(${enabled}),` : ''\n\n return (\n <File.Source name={name} isExportable isIndexable>\n <Function name={name} export params={params.toConstructor()}>\n {`\n const queryKey = ${queryKeyName}(${queryKeyParams.toCall()})\n return queryOptions<${TData}, ${TError}, ${TData}, typeof queryKey>({\n ${enabledText}\n queryKey,\n queryFn: async ({ signal }) => {\n config.signal = signal\n return ${clientName}(${clientParams.toCall()})\n },\n })\n`}\n </Function>\n </File.Source>\n )\n}\n\nQueryOptions.getParams = getParams\n","import { isOptional, type Operation } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getComments, getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams } from '@kubb/react'\nimport type { ReactNode } from 'react'\nimport type { PluginSolidQuery } from '../types.ts'\nimport { QueryKey } from './QueryKey.tsx'\nimport { QueryOptions } from './QueryOptions.tsx'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n queryOptionsName: string\n queryKeyName: string\n queryKeyTypeName: string\n typeSchemas: OperationSchemas\n operation: Operation\n paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']\n paramsType: PluginSolidQuery['resolvedOptions']['paramsType']\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n dataReturnType: PluginSolidQuery['resolvedOptions']['client']['dataReturnType']\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']\n paramsType: PluginSolidQuery['resolvedOptions']['paramsType']\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n dataReturnType: PluginSolidQuery['resolvedOptions']['client']['dataReturnType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas }: GetParamsProps) {\n const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`\n const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`\n\n if (paramsType === 'object') {\n return FunctionParams.factory({\n data: {\n mode: 'object',\n children: {\n ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n },\n },\n options: {\n type: `\n{\n query?: Partial<UseBaseQueryOptions<${[TData, TError, 'TData', 'TQueryData', 'TQueryKey'].join(', ')}>> & { client?: QueryClient },\n client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : 'Partial<RequestConfig> & { client?: typeof fetch }'}\n}\n`,\n default: '{}',\n },\n })\n }\n\n return FunctionParams.factory({\n pathParams: typeSchemas.pathParams?.name\n ? {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n optional: isOptional(typeSchemas.pathParams?.schema),\n }\n : undefined,\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n options: {\n type: `\n{\n query?: Partial<UseBaseQueryOptions<${[TData, TError, 'TData', 'TQueryData', 'TQueryKey'].join(', ')}>> & { client?: QueryClient },\n client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : 'Partial<RequestConfig> & { client?: typeof fetch }'}\n}\n`,\n default: '{}',\n },\n })\n}\n\nexport function Query({\n name,\n queryKeyTypeName,\n queryOptionsName,\n queryKeyName,\n paramsCasing,\n paramsType,\n pathParamsType,\n dataReturnType,\n typeSchemas,\n operation,\n}: Props): ReactNode {\n const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`\n const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`\n const returnType = `UseQueryResult<${['TData', TError].join(', ')}> & { queryKey: TQueryKey }`\n const generics = [`TData = ${TData}`, `TQueryData = ${TData}`, `TQueryKey extends QueryKey = ${queryKeyTypeName}`]\n\n const queryKeyParams = QueryKey.getParams({\n pathParamsType,\n typeSchemas,\n paramsCasing,\n })\n const queryOptionsParams = QueryOptions.getParams({\n paramsType,\n paramsCasing,\n pathParamsType,\n typeSchemas,\n })\n const params = getParams({\n paramsCasing,\n paramsType,\n pathParamsType,\n dataReturnType,\n typeSchemas,\n })\n\n const queryOptions = `${queryOptionsName}(${queryOptionsParams.toCall()}) as unknown as UseBaseQueryOptions`\n\n return (\n <File.Source name={name} isExportable isIndexable>\n <Function\n name={name}\n export\n generics={generics.join(', ')}\n params={params.toConstructor()}\n JSDoc={{\n comments: getComments(operation),\n }}\n >\n {`\n const { query: queryConfig = {}, client: config = {} } = options ?? {}\n const { client: queryClient, ...queryOptions } = queryConfig\n const queryKey = queryOptions?.queryKey ?? ${queryKeyName}(${queryKeyParams.toCall()})\n\n const query = createQuery(() => ({\n ...${queryOptions},\n queryKey,\n initialData: null,\n ...queryOptions as unknown as Omit<UseBaseQueryOptions, \"queryKey\">\n }), queryClient? () => queryClient: undefined) as ${returnType}\n\n return query\n `}\n </Function>\n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AAS,KAAK,MAAM,KAAK,UAAU,QAAQ;CAC1G,MAAM,aAAa,kBAAkB,CAAC,SAAS,OAAO,CAAC,KAAK,MAAM;CAClE,MAAM,WAAW;EAAC,WAAW;EAAS,gBAAgB;EAAS,gCAAgC;EAAmB;CAElH,MAAM,iBAAiB,SAAS,UAAU;EACxC;EACA;EACA;EACD;CACD,MAAM,qBAAqB,aAAa,UAAU;EAChD;EACA;EACA;EACA;EACD;CACD,MAAM,SAAS,UAAU;EACvB;EACA;EACA;EACA;EACA;EACD;CAED,MAAM,eAAe,GAAG,iBAAiB,GAAG,mBAAmB,SAAS;AAExE,QACE,kDAACC,kBAAK;EAAa;EAAM;EAAa;YACpC,kDAACC;GACO;GACN;GACA,UAAU,SAAS,KAAK;GACxB,QAAQ,OAAO;GACf,OAAO,EACL,mDAAsB,YACvB;aAEA;;;oDAG2C,aAAa,GAAG,eAAe,SAAS;;;aAG/E,aAAa;;;;2DAIiC,WAAW;;;;;;AAOrE;AAED,MAAM,YAAY"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { File, Function, FunctionParams, Type } from "@kubb/react";
|
|
2
1
|
import { isOptional } from "@kubb/oas";
|
|
3
2
|
import { getComments, getPathParams } from "@kubb/plugin-oas/utils";
|
|
3
|
+
import { File, Function, FunctionParams, Type } from "@kubb/react";
|
|
4
4
|
import { URLPath } from "@kubb/core/utils";
|
|
5
5
|
import { Fragment, jsx, jsxs } from "@kubb/react/jsx-runtime";
|
|
6
6
|
import { Client } from "@kubb/plugin-client/components";
|
|
@@ -298,7 +298,8 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsC
|
|
|
298
298
|
params: params.toConstructor(),
|
|
299
299
|
JSDoc: { comments: getComments(operation) },
|
|
300
300
|
children: `
|
|
301
|
-
const { query:
|
|
301
|
+
const { query: queryConfig = {}, client: config = {} } = options ?? {}
|
|
302
|
+
const { client: queryClient, ...queryOptions } = queryConfig
|
|
302
303
|
const queryKey = queryOptions?.queryKey ?? ${queryKeyName}(${queryKeyParams.toCall()})
|
|
303
304
|
|
|
304
305
|
const query = createQuery(() => ({
|
|
@@ -317,4 +318,4 @@ Query.getParams = getParams;
|
|
|
317
318
|
|
|
318
319
|
//#endregion
|
|
319
320
|
export { Query, QueryKey, QueryOptions };
|
|
320
|
-
//# sourceMappingURL=components-
|
|
321
|
+
//# sourceMappingURL=components-DteoGXDw.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components-DteoGXDw.js","names":["getParams","getTransformer: Transformer","getParams"],"sources":["../src/components/QueryKey.tsx","../src/components/QueryOptions.tsx","../src/components/Query.tsx"],"sourcesContent":["import { URLPath } from '@kubb/core/utils'\nimport { getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams, Type } from '@kubb/react'\n\nimport { type Operation, isOptional } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport type { ReactNode } from 'react'\nimport type { PluginSolidQuery, Transformer } from '../types'\n\ntype Props = {\n name: string\n typeName: string\n typeSchemas: OperationSchemas\n operation: Operation\n paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n transformer: Transformer | undefined\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ pathParamsType, paramsCasing, typeSchemas }: GetParamsProps) {\n return FunctionParams.factory({\n pathParams: {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n },\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n })\n}\n\nconst getTransformer: Transformer = ({ operation, schemas, casing }) => {\n const path = new URLPath(operation.path, { casing })\n const keys = [\n path.toObject({\n type: 'path',\n stringify: true,\n }),\n schemas.queryParams?.name ? '...(params ? [params] : [])' : undefined,\n schemas.request?.name ? '...(data ? [data] : [])' : undefined,\n ].filter(Boolean)\n\n return keys\n}\n\nexport function QueryKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer = getTransformer }: Props): ReactNode {\n const params = getParams({ pathParamsType, paramsCasing, typeSchemas })\n const keys = transformer({\n operation,\n schemas: typeSchemas,\n casing: paramsCasing,\n })\n\n return (\n <>\n <File.Source name={name} isExportable isIndexable>\n <Function.Arrow name={name} export params={params.toConstructor()} singleLine>\n {`[${keys.join(', ')}] as const`}\n </Function.Arrow>\n </File.Source>\n <File.Source name={typeName} isExportable isIndexable isTypeOnly>\n <Type name={typeName} export>\n {`ReturnType<typeof ${name}>`}\n </Type>\n </File.Source>\n </>\n )\n}\n\nQueryKey.getParams = getParams\nQueryKey.getTransformer = getTransformer\n","import { getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams } from '@kubb/react'\n\nimport type { ReactNode } from 'react'\n\nimport { isOptional } from '@kubb/oas'\nimport { Client } from '@kubb/plugin-client/components'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport type { PluginSolidQuery } from '../types.ts'\nimport { QueryKey } from './QueryKey.tsx'\n\ntype Props = {\n name: string\n clientName: string\n queryKeyName: string\n typeSchemas: OperationSchemas\n paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']\n paramsType: PluginSolidQuery['resolvedOptions']['paramsType']\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n dataReturnType: PluginSolidQuery['resolvedOptions']['client']['dataReturnType']\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']\n paramsType: PluginSolidQuery['resolvedOptions']['paramsType']\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }: GetParamsProps) {\n if (paramsType === 'object') {\n return FunctionParams.factory({\n data: {\n mode: 'object',\n children: {\n ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n },\n },\n config: {\n type: typeSchemas.request?.name\n ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }`\n : 'Partial<RequestConfig> & { client?: typeof fetch }',\n default: '{}',\n },\n })\n }\n\n return FunctionParams.factory({\n pathParams: typeSchemas.pathParams?.name\n ? {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n optional: isOptional(typeSchemas.pathParams?.schema),\n }\n : undefined,\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n config: {\n type: typeSchemas.request?.name\n ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }`\n : 'Partial<RequestConfig> & { client?: typeof fetch }',\n default: '{}',\n },\n })\n}\n\nexport function QueryOptions({ name, clientName, typeSchemas, paramsCasing, paramsType, dataReturnType, pathParamsType, queryKeyName }: Props): ReactNode {\n const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`\n const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`\n\n const params = getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas })\n const clientParams = Client.getParams({\n paramsCasing,\n typeSchemas,\n paramsType,\n pathParamsType,\n isConfigurable: true,\n })\n const queryKeyParams = QueryKey.getParams({\n pathParamsType,\n paramsCasing,\n typeSchemas,\n })\n\n const enabled = Object.entries(queryKeyParams.flatParams)\n .map(([key, item]) => (item && !item.optional ? key : undefined))\n .filter(Boolean)\n .join('&& ')\n\n const enabledText = enabled ? `enabled: !!(${enabled}),` : ''\n\n return (\n <File.Source name={name} isExportable isIndexable>\n <Function name={name} export params={params.toConstructor()}>\n {`\n const queryKey = ${queryKeyName}(${queryKeyParams.toCall()})\n return queryOptions<${TData}, ${TError}, ${TData}, typeof queryKey>({\n ${enabledText}\n queryKey,\n queryFn: async ({ signal }) => {\n config.signal = signal\n return ${clientName}(${clientParams.toCall()})\n },\n })\n`}\n </Function>\n </File.Source>\n )\n}\n\nQueryOptions.getParams = getParams\n","import { isOptional, type Operation } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getComments, getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams } from '@kubb/react'\nimport type { ReactNode } from 'react'\nimport type { PluginSolidQuery } from '../types.ts'\nimport { QueryKey } from './QueryKey.tsx'\nimport { QueryOptions } from './QueryOptions.tsx'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n queryOptionsName: string\n queryKeyName: string\n queryKeyTypeName: string\n typeSchemas: OperationSchemas\n operation: Operation\n paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']\n paramsType: PluginSolidQuery['resolvedOptions']['paramsType']\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n dataReturnType: PluginSolidQuery['resolvedOptions']['client']['dataReturnType']\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']\n paramsType: PluginSolidQuery['resolvedOptions']['paramsType']\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n dataReturnType: PluginSolidQuery['resolvedOptions']['client']['dataReturnType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas }: GetParamsProps) {\n const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`\n const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`\n\n if (paramsType === 'object') {\n return FunctionParams.factory({\n data: {\n mode: 'object',\n children: {\n ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n },\n },\n options: {\n type: `\n{\n query?: Partial<UseBaseQueryOptions<${[TData, TError, 'TData', 'TQueryData', 'TQueryKey'].join(', ')}>> & { client?: QueryClient },\n client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : 'Partial<RequestConfig> & { client?: typeof fetch }'}\n}\n`,\n default: '{}',\n },\n })\n }\n\n return FunctionParams.factory({\n pathParams: typeSchemas.pathParams?.name\n ? {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n optional: isOptional(typeSchemas.pathParams?.schema),\n }\n : undefined,\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n options: {\n type: `\n{\n query?: Partial<UseBaseQueryOptions<${[TData, TError, 'TData', 'TQueryData', 'TQueryKey'].join(', ')}>> & { client?: QueryClient },\n client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : 'Partial<RequestConfig> & { client?: typeof fetch }'}\n}\n`,\n default: '{}',\n },\n })\n}\n\nexport function Query({\n name,\n queryKeyTypeName,\n queryOptionsName,\n queryKeyName,\n paramsCasing,\n paramsType,\n pathParamsType,\n dataReturnType,\n typeSchemas,\n operation,\n}: Props): ReactNode {\n const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`\n const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`\n const returnType = `UseQueryResult<${['TData', TError].join(', ')}> & { queryKey: TQueryKey }`\n const generics = [`TData = ${TData}`, `TQueryData = ${TData}`, `TQueryKey extends QueryKey = ${queryKeyTypeName}`]\n\n const queryKeyParams = QueryKey.getParams({\n pathParamsType,\n typeSchemas,\n paramsCasing,\n })\n const queryOptionsParams = QueryOptions.getParams({\n paramsType,\n paramsCasing,\n pathParamsType,\n typeSchemas,\n })\n const params = getParams({\n paramsCasing,\n paramsType,\n pathParamsType,\n dataReturnType,\n typeSchemas,\n })\n\n const queryOptions = `${queryOptionsName}(${queryOptionsParams.toCall()}) as unknown as UseBaseQueryOptions`\n\n return (\n <File.Source name={name} isExportable isIndexable>\n <Function\n name={name}\n export\n generics={generics.join(', ')}\n params={params.toConstructor()}\n JSDoc={{\n comments: getComments(operation),\n }}\n >\n {`\n const { query: queryConfig = {}, client: config = {} } = options ?? {}\n const { client: queryClient, ...queryOptions } = queryConfig\n const queryKey = queryOptions?.queryKey ?? ${queryKeyName}(${queryKeyParams.toCall()})\n\n const query = createQuery(() => ({\n ...${queryOptions},\n queryKey,\n initialData: null,\n ...queryOptions as unknown as Omit<UseBaseQueryOptions, \"queryKey\">\n }), queryClient? () => queryClient: undefined) as ${returnType}\n\n return query\n `}\n </Function>\n </File.Source>\n )\n}\n\nQuery.getParams = getParams\n"],"mappings":";;;;;;;;AAyBA,SAASA,YAAU,EAAE,gBAAgB,cAAc,aAA6B,EAAE;AAChF,QAAO,eAAe,QAAQ;EAC5B,YAAY;GACV,MAAM,mBAAmB,WAAW,WAAW;GAC/C,UAAU,cAAc,YAAY,YAAY;IAAE,OAAO;IAAM,QAAQ;IAAc;GACtF;EACD,MAAM,YAAY,SAAS,OACvB;GACE,MAAM,YAAY,SAAS;GAC3B,UAAU,WAAW,YAAY,SAAS;GAC3C,GACD;EACJ,QAAQ,YAAY,aAAa,OAC7B;GACE,MAAM,YAAY,aAAa;GAC/B,UAAU,WAAW,YAAY,aAAa;GAC/C,GACD;EACL;AACF;AAED,MAAMC,kBAA+B,EAAE,WAAW,SAAS,QAAQ,KAAK;CACtE,MAAM,OAAO,IAAI,QAAQ,UAAU,MAAM,EAAE,QAAQ;CACnD,MAAM,OAAO;EACX,KAAK,SAAS;GACZ,MAAM;GACN,WAAW;GACZ;EACD,QAAQ,aAAa,OAAO,gCAAgC;EAC5D,QAAQ,SAAS,OAAO,4BAA4B;EACrD,CAAC,OAAO;AAET,QAAO;AACR;AAED,SAAgB,SAAS,EAAE,MAAM,aAAa,cAAc,gBAAgB,WAAW,UAAU,cAAc,gBAAuB,EAAa;CACjJ,MAAM,SAASD,YAAU;EAAE;EAAgB;EAAc;EAAa;CACtE,MAAM,O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,SAAS;GACP,MAAM;;wCAE4B;IAAC;IAAO;IAAQ;IAAS;IAAc;IAAY,CAAC,KAAK,MAAM;aAC1F,YAAY,SAAS,OAAO,yBAAyB,YAAY,SAAS,KAAK,kCAAkC,qDAAqD;;;GAG7K,SAAS;GACV;EACF;AACF;AAED,SAAgB,MAAM,EACpB,MACA,kBACA,kBACA,cACA,cACA,YACA,gBACA,gBACA,aACA,WACM,EAAa;CACnB,MAAM,QAAQ,mBAAmB,SAAS,YAAY,SAAS,OAAO,kBAAkB,YAAY,SAAS,KAAK;CAClH,MAAM,SAAS,uBAAuB,YAAY,QAAQ,KAAK,SAAS,KAAK,MAAM,KAAK,UAAU,QAAQ;CAC1G,MAAM,aAAa,kBAAkB,CAAC,SAAS,OAAO,CAAC,KAAK,MAAM;CAClE,MAAM,WAAW;EAAC,WAAW;EAAS,gBAAgB;EAAS,gCAAgC;EAAmB;CAElH,MAAM,iBAAiB,SAAS,UAAU;EACxC;EACA;EACA;EACD;CACD,MAAM,qBAAqB,aAAa,UAAU;EAChD;EACA;EACA;EACA;EACD;CACD,MAAM,SAAS,UAAU;EACvB;EACA;EACA;EACA;EACA;EACD;CAED,MAAM,eAAe,GAAG,iBAAiB,GAAG,mBAAmB,SAAS;AAExE,QACE,oBAAC,KAAK;EAAa;EAAM;EAAa;YACpC,oBAAC;GACO;GACN;GACA,UAAU,SAAS,KAAK;GACxB,QAAQ,OAAO;GACf,OAAO,EACL,UAAU,YAAY,YACvB;aAEA;;;oDAG2C,aAAa,GAAG,eAAe,SAAS;;;aAG/E,aAAa;;;;2DAIiC,WAAW;;;;;;AAOrE;AAED,MAAM,YAAY"}
|
package/dist/components.cjs
CHANGED
package/dist/components.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Operation, OperationSchemas, PluginSolidQuery, Transformer } from "./types-
|
|
1
|
+
import { Operation, OperationSchemas, PluginSolidQuery, Transformer } from "./types-DLEwjVmP.cjs";
|
|
2
2
|
import { ReactNode } from "react";
|
|
3
3
|
|
|
4
4
|
//#region ../react/src/utils/getFunctionParams.d.ts
|
package/dist/components.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Operation, OperationSchemas, PluginSolidQuery, Transformer } from "./types-
|
|
1
|
+
import { Operation, OperationSchemas, PluginSolidQuery, Transformer } from "./types-Ci_4FqMj.js";
|
|
2
2
|
import { ReactNode } from "react";
|
|
3
3
|
|
|
4
4
|
//#region ../react/src/utils/getFunctionParams.d.ts
|
package/dist/components.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Query, QueryKey, QueryOptions } from "./components-
|
|
1
|
+
import { Query, QueryKey, QueryOptions } from "./components-DteoGXDw.js";
|
|
2
2
|
import { createReactGenerator } from "@kubb/plugin-oas";
|
|
3
3
|
import { pluginTsName } from "@kubb/plugin-ts";
|
|
4
4
|
import { pluginZodName } from "@kubb/plugin-zod";
|
|
5
|
-
import { File, useApp } from "@kubb/react";
|
|
6
5
|
import { getBanner, getFooter } from "@kubb/plugin-oas/utils";
|
|
6
|
+
import { File, useApp } from "@kubb/react";
|
|
7
7
|
import { Fragment, jsx, jsxs } from "@kubb/react/jsx-runtime";
|
|
8
8
|
import { Client } from "@kubb/plugin-client/components";
|
|
9
9
|
import { pluginClientName } from "@kubb/plugin-client";
|
|
@@ -191,4 +191,4 @@ const queryGenerator = createReactGenerator({
|
|
|
191
191
|
|
|
192
192
|
//#endregion
|
|
193
193
|
export { queryGenerator };
|
|
194
|
-
//# sourceMappingURL=generators-
|
|
194
|
+
//# sourceMappingURL=generators-D4zsCZ8Y.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generators-
|
|
1
|
+
{"version":3,"file":"generators-D4zsCZ8Y.js","names":[],"sources":["../src/generators/queryGenerator.tsx"],"sourcesContent":["import { pluginClientName } from '@kubb/plugin-client'\nimport { Client } from '@kubb/plugin-client/components'\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File, useApp } from '@kubb/react'\nimport { difference } from 'remeda'\nimport { Query, QueryKey, QueryOptions } from '../components'\nimport type { PluginSolidQuery } from '../types'\n\nexport const queryGenerator = createReactGenerator<PluginSolidQuery>({\n name: 'svelte-query',\n Operation({ options, operation }) {\n const {\n plugin: {\n options: { output },\n },\n pluginManager,\n } = useApp<PluginSolidQuery>()\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const isQuery = typeof options.query === 'boolean' ? true : options.query?.methods.some((method) => operation.method === method)\n const isMutation = difference(['post', 'put', 'delete', 'patch'], options.query ? options.query.methods : []).some((method) => operation.method === method)\n const importPath = options.query ? options.query.importPath : '@tanstack/solid-query'\n\n const query = {\n name: getName(operation, { type: 'function', prefix: 'create' }),\n typeName: getName(operation, { type: 'type' }),\n file: getFile(operation, { prefix: 'create' }),\n }\n\n const hasClientPlugin = !!pluginManager.getPluginByKey([pluginClientName])\n const client = {\n name: hasClientPlugin\n ? getName(operation, {\n type: 'function',\n pluginKey: [pluginClientName],\n })\n : getName(operation, {\n type: 'function',\n }),\n file: getFile(operation, { pluginKey: [pluginClientName] }),\n }\n\n const queryOptions = {\n name: getName(operation, { type: 'function', suffix: 'QueryOptions' }),\n }\n\n const queryKey = {\n name: getName(operation, { type: 'const', suffix: 'QueryKey' }),\n typeName: getName(operation, { type: 'type', suffix: 'QueryKey' }),\n }\n\n const type = {\n file: getFile(operation, { pluginKey: [pluginTsName] }),\n //todo remove type?\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n }\n\n const zod = {\n file: getFile(operation, { pluginKey: [pluginZodName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' }),\n }\n\n if (!isQuery || isMutation) {\n return null\n }\n\n return (\n <File\n baseName={query.file.baseName}\n path={query.file.path}\n meta={query.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n {options.parser === 'zod' && (\n <File.Import name={[zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean)} root={query.file.path} path={zod.file.path} />\n )}\n <File.Import name={'fetch'} path={options.client.importPath} />\n {!!hasClientPlugin && <File.Import name={[client.name]} root={query.file.path} path={client.file.path} />}\n <File.Import name={['RequestConfig', 'ResponseErrorConfig']} path={options.client.importPath} isTypeOnly />\n {options.client.dataReturnType === 'full' && <File.Import name={['ResponseConfig']} path={options.client.importPath} isTypeOnly />}\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={query.file.path}\n path={type.file.path}\n isTypeOnly\n />\n <QueryKey\n name={queryKey.name}\n typeName={queryKey.typeName}\n operation={operation}\n paramsCasing={options.paramsCasing}\n pathParamsType={options.pathParamsType}\n typeSchemas={type.schemas}\n transformer={options.queryKey}\n />\n {!hasClientPlugin && (\n <Client\n name={client.name}\n baseURL={options.client.baseURL}\n operation={operation}\n typeSchemas={type.schemas}\n zodSchemas={zod.schemas}\n dataReturnType={options.client.dataReturnType}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n parser={options.parser}\n />\n )}\n <File.Import name={['queryOptions']} path={importPath} />\n <QueryOptions\n name={queryOptions.name}\n clientName={client.name}\n queryKeyName={queryKey.name}\n typeSchemas={type.schemas}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n dataReturnType={options.client.dataReturnType}\n />\n {options.query && (\n <>\n <File.Import name={['createQuery']} path={importPath} />\n <File.Import name={['QueryKey', 'QueryClient', 'UseBaseQueryOptions', 'UseQueryResult']} path={importPath} isTypeOnly />\n <Query\n name={query.name}\n queryOptionsName={queryOptions.name}\n typeSchemas={type.schemas}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n operation={operation}\n paramsCasing={options.paramsCasing}\n dataReturnType={options.client.dataReturnType}\n queryKeyName={queryKey.name}\n queryKeyTypeName={queryKey.typeName}\n />\n </>\n )}\n </File>\n )\n },\n})\n"],"mappings":";;;;;;;;;;;;;AAYA,MAAa,iBAAiB,qBAAuC;CACnE,MAAM;CACN,UAAU,EAAE,SAAS,WAAW,EAAE;EAChC,MAAM,EACJ,QAAQ,EACN,SAAS,EAAE,QAAQ,EACpB,EACD,eACD,GAAG;EACJ,MAAM,MAAM;EACZ,MAAM,EAAE,YAAY,SAAS,SAAS,GAAG;EAEzC,MAAM,UAAU,OAAO,QAAQ,UAAU,YAAY,OAAO,QAAQ,OAAO,QAAQ,MAAM,WAAW,UAAU,WAAW;EACzH,MAAM,aAAa,WAAW;GAAC;GAAQ;GAAO;GAAU;GAAQ,EAAE,QAAQ,QAAQ,QAAQ,MAAM,UAAU,EAAE,EAAE,MAAM,WAAW,UAAU,WAAW;EACpJ,MAAM,aAAa,QAAQ,QAAQ,QAAQ,MAAM,aAAa;EAE9D,MAAM,QAAQ;GACZ,MAAM,QAAQ,WAAW;IAAE,MAAM;IAAY,QAAQ;IAAU;GAC/D,UAAU,QAAQ,WAAW,EAAE,MAAM,QAAQ;GAC7C,MAAM,QAAQ,WAAW,EAAE,QAAQ,UAAU;GAC9C;EAED,MAAM,kBAAkB,CAAC,CAAC,cAAc,eAAe,CAAC,iBAAiB;EACzE,MAAM,SAAS;GACb,MAAM,kBACF,QAAQ,WAAW;IACjB,MAAM;IACN,WAAW,CAAC,iBAAiB;IAC9B,IACD,QAAQ,WAAW,EACjB,MAAM,YACP;GACL,MAAM,QAAQ,WAAW,EAAE,WAAW,CAAC,iBAAiB,EAAE;GAC3D;EAED,MAAM,eAAe,EACnB,MAAM,QAAQ,WAAW;GAAE,MAAM;GAAY,QAAQ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|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
const require_components = require('./components-
|
|
1
|
+
const require_components = require('./components-CCkbce4B.cjs');
|
|
2
2
|
const __kubb_plugin_oas = require_components.__toESM(require("@kubb/plugin-oas"));
|
|
3
3
|
const __kubb_plugin_ts = require_components.__toESM(require("@kubb/plugin-ts"));
|
|
4
4
|
const __kubb_plugin_zod = require_components.__toESM(require("@kubb/plugin-zod"));
|
|
5
|
-
const __kubb_react = require_components.__toESM(require("@kubb/react"));
|
|
6
5
|
const __kubb_plugin_oas_utils = require_components.__toESM(require("@kubb/plugin-oas/utils"));
|
|
6
|
+
const __kubb_react = require_components.__toESM(require("@kubb/react"));
|
|
7
7
|
const __kubb_react_jsx_runtime = require_components.__toESM(require("@kubb/react/jsx-runtime"));
|
|
8
8
|
const __kubb_plugin_client_components = require_components.__toESM(require("@kubb/plugin-client/components"));
|
|
9
9
|
const __kubb_plugin_client = require_components.__toESM(require("@kubb/plugin-client"));
|
|
@@ -196,4 +196,4 @@ Object.defineProperty(exports, 'queryGenerator', {
|
|
|
196
196
|
return queryGenerator;
|
|
197
197
|
}
|
|
198
198
|
});
|
|
199
|
-
//# sourceMappingURL=generators-
|
|
199
|
+
//# sourceMappingURL=generators-yp4-76zC.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generators-
|
|
1
|
+
{"version":3,"file":"generators-yp4-76zC.cjs","names":["pluginClientName","pluginTsName","pluginZodName","File","QueryKey","Client","QueryOptions","Query"],"sources":["../src/generators/queryGenerator.tsx"],"sourcesContent":["import { pluginClientName } from '@kubb/plugin-client'\nimport { Client } from '@kubb/plugin-client/components'\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File, useApp } from '@kubb/react'\nimport { difference } from 'remeda'\nimport { Query, QueryKey, QueryOptions } from '../components'\nimport type { PluginSolidQuery } from '../types'\n\nexport const queryGenerator = createReactGenerator<PluginSolidQuery>({\n name: 'svelte-query',\n Operation({ options, operation }) {\n const {\n plugin: {\n options: { output },\n },\n pluginManager,\n } = useApp<PluginSolidQuery>()\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const isQuery = typeof options.query === 'boolean' ? true : options.query?.methods.some((method) => operation.method === method)\n const isMutation = difference(['post', 'put', 'delete', 'patch'], options.query ? options.query.methods : []).some((method) => operation.method === method)\n const importPath = options.query ? options.query.importPath : '@tanstack/solid-query'\n\n const query = {\n name: getName(operation, { type: 'function', prefix: 'create' }),\n typeName: getName(operation, { type: 'type' }),\n file: getFile(operation, { prefix: 'create' }),\n }\n\n const hasClientPlugin = !!pluginManager.getPluginByKey([pluginClientName])\n const client = {\n name: hasClientPlugin\n ? getName(operation, {\n type: 'function',\n pluginKey: [pluginClientName],\n })\n : getName(operation, {\n type: 'function',\n }),\n file: getFile(operation, { pluginKey: [pluginClientName] }),\n }\n\n const queryOptions = {\n name: getName(operation, { type: 'function', suffix: 'QueryOptions' }),\n }\n\n const queryKey = {\n name: getName(operation, { type: 'const', suffix: 'QueryKey' }),\n typeName: getName(operation, { type: 'type', suffix: 'QueryKey' }),\n }\n\n const type = {\n file: getFile(operation, { pluginKey: [pluginTsName] }),\n //todo remove type?\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n }\n\n const zod = {\n file: getFile(operation, { pluginKey: [pluginZodName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' }),\n }\n\n if (!isQuery || isMutation) {\n return null\n }\n\n return (\n <File\n baseName={query.file.baseName}\n path={query.file.path}\n meta={query.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n {options.parser === 'zod' && (\n <File.Import name={[zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean)} root={query.file.path} path={zod.file.path} />\n )}\n <File.Import name={'fetch'} path={options.client.importPath} />\n {!!hasClientPlugin && <File.Import name={[client.name]} root={query.file.path} path={client.file.path} />}\n <File.Import name={['RequestConfig', 'ResponseErrorConfig']} path={options.client.importPath} isTypeOnly />\n {options.client.dataReturnType === 'full' && <File.Import name={['ResponseConfig']} path={options.client.importPath} isTypeOnly />}\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={query.file.path}\n path={type.file.path}\n isTypeOnly\n />\n <QueryKey\n name={queryKey.name}\n typeName={queryKey.typeName}\n operation={operation}\n paramsCasing={options.paramsCasing}\n pathParamsType={options.pathParamsType}\n typeSchemas={type.schemas}\n transformer={options.queryKey}\n />\n {!hasClientPlugin && (\n <Client\n name={client.name}\n baseURL={options.client.baseURL}\n operation={operation}\n typeSchemas={type.schemas}\n zodSchemas={zod.schemas}\n dataReturnType={options.client.dataReturnType}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n parser={options.parser}\n />\n )}\n <File.Import name={['queryOptions']} path={importPath} />\n <QueryOptions\n name={queryOptions.name}\n clientName={client.name}\n queryKeyName={queryKey.name}\n typeSchemas={type.schemas}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n dataReturnType={options.client.dataReturnType}\n />\n {options.query && (\n <>\n <File.Import name={['createQuery']} path={importPath} />\n <File.Import name={['QueryKey', 'QueryClient', 'UseBaseQueryOptions', 'UseQueryResult']} path={importPath} isTypeOnly />\n <Query\n name={query.name}\n queryOptionsName={queryOptions.name}\n typeSchemas={type.schemas}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n operation={operation}\n paramsCasing={options.paramsCasing}\n dataReturnType={options.client.dataReturnType}\n queryKeyName={queryKey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7D,CAAC,OAAO;KACT,MAAM,MAAM,KAAK;KACjB,MAAM,KAAK,KAAK;KAChB;;IAEF,kDAACC;KACC,MAAM,SAAS;KACf,UAAU,SAAS;KACR;KACX,cAAc,QAAQ;KACtB,gBAAgB,QAAQ;KACxB,aAAa,KAAK;KAClB,aAAa,QAAQ;;IAEtB,CAAC,mBACA,kDAACC;KACC,MAAM,OAAO;KACb,SAAS,QAAQ,OAAO;KACb;KACX,aAAa,KAAK;KAClB,YAAY,IAAI;KAChB,gBAAgB,QAAQ,OAAO;KAC/B,cAAc,QAAQ;KACtB,YAAY,QAAQ;KACpB,gBAAgB,QAAQ;KACxB,QAAQ,QAAQ;;IAGpB,kDAACF,kBAAK;KAAO,MAAM,CAAC,eAAe;KAAE,MAAM;;IAC3C,kDAACG;KACC,MAAM,aAAa;KACnB,YAAY,OAAO;KACnB,cAAc,SAAS;KACvB,aAAa,KAAK;KAClB,cAAc,QAAQ;KACtB,YAAY,QAAQ;KACpB,gBAAgB,QAAQ;KACxB,gBAAgB,QAAQ,OAAO;;IAEhC,QAAQ,SACP;KACE,kDAACH,kBAAK;MAAO,MAAM,CAAC,cAAc;MAAE,MAAM;;KAC1C,kDAACA,kBAAK;MAAO,MAAM;OAAC;OAAY;OAAe;OAAuB;OAAiB;MAAE,MAAM;MAAY;;KAC3G,kDAACI;MACC,MAAM,MAAM;MACZ,kBAAkB,aAAa;MAC/B,aAAa,KAAK;MAClB,YAAY,QAAQ;MACpB,gBAAgB,QAAQ;MACb;MACX,cAAc,QAAQ;MACtB,gBAAgB,QAAQ,OAAO;MAC/B,cAAc,SAAS;MACvB,kBAAkB,SAAS;;;;;CAMtC;CACF"}
|
package/dist/generators.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require('./components-
|
|
2
|
-
const require_generators = require('./generators-
|
|
1
|
+
require('./components-CCkbce4B.cjs');
|
|
2
|
+
const require_generators = require('./generators-yp4-76zC.cjs');
|
|
3
3
|
|
|
4
4
|
exports.queryGenerator = require_generators.queryGenerator;
|
package/dist/generators.d.cts
CHANGED
package/dist/generators.d.ts
CHANGED
package/dist/generators.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_components = require('./components-
|
|
2
|
-
const require_generators = require('./generators-
|
|
1
|
+
const require_components = require('./components-CCkbce4B.cjs');
|
|
2
|
+
const require_generators = require('./generators-yp4-76zC.cjs');
|
|
3
3
|
const node_path = require_components.__toESM(require("node:path"));
|
|
4
4
|
const __kubb_core = require_components.__toESM(require("@kubb/core"));
|
|
5
5
|
const __kubb_core_transformers = require_components.__toESM(require("@kubb/core/transformers"));
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Options, PluginSolidQuery, UserPluginWithLifeCycle } from "./types-
|
|
1
|
+
import { Options, PluginSolidQuery, UserPluginWithLifeCycle } from "./types-DLEwjVmP.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/plugin.d.ts
|
|
4
4
|
declare const pluginSolidQueryName = "plugin-solid-query";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Options, PluginSolidQuery, UserPluginWithLifeCycle } from "./types-
|
|
1
|
+
import { Options, PluginSolidQuery, UserPluginWithLifeCycle } from "./types-Ci_4FqMj.js";
|
|
2
2
|
|
|
3
3
|
//#region src/plugin.d.ts
|
|
4
4
|
declare const pluginSolidQueryName = "plugin-solid-query";
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { QueryKey } from "./components-
|
|
2
|
-
import { queryGenerator } from "./generators-
|
|
1
|
+
import { QueryKey } from "./components-DteoGXDw.js";
|
|
2
|
+
import { queryGenerator } from "./generators-D4zsCZ8Y.js";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { FileManager, PluginManager, createPlugin } from "@kubb/core";
|
|
5
5
|
import { camelCase, pascalCase } from "@kubb/core/transformers";
|
|
@@ -1,11 +1,60 @@
|
|
|
1
|
-
import { ConsolaInstance, LogLevel } from "consola";
|
|
2
1
|
import * as OasTypes from "oas/types";
|
|
3
2
|
import { HttpMethods as HttpMethod, OASDocument, SchemaObject, User } from "oas/types";
|
|
4
3
|
import { Operation, Operation as Operation$1 } from "oas/operation";
|
|
5
4
|
import { OpenAPIV3 } from "openapi-types";
|
|
6
5
|
import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
|
|
7
6
|
import BaseOas from "oas";
|
|
7
|
+
import { ConsolaInstance, LogLevel } from "consola";
|
|
8
8
|
|
|
9
|
+
//#region ../oas/src/types.d.ts
|
|
10
|
+
type contentType = 'application/json' | (string & {});
|
|
11
|
+
type SchemaObject$1 = OasTypes.SchemaObject & {
|
|
12
|
+
'x-nullable'?: boolean;
|
|
13
|
+
$ref?: string;
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region ../oas/src/Oas.d.ts
|
|
17
|
+
type Options$4 = {
|
|
18
|
+
contentType?: contentType;
|
|
19
|
+
discriminator?: 'strict' | 'inherit';
|
|
20
|
+
};
|
|
21
|
+
declare class Oas<const TOAS = unknown> extends BaseOas {
|
|
22
|
+
#private;
|
|
23
|
+
document: TOAS;
|
|
24
|
+
constructor({
|
|
25
|
+
oas,
|
|
26
|
+
user
|
|
27
|
+
}: {
|
|
28
|
+
oas: TOAS | OASDocument | string;
|
|
29
|
+
user?: User;
|
|
30
|
+
});
|
|
31
|
+
setOptions(options: Options$4): void;
|
|
32
|
+
get options(): Options$4;
|
|
33
|
+
get($ref: string): any;
|
|
34
|
+
getKey($ref: string): string | undefined;
|
|
35
|
+
set($ref: string, value: unknown): false | undefined;
|
|
36
|
+
getDiscriminator(schema: OasTypes.SchemaObject): OpenAPIV3.DiscriminatorObject | undefined;
|
|
37
|
+
dereferenceWithRef(schema?: unknown): any;
|
|
38
|
+
getResponseSchema(operation: Operation, statusCode: string | number): SchemaObject;
|
|
39
|
+
getRequestSchema(operation: Operation): SchemaObject | undefined;
|
|
40
|
+
getParametersSchema(operation: Operation, inKey: 'path' | 'query' | 'header'): SchemaObject | null;
|
|
41
|
+
valdiate(): Promise<oas_normalize_lib_types0.ValidationResult>;
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region ../core/src/BaseGenerator.d.ts
|
|
45
|
+
/**
|
|
46
|
+
* Abstract class that contains the building blocks for plugins to create their own Generator
|
|
47
|
+
* @link idea based on https://github.com/colinhacks/zod/blob/master/src/types.ts#L137
|
|
48
|
+
*/
|
|
49
|
+
declare abstract class BaseGenerator<TOptions = unknown, TContext = unknown> {
|
|
50
|
+
#private;
|
|
51
|
+
constructor(options?: TOptions, context?: TContext);
|
|
52
|
+
get options(): TOptions;
|
|
53
|
+
get context(): TContext;
|
|
54
|
+
set options(options: TOptions);
|
|
55
|
+
abstract build(...params: unknown[]): unknown;
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
9
58
|
//#region ../core/src/fs/types.d.ts
|
|
10
59
|
type BasePath<T extends string = string> = `${T}/`;
|
|
11
60
|
type Import = {
|
|
@@ -121,20 +170,6 @@ type ResolvedFile<TMeta extends object = object> = File<TMeta> & {
|
|
|
121
170
|
exports: Array<ResolvedExport>;
|
|
122
171
|
};
|
|
123
172
|
//#endregion
|
|
124
|
-
//#region ../core/src/BaseGenerator.d.ts
|
|
125
|
-
/**
|
|
126
|
-
* Abstract class that contains the building blocks for plugins to create their own Generator
|
|
127
|
-
* @link idea based on https://github.com/colinhacks/zod/blob/master/src/types.ts#L137
|
|
128
|
-
*/
|
|
129
|
-
declare abstract class BaseGenerator<TOptions = unknown, TContext = unknown> {
|
|
130
|
-
#private;
|
|
131
|
-
constructor(options?: TOptions, context?: TContext);
|
|
132
|
-
get options(): TOptions;
|
|
133
|
-
get context(): TContext;
|
|
134
|
-
set options(options: TOptions);
|
|
135
|
-
abstract build(...params: unknown[]): unknown;
|
|
136
|
-
}
|
|
137
|
-
//#endregion
|
|
138
173
|
//#region ../core/src/utils/EventEmitter.d.ts
|
|
139
174
|
declare class EventEmitter<TEvents extends Record<string, any>> {
|
|
140
175
|
#private;
|
|
@@ -529,7 +564,7 @@ type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseRe
|
|
|
529
564
|
result: Result;
|
|
530
565
|
plugin: Plugin;
|
|
531
566
|
};
|
|
532
|
-
type Options$
|
|
567
|
+
type Options$3 = {
|
|
533
568
|
logger: Logger;
|
|
534
569
|
/**
|
|
535
570
|
* @default Number.POSITIVE_INFINITY
|
|
@@ -556,8 +591,8 @@ declare class PluginManager {
|
|
|
556
591
|
readonly config: Config;
|
|
557
592
|
readonly executed: Array<Executer>;
|
|
558
593
|
readonly logger: Logger;
|
|
559
|
-
readonly options: Options$
|
|
560
|
-
constructor(config: Config, options: Options$
|
|
594
|
+
readonly options: Options$3;
|
|
595
|
+
constructor(config: Config, options: Options$3);
|
|
561
596
|
getFile<TOptions = object>({
|
|
562
597
|
name,
|
|
563
598
|
mode,
|
|
@@ -659,41 +694,6 @@ declare class PluginManager {
|
|
|
659
694
|
static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "buildEnd"];
|
|
660
695
|
}
|
|
661
696
|
//#endregion
|
|
662
|
-
//#region ../oas/src/types.d.ts
|
|
663
|
-
type contentType = 'application/json' | (string & {});
|
|
664
|
-
type SchemaObject$1 = OasTypes.SchemaObject & {
|
|
665
|
-
'x-nullable'?: boolean;
|
|
666
|
-
$ref?: string;
|
|
667
|
-
};
|
|
668
|
-
//#endregion
|
|
669
|
-
//#region ../oas/src/Oas.d.ts
|
|
670
|
-
type Options$3 = {
|
|
671
|
-
contentType?: contentType;
|
|
672
|
-
discriminator?: 'strict' | 'inherit';
|
|
673
|
-
};
|
|
674
|
-
declare class Oas<const TOAS = unknown> extends BaseOas {
|
|
675
|
-
#private;
|
|
676
|
-
document: TOAS;
|
|
677
|
-
constructor({
|
|
678
|
-
oas,
|
|
679
|
-
user
|
|
680
|
-
}: {
|
|
681
|
-
oas: TOAS | OASDocument | string;
|
|
682
|
-
user?: User;
|
|
683
|
-
});
|
|
684
|
-
setOptions(options: Options$3): void;
|
|
685
|
-
get options(): Options$3;
|
|
686
|
-
get($ref: string): any;
|
|
687
|
-
getKey($ref: string): string | undefined;
|
|
688
|
-
set($ref: string, value: unknown): false | undefined;
|
|
689
|
-
getDiscriminator(schema: OasTypes.SchemaObject): OpenAPIV3.DiscriminatorObject | undefined;
|
|
690
|
-
dereferenceWithRef(schema?: unknown): any;
|
|
691
|
-
getResponseSchema(operation: Operation, statusCode: string | number): SchemaObject;
|
|
692
|
-
getRequestSchema(operation: Operation): SchemaObject | undefined;
|
|
693
|
-
getParametersSchema(operation: Operation, inKey: 'path' | 'query' | 'header'): SchemaObject | null;
|
|
694
|
-
valdiate(): Promise<oas_normalize_lib_types0.ValidationResult>;
|
|
695
|
-
}
|
|
696
|
-
//#endregion
|
|
697
697
|
//#region ../plugin-oas/src/SchemaMapper.d.ts
|
|
698
698
|
type SchemaKeywordMapper = {
|
|
699
699
|
object: {
|
|
@@ -1332,4 +1332,4 @@ type ResolvedOptions = {
|
|
|
1332
1332
|
type PluginSolidQuery = PluginFactoryOptions<'plugin-solid-query', Options$1, ResolvedOptions, never, ResolvePathOptions>;
|
|
1333
1333
|
//#endregion
|
|
1334
1334
|
export { Generator, type Operation$1 as Operation, OperationSchemas, Options$1 as Options, PluginSolidQuery, Transformer, UserPluginWithLifeCycle };
|
|
1335
|
-
//# sourceMappingURL=types-
|
|
1335
|
+
//# sourceMappingURL=types-Ci_4FqMj.d.ts.map
|
|
@@ -1,11 +1,60 @@
|
|
|
1
|
-
import { ConsolaInstance, LogLevel } from "consola";
|
|
2
1
|
import * as OasTypes from "oas/types";
|
|
3
2
|
import { HttpMethods as HttpMethod, OASDocument, SchemaObject, User } from "oas/types";
|
|
4
3
|
import { Operation, Operation as Operation$1 } from "oas/operation";
|
|
5
4
|
import { OpenAPIV3 } from "openapi-types";
|
|
6
5
|
import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
|
|
7
6
|
import BaseOas from "oas";
|
|
7
|
+
import { ConsolaInstance, LogLevel } from "consola";
|
|
8
8
|
|
|
9
|
+
//#region ../oas/src/types.d.ts
|
|
10
|
+
type contentType = 'application/json' | (string & {});
|
|
11
|
+
type SchemaObject$1 = OasTypes.SchemaObject & {
|
|
12
|
+
'x-nullable'?: boolean;
|
|
13
|
+
$ref?: string;
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region ../oas/src/Oas.d.ts
|
|
17
|
+
type Options$4 = {
|
|
18
|
+
contentType?: contentType;
|
|
19
|
+
discriminator?: 'strict' | 'inherit';
|
|
20
|
+
};
|
|
21
|
+
declare class Oas<const TOAS = unknown> extends BaseOas {
|
|
22
|
+
#private;
|
|
23
|
+
document: TOAS;
|
|
24
|
+
constructor({
|
|
25
|
+
oas,
|
|
26
|
+
user
|
|
27
|
+
}: {
|
|
28
|
+
oas: TOAS | OASDocument | string;
|
|
29
|
+
user?: User;
|
|
30
|
+
});
|
|
31
|
+
setOptions(options: Options$4): void;
|
|
32
|
+
get options(): Options$4;
|
|
33
|
+
get($ref: string): any;
|
|
34
|
+
getKey($ref: string): string | undefined;
|
|
35
|
+
set($ref: string, value: unknown): false | undefined;
|
|
36
|
+
getDiscriminator(schema: OasTypes.SchemaObject): OpenAPIV3.DiscriminatorObject | undefined;
|
|
37
|
+
dereferenceWithRef(schema?: unknown): any;
|
|
38
|
+
getResponseSchema(operation: Operation, statusCode: string | number): SchemaObject;
|
|
39
|
+
getRequestSchema(operation: Operation): SchemaObject | undefined;
|
|
40
|
+
getParametersSchema(operation: Operation, inKey: 'path' | 'query' | 'header'): SchemaObject | null;
|
|
41
|
+
valdiate(): Promise<oas_normalize_lib_types0.ValidationResult>;
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region ../core/src/BaseGenerator.d.ts
|
|
45
|
+
/**
|
|
46
|
+
* Abstract class that contains the building blocks for plugins to create their own Generator
|
|
47
|
+
* @link idea based on https://github.com/colinhacks/zod/blob/master/src/types.ts#L137
|
|
48
|
+
*/
|
|
49
|
+
declare abstract class BaseGenerator<TOptions = unknown, TContext = unknown> {
|
|
50
|
+
#private;
|
|
51
|
+
constructor(options?: TOptions, context?: TContext);
|
|
52
|
+
get options(): TOptions;
|
|
53
|
+
get context(): TContext;
|
|
54
|
+
set options(options: TOptions);
|
|
55
|
+
abstract build(...params: unknown[]): unknown;
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
9
58
|
//#region ../core/src/fs/types.d.ts
|
|
10
59
|
type BasePath<T extends string = string> = `${T}/`;
|
|
11
60
|
type Import = {
|
|
@@ -121,20 +170,6 @@ type ResolvedFile<TMeta extends object = object> = File<TMeta> & {
|
|
|
121
170
|
exports: Array<ResolvedExport>;
|
|
122
171
|
};
|
|
123
172
|
//#endregion
|
|
124
|
-
//#region ../core/src/BaseGenerator.d.ts
|
|
125
|
-
/**
|
|
126
|
-
* Abstract class that contains the building blocks for plugins to create their own Generator
|
|
127
|
-
* @link idea based on https://github.com/colinhacks/zod/blob/master/src/types.ts#L137
|
|
128
|
-
*/
|
|
129
|
-
declare abstract class BaseGenerator<TOptions = unknown, TContext = unknown> {
|
|
130
|
-
#private;
|
|
131
|
-
constructor(options?: TOptions, context?: TContext);
|
|
132
|
-
get options(): TOptions;
|
|
133
|
-
get context(): TContext;
|
|
134
|
-
set options(options: TOptions);
|
|
135
|
-
abstract build(...params: unknown[]): unknown;
|
|
136
|
-
}
|
|
137
|
-
//#endregion
|
|
138
173
|
//#region ../core/src/utils/EventEmitter.d.ts
|
|
139
174
|
declare class EventEmitter<TEvents extends Record<string, any>> {
|
|
140
175
|
#private;
|
|
@@ -529,7 +564,7 @@ type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseRe
|
|
|
529
564
|
result: Result;
|
|
530
565
|
plugin: Plugin;
|
|
531
566
|
};
|
|
532
|
-
type Options$
|
|
567
|
+
type Options$3 = {
|
|
533
568
|
logger: Logger;
|
|
534
569
|
/**
|
|
535
570
|
* @default Number.POSITIVE_INFINITY
|
|
@@ -556,8 +591,8 @@ declare class PluginManager {
|
|
|
556
591
|
readonly config: Config;
|
|
557
592
|
readonly executed: Array<Executer>;
|
|
558
593
|
readonly logger: Logger;
|
|
559
|
-
readonly options: Options$
|
|
560
|
-
constructor(config: Config, options: Options$
|
|
594
|
+
readonly options: Options$3;
|
|
595
|
+
constructor(config: Config, options: Options$3);
|
|
561
596
|
getFile<TOptions = object>({
|
|
562
597
|
name,
|
|
563
598
|
mode,
|
|
@@ -659,41 +694,6 @@ declare class PluginManager {
|
|
|
659
694
|
static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "buildEnd"];
|
|
660
695
|
}
|
|
661
696
|
//#endregion
|
|
662
|
-
//#region ../oas/src/types.d.ts
|
|
663
|
-
type contentType = 'application/json' | (string & {});
|
|
664
|
-
type SchemaObject$1 = OasTypes.SchemaObject & {
|
|
665
|
-
'x-nullable'?: boolean;
|
|
666
|
-
$ref?: string;
|
|
667
|
-
};
|
|
668
|
-
//#endregion
|
|
669
|
-
//#region ../oas/src/Oas.d.ts
|
|
670
|
-
type Options$3 = {
|
|
671
|
-
contentType?: contentType;
|
|
672
|
-
discriminator?: 'strict' | 'inherit';
|
|
673
|
-
};
|
|
674
|
-
declare class Oas<const TOAS = unknown> extends BaseOas {
|
|
675
|
-
#private;
|
|
676
|
-
document: TOAS;
|
|
677
|
-
constructor({
|
|
678
|
-
oas,
|
|
679
|
-
user
|
|
680
|
-
}: {
|
|
681
|
-
oas: TOAS | OASDocument | string;
|
|
682
|
-
user?: User;
|
|
683
|
-
});
|
|
684
|
-
setOptions(options: Options$3): void;
|
|
685
|
-
get options(): Options$3;
|
|
686
|
-
get($ref: string): any;
|
|
687
|
-
getKey($ref: string): string | undefined;
|
|
688
|
-
set($ref: string, value: unknown): false | undefined;
|
|
689
|
-
getDiscriminator(schema: OasTypes.SchemaObject): OpenAPIV3.DiscriminatorObject | undefined;
|
|
690
|
-
dereferenceWithRef(schema?: unknown): any;
|
|
691
|
-
getResponseSchema(operation: Operation, statusCode: string | number): SchemaObject;
|
|
692
|
-
getRequestSchema(operation: Operation): SchemaObject | undefined;
|
|
693
|
-
getParametersSchema(operation: Operation, inKey: 'path' | 'query' | 'header'): SchemaObject | null;
|
|
694
|
-
valdiate(): Promise<oas_normalize_lib_types0.ValidationResult>;
|
|
695
|
-
}
|
|
696
|
-
//#endregion
|
|
697
697
|
//#region ../plugin-oas/src/SchemaMapper.d.ts
|
|
698
698
|
type SchemaKeywordMapper = {
|
|
699
699
|
object: {
|
|
@@ -1332,4 +1332,4 @@ type ResolvedOptions = {
|
|
|
1332
1332
|
type PluginSolidQuery = PluginFactoryOptions<'plugin-solid-query', Options$1, ResolvedOptions, never, ResolvePathOptions>;
|
|
1333
1333
|
//#endregion
|
|
1334
1334
|
export { Generator, type Operation$1 as Operation, OperationSchemas, Options$1 as Options, PluginSolidQuery, Transformer, UserPluginWithLifeCycle };
|
|
1335
|
-
//# sourceMappingURL=types-
|
|
1335
|
+
//# sourceMappingURL=types-DLEwjVmP.d.cts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-solid-query",
|
|
3
|
-
"version": "3.17.
|
|
3
|
+
"version": "3.17.1",
|
|
4
4
|
"description": "Solid Query hooks generator plugin for Kubb, creating type-safe API client hooks from OpenAPI specifications for Solid.js applications.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"solid-query",
|
|
@@ -62,20 +62,20 @@
|
|
|
62
62
|
],
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"remeda": "^2.30.0",
|
|
65
|
-
"@kubb/core": "3.17.
|
|
66
|
-
"@kubb/oas": "3.17.
|
|
67
|
-
"@kubb/plugin-client": "3.17.
|
|
68
|
-
"@kubb/plugin-oas": "3.17.
|
|
69
|
-
"@kubb/plugin-ts": "3.17.
|
|
70
|
-
"@kubb/plugin-zod": "3.17.
|
|
71
|
-
"@kubb/react": "3.17.
|
|
65
|
+
"@kubb/core": "3.17.1",
|
|
66
|
+
"@kubb/oas": "3.17.1",
|
|
67
|
+
"@kubb/plugin-client": "3.17.1",
|
|
68
|
+
"@kubb/plugin-oas": "3.17.1",
|
|
69
|
+
"@kubb/plugin-ts": "3.17.1",
|
|
70
|
+
"@kubb/plugin-zod": "3.17.1",
|
|
71
|
+
"@kubb/react": "3.17.1"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@types/react": "^18.3.23",
|
|
75
75
|
"react": "^18.3.1",
|
|
76
76
|
"tsdown": "^0.14.1",
|
|
77
77
|
"typescript": "^5.9.2",
|
|
78
|
-
"@kubb/config-ts": "3.17.
|
|
78
|
+
"@kubb/config-ts": "3.17.1"
|
|
79
79
|
},
|
|
80
80
|
"peerDependencies": {
|
|
81
81
|
"@kubb/react": "^3.0.0"
|
package/src/components/Query.tsx
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { type Operation, isOptional } from '@kubb/oas'
|
|
1
|
+
import { isOptional, type Operation } from '@kubb/oas'
|
|
4
2
|
import type { OperationSchemas } from '@kubb/plugin-oas'
|
|
5
3
|
import { getComments, getPathParams } from '@kubb/plugin-oas/utils'
|
|
4
|
+
import { File, Function, FunctionParams } from '@kubb/react'
|
|
6
5
|
import type { ReactNode } from 'react'
|
|
7
6
|
import type { PluginSolidQuery } from '../types.ts'
|
|
8
7
|
import { QueryKey } from './QueryKey.tsx'
|
|
@@ -162,7 +161,8 @@ export function Query({
|
|
|
162
161
|
}}
|
|
163
162
|
>
|
|
164
163
|
{`
|
|
165
|
-
const { query:
|
|
164
|
+
const { query: queryConfig = {}, client: config = {} } = options ?? {}
|
|
165
|
+
const { client: queryClient, ...queryOptions } = queryConfig
|
|
166
166
|
const queryKey = queryOptions?.queryKey ?? ${queryKeyName}(${queryKeyParams.toCall()})
|
|
167
167
|
|
|
168
168
|
const query = createQuery(() => ({
|
|
@@ -72,7 +72,8 @@ export function createFindPetsByTags<
|
|
|
72
72
|
client?: Partial<RequestConfig> & { client?: typeof fetch }
|
|
73
73
|
} = {},
|
|
74
74
|
) {
|
|
75
|
-
const { query:
|
|
75
|
+
const { query: queryConfig = {}, client: config = {} } = options ?? {}
|
|
76
|
+
const { client: queryClient, ...queryOptions } = queryConfig
|
|
76
77
|
const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params)
|
|
77
78
|
|
|
78
79
|
const query = createQuery(
|
|
@@ -67,7 +67,8 @@ export function createFindPetsByTags<
|
|
|
67
67
|
client?: Partial<RequestConfig> & { client?: typeof fetch }
|
|
68
68
|
} = {},
|
|
69
69
|
) {
|
|
70
|
-
const { query:
|
|
70
|
+
const { query: queryConfig = {}, client: config = {} } = options ?? {}
|
|
71
|
+
const { client: queryClient, ...queryOptions } = queryConfig
|
|
71
72
|
const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params)
|
|
72
73
|
|
|
73
74
|
const query = createQuery(
|
|
@@ -67,7 +67,8 @@ export function createFindPetsByTags<
|
|
|
67
67
|
client?: Partial<RequestConfig> & { client?: typeof fetch }
|
|
68
68
|
} = {},
|
|
69
69
|
) {
|
|
70
|
-
const { query:
|
|
70
|
+
const { query: queryConfig = {}, client: config = {} } = options ?? {}
|
|
71
|
+
const { client: queryClient, ...queryOptions } = queryConfig
|
|
71
72
|
const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params)
|
|
72
73
|
|
|
73
74
|
const query = createQuery(
|
|
@@ -64,7 +64,8 @@ export function createFindPetsByTags<
|
|
|
64
64
|
client?: Partial<RequestConfig> & { client?: typeof fetch }
|
|
65
65
|
} = {},
|
|
66
66
|
) {
|
|
67
|
-
const { query:
|
|
67
|
+
const { query: queryConfig = {}, client: config = {} } = options ?? {}
|
|
68
|
+
const { client: queryClient, ...queryOptions } = queryConfig
|
|
68
69
|
const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params)
|
|
69
70
|
|
|
70
71
|
const query = createQuery(
|
|
@@ -67,7 +67,8 @@ export function createFindPetsByTags<
|
|
|
67
67
|
client?: Partial<RequestConfig> & { client?: typeof fetch }
|
|
68
68
|
} = {},
|
|
69
69
|
) {
|
|
70
|
-
const { query:
|
|
70
|
+
const { query: queryConfig = {}, client: config = {} } = options ?? {}
|
|
71
|
+
const { client: queryClient, ...queryOptions } = queryConfig
|
|
71
72
|
const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params)
|
|
72
73
|
|
|
73
74
|
const query = createQuery(
|
|
@@ -67,7 +67,8 @@ export function createFindPetsByTags<
|
|
|
67
67
|
client?: Partial<RequestConfig> & { client?: typeof fetch }
|
|
68
68
|
} = {},
|
|
69
69
|
) {
|
|
70
|
-
const { query:
|
|
70
|
+
const { query: queryConfig = {}, client: config = {} } = options ?? {}
|
|
71
|
+
const { client: queryClient, ...queryOptions } = queryConfig
|
|
71
72
|
const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params)
|
|
72
73
|
|
|
73
74
|
const query = createQuery(
|
|
@@ -67,7 +67,8 @@ export function createFindPetsByTags<
|
|
|
67
67
|
client?: Partial<RequestConfig> & { client?: typeof fetch }
|
|
68
68
|
} = {},
|
|
69
69
|
) {
|
|
70
|
-
const { query:
|
|
70
|
+
const { query: queryConfig = {}, client: config = {} } = options ?? {}
|
|
71
|
+
const { client: queryClient, ...queryOptions } = queryConfig
|
|
71
72
|
const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params)
|
|
72
73
|
|
|
73
74
|
const query = createQuery(
|
|
@@ -74,7 +74,8 @@ export function createUpdatePetWithForm<
|
|
|
74
74
|
client?: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> & { client?: typeof fetch }
|
|
75
75
|
} = {},
|
|
76
76
|
) {
|
|
77
|
-
const { query:
|
|
77
|
+
const { query: queryConfig = {}, client: config = {} } = options ?? {}
|
|
78
|
+
const { client: queryClient, ...queryOptions } = queryConfig
|
|
78
79
|
const queryKey = queryOptions?.queryKey ?? updatePetWithFormQueryKey(petId, data, params)
|
|
79
80
|
|
|
80
81
|
const query = createQuery(
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"components-CNM6UaoG.js","names":["getParams","getTransformer: Transformer","getParams"],"sources":["../src/components/QueryKey.tsx","../src/components/QueryOptions.tsx","../src/components/Query.tsx"],"sourcesContent":["import { URLPath } from '@kubb/core/utils'\nimport { getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams, Type } from '@kubb/react'\n\nimport { type Operation, isOptional } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport type { ReactNode } from 'react'\nimport type { PluginSolidQuery, Transformer } from '../types'\n\ntype Props = {\n name: string\n typeName: string\n typeSchemas: OperationSchemas\n operation: Operation\n paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n transformer: Transformer | undefined\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ pathParamsType, paramsCasing, typeSchemas }: GetParamsProps) {\n return FunctionParams.factory({\n pathParams: {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n },\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n })\n}\n\nconst getTransformer: Transformer = ({ operation, schemas, casing }) => {\n const path = new URLPath(operation.path, { casing })\n const keys = [\n path.toObject({\n type: 'path',\n stringify: true,\n }),\n schemas.queryParams?.name ? '...(params ? [params] : [])' : undefined,\n schemas.request?.name ? '...(data ? [data] : [])' : undefined,\n ].filter(Boolean)\n\n return keys\n}\n\nexport function QueryKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer = getTransformer }: Props): ReactNode {\n const params = getParams({ pathParamsType, paramsCasing, typeSchemas })\n const keys = transformer({\n operation,\n schemas: typeSchemas,\n casing: paramsCasing,\n })\n\n return (\n <>\n <File.Source name={name} isExportable isIndexable>\n <Function.Arrow name={name} export params={params.toConstructor()} singleLine>\n {`[${keys.join(', ')}] as const`}\n </Function.Arrow>\n </File.Source>\n <File.Source name={typeName} isExportable isIndexable isTypeOnly>\n <Type name={typeName} export>\n {`ReturnType<typeof ${name}>`}\n </Type>\n </File.Source>\n </>\n )\n}\n\nQueryKey.getParams = getParams\nQueryKey.getTransformer = getTransformer\n","import { getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams } from '@kubb/react'\n\nimport type { ReactNode } from 'react'\n\nimport { isOptional } from '@kubb/oas'\nimport { Client } from '@kubb/plugin-client/components'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport type { PluginSolidQuery } from '../types.ts'\nimport { QueryKey } from './QueryKey.tsx'\n\ntype Props = {\n name: string\n clientName: string\n queryKeyName: string\n typeSchemas: OperationSchemas\n paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']\n paramsType: PluginSolidQuery['resolvedOptions']['paramsType']\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n dataReturnType: PluginSolidQuery['resolvedOptions']['client']['dataReturnType']\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']\n paramsType: PluginSolidQuery['resolvedOptions']['paramsType']\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }: GetParamsProps) {\n if (paramsType === 'object') {\n return FunctionParams.factory({\n data: {\n mode: 'object',\n children: {\n ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n },\n },\n config: {\n type: typeSchemas.request?.name\n ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }`\n : 'Partial<RequestConfig> & { client?: typeof fetch }',\n default: '{}',\n },\n })\n }\n\n return FunctionParams.factory({\n pathParams: typeSchemas.pathParams?.name\n ? {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n optional: isOptional(typeSchemas.pathParams?.schema),\n }\n : undefined,\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n config: {\n type: typeSchemas.request?.name\n ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }`\n : 'Partial<RequestConfig> & { client?: typeof fetch }',\n default: '{}',\n },\n })\n}\n\nexport function QueryOptions({ name, clientName, typeSchemas, paramsCasing, paramsType, dataReturnType, pathParamsType, queryKeyName }: Props): ReactNode {\n const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`\n const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`\n\n const params = getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas })\n const clientParams = Client.getParams({\n paramsCasing,\n typeSchemas,\n paramsType,\n pathParamsType,\n isConfigurable: true,\n })\n const queryKeyParams = QueryKey.getParams({\n pathParamsType,\n paramsCasing,\n typeSchemas,\n })\n\n const enabled = Object.entries(queryKeyParams.flatParams)\n .map(([key, item]) => (item && !item.optional ? key : undefined))\n .filter(Boolean)\n .join('&& ')\n\n const enabledText = enabled ? `enabled: !!(${enabled}),` : ''\n\n return (\n <File.Source name={name} isExportable isIndexable>\n <Function name={name} export params={params.toConstructor()}>\n {`\n const queryKey = ${queryKeyName}(${queryKeyParams.toCall()})\n return queryOptions<${TData}, ${TError}, ${TData}, typeof queryKey>({\n ${enabledText}\n queryKey,\n queryFn: async ({ signal }) => {\n config.signal = signal\n return ${clientName}(${clientParams.toCall()})\n },\n })\n`}\n </Function>\n </File.Source>\n )\n}\n\nQueryOptions.getParams = getParams\n","import { File, Function, FunctionParams } from '@kubb/react'\n\nimport { type Operation, isOptional } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getComments, getPathParams } from '@kubb/plugin-oas/utils'\nimport type { ReactNode } from 'react'\nimport type { PluginSolidQuery } from '../types.ts'\nimport { QueryKey } from './QueryKey.tsx'\nimport { QueryOptions } from './QueryOptions.tsx'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n queryOptionsName: string\n queryKeyName: string\n queryKeyTypeName: string\n typeSchemas: OperationSchemas\n operation: Operation\n paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']\n paramsType: PluginSolidQuery['resolvedOptions']['paramsType']\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n dataReturnType: PluginSolidQuery['resolvedOptions']['client']['dataReturnType']\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']\n paramsType: PluginSolidQuery['resolvedOptions']['paramsType']\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n dataReturnType: PluginSolidQuery['resolvedOptions']['client']['dataReturnType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas }: GetParamsProps) {\n const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`\n const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`\n\n if (paramsType === 'object') {\n return FunctionParams.factory({\n data: {\n mode: 'object',\n children: {\n ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n },\n },\n options: {\n type: `\n{\n query?: Partial<UseBaseQueryOptions<${[TData, TError, 'TData', 'TQueryData', 'TQueryKey'].join(', ')}>> & { client?: QueryClient },\n client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : 'Partial<RequestConfig> & { client?: typeof fetch }'}\n}\n`,\n default: '{}',\n },\n })\n }\n\n return FunctionParams.factory({\n pathParams: typeSchemas.pathParams?.name\n ? {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n optional: isOptional(typeSchemas.pathParams?.schema),\n }\n : undefined,\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n options: {\n type: `\n{\n query?: Partial<UseBaseQueryOptions<${[TData, TError, 'TData', 'TQueryData', 'TQueryKey'].join(', ')}>> & { client?: QueryClient },\n client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : 'Partial<RequestConfig> & { client?: typeof fetch }'}\n}\n`,\n default: '{}',\n },\n })\n}\n\nexport function Query({\n name,\n queryKeyTypeName,\n queryOptionsName,\n queryKeyName,\n paramsCasing,\n paramsType,\n pathParamsType,\n dataReturnType,\n typeSchemas,\n operation,\n}: Props): ReactNode {\n const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`\n const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`\n const returnType = `UseQueryResult<${['TData', TError].join(', ')}> & { queryKey: TQueryKey }`\n const generics = [`TData = ${TData}`, `TQueryData = ${TData}`, `TQueryKey extends QueryKey = ${queryKeyTypeName}`]\n\n const queryKeyParams = QueryKey.getParams({\n pathParamsType,\n typeSchemas,\n paramsCasing,\n })\n const queryOptionsParams = QueryOptions.getParams({\n paramsType,\n paramsCasing,\n pathParamsType,\n typeSchemas,\n })\n const params = getParams({\n paramsCasing,\n paramsType,\n pathParamsType,\n dataReturnType,\n typeSchemas,\n })\n\n const queryOptions = `${queryOptionsName}(${queryOptionsParams.toCall()}) as unknown as UseBaseQueryOptions`\n\n return (\n <File.Source name={name} isExportable isIndexable>\n <Function\n name={name}\n export\n generics={generics.join(', ')}\n params={params.toConstructor()}\n JSDoc={{\n comments: getComments(operation),\n }}\n >\n {`\n const { query: { client: queryClient, ...queryOptions } = {}, client: config = {} } = options ?? {}\n const queryKey = queryOptions?.queryKey ?? ${queryKeyName}(${queryKeyParams.toCall()})\n\n const query = createQuery(() => ({\n ...${queryOptions},\n queryKey,\n initialData: null,\n ...queryOptions as unknown as Omit<UseBaseQueryOptions, \"queryKey\">\n }), queryClient? () => queryClient: undefined) as ${returnType}\n\n return query\n `}\n </Function>\n </File.Source>\n )\n}\n\nQuery.getParams = getParams\n"],"mappings":";;;;;;;;AAyBA,SAASA,YAAU,EAAE,gBAAgB,cAAc,aAA6B,EAAE;AAChF,QAAO,eAAe,QAAQ;EAC5B,YAAY;GACV,MAAM,mBAAmB,WAAW,WAAW;GAC/C,UAAU,cAAc,YAAY,YAAY;IAAE,OAAO;IAAM,QAAQ;IAAc;GACtF;EACD,MAAM,YAAY,SAAS,OACvB;GACE,MAAM,YAAY,SAAS;GAC3B,UAAU,WAAW,YAAY,SAAS;GAC3C,GACD;EACJ,QAAQ,YAAY,aAAa,OAC7B;GACE,MAAM,YAAY,aAAa;GAC/B,UAAU,WAAW,YAAY,aAAa;GAC/C,GACD;EACL;AACF;AAED,MAAMC,kBAA+B,EAAE,WAAW,SAAS,QAAQ,KAAK;CACtE,MAAM,OAAO,IAAI,QAAQ,UAAU,MAAM,EAAE,QAAQ;CACnD,MAAM,OAAO;EACX,KAAK,SAAS;GACZ,MAAM;GACN,WAAW;GACZ;EACD,QAAQ,aAAa,OAAO,gCAAgC;EAC5D,QAAQ,SAAS,OAAO,4BAA4B;EACrD,CAAC,OAAO;AAET,QAAO;AACR;AAED,SAAgB,SAAS,EAAE,MAAM,aAAa,cAAc,gBAAgB,WAAW,UAAU,cAAc,gBAAuB,EAAa;CACjJ,MAAM,SAASD,YAAU;EAAE;EAAgB;EAAc;EAAa;CACtE,MAAM,OAAO,YAAY;EACvB;EACA,SAAS;EACT,QAAQ;EACT;AAED,QACE,4CACE,oBAAC,KAAK;EAAa;EAAM;EAAa;YACpC,oBAAC,SAAS;GAAY;GAAM;GAAO,QAAQ,OAAO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C,qDAAqD;;;GAG7K,SAAS;GACV;EACF;AACF;AAED,SAAgB,MAAM,EACpB,MACA,kBACA,kBACA,cACA,cACA,YACA,gBACA,gBACA,aACA,WACM,EAAa;CACnB,MAAM,QAAQ,mBAAmB,SAAS,YAAY,SAAS,OAAO,kBAAkB,YAAY,SAAS,KAAK;CAClH,MAAM,SAAS,uBAAuB,YAAY,QAAQ,KAAK,SAAS,KAAK,MAAM,KAAK,UAAU,QAAQ;CAC1G,MAAM,aAAa,kBAAkB,CAAC,SAAS,OAAO,CAAC,KAAK,MAAM;CAClE,MAAM,WAAW;EAAC,WAAW;EAAS,gBAAgB;EAAS,gCAAgC;EAAmB;CAElH,MAAM,iBAAiB,SAAS,UAAU;EACxC;EACA;EACA;EACD;CACD,MAAM,qBAAqB,aAAa,UAAU;EAChD;EACA;EACA;EACA;EACD;CACD,MAAM,SAAS,UAAU;EACvB;EACA;EACA;EACA;EACA;EACD;CAED,MAAM,eAAe,GAAG,iBAAiB,GAAG,mBAAmB,SAAS;AAExE,QACE,oBAAC,KAAK;EAAa;EAAM;EAAa;YACpC,oBAAC;GACO;GACN;GACA,UAAU,SAAS,KAAK;GACxB,QAAQ,OAAO;GACf,OAAO,EACL,UAAU,YAAY,YACvB;aAEA;;oDAE2C,aAAa,GAAG,eAAe,SAAS;;;aAG/E,aAAa;;;;2DAIiC,WAAW;;;;;;AAOrE;AAED,MAAM,YAAY"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"components-LAcBpjX8.cjs","names":["getParams","FunctionParams","getTransformer: Transformer","URLPath","File","Function","Type","getParams","FunctionParams","Client","File","Function","FunctionParams","File","Function"],"sources":["../src/components/QueryKey.tsx","../src/components/QueryOptions.tsx","../src/components/Query.tsx"],"sourcesContent":["import { URLPath } from '@kubb/core/utils'\nimport { getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams, Type } from '@kubb/react'\n\nimport { type Operation, isOptional } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport type { ReactNode } from 'react'\nimport type { PluginSolidQuery, Transformer } from '../types'\n\ntype Props = {\n name: string\n typeName: string\n typeSchemas: OperationSchemas\n operation: Operation\n paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n transformer: Transformer | undefined\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ pathParamsType, paramsCasing, typeSchemas }: GetParamsProps) {\n return FunctionParams.factory({\n pathParams: {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n },\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n })\n}\n\nconst getTransformer: Transformer = ({ operation, schemas, casing }) => {\n const path = new URLPath(operation.path, { casing })\n const keys = [\n path.toObject({\n type: 'path',\n stringify: true,\n }),\n schemas.queryParams?.name ? '...(params ? [params] : [])' : undefined,\n schemas.request?.name ? '...(data ? [data] : [])' : undefined,\n ].filter(Boolean)\n\n return keys\n}\n\nexport function QueryKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer = getTransformer }: Props): ReactNode {\n const params = getParams({ pathParamsType, paramsCasing, typeSchemas })\n const keys = transformer({\n operation,\n schemas: typeSchemas,\n casing: paramsCasing,\n })\n\n return (\n <>\n <File.Source name={name} isExportable isIndexable>\n <Function.Arrow name={name} export params={params.toConstructor()} singleLine>\n {`[${keys.join(', ')}] as const`}\n </Function.Arrow>\n </File.Source>\n <File.Source name={typeName} isExportable isIndexable isTypeOnly>\n <Type name={typeName} export>\n {`ReturnType<typeof ${name}>`}\n </Type>\n </File.Source>\n </>\n )\n}\n\nQueryKey.getParams = getParams\nQueryKey.getTransformer = getTransformer\n","import { getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams } from '@kubb/react'\n\nimport type { ReactNode } from 'react'\n\nimport { isOptional } from '@kubb/oas'\nimport { Client } from '@kubb/plugin-client/components'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport type { PluginSolidQuery } from '../types.ts'\nimport { QueryKey } from './QueryKey.tsx'\n\ntype Props = {\n name: string\n clientName: string\n queryKeyName: string\n typeSchemas: OperationSchemas\n paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']\n paramsType: PluginSolidQuery['resolvedOptions']['paramsType']\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n dataReturnType: PluginSolidQuery['resolvedOptions']['client']['dataReturnType']\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']\n paramsType: PluginSolidQuery['resolvedOptions']['paramsType']\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }: GetParamsProps) {\n if (paramsType === 'object') {\n return FunctionParams.factory({\n data: {\n mode: 'object',\n children: {\n ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n },\n },\n config: {\n type: typeSchemas.request?.name\n ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }`\n : 'Partial<RequestConfig> & { client?: typeof fetch }',\n default: '{}',\n },\n })\n }\n\n return FunctionParams.factory({\n pathParams: typeSchemas.pathParams?.name\n ? {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n optional: isOptional(typeSchemas.pathParams?.schema),\n }\n : undefined,\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n config: {\n type: typeSchemas.request?.name\n ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }`\n : 'Partial<RequestConfig> & { client?: typeof fetch }',\n default: '{}',\n },\n })\n}\n\nexport function QueryOptions({ name, clientName, typeSchemas, paramsCasing, paramsType, dataReturnType, pathParamsType, queryKeyName }: Props): ReactNode {\n const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`\n const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`\n\n const params = getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas })\n const clientParams = Client.getParams({\n paramsCasing,\n typeSchemas,\n paramsType,\n pathParamsType,\n isConfigurable: true,\n })\n const queryKeyParams = QueryKey.getParams({\n pathParamsType,\n paramsCasing,\n typeSchemas,\n })\n\n const enabled = Object.entries(queryKeyParams.flatParams)\n .map(([key, item]) => (item && !item.optional ? key : undefined))\n .filter(Boolean)\n .join('&& ')\n\n const enabledText = enabled ? `enabled: !!(${enabled}),` : ''\n\n return (\n <File.Source name={name} isExportable isIndexable>\n <Function name={name} export params={params.toConstructor()}>\n {`\n const queryKey = ${queryKeyName}(${queryKeyParams.toCall()})\n return queryOptions<${TData}, ${TError}, ${TData}, typeof queryKey>({\n ${enabledText}\n queryKey,\n queryFn: async ({ signal }) => {\n config.signal = signal\n return ${clientName}(${clientParams.toCall()})\n },\n })\n`}\n </Function>\n </File.Source>\n )\n}\n\nQueryOptions.getParams = getParams\n","import { File, Function, FunctionParams } from '@kubb/react'\n\nimport { type Operation, isOptional } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getComments, getPathParams } from '@kubb/plugin-oas/utils'\nimport type { ReactNode } from 'react'\nimport type { PluginSolidQuery } from '../types.ts'\nimport { QueryKey } from './QueryKey.tsx'\nimport { QueryOptions } from './QueryOptions.tsx'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n queryOptionsName: string\n queryKeyName: string\n queryKeyTypeName: string\n typeSchemas: OperationSchemas\n operation: Operation\n paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']\n paramsType: PluginSolidQuery['resolvedOptions']['paramsType']\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n dataReturnType: PluginSolidQuery['resolvedOptions']['client']['dataReturnType']\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']\n paramsType: PluginSolidQuery['resolvedOptions']['paramsType']\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n dataReturnType: PluginSolidQuery['resolvedOptions']['client']['dataReturnType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas }: GetParamsProps) {\n const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`\n const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`\n\n if (paramsType === 'object') {\n return FunctionParams.factory({\n data: {\n mode: 'object',\n children: {\n ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n },\n },\n options: {\n type: `\n{\n query?: Partial<UseBaseQueryOptions<${[TData, TError, 'TData', 'TQueryData', 'TQueryKey'].join(', ')}>> & { client?: QueryClient },\n client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : 'Partial<RequestConfig> & { client?: typeof fetch }'}\n}\n`,\n default: '{}',\n },\n })\n }\n\n return FunctionParams.factory({\n pathParams: typeSchemas.pathParams?.name\n ? {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n optional: isOptional(typeSchemas.pathParams?.schema),\n }\n : undefined,\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n options: {\n type: `\n{\n query?: Partial<UseBaseQueryOptions<${[TData, TError, 'TData', 'TQueryData', 'TQueryKey'].join(', ')}>> & { client?: QueryClient },\n client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : 'Partial<RequestConfig> & { client?: typeof fetch }'}\n}\n`,\n default: '{}',\n },\n })\n}\n\nexport function Query({\n name,\n queryKeyTypeName,\n queryOptionsName,\n queryKeyName,\n paramsCasing,\n paramsType,\n pathParamsType,\n dataReturnType,\n typeSchemas,\n operation,\n}: Props): ReactNode {\n const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`\n const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`\n const returnType = `UseQueryResult<${['TData', TError].join(', ')}> & { queryKey: TQueryKey }`\n const generics = [`TData = ${TData}`, `TQueryData = ${TData}`, `TQueryKey extends QueryKey = ${queryKeyTypeName}`]\n\n const queryKeyParams = QueryKey.getParams({\n pathParamsType,\n typeSchemas,\n paramsCasing,\n })\n const queryOptionsParams = QueryOptions.getParams({\n paramsType,\n paramsCasing,\n pathParamsType,\n typeSchemas,\n })\n const params = getParams({\n paramsCasing,\n paramsType,\n pathParamsType,\n dataReturnType,\n typeSchemas,\n })\n\n const queryOptions = `${queryOptionsName}(${queryOptionsParams.toCall()}) as unknown as UseBaseQueryOptions`\n\n return (\n <File.Source name={name} isExportable isIndexable>\n <Function\n name={name}\n export\n generics={generics.join(', ')}\n params={params.toConstructor()}\n JSDoc={{\n comments: getComments(operation),\n }}\n >\n {`\n const { query: { client: queryClient, ...queryOptions } = {}, client: config = {} } = options ?? {}\n const queryKey = queryOptions?.queryKey ?? ${queryKeyName}(${queryKeyParams.toCall()})\n\n const query = createQuery(() => ({\n ...${queryOptions},\n queryKey,\n initialData: null,\n ...queryOptions as unknown as Omit<UseBaseQueryOptions, \"queryKey\">\n }), queryClient? () => queryClient: undefined) as ${returnType}\n\n return query\n `}\n </Function>\n </File.Source>\n )\n}\n\nQuery.getParams = getParams\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAASA,YAAU,EAAE,gBAAgB,cAAc,aAA6B,EAAE;AAChF,QAAOC,4BAAe,QAAQ;EAC5B,YAAY;GACV,MAAM,mBAAmB,WAAW,W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