@kubb/plugin-faker 5.0.0-beta.80 → 5.0.0-beta.84
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/index.cjs +57 -59
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +8 -14
- package/dist/index.js +25 -27
- package/dist/index.js.map +1 -1
- package/package.json +4 -6
package/dist/index.cjs
CHANGED
|
@@ -24,13 +24,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
24
|
enumerable: true
|
|
25
25
|
}) : target, mod));
|
|
26
26
|
//#endregion
|
|
27
|
-
let
|
|
27
|
+
let kubb_kit = require("kubb/kit");
|
|
28
28
|
let _kubb_plugin_ts = require("@kubb/plugin-ts");
|
|
29
|
-
let
|
|
29
|
+
let kubb_jsx = require("kubb/jsx");
|
|
30
30
|
let node_path = require("node:path");
|
|
31
31
|
node_path = __toESM(node_path, 1);
|
|
32
|
-
let
|
|
33
|
-
let _kubb_renderer_jsx_jsx_runtime = require("@kubb/renderer-jsx/jsx-runtime");
|
|
32
|
+
let kubb_jsx_jsx_runtime = require("kubb/jsx/jsx-runtime");
|
|
34
33
|
let node_crypto = require("node:crypto");
|
|
35
34
|
//#region src/utils.ts
|
|
36
35
|
/**
|
|
@@ -125,14 +124,14 @@ function buildResponseUnionSchema(node, resolver) {
|
|
|
125
124
|
if (responses.length === 1) {
|
|
126
125
|
const schema = responses[0].content?.[0]?.schema;
|
|
127
126
|
if (schema && shouldInlineSingleResponseSchema(schema)) return schema;
|
|
128
|
-
return
|
|
127
|
+
return kubb_kit.ast.factory.createSchema({
|
|
129
128
|
type: "ref",
|
|
130
129
|
name: resolver.resolveResponseStatusName(node, responses[0].statusCode)
|
|
131
130
|
});
|
|
132
131
|
}
|
|
133
|
-
return
|
|
132
|
+
return kubb_kit.ast.factory.createSchema({
|
|
134
133
|
type: "union",
|
|
135
|
-
members: responses.map((response) =>
|
|
134
|
+
members: responses.map((response) => kubb_kit.ast.factory.createSchema({
|
|
136
135
|
type: "ref",
|
|
137
136
|
name: resolver.resolveResponseStatusName(node, response.statusCode)
|
|
138
137
|
}))
|
|
@@ -255,24 +254,24 @@ function Faker({ node, description, name, typeName, printer, seed, canOverride }
|
|
|
255
254
|
const paramsSignature = declarationPrinter.print(params) ?? "";
|
|
256
255
|
const returnType = resolvedReturnType;
|
|
257
256
|
const returnExpression = node.type === "ref" && canOverride && returnType ? `${fakerTextWithOverride} as ${returnType}` : fakerTextWithOverride;
|
|
258
|
-
return /* @__PURE__ */ (0,
|
|
257
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
259
258
|
name,
|
|
260
259
|
isExportable: true,
|
|
261
260
|
isIndexable: true,
|
|
262
|
-
children: /* @__PURE__ */ (0,
|
|
261
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx.Function, {
|
|
263
262
|
export: true,
|
|
264
263
|
name,
|
|
265
|
-
JSDoc: { comments: description ? [`@description ${
|
|
264
|
+
JSDoc: { comments: description ? [`@description ${kubb_kit.ast.jsStringEscape(description)}`] : [] },
|
|
266
265
|
params: canOverride ? paramsSignature : void 0,
|
|
267
266
|
returnType: returnType ?? void 0,
|
|
268
|
-
children: [seed ? /* @__PURE__ */ (0,
|
|
267
|
+
children: [seed ? /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx_jsx_runtime.Fragment, { children: [`faker.seed(${JSON.stringify(seed)})`, /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)("br", {})] }) : void 0, `return ${returnExpression}`]
|
|
269
268
|
})
|
|
270
269
|
});
|
|
271
270
|
}
|
|
272
|
-
const functionSignature = `${description ? `/**\n * @description ${
|
|
271
|
+
const functionSignature = `${description ? `/**\n * @description ${kubb_kit.ast.jsStringEscape(description)}\n */\n ` : ""}export function ${name}<TData extends Partial<${typeName}> = object>(data?: TData)`;
|
|
273
272
|
const seedCode = seed ? `faker.seed(${JSON.stringify(seed)})\n ` : "";
|
|
274
273
|
const { cyclicSchemas, schemaName } = printer.options;
|
|
275
|
-
const functionBody = node.type === "object" && !!cyclicSchemas && (node.properties ?? []).some((p) =>
|
|
274
|
+
const functionBody = node.type === "object" && !!cyclicSchemas && (node.properties ?? []).some((p) => kubb_kit.ast.containsCircularRef(p.schema, {
|
|
276
275
|
circularSchemas: cyclicSchemas,
|
|
277
276
|
excludeName: schemaName
|
|
278
277
|
})) ? `{
|
|
@@ -290,7 +289,7 @@ function Faker({ node, description, name, typeName, printer, seed, canOverride }
|
|
|
290
289
|
...(data || {}),
|
|
291
290
|
} as Omit<typeof defaultFakeData, keyof TData> & TData
|
|
292
291
|
}`;
|
|
293
|
-
return /* @__PURE__ */ (0,
|
|
292
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx.File.Source, {
|
|
294
293
|
name,
|
|
295
294
|
isExportable: true,
|
|
296
295
|
isIndexable: true,
|
|
@@ -682,7 +681,7 @@ const fakerKeywordMapper = {
|
|
|
682
681
|
return `{...${items.join(", ...")}}`;
|
|
683
682
|
},
|
|
684
683
|
matches: (value = "", regexGenerator = "faker") => {
|
|
685
|
-
if (regexGenerator === "randexp") return `${
|
|
684
|
+
if (regexGenerator === "randexp") return `${kubb_kit.ast.toRegExpString(value, "RandExp")}.gen()`;
|
|
686
685
|
return `faker.helpers.fromRegExp("${value}")`;
|
|
687
686
|
},
|
|
688
687
|
email: () => "faker.internet.email()",
|
|
@@ -693,13 +692,15 @@ function getEnumValues(node) {
|
|
|
693
692
|
return node.enumValues ?? [];
|
|
694
693
|
}
|
|
695
694
|
function parseEnumValue(value) {
|
|
696
|
-
if (typeof value === "string") return
|
|
695
|
+
if (typeof value === "string") return kubb_kit.ast.stringify(value);
|
|
697
696
|
return value;
|
|
698
697
|
}
|
|
699
|
-
/**
|
|
698
|
+
/**
|
|
699
|
+
* Reads the discriminator literal off a variant, or `undefined` when it can't be determined.
|
|
700
|
+
*/
|
|
700
701
|
function getDiscriminatorValue(member, discriminatorPropertyName) {
|
|
701
|
-
const prop =
|
|
702
|
-
const enumNode = prop ?
|
|
702
|
+
const prop = kubb_kit.ast.narrowSchema(member, "object")?.properties?.find((p) => p.name === discriminatorPropertyName);
|
|
703
|
+
const enumNode = prop ? kubb_kit.ast.narrowSchema(prop.schema, "enum") : null;
|
|
703
704
|
return enumNode ? getEnumValues(enumNode)[0] : void 0;
|
|
704
705
|
}
|
|
705
706
|
/**
|
|
@@ -716,7 +717,7 @@ function indexedTypeName(typeName, propertyName, nestedInUnion) {
|
|
|
716
717
|
* Creates a Faker printer that generates mock data generation code from schema nodes.
|
|
717
718
|
* Handles circular references gracefully by emitting memoizing getters for cyclic properties.
|
|
718
719
|
*/
|
|
719
|
-
const printerFaker =
|
|
720
|
+
const printerFaker = kubb_kit.ast.createPrinter((options) => {
|
|
720
721
|
const printNested = (node, overrideOptions = {}) => {
|
|
721
722
|
return printerFaker({
|
|
722
723
|
...options,
|
|
@@ -756,7 +757,7 @@ const printerFaker = _kubb_core.ast.createPrinter((options) => {
|
|
|
756
757
|
return fakerKeywordMapper.time(node.representation ?? "string", this.options.dateParser);
|
|
757
758
|
},
|
|
758
759
|
ref(node) {
|
|
759
|
-
const refName = node.ref ? this.options.nameMapping?.get(node.ref) ??
|
|
760
|
+
const refName = node.ref ? this.options.nameMapping?.get(node.ref) ?? kubb_kit.ast.extractRefName(node.ref) ?? node.name ?? node.schema?.name : node.name ?? node.schema?.name;
|
|
760
761
|
if (!refName) throw new Error("Name not defined for ref node");
|
|
761
762
|
if (this.options.schemaName && refName === this.options.schemaName) return this.options.typeName ? `undefined as unknown as ${this.options.typeName}` : "undefined as unknown";
|
|
762
763
|
const resolvedName = node.ref ? this.options.resolver.resolveName(refName) : refName;
|
|
@@ -769,7 +770,7 @@ const printerFaker = _kubb_core.ast.createPrinter((options) => {
|
|
|
769
770
|
union(node) {
|
|
770
771
|
const { discriminatorPropertyName } = node;
|
|
771
772
|
const baseTypeName = this.options.typeName;
|
|
772
|
-
const items =
|
|
773
|
+
const items = kubb_kit.ast.mapSchemaMembers(node, (member) => {
|
|
773
774
|
const value = discriminatorPropertyName ? getDiscriminatorValue(member, discriminatorPropertyName) : void 0;
|
|
774
775
|
if (baseTypeName && value !== void 0) return printNested(member, {
|
|
775
776
|
typeName: `Extract<NonNullable<${baseTypeName}>, { ${JSON.stringify(discriminatorPropertyName)}: ${parseEnumValue(value)} }>`,
|
|
@@ -784,11 +785,11 @@ const printerFaker = _kubb_core.ast.createPrinter((options) => {
|
|
|
784
785
|
return fakerKeywordMapper.union(items);
|
|
785
786
|
},
|
|
786
787
|
intersection(node) {
|
|
787
|
-
const items =
|
|
788
|
+
const items = kubb_kit.ast.mapSchemaMembers(node, (member) => printNested(member, { nestedInObject: true })).map(({ output }) => output).filter((item) => Boolean(item) && item !== "undefined");
|
|
788
789
|
return fakerKeywordMapper.and(items);
|
|
789
790
|
},
|
|
790
791
|
array(node) {
|
|
791
|
-
const items =
|
|
792
|
+
const items = kubb_kit.ast.mapSchemaItems(node, (member) => printNested(member, {
|
|
792
793
|
typeName: this.options.typeName ? `NonNullable<${this.options.typeName}>[number]` : void 0,
|
|
793
794
|
nestedInObject: true
|
|
794
795
|
})).map(({ output }) => output).filter((item) => Boolean(item));
|
|
@@ -803,18 +804,18 @@ const printerFaker = _kubb_core.ast.createPrinter((options) => {
|
|
|
803
804
|
},
|
|
804
805
|
object(node) {
|
|
805
806
|
const cyclicSchemas = this.options.cyclicSchemas;
|
|
806
|
-
|
|
807
|
-
if (this.options.mapper && Object.hasOwn(this.options.mapper, property.name)) return `${(0, _kubb_ast_utils.objectKey)(property.name)}: ${this.options.mapper[property.name]}`;
|
|
807
|
+
const entries = (node.properties ?? []).map((property) => {
|
|
808
808
|
const value = printNested(property.schema, {
|
|
809
809
|
typeName: this.options.typeName ? indexedTypeName(this.options.typeName, property.name, this.options.nestedInUnion) : void 0,
|
|
810
810
|
nestedInObject: true
|
|
811
811
|
}) ?? "undefined";
|
|
812
|
-
if (cyclicSchemas &&
|
|
812
|
+
if (cyclicSchemas && kubb_kit.ast.containsCircularRef(property.schema, {
|
|
813
813
|
circularSchemas: cyclicSchemas,
|
|
814
814
|
excludeName: this.options.schemaName
|
|
815
|
-
})) return `get ${
|
|
816
|
-
return `${
|
|
817
|
-
})
|
|
815
|
+
})) return `get ${kubb_kit.ast.objectKey(property.name)}() { const _value = ${value}; Object.defineProperty(this, ${JSON.stringify(property.name)}, { value: _value, configurable: true, writable: true, enumerable: true }); return _value }`;
|
|
816
|
+
return `${kubb_kit.ast.objectKey(property.name)}: ${value}`;
|
|
817
|
+
});
|
|
818
|
+
return kubb_kit.ast.buildObject(entries);
|
|
818
819
|
},
|
|
819
820
|
...options.nodes
|
|
820
821
|
},
|
|
@@ -831,17 +832,17 @@ const printerFaker = _kubb_core.ast.createPrinter((options) => {
|
|
|
831
832
|
* factory returns a value matching the corresponding TypeScript type from
|
|
832
833
|
* `@kubb/plugin-ts`.
|
|
833
834
|
*/
|
|
834
|
-
const fakerGenerator = (0,
|
|
835
|
+
const fakerGenerator = (0, kubb_kit.defineGenerator)({
|
|
835
836
|
name: "faker",
|
|
836
|
-
renderer:
|
|
837
|
+
renderer: kubb_jsx.jsxRenderer,
|
|
837
838
|
schema(node, ctx) {
|
|
838
839
|
const { adapter, config, resolver, root } = ctx;
|
|
839
|
-
const { output, group, dateParser, regexGenerator,
|
|
840
|
+
const { output, group, dateParser, regexGenerator, seed, locale, printer } = ctx.options;
|
|
840
841
|
const pluginTs = ctx.driver.getPlugin(_kubb_plugin_ts.pluginTsName);
|
|
841
842
|
if (!node.name || !pluginTs) return;
|
|
842
843
|
const tsResolver = ctx.driver.getResolver(_kubb_plugin_ts.pluginTsName);
|
|
843
844
|
const schemaName = node.name;
|
|
844
|
-
const isEnumSchema = !!
|
|
845
|
+
const isEnumSchema = !!kubb_kit.ast.narrowSchema(node, kubb_kit.ast.schemaTypes.enum);
|
|
845
846
|
const tsEnumType = pluginTs.options?.enum?.type;
|
|
846
847
|
const tsEnumTypeSuffix = pluginTs.options?.enum?.typeSuffix ?? "Key";
|
|
847
848
|
const schemaTypeName = isEnumSchema && tsEnumType === "asConst" ? tsResolver.resolveEnumKeyName({ name: schemaName }, tsEnumTypeSuffix) : tsResolver.resolveTypeName(schemaName);
|
|
@@ -873,7 +874,6 @@ const fakerGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
873
874
|
typeName: meta.typeName,
|
|
874
875
|
dateParser,
|
|
875
876
|
regexGenerator,
|
|
876
|
-
mapper,
|
|
877
877
|
nodes: printer?.nodes,
|
|
878
878
|
cyclicSchemas,
|
|
879
879
|
nameMapping: adapter.options.nameMapping
|
|
@@ -898,7 +898,7 @@ const fakerGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
898
898
|
group: group ?? void 0
|
|
899
899
|
}).path
|
|
900
900
|
})), fakerText);
|
|
901
|
-
return /* @__PURE__ */ (0,
|
|
901
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx.File, {
|
|
902
902
|
baseName: meta.file.baseName,
|
|
903
903
|
path: meta.file.path,
|
|
904
904
|
meta: meta.file.meta,
|
|
@@ -919,28 +919,28 @@ const fakerGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
919
919
|
}
|
|
920
920
|
}),
|
|
921
921
|
children: [
|
|
922
|
-
/* @__PURE__ */ (0,
|
|
922
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
923
923
|
name: locale ? [{
|
|
924
924
|
propertyName: localeToFakerImport(locale),
|
|
925
925
|
name: "faker"
|
|
926
926
|
}] : ["faker"],
|
|
927
927
|
path: "@faker-js/faker"
|
|
928
928
|
}),
|
|
929
|
-
regexGenerator === "randexp" && /* @__PURE__ */ (0,
|
|
929
|
+
regexGenerator === "randexp" && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
930
930
|
name: "RandExp",
|
|
931
931
|
path: "randexp"
|
|
932
932
|
}),
|
|
933
|
-
dateParser !== "faker" && /* @__PURE__ */ (0,
|
|
933
|
+
dateParser !== "faker" && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
934
934
|
path: dateParser,
|
|
935
935
|
name: dateParser
|
|
936
936
|
}),
|
|
937
|
-
typeReference.importPath && /* @__PURE__ */ (0,
|
|
937
|
+
typeReference.importPath && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
938
938
|
isTypeOnly: true,
|
|
939
939
|
root: meta.file.path,
|
|
940
940
|
path: typeReference.importPath,
|
|
941
941
|
name: [meta.typeName]
|
|
942
942
|
}),
|
|
943
|
-
usedImports.map((imp) => /* @__PURE__ */ (0,
|
|
943
|
+
usedImports.map((imp) => /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
944
944
|
root: meta.file.path,
|
|
945
945
|
path: imp.path,
|
|
946
946
|
name: imp.name
|
|
@@ -949,7 +949,7 @@ const fakerGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
949
949
|
imp.path,
|
|
950
950
|
imp.name
|
|
951
951
|
].join("-"))),
|
|
952
|
-
/* @__PURE__ */ (0,
|
|
952
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(Faker, {
|
|
953
953
|
name: meta.name,
|
|
954
954
|
typeName: typeReference.typeName,
|
|
955
955
|
description: node.description,
|
|
@@ -963,7 +963,7 @@ const fakerGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
963
963
|
},
|
|
964
964
|
operation(node, ctx) {
|
|
965
965
|
const { adapter, config, resolver, root } = ctx;
|
|
966
|
-
const { output, group, dateParser, regexGenerator,
|
|
966
|
+
const { output, group, dateParser, regexGenerator, seed, locale, printer } = ctx.options;
|
|
967
967
|
const pluginTs = ctx.driver.getPlugin(_kubb_plugin_ts.pluginTsName);
|
|
968
968
|
if (!pluginTs) return;
|
|
969
969
|
const tsResolver = ctx.driver.getResolver(_kubb_plugin_ts.pluginTsName);
|
|
@@ -986,9 +986,9 @@ const fakerGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
986
986
|
}];
|
|
987
987
|
}
|
|
988
988
|
const variants = resolveContentTypeVariants(entries, baseName);
|
|
989
|
-
const unionSchema =
|
|
989
|
+
const unionSchema = kubb_kit.ast.factory.createSchema({
|
|
990
990
|
type: "union",
|
|
991
|
-
members: variants.map((variant) =>
|
|
991
|
+
members: variants.map((variant) => kubb_kit.ast.factory.createSchema({
|
|
992
992
|
type: "ref",
|
|
993
993
|
name: variant.name
|
|
994
994
|
}))
|
|
@@ -1064,7 +1064,6 @@ const fakerGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1064
1064
|
typeName,
|
|
1065
1065
|
dateParser,
|
|
1066
1066
|
regexGenerator,
|
|
1067
|
-
mapper,
|
|
1068
1067
|
nodes: printer?.nodes,
|
|
1069
1068
|
cyclicSchemas,
|
|
1070
1069
|
nameMapping: adapter.options.nameMapping
|
|
@@ -1080,14 +1079,14 @@ const fakerGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1080
1079
|
filePath: meta.file.path,
|
|
1081
1080
|
typeFilePath: meta.typeFile.path
|
|
1082
1081
|
});
|
|
1083
|
-
return /* @__PURE__ */ (0,
|
|
1084
|
-
typeReference.importPath && /* @__PURE__ */ (0,
|
|
1082
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx_jsx_runtime.Fragment, { children: [
|
|
1083
|
+
typeReference.importPath && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1085
1084
|
isTypeOnly: true,
|
|
1086
1085
|
root: meta.file.path,
|
|
1087
1086
|
path: typeReference.importPath,
|
|
1088
1087
|
name: [typeName]
|
|
1089
1088
|
}),
|
|
1090
|
-
imports.map((imp) => /* @__PURE__ */ (0,
|
|
1089
|
+
imports.map((imp) => /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1091
1090
|
root: meta.file.path,
|
|
1092
1091
|
path: imp.path,
|
|
1093
1092
|
name: imp.name
|
|
@@ -1096,7 +1095,7 @@ const fakerGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1096
1095
|
imp.path,
|
|
1097
1096
|
imp.name
|
|
1098
1097
|
].join("-"))),
|
|
1099
|
-
/* @__PURE__ */ (0,
|
|
1098
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(Faker, {
|
|
1100
1099
|
name,
|
|
1101
1100
|
typeName: typeReference.typeName,
|
|
1102
1101
|
description,
|
|
@@ -1110,7 +1109,7 @@ const fakerGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1110
1109
|
})
|
|
1111
1110
|
] });
|
|
1112
1111
|
}
|
|
1113
|
-
return /* @__PURE__ */ (0,
|
|
1112
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx.File, {
|
|
1114
1113
|
baseName: meta.file.baseName,
|
|
1115
1114
|
path: meta.file.path,
|
|
1116
1115
|
meta: meta.file.meta,
|
|
@@ -1131,18 +1130,18 @@ const fakerGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1131
1130
|
}
|
|
1132
1131
|
}),
|
|
1133
1132
|
children: [
|
|
1134
|
-
/* @__PURE__ */ (0,
|
|
1133
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1135
1134
|
name: locale ? [{
|
|
1136
1135
|
propertyName: localeToFakerImport(locale),
|
|
1137
1136
|
name: "faker"
|
|
1138
1137
|
}] : ["faker"],
|
|
1139
1138
|
path: "@faker-js/faker"
|
|
1140
1139
|
}),
|
|
1141
|
-
regexGenerator === "randexp" && /* @__PURE__ */ (0,
|
|
1140
|
+
regexGenerator === "randexp" && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1142
1141
|
name: "RandExp",
|
|
1143
1142
|
path: "randexp"
|
|
1144
1143
|
}),
|
|
1145
|
-
dateParser !== "faker" && /* @__PURE__ */ (0,
|
|
1144
|
+
dateParser !== "faker" && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1146
1145
|
path: dateParser,
|
|
1147
1146
|
name: dateParser
|
|
1148
1147
|
}),
|
|
@@ -1189,7 +1188,7 @@ const fakerGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1189
1188
|
* resolverFaker.default('list pets', 'function') // 'createListPets'
|
|
1190
1189
|
* ```
|
|
1191
1190
|
*/
|
|
1192
|
-
const resolverFaker = (0,
|
|
1191
|
+
const resolverFaker = (0, kubb_kit.defineResolver)(() => {
|
|
1193
1192
|
return {
|
|
1194
1193
|
name: "default",
|
|
1195
1194
|
pluginName: "plugin-faker",
|
|
@@ -1264,7 +1263,7 @@ const pluginFakerName = "plugin-faker";
|
|
|
1264
1263
|
*
|
|
1265
1264
|
* @example
|
|
1266
1265
|
* ```ts
|
|
1267
|
-
* import { defineConfig } from 'kubb'
|
|
1266
|
+
* import { defineConfig } from 'kubb/config'
|
|
1268
1267
|
* import { pluginTs } from '@kubb/plugin-ts'
|
|
1269
1268
|
* import { pluginFaker } from '@kubb/plugin-faker'
|
|
1270
1269
|
*
|
|
@@ -1281,11 +1280,11 @@ const pluginFakerName = "plugin-faker";
|
|
|
1281
1280
|
* })
|
|
1282
1281
|
* ```
|
|
1283
1282
|
*/
|
|
1284
|
-
const pluginFaker = (0,
|
|
1283
|
+
const pluginFaker = (0, kubb_kit.definePlugin)((options) => {
|
|
1285
1284
|
const { output = {
|
|
1286
1285
|
path: "mocks",
|
|
1287
1286
|
barrel: { type: "named" }
|
|
1288
|
-
}, seed, locale = "en", group, exclude = [], include, override = [],
|
|
1287
|
+
}, seed, locale = "en", group, exclude = [], include, override = [], dateParser = "faker", regexGenerator = "faker", printer, resolver: userResolver, macros: userMacros } = options;
|
|
1289
1288
|
const groupConfig = createGroupConfig(group);
|
|
1290
1289
|
return {
|
|
1291
1290
|
name: pluginFakerName,
|
|
@@ -1300,7 +1299,6 @@ const pluginFaker = (0, _kubb_core.definePlugin)((options) => {
|
|
|
1300
1299
|
include,
|
|
1301
1300
|
override,
|
|
1302
1301
|
group: groupConfig,
|
|
1303
|
-
mapper,
|
|
1304
1302
|
dateParser,
|
|
1305
1303
|
regexGenerator,
|
|
1306
1304
|
printer
|