@kubb/plugin-solid-query 4.0.0 → 4.0.2
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-Bi0-xvca.cjs → components-CrpQqUQQ.cjs} +181 -4
- package/dist/components-CrpQqUQQ.cjs.map +1 -0
- package/dist/{components-B_yhFBLa.js → components-JN6XAKh3.js} +169 -4
- package/dist/components-JN6XAKh3.js.map +1 -0
- package/dist/components.cjs +3 -1
- package/dist/components.d.cts +58 -2
- package/dist/components.d.ts +58 -2
- package/dist/components.js +2 -2
- package/dist/{generators-0TNaKUZf.cjs → generators-CUcA3_rk.cjs} +161 -5
- package/dist/generators-CUcA3_rk.cjs.map +1 -0
- package/dist/{generators-DsUzHPML.js → generators-DRX-ix2A.js} +155 -5
- package/dist/generators-DRX-ix2A.js.map +1 -0
- package/dist/generators.cjs +3 -2
- package/dist/generators.d.cts +5 -2
- package/dist/generators.d.ts +5 -2
- package/dist/generators.js +3 -3
- package/dist/index.cjs +14 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +14 -3
- package/dist/index.js.map +1 -1
- package/dist/{types-BcAT9UxT.d.cts → types-BI1GJc6y.d.cts} +27 -1
- package/dist/{types-B5mFPIGb.d.ts → types-fv5KLGsJ.d.ts} +27 -1
- package/package.json +9 -10
- package/src/components/Mutation.tsx +177 -0
- package/src/components/MutationKey.tsx +54 -0
- package/src/components/Query.tsx +1 -1
- package/src/components/index.ts +2 -0
- package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +2 -2
- package/src/generators/__snapshots__/clientGetImportPath.ts +2 -2
- package/src/generators/__snapshots__/findByTags.ts +2 -2
- package/src/generators/__snapshots__/findByTagsObject.ts +2 -2
- package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +2 -2
- package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +2 -2
- package/src/generators/__snapshots__/findByTagsWithZod.ts +2 -2
- package/src/generators/__snapshots__/postAsQuery.ts +2 -2
- package/src/generators/index.ts +1 -0
- package/src/generators/mutationGenerator.tsx +144 -0
- package/src/generators/queryGenerator.tsx +1 -1
- package/src/plugin.ts +14 -9
- package/src/types.ts +28 -0
- package/dist/components-B_yhFBLa.js.map +0 -1
- package/dist/components-Bi0-xvca.cjs.map +0 -1
- package/dist/generators-0TNaKUZf.cjs.map +0 -1
- package/dist/generators-DsUzHPML.js.map +0 -1
|
@@ -23,6 +23,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
23
|
//#endregion
|
|
24
24
|
let __kubb_oas = require("@kubb/oas");
|
|
25
25
|
__kubb_oas = __toESM(__kubb_oas);
|
|
26
|
+
let __kubb_plugin_client_components = require("@kubb/plugin-client/components");
|
|
27
|
+
__kubb_plugin_client_components = __toESM(__kubb_plugin_client_components);
|
|
26
28
|
let __kubb_plugin_oas_utils = require("@kubb/plugin-oas/utils");
|
|
27
29
|
__kubb_plugin_oas_utils = __toESM(__kubb_plugin_oas_utils);
|
|
28
30
|
let __kubb_react = require("@kubb/react");
|
|
@@ -31,9 +33,172 @@ let __kubb_core_utils = require("@kubb/core/utils");
|
|
|
31
33
|
__kubb_core_utils = __toESM(__kubb_core_utils);
|
|
32
34
|
let __kubb_react_jsx_runtime = require("@kubb/react/jsx-runtime");
|
|
33
35
|
__kubb_react_jsx_runtime = __toESM(__kubb_react_jsx_runtime);
|
|
34
|
-
let __kubb_plugin_client_components = require("@kubb/plugin-client/components");
|
|
35
|
-
__kubb_plugin_client_components = __toESM(__kubb_plugin_client_components);
|
|
36
36
|
|
|
37
|
+
//#region src/components/MutationKey.tsx
|
|
38
|
+
function getParams$4({}) {
|
|
39
|
+
return __kubb_react.FunctionParams.factory({});
|
|
40
|
+
}
|
|
41
|
+
const getTransformer$1 = ({ operation, casing }) => {
|
|
42
|
+
return [`{ url: '${new __kubb_core_utils.URLPath(operation.path, { casing }).toURLPath()}' }`];
|
|
43
|
+
};
|
|
44
|
+
function MutationKey({ name, typeSchemas, pathParamsType, paramsCasing, operation, typeName, transformer = getTransformer$1 }) {
|
|
45
|
+
const params = getParams$4({
|
|
46
|
+
pathParamsType,
|
|
47
|
+
typeSchemas
|
|
48
|
+
});
|
|
49
|
+
const keys = transformer({
|
|
50
|
+
operation,
|
|
51
|
+
schemas: typeSchemas,
|
|
52
|
+
casing: paramsCasing
|
|
53
|
+
});
|
|
54
|
+
return /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsxs)(__kubb_react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Source, {
|
|
55
|
+
name,
|
|
56
|
+
isExportable: true,
|
|
57
|
+
isIndexable: true,
|
|
58
|
+
children: /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.Function.Arrow, {
|
|
59
|
+
name,
|
|
60
|
+
export: true,
|
|
61
|
+
params: params.toConstructor(),
|
|
62
|
+
singleLine: true,
|
|
63
|
+
children: `[${keys.join(", ")}] as const`
|
|
64
|
+
})
|
|
65
|
+
}), /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Source, {
|
|
66
|
+
name: typeName,
|
|
67
|
+
isExportable: true,
|
|
68
|
+
isIndexable: true,
|
|
69
|
+
isTypeOnly: true,
|
|
70
|
+
children: /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.Type, {
|
|
71
|
+
name: typeName,
|
|
72
|
+
export: true,
|
|
73
|
+
children: `ReturnType<typeof ${name}>`
|
|
74
|
+
})
|
|
75
|
+
})] });
|
|
76
|
+
}
|
|
77
|
+
MutationKey.getParams = getParams$4;
|
|
78
|
+
MutationKey.getTransformer = getTransformer$1;
|
|
79
|
+
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/components/Mutation.tsx
|
|
82
|
+
function getParams$3({ paramsCasing, dataReturnType, typeSchemas }) {
|
|
83
|
+
const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
84
|
+
const TRequest = __kubb_react.FunctionParams.factory({
|
|
85
|
+
...(0, __kubb_plugin_oas_utils.getPathParams)(typeSchemas.pathParams, {
|
|
86
|
+
typed: true,
|
|
87
|
+
casing: paramsCasing
|
|
88
|
+
}),
|
|
89
|
+
data: typeSchemas.request?.name ? {
|
|
90
|
+
type: typeSchemas.request?.name,
|
|
91
|
+
optional: (0, __kubb_oas.isOptional)(typeSchemas.request?.schema)
|
|
92
|
+
} : void 0,
|
|
93
|
+
params: typeSchemas.queryParams?.name ? {
|
|
94
|
+
type: typeSchemas.queryParams?.name,
|
|
95
|
+
optional: (0, __kubb_oas.isOptional)(typeSchemas.queryParams?.schema)
|
|
96
|
+
} : void 0,
|
|
97
|
+
headers: typeSchemas.headerParams?.name ? {
|
|
98
|
+
type: typeSchemas.headerParams?.name,
|
|
99
|
+
optional: (0, __kubb_oas.isOptional)(typeSchemas.headerParams?.schema)
|
|
100
|
+
} : void 0
|
|
101
|
+
}).toConstructor();
|
|
102
|
+
const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
|
|
103
|
+
const generics = [
|
|
104
|
+
TData,
|
|
105
|
+
TError,
|
|
106
|
+
TRequest ? `{${TRequest}}` : "void",
|
|
107
|
+
"TContext"
|
|
108
|
+
].join(", ");
|
|
109
|
+
return __kubb_react.FunctionParams.factory({ options: {
|
|
110
|
+
type: `
|
|
111
|
+
{
|
|
112
|
+
mutation?: ReturnType<UseMutationOptions<${generics}>> & { client?: QueryClient },
|
|
113
|
+
client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }"},
|
|
114
|
+
}
|
|
115
|
+
`,
|
|
116
|
+
default: "{}"
|
|
117
|
+
} });
|
|
118
|
+
}
|
|
119
|
+
function Mutation({ name, clientName, paramsCasing, paramsType, pathParamsType, dataReturnType, typeSchemas, operation, mutationKeyName }) {
|
|
120
|
+
const mutationKeyParams = MutationKey.getParams({
|
|
121
|
+
pathParamsType,
|
|
122
|
+
typeSchemas
|
|
123
|
+
});
|
|
124
|
+
const params = getParams$3({
|
|
125
|
+
paramsCasing,
|
|
126
|
+
pathParamsType,
|
|
127
|
+
dataReturnType,
|
|
128
|
+
typeSchemas
|
|
129
|
+
});
|
|
130
|
+
const clientParams = __kubb_plugin_client_components.Client.getParams({
|
|
131
|
+
paramsCasing,
|
|
132
|
+
paramsType,
|
|
133
|
+
typeSchemas,
|
|
134
|
+
pathParamsType,
|
|
135
|
+
isConfigurable: true
|
|
136
|
+
});
|
|
137
|
+
const mutationParams = __kubb_react.FunctionParams.factory({
|
|
138
|
+
...(0, __kubb_plugin_oas_utils.getPathParams)(typeSchemas.pathParams, {
|
|
139
|
+
typed: true,
|
|
140
|
+
casing: paramsCasing
|
|
141
|
+
}),
|
|
142
|
+
data: typeSchemas.request?.name ? {
|
|
143
|
+
type: typeSchemas.request?.name,
|
|
144
|
+
optional: (0, __kubb_oas.isOptional)(typeSchemas.request?.schema)
|
|
145
|
+
} : void 0,
|
|
146
|
+
params: typeSchemas.queryParams?.name ? {
|
|
147
|
+
type: typeSchemas.queryParams?.name,
|
|
148
|
+
optional: (0, __kubb_oas.isOptional)(typeSchemas.queryParams?.schema)
|
|
149
|
+
} : void 0,
|
|
150
|
+
headers: typeSchemas.headerParams?.name ? {
|
|
151
|
+
type: typeSchemas.headerParams?.name,
|
|
152
|
+
optional: (0, __kubb_oas.isOptional)(typeSchemas.headerParams?.schema)
|
|
153
|
+
} : void 0
|
|
154
|
+
});
|
|
155
|
+
const dataParams = __kubb_react.FunctionParams.factory({ data: {
|
|
156
|
+
mode: "object",
|
|
157
|
+
children: Object.entries(mutationParams.params).reduce((acc, [key, value]) => {
|
|
158
|
+
if (value) acc[key] = {
|
|
159
|
+
...value,
|
|
160
|
+
type: void 0
|
|
161
|
+
};
|
|
162
|
+
return acc;
|
|
163
|
+
}, {})
|
|
164
|
+
} });
|
|
165
|
+
const TRequest = mutationParams.toConstructor();
|
|
166
|
+
const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
167
|
+
const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
|
|
168
|
+
const generics = [
|
|
169
|
+
TData,
|
|
170
|
+
TError,
|
|
171
|
+
TRequest ? `{${TRequest}}` : "void",
|
|
172
|
+
"TContext"
|
|
173
|
+
].join(", ");
|
|
174
|
+
return /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Source, {
|
|
175
|
+
name,
|
|
176
|
+
isExportable: true,
|
|
177
|
+
isIndexable: true,
|
|
178
|
+
children: /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.Function, {
|
|
179
|
+
name,
|
|
180
|
+
export: true,
|
|
181
|
+
params: params.toConstructor(),
|
|
182
|
+
JSDoc: { comments: (0, __kubb_plugin_oas_utils.getComments)(operation) },
|
|
183
|
+
generics: ["TContext"],
|
|
184
|
+
children: `
|
|
185
|
+
const { mutation = {}, client: config = {} } = options ?? {}
|
|
186
|
+
const { client: queryClient, ...mutationOptions } = mutation;
|
|
187
|
+
const mutationKey = mutationOptions.mutationKey ?? ${mutationKeyName}(${mutationKeyParams.toCall()})
|
|
188
|
+
|
|
189
|
+
return useMutation<${generics}>(()=> ({
|
|
190
|
+
mutationFn: async(${dataParams.toConstructor()}) => {
|
|
191
|
+
return ${clientName}(${clientParams.toCall()})
|
|
192
|
+
},
|
|
193
|
+
mutationKey,
|
|
194
|
+
...mutationOptions
|
|
195
|
+
}), queryClient? () => queryClient: undefined)
|
|
196
|
+
`
|
|
197
|
+
})
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
//#endregion
|
|
37
202
|
//#region src/components/QueryKey.tsx
|
|
38
203
|
function getParams$2({ pathParamsType, paramsCasing, typeSchemas }) {
|
|
39
204
|
return __kubb_react.FunctionParams.factory({
|
|
@@ -328,7 +493,7 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsC
|
|
|
328
493
|
const { client: queryClient, ...queryOptions } = queryConfig
|
|
329
494
|
const queryKey = queryOptions?.queryKey ?? ${queryKeyName}(${queryKeyParams.toCall()})
|
|
330
495
|
|
|
331
|
-
const query =
|
|
496
|
+
const query = useQuery(() => ({
|
|
332
497
|
...${queryOptions},
|
|
333
498
|
queryKey,
|
|
334
499
|
initialData: null,
|
|
@@ -343,6 +508,18 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsC
|
|
|
343
508
|
Query.getParams = getParams;
|
|
344
509
|
|
|
345
510
|
//#endregion
|
|
511
|
+
Object.defineProperty(exports, 'Mutation', {
|
|
512
|
+
enumerable: true,
|
|
513
|
+
get: function () {
|
|
514
|
+
return Mutation;
|
|
515
|
+
}
|
|
516
|
+
});
|
|
517
|
+
Object.defineProperty(exports, 'MutationKey', {
|
|
518
|
+
enumerable: true,
|
|
519
|
+
get: function () {
|
|
520
|
+
return MutationKey;
|
|
521
|
+
}
|
|
522
|
+
});
|
|
346
523
|
Object.defineProperty(exports, 'Query', {
|
|
347
524
|
enumerable: true,
|
|
348
525
|
get: function () {
|
|
@@ -367,4 +544,4 @@ Object.defineProperty(exports, '__toESM', {
|
|
|
367
544
|
return __toESM;
|
|
368
545
|
}
|
|
369
546
|
});
|
|
370
|
-
//# sourceMappingURL=components-
|
|
547
|
+
//# sourceMappingURL=components-CrpQqUQQ.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components-CrpQqUQQ.cjs","names":["getParams","FunctionParams","getTransformer: Transformer","URLPath","getTransformer","File","Function","Type","getParams","FunctionParams","Client","File","Function","getParams","FunctionParams","getTransformer: Transformer","URLPath","File","Function","Type","getParams","FunctionParams","Client","File","Function","FunctionParams","File","Function"],"sources":["../src/components/MutationKey.tsx","../src/components/Mutation.tsx","../src/components/QueryKey.tsx","../src/components/QueryOptions.tsx","../src/components/Query.tsx"],"sourcesContent":["import { URLPath } from '@kubb/core/utils'\nimport type { Operation } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { File, Function, FunctionParams, Type } from '@kubb/react'\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 pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({}: GetParamsProps) {\n return FunctionParams.factory({})\n}\n\nconst getTransformer: Transformer = ({ operation, casing }) => {\n const path = new URLPath(operation.path, { casing })\n\n return [`{ url: '${path.toURLPath()}' }`]\n}\n\nexport function MutationKey({ name, typeSchemas, pathParamsType, paramsCasing, operation, typeName, transformer = getTransformer }: Props): ReactNode {\n const params = getParams({ pathParamsType, typeSchemas })\n const keys = transformer({ operation, schemas: typeSchemas, casing: paramsCasing })\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\nMutationKey.getParams = getParams\nMutationKey.getTransformer = getTransformer\n","import { isOptional, type Operation } from '@kubb/oas'\nimport { Client } from '@kubb/plugin-client/components'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getComments, getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams } from '@kubb/react'\nimport type { Params } from '@kubb/react/types'\nimport type { ReactNode } from 'react'\nimport type { PluginSolidQuery } from '../types.ts'\nimport { MutationKey } from './MutationKey.tsx'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n typeName: string\n clientName: string\n mutationKeyName: string\n typeSchemas: OperationSchemas\n operation: Operation\n dataReturnType: PluginSolidQuery['resolvedOptions']['client']['dataReturnType']\n paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']\n paramsType: PluginSolidQuery['resolvedOptions']['paramsType']\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n dataReturnType: PluginSolidQuery['resolvedOptions']['client']['dataReturnType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ paramsCasing, dataReturnType, typeSchemas }: GetParamsProps) {\n const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`\n const mutationParams = FunctionParams.factory({\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 const TRequest = mutationParams.toConstructor()\n const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`\n const generics = [TData, TError, TRequest ? `{${TRequest}}` : 'void', 'TContext'].join(', ')\n\n return FunctionParams.factory({\n options: {\n type: `\n{\n mutation?: ReturnType<UseMutationOptions<${generics}>> & { 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 Mutation({\n name,\n clientName,\n paramsCasing,\n paramsType,\n pathParamsType,\n dataReturnType,\n typeSchemas,\n operation,\n mutationKeyName,\n}: Props): ReactNode {\n const mutationKeyParams = MutationKey.getParams({\n pathParamsType,\n typeSchemas,\n })\n\n const params = getParams({\n paramsCasing,\n pathParamsType,\n dataReturnType,\n typeSchemas,\n })\n\n const clientParams = Client.getParams({\n paramsCasing,\n paramsType,\n typeSchemas,\n pathParamsType,\n isConfigurable: true,\n })\n\n const mutationParams = FunctionParams.factory({\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 const dataParams = FunctionParams.factory({\n data: {\n // No use of pathParams because useMutation can only take one argument in object form,\n // see https://tanstack.com/query/latest/docs/framework/react/reference/useMutation#usemutation\n mode: 'object',\n children: Object.entries(mutationParams.params).reduce((acc, [key, value]) => {\n if (value) {\n acc[key] = {\n ...value,\n type: undefined,\n }\n }\n\n return acc\n }, {} as Params),\n },\n })\n\n const TRequest = mutationParams.toConstructor()\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 generics = [TData, TError, TRequest ? `{${TRequest}}` : 'void', 'TContext'].join(', ')\n\n return (\n <File.Source name={name} isExportable isIndexable>\n <Function\n name={name}\n export\n params={params.toConstructor()}\n JSDoc={{\n comments: getComments(operation),\n }}\n generics={['TContext']}\n >\n {`\n const { mutation = {}, client: config = {} } = options ?? {}\n const { client: queryClient, ...mutationOptions } = mutation;\n const mutationKey = mutationOptions.mutationKey ?? ${mutationKeyName}(${mutationKeyParams.toCall()})\n\n return useMutation<${generics}>(()=> ({\n mutationFn: async(${dataParams.toConstructor()}) => {\n return ${clientName}(${clientParams.toCall()})\n },\n mutationKey,\n ...mutationOptions\n }), queryClient? () => queryClient: undefined)\n `}\n </Function>\n </File.Source>\n )\n}\n","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 = useQuery(() => ({\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,SAASA,YAAU,IAAoB;AACrC,QAAOC,4BAAe,QAAQ,EAAE,CAAC;;AAGnC,MAAMC,oBAA+B,EAAE,WAAW,aAAa;AAG7D,QAAO,CAAC,WAFK,IAAIC,0BAAQ,UAAU,MAAM,EAAE,QAAQ,CAAC,CAE5B,WAAW,CAAC,KAAK;;AAG3C,SAAgB,YAAY,EAAE,MAAM,aAAa,gBAAgB,cAAc,WAAW,UAAU,cAAcC,oBAAoC;CACpJ,MAAM,SAASJ,YAAU;EAAE;EAAgB;EAAa,CAAC;CACzD,MAAM,OAAO,YAAY;EAAE;EAAW,SAAS;EAAa,QAAQ;EAAc,CAAC;AAEnF,QACE,mGACE,kDAACK,kBAAK;EAAa;EAAM;EAAa;YACpC,kDAACC,sBAAS;GAAY;GAAM;GAAO,QAAQ,OAAO,eAAe;GAAE;aAChE,IAAI,KAAK,KAAK,KAAK,CAAC;IACN;GACL,EACd,kDAACD,kBAAK;EAAO,MAAM;EAAU;EAAa;EAAY;YACpD,kDAACE;GAAK,MAAM;GAAU;aACnB,qBAAqB,KAAK;IACtB;GACK,IACb;;AAIP,YAAY,YAAYP;AACxB,YAAY,iBAAiBI;;;;ACpB7B,SAASI,YAAU,EAAE,cAAc,gBAAgB,eAA+B;CAChF,MAAM,QAAQ,m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kBAAkB,CAAC,SADvB,uBAAuB,YAAY,QAAQ,KAAK,SAAS,KAAK,KAAK,CAAC,KAAK,MAAM,IAAI,QAAQ,GACpD,CAAC,KAAK,KAAK,CAAC;CAClE,MAAM,WAAW;EAAC,WAAW;EAAS,gBAAgB;EAAS,gCAAgC;EAAmB;CAElH,MAAM,iBAAiB,SAAS,UAAU;EACxC;EACA;EACA;EACD,CAAC;CACF,MAAM,qBAAqB,aAAa,UAAU;EAChD;EACA;EACA;EACA;EACD,CAAC;CACF,MAAM,SAAS,UAAU;EACvB;EACA;EACA;EACA;EACA;EACD,CAAC;CAEF,MAAM,eAAe,GAAG,iBAAiB,GAAG,mBAAmB,QAAQ,CAAC;AAExE,QACE,kDAACC,kBAAK;EAAa;EAAM;EAAa;YACpC,kDAACC;GACO;GACN;GACA,UAAU,SAAS,KAAK,KAAK;GAC7B,QAAQ,OAAO,eAAe;GAC9B,OAAO,EACL,mDAAsB,UAAU,EACjC;aAEA;;;oDAG2C,aAAa,GAAG,eAAe,QAAQ,CAAC;;;aAG/E,aAAa;;;;2DAIiC,WAAW;;;;IAIrD;GACC;;AAIlB,MAAM,YAAY"}
|
|
@@ -1,10 +1,175 @@
|
|
|
1
1
|
import { isOptional } from "@kubb/oas";
|
|
2
|
+
import { Client } from "@kubb/plugin-client/components";
|
|
2
3
|
import { getComments, getPathParams } from "@kubb/plugin-oas/utils";
|
|
3
4
|
import { File, Function, FunctionParams, Type } from "@kubb/react";
|
|
4
5
|
import { URLPath } from "@kubb/core/utils";
|
|
5
6
|
import { Fragment, jsx, jsxs } from "@kubb/react/jsx-runtime";
|
|
6
|
-
import { Client } from "@kubb/plugin-client/components";
|
|
7
7
|
|
|
8
|
+
//#region src/components/MutationKey.tsx
|
|
9
|
+
function getParams$4({}) {
|
|
10
|
+
return FunctionParams.factory({});
|
|
11
|
+
}
|
|
12
|
+
const getTransformer$1 = ({ operation, casing }) => {
|
|
13
|
+
return [`{ url: '${new URLPath(operation.path, { casing }).toURLPath()}' }`];
|
|
14
|
+
};
|
|
15
|
+
function MutationKey({ name, typeSchemas, pathParamsType, paramsCasing, operation, typeName, transformer = getTransformer$1 }) {
|
|
16
|
+
const params = getParams$4({
|
|
17
|
+
pathParamsType,
|
|
18
|
+
typeSchemas
|
|
19
|
+
});
|
|
20
|
+
const keys = transformer({
|
|
21
|
+
operation,
|
|
22
|
+
schemas: typeSchemas,
|
|
23
|
+
casing: paramsCasing
|
|
24
|
+
});
|
|
25
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(File.Source, {
|
|
26
|
+
name,
|
|
27
|
+
isExportable: true,
|
|
28
|
+
isIndexable: true,
|
|
29
|
+
children: /* @__PURE__ */ jsx(Function.Arrow, {
|
|
30
|
+
name,
|
|
31
|
+
export: true,
|
|
32
|
+
params: params.toConstructor(),
|
|
33
|
+
singleLine: true,
|
|
34
|
+
children: `[${keys.join(", ")}] as const`
|
|
35
|
+
})
|
|
36
|
+
}), /* @__PURE__ */ jsx(File.Source, {
|
|
37
|
+
name: typeName,
|
|
38
|
+
isExportable: true,
|
|
39
|
+
isIndexable: true,
|
|
40
|
+
isTypeOnly: true,
|
|
41
|
+
children: /* @__PURE__ */ jsx(Type, {
|
|
42
|
+
name: typeName,
|
|
43
|
+
export: true,
|
|
44
|
+
children: `ReturnType<typeof ${name}>`
|
|
45
|
+
})
|
|
46
|
+
})] });
|
|
47
|
+
}
|
|
48
|
+
MutationKey.getParams = getParams$4;
|
|
49
|
+
MutationKey.getTransformer = getTransformer$1;
|
|
50
|
+
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/components/Mutation.tsx
|
|
53
|
+
function getParams$3({ paramsCasing, dataReturnType, typeSchemas }) {
|
|
54
|
+
const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
55
|
+
const TRequest = FunctionParams.factory({
|
|
56
|
+
...getPathParams(typeSchemas.pathParams, {
|
|
57
|
+
typed: true,
|
|
58
|
+
casing: paramsCasing
|
|
59
|
+
}),
|
|
60
|
+
data: typeSchemas.request?.name ? {
|
|
61
|
+
type: typeSchemas.request?.name,
|
|
62
|
+
optional: isOptional(typeSchemas.request?.schema)
|
|
63
|
+
} : void 0,
|
|
64
|
+
params: typeSchemas.queryParams?.name ? {
|
|
65
|
+
type: typeSchemas.queryParams?.name,
|
|
66
|
+
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
67
|
+
} : void 0,
|
|
68
|
+
headers: typeSchemas.headerParams?.name ? {
|
|
69
|
+
type: typeSchemas.headerParams?.name,
|
|
70
|
+
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
71
|
+
} : void 0
|
|
72
|
+
}).toConstructor();
|
|
73
|
+
const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
|
|
74
|
+
const generics = [
|
|
75
|
+
TData,
|
|
76
|
+
TError,
|
|
77
|
+
TRequest ? `{${TRequest}}` : "void",
|
|
78
|
+
"TContext"
|
|
79
|
+
].join(", ");
|
|
80
|
+
return FunctionParams.factory({ options: {
|
|
81
|
+
type: `
|
|
82
|
+
{
|
|
83
|
+
mutation?: ReturnType<UseMutationOptions<${generics}>> & { client?: QueryClient },
|
|
84
|
+
client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }"},
|
|
85
|
+
}
|
|
86
|
+
`,
|
|
87
|
+
default: "{}"
|
|
88
|
+
} });
|
|
89
|
+
}
|
|
90
|
+
function Mutation({ name, clientName, paramsCasing, paramsType, pathParamsType, dataReturnType, typeSchemas, operation, mutationKeyName }) {
|
|
91
|
+
const mutationKeyParams = MutationKey.getParams({
|
|
92
|
+
pathParamsType,
|
|
93
|
+
typeSchemas
|
|
94
|
+
});
|
|
95
|
+
const params = getParams$3({
|
|
96
|
+
paramsCasing,
|
|
97
|
+
pathParamsType,
|
|
98
|
+
dataReturnType,
|
|
99
|
+
typeSchemas
|
|
100
|
+
});
|
|
101
|
+
const clientParams = Client.getParams({
|
|
102
|
+
paramsCasing,
|
|
103
|
+
paramsType,
|
|
104
|
+
typeSchemas,
|
|
105
|
+
pathParamsType,
|
|
106
|
+
isConfigurable: true
|
|
107
|
+
});
|
|
108
|
+
const mutationParams = FunctionParams.factory({
|
|
109
|
+
...getPathParams(typeSchemas.pathParams, {
|
|
110
|
+
typed: true,
|
|
111
|
+
casing: paramsCasing
|
|
112
|
+
}),
|
|
113
|
+
data: typeSchemas.request?.name ? {
|
|
114
|
+
type: typeSchemas.request?.name,
|
|
115
|
+
optional: isOptional(typeSchemas.request?.schema)
|
|
116
|
+
} : void 0,
|
|
117
|
+
params: typeSchemas.queryParams?.name ? {
|
|
118
|
+
type: typeSchemas.queryParams?.name,
|
|
119
|
+
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
120
|
+
} : void 0,
|
|
121
|
+
headers: typeSchemas.headerParams?.name ? {
|
|
122
|
+
type: typeSchemas.headerParams?.name,
|
|
123
|
+
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
124
|
+
} : void 0
|
|
125
|
+
});
|
|
126
|
+
const dataParams = FunctionParams.factory({ data: {
|
|
127
|
+
mode: "object",
|
|
128
|
+
children: Object.entries(mutationParams.params).reduce((acc, [key, value]) => {
|
|
129
|
+
if (value) acc[key] = {
|
|
130
|
+
...value,
|
|
131
|
+
type: void 0
|
|
132
|
+
};
|
|
133
|
+
return acc;
|
|
134
|
+
}, {})
|
|
135
|
+
} });
|
|
136
|
+
const TRequest = mutationParams.toConstructor();
|
|
137
|
+
const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
138
|
+
const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
|
|
139
|
+
const generics = [
|
|
140
|
+
TData,
|
|
141
|
+
TError,
|
|
142
|
+
TRequest ? `{${TRequest}}` : "void",
|
|
143
|
+
"TContext"
|
|
144
|
+
].join(", ");
|
|
145
|
+
return /* @__PURE__ */ jsx(File.Source, {
|
|
146
|
+
name,
|
|
147
|
+
isExportable: true,
|
|
148
|
+
isIndexable: true,
|
|
149
|
+
children: /* @__PURE__ */ jsx(Function, {
|
|
150
|
+
name,
|
|
151
|
+
export: true,
|
|
152
|
+
params: params.toConstructor(),
|
|
153
|
+
JSDoc: { comments: getComments(operation) },
|
|
154
|
+
generics: ["TContext"],
|
|
155
|
+
children: `
|
|
156
|
+
const { mutation = {}, client: config = {} } = options ?? {}
|
|
157
|
+
const { client: queryClient, ...mutationOptions } = mutation;
|
|
158
|
+
const mutationKey = mutationOptions.mutationKey ?? ${mutationKeyName}(${mutationKeyParams.toCall()})
|
|
159
|
+
|
|
160
|
+
return useMutation<${generics}>(()=> ({
|
|
161
|
+
mutationFn: async(${dataParams.toConstructor()}) => {
|
|
162
|
+
return ${clientName}(${clientParams.toCall()})
|
|
163
|
+
},
|
|
164
|
+
mutationKey,
|
|
165
|
+
...mutationOptions
|
|
166
|
+
}), queryClient? () => queryClient: undefined)
|
|
167
|
+
`
|
|
168
|
+
})
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
//#endregion
|
|
8
173
|
//#region src/components/QueryKey.tsx
|
|
9
174
|
function getParams$2({ pathParamsType, paramsCasing, typeSchemas }) {
|
|
10
175
|
return FunctionParams.factory({
|
|
@@ -299,7 +464,7 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsC
|
|
|
299
464
|
const { client: queryClient, ...queryOptions } = queryConfig
|
|
300
465
|
const queryKey = queryOptions?.queryKey ?? ${queryKeyName}(${queryKeyParams.toCall()})
|
|
301
466
|
|
|
302
|
-
const query =
|
|
467
|
+
const query = useQuery(() => ({
|
|
303
468
|
...${queryOptions},
|
|
304
469
|
queryKey,
|
|
305
470
|
initialData: null,
|
|
@@ -314,5 +479,5 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsC
|
|
|
314
479
|
Query.getParams = getParams;
|
|
315
480
|
|
|
316
481
|
//#endregion
|
|
317
|
-
export { Query, QueryKey, QueryOptions };
|
|
318
|
-
//# sourceMappingURL=components-
|
|
482
|
+
export { Mutation, MutationKey, Query, QueryKey, QueryOptions };
|
|
483
|
+
//# sourceMappingURL=components-JN6XAKh3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components-JN6XAKh3.js","names":["getParams","getTransformer: Transformer","getTransformer","getParams","getParams","getTransformer: Transformer","getParams"],"sources":["../src/components/MutationKey.tsx","../src/components/Mutation.tsx","../src/components/QueryKey.tsx","../src/components/QueryOptions.tsx","../src/components/Query.tsx"],"sourcesContent":["import { URLPath } from '@kubb/core/utils'\nimport type { Operation } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { File, Function, FunctionParams, Type } from '@kubb/react'\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 pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({}: GetParamsProps) {\n return FunctionParams.factory({})\n}\n\nconst getTransformer: Transformer = ({ operation, casing }) => {\n const path = new URLPath(operation.path, { casing })\n\n return [`{ url: '${path.toURLPath()}' }`]\n}\n\nexport function MutationKey({ name, typeSchemas, pathParamsType, paramsCasing, operation, typeName, transformer = getTransformer }: Props): ReactNode {\n const params = getParams({ pathParamsType, typeSchemas })\n const keys = transformer({ operation, schemas: typeSchemas, casing: paramsCasing })\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\nMutationKey.getParams = getParams\nMutationKey.getTransformer = getTransformer\n","import { isOptional, type Operation } from '@kubb/oas'\nimport { Client } from '@kubb/plugin-client/components'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getComments, getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams } from '@kubb/react'\nimport type { Params } from '@kubb/react/types'\nimport type { ReactNode } from 'react'\nimport type { PluginSolidQuery } from '../types.ts'\nimport { MutationKey } from './MutationKey.tsx'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n typeName: string\n clientName: string\n mutationKeyName: string\n typeSchemas: OperationSchemas\n operation: Operation\n dataReturnType: PluginSolidQuery['resolvedOptions']['client']['dataReturnType']\n paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']\n paramsType: PluginSolidQuery['resolvedOptions']['paramsType']\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n dataReturnType: PluginSolidQuery['resolvedOptions']['client']['dataReturnType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ paramsCasing, dataReturnType, typeSchemas }: GetParamsProps) {\n const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`\n const mutationParams = FunctionParams.factory({\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 const TRequest = mutationParams.toConstructor()\n const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`\n const generics = [TData, TError, TRequest ? `{${TRequest}}` : 'void', 'TContext'].join(', ')\n\n return FunctionParams.factory({\n options: {\n type: `\n{\n mutation?: ReturnType<UseMutationOptions<${generics}>> & { 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 Mutation({\n name,\n clientName,\n paramsCasing,\n paramsType,\n pathParamsType,\n dataReturnType,\n typeSchemas,\n operation,\n mutationKeyName,\n}: Props): ReactNode {\n const mutationKeyParams = MutationKey.getParams({\n pathParamsType,\n typeSchemas,\n })\n\n const params = getParams({\n paramsCasing,\n pathParamsType,\n dataReturnType,\n typeSchemas,\n })\n\n const clientParams = Client.getParams({\n paramsCasing,\n paramsType,\n typeSchemas,\n pathParamsType,\n isConfigurable: true,\n })\n\n const mutationParams = FunctionParams.factory({\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 const dataParams = FunctionParams.factory({\n data: {\n // No use of pathParams because useMutation can only take one argument in object form,\n // see https://tanstack.com/query/latest/docs/framework/react/reference/useMutation#usemutation\n mode: 'object',\n children: Object.entries(mutationParams.params).reduce((acc, [key, value]) => {\n if (value) {\n acc[key] = {\n ...value,\n type: undefined,\n }\n }\n\n return acc\n }, {} as Params),\n },\n })\n\n const TRequest = mutationParams.toConstructor()\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 generics = [TData, TError, TRequest ? `{${TRequest}}` : 'void', 'TContext'].join(', ')\n\n return (\n <File.Source name={name} isExportable isIndexable>\n <Function\n name={name}\n export\n params={params.toConstructor()}\n JSDoc={{\n comments: getComments(operation),\n }}\n generics={['TContext']}\n >\n {`\n const { mutation = {}, client: config = {} } = options ?? {}\n const { client: queryClient, ...mutationOptions } = mutation;\n const mutationKey = mutationOptions.mutationKey ?? ${mutationKeyName}(${mutationKeyParams.toCall()})\n\n return useMutation<${generics}>(()=> ({\n mutationFn: async(${dataParams.toConstructor()}) => {\n return ${clientName}(${clientParams.toCall()})\n },\n mutationKey,\n ...mutationOptions\n }), queryClient? () => queryClient: undefined)\n `}\n </Function>\n </File.Source>\n )\n}\n","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 = useQuery(() => ({\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":";;;;;;;;AAsBA,SAASA,YAAU,IAAoB;AACrC,QAAO,eAAe,QAAQ,EAAE,CAAC;;AAGnC,MAAMC,oBAA+B,EAAE,WAAW,aAAa;AAG7D,QAAO,CAAC,WAFK,IAAI,QAAQ,UAAU,MAAM,EAAE,QAAQ,CAAC,CAE5B,WAAW,CAAC,KAAK;;AAG3C,SAAgB,YAAY,EAAE,MAAM,aAAa,gBAAgB,cAAc,WAAW,UAAU,cAAcC,oBAAoC;CACpJ,MAAM,SAASF,YAAU;EAAE;EAAgB;EAAa,CAAC;CACzD,MAAM,OAAO,YAAY;EAAE;EAAW,SAAS;EAAa,QAAQ;EAAc,CAAC;AAEnF,QACE,4CACE,oBAAC,KAAK;EAAa;EAAM;EAAa;YACpC,oBAAC,SAAS;GAAY;GAAM;GAAO,QAAQ,OA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AS;GACP,MAAM;;wCAE4B;IAAC;IAAO;IAAQ;IAAS;IAAc;IAAY,CAAC,KAAK,KAAK,CAAC;aAC1F,YAAY,SAAS,OAAO,yBAAyB,YAAY,SAAS,KAAK,kCAAkC,qDAAqD;;;GAG7K,SAAS;GACV;EACF,CAAC;;AAGJ,SAAgB,MAAM,EACpB,MACA,kBACA,kBACA,cACA,cACA,YACA,gBACA,gBACA,aACA,aACmB;CACnB,MAAM,QAAQ,mBAAmB,SAAS,YAAY,SAAS,OAAO,kBAAkB,YAAY,SAAS,KAAK;CAElH,MAAM,aAAa,kBAAkB,CAAC,SADvB,uBAAuB,YAAY,QAAQ,KAAK,SAAS,KAAK,KAAK,CAAC,KAAK,MAAM,IAAI,QAAQ,GACpD,CAAC,KAAK,KAAK,CAAC;CAClE,MAAM,WAAW;EAAC,WAAW;EAAS,gBAAgB;EAAS,gCAAgC;EAAmB;CAElH,MAAM,iBAAiB,SAAS,UAAU;EACxC;EACA;EACA;EACD,CAAC;CACF,MAAM,qBAAqB,aAAa,UAAU;EAChD;EACA;EACA;EACA;EACD,CAAC;CACF,MAAM,SAAS,UAAU;EACvB;EACA;EACA;EACA;EACA;EACD,CAAC;CAEF,MAAM,eAAe,GAAG,iBAAiB,GAAG,mBAAmB,QAAQ,CAAC;AAExE,QACE,oBAAC,KAAK;EAAa;EAAM;EAAa;YACpC,oBAAC;GACO;GACN;GACA,UAAU,SAAS,KAAK,KAAK;GAC7B,QAAQ,OAAO,eAAe;GAC9B,OAAO,EACL,UAAU,YAAY,UAAU,EACjC;aAEA;;;oDAG2C,aAAa,GAAG,eAAe,QAAQ,CAAC;;;aAG/E,aAAa;;;;2DAIiC,WAAW;;;;IAIrD;GACC;;AAIlB,MAAM,YAAY"}
|
package/dist/components.cjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
const require_components = require('./components-
|
|
1
|
+
const require_components = require('./components-CrpQqUQQ.cjs');
|
|
2
2
|
|
|
3
|
+
exports.Mutation = require_components.Mutation;
|
|
4
|
+
exports.MutationKey = require_components.MutationKey;
|
|
3
5
|
exports.Query = require_components.Query;
|
|
4
6
|
exports.QueryKey = require_components.QueryKey;
|
|
5
7
|
exports.QueryOptions = require_components.QueryOptions;
|
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-BI1GJc6y.cjs";
|
|
2
2
|
import { ReactNode } from "react";
|
|
3
3
|
|
|
4
4
|
//#region ../react/src/utils/getFunctionParams.d.ts
|
|
@@ -45,6 +45,62 @@ declare class FunctionParams {
|
|
|
45
45
|
toConstructor(): string;
|
|
46
46
|
}
|
|
47
47
|
//#endregion
|
|
48
|
+
//#region src/components/Mutation.d.ts
|
|
49
|
+
type Props$4 = {
|
|
50
|
+
/**
|
|
51
|
+
* Name of the function
|
|
52
|
+
*/
|
|
53
|
+
name: string;
|
|
54
|
+
typeName: string;
|
|
55
|
+
clientName: string;
|
|
56
|
+
mutationKeyName: string;
|
|
57
|
+
typeSchemas: OperationSchemas;
|
|
58
|
+
operation: Operation;
|
|
59
|
+
dataReturnType: PluginSolidQuery['resolvedOptions']['client']['dataReturnType'];
|
|
60
|
+
paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing'];
|
|
61
|
+
paramsType: PluginSolidQuery['resolvedOptions']['paramsType'];
|
|
62
|
+
pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType'];
|
|
63
|
+
};
|
|
64
|
+
declare function Mutation({
|
|
65
|
+
name,
|
|
66
|
+
clientName,
|
|
67
|
+
paramsCasing,
|
|
68
|
+
paramsType,
|
|
69
|
+
pathParamsType,
|
|
70
|
+
dataReturnType,
|
|
71
|
+
typeSchemas,
|
|
72
|
+
operation,
|
|
73
|
+
mutationKeyName
|
|
74
|
+
}: Props$4): ReactNode;
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region src/components/MutationKey.d.ts
|
|
77
|
+
type Props$3 = {
|
|
78
|
+
name: string;
|
|
79
|
+
typeName: string;
|
|
80
|
+
typeSchemas: OperationSchemas;
|
|
81
|
+
operation: Operation;
|
|
82
|
+
paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing'];
|
|
83
|
+
pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType'];
|
|
84
|
+
transformer: Transformer | undefined;
|
|
85
|
+
};
|
|
86
|
+
type GetParamsProps$3 = {
|
|
87
|
+
pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType'];
|
|
88
|
+
typeSchemas: OperationSchemas;
|
|
89
|
+
};
|
|
90
|
+
declare function MutationKey({
|
|
91
|
+
name,
|
|
92
|
+
typeSchemas,
|
|
93
|
+
pathParamsType,
|
|
94
|
+
paramsCasing,
|
|
95
|
+
operation,
|
|
96
|
+
typeName,
|
|
97
|
+
transformer
|
|
98
|
+
}: Props$3): ReactNode;
|
|
99
|
+
declare namespace MutationKey {
|
|
100
|
+
var getParams: ({}: GetParamsProps$3) => FunctionParams;
|
|
101
|
+
var getTransformer: Transformer;
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
48
104
|
//#region src/components/Query.d.ts
|
|
49
105
|
type Props$2 = {
|
|
50
106
|
/**
|
|
@@ -159,5 +215,5 @@ declare namespace QueryOptions {
|
|
|
159
215
|
}: GetParamsProps) => FunctionParams;
|
|
160
216
|
}
|
|
161
217
|
//#endregion
|
|
162
|
-
export { Query, QueryKey, QueryOptions };
|
|
218
|
+
export { Mutation, MutationKey, Query, QueryKey, QueryOptions };
|
|
163
219
|
//# sourceMappingURL=components.d.cts.map
|