@kubb/plugin-faker 5.0.0-alpha.9 → 5.0.0-beta.100

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.
@@ -1,204 +0,0 @@
1
- const require_components = require("./components-IdP8GXXX.cjs");
2
- let _kubb_plugin_oas = require("@kubb/plugin-oas");
3
- let _kubb_plugin_ts = require("@kubb/plugin-ts");
4
- let _kubb_core_hooks = require("@kubb/core/hooks");
5
- let _kubb_plugin_oas_generators = require("@kubb/plugin-oas/generators");
6
- let _kubb_plugin_oas_hooks = require("@kubb/plugin-oas/hooks");
7
- let _kubb_plugin_oas_utils = require("@kubb/plugin-oas/utils");
8
- let _kubb_react_fabric = require("@kubb/react-fabric");
9
- let _kubb_react_fabric_jsx_runtime = require("@kubb/react-fabric/jsx-runtime");
10
- //#region src/generators/fakerGenerator.tsx
11
- const fakerGenerator = (0, _kubb_plugin_oas_generators.createReactGenerator)({
12
- name: "faker",
13
- Operation({ operation, generator, plugin }) {
14
- const { options, options: { dateParser, regexGenerator, seed, mapper } } = plugin;
15
- const mode = (0, _kubb_core_hooks.useMode)();
16
- const driver = (0, _kubb_core_hooks.usePluginDriver)();
17
- const oas = (0, _kubb_plugin_oas_hooks.useOas)();
18
- const { getSchemas, getFile, getGroup } = (0, _kubb_plugin_oas_hooks.useOperationManager)(generator);
19
- const schemaManager = (0, _kubb_plugin_oas_hooks.useSchemaManager)();
20
- const file = getFile(operation);
21
- const schemas = getSchemas(operation);
22
- const schemaGenerator = new _kubb_plugin_oas.SchemaGenerator(options, {
23
- fabric: generator.context.fabric,
24
- oas,
25
- plugin,
26
- events: generator.context.events,
27
- driver,
28
- mode,
29
- override: options.override
30
- });
31
- const operationSchemas = [
32
- schemas.pathParams,
33
- schemas.queryParams,
34
- schemas.headerParams,
35
- schemas.statusCodes,
36
- schemas.request,
37
- schemas.response
38
- ].flat().filter((x) => Boolean(x));
39
- const mapOperationSchema = ({ name, schema, description, ...options }) => {
40
- const transformedSchema = (0, _kubb_plugin_oas_utils.isParameterSchema)(name) && plugin.options.paramsCasing ? (0, _kubb_plugin_oas_utils.applyParamsCasing)(schema, plugin.options.paramsCasing) : schema;
41
- const tree = schemaGenerator.parse({
42
- schema: transformedSchema,
43
- name,
44
- parentName: null
45
- });
46
- const imports = (0, _kubb_plugin_oas_utils.getImports)(tree);
47
- const group = options.operation ? getGroup(options.operation) : void 0;
48
- const faker = {
49
- name: schemaManager.getName(name, { type: "function" }),
50
- file: schemaManager.getFile(name)
51
- };
52
- const type = {
53
- name: schemaManager.getName(name, {
54
- type: "type",
55
- pluginName: _kubb_plugin_ts.pluginTsName
56
- }),
57
- file: schemaManager.getFile(options.operationName || name, {
58
- pluginName: _kubb_plugin_ts.pluginTsName,
59
- group
60
- })
61
- };
62
- const canOverride = tree.some(({ keyword }) => keyword === _kubb_plugin_oas.schemaKeywords.array || keyword === _kubb_plugin_oas.schemaKeywords.and || keyword === _kubb_plugin_oas.schemaKeywords.object || keyword === _kubb_plugin_oas.schemaKeywords.union || keyword === _kubb_plugin_oas.schemaKeywords.tuple || keyword === _kubb_plugin_oas.schemaKeywords.enum || keyword === _kubb_plugin_oas.schemaKeywords.ref);
63
- return /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric_jsx_runtime.Fragment, { children: [
64
- canOverride && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
65
- isTypeOnly: true,
66
- root: file.path,
67
- path: type.file.path,
68
- name: [type.name]
69
- }),
70
- imports.map((imp) => /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
71
- root: file.path,
72
- path: imp.path,
73
- name: imp.name
74
- }, [
75
- imp.path,
76
- imp.name,
77
- imp.isTypeOnly
78
- ].join("-"))),
79
- /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(require_components.Faker, {
80
- name: faker.name,
81
- typeName: type.name,
82
- description,
83
- tree,
84
- regexGenerator,
85
- dateParser,
86
- mapper,
87
- seed,
88
- canOverride
89
- })
90
- ] });
91
- };
92
- return /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric.File, {
93
- baseName: file.baseName,
94
- path: file.path,
95
- meta: file.meta,
96
- banner: (0, _kubb_plugin_oas_utils.getBanner)({
97
- oas,
98
- output: plugin.options.output,
99
- config: driver.config
100
- }),
101
- footer: (0, _kubb_plugin_oas_utils.getFooter)({
102
- oas,
103
- output: plugin.options.output
104
- }),
105
- children: [
106
- /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
107
- name: ["faker"],
108
- path: "@faker-js/faker"
109
- }),
110
- regexGenerator === "randexp" && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
111
- name: "RandExp",
112
- path: "randexp"
113
- }),
114
- dateParser !== "faker" && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
115
- path: dateParser,
116
- name: dateParser
117
- }),
118
- operationSchemas.map(mapOperationSchema)
119
- ]
120
- });
121
- },
122
- Schema({ schema, plugin }) {
123
- const { getName, getFile } = (0, _kubb_plugin_oas_hooks.useSchemaManager)();
124
- const { options: { output, dateParser, regexGenerator, seed, mapper } } = plugin;
125
- const driver = (0, _kubb_core_hooks.usePluginDriver)();
126
- const oas = (0, _kubb_plugin_oas_hooks.useOas)();
127
- const imports = (0, _kubb_plugin_oas_utils.getImports)(schema.tree);
128
- const faker = {
129
- name: getName(schema.name, { type: "function" }),
130
- file: getFile(schema.name)
131
- };
132
- const type = {
133
- name: getName(schema.name, {
134
- type: "type",
135
- pluginName: _kubb_plugin_ts.pluginTsName
136
- }),
137
- file: getFile(schema.name, { pluginName: _kubb_plugin_ts.pluginTsName })
138
- };
139
- const canOverride = schema.tree.some(({ keyword }) => keyword === _kubb_plugin_oas.schemaKeywords.array || keyword === _kubb_plugin_oas.schemaKeywords.and || keyword === _kubb_plugin_oas.schemaKeywords.object || keyword === _kubb_plugin_oas.schemaKeywords.union || keyword === _kubb_plugin_oas.schemaKeywords.tuple || keyword === _kubb_plugin_oas.schemaKeywords.ref || keyword === _kubb_plugin_oas.schemaKeywords.enum || keyword === _kubb_plugin_oas.schemaKeywords.string || keyword === _kubb_plugin_oas.schemaKeywords.integer || keyword === _kubb_plugin_oas.schemaKeywords.number);
140
- return /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric.File, {
141
- baseName: faker.file.baseName,
142
- path: faker.file.path,
143
- meta: faker.file.meta,
144
- banner: (0, _kubb_plugin_oas_utils.getBanner)({
145
- oas,
146
- output,
147
- config: driver.config
148
- }),
149
- footer: (0, _kubb_plugin_oas_utils.getFooter)({
150
- oas,
151
- output
152
- }),
153
- children: [
154
- /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
155
- name: ["faker"],
156
- path: "@faker-js/faker"
157
- }),
158
- regexGenerator === "randexp" && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
159
- name: "RandExp",
160
- path: "randexp"
161
- }),
162
- dateParser !== "faker" && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
163
- path: dateParser,
164
- name: dateParser
165
- }),
166
- /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
167
- isTypeOnly: true,
168
- root: faker.file.path,
169
- path: type.file.path,
170
- name: [type.name]
171
- }),
172
- imports.map((imp) => /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
173
- root: faker.file.path,
174
- path: imp.path,
175
- name: imp.name
176
- }, [
177
- imp.path,
178
- imp.name,
179
- imp.isTypeOnly
180
- ].join("-"))),
181
- /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(require_components.Faker, {
182
- name: faker.name,
183
- typeName: type.name,
184
- description: schema.value.description,
185
- tree: schema.tree,
186
- regexGenerator,
187
- dateParser,
188
- mapper,
189
- seed,
190
- canOverride
191
- })
192
- ]
193
- });
194
- }
195
- });
196
- //#endregion
197
- Object.defineProperty(exports, "fakerGenerator", {
198
- enumerable: true,
199
- get: function() {
200
- return fakerGenerator;
201
- }
202
- });
203
-
204
- //# sourceMappingURL=fakerGenerator-CYUCNH3Q.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fakerGenerator-CYUCNH3Q.cjs","names":["SchemaGenerator","pluginTsName","schemaKeywords","File","Faker"],"sources":["../src/generators/fakerGenerator.tsx"],"sourcesContent":["import { useMode, usePluginDriver } from '@kubb/core/hooks'\nimport { type OperationSchema as OperationSchemaType, SchemaGenerator, schemaKeywords } from '@kubb/plugin-oas'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas, useOperationManager, useSchemaManager } from '@kubb/plugin-oas/hooks'\nimport { applyParamsCasing, getBanner, getFooter, getImports, isParameterSchema } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File } from '@kubb/react-fabric'\nimport { Faker } from '../components'\nimport type { PluginFaker } from '../types'\n\nexport const fakerGenerator = createReactGenerator<PluginFaker>({\n name: 'faker',\n Operation({ operation, generator, plugin }) {\n const {\n options,\n options: { dateParser, regexGenerator, seed, mapper },\n } = plugin\n const mode = useMode()\n const driver = usePluginDriver()\n\n const oas = useOas()\n const { getSchemas, getFile, getGroup } = useOperationManager(generator)\n const schemaManager = useSchemaManager()\n\n const file = getFile(operation)\n const schemas = getSchemas(operation)\n const schemaGenerator = new SchemaGenerator(options, {\n fabric: generator.context.fabric,\n oas,\n plugin,\n events: generator.context.events,\n driver,\n mode,\n override: options.override,\n })\n\n const operationSchemas = [schemas.pathParams, schemas.queryParams, schemas.headerParams, schemas.statusCodes, schemas.request, schemas.response]\n .flat()\n .filter((x): x is OperationSchemaType => Boolean(x))\n\n const mapOperationSchema = ({ name, schema, description, ...options }: OperationSchemaType) => {\n // Apply paramsCasing transformation if enabled and this is a parameter schema\n const shouldTransform = isParameterSchema(name) && plugin.options.paramsCasing\n const transformedSchema = shouldTransform ? applyParamsCasing(schema, plugin.options.paramsCasing) : schema\n\n const tree = schemaGenerator.parse({ schema: transformedSchema, name, parentName: null })\n const imports = getImports(tree)\n const group = options.operation ? getGroup(options.operation) : undefined\n\n const faker = {\n name: schemaManager.getName(name, { type: 'function' }),\n file: schemaManager.getFile(name),\n }\n\n const type = {\n name: schemaManager.getName(name, { type: 'type', pluginName: pluginTsName }),\n file: schemaManager.getFile(options.operationName || name, { pluginName: pluginTsName, group }),\n }\n\n const canOverride = tree.some(\n ({ keyword }) =>\n keyword === schemaKeywords.array ||\n keyword === schemaKeywords.and ||\n keyword === schemaKeywords.object ||\n keyword === schemaKeywords.union ||\n keyword === schemaKeywords.tuple ||\n keyword === schemaKeywords.enum ||\n keyword === schemaKeywords.ref,\n )\n\n return (\n <>\n {canOverride && <File.Import isTypeOnly root={file.path} path={type.file.path} name={[type.name]} />}\n {imports.map((imp) => (\n <File.Import key={[imp.path, imp.name, imp.isTypeOnly].join('-')} root={file.path} path={imp.path} name={imp.name} />\n ))}\n <Faker\n name={faker.name}\n typeName={type.name}\n description={description}\n tree={tree}\n regexGenerator={regexGenerator}\n dateParser={dateParser}\n mapper={mapper}\n seed={seed}\n canOverride={canOverride}\n />\n </>\n )\n }\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output: plugin.options.output, config: driver.config })}\n footer={getFooter({ oas, output: plugin.options.output })}\n >\n <File.Import name={['faker']} path=\"@faker-js/faker\" />\n {regexGenerator === 'randexp' && <File.Import name={'RandExp'} path={'randexp'} />}\n {dateParser !== 'faker' && <File.Import path={dateParser} name={dateParser} />}\n {operationSchemas.map(mapOperationSchema)}\n </File>\n )\n },\n Schema({ schema, plugin }) {\n const { getName, getFile } = useSchemaManager()\n const {\n options: { output, dateParser, regexGenerator, seed, mapper },\n } = plugin\n const driver = usePluginDriver()\n const oas = useOas()\n const imports = getImports(schema.tree)\n\n const faker = {\n name: getName(schema.name, { type: 'function' }),\n file: getFile(schema.name),\n }\n\n const type = {\n name: getName(schema.name, { type: 'type', pluginName: pluginTsName }),\n file: getFile(schema.name, { pluginName: pluginTsName }),\n }\n\n const canOverride = schema.tree.some(\n ({ keyword }) =>\n keyword === schemaKeywords.array ||\n keyword === schemaKeywords.and ||\n keyword === schemaKeywords.object ||\n keyword === schemaKeywords.union ||\n keyword === schemaKeywords.tuple ||\n keyword === schemaKeywords.ref ||\n keyword === schemaKeywords.enum ||\n keyword === schemaKeywords.string ||\n keyword === schemaKeywords.integer ||\n keyword === schemaKeywords.number,\n )\n\n return (\n <File\n baseName={faker.file.baseName}\n path={faker.file.path}\n meta={faker.file.meta}\n banner={getBanner({ oas, output, config: driver.config })}\n footer={getFooter({ oas, output })}\n >\n <File.Import name={['faker']} path=\"@faker-js/faker\" />\n {regexGenerator === 'randexp' && <File.Import name={'RandExp'} path={'randexp'} />}\n {dateParser !== 'faker' && <File.Import path={dateParser} name={dateParser} />}\n <File.Import isTypeOnly root={faker.file.path} path={type.file.path} name={[type.name]} />\n {imports.map((imp) => (\n <File.Import key={[imp.path, imp.name, imp.isTypeOnly].join('-')} root={faker.file.path} path={imp.path} name={imp.name} />\n ))}\n\n <Faker\n name={faker.name}\n typeName={type.name}\n description={schema.value.description}\n tree={schema.tree}\n regexGenerator={regexGenerator}\n dateParser={dateParser}\n mapper={mapper}\n seed={seed}\n canOverride={canOverride}\n />\n </File>\n )\n },\n})\n"],"mappings":";;;;;;;;;;AAUA,MAAa,kBAAA,GAAA,4BAAA,sBAAmD;CAC9D,MAAM;CACN,UAAU,EAAE,WAAW,WAAW,UAAU;EAC1C,MAAM,EACJ,SACA,SAAS,EA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,UAAU,MAAM,KAAK;GACrB,MAAM,MAAM,KAAK;GACjB,MAAM,MAAM,KAAK;GACjB,SAAA,GAAA,uBAAA,WAAkB;IAAE;IAAK;IAAQ,QAAQ,OAAO;IAAQ,CAAC;GACzD,SAAA,GAAA,uBAAA,WAAkB;IAAE;IAAK;IAAQ,CAAC;aALpC;IAOE,iBAAA,GAAA,+BAAA,KAACA,mBAAAA,KAAK,QAAN;KAAa,MAAM,CAAC,QAAQ;KAAE,MAAK;KAAoB,CAAA;IACtD,mBAAmB,aAAa,iBAAA,GAAA,+BAAA,KAACA,mBAAAA,KAAK,QAAN;KAAa,MAAM;KAAW,MAAM;KAAa,CAAA;IACjF,eAAe,WAAW,iBAAA,GAAA,+BAAA,KAACA,mBAAAA,KAAK,QAAN;KAAa,MAAM;KAAY,MAAM;KAAc,CAAA;IAC9E,iBAAA,GAAA,+BAAA,KAACA,mBAAAA,KAAK,QAAN;KAAa,YAAA;KAAW,MAAM,MAAM,KAAK;KAAM,MAAM,KAAK,KAAK;KAAM,MAAM,CAAC,KAAK,KAAK;KAAI,CAAA;IACzF,QAAQ,KAAK,QACZ,iBAAA,GAAA,+BAAA,KAACA,mBAAAA,KAAK,QAAN;KAAkE,MAAM,MAAM,KAAK;KAAM,MAAM,IAAI;KAAM,MAAM,IAAI;KAAQ,EAAzG;KAAC,IAAI;KAAM,IAAI;KAAM,IAAI;KAAW,CAAC,KAAK,IAAI,CAA2D,CAC3H;IAEF,iBAAA,GAAA,+BAAA,KAACC,mBAAAA,OAAD;KACE,MAAM,MAAM;KACZ,UAAU,KAAK;KACf,aAAa,OAAO,MAAM;KAC1B,MAAM,OAAO;KACG;KACJ;KACJ;KACF;KACO;KACb,CAAA;IACG;;;CAGZ,CAAC"}
@@ -1,200 +0,0 @@
1
- import "./chunk--u3MIqq1.js";
2
- import { t as Faker } from "./components-BkBIov4R.js";
3
- import { SchemaGenerator, schemaKeywords } from "@kubb/plugin-oas";
4
- import { pluginTsName } from "@kubb/plugin-ts";
5
- import { useMode, usePluginDriver } from "@kubb/core/hooks";
6
- import { createReactGenerator } from "@kubb/plugin-oas/generators";
7
- import { useOas, useOperationManager, useSchemaManager } from "@kubb/plugin-oas/hooks";
8
- import { applyParamsCasing, getBanner, getFooter, getImports, isParameterSchema } from "@kubb/plugin-oas/utils";
9
- import { File } from "@kubb/react-fabric";
10
- import { Fragment, jsx, jsxs } from "@kubb/react-fabric/jsx-runtime";
11
- //#region src/generators/fakerGenerator.tsx
12
- const fakerGenerator = createReactGenerator({
13
- name: "faker",
14
- Operation({ operation, generator, plugin }) {
15
- const { options, options: { dateParser, regexGenerator, seed, mapper } } = plugin;
16
- const mode = useMode();
17
- const driver = usePluginDriver();
18
- const oas = useOas();
19
- const { getSchemas, getFile, getGroup } = useOperationManager(generator);
20
- const schemaManager = useSchemaManager();
21
- const file = getFile(operation);
22
- const schemas = getSchemas(operation);
23
- const schemaGenerator = new SchemaGenerator(options, {
24
- fabric: generator.context.fabric,
25
- oas,
26
- plugin,
27
- events: generator.context.events,
28
- driver,
29
- mode,
30
- override: options.override
31
- });
32
- const operationSchemas = [
33
- schemas.pathParams,
34
- schemas.queryParams,
35
- schemas.headerParams,
36
- schemas.statusCodes,
37
- schemas.request,
38
- schemas.response
39
- ].flat().filter((x) => Boolean(x));
40
- const mapOperationSchema = ({ name, schema, description, ...options }) => {
41
- const transformedSchema = isParameterSchema(name) && plugin.options.paramsCasing ? applyParamsCasing(schema, plugin.options.paramsCasing) : schema;
42
- const tree = schemaGenerator.parse({
43
- schema: transformedSchema,
44
- name,
45
- parentName: null
46
- });
47
- const imports = getImports(tree);
48
- const group = options.operation ? getGroup(options.operation) : void 0;
49
- const faker = {
50
- name: schemaManager.getName(name, { type: "function" }),
51
- file: schemaManager.getFile(name)
52
- };
53
- const type = {
54
- name: schemaManager.getName(name, {
55
- type: "type",
56
- pluginName: pluginTsName
57
- }),
58
- file: schemaManager.getFile(options.operationName || name, {
59
- pluginName: pluginTsName,
60
- group
61
- })
62
- };
63
- const canOverride = tree.some(({ keyword }) => keyword === schemaKeywords.array || keyword === schemaKeywords.and || keyword === schemaKeywords.object || keyword === schemaKeywords.union || keyword === schemaKeywords.tuple || keyword === schemaKeywords.enum || keyword === schemaKeywords.ref);
64
- return /* @__PURE__ */ jsxs(Fragment, { children: [
65
- canOverride && /* @__PURE__ */ jsx(File.Import, {
66
- isTypeOnly: true,
67
- root: file.path,
68
- path: type.file.path,
69
- name: [type.name]
70
- }),
71
- imports.map((imp) => /* @__PURE__ */ jsx(File.Import, {
72
- root: file.path,
73
- path: imp.path,
74
- name: imp.name
75
- }, [
76
- imp.path,
77
- imp.name,
78
- imp.isTypeOnly
79
- ].join("-"))),
80
- /* @__PURE__ */ jsx(Faker, {
81
- name: faker.name,
82
- typeName: type.name,
83
- description,
84
- tree,
85
- regexGenerator,
86
- dateParser,
87
- mapper,
88
- seed,
89
- canOverride
90
- })
91
- ] });
92
- };
93
- return /* @__PURE__ */ jsxs(File, {
94
- baseName: file.baseName,
95
- path: file.path,
96
- meta: file.meta,
97
- banner: getBanner({
98
- oas,
99
- output: plugin.options.output,
100
- config: driver.config
101
- }),
102
- footer: getFooter({
103
- oas,
104
- output: plugin.options.output
105
- }),
106
- children: [
107
- /* @__PURE__ */ jsx(File.Import, {
108
- name: ["faker"],
109
- path: "@faker-js/faker"
110
- }),
111
- regexGenerator === "randexp" && /* @__PURE__ */ jsx(File.Import, {
112
- name: "RandExp",
113
- path: "randexp"
114
- }),
115
- dateParser !== "faker" && /* @__PURE__ */ jsx(File.Import, {
116
- path: dateParser,
117
- name: dateParser
118
- }),
119
- operationSchemas.map(mapOperationSchema)
120
- ]
121
- });
122
- },
123
- Schema({ schema, plugin }) {
124
- const { getName, getFile } = useSchemaManager();
125
- const { options: { output, dateParser, regexGenerator, seed, mapper } } = plugin;
126
- const driver = usePluginDriver();
127
- const oas = useOas();
128
- const imports = getImports(schema.tree);
129
- const faker = {
130
- name: getName(schema.name, { type: "function" }),
131
- file: getFile(schema.name)
132
- };
133
- const type = {
134
- name: getName(schema.name, {
135
- type: "type",
136
- pluginName: pluginTsName
137
- }),
138
- file: getFile(schema.name, { pluginName: pluginTsName })
139
- };
140
- const canOverride = schema.tree.some(({ keyword }) => keyword === schemaKeywords.array || keyword === schemaKeywords.and || keyword === schemaKeywords.object || keyword === schemaKeywords.union || keyword === schemaKeywords.tuple || keyword === schemaKeywords.ref || keyword === schemaKeywords.enum || keyword === schemaKeywords.string || keyword === schemaKeywords.integer || keyword === schemaKeywords.number);
141
- return /* @__PURE__ */ jsxs(File, {
142
- baseName: faker.file.baseName,
143
- path: faker.file.path,
144
- meta: faker.file.meta,
145
- banner: getBanner({
146
- oas,
147
- output,
148
- config: driver.config
149
- }),
150
- footer: getFooter({
151
- oas,
152
- output
153
- }),
154
- children: [
155
- /* @__PURE__ */ jsx(File.Import, {
156
- name: ["faker"],
157
- path: "@faker-js/faker"
158
- }),
159
- regexGenerator === "randexp" && /* @__PURE__ */ jsx(File.Import, {
160
- name: "RandExp",
161
- path: "randexp"
162
- }),
163
- dateParser !== "faker" && /* @__PURE__ */ jsx(File.Import, {
164
- path: dateParser,
165
- name: dateParser
166
- }),
167
- /* @__PURE__ */ jsx(File.Import, {
168
- isTypeOnly: true,
169
- root: faker.file.path,
170
- path: type.file.path,
171
- name: [type.name]
172
- }),
173
- imports.map((imp) => /* @__PURE__ */ jsx(File.Import, {
174
- root: faker.file.path,
175
- path: imp.path,
176
- name: imp.name
177
- }, [
178
- imp.path,
179
- imp.name,
180
- imp.isTypeOnly
181
- ].join("-"))),
182
- /* @__PURE__ */ jsx(Faker, {
183
- name: faker.name,
184
- typeName: type.name,
185
- description: schema.value.description,
186
- tree: schema.tree,
187
- regexGenerator,
188
- dateParser,
189
- mapper,
190
- seed,
191
- canOverride
192
- })
193
- ]
194
- });
195
- }
196
- });
197
- //#endregion
198
- export { fakerGenerator as t };
199
-
200
- //# sourceMappingURL=fakerGenerator-M5oCrPmy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fakerGenerator-M5oCrPmy.js","names":[],"sources":["../src/generators/fakerGenerator.tsx"],"sourcesContent":["import { useMode, usePluginDriver } from '@kubb/core/hooks'\nimport { type OperationSchema as OperationSchemaType, SchemaGenerator, schemaKeywords } from '@kubb/plugin-oas'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas, useOperationManager, useSchemaManager } from '@kubb/plugin-oas/hooks'\nimport { applyParamsCasing, getBanner, getFooter, getImports, isParameterSchema } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File } from '@kubb/react-fabric'\nimport { Faker } from '../components'\nimport type { PluginFaker } from '../types'\n\nexport const fakerGenerator = createReactGenerator<PluginFaker>({\n name: 'faker',\n Operation({ operation, generator, plugin }) {\n const {\n options,\n options: { dateParser, regexGenerator, seed, mapper },\n } = plugin\n const mode = useMode()\n const driver = usePluginDriver()\n\n const oas = useOas()\n const { getSchemas, getFile, getGroup } = useOperationManager(generator)\n const schemaManager = useSchemaManager()\n\n const file = getFile(operation)\n const schemas = getSchemas(operation)\n const schemaGenerator = new SchemaGenerator(options, {\n fabric: generator.context.fabric,\n oas,\n plugin,\n events: generator.context.events,\n driver,\n mode,\n override: options.override,\n })\n\n const operationSchemas = [schemas.pathParams, schemas.queryParams, schemas.headerParams, schemas.statusCodes, schemas.request, schemas.response]\n .flat()\n .filter((x): x is OperationSchemaType => Boolean(x))\n\n const mapOperationSchema = ({ name, schema, description, ...options }: OperationSchemaType) => {\n // Apply paramsCasing transformation if enabled and this is a parameter schema\n const shouldTransform = isParameterSchema(name) && plugin.options.paramsCasing\n const transformedSchema = shouldTransform ? applyParamsCasing(schema, plugin.options.paramsCasing) : schema\n\n const tree = schemaGenerator.parse({ schema: transformedSchema, name, parentName: null })\n const imports = getImports(tree)\n const group = options.operation ? getGroup(options.operation) : undefined\n\n const faker = {\n name: schemaManager.getName(name, { type: 'function' }),\n file: schemaManager.getFile(name),\n }\n\n const type = {\n name: schemaManager.getName(name, { type: 'type', pluginName: pluginTsName }),\n file: schemaManager.getFile(options.operationName || name, { pluginName: pluginTsName, group }),\n }\n\n const canOverride = tree.some(\n ({ keyword }) =>\n keyword === schemaKeywords.array ||\n keyword === schemaKeywords.and ||\n keyword === schemaKeywords.object ||\n keyword === schemaKeywords.union ||\n keyword === schemaKeywords.tuple ||\n keyword === schemaKeywords.enum ||\n keyword === schemaKeywords.ref,\n )\n\n return (\n <>\n {canOverride && <File.Import isTypeOnly root={file.path} path={type.file.path} name={[type.name]} />}\n {imports.map((imp) => (\n <File.Import key={[imp.path, imp.name, imp.isTypeOnly].join('-')} root={file.path} path={imp.path} name={imp.name} />\n ))}\n <Faker\n name={faker.name}\n typeName={type.name}\n description={description}\n tree={tree}\n regexGenerator={regexGenerator}\n dateParser={dateParser}\n mapper={mapper}\n seed={seed}\n canOverride={canOverride}\n />\n </>\n )\n }\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output: plugin.options.output, config: driver.config })}\n footer={getFooter({ oas, output: plugin.options.output })}\n >\n <File.Import name={['faker']} path=\"@faker-js/faker\" />\n {regexGenerator === 'randexp' && <File.Import name={'RandExp'} path={'randexp'} />}\n {dateParser !== 'faker' && <File.Import path={dateParser} name={dateParser} />}\n {operationSchemas.map(mapOperationSchema)}\n </File>\n )\n },\n Schema({ schema, plugin }) {\n const { getName, getFile } = useSchemaManager()\n const {\n options: { output, dateParser, regexGenerator, seed, mapper },\n } = plugin\n const driver = usePluginDriver()\n const oas = useOas()\n const imports = getImports(schema.tree)\n\n const faker = {\n name: getName(schema.name, { type: 'function' }),\n file: getFile(schema.name),\n }\n\n const type = {\n name: getName(schema.name, { type: 'type', pluginName: pluginTsName }),\n file: getFile(schema.name, { pluginName: pluginTsName }),\n }\n\n const canOverride = schema.tree.some(\n ({ keyword }) =>\n keyword === schemaKeywords.array ||\n keyword === schemaKeywords.and ||\n keyword === schemaKeywords.object ||\n keyword === schemaKeywords.union ||\n keyword === schemaKeywords.tuple ||\n keyword === schemaKeywords.ref ||\n keyword === schemaKeywords.enum ||\n keyword === schemaKeywords.string ||\n keyword === schemaKeywords.integer ||\n keyword === schemaKeywords.number,\n )\n\n return (\n <File\n baseName={faker.file.baseName}\n path={faker.file.path}\n meta={faker.file.meta}\n banner={getBanner({ oas, output, config: driver.config })}\n footer={getFooter({ oas, output })}\n >\n <File.Import name={['faker']} path=\"@faker-js/faker\" />\n {regexGenerator === 'randexp' && <File.Import name={'RandExp'} path={'randexp'} />}\n {dateParser !== 'faker' && <File.Import path={dateParser} name={dateParser} />}\n <File.Import isTypeOnly root={faker.file.path} path={type.file.path} name={[type.name]} />\n {imports.map((imp) => (\n <File.Import key={[imp.path, imp.name, imp.isTypeOnly].join('-')} root={faker.file.path} path={imp.path} name={imp.name} />\n ))}\n\n <Faker\n name={faker.name}\n typeName={type.name}\n description={schema.value.description}\n tree={schema.tree}\n regexGenerator={regexGenerator}\n dateParser={dateParser}\n mapper={mapper}\n seed={seed}\n canOverride={canOverride}\n />\n </File>\n )\n },\n})\n"],"mappings":";;;;;;;;;;;AAUA,MAAa,iBAAiB,qBAAkC;CAC9D,MAAM;CACN,UAAU,EAAE,WAAW,WAAW,UAAU;EAC1C,MAAM,EACJ,SACA,SAAS,EAAE,YAAY,gBAAgB,MAAM,aAC3C;EACJ,MAAM,OAAO,SAAS;EACtB,MAAM,SAAS,iBAAiB;EAEhC,MAAM,MAAM,QAAQ;EACpB,MAAM,EAAE,YAAY,SAAS,aAAa,oBAAoB,UAAU;EACxE,MAAM,gBAAgB,kBAAkB;EAExC,MAAM,OAAO,QAAQ,UAAU;EAC/B,MAAM,UAAU,WAAW,UAAU;EACrC,MAAM,kBAAkB,IAAI,gBAAgB,SAAS;GACnD,QAAQ,UAAU,QAAQ;GAC1B;GACA;GACA,QAAQ,UAAU,QAAQ;GAC1B;GACA;GACA,UAAU,QAAQ;GACnB,CAAC;EAEF,MAAM,mBAAmB;GAAC,QAAQ;GAAY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Ae,SAC3B,YAAY,eAAe,SAC3B,YAAY,eAAe,OAC3B,YAAY,eAAe,QAC3B,YAAY,eAAe,UAC3B,YAAY,eAAe,WAC3B,YAAY,eAAe,OAC9B;AAED,SACE,qBAAC,MAAD;GACE,UAAU,MAAM,KAAK;GACrB,MAAM,MAAM,KAAK;GACjB,MAAM,MAAM,KAAK;GACjB,QAAQ,UAAU;IAAE;IAAK;IAAQ,QAAQ,OAAO;IAAQ,CAAC;GACzD,QAAQ,UAAU;IAAE;IAAK;IAAQ,CAAC;aALpC;IAOE,oBAAC,KAAK,QAAN;KAAa,MAAM,CAAC,QAAQ;KAAE,MAAK;KAAoB,CAAA;IACtD,mBAAmB,aAAa,oBAAC,KAAK,QAAN;KAAa,MAAM;KAAW,MAAM;KAAa,CAAA;IACjF,eAAe,WAAW,oBAAC,KAAK,QAAN;KAAa,MAAM;KAAY,MAAM;KAAc,CAAA;IAC9E,oBAAC,KAAK,QAAN;KAAa,YAAA;KAAW,MAAM,MAAM,KAAK;KAAM,MAAM,KAAK,KAAK;KAAM,MAAM,CAAC,KAAK,KAAK;KAAI,CAAA;IACzF,QAAQ,KAAK,QACZ,oBAAC,KAAK,QAAN;KAAkE,MAAM,MAAM,KAAK;KAAM,MAAM,IAAI;KAAM,MAAM,IAAI;KAAQ,EAAzG;KAAC,IAAI;KAAM,IAAI;KAAM,IAAI;KAAW,CAAC,KAAK,IAAI,CAA2D,CAC3H;IAEF,oBAAC,OAAD;KACE,MAAM,MAAM;KACZ,UAAU,KAAK;KACf,aAAa,OAAO,MAAM;KAC1B,MAAM,OAAO;KACG;KACJ;KACJ;KACF;KACO;KACb,CAAA;IACG;;;CAGZ,CAAC"}
@@ -1,3 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_fakerGenerator = require("./fakerGenerator-CYUCNH3Q.cjs");
3
- exports.fakerGenerator = require_fakerGenerator.fakerGenerator;