@kubb/plugin-react-query 3.0.0-alpha.0
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/LICENSE +21 -0
- package/README.md +114 -0
- package/dist/chunk-5IL6M74X.js +1504 -0
- package/dist/chunk-5IL6M74X.js.map +1 -0
- package/dist/chunk-JFX7DCS7.cjs +1504 -0
- package/dist/chunk-JFX7DCS7.cjs.map +1 -0
- package/dist/components.cjs +15 -0
- package/dist/components.cjs.map +1 -0
- package/dist/components.d.cts +8 -0
- package/dist/components.d.ts +8 -0
- package/dist/components.js +15 -0
- package/dist/components.js.map +1 -0
- package/dist/index-yXskx3Td.d.cts +584 -0
- package/dist/index-yXskx3Td.d.ts +584 -0
- package/dist/index.cjs +223 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +13 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +223 -0
- package/dist/index.js.map +1 -0
- package/package.json +97 -0
- package/src/OperationGenerator.tsx +86 -0
- package/src/__snapshots__/mutateAsQuery/updatePetWithForm.ts +64 -0
- package/src/__snapshots__/pathParamsTypeInline/getPetById.ts +57 -0
- package/src/__snapshots__/pathParamsTypeObject/getPetById.ts +63 -0
- package/src/__snapshots__/queryOptions/getPetById.ts +37 -0
- package/src/__snapshots__/queryWithoutQueryOptions/getPetById.ts +47 -0
- package/src/__snapshots__/upload/UploadFile.ts +67 -0
- package/src/__snapshots__/uploadMutation/UploadFile.ts +44 -0
- package/src/__snapshots__/variablesTypeMutate/deletePet.ts +21 -0
- package/src/components/Mutation.tsx +341 -0
- package/src/components/Operations.tsx +74 -0
- package/src/components/Query.tsx +627 -0
- package/src/components/QueryImports.tsx +167 -0
- package/src/components/QueryKey.tsx +200 -0
- package/src/components/QueryOptions.tsx +487 -0
- package/src/components/SchemaType.tsx +55 -0
- package/src/components/__snapshots__/gen/showPetById.ts +57 -0
- package/src/components/__snapshots__/gen/useCreatePets.ts +46 -0
- package/src/components/__snapshots__/gen/useCreatePetsMutate.ts +47 -0
- package/src/components/index.ts +5 -0
- package/src/index.ts +2 -0
- package/src/plugin.ts +183 -0
- package/src/types.ts +240 -0
- package/src/utils.ts +96 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
var _chunkJFX7DCS7cjs = require('./chunk-JFX7DCS7.cjs');
|
|
9
|
+
|
|
10
|
+
// src/plugin.ts
|
|
11
|
+
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
12
|
+
var _core = require('@kubb/core');
|
|
13
|
+
var _transformers = require('@kubb/core/transformers');
|
|
14
|
+
var _utils = require('@kubb/core/utils');
|
|
15
|
+
var _pluginoas = require('@kubb/plugin-oas');
|
|
16
|
+
var _utils3 = require('@kubb/plugin-oas/utils');
|
|
17
|
+
var _plugints = require('@kubb/plugin-ts');
|
|
18
|
+
var _pluginzod = require('@kubb/plugin-zod');
|
|
19
|
+
|
|
20
|
+
// src/OperationGenerator.tsx
|
|
21
|
+
|
|
22
|
+
var _components = require('@kubb/plugin-oas/components');
|
|
23
|
+
var _react = require('@kubb/react');
|
|
24
|
+
var _jsxruntime = require('@kubb/react/jsx-runtime');
|
|
25
|
+
var OperationGenerator = class extends _pluginoas.OperationGenerator {
|
|
26
|
+
async all(operations) {
|
|
27
|
+
const { pluginManager, oas, plugin, mode } = this.context;
|
|
28
|
+
const root = _react.createRoot.call(void 0, {
|
|
29
|
+
logger: pluginManager.logger
|
|
30
|
+
});
|
|
31
|
+
const templates = {
|
|
32
|
+
mutation: _chunkJFX7DCS7cjs.Mutation.templates,
|
|
33
|
+
query: _chunkJFX7DCS7cjs.Query.templates,
|
|
34
|
+
queryOptions: _chunkJFX7DCS7cjs.QueryOptions.templates,
|
|
35
|
+
queryKey: _chunkJFX7DCS7cjs.QueryKey.templates,
|
|
36
|
+
queryImports: _chunkJFX7DCS7cjs.QueryImports.templates,
|
|
37
|
+
operations: _chunkJFX7DCS7cjs.Operations.templates,
|
|
38
|
+
...this.options.templates
|
|
39
|
+
};
|
|
40
|
+
root.render(
|
|
41
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.App, { pluginManager, plugin, mode, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _components.Oas, { oas, operations, generator: this, children: templates.operations && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkJFX7DCS7cjs.Operations.File, { templates: templates.operations }) }) })
|
|
42
|
+
);
|
|
43
|
+
return root.files;
|
|
44
|
+
}
|
|
45
|
+
async operation(operation, options) {
|
|
46
|
+
const { oas, pluginManager, plugin, mode } = this.context;
|
|
47
|
+
const root = _react.createRoot.call(void 0, {
|
|
48
|
+
logger: pluginManager.logger
|
|
49
|
+
});
|
|
50
|
+
const templates = {
|
|
51
|
+
mutation: _chunkJFX7DCS7cjs.Mutation.templates,
|
|
52
|
+
query: _chunkJFX7DCS7cjs.Query.templates,
|
|
53
|
+
queryOptions: _chunkJFX7DCS7cjs.QueryOptions.templates,
|
|
54
|
+
queryKey: _chunkJFX7DCS7cjs.QueryKey.templates,
|
|
55
|
+
queryImports: _chunkJFX7DCS7cjs.QueryImports.templates,
|
|
56
|
+
...options.templates
|
|
57
|
+
};
|
|
58
|
+
const isQuery = typeof options.query === "boolean" ? true : _optionalChain([options, 'access', _ => _.query, 'optionalAccess', _2 => _2.methods, 'access', _3 => _3.some, 'call', _4 => _4((method) => operation.method === method)]);
|
|
59
|
+
const isMutate = !isQuery && options.mutate && options.mutate.methods.some((method) => operation.method === method);
|
|
60
|
+
root.render(
|
|
61
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _components.Oas, { oas, operations: [operation], generator: this, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _components.Oas.Operation, { operation, children: [
|
|
62
|
+
isMutate && _optionalChain([templates, 'optionalAccess', _5 => _5.mutation]) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkJFX7DCS7cjs.Mutation.File, { templates: templates.mutation }),
|
|
63
|
+
isQuery && _optionalChain([templates, 'optionalAccess', _6 => _6.query]) && templates.queryKey && templates.queryOptions && templates.queryImports && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
64
|
+
_chunkJFX7DCS7cjs.Query.File,
|
|
65
|
+
{
|
|
66
|
+
templates: {
|
|
67
|
+
query: templates.query,
|
|
68
|
+
queryKey: templates.queryKey,
|
|
69
|
+
queryOptions: templates.queryOptions,
|
|
70
|
+
queryImports: templates.queryImports
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
)
|
|
74
|
+
] }) }) })
|
|
75
|
+
);
|
|
76
|
+
return root.files;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// src/plugin.ts
|
|
81
|
+
var pluginReactQueryName = "plugin-react-query";
|
|
82
|
+
var pluginReactQuery = _core.createPlugin.call(void 0, (options) => {
|
|
83
|
+
const {
|
|
84
|
+
output = { path: "hooks" },
|
|
85
|
+
group,
|
|
86
|
+
exclude = [],
|
|
87
|
+
include,
|
|
88
|
+
override = [],
|
|
89
|
+
parser,
|
|
90
|
+
suspense = {},
|
|
91
|
+
infinite,
|
|
92
|
+
transformers = {},
|
|
93
|
+
dataReturnType = "data",
|
|
94
|
+
pathParamsType = "inline",
|
|
95
|
+
mutate = {},
|
|
96
|
+
query = {},
|
|
97
|
+
queryOptions = {},
|
|
98
|
+
templates
|
|
99
|
+
} = options;
|
|
100
|
+
const template = _optionalChain([group, 'optionalAccess', _7 => _7.output]) ? group.output : `${output.path}/{{tag}}Controller`;
|
|
101
|
+
return {
|
|
102
|
+
name: pluginReactQueryName,
|
|
103
|
+
options: {
|
|
104
|
+
client: {
|
|
105
|
+
importPath: "@kubb/plugin-client/client",
|
|
106
|
+
...options.client
|
|
107
|
+
},
|
|
108
|
+
dataReturnType,
|
|
109
|
+
pathParamsType,
|
|
110
|
+
infinite: infinite ? {
|
|
111
|
+
queryParam: "id",
|
|
112
|
+
initialPageParam: 0,
|
|
113
|
+
cursorParam: void 0,
|
|
114
|
+
...infinite
|
|
115
|
+
} : false,
|
|
116
|
+
suspense,
|
|
117
|
+
query: query ? {
|
|
118
|
+
queryKey: (key) => key,
|
|
119
|
+
methods: ["get"],
|
|
120
|
+
importPath: "@tanstack/react-query",
|
|
121
|
+
...query
|
|
122
|
+
} : false,
|
|
123
|
+
queryOptions,
|
|
124
|
+
mutate: mutate ? {
|
|
125
|
+
variablesType: "hook",
|
|
126
|
+
methods: ["post", "put", "patch", "delete"],
|
|
127
|
+
...mutate
|
|
128
|
+
} : false,
|
|
129
|
+
templates: {
|
|
130
|
+
mutation: _chunkJFX7DCS7cjs.Mutation.templates,
|
|
131
|
+
query: _chunkJFX7DCS7cjs.Query.templates,
|
|
132
|
+
queryOptions: _chunkJFX7DCS7cjs.QueryOptions.templates,
|
|
133
|
+
queryKey: _chunkJFX7DCS7cjs.QueryKey.templates,
|
|
134
|
+
queryImports: _chunkJFX7DCS7cjs.QueryImports.templates,
|
|
135
|
+
operations: _chunkJFX7DCS7cjs.Operations.templates,
|
|
136
|
+
...templates
|
|
137
|
+
},
|
|
138
|
+
parser
|
|
139
|
+
},
|
|
140
|
+
pre: [_pluginoas.pluginOasName, _plugints.pluginTsName, parser === "zod" ? _pluginzod.pluginZodName : void 0].filter(Boolean),
|
|
141
|
+
resolvePath(baseName, pathMode, options2) {
|
|
142
|
+
const root = _path2.default.resolve(this.config.root, this.config.output.path);
|
|
143
|
+
const mode = _nullishCoalesce(pathMode, () => ( _core.FileManager.getMode(_path2.default.resolve(root, output.path))));
|
|
144
|
+
if (mode === "single") {
|
|
145
|
+
return _path2.default.resolve(root, output.path);
|
|
146
|
+
}
|
|
147
|
+
if (_optionalChain([options2, 'optionalAccess', _8 => _8.tag]) && _optionalChain([group, 'optionalAccess', _9 => _9.type]) === "tag") {
|
|
148
|
+
const tag = _transformers.camelCase.call(void 0, options2.tag);
|
|
149
|
+
return _path2.default.resolve(root, _utils.renderTemplate.call(void 0, template, { tag }), baseName);
|
|
150
|
+
}
|
|
151
|
+
return _path2.default.resolve(root, output.path, baseName);
|
|
152
|
+
},
|
|
153
|
+
resolveName(name, type) {
|
|
154
|
+
let resolvedName = _transformers.camelCase.call(void 0, name);
|
|
155
|
+
if (type === "file" || type === "function") {
|
|
156
|
+
resolvedName = _transformers.camelCase.call(void 0, name, {
|
|
157
|
+
prefix: "use",
|
|
158
|
+
isFile: type === "file"
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
if (type === "type") {
|
|
162
|
+
resolvedName = _transformers.pascalCase.call(void 0, name);
|
|
163
|
+
}
|
|
164
|
+
if (type) {
|
|
165
|
+
return _optionalChain([transformers, 'optionalAccess', _10 => _10.name, 'optionalCall', _11 => _11(resolvedName, type)]) || resolvedName;
|
|
166
|
+
}
|
|
167
|
+
return resolvedName;
|
|
168
|
+
},
|
|
169
|
+
async buildStart() {
|
|
170
|
+
const [swaggerPlugin] = _core.PluginManager.getDependedPlugins(this.plugins, [_pluginoas.pluginOasName]);
|
|
171
|
+
const oas = await swaggerPlugin.api.getOas();
|
|
172
|
+
const root = _path2.default.resolve(this.config.root, this.config.output.path);
|
|
173
|
+
const mode = _core.FileManager.getMode(_path2.default.resolve(root, output.path));
|
|
174
|
+
const operationGenerator = new OperationGenerator(this.plugin.options, {
|
|
175
|
+
oas,
|
|
176
|
+
pluginManager: this.pluginManager,
|
|
177
|
+
plugin: this.plugin,
|
|
178
|
+
contentType: swaggerPlugin.api.contentType,
|
|
179
|
+
exclude,
|
|
180
|
+
include,
|
|
181
|
+
override,
|
|
182
|
+
mode
|
|
183
|
+
});
|
|
184
|
+
const files = await operationGenerator.build();
|
|
185
|
+
await this.addFile(...files);
|
|
186
|
+
},
|
|
187
|
+
async writeFile(path2, source) {
|
|
188
|
+
if (!path2.endsWith(".ts") || !source) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
return this.fileManager.write(path2, source, { sanity: false });
|
|
192
|
+
},
|
|
193
|
+
async buildEnd() {
|
|
194
|
+
if (this.config.output.write === false) {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
const root = _path2.default.resolve(this.config.root, this.config.output.path);
|
|
198
|
+
if (_optionalChain([group, 'optionalAccess', _12 => _12.type]) === "tag") {
|
|
199
|
+
const rootFiles = await _utils3.getGroupedByTagFiles.call(void 0, {
|
|
200
|
+
logger: this.logger,
|
|
201
|
+
files: this.fileManager.files,
|
|
202
|
+
plugin: this.plugin,
|
|
203
|
+
template,
|
|
204
|
+
exportAs: group.exportAs || "{{tag}}Hooks",
|
|
205
|
+
root,
|
|
206
|
+
output
|
|
207
|
+
});
|
|
208
|
+
await this.addFile(...rootFiles);
|
|
209
|
+
}
|
|
210
|
+
await this.fileManager.addIndexes({
|
|
211
|
+
root,
|
|
212
|
+
output,
|
|
213
|
+
meta: { pluginKey: this.plugin.key },
|
|
214
|
+
logger: this.logger
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
exports.pluginReactQuery = pluginReactQuery; exports.pluginReactQueryName = pluginReactQueryName;
|
|
223
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-react-query/dist/index.cjs","../src/plugin.ts","../src/OperationGenerator.tsx"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACTA,wEAAiB;AAEjB,kCAAyD;AACzD,uDAAsC;AACtC,yCAA+B;AAC/B,6CAA8B;AAC9B,gDAAqC;AACrC,2CAA6B;AAC7B,6CAA8B;ADU9B;AACA;AEnBA;AACA,yDAAoB;AACpB,oCAAgC;AAkCG,qDAAA;AArB5B,IAAM,mBAAA,EAAN,MAAA,QAAiC,8BAA2E;AAAA,EACjH,MAAM,GAAA,CAAI,UAAA,EAA0D;AAClE,IAAA,MAAM,EAAE,aAAA,EAAe,GAAA,EAAK,MAAA,EAAQ,KAAK,EAAA,EAAI,IAAA,CAAK,OAAA;AAElD,IAAA,MAAM,KAAA,EAAO,+BAAA;AAAW,MACtB,MAAA,EAAQ,aAAA,CAAc;AAAA,IACxB,CAAC,CAAA;AAED,IAAA,MAAM,UAAA,EAAY;AAAA,MAChB,QAAA,EAAU,0BAAA,CAAS,SAAA;AAAA,MACnB,KAAA,EAAO,uBAAA,CAAM,SAAA;AAAA,MACb,YAAA,EAAc,8BAAA,CAAa,SAAA;AAAA,MAC3B,QAAA,EAAU,0BAAA,CAAS,SAAA;AAAA,MACnB,YAAA,EAAc,8BAAA,CAAa,SAAA;AAAA,MAC3B,UAAA,EAAY,4BAAA,CAAW,SAAA;AAAA,MACvB,GAAG,IAAA,CAAK,OAAA,CAAQ;AAAA,IAClB,CAAA;AAEA,IAAA,IAAA,CAAK,MAAA;AAAA,sBACH,6BAAA,UAAC,EAAA,EAAI,aAAA,EAA8B,MAAA,EAAgB,IAAA,EACjD,QAAA,kBAAA,6BAAA,eAAC,EAAA,EAAI,G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ACC,MAAA;AACN,MAAA;AAEP,MAAA;AAC7B,QAAA;AACoB,QAAA;AACP,QAAA;AACkB,QAAA;AAC/B,QAAA;AACA,QAAA;AACA,QAAA;AACA,QAAA;AACD,MAAA;AAE4C,MAAA;AAClB,MAAA;AAC7B,IAAA;AAC8B,IAAA;AACU,MAAA;AACpC,QAAA;AACF,MAAA;AAE4C,MAAA;AAC9C,IAAA;AACiB,IAAA;AACyB,MAAA;AACtC,QAAA;AACF,MAAA;AAE4C,MAAA;AAEjB,MAAA;AACD,QAAA;AACT,UAAA;AACW,UAAA;AACX,UAAA;AACb,UAAA;AAC4B,UAAA;AAC5B,UAAA;AACA,UAAA;AACD,QAAA;AAE8B,QAAA;AACjC,MAAA;AAEkC,MAAA;AAChC,QAAA;AACA,QAAA;AACmC,QAAA;AACtB,QAAA;AACd,MAAA;AACH,IAAA;AACF,EAAA;AACD;ADoCkD;AACA;AACA;AACA","file":"/home/runner/work/kubb/kubb/packages/plugin-react-query/dist/index.cjs","sourcesContent":[null,"import path from 'node:path'\n\nimport { FileManager, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { renderTemplate } from '@kubb/core/utils'\nimport { pluginOasName } from '@kubb/plugin-oas'\nimport { getGroupedByTagFiles } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\n\nimport { OperationGenerator } from './OperationGenerator.tsx'\nimport { Mutation, Operations, Query, QueryKey, QueryOptions } from './components/index.ts'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas } from '@kubb/plugin-oas'\nimport { QueryImports } from './components/QueryImports.tsx'\nimport type { PluginReactQuery } from './types.ts'\n\nexport const pluginReactQueryName = 'plugin-react-query' satisfies PluginReactQuery['name']\n\nexport const pluginReactQuery = createPlugin<PluginReactQuery>((options) => {\n const {\n output = { path: 'hooks' },\n group,\n exclude = [],\n include,\n override = [],\n parser,\n suspense = {},\n infinite,\n transformers = {},\n dataReturnType = 'data',\n pathParamsType = 'inline',\n mutate = {},\n query = {},\n queryOptions = {},\n templates,\n } = options\n const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`\n\n return {\n name: pluginReactQueryName,\n options: {\n client: {\n importPath: '@kubb/plugin-client/client',\n ...options.client,\n },\n dataReturnType,\n pathParamsType,\n infinite: infinite\n ? {\n queryParam: 'id',\n initialPageParam: 0,\n cursorParam: undefined,\n ...infinite,\n }\n : false,\n suspense,\n query: query\n ? {\n queryKey: (key: unknown[]) => key,\n methods: ['get'],\n importPath: '@tanstack/react-query',\n ...query,\n }\n : false,\n queryOptions,\n mutate: mutate\n ? {\n variablesType: 'hook',\n methods: ['post', 'put', 'patch', 'delete'],\n ...mutate,\n }\n : false,\n templates: {\n mutation: Mutation.templates,\n query: Query.templates,\n queryOptions: QueryOptions.templates,\n queryKey: QueryKey.templates,\n queryImports: QueryImports.templates,\n operations: Operations.templates,\n ...templates,\n },\n parser,\n },\n pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (options?.tag && group?.type === 'tag') {\n const tag = camelCase(options.tag)\n\n return path.resolve(root, renderTemplate(template, { tag }), baseName)\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n let resolvedName = camelCase(name)\n\n if (type === 'file' || type === 'function') {\n resolvedName = camelCase(name, {\n prefix: 'use',\n isFile: type === 'file',\n })\n }\n if (type === 'type') {\n resolvedName = pascalCase(name)\n }\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<PluginOas>] = PluginManager.getDependedPlugins<PluginOas>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.api.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.api.contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build()\n await this.addFile(...files)\n },\n async writeFile(path, source) {\n if (!path.endsWith('.ts') || !source) {\n return\n }\n\n return this.fileManager.write(path, source, { sanity: false })\n },\n async buildEnd() {\n if (this.config.output.write === false) {\n return\n }\n\n const root = path.resolve(this.config.root, this.config.output.path)\n\n if (group?.type === 'tag') {\n const rootFiles = await getGroupedByTagFiles({\n logger: this.logger,\n files: this.fileManager.files,\n plugin: this.plugin,\n template,\n exportAs: group.exportAs || '{{tag}}Hooks',\n root,\n output,\n })\n\n await this.addFile(...rootFiles)\n }\n\n await this.fileManager.addIndexes({\n root,\n output,\n meta: { pluginKey: this.plugin.key },\n logger: this.logger,\n })\n },\n }\n})\n","import { OperationGenerator as Generator } from '@kubb/plugin-oas'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport { App, createRoot } from '@kubb/react'\n\nimport { Mutation } from './components/Mutation.tsx'\nimport { Operations } from './components/Operations.tsx'\nimport { Query } from './components/Query.tsx'\nimport { QueryKey } from './components/QueryKey.tsx'\nimport { QueryOptions } from './components/QueryOptions.tsx'\n\nimport type { Operation } from '@kubb/oas'\nimport type { OperationMethodResult } from '@kubb/plugin-oas'\nimport { QueryImports } from './components/QueryImports.tsx'\nimport type { FileMeta, PluginReactQuery } from './types.ts'\n\nexport class OperationGenerator extends Generator<PluginReactQuery['resolvedOptions'], PluginReactQuery, FileMeta> {\n async all(operations: Operation[]): OperationMethodResult<FileMeta> {\n const { pluginManager, oas, plugin, mode } = this.context\n\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n const templates = {\n mutation: Mutation.templates,\n query: Query.templates,\n queryOptions: QueryOptions.templates,\n queryKey: QueryKey.templates,\n queryImports: QueryImports.templates,\n operations: Operations.templates,\n ...this.options.templates,\n }\n\n root.render(\n <App pluginManager={pluginManager} plugin={plugin} mode={mode}>\n <Oas oas={oas} operations={operations} generator={this}>\n {templates.operations && <Operations.File templates={templates.operations} />}\n </Oas>\n </App>,\n )\n\n return root.files\n }\n\n async operation(operation: Operation, options: PluginReactQuery['resolvedOptions']): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin, mode } = this.context\n\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n const templates = {\n mutation: Mutation.templates,\n query: Query.templates,\n queryOptions: QueryOptions.templates,\n queryKey: QueryKey.templates,\n queryImports: QueryImports.templates,\n ...options.templates,\n }\n\n const isQuery = typeof options.query === 'boolean' ? true : options.query?.methods.some((method) => operation.method === method)\n const isMutate = !isQuery && options.mutate && options.mutate.methods.some((method) => operation.method === method)\n\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas} operations={[operation]} generator={this}>\n <Oas.Operation operation={operation}>\n {isMutate && templates?.mutation && <Mutation.File templates={templates.mutation} />}\n {isQuery && templates?.query && templates.queryKey && templates.queryOptions && templates.queryImports && (\n <Query.File\n templates={{\n query: templates.query,\n queryKey: templates.queryKey,\n queryOptions: templates.queryOptions,\n queryImports: templates.queryImports,\n }}\n />\n )}\n </Oas.Operation>\n </Oas>\n </App>,\n )\n\n return root.files\n }\n}\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as _kubb_core from '@kubb/core';
|
|
2
|
+
import { O as Options, P as PluginReactQuery } from './index-yXskx3Td.cjs';
|
|
3
|
+
import '@kubb/core/utils';
|
|
4
|
+
import '@kubb/oas';
|
|
5
|
+
import 'react';
|
|
6
|
+
import '@kubb/fs/types';
|
|
7
|
+
import '@kubb/plugin-oas';
|
|
8
|
+
import '@kubb/react';
|
|
9
|
+
|
|
10
|
+
declare const pluginReactQueryName = "plugin-react-query";
|
|
11
|
+
declare const pluginReactQuery: (options?: Options | undefined) => _kubb_core.UserPluginWithLifeCycle<PluginReactQuery>;
|
|
12
|
+
|
|
13
|
+
export { PluginReactQuery, pluginReactQuery, pluginReactQueryName };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as _kubb_core from '@kubb/core';
|
|
2
|
+
import { O as Options, P as PluginReactQuery } from './index-yXskx3Td.js';
|
|
3
|
+
import '@kubb/core/utils';
|
|
4
|
+
import '@kubb/oas';
|
|
5
|
+
import 'react';
|
|
6
|
+
import '@kubb/fs/types';
|
|
7
|
+
import '@kubb/plugin-oas';
|
|
8
|
+
import '@kubb/react';
|
|
9
|
+
|
|
10
|
+
declare const pluginReactQueryName = "plugin-react-query";
|
|
11
|
+
declare const pluginReactQuery: (options?: Options | undefined) => _kubb_core.UserPluginWithLifeCycle<PluginReactQuery>;
|
|
12
|
+
|
|
13
|
+
export { PluginReactQuery, pluginReactQuery, pluginReactQueryName };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Mutation,
|
|
3
|
+
Operations,
|
|
4
|
+
Query,
|
|
5
|
+
QueryImports,
|
|
6
|
+
QueryKey,
|
|
7
|
+
QueryOptions
|
|
8
|
+
} from "./chunk-5IL6M74X.js";
|
|
9
|
+
|
|
10
|
+
// src/plugin.ts
|
|
11
|
+
import path from "path";
|
|
12
|
+
import { FileManager, PluginManager, createPlugin } from "@kubb/core";
|
|
13
|
+
import { camelCase, pascalCase } from "@kubb/core/transformers";
|
|
14
|
+
import { renderTemplate } from "@kubb/core/utils";
|
|
15
|
+
import { pluginOasName } from "@kubb/plugin-oas";
|
|
16
|
+
import { getGroupedByTagFiles } from "@kubb/plugin-oas/utils";
|
|
17
|
+
import { pluginTsName } from "@kubb/plugin-ts";
|
|
18
|
+
import { pluginZodName } from "@kubb/plugin-zod";
|
|
19
|
+
|
|
20
|
+
// src/OperationGenerator.tsx
|
|
21
|
+
import { OperationGenerator as Generator } from "@kubb/plugin-oas";
|
|
22
|
+
import { Oas } from "@kubb/plugin-oas/components";
|
|
23
|
+
import { App, createRoot } from "@kubb/react";
|
|
24
|
+
import { jsx, jsxs } from "@kubb/react/jsx-runtime";
|
|
25
|
+
var OperationGenerator = class extends Generator {
|
|
26
|
+
async all(operations) {
|
|
27
|
+
const { pluginManager, oas, plugin, mode } = this.context;
|
|
28
|
+
const root = createRoot({
|
|
29
|
+
logger: pluginManager.logger
|
|
30
|
+
});
|
|
31
|
+
const templates = {
|
|
32
|
+
mutation: Mutation.templates,
|
|
33
|
+
query: Query.templates,
|
|
34
|
+
queryOptions: QueryOptions.templates,
|
|
35
|
+
queryKey: QueryKey.templates,
|
|
36
|
+
queryImports: QueryImports.templates,
|
|
37
|
+
operations: Operations.templates,
|
|
38
|
+
...this.options.templates
|
|
39
|
+
};
|
|
40
|
+
root.render(
|
|
41
|
+
/* @__PURE__ */ jsx(App, { pluginManager, plugin, mode, children: /* @__PURE__ */ jsx(Oas, { oas, operations, generator: this, children: templates.operations && /* @__PURE__ */ jsx(Operations.File, { templates: templates.operations }) }) })
|
|
42
|
+
);
|
|
43
|
+
return root.files;
|
|
44
|
+
}
|
|
45
|
+
async operation(operation, options) {
|
|
46
|
+
const { oas, pluginManager, plugin, mode } = this.context;
|
|
47
|
+
const root = createRoot({
|
|
48
|
+
logger: pluginManager.logger
|
|
49
|
+
});
|
|
50
|
+
const templates = {
|
|
51
|
+
mutation: Mutation.templates,
|
|
52
|
+
query: Query.templates,
|
|
53
|
+
queryOptions: QueryOptions.templates,
|
|
54
|
+
queryKey: QueryKey.templates,
|
|
55
|
+
queryImports: QueryImports.templates,
|
|
56
|
+
...options.templates
|
|
57
|
+
};
|
|
58
|
+
const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
|
|
59
|
+
const isMutate = !isQuery && options.mutate && options.mutate.methods.some((method) => operation.method === method);
|
|
60
|
+
root.render(
|
|
61
|
+
/* @__PURE__ */ jsx(App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ jsx(Oas, { oas, operations: [operation], generator: this, children: /* @__PURE__ */ jsxs(Oas.Operation, { operation, children: [
|
|
62
|
+
isMutate && templates?.mutation && /* @__PURE__ */ jsx(Mutation.File, { templates: templates.mutation }),
|
|
63
|
+
isQuery && templates?.query && templates.queryKey && templates.queryOptions && templates.queryImports && /* @__PURE__ */ jsx(
|
|
64
|
+
Query.File,
|
|
65
|
+
{
|
|
66
|
+
templates: {
|
|
67
|
+
query: templates.query,
|
|
68
|
+
queryKey: templates.queryKey,
|
|
69
|
+
queryOptions: templates.queryOptions,
|
|
70
|
+
queryImports: templates.queryImports
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
)
|
|
74
|
+
] }) }) })
|
|
75
|
+
);
|
|
76
|
+
return root.files;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// src/plugin.ts
|
|
81
|
+
var pluginReactQueryName = "plugin-react-query";
|
|
82
|
+
var pluginReactQuery = createPlugin((options) => {
|
|
83
|
+
const {
|
|
84
|
+
output = { path: "hooks" },
|
|
85
|
+
group,
|
|
86
|
+
exclude = [],
|
|
87
|
+
include,
|
|
88
|
+
override = [],
|
|
89
|
+
parser,
|
|
90
|
+
suspense = {},
|
|
91
|
+
infinite,
|
|
92
|
+
transformers = {},
|
|
93
|
+
dataReturnType = "data",
|
|
94
|
+
pathParamsType = "inline",
|
|
95
|
+
mutate = {},
|
|
96
|
+
query = {},
|
|
97
|
+
queryOptions = {},
|
|
98
|
+
templates
|
|
99
|
+
} = options;
|
|
100
|
+
const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`;
|
|
101
|
+
return {
|
|
102
|
+
name: pluginReactQueryName,
|
|
103
|
+
options: {
|
|
104
|
+
client: {
|
|
105
|
+
importPath: "@kubb/plugin-client/client",
|
|
106
|
+
...options.client
|
|
107
|
+
},
|
|
108
|
+
dataReturnType,
|
|
109
|
+
pathParamsType,
|
|
110
|
+
infinite: infinite ? {
|
|
111
|
+
queryParam: "id",
|
|
112
|
+
initialPageParam: 0,
|
|
113
|
+
cursorParam: void 0,
|
|
114
|
+
...infinite
|
|
115
|
+
} : false,
|
|
116
|
+
suspense,
|
|
117
|
+
query: query ? {
|
|
118
|
+
queryKey: (key) => key,
|
|
119
|
+
methods: ["get"],
|
|
120
|
+
importPath: "@tanstack/react-query",
|
|
121
|
+
...query
|
|
122
|
+
} : false,
|
|
123
|
+
queryOptions,
|
|
124
|
+
mutate: mutate ? {
|
|
125
|
+
variablesType: "hook",
|
|
126
|
+
methods: ["post", "put", "patch", "delete"],
|
|
127
|
+
...mutate
|
|
128
|
+
} : false,
|
|
129
|
+
templates: {
|
|
130
|
+
mutation: Mutation.templates,
|
|
131
|
+
query: Query.templates,
|
|
132
|
+
queryOptions: QueryOptions.templates,
|
|
133
|
+
queryKey: QueryKey.templates,
|
|
134
|
+
queryImports: QueryImports.templates,
|
|
135
|
+
operations: Operations.templates,
|
|
136
|
+
...templates
|
|
137
|
+
},
|
|
138
|
+
parser
|
|
139
|
+
},
|
|
140
|
+
pre: [pluginOasName, pluginTsName, parser === "zod" ? pluginZodName : void 0].filter(Boolean),
|
|
141
|
+
resolvePath(baseName, pathMode, options2) {
|
|
142
|
+
const root = path.resolve(this.config.root, this.config.output.path);
|
|
143
|
+
const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path));
|
|
144
|
+
if (mode === "single") {
|
|
145
|
+
return path.resolve(root, output.path);
|
|
146
|
+
}
|
|
147
|
+
if (options2?.tag && group?.type === "tag") {
|
|
148
|
+
const tag = camelCase(options2.tag);
|
|
149
|
+
return path.resolve(root, renderTemplate(template, { tag }), baseName);
|
|
150
|
+
}
|
|
151
|
+
return path.resolve(root, output.path, baseName);
|
|
152
|
+
},
|
|
153
|
+
resolveName(name, type) {
|
|
154
|
+
let resolvedName = camelCase(name);
|
|
155
|
+
if (type === "file" || type === "function") {
|
|
156
|
+
resolvedName = camelCase(name, {
|
|
157
|
+
prefix: "use",
|
|
158
|
+
isFile: type === "file"
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
if (type === "type") {
|
|
162
|
+
resolvedName = pascalCase(name);
|
|
163
|
+
}
|
|
164
|
+
if (type) {
|
|
165
|
+
return transformers?.name?.(resolvedName, type) || resolvedName;
|
|
166
|
+
}
|
|
167
|
+
return resolvedName;
|
|
168
|
+
},
|
|
169
|
+
async buildStart() {
|
|
170
|
+
const [swaggerPlugin] = PluginManager.getDependedPlugins(this.plugins, [pluginOasName]);
|
|
171
|
+
const oas = await swaggerPlugin.api.getOas();
|
|
172
|
+
const root = path.resolve(this.config.root, this.config.output.path);
|
|
173
|
+
const mode = FileManager.getMode(path.resolve(root, output.path));
|
|
174
|
+
const operationGenerator = new OperationGenerator(this.plugin.options, {
|
|
175
|
+
oas,
|
|
176
|
+
pluginManager: this.pluginManager,
|
|
177
|
+
plugin: this.plugin,
|
|
178
|
+
contentType: swaggerPlugin.api.contentType,
|
|
179
|
+
exclude,
|
|
180
|
+
include,
|
|
181
|
+
override,
|
|
182
|
+
mode
|
|
183
|
+
});
|
|
184
|
+
const files = await operationGenerator.build();
|
|
185
|
+
await this.addFile(...files);
|
|
186
|
+
},
|
|
187
|
+
async writeFile(path2, source) {
|
|
188
|
+
if (!path2.endsWith(".ts") || !source) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
return this.fileManager.write(path2, source, { sanity: false });
|
|
192
|
+
},
|
|
193
|
+
async buildEnd() {
|
|
194
|
+
if (this.config.output.write === false) {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
const root = path.resolve(this.config.root, this.config.output.path);
|
|
198
|
+
if (group?.type === "tag") {
|
|
199
|
+
const rootFiles = await getGroupedByTagFiles({
|
|
200
|
+
logger: this.logger,
|
|
201
|
+
files: this.fileManager.files,
|
|
202
|
+
plugin: this.plugin,
|
|
203
|
+
template,
|
|
204
|
+
exportAs: group.exportAs || "{{tag}}Hooks",
|
|
205
|
+
root,
|
|
206
|
+
output
|
|
207
|
+
});
|
|
208
|
+
await this.addFile(...rootFiles);
|
|
209
|
+
}
|
|
210
|
+
await this.fileManager.addIndexes({
|
|
211
|
+
root,
|
|
212
|
+
output,
|
|
213
|
+
meta: { pluginKey: this.plugin.key },
|
|
214
|
+
logger: this.logger
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
});
|
|
219
|
+
export {
|
|
220
|
+
pluginReactQuery,
|
|
221
|
+
pluginReactQueryName
|
|
222
|
+
};
|
|
223
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/plugin.ts","../src/OperationGenerator.tsx"],"sourcesContent":["import path from 'node:path'\n\nimport { FileManager, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { renderTemplate } from '@kubb/core/utils'\nimport { pluginOasName } from '@kubb/plugin-oas'\nimport { getGroupedByTagFiles } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\n\nimport { OperationGenerator } from './OperationGenerator.tsx'\nimport { Mutation, Operations, Query, QueryKey, QueryOptions } from './components/index.ts'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas } from '@kubb/plugin-oas'\nimport { QueryImports } from './components/QueryImports.tsx'\nimport type { PluginReactQuery } from './types.ts'\n\nexport const pluginReactQueryName = 'plugin-react-query' satisfies PluginReactQuery['name']\n\nexport const pluginReactQuery = createPlugin<PluginReactQuery>((options) => {\n const {\n output = { path: 'hooks' },\n group,\n exclude = [],\n include,\n override = [],\n parser,\n suspense = {},\n infinite,\n transformers = {},\n dataReturnType = 'data',\n pathParamsType = 'inline',\n mutate = {},\n query = {},\n queryOptions = {},\n templates,\n } = options\n const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`\n\n return {\n name: pluginReactQueryName,\n options: {\n client: {\n importPath: '@kubb/plugin-client/client',\n ...options.client,\n },\n dataReturnType,\n pathParamsType,\n infinite: infinite\n ? {\n queryParam: 'id',\n initialPageParam: 0,\n cursorParam: undefined,\n ...infinite,\n }\n : false,\n suspense,\n query: query\n ? {\n queryKey: (key: unknown[]) => key,\n methods: ['get'],\n importPath: '@tanstack/react-query',\n ...query,\n }\n : false,\n queryOptions,\n mutate: mutate\n ? {\n variablesType: 'hook',\n methods: ['post', 'put', 'patch', 'delete'],\n ...mutate,\n }\n : false,\n templates: {\n mutation: Mutation.templates,\n query: Query.templates,\n queryOptions: QueryOptions.templates,\n queryKey: QueryKey.templates,\n queryImports: QueryImports.templates,\n operations: Operations.templates,\n ...templates,\n },\n parser,\n },\n pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (options?.tag && group?.type === 'tag') {\n const tag = camelCase(options.tag)\n\n return path.resolve(root, renderTemplate(template, { tag }), baseName)\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n let resolvedName = camelCase(name)\n\n if (type === 'file' || type === 'function') {\n resolvedName = camelCase(name, {\n prefix: 'use',\n isFile: type === 'file',\n })\n }\n if (type === 'type') {\n resolvedName = pascalCase(name)\n }\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<PluginOas>] = PluginManager.getDependedPlugins<PluginOas>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.api.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.api.contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build()\n await this.addFile(...files)\n },\n async writeFile(path, source) {\n if (!path.endsWith('.ts') || !source) {\n return\n }\n\n return this.fileManager.write(path, source, { sanity: false })\n },\n async buildEnd() {\n if (this.config.output.write === false) {\n return\n }\n\n const root = path.resolve(this.config.root, this.config.output.path)\n\n if (group?.type === 'tag') {\n const rootFiles = await getGroupedByTagFiles({\n logger: this.logger,\n files: this.fileManager.files,\n plugin: this.plugin,\n template,\n exportAs: group.exportAs || '{{tag}}Hooks',\n root,\n output,\n })\n\n await this.addFile(...rootFiles)\n }\n\n await this.fileManager.addIndexes({\n root,\n output,\n meta: { pluginKey: this.plugin.key },\n logger: this.logger,\n })\n },\n }\n})\n","import { OperationGenerator as Generator } from '@kubb/plugin-oas'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport { App, createRoot } from '@kubb/react'\n\nimport { Mutation } from './components/Mutation.tsx'\nimport { Operations } from './components/Operations.tsx'\nimport { Query } from './components/Query.tsx'\nimport { QueryKey } from './components/QueryKey.tsx'\nimport { QueryOptions } from './components/QueryOptions.tsx'\n\nimport type { Operation } from '@kubb/oas'\nimport type { OperationMethodResult } from '@kubb/plugin-oas'\nimport { QueryImports } from './components/QueryImports.tsx'\nimport type { FileMeta, PluginReactQuery } from './types.ts'\n\nexport class OperationGenerator extends Generator<PluginReactQuery['resolvedOptions'], PluginReactQuery, FileMeta> {\n async all(operations: Operation[]): OperationMethodResult<FileMeta> {\n const { pluginManager, oas, plugin, mode } = this.context\n\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n const templates = {\n mutation: Mutation.templates,\n query: Query.templates,\n queryOptions: QueryOptions.templates,\n queryKey: QueryKey.templates,\n queryImports: QueryImports.templates,\n operations: Operations.templates,\n ...this.options.templates,\n }\n\n root.render(\n <App pluginManager={pluginManager} plugin={plugin} mode={mode}>\n <Oas oas={oas} operations={operations} generator={this}>\n {templates.operations && <Operations.File templates={templates.operations} />}\n </Oas>\n </App>,\n )\n\n return root.files\n }\n\n async operation(operation: Operation, options: PluginReactQuery['resolvedOptions']): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin, mode } = this.context\n\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n const templates = {\n mutation: Mutation.templates,\n query: Query.templates,\n queryOptions: QueryOptions.templates,\n queryKey: QueryKey.templates,\n queryImports: QueryImports.templates,\n ...options.templates,\n }\n\n const isQuery = typeof options.query === 'boolean' ? true : options.query?.methods.some((method) => operation.method === method)\n const isMutate = !isQuery && options.mutate && options.mutate.methods.some((method) => operation.method === method)\n\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas} operations={[operation]} generator={this}>\n <Oas.Operation operation={operation}>\n {isMutate && templates?.mutation && <Mutation.File templates={templates.mutation} />}\n {isQuery && templates?.query && templates.queryKey && templates.queryOptions && templates.queryImports && (\n <Query.File\n templates={{\n query: templates.query,\n queryKey: templates.queryKey,\n queryOptions: templates.queryOptions,\n queryImports: templates.queryImports,\n }}\n />\n )}\n </Oas.Operation>\n </Oas>\n </App>,\n )\n\n return root.files\n }\n}\n"],"mappings":";;;;;;;;;;AAAA,OAAO,UAAU;AAEjB,SAAS,aAAa,eAAe,oBAAoB;AACzD,SAAS,WAAW,kBAAkB;AACtC,SAAS,sBAAsB;AAC/B,SAAS,qBAAqB;AAC9B,SAAS,4BAA4B;AACrC,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;;;ACR9B,SAAS,sBAAsB,iBAAiB;AAChD,SAAS,WAAW;AACpB,SAAS,KAAK,kBAAkB;AAkCG,cA8B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AA,UACA,UAAU,MAAM,YAAY;AAAA,UAC5B;AAAA,UACA;AAAA,QACF,CAAC;AAED,cAAM,KAAK,QAAQ,GAAG,SAAS;AAAA,MACjC;AAEA,YAAM,KAAK,YAAY,WAAW;AAAA,QAChC;AAAA,QACA;AAAA,QACA,MAAM,EAAE,WAAW,KAAK,OAAO,IAAI;AAAA,QACnC,QAAQ,KAAK;AAAA,MACf,CAAC;AAAA,IACH;AAAA,EACF;AACF,CAAC;","names":["options","path"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kubb/plugin-react-query",
|
|
3
|
+
"version": "3.0.0-alpha.0",
|
|
4
|
+
"description": "Generator react-query hooks",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"faker",
|
|
7
|
+
"faker.js",
|
|
8
|
+
"msw",
|
|
9
|
+
"mock",
|
|
10
|
+
"mocking",
|
|
11
|
+
"plugins",
|
|
12
|
+
"kubb",
|
|
13
|
+
"codegen",
|
|
14
|
+
"swagger",
|
|
15
|
+
"openapi"
|
|
16
|
+
],
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git://github.com/kubb-labs/kubb.git",
|
|
20
|
+
"directory": "packages/plugin-react-query"
|
|
21
|
+
},
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"author": "Stijn Van Hulle <stijn@stijnvanhulle.be",
|
|
24
|
+
"sideEffects": false,
|
|
25
|
+
"type": "module",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"import": "./dist/index.js",
|
|
29
|
+
"require": "./dist/index.cjs",
|
|
30
|
+
"default": "./dist/index.cjs"
|
|
31
|
+
},
|
|
32
|
+
"./components": {
|
|
33
|
+
"import": "./dist/components.js",
|
|
34
|
+
"require": "./dist/components.cjs",
|
|
35
|
+
"default": "./dist/components.cjs"
|
|
36
|
+
},
|
|
37
|
+
"./package.json": "./package.json",
|
|
38
|
+
"./*": "./*"
|
|
39
|
+
},
|
|
40
|
+
"main": "dist/index.cjs",
|
|
41
|
+
"module": "dist/index.js",
|
|
42
|
+
"types": "./dist/index.d.ts",
|
|
43
|
+
"typesVersions": {
|
|
44
|
+
"*": {
|
|
45
|
+
"components": [
|
|
46
|
+
"./dist/components.d.ts"
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"files": [
|
|
51
|
+
"src",
|
|
52
|
+
"dist",
|
|
53
|
+
"!/**/**.test.**",
|
|
54
|
+
"!/**/__tests__/**"
|
|
55
|
+
],
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"@kubb/core": "3.0.0-alpha.0",
|
|
58
|
+
"@kubb/fs": "3.0.0-alpha.0",
|
|
59
|
+
"@kubb/oas": "3.0.0-alpha.0",
|
|
60
|
+
"@kubb/parser-ts": "3.0.0-alpha.0",
|
|
61
|
+
"@kubb/plugin-faker": "3.0.0-alpha.0",
|
|
62
|
+
"@kubb/plugin-oas": "3.0.0-alpha.0",
|
|
63
|
+
"@kubb/plugin-ts": "3.0.0-alpha.0",
|
|
64
|
+
"@kubb/plugin-zod": "3.0.0-alpha.0",
|
|
65
|
+
"@kubb/react": "3.0.0-alpha.0"
|
|
66
|
+
},
|
|
67
|
+
"devDependencies": {
|
|
68
|
+
"@types/react": "^18.3.3",
|
|
69
|
+
"react": "^18.3.1",
|
|
70
|
+
"tsup": "^8.2.4",
|
|
71
|
+
"typescript": "^5.5.4",
|
|
72
|
+
"@kubb/config-biome": "3.0.0-alpha.0",
|
|
73
|
+
"@kubb/config-ts": "3.0.0-alpha.0",
|
|
74
|
+
"@kubb/config-tsup": "3.0.0-alpha.0"
|
|
75
|
+
},
|
|
76
|
+
"peerDependencies": {
|
|
77
|
+
"@kubb/react": "3.0.0-alpha.0"
|
|
78
|
+
},
|
|
79
|
+
"engines": {
|
|
80
|
+
"node": ">=20"
|
|
81
|
+
},
|
|
82
|
+
"publishConfig": {
|
|
83
|
+
"access": "public",
|
|
84
|
+
"registry": "https://registry.npmjs.org/"
|
|
85
|
+
},
|
|
86
|
+
"scripts": {
|
|
87
|
+
"build": "tsup",
|
|
88
|
+
"clean": "npx rimraf ./dist",
|
|
89
|
+
"lint": "bun biome lint .",
|
|
90
|
+
"lint:fix": "bun biome lint --apply-unsafe .",
|
|
91
|
+
"release": "pnpm publish --no-git-check",
|
|
92
|
+
"release:canary": "bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check",
|
|
93
|
+
"start": "tsup --watch",
|
|
94
|
+
"test": "vitest --passWithNoTests",
|
|
95
|
+
"typecheck": "tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false"
|
|
96
|
+
}
|
|
97
|
+
}
|