@kubb/plugin-solid-query 3.0.0-alpha.20

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.
Files changed (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +53 -0
  3. package/dist/chunk-7ZYWNHQM.js +291 -0
  4. package/dist/chunk-7ZYWNHQM.js.map +1 -0
  5. package/dist/chunk-D6TNFQR6.js +285 -0
  6. package/dist/chunk-D6TNFQR6.js.map +1 -0
  7. package/dist/chunk-KBTDHYL2.cjs +298 -0
  8. package/dist/chunk-KBTDHYL2.cjs.map +1 -0
  9. package/dist/chunk-WIE2QWZT.cjs +291 -0
  10. package/dist/chunk-WIE2QWZT.cjs.map +1 -0
  11. package/dist/components.cjs +20 -0
  12. package/dist/components.cjs.map +1 -0
  13. package/dist/components.d.cts +64 -0
  14. package/dist/components.d.ts +64 -0
  15. package/dist/components.js +3 -0
  16. package/dist/components.js.map +1 -0
  17. package/dist/generators.cjs +13 -0
  18. package/dist/generators.cjs.map +1 -0
  19. package/dist/generators.d.cts +8 -0
  20. package/dist/generators.d.ts +8 -0
  21. package/dist/generators.js +4 -0
  22. package/dist/generators.js.map +1 -0
  23. package/dist/index.cjs +125 -0
  24. package/dist/index.cjs.map +1 -0
  25. package/dist/index.d.cts +9 -0
  26. package/dist/index.d.ts +9 -0
  27. package/dist/index.js +118 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/types-DlkKXn9W.d.cts +128 -0
  30. package/dist/types-DlkKXn9W.d.ts +128 -0
  31. package/package.json +102 -0
  32. package/src/components/Query.tsx +121 -0
  33. package/src/components/QueryKey.tsx +73 -0
  34. package/src/components/QueryOptions.tsx +84 -0
  35. package/src/components/index.ts +3 -0
  36. package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +51 -0
  37. package/src/generators/__snapshots__/clientGetImportPath.ts +51 -0
  38. package/src/generators/__snapshots__/findByTags.ts +51 -0
  39. package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +51 -0
  40. package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +51 -0
  41. package/src/generators/__snapshots__/findByTagsWithZod.ts +51 -0
  42. package/src/generators/__snapshots__/postAsQuery.ts +49 -0
  43. package/src/generators/index.ts +1 -0
  44. package/src/generators/queryGenerator.tsx +121 -0
  45. package/src/index.ts +2 -0
  46. package/src/plugin.ts +137 -0
  47. package/src/types.ts +132 -0
@@ -0,0 +1,285 @@
1
+ import { File, Function, Type, FunctionParams, Const } from '@kubb/react';
2
+ import { isOptional } from '@kubb/oas';
3
+ import { getComments, getPathParams } from '@kubb/plugin-oas/utils';
4
+ import { URLPath } from '@kubb/core/utils';
5
+ import { jsxs, Fragment, jsx } from '@kubb/react/jsx-runtime';
6
+
7
+ // src/components/Query.tsx
8
+ function getParams({ pathParamsType, typeSchemas }) {
9
+ return FunctionParams.factory({
10
+ pathParams: {
11
+ mode: pathParamsType === "object" ? "object" : "inlineSpread",
12
+ children: getPathParams(typeSchemas.pathParams, { typed: true })
13
+ },
14
+ data: typeSchemas.request?.name ? {
15
+ type: typeSchemas.request?.name,
16
+ optional: isOptional(typeSchemas.request?.schema)
17
+ } : void 0,
18
+ params: typeSchemas.queryParams?.name ? {
19
+ type: typeSchemas.queryParams?.name,
20
+ optional: isOptional(typeSchemas.queryParams?.schema)
21
+ } : void 0
22
+ });
23
+ }
24
+ function QueryKey({ name, typeSchemas, pathParamsType, operation, typeName, keysFn = (name2) => name2 }) {
25
+ const path = new URLPath(operation.path);
26
+ const params = getParams({ pathParamsType, typeSchemas });
27
+ const keys = [
28
+ path.toObject({
29
+ type: "path",
30
+ stringify: true
31
+ }),
32
+ typeSchemas.queryParams?.name ? "...(params ? [params] : [])" : void 0,
33
+ typeSchemas.request?.name ? "...(data ? [data] : [])" : void 0
34
+ ].filter(Boolean);
35
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
36
+ /* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx(Function.Arrow, { name, export: true, params: params.toConstructor(), singleLine: true, children: `[${keysFn(keys).join(", ")}] as const` }) }),
37
+ /* @__PURE__ */ jsx(File.Source, { name: typeName, isExportable: true, isIndexable: true, isTypeOnly: true, children: /* @__PURE__ */ jsx(Type, { name: typeName, export: true, children: `ReturnType<typeof ${name}>` }) })
38
+ ] });
39
+ }
40
+ QueryKey.getParams = getParams;
41
+ function getParams2({ pathParamsType, typeSchemas }) {
42
+ return FunctionParams.factory({
43
+ pathParams: {
44
+ mode: pathParamsType === "object" ? "object" : "inlineSpread",
45
+ children: getPathParams(typeSchemas.pathParams, { typed: true })
46
+ },
47
+ data: typeSchemas.request?.name ? {
48
+ type: typeSchemas.request?.name,
49
+ optional: isOptional(typeSchemas.request?.schema)
50
+ } : void 0,
51
+ params: typeSchemas.queryParams?.name ? {
52
+ type: typeSchemas.queryParams?.name,
53
+ optional: isOptional(typeSchemas.queryParams?.schema)
54
+ } : void 0,
55
+ headers: typeSchemas.headerParams?.name ? {
56
+ type: typeSchemas.headerParams?.name,
57
+ optional: isOptional(typeSchemas.headerParams?.schema)
58
+ } : void 0,
59
+ config: {
60
+ type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : "Partial<RequestConfig>",
61
+ default: "{}"
62
+ }
63
+ });
64
+ }
65
+ function Client({
66
+ name,
67
+ isExportable = true,
68
+ isIndexable = true,
69
+ typeSchemas,
70
+ baseURL,
71
+ dataReturnType,
72
+ parser,
73
+ zodSchemas,
74
+ pathParamsType,
75
+ operation
76
+ }) {
77
+ const path = new URLPath(operation.path);
78
+ const contentType = operation.getContentType();
79
+ const isFormData = contentType === "multipart/form-data";
80
+ const headers = [
81
+ contentType !== "application/json" ? `'Content-Type': '${contentType}'` : void 0,
82
+ typeSchemas.headerParams?.name ? "...headers" : void 0
83
+ ].filter(Boolean);
84
+ const generics = [
85
+ typeSchemas.response.name,
86
+ typeSchemas.errors?.map((item) => item.name).join(" | ") || "unknown",
87
+ typeSchemas.request?.name || "unknown"
88
+ ].filter(Boolean);
89
+ const params = getParams2({ pathParamsType, typeSchemas });
90
+ const clientParams = FunctionParams.factory({
91
+ config: {
92
+ mode: "object",
93
+ children: {
94
+ method: {
95
+ value: JSON.stringify(operation.method)
96
+ },
97
+ url: {
98
+ value: path.template
99
+ },
100
+ baseURL: baseURL ? {
101
+ value: JSON.stringify(baseURL)
102
+ } : void 0,
103
+ params: typeSchemas.queryParams?.name ? {} : void 0,
104
+ data: typeSchemas.request?.name ? {
105
+ value: isFormData ? "formData" : void 0
106
+ } : void 0,
107
+ headers: headers.length ? {
108
+ value: headers.length ? `{ ${headers.join(", ")}, ...config.headers }` : void 0
109
+ } : void 0,
110
+ config: {
111
+ mode: "inlineSpread"
112
+ }
113
+ }
114
+ }
115
+ });
116
+ const formData = isFormData ? `
117
+ const formData = new FormData()
118
+ if(data) {
119
+ Object.keys(data).forEach((key) => {
120
+ const value = data[key];
121
+ if (typeof key === "string" && (typeof value === "string" || value instanceof Blob)) {
122
+ formData.append(key, value);
123
+ }
124
+ })
125
+ }
126
+ ` : "";
127
+ return /* @__PURE__ */ jsx(File.Source, { name, isExportable, isIndexable, children: /* @__PURE__ */ jsxs(
128
+ Function,
129
+ {
130
+ name,
131
+ async: true,
132
+ export: isExportable,
133
+ params: params.toConstructor(),
134
+ JSDoc: {
135
+ comments: getComments(operation)
136
+ },
137
+ children: [
138
+ formData,
139
+ `const res = await client<${generics.join(", ")}>(${clientParams.toCall()})`,
140
+ /* @__PURE__ */ jsx("br", {}),
141
+ dataReturnType === "full" && parser === "zod" && zodSchemas && `return {...res, data: ${zodSchemas.response.name}.parse(res.data)}`,
142
+ dataReturnType === "data" && parser === "zod" && zodSchemas && `return ${zodSchemas.response.name}.parse(res.data)`,
143
+ dataReturnType === "full" && parser === "client" && "return res",
144
+ dataReturnType === "data" && parser === "client" && "return res.data"
145
+ ]
146
+ }
147
+ ) });
148
+ }
149
+ Client.getParams = getParams2;
150
+ function Operations({ name, operations }) {
151
+ const operationsObject = {};
152
+ operations.forEach((operation) => {
153
+ operationsObject[operation.getOperationId()] = {
154
+ path: new URLPath(operation.path).URL,
155
+ method: operation.method
156
+ };
157
+ });
158
+ return /* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx(Const, { name, export: true, asConst: true, children: JSON.stringify(operationsObject, void 0, 2) }) });
159
+ }
160
+ function getParams3({ pathParamsType, typeSchemas }) {
161
+ return FunctionParams.factory({
162
+ pathParams: {
163
+ mode: pathParamsType === "object" ? "object" : "inlineSpread",
164
+ children: getPathParams(typeSchemas.pathParams, { typed: true })
165
+ },
166
+ data: typeSchemas.request?.name ? {
167
+ type: typeSchemas.request?.name,
168
+ optional: isOptional(typeSchemas.request?.schema)
169
+ } : void 0,
170
+ params: typeSchemas.queryParams?.name ? {
171
+ type: typeSchemas.queryParams?.name,
172
+ optional: isOptional(typeSchemas.queryParams?.schema)
173
+ } : void 0,
174
+ headers: typeSchemas.headerParams?.name ? {
175
+ type: typeSchemas.headerParams?.name,
176
+ optional: isOptional(typeSchemas.headerParams?.schema)
177
+ } : void 0,
178
+ config: {
179
+ type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : "Partial<RequestConfig>",
180
+ default: "{}"
181
+ }
182
+ });
183
+ }
184
+ function QueryOptions({ name, clientName, typeSchemas, pathParamsType, queryKeyName }) {
185
+ const params = getParams3({ pathParamsType, typeSchemas });
186
+ const clientParams = Client.getParams({
187
+ typeSchemas,
188
+ pathParamsType
189
+ });
190
+ const queryKeyParams = QueryKey.getParams({
191
+ pathParamsType,
192
+ typeSchemas
193
+ });
194
+ return /* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx(Function, { name, export: true, params: params.toConstructor(), children: `
195
+ const queryKey = ${queryKeyName}(${queryKeyParams.toCall()})
196
+ return queryOptions({
197
+ queryKey,
198
+ queryFn: async () => {
199
+ return ${clientName}(${clientParams.toCall()})
200
+ },
201
+ })
202
+ ` }) });
203
+ }
204
+ QueryOptions.getParams = getParams3;
205
+ function getParams4({ pathParamsType, dataReturnType, typeSchemas }) {
206
+ const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
207
+ return FunctionParams.factory({
208
+ pathParams: {
209
+ mode: pathParamsType === "object" ? "object" : "inlineSpread",
210
+ children: getPathParams(typeSchemas.pathParams, { typed: true })
211
+ },
212
+ data: typeSchemas.request?.name ? {
213
+ type: typeSchemas.request?.name,
214
+ optional: isOptional(typeSchemas.request?.schema)
215
+ } : void 0,
216
+ params: typeSchemas.queryParams?.name ? {
217
+ type: typeSchemas.queryParams?.name,
218
+ optional: isOptional(typeSchemas.queryParams?.schema)
219
+ } : void 0,
220
+ headers: typeSchemas.headerParams?.name ? {
221
+ type: typeSchemas.headerParams?.name,
222
+ optional: isOptional(typeSchemas.headerParams?.schema)
223
+ } : void 0,
224
+ options: {
225
+ type: `
226
+ {
227
+ query?: Partial<CreateBaseQueryOptions<${[TData, typeSchemas.errors?.map((item) => item.name).join(" | ") || "unknown", "TData", "TQueryData", "TQueryKey"].join(", ")}>>,
228
+ client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : "Partial<RequestConfig>"}
229
+ }
230
+ `,
231
+ default: "{}"
232
+ }
233
+ });
234
+ }
235
+ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, pathParamsType, dataReturnType, typeSchemas, operation }) {
236
+ const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
237
+ const returnType = `CreateQueryResult<${["TData", typeSchemas.errors?.map((item) => item.name).join(" | ") || "unknown"].join(", ")}> & { queryKey: TQueryKey }`;
238
+ const generics = [`TData = ${TData}`, `TQueryData = ${TData}`, `TQueryKey extends QueryKey = ${queryKeyTypeName}`];
239
+ const queryKeyParams = QueryKey.getParams({
240
+ pathParamsType,
241
+ typeSchemas
242
+ });
243
+ const queryOptionsParams = QueryOptions.getParams({
244
+ pathParamsType,
245
+ typeSchemas
246
+ });
247
+ const params = getParams4({
248
+ pathParamsType,
249
+ dataReturnType,
250
+ typeSchemas
251
+ });
252
+ const queryOptions = `${queryOptionsName}(${queryOptionsParams.toCall()}) as unknown as CreateBaseQueryOptions`;
253
+ return /* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx(
254
+ Function,
255
+ {
256
+ name,
257
+ export: true,
258
+ generics: generics.join(", "),
259
+ params: params.toConstructor(),
260
+ JSDoc: {
261
+ comments: getComments(operation)
262
+ },
263
+ children: `
264
+ const { query: queryOptions, client: config = {} } = options ?? {}
265
+ const queryKey = queryOptions?.queryKey ?? ${queryKeyName}(${queryKeyParams.toCall()})
266
+
267
+ const query = createQuery(() => ({
268
+ ...${queryOptions},
269
+ queryKey,
270
+ initialData: null,
271
+ ...queryOptions as unknown as Omit<CreateBaseQueryOptions, "queryKey">
272
+ })) as ${returnType}
273
+
274
+ query.queryKey = queryKey as TQueryKey
275
+
276
+ return query
277
+ `
278
+ }
279
+ ) });
280
+ }
281
+ Query.getParams = getParams4;
282
+
283
+ export { Client, Operations, Query, QueryKey, QueryOptions };
284
+ //# sourceMappingURL=chunk-D6TNFQR6.js.map
285
+ //# sourceMappingURL=chunk-D6TNFQR6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/QueryKey.tsx","../../plugin-client/src/components/Client.tsx","../../plugin-client/src/components/Operations.tsx","../src/components/QueryOptions.tsx","../src/components/Query.tsx"],"names":["name","getParams","FunctionParams","getPathParams","isOptional","URLPath","jsx","File","jsxs","Function","getComments"],"mappings":";;;;;;;AAuBA,SAAS,SAAU,CAAA,EAAE,cAAgB,EAAA,WAAA,EAA+B,EAAA;AAClE,EAAA,OAAO,eAAe,OAAQ,CAAA;AAAA,IAC5B,UAAY,EAAA;AAAA,MACV,IAAA,EAAM,cAAmB,KAAA,QAAA,GA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AA,WAAA,EAG9E,YAAY,CAAA;AAAA;AAAA;AAAA;AAAA,cAAA,EAIT,UAAU,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA,OAAA,CAAA;AAAA,KAAA;AAAA,GAOtB,EAAA,CAAA,CAAA;AAEJ,CAAA;AAEA,KAAA,CAAM,SAAYT,GAAAA,UAAAA","file":"chunk-D6TNFQR6.js","sourcesContent":["import { URLPath } from '@kubb/core/utils'\nimport { getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams, Type } from '@kubb/react'\n\nimport { type Operation, isOptional } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport type { ReactNode } from 'react'\nimport type { PluginSolidQuery } from '../types'\n\ntype Props = {\n name: string\n typeName: string\n typeSchemas: OperationSchemas\n operation: Operation\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n keysFn: ((keys: unknown[]) => unknown[]) | undefined\n}\n\ntype GetParamsProps = {\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ pathParamsType, typeSchemas }: GetParamsProps) {\n return FunctionParams.factory({\n pathParams: {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true }),\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\nexport function QueryKey({ name, typeSchemas, pathParamsType, operation, typeName, keysFn = (name) => name }: Props): ReactNode {\n const path = new URLPath(operation.path)\n const params = getParams({ pathParamsType, typeSchemas })\n const keys = [\n path.toObject({\n type: 'path',\n stringify: true,\n }),\n typeSchemas.queryParams?.name ? '...(params ? [params] : [])' : undefined,\n typeSchemas.request?.name ? '...(data ? [data] : [])' : undefined,\n ].filter(Boolean)\n\n return (\n <>\n <File.Source name={name} isExportable isIndexable>\n <Function.Arrow name={name} export params={params.toConstructor()} singleLine>\n {`[${keysFn(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\n","import { URLPath } from '@kubb/core/utils'\n\nimport { type Operation, isOptional } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getComments, getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams } from '@kubb/react'\nimport type { KubbNode } from '@kubb/react/types'\nimport type { PluginClient } from '../types.ts'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n isExportable?: boolean\n isIndexable?: boolean\n\n baseURL: string | undefined\n dataReturnType: PluginClient['resolvedOptions']['dataReturnType']\n pathParamsType: PluginClient['resolvedOptions']['pathParamsType']\n parser: PluginClient['resolvedOptions']['parser'] | undefined\n typeSchemas: OperationSchemas\n zodSchemas: OperationSchemas | undefined\n operation: Operation\n}\n\ntype GetParamsProps = {\n pathParamsType: PluginClient['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ pathParamsType, typeSchemas }: GetParamsProps) {\n return FunctionParams.factory({\n pathParams: {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true }),\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 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 ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : 'Partial<RequestConfig>',\n default: '{}',\n },\n })\n}\n\nexport function Client({\n name,\n isExportable = true,\n isIndexable = true,\n typeSchemas,\n baseURL,\n dataReturnType,\n parser,\n zodSchemas,\n pathParamsType,\n operation,\n}: Props): KubbNode {\n const path = new URLPath(operation.path)\n const contentType = operation.getContentType()\n const isFormData = contentType === 'multipart/form-data'\n const headers = [\n contentType !== 'application/json' ? `'Content-Type': '${contentType}'` : undefined,\n typeSchemas.headerParams?.name ? '...headers' : undefined,\n ].filter(Boolean)\n\n const generics = [\n typeSchemas.response.name,\n typeSchemas.errors?.map((item) => item.name).join(' | ') || 'unknown',\n typeSchemas.request?.name || 'unknown',\n ].filter(Boolean)\n const params = getParams({ pathParamsType, typeSchemas })\n const clientParams = FunctionParams.factory({\n config: {\n mode: 'object',\n children: {\n method: {\n value: JSON.stringify(operation.method),\n },\n url: {\n value: path.template,\n },\n baseURL: baseURL\n ? {\n value: JSON.stringify(baseURL),\n }\n : undefined,\n params: typeSchemas.queryParams?.name ? {} : undefined,\n data: typeSchemas.request?.name\n ? {\n value: isFormData ? 'formData' : undefined,\n }\n : undefined,\n headers: headers.length\n ? {\n value: headers.length ? `{ ${headers.join(', ')}, ...config.headers }` : undefined,\n }\n : undefined,\n config: {\n mode: 'inlineSpread',\n },\n },\n },\n })\n\n const formData = isFormData\n ? `\n const formData = new FormData()\n if(data) {\n Object.keys(data).forEach((key) => {\n const value = data[key];\n if (typeof key === \"string\" && (typeof value === \"string\" || value instanceof Blob)) {\n formData.append(key, value);\n }\n })\n }\n `\n : ''\n\n return (\n <File.Source name={name} isExportable={isExportable} isIndexable={isIndexable}>\n <Function\n name={name}\n async\n export={isExportable}\n params={params.toConstructor()}\n JSDoc={{\n comments: getComments(operation),\n }}\n >\n {formData}\n {`const res = await client<${generics.join(', ')}>(${clientParams.toCall()})`}\n <br />\n {dataReturnType === 'full' && parser === 'zod' && zodSchemas && `return {...res, data: ${zodSchemas.response.name}.parse(res.data)}`}\n {dataReturnType === 'data' && parser === 'zod' && zodSchemas && `return ${zodSchemas.response.name}.parse(res.data)`}\n {dataReturnType === 'full' && parser === 'client' && 'return res'}\n {dataReturnType === 'data' && parser === 'client' && 'return res.data'}\n </Function>\n </File.Source>\n )\n}\n\nClient.getParams = getParams\n","import { URLPath } from '@kubb/core/utils'\nimport { Const, File } from '@kubb/react'\n\nimport type { HttpMethod, Operation } from '@kubb/oas'\n\ntype OperationsProps = {\n name: string\n operations: Array<Operation>\n}\n\nexport function Operations({ name, operations }: OperationsProps) {\n const operationsObject: Record<string, { path: string; method: HttpMethod }> = {}\n\n operations.forEach((operation) => {\n operationsObject[operation.getOperationId()] = {\n path: new URLPath(operation.path).URL,\n method: operation.method,\n }\n })\n\n return (\n <File.Source name={name} isExportable isIndexable>\n <Const name={name} export asConst>\n {JSON.stringify(operationsObject, undefined, 2)}\n </Const>\n </File.Source>\n )\n}\n","import { getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams } from '@kubb/react'\n\nimport type { ReactNode } from 'react'\n\nimport { isOptional } from '@kubb/oas'\nimport { Client } from '@kubb/plugin-client/components'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport type { PluginSolidQuery } from '../types.ts'\nimport { QueryKey } from './QueryKey.tsx'\n\ntype Props = {\n name: string\n clientName: string\n queryKeyName: string\n typeSchemas: OperationSchemas\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n}\n\ntype GetParamsProps = {\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ pathParamsType, typeSchemas }: GetParamsProps) {\n return FunctionParams.factory({\n pathParams: {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true }),\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 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 ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : 'Partial<RequestConfig>',\n default: '{}',\n },\n })\n}\n\nexport function QueryOptions({ name, clientName, typeSchemas, pathParamsType, queryKeyName }: Props): ReactNode {\n const params = getParams({ pathParamsType, typeSchemas })\n const clientParams = Client.getParams({\n typeSchemas,\n pathParamsType,\n })\n const queryKeyParams = QueryKey.getParams({\n pathParamsType,\n typeSchemas,\n })\n\n return (\n <File.Source name={name} isExportable isIndexable>\n <Function name={name} export params={params.toConstructor()}>\n {`\n const queryKey = ${queryKeyName}(${queryKeyParams.toCall()})\n return queryOptions({\n queryKey,\n queryFn: async () => {\n return ${clientName}(${clientParams.toCall()})\n },\n })\n`}\n </Function>\n </File.Source>\n )\n}\n\nQueryOptions.getParams = getParams\n","import { File, Function, FunctionParams } from '@kubb/react'\n\nimport { type Operation, isOptional } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getComments, getPathParams } from '@kubb/plugin-oas/utils'\nimport type { ReactNode } from 'react'\nimport type { PluginSolidQuery } from '../types.ts'\nimport { QueryKey } from './QueryKey.tsx'\nimport { QueryOptions } from './QueryOptions.tsx'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n queryOptionsName: string\n queryKeyName: string\n queryKeyTypeName: string\n typeSchemas: OperationSchemas\n operation: Operation\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n dataReturnType: PluginSolidQuery['resolvedOptions']['client']['dataReturnType']\n}\n\ntype GetParamsProps = {\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n dataReturnType: PluginSolidQuery['resolvedOptions']['client']['dataReturnType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ pathParamsType, dataReturnType, typeSchemas }: GetParamsProps) {\n const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`\n\n return FunctionParams.factory({\n pathParams: {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true }),\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 headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n options: {\n type: `\n{\n query?: Partial<CreateBaseQueryOptions<${[TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || 'unknown', 'TData', 'TQueryData', 'TQueryKey'].join(', ')}>>,\n client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : 'Partial<RequestConfig>'}\n}\n`,\n default: '{}',\n },\n })\n}\n\nexport function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, pathParamsType, dataReturnType, typeSchemas, operation }: Props): ReactNode {\n const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`\n const returnType = `CreateQueryResult<${['TData', typeSchemas.errors?.map((item) => item.name).join(' | ') || 'unknown'].join(', ')}> & { queryKey: TQueryKey }`\n const generics = [`TData = ${TData}`, `TQueryData = ${TData}`, `TQueryKey extends QueryKey = ${queryKeyTypeName}`]\n\n const queryKeyParams = QueryKey.getParams({\n pathParamsType,\n typeSchemas,\n })\n const queryOptionsParams = QueryOptions.getParams({\n pathParamsType,\n typeSchemas,\n })\n const params = getParams({\n pathParamsType,\n dataReturnType,\n typeSchemas,\n })\n\n const queryOptions = `${queryOptionsName}(${queryOptionsParams.toCall()}) as unknown as CreateBaseQueryOptions`\n\n return (\n <File.Source name={name} isExportable isIndexable>\n <Function\n name={name}\n export\n generics={generics.join(', ')}\n params={params.toConstructor()}\n JSDoc={{\n comments: getComments(operation),\n }}\n >\n {`\n const { query: queryOptions, client: config = {} } = options ?? {}\n const queryKey = queryOptions?.queryKey ?? ${queryKeyName}(${queryKeyParams.toCall()})\n\n const query = createQuery(() => ({\n ...${queryOptions},\n queryKey,\n initialData: null,\n ...queryOptions as unknown as Omit<CreateBaseQueryOptions, \"queryKey\">\n })) as ${returnType}\n\n query.queryKey = queryKey as TQueryKey\n\n return query\n `}\n </Function>\n </File.Source>\n )\n}\n\nQuery.getParams = getParams\n"]}
@@ -0,0 +1,298 @@
1
+ 'use strict';
2
+
3
+ var chunkWIE2QWZT_cjs = require('./chunk-WIE2QWZT.cjs');
4
+ var transformers = require('@kubb/core/transformers');
5
+ var path = require('path');
6
+ var core = require('@kubb/core');
7
+ var utils = require('@kubb/core/utils');
8
+ var pluginOas = require('@kubb/plugin-oas');
9
+ var pluginZod = require('@kubb/plugin-zod');
10
+ var hooks = require('@kubb/plugin-oas/hooks');
11
+ var pluginTs = require('@kubb/plugin-ts');
12
+ var react = require('@kubb/react');
13
+ var jsxRuntime = require('@kubb/react/jsx-runtime');
14
+
15
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
16
+
17
+ var transformers__default = /*#__PURE__*/_interopDefault(transformers);
18
+ var path__default = /*#__PURE__*/_interopDefault(path);
19
+
20
+ var clientGenerator = pluginOas.createReactGenerator({
21
+ name: "client",
22
+ Operation({ options, operation }) {
23
+ const {
24
+ plugin: {
25
+ options: { output }
26
+ }
27
+ } = react.useApp();
28
+ const { getSchemas, getName, getFile } = hooks.useOperationManager();
29
+ const client = {
30
+ name: getName(operation, { type: "function" }),
31
+ file: getFile(operation)
32
+ };
33
+ const type = {
34
+ file: getFile(operation, { pluginKey: [pluginTs.pluginTsName] }),
35
+ schemas: getSchemas(operation, { pluginKey: [pluginTs.pluginTsName], type: "type" })
36
+ };
37
+ const zod = {
38
+ file: getFile(operation, { pluginKey: [pluginZod.pluginZodName] }),
39
+ schemas: getSchemas(operation, { pluginKey: [pluginZod.pluginZodName], type: "function" })
40
+ };
41
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.File, { baseName: client.file.baseName, path: client.file.path, meta: client.file.meta, banner: output?.banner, footer: output?.footer, children: [
42
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: "client", path: options.importPath }),
43
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["RequestConfig"], path: options.importPath, isTypeOnly: true }),
44
+ options.parser === "zod" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { extName: output?.extName, name: [zod.schemas.response.name], root: client.file.path, path: zod.file.path }),
45
+ /* @__PURE__ */ jsxRuntime.jsx(
46
+ react.File.Import,
47
+ {
48
+ extName: output?.extName,
49
+ name: [
50
+ type.schemas.request?.name,
51
+ type.schemas.response.name,
52
+ type.schemas.pathParams?.name,
53
+ type.schemas.queryParams?.name,
54
+ type.schemas.headerParams?.name,
55
+ ...type.schemas.statusCodes?.map((item) => item.name) || []
56
+ ].filter(Boolean),
57
+ root: client.file.path,
58
+ path: type.file.path,
59
+ isTypeOnly: true
60
+ }
61
+ ),
62
+ /* @__PURE__ */ jsxRuntime.jsx(
63
+ chunkWIE2QWZT_cjs.Client,
64
+ {
65
+ name: client.name,
66
+ baseURL: options.baseURL,
67
+ dataReturnType: options.dataReturnType,
68
+ pathParamsType: options.pathParamsType,
69
+ typeSchemas: type.schemas,
70
+ operation,
71
+ parser: options.parser,
72
+ zodSchemas: zod.schemas
73
+ }
74
+ )
75
+ ] });
76
+ }
77
+ });
78
+ var operationsGenerator = pluginOas.createReactGenerator({
79
+ name: "client",
80
+ Operations({ operations }) {
81
+ const {
82
+ pluginManager,
83
+ plugin: {
84
+ options: { output }
85
+ }
86
+ } = react.useApp();
87
+ const name = "operations";
88
+ const file = pluginManager.getFile({ name, extName: ".ts", pluginKey: [pluginClientName] });
89
+ return /* @__PURE__ */ jsxRuntime.jsx(react.File, { baseName: file.baseName, path: file.path, meta: file.meta, banner: output?.banner, footer: output?.footer, children: /* @__PURE__ */ jsxRuntime.jsx(chunkWIE2QWZT_cjs.Operations, { name, operations }) });
90
+ }
91
+ });
92
+
93
+ // ../plugin-client/src/plugin.ts
94
+ var pluginClientName = "plugin-client";
95
+ core.createPlugin((options) => {
96
+ const {
97
+ output = { path: "clients" },
98
+ group,
99
+ exclude = [],
100
+ include,
101
+ override = [],
102
+ transformers: transformers2 = {},
103
+ dataReturnType = "data",
104
+ pathParamsType = "inline",
105
+ operations = false,
106
+ importPath = "@kubb/plugin-client/client",
107
+ parser = "client"
108
+ } = options;
109
+ const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`;
110
+ return {
111
+ name: pluginClientName,
112
+ options: {
113
+ output: {
114
+ exportType: "barrelNamed",
115
+ ...output
116
+ },
117
+ parser,
118
+ dataReturnType,
119
+ importPath,
120
+ pathParamsType,
121
+ baseURL: void 0
122
+ },
123
+ pre: [pluginOas.pluginOasName, parser === "zod" ? pluginZod.pluginZodName : void 0].filter(Boolean),
124
+ resolvePath(baseName, pathMode, options2) {
125
+ const root = path__default.default.resolve(this.config.root, this.config.output.path);
126
+ const mode = pathMode ?? core.FileManager.getMode(path__default.default.resolve(root, output.path));
127
+ if (mode === "single") {
128
+ return path__default.default.resolve(root, output.path);
129
+ }
130
+ if (options2?.tag && group?.type === "tag") {
131
+ const tag = transformers.camelCase(options2.tag);
132
+ return path__default.default.resolve(root, utils.renderTemplate(template, { tag }), baseName);
133
+ }
134
+ return path__default.default.resolve(root, output.path, baseName);
135
+ },
136
+ resolveName(name, type) {
137
+ const resolvedName = transformers.camelCase(name, { isFile: type === "file" });
138
+ if (type) {
139
+ return transformers2?.name?.(resolvedName, type) || resolvedName;
140
+ }
141
+ return resolvedName;
142
+ },
143
+ async buildStart() {
144
+ const [swaggerPlugin] = core.PluginManager.getDependedPlugins(this.plugins, [pluginOas.pluginOasName]);
145
+ const oas = await swaggerPlugin.context.getOas();
146
+ const root = path__default.default.resolve(this.config.root, this.config.output.path);
147
+ const mode = core.FileManager.getMode(path__default.default.resolve(root, output.path));
148
+ const baseURL = await swaggerPlugin.context.getBaseURL();
149
+ const operationGenerator = new pluginOas.OperationGenerator(
150
+ {
151
+ ...this.plugin.options,
152
+ baseURL
153
+ },
154
+ {
155
+ oas,
156
+ pluginManager: this.pluginManager,
157
+ plugin: this.plugin,
158
+ contentType: swaggerPlugin.context.contentType,
159
+ exclude,
160
+ include,
161
+ override,
162
+ mode
163
+ }
164
+ );
165
+ const files = await operationGenerator.build(...[clientGenerator, operations ? operationsGenerator : void 0].filter(Boolean));
166
+ await this.addFile(...files);
167
+ if (this.config.output.exportType) {
168
+ const barrelFiles = await this.fileManager.getBarrelFiles({
169
+ root,
170
+ output,
171
+ files: this.fileManager.files,
172
+ meta: {
173
+ pluginKey: this.plugin.key
174
+ },
175
+ logger: this.logger
176
+ });
177
+ await this.addFile(...barrelFiles);
178
+ }
179
+ }
180
+ };
181
+ });
182
+ var queryGenerator = pluginOas.createReactGenerator({
183
+ name: "svelte-query",
184
+ Operation({ options, operation }) {
185
+ const {
186
+ plugin: {
187
+ options: { output }
188
+ }
189
+ } = react.useApp();
190
+ const { getSchemas, getName, getFile } = hooks.useOperationManager();
191
+ const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
192
+ const query = {
193
+ name: getName(operation, { type: "function", prefix: "create" }),
194
+ typeName: getName(operation, { type: "type" }),
195
+ file: getFile(operation, { prefix: "create" })
196
+ };
197
+ const client = {
198
+ name: getName(operation, { type: "function", pluginKey: [pluginClientName] })
199
+ };
200
+ const queryOptions = {
201
+ name: transformers__default.default.camelCase(`${operation.getOperationId()} QueryOptions`)
202
+ };
203
+ const queryKey = {
204
+ name: transformers__default.default.camelCase(`${operation.getOperationId()} QueryKey`),
205
+ typeName: transformers__default.default.pascalCase(`${operation.getOperationId()} QueryKey`)
206
+ };
207
+ const type = {
208
+ file: getFile(operation, { pluginKey: [pluginTs.pluginTsName] }),
209
+ //todo remove type?
210
+ schemas: getSchemas(operation, { pluginKey: [pluginTs.pluginTsName], type: "type" })
211
+ };
212
+ const zod = {
213
+ file: getFile(operation, { pluginKey: [pluginZod.pluginZodName] }),
214
+ schemas: getSchemas(operation, { pluginKey: [pluginZod.pluginZodName], type: "function" })
215
+ };
216
+ if (!isQuery || typeof options.query === "boolean") {
217
+ return null;
218
+ }
219
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.File, { baseName: query.file.baseName, path: query.file.path, meta: query.file.meta, banner: output?.banner, footer: output?.footer, children: [
220
+ options.parser === "zod" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { extName: output?.extName, name: [zod.schemas.response.name], root: query.file.path, path: zod.file.path }),
221
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["createQuery", "queryOptions"], path: options.query.importPath }),
222
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["QueryKey", "WithRequired", "CreateBaseQueryOptions", "CreateQueryResult"], path: options.query.importPath, isTypeOnly: true }),
223
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: "client", path: options.client.importPath }),
224
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["RequestConfig"], path: options.client.importPath, isTypeOnly: true }),
225
+ options.client.dataReturnType === "full" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
226
+ /* @__PURE__ */ jsxRuntime.jsx(
227
+ react.File.Import,
228
+ {
229
+ extName: output?.extName,
230
+ name: [
231
+ type.schemas.request?.name,
232
+ type.schemas.response.name,
233
+ type.schemas.pathParams?.name,
234
+ type.schemas.queryParams?.name,
235
+ type.schemas.headerParams?.name,
236
+ ...type.schemas.statusCodes?.map((item) => item.name) || []
237
+ ].filter(Boolean),
238
+ root: query.file.path,
239
+ path: type.file.path,
240
+ isTypeOnly: true
241
+ }
242
+ ),
243
+ /* @__PURE__ */ jsxRuntime.jsx(
244
+ chunkWIE2QWZT_cjs.QueryKey,
245
+ {
246
+ name: queryKey.name,
247
+ typeName: queryKey.typeName,
248
+ operation,
249
+ pathParamsType: options.pathParamsType,
250
+ typeSchemas: type.schemas,
251
+ keysFn: options.query.key
252
+ }
253
+ ),
254
+ /* @__PURE__ */ jsxRuntime.jsx(
255
+ chunkWIE2QWZT_cjs.Client,
256
+ {
257
+ name: client.name,
258
+ isExportable: false,
259
+ isIndexable: false,
260
+ baseURL: options.baseURL,
261
+ operation,
262
+ typeSchemas: type.schemas,
263
+ zodSchemas: zod.schemas,
264
+ dataReturnType: options.client.dataReturnType,
265
+ pathParamsType: options.pathParamsType,
266
+ parser: options.parser
267
+ }
268
+ ),
269
+ /* @__PURE__ */ jsxRuntime.jsx(
270
+ chunkWIE2QWZT_cjs.QueryOptions,
271
+ {
272
+ name: queryOptions.name,
273
+ clientName: client.name,
274
+ queryKeyName: queryKey.name,
275
+ typeSchemas: type.schemas,
276
+ pathParamsType: options.pathParamsType
277
+ }
278
+ ),
279
+ /* @__PURE__ */ jsxRuntime.jsx(
280
+ chunkWIE2QWZT_cjs.Query,
281
+ {
282
+ name: query.name,
283
+ queryOptionsName: queryOptions.name,
284
+ typeSchemas: type.schemas,
285
+ pathParamsType: options.pathParamsType,
286
+ operation,
287
+ dataReturnType: options.client.dataReturnType,
288
+ queryKeyName: queryKey.name,
289
+ queryKeyTypeName: queryKey.typeName
290
+ }
291
+ )
292
+ ] });
293
+ }
294
+ });
295
+
296
+ exports.queryGenerator = queryGenerator;
297
+ //# sourceMappingURL=chunk-KBTDHYL2.cjs.map
298
+ //# sourceMappingURL=chunk-KBTDHYL2.cjs.map