@kubb/plugin-msw 5.0.0-beta.4 → 5.0.0-beta.56
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/README.md +39 -22
- package/dist/{components-vO0FIb2i.js → components-Bi7cN-ws.js} +111 -199
- package/dist/components-Bi7cN-ws.js.map +1 -0
- package/dist/{components-CLQ77DVn.cjs → components-Bp69JYOt.cjs} +113 -213
- package/dist/components-Bp69JYOt.cjs.map +1 -0
- package/dist/components.cjs +1 -2
- package/dist/components.d.ts +6 -19
- package/dist/components.js +2 -2
- package/dist/{generators-BPJCs1x1.js → generators-BnEvTy3q.js} +71 -39
- package/dist/generators-BnEvTy3q.js.map +1 -0
- package/dist/{generators-CrmMwWE4.cjs → generators-d22_s2UN.cjs} +69 -37
- package/dist/generators-d22_s2UN.cjs.map +1 -0
- package/dist/generators.cjs +1 -1
- package/dist/generators.d.ts +16 -5
- package/dist/generators.js +1 -1
- package/dist/index.cjs +112 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +33 -4
- package/dist/index.js +113 -18
- package/dist/index.js.map +1 -1
- package/dist/types-B1yTWOfj.d.ts +99 -0
- package/package.json +13 -23
- package/src/components/Mock.tsx +7 -6
- package/src/components/MockWithFaker.tsx +7 -6
- package/src/components/Response.tsx +1 -1
- package/src/components/index.ts +0 -1
- package/src/generators/handlersGenerator.ts +49 -0
- package/src/generators/index.ts +1 -1
- package/src/generators/mswGenerator.tsx +27 -16
- package/src/plugin.ts +35 -19
- package/src/resolvers/resolverMsw.ts +21 -5
- package/src/types.ts +36 -26
- package/src/utils.ts +26 -61
- package/dist/components-CLQ77DVn.cjs.map +0 -1
- package/dist/components-vO0FIb2i.js.map +0 -1
- package/dist/generators-BPJCs1x1.js.map +0 -1
- package/dist/generators-CrmMwWE4.cjs.map +0 -1
- package/dist/types-Dxu0KMQ4.d.ts +0 -89
- package/extension.yaml +0 -260
- package/src/components/Handlers.tsx +0 -19
- package/src/generators/handlersGenerator.tsx +0 -41
- /package/dist/{chunk--u3MIqq1.js → chunk-C0LytTxp.js} +0 -0
|
@@ -1,34 +1,45 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getOperationSuccessResponses, resolveResponseTypes } from '@internals/shared'
|
|
2
|
+
import { ast, defineGenerator } from '@kubb/core'
|
|
2
3
|
import { pluginFakerName } from '@kubb/plugin-faker'
|
|
3
4
|
import { pluginTsName } from '@kubb/plugin-ts'
|
|
4
5
|
import { File, jsxRenderer } from '@kubb/renderer-jsx'
|
|
5
6
|
import { Mock, MockWithFaker, Response } from '../components'
|
|
6
7
|
import type { PluginMsw } from '../types'
|
|
7
|
-
import {
|
|
8
|
+
import { resolveFakerMeta } from '../utils.ts'
|
|
8
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Built-in operation generator for `@kubb/plugin-msw`. Emits one MSW handler
|
|
12
|
+
* per OpenAPI operation. With `parser: 'faker'` the handler returns a value
|
|
13
|
+
* from `@kubb/plugin-faker`; with `parser: 'data'` it returns a typed empty
|
|
14
|
+
* payload for tests to fill in.
|
|
15
|
+
*/
|
|
9
16
|
export const mswGenerator = defineGenerator<PluginMsw>({
|
|
10
17
|
name: 'msw',
|
|
11
18
|
renderer: jsxRenderer,
|
|
12
19
|
operation(node, ctx) {
|
|
13
|
-
|
|
14
|
-
const {
|
|
20
|
+
if (!ast.isHttpOperationNode(node)) return null
|
|
21
|
+
const { driver, resolver, config, root } = ctx
|
|
22
|
+
const { output, parser, baseURL, group } = ctx.options
|
|
15
23
|
|
|
16
24
|
const fileName = resolver.resolveName(node.operationId)
|
|
17
25
|
const mock = {
|
|
18
|
-
name:
|
|
19
|
-
file: resolver.resolveFile(
|
|
26
|
+
name: resolver.resolveHandlerName(node),
|
|
27
|
+
file: resolver.resolveFile(
|
|
28
|
+
{ name: fileName, extname: '.ts', tag: node.tags[0] ?? 'default', path: node.path },
|
|
29
|
+
{ root, output, group: group ?? undefined },
|
|
30
|
+
),
|
|
20
31
|
}
|
|
21
32
|
|
|
22
|
-
const fakerPlugin = parser === 'faker' ? driver.getPlugin(pluginFakerName) :
|
|
33
|
+
const fakerPlugin = parser === 'faker' ? driver.getPlugin(pluginFakerName) : null
|
|
23
34
|
const faker =
|
|
24
35
|
parser === 'faker' && fakerPlugin
|
|
25
36
|
? resolveFakerMeta(node, {
|
|
26
37
|
root,
|
|
27
38
|
fakerResolver: driver.getResolver(pluginFakerName),
|
|
28
39
|
fakerOutput: fakerPlugin.options?.output ?? output,
|
|
29
|
-
fakerGroup: fakerPlugin.options?.group,
|
|
40
|
+
fakerGroup: fakerPlugin.options?.group ?? null,
|
|
30
41
|
})
|
|
31
|
-
:
|
|
42
|
+
: null
|
|
32
43
|
|
|
33
44
|
const pluginTs = driver.getPlugin(pluginTsName)
|
|
34
45
|
if (!pluginTs) return null
|
|
@@ -37,24 +48,24 @@ export const mswGenerator = defineGenerator<PluginMsw>({
|
|
|
37
48
|
const type = {
|
|
38
49
|
file: tsResolver.resolveFile(
|
|
39
50
|
{ name: node.operationId, extname: '.ts', tag: node.tags[0] ?? 'default', path: node.path },
|
|
40
|
-
{ root, output: pluginTs.options?.output ?? output, group: pluginTs.options?.group },
|
|
51
|
+
{ root, output: pluginTs.options?.output ?? output, group: pluginTs.options?.group ?? undefined },
|
|
41
52
|
),
|
|
42
53
|
responseName: tsResolver.resolveResponseName(node),
|
|
43
54
|
}
|
|
44
55
|
|
|
45
|
-
const types =
|
|
46
|
-
const successResponses =
|
|
47
|
-
const hasSuccessSchema = successResponses.some((response) => !!response.schema)
|
|
56
|
+
const types = resolveResponseTypes(node, tsResolver)
|
|
57
|
+
const successResponses = getOperationSuccessResponses(node)
|
|
58
|
+
const hasSuccessSchema = successResponses.some((response) => !!response.content?.[0]?.schema)
|
|
48
59
|
|
|
49
|
-
const requestName = node.requestBody?.content?.[0]?.schema ? tsResolver.resolveDataName(node) :
|
|
60
|
+
const requestName = node.requestBody?.content?.[0]?.schema ? tsResolver.resolveDataName(node) : null
|
|
50
61
|
|
|
51
62
|
return (
|
|
52
63
|
<File
|
|
53
64
|
baseName={mock.file.baseName}
|
|
54
65
|
path={mock.file.path}
|
|
55
66
|
meta={mock.file.meta}
|
|
56
|
-
banner={resolver.resolveBanner(
|
|
57
|
-
footer={resolver.resolveFooter(
|
|
67
|
+
banner={resolver.resolveBanner(ctx.meta, { output, config, file: { path: mock.file.path, baseName: mock.file.baseName } })}
|
|
68
|
+
footer={resolver.resolveFooter(ctx.meta, { output, config, file: { path: mock.file.path, baseName: mock.file.baseName } })}
|
|
58
69
|
>
|
|
59
70
|
<File.Import name={['http']} path="msw" />
|
|
60
71
|
<File.Import name={['HttpResponseResolver']} isTypeOnly path="msw" />
|
package/src/plugin.ts
CHANGED
|
@@ -1,21 +1,50 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { definePlugin
|
|
1
|
+
import { createGroupConfig } from '@internals/shared'
|
|
2
|
+
import { definePlugin } from '@kubb/core'
|
|
3
3
|
import { pluginFakerName } from '@kubb/plugin-faker'
|
|
4
4
|
import { pluginTsName } from '@kubb/plugin-ts'
|
|
5
5
|
import { handlersGenerator, mswGenerator } from './generators'
|
|
6
6
|
import { resolverMsw } from './resolvers/resolverMsw.ts'
|
|
7
7
|
import type { PluginMsw } from './types.ts'
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Canonical plugin name for `@kubb/plugin-msw`. Used for driver lookups and
|
|
11
|
+
* cross-plugin dependency references.
|
|
12
|
+
*/
|
|
9
13
|
export const pluginMswName = 'plugin-msw' satisfies PluginMsw['name']
|
|
10
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Generates MSW request handlers from an OpenAPI spec. Drop them into your
|
|
17
|
+
* test setup or service worker to mock the API end-to-end. Request path,
|
|
18
|
+
* method, status, and response body all stay in sync with the spec. Combine
|
|
19
|
+
* with `@kubb/plugin-faker` (via `parser: 'faker'`) to seed handlers with
|
|
20
|
+
* realistic data.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* import { defineConfig } from 'kubb'
|
|
25
|
+
* import { pluginTs } from '@kubb/plugin-ts'
|
|
26
|
+
* import { pluginMsw } from '@kubb/plugin-msw'
|
|
27
|
+
*
|
|
28
|
+
* export default defineConfig({
|
|
29
|
+
* input: { path: './petStore.yaml' },
|
|
30
|
+
* output: { path: './src/gen' },
|
|
31
|
+
* plugins: [
|
|
32
|
+
* pluginTs(),
|
|
33
|
+
* pluginMsw({
|
|
34
|
+
* output: { path: './handlers' },
|
|
35
|
+
* handlers: true,
|
|
36
|
+
* }),
|
|
37
|
+
* ],
|
|
38
|
+
* })
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
11
41
|
export const pluginMsw = definePlugin<PluginMsw>((options) => {
|
|
12
42
|
const {
|
|
13
|
-
output = { path: 'handlers',
|
|
43
|
+
output = { path: 'handlers', barrel: { type: 'named' } },
|
|
14
44
|
group,
|
|
15
45
|
exclude = [],
|
|
16
46
|
include,
|
|
17
47
|
override = [],
|
|
18
|
-
transformers = {},
|
|
19
48
|
handlers = false,
|
|
20
49
|
parser = 'data',
|
|
21
50
|
baseURL,
|
|
@@ -24,24 +53,12 @@ export const pluginMsw = definePlugin<PluginMsw>((options) => {
|
|
|
24
53
|
generators: userGenerators = [],
|
|
25
54
|
} = options
|
|
26
55
|
|
|
27
|
-
const groupConfig = group
|
|
28
|
-
? ({
|
|
29
|
-
...group,
|
|
30
|
-
name: group.name
|
|
31
|
-
? group.name
|
|
32
|
-
: (ctx: { group: string }) => {
|
|
33
|
-
if (group.type === 'path') {
|
|
34
|
-
return `${ctx.group.split('/')[1]}`
|
|
35
|
-
}
|
|
36
|
-
return `${camelCase(ctx.group)}Controller`
|
|
37
|
-
},
|
|
38
|
-
} satisfies Group)
|
|
39
|
-
: undefined
|
|
56
|
+
const groupConfig = createGroupConfig(group)
|
|
40
57
|
|
|
41
58
|
return {
|
|
42
59
|
name: pluginMswName,
|
|
43
60
|
options,
|
|
44
|
-
dependencies: [pluginTsName, parser === 'faker' ? pluginFakerName :
|
|
61
|
+
dependencies: [pluginTsName, parser === 'faker' ? pluginFakerName : null].filter((dependency): dependency is string => Boolean(dependency)),
|
|
45
62
|
hooks: {
|
|
46
63
|
'kubb:plugin:setup'(ctx) {
|
|
47
64
|
const resolver = userResolver ? { ...resolverMsw, ...userResolver } : resolverMsw
|
|
@@ -55,7 +72,6 @@ export const pluginMsw = definePlugin<PluginMsw>((options) => {
|
|
|
55
72
|
include,
|
|
56
73
|
override,
|
|
57
74
|
handlers,
|
|
58
|
-
transformers,
|
|
59
75
|
resolver,
|
|
60
76
|
})
|
|
61
77
|
ctx.setResolver(resolver)
|
|
@@ -1,19 +1,35 @@
|
|
|
1
|
-
import { camelCase } from '@internals/utils'
|
|
1
|
+
import { camelCase, toFilePath } from '@internals/utils'
|
|
2
2
|
import { defineResolver } from '@kubb/core'
|
|
3
3
|
import type { PluginMsw } from '../types.ts'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Default resolver used by `@kubb/plugin-msw`. Decides the names and file
|
|
7
|
+
* paths for every generated MSW handler. Function names get a `Handler`
|
|
8
|
+
* suffix; the aggregate export is always `handlers`.
|
|
7
9
|
*
|
|
8
|
-
*
|
|
10
|
+
* @example Resolve a handler name
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { resolverMsw } from '@kubb/plugin-msw'
|
|
13
|
+
*
|
|
14
|
+
* resolverMsw.resolveName('addPet') // 'addPetHandler'
|
|
15
|
+
* ```
|
|
9
16
|
*/
|
|
10
|
-
export const resolverMsw = defineResolver<PluginMsw>((
|
|
17
|
+
export const resolverMsw = defineResolver<PluginMsw>(() => ({
|
|
11
18
|
name: 'default',
|
|
12
19
|
pluginName: 'plugin-msw',
|
|
13
20
|
default(name, type) {
|
|
14
|
-
return
|
|
21
|
+
return type === 'file' ? toFilePath(name) : camelCase(name)
|
|
15
22
|
},
|
|
16
23
|
resolveName(name) {
|
|
17
24
|
return camelCase(name, { suffix: 'handler' })
|
|
18
25
|
},
|
|
26
|
+
resolvePathName(name, type) {
|
|
27
|
+
return this.default(name, type)
|
|
28
|
+
},
|
|
29
|
+
resolveHandlerName(node) {
|
|
30
|
+
return this.resolveName(node.operationId)
|
|
31
|
+
},
|
|
32
|
+
resolveHandlersName() {
|
|
33
|
+
return 'handlers'
|
|
34
|
+
},
|
|
19
35
|
}))
|
package/src/types.ts
CHANGED
|
@@ -1,79 +1,89 @@
|
|
|
1
|
-
import type { ast, Exclude, Generator, Group, Include, Output, Override, PluginFactoryOptions,
|
|
1
|
+
import type { ast, Exclude, Generator, Group, Include, Output, OutputOptions, Override, PluginFactoryOptions, Resolver } from '@kubb/core'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Resolver for MSW that provides naming methods for handler functions.
|
|
5
5
|
*/
|
|
6
6
|
export type ResolverMsw = Resolver & {
|
|
7
7
|
/**
|
|
8
|
-
* Resolves the handler function name for an operation.
|
|
8
|
+
* Resolves the base handler function name for an operation.
|
|
9
9
|
*/
|
|
10
10
|
resolveName(this: ResolverMsw, name: string): string
|
|
11
|
+
/**
|
|
12
|
+
* Resolves the output file name for an MSW handler module.
|
|
13
|
+
*/
|
|
14
|
+
resolvePathName(this: ResolverMsw, name: string, type?: 'file' | 'function' | 'type' | 'const'): string
|
|
15
|
+
/**
|
|
16
|
+
* Resolves the handler function name for an operation.
|
|
17
|
+
*/
|
|
18
|
+
resolveHandlerName(this: ResolverMsw, node: ast.OperationNode): string
|
|
19
|
+
/**
|
|
20
|
+
* Resolves the exported handlers collection name.
|
|
21
|
+
*/
|
|
22
|
+
resolveHandlersName(this: ResolverMsw): string
|
|
11
23
|
}
|
|
12
24
|
|
|
13
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Where the generated MSW handlers are written and how they are exported, plus the optional
|
|
27
|
+
* `group` strategy. The `group` option organizes `output.mode: 'directory'` output into per-tag or per-path subdirectories.
|
|
28
|
+
*
|
|
29
|
+
* @default { path: 'handlers', barrel: { type: 'named' } }
|
|
30
|
+
*/
|
|
31
|
+
export type Options = OutputOptions & {
|
|
14
32
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
33
|
+
* Base URL prepended to every handler's request URL. When omitted, falls back
|
|
34
|
+
* to the adapter's server URL (typically `servers[0].url`).
|
|
17
35
|
*/
|
|
18
|
-
output?: Output
|
|
19
36
|
baseURL?: string
|
|
20
37
|
/**
|
|
21
|
-
*
|
|
22
|
-
*/
|
|
23
|
-
group?: Group
|
|
24
|
-
/**
|
|
25
|
-
* Tags, operations, or paths to exclude from generation.
|
|
38
|
+
* Skip operations matching at least one entry in the list.
|
|
26
39
|
*/
|
|
27
40
|
exclude?: Array<Exclude>
|
|
28
41
|
/**
|
|
29
|
-
*
|
|
42
|
+
* Restrict generation to operations matching at least one entry in the list.
|
|
30
43
|
*/
|
|
31
44
|
include?: Array<Include>
|
|
32
45
|
/**
|
|
33
|
-
*
|
|
46
|
+
* Apply a different options object to operations matching a pattern.
|
|
34
47
|
*/
|
|
35
48
|
override?: Array<Override<ResolvedOptions>>
|
|
36
|
-
transformers?: {
|
|
37
|
-
/**
|
|
38
|
-
* Override the default naming for handlers.
|
|
39
|
-
*/
|
|
40
|
-
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string
|
|
41
|
-
}
|
|
42
49
|
/**
|
|
43
|
-
* Override
|
|
50
|
+
* Override how handler names and file paths are built.
|
|
44
51
|
*/
|
|
45
52
|
resolver?: Partial<ResolverMsw> & ThisType<ResolverMsw>
|
|
46
53
|
/**
|
|
47
|
-
* AST visitor to
|
|
54
|
+
* AST visitor applied to operation nodes before printing.
|
|
48
55
|
*/
|
|
49
56
|
transformer?: ast.Visitor
|
|
50
57
|
/**
|
|
51
|
-
*
|
|
58
|
+
* Emit a `handlers.ts` file that re-exports every handler grouped by HTTP method.
|
|
59
|
+
* Drop the file into `setupServer(...handlers)` or `setupWorker(...handlers)`.
|
|
60
|
+
*
|
|
52
61
|
* @default false
|
|
53
62
|
*/
|
|
54
63
|
handlers?: boolean
|
|
55
64
|
/**
|
|
56
|
-
*
|
|
65
|
+
* Source of the response body returned by each generated handler.
|
|
66
|
+
* - `'data'` — typed empty/example payload, ready for you to fill in from tests.
|
|
67
|
+
* - `'faker'` — value produced by `@kubb/plugin-faker`.
|
|
57
68
|
*
|
|
58
69
|
* @default 'data'
|
|
59
70
|
*/
|
|
60
71
|
parser?: 'data' | 'faker'
|
|
61
72
|
/**
|
|
62
|
-
*
|
|
73
|
+
* Custom generators that run alongside the built-in MSW generators.
|
|
63
74
|
*/
|
|
64
75
|
generators?: Array<Generator<PluginMsw>>
|
|
65
76
|
}
|
|
66
77
|
|
|
67
78
|
type ResolvedOptions = {
|
|
68
79
|
output: Output
|
|
69
|
-
group: Group |
|
|
80
|
+
group: Group | null
|
|
70
81
|
exclude: NonNullable<Options['exclude']>
|
|
71
82
|
include: Options['include']
|
|
72
83
|
override: NonNullable<Options['override']>
|
|
73
84
|
parser: NonNullable<Options['parser']>
|
|
74
85
|
baseURL: Options['baseURL'] | undefined
|
|
75
86
|
handlers: boolean
|
|
76
|
-
transformers: NonNullable<Options['transformers']>
|
|
77
87
|
resolver: ResolverMsw
|
|
78
88
|
}
|
|
79
89
|
|
package/src/utils.ts
CHANGED
|
@@ -1,90 +1,52 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ast } from '@kubb/core'
|
|
2
2
|
import type { ResolverFaker } from '@kubb/plugin-faker'
|
|
3
|
-
import type { ResolverTs } from '@kubb/plugin-ts'
|
|
4
3
|
import type { PluginMsw } from './types.ts'
|
|
5
4
|
|
|
6
|
-
/**
|
|
7
|
-
* Applies a name transformer function to a name if configured, otherwise returns it unchanged.
|
|
8
|
-
*/
|
|
9
|
-
export function transformName(name: string, type: 'function' | 'type' | 'file' | 'const', transformers?: PluginMsw['resolvedOptions']['transformers']): string {
|
|
10
|
-
return transformers?.name?.(name, type) || name
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Filters responses to only those with 2xx status codes.
|
|
15
|
-
*/
|
|
16
|
-
export function getSuccessResponses(node: ast.OperationNode): ast.ResponseNode[] {
|
|
17
|
-
return node.responses.filter((response) => {
|
|
18
|
-
const code = Number.parseInt(response.statusCode, 10)
|
|
19
|
-
return !Number.isNaN(code) && code >= 200 && code < 300
|
|
20
|
-
})
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Returns the first 2xx response for an operation, if any.
|
|
25
|
-
*/
|
|
26
|
-
export function getPrimarySuccessResponse(node: ast.OperationNode): ast.ResponseNode | undefined {
|
|
27
|
-
return getSuccessResponses(node)[0]
|
|
28
|
-
}
|
|
29
|
-
|
|
30
5
|
/**
|
|
31
6
|
* Gets the content type from a response, defaulting to 'application/json' if a schema exists.
|
|
32
7
|
*/
|
|
33
|
-
export function getContentType(response: ast.ResponseNode | undefined): string |
|
|
34
|
-
|
|
8
|
+
export function getContentType(response: ast.ResponseNode | null | undefined): string | null {
|
|
9
|
+
if (!hasResponseSchema(response)) {
|
|
10
|
+
return null
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return getResponseContentType(response) ?? 'application/json'
|
|
35
14
|
}
|
|
36
15
|
|
|
37
16
|
/**
|
|
38
17
|
* Determines if a response has a schema that is not void or any.
|
|
39
18
|
*/
|
|
40
|
-
export function hasResponseSchema(response: ast.ResponseNode | undefined): boolean {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
function getResponseContentType(response: ast.ResponseNode | undefined): string | undefined {
|
|
45
|
-
const contentType = response as unknown as { mediaType?: string | null; contentType?: string | null } | undefined
|
|
46
|
-
const value = contentType?.mediaType ?? contentType?.contentType
|
|
47
|
-
return typeof value === 'string' && value.length > 0 ? value : undefined
|
|
19
|
+
export function hasResponseSchema(response: ast.ResponseNode | null | undefined): boolean {
|
|
20
|
+
const schema = response?.content?.find((entry) => entry.schema)?.schema
|
|
21
|
+
return !!schema && schema.type !== 'void' && schema.type !== 'any'
|
|
48
22
|
}
|
|
49
23
|
|
|
50
24
|
/**
|
|
51
|
-
*
|
|
25
|
+
* Picks the content type used for the mocked response header. When a response declares multiple
|
|
26
|
+
* content types, JSON is preferred (the faker mock body is JSON), otherwise the first declared type.
|
|
52
27
|
*/
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const code = Number.parseInt(response.statusCode, 10)
|
|
63
|
-
if (Number.isNaN(code)) continue
|
|
64
|
-
|
|
65
|
-
if (code >= 200 && code < 300) {
|
|
66
|
-
types.push([code, tsResolver.resolveResponseName(node)])
|
|
67
|
-
continue
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
types.push([code, tsResolver.resolveResponseStatusName(node, response.statusCode)])
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return types
|
|
28
|
+
function getResponseContentType(response: ast.ResponseNode | null | undefined): string | null {
|
|
29
|
+
const contents = response?.content ?? []
|
|
30
|
+
const jsonEntry = contents.find((entry) => {
|
|
31
|
+
const baseType = entry.contentType?.split(';')[0]?.trim().toLowerCase()
|
|
32
|
+
return baseType === 'application/json' || baseType?.endsWith('+json')
|
|
33
|
+
})
|
|
34
|
+
const value = (jsonEntry ?? contents[0])?.contentType
|
|
35
|
+
return typeof value === 'string' && value.length > 0 ? value : null
|
|
74
36
|
}
|
|
75
37
|
|
|
76
38
|
/**
|
|
77
39
|
* Converts an HTTP method to its lowercase MSW equivalent (e.g., 'POST' → 'post').
|
|
78
40
|
*/
|
|
79
41
|
export function getMswMethod(node: ast.OperationNode): string {
|
|
80
|
-
return node.method.toLowerCase()
|
|
42
|
+
return ast.isHttpOperationNode(node) ? node.method.toLowerCase() : ''
|
|
81
43
|
}
|
|
82
44
|
|
|
83
45
|
/**
|
|
84
46
|
* Converts an OpenAPI-style path to an Express/MSW-style path by replacing `{param}` with `:param`.
|
|
85
47
|
*/
|
|
86
48
|
export function getMswUrl(node: ast.OperationNode): string {
|
|
87
|
-
return node.path.replaceAll('{', ':').replaceAll('}', '')
|
|
49
|
+
return ast.isHttpOperationNode(node) ? node.path.replaceAll('{', ':').replaceAll('}', '') : ''
|
|
88
50
|
}
|
|
89
51
|
|
|
90
52
|
/**
|
|
@@ -104,6 +66,9 @@ export function resolveFakerMeta(
|
|
|
104
66
|
|
|
105
67
|
return {
|
|
106
68
|
name: fakerResolver.resolveResponseName(node),
|
|
107
|
-
file: fakerResolver.resolveFile(
|
|
69
|
+
file: fakerResolver.resolveFile(
|
|
70
|
+
{ name: node.operationId, extname: '.ts', tag, path: node.path },
|
|
71
|
+
{ root, output: fakerOutput, group: fakerGroup ?? undefined },
|
|
72
|
+
),
|
|
108
73
|
}
|
|
109
74
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"components-CLQ77DVn.cjs","names":["#options","#transformParam","#eachParam","File","declarationPrinter","ast","File","Function","declarationPrinter","ast","File","Function","ast","File","Function"],"sources":["../../../internals/utils/src/casing.ts","../../../internals/utils/src/reserved.ts","../../../internals/utils/src/urlPath.ts","../src/components/Handlers.tsx","../src/utils.ts","../src/components/Mock.tsx","../src/components/MockWithFaker.tsx","../src/components/Response.tsx"],"sourcesContent":["type Options = {\n /**\n * When `true`, dot-separated segments are split on `.` and joined with `/` after casing.\n */\n isFile?: boolean\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 const normalized = 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\n const words = normalized.split(/[\\s\\-_./\\\\:]+/).filter(Boolean)\n\n return words\n .map((word, i) => {\n const allUpper = word.length > 1 && word === word.toUpperCase()\n if (allUpper) return word\n if (i === 0 && !pascal) return word.charAt(0).toLowerCase() + word.slice(1)\n return word.charAt(0).toUpperCase() + word.slice(1)\n })\n .join('')\n .replace(/[^a-zA-Z0-9]/g, '')\n}\n\n/**\n * Splits `text` on `.` and applies `transformPart` to each segment.\n * The last segment receives `isLast = true`, all earlier segments receive `false`.\n * Segments are joined with `/` to form a file path.\n *\n * Only splits on dots followed by a letter so that version numbers\n * embedded in operationIds (e.g. `v2025.0`) are kept intact.\n */\nfunction applyToFileParts(text: string, transformPart: (part: string, isLast: boolean) => string): string {\n const parts = text.split(/\\.(?=[a-zA-Z])/)\n return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join('/')\n}\n\n/**\n * Converts `text` to camelCase.\n * When `isFile` is `true`, dot-separated segments are each cased independently and joined with `/`.\n *\n * @example\n * camelCase('hello-world') // 'helloWorld'\n * camelCase('pet.petId', { isFile: true }) // 'pet/petId'\n */\nexport function camelCase(text: string, { isFile, prefix = '', suffix = '' }: Options = {}): string {\n if (isFile) {\n return applyToFileParts(text, (part, isLast) => camelCase(part, isLast ? { prefix, suffix } : {}))\n }\n\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false)\n}\n\n/**\n * Converts `text` to PascalCase.\n * When `isFile` is `true`, the last dot-separated segment is PascalCased and earlier segments are camelCased.\n *\n * @example\n * pascalCase('hello-world') // 'HelloWorld'\n * pascalCase('pet.petId', { isFile: true }) // 'pet/PetId'\n */\nexport function pascalCase(text: string, { isFile, prefix = '', suffix = '' }: Options = {}): string {\n if (isFile) {\n return applyToFileParts(text, (part, isLast) => (isLast ? pascalCase(part, { prefix, suffix }) : camelCase(part)))\n }\n\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true)\n}\n\n/**\n * Converts `text` to snake_case.\n *\n * @example\n * snakeCase('helloWorld') // 'hello_world'\n * snakeCase('Hello-World') // 'hello_world'\n */\nexport function snakeCase(text: string, { prefix = '', suffix = '' }: Omit<Options, 'isFile'> = {}): 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\n * screamingSnakeCase('helloWorld') // 'HELLO_WORLD'\n */\nexport function screamingSnakeCase(text: string, { prefix = '', suffix = '' }: Omit<Options, 'isFile'> = {}): 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","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 `undefined` when the path has none.\n */\n params?: Record<string, string>\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 * Optional 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\n/**\n * Supported identifier casing strategies for path parameters.\n */\ntype PathCasing = 'camelcase'\n\ntype Options = {\n /**\n * Casing strategy applied to path parameter names.\n * @default undefined (original identifier preserved)\n */\n casing?: PathCasing\n}\n\n/**\n * Parses and transforms an OpenAPI/Swagger path string into various URL formats.\n *\n * @example\n * const p = new URLPath('/pet/{petId}')\n * p.URL // '/pet/:petId'\n * p.template // '`/pet/${petId}`'\n */\nexport class URLPath {\n /**\n * The raw OpenAPI/Swagger path string, e.g. `/pet/{petId}`.\n */\n path: string\n\n #options: Options\n\n constructor(path: string, options: Options = {}) {\n this.path = path\n this.#options = options\n }\n\n /** Converts the OpenAPI path to Express-style colon syntax, e.g. `/pet/{petId}` → `/pet/:petId`.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}').URL // '/pet/:petId'\n * ```\n */\n get URL(): string {\n return this.toURLPath()\n }\n\n /** Returns `true` when `path` is a fully-qualified URL (e.g. starts with `https://`).\n *\n * @example\n * ```ts\n * new URLPath('https://petstore.swagger.io/v2/pet').isURL // true\n * new URLPath('/pet/{petId}').isURL // false\n * ```\n */\n get isURL(): boolean {\n try {\n return !!new URL(this.path).href\n } catch {\n return false\n }\n }\n\n /**\n * Converts the OpenAPI path to a TypeScript template literal string.\n *\n * @example\n * new URLPath('/pet/{petId}').template // '`/pet/${petId}`'\n * new URLPath('/account/monetary-accountID').template // '`/account/${monetaryAccountId}`'\n */\n get template(): string {\n return this.toTemplateString()\n }\n\n /** Returns the path and its extracted params as a structured `URLObject`, or as a stringified expression when `stringify` is set.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}').object\n * // { url: '/pet/:petId', params: { petId: 'petId' } }\n * ```\n */\n get object(): URLObject | string {\n return this.toObject()\n }\n\n /** Returns a map of path parameter names, or `undefined` when the path has no parameters.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}').params // { petId: 'petId' }\n * new URLPath('/pet').params // undefined\n * ```\n */\n get params(): Record<string, string> | undefined {\n return this.getParams()\n }\n\n #transformParam(raw: string): string {\n const param = isValidVarName(raw) ? raw : camelCase(raw)\n return this.#options.casing === 'camelcase' ? camelCase(param) : param\n }\n\n /**\n * Iterates over every `{param}` token in `path`, calling `fn` with the raw token and transformed name.\n */\n #eachParam(fn: (raw: string, param: string) => void): void {\n for (const match of this.path.matchAll(/\\{([^}]+)\\}/g)) {\n const raw = match[1]!\n fn(raw, this.#transformParam(raw))\n }\n }\n\n toObject({ type = 'path', replacer, stringify }: ObjectOptions = {}): URLObject | string {\n const object = {\n url: type === 'path' ? this.toURLPath() : this.toTemplateString({ replacer }),\n params: this.getParams(),\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 /**\n * Converts the OpenAPI path to a TypeScript template literal string.\n * An optional `replacer` can transform each extracted parameter name before interpolation.\n *\n * @example\n * new URLPath('/pet/{petId}').toTemplateString() // '`/pet/${petId}`'\n */\n toTemplateString({ prefix = '', replacer }: { prefix?: string; replacer?: (pathParam: string) => string } = {}): string {\n const parts = this.path.split(/\\{([^}]+)\\}/)\n const result = parts\n .map((part, i) => {\n if (i % 2 === 0) return part\n const param = this.#transformParam(part)\n return `\\${${replacer ? replacer(param) : param}}`\n })\n .join('')\n\n return `\\`${prefix}${result}\\``\n }\n\n /**\n * Extracts all `{param}` segments from the path and returns them as a key-value map.\n * An optional `replacer` transforms each parameter name in both key and value positions.\n * Returns `undefined` when no path parameters are found.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}/tag/{tagId}').getParams()\n * // { petId: 'petId', tagId: 'tagId' }\n * ```\n */\n getParams(replacer?: (pathParam: string) => string): Record<string, string> | undefined {\n const params: Record<string, string> = {}\n\n this.#eachParam((_raw, param) => {\n const key = replacer ? replacer(param) : param\n params[key] = key\n })\n\n return Object.keys(params).length > 0 ? params : undefined\n }\n\n /** Converts the OpenAPI path to Express-style colon syntax.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}').toURLPath() // '/pet/:petId'\n * ```\n */\n toURLPath(): string {\n return this.path.replace(/\\{([^}]+)\\}/g, ':$1')\n }\n}\n","import { File } from '@kubb/renderer-jsx'\nimport type { KubbReactNode } from '@kubb/renderer-jsx/types'\n\ntype HandlersProps = {\n /**\n * Name of the function\n */\n name: string\n // custom\n handlers: string[]\n}\n\nexport function Handlers({ name, handlers }: HandlersProps): KubbReactNode {\n return (\n <File.Source name={name} isIndexable isExportable>\n {`export const ${name} = ${JSON.stringify(handlers).replaceAll(`\"`, '')} as const`}\n </File.Source>\n )\n}\n","import type { ast } from '@kubb/core'\nimport type { ResolverFaker } from '@kubb/plugin-faker'\nimport type { ResolverTs } from '@kubb/plugin-ts'\nimport type { PluginMsw } from './types.ts'\n\n/**\n * Applies a name transformer function to a name if configured, otherwise returns it unchanged.\n */\nexport function transformName(name: string, type: 'function' | 'type' | 'file' | 'const', transformers?: PluginMsw['resolvedOptions']['transformers']): string {\n return transformers?.name?.(name, type) || name\n}\n\n/**\n * Filters responses to only those with 2xx status codes.\n */\nexport function getSuccessResponses(node: ast.OperationNode): ast.ResponseNode[] {\n return node.responses.filter((response) => {\n const code = Number.parseInt(response.statusCode, 10)\n return !Number.isNaN(code) && code >= 200 && code < 300\n })\n}\n\n/**\n * Returns the first 2xx response for an operation, if any.\n */\nexport function getPrimarySuccessResponse(node: ast.OperationNode): ast.ResponseNode | undefined {\n return getSuccessResponses(node)[0]\n}\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 | undefined): string | undefined {\n return getResponseContentType(response) ?? (hasResponseSchema(response) ? 'application/json' : undefined)\n}\n\n/**\n * Determines if a response has a schema that is not void or any.\n */\nexport function hasResponseSchema(response: ast.ResponseNode | undefined): boolean {\n return !!getResponseContentType(response) || (!!response?.schema && response.schema.type !== 'void' && response.schema.type !== 'any')\n}\n\nfunction getResponseContentType(response: ast.ResponseNode | undefined): string | undefined {\n const contentType = response as unknown as { mediaType?: string | null; contentType?: string | null } | undefined\n const value = contentType?.mediaType ?? contentType?.contentType\n return typeof value === 'string' && value.length > 0 ? value : undefined\n}\n\n/**\n * Maps all operation responses to their type names, including status code or 'default' for default responses.\n */\nexport function getResponseTypes(node: ast.OperationNode, tsResolver: ResolverTs): 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', tsResolver.resolveResponseName(node)])\n continue\n }\n\n const code = Number.parseInt(response.statusCode, 10)\n if (Number.isNaN(code)) continue\n\n if (code >= 200 && code < 300) {\n types.push([code, tsResolver.resolveResponseName(node)])\n continue\n }\n\n types.push([code, tsResolver.resolveResponseStatusName(node, response.statusCode)])\n }\n\n return types\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 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 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({ name: node.operationId, extname: '.ts', tag, path: node.path }, { root, output: fakerOutput, group: fakerGroup }),\n }\n}\n","import { URLPath } 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, getPrimarySuccessResponse, hasResponseSchema } from '../utils.ts'\n\ntype Props = {\n name: string\n typeName: string\n requestTypeName?: string\n baseURL: string | 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 = new URLPath(getMswUrl(node)).toURLPath()\n\n const headers = [contentType ? `'Content-Type': '${contentType}'` : undefined].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.createFunctionParameters({\n params: [\n ast.createFunctionParameter({\n name: 'data',\n type: ast.createParamsType({\n variant: 'reference',\n name: `${dataType} | ${callbackType}`,\n }),\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 { URLPath } 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, getPrimarySuccessResponse } from '../utils.ts'\n\ntype Props = {\n name: string\n typeName: string\n requestTypeName?: string\n fakerName: string\n baseURL: string | 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 = new URLPath(getMswUrl(node)).toURLPath()\n\n const headers = [contentType ? `'Content-Type': '${contentType}'` : undefined].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.createFunctionParameters({\n params: [\n ast.createFunctionParameter({\n name: 'data',\n type: ast.createParamsType({\n variant: 'reference',\n name: `${typeName} | ${callbackType}`,\n }),\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}'` : undefined].filter(Boolean)\n\n const params = declarationPrinter.print(\n ast.createFunctionParameters({\n params: [\n ast.createFunctionParameter({\n name: 'data',\n type: ast.createParamsType({ variant: 'reference', name: 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":";;;;;;;;;;;;;;;;;;;AAsBA,SAAS,gBAAgB,MAAc,QAAyB;AAS9D,QARmB,KAChB,MAAM,CACN,QAAQ,qBAAqB,QAAQ,CACrC,QAAQ,yBAAyB,QAAQ,CACzC,QAAQ,gBAAgB,QAEH,CAAC,MAAM,gBAAgB,CAAC,OAAO,QAE3C,CACT,KAAK,MAAM,MAAM;AAEhB,MADiB,KAAK,SAAS,KAAK,SAAS,KAAK,aAAa,CACjD,QAAO;AACrB,MAAI,MAAM,KAAK,CAAC,OAAQ,QAAO,KAAK,OAAO,EAAE,CAAC,aAAa,GAAG,KAAK,MAAM,EAAE;AAC3E,SAAO,KAAK,OAAO,EAAE,CAAC,aAAa,GAAG,KAAK,MAAM,EAAE;GACnD,CACD,KAAK,GAAG,CACR,QAAQ,iBAAiB,GAAG;;;;;;;;;;AAWjC,SAAS,iBAAiB,MAAc,eAAkE;CACxG,MAAM,QAAQ,KAAK,MAAM,iBAAiB;AAC1C,QAAO,MAAM,KAAK,MAAM,MAAM,cAAc,MAAM,MAAM,MAAM,SAAS,EAAE,CAAC,CAAC,KAAK,IAAI;;;;;;;;;;AAWtF,SAAgB,UAAU,MAAc,EAAE,QAAQ,SAAS,IAAI,SAAS,OAAgB,EAAE,EAAU;AAClG,KAAI,OACF,QAAO,iBAAiB,OAAO,MAAM,WAAW,UAAU,MAAM,SAAS;EAAE;EAAQ;EAAQ,GAAG,EAAE,CAAC,CAAC;AAGpG,QAAO,gBAAgB,GAAG,OAAO,GAAG,KAAK,GAAG,UAAU,MAAM;;;;;;;;AChE9D,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;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vO0FIb2i.js","names":["#options","#transformParam","#eachParam","declarationPrinter","declarationPrinter"],"sources":["../../../internals/utils/src/casing.ts","../../../internals/utils/src/reserved.ts","../../../internals/utils/src/urlPath.ts","../src/components/Handlers.tsx","../src/utils.ts","../src/components/Mock.tsx","../src/components/MockWithFaker.tsx","../src/components/Response.tsx"],"sourcesContent":["type Options = {\n /**\n * When `true`, dot-separated segments are split on `.` and joined with `/` after casing.\n */\n isFile?: boolean\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 const normalized = 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\n const words = normalized.split(/[\\s\\-_./\\\\:]+/).filter(Boolean)\n\n return words\n .map((word, i) => {\n const allUpper = word.length > 1 && word === word.toUpperCase()\n if (allUpper) return word\n if (i === 0 && !pascal) return word.charAt(0).toLowerCase() + word.slice(1)\n return word.charAt(0).toUpperCase() + word.slice(1)\n })\n .join('')\n .replace(/[^a-zA-Z0-9]/g, '')\n}\n\n/**\n * Splits `text` on `.` and applies `transformPart` to each segment.\n * The last segment receives `isLast = true`, all earlier segments receive `false`.\n * Segments are joined with `/` to form a file path.\n *\n * Only splits on dots followed by a letter so that version numbers\n * embedded in operationIds (e.g. `v2025.0`) are kept intact.\n */\nfunction applyToFileParts(text: string, transformPart: (part: string, isLast: boolean) => string): string {\n const parts = text.split(/\\.(?=[a-zA-Z])/)\n return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join('/')\n}\n\n/**\n * Converts `text` to camelCase.\n * When `isFile` is `true`, dot-separated segments are each cased independently and joined with `/`.\n *\n * @example\n * camelCase('hello-world') // 'helloWorld'\n * camelCase('pet.petId', { isFile: true }) // 'pet/petId'\n */\nexport function camelCase(text: string, { isFile, prefix = '', suffix = '' }: Options = {}): string {\n if (isFile) {\n return applyToFileParts(text, (part, isLast) => camelCase(part, isLast ? { prefix, suffix } : {}))\n }\n\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false)\n}\n\n/**\n * Converts `text` to PascalCase.\n * When `isFile` is `true`, the last dot-separated segment is PascalCased and earlier segments are camelCased.\n *\n * @example\n * pascalCase('hello-world') // 'HelloWorld'\n * pascalCase('pet.petId', { isFile: true }) // 'pet/PetId'\n */\nexport function pascalCase(text: string, { isFile, prefix = '', suffix = '' }: Options = {}): string {\n if (isFile) {\n return applyToFileParts(text, (part, isLast) => (isLast ? pascalCase(part, { prefix, suffix }) : camelCase(part)))\n }\n\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true)\n}\n\n/**\n * Converts `text` to snake_case.\n *\n * @example\n * snakeCase('helloWorld') // 'hello_world'\n * snakeCase('Hello-World') // 'hello_world'\n */\nexport function snakeCase(text: string, { prefix = '', suffix = '' }: Omit<Options, 'isFile'> = {}): 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\n * screamingSnakeCase('helloWorld') // 'HELLO_WORLD'\n */\nexport function screamingSnakeCase(text: string, { prefix = '', suffix = '' }: Omit<Options, 'isFile'> = {}): 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","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 `undefined` when the path has none.\n */\n params?: Record<string, string>\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 * Optional 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\n/**\n * Supported identifier casing strategies for path parameters.\n */\ntype PathCasing = 'camelcase'\n\ntype Options = {\n /**\n * Casing strategy applied to path parameter names.\n * @default undefined (original identifier preserved)\n */\n casing?: PathCasing\n}\n\n/**\n * Parses and transforms an OpenAPI/Swagger path string into various URL formats.\n *\n * @example\n * const p = new URLPath('/pet/{petId}')\n * p.URL // '/pet/:petId'\n * p.template // '`/pet/${petId}`'\n */\nexport class URLPath {\n /**\n * The raw OpenAPI/Swagger path string, e.g. `/pet/{petId}`.\n */\n path: string\n\n #options: Options\n\n constructor(path: string, options: Options = {}) {\n this.path = path\n this.#options = options\n }\n\n /** Converts the OpenAPI path to Express-style colon syntax, e.g. `/pet/{petId}` → `/pet/:petId`.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}').URL // '/pet/:petId'\n * ```\n */\n get URL(): string {\n return this.toURLPath()\n }\n\n /** Returns `true` when `path` is a fully-qualified URL (e.g. starts with `https://`).\n *\n * @example\n * ```ts\n * new URLPath('https://petstore.swagger.io/v2/pet').isURL // true\n * new URLPath('/pet/{petId}').isURL // false\n * ```\n */\n get isURL(): boolean {\n try {\n return !!new URL(this.path).href\n } catch {\n return false\n }\n }\n\n /**\n * Converts the OpenAPI path to a TypeScript template literal string.\n *\n * @example\n * new URLPath('/pet/{petId}').template // '`/pet/${petId}`'\n * new URLPath('/account/monetary-accountID').template // '`/account/${monetaryAccountId}`'\n */\n get template(): string {\n return this.toTemplateString()\n }\n\n /** Returns the path and its extracted params as a structured `URLObject`, or as a stringified expression when `stringify` is set.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}').object\n * // { url: '/pet/:petId', params: { petId: 'petId' } }\n * ```\n */\n get object(): URLObject | string {\n return this.toObject()\n }\n\n /** Returns a map of path parameter names, or `undefined` when the path has no parameters.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}').params // { petId: 'petId' }\n * new URLPath('/pet').params // undefined\n * ```\n */\n get params(): Record<string, string> | undefined {\n return this.getParams()\n }\n\n #transformParam(raw: string): string {\n const param = isValidVarName(raw) ? raw : camelCase(raw)\n return this.#options.casing === 'camelcase' ? camelCase(param) : param\n }\n\n /**\n * Iterates over every `{param}` token in `path`, calling `fn` with the raw token and transformed name.\n */\n #eachParam(fn: (raw: string, param: string) => void): void {\n for (const match of this.path.matchAll(/\\{([^}]+)\\}/g)) {\n const raw = match[1]!\n fn(raw, this.#transformParam(raw))\n }\n }\n\n toObject({ type = 'path', replacer, stringify }: ObjectOptions = {}): URLObject | string {\n const object = {\n url: type === 'path' ? this.toURLPath() : this.toTemplateString({ replacer }),\n params: this.getParams(),\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 /**\n * Converts the OpenAPI path to a TypeScript template literal string.\n * An optional `replacer` can transform each extracted parameter name before interpolation.\n *\n * @example\n * new URLPath('/pet/{petId}').toTemplateString() // '`/pet/${petId}`'\n */\n toTemplateString({ prefix = '', replacer }: { prefix?: string; replacer?: (pathParam: string) => string } = {}): string {\n const parts = this.path.split(/\\{([^}]+)\\}/)\n const result = parts\n .map((part, i) => {\n if (i % 2 === 0) return part\n const param = this.#transformParam(part)\n return `\\${${replacer ? replacer(param) : param}}`\n })\n .join('')\n\n return `\\`${prefix}${result}\\``\n }\n\n /**\n * Extracts all `{param}` segments from the path and returns them as a key-value map.\n * An optional `replacer` transforms each parameter name in both key and value positions.\n * Returns `undefined` when no path parameters are found.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}/tag/{tagId}').getParams()\n * // { petId: 'petId', tagId: 'tagId' }\n * ```\n */\n getParams(replacer?: (pathParam: string) => string): Record<string, string> | undefined {\n const params: Record<string, string> = {}\n\n this.#eachParam((_raw, param) => {\n const key = replacer ? replacer(param) : param\n params[key] = key\n })\n\n return Object.keys(params).length > 0 ? params : undefined\n }\n\n /** Converts the OpenAPI path to Express-style colon syntax.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}').toURLPath() // '/pet/:petId'\n * ```\n */\n toURLPath(): string {\n return this.path.replace(/\\{([^}]+)\\}/g, ':$1')\n }\n}\n","import { File } from '@kubb/renderer-jsx'\nimport type { KubbReactNode } from '@kubb/renderer-jsx/types'\n\ntype HandlersProps = {\n /**\n * Name of the function\n */\n name: string\n // custom\n handlers: string[]\n}\n\nexport function Handlers({ name, handlers }: HandlersProps): KubbReactNode {\n return (\n <File.Source name={name} isIndexable isExportable>\n {`export const ${name} = ${JSON.stringify(handlers).replaceAll(`\"`, '')} as const`}\n </File.Source>\n )\n}\n","import type { ast } from '@kubb/core'\nimport type { ResolverFaker } from '@kubb/plugin-faker'\nimport type { ResolverTs } from '@kubb/plugin-ts'\nimport type { PluginMsw } from './types.ts'\n\n/**\n * Applies a name transformer function to a name if configured, otherwise returns it unchanged.\n */\nexport function transformName(name: string, type: 'function' | 'type' | 'file' | 'const', transformers?: PluginMsw['resolvedOptions']['transformers']): string {\n return transformers?.name?.(name, type) || name\n}\n\n/**\n * Filters responses to only those with 2xx status codes.\n */\nexport function getSuccessResponses(node: ast.OperationNode): ast.ResponseNode[] {\n return node.responses.filter((response) => {\n const code = Number.parseInt(response.statusCode, 10)\n return !Number.isNaN(code) && code >= 200 && code < 300\n })\n}\n\n/**\n * Returns the first 2xx response for an operation, if any.\n */\nexport function getPrimarySuccessResponse(node: ast.OperationNode): ast.ResponseNode | undefined {\n return getSuccessResponses(node)[0]\n}\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 | undefined): string | undefined {\n return getResponseContentType(response) ?? (hasResponseSchema(response) ? 'application/json' : undefined)\n}\n\n/**\n * Determines if a response has a schema that is not void or any.\n */\nexport function hasResponseSchema(response: ast.ResponseNode | undefined): boolean {\n return !!getResponseContentType(response) || (!!response?.schema && response.schema.type !== 'void' && response.schema.type !== 'any')\n}\n\nfunction getResponseContentType(response: ast.ResponseNode | undefined): string | undefined {\n const contentType = response as unknown as { mediaType?: string | null; contentType?: string | null } | undefined\n const value = contentType?.mediaType ?? contentType?.contentType\n return typeof value === 'string' && value.length > 0 ? value : undefined\n}\n\n/**\n * Maps all operation responses to their type names, including status code or 'default' for default responses.\n */\nexport function getResponseTypes(node: ast.OperationNode, tsResolver: ResolverTs): 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', tsResolver.resolveResponseName(node)])\n continue\n }\n\n const code = Number.parseInt(response.statusCode, 10)\n if (Number.isNaN(code)) continue\n\n if (code >= 200 && code < 300) {\n types.push([code, tsResolver.resolveResponseName(node)])\n continue\n }\n\n types.push([code, tsResolver.resolveResponseStatusName(node, response.statusCode)])\n }\n\n return types\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 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 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({ name: node.operationId, extname: '.ts', tag, path: node.path }, { root, output: fakerOutput, group: fakerGroup }),\n }\n}\n","import { URLPath } 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, getPrimarySuccessResponse, hasResponseSchema } from '../utils.ts'\n\ntype Props = {\n name: string\n typeName: string\n requestTypeName?: string\n baseURL: string | 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 = new URLPath(getMswUrl(node)).toURLPath()\n\n const headers = [contentType ? `'Content-Type': '${contentType}'` : undefined].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.createFunctionParameters({\n params: [\n ast.createFunctionParameter({\n name: 'data',\n type: ast.createParamsType({\n variant: 'reference',\n name: `${dataType} | ${callbackType}`,\n }),\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 { URLPath } 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, getPrimarySuccessResponse } from '../utils.ts'\n\ntype Props = {\n name: string\n typeName: string\n requestTypeName?: string\n fakerName: string\n baseURL: string | 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 = new URLPath(getMswUrl(node)).toURLPath()\n\n const headers = [contentType ? `'Content-Type': '${contentType}'` : undefined].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.createFunctionParameters({\n params: [\n ast.createFunctionParameter({\n name: 'data',\n type: ast.createParamsType({\n variant: 'reference',\n name: `${typeName} | ${callbackType}`,\n }),\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}'` : undefined].filter(Boolean)\n\n const params = declarationPrinter.print(\n ast.createFunctionParameters({\n params: [\n ast.createFunctionParameter({\n name: 'data',\n type: ast.createParamsType({ variant: 'reference', name: 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":";;;;;;;;;;;;;AAsBA,SAAS,gBAAgB,MAAc,QAAyB;AAS9D,QARmB,KAChB,MAAM,CACN,QAAQ,qBAAqB,QAAQ,CACrC,QAAQ,yBAAyB,QAAQ,CACzC,QAAQ,gBAAgB,QAEH,CAAC,MAAM,gBAAgB,CAAC,OAAO,QAE3C,CACT,KAAK,MAAM,MAAM;AAEhB,MADiB,KAAK,SAAS,KAAK,SAAS,KAAK,aAAa,CACjD,QAAO;AACrB,MAAI,MAAM,KAAK,CAAC,OAAQ,QAAO,KAAK,OAAO,EAAE,CAAC,aAAa,GAAG,KAAK,MAAM,EAAE;AAC3E,SAAO,KAAK,OAAO,EAAE,CAAC,aAAa,GAAG,KAAK,MAAM,EAAE;GACnD,CACD,KAAK,G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