@kubb/plugin-faker 3.16.2 → 3.16.3
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-BpyQzZAY.cjs +324 -0
- package/dist/components-BpyQzZAY.cjs.map +1 -0
- package/dist/components-BwSq4Ikw.js +290 -0
- package/dist/components-BwSq4Ikw.js.map +1 -0
- package/dist/components.cjs +2 -11
- package/dist/components.d.cts +24 -15
- package/dist/components.d.ts +24 -15
- package/dist/components.js +3 -3
- package/dist/fakerGenerator-CXR9ksYA.js +199 -0
- package/dist/fakerGenerator-CXR9ksYA.js.map +1 -0
- package/dist/fakerGenerator-S8sgrtl5.cjs +204 -0
- package/dist/fakerGenerator-S8sgrtl5.cjs.map +1 -0
- package/dist/generators.cjs +3 -12
- package/dist/generators.d.cts +5 -6
- package/dist/generators.d.ts +5 -6
- package/dist/generators.js +4 -4
- package/dist/index.cjs +96 -124
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -7
- package/dist/index.d.ts +6 -7
- package/dist/index.js +96 -118
- package/dist/index.js.map +1 -1
- package/dist/types-Bh_6SttY.d.cts +1214 -0
- package/dist/types-DYUKPbgH.d.ts +1214 -0
- package/package.json +22 -27
- package/src/generators/__snapshots__/pet.ts +1 -0
- package/src/generators/__snapshots__/petWithDateString.ts +1 -0
- package/src/generators/__snapshots__/petWithDayjs.ts +1 -0
- package/src/generators/__snapshots__/petWithMapper.ts +1 -0
- package/src/generators/__snapshots__/petWithRandExp.ts +1 -0
- package/src/parser.ts +12 -3
- package/dist/chunk-BQQKSGJ4.js +0 -370
- package/dist/chunk-BQQKSGJ4.js.map +0 -1
- package/dist/chunk-DP3UK3GA.js +0 -137
- package/dist/chunk-DP3UK3GA.js.map +0 -1
- package/dist/chunk-DUV3ZLQX.cjs +0 -139
- package/dist/chunk-DUV3ZLQX.cjs.map +0 -1
- package/dist/chunk-ZA3QHI3O.cjs +0 -376
- package/dist/chunk-ZA3QHI3O.cjs.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-kyHdJ8oH.d.cts +0 -107
- package/dist/types-kyHdJ8oH.d.ts +0 -107
package/dist/chunk-DP3UK3GA.js
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { Faker } from './chunk-BQQKSGJ4.js';
|
|
2
|
-
import { createReactGenerator, schemaKeywords, SchemaGenerator } from '@kubb/plugin-oas';
|
|
3
|
-
import { Oas } from '@kubb/plugin-oas/components';
|
|
4
|
-
import { useSchemaManager, useOas, useOperationManager } from '@kubb/plugin-oas/hooks';
|
|
5
|
-
import { getFooter, getBanner } from '@kubb/plugin-oas/utils';
|
|
6
|
-
import { pluginTsName } from '@kubb/plugin-ts';
|
|
7
|
-
import { useApp, File } from '@kubb/react';
|
|
8
|
-
import { jsxs, jsx } from '@kubb/react/jsx-runtime';
|
|
9
|
-
|
|
10
|
-
var fakerGenerator = createReactGenerator({
|
|
11
|
-
name: "faker",
|
|
12
|
-
Operation({ operation, options }) {
|
|
13
|
-
const { dateParser, regexGenerator, seed, mapper } = options;
|
|
14
|
-
const { plugin, pluginManager, mode } = useApp();
|
|
15
|
-
const oas = useOas();
|
|
16
|
-
const { getSchemas, getFile, getGroup } = useOperationManager();
|
|
17
|
-
const schemaManager = useSchemaManager();
|
|
18
|
-
const file = getFile(operation);
|
|
19
|
-
const schemas = getSchemas(operation);
|
|
20
|
-
const schemaGenerator = new SchemaGenerator(options, {
|
|
21
|
-
oas,
|
|
22
|
-
plugin,
|
|
23
|
-
pluginManager,
|
|
24
|
-
mode,
|
|
25
|
-
override: options.override
|
|
26
|
-
});
|
|
27
|
-
const operationSchemas = [schemas.pathParams, schemas.queryParams, schemas.headerParams, schemas.statusCodes, schemas.request, schemas.response].flat().filter(Boolean);
|
|
28
|
-
const mapOperationSchema = ({ name, schema: schemaObject, description, ...options2 }, i) => {
|
|
29
|
-
const tree = schemaGenerator.parse({ schemaObject, name });
|
|
30
|
-
const imports = schemaManager.getImports(tree);
|
|
31
|
-
const group = options2.operation ? getGroup(options2.operation) : void 0;
|
|
32
|
-
const faker = {
|
|
33
|
-
name: schemaManager.getName(name, { type: "function" }),
|
|
34
|
-
file: schemaManager.getFile(name)
|
|
35
|
-
};
|
|
36
|
-
const type = {
|
|
37
|
-
name: schemaManager.getName(name, { type: "type", pluginKey: [pluginTsName] }),
|
|
38
|
-
file: schemaManager.getFile(options2.operationName || name, { pluginKey: [pluginTsName], group })
|
|
39
|
-
};
|
|
40
|
-
const canOverride = tree.some(
|
|
41
|
-
({ keyword }) => keyword === schemaKeywords.array || keyword === schemaKeywords.and || keyword === schemaKeywords.object || keyword === schemaKeywords.union || keyword === schemaKeywords.tuple
|
|
42
|
-
);
|
|
43
|
-
return /* @__PURE__ */ jsxs(Oas.Schema, { name, schemaObject, tree, children: [
|
|
44
|
-
canOverride && /* @__PURE__ */ jsx(File.Import, { isTypeOnly: true, root: file.path, path: type.file.path, name: [type.name] }),
|
|
45
|
-
imports.map((imp) => /* @__PURE__ */ jsx(File.Import, { root: file.path, path: imp.path, name: imp.name }, [imp.path, imp.name, imp.isTypeOnly].join("-"))),
|
|
46
|
-
/* @__PURE__ */ jsx(
|
|
47
|
-
Faker,
|
|
48
|
-
{
|
|
49
|
-
name: faker.name,
|
|
50
|
-
typeName: type.name,
|
|
51
|
-
description,
|
|
52
|
-
tree,
|
|
53
|
-
regexGenerator,
|
|
54
|
-
dateParser,
|
|
55
|
-
mapper,
|
|
56
|
-
seed,
|
|
57
|
-
canOverride
|
|
58
|
-
}
|
|
59
|
-
)
|
|
60
|
-
] }, i);
|
|
61
|
-
};
|
|
62
|
-
return /* @__PURE__ */ jsxs(
|
|
63
|
-
File,
|
|
64
|
-
{
|
|
65
|
-
baseName: file.baseName,
|
|
66
|
-
path: file.path,
|
|
67
|
-
meta: file.meta,
|
|
68
|
-
banner: getBanner({ oas, output: plugin.options.output, config: pluginManager.config }),
|
|
69
|
-
footer: getFooter({ oas, output: plugin.options.output }),
|
|
70
|
-
children: [
|
|
71
|
-
/* @__PURE__ */ jsx(File.Import, { name: ["faker"], path: "@faker-js/faker" }),
|
|
72
|
-
regexGenerator === "randexp" && /* @__PURE__ */ jsx(File.Import, { name: "RandExp", path: "randexp" }),
|
|
73
|
-
dateParser !== "faker" && /* @__PURE__ */ jsx(File.Import, { path: dateParser, name: dateParser }),
|
|
74
|
-
operationSchemas.map(mapOperationSchema)
|
|
75
|
-
]
|
|
76
|
-
}
|
|
77
|
-
);
|
|
78
|
-
},
|
|
79
|
-
Schema({ schema, options }) {
|
|
80
|
-
const { dateParser, regexGenerator, seed, mapper } = options;
|
|
81
|
-
const { getName, getFile, getImports } = useSchemaManager();
|
|
82
|
-
const {
|
|
83
|
-
pluginManager,
|
|
84
|
-
plugin: {
|
|
85
|
-
options: { output }
|
|
86
|
-
}
|
|
87
|
-
} = useApp();
|
|
88
|
-
const oas = useOas();
|
|
89
|
-
const imports = getImports(schema.tree);
|
|
90
|
-
const faker = {
|
|
91
|
-
name: getName(schema.name, { type: "function" }),
|
|
92
|
-
file: getFile(schema.name)
|
|
93
|
-
};
|
|
94
|
-
const type = {
|
|
95
|
-
name: getName(schema.name, { type: "type", pluginKey: [pluginTsName] }),
|
|
96
|
-
file: getFile(schema.name, { pluginKey: [pluginTsName] })
|
|
97
|
-
};
|
|
98
|
-
const canOverride = schema.tree.some(
|
|
99
|
-
({ keyword }) => keyword === schemaKeywords.array || keyword === schemaKeywords.and || keyword === schemaKeywords.object || keyword === schemaKeywords.union || keyword === schemaKeywords.tuple
|
|
100
|
-
);
|
|
101
|
-
return /* @__PURE__ */ jsxs(
|
|
102
|
-
File,
|
|
103
|
-
{
|
|
104
|
-
baseName: faker.file.baseName,
|
|
105
|
-
path: faker.file.path,
|
|
106
|
-
meta: faker.file.meta,
|
|
107
|
-
banner: getBanner({ oas, output, config: pluginManager.config }),
|
|
108
|
-
footer: getFooter({ oas, output }),
|
|
109
|
-
children: [
|
|
110
|
-
/* @__PURE__ */ jsx(File.Import, { name: ["faker"], path: "@faker-js/faker" }),
|
|
111
|
-
regexGenerator === "randexp" && /* @__PURE__ */ jsx(File.Import, { name: "RandExp", path: "randexp" }),
|
|
112
|
-
dateParser !== "faker" && /* @__PURE__ */ jsx(File.Import, { path: dateParser, name: dateParser }),
|
|
113
|
-
/* @__PURE__ */ jsx(File.Import, { isTypeOnly: true, root: faker.file.path, path: type.file.path, name: [type.name] }),
|
|
114
|
-
imports.map((imp) => /* @__PURE__ */ jsx(File.Import, { root: faker.file.path, path: imp.path, name: imp.name }, [imp.path, imp.name, imp.isTypeOnly].join("-"))),
|
|
115
|
-
/* @__PURE__ */ jsx(
|
|
116
|
-
Faker,
|
|
117
|
-
{
|
|
118
|
-
name: faker.name,
|
|
119
|
-
typeName: type.name,
|
|
120
|
-
description: schema.value.description,
|
|
121
|
-
tree: schema.tree,
|
|
122
|
-
regexGenerator,
|
|
123
|
-
dateParser,
|
|
124
|
-
mapper,
|
|
125
|
-
seed,
|
|
126
|
-
canOverride
|
|
127
|
-
}
|
|
128
|
-
)
|
|
129
|
-
]
|
|
130
|
-
}
|
|
131
|
-
);
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
export { fakerGenerator };
|
|
136
|
-
//# sourceMappingURL=chunk-DP3UK3GA.js.map
|
|
137
|
-
//# sourceMappingURL=chunk-DP3UK3GA.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/generators/fakerGenerator.tsx"],"names":["options"],"mappings":";;;;;;;;;AASO,IAAM,iBAAiB,oBAAkC,CAAA;AAAA,EAC9D,IAAM,EAAA,OAAA;AAAA,EACN,SAAU,CAAA,EAAE,SAAW,EAAA,OAAA,EAAW,EAAA;AAChC,IAAA,MAAM,EAAE,UAAA,EAAY,cAAgB,EAAA,IAAA,EAAM,QAAW,GAAA,OAAA;AAErD,IAAA,MAAM,EAA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K,CAAA,IAAA;AAAA,cACf,WAAA,EAAa,OAAO,KAAM,CAAA,WAAA;AAAA,cAC1B,MAAM,MAAO,CAAA,IAAA;AAAA,cACb,cAAA;AAAA,cACA,UAAA;AAAA,cACA,MAAA;AAAA,cACA,IAAA;AAAA,cACA;AAAA;AAAA;AACF;AAAA;AAAA,KACF;AAAA;AAGN,CAAC","file":"chunk-DP3UK3GA.js","sourcesContent":["import { createReactGenerator, type OperationSchema as OperationSchemaType, SchemaGenerator, schemaKeywords } from '@kubb/plugin-oas'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport { useOas, useOperationManager, useSchemaManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File, useApp } from '@kubb/react'\nimport { Faker } from '../components'\nimport type { PluginFaker } from '../types'\n\nexport const fakerGenerator = createReactGenerator<PluginFaker>({\n name: 'faker',\n Operation({ operation, options }) {\n const { dateParser, regexGenerator, seed, mapper } = options\n\n const { plugin, pluginManager, mode } = useApp<PluginFaker>()\n const oas = useOas()\n const { getSchemas, getFile, getGroup } = useOperationManager()\n const schemaManager = useSchemaManager()\n\n const file = getFile(operation)\n const schemas = getSchemas(operation)\n const schemaGenerator = new SchemaGenerator(options, {\n oas,\n plugin,\n pluginManager,\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(Boolean)\n\n const mapOperationSchema = ({ name, schema: schemaObject, description, ...options }: OperationSchemaType, i: number) => {\n const tree = schemaGenerator.parse({ schemaObject, name })\n const imports = schemaManager.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', pluginKey: [pluginTsName] }),\n file: schemaManager.getFile(options.operationName || name, { pluginKey: [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 )\n\n return (\n <Oas.Schema key={i} name={name} schemaObject={schemaObject} tree={tree}>\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 </Oas.Schema>\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: pluginManager.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, options }) {\n const { dateParser, regexGenerator, seed, mapper } = options\n\n const { getName, getFile, getImports } = useSchemaManager()\n const {\n pluginManager,\n plugin: {\n options: { output },\n },\n } = useApp<PluginFaker>()\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', pluginKey: [pluginTsName] }),\n file: getFile(schema.name, { pluginKey: [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 )\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: pluginManager.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"]}
|
package/dist/chunk-DUV3ZLQX.cjs
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunkZA3QHI3O_cjs = require('./chunk-ZA3QHI3O.cjs');
|
|
4
|
-
var pluginOas = require('@kubb/plugin-oas');
|
|
5
|
-
var components = require('@kubb/plugin-oas/components');
|
|
6
|
-
var hooks = require('@kubb/plugin-oas/hooks');
|
|
7
|
-
var utils = require('@kubb/plugin-oas/utils');
|
|
8
|
-
var pluginTs = require('@kubb/plugin-ts');
|
|
9
|
-
var react = require('@kubb/react');
|
|
10
|
-
var jsxRuntime = require('@kubb/react/jsx-runtime');
|
|
11
|
-
|
|
12
|
-
var fakerGenerator = pluginOas.createReactGenerator({
|
|
13
|
-
name: "faker",
|
|
14
|
-
Operation({ operation, options }) {
|
|
15
|
-
const { dateParser, regexGenerator, seed, mapper } = options;
|
|
16
|
-
const { plugin, pluginManager, mode } = react.useApp();
|
|
17
|
-
const oas = hooks.useOas();
|
|
18
|
-
const { getSchemas, getFile, getGroup } = hooks.useOperationManager();
|
|
19
|
-
const schemaManager = hooks.useSchemaManager();
|
|
20
|
-
const file = getFile(operation);
|
|
21
|
-
const schemas = getSchemas(operation);
|
|
22
|
-
const schemaGenerator = new pluginOas.SchemaGenerator(options, {
|
|
23
|
-
oas,
|
|
24
|
-
plugin,
|
|
25
|
-
pluginManager,
|
|
26
|
-
mode,
|
|
27
|
-
override: options.override
|
|
28
|
-
});
|
|
29
|
-
const operationSchemas = [schemas.pathParams, schemas.queryParams, schemas.headerParams, schemas.statusCodes, schemas.request, schemas.response].flat().filter(Boolean);
|
|
30
|
-
const mapOperationSchema = ({ name, schema: schemaObject, description, ...options2 }, i) => {
|
|
31
|
-
const tree = schemaGenerator.parse({ schemaObject, name });
|
|
32
|
-
const imports = schemaManager.getImports(tree);
|
|
33
|
-
const group = options2.operation ? getGroup(options2.operation) : void 0;
|
|
34
|
-
const faker = {
|
|
35
|
-
name: schemaManager.getName(name, { type: "function" }),
|
|
36
|
-
file: schemaManager.getFile(name)
|
|
37
|
-
};
|
|
38
|
-
const type = {
|
|
39
|
-
name: schemaManager.getName(name, { type: "type", pluginKey: [pluginTs.pluginTsName] }),
|
|
40
|
-
file: schemaManager.getFile(options2.operationName || name, { pluginKey: [pluginTs.pluginTsName], group })
|
|
41
|
-
};
|
|
42
|
-
const canOverride = tree.some(
|
|
43
|
-
({ keyword }) => keyword === pluginOas.schemaKeywords.array || keyword === pluginOas.schemaKeywords.and || keyword === pluginOas.schemaKeywords.object || keyword === pluginOas.schemaKeywords.union || keyword === pluginOas.schemaKeywords.tuple
|
|
44
|
-
);
|
|
45
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(components.Oas.Schema, { name, schemaObject, tree, children: [
|
|
46
|
-
canOverride && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { isTypeOnly: true, root: file.path, path: type.file.path, name: [type.name] }),
|
|
47
|
-
imports.map((imp) => /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { root: file.path, path: imp.path, name: imp.name }, [imp.path, imp.name, imp.isTypeOnly].join("-"))),
|
|
48
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
49
|
-
chunkZA3QHI3O_cjs.Faker,
|
|
50
|
-
{
|
|
51
|
-
name: faker.name,
|
|
52
|
-
typeName: type.name,
|
|
53
|
-
description,
|
|
54
|
-
tree,
|
|
55
|
-
regexGenerator,
|
|
56
|
-
dateParser,
|
|
57
|
-
mapper,
|
|
58
|
-
seed,
|
|
59
|
-
canOverride
|
|
60
|
-
}
|
|
61
|
-
)
|
|
62
|
-
] }, i);
|
|
63
|
-
};
|
|
64
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
65
|
-
react.File,
|
|
66
|
-
{
|
|
67
|
-
baseName: file.baseName,
|
|
68
|
-
path: file.path,
|
|
69
|
-
meta: file.meta,
|
|
70
|
-
banner: utils.getBanner({ oas, output: plugin.options.output, config: pluginManager.config }),
|
|
71
|
-
footer: utils.getFooter({ oas, output: plugin.options.output }),
|
|
72
|
-
children: [
|
|
73
|
-
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["faker"], path: "@faker-js/faker" }),
|
|
74
|
-
regexGenerator === "randexp" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: "RandExp", path: "randexp" }),
|
|
75
|
-
dateParser !== "faker" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { path: dateParser, name: dateParser }),
|
|
76
|
-
operationSchemas.map(mapOperationSchema)
|
|
77
|
-
]
|
|
78
|
-
}
|
|
79
|
-
);
|
|
80
|
-
},
|
|
81
|
-
Schema({ schema, options }) {
|
|
82
|
-
const { dateParser, regexGenerator, seed, mapper } = options;
|
|
83
|
-
const { getName, getFile, getImports } = hooks.useSchemaManager();
|
|
84
|
-
const {
|
|
85
|
-
pluginManager,
|
|
86
|
-
plugin: {
|
|
87
|
-
options: { output }
|
|
88
|
-
}
|
|
89
|
-
} = react.useApp();
|
|
90
|
-
const oas = hooks.useOas();
|
|
91
|
-
const imports = getImports(schema.tree);
|
|
92
|
-
const faker = {
|
|
93
|
-
name: getName(schema.name, { type: "function" }),
|
|
94
|
-
file: getFile(schema.name)
|
|
95
|
-
};
|
|
96
|
-
const type = {
|
|
97
|
-
name: getName(schema.name, { type: "type", pluginKey: [pluginTs.pluginTsName] }),
|
|
98
|
-
file: getFile(schema.name, { pluginKey: [pluginTs.pluginTsName] })
|
|
99
|
-
};
|
|
100
|
-
const canOverride = schema.tree.some(
|
|
101
|
-
({ keyword }) => keyword === pluginOas.schemaKeywords.array || keyword === pluginOas.schemaKeywords.and || keyword === pluginOas.schemaKeywords.object || keyword === pluginOas.schemaKeywords.union || keyword === pluginOas.schemaKeywords.tuple
|
|
102
|
-
);
|
|
103
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
104
|
-
react.File,
|
|
105
|
-
{
|
|
106
|
-
baseName: faker.file.baseName,
|
|
107
|
-
path: faker.file.path,
|
|
108
|
-
meta: faker.file.meta,
|
|
109
|
-
banner: utils.getBanner({ oas, output, config: pluginManager.config }),
|
|
110
|
-
footer: utils.getFooter({ oas, output }),
|
|
111
|
-
children: [
|
|
112
|
-
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["faker"], path: "@faker-js/faker" }),
|
|
113
|
-
regexGenerator === "randexp" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: "RandExp", path: "randexp" }),
|
|
114
|
-
dateParser !== "faker" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { path: dateParser, name: dateParser }),
|
|
115
|
-
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { isTypeOnly: true, root: faker.file.path, path: type.file.path, name: [type.name] }),
|
|
116
|
-
imports.map((imp) => /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { root: faker.file.path, path: imp.path, name: imp.name }, [imp.path, imp.name, imp.isTypeOnly].join("-"))),
|
|
117
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
118
|
-
chunkZA3QHI3O_cjs.Faker,
|
|
119
|
-
{
|
|
120
|
-
name: faker.name,
|
|
121
|
-
typeName: type.name,
|
|
122
|
-
description: schema.value.description,
|
|
123
|
-
tree: schema.tree,
|
|
124
|
-
regexGenerator,
|
|
125
|
-
dateParser,
|
|
126
|
-
mapper,
|
|
127
|
-
seed,
|
|
128
|
-
canOverride
|
|
129
|
-
}
|
|
130
|
-
)
|
|
131
|
-
]
|
|
132
|
-
}
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
exports.fakerGenerator = fakerGenerator;
|
|
138
|
-
//# sourceMappingURL=chunk-DUV3ZLQX.cjs.map
|
|
139
|
-
//# sourceMappingURL=chunk-DUV3ZLQX.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/generators/fakerGenerator.tsx"],"names":["createReactGenerator","useApp","useOas","useOperationManager","useSchemaManager","SchemaGenerator","options","pluginTsName","schemaKeywords","Oas","File","jsx","Faker","jsxs","getBanner","getFooter"],"mappings":";;;;;;;;;;;AASO,IAAM,iBAAiBA,8BAAkC,CAAA;AAAA,EAC9D,IAAM,EAAA,OAAA;AAAA,EACN,SAAU,CAAA,EAAE,SAAW,EAAA,OAAA,EAAW,EAAA;AAChC,IAAA,MAAM,EAAE,UAAA,EAAY,cAAgB,EAAA,IAAA,EAAM,QAAW,GAAA,OAAA;AAErD,IAAA,MAAM,EAAE,MAAA,EAAQ,aAAe,EAAA,IAAA,KAASC,YAAoB,EAAA;AAC5D,IAAA,MAAM,MAAMC,YAAO,EAAA;AACnB,IAAA,MAAM,EAAE,UAAA,EAAY,OAAS,EAAA,QAAA,KAAaC,yBAAoB,EAAA;AAC9D,IAAA,MAAM,gBAAgBC,sBAAiB,EAAA;AAEvC,IAAM,MAAA,IAAA,GAAO,QAAQ,SAAS,CAAA;AAC9B,IAAM,MAAA,OAAA,GAAU,WAAW,SAAS,CAAA;AACpC,IAAM,MAAA,eAAA,GAAkB,IAAIC,yBAAA,CAAgB,O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emaType, SchemaGenerator, schemaKeywords } from '@kubb/plugin-oas'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport { useOas, useOperationManager, useSchemaManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File, useApp } from '@kubb/react'\nimport { Faker } from '../components'\nimport type { PluginFaker } from '../types'\n\nexport const fakerGenerator = createReactGenerator<PluginFaker>({\n name: 'faker',\n Operation({ operation, options }) {\n const { dateParser, regexGenerator, seed, mapper } = options\n\n const { plugin, pluginManager, mode } = useApp<PluginFaker>()\n const oas = useOas()\n const { getSchemas, getFile, getGroup } = useOperationManager()\n const schemaManager = useSchemaManager()\n\n const file = getFile(operation)\n const schemas = getSchemas(operation)\n const schemaGenerator = new SchemaGenerator(options, {\n oas,\n plugin,\n pluginManager,\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(Boolean)\n\n const mapOperationSchema = ({ name, schema: schemaObject, description, ...options }: OperationSchemaType, i: number) => {\n const tree = schemaGenerator.parse({ schemaObject, name })\n const imports = schemaManager.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', pluginKey: [pluginTsName] }),\n file: schemaManager.getFile(options.operationName || name, { pluginKey: [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 )\n\n return (\n <Oas.Schema key={i} name={name} schemaObject={schemaObject} tree={tree}>\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 </Oas.Schema>\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: pluginManager.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, options }) {\n const { dateParser, regexGenerator, seed, mapper } = options\n\n const { getName, getFile, getImports } = useSchemaManager()\n const {\n pluginManager,\n plugin: {\n options: { output },\n },\n } = useApp<PluginFaker>()\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', pluginKey: [pluginTsName] }),\n file: getFile(schema.name, { pluginKey: [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 )\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: pluginManager.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"]}
|