@kubb/plugin-swr 5.0.0-beta.84 → 5.0.0-beta.86
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/index.cjs +92 -122
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +75 -46
- package/dist/index.js +92 -122
- package/dist/index.js.map +1 -1
- package/package.json +5 -6
package/dist/index.cjs
CHANGED
|
@@ -28,10 +28,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
enumerable: true
|
|
29
29
|
}) : target, mod));
|
|
30
30
|
//#endregion
|
|
31
|
-
let node_path = require("node:path");
|
|
32
|
-
node_path = __toESM(node_path, 1);
|
|
33
31
|
let kubb_kit = require("kubb/kit");
|
|
34
32
|
let _kubb_plugin_ts = require("@kubb/plugin-ts");
|
|
33
|
+
let node_path = require("node:path");
|
|
34
|
+
node_path = __toESM(node_path, 1);
|
|
35
35
|
let kubb_jsx = require("kubb/jsx");
|
|
36
36
|
let kubb_jsx_jsx_runtime = require("kubb/jsx/jsx-runtime");
|
|
37
37
|
//#region ../../internals/utils/src/casing.ts
|
|
@@ -61,31 +61,6 @@ function camelCase(text, { prefix = "", suffix = "" } = {}) {
|
|
|
61
61
|
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
|
|
62
62
|
}
|
|
63
63
|
//#endregion
|
|
64
|
-
//#region ../../internals/utils/src/fs.ts
|
|
65
|
-
/**
|
|
66
|
-
* Builds a nested file path from a dotted name. Splits on dots that precede a letter
|
|
67
|
-
* (so version numbers embedded in operationIds like `v2025.0` stay intact), camelCases
|
|
68
|
-
* every earlier segment, applies `caseLast` to the final segment, and joins with `/`.
|
|
69
|
-
*
|
|
70
|
-
* Empty segments are dropped before joining. They arise when the name starts with a dot
|
|
71
|
-
* followed by a letter (e.g. `..Schema` splits into `['..', 'Schema']` and `'..'` cases to
|
|
72
|
-
* an empty string). Without this a leading `/` would form, which `path.resolve` reads as an
|
|
73
|
-
* absolute path, letting generated files escape the configured output directory.
|
|
74
|
-
*
|
|
75
|
-
* @example Nested path from a dotted name
|
|
76
|
-
* `toFilePath('pet.petId') // 'pet/petId'`
|
|
77
|
-
*
|
|
78
|
-
* @example PascalCase the final segment
|
|
79
|
-
* `toFilePath('pet.Pet', pascalCase) // 'pet/Pet'`
|
|
80
|
-
*
|
|
81
|
-
* @example Suffix applied to the final segment only
|
|
82
|
-
* `toFilePath('tag.tag', (part) => camelCase(part, { suffix: 'schema' })) // 'tag/tagSchema'`
|
|
83
|
-
*/
|
|
84
|
-
function toFilePath(name, caseLast = camelCase) {
|
|
85
|
-
const parts = name.split(/\.(?=[a-zA-Z])/);
|
|
86
|
-
return parts.map((part, i) => i === parts.length - 1 ? caseLast(part) : camelCase(part)).filter(Boolean).join("/");
|
|
87
|
-
}
|
|
88
|
-
//#endregion
|
|
89
64
|
//#region ../../internals/utils/src/reserved.ts
|
|
90
65
|
/**
|
|
91
66
|
* JavaScript and Java reserved words.
|
|
@@ -341,13 +316,13 @@ function dedupeByCasedName(params) {
|
|
|
341
316
|
//#region ../../internals/shared/src/operation.ts
|
|
342
317
|
/**
|
|
343
318
|
* Builds the `ResolverFileParams` every operation generator passes to
|
|
344
|
-
* `resolver.
|
|
319
|
+
* `resolver.file`: a file named `name`, tagged by the operation's first
|
|
345
320
|
* tag (or `'default'`), at the operation's path. Centralizes the entry object
|
|
346
321
|
* that was repeated at dozens of call sites across the client and query plugins.
|
|
347
322
|
*
|
|
348
323
|
* @example
|
|
349
324
|
* ```ts
|
|
350
|
-
* resolver.
|
|
325
|
+
* resolver.file(operationFileEntry(node, node.operationId), { root, output, group })
|
|
351
326
|
* ```
|
|
352
327
|
*/
|
|
353
328
|
function operationFileEntry(node, name, extname = ".ts") {
|
|
@@ -485,10 +460,10 @@ function getPrimarySuccessResponse(node) {
|
|
|
485
460
|
return getOperationSuccessResponses(node)[0] ?? null;
|
|
486
461
|
}
|
|
487
462
|
function resolveErrorNames(node, resolver) {
|
|
488
|
-
return node.responses.filter((response) => isErrorStatusCode(response.statusCode)).map((response) => resolver.
|
|
463
|
+
return node.responses.filter((response) => isErrorStatusCode(response.statusCode)).map((response) => resolver.response.status(node, response.statusCode));
|
|
489
464
|
}
|
|
490
465
|
function resolveStatusCodeNames(node, resolver) {
|
|
491
|
-
return node.responses.map((response) => resolver.
|
|
466
|
+
return node.responses.map((response) => resolver.response.status(node, response.statusCode));
|
|
492
467
|
}
|
|
493
468
|
const typeNamesByResolver = /* @__PURE__ */ new WeakMap();
|
|
494
469
|
function resolveOperationTypeNames(node, resolver, options = {}) {
|
|
@@ -505,11 +480,11 @@ function resolveOperationTypeNames(node, resolver, options = {}) {
|
|
|
505
480
|
const responseStatusNames = options.responseStatusNames === "error" ? resolveErrorNames(node, resolver) : options.responseStatusNames === false ? [] : resolveStatusCodeNames(node, resolver);
|
|
506
481
|
const exclude = new Set(options.exclude ?? []);
|
|
507
482
|
const paramNames = options.includeParams === false ? [] : [
|
|
508
|
-
...path.map((param) => resolver.
|
|
509
|
-
...query.map((param) => resolver.
|
|
510
|
-
...header.map((param) => resolver.
|
|
483
|
+
...path.map((param) => resolver.param.path(node, param)),
|
|
484
|
+
...query.map((param) => resolver.param.query(node, param)),
|
|
485
|
+
...header.map((param) => resolver.param.headers(node, param))
|
|
511
486
|
];
|
|
512
|
-
const bodyAndResponseNames = [node.requestBody?.content?.[0]?.schema ? resolver.
|
|
487
|
+
const bodyAndResponseNames = [node.requestBody?.content?.[0]?.schema ? resolver.response.body(node) : null, resolver.response.response(node)];
|
|
513
488
|
const result = (options.order === "body-response-first" ? [
|
|
514
489
|
...bodyAndResponseNames,
|
|
515
490
|
...paramNames,
|
|
@@ -633,15 +608,15 @@ function resolveClientOperation(options) {
|
|
|
633
608
|
const { clientPlugin, driver, node, root, output } = options;
|
|
634
609
|
if (!clientPlugin) return null;
|
|
635
610
|
const resolver = driver.getResolver(clientPlugin.pluginName);
|
|
636
|
-
if (!resolver) return null;
|
|
637
611
|
const plugin = driver.getPlugin(clientPlugin.pluginName);
|
|
638
|
-
const file = resolver.
|
|
612
|
+
const file = resolver.file({
|
|
613
|
+
...operationFileEntry(node, node.operationId),
|
|
639
614
|
root,
|
|
640
615
|
output: plugin?.options?.output ?? output,
|
|
641
616
|
group: plugin?.options?.group ?? void 0
|
|
642
617
|
});
|
|
643
618
|
return {
|
|
644
|
-
name: resolver.
|
|
619
|
+
name: resolver.name(node.operationId),
|
|
645
620
|
path: file.path,
|
|
646
621
|
clientPath: node_path.default.resolve(root, ".kubb/client.ts")
|
|
647
622
|
};
|
|
@@ -689,12 +664,12 @@ const requestGroupOrder = [
|
|
|
689
664
|
/**
|
|
690
665
|
* Builds the grouped `{ path, query, body, headers }` parameter that mirrors the client
|
|
691
666
|
* function signature. Only the groups the operation carries are emitted, typed from the
|
|
692
|
-
* operation's `
|
|
667
|
+
* operation's `Options`. `keys` narrows the emitted groups, used by the query key which
|
|
693
668
|
* never carries `headers`.
|
|
694
669
|
*
|
|
695
|
-
* By default the whole group is typed as the single `
|
|
670
|
+
* By default the whole group is typed as the single `Options` reference. When
|
|
696
671
|
* `memberTypeWrapper` is set, each group is emitted as its own member typed from the matching
|
|
697
|
-
* `
|
|
672
|
+
* `Options['<group>']` slice and wrapped, used by vue-query to apply
|
|
698
673
|
* `MaybeRefOrGetter` per group.
|
|
699
674
|
*/
|
|
700
675
|
function buildGroupedRequestParam(node, options) {
|
|
@@ -709,13 +684,13 @@ function buildGroupedRequestParam(node, options) {
|
|
|
709
684
|
headers: hasRequiredHeader
|
|
710
685
|
};
|
|
711
686
|
const isOptional = names.every((name) => !requiredByGroup[name]);
|
|
712
|
-
const
|
|
687
|
+
const optionsName = resolver.response.options(node);
|
|
713
688
|
const omittedKeys = requestGroupOrder.filter((key) => !keys.includes(key));
|
|
714
|
-
const
|
|
689
|
+
const optionsType = omittedKeys.length > 0 ? `Omit<${optionsName}, ${omittedKeys.map((key) => `'${key}'`).join(" | ")}>` : optionsName;
|
|
715
690
|
if (memberTypeWrapper) {
|
|
716
691
|
const members = names.map((name) => ({
|
|
717
692
|
name,
|
|
718
|
-
type: memberTypeWrapper(`${
|
|
693
|
+
type: memberTypeWrapper(`${optionsType}['${name}']`),
|
|
719
694
|
optional: !requiredByGroup[name]
|
|
720
695
|
}));
|
|
721
696
|
return (0, _kubb_plugin_ts.createFunctionParameter)({
|
|
@@ -727,7 +702,7 @@ function buildGroupedRequestParam(node, options) {
|
|
|
727
702
|
}
|
|
728
703
|
return (0, _kubb_plugin_ts.createFunctionParameter)({
|
|
729
704
|
name: (0, _kubb_plugin_ts.createObjectBindingPattern)({ elements: names.map((name) => ({ name })) }),
|
|
730
|
-
type:
|
|
705
|
+
type: optionsType,
|
|
731
706
|
optional: false,
|
|
732
707
|
...isOptional ? { default: "{}" } : {}
|
|
733
708
|
});
|
|
@@ -773,7 +748,7 @@ function buildClientCall(node, options) {
|
|
|
773
748
|
}
|
|
774
749
|
/**
|
|
775
750
|
* Build QueryKey params as the grouped `{ path, query, body }` object (NO headers, NO config),
|
|
776
|
-
* typed from the operation's `
|
|
751
|
+
* typed from the operation's `Options` minus `url`. The query key transformer reads the
|
|
777
752
|
* grouped `path`/`query`/`body` bindings.
|
|
778
753
|
*/
|
|
779
754
|
function buildQueryKeyParams(node, options) {
|
|
@@ -835,7 +810,7 @@ const declarationPrinter$2 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "decla
|
|
|
835
810
|
const callPrinter$1 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "call" });
|
|
836
811
|
function buildMutationParamsNode(node, options) {
|
|
837
812
|
const { mutationKeyTypeName, mutationArgTypeName, resolver } = options;
|
|
838
|
-
const responseName = resolver.
|
|
813
|
+
const responseName = resolver.response.response(node);
|
|
839
814
|
const errorNames = resolveErrorNames(node, resolver);
|
|
840
815
|
return (0, _kubb_plugin_ts.createFunctionParameters)({ params: [(0, _kubb_plugin_ts.createFunctionParameter)({
|
|
841
816
|
name: "options",
|
|
@@ -848,14 +823,14 @@ function buildMutationParamsNode(node, options) {
|
|
|
848
823
|
})] });
|
|
849
824
|
}
|
|
850
825
|
function Mutation({ name, clientName, mutationKeyName, mutationKeyTypeName, mutationArgTypeName, node, tsResolver }) {
|
|
851
|
-
const responseName = tsResolver.
|
|
826
|
+
const responseName = tsResolver.response.response(node);
|
|
852
827
|
const errorNames = resolveErrorNames(node, tsResolver);
|
|
853
828
|
const TData = responseName;
|
|
854
829
|
const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
|
|
855
830
|
const groupedParam = buildGroupedRequestParam(node, { resolver: tsResolver });
|
|
856
831
|
const hasMutationParams = groupedParam !== null;
|
|
857
832
|
const groupedParamsNode = (0, _kubb_plugin_ts.createFunctionParameters)({ params: groupedParam ? [groupedParam] : [] });
|
|
858
|
-
const argTypeBody = hasMutationParams ? tsResolver.
|
|
833
|
+
const argTypeBody = hasMutationParams ? tsResolver.response.options(node) : "";
|
|
859
834
|
const argBindingStr = hasMutationParams ? callPrinter$1.print(groupedParamsNode) ?? "" : "";
|
|
860
835
|
const mutationFnBody = `const { data } = await ${buildClientCall(node, {
|
|
861
836
|
clientName,
|
|
@@ -965,7 +940,7 @@ const declarationPrinter = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declara
|
|
|
965
940
|
const callPrinter = (0, _kubb_plugin_ts.functionPrinter)({ mode: "call" });
|
|
966
941
|
function buildQueryParamsNode(node, options) {
|
|
967
942
|
const { resolver } = options;
|
|
968
|
-
const responseName = resolver.
|
|
943
|
+
const responseName = resolver.response.response(node);
|
|
969
944
|
const errorNames = resolveErrorNames(node, resolver);
|
|
970
945
|
const optionsParam = (0, _kubb_plugin_ts.createFunctionParameter)({
|
|
971
946
|
name: "options",
|
|
@@ -980,7 +955,7 @@ function buildQueryParamsNode(node, options) {
|
|
|
980
955
|
return (0, _kubb_plugin_ts.createFunctionParameters)({ params: [buildGroupedRequestParam(node, { resolver }), optionsParam].filter((param) => param !== null) });
|
|
981
956
|
}
|
|
982
957
|
function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, node, tsResolver }) {
|
|
983
|
-
const responseName = tsResolver.
|
|
958
|
+
const responseName = tsResolver.response.response(node);
|
|
984
959
|
const errorNames = resolveErrorNames(node, tsResolver);
|
|
985
960
|
const generics = [
|
|
986
961
|
responseName,
|
|
@@ -1052,33 +1027,31 @@ const mutationGenerator = (0, kubb_kit.defineGenerator)({
|
|
|
1052
1027
|
output
|
|
1053
1028
|
});
|
|
1054
1029
|
if (!contractOp) return null;
|
|
1055
|
-
const mutationHookName = resolver.
|
|
1056
|
-
const mutationKeyName = resolver.
|
|
1057
|
-
const mutationKeyTypeName = resolver.
|
|
1058
|
-
const mutationArgTypeName = resolver.
|
|
1030
|
+
const mutationHookName = resolver.mutation.name(node);
|
|
1031
|
+
const mutationKeyName = resolver.mutation.keyName(node);
|
|
1032
|
+
const mutationKeyTypeName = resolver.mutation.keyTypeName(node);
|
|
1033
|
+
const mutationArgTypeName = resolver.mutation.argTypeName(node);
|
|
1059
1034
|
const meta = {
|
|
1060
|
-
file: resolver.
|
|
1035
|
+
file: resolver.file({
|
|
1061
1036
|
name: mutationHookName,
|
|
1062
1037
|
extname: ".ts",
|
|
1063
1038
|
tag: node.tags[0] ?? "default",
|
|
1064
|
-
path: node.path
|
|
1065
|
-
}, {
|
|
1039
|
+
path: node.path,
|
|
1066
1040
|
root,
|
|
1067
1041
|
output,
|
|
1068
1042
|
group
|
|
1069
1043
|
}),
|
|
1070
|
-
fileTs: tsResolver.
|
|
1044
|
+
fileTs: tsResolver.file({
|
|
1071
1045
|
name: node.operationId,
|
|
1072
1046
|
extname: ".ts",
|
|
1073
1047
|
tag: node.tags[0] ?? "default",
|
|
1074
|
-
path: node.path
|
|
1075
|
-
}, {
|
|
1048
|
+
path: node.path,
|
|
1076
1049
|
root,
|
|
1077
1050
|
output: pluginTs.options?.output ?? output,
|
|
1078
1051
|
group: pluginTs.options?.group
|
|
1079
1052
|
})
|
|
1080
1053
|
};
|
|
1081
|
-
const importedTypeNames = [tsResolver.
|
|
1054
|
+
const importedTypeNames = [tsResolver.response.options(node), ...resolveOperationTypeNames(node, tsResolver, {
|
|
1082
1055
|
order: "body-response-first",
|
|
1083
1056
|
includeParams: false
|
|
1084
1057
|
})].filter((name) => Boolean(name));
|
|
@@ -1087,7 +1060,7 @@ const mutationGenerator = (0, kubb_kit.defineGenerator)({
|
|
|
1087
1060
|
baseName: meta.file.baseName,
|
|
1088
1061
|
path: meta.file.path,
|
|
1089
1062
|
meta: meta.file.meta,
|
|
1090
|
-
banner: resolver.
|
|
1063
|
+
banner: resolver.default.banner(ctx.meta, {
|
|
1091
1064
|
output,
|
|
1092
1065
|
config,
|
|
1093
1066
|
file: {
|
|
@@ -1095,7 +1068,7 @@ const mutationGenerator = (0, kubb_kit.defineGenerator)({
|
|
|
1095
1068
|
baseName: meta.file.baseName
|
|
1096
1069
|
}
|
|
1097
1070
|
}),
|
|
1098
|
-
footer: resolver.
|
|
1071
|
+
footer: resolver.default.footer(ctx.meta, {
|
|
1099
1072
|
output,
|
|
1100
1073
|
config,
|
|
1101
1074
|
file: {
|
|
@@ -1180,33 +1153,31 @@ const queryGenerator = (0, kubb_kit.defineGenerator)({
|
|
|
1180
1153
|
output
|
|
1181
1154
|
});
|
|
1182
1155
|
if (!contractOp) return null;
|
|
1183
|
-
const queryName = resolver.
|
|
1184
|
-
const queryOptionsName = resolver.
|
|
1185
|
-
const queryKeyName = resolver.
|
|
1186
|
-
const queryKeyTypeName = resolver.
|
|
1156
|
+
const queryName = resolver.query.name(node);
|
|
1157
|
+
const queryOptionsName = resolver.query.optionsName(node);
|
|
1158
|
+
const queryKeyName = resolver.query.keyName(node);
|
|
1159
|
+
const queryKeyTypeName = resolver.query.keyTypeName(node);
|
|
1187
1160
|
const meta = {
|
|
1188
|
-
file: resolver.
|
|
1161
|
+
file: resolver.file({
|
|
1189
1162
|
name: queryName,
|
|
1190
1163
|
extname: ".ts",
|
|
1191
1164
|
tag: node.tags[0] ?? "default",
|
|
1192
|
-
path: node.path
|
|
1193
|
-
}, {
|
|
1165
|
+
path: node.path,
|
|
1194
1166
|
root,
|
|
1195
1167
|
output,
|
|
1196
1168
|
group
|
|
1197
1169
|
}),
|
|
1198
|
-
fileTs: tsResolver.
|
|
1170
|
+
fileTs: tsResolver.file({
|
|
1199
1171
|
name: node.operationId,
|
|
1200
1172
|
extname: ".ts",
|
|
1201
1173
|
tag: node.tags[0] ?? "default",
|
|
1202
|
-
path: node.path
|
|
1203
|
-
}, {
|
|
1174
|
+
path: node.path,
|
|
1204
1175
|
root,
|
|
1205
1176
|
output: pluginTs.options?.output ?? output,
|
|
1206
1177
|
group: pluginTs.options?.group
|
|
1207
1178
|
})
|
|
1208
1179
|
};
|
|
1209
|
-
const importedTypeNames = [tsResolver.
|
|
1180
|
+
const importedTypeNames = [tsResolver.response.options(node), ...resolveOperationTypeNames(node, tsResolver, {
|
|
1210
1181
|
exclude: [queryKeyTypeName],
|
|
1211
1182
|
order: "body-response-first",
|
|
1212
1183
|
includeParams: false
|
|
@@ -1216,7 +1187,7 @@ const queryGenerator = (0, kubb_kit.defineGenerator)({
|
|
|
1216
1187
|
baseName: meta.file.baseName,
|
|
1217
1188
|
path: meta.file.path,
|
|
1218
1189
|
meta: meta.file.meta,
|
|
1219
|
-
banner: resolver.
|
|
1190
|
+
banner: resolver.default.banner(ctx.meta, {
|
|
1220
1191
|
output,
|
|
1221
1192
|
config,
|
|
1222
1193
|
file: {
|
|
@@ -1224,7 +1195,7 @@ const queryGenerator = (0, kubb_kit.defineGenerator)({
|
|
|
1224
1195
|
baseName: meta.file.baseName
|
|
1225
1196
|
}
|
|
1226
1197
|
}),
|
|
1227
|
-
footer: resolver.
|
|
1198
|
+
footer: resolver.default.footer(ctx.meta, {
|
|
1228
1199
|
output,
|
|
1229
1200
|
config,
|
|
1230
1201
|
file: {
|
|
@@ -1292,53 +1263,55 @@ function capitalize(name) {
|
|
|
1292
1263
|
return `${name.charAt(0).toUpperCase()}${name.slice(1)}`;
|
|
1293
1264
|
}
|
|
1294
1265
|
/**
|
|
1295
|
-
*
|
|
1266
|
+
* Default resolver used by `@kubb/plugin-swr`. Decides the names and file paths for every generated
|
|
1267
|
+
* SWR hook (`useFoo`, `useFooMutation`) and its companion helpers (`fooQueryKey`, `fooQueryOptions`,
|
|
1268
|
+
* `fooMutationKey`).
|
|
1296
1269
|
*
|
|
1297
|
-
*
|
|
1270
|
+
* Functions and files use the built-in camelCase casing; hooks get the `use` prefix.
|
|
1298
1271
|
*
|
|
1299
|
-
* @example
|
|
1300
|
-
*
|
|
1272
|
+
* @example Resolve hook and helper names
|
|
1273
|
+
* ```ts
|
|
1274
|
+
* import { resolverSwr } from '@kubb/plugin-swr'
|
|
1275
|
+
*
|
|
1276
|
+
* resolverSwr.query.name(operationNode) // 'useGetPetById'
|
|
1277
|
+
* resolverSwr.query.keyName(operationNode) // 'getPetByIdQueryKey'
|
|
1278
|
+
* resolverSwr.mutation.name(operationNode) // 'useUpdatePet'
|
|
1279
|
+
* ```
|
|
1301
1280
|
*/
|
|
1302
|
-
const resolverSwr = (0, kubb_kit.
|
|
1303
|
-
name: "default",
|
|
1281
|
+
const resolverSwr = (0, kubb_kit.createResolver)({
|
|
1304
1282
|
pluginName: "plugin-swr",
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
return `${this.resolveName(node.operationId)}QueryOptions`;
|
|
1322
|
-
},
|
|
1323
|
-
resolveQueryKeyName(node) {
|
|
1324
|
-
return `${this.resolveName(node.operationId)}QueryKey`;
|
|
1325
|
-
},
|
|
1326
|
-
resolveMutationKeyName(node) {
|
|
1327
|
-
return `${this.resolveName(node.operationId)}MutationKey`;
|
|
1328
|
-
},
|
|
1329
|
-
resolveQueryKeyTypeName(node) {
|
|
1330
|
-
return `${capitalize(this.resolveName(node.operationId))}QueryKey`;
|
|
1331
|
-
},
|
|
1332
|
-
resolveMutationKeyTypeName(node) {
|
|
1333
|
-
return `${capitalize(this.resolveName(node.operationId))}MutationKey`;
|
|
1334
|
-
},
|
|
1335
|
-
resolveMutationArgTypeName(node) {
|
|
1336
|
-
return `${capitalize(this.resolveName(node.operationId))}MutationArg`;
|
|
1283
|
+
query: {
|
|
1284
|
+
name(node) {
|
|
1285
|
+
return `use${capitalize(this.name(node.operationId))}`;
|
|
1286
|
+
},
|
|
1287
|
+
optionsName(node) {
|
|
1288
|
+
return `${this.name(node.operationId)}QueryOptions`;
|
|
1289
|
+
},
|
|
1290
|
+
keyName(node) {
|
|
1291
|
+
return `${this.name(node.operationId)}QueryKey`;
|
|
1292
|
+
},
|
|
1293
|
+
keyTypeName(node) {
|
|
1294
|
+
return `${capitalize(this.name(node.operationId))}QueryKey`;
|
|
1295
|
+
},
|
|
1296
|
+
clientName(node) {
|
|
1297
|
+
return this.name(node.operationId);
|
|
1298
|
+
}
|
|
1337
1299
|
},
|
|
1338
|
-
|
|
1339
|
-
|
|
1300
|
+
mutation: {
|
|
1301
|
+
name(node) {
|
|
1302
|
+
return `use${capitalize(this.name(node.operationId))}`;
|
|
1303
|
+
},
|
|
1304
|
+
keyName(node) {
|
|
1305
|
+
return `${this.name(node.operationId)}MutationKey`;
|
|
1306
|
+
},
|
|
1307
|
+
keyTypeName(node) {
|
|
1308
|
+
return `${capitalize(this.name(node.operationId))}MutationKey`;
|
|
1309
|
+
},
|
|
1310
|
+
argTypeName(node) {
|
|
1311
|
+
return `${capitalize(this.name(node.operationId))}MutationArg`;
|
|
1312
|
+
}
|
|
1340
1313
|
}
|
|
1341
|
-
})
|
|
1314
|
+
});
|
|
1342
1315
|
//#endregion
|
|
1343
1316
|
//#region src/plugin.ts
|
|
1344
1317
|
/**
|
|
@@ -1379,10 +1352,7 @@ const pluginSwr = (0, kubb_kit.definePlugin)((options) => {
|
|
|
1379
1352
|
options,
|
|
1380
1353
|
dependencies: [_kubb_plugin_ts.pluginTsName],
|
|
1381
1354
|
hooks: { "kubb:plugin:setup"(ctx) {
|
|
1382
|
-
const resolver = userResolver ?
|
|
1383
|
-
...resolverSwr,
|
|
1384
|
-
...userResolver
|
|
1385
|
-
} : resolverSwr;
|
|
1355
|
+
const resolver = userResolver ? kubb_kit.Resolver.merge(resolverSwr, userResolver) : resolverSwr;
|
|
1386
1356
|
const resolvedClient = resolveClient({
|
|
1387
1357
|
client,
|
|
1388
1358
|
pluginNames: (ctx.config.plugins ?? []).map((p) => p.name).filter((name) => Boolean(name))
|