@kubb/plugin-msw 5.0.0-beta.3 → 5.0.0-beta.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +26 -5
  2. package/dist/{components-CLQ77DVn.cjs → components-B1Dsj2WT.cjs} +67 -72
  3. package/dist/components-B1Dsj2WT.cjs.map +1 -0
  4. package/dist/{components-vO0FIb2i.js → components-BxzfyX2u.js} +64 -63
  5. package/dist/components-BxzfyX2u.js.map +1 -0
  6. package/dist/components.cjs +1 -1
  7. package/dist/components.d.ts +5 -5
  8. package/dist/components.js +1 -1
  9. package/dist/{generators-CrmMwWE4.cjs → generators-C5AvweCJ.cjs} +61 -31
  10. package/dist/generators-C5AvweCJ.cjs.map +1 -0
  11. package/dist/{generators-BPJCs1x1.js → generators-srLe3oqm.js} +63 -33
  12. package/dist/generators-srLe3oqm.js.map +1 -0
  13. package/dist/generators.cjs +1 -1
  14. package/dist/generators.d.ts +13 -1
  15. package/dist/generators.js +1 -1
  16. package/dist/index.cjs +90 -15
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.ts +31 -1
  19. package/dist/index.js +90 -15
  20. package/dist/index.js.map +1 -1
  21. package/dist/types-CLAiv8qc.d.ts +103 -0
  22. package/extension.yaml +680 -0
  23. package/package.json +11 -14
  24. package/src/components/Handlers.tsx +1 -1
  25. package/src/components/Mock.tsx +5 -4
  26. package/src/components/MockWithFaker.tsx +5 -4
  27. package/src/components/Response.tsx +1 -1
  28. package/src/generators/handlersGenerator.tsx +18 -12
  29. package/src/generators/mswGenerator.tsx +29 -18
  30. package/src/plugin.ts +34 -18
  31. package/src/resolvers/resolverMsw.ts +19 -3
  32. package/src/types.ts +35 -21
  33. package/src/utils.ts +26 -61
  34. package/dist/components-CLQ77DVn.cjs.map +0 -1
  35. package/dist/components-vO0FIb2i.js.map +0 -1
  36. package/dist/generators-BPJCs1x1.js.map +0 -1
  37. package/dist/generators-CrmMwWE4.cjs.map +0 -1
  38. package/dist/types-Dxu0KMQ4.d.ts +0 -89
@@ -0,0 +1,103 @@
1
+ import { t as __name } from "./chunk--u3MIqq1.js";
2
+ import { Exclude, Generator, Group, Include, Output, Override, PluginFactoryOptions, Resolver, ast } from "@kubb/core";
3
+
4
+ //#region src/types.d.ts
5
+ /**
6
+ * Resolver for MSW that provides naming methods for handler functions.
7
+ */
8
+ type ResolverMsw = Resolver & {
9
+ /**
10
+ * Resolves the base handler function name for an operation.
11
+ */
12
+ resolveName(this: ResolverMsw, name: string): string;
13
+ /**
14
+ * Resolves the output file name for an MSW handler module.
15
+ */
16
+ resolvePathName(this: ResolverMsw, name: string, type?: 'file' | 'function' | 'type' | 'const'): string;
17
+ /**
18
+ * Resolves the handler function name for an operation.
19
+ */
20
+ resolveHandlerName(this: ResolverMsw, node: ast.OperationNode): string;
21
+ /**
22
+ * Resolves the exported handlers collection name.
23
+ */
24
+ resolveHandlersName(this: ResolverMsw): string;
25
+ };
26
+ type Options = {
27
+ /**
28
+ * Where the generated MSW handlers are written and how they are exported.
29
+ *
30
+ * @default { path: 'handlers', barrel: { type: 'named' } }
31
+ */
32
+ output?: Output;
33
+ /**
34
+ * Base URL prepended to every handler's request URL. When omitted, falls back
35
+ * to the adapter's server URL (typically `servers[0].url`).
36
+ */
37
+ baseURL?: string;
38
+ /**
39
+ * Split generated files into subfolders based on the operation's tag.
40
+ */
41
+ group?: Group;
42
+ /**
43
+ * Skip operations matching at least one entry in the list.
44
+ */
45
+ exclude?: Array<Exclude>;
46
+ /**
47
+ * Restrict generation to operations matching at least one entry in the list.
48
+ */
49
+ include?: Array<Include>;
50
+ /**
51
+ * Apply a different options object to operations matching a pattern.
52
+ */
53
+ override?: Array<Override<ResolvedOptions>>;
54
+ /**
55
+ * Override how handler names and file paths are built.
56
+ */
57
+ resolver?: Partial<ResolverMsw> & ThisType<ResolverMsw>;
58
+ /**
59
+ * AST visitor applied to operation nodes before printing.
60
+ */
61
+ transformer?: ast.Visitor;
62
+ /**
63
+ * Emit a `handlers.ts` file that re-exports every handler grouped by HTTP method.
64
+ * Drop the file into `setupServer(...handlers)` or `setupWorker(...handlers)`.
65
+ *
66
+ * @default false
67
+ */
68
+ handlers?: boolean;
69
+ /**
70
+ * Source of the response body returned by each generated handler.
71
+ * - `'data'` — typed empty/example payload, ready for you to fill in from tests.
72
+ * - `'faker'` — value produced by `@kubb/plugin-faker`.
73
+ *
74
+ * @default 'data'
75
+ */
76
+ parser?: 'data' | 'faker';
77
+ /**
78
+ * Custom generators that run alongside the built-in MSW generators.
79
+ */
80
+ generators?: Array<Generator<PluginMsw>>;
81
+ };
82
+ type ResolvedOptions = {
83
+ output: Output;
84
+ group: Group | null;
85
+ exclude: NonNullable<Options['exclude']>;
86
+ include: Options['include'];
87
+ override: NonNullable<Options['override']>;
88
+ parser: NonNullable<Options['parser']>;
89
+ baseURL: Options['baseURL'] | undefined;
90
+ handlers: boolean;
91
+ resolver: ResolverMsw;
92
+ };
93
+ type PluginMsw = PluginFactoryOptions<'plugin-msw', Options, ResolvedOptions, ResolverMsw>;
94
+ declare global {
95
+ namespace Kubb {
96
+ interface PluginRegistry {
97
+ 'plugin-msw': PluginMsw;
98
+ }
99
+ }
100
+ }
101
+ //#endregion
102
+ export { PluginMsw as n, Options as t };
103
+ //# sourceMappingURL=types-CLAiv8qc.d.ts.map