@kubb/plugin-msw 3.16.2 → 3.16.4
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-ByUOezvw.js +93 -0
- package/dist/components-ByUOezvw.js.map +1 -0
- package/dist/components-Bz0C7Qrg.cjs +139 -0
- package/dist/components-Bz0C7Qrg.cjs.map +1 -0
- package/dist/components.cjs +4 -19
- package/dist/components.d.cts +47 -33
- package/dist/components.d.ts +47 -33
- package/dist/components.js +3 -3
- package/dist/generators-BjQcx0SS.js +140 -0
- package/dist/generators-BjQcx0SS.js.map +1 -0
- package/dist/generators-DQ6KjdAH.cjs +151 -0
- package/dist/generators-DQ6KjdAH.cjs.map +1 -0
- package/dist/generators.cjs +4 -16
- package/dist/generators.d.cts +9 -8
- package/dist/generators.d.ts +9 -8
- package/dist/generators.js +4 -4
- package/dist/index.cjs +82 -102
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +82 -96
- package/dist/index.js.map +1 -1
- package/dist/types-BOMj2hjt.d.ts +13 -0
- package/dist/types-CxxnBHOU.d.cts +1164 -0
- package/dist/types-DYAniEBx.d.cts +13 -0
- package/dist/types-Dte4R-vh.d.ts +1164 -0
- package/package.json +19 -34
- package/src/components/Mock.tsx +21 -9
- package/src/components/MockWithFaker.tsx +22 -9
- package/src/generators/__snapshots__/createPet.ts +0 -3
- package/src/generators/__snapshots__/createPetFaker.ts +0 -3
- package/src/generators/__snapshots__/deletePet.ts +0 -3
- package/src/generators/mswGenerator.tsx +2 -16
- package/dist/chunk-6ANKBOX6.cjs +0 -113
- package/dist/chunk-6ANKBOX6.cjs.map +0 -1
- package/dist/chunk-FYUFQXX6.cjs +0 -55
- package/dist/chunk-FYUFQXX6.cjs.map +0 -1
- package/dist/chunk-GUSADLEP.js +0 -110
- package/dist/chunk-GUSADLEP.js.map +0 -1
- package/dist/chunk-HL53J5NZ.js +0 -51
- package/dist/chunk-HL53J5NZ.js.map +0 -1
- package/dist/components.cjs.map +0 -1
- package/dist/components.js.map +0 -1
- package/dist/generators.cjs.map +0 -1
- package/dist/generators.js.map +0 -1
- package/dist/types-CzI_io_g.d.cts +0 -64
- package/dist/types-CzI_io_g.d.ts +0 -64
package/dist/chunk-HL53J5NZ.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { FunctionParams, File, Function } from '@kubb/react';
|
|
2
|
-
import { jsx } from '@kubb/react/jsx-runtime';
|
|
3
|
-
|
|
4
|
-
// src/components/Mock.tsx
|
|
5
|
-
function Mock({ baseURL = "", name, typeName, url, method, statusCode }) {
|
|
6
|
-
const params = FunctionParams.factory({
|
|
7
|
-
data: {
|
|
8
|
-
type: `${typeName} | ((
|
|
9
|
-
info: Parameters<Parameters<typeof http.${method}>[1]>[0],
|
|
10
|
-
) => Response)`,
|
|
11
|
-
optional: true
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
return /* @__PURE__ */ jsx(File.Source, { name, isIndexable: true, isExportable: true, children: /* @__PURE__ */ jsx(Function, { name, export: true, params: params.toConstructor(), children: `return http.${method}('${baseURL}${url.replace(/([^/]):/g, "$1\\\\:")}', function handler(info) {
|
|
15
|
-
if(typeof data === 'function') return data(info)
|
|
16
|
-
|
|
17
|
-
return new Response(JSON.stringify(data), {
|
|
18
|
-
status: ${statusCode},
|
|
19
|
-
headers: {
|
|
20
|
-
'Content-Type': 'application/json',
|
|
21
|
-
},
|
|
22
|
-
})
|
|
23
|
-
})` }) });
|
|
24
|
-
}
|
|
25
|
-
function Handlers({ name, handlers }) {
|
|
26
|
-
return /* @__PURE__ */ jsx(File.Source, { name, isIndexable: true, isExportable: true, children: `export const ${name} = ${JSON.stringify(handlers).replaceAll(`"`, "")} as const` });
|
|
27
|
-
}
|
|
28
|
-
function MockWithFaker({ baseURL = "", name, fakerName, typeName, url, method, statusCode }) {
|
|
29
|
-
const params = FunctionParams.factory({
|
|
30
|
-
data: {
|
|
31
|
-
type: `${typeName} | ((
|
|
32
|
-
info: Parameters<Parameters<typeof http.${method}>[1]>[0],
|
|
33
|
-
) => Response)`,
|
|
34
|
-
optional: true
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
return /* @__PURE__ */ jsx(File.Source, { name, isIndexable: true, isExportable: true, children: /* @__PURE__ */ jsx(Function, { name, export: true, params: params.toConstructor(), children: `return http.${method}('${baseURL}${url.replace(/([^/]):/g, "$1\\\\:")}', function handler(info) {
|
|
38
|
-
if(typeof data === 'function') return data(info)
|
|
39
|
-
|
|
40
|
-
return new Response(JSON.stringify(data || ${fakerName}(data)), {
|
|
41
|
-
status: ${statusCode},
|
|
42
|
-
headers: {
|
|
43
|
-
'Content-Type': 'application/json',
|
|
44
|
-
},
|
|
45
|
-
})
|
|
46
|
-
})` }) });
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export { Handlers, Mock, MockWithFaker };
|
|
50
|
-
//# sourceMappingURL=chunk-HL53J5NZ.js.map
|
|
51
|
-
//# sourceMappingURL=chunk-HL53J5NZ.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Mock.tsx","../src/components/Handlers.tsx","../src/components/MockWithFaker.tsx"],"names":["jsx","File","FunctionParams","Function"],"mappings":";;;;AAkBO,SAAS,IAAA,CAAK,EAAE,OAAU,GAAA,EAAA,EAAI,MAAM,QAAU,EAAA,GAAA,EAAK,MAAQ,EAAA,UAAA,EAAgC,EAAA;AAChG,EAAM,MAAA,MAAA,GAAS,eAAe,OAAQ,CAAA;AAAA,IACpC,IAAM,EAAA;AAAA,MACJ,IAAA,EAAM,GAAG,QAAQ,CAAA;AAAA,gDAAA,EAC2B,MAAM,CAAA;AAAA,oBAAA,CAAA;AAAA,MAElD,QAAU,EAAA;AAAA;AACZ,GACD,CAAA;AAED,EACE,uBAAA,GAAA,CAAC,IAAK,CAAA,MAAA,EAAL,EAAY,IAAA,EAAY,WAAW,EAAA,IAAA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AA,EAAY,MAAM,EAAA,IAAA,EAAC,MAAQ,EAAA,MAAA,CAAO,aAAc,EAAA,EACvD,QAAe,EAAA,CAAA,YAAA,EAAA,MAAM,CAAK,EAAA,EAAA,OAAO,CAAG,EAAA,GAAA,CAAI,OAAQ,CAAA,UAAA,EAAY,SAAS,CAAC,CAAA;AAAA;;AAAA,+CAAA,EAG9B,SAAS,CAAA;AAAA,cAAA,EAC1C,UAAU,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAA,CAAA,EAMpB,CACF,EAAA,CAAA;AAEJ","file":"chunk-HL53J5NZ.js","sourcesContent":["import { File, Function, FunctionParams } from '@kubb/react'\n\nimport type { HttpMethod } from '@kubb/oas'\nimport type { ReactNode } from 'react'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n typeName: string\n fakerName: string\n url: string\n baseURL: string | undefined\n method: HttpMethod\n statusCode: number\n}\n\nexport function Mock({ baseURL = '', name, typeName, url, method, statusCode }: Props): ReactNode {\n const params = FunctionParams.factory({\n data: {\n type: `${typeName} | ((\n info: Parameters<Parameters<typeof http.${method}>[1]>[0],\n ) => Response)`,\n optional: true,\n },\n })\n\n return (\n <File.Source name={name} isIndexable isExportable>\n <Function name={name} export params={params.toConstructor()}>\n {`return http.${method}('${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 headers: {\n 'Content-Type': 'application/json',\n },\n })\n })`}\n </Function>\n </File.Source>\n )\n}\n","import { File } from '@kubb/react'\nimport type { ReactNode } from 'react'\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): ReactNode {\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 { File, Function, FunctionParams } from '@kubb/react'\n\nimport type { HttpMethod } from '@kubb/oas'\nimport type { ReactNode } from 'react'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n typeName: string\n fakerName: string\n baseURL: string | undefined\n url: string\n method: HttpMethod\n statusCode: number\n}\n\nexport function MockWithFaker({ baseURL = '', name, fakerName, typeName, url, method, statusCode }: Props): ReactNode {\n const params = FunctionParams.factory({\n data: {\n type: `${typeName} | ((\n info: Parameters<Parameters<typeof http.${method}>[1]>[0],\n ) => Response)`,\n optional: true,\n },\n })\n\n return (\n <File.Source name={name} isIndexable isExportable>\n <Function name={name} export params={params.toConstructor()}>\n {`return http.${method}('${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 headers: {\n 'Content-Type': 'application/json',\n },\n })\n })`}\n </Function>\n </File.Source>\n )\n}\n"]}
|
package/dist/components.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"components.cjs"}
|
package/dist/components.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"components.js"}
|
package/dist/generators.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"generators.cjs"}
|
package/dist/generators.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"generators.js"}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { Output, Group, ResolveNameParams, PluginFactoryOptions } from '@kubb/core';
|
|
2
|
-
import { Oas, contentType } from '@kubb/oas';
|
|
3
|
-
import { Exclude, Include, Override, Generator, ResolvePathOptions } from '@kubb/plugin-oas';
|
|
4
|
-
|
|
5
|
-
type Options = {
|
|
6
|
-
/**
|
|
7
|
-
* Specify the export location for the files and define the behavior of the output
|
|
8
|
-
* @default { path: 'mocks', barrelType: 'named' }
|
|
9
|
-
*/
|
|
10
|
-
output?: Output<Oas>;
|
|
11
|
-
/**
|
|
12
|
-
* Define which contentType should be used.
|
|
13
|
-
* By default, the first JSON valid mediaType will be used
|
|
14
|
-
*/
|
|
15
|
-
contentType?: contentType;
|
|
16
|
-
baseURL?: string;
|
|
17
|
-
/**
|
|
18
|
-
* Group the MSW mocks based on the provided name.
|
|
19
|
-
*/
|
|
20
|
-
group?: Group;
|
|
21
|
-
/**
|
|
22
|
-
* Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
|
|
23
|
-
*/
|
|
24
|
-
exclude?: Array<Exclude>;
|
|
25
|
-
/**
|
|
26
|
-
* Array containing include parameters to include tags/operations/methods/paths.
|
|
27
|
-
*/
|
|
28
|
-
include?: Array<Include>;
|
|
29
|
-
/**
|
|
30
|
-
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
31
|
-
*/
|
|
32
|
-
override?: Array<Override<ResolvedOptions>>;
|
|
33
|
-
transformers?: {
|
|
34
|
-
/**
|
|
35
|
-
* Customize the names based on the type that is provided by the plugin.
|
|
36
|
-
*/
|
|
37
|
-
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* Create `handlers.ts` file with all handlers grouped by methods.
|
|
41
|
-
* @default false
|
|
42
|
-
*/
|
|
43
|
-
handlers?: boolean;
|
|
44
|
-
/**
|
|
45
|
-
* Which parser should be used before returning the data to the `Response` of MSW.
|
|
46
|
-
* - `'faker'` will use `@kubb/plugin-faker` to generate the data for the response
|
|
47
|
-
* - `'data'` will use your custom data to generate the data for the response
|
|
48
|
-
* @default 'data'
|
|
49
|
-
*/
|
|
50
|
-
parser?: 'data' | 'faker';
|
|
51
|
-
/**
|
|
52
|
-
* Define some generators next to the msw generators
|
|
53
|
-
*/
|
|
54
|
-
generators?: Array<Generator<PluginMsw>>;
|
|
55
|
-
};
|
|
56
|
-
type ResolvedOptions = {
|
|
57
|
-
output: Output<Oas>;
|
|
58
|
-
group: Options['group'];
|
|
59
|
-
parser: NonNullable<Options['parser']>;
|
|
60
|
-
baseURL: Options['baseURL'] | undefined;
|
|
61
|
-
};
|
|
62
|
-
type PluginMsw = PluginFactoryOptions<'plugin-msw', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
63
|
-
|
|
64
|
-
export type { Options as O, PluginMsw as P };
|
package/dist/types-CzI_io_g.d.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { Output, Group, ResolveNameParams, PluginFactoryOptions } from '@kubb/core';
|
|
2
|
-
import { Oas, contentType } from '@kubb/oas';
|
|
3
|
-
import { Exclude, Include, Override, Generator, ResolvePathOptions } from '@kubb/plugin-oas';
|
|
4
|
-
|
|
5
|
-
type Options = {
|
|
6
|
-
/**
|
|
7
|
-
* Specify the export location for the files and define the behavior of the output
|
|
8
|
-
* @default { path: 'mocks', barrelType: 'named' }
|
|
9
|
-
*/
|
|
10
|
-
output?: Output<Oas>;
|
|
11
|
-
/**
|
|
12
|
-
* Define which contentType should be used.
|
|
13
|
-
* By default, the first JSON valid mediaType will be used
|
|
14
|
-
*/
|
|
15
|
-
contentType?: contentType;
|
|
16
|
-
baseURL?: string;
|
|
17
|
-
/**
|
|
18
|
-
* Group the MSW mocks based on the provided name.
|
|
19
|
-
*/
|
|
20
|
-
group?: Group;
|
|
21
|
-
/**
|
|
22
|
-
* Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
|
|
23
|
-
*/
|
|
24
|
-
exclude?: Array<Exclude>;
|
|
25
|
-
/**
|
|
26
|
-
* Array containing include parameters to include tags/operations/methods/paths.
|
|
27
|
-
*/
|
|
28
|
-
include?: Array<Include>;
|
|
29
|
-
/**
|
|
30
|
-
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
31
|
-
*/
|
|
32
|
-
override?: Array<Override<ResolvedOptions>>;
|
|
33
|
-
transformers?: {
|
|
34
|
-
/**
|
|
35
|
-
* Customize the names based on the type that is provided by the plugin.
|
|
36
|
-
*/
|
|
37
|
-
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* Create `handlers.ts` file with all handlers grouped by methods.
|
|
41
|
-
* @default false
|
|
42
|
-
*/
|
|
43
|
-
handlers?: boolean;
|
|
44
|
-
/**
|
|
45
|
-
* Which parser should be used before returning the data to the `Response` of MSW.
|
|
46
|
-
* - `'faker'` will use `@kubb/plugin-faker` to generate the data for the response
|
|
47
|
-
* - `'data'` will use your custom data to generate the data for the response
|
|
48
|
-
* @default 'data'
|
|
49
|
-
*/
|
|
50
|
-
parser?: 'data' | 'faker';
|
|
51
|
-
/**
|
|
52
|
-
* Define some generators next to the msw generators
|
|
53
|
-
*/
|
|
54
|
-
generators?: Array<Generator<PluginMsw>>;
|
|
55
|
-
};
|
|
56
|
-
type ResolvedOptions = {
|
|
57
|
-
output: Output<Oas>;
|
|
58
|
-
group: Options['group'];
|
|
59
|
-
parser: NonNullable<Options['parser']>;
|
|
60
|
-
baseURL: Options['baseURL'] | undefined;
|
|
61
|
-
};
|
|
62
|
-
type PluginMsw = PluginFactoryOptions<'plugin-msw', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
63
|
-
|
|
64
|
-
export type { Options as O, PluginMsw as P };
|