@kubb/plugin-msw 5.0.0-beta.42 → 5.0.0-beta.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{components-BW5VCVSO.cjs → components-BZ9KakZO.cjs} +69 -172
- package/dist/components-BZ9KakZO.cjs.map +1 -0
- package/dist/{components--3aER8iM.js → components-DNiDZfAv.js} +70 -167
- package/dist/components-DNiDZfAv.js.map +1 -0
- package/dist/components.cjs +1 -2
- package/dist/components.d.ts +1 -14
- package/dist/components.js +2 -2
- package/dist/{generators-B6qnyBTW.cjs → generators-CkGOweF4.cjs} +13 -11
- package/dist/generators-CkGOweF4.cjs.map +1 -0
- package/dist/{generators-CLKAZMic.js → generators-U8mPM19f.js} +14 -12
- package/dist/generators-U8mPM19f.js.map +1 -0
- package/dist/generators.cjs +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/generators.js +1 -1
- package/dist/index.cjs +36 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +36 -13
- package/dist/index.js.map +1 -1
- package/dist/{types-CwhQTrui.d.ts → types-Dxnur70I.d.ts} +11 -15
- package/package.json +9 -17
- package/dist/components--3aER8iM.js.map +0 -1
- package/dist/components-BW5VCVSO.cjs.map +0 -1
- package/dist/generators-B6qnyBTW.cjs.map +0 -1
- package/dist/generators-CLKAZMic.js.map +0 -1
- package/extension.yaml +0 -752
- package/src/components/Handlers.tsx +0 -19
- package/src/components/Mock.tsx +0 -71
- package/src/components/MockWithFaker.tsx +0 -70
- package/src/components/Response.tsx +0 -52
- package/src/components/index.ts +0 -4
- package/src/generators/handlersGenerator.tsx +0 -47
- package/src/generators/index.ts +0 -2
- package/src/generators/mswGenerator.tsx +0 -96
- package/src/index.ts +0 -2
- package/src/plugin.ts +0 -94
- package/src/resolvers/resolverMsw.ts +0 -35
- package/src/types.ts +0 -102
- package/src/utils.ts +0 -74
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import "./chunk-C0LytTxp.js";
|
|
2
2
|
import { ast } from "@kubb/core";
|
|
3
|
+
import "@kubb/ast/utils";
|
|
3
4
|
import { functionPrinter } from "@kubb/plugin-ts";
|
|
4
5
|
import { File, Function } from "@kubb/renderer-jsx";
|
|
5
6
|
import { jsx } from "@kubb/renderer-jsx/jsx-runtime";
|
|
@@ -14,35 +15,19 @@ import { jsx } from "@kubb/renderer-jsx/jsx-runtime";
|
|
|
14
15
|
function toCamelOrPascal(text, pascal) {
|
|
15
16
|
return text.trim().replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/(\d)([a-z])/g, "$1 $2").split(/[\s\-_./\\:]+/).filter(Boolean).map((word, i) => {
|
|
16
17
|
if (word.length > 1 && word === word.toUpperCase()) return word;
|
|
17
|
-
|
|
18
|
-
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
18
|
+
return (i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()) + word.slice(1);
|
|
19
19
|
}).join("").replace(/[^a-zA-Z0-9]/g, "");
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
|
-
* Splits `text` on `.` and applies `transformPart` to each segment.
|
|
23
|
-
* The last segment receives `isLast = true`, all earlier segments receive `false`.
|
|
24
|
-
* Segments are joined with `/` to form a file path.
|
|
25
|
-
*
|
|
26
|
-
* Only splits on dots followed by a letter so that version numbers
|
|
27
|
-
* embedded in operationIds (e.g. `v2025.0`) are kept intact.
|
|
28
|
-
*/
|
|
29
|
-
function applyToFileParts(text, transformPart) {
|
|
30
|
-
const parts = text.split(/\.(?=[a-zA-Z])/);
|
|
31
|
-
return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
22
|
* Converts `text` to camelCase.
|
|
35
|
-
* When `isFile` is `true`, dot-separated segments are each cased independently and joined with `/`.
|
|
36
23
|
*
|
|
37
|
-
* @example
|
|
38
|
-
* camelCase('hello-world')
|
|
39
|
-
*
|
|
24
|
+
* @example Word boundaries
|
|
25
|
+
* `camelCase('hello-world') // 'helloWorld'`
|
|
26
|
+
*
|
|
27
|
+
* @example With a prefix
|
|
28
|
+
* `camelCase('tag', { prefix: 'create' }) // 'createTag'`
|
|
40
29
|
*/
|
|
41
|
-
function camelCase(text, {
|
|
42
|
-
if (isFile) return applyToFileParts(text, (part, isLast) => camelCase(part, isLast ? {
|
|
43
|
-
prefix,
|
|
44
|
-
suffix
|
|
45
|
-
} : {}));
|
|
30
|
+
function camelCase(text, { prefix = "", suffix = "" } = {}) {
|
|
46
31
|
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
|
|
47
32
|
}
|
|
48
33
|
//#endregion
|
|
@@ -149,99 +134,80 @@ function isValidVarName(name) {
|
|
|
149
134
|
return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name);
|
|
150
135
|
}
|
|
151
136
|
//#endregion
|
|
152
|
-
//#region ../../internals/utils/src/
|
|
137
|
+
//#region ../../internals/utils/src/url.ts
|
|
138
|
+
function transformParam(raw, casing) {
|
|
139
|
+
const param = isValidVarName(raw) ? raw : camelCase(raw);
|
|
140
|
+
return casing === "camelcase" ? camelCase(param) : param;
|
|
141
|
+
}
|
|
142
|
+
function toParamsObject(path, { replacer, casing } = {}) {
|
|
143
|
+
const params = {};
|
|
144
|
+
for (const match of path.matchAll(/\{([^}]+)\}/g)) {
|
|
145
|
+
const param = transformParam(match[1], casing);
|
|
146
|
+
const key = replacer ? replacer(param) : param;
|
|
147
|
+
params[key] = key;
|
|
148
|
+
}
|
|
149
|
+
return Object.keys(params).length > 0 ? params : null;
|
|
150
|
+
}
|
|
153
151
|
/**
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
* @example
|
|
157
|
-
* const p = new URLPath('/pet/{petId}')
|
|
158
|
-
* p.URL // '/pet/:petId'
|
|
159
|
-
* p.template // '`/pet/${petId}`'
|
|
152
|
+
* Helpers for OpenAPI/Swagger paths, plus a thin wrapper over the native `URL`.
|
|
160
153
|
*/
|
|
161
|
-
var
|
|
154
|
+
var Url = class Url {
|
|
162
155
|
/**
|
|
163
|
-
*
|
|
164
|
-
*/
|
|
165
|
-
path;
|
|
166
|
-
#options;
|
|
167
|
-
constructor(path, options = {}) {
|
|
168
|
-
this.path = path;
|
|
169
|
-
this.#options = options;
|
|
170
|
-
}
|
|
171
|
-
/** Converts the OpenAPI path to Express-style colon syntax, e.g. `/pet/{petId}` → `/pet/:petId`.
|
|
156
|
+
* Reports whether `url` is a parseable absolute URL. Delegates to the native `URL.canParse`.
|
|
172
157
|
*
|
|
173
158
|
* @example
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
* ```
|
|
159
|
+
* Url.canParse('https://petstore.swagger.io/v2') // true
|
|
160
|
+
* Url.canParse('/pet/{petId}') // false
|
|
177
161
|
*/
|
|
178
|
-
|
|
179
|
-
return
|
|
162
|
+
static canParse(url, base) {
|
|
163
|
+
return URL.canParse(url, base);
|
|
180
164
|
}
|
|
181
|
-
/**
|
|
165
|
+
/**
|
|
166
|
+
* Converts an OpenAPI/Swagger path to Express-style colon syntax.
|
|
182
167
|
*
|
|
183
168
|
* @example
|
|
184
|
-
*
|
|
185
|
-
* new URLPath('https://petstore.swagger.io/v2/pet').isURL // true
|
|
186
|
-
* new URLPath('/pet/{petId}').isURL // false
|
|
187
|
-
* ```
|
|
169
|
+
* Url.toPath('/pet/{petId}') // '/pet/:petId'
|
|
188
170
|
*/
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
return !!new URL(this.path).href;
|
|
192
|
-
} catch {
|
|
193
|
-
return false;
|
|
194
|
-
}
|
|
171
|
+
static toPath(path) {
|
|
172
|
+
return path.replace(/\{([^}]+)\}/g, ":$1");
|
|
195
173
|
}
|
|
196
174
|
/**
|
|
197
|
-
* Converts
|
|
175
|
+
* Converts an OpenAPI/Swagger path to a TypeScript template literal string.
|
|
176
|
+
* `prefix` is prepended inside the literal, `replacer` transforms each parameter name,
|
|
177
|
+
* and `casing` controls parameter identifier casing.
|
|
198
178
|
*
|
|
199
179
|
* @example
|
|
200
|
-
*
|
|
201
|
-
* new URLPath('/account/monetary-accountID').template // '`/account/${monetaryAccountId}`'
|
|
202
|
-
*/
|
|
203
|
-
get template() {
|
|
204
|
-
return this.toTemplateString();
|
|
205
|
-
}
|
|
206
|
-
/** Returns the path and its extracted params as a structured `URLObject`, or as a stringified expression when `stringify` is set.
|
|
180
|
+
* Url.toTemplateString('/pet/{petId}') // '`/pet/${petId}`'
|
|
207
181
|
*
|
|
208
182
|
* @example
|
|
209
|
-
*
|
|
210
|
-
* new URLPath('/pet/{petId}').object
|
|
211
|
-
* // { url: '/pet/:petId', params: { petId: 'petId' } }
|
|
212
|
-
* ```
|
|
183
|
+
* Url.toTemplateString('/pet/{petId}', { prefix: 'https://api' }) // '`https://api/pet/${petId}`'
|
|
213
184
|
*/
|
|
214
|
-
|
|
215
|
-
|
|
185
|
+
static toTemplateString(path, { prefix, replacer, casing } = {}) {
|
|
186
|
+
const result = path.split(/\{([^}]+)\}/).map((part, i) => {
|
|
187
|
+
if (i % 2 === 0) return part;
|
|
188
|
+
const param = transformParam(part, casing);
|
|
189
|
+
return `\${${replacer ? replacer(param) : param}}`;
|
|
190
|
+
}).join("");
|
|
191
|
+
return `\`${prefix ?? ""}${result}\``;
|
|
216
192
|
}
|
|
217
|
-
/**
|
|
193
|
+
/**
|
|
194
|
+
* Returns the path and its extracted params as a structured `URLObject`, or as a stringified
|
|
195
|
+
* expression when `stringify` is set.
|
|
218
196
|
*
|
|
219
197
|
* @example
|
|
220
|
-
*
|
|
221
|
-
*
|
|
222
|
-
* new URLPath('/pet').params // null
|
|
223
|
-
* ```
|
|
224
|
-
*/
|
|
225
|
-
get params() {
|
|
226
|
-
return this.toParamsObject();
|
|
227
|
-
}
|
|
228
|
-
#transformParam(raw) {
|
|
229
|
-
const param = isValidVarName(raw) ? raw : camelCase(raw);
|
|
230
|
-
return this.#options.casing === "camelcase" ? camelCase(param) : param;
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* Iterates over every `{param}` token in `path`, calling `fn` with the raw token and transformed name.
|
|
198
|
+
* Url.toObject('/pet/{petId}')
|
|
199
|
+
* // { url: '/pet/:petId', params: { petId: 'petId' } }
|
|
234
200
|
*/
|
|
235
|
-
|
|
236
|
-
for (const match of this.path.matchAll(/\{([^}]+)\}/g)) {
|
|
237
|
-
const raw = match[1];
|
|
238
|
-
fn(raw, this.#transformParam(raw));
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
toObject({ type = "path", replacer, stringify } = {}) {
|
|
201
|
+
static toObject(path, { type = "path", replacer, stringify, casing } = {}) {
|
|
242
202
|
const object = {
|
|
243
|
-
url: type === "path" ?
|
|
244
|
-
|
|
203
|
+
url: type === "path" ? Url.toPath(path) : Url.toTemplateString(path, {
|
|
204
|
+
replacer,
|
|
205
|
+
casing
|
|
206
|
+
}),
|
|
207
|
+
params: toParamsObject(path, {
|
|
208
|
+
replacer,
|
|
209
|
+
casing
|
|
210
|
+
})
|
|
245
211
|
};
|
|
246
212
|
if (stringify) {
|
|
247
213
|
if (type === "template") return JSON.stringify(object).replaceAll("'", "").replaceAll(`"`, "");
|
|
@@ -250,50 +216,6 @@ var URLPath = class {
|
|
|
250
216
|
}
|
|
251
217
|
return object;
|
|
252
218
|
}
|
|
253
|
-
/**
|
|
254
|
-
* Converts the OpenAPI path to a TypeScript template literal string.
|
|
255
|
-
* An optional `replacer` can transform each extracted parameter name before interpolation.
|
|
256
|
-
*
|
|
257
|
-
* @example
|
|
258
|
-
* new URLPath('/pet/{petId}').toTemplateString() // '`/pet/${petId}`'
|
|
259
|
-
*/
|
|
260
|
-
toTemplateString({ prefix, replacer } = {}) {
|
|
261
|
-
const result = this.path.split(/\{([^}]+)\}/).map((part, i) => {
|
|
262
|
-
if (i % 2 === 0) return part;
|
|
263
|
-
const param = this.#transformParam(part);
|
|
264
|
-
return `\${${replacer ? replacer(param) : param}}`;
|
|
265
|
-
}).join("");
|
|
266
|
-
return `\`${prefix ?? ""}${result}\``;
|
|
267
|
-
}
|
|
268
|
-
/**
|
|
269
|
-
* Extracts all `{param}` segments from the path and returns them as a key-value map.
|
|
270
|
-
* An optional `replacer` transforms each parameter name in both key and value positions.
|
|
271
|
-
* Returns `undefined` when no path parameters are found.
|
|
272
|
-
*
|
|
273
|
-
* @example
|
|
274
|
-
* ```ts
|
|
275
|
-
* new URLPath('/pet/{petId}/tag/{tagId}').toParamsObject()
|
|
276
|
-
* // { petId: 'petId', tagId: 'tagId' }
|
|
277
|
-
* ```
|
|
278
|
-
*/
|
|
279
|
-
toParamsObject(replacer) {
|
|
280
|
-
const params = {};
|
|
281
|
-
this.#eachParam((_raw, param) => {
|
|
282
|
-
const key = replacer ? replacer(param) : param;
|
|
283
|
-
params[key] = key;
|
|
284
|
-
});
|
|
285
|
-
return Object.keys(params).length > 0 ? params : null;
|
|
286
|
-
}
|
|
287
|
-
/** Converts the OpenAPI path to Express-style colon syntax.
|
|
288
|
-
*
|
|
289
|
-
* @example
|
|
290
|
-
* ```ts
|
|
291
|
-
* new URLPath('/pet/{petId}').toURLPath() // '/pet/:petId'
|
|
292
|
-
* ```
|
|
293
|
-
*/
|
|
294
|
-
toURLPath() {
|
|
295
|
-
return this.path.replace(/\{([^}]+)\}/g, ":$1");
|
|
296
|
-
}
|
|
297
219
|
};
|
|
298
220
|
//#endregion
|
|
299
221
|
//#region ../../internals/shared/src/operation.ts
|
|
@@ -328,16 +250,6 @@ function resolveResponseTypes(node, resolver) {
|
|
|
328
250
|
return types;
|
|
329
251
|
}
|
|
330
252
|
//#endregion
|
|
331
|
-
//#region src/components/Handlers.tsx
|
|
332
|
-
function Handlers({ name, handlers }) {
|
|
333
|
-
return /* @__PURE__ */ jsx(File.Source, {
|
|
334
|
-
name,
|
|
335
|
-
isIndexable: true,
|
|
336
|
-
isExportable: true,
|
|
337
|
-
children: `export const ${name} = ${JSON.stringify(handlers).replaceAll(`"`, "")} as const`
|
|
338
|
-
});
|
|
339
|
-
}
|
|
340
|
-
//#endregion
|
|
341
253
|
//#region src/utils.ts
|
|
342
254
|
/**
|
|
343
255
|
* Gets the content type from a response, defaulting to 'application/json' if a schema exists.
|
|
@@ -405,16 +317,13 @@ function Mock({ baseURL = "", name, typeName, requestTypeName, node }) {
|
|
|
405
317
|
const successResponse = getPrimarySuccessResponse(node);
|
|
406
318
|
const statusCode = successResponse ? Number(successResponse.statusCode) : 200;
|
|
407
319
|
const contentType = getContentType(successResponse);
|
|
408
|
-
const url =
|
|
320
|
+
const url = Url.toPath(getMswUrl(node));
|
|
409
321
|
const headers = [contentType ? `'Content-Type': '${contentType}'` : null].filter(Boolean);
|
|
410
322
|
const dataType = hasResponseSchema(successResponse) ? typeName : "string | number | boolean | null | object";
|
|
411
323
|
const callbackType = requestTypeName ? `HttpResponseResolver<Record<string, string>, ${requestTypeName}, any>` : `((info: Parameters<Parameters<typeof http.${method}>[1]>[0]) => Response | Promise<Response>)`;
|
|
412
|
-
const params = declarationPrinter$2.print(ast.createFunctionParameters({ params: [ast.createFunctionParameter({
|
|
324
|
+
const params = declarationPrinter$2.print(ast.factory.createFunctionParameters({ params: [ast.factory.createFunctionParameter({
|
|
413
325
|
name: "data",
|
|
414
|
-
type:
|
|
415
|
-
variant: "reference",
|
|
416
|
-
name: `${dataType} | ${callbackType}`
|
|
417
|
-
}),
|
|
326
|
+
type: `${dataType} | ${callbackType}`,
|
|
418
327
|
optional: true
|
|
419
328
|
})] }));
|
|
420
329
|
const httpCall = requestTypeName ? `http.${method}<Record<string, string>, ${requestTypeName}, any>` : `http.${method}`;
|
|
@@ -447,15 +356,12 @@ function MockWithFaker({ baseURL = "", name, fakerName, typeName, requestTypeNam
|
|
|
447
356
|
const successResponse = getPrimarySuccessResponse(node);
|
|
448
357
|
const statusCode = successResponse ? Number(successResponse.statusCode) : 200;
|
|
449
358
|
const contentType = getContentType(successResponse);
|
|
450
|
-
const url =
|
|
359
|
+
const url = Url.toPath(getMswUrl(node));
|
|
451
360
|
const headers = [contentType ? `'Content-Type': '${contentType}'` : null].filter(Boolean);
|
|
452
361
|
const callbackType = requestTypeName ? `HttpResponseResolver<Record<string, string>, ${requestTypeName}, any>` : `((info: Parameters<Parameters<typeof http.${method}>[1]>[0]) => Response | Promise<Response>)`;
|
|
453
|
-
const params = declarationPrinter$1.print(ast.createFunctionParameters({ params: [ast.createFunctionParameter({
|
|
362
|
+
const params = declarationPrinter$1.print(ast.factory.createFunctionParameters({ params: [ast.factory.createFunctionParameter({
|
|
454
363
|
name: "data",
|
|
455
|
-
type:
|
|
456
|
-
variant: "reference",
|
|
457
|
-
name: `${typeName} | ${callbackType}`
|
|
458
|
-
}),
|
|
364
|
+
type: `${typeName} | ${callbackType}`,
|
|
459
365
|
optional: true
|
|
460
366
|
})] }));
|
|
461
367
|
const httpCall = requestTypeName ? `http.${method}<Record<string, string>, ${requestTypeName}, any>` : `http.${method}`;
|
|
@@ -487,12 +393,9 @@ function Response({ name, typeName, response }) {
|
|
|
487
393
|
const statusCode = Number(response.statusCode);
|
|
488
394
|
const contentType = getContentType(response);
|
|
489
395
|
const headers = [contentType ? `'Content-Type': '${contentType}'` : null].filter(Boolean);
|
|
490
|
-
const params = declarationPrinter.print(ast.createFunctionParameters({ params: [ast.createFunctionParameter({
|
|
396
|
+
const params = declarationPrinter.print(ast.factory.createFunctionParameters({ params: [ast.factory.createFunctionParameter({
|
|
491
397
|
name: "data",
|
|
492
|
-
type:
|
|
493
|
-
variant: "reference",
|
|
494
|
-
name: typeName
|
|
495
|
-
}),
|
|
398
|
+
type: typeName,
|
|
496
399
|
optional: !hasResponseSchema(response)
|
|
497
400
|
})] }));
|
|
498
401
|
const responseName = `${name}Response${statusCode}`;
|
|
@@ -515,6 +418,6 @@ function Response({ name, typeName, response }) {
|
|
|
515
418
|
});
|
|
516
419
|
}
|
|
517
420
|
//#endregion
|
|
518
|
-
export {
|
|
421
|
+
export { getOperationSuccessResponses as a, resolveFakerMeta as i, MockWithFaker as n, resolveResponseTypes as o, Mock as r, camelCase as s, Response as t };
|
|
519
422
|
|
|
520
|
-
//# sourceMappingURL=components
|
|
423
|
+
//# sourceMappingURL=components-DNiDZfAv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components-DNiDZfAv.js","names":["declarationPrinter","declarationPrinter"],"sources":["../../../internals/utils/src/casing.ts","../../../internals/utils/src/reserved.ts","../../../internals/utils/src/url.ts","../../../internals/shared/src/operation.ts","../src/utils.ts","../src/components/Mock.tsx","../src/components/MockWithFaker.tsx","../src/components/Response.tsx"],"sourcesContent":["type Options = {\n /**\n * Text prepended before casing is applied.\n */\n prefix?: string\n /**\n * Text appended before casing is applied.\n */\n suffix?: string\n}\n\n/**\n * Shared implementation for camelCase and PascalCase conversion.\n * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)\n * and capitalizes each word according to `pascal`.\n *\n * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.\n */\nfunction toCamelOrPascal(text: string, pascal: boolean): string {\n return text\n .trim()\n .replace(/([a-z\\d])([A-Z])/g, '$1 $2')\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')\n .replace(/(\\d)([a-z])/g, '$1 $2')\n .split(/[\\s\\-_./\\\\:]+/)\n .filter(Boolean)\n .map((word, i) => {\n if (word.length > 1 && word === word.toUpperCase()) return word\n const head = i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()\n return head + word.slice(1)\n })\n .join('')\n .replace(/[^a-zA-Z0-9]/g, '')\n}\n\n/**\n * Converts `text` to camelCase.\n *\n * @example Word boundaries\n * `camelCase('hello-world') // 'helloWorld'`\n *\n * @example With a prefix\n * `camelCase('tag', { prefix: 'create' }) // 'createTag'`\n */\nexport function camelCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false)\n}\n\n/**\n * Converts `text` to PascalCase.\n *\n * @example Word boundaries\n * `pascalCase('hello-world') // 'HelloWorld'`\n *\n * @example With a suffix\n * `pascalCase('tag', { suffix: 'schema' }) // 'TagSchema'`\n */\nexport function pascalCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true)\n}\n\n/**\n * Converts `text` to snake_case.\n *\n * @example From camelCase\n * `snakeCase('helloWorld') // 'hello_world'`\n *\n * @example From mixed separators\n * `snakeCase('Hello-World') // 'hello_world'`\n */\nexport function snakeCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n const processed = `${prefix} ${text} ${suffix}`.trim()\n return processed\n .replace(/([a-z])([A-Z])/g, '$1_$2')\n .replace(/[\\s\\-.]+/g, '_')\n .replace(/[^a-zA-Z0-9_]/g, '')\n .toLowerCase()\n .split('_')\n .filter(Boolean)\n .join('_')\n}\n\n/**\n * Converts `text` to SCREAMING_SNAKE_CASE.\n *\n * @example From camelCase\n * `screamingSnakeCase('helloWorld') // 'HELLO_WORLD'`\n */\nexport function screamingSnakeCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return snakeCase(text, { prefix, suffix }).toUpperCase()\n}\n","/**\n * JavaScript and Java reserved words.\n * @link https://github.com/jonschlinkert/reserved/blob/master/index.js\n */\nconst reservedWords = new Set([\n 'abstract',\n 'arguments',\n 'boolean',\n 'break',\n 'byte',\n 'case',\n 'catch',\n 'char',\n 'class',\n 'const',\n 'continue',\n 'debugger',\n 'default',\n 'delete',\n 'do',\n 'double',\n 'else',\n 'enum',\n 'eval',\n 'export',\n 'extends',\n 'false',\n 'final',\n 'finally',\n 'float',\n 'for',\n 'function',\n 'goto',\n 'if',\n 'implements',\n 'import',\n 'in',\n 'instanceof',\n 'int',\n 'interface',\n 'let',\n 'long',\n 'native',\n 'new',\n 'null',\n 'package',\n 'private',\n 'protected',\n 'public',\n 'return',\n 'short',\n 'static',\n 'super',\n 'switch',\n 'synchronized',\n 'this',\n 'throw',\n 'throws',\n 'transient',\n 'true',\n 'try',\n 'typeof',\n 'var',\n 'void',\n 'volatile',\n 'while',\n 'with',\n 'yield',\n 'Array',\n 'Date',\n 'hasOwnProperty',\n 'Infinity',\n 'isFinite',\n 'isNaN',\n 'isPrototypeOf',\n 'length',\n 'Math',\n 'name',\n 'NaN',\n 'Number',\n 'Object',\n 'prototype',\n 'String',\n 'toString',\n 'undefined',\n 'valueOf',\n] as const)\n\n/**\n * Returns `true` when `name` is a syntactically valid JavaScript variable name.\n *\n * @example\n * ```ts\n * isValidVarName('status') // true\n * isValidVarName('class') // false (reserved word)\n * isValidVarName('42foo') // false (starts with digit)\n * ```\n */\nexport function isValidVarName(name: string): boolean {\n if (!name || reservedWords.has(name as 'valueOf')) {\n return false\n }\n return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name)\n}\n\n/**\n * Returns `name` when it's a syntactically valid JavaScript variable name,\n * otherwise prefixes it with `_` so the result is a valid identifier.\n *\n * Useful for sanitizing OpenAPI schema names or operation IDs that start with\n * a digit (e.g. `409`, `504AccountCancel`) before using them as exported\n * variable, type, or function names.\n *\n * @example\n * ```ts\n * ensureValidVarName('409') // '_409'\n * ensureValidVarName('504AccountCancel') // '_504AccountCancel'\n * ensureValidVarName('Pet') // 'Pet'\n * ensureValidVarName('class') // '_class'\n * ```\n */\nexport function ensureValidVarName(name: string): string {\n if (!name || isValidVarName(name)) {\n return name\n }\n return `_${name}`\n}\n","import { camelCase } from './casing.ts'\nimport { isValidVarName } from './reserved.ts'\n\nexport type URLObject = {\n /**\n * The resolved URL string (Express-style or template literal, depending on context).\n */\n url: string\n /**\n * Extracted path parameters as a key-value map, or `null` when the path has none.\n */\n params: Record<string, string> | null\n}\n\n/**\n * Supported identifier casing strategies for path parameters.\n */\nexport type PathCasing = 'camelcase'\n\ntype TemplateOptions = {\n /**\n * Literal text prepended inside the template literal, e.g. a base URL.\n */\n prefix?: string | null\n /**\n * Transform applied to each extracted parameter name before interpolation.\n */\n replacer?: (pathParam: string) => string\n /**\n * Casing strategy applied to path parameter names.\n */\n casing?: PathCasing\n}\n\ntype ObjectOptions = {\n /**\n * Controls whether the `url` is rendered as an Express path or a template literal.\n * @default 'path'\n */\n type?: 'path' | 'template'\n /**\n * Transform applied to each extracted parameter name.\n */\n replacer?: (pathParam: string) => string\n /**\n * When `true`, the result is serialized to a string expression instead of a plain object.\n */\n stringify?: boolean\n /**\n * Casing strategy applied to path parameter names.\n */\n casing?: PathCasing\n}\n\nfunction transformParam(raw: string, casing?: PathCasing): string {\n const param = isValidVarName(raw) ? raw : camelCase(raw)\n return casing === 'camelcase' ? camelCase(param) : param\n}\n\nfunction toParamsObject(\n path: string,\n { replacer, casing }: { replacer?: (pathParam: string) => string; casing?: PathCasing } = {},\n): Record<string, string> | null {\n const params: Record<string, string> = {}\n\n for (const match of path.matchAll(/\\{([^}]+)\\}/g)) {\n const param = transformParam(match[1]!, casing)\n const key = replacer ? replacer(param) : param\n params[key] = key\n }\n\n return Object.keys(params).length > 0 ? params : null\n}\n\n/**\n * Helpers for OpenAPI/Swagger paths, plus a thin wrapper over the native `URL`.\n */\nexport class Url {\n /**\n * Reports whether `url` is a parseable absolute URL. Delegates to the native `URL.canParse`.\n *\n * @example\n * Url.canParse('https://petstore.swagger.io/v2') // true\n * Url.canParse('/pet/{petId}') // false\n */\n static canParse(url: string, base?: string | URL): boolean {\n return URL.canParse(url, base)\n }\n\n /**\n * Converts an OpenAPI/Swagger path to Express-style colon syntax.\n *\n * @example\n * Url.toPath('/pet/{petId}') // '/pet/:petId'\n */\n static toPath(path: string): string {\n return path.replace(/\\{([^}]+)\\}/g, ':$1')\n }\n\n /**\n * Converts an OpenAPI/Swagger path to a TypeScript template literal string.\n * `prefix` is prepended inside the literal, `replacer` transforms each parameter name,\n * and `casing` controls parameter identifier casing.\n *\n * @example\n * Url.toTemplateString('/pet/{petId}') // '`/pet/${petId}`'\n *\n * @example\n * Url.toTemplateString('/pet/{petId}', { prefix: 'https://api' }) // '`https://api/pet/${petId}`'\n */\n static toTemplateString(path: string, { prefix, replacer, casing }: TemplateOptions = {}): string {\n const parts = path.split(/\\{([^}]+)\\}/)\n const result = parts\n .map((part, i) => {\n if (i % 2 === 0) return part\n const param = transformParam(part, casing)\n return `\\${${replacer ? replacer(param) : param}}`\n })\n .join('')\n\n return `\\`${prefix ?? ''}${result}\\``\n }\n\n /**\n * Returns the path and its extracted params as a structured `URLObject`, or as a stringified\n * expression when `stringify` is set.\n *\n * @example\n * Url.toObject('/pet/{petId}')\n * // { url: '/pet/:petId', params: { petId: 'petId' } }\n */\n static toObject(path: string, { type = 'path', replacer, stringify, casing }: ObjectOptions = {}): URLObject | string {\n const object: URLObject = {\n url: type === 'path' ? Url.toPath(path) : Url.toTemplateString(path, { replacer, casing }),\n params: toParamsObject(path, { replacer, casing }),\n }\n\n if (stringify) {\n if (type === 'template') {\n return JSON.stringify(object).replaceAll(\"'\", '').replaceAll(`\"`, '')\n }\n\n if (object.params) {\n return `{ url: '${object.url}', params: ${JSON.stringify(object.params).replaceAll(\"'\", '').replaceAll(`\"`, '')} }`\n }\n\n return `{ url: '${object.url}' }`\n }\n\n return object\n }\n}\n","import { Url } from '@internals/utils'\nimport { ast, type ResolverFileParams } from '@kubb/core'\nimport { caseParams } from '@kubb/ast/utils'\n\n/**\n * Builds the `ResolverFileParams` every operation generator passes to\n * `resolver.resolveFile`: a file named `name`, tagged by the operation's first\n * tag (or `'default'`), at the operation's path. Centralizes the entry object\n * that was repeated at dozens of call sites across the client and query plugins.\n *\n * @example\n * ```ts\n * resolver.resolveFile(operationFileEntry(node, node.operationId), { root, output, group })\n * ```\n */\nexport function operationFileEntry(node: ast.OperationNode, name: string, extname: ResolverFileParams['extname'] = '.ts'): ResolverFileParams {\n return {\n name,\n extname,\n tag: node.tags[0] ?? 'default',\n path: node.path,\n }\n}\n\nexport type ContentTypeInfo = {\n contentTypes: string[]\n isMultipleContentTypes: boolean\n contentTypeUnion: string\n defaultContentType: string\n hasFormData: boolean\n}\n\nexport type RequestConfigResolver = {\n resolveDataName(node: ast.OperationNode): string\n}\n\nexport type ResponseStatusNameResolver = {\n resolveResponseStatusName(node: ast.OperationNode, statusCode: ast.StatusCode): string\n}\n\nexport type ResponseNameResolver = ResponseStatusNameResolver & {\n resolveResponseName(node: ast.OperationNode): string\n}\n\nexport type OperationTypeNameResolver = RequestConfigResolver &\n ResponseNameResolver & {\n resolvePathParamsName(node: ast.OperationNode, param: ast.ParameterNode): string\n resolveQueryParamsName(node: ast.OperationNode, param: ast.ParameterNode): string\n resolveHeaderParamsName(node: ast.OperationNode, param: ast.ParameterNode): string\n }\n\nexport type OperationCommentLink = 'pathTemplate' | 'urlPath' | false | ((node: ast.OperationNode) => string | undefined)\n\nexport type BuildOperationCommentsOptions = {\n link?: OperationCommentLink\n linkPosition?: 'beforeDeprecated' | 'afterDeprecated'\n splitLines?: boolean\n}\n\ntype ResponseLike = {\n statusCode: ast.StatusCode | number | string\n}\n\nexport type OperationParameterGroups = Record<ast.ParameterNode['in'], Array<ast.ParameterNode>>\n\nexport type ResolveOperationTypeNameOptions = {\n paramsCasing?: 'camelcase'\n responseStatusNames?: boolean | 'error'\n exclude?: ReadonlyArray<string | undefined>\n order?: 'params-first' | 'body-response-first'\n}\n\nfunction getOperationLink(node: ast.OperationNode, link: OperationCommentLink): string | null {\n if (!link) {\n return null\n }\n\n if (typeof link === 'function') {\n return link(node) ?? null\n }\n\n if (link === 'urlPath') {\n return node.path ? `{@link ${Url.toPath(node.path)}}` : null\n }\n\n return node.path ? `{@link ${node.path.replaceAll('{', ':').replaceAll('}', '')}}` : null\n}\n\nexport function getContentTypeInfo(node: ast.OperationNode): ContentTypeInfo {\n const contentTypes = node.requestBody?.content?.map((e) => e.contentType) ?? []\n const isMultipleContentTypes = contentTypes.length > 1\n\n return {\n contentTypes,\n isMultipleContentTypes,\n contentTypeUnion: isMultipleContentTypes ? contentTypes.map((ct) => JSON.stringify(ct)).join(' | ') : '',\n defaultContentType: contentTypes[0] ?? 'application/json',\n hasFormData: contentTypes.some((ct) => ct === 'multipart/form-data'),\n }\n}\n\nexport type ResponseType = 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'\n\n/**\n * Derives the default `responseType` for an operation from its primary success response.\n *\n * Returns a value only when that response declares a single non-JSON content type — a binary type\n * (`application/octet-stream`, `application/pdf`, `image/*`, `audio/*`, `video/*`) maps to `'blob'`\n * and other `text/*` maps to `'text'`. Otherwise `undefined`, leaving the runtime client's\n * `Content-Type` auto-detection in charge.\n */\nexport function getResponseType(node: ast.OperationNode): ResponseType | undefined {\n const contentTypes = getPrimarySuccessResponse(node)?.content?.map((entry) => entry.contentType) ?? []\n if (contentTypes.length !== 1) return undefined\n\n const baseType = contentTypes[0]!.split(';')[0]!.trim().toLowerCase()\n if (baseType === 'application/json' || baseType.endsWith('+json') || baseType === 'text/json') return undefined\n if (baseType.startsWith('text/')) return 'text'\n if (baseType === 'application/octet-stream' || baseType === 'application/pdf' || /^(image|audio|video)\\//.test(baseType)) return 'blob'\n return undefined\n}\n\n/**\n * Maps a content type to the PascalCase suffix used to name per-content-type variants\n * (e.g. `application/json` → `Json`, `application/xml` → `Xml`, `multipart/form-data` → `FormData`).\n */\nexport function getContentTypeSuffix(contentType: string): string {\n const baseType = contentType.split(';')[0]!.trim()\n if (baseType === 'application/json') return 'Json'\n if (baseType === 'multipart/form-data') return 'FormData'\n if (baseType === 'application/x-www-form-urlencoded') return 'FormUrlEncoded'\n const subtype = baseType.split('/').pop() ?? baseType\n const parts = subtype.split(/[^a-zA-Z0-9]+/).filter(Boolean)\n if (parts.length === 0) return 'Unknown'\n return parts.map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join('')\n}\n\n/**\n * Appends a content-type suffix to a base name, keeping a trailing `Data` segment last\n * (e.g. `AddPetData` + `Json` → `AddPetJsonData`, `AddPetStatus200` + `Xml` → `AddPetStatus200Xml`).\n */\nexport function getPerContentTypeName(baseName: string, suffix: string): string {\n if (baseName.endsWith('Data')) {\n return suffix.endsWith('Data') ? baseName.slice(0, -4) + suffix : `${baseName.slice(0, -4)}${suffix}Data`\n }\n return baseName + suffix\n}\n\nexport type ContentVariantInput = { contentType: string; schema?: ast.SchemaNode | null; keysToOmit?: Array<string> | null }\nexport type ContentVariant = { name: string; suffix: string; schema: ast.SchemaNode; keysToOmit?: Array<string> | null; contentType: string }\n\n/**\n * Resolves per-content-type variant names for a set of content entries, deduplicating suffix\n * collisions with a numeric counter. Entries without a schema are skipped. The returned `suffix` is\n * the final (possibly counter-augmented) value, so callers can derive parallel names in another\n * namespace (e.g. plugin-faker deriving the matching plugin-ts type name).\n */\nexport function resolveContentTypeVariants(entries: Array<ContentVariantInput>, baseName: string): Array<ContentVariant> {\n const usedNames = new Set<string>()\n return entries\n .filter((entry) => entry.schema)\n .map((entry) => {\n const baseSuffix = getContentTypeSuffix(entry.contentType)\n let suffix = baseSuffix\n let name = getPerContentTypeName(baseName, suffix)\n let counter = 2\n while (usedNames.has(name)) {\n suffix = `${baseSuffix}${counter++}`\n name = getPerContentTypeName(baseName, suffix)\n }\n usedNames.add(name)\n return { name, suffix, schema: entry.schema!, keysToOmit: entry.keysToOmit, contentType: entry.contentType }\n })\n}\n\nexport function buildRequestConfigType(node: ast.OperationNode, resolver: RequestConfigResolver): string {\n const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : null\n const { isMultipleContentTypes, contentTypeUnion } = getContentTypeInfo(node)\n const configType = requestName ? `Partial<RequestConfig<${requestName}>>` : 'Partial<RequestConfig>'\n const configProps = ['client?: Client', isMultipleContentTypes ? `contentType?: ${contentTypeUnion}` : null].filter(Boolean).join('; ')\n\n return `${configType} & { ${configProps} }`\n}\n\nexport function buildOperationComments(node: ast.OperationNode, options: BuildOperationCommentsOptions = {}): Array<string> {\n const { link = 'pathTemplate', linkPosition = 'afterDeprecated', splitLines = false } = options\n const linkComment = getOperationLink(node, link)\n const comments =\n linkPosition === 'beforeDeprecated'\n ? [node.description && `@description ${node.description}`, node.summary && `@summary ${node.summary}`, linkComment, node.deprecated && '@deprecated']\n : [node.description && `@description ${node.description}`, node.summary && `@summary ${node.summary}`, node.deprecated && '@deprecated', linkComment]\n\n const filteredComments = comments.filter((comment): comment is string => Boolean(comment))\n\n if (!splitLines) {\n return filteredComments\n }\n\n return filteredComments.flatMap((text) => text.split(/\\r?\\n/).map((line) => line.trim())).filter((comment): comment is string => Boolean(comment))\n}\n\nexport function getOperationParameters(node: ast.OperationNode, options: { paramsCasing?: 'camelcase' } = {}): OperationParameterGroups {\n const params = caseParams(node.parameters, options.paramsCasing)\n\n return {\n path: params.filter((param) => param.in === 'path'),\n query: params.filter((param) => param.in === 'query'),\n header: params.filter((param) => param.in === 'header'),\n cookie: params.filter((param) => param.in === 'cookie'),\n }\n}\n\nexport function getStatusCodeNumber(statusCode: ast.StatusCode | number | string): number | null {\n const code = Number(statusCode)\n\n return Number.isNaN(code) ? null : code\n}\n\nexport function isSuccessStatusCode(statusCode: ast.StatusCode | number | string): boolean {\n const code = getStatusCodeNumber(statusCode)\n\n return code !== null && code >= 200 && code < 300\n}\n\nexport function isErrorStatusCode(statusCode: ast.StatusCode | number | string): boolean {\n const code = getStatusCodeNumber(statusCode)\n\n return code !== null && code >= 400\n}\n\nexport function getSuccessResponses<TResponse extends ResponseLike>(responses: ReadonlyArray<TResponse>): Array<TResponse> {\n return responses.filter((response) => isSuccessStatusCode(response.statusCode))\n}\n\nexport function getOperationSuccessResponses(node: ast.OperationNode): Array<ast.ResponseNode> {\n return getSuccessResponses(node.responses)\n}\n\nexport function getPrimarySuccessResponse(node: ast.OperationNode): ast.ResponseNode | null {\n return getOperationSuccessResponses(node)[0] ?? null\n}\n\nexport function resolveErrorNames(node: ast.OperationNode, resolver: ResponseStatusNameResolver): string[] {\n return node.responses\n .filter((response) => isErrorStatusCode(response.statusCode))\n .map((response) => resolver.resolveResponseStatusName(node, response.statusCode))\n}\n\nexport function resolveSuccessNames(node: ast.OperationNode, resolver: ResponseStatusNameResolver): string[] {\n return node.responses\n .filter((response) => isSuccessStatusCode(response.statusCode))\n .map((response) => resolver.resolveResponseStatusName(node, response.statusCode))\n}\n\nexport function resolveStatusCodeNames(node: ast.OperationNode, resolver: ResponseStatusNameResolver): string[] {\n return node.responses.map((response) => resolver.resolveResponseStatusName(node, response.statusCode))\n}\n\n/**\n * Builds the discriminated union type string for `dataReturnType: 'full'` return shapes.\n * Each member is `{ status: N; data: StatusNType; statusText: string }`.\n */\nexport function buildStatusUnionType(node: ast.OperationNode, resolver: ResponseStatusNameResolver): string {\n const members = node.responses.map((r) => {\n const typeName = resolver.resolveResponseStatusName(node, r.statusCode)\n const statusCode = Number.parseInt(r.statusCode, 10)\n const statusLiteral = Number.isNaN(statusCode) ? 'number' : String(statusCode)\n return `{ status: ${statusLiteral}; data: ${typeName}; statusText: string }`\n })\n if (members.length === 1) return members[0]!\n return `(${members.join(' | ')})`\n}\n\nconst typeNamesByResolver = new WeakMap<OperationTypeNameResolver, Map<string, string[]>>()\n\nexport function resolveOperationTypeNames(\n node: ast.OperationNode,\n resolver: OperationTypeNameResolver,\n options: ResolveOperationTypeNameOptions = {},\n): string[] {\n const cacheKey = `${node.operationId}\\0${options.paramsCasing ?? ''}\\0${options.order ?? ''}\\0${options.responseStatusNames ?? ''}\\0${(options.exclude ?? []).join(',')}`\n let byResolver = typeNamesByResolver.get(resolver)\n if (byResolver) {\n const cached = byResolver.get(cacheKey)\n if (cached) return cached\n } else {\n byResolver = new Map()\n typeNamesByResolver.set(resolver, byResolver)\n }\n\n const { path, query, header } = getOperationParameters(node, { paramsCasing: options.paramsCasing })\n const responseStatusNames =\n options.responseStatusNames === 'error'\n ? resolveErrorNames(node, resolver)\n : options.responseStatusNames === false\n ? []\n : resolveStatusCodeNames(node, resolver)\n const exclude = new Set(options.exclude ?? [])\n const paramNames = [\n ...path.map((param) => resolver.resolvePathParamsName(node, param)),\n ...query.map((param) => resolver.resolveQueryParamsName(node, param)),\n ...header.map((param) => resolver.resolveHeaderParamsName(node, param)),\n ]\n const bodyAndResponseNames = [node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : null, resolver.resolveResponseName(node)]\n const names =\n options.order === 'body-response-first'\n ? [...bodyAndResponseNames, ...paramNames, ...responseStatusNames]\n : [...paramNames, ...bodyAndResponseNames, ...responseStatusNames]\n\n const result = names.filter((name): name is string => Boolean(name) && !exclude.has(name as string))\n byResolver.set(cacheKey, result)\n return result\n}\n\nexport function resolveResponseTypes(node: ast.OperationNode, resolver: ResponseNameResolver): Array<[statusCode: number | 'default', typeName: string]> {\n const types: Array<[number | 'default', string]> = []\n\n for (const response of node.responses) {\n if (response.statusCode === 'default') {\n types.push(['default', resolver.resolveResponseName(node)])\n continue\n }\n\n const code = getStatusCodeNumber(response.statusCode)\n if (code === null) {\n continue\n }\n\n types.push([code, isSuccessStatusCode(code) ? resolver.resolveResponseName(node) : resolver.resolveResponseStatusName(node, response.statusCode)])\n }\n\n return types\n}\n\nexport function findSuccessStatusCode(responses: Array<{ statusCode: ast.StatusCode | number | string }>): ast.StatusCode | null {\n for (const response of responses) {\n if (isSuccessStatusCode(response.statusCode)) {\n return response.statusCode as ast.StatusCode\n }\n }\n\n return null\n}\n","import { ast } from '@kubb/core'\nimport type { ResolverFaker } from '@kubb/plugin-faker'\nimport type { PluginMsw } from './types.ts'\n\n/**\n * Gets the content type from a response, defaulting to 'application/json' if a schema exists.\n */\nexport function getContentType(response: ast.ResponseNode | null | undefined): string | null {\n if (!hasResponseSchema(response)) {\n return null\n }\n\n return getResponseContentType(response) ?? 'application/json'\n}\n\n/**\n * Determines if a response has a schema that is not void or any.\n */\nexport function hasResponseSchema(response: ast.ResponseNode | null | undefined): boolean {\n const schema = response?.content?.find((entry) => entry.schema)?.schema\n return !!schema && schema.type !== 'void' && schema.type !== 'any'\n}\n\n/**\n * Picks the content type used for the mocked response header. When a response declares multiple\n * content types, JSON is preferred (the faker mock body is JSON), otherwise the first declared type.\n */\nfunction getResponseContentType(response: ast.ResponseNode | null | undefined): string | null {\n const contents = response?.content ?? []\n const jsonEntry = contents.find((entry) => {\n const baseType = entry.contentType?.split(';')[0]?.trim().toLowerCase()\n return baseType === 'application/json' || baseType?.endsWith('+json')\n })\n const value = (jsonEntry ?? contents[0])?.contentType\n return typeof value === 'string' && value.length > 0 ? value : null\n}\n\n/**\n * Converts an HTTP method to its lowercase MSW equivalent (e.g., 'POST' → 'post').\n */\nexport function getMswMethod(node: ast.OperationNode): string {\n return ast.isHttpOperationNode(node) ? node.method.toLowerCase() : ''\n}\n\n/**\n * Converts an OpenAPI-style path to an Express/MSW-style path by replacing `{param}` with `:param`.\n */\nexport function getMswUrl(node: ast.OperationNode): string {\n return ast.isHttpOperationNode(node) ? node.path.replaceAll('{', ':').replaceAll('}', '') : ''\n}\n\n/**\n * Resolves faker metadata for an MSW operation, including response name and file path.\n */\nexport function resolveFakerMeta(\n node: ast.OperationNode,\n options: {\n root: string\n fakerResolver: ResolverFaker\n fakerOutput: PluginMsw['resolvedOptions']['output']\n fakerGroup: PluginMsw['resolvedOptions']['group']\n },\n): { name: string; file: { path: string } } {\n const { root, fakerResolver, fakerOutput, fakerGroup } = options\n const tag = node.tags[0] ?? 'default'\n\n return {\n name: fakerResolver.resolveResponseName(node),\n file: fakerResolver.resolveFile(\n { name: node.operationId, extname: '.ts', tag, path: node.path },\n { root, output: fakerOutput, group: fakerGroup ?? undefined },\n ),\n }\n}\n","import { getPrimarySuccessResponse } from '@internals/shared'\nimport { Url } from '@internals/utils'\nimport { ast } from '@kubb/core'\nimport { functionPrinter } from '@kubb/plugin-ts'\nimport { File, Function } from '@kubb/renderer-jsx'\nimport type { KubbReactNode } from '@kubb/renderer-jsx/types'\nimport { getContentType, getMswMethod, getMswUrl, hasResponseSchema } from '../utils.ts'\n\ntype Props = {\n name: string\n typeName: string\n requestTypeName?: string | null\n baseURL: string | null | undefined\n node: ast.OperationNode\n}\n\nconst declarationPrinter = functionPrinter({ mode: 'declaration' })\n\nexport function Mock({ baseURL = '', name, typeName, requestTypeName, node }: Props): KubbReactNode {\n const method = getMswMethod(node)\n const successResponse = getPrimarySuccessResponse(node)\n const statusCode = successResponse ? Number(successResponse.statusCode) : 200\n const contentType = getContentType(successResponse)\n const url = Url.toPath(getMswUrl(node))\n\n const headers = [contentType ? `'Content-Type': '${contentType}'` : null].filter(Boolean)\n const responseHasSchema = hasResponseSchema(successResponse)\n const dataType = responseHasSchema ? typeName : 'string | number | boolean | null | object'\n\n const callbackType = requestTypeName\n ? `HttpResponseResolver<Record<string, string>, ${requestTypeName}, any>`\n : `((info: Parameters<Parameters<typeof http.${method}>[1]>[0]) => Response | Promise<Response>)`\n\n const params = declarationPrinter.print(\n ast.factory.createFunctionParameters({\n params: [\n ast.factory.createFunctionParameter({\n name: 'data',\n type: `${dataType} | ${callbackType}`,\n optional: true,\n }),\n ],\n }),\n )\n\n const httpCall = requestTypeName ? `http.${method}<Record<string, string>, ${requestTypeName}, any>` : `http.${method}`\n\n return (\n <File.Source name={name} isIndexable isExportable>\n <Function name={name} export params={params ?? ''}>\n {`return ${httpCall}(\\`${baseURL}${url.replace(/([^/]):/g, '$1\\\\\\\\:')}\\`, function handler(info) {\n if(typeof data === 'function') return data(info)\n\n return new Response(JSON.stringify(data), {\n status: ${statusCode},\n ${\n headers.length\n ? ` headers: {\n ${headers.join(', \\n')}\n },`\n : ''\n }\n })\n })`}\n </Function>\n </File.Source>\n )\n}\n","import { getPrimarySuccessResponse } from '@internals/shared'\nimport { Url } from '@internals/utils'\nimport { ast } from '@kubb/core'\nimport { functionPrinter } from '@kubb/plugin-ts'\nimport { File, Function } from '@kubb/renderer-jsx'\nimport type { KubbReactNode } from '@kubb/renderer-jsx/types'\nimport { getContentType, getMswMethod, getMswUrl } from '../utils.ts'\n\ntype Props = {\n name: string\n typeName: string\n requestTypeName?: string | null\n fakerName: string\n baseURL: string | null | undefined\n node: ast.OperationNode\n}\n\nconst declarationPrinter = functionPrinter({ mode: 'declaration' })\n\nexport function MockWithFaker({ baseURL = '', name, fakerName, typeName, requestTypeName, node }: Props): KubbReactNode {\n const method = getMswMethod(node)\n const successResponse = getPrimarySuccessResponse(node)\n const statusCode = successResponse ? Number(successResponse.statusCode) : 200\n const contentType = getContentType(successResponse)\n const url = Url.toPath(getMswUrl(node))\n\n const headers = [contentType ? `'Content-Type': '${contentType}'` : null].filter(Boolean)\n\n const callbackType = requestTypeName\n ? `HttpResponseResolver<Record<string, string>, ${requestTypeName}, any>`\n : `((info: Parameters<Parameters<typeof http.${method}>[1]>[0]) => Response | Promise<Response>)`\n\n const params = declarationPrinter.print(\n ast.factory.createFunctionParameters({\n params: [\n ast.factory.createFunctionParameter({\n name: 'data',\n type: `${typeName} | ${callbackType}`,\n optional: true,\n }),\n ],\n }),\n )\n\n const httpCall = requestTypeName ? `http.${method}<Record<string, string>, ${requestTypeName}, any>` : `http.${method}`\n\n return (\n <File.Source name={name} isIndexable isExportable>\n <Function name={name} export params={params ?? ''}>\n {`return ${httpCall}('${baseURL}${url.replace(/([^/]):/g, '$1\\\\\\\\:')}', function handler(info) {\n if(typeof data === 'function') return data(info)\n\n return new Response(JSON.stringify(data || ${fakerName}(data)), {\n status: ${statusCode},\n ${\n headers.length\n ? ` headers: {\n ${headers.join(', \\n')}\n },`\n : ''\n }\n })\n })`}\n </Function>\n </File.Source>\n )\n}\n","import { ast } from '@kubb/core'\nimport { functionPrinter } from '@kubb/plugin-ts'\nimport { File, Function } from '@kubb/renderer-jsx'\nimport type { KubbReactNode } from '@kubb/renderer-jsx/types'\nimport { getContentType, hasResponseSchema } from '../utils.ts'\n\ntype Props = {\n typeName: string\n name: string\n response: ast.ResponseNode\n key?: string | number | null\n}\n\nconst declarationPrinter = functionPrinter({ mode: 'declaration' })\n\nexport function Response({ name, typeName, response }: Props): KubbReactNode {\n const statusCode = Number(response.statusCode)\n const contentType = getContentType(response)\n const headers = [contentType ? `'Content-Type': '${contentType}'` : null].filter(Boolean)\n\n const params = declarationPrinter.print(\n ast.factory.createFunctionParameters({\n params: [\n ast.factory.createFunctionParameter({\n name: 'data',\n type: typeName,\n optional: !hasResponseSchema(response),\n }),\n ],\n }),\n )\n\n const responseName = `${name}Response${statusCode}`\n\n return (\n <File.Source name={responseName} isIndexable isExportable>\n <Function name={responseName} export params={params ?? ''}>\n {`\n return new Response(JSON.stringify(data), {\n status: ${statusCode},\n ${\n headers.length\n ? ` headers: {\n ${headers.join(', \\n')}\n },`\n : ''\n }\n })`}\n </Function>\n </File.Source>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;AAkBA,SAAS,gBAAgB,MAAc,QAAyB;CAC9D,OAAO,KACJ,KAAK,CAAC,CACN,QAAQ,qBAAqB,OAAO,CAAC,CACrC,QAAQ,yBAAyB,OAAO,CAAC,CACzC,QAAQ,gBAAgB,OAAO,CAAC,CAChC,MAAM,eAAe,CAAC,CACtB,OAAO,OAAO,CAAC,CACf,KAAK,MAAM,MAAM;EAChB,IAAI,KAAK,SAAS,KAAK,SAAS,KAAK,YAAY,GAAG,OAAO;EAE3D,QADa,MAAM,KAAK,CAAC,SAAS,KAAK,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,YAAY,KAC9E,KAAK,MAAM,CAAC;CAC5B,CAAC,CAAC,CACD,KAAK,EAAE,CAAC,CACR,QAAQ,iBAAiB,EAAE;AAChC;;;;;;;;;;AAWA,SAAgB,UAAU,MAAc,EAAE,SAAS,IAAI,SAAS,OAAgB,CAAC,GAAW;CAC1F,OAAO,gBAAgB,GAAG,OAAO,GAAG,KAAK,GAAG,UAAU,KAAK;AAC7D;;;;;;;AC1CA,MAAM,gBAAgB,IAAI,IAAI;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAC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C;CAC3E,MAAM,aAAa,OAAO,SAAS,UAAU;CAC7C,MAAM,cAAc,eAAe,QAAQ;CAC3C,MAAM,UAAU,CAAC,cAAc,oBAAoB,YAAY,KAAK,IAAI,CAAC,CAAC,OAAO,OAAO;CAExF,MAAM,SAAS,mBAAmB,MAChC,IAAI,QAAQ,yBAAyB,EACnC,QAAQ,CACN,IAAI,QAAQ,wBAAwB;EAClC,MAAM;EACN,MAAM;EACN,UAAU,CAAC,kBAAkB,QAAQ;CACvC,CAAC,CACH,EACF,CAAC,CACH;CAEA,MAAM,eAAe,GAAG,KAAK,UAAU;CAEvC,OACE,oBAAC,KAAK,QAAN;EAAa,MAAM;EAAc,aAAA;EAAY,cAAA;YAC3C,oBAAC,UAAD;GAAU,MAAM;GAAc,QAAA;GAAO,QAAQ,UAAU;aACpD;;gBAEO,WAAW;QAEnB,QAAQ,SACJ;UACF,QAAQ,KAAK,MAAM,EAAE;YAEnB,GACL;;EAES,CAAA;CACC,CAAA;AAEjB"}
|
package/dist/components.cjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_components = require("./components-
|
|
3
|
-
exports.Handlers = require_components.Handlers;
|
|
2
|
+
const require_components = require("./components-BZ9KakZO.cjs");
|
|
4
3
|
exports.Mock = require_components.Mock;
|
|
5
4
|
exports.MockWithFaker = require_components.MockWithFaker;
|
|
6
5
|
exports.Response = require_components.Response;
|
package/dist/components.d.ts
CHANGED
|
@@ -2,19 +2,6 @@ import { t as __name } from "./chunk-C0LytTxp.js";
|
|
|
2
2
|
import { ast } from "@kubb/core";
|
|
3
3
|
import { KubbReactNode } from "@kubb/renderer-jsx/types";
|
|
4
4
|
|
|
5
|
-
//#region src/components/Handlers.d.ts
|
|
6
|
-
type HandlersProps = {
|
|
7
|
-
/**
|
|
8
|
-
* Name of the function
|
|
9
|
-
*/
|
|
10
|
-
name: string;
|
|
11
|
-
handlers: Array<string>;
|
|
12
|
-
};
|
|
13
|
-
declare function Handlers({
|
|
14
|
-
name,
|
|
15
|
-
handlers
|
|
16
|
-
}: HandlersProps): KubbReactNode;
|
|
17
|
-
//#endregion
|
|
18
5
|
//#region src/components/Mock.d.ts
|
|
19
6
|
type Props$2 = {
|
|
20
7
|
name: string;
|
|
@@ -62,5 +49,5 @@ declare function Response({
|
|
|
62
49
|
response
|
|
63
50
|
}: Props): KubbReactNode;
|
|
64
51
|
//#endregion
|
|
65
|
-
export {
|
|
52
|
+
export { Mock, MockWithFaker, Response };
|
|
66
53
|
//# sourceMappingURL=components.d.ts.map
|
package/dist/components.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { n as MockWithFaker, r as Mock, t as Response } from "./components-DNiDZfAv.js";
|
|
2
|
+
export { Mock, MockWithFaker, Response };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const require_components = require("./components-
|
|
1
|
+
const require_components = require("./components-BZ9KakZO.cjs");
|
|
2
2
|
let _kubb_core = require("@kubb/core");
|
|
3
3
|
let _kubb_plugin_faker = require("@kubb/plugin-faker");
|
|
4
4
|
let _kubb_plugin_ts = require("@kubb/plugin-ts");
|
|
5
5
|
let _kubb_renderer_jsx = require("@kubb/renderer-jsx");
|
|
6
6
|
let _kubb_renderer_jsx_jsx_runtime = require("@kubb/renderer-jsx/jsx-runtime");
|
|
7
|
-
//#region src/generators/handlersGenerator.
|
|
7
|
+
//#region src/generators/handlersGenerator.ts
|
|
8
8
|
/**
|
|
9
9
|
* Aggregate generator enabled by `pluginMsw({ handlers: true })`. Emits a
|
|
10
10
|
* `handlers.ts` file that re-exports every generated handler grouped by HTTP
|
|
@@ -13,7 +13,6 @@ let _kubb_renderer_jsx_jsx_runtime = require("@kubb/renderer-jsx/jsx-runtime");
|
|
|
13
13
|
*/
|
|
14
14
|
const handlersGenerator = (0, _kubb_core.defineGenerator)({
|
|
15
15
|
name: "plugin-msw",
|
|
16
|
-
renderer: _kubb_renderer_jsx.jsxRendererSync,
|
|
17
16
|
operations(nodes, ctx) {
|
|
18
17
|
const { resolver, config, root } = ctx;
|
|
19
18
|
const { output, group } = ctx.options;
|
|
@@ -38,14 +37,14 @@ const handlersGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
38
37
|
output,
|
|
39
38
|
group: group ?? void 0
|
|
40
39
|
});
|
|
41
|
-
return
|
|
40
|
+
return _kubb_core.ast.factory.createImport({
|
|
42
41
|
name: [operationName],
|
|
43
42
|
root: file.path,
|
|
44
43
|
path: operationFile.path
|
|
45
|
-
}
|
|
44
|
+
});
|
|
46
45
|
});
|
|
47
46
|
const handlers = nodes.map((node) => `${resolver.resolveHandlerName(node)}()`);
|
|
48
|
-
return
|
|
47
|
+
return [_kubb_core.ast.factory.createFile({
|
|
49
48
|
baseName: file.baseName,
|
|
50
49
|
path: file.path,
|
|
51
50
|
meta: file.meta,
|
|
@@ -65,11 +64,14 @@ const handlersGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
65
64
|
baseName: file.baseName
|
|
66
65
|
}
|
|
67
66
|
}),
|
|
68
|
-
|
|
67
|
+
imports,
|
|
68
|
+
sources: [_kubb_core.ast.factory.createSource({
|
|
69
69
|
name: handlersName,
|
|
70
|
-
|
|
70
|
+
isIndexable: true,
|
|
71
|
+
isExportable: true,
|
|
72
|
+
nodes: [_kubb_core.ast.factory.createText(`export const ${handlersName} = ${JSON.stringify(handlers).replaceAll("\"", "")} as const`)]
|
|
71
73
|
})]
|
|
72
|
-
});
|
|
74
|
+
})];
|
|
73
75
|
}
|
|
74
76
|
});
|
|
75
77
|
//#endregion
|
|
@@ -82,7 +84,7 @@ const handlersGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
82
84
|
*/
|
|
83
85
|
const mswGenerator = (0, _kubb_core.defineGenerator)({
|
|
84
86
|
name: "msw",
|
|
85
|
-
renderer: _kubb_renderer_jsx.
|
|
87
|
+
renderer: _kubb_renderer_jsx.jsxRenderer,
|
|
86
88
|
operation(node, ctx) {
|
|
87
89
|
if (!_kubb_core.ast.isHttpOperationNode(node)) return null;
|
|
88
90
|
const { driver, resolver, config, root } = ctx;
|
|
@@ -213,4 +215,4 @@ Object.defineProperty(exports, "mswGenerator", {
|
|
|
213
215
|
}
|
|
214
216
|
});
|
|
215
217
|
|
|
216
|
-
//# sourceMappingURL=generators-
|
|
218
|
+
//# sourceMappingURL=generators-CkGOweF4.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generators-CkGOweF4.cjs","names":["ast","jsxRenderer","ast","pluginFakerName","resolveFakerMeta","pluginTsName","resolveResponseTypes","getOperationSuccessResponses","File","Response","MockWithFaker","Mock"],"sources":["../src/generators/handlersGenerator.ts","../src/generators/mswGenerator.tsx"],"sourcesContent":["import { ast, defineGenerator } from '@kubb/core'\nimport type { PluginMsw } from '../types'\n\n/**\n * Aggregate generator enabled by `pluginMsw({ handlers: true })`. Emits a\n * `handlers.ts` file that re-exports every generated handler grouped by HTTP\n * method, ready to spread into `setupServer(...handlers)` or\n * `setupWorker(...handlers)`.\n */\nexport const handlersGenerator = defineGenerator<PluginMsw>({\n name: 'plugin-msw',\n operations(nodes, ctx) {\n const { resolver, config, root } = ctx\n const { output, group } = ctx.options\n\n const handlersName = resolver.resolveHandlersName()\n const file = resolver.resolveFile({ name: resolver.resolvePathName(handlersName, 'file'), extname: '.ts' }, { root, output, group: group ?? undefined })\n\n const imports = nodes.map((node) => {\n const operationName = resolver.resolveHandlerName(node)\n const operationFile = resolver.resolveFile(\n { name: resolver.resolveName(node.operationId), extname: '.ts', tag: node.tags[0] ?? 'default', path: node.path },\n { root, output, group: group ?? undefined },\n )\n return ast.factory.createImport({ name: [operationName], root: file.path, path: operationFile.path })\n })\n\n const handlers = nodes.map((node) => `${resolver.resolveHandlerName(node)}()`)\n\n return [\n ast.factory.createFile({\n baseName: file.baseName,\n path: file.path,\n meta: file.meta,\n banner: resolver.resolveBanner(ctx.meta, { output, config, file: { path: file.path, baseName: file.baseName } }),\n footer: resolver.resolveFooter(ctx.meta, { output, config, file: { path: file.path, baseName: file.baseName } }),\n imports,\n sources: [\n ast.factory.createSource({\n name: handlersName,\n isIndexable: true,\n isExportable: true,\n nodes: [ast.factory.createText(`export const ${handlersName} = ${JSON.stringify(handlers).replaceAll('\"', '')} as const`)],\n }),\n ],\n }),\n ]\n },\n})\n","import { getOperationSuccessResponses, resolveResponseTypes } from '@internals/shared'\nimport { ast, defineGenerator } from '@kubb/core'\nimport { pluginFakerName } from '@kubb/plugin-faker'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File, jsxRenderer } from '@kubb/renderer-jsx'\nimport { Mock, MockWithFaker, Response } from '../components'\nimport type { PluginMsw } from '../types'\nimport { resolveFakerMeta } from '../utils.ts'\n\n/**\n * Built-in operation generator for `@kubb/plugin-msw`. Emits one MSW handler\n * per OpenAPI operation. With `parser: 'faker'` the handler returns a value\n * from `@kubb/plugin-faker`; with `parser: 'data'` it returns a typed empty\n * payload for tests to fill in.\n */\nexport const mswGenerator = defineGenerator<PluginMsw>({\n name: 'msw',\n renderer: jsxRenderer,\n operation(node, ctx) {\n if (!ast.isHttpOperationNode(node)) return null\n const { driver, resolver, config, root } = ctx\n const { output, parser, baseURL, group } = ctx.options\n\n const fileName = resolver.resolveName(node.operationId)\n const mock = {\n name: resolver.resolveHandlerName(node),\n file: resolver.resolveFile(\n { name: fileName, extname: '.ts', tag: node.tags[0] ?? 'default', path: node.path },\n { root, output, group: group ?? undefined },\n ),\n }\n\n const fakerPlugin = parser === 'faker' ? driver.getPlugin(pluginFakerName) : null\n const faker =\n parser === 'faker' && fakerPlugin\n ? resolveFakerMeta(node, {\n root,\n fakerResolver: driver.getResolver(pluginFakerName),\n fakerOutput: fakerPlugin.options?.output ?? output,\n fakerGroup: fakerPlugin.options?.group ?? null,\n })\n : null\n\n const pluginTs = driver.getPlugin(pluginTsName)\n if (!pluginTs) return null\n const tsResolver = driver.getResolver(pluginTsName)\n\n const type = {\n file: tsResolver.resolveFile(\n { name: node.operationId, extname: '.ts', tag: node.tags[0] ?? 'default', path: node.path },\n { root, output: pluginTs.options?.output ?? output, group: pluginTs.options?.group ?? undefined },\n ),\n responseName: tsResolver.resolveResponseName(node),\n }\n\n const types = resolveResponseTypes(node, tsResolver)\n const successResponses = getOperationSuccessResponses(node)\n const hasSuccessSchema = successResponses.some((response) => !!response.content?.[0]?.schema)\n\n const requestName = node.requestBody?.content?.[0]?.schema ? tsResolver.resolveDataName(node) : null\n\n return (\n <File\n baseName={mock.file.baseName}\n path={mock.file.path}\n meta={mock.file.meta}\n banner={resolver.resolveBanner(ctx.meta, { output, config, file: { path: mock.file.path, baseName: mock.file.baseName } })}\n footer={resolver.resolveFooter(ctx.meta, { output, config, file: { path: mock.file.path, baseName: mock.file.baseName } })}\n >\n <File.Import name={['http']} path=\"msw\" />\n <File.Import name={['HttpResponseResolver']} isTypeOnly path=\"msw\" />\n <File.Import\n name={Array.from(new Set([type.responseName, ...types.map((t) => t[1]), ...(requestName ? [requestName] : [])]))}\n path={type.file.path}\n root={mock.file.path}\n isTypeOnly\n />\n {parser === 'faker' && faker && <File.Import name={[faker.name]} root={mock.file.path} path={faker.file.path} />}\n\n {types\n .filter(([code]) => code !== 'default')\n .map(([code, typeName]) => {\n const response = node.responses.find((item) => item.statusCode === String(code))\n if (!response) return null\n return <Response key={typeName} typeName={typeName} response={response} name={mock.name} />\n })}\n\n {parser === 'faker' && faker && hasSuccessSchema ? (\n <MockWithFaker name={mock.name} typeName={type.responseName} requestTypeName={requestName} fakerName={faker.name} node={node} baseURL={baseURL} />\n ) : (\n <Mock name={mock.name} typeName={type.responseName} requestTypeName={requestName} node={node} baseURL={baseURL} />\n )}\n </File>\n )\n },\n})\n"],"mappings":";;;;;;;;;;;;;AASA,MAAa,qBAAA,GAAA,WAAA,gBAAA,CAA+C;CAC1D,MAAM;CACN,WAAW,OAAO,KAAK;EACrB,MAAM,EAAE,UAAU,Q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,MAAM,KAAK,KAAK;KAAM,MAAM,MAAM,KAAK;IAAO,CAAA;IAE9G,MACE,QAAQ,CAAC,UAAU,SAAS,SAAS,CAAC,CACtC,KAAK,CAAC,MAAM,cAAc;KACzB,MAAM,WAAW,KAAK,UAAU,MAAM,SAAS,KAAK,eAAe,OAAO,IAAI,CAAC;KAC/E,IAAI,CAAC,UAAU,OAAO;KACtB,OAAO,iBAAA,GAAA,+BAAA,IAAA,CAACC,mBAAAA,UAAD;MAAmC;MAAoB;MAAU,MAAM,KAAK;KAAO,GAApE,QAAoE;IAC5F,CAAC;IAEF,WAAW,WAAW,SAAS,mBAC9B,iBAAA,GAAA,+BAAA,IAAA,CAACC,mBAAAA,eAAD;KAAe,MAAM,KAAK;KAAM,UAAU,KAAK;KAAc,iBAAiB;KAAa,WAAW,MAAM;KAAY;KAAe;IAAU,CAAA,IAEjJ,iBAAA,GAAA,+BAAA,IAAA,CAACC,mBAAAA,MAAD;KAAM,MAAM,KAAK;KAAM,UAAU,KAAK;KAAc,iBAAiB;KAAmB;KAAe;IAAU,CAAA;GAE/G;;CAEV;AACF,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import "./chunk-C0LytTxp.js";
|
|
2
|
-
import { a as
|
|
2
|
+
import { a as getOperationSuccessResponses, i as resolveFakerMeta, n as MockWithFaker, o as resolveResponseTypes, r as Mock, t as Response } from "./components-DNiDZfAv.js";
|
|
3
3
|
import { ast, defineGenerator } from "@kubb/core";
|
|
4
4
|
import { pluginFakerName } from "@kubb/plugin-faker";
|
|
5
5
|
import { pluginTsName } from "@kubb/plugin-ts";
|
|
6
|
-
import { File,
|
|
6
|
+
import { File, jsxRenderer } from "@kubb/renderer-jsx";
|
|
7
7
|
import { jsx, jsxs } from "@kubb/renderer-jsx/jsx-runtime";
|
|
8
|
-
//#region src/generators/handlersGenerator.
|
|
8
|
+
//#region src/generators/handlersGenerator.ts
|
|
9
9
|
/**
|
|
10
10
|
* Aggregate generator enabled by `pluginMsw({ handlers: true })`. Emits a
|
|
11
11
|
* `handlers.ts` file that re-exports every generated handler grouped by HTTP
|
|
@@ -14,7 +14,6 @@ import { jsx, jsxs } from "@kubb/renderer-jsx/jsx-runtime";
|
|
|
14
14
|
*/
|
|
15
15
|
const handlersGenerator = defineGenerator({
|
|
16
16
|
name: "plugin-msw",
|
|
17
|
-
renderer: jsxRendererSync,
|
|
18
17
|
operations(nodes, ctx) {
|
|
19
18
|
const { resolver, config, root } = ctx;
|
|
20
19
|
const { output, group } = ctx.options;
|
|
@@ -39,14 +38,14 @@ const handlersGenerator = defineGenerator({
|
|
|
39
38
|
output,
|
|
40
39
|
group: group ?? void 0
|
|
41
40
|
});
|
|
42
|
-
return
|
|
41
|
+
return ast.factory.createImport({
|
|
43
42
|
name: [operationName],
|
|
44
43
|
root: file.path,
|
|
45
44
|
path: operationFile.path
|
|
46
|
-
}
|
|
45
|
+
});
|
|
47
46
|
});
|
|
48
47
|
const handlers = nodes.map((node) => `${resolver.resolveHandlerName(node)}()`);
|
|
49
|
-
return
|
|
48
|
+
return [ast.factory.createFile({
|
|
50
49
|
baseName: file.baseName,
|
|
51
50
|
path: file.path,
|
|
52
51
|
meta: file.meta,
|
|
@@ -66,11 +65,14 @@ const handlersGenerator = defineGenerator({
|
|
|
66
65
|
baseName: file.baseName
|
|
67
66
|
}
|
|
68
67
|
}),
|
|
69
|
-
|
|
68
|
+
imports,
|
|
69
|
+
sources: [ast.factory.createSource({
|
|
70
70
|
name: handlersName,
|
|
71
|
-
|
|
71
|
+
isIndexable: true,
|
|
72
|
+
isExportable: true,
|
|
73
|
+
nodes: [ast.factory.createText(`export const ${handlersName} = ${JSON.stringify(handlers).replaceAll("\"", "")} as const`)]
|
|
72
74
|
})]
|
|
73
|
-
});
|
|
75
|
+
})];
|
|
74
76
|
}
|
|
75
77
|
});
|
|
76
78
|
//#endregion
|
|
@@ -83,7 +85,7 @@ const handlersGenerator = defineGenerator({
|
|
|
83
85
|
*/
|
|
84
86
|
const mswGenerator = defineGenerator({
|
|
85
87
|
name: "msw",
|
|
86
|
-
renderer:
|
|
88
|
+
renderer: jsxRenderer,
|
|
87
89
|
operation(node, ctx) {
|
|
88
90
|
if (!ast.isHttpOperationNode(node)) return null;
|
|
89
91
|
const { driver, resolver, config, root } = ctx;
|
|
@@ -203,4 +205,4 @@ const mswGenerator = defineGenerator({
|
|
|
203
205
|
//#endregion
|
|
204
206
|
export { handlersGenerator as n, mswGenerator as t };
|
|
205
207
|
|
|
206
|
-
//# sourceMappingURL=generators-
|
|
208
|
+
//# sourceMappingURL=generators-U8mPM19f.js.map
|