@kubb/plugin-faker 4.29.0 → 4.29.1
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.d.ts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/{types-BkocHcoS.d.ts → types-BIWyHbXy.d.ts} +10 -1
- package/dist/{types-BYSbV9lp.d.ts → types-DpNAdZTi.d.ts} +10 -1
- package/package.json +5 -5
- package/src/generators/__snapshots__/pet.ts +1 -1
- package/src/generators/__snapshots__/petWithDateString.ts +1 -1
- package/src/generators/__snapshots__/petWithDayjs.ts +1 -1
- package/src/generators/__snapshots__/petWithRandExp.ts +1 -1
- package/src/generators/__snapshots__/updatePet.ts +1 -1
- package/src/plugin.ts +2 -0
- package/src/types.ts +9 -0
package/dist/components.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __name } from "./chunk-DKWOrOAv.js";
|
|
2
|
-
import { n as PluginFaker } from "./types-
|
|
2
|
+
import { n as PluginFaker } from "./types-BIWyHbXy.js";
|
|
3
3
|
import { Schema } from "@kubb/plugin-oas";
|
|
4
4
|
import { FabricReactNode } from "@kubb/react-fabric/types";
|
|
5
5
|
|
package/dist/generators.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __name } from "./chunk-DKWOrOAv.js";
|
|
2
|
-
import { n as PluginFaker } from "./types-
|
|
2
|
+
import { n as PluginFaker } from "./types-BIWyHbXy.js";
|
|
3
3
|
import { BaseGenerator, Config, FileMetaBase, Group, KubbEvents, Output, Plugin, PluginFactoryOptions, PluginManager, ResolveNameParams } from "@kubb/core";
|
|
4
4
|
import { Fabric } from "@kubb/react-fabric";
|
|
5
5
|
import { FabricReactNode } from "@kubb/react-fabric/types";
|
package/dist/index.cjs
CHANGED
|
@@ -14,7 +14,7 @@ const pluginFaker = (0, _kubb_core.definePlugin)((options) => {
|
|
|
14
14
|
const { output = {
|
|
15
15
|
path: "mocks",
|
|
16
16
|
barrelType: "named"
|
|
17
|
-
}, seed, group, exclude = [], include, override = [], transformers = {}, mapper = {}, unknownType = "any", emptySchemaType = unknownType, dateType = "string", dateParser = "faker", generators = [require_fakerGenerator.fakerGenerator].filter(Boolean), regexGenerator = "faker", paramsCasing, contentType } = options;
|
|
17
|
+
}, seed, group, exclude = [], include, override = [], transformers = {}, mapper = {}, unknownType = "any", emptySchemaType = unknownType, dateType = "string", integerType = "number", dateParser = "faker", generators = [require_fakerGenerator.fakerGenerator].filter(Boolean), regexGenerator = "faker", paramsCasing, contentType } = options;
|
|
18
18
|
return {
|
|
19
19
|
name: pluginFakerName,
|
|
20
20
|
options: {
|
|
@@ -22,6 +22,7 @@ const pluginFaker = (0, _kubb_core.definePlugin)((options) => {
|
|
|
22
22
|
transformers,
|
|
23
23
|
seed,
|
|
24
24
|
dateType,
|
|
25
|
+
integerType,
|
|
25
26
|
unknownType,
|
|
26
27
|
emptySchemaType,
|
|
27
28
|
dateParser,
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["fakerGenerator","pluginOasName","pluginTsName","path","SchemaGenerator","OperationGenerator"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { OperationGenerator, pluginOasName, SchemaGenerator } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { fakerGenerator } from './generators/fakerGenerator.tsx'\nimport type { PluginFaker } from './types.ts'\n\nexport const pluginFakerName = 'plugin-faker' satisfies PluginFaker['name']\n\nexport const pluginFaker = definePlugin<PluginFaker>((options) => {\n const {\n output = { path: 'mocks', barrelType: 'named' },\n seed,\n group,\n exclude = [],\n include,\n override = [],\n transformers = {},\n mapper = {},\n unknownType = 'any',\n emptySchemaType = unknownType,\n dateType = 'string',\n dateParser = 'faker',\n generators = [fakerGenerator].filter(Boolean),\n regexGenerator = 'faker',\n paramsCasing,\n contentType,\n } = options\n\n // @deprecated Will be removed in v5 when collisionDetection defaults to true\n const usedEnumNames = {}\n\n return {\n name: pluginFakerName,\n options: {\n output,\n transformers,\n seed,\n dateType,\n unknownType,\n emptySchemaType,\n dateParser,\n mapper,\n override,\n regexGenerator,\n paramsCasing,\n group,\n usedEnumNames,\n },\n pre: [pluginOasName, pluginTsName],\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n const resolvedName = camelCase(name, {\n prefix: type ? 'create' : undefined,\n isFile: type === 'file',\n })\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async install() {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n const oas = await this.getOas()\n\n const schemaGenerator = new SchemaGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n events: this.events,\n plugin: this.plugin,\n contentType,\n include: undefined,\n override,\n mode,\n output: output.path,\n })\n\n const schemaFiles = await schemaGenerator.build(...generators)\n await this.upsertFile(...schemaFiles)\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n events: this.events,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const operationFiles = await operationGenerator.build(...generators)\n await this.upsertFile(...operationFiles)\n\n const barrelFiles = await getBarrelFiles(this.fabric.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;AAQA,MAAa,kBAAkB;AAE/B,MAAa,4CAAyC,YAAY;CAChE,MAAM,EACJ,SAAS;EAAE,MAAM;EAAS,YAAY;EAAS,EAC/C,MACA,OACA,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,eAAe,EAAE,EACjB,SAAS,EAAE,EACX,cAAc,OACd,kBAAkB,aAClB,WAAW,UACX,aAAa,SACb,aAAa,CAACA,sCAAe,CAAC,OAAO,QAAQ,EAC7C,iBAAiB,SACjB,cACA,gBACE;AAKJ,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["fakerGenerator","pluginOasName","pluginTsName","path","SchemaGenerator","OperationGenerator"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { OperationGenerator, pluginOasName, SchemaGenerator } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { fakerGenerator } from './generators/fakerGenerator.tsx'\nimport type { PluginFaker } from './types.ts'\n\nexport const pluginFakerName = 'plugin-faker' satisfies PluginFaker['name']\n\nexport const pluginFaker = definePlugin<PluginFaker>((options) => {\n const {\n output = { path: 'mocks', barrelType: 'named' },\n seed,\n group,\n exclude = [],\n include,\n override = [],\n transformers = {},\n mapper = {},\n unknownType = 'any',\n emptySchemaType = unknownType,\n dateType = 'string',\n integerType = 'number',\n dateParser = 'faker',\n generators = [fakerGenerator].filter(Boolean),\n regexGenerator = 'faker',\n paramsCasing,\n contentType,\n } = options\n\n // @deprecated Will be removed in v5 when collisionDetection defaults to true\n const usedEnumNames = {}\n\n return {\n name: pluginFakerName,\n options: {\n output,\n transformers,\n seed,\n dateType,\n integerType,\n unknownType,\n emptySchemaType,\n dateParser,\n mapper,\n override,\n regexGenerator,\n paramsCasing,\n group,\n usedEnumNames,\n },\n pre: [pluginOasName, pluginTsName],\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n const resolvedName = camelCase(name, {\n prefix: type ? 'create' : undefined,\n isFile: type === 'file',\n })\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async install() {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n const oas = await this.getOas()\n\n const schemaGenerator = new SchemaGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n events: this.events,\n plugin: this.plugin,\n contentType,\n include: undefined,\n override,\n mode,\n output: output.path,\n })\n\n const schemaFiles = await schemaGenerator.build(...generators)\n await this.upsertFile(...schemaFiles)\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n events: this.events,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const operationFiles = await operationGenerator.build(...generators)\n await this.upsertFile(...operationFiles)\n\n const barrelFiles = await getBarrelFiles(this.fabric.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;AAQA,MAAa,kBAAkB;AAE/B,MAAa,4CAAyC,YAAY;CAChE,MAAM,EACJ,SAAS;EAAE,MAAM;EAAS,YAAY;EAAS,EAC/C,MACA,OACA,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,eAAe,EAAE,EACjB,SAAS,EAAE,EACX,cAAc,OACd,kBAAkB,aAClB,WAAW,UACX,cAAc,UACd,aAAa,SACb,aAAa,CAACA,sCAAe,CAAC,OAAO,QAAQ,EAC7C,iBAAiB,SACjB,cACA,gBACE;AAKJ,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,eAlBkB,EAAE;GAmBrB;EACD,KAAK,CAACC,gCAAeC,6BAAa;EAClC,YAAY,UAAU,UAAU,SAAS;GACvC,MAAM,OAAOC,kBAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;AAGpE,QAFa,oCAAoBA,kBAAK,QAAQ,MAAM,OAAO,KAAK,CAAC,MAEpD;;;;;AAKX,UAAOA,kBAAK,QAAQ,MAAM,OAAO,KAAK;AAGxC,OAAI,UAAU,SAAS,OAAO,QAAQ,SAAS,OAAO,MAAM;IAC1D,MAAM,YAA2B,OAAO,OACpC,MAAM,QACL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C3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACF,CAAC;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;EACD"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@ const pluginFaker = definePlugin((options) => {
|
|
|
12
12
|
const { output = {
|
|
13
13
|
path: "mocks",
|
|
14
14
|
barrelType: "named"
|
|
15
|
-
}, seed, group, exclude = [], include, override = [], transformers = {}, mapper = {}, unknownType = "any", emptySchemaType = unknownType, dateType = "string", dateParser = "faker", generators = [fakerGenerator].filter(Boolean), regexGenerator = "faker", paramsCasing, contentType } = options;
|
|
15
|
+
}, seed, group, exclude = [], include, override = [], transformers = {}, mapper = {}, unknownType = "any", emptySchemaType = unknownType, dateType = "string", integerType = "number", dateParser = "faker", generators = [fakerGenerator].filter(Boolean), regexGenerator = "faker", paramsCasing, contentType } = options;
|
|
16
16
|
return {
|
|
17
17
|
name: pluginFakerName,
|
|
18
18
|
options: {
|
|
@@ -20,6 +20,7 @@ const pluginFaker = definePlugin((options) => {
|
|
|
20
20
|
transformers,
|
|
21
21
|
seed,
|
|
22
22
|
dateType,
|
|
23
|
+
integerType,
|
|
23
24
|
unknownType,
|
|
24
25
|
emptySchemaType,
|
|
25
26
|
dateParser,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { OperationGenerator, pluginOasName, SchemaGenerator } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { fakerGenerator } from './generators/fakerGenerator.tsx'\nimport type { PluginFaker } from './types.ts'\n\nexport const pluginFakerName = 'plugin-faker' satisfies PluginFaker['name']\n\nexport const pluginFaker = definePlugin<PluginFaker>((options) => {\n const {\n output = { path: 'mocks', barrelType: 'named' },\n seed,\n group,\n exclude = [],\n include,\n override = [],\n transformers = {},\n mapper = {},\n unknownType = 'any',\n emptySchemaType = unknownType,\n dateType = 'string',\n dateParser = 'faker',\n generators = [fakerGenerator].filter(Boolean),\n regexGenerator = 'faker',\n paramsCasing,\n contentType,\n } = options\n\n // @deprecated Will be removed in v5 when collisionDetection defaults to true\n const usedEnumNames = {}\n\n return {\n name: pluginFakerName,\n options: {\n output,\n transformers,\n seed,\n dateType,\n unknownType,\n emptySchemaType,\n dateParser,\n mapper,\n override,\n regexGenerator,\n paramsCasing,\n group,\n usedEnumNames,\n },\n pre: [pluginOasName, pluginTsName],\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n const resolvedName = camelCase(name, {\n prefix: type ? 'create' : undefined,\n isFile: type === 'file',\n })\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async install() {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n const oas = await this.getOas()\n\n const schemaGenerator = new SchemaGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n events: this.events,\n plugin: this.plugin,\n contentType,\n include: undefined,\n override,\n mode,\n output: output.path,\n })\n\n const schemaFiles = await schemaGenerator.build(...generators)\n await this.upsertFile(...schemaFiles)\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n events: this.events,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const operationFiles = await operationGenerator.build(...generators)\n await this.upsertFile(...operationFiles)\n\n const barrelFiles = await getBarrelFiles(this.fabric.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;AAQA,MAAa,kBAAkB;AAE/B,MAAa,cAAc,cAA2B,YAAY;CAChE,MAAM,EACJ,SAAS;EAAE,MAAM;EAAS,YAAY;EAAS,EAC/C,MACA,OACA,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,eAAe,EAAE,EACjB,SAAS,EAAE,EACX,cAAc,OACd,kBAAkB,aAClB,WAAW,UACX,aAAa,SACb,aAAa,CAAC,eAAe,CAAC,OAAO,QAAQ,EAC7C,iBAAiB,SACjB,cACA,gBACE;AAKJ,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { OperationGenerator, pluginOasName, SchemaGenerator } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { fakerGenerator } from './generators/fakerGenerator.tsx'\nimport type { PluginFaker } from './types.ts'\n\nexport const pluginFakerName = 'plugin-faker' satisfies PluginFaker['name']\n\nexport const pluginFaker = definePlugin<PluginFaker>((options) => {\n const {\n output = { path: 'mocks', barrelType: 'named' },\n seed,\n group,\n exclude = [],\n include,\n override = [],\n transformers = {},\n mapper = {},\n unknownType = 'any',\n emptySchemaType = unknownType,\n dateType = 'string',\n integerType = 'number',\n dateParser = 'faker',\n generators = [fakerGenerator].filter(Boolean),\n regexGenerator = 'faker',\n paramsCasing,\n contentType,\n } = options\n\n // @deprecated Will be removed in v5 when collisionDetection defaults to true\n const usedEnumNames = {}\n\n return {\n name: pluginFakerName,\n options: {\n output,\n transformers,\n seed,\n dateType,\n integerType,\n unknownType,\n emptySchemaType,\n dateParser,\n mapper,\n override,\n regexGenerator,\n paramsCasing,\n group,\n usedEnumNames,\n },\n pre: [pluginOasName, pluginTsName],\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n const resolvedName = camelCase(name, {\n prefix: type ? 'create' : undefined,\n isFile: type === 'file',\n })\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async install() {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n const oas = await this.getOas()\n\n const schemaGenerator = new SchemaGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n events: this.events,\n plugin: this.plugin,\n contentType,\n include: undefined,\n override,\n mode,\n output: output.path,\n })\n\n const schemaFiles = await schemaGenerator.build(...generators)\n await this.upsertFile(...schemaFiles)\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n events: this.events,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const operationFiles = await operationGenerator.build(...generators)\n await this.upsertFile(...operationFiles)\n\n const barrelFiles = await getBarrelFiles(this.fabric.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;AAQA,MAAa,kBAAkB;AAE/B,MAAa,cAAc,cAA2B,YAAY;CAChE,MAAM,EACJ,SAAS;EAAE,MAAM;EAAS,YAAY;EAAS,EAC/C,MACA,OACA,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,eAAe,EAAE,EACjB,SAAS,EAAE,EACX,cAAc,OACd,kBAAkB,aAClB,WAAW,UACX,cAAc,UACd,aAAa,SACb,aAAa,CAAC,eAAe,CAAC,OAAO,QAAQ,EAC7C,iBAAiB,SACjB,cACA,gBACE;AAKJ,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,eAlBkB,EAAE;GAmBrB;EACD,KAAK,CAAC,eAAe,aAAa;EAClC,YAAY,UAAU,UAAU,SAAS;GACvC,MAAM,OAAO,KAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;AAGpE,QAFa,YAAY,QAAQ,KAAK,QAAQ,MAAM,OAAO,KAAK,CAAC,MAEpD;;;;;AAKX,UAAO,KAAK,QAAQ,MAAM,OAAO,KAAK;AAGxC,OAAI,UAAU,SAAS,OAAO,QAAQ,SAAS,OAAO,MAAM;IAC1D,MAAM,YAA2B,OAAO,OACpC,MAAM,QACL,QAAQ;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B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACF,CAAC;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;EACD"}
|
|
@@ -39,6 +39,14 @@ type Options = {
|
|
|
39
39
|
* @default 'string'
|
|
40
40
|
*/
|
|
41
41
|
dateType?: 'string' | 'date';
|
|
42
|
+
/**
|
|
43
|
+
* Choose to use `number` or `bigint` for integer fields with `int64` format.
|
|
44
|
+
* - 'number' uses the JavaScript `number` type (matches JSON.parse() runtime behavior).
|
|
45
|
+
* - 'bigint' uses the JavaScript `bigint` type (accurate for values exceeding Number.MAX_SAFE_INTEGER).
|
|
46
|
+
* @note in v5 of Kubb 'bigint' will become the default to better align with OpenAPI's int64 specification.
|
|
47
|
+
* @default 'number'
|
|
48
|
+
*/
|
|
49
|
+
integerType?: 'number' | 'bigint';
|
|
42
50
|
/**
|
|
43
51
|
* Which parser should be used when dateType is set to string.
|
|
44
52
|
* - 'faker' uses faker's built-in date formatting methods.
|
|
@@ -108,6 +116,7 @@ type ResolvedOptions = {
|
|
|
108
116
|
group: Options['group'];
|
|
109
117
|
override: NonNullable<Options['override']>;
|
|
110
118
|
dateType: NonNullable<Options['dateType']>;
|
|
119
|
+
integerType: NonNullable<Options['integerType']>;
|
|
111
120
|
dateParser: NonNullable<Options['dateParser']>;
|
|
112
121
|
unknownType: NonNullable<Options['unknownType']>;
|
|
113
122
|
emptySchemaType: NonNullable<Options['emptySchemaType']>;
|
|
@@ -120,4 +129,4 @@ type ResolvedOptions = {
|
|
|
120
129
|
type PluginFaker = PluginFactoryOptions<'plugin-faker', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
121
130
|
//#endregion
|
|
122
131
|
export { PluginFaker as n, Options as t };
|
|
123
|
-
//# sourceMappingURL=types-
|
|
132
|
+
//# sourceMappingURL=types-BIWyHbXy.d.ts.map
|
|
@@ -40,6 +40,14 @@ type Options = {
|
|
|
40
40
|
* @default 'string'
|
|
41
41
|
*/
|
|
42
42
|
dateType?: 'string' | 'date';
|
|
43
|
+
/**
|
|
44
|
+
* Choose to use `number` or `bigint` for integer fields with `int64` format.
|
|
45
|
+
* - 'number' uses the JavaScript `number` type (matches JSON.parse() runtime behavior).
|
|
46
|
+
* - 'bigint' uses the JavaScript `bigint` type (accurate for values exceeding Number.MAX_SAFE_INTEGER).
|
|
47
|
+
* @note in v5 of Kubb 'bigint' will become the default to better align with OpenAPI's int64 specification.
|
|
48
|
+
* @default 'number'
|
|
49
|
+
*/
|
|
50
|
+
integerType?: 'number' | 'bigint';
|
|
43
51
|
/**
|
|
44
52
|
* Which parser should be used when dateType is set to string.
|
|
45
53
|
* - 'faker' uses faker's built-in date formatting methods.
|
|
@@ -109,6 +117,7 @@ type ResolvedOptions = {
|
|
|
109
117
|
group: Options['group'];
|
|
110
118
|
override: NonNullable<Options['override']>;
|
|
111
119
|
dateType: NonNullable<Options['dateType']>;
|
|
120
|
+
integerType: NonNullable<Options['integerType']>;
|
|
112
121
|
dateParser: NonNullable<Options['dateParser']>;
|
|
113
122
|
unknownType: NonNullable<Options['unknownType']>;
|
|
114
123
|
emptySchemaType: NonNullable<Options['emptySchemaType']>;
|
|
@@ -121,4 +130,4 @@ type ResolvedOptions = {
|
|
|
121
130
|
type PluginFaker = PluginFactoryOptions<'plugin-faker', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
122
131
|
//#endregion
|
|
123
132
|
export { PluginFaker as n, __name as r, Options as t };
|
|
124
|
-
//# sourceMappingURL=types-
|
|
133
|
+
//# sourceMappingURL=types-DpNAdZTi.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-faker",
|
|
3
|
-
"version": "4.29.
|
|
3
|
+
"version": "4.29.1",
|
|
4
4
|
"description": "Faker.js data generator plugin for Kubb, creating realistic mock data from OpenAPI specifications for development and testing.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"faker",
|
|
@@ -71,10 +71,10 @@
|
|
|
71
71
|
],
|
|
72
72
|
"dependencies": {
|
|
73
73
|
"@kubb/react-fabric": "0.13.1",
|
|
74
|
-
"@kubb/core": "4.29.
|
|
75
|
-
"@kubb/oas": "4.29.
|
|
76
|
-
"@kubb/plugin-oas": "4.29.
|
|
77
|
-
"@kubb/plugin-ts": "4.29.
|
|
74
|
+
"@kubb/core": "4.29.1",
|
|
75
|
+
"@kubb/oas": "4.29.1",
|
|
76
|
+
"@kubb/plugin-oas": "4.29.1",
|
|
77
|
+
"@kubb/plugin-ts": "4.29.1"
|
|
78
78
|
},
|
|
79
79
|
"engines": {
|
|
80
80
|
"node": ">=20"
|
|
@@ -7,7 +7,7 @@ import { faker } from '@faker-js/faker'
|
|
|
7
7
|
export function pet(data?: Partial<Pet>): Pet {
|
|
8
8
|
return {
|
|
9
9
|
...{
|
|
10
|
-
id: faker.number.
|
|
10
|
+
id: faker.number.int(),
|
|
11
11
|
name: faker.string.alpha(),
|
|
12
12
|
tag: faker.string.alpha(),
|
|
13
13
|
code: faker.helpers.fromRegExp('\b[1-9]\b'),
|
|
@@ -7,7 +7,7 @@ import { faker } from '@faker-js/faker'
|
|
|
7
7
|
export function pet(data?: Partial<Pet>): Pet {
|
|
8
8
|
return {
|
|
9
9
|
...{
|
|
10
|
-
id: faker.number.
|
|
10
|
+
id: faker.number.int(),
|
|
11
11
|
name: faker.string.alpha(),
|
|
12
12
|
tag: faker.string.alpha(),
|
|
13
13
|
code: faker.helpers.fromRegExp('\b[1-9]\b'),
|
|
@@ -8,7 +8,7 @@ import { faker } from '@faker-js/faker'
|
|
|
8
8
|
export function pet(data?: Partial<Pet>): Pet {
|
|
9
9
|
return {
|
|
10
10
|
...{
|
|
11
|
-
id: faker.number.
|
|
11
|
+
id: faker.number.int(),
|
|
12
12
|
name: faker.string.alpha(),
|
|
13
13
|
tag: faker.string.alpha(),
|
|
14
14
|
code: faker.helpers.fromRegExp('\b[1-9]\b'),
|
|
@@ -8,7 +8,7 @@ import { faker } from '@faker-js/faker'
|
|
|
8
8
|
export function pet(data?: Partial<Pet>): Pet {
|
|
9
9
|
return {
|
|
10
10
|
...{
|
|
11
|
-
id: faker.number.
|
|
11
|
+
id: faker.number.int(),
|
|
12
12
|
name: faker.string.alpha(),
|
|
13
13
|
tag: faker.string.alpha(),
|
|
14
14
|
code: new RandExp('\\b[1-9]\\b').gen(),
|
package/src/plugin.ts
CHANGED
|
@@ -21,6 +21,7 @@ export const pluginFaker = definePlugin<PluginFaker>((options) => {
|
|
|
21
21
|
unknownType = 'any',
|
|
22
22
|
emptySchemaType = unknownType,
|
|
23
23
|
dateType = 'string',
|
|
24
|
+
integerType = 'number',
|
|
24
25
|
dateParser = 'faker',
|
|
25
26
|
generators = [fakerGenerator].filter(Boolean),
|
|
26
27
|
regexGenerator = 'faker',
|
|
@@ -38,6 +39,7 @@ export const pluginFaker = definePlugin<PluginFaker>((options) => {
|
|
|
38
39
|
transformers,
|
|
39
40
|
seed,
|
|
40
41
|
dateType,
|
|
42
|
+
integerType,
|
|
41
43
|
unknownType,
|
|
42
44
|
emptySchemaType,
|
|
43
45
|
dateParser,
|
package/src/types.ts
CHANGED
|
@@ -38,6 +38,14 @@ export type Options = {
|
|
|
38
38
|
* @default 'string'
|
|
39
39
|
*/
|
|
40
40
|
dateType?: 'string' | 'date'
|
|
41
|
+
/**
|
|
42
|
+
* Choose to use `number` or `bigint` for integer fields with `int64` format.
|
|
43
|
+
* - 'number' uses the JavaScript `number` type (matches JSON.parse() runtime behavior).
|
|
44
|
+
* - 'bigint' uses the JavaScript `bigint` type (accurate for values exceeding Number.MAX_SAFE_INTEGER).
|
|
45
|
+
* @note in v5 of Kubb 'bigint' will become the default to better align with OpenAPI's int64 specification.
|
|
46
|
+
* @default 'number'
|
|
47
|
+
*/
|
|
48
|
+
integerType?: 'number' | 'bigint'
|
|
41
49
|
/**
|
|
42
50
|
* Which parser should be used when dateType is set to string.
|
|
43
51
|
* - 'faker' uses faker's built-in date formatting methods.
|
|
@@ -105,6 +113,7 @@ type ResolvedOptions = {
|
|
|
105
113
|
group: Options['group']
|
|
106
114
|
override: NonNullable<Options['override']>
|
|
107
115
|
dateType: NonNullable<Options['dateType']>
|
|
116
|
+
integerType: NonNullable<Options['integerType']>
|
|
108
117
|
dateParser: NonNullable<Options['dateParser']>
|
|
109
118
|
unknownType: NonNullable<Options['unknownType']>
|
|
110
119
|
emptySchemaType: NonNullable<Options['emptySchemaType']>
|