@kubb/plugin-solid-query 3.10.9 → 3.10.11
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/{chunk-P7PP4SS2.js → chunk-6MS45DTW.js} +10 -196
- package/dist/chunk-6MS45DTW.js.map +1 -0
- package/dist/chunk-DX7FN4CR.cjs +161 -0
- package/dist/chunk-DX7FN4CR.cjs.map +1 -0
- package/dist/chunk-EBY2GJUJ.js +159 -0
- package/dist/chunk-EBY2GJUJ.js.map +1 -0
- package/dist/{chunk-NUP5RKX7.cjs → chunk-J4MF3435.cjs} +18 -207
- package/dist/chunk-J4MF3435.cjs.map +1 -0
- package/dist/components.cjs +4 -4
- package/dist/components.d.cts +2 -1
- package/dist/components.d.ts +2 -1
- package/dist/components.js +1 -1
- package/dist/generators.cjs +3 -3
- package/dist/generators.d.cts +2 -1
- package/dist/generators.d.ts +2 -1
- package/dist/generators.js +2 -2
- package/dist/index.cjs +4 -4
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -2
- package/dist/types-Cx6RgBxP.d.cts +114 -0
- package/dist/types-Cx6RgBxP.d.ts +114 -0
- package/package.json +12 -11
- package/src/types.ts +2 -3
- package/dist/chunk-HBJIQLPC.cjs +0 -447
- package/dist/chunk-HBJIQLPC.cjs.map +0 -1
- package/dist/chunk-NUP5RKX7.cjs.map +0 -1
- package/dist/chunk-P7PP4SS2.js.map +0 -1
- package/dist/chunk-SE5LBLVZ.js +0 -441
- package/dist/chunk-SE5LBLVZ.js.map +0 -1
- package/dist/types-6ZuUeFA7.d.cts +0 -391
- package/dist/types-6ZuUeFA7.d.ts +0 -391
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { File, Function, Type, FunctionParams
|
|
1
|
+
import { File, Function, Type, FunctionParams } from '@kubb/react';
|
|
2
2
|
import { isOptional } from '@kubb/oas';
|
|
3
3
|
import { getComments, getPathParams } from '@kubb/plugin-oas/utils';
|
|
4
4
|
import { URLPath } from '@kubb/core/utils';
|
|
5
5
|
import { jsxs, Fragment, jsx } from '@kubb/react/jsx-runtime';
|
|
6
|
+
import { Client } from '@kubb/plugin-client/components';
|
|
6
7
|
|
|
7
8
|
// src/components/Query.tsx
|
|
8
9
|
function getParams({ pathParamsType, paramsCasing, typeSchemas }) {
|
|
@@ -48,193 +49,6 @@ function QueryKey({ name, typeSchemas, paramsCasing, pathParamsType, operation,
|
|
|
48
49
|
QueryKey.getParams = getParams;
|
|
49
50
|
QueryKey.getTransformer = getTransformer;
|
|
50
51
|
function getParams2({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
|
|
51
|
-
if (paramsType === "object") {
|
|
52
|
-
return FunctionParams.factory({
|
|
53
|
-
data: {
|
|
54
|
-
mode: "object",
|
|
55
|
-
children: {
|
|
56
|
-
...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing })
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
return FunctionParams.factory({
|
|
62
|
-
pathParams: typeSchemas.pathParams?.name ? {
|
|
63
|
-
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
64
|
-
children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
|
|
65
|
-
optional: isOptional(typeSchemas.pathParams?.schema)
|
|
66
|
-
} : void 0
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
function Url({ name, isExportable = true, isIndexable = true, typeSchemas, baseURL, paramsType, paramsCasing, pathParamsType, operation }) {
|
|
70
|
-
const path = new URLPath(operation.path, { casing: paramsCasing });
|
|
71
|
-
const params = getParams2({ paramsType, paramsCasing, pathParamsType, typeSchemas });
|
|
72
|
-
return /* @__PURE__ */ jsx(File.Source, { name, isExportable, isIndexable, children: /* @__PURE__ */ jsx(Function, { name, export: isExportable, params: params.toConstructor(), children: `return ${path.toTemplateString({ prefix: baseURL })} as const` }) });
|
|
73
|
-
}
|
|
74
|
-
Url.getParams = getParams2;
|
|
75
|
-
function getParams3({ paramsType, paramsCasing, pathParamsType, typeSchemas, isConfigurable }) {
|
|
76
|
-
if (paramsType === "object") {
|
|
77
|
-
return FunctionParams.factory({
|
|
78
|
-
data: {
|
|
79
|
-
mode: "object",
|
|
80
|
-
children: {
|
|
81
|
-
...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
|
|
82
|
-
data: typeSchemas.request?.name ? {
|
|
83
|
-
type: typeSchemas.request?.name,
|
|
84
|
-
optional: isOptional(typeSchemas.request?.schema)
|
|
85
|
-
} : void 0,
|
|
86
|
-
params: typeSchemas.queryParams?.name ? {
|
|
87
|
-
type: typeSchemas.queryParams?.name,
|
|
88
|
-
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
89
|
-
} : void 0,
|
|
90
|
-
headers: typeSchemas.headerParams?.name ? {
|
|
91
|
-
type: typeSchemas.headerParams?.name,
|
|
92
|
-
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
93
|
-
} : void 0
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
config: isConfigurable ? {
|
|
97
|
-
type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof client }` : "Partial<RequestConfig> & { client?: typeof client }",
|
|
98
|
-
default: "{}"
|
|
99
|
-
} : void 0
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
return FunctionParams.factory({
|
|
103
|
-
pathParams: typeSchemas.pathParams?.name ? {
|
|
104
|
-
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
105
|
-
children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
|
|
106
|
-
optional: isOptional(typeSchemas.pathParams?.schema)
|
|
107
|
-
} : void 0,
|
|
108
|
-
data: typeSchemas.request?.name ? {
|
|
109
|
-
type: typeSchemas.request?.name,
|
|
110
|
-
optional: isOptional(typeSchemas.request?.schema)
|
|
111
|
-
} : void 0,
|
|
112
|
-
params: typeSchemas.queryParams?.name ? {
|
|
113
|
-
type: typeSchemas.queryParams?.name,
|
|
114
|
-
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
115
|
-
} : void 0,
|
|
116
|
-
headers: typeSchemas.headerParams?.name ? {
|
|
117
|
-
type: typeSchemas.headerParams?.name,
|
|
118
|
-
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
119
|
-
} : void 0,
|
|
120
|
-
config: isConfigurable ? {
|
|
121
|
-
type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof client }` : "Partial<RequestConfig> & { client?: typeof client }",
|
|
122
|
-
default: "{}"
|
|
123
|
-
} : void 0
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
function Client({
|
|
127
|
-
name,
|
|
128
|
-
isExportable = true,
|
|
129
|
-
isIndexable = true,
|
|
130
|
-
returnType,
|
|
131
|
-
typeSchemas,
|
|
132
|
-
baseURL,
|
|
133
|
-
dataReturnType,
|
|
134
|
-
parser,
|
|
135
|
-
zodSchemas,
|
|
136
|
-
paramsType,
|
|
137
|
-
paramsCasing,
|
|
138
|
-
pathParamsType,
|
|
139
|
-
operation,
|
|
140
|
-
urlName,
|
|
141
|
-
children,
|
|
142
|
-
isConfigurable = true
|
|
143
|
-
}) {
|
|
144
|
-
const path = new URLPath(operation.path, { casing: paramsCasing });
|
|
145
|
-
const contentType = operation.getContentType();
|
|
146
|
-
const isFormData = contentType === "multipart/form-data";
|
|
147
|
-
const headers = [
|
|
148
|
-
contentType !== "application/json" ? `'Content-Type': '${contentType}'` : void 0,
|
|
149
|
-
typeSchemas.headerParams?.name ? "...headers" : void 0
|
|
150
|
-
].filter(Boolean);
|
|
151
|
-
const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
|
|
152
|
-
const generics = [typeSchemas.response.name, TError, typeSchemas.request?.name || "unknown"].filter(Boolean);
|
|
153
|
-
const params = getParams3({ paramsType, paramsCasing, pathParamsType, typeSchemas, isConfigurable });
|
|
154
|
-
const urlParams = Url.getParams({
|
|
155
|
-
paramsType,
|
|
156
|
-
paramsCasing,
|
|
157
|
-
pathParamsType,
|
|
158
|
-
typeSchemas
|
|
159
|
-
});
|
|
160
|
-
const clientParams = FunctionParams.factory({
|
|
161
|
-
config: {
|
|
162
|
-
mode: "object",
|
|
163
|
-
children: {
|
|
164
|
-
method: {
|
|
165
|
-
value: JSON.stringify(operation.method.toUpperCase())
|
|
166
|
-
},
|
|
167
|
-
url: {
|
|
168
|
-
value: urlName ? `${urlName}(${urlParams.toCall()}).toString()` : path.template
|
|
169
|
-
},
|
|
170
|
-
baseURL: baseURL && !urlName ? {
|
|
171
|
-
value: JSON.stringify(baseURL)
|
|
172
|
-
} : void 0,
|
|
173
|
-
params: typeSchemas.queryParams?.name ? {} : void 0,
|
|
174
|
-
data: typeSchemas.request?.name ? {
|
|
175
|
-
value: parser === "zod" && zodSchemas ? `${zodSchemas.request?.name}.parse(${isFormData ? "formData" : "data"})` : isFormData ? "formData" : void 0
|
|
176
|
-
} : void 0,
|
|
177
|
-
requestConfig: isConfigurable ? {
|
|
178
|
-
mode: "inlineSpread"
|
|
179
|
-
} : void 0,
|
|
180
|
-
headers: headers.length ? {
|
|
181
|
-
value: isConfigurable ? `{ ${headers.join(", ")}, ...requestConfig.headers }` : `{ ${headers.join(", ")} }`
|
|
182
|
-
} : void 0
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
const formData = isFormData ? `
|
|
187
|
-
const formData = new FormData()
|
|
188
|
-
if(data) {
|
|
189
|
-
Object.keys(data).forEach((key) => {
|
|
190
|
-
const value = data[key as keyof typeof data];
|
|
191
|
-
if (typeof key === "string" && (typeof value === "string" || (value as Blob) instanceof Blob)) {
|
|
192
|
-
formData.append(key, value as unknown as string);
|
|
193
|
-
}
|
|
194
|
-
})
|
|
195
|
-
}
|
|
196
|
-
` : "";
|
|
197
|
-
const childrenElement = children ? children : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
198
|
-
dataReturnType === "full" && parser === "zod" && zodSchemas && `return {...res, data: ${zodSchemas.response.name}.parse(res.data)}`,
|
|
199
|
-
dataReturnType === "data" && parser === "zod" && zodSchemas && `return ${zodSchemas.response.name}.parse(res.data)`,
|
|
200
|
-
dataReturnType === "full" && parser === "client" && "return res",
|
|
201
|
-
dataReturnType === "data" && parser === "client" && "return res.data"
|
|
202
|
-
] });
|
|
203
|
-
return /* @__PURE__ */ jsx(File.Source, { name, isExportable, isIndexable, children: /* @__PURE__ */ jsxs(
|
|
204
|
-
Function,
|
|
205
|
-
{
|
|
206
|
-
name,
|
|
207
|
-
async: true,
|
|
208
|
-
export: isExportable,
|
|
209
|
-
params: params.toConstructor(),
|
|
210
|
-
JSDoc: {
|
|
211
|
-
comments: getComments(operation)
|
|
212
|
-
},
|
|
213
|
-
returnType,
|
|
214
|
-
children: [
|
|
215
|
-
isConfigurable ? "const { client:request = client, ...requestConfig } = config" : "",
|
|
216
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
217
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
218
|
-
formData,
|
|
219
|
-
isConfigurable ? `const res = await request<${generics.join(", ")}>(${clientParams.toCall()})` : `const res = await client<${generics.join(", ")}>(${clientParams.toCall()})`,
|
|
220
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
221
|
-
childrenElement
|
|
222
|
-
]
|
|
223
|
-
}
|
|
224
|
-
) });
|
|
225
|
-
}
|
|
226
|
-
Client.getParams = getParams3;
|
|
227
|
-
function Operations({ name, operations }) {
|
|
228
|
-
const operationsObject = {};
|
|
229
|
-
operations.forEach((operation) => {
|
|
230
|
-
operationsObject[operation.getOperationId()] = {
|
|
231
|
-
path: new URLPath(operation.path).URL,
|
|
232
|
-
method: operation.method
|
|
233
|
-
};
|
|
234
|
-
});
|
|
235
|
-
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) }) });
|
|
236
|
-
}
|
|
237
|
-
function getParams4({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
|
|
238
52
|
if (paramsType === "object") {
|
|
239
53
|
return FunctionParams.factory({
|
|
240
54
|
data: {
|
|
@@ -288,7 +102,7 @@ function getParams4({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
|
|
|
288
102
|
function QueryOptions({ name, clientName, typeSchemas, paramsCasing, paramsType, dataReturnType, pathParamsType, queryKeyName }) {
|
|
289
103
|
const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
290
104
|
const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
|
|
291
|
-
const params =
|
|
105
|
+
const params = getParams2({ paramsType, paramsCasing, pathParamsType, typeSchemas });
|
|
292
106
|
const clientParams = Client.getParams({
|
|
293
107
|
paramsCasing,
|
|
294
108
|
typeSchemas,
|
|
@@ -315,8 +129,8 @@ function QueryOptions({ name, clientName, typeSchemas, paramsCasing, paramsType,
|
|
|
315
129
|
})
|
|
316
130
|
` }) });
|
|
317
131
|
}
|
|
318
|
-
QueryOptions.getParams =
|
|
319
|
-
function
|
|
132
|
+
QueryOptions.getParams = getParams2;
|
|
133
|
+
function getParams3({ paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas }) {
|
|
320
134
|
const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
321
135
|
const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
|
|
322
136
|
if (paramsType === "object") {
|
|
@@ -406,7 +220,7 @@ function Query({
|
|
|
406
220
|
pathParamsType,
|
|
407
221
|
typeSchemas
|
|
408
222
|
});
|
|
409
|
-
const params =
|
|
223
|
+
const params = getParams3({
|
|
410
224
|
paramsCasing,
|
|
411
225
|
paramsType,
|
|
412
226
|
pathParamsType,
|
|
@@ -442,8 +256,8 @@ function Query({
|
|
|
442
256
|
}
|
|
443
257
|
) });
|
|
444
258
|
}
|
|
445
|
-
Query.getParams =
|
|
259
|
+
Query.getParams = getParams3;
|
|
446
260
|
|
|
447
|
-
export {
|
|
448
|
-
//# sourceMappingURL=chunk-
|
|
449
|
-
//# sourceMappingURL=chunk-
|
|
261
|
+
export { Query, QueryKey, QueryOptions };
|
|
262
|
+
//# sourceMappingURL=chunk-6MS45DTW.js.map
|
|
263
|
+
//# sourceMappingURL=chunk-6MS45DTW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/QueryKey.tsx","../src/components/QueryOptions.tsx","../src/components/Query.tsx"],"names":["getParams","FunctionParams","getPathParams","isOptional","jsx","File","Function"],"mappings":";;;;;;;;AAyBA,SAAS,SAAU,CAAA,EAAE,cAAgB,EAAA,YAAA,EAAc,aAA+B,EAAA;AAChF,EAAA,OAAO,eAAe,OAAQ,CAAA;AAAA,IAC5B,UAAY,EAAA;AAAA,MACV,IAAA,EAAM,cAAmB,KAAA,QAAA,GAAW,QAAW,GAAA,cAAA;AAAA,MAC/C,QAAA,EAAU,cAAc,WAAY,CAAA,UAAA,EAAY,EAAE,KAAO,EAAA,IAAA,EAAM,MAAQ,EAAA,YAAA,EAAc;AAAA,KACvF;AAAA,IACA,IAAA,EAAM,WAAY,CAAA,OAAA,EAAS,IACvB,GAAA;AAAA,MACE,IAAA,EAAM,YAAY,OAAS,EAAA,IAAA;AAAA,MAC3B,QAAU,EAAA,UAAA,CAAW,WAAY,CAAA,OAAA,EAAS,MAAM;AAAA,KAElD,GAAA,MAAA;AAAA,IACJ,MAAA,EAAQ,WAAY,CAAA,WAAA,EAAa,IAC7B,GAAA;AAAA,MACE,IAAA,EAAM,YAAY,WAAa,EAAA,IAAA;AAAA,MAC/B,QAAU,EAAA,UAAA,CAAW,WAAY,CAAA,WAAA,EAAa,MAAM;AAAA,KAEtD,G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,CAAA;AAAA,IACvB,YAAA;AAAA,IACA,UAAA;AAAA,IACA,cAAA;AAAA,IACA,cAAA;AAAA,IACA;AAAA,GACD,CAAA;AAED,EAAA,MAAM,eAAe,CAAG,EAAA,gBAAgB,CAAI,CAAA,EAAA,kBAAA,CAAmB,QAAQ,CAAA,sCAAA,CAAA;AAEvE,EACE,uBAAAI,GAACC,CAAAA,IAAAA,CAAK,MAAL,EAAA,EAAY,MAAY,YAAY,EAAA,IAAA,EAAC,WAAW,EAAA,IAAA,EAC/C,QAAAD,kBAAAA,GAAAA;AAAA,IAACE,QAAAA;AAAA,IAAA;AAAA,MACC,IAAA;AAAA,MACA,MAAM,EAAA,IAAA;AAAA,MACN,QAAA,EAAU,QAAS,CAAA,IAAA,CAAK,IAAI,CAAA;AAAA,MAC5B,MAAA,EAAQ,OAAO,aAAc,EAAA;AAAA,MAC7B,KAAO,EAAA;AAAA,QACL,QAAA,EAAU,YAAY,SAAS;AAAA,OACjC;AAAA,MAEC,QAAA,EAAA;AAAA;AAAA,kDAAA,EAE2C,YAAY,CAAA,CAAA,EAAI,cAAe,CAAA,MAAA,EAAQ,CAAA;;AAAA;AAAA,WAAA,EAG9E,YAAY,CAAA;AAAA;AAAA;AAAA;AAAA,yDAAA,EAIkC,UAAU;;AAAA;;AAAA;AAAA,OAAA;AAAA;AAAA,GAOjE,EAAA,CAAA;AAEJ;AAEA,KAAA,CAAM,SAAYN,GAAAA,UAAAA","file":"chunk-6MS45DTW.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, Transformer } from '../types'\n\ntype Props = {\n name: string\n typeName: string\n typeSchemas: OperationSchemas\n operation: Operation\n paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n transformer: Transformer | undefined\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ pathParamsType, paramsCasing, typeSchemas }: GetParamsProps) {\n return FunctionParams.factory({\n pathParams: {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n },\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n })\n}\n\nconst getTransformer: Transformer = ({ operation, schemas, casing }) => {\n const path = new URLPath(operation.path, { casing })\n const keys = [\n path.toObject({\n type: 'path',\n stringify: true,\n }),\n schemas.queryParams?.name ? '...(params ? [params] : [])' : undefined,\n schemas.request?.name ? '...(data ? [data] : [])' : undefined,\n ].filter(Boolean)\n\n return keys\n}\n\nexport function QueryKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer = getTransformer }: Props): ReactNode {\n const params = getParams({ pathParamsType, paramsCasing, typeSchemas })\n const keys = transformer({\n operation,\n schemas: typeSchemas,\n casing: paramsCasing,\n })\n\n return (\n <>\n <File.Source name={name} isExportable isIndexable>\n <Function.Arrow name={name} export params={params.toConstructor()} singleLine>\n {`[${keys.join(', ')}] as const`}\n </Function.Arrow>\n </File.Source>\n <File.Source name={typeName} isExportable isIndexable isTypeOnly>\n <Type name={typeName} export>\n {`ReturnType<typeof ${name}>`}\n </Type>\n </File.Source>\n </>\n )\n}\n\nQueryKey.getParams = getParams\nQueryKey.getTransformer = getTransformer\n","import { getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams } from '@kubb/react'\n\nimport type { ReactNode } from 'react'\n\nimport { isOptional } from '@kubb/oas'\nimport { Client } from '@kubb/plugin-client/components'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport type { PluginSolidQuery } from '../types.ts'\nimport { QueryKey } from './QueryKey.tsx'\n\ntype Props = {\n name: string\n clientName: string\n queryKeyName: string\n typeSchemas: OperationSchemas\n paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']\n paramsType: PluginSolidQuery['resolvedOptions']['paramsType']\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n dataReturnType: PluginSolidQuery['resolvedOptions']['client']['dataReturnType']\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']\n paramsType: PluginSolidQuery['resolvedOptions']['paramsType']\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }: GetParamsProps) {\n if (paramsType === 'object') {\n return FunctionParams.factory({\n data: {\n mode: 'object',\n children: {\n ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n },\n },\n config: {\n type: typeSchemas.request?.name\n ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof client }`\n : 'Partial<RequestConfig> & { client?: typeof client }',\n default: '{}',\n },\n })\n }\n\n return FunctionParams.factory({\n pathParams: typeSchemas.pathParams?.name\n ? {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n optional: isOptional(typeSchemas.pathParams?.schema),\n }\n : undefined,\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n config: {\n type: typeSchemas.request?.name\n ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof client }`\n : 'Partial<RequestConfig> & { client?: typeof client }',\n default: '{}',\n },\n })\n}\n\nexport function QueryOptions({ name, clientName, typeSchemas, paramsCasing, paramsType, dataReturnType, pathParamsType, queryKeyName }: Props): ReactNode {\n const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`\n const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`\n\n const params = getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas })\n const clientParams = Client.getParams({\n paramsCasing,\n typeSchemas,\n paramsType,\n pathParamsType,\n isConfigurable: true,\n })\n const queryKeyParams = QueryKey.getParams({\n pathParamsType,\n paramsCasing,\n typeSchemas,\n })\n\n const enabled = Object.entries(queryKeyParams.flatParams)\n .map(([key, item]) => (item && !item.optional ? key : undefined))\n .filter(Boolean)\n .join('&& ')\n\n const enabledText = enabled ? `enabled: !!(${enabled}),` : ''\n\n return (\n <File.Source name={name} isExportable isIndexable>\n <Function name={name} export params={params.toConstructor()}>\n {`\n const queryKey = ${queryKeyName}(${queryKeyParams.toCall()})\n return queryOptions<${TData}, ${TError}, ${TData}, typeof queryKey>({\n ${enabledText}\n queryKey,\n queryFn: async ({ signal }) => {\n config.signal = signal\n return ${clientName}(${clientParams.toCall()})\n },\n })\n`}\n </Function>\n </File.Source>\n )\n}\n\nQueryOptions.getParams = getParams\n","import { 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 paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']\n paramsType: PluginSolidQuery['resolvedOptions']['paramsType']\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n dataReturnType: PluginSolidQuery['resolvedOptions']['client']['dataReturnType']\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']\n paramsType: PluginSolidQuery['resolvedOptions']['paramsType']\n pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']\n dataReturnType: PluginSolidQuery['resolvedOptions']['client']['dataReturnType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas }: GetParamsProps) {\n const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`\n const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`\n\n if (paramsType === 'object') {\n return FunctionParams.factory({\n data: {\n mode: 'object',\n children: {\n ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n },\n },\n options: {\n type: `\n{\n query?: Partial<CreateBaseQueryOptions<${[TData, TError, 'TData', 'TQueryData', 'TQueryKey'].join(', ')}>> & { client?: QueryClient },\n client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof client }` : 'Partial<RequestConfig> & { client?: typeof client }'}\n}\n`,\n default: '{}',\n },\n })\n }\n\n return FunctionParams.factory({\n pathParams: typeSchemas.pathParams?.name\n ? {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n optional: isOptional(typeSchemas.pathParams?.schema),\n }\n : undefined,\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n options: {\n type: `\n{\n query?: Partial<CreateBaseQueryOptions<${[TData, TError, 'TData', 'TQueryData', 'TQueryKey'].join(', ')}>> & { client?: QueryClient },\n client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof client }` : 'Partial<RequestConfig> & { client?: typeof client }'}\n}\n`,\n default: '{}',\n },\n })\n}\n\nexport function Query({\n name,\n queryKeyTypeName,\n queryOptionsName,\n queryKeyName,\n paramsCasing,\n paramsType,\n pathParamsType,\n dataReturnType,\n typeSchemas,\n operation,\n}: Props): ReactNode {\n const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`\n const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`\n const returnType = `CreateQueryResult<${['TData', TError].join(', ')}> & { queryKey: TQueryKey }`\n const generics = [`TData = ${TData}`, `TQueryData = ${TData}`, `TQueryKey extends QueryKey = ${queryKeyTypeName}`]\n\n const queryKeyParams = QueryKey.getParams({\n pathParamsType,\n typeSchemas,\n paramsCasing,\n })\n const queryOptionsParams = QueryOptions.getParams({\n paramsType,\n paramsCasing,\n pathParamsType,\n typeSchemas,\n })\n const params = getParams({\n paramsCasing,\n paramsType,\n pathParamsType,\n dataReturnType,\n typeSchemas,\n })\n\n const queryOptions = `${queryOptionsName}(${queryOptionsParams.toCall()}) as unknown as 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: { client: queryClient, ...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 }), queryClient? () => queryClient: undefined) 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,161 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkJ4MF3435_cjs = require('./chunk-J4MF3435.cjs');
|
|
4
|
+
var pluginClient = require('@kubb/plugin-client');
|
|
5
|
+
var components = require('@kubb/plugin-client/components');
|
|
6
|
+
var pluginOas = require('@kubb/plugin-oas');
|
|
7
|
+
var hooks = require('@kubb/plugin-oas/hooks');
|
|
8
|
+
var utils = require('@kubb/plugin-oas/utils');
|
|
9
|
+
var pluginTs = require('@kubb/plugin-ts');
|
|
10
|
+
var pluginZod = require('@kubb/plugin-zod');
|
|
11
|
+
var react = require('@kubb/react');
|
|
12
|
+
var remeda = require('remeda');
|
|
13
|
+
var jsxRuntime = require('@kubb/react/jsx-runtime');
|
|
14
|
+
|
|
15
|
+
var queryGenerator = pluginOas.createReactGenerator({
|
|
16
|
+
name: "svelte-query",
|
|
17
|
+
Operation({ options, operation }) {
|
|
18
|
+
const {
|
|
19
|
+
plugin: {
|
|
20
|
+
options: { output }
|
|
21
|
+
},
|
|
22
|
+
pluginManager
|
|
23
|
+
} = react.useApp();
|
|
24
|
+
const oas = hooks.useOas();
|
|
25
|
+
const { getSchemas, getName, getFile } = hooks.useOperationManager();
|
|
26
|
+
const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
|
|
27
|
+
const isMutation = remeda.difference(["post", "put", "delete", "patch"], options.query ? options.query.methods : []).some((method) => operation.method === method);
|
|
28
|
+
const importPath = options.query ? options.query.importPath : "@tanstack/solid-query";
|
|
29
|
+
const query = {
|
|
30
|
+
name: getName(operation, { type: "function", prefix: "create" }),
|
|
31
|
+
typeName: getName(operation, { type: "type" }),
|
|
32
|
+
file: getFile(operation, { prefix: "create" })
|
|
33
|
+
};
|
|
34
|
+
const hasClientPlugin = !!pluginManager.getPluginByKey([pluginClient.pluginClientName]);
|
|
35
|
+
const client = {
|
|
36
|
+
name: hasClientPlugin ? getName(operation, {
|
|
37
|
+
type: "function",
|
|
38
|
+
pluginKey: [pluginClient.pluginClientName]
|
|
39
|
+
}) : getName(operation, {
|
|
40
|
+
type: "function"
|
|
41
|
+
}),
|
|
42
|
+
file: getFile(operation, { pluginKey: [pluginClient.pluginClientName] })
|
|
43
|
+
};
|
|
44
|
+
const queryOptions = {
|
|
45
|
+
name: getName(operation, { type: "function", suffix: "QueryOptions" })
|
|
46
|
+
};
|
|
47
|
+
const queryKey = {
|
|
48
|
+
name: getName(operation, { type: "const", suffix: "QueryKey" }),
|
|
49
|
+
typeName: getName(operation, { type: "type", suffix: "QueryKey" })
|
|
50
|
+
};
|
|
51
|
+
const type = {
|
|
52
|
+
file: getFile(operation, { pluginKey: [pluginTs.pluginTsName] }),
|
|
53
|
+
//todo remove type?
|
|
54
|
+
schemas: getSchemas(operation, { pluginKey: [pluginTs.pluginTsName], type: "type" })
|
|
55
|
+
};
|
|
56
|
+
const zod = {
|
|
57
|
+
file: getFile(operation, { pluginKey: [pluginZod.pluginZodName] }),
|
|
58
|
+
schemas: getSchemas(operation, { pluginKey: [pluginZod.pluginZodName], type: "function" })
|
|
59
|
+
};
|
|
60
|
+
if (!isQuery || isMutation) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
64
|
+
react.File,
|
|
65
|
+
{
|
|
66
|
+
baseName: query.file.baseName,
|
|
67
|
+
path: query.file.path,
|
|
68
|
+
meta: query.file.meta,
|
|
69
|
+
banner: utils.getBanner({ oas, output, config: pluginManager.config }),
|
|
70
|
+
footer: utils.getFooter({ oas, output }),
|
|
71
|
+
children: [
|
|
72
|
+
options.parser === "zod" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean), root: query.file.path, path: zod.file.path }),
|
|
73
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: "client", path: options.client.importPath }),
|
|
74
|
+
!!hasClientPlugin && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [client.name], root: query.file.path, path: client.file.path }),
|
|
75
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["RequestConfig", "ResponseErrorConfig"], path: options.client.importPath, isTypeOnly: true }),
|
|
76
|
+
options.client.dataReturnType === "full" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
|
|
77
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
78
|
+
react.File.Import,
|
|
79
|
+
{
|
|
80
|
+
name: [
|
|
81
|
+
type.schemas.request?.name,
|
|
82
|
+
type.schemas.response.name,
|
|
83
|
+
type.schemas.pathParams?.name,
|
|
84
|
+
type.schemas.queryParams?.name,
|
|
85
|
+
type.schemas.headerParams?.name,
|
|
86
|
+
...type.schemas.statusCodes?.map((item) => item.name) || []
|
|
87
|
+
].filter(Boolean),
|
|
88
|
+
root: query.file.path,
|
|
89
|
+
path: type.file.path,
|
|
90
|
+
isTypeOnly: true
|
|
91
|
+
}
|
|
92
|
+
),
|
|
93
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
94
|
+
chunkJ4MF3435_cjs.QueryKey,
|
|
95
|
+
{
|
|
96
|
+
name: queryKey.name,
|
|
97
|
+
typeName: queryKey.typeName,
|
|
98
|
+
operation,
|
|
99
|
+
paramsCasing: options.paramsCasing,
|
|
100
|
+
pathParamsType: options.pathParamsType,
|
|
101
|
+
typeSchemas: type.schemas,
|
|
102
|
+
transformer: options.queryKey
|
|
103
|
+
}
|
|
104
|
+
),
|
|
105
|
+
!hasClientPlugin && /* @__PURE__ */ jsxRuntime.jsx(
|
|
106
|
+
components.Client,
|
|
107
|
+
{
|
|
108
|
+
name: client.name,
|
|
109
|
+
baseURL: options.client.baseURL,
|
|
110
|
+
operation,
|
|
111
|
+
typeSchemas: type.schemas,
|
|
112
|
+
zodSchemas: zod.schemas,
|
|
113
|
+
dataReturnType: options.client.dataReturnType,
|
|
114
|
+
paramsCasing: options.paramsCasing,
|
|
115
|
+
paramsType: options.paramsType,
|
|
116
|
+
pathParamsType: options.pathParamsType,
|
|
117
|
+
parser: options.parser
|
|
118
|
+
}
|
|
119
|
+
),
|
|
120
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["queryOptions"], path: importPath }),
|
|
121
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
122
|
+
chunkJ4MF3435_cjs.QueryOptions,
|
|
123
|
+
{
|
|
124
|
+
name: queryOptions.name,
|
|
125
|
+
clientName: client.name,
|
|
126
|
+
queryKeyName: queryKey.name,
|
|
127
|
+
typeSchemas: type.schemas,
|
|
128
|
+
paramsCasing: options.paramsCasing,
|
|
129
|
+
paramsType: options.paramsType,
|
|
130
|
+
pathParamsType: options.pathParamsType,
|
|
131
|
+
dataReturnType: options.client.dataReturnType
|
|
132
|
+
}
|
|
133
|
+
),
|
|
134
|
+
options.query && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
135
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["createQuery"], path: importPath }),
|
|
136
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["QueryKey", "QueryClient", "CreateBaseQueryOptions", "CreateQueryResult"], path: importPath, isTypeOnly: true }),
|
|
137
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
138
|
+
chunkJ4MF3435_cjs.Query,
|
|
139
|
+
{
|
|
140
|
+
name: query.name,
|
|
141
|
+
queryOptionsName: queryOptions.name,
|
|
142
|
+
typeSchemas: type.schemas,
|
|
143
|
+
paramsType: options.paramsType,
|
|
144
|
+
pathParamsType: options.pathParamsType,
|
|
145
|
+
operation,
|
|
146
|
+
paramsCasing: options.paramsCasing,
|
|
147
|
+
dataReturnType: options.client.dataReturnType,
|
|
148
|
+
queryKeyName: queryKey.name,
|
|
149
|
+
queryKeyTypeName: queryKey.typeName
|
|
150
|
+
}
|
|
151
|
+
)
|
|
152
|
+
] })
|
|
153
|
+
]
|
|
154
|
+
}
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
exports.queryGenerator = queryGenerator;
|
|
160
|
+
//# sourceMappingURL=chunk-DX7FN4CR.cjs.map
|
|
161
|
+
//# sourceMappingURL=chunk-DX7FN4CR.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/generators/queryGenerator.tsx"],"names":["createReactGenerator","useApp","useOas","useOperationManager","difference","pluginClientName","pluginTsName","pluginZodName","jsxs","File","getBanner","getFooter","jsx","QueryKey","Client","QueryOptions","Fragment","Query"],"mappings":";;;;;;;;;;;;;;AAYO,IAAM,iBAAiBA,8BAAuC,CAAA;AAAA,EACnE,IAAM,EAAA,cAAA;AAAA,EACN,SAAU,CAAA,EAAE,OAAS,EAAA,SAAA,EAAa,EAAA;AAChC,IAAM,MAAA;AAAA,MACJ,MAAQ,EAAA;AAAA,QACN,OAAA,EAAS,EAAE,MAAO;AAAA,OACpB;AAAA,MACA;AAAA,QACEC,YAAyB,EAAA;AAC7B,IAAA,MAAM,MAAMC,YAAO,EAAA;AACnB,IAAA,MAAM,EAAE,UAAA,EAAY,OAAS,EAAA,OAAA,KAAYC,yBAAoB,EAAA;AAE7D,IAAA,MAAM,OAAU,GAAA,OAAO,OAAQ,CAAA,KAAA,KAAU,YAAY,IAAO,GAAA,OAAA,CAAQ,KAAO,EAAA,OAAA,CAAQ,IAAK,CAAA,CAAC,MAAW,KAAA,SAAA,CAAU,WAAW,MAAM,CAAA;AAC/H,IAAM,MAAA,UAAA,GAAaC,kBAAW,CAAC,MAAA,EAAQ,OAAO,QAAU,EAAA,OAAO,GAAG,OAAQ,CAAA,KAAA,GAAQ,QAAQ,KAAM,CAAA,OAAA,GAAU,EAAE,CAAA,CAAE,KAAK,CAAC,MAAA,KAAW,SAAU,CAAA,MAAA,KAAW,MAAM,CAAA;AAC1J,IAAA,MAAM,UAAa,GAAA,OAAA,CAAQ,KAAQ,GAAA,OAAA,CAAQ,MAAM,UAAa,GAAA,uBAAA;AAE9D,IAAA,MAAM,KAAQ,GAAA;AAAA,MACZ,IAAA,EAAM,QAAQ,SAAW,EAAA,EAAE,MAAM,UAAY,EAAA,MAAA,EAAQ,UAAU,CAAA;AAAA,MAC/D,UAAU,OAAQ,CAAA,SAAA,EAAW,EAAE,IAAA,EAAM,QAAQ,CAAA;AAAA,MAC7C,MAAM,OAAQ,CAAA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AA,EAAY,MAAM,CAAC,UAAA,EAAY,aAAe,EAAA,wBAAA,EAA0B,mBAAmB,CAAA,EAAG,IAAM,EAAA,UAAA,EAAY,YAAU,IAAC,EAAA,CAAA;AAAA,4BAC5HG,cAAA;AAAA,cAACK,uBAAA;AAAA,cAAA;AAAA,gBACC,MAAM,KAAM,CAAA,IAAA;AAAA,gBACZ,kBAAkB,YAAa,CAAA,IAAA;AAAA,gBAC/B,aAAa,IAAK,CAAA,OAAA;AAAA,gBAClB,YAAY,OAAQ,CAAA,UAAA;AAAA,gBACpB,gBAAgB,OAAQ,CAAA,cAAA;AAAA,gBACxB,SAAA;AAAA,gBACA,cAAc,OAAQ,CAAA,YAAA;AAAA,gBACtB,cAAA,EAAgB,QAAQ,MAAO,CAAA,cAAA;AAAA,gBAC/B,cAAc,QAAS,CAAA,IAAA;AAAA,gBACvB,kBAAkB,QAAS,CAAA;AAAA;AAAA;AAC7B,WACF,EAAA;AAAA;AAAA;AAAA,KAEJ;AAAA;AAGN,CAAC","file":"chunk-DX7FN4CR.cjs","sourcesContent":["import { pluginClientName } from '@kubb/plugin-client'\nimport { Client } from '@kubb/plugin-client/components'\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File, useApp } from '@kubb/react'\nimport { difference } from 'remeda'\nimport { Query, QueryKey, QueryOptions } from '../components'\nimport type { PluginSolidQuery } from '../types'\n\nexport const queryGenerator = createReactGenerator<PluginSolidQuery>({\n name: 'svelte-query',\n Operation({ options, operation }) {\n const {\n plugin: {\n options: { output },\n },\n pluginManager,\n } = useApp<PluginSolidQuery>()\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const isQuery = typeof options.query === 'boolean' ? true : options.query?.methods.some((method) => operation.method === method)\n const isMutation = difference(['post', 'put', 'delete', 'patch'], options.query ? options.query.methods : []).some((method) => operation.method === method)\n const importPath = options.query ? options.query.importPath : '@tanstack/solid-query'\n\n const query = {\n name: getName(operation, { type: 'function', prefix: 'create' }),\n typeName: getName(operation, { type: 'type' }),\n file: getFile(operation, { prefix: 'create' }),\n }\n\n const hasClientPlugin = !!pluginManager.getPluginByKey([pluginClientName])\n const client = {\n name: hasClientPlugin\n ? getName(operation, {\n type: 'function',\n pluginKey: [pluginClientName],\n })\n : getName(operation, {\n type: 'function',\n }),\n file: getFile(operation, { pluginKey: [pluginClientName] }),\n }\n\n const queryOptions = {\n name: getName(operation, { type: 'function', suffix: 'QueryOptions' }),\n }\n\n const queryKey = {\n name: getName(operation, { type: 'const', suffix: 'QueryKey' }),\n typeName: getName(operation, { type: 'type', suffix: 'QueryKey' }),\n }\n\n const type = {\n file: getFile(operation, { pluginKey: [pluginTsName] }),\n //todo remove type?\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n }\n\n const zod = {\n file: getFile(operation, { pluginKey: [pluginZodName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' }),\n }\n\n if (!isQuery || isMutation) {\n return null\n }\n\n return (\n <File\n baseName={query.file.baseName}\n path={query.file.path}\n meta={query.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n {options.parser === 'zod' && (\n <File.Import name={[zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean)} root={query.file.path} path={zod.file.path} />\n )}\n <File.Import name={'client'} path={options.client.importPath} />\n {!!hasClientPlugin && <File.Import name={[client.name]} root={query.file.path} path={client.file.path} />}\n <File.Import name={['RequestConfig', 'ResponseErrorConfig']} path={options.client.importPath} isTypeOnly />\n {options.client.dataReturnType === 'full' && <File.Import name={['ResponseConfig']} path={options.client.importPath} isTypeOnly />}\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={query.file.path}\n path={type.file.path}\n isTypeOnly\n />\n <QueryKey\n name={queryKey.name}\n typeName={queryKey.typeName}\n operation={operation}\n paramsCasing={options.paramsCasing}\n pathParamsType={options.pathParamsType}\n typeSchemas={type.schemas}\n transformer={options.queryKey}\n />\n {!hasClientPlugin && (\n <Client\n name={client.name}\n baseURL={options.client.baseURL}\n operation={operation}\n typeSchemas={type.schemas}\n zodSchemas={zod.schemas}\n dataReturnType={options.client.dataReturnType}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n parser={options.parser}\n />\n )}\n <File.Import name={['queryOptions']} path={importPath} />\n <QueryOptions\n name={queryOptions.name}\n clientName={client.name}\n queryKeyName={queryKey.name}\n typeSchemas={type.schemas}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n dataReturnType={options.client.dataReturnType}\n />\n {options.query && (\n <>\n <File.Import name={['createQuery']} path={importPath} />\n <File.Import name={['QueryKey', 'QueryClient', 'CreateBaseQueryOptions', 'CreateQueryResult']} path={importPath} isTypeOnly />\n <Query\n name={query.name}\n queryOptionsName={queryOptions.name}\n typeSchemas={type.schemas}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n operation={operation}\n paramsCasing={options.paramsCasing}\n dataReturnType={options.client.dataReturnType}\n queryKeyName={queryKey.name}\n queryKeyTypeName={queryKey.typeName}\n />\n </>\n )}\n </File>\n )\n },\n})\n"]}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { QueryKey, QueryOptions, Query } from './chunk-6MS45DTW.js';
|
|
2
|
+
import { pluginClientName } from '@kubb/plugin-client';
|
|
3
|
+
import { Client } from '@kubb/plugin-client/components';
|
|
4
|
+
import { createReactGenerator } from '@kubb/plugin-oas';
|
|
5
|
+
import { useOas, useOperationManager } from '@kubb/plugin-oas/hooks';
|
|
6
|
+
import { getFooter, getBanner } from '@kubb/plugin-oas/utils';
|
|
7
|
+
import { pluginTsName } from '@kubb/plugin-ts';
|
|
8
|
+
import { pluginZodName } from '@kubb/plugin-zod';
|
|
9
|
+
import { useApp, File } from '@kubb/react';
|
|
10
|
+
import { difference } from 'remeda';
|
|
11
|
+
import { jsxs, jsx, Fragment } from '@kubb/react/jsx-runtime';
|
|
12
|
+
|
|
13
|
+
var queryGenerator = createReactGenerator({
|
|
14
|
+
name: "svelte-query",
|
|
15
|
+
Operation({ options, operation }) {
|
|
16
|
+
const {
|
|
17
|
+
plugin: {
|
|
18
|
+
options: { output }
|
|
19
|
+
},
|
|
20
|
+
pluginManager
|
|
21
|
+
} = useApp();
|
|
22
|
+
const oas = useOas();
|
|
23
|
+
const { getSchemas, getName, getFile } = useOperationManager();
|
|
24
|
+
const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
|
|
25
|
+
const isMutation = difference(["post", "put", "delete", "patch"], options.query ? options.query.methods : []).some((method) => operation.method === method);
|
|
26
|
+
const importPath = options.query ? options.query.importPath : "@tanstack/solid-query";
|
|
27
|
+
const query = {
|
|
28
|
+
name: getName(operation, { type: "function", prefix: "create" }),
|
|
29
|
+
typeName: getName(operation, { type: "type" }),
|
|
30
|
+
file: getFile(operation, { prefix: "create" })
|
|
31
|
+
};
|
|
32
|
+
const hasClientPlugin = !!pluginManager.getPluginByKey([pluginClientName]);
|
|
33
|
+
const client = {
|
|
34
|
+
name: hasClientPlugin ? getName(operation, {
|
|
35
|
+
type: "function",
|
|
36
|
+
pluginKey: [pluginClientName]
|
|
37
|
+
}) : getName(operation, {
|
|
38
|
+
type: "function"
|
|
39
|
+
}),
|
|
40
|
+
file: getFile(operation, { pluginKey: [pluginClientName] })
|
|
41
|
+
};
|
|
42
|
+
const queryOptions = {
|
|
43
|
+
name: getName(operation, { type: "function", suffix: "QueryOptions" })
|
|
44
|
+
};
|
|
45
|
+
const queryKey = {
|
|
46
|
+
name: getName(operation, { type: "const", suffix: "QueryKey" }),
|
|
47
|
+
typeName: getName(operation, { type: "type", suffix: "QueryKey" })
|
|
48
|
+
};
|
|
49
|
+
const type = {
|
|
50
|
+
file: getFile(operation, { pluginKey: [pluginTsName] }),
|
|
51
|
+
//todo remove type?
|
|
52
|
+
schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: "type" })
|
|
53
|
+
};
|
|
54
|
+
const zod = {
|
|
55
|
+
file: getFile(operation, { pluginKey: [pluginZodName] }),
|
|
56
|
+
schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: "function" })
|
|
57
|
+
};
|
|
58
|
+
if (!isQuery || isMutation) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
return /* @__PURE__ */ jsxs(
|
|
62
|
+
File,
|
|
63
|
+
{
|
|
64
|
+
baseName: query.file.baseName,
|
|
65
|
+
path: query.file.path,
|
|
66
|
+
meta: query.file.meta,
|
|
67
|
+
banner: getBanner({ oas, output, config: pluginManager.config }),
|
|
68
|
+
footer: getFooter({ oas, output }),
|
|
69
|
+
children: [
|
|
70
|
+
options.parser === "zod" && /* @__PURE__ */ jsx(File.Import, { name: [zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean), root: query.file.path, path: zod.file.path }),
|
|
71
|
+
/* @__PURE__ */ jsx(File.Import, { name: "client", path: options.client.importPath }),
|
|
72
|
+
!!hasClientPlugin && /* @__PURE__ */ jsx(File.Import, { name: [client.name], root: query.file.path, path: client.file.path }),
|
|
73
|
+
/* @__PURE__ */ jsx(File.Import, { name: ["RequestConfig", "ResponseErrorConfig"], path: options.client.importPath, isTypeOnly: true }),
|
|
74
|
+
options.client.dataReturnType === "full" && /* @__PURE__ */ jsx(File.Import, { name: ["ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
|
|
75
|
+
/* @__PURE__ */ jsx(
|
|
76
|
+
File.Import,
|
|
77
|
+
{
|
|
78
|
+
name: [
|
|
79
|
+
type.schemas.request?.name,
|
|
80
|
+
type.schemas.response.name,
|
|
81
|
+
type.schemas.pathParams?.name,
|
|
82
|
+
type.schemas.queryParams?.name,
|
|
83
|
+
type.schemas.headerParams?.name,
|
|
84
|
+
...type.schemas.statusCodes?.map((item) => item.name) || []
|
|
85
|
+
].filter(Boolean),
|
|
86
|
+
root: query.file.path,
|
|
87
|
+
path: type.file.path,
|
|
88
|
+
isTypeOnly: true
|
|
89
|
+
}
|
|
90
|
+
),
|
|
91
|
+
/* @__PURE__ */ jsx(
|
|
92
|
+
QueryKey,
|
|
93
|
+
{
|
|
94
|
+
name: queryKey.name,
|
|
95
|
+
typeName: queryKey.typeName,
|
|
96
|
+
operation,
|
|
97
|
+
paramsCasing: options.paramsCasing,
|
|
98
|
+
pathParamsType: options.pathParamsType,
|
|
99
|
+
typeSchemas: type.schemas,
|
|
100
|
+
transformer: options.queryKey
|
|
101
|
+
}
|
|
102
|
+
),
|
|
103
|
+
!hasClientPlugin && /* @__PURE__ */ jsx(
|
|
104
|
+
Client,
|
|
105
|
+
{
|
|
106
|
+
name: client.name,
|
|
107
|
+
baseURL: options.client.baseURL,
|
|
108
|
+
operation,
|
|
109
|
+
typeSchemas: type.schemas,
|
|
110
|
+
zodSchemas: zod.schemas,
|
|
111
|
+
dataReturnType: options.client.dataReturnType,
|
|
112
|
+
paramsCasing: options.paramsCasing,
|
|
113
|
+
paramsType: options.paramsType,
|
|
114
|
+
pathParamsType: options.pathParamsType,
|
|
115
|
+
parser: options.parser
|
|
116
|
+
}
|
|
117
|
+
),
|
|
118
|
+
/* @__PURE__ */ jsx(File.Import, { name: ["queryOptions"], path: importPath }),
|
|
119
|
+
/* @__PURE__ */ jsx(
|
|
120
|
+
QueryOptions,
|
|
121
|
+
{
|
|
122
|
+
name: queryOptions.name,
|
|
123
|
+
clientName: client.name,
|
|
124
|
+
queryKeyName: queryKey.name,
|
|
125
|
+
typeSchemas: type.schemas,
|
|
126
|
+
paramsCasing: options.paramsCasing,
|
|
127
|
+
paramsType: options.paramsType,
|
|
128
|
+
pathParamsType: options.pathParamsType,
|
|
129
|
+
dataReturnType: options.client.dataReturnType
|
|
130
|
+
}
|
|
131
|
+
),
|
|
132
|
+
options.query && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
133
|
+
/* @__PURE__ */ jsx(File.Import, { name: ["createQuery"], path: importPath }),
|
|
134
|
+
/* @__PURE__ */ jsx(File.Import, { name: ["QueryKey", "QueryClient", "CreateBaseQueryOptions", "CreateQueryResult"], path: importPath, isTypeOnly: true }),
|
|
135
|
+
/* @__PURE__ */ jsx(
|
|
136
|
+
Query,
|
|
137
|
+
{
|
|
138
|
+
name: query.name,
|
|
139
|
+
queryOptionsName: queryOptions.name,
|
|
140
|
+
typeSchemas: type.schemas,
|
|
141
|
+
paramsType: options.paramsType,
|
|
142
|
+
pathParamsType: options.pathParamsType,
|
|
143
|
+
operation,
|
|
144
|
+
paramsCasing: options.paramsCasing,
|
|
145
|
+
dataReturnType: options.client.dataReturnType,
|
|
146
|
+
queryKeyName: queryKey.name,
|
|
147
|
+
queryKeyTypeName: queryKey.typeName
|
|
148
|
+
}
|
|
149
|
+
)
|
|
150
|
+
] })
|
|
151
|
+
]
|
|
152
|
+
}
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
export { queryGenerator };
|
|
158
|
+
//# sourceMappingURL=chunk-EBY2GJUJ.js.map
|
|
159
|
+
//# sourceMappingURL=chunk-EBY2GJUJ.js.map
|