@kubb/plugin-swr 4.9.1 → 4.9.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-BkOGXzS-.cjs → components-CWmdrh07.cjs} +116 -16
- package/dist/components-CWmdrh07.cjs.map +1 -0
- package/dist/{components-BWaOPuUc.js → components-bS6nIkbY.js} +115 -15
- package/dist/components-bS6nIkbY.js.map +1 -0
- package/dist/components.cjs +1 -1
- package/dist/components.d.cts +8 -2
- package/dist/components.d.ts +8 -2
- package/dist/components.js +1 -1
- package/dist/{generators-B-l1M57U.cjs → generators-CVb2gh4h.cjs} +4 -3
- package/dist/{generators-B-l1M57U.cjs.map → generators-CVb2gh4h.cjs.map} +1 -1
- package/dist/{generators-Cqn7fJTZ.js → generators-Cb1LhyE9.js} +4 -3
- package/dist/{generators-Cqn7fJTZ.js.map → generators-Cb1LhyE9.js.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-CZ5nqQF8.d.cts → types-BhMJy6gt.d.ts} +10 -3
- package/dist/{types-CzR1-kCr.d.ts → types-DV16H9Nj.d.cts} +10 -3
- package/package.json +7 -7
- package/src/components/Mutation.tsx +155 -17
- package/src/generators/__snapshots__/updatePetByIdParamsToTrigger.ts +67 -0
- package/src/generators/mutationGenerator.tsx +1 -0
- package/src/types.ts +8 -1
- package/dist/components-BWaOPuUc.js.map +0 -1
- package/dist/components-BkOGXzS-.cjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_generators = require('./generators-
|
|
1
|
+
const require_generators = require('./generators-CVb2gh4h.cjs');
|
|
2
2
|
let __kubb_core_utils = require("@kubb/core/utils");
|
|
3
3
|
let __kubb_oas = require("@kubb/oas");
|
|
4
4
|
let __kubb_plugin_client_components = require("@kubb/plugin-client/components");
|
|
@@ -83,24 +83,47 @@ function getParams$3({ pathParamsType, paramsCasing, dataReturnType, typeSchemas
|
|
|
83
83
|
}
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
|
-
function
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
86
|
+
function getTriggerParams({ dataReturnType, typeSchemas, mutationKeyTypeName, mutationArgTypeName }) {
|
|
87
|
+
const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
88
|
+
const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
|
|
89
|
+
return __kubb_react_fabric.FunctionParams.factory({ options: {
|
|
90
|
+
type: `
|
|
91
|
+
{
|
|
92
|
+
mutation?: SWRMutationConfiguration<${TData}, ${TError}, ${mutationKeyTypeName} | null, ${mutationArgTypeName}> & { throwOnError?: boolean },
|
|
93
|
+
client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }"},
|
|
94
|
+
shouldFetch?: boolean,
|
|
95
|
+
}
|
|
96
|
+
`,
|
|
97
|
+
default: "{}"
|
|
98
|
+
} });
|
|
99
|
+
}
|
|
100
|
+
function getMutationParams({ paramsCasing, typeSchemas }) {
|
|
101
|
+
return __kubb_react_fabric.FunctionParams.factory({
|
|
102
|
+
...(0, __kubb_plugin_oas_utils.getPathParams)(typeSchemas.pathParams, {
|
|
103
|
+
typed: true,
|
|
104
|
+
casing: paramsCasing
|
|
105
|
+
}),
|
|
106
|
+
data: typeSchemas.request?.name ? {
|
|
107
|
+
type: typeSchemas.request?.name,
|
|
108
|
+
optional: (0, __kubb_oas.isOptional)(typeSchemas.request?.schema)
|
|
109
|
+
} : void 0,
|
|
110
|
+
params: typeSchemas.queryParams?.name ? {
|
|
111
|
+
type: typeSchemas.queryParams?.name,
|
|
112
|
+
optional: (0, __kubb_oas.isOptional)(typeSchemas.queryParams?.schema)
|
|
113
|
+
} : void 0,
|
|
114
|
+
headers: typeSchemas.headerParams?.name ? {
|
|
115
|
+
type: typeSchemas.headerParams?.name,
|
|
116
|
+
optional: (0, __kubb_oas.isOptional)(typeSchemas.headerParams?.schema)
|
|
117
|
+
} : void 0
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
function Mutation({ name, clientName, mutationKeyName, mutationKeyTypeName, paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas, operation, paramsToTrigger = false }) {
|
|
121
|
+
const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
122
|
+
const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
|
|
93
123
|
const mutationKeyParams = MutationKey.getParams({
|
|
94
124
|
pathParamsType,
|
|
95
125
|
typeSchemas
|
|
96
126
|
});
|
|
97
|
-
const params = getParams$3({
|
|
98
|
-
paramsCasing,
|
|
99
|
-
pathParamsType,
|
|
100
|
-
dataReturnType,
|
|
101
|
-
typeSchemas,
|
|
102
|
-
mutationKeyTypeName
|
|
103
|
-
});
|
|
104
127
|
const clientParams = __kubb_plugin_client_components.Client.getParams({
|
|
105
128
|
paramsCasing,
|
|
106
129
|
paramsType,
|
|
@@ -108,6 +131,83 @@ function Mutation({ name, clientName, mutationKeyName, mutationKeyTypeName, para
|
|
|
108
131
|
pathParamsType,
|
|
109
132
|
isConfigurable: true
|
|
110
133
|
});
|
|
134
|
+
if (paramsToTrigger) {
|
|
135
|
+
const mutationParams = getMutationParams({
|
|
136
|
+
paramsCasing,
|
|
137
|
+
typeSchemas
|
|
138
|
+
});
|
|
139
|
+
const mutationArgTypeName = `${mutationKeyTypeName.replace("MutationKey", "")}MutationArg`;
|
|
140
|
+
const hasMutationParams = Object.keys(mutationParams.params).length > 0;
|
|
141
|
+
const argParams = __kubb_react_fabric.FunctionParams.factory({ data: {
|
|
142
|
+
mode: "object",
|
|
143
|
+
children: Object.entries(mutationParams.params).reduce((acc, [key, value]) => {
|
|
144
|
+
if (value) acc[key] = {
|
|
145
|
+
...value,
|
|
146
|
+
type: void 0
|
|
147
|
+
};
|
|
148
|
+
return acc;
|
|
149
|
+
}, {})
|
|
150
|
+
} });
|
|
151
|
+
const params$1 = getTriggerParams({
|
|
152
|
+
dataReturnType,
|
|
153
|
+
typeSchemas,
|
|
154
|
+
mutationKeyTypeName,
|
|
155
|
+
mutationArgTypeName
|
|
156
|
+
});
|
|
157
|
+
const generics$1 = [
|
|
158
|
+
TData,
|
|
159
|
+
TError,
|
|
160
|
+
`${mutationKeyTypeName} | null`,
|
|
161
|
+
mutationArgTypeName
|
|
162
|
+
].filter(Boolean);
|
|
163
|
+
const mutationArg = mutationParams.toConstructor();
|
|
164
|
+
return /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsxs)(__kubb_react_fabric_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Source, {
|
|
165
|
+
name: mutationArgTypeName,
|
|
166
|
+
isExportable: true,
|
|
167
|
+
isIndexable: true,
|
|
168
|
+
isTypeOnly: true,
|
|
169
|
+
children: /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.Type, {
|
|
170
|
+
name: mutationArgTypeName,
|
|
171
|
+
export: true,
|
|
172
|
+
children: hasMutationParams ? `{${mutationArg}}` : "never"
|
|
173
|
+
})
|
|
174
|
+
}), /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Source, {
|
|
175
|
+
name,
|
|
176
|
+
isExportable: true,
|
|
177
|
+
isIndexable: true,
|
|
178
|
+
children: /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.Function, {
|
|
179
|
+
name,
|
|
180
|
+
export: true,
|
|
181
|
+
params: params$1.toConstructor(),
|
|
182
|
+
JSDoc: { comments: (0, __kubb_plugin_oas_utils.getComments)(operation) },
|
|
183
|
+
children: `
|
|
184
|
+
const { mutation: mutationOptions, client: config = {}, shouldFetch = true } = options ?? {}
|
|
185
|
+
const mutationKey = ${mutationKeyName}(${mutationKeyParams.toCall()})
|
|
186
|
+
|
|
187
|
+
return useSWRMutation<${generics$1.join(", ")}>(
|
|
188
|
+
shouldFetch ? mutationKey : null,
|
|
189
|
+
async (_url${hasMutationParams ? `, { arg: ${argParams.toCall()} }` : ""}) => {
|
|
190
|
+
return ${clientName}(${clientParams.toCall()})
|
|
191
|
+
},
|
|
192
|
+
mutationOptions
|
|
193
|
+
)
|
|
194
|
+
`
|
|
195
|
+
})
|
|
196
|
+
})] });
|
|
197
|
+
}
|
|
198
|
+
const generics = [
|
|
199
|
+
TData,
|
|
200
|
+
TError,
|
|
201
|
+
`${mutationKeyTypeName} | null`,
|
|
202
|
+
typeSchemas.request?.name
|
|
203
|
+
].filter(Boolean);
|
|
204
|
+
const params = getParams$3({
|
|
205
|
+
paramsCasing,
|
|
206
|
+
pathParamsType,
|
|
207
|
+
dataReturnType,
|
|
208
|
+
typeSchemas,
|
|
209
|
+
mutationKeyTypeName
|
|
210
|
+
});
|
|
111
211
|
return /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Source, {
|
|
112
212
|
name,
|
|
113
213
|
isExportable: true,
|
|
@@ -451,4 +551,4 @@ Object.defineProperty(exports, 'QueryOptions', {
|
|
|
451
551
|
return QueryOptions;
|
|
452
552
|
}
|
|
453
553
|
});
|
|
454
|
-
//# sourceMappingURL=components-
|
|
554
|
+
//# sourceMappingURL=components-CWmdrh07.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components-CWmdrh07.cjs","names":["getParams","FunctionParams","getTransformer: Transformer","URLPath","getTransformer","File","Function","Type","getParams","FunctionParams","Client","params","generics","File","Type","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-fabric'\nimport type { KubbNode } from '@kubb/react-fabric/types'\nimport type { PluginSwr, Transformer } from '../types'\n\ntype Props = {\n name: string\n typeName: string\n typeSchemas: OperationSchemas\n operation: Operation\n paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n transformer: Transformer | undefined\n}\n\ntype GetParamsProps = {\n pathParamsType: PluginSwr['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, paramsCasing, pathParamsType, operation, typeName, transformer = getTransformer }: Props): KubbNode {\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, Type } from '@kubb/react-fabric'\nimport type { KubbNode, Params } from '@kubb/react-fabric/types'\nimport type { PluginSwr } 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 mutationKeyTypeName: string\n typeSchemas: OperationSchemas\n operation: Operation\n paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n paramsType: PluginSwr['resolvedOptions']['paramsType']\n dataReturnType: PluginSwr['resolvedOptions']['client']['dataReturnType']\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n /**\n * When true, mutation parameters are passed via trigger() instead of as hook arguments\n * @default false\n */\n paramsToTrigger?: boolean\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n dataReturnType: PluginSwr['resolvedOptions']['client']['dataReturnType']\n typeSchemas: OperationSchemas\n mutationKeyTypeName: string\n}\n\n// Original getParams - used when paramsToTrigger is false (default)\nfunction getParams({ pathParamsType, paramsCasing, dataReturnType, typeSchemas, mutationKeyTypeName }: 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 const TExtraArg = typeSchemas.request?.name || 'never'\n\n return FunctionParams.factory({\n pathParams: {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n },\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 mutation?: SWRMutationConfiguration<${TData}, ${TError}, ${mutationKeyTypeName} | null, ${TExtraArg}> & { throwOnError?: boolean },\n client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : 'Partial<RequestConfig> & { client?: typeof fetch }'},\n shouldFetch?: boolean,\n}\n`,\n default: '{}',\n },\n })\n}\n\ntype GetTriggerParamsProps = {\n dataReturnType: PluginSwr['resolvedOptions']['client']['dataReturnType']\n typeSchemas: OperationSchemas\n mutationKeyTypeName: string\n mutationArgTypeName: string\n}\n\n// New getParams - used when paramsToTrigger is true\nfunction getTriggerParams({ dataReturnType, typeSchemas, mutationKeyTypeName, mutationArgTypeName }: GetTriggerParamsProps) {\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 return FunctionParams.factory({\n options: {\n type: `\n{\n mutation?: SWRMutationConfiguration<${TData}, ${TError}, ${mutationKeyTypeName} | null, ${mutationArgTypeName}> & { throwOnError?: boolean },\n client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : 'Partial<RequestConfig> & { client?: typeof fetch }'},\n shouldFetch?: boolean,\n}\n`,\n default: '{}',\n },\n })\n}\n\ntype GetMutationParamsProps = {\n paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n typeSchemas: OperationSchemas\n}\n\nfunction getMutationParams({ paramsCasing, typeSchemas }: GetMutationParamsProps) {\n return 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\nexport function Mutation({\n name,\n clientName,\n mutationKeyName,\n mutationKeyTypeName,\n paramsType,\n paramsCasing,\n pathParamsType,\n dataReturnType,\n typeSchemas,\n operation,\n paramsToTrigger = false,\n}: Props): KubbNode {\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 mutationKeyParams = MutationKey.getParams({\n pathParamsType,\n typeSchemas,\n })\n\n const clientParams = Client.getParams({\n paramsCasing,\n paramsType,\n typeSchemas,\n pathParamsType,\n isConfigurable: true,\n })\n\n // Use the new trigger-based approach when paramsToTrigger is true\n if (paramsToTrigger) {\n // Build the mutation params type (for arg destructuring)\n const mutationParams = getMutationParams({\n paramsCasing,\n typeSchemas,\n })\n\n // Get the arg type name\n const mutationArgTypeName = `${mutationKeyTypeName.replace('MutationKey', '')}MutationArg`\n\n // Check if there are any mutation params (path, data, params, headers)\n const hasMutationParams = Object.keys(mutationParams.params).length > 0\n\n // Build the arg type for useSWRMutation\n const argParams = FunctionParams.factory({\n data: {\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 return acc\n }, {} as Params),\n },\n })\n\n const params = getTriggerParams({\n dataReturnType,\n typeSchemas,\n mutationKeyTypeName,\n mutationArgTypeName,\n })\n\n const generics = [TData, TError, `${mutationKeyTypeName} | null`, mutationArgTypeName].filter(Boolean)\n\n const mutationArg = mutationParams.toConstructor()\n\n return (\n <>\n <File.Source name={mutationArgTypeName} isExportable isIndexable isTypeOnly>\n <Type name={mutationArgTypeName} export>\n {hasMutationParams ? `{${mutationArg}}` : 'never'}\n </Type>\n </File.Source>\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 >\n {`\n const { mutation: mutationOptions, client: config = {}, shouldFetch = true } = options ?? {}\n const mutationKey = ${mutationKeyName}(${mutationKeyParams.toCall()})\n\n return useSWRMutation<${generics.join(', ')}>(\n shouldFetch ? mutationKey : null,\n async (_url${hasMutationParams ? `, { arg: ${argParams.toCall()} }` : ''}) => {\n return ${clientName}(${clientParams.toCall()})\n },\n mutationOptions\n )\n `}\n </Function>\n </File.Source>\n </>\n )\n }\n\n // Original behavior (default)\n const generics = [\n TData,\n TError,\n `${mutationKeyTypeName} | null`,\n typeSchemas.request?.name, // TExtraArg - the arg type for useSWRMutation\n ].filter(Boolean)\n\n const params = getParams({\n paramsCasing,\n pathParamsType,\n dataReturnType,\n typeSchemas,\n mutationKeyTypeName,\n })\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 >\n {`\n const { mutation: mutationOptions, client: config = {}, shouldFetch = true } = options ?? {}\n const mutationKey = ${mutationKeyName}(${mutationKeyParams.toCall()})\n\n return useSWRMutation<${generics.join(', ')}>(\n shouldFetch ? mutationKey : null,\n async (_url${typeSchemas.request?.name ? ', { arg: data }' : ''}) => {\n return ${clientName}(${clientParams.toCall()})\n },\n mutationOptions\n )\n `}\n </Function>\n </File.Source>\n )\n}\n","import { URLPath } from '@kubb/core/utils'\nimport { isOptional, type Operation } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams, Type } from '@kubb/react-fabric'\nimport type { KubbNode } from '@kubb/react-fabric/types'\nimport type { PluginSwr, Transformer } from '../types'\n\ntype Props = {\n name: string\n typeName: string\n typeSchemas: OperationSchemas\n operation: Operation\n paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n transformer: Transformer | undefined\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n pathParamsType: PluginSwr['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): KubbNode {\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 { isOptional } from '@kubb/oas'\nimport { Client } from '@kubb/plugin-client/components'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams } from '@kubb/react-fabric'\nimport type { KubbNode } from '@kubb/react-fabric/types'\nimport type { PluginSwr } from '../types.ts'\n\ntype Props = {\n name: string\n clientName: string\n typeSchemas: OperationSchemas\n paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n paramsType: PluginSwr['resolvedOptions']['paramsType']\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n}\n\ntype GetParamsProps = {\n paramsType: PluginSwr['resolvedOptions']['paramsType']\n paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n pathParamsType: PluginSwr['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, pathParamsType }: Props): KubbNode {\n const params = getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas })\n const clientParams = Client.getParams({\n paramsCasing,\n paramsType,\n typeSchemas,\n pathParamsType,\n isConfigurable: true,\n })\n\n return (\n <File.Source name={name} isExportable isIndexable>\n <Function name={name} export params={params.toConstructor()}>\n {`\n return {\n fetcher: async () => {\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-fabric'\nimport type { KubbNode } from '@kubb/react-fabric/types'\nimport type { PluginSwr } 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 paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n paramsType: PluginSwr['resolvedOptions']['paramsType']\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n dataReturnType: PluginSwr['resolvedOptions']['client']['dataReturnType']\n operation: Operation\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n paramsType: PluginSwr['resolvedOptions']['paramsType']\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n dataReturnType: PluginSwr['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?: Parameters<typeof useSWR<${[TData, TError].join(', ')}>>[2],\n client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : 'Partial<RequestConfig> & { client?: typeof fetch }'},\n shouldFetch?: boolean,\n immutable?: boolean\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?: Parameters<typeof useSWR<${[TData, TError].join(', ')}>>[2],\n client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : 'Partial<RequestConfig> & { client?: typeof fetch }'},\n shouldFetch?: boolean,\n immutable?: boolean\n}\n`,\n default: '{}',\n },\n })\n}\n\nexport function Query({\n name,\n typeSchemas,\n queryKeyName,\n queryKeyTypeName,\n queryOptionsName,\n operation,\n dataReturnType,\n paramsType,\n paramsCasing,\n pathParamsType,\n}: Props): KubbNode {\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, `${queryKeyTypeName} | null`]\n\n const queryKeyParams = QueryKey.getParams({\n pathParamsType,\n typeSchemas,\n paramsCasing,\n })\n const params = getParams({\n paramsCasing,\n paramsType,\n pathParamsType,\n dataReturnType,\n typeSchemas,\n })\n\n const queryOptionsParams = QueryOptions.getParams({\n paramsCasing,\n paramsType,\n pathParamsType,\n typeSchemas,\n })\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 >\n {`\n const { query: queryOptions, client: config = {}, shouldFetch = true, immutable } = options ?? {}\n\n const queryKey = ${queryKeyName}(${queryKeyParams.toCall()})\n\n return useSWR<${generics.join(', ')}>(\n shouldFetch ? queryKey : null,\n {\n ...${queryOptionsName}(${queryOptionsParams.toCall()}),\n ...(immutable ? {\n revalidateIfStale: false,\n revalidateOnFocus: false,\n revalidateOnReconnect: false\n } : { }),\n ...queryOptions\n }\n )\n `}\n </Function>\n </File.Source>\n )\n}\n"],"mappings":";;;;;;;;;AAsBA,SAASA,YAAU,IAAoB;AACrC,QAAOC,mCAAe,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,cAAc,gBAAgB,WAAW,UAAU,cAAcC,oBAAmC;CACnJ,MAAM,SAASJ,YAAU;EAAE;EAAgB;EAAa,CAAC;CACzD,MAAM,OAAO,YAAY;EAAE;EAAW,SAAS;EAAa,QAAQ;EAAc,CAAC;AAEnF,QACE,iHACE,yDAACK,yBAAK;EAAa;EAAM;EAAa;YACpC,yDAACC,6BAAS;GAAY;GAAM;GAAO,QAAQ,OAAO,eAAe;GAAE;aAChE,IAAI,KAAK,KAAK,KAAK,CAAC;IACN;GACL,EACd,yDAACD,yBAAK;EAAO,MAAM;EAAU;EAAa;EAAY;YACpD,yDAACE;GAAK,MAAM;GAAU;aACnB,qBAAqB,KAAK;IACtB;GACK,IACb;;AAIP,YAAY,YAAYP;AACxB,YAAY,iBAAiBI;;;;ACb7B,SAASI,YAAU,EAAE,gBAAgB,cAAc,gBAAgB,aAAa,uBAAuC;CACrH,MAAM,QAAQ,mBAAmB,SAAS,YAAY,SAAS,OAAO,kBAAkB,YAAY,SAAS,KAAK;CAClH,MAAM,SAAS,uBAAuB,YAAY,QAAQ,KAAK,SAAS,KAAK,KAAK,CAAC,KAAK,MAAM,IAAI,QAAQ;CAC1G,MAAM,YAAY,YAAY,SAAS,QAAQ;AAE/C,QAAOC,mCAAe,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Y,cAAc;GAChC,qCAAqB,YAAY,cAAc,OAAO;GACvD,GACD;EACJ,SAAS;GACP,MAAM;;qCAEyB,CAAC,OAAO,OAAO,CAAC,KAAK,KAAK,CAAC;aACnD,YAAY,SAAS,OAAO,yBAAyB,YAAY,SAAS,KAAK,kCAAkC,qDAAqD;;;;;GAK7K,SAAS;GACV;EACF,CAAC;;AAGJ,SAAgB,MAAM,EACpB,MACA,aACA,cACA,kBACA,kBACA,WACA,gBACA,YACA,cACA,kBACkB;CAGlB,MAAM,WAAW;EAFH,mBAAmB,SAAS,YAAY,SAAS,OAAO,kBAAkB,YAAY,SAAS,KAAK;EACnG,uBAAuB,YAAY,QAAQ,KAAK,SAAS,KAAK,KAAK,CAAC,KAAK,MAAM,IAAI,QAAQ;EACzE,GAAG,iBAAiB;EAAS;CAE9D,MAAM,iBAAiB,SAAS,UAAU;EACxC;EACA;EACA;EACD,CAAC;CACF,MAAM,SAAS,UAAU;EACvB;EACA;EACA;EACA;EACA;EACD,CAAC;CAEF,MAAM,qBAAqB,aAAa,UAAU;EAChD;EACA;EACA;EACA;EACD,CAAC;AAEF,QACE,yDAACC,yBAAK;EAAa;EAAM;EAAa;YACpC,yDAACC;GACO;GACN;GACA,QAAQ,OAAO,eAAe;GAC9B,OAAO,EACL,mDAAsB,UAAU,EACjC;aAEA;;;0BAGiB,aAAa,GAAG,eAAe,QAAQ,CAAC;;uBAE3C,SAAS,KAAK,KAAK,CAAC;;;eAG5B,iBAAiB,GAAG,mBAAmB,QAAQ,CAAC;;;;;;;;;;IAU9C;GACC"}
|
|
@@ -82,24 +82,47 @@ function getParams$3({ pathParamsType, paramsCasing, dataReturnType, typeSchemas
|
|
|
82
82
|
}
|
|
83
83
|
});
|
|
84
84
|
}
|
|
85
|
-
function
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
85
|
+
function getTriggerParams({ dataReturnType, typeSchemas, mutationKeyTypeName, mutationArgTypeName }) {
|
|
86
|
+
const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
87
|
+
const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
|
|
88
|
+
return FunctionParams.factory({ options: {
|
|
89
|
+
type: `
|
|
90
|
+
{
|
|
91
|
+
mutation?: SWRMutationConfiguration<${TData}, ${TError}, ${mutationKeyTypeName} | null, ${mutationArgTypeName}> & { throwOnError?: boolean },
|
|
92
|
+
client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }"},
|
|
93
|
+
shouldFetch?: boolean,
|
|
94
|
+
}
|
|
95
|
+
`,
|
|
96
|
+
default: "{}"
|
|
97
|
+
} });
|
|
98
|
+
}
|
|
99
|
+
function getMutationParams({ paramsCasing, typeSchemas }) {
|
|
100
|
+
return FunctionParams.factory({
|
|
101
|
+
...getPathParams(typeSchemas.pathParams, {
|
|
102
|
+
typed: true,
|
|
103
|
+
casing: paramsCasing
|
|
104
|
+
}),
|
|
105
|
+
data: typeSchemas.request?.name ? {
|
|
106
|
+
type: typeSchemas.request?.name,
|
|
107
|
+
optional: isOptional(typeSchemas.request?.schema)
|
|
108
|
+
} : void 0,
|
|
109
|
+
params: typeSchemas.queryParams?.name ? {
|
|
110
|
+
type: typeSchemas.queryParams?.name,
|
|
111
|
+
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
112
|
+
} : void 0,
|
|
113
|
+
headers: typeSchemas.headerParams?.name ? {
|
|
114
|
+
type: typeSchemas.headerParams?.name,
|
|
115
|
+
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
116
|
+
} : void 0
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
function Mutation({ name, clientName, mutationKeyName, mutationKeyTypeName, paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas, operation, paramsToTrigger = false }) {
|
|
120
|
+
const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
121
|
+
const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
|
|
92
122
|
const mutationKeyParams = MutationKey.getParams({
|
|
93
123
|
pathParamsType,
|
|
94
124
|
typeSchemas
|
|
95
125
|
});
|
|
96
|
-
const params = getParams$3({
|
|
97
|
-
paramsCasing,
|
|
98
|
-
pathParamsType,
|
|
99
|
-
dataReturnType,
|
|
100
|
-
typeSchemas,
|
|
101
|
-
mutationKeyTypeName
|
|
102
|
-
});
|
|
103
126
|
const clientParams = Client.getParams({
|
|
104
127
|
paramsCasing,
|
|
105
128
|
paramsType,
|
|
@@ -107,6 +130,83 @@ function Mutation({ name, clientName, mutationKeyName, mutationKeyTypeName, para
|
|
|
107
130
|
pathParamsType,
|
|
108
131
|
isConfigurable: true
|
|
109
132
|
});
|
|
133
|
+
if (paramsToTrigger) {
|
|
134
|
+
const mutationParams = getMutationParams({
|
|
135
|
+
paramsCasing,
|
|
136
|
+
typeSchemas
|
|
137
|
+
});
|
|
138
|
+
const mutationArgTypeName = `${mutationKeyTypeName.replace("MutationKey", "")}MutationArg`;
|
|
139
|
+
const hasMutationParams = Object.keys(mutationParams.params).length > 0;
|
|
140
|
+
const argParams = FunctionParams.factory({ data: {
|
|
141
|
+
mode: "object",
|
|
142
|
+
children: Object.entries(mutationParams.params).reduce((acc, [key, value]) => {
|
|
143
|
+
if (value) acc[key] = {
|
|
144
|
+
...value,
|
|
145
|
+
type: void 0
|
|
146
|
+
};
|
|
147
|
+
return acc;
|
|
148
|
+
}, {})
|
|
149
|
+
} });
|
|
150
|
+
const params$1 = getTriggerParams({
|
|
151
|
+
dataReturnType,
|
|
152
|
+
typeSchemas,
|
|
153
|
+
mutationKeyTypeName,
|
|
154
|
+
mutationArgTypeName
|
|
155
|
+
});
|
|
156
|
+
const generics$1 = [
|
|
157
|
+
TData,
|
|
158
|
+
TError,
|
|
159
|
+
`${mutationKeyTypeName} | null`,
|
|
160
|
+
mutationArgTypeName
|
|
161
|
+
].filter(Boolean);
|
|
162
|
+
const mutationArg = mutationParams.toConstructor();
|
|
163
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(File.Source, {
|
|
164
|
+
name: mutationArgTypeName,
|
|
165
|
+
isExportable: true,
|
|
166
|
+
isIndexable: true,
|
|
167
|
+
isTypeOnly: true,
|
|
168
|
+
children: /* @__PURE__ */ jsx(Type, {
|
|
169
|
+
name: mutationArgTypeName,
|
|
170
|
+
export: true,
|
|
171
|
+
children: hasMutationParams ? `{${mutationArg}}` : "never"
|
|
172
|
+
})
|
|
173
|
+
}), /* @__PURE__ */ jsx(File.Source, {
|
|
174
|
+
name,
|
|
175
|
+
isExportable: true,
|
|
176
|
+
isIndexable: true,
|
|
177
|
+
children: /* @__PURE__ */ jsx(Function, {
|
|
178
|
+
name,
|
|
179
|
+
export: true,
|
|
180
|
+
params: params$1.toConstructor(),
|
|
181
|
+
JSDoc: { comments: getComments(operation) },
|
|
182
|
+
children: `
|
|
183
|
+
const { mutation: mutationOptions, client: config = {}, shouldFetch = true } = options ?? {}
|
|
184
|
+
const mutationKey = ${mutationKeyName}(${mutationKeyParams.toCall()})
|
|
185
|
+
|
|
186
|
+
return useSWRMutation<${generics$1.join(", ")}>(
|
|
187
|
+
shouldFetch ? mutationKey : null,
|
|
188
|
+
async (_url${hasMutationParams ? `, { arg: ${argParams.toCall()} }` : ""}) => {
|
|
189
|
+
return ${clientName}(${clientParams.toCall()})
|
|
190
|
+
},
|
|
191
|
+
mutationOptions
|
|
192
|
+
)
|
|
193
|
+
`
|
|
194
|
+
})
|
|
195
|
+
})] });
|
|
196
|
+
}
|
|
197
|
+
const generics = [
|
|
198
|
+
TData,
|
|
199
|
+
TError,
|
|
200
|
+
`${mutationKeyTypeName} | null`,
|
|
201
|
+
typeSchemas.request?.name
|
|
202
|
+
].filter(Boolean);
|
|
203
|
+
const params = getParams$3({
|
|
204
|
+
paramsCasing,
|
|
205
|
+
pathParamsType,
|
|
206
|
+
dataReturnType,
|
|
207
|
+
typeSchemas,
|
|
208
|
+
mutationKeyTypeName
|
|
209
|
+
});
|
|
110
210
|
return /* @__PURE__ */ jsx(File.Source, {
|
|
111
211
|
name,
|
|
112
212
|
isExportable: true,
|
|
@@ -421,4 +521,4 @@ function Query({ name, typeSchemas, queryKeyName, queryKeyTypeName, queryOptions
|
|
|
421
521
|
|
|
422
522
|
//#endregion
|
|
423
523
|
export { MutationKey as a, Mutation as i, QueryOptions as n, QueryKey as r, Query as t };
|
|
424
|
-
//# sourceMappingURL=components-
|
|
524
|
+
//# sourceMappingURL=components-bS6nIkbY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components-bS6nIkbY.js","names":["getParams","getTransformer: Transformer","getTransformer","getParams","params","generics","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-fabric'\nimport type { KubbNode } from '@kubb/react-fabric/types'\nimport type { PluginSwr, Transformer } from '../types'\n\ntype Props = {\n name: string\n typeName: string\n typeSchemas: OperationSchemas\n operation: Operation\n paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n transformer: Transformer | undefined\n}\n\ntype GetParamsProps = {\n pathParamsType: PluginSwr['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, paramsCasing, pathParamsType, operation, typeName, transformer = getTransformer }: Props): KubbNode {\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, Type } from '@kubb/react-fabric'\nimport type { KubbNode, Params } from '@kubb/react-fabric/types'\nimport type { PluginSwr } 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 mutationKeyTypeName: string\n typeSchemas: OperationSchemas\n operation: Operation\n paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n paramsType: PluginSwr['resolvedOptions']['paramsType']\n dataReturnType: PluginSwr['resolvedOptions']['client']['dataReturnType']\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n /**\n * When true, mutation parameters are passed via trigger() instead of as hook arguments\n * @default false\n */\n paramsToTrigger?: boolean\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n dataReturnType: PluginSwr['resolvedOptions']['client']['dataReturnType']\n typeSchemas: OperationSchemas\n mutationKeyTypeName: string\n}\n\n// Original getParams - used when paramsToTrigger is false (default)\nfunction getParams({ pathParamsType, paramsCasing, dataReturnType, typeSchemas, mutationKeyTypeName }: 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 const TExtraArg = typeSchemas.request?.name || 'never'\n\n return FunctionParams.factory({\n pathParams: {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n },\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 mutation?: SWRMutationConfiguration<${TData}, ${TError}, ${mutationKeyTypeName} | null, ${TExtraArg}> & { throwOnError?: boolean },\n client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : 'Partial<RequestConfig> & { client?: typeof fetch }'},\n shouldFetch?: boolean,\n}\n`,\n default: '{}',\n },\n })\n}\n\ntype GetTriggerParamsProps = {\n dataReturnType: PluginSwr['resolvedOptions']['client']['dataReturnType']\n typeSchemas: OperationSchemas\n mutationKeyTypeName: string\n mutationArgTypeName: string\n}\n\n// New getParams - used when paramsToTrigger is true\nfunction getTriggerParams({ dataReturnType, typeSchemas, mutationKeyTypeName, mutationArgTypeName }: GetTriggerParamsProps) {\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 return FunctionParams.factory({\n options: {\n type: `\n{\n mutation?: SWRMutationConfiguration<${TData}, ${TError}, ${mutationKeyTypeName} | null, ${mutationArgTypeName}> & { throwOnError?: boolean },\n client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : 'Partial<RequestConfig> & { client?: typeof fetch }'},\n shouldFetch?: boolean,\n}\n`,\n default: '{}',\n },\n })\n}\n\ntype GetMutationParamsProps = {\n paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n typeSchemas: OperationSchemas\n}\n\nfunction getMutationParams({ paramsCasing, typeSchemas }: GetMutationParamsProps) {\n return 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\nexport function Mutation({\n name,\n clientName,\n mutationKeyName,\n mutationKeyTypeName,\n paramsType,\n paramsCasing,\n pathParamsType,\n dataReturnType,\n typeSchemas,\n operation,\n paramsToTrigger = false,\n}: Props): KubbNode {\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 mutationKeyParams = MutationKey.getParams({\n pathParamsType,\n typeSchemas,\n })\n\n const clientParams = Client.getParams({\n paramsCasing,\n paramsType,\n typeSchemas,\n pathParamsType,\n isConfigurable: true,\n })\n\n // Use the new trigger-based approach when paramsToTrigger is true\n if (paramsToTrigger) {\n // Build the mutation params type (for arg destructuring)\n const mutationParams = getMutationParams({\n paramsCasing,\n typeSchemas,\n })\n\n // Get the arg type name\n const mutationArgTypeName = `${mutationKeyTypeName.replace('MutationKey', '')}MutationArg`\n\n // Check if there are any mutation params (path, data, params, headers)\n const hasMutationParams = Object.keys(mutationParams.params).length > 0\n\n // Build the arg type for useSWRMutation\n const argParams = FunctionParams.factory({\n data: {\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 return acc\n }, {} as Params),\n },\n })\n\n const params = getTriggerParams({\n dataReturnType,\n typeSchemas,\n mutationKeyTypeName,\n mutationArgTypeName,\n })\n\n const generics = [TData, TError, `${mutationKeyTypeName} | null`, mutationArgTypeName].filter(Boolean)\n\n const mutationArg = mutationParams.toConstructor()\n\n return (\n <>\n <File.Source name={mutationArgTypeName} isExportable isIndexable isTypeOnly>\n <Type name={mutationArgTypeName} export>\n {hasMutationParams ? `{${mutationArg}}` : 'never'}\n </Type>\n </File.Source>\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 >\n {`\n const { mutation: mutationOptions, client: config = {}, shouldFetch = true } = options ?? {}\n const mutationKey = ${mutationKeyName}(${mutationKeyParams.toCall()})\n\n return useSWRMutation<${generics.join(', ')}>(\n shouldFetch ? mutationKey : null,\n async (_url${hasMutationParams ? `, { arg: ${argParams.toCall()} }` : ''}) => {\n return ${clientName}(${clientParams.toCall()})\n },\n mutationOptions\n )\n `}\n </Function>\n </File.Source>\n </>\n )\n }\n\n // Original behavior (default)\n const generics = [\n TData,\n TError,\n `${mutationKeyTypeName} | null`,\n typeSchemas.request?.name, // TExtraArg - the arg type for useSWRMutation\n ].filter(Boolean)\n\n const params = getParams({\n paramsCasing,\n pathParamsType,\n dataReturnType,\n typeSchemas,\n mutationKeyTypeName,\n })\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 >\n {`\n const { mutation: mutationOptions, client: config = {}, shouldFetch = true } = options ?? {}\n const mutationKey = ${mutationKeyName}(${mutationKeyParams.toCall()})\n\n return useSWRMutation<${generics.join(', ')}>(\n shouldFetch ? mutationKey : null,\n async (_url${typeSchemas.request?.name ? ', { arg: data }' : ''}) => {\n return ${clientName}(${clientParams.toCall()})\n },\n mutationOptions\n )\n `}\n </Function>\n </File.Source>\n )\n}\n","import { URLPath } from '@kubb/core/utils'\nimport { isOptional, type Operation } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams, Type } from '@kubb/react-fabric'\nimport type { KubbNode } from '@kubb/react-fabric/types'\nimport type { PluginSwr, Transformer } from '../types'\n\ntype Props = {\n name: string\n typeName: string\n typeSchemas: OperationSchemas\n operation: Operation\n paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n transformer: Transformer | undefined\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n pathParamsType: PluginSwr['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): KubbNode {\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 { isOptional } from '@kubb/oas'\nimport { Client } from '@kubb/plugin-client/components'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams } from '@kubb/react-fabric'\nimport type { KubbNode } from '@kubb/react-fabric/types'\nimport type { PluginSwr } from '../types.ts'\n\ntype Props = {\n name: string\n clientName: string\n typeSchemas: OperationSchemas\n paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n paramsType: PluginSwr['resolvedOptions']['paramsType']\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n}\n\ntype GetParamsProps = {\n paramsType: PluginSwr['resolvedOptions']['paramsType']\n paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n pathParamsType: PluginSwr['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, pathParamsType }: Props): KubbNode {\n const params = getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas })\n const clientParams = Client.getParams({\n paramsCasing,\n paramsType,\n typeSchemas,\n pathParamsType,\n isConfigurable: true,\n })\n\n return (\n <File.Source name={name} isExportable isIndexable>\n <Function name={name} export params={params.toConstructor()}>\n {`\n return {\n fetcher: async () => {\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-fabric'\nimport type { KubbNode } from '@kubb/react-fabric/types'\nimport type { PluginSwr } 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 paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n paramsType: PluginSwr['resolvedOptions']['paramsType']\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n dataReturnType: PluginSwr['resolvedOptions']['client']['dataReturnType']\n operation: Operation\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n paramsType: PluginSwr['resolvedOptions']['paramsType']\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n dataReturnType: PluginSwr['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?: Parameters<typeof useSWR<${[TData, TError].join(', ')}>>[2],\n client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : 'Partial<RequestConfig> & { client?: typeof fetch }'},\n shouldFetch?: boolean,\n immutable?: boolean\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?: Parameters<typeof useSWR<${[TData, TError].join(', ')}>>[2],\n client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : 'Partial<RequestConfig> & { client?: typeof fetch }'},\n shouldFetch?: boolean,\n immutable?: boolean\n}\n`,\n default: '{}',\n },\n })\n}\n\nexport function Query({\n name,\n typeSchemas,\n queryKeyName,\n queryKeyTypeName,\n queryOptionsName,\n operation,\n dataReturnType,\n paramsType,\n paramsCasing,\n pathParamsType,\n}: Props): KubbNode {\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, `${queryKeyTypeName} | null`]\n\n const queryKeyParams = QueryKey.getParams({\n pathParamsType,\n typeSchemas,\n paramsCasing,\n })\n const params = getParams({\n paramsCasing,\n paramsType,\n pathParamsType,\n dataReturnType,\n typeSchemas,\n })\n\n const queryOptionsParams = QueryOptions.getParams({\n paramsCasing,\n paramsType,\n pathParamsType,\n typeSchemas,\n })\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 >\n {`\n const { query: queryOptions, client: config = {}, shouldFetch = true, immutable } = options ?? {}\n\n const queryKey = ${queryKeyName}(${queryKeyParams.toCall()})\n\n return useSWR<${generics.join(', ')}>(\n shouldFetch ? queryKey : null,\n {\n ...${queryOptionsName}(${queryOptionsParams.toCall()}),\n ...(immutable ? {\n revalidateIfStale: false,\n revalidateOnFocus: false,\n revalidateOnReconnect: false\n } : { }),\n ...queryOptions\n }\n )\n `}\n </Function>\n </File.Source>\n )\n}\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,cAAc,gBAAgB,WAAW,UAAU,cAAcC,oBAAmC;CACnJ,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,OAAO,eAAe;GAAE;aAChE,IAAI,KAAK,KAAK,KAAK,CAAC;IAC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AAC,KAAK;EAAa;EAAM;EAAa;YACpC,oBAAC;GACO;GACN;GACA,QAAQ,OAAO,eAAe;GAC9B,OAAO,EACL,UAAU,YAAY,UAAU,EACjC;aAEA;;;0BAGiB,aAAa,GAAG,eAAe,QAAQ,CAAC;;uBAE3C,SAAS,KAAK,KAAK,CAAC;;;eAG5B,iBAAiB,GAAG,mBAAmB,QAAQ,CAAC;;;;;;;;;;IAU9C;GACC"}
|
package/dist/components.cjs
CHANGED
package/dist/components.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as OperationSchemas, n as PluginSwr, r as Transformer, s as Operation } from "./types-
|
|
1
|
+
import { a as OperationSchemas, n as PluginSwr, r as Transformer, s as Operation } from "./types-DV16H9Nj.cjs";
|
|
2
2
|
import { FunctionParams } from "@kubb/react-fabric";
|
|
3
3
|
import { KubbNode } from "@kubb/react-fabric/types";
|
|
4
4
|
|
|
@@ -18,6 +18,11 @@ type Props$4 = {
|
|
|
18
18
|
paramsType: PluginSwr['resolvedOptions']['paramsType'];
|
|
19
19
|
dataReturnType: PluginSwr['resolvedOptions']['client']['dataReturnType'];
|
|
20
20
|
pathParamsType: PluginSwr['resolvedOptions']['pathParamsType'];
|
|
21
|
+
/**
|
|
22
|
+
* When true, mutation parameters are passed via trigger() instead of as hook arguments
|
|
23
|
+
* @default false
|
|
24
|
+
*/
|
|
25
|
+
paramsToTrigger?: boolean;
|
|
21
26
|
};
|
|
22
27
|
declare function Mutation({
|
|
23
28
|
name,
|
|
@@ -29,7 +34,8 @@ declare function Mutation({
|
|
|
29
34
|
pathParamsType,
|
|
30
35
|
dataReturnType,
|
|
31
36
|
typeSchemas,
|
|
32
|
-
operation
|
|
37
|
+
operation,
|
|
38
|
+
paramsToTrigger
|
|
33
39
|
}: Props$4): KubbNode;
|
|
34
40
|
//#endregion
|
|
35
41
|
//#region src/components/MutationKey.d.ts
|
package/dist/components.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as OperationSchemas, n as PluginSwr, r as Transformer, s as Operation } from "./types-
|
|
1
|
+
import { a as OperationSchemas, n as PluginSwr, r as Transformer, s as Operation } from "./types-BhMJy6gt.js";
|
|
2
2
|
import { FunctionParams } from "@kubb/react-fabric";
|
|
3
3
|
import { KubbNode } from "@kubb/react-fabric/types";
|
|
4
4
|
|
|
@@ -18,6 +18,11 @@ type Props$4 = {
|
|
|
18
18
|
paramsType: PluginSwr['resolvedOptions']['paramsType'];
|
|
19
19
|
dataReturnType: PluginSwr['resolvedOptions']['client']['dataReturnType'];
|
|
20
20
|
pathParamsType: PluginSwr['resolvedOptions']['pathParamsType'];
|
|
21
|
+
/**
|
|
22
|
+
* When true, mutation parameters are passed via trigger() instead of as hook arguments
|
|
23
|
+
* @default false
|
|
24
|
+
*/
|
|
25
|
+
paramsToTrigger?: boolean;
|
|
21
26
|
};
|
|
22
27
|
declare function Mutation({
|
|
23
28
|
name,
|
|
@@ -29,7 +34,8 @@ declare function Mutation({
|
|
|
29
34
|
pathParamsType,
|
|
30
35
|
dataReturnType,
|
|
31
36
|
typeSchemas,
|
|
32
|
-
operation
|
|
37
|
+
operation,
|
|
38
|
+
paramsToTrigger
|
|
33
39
|
}: Props$4): KubbNode;
|
|
34
40
|
//#endregion
|
|
35
41
|
//#region src/components/MutationKey.d.ts
|
package/dist/components.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as MutationKey, i as Mutation, n as QueryOptions, r as QueryKey, t as Query } from "./components-
|
|
1
|
+
import { a as MutationKey, i as Mutation, n as QueryOptions, r as QueryKey, t as Query } from "./components-bS6nIkbY.js";
|
|
2
2
|
|
|
3
3
|
export { Mutation, MutationKey, Query, QueryKey, QueryOptions };
|
|
@@ -25,7 +25,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
25
|
}) : target, mod));
|
|
26
26
|
|
|
27
27
|
//#endregion
|
|
28
|
-
const require_components = require('./components-
|
|
28
|
+
const require_components = require('./components-CWmdrh07.cjs');
|
|
29
29
|
let node_path = require("node:path");
|
|
30
30
|
node_path = __toESM(node_path);
|
|
31
31
|
let __kubb_plugin_client = require("@kubb/plugin-client");
|
|
@@ -208,7 +208,8 @@ const mutationGenerator = (0, __kubb_plugin_oas_generators.createReactGenerator)
|
|
|
208
208
|
paramsCasing: options.paramsCasing,
|
|
209
209
|
pathParamsType: options.pathParamsType,
|
|
210
210
|
mutationKeyName: mutationKey.name,
|
|
211
|
-
mutationKeyTypeName: mutationKey.typeName
|
|
211
|
+
mutationKeyTypeName: mutationKey.typeName,
|
|
212
|
+
paramsToTrigger: options.mutation.paramsToTrigger
|
|
212
213
|
})
|
|
213
214
|
]
|
|
214
215
|
});
|
|
@@ -424,4 +425,4 @@ Object.defineProperty(exports, 'queryGenerator', {
|
|
|
424
425
|
return queryGenerator;
|
|
425
426
|
}
|
|
426
427
|
});
|
|
427
|
-
//# sourceMappingURL=generators-
|
|
428
|
+
//# sourceMappingURL=generators-CVb2gh4h.cjs.map
|