@kubb/plugin-faker 4.2.0 → 4.2.2

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,4 +1,4 @@
1
- import { i as Schema, n as PluginFaker } from "./types-lIcQ-X71.cjs";
1
+ import { i as Schema, n as PluginFaker } from "./types-DNb0qEes.cjs";
2
2
 
3
3
  //#region src/components/Faker.d.ts
4
4
  type Props = {
@@ -1,4 +1,4 @@
1
- import { i as Schema, n as PluginFaker } from "./types-cxd0vUAA.js";
1
+ import { i as Schema, n as PluginFaker } from "./types-CE8sVPcD.js";
2
2
 
3
3
  //#region src/components/Faker.d.ts
4
4
  type Props = {
@@ -1,4 +1,4 @@
1
- import { n as PluginFaker, r as Generator } from "./types-lIcQ-X71.cjs";
1
+ import { n as PluginFaker, r as Generator } from "./types-DNb0qEes.cjs";
2
2
 
3
3
  //#region src/generators/fakerGenerator.d.ts
4
4
  declare const fakerGenerator: Generator<PluginFaker>;
@@ -1,4 +1,4 @@
1
- import { n as PluginFaker, r as Generator } from "./types-cxd0vUAA.js";
1
+ import { n as PluginFaker, r as Generator } from "./types-CE8sVPcD.js";
2
2
 
3
3
  //#region src/generators/fakerGenerator.d.ts
4
4
  declare const fakerGenerator: Generator<PluginFaker>;
package/dist/index.cjs CHANGED
@@ -36,7 +36,7 @@ const pluginFaker = (0, __kubb_core.createPlugin)((options) => {
36
36
  pre: [__kubb_plugin_oas.pluginOasName, __kubb_plugin_ts.pluginTsName],
37
37
  resolvePath(baseName, pathMode, options$1) {
38
38
  const root = node_path.default.resolve(this.config.root, this.config.output.path);
39
- if ((pathMode ?? __kubb_core.FileManager.getMode(node_path.default.resolve(root, output.path))) === "single")
39
+ if ((pathMode ?? (0, __kubb_core.getMode)(node_path.default.resolve(root, output.path))) === "single")
40
40
  /**
41
41
  * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
42
42
  * Other plugins then need to call addOrAppend instead of just add from the fileManager class
@@ -63,7 +63,7 @@ const pluginFaker = (0, __kubb_core.createPlugin)((options) => {
63
63
  const [swaggerPlugin] = __kubb_core.PluginManager.getDependedPlugins(this.plugins, [__kubb_plugin_oas.pluginOasName]);
64
64
  const oas = await swaggerPlugin.context.getOas();
65
65
  const root = node_path.default.resolve(this.config.root, this.config.output.path);
66
- const mode = __kubb_core.FileManager.getMode(node_path.default.resolve(root, output.path));
66
+ const mode = (0, __kubb_core.getMode)(node_path.default.resolve(root, output.path));
67
67
  const schemaFiles = await new __kubb_plugin_oas.SchemaGenerator(this.plugin.options, {
68
68
  oas,
69
69
  pluginManager: this.pluginManager,
@@ -86,7 +86,7 @@ const pluginFaker = (0, __kubb_core.createPlugin)((options) => {
86
86
  mode
87
87
  }).build(...generators);
88
88
  await this.addFile(...operationFiles);
89
- const barrelFiles = await this.fileManager.getBarrelFiles({
89
+ const barrelFiles = await (0, __kubb_core.getBarrelFiles)(this.fileManager.files, {
90
90
  type: output.barrelType ?? "named",
91
91
  root,
92
92
  output,
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["fakerGenerator","pluginOasName","pluginTsName","path","FileManager","options","groupName: Group['name']","PluginManager","SchemaGenerator","OperationGenerator"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\n\nimport { FileManager, type Group, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { OperationGenerator, SchemaGenerator, pluginOasName } from '@kubb/plugin-oas'\n\nimport { pluginTsName } from '@kubb/plugin-ts'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas } from '@kubb/plugin-oas'\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 = createPlugin<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 contentType,\n } = options\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 group,\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 ?? FileManager.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 buildStart() {\n const [swaggerPlugin]: [Plugin<PluginOas>] = PluginManager.getDependedPlugins<PluginOas>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n\n const schemaGenerator = new SchemaGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\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.addFile(...schemaFiles)\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\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.addFile(...operationFiles)\n\n const barrelFiles = await this.fileManager.getBarrelFiles({\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;;AAaA,MAAa,kBAAkB;AAE/B,MAAa,6CAAyC,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,gBACE;AAEJ,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACD;EACD,KAAK,CAACC,iCAAeC,8BAAa;EAClC,YAAY,UAAU,UAAU,WAAS;GACvC,MAAM,OAAOC,kBAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;AAGpE,QAFa,YAAYC,wBAAY,QAAQD,kBAAK,QAAQ,MAAM,OAAO,KAAK,CAAC,MAEhE;;;;;AAKX,UAAOA,kBAAK,QAAQ,MAAM,OAAO,KAAK;AAGxC,OAAI,UAAUE,WAAS,OAAO,QAAQA,WAAS,OAAO,MAAM;IAC1D,MAAMC,YAA2B,OAAO,OACpC,MAAM,QACL,QAAQ;AACP,SAAI,OAAO,SAAS,OAClB,QAAO,GAAG,IAAI,MAAM,MAAM,IAAI,CAAC;AAEjC,YAAO,2CAAa,IAAI,MAAM,CAAC;;AAGrC,WAAOH,kBAAK,QACV,MACA,OAA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1
+ {"version":3,"file":"index.cjs","names":["fakerGenerator","pluginOasName","pluginTsName","path","options","groupName: Group['name']","PluginManager","SchemaGenerator","OperationGenerator"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { createPlugin, type Group, getBarrelFiles, getMode, type Plugin, PluginManager } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport type { PluginOas } from '@kubb/plugin-oas'\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 = createPlugin<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 contentType,\n } = options\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 group,\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 buildStart() {\n const [swaggerPlugin]: [Plugin<PluginOas>] = PluginManager.getDependedPlugins<PluginOas>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n\n const schemaGenerator = new SchemaGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\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.addFile(...schemaFiles)\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\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.addFile(...operationFiles)\n\n const barrelFiles = await getBarrelFiles(this.fileManager.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;;AASA,MAAa,kBAAkB;AAE/B,MAAa,6CAAyC,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,gBACE;AAEJ,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA;G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,KAAK;IACpB,QAAQ,KAAK;IACb;IACA,SAAS;IACT;IACA;IACA,QAAQ,OAAO;IAChB,CAAC,CAEwC,MAAM,GAAG,WAAW;AAC9D,SAAM,KAAK,QAAQ,GAAG,YAAY;GAalC,MAAM,iBAAiB,MAXI,IAAIC,qCAAmB,KAAK,OAAO,SAAS;IACrE;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CAAC,CAE8C,MAAM,GAAG,WAAW;AACpE,SAAM,KAAK,QAAQ,GAAG,eAAe;GAErC,MAAM,cAAc,sCAAqB,KAAK,YAAY,OAAO;IAC/D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACD,QAAQ,KAAK;IACd,CAAC;AAEF,SAAM,KAAK,QAAQ,GAAG,YAAY;;EAErC;EACD"}
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as UserPluginWithLifeCycle, n as PluginFaker, t as Options } from "./types-lIcQ-X71.cjs";
1
+ import { a as UserPluginWithLifeCycle, n as PluginFaker, t as Options } from "./types-DNb0qEes.cjs";
2
2
 
3
3
  //#region src/plugin.d.ts
4
4
  declare const pluginFakerName = "plugin-faker";
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as UserPluginWithLifeCycle, n as PluginFaker, t as Options } from "./types-cxd0vUAA.js";
1
+ import { a as UserPluginWithLifeCycle, n as PluginFaker, t as Options } from "./types-CE8sVPcD.js";
2
2
 
3
3
  //#region src/plugin.d.ts
4
4
  declare const pluginFakerName = "plugin-faker";
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import "./components-DifNFxNO.js";
2
2
  import { t as fakerGenerator } from "./fakerGenerator-B99X1p4-.js";
3
3
  import path from "node:path";
4
- import { FileManager, PluginManager, createPlugin } from "@kubb/core";
4
+ import { PluginManager, createPlugin, getBarrelFiles, getMode } from "@kubb/core";
5
5
  import { camelCase } from "@kubb/core/transformers";
6
6
  import { OperationGenerator, SchemaGenerator, pluginOasName } from "@kubb/plugin-oas";
7
7
  import { pluginTsName } from "@kubb/plugin-ts";
@@ -31,7 +31,7 @@ const pluginFaker = createPlugin((options) => {
31
31
  pre: [pluginOasName, pluginTsName],
32
32
  resolvePath(baseName, pathMode, options$1) {
33
33
  const root = path.resolve(this.config.root, this.config.output.path);
34
- if ((pathMode ?? FileManager.getMode(path.resolve(root, output.path))) === "single")
34
+ if ((pathMode ?? getMode(path.resolve(root, output.path))) === "single")
35
35
  /**
36
36
  * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
37
37
  * Other plugins then need to call addOrAppend instead of just add from the fileManager class
@@ -58,7 +58,7 @@ const pluginFaker = createPlugin((options) => {
58
58
  const [swaggerPlugin] = PluginManager.getDependedPlugins(this.plugins, [pluginOasName]);
59
59
  const oas = await swaggerPlugin.context.getOas();
60
60
  const root = path.resolve(this.config.root, this.config.output.path);
61
- const mode = FileManager.getMode(path.resolve(root, output.path));
61
+ const mode = getMode(path.resolve(root, output.path));
62
62
  const schemaFiles = await new SchemaGenerator(this.plugin.options, {
63
63
  oas,
64
64
  pluginManager: this.pluginManager,
@@ -81,7 +81,7 @@ const pluginFaker = createPlugin((options) => {
81
81
  mode
82
82
  }).build(...generators);
83
83
  await this.addFile(...operationFiles);
84
- const barrelFiles = await this.fileManager.getBarrelFiles({
84
+ const barrelFiles = await getBarrelFiles(this.fileManager.files, {
85
85
  type: output.barrelType ?? "named",
86
86
  root,
87
87
  output,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["options","groupName: Group['name']","transformers"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\n\nimport { FileManager, type Group, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { OperationGenerator, SchemaGenerator, pluginOasName } from '@kubb/plugin-oas'\n\nimport { pluginTsName } from '@kubb/plugin-ts'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas } from '@kubb/plugin-oas'\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 = createPlugin<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 contentType,\n } = options\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 group,\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 ?? FileManager.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 buildStart() {\n const [swaggerPlugin]: [Plugin<PluginOas>] = PluginManager.getDependedPlugins<PluginOas>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n\n const schemaGenerator = new SchemaGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\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.addFile(...schemaFiles)\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\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.addFile(...operationFiles)\n\n const barrelFiles = await this.fileManager.getBarrelFiles({\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;AAaA,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,+BAAe,EAAE,EACjB,SAAS,EAAE,EACX,cAAc,OACd,kBAAkB,aAClB,WAAW,UACX,aAAa,SACb,aAAa,CAAC,eAAe,CAAC,OAAO,QAAQ,EAC7C,iBAAiB,SACjB,gBACE;AAEJ,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACD;EACD,KAAK,CAAC,eAAe,aAAa;EAClC,YAAY,UAAU,UAAU,WAAS;GACvC,MAAM,OAAO,KAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;AAGpE,QAFa,YAAY,YAAY,QAAQ,KAAK,QAAQ,MAAM,OAAO,KAAK,CAAC,MAEhE;;;;;AAKX,UAAO,KAAK,QAA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D,CAAC,CAE8C,MAAM,GAAG,WAAW;AACpE,SAAM,KAAK,QAAQ,GAAG,eAAe;GAErC,MAAM,cAAc,MAAM,KAAK,YAAY,eAAe;IACxD,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACD,QAAQ,KAAK;IACd,CAAC;AAEF,SAAM,KAAK,QAAQ,GAAG,YAAY;;EAErC;EACD"}
1
+ {"version":3,"file":"index.js","names":["options","groupName: Group['name']","transformers"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { createPlugin, type Group, getBarrelFiles, getMode, type Plugin, PluginManager } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport type { PluginOas } from '@kubb/plugin-oas'\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 = createPlugin<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 contentType,\n } = options\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 group,\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 buildStart() {\n const [swaggerPlugin]: [Plugin<PluginOas>] = PluginManager.getDependedPlugins<PluginOas>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n\n const schemaGenerator = new SchemaGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\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.addFile(...schemaFiles)\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\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.addFile(...operationFiles)\n\n const barrelFiles = await getBarrelFiles(this.fileManager.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;AASA,MAAa,kBAAkB;AAE/B,MAAa,cAAc,cAA2B,YAAY;CAChE,MAAM,EACJ,SAAS;EAAE,MAAM;EAAS,YAAY;EAAS,EAC/C,MACA,OACA,UAAU,EAAE,EACZ,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Q;GAChD,MAAM,OAAO,KAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;GACpE,MAAM,OAAO,QAAQ,KAAK,QAAQ,MAAM,OAAO,KAAK,CAAC;GAarD,MAAM,cAAc,MAXI,IAAI,gBAAgB,KAAK,OAAO,SAAS;IAC/D;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA,SAAS;IACT;IACA;IACA,QAAQ,OAAO;IAChB,CAAC,CAEwC,MAAM,GAAG,WAAW;AAC9D,SAAM,KAAK,QAAQ,GAAG,YAAY;GAalC,MAAM,iBAAiB,MAXI,IAAI,mBAAmB,KAAK,OAAO,SAAS;IACrE;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CAAC,CAE8C,MAAM,GAAG,WAAW;AACpE,SAAM,KAAK,QAAQ,GAAG,eAAe;GAErC,MAAM,cAAc,MAAM,eAAe,KAAK,YAAY,OAAO;IAC/D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACD,QAAQ,KAAK;IACd,CAAC;AAEF,SAAM,KAAK,QAAQ,GAAG,YAAY;;EAErC;EACD"}
@@ -1,4 +1,5 @@
1
1
  import { ConsolaInstance, LogLevel } from "consola";
2
+ import { FileManager } from "@kubb/fabric-core";
2
3
  import * as OasTypes from "oas/types";
3
4
  import { HttpMethods as HttpMethod, OASDocument, SchemaObject, User } from "oas/types";
4
5
  import { Operation, Operation as Operation$1 } from "oas/operation";
@@ -185,8 +186,6 @@ type Logger = {
185
186
  //#endregion
186
187
  //#region ../core/src/utils/types.d.ts
187
188
  type PossiblePromise<T$1> = Promise<T$1> | T$1;
188
- type ArrayWithLength<T$1 extends number, U extends any[] = []> = U['length'] extends T$1 ? U : ArrayWithLength<T$1, [true, ...U]>;
189
- type GreaterThan<T$1 extends number, U extends number> = ArrayWithLength<U> extends [...ArrayWithLength<T$1>, ...infer _] ? false : true;
190
189
  //#endregion
191
190
  //#region ../core/src/types.d.ts
192
191
  type InputPath = {
@@ -429,6 +428,9 @@ type ResolveNameParams = {
429
428
  };
430
429
  type PluginContext<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
431
430
  config: Config;
431
+ /**
432
+ * @deprecated
433
+ */
432
434
  fileManager: FileManager;
433
435
  pluginManager: PluginManager;
434
436
  addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
@@ -480,60 +482,6 @@ type Group = {
480
482
  name?: (context: GroupContext) => string;
481
483
  };
482
484
  //#endregion
483
- //#region ../core/src/FileManager.d.ts
484
- type FileMetaBase = {
485
- pluginKey?: Plugin['key'];
486
- };
487
- type AddResult<T$1 extends Array<File>> = Promise<Awaited<GreaterThan<T$1['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
488
- type AddIndexesProps = {
489
- type: BarrelType | false | undefined;
490
- /**
491
- * Root based on root and output.path specified in the config
492
- */
493
- root: string;
494
- /**
495
- * Output for plugin
496
- */
497
- output: {
498
- path: string;
499
- };
500
- group?: {
501
- output: string;
502
- exportAs: string;
503
- };
504
- logger?: Logger;
505
- meta?: FileMetaBase;
506
- };
507
- type WriteFilesProps = {
508
- root: Config['root'];
509
- extension?: Record<Extname, Extname | ''>;
510
- logger?: Logger;
511
- dryRun?: boolean;
512
- };
513
- declare class FileManager {
514
- #private;
515
- constructor();
516
- add<T extends Array<File> = Array<File>>(...files: T): AddResult<T>;
517
- getByPath(path: Path): Promise<ResolvedFile | null>;
518
- deleteByPath(path: Path): Promise<void>;
519
- clear(): Promise<void>;
520
- getFiles(): Promise<Array<ResolvedFile>>;
521
- processFiles({
522
- dryRun,
523
- root,
524
- extension,
525
- logger
526
- }: WriteFilesProps): Promise<Array<ResolvedFile>>;
527
- getBarrelFiles({
528
- type,
529
- meta,
530
- root,
531
- output,
532
- logger
533
- }: AddIndexesProps): Promise<File[]>;
534
- static getMode(path: string | undefined | null): Mode;
535
- }
536
- //#endregion
537
485
  //#region ../core/src/PluginManager.d.ts
538
486
  type RequiredPluginLifecycle = Required<PluginLifecycle>;
539
487
  type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
@@ -572,6 +520,9 @@ type GetFileProps<TOptions$1 = object> = {
572
520
  declare class PluginManager {
573
521
  #private;
574
522
  readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
523
+ /**
524
+ * @deprecated do not use from pluginManager
525
+ */
575
526
  readonly fileManager: FileManager;
576
527
  readonly events: EventEmitter<Events>;
577
528
  readonly config: Config;
@@ -680,6 +631,11 @@ declare class PluginManager {
680
631
  static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "buildEnd"];
681
632
  }
682
633
  //#endregion
634
+ //#region ../core/src/FileManager.d.ts
635
+ type FileMetaBase = {
636
+ pluginKey?: Plugin['key'];
637
+ };
638
+ //#endregion
683
639
  //#region ../oas/src/types.d.ts
684
640
  type contentType = 'application/json' | (string & {});
685
641
  type SchemaObject$1 = OasTypes.SchemaObject & {
@@ -1232,4 +1188,4 @@ type ResolvedOptions = {
1232
1188
  type PluginFaker = PluginFactoryOptions<'plugin-faker', Options$1, ResolvedOptions, never, ResolvePathOptions>;
1233
1189
  //#endregion
1234
1190
  export { UserPluginWithLifeCycle as a, Schema as i, PluginFaker as n, Generator as r, Options$1 as t };
1235
- //# sourceMappingURL=types-cxd0vUAA.d.ts.map
1191
+ //# sourceMappingURL=types-CE8sVPcD.d.ts.map
@@ -1,4 +1,5 @@
1
1
  import { ConsolaInstance, LogLevel } from "consola";
2
+ import { FileManager } from "@kubb/fabric-core";
2
3
  import * as OasTypes from "oas/types";
3
4
  import { HttpMethods as HttpMethod, OASDocument, SchemaObject, User } from "oas/types";
4
5
  import { Operation, Operation as Operation$1 } from "oas/operation";
@@ -185,8 +186,6 @@ type Logger = {
185
186
  //#endregion
186
187
  //#region ../core/src/utils/types.d.ts
187
188
  type PossiblePromise<T$1> = Promise<T$1> | T$1;
188
- type ArrayWithLength<T$1 extends number, U extends any[] = []> = U['length'] extends T$1 ? U : ArrayWithLength<T$1, [true, ...U]>;
189
- type GreaterThan<T$1 extends number, U extends number> = ArrayWithLength<U> extends [...ArrayWithLength<T$1>, ...infer _] ? false : true;
190
189
  //#endregion
191
190
  //#region ../core/src/types.d.ts
192
191
  type InputPath = {
@@ -429,6 +428,9 @@ type ResolveNameParams = {
429
428
  };
430
429
  type PluginContext<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
431
430
  config: Config;
431
+ /**
432
+ * @deprecated
433
+ */
432
434
  fileManager: FileManager;
433
435
  pluginManager: PluginManager;
434
436
  addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
@@ -480,60 +482,6 @@ type Group = {
480
482
  name?: (context: GroupContext) => string;
481
483
  };
482
484
  //#endregion
483
- //#region ../core/src/FileManager.d.ts
484
- type FileMetaBase = {
485
- pluginKey?: Plugin['key'];
486
- };
487
- type AddResult<T$1 extends Array<File>> = Promise<Awaited<GreaterThan<T$1['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
488
- type AddIndexesProps = {
489
- type: BarrelType | false | undefined;
490
- /**
491
- * Root based on root and output.path specified in the config
492
- */
493
- root: string;
494
- /**
495
- * Output for plugin
496
- */
497
- output: {
498
- path: string;
499
- };
500
- group?: {
501
- output: string;
502
- exportAs: string;
503
- };
504
- logger?: Logger;
505
- meta?: FileMetaBase;
506
- };
507
- type WriteFilesProps = {
508
- root: Config['root'];
509
- extension?: Record<Extname, Extname | ''>;
510
- logger?: Logger;
511
- dryRun?: boolean;
512
- };
513
- declare class FileManager {
514
- #private;
515
- constructor();
516
- add<T extends Array<File> = Array<File>>(...files: T): AddResult<T>;
517
- getByPath(path: Path): Promise<ResolvedFile | null>;
518
- deleteByPath(path: Path): Promise<void>;
519
- clear(): Promise<void>;
520
- getFiles(): Promise<Array<ResolvedFile>>;
521
- processFiles({
522
- dryRun,
523
- root,
524
- extension,
525
- logger
526
- }: WriteFilesProps): Promise<Array<ResolvedFile>>;
527
- getBarrelFiles({
528
- type,
529
- meta,
530
- root,
531
- output,
532
- logger
533
- }: AddIndexesProps): Promise<File[]>;
534
- static getMode(path: string | undefined | null): Mode;
535
- }
536
- //#endregion
537
485
  //#region ../core/src/PluginManager.d.ts
538
486
  type RequiredPluginLifecycle = Required<PluginLifecycle>;
539
487
  type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
@@ -572,6 +520,9 @@ type GetFileProps<TOptions$1 = object> = {
572
520
  declare class PluginManager {
573
521
  #private;
574
522
  readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
523
+ /**
524
+ * @deprecated do not use from pluginManager
525
+ */
575
526
  readonly fileManager: FileManager;
576
527
  readonly events: EventEmitter<Events>;
577
528
  readonly config: Config;
@@ -680,6 +631,11 @@ declare class PluginManager {
680
631
  static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "buildEnd"];
681
632
  }
682
633
  //#endregion
634
+ //#region ../core/src/FileManager.d.ts
635
+ type FileMetaBase = {
636
+ pluginKey?: Plugin['key'];
637
+ };
638
+ //#endregion
683
639
  //#region ../oas/src/types.d.ts
684
640
  type contentType = 'application/json' | (string & {});
685
641
  type SchemaObject$1 = OasTypes.SchemaObject & {
@@ -1232,4 +1188,4 @@ type ResolvedOptions = {
1232
1188
  type PluginFaker = PluginFactoryOptions<'plugin-faker', Options$1, ResolvedOptions, never, ResolvePathOptions>;
1233
1189
  //#endregion
1234
1190
  export { UserPluginWithLifeCycle as a, Schema as i, PluginFaker as n, Generator as r, Options$1 as t };
1235
- //# sourceMappingURL=types-lIcQ-X71.d.cts.map
1191
+ //# sourceMappingURL=types-DNb0qEes.d.cts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-faker",
3
- "version": "4.2.0",
3
+ "version": "4.2.2",
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",
@@ -61,16 +61,16 @@
61
61
  "!/**/__tests__/**"
62
62
  ],
63
63
  "dependencies": {
64
- "@kubb/core": "4.2.0",
65
- "@kubb/oas": "4.2.0",
66
- "@kubb/plugin-oas": "4.2.0",
67
- "@kubb/plugin-ts": "4.2.0",
68
- "@kubb/react": "4.2.0"
64
+ "@kubb/core": "4.2.2",
65
+ "@kubb/oas": "4.2.2",
66
+ "@kubb/plugin-oas": "4.2.2",
67
+ "@kubb/plugin-ts": "4.2.2",
68
+ "@kubb/react": "4.2.2"
69
69
  },
70
70
  "devDependencies": {
71
71
  "tsdown": "^0.15.9",
72
72
  "typescript": "^5.9.3",
73
- "@kubb/plugin-oas": "4.2.0"
73
+ "@kubb/plugin-oas": "4.2.2"
74
74
  },
75
75
  "peerDependencies": {
76
76
  "@kubb/react": "^4.0.0"
package/src/plugin.ts CHANGED
@@ -1,13 +1,9 @@
1
1
  import path from 'node:path'
2
-
3
- import { FileManager, type Group, PluginManager, createPlugin } from '@kubb/core'
2
+ import { createPlugin, type Group, getBarrelFiles, getMode, type Plugin, PluginManager } from '@kubb/core'
4
3
  import { camelCase } from '@kubb/core/transformers'
5
- import { OperationGenerator, SchemaGenerator, pluginOasName } from '@kubb/plugin-oas'
6
-
7
- import { pluginTsName } from '@kubb/plugin-ts'
8
-
9
- import type { Plugin } from '@kubb/core'
10
4
  import type { PluginOas } from '@kubb/plugin-oas'
5
+ import { OperationGenerator, pluginOasName, SchemaGenerator } from '@kubb/plugin-oas'
6
+ import { pluginTsName } from '@kubb/plugin-ts'
11
7
  import { fakerGenerator } from './generators/fakerGenerator.tsx'
12
8
  import type { PluginFaker } from './types.ts'
13
9
 
@@ -50,7 +46,7 @@ export const pluginFaker = createPlugin<PluginFaker>((options) => {
50
46
  pre: [pluginOasName, pluginTsName],
51
47
  resolvePath(baseName, pathMode, options) {
52
48
  const root = path.resolve(this.config.root, this.config.output.path)
53
- const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path))
49
+ const mode = pathMode ?? getMode(path.resolve(root, output.path))
54
50
 
55
51
  if (mode === 'single') {
56
52
  /**
@@ -99,7 +95,7 @@ export const pluginFaker = createPlugin<PluginFaker>((options) => {
99
95
 
100
96
  const oas = await swaggerPlugin.context.getOas()
101
97
  const root = path.resolve(this.config.root, this.config.output.path)
102
- const mode = FileManager.getMode(path.resolve(root, output.path))
98
+ const mode = getMode(path.resolve(root, output.path))
103
99
 
104
100
  const schemaGenerator = new SchemaGenerator(this.plugin.options, {
105
101
  oas,
@@ -129,7 +125,7 @@ export const pluginFaker = createPlugin<PluginFaker>((options) => {
129
125
  const operationFiles = await operationGenerator.build(...generators)
130
126
  await this.addFile(...operationFiles)
131
127
 
132
- const barrelFiles = await this.fileManager.getBarrelFiles({
128
+ const barrelFiles = await getBarrelFiles(this.fileManager.files, {
133
129
  type: output.barrelType ?? 'named',
134
130
  root,
135
131
  output,