@kubb/plugin-faker 4.11.3 → 4.12.0
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.cts +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/{fakerGenerator-B7NcLOvg.cjs → fakerGenerator-CSSHNMRH.cjs} +2 -2
- package/dist/{fakerGenerator-B7NcLOvg.cjs.map → fakerGenerator-CSSHNMRH.cjs.map} +1 -1
- package/dist/{fakerGenerator-wJgFsJ4k.js → fakerGenerator-E5O0u3li.js} +2 -2
- package/dist/{fakerGenerator-wJgFsJ4k.js.map → fakerGenerator-E5O0u3li.js.map} +1 -1
- package/dist/generators.cjs +1 -1
- package/dist/generators.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/generators.js +1 -1
- package/dist/index.cjs +4 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -5
- package/dist/index.js.map +1 -1
- package/dist/{types-CZCTeVpk.d.cts → types-B0uUNfYF.d.ts} +216 -103
- package/dist/{types-CfzJF-pQ.d.ts → types-Blj03WRB.d.cts} +216 -103
- package/package.json +7 -7
- package/src/generators/fakerGenerator.tsx +1 -1
- package/src/plugin.ts +2 -3
package/dist/components.d.cts
CHANGED
package/dist/components.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ const fakerGenerator = (0, __kubb_plugin_oas_generators.createReactGenerator)({
|
|
|
24
24
|
fabric: generator.context.fabric,
|
|
25
25
|
oas,
|
|
26
26
|
plugin,
|
|
27
|
-
|
|
27
|
+
events: generator.context.events,
|
|
28
28
|
pluginManager,
|
|
29
29
|
mode,
|
|
30
30
|
override: options.override
|
|
@@ -200,4 +200,4 @@ Object.defineProperty(exports, 'fakerGenerator', {
|
|
|
200
200
|
return fakerGenerator;
|
|
201
201
|
}
|
|
202
202
|
});
|
|
203
|
-
//# sourceMappingURL=fakerGenerator-
|
|
203
|
+
//# sourceMappingURL=fakerGenerator-CSSHNMRH.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fakerGenerator-
|
|
1
|
+
{"version":3,"file":"fakerGenerator-CSSHNMRH.cjs","names":["SchemaGenerator","options","pluginTsName","schemaKeywords","Fragment","File","Faker"],"sources":["../src/generators/fakerGenerator.tsx"],"sourcesContent":["import { useMode, usePluginManager } from '@kubb/core/hooks'\nimport { type OperationSchema as OperationSchemaType, SchemaGenerator, schemaKeywords } from '@kubb/plugin-oas'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas, useOperationManager, useSchemaManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File, Fragment } from '@kubb/react-fabric'\nimport { Faker } from '../components'\nimport type { PluginFaker } from '../types'\n\nexport const fakerGenerator = createReactGenerator<PluginFaker>({\n name: 'faker',\n Operation({ operation, generator, plugin }) {\n const {\n options,\n options: { dateParser, regexGenerator, seed, mapper },\n } = plugin\n const mode = useMode()\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n const { getSchemas, getFile, getGroup } = useOperationManager(generator)\n const schemaManager = useSchemaManager()\n\n const file = getFile(operation)\n const schemas = getSchemas(operation)\n const schemaGenerator = new SchemaGenerator(options, {\n fabric: generator.context.fabric,\n oas,\n plugin,\n events: generator.context.events,\n 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) => {\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 <Fragment>\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 </Fragment>\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, plugin }) {\n const { getName, getFile, getImports } = useSchemaManager()\n const {\n options: { output, dateParser, regexGenerator, seed, mapper },\n } = plugin\n const pluginManager = usePluginManager()\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 keyword === schemaKeywords.string ||\n keyword === schemaKeywords.integer ||\n keyword === schemaKeywords.number,\n )\n\n return (\n <File\n baseName={faker.file.baseName}\n path={faker.file.path}\n meta={faker.file.meta}\n banner={getBanner({ oas, output, config: 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"],"mappings":";;;;;;;;;;;AAUA,MAAa,wEAAmD;CAC9D,MAAM;CACN,UAAU,EAAE,WAAW,WAAW,UAAU;EAC1C,MAAM,EACJ,SACA,SAAS,EAAE,YAAY,gBAAgB,MAAM,aAC3C;EACJ,MAAM,uCAAgB;EACtB,MAAM,yDAAkC;EAExC,MAAM,2CAAc;EACpB,MAAM,EAAE,YAAY,SAAS,8DAAiC,UAAU;EACxE,MAAM,+DAAkC;EAExC,MAAM,OAAO,QAAQ,UAAU;EAC/B,MAAM,UAAU,WAAW,UAAU;EACrC,MAAM,kBAAkB,IAAIA,kCAAgB,SAAS;GACnD,QAAQ,UAAU,QAAQ;GAC1B;GACA;GACA,QAAQ,UAAU,QAAQ;GAC1B;GACA;GACA,UAAU,QAAQ;GACnB,CAAC;EAEF,MAAM,mBAAmB;GAAC,QAAQ;GAAY,QAAQ;GAAa,QAAQ;GAAc,QAAQ;GAAa,QAAQ;GAAS,QAAQ;GAAS,CAC7I,MAAM,CACN,OAA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CAAC,QAAQ;KAAE,MAAK;MAAoB;IACtD,mBAAmB,aAAa,yDAACA,yBAAK;KAAO,MAAM;KAAW,MAAM;MAAa;IACjF,eAAe,WAAW,yDAACA,yBAAK;KAAO,MAAM;KAAY,MAAM;MAAc;IAC9E,yDAACA,yBAAK;KAAO;KAAW,MAAM,MAAM,KAAK;KAAM,MAAM,KAAK,KAAK;KAAM,MAAM,CAAC,KAAK,KAAK;MAAI;IACzF,QAAQ,KAAK,QACZ,yDAACA,yBAAK;KAA4D,MAAM,MAAM,KAAK;KAAM,MAAM,IAAI;KAAM,MAAM,IAAI;OAAjG;KAAC,IAAI;KAAM,IAAI;KAAM,IAAI;KAAW,CAAC,KAAK,IAAI,CAA2D,CAC3H;IAEF,yDAACC;KACC,MAAM,MAAM;KACZ,UAAU,KAAK;KACf,aAAa,OAAO,MAAM;KAC1B,MAAM,OAAO;KACG;KACJ;KACJ;KACF;KACO;MACb;;IACG;;CAGZ,CAAC"}
|
|
@@ -24,7 +24,7 @@ const fakerGenerator = createReactGenerator({
|
|
|
24
24
|
fabric: generator.context.fabric,
|
|
25
25
|
oas,
|
|
26
26
|
plugin,
|
|
27
|
-
|
|
27
|
+
events: generator.context.events,
|
|
28
28
|
pluginManager,
|
|
29
29
|
mode,
|
|
30
30
|
override: options.override
|
|
@@ -195,4 +195,4 @@ const fakerGenerator = createReactGenerator({
|
|
|
195
195
|
|
|
196
196
|
//#endregion
|
|
197
197
|
export { fakerGenerator as t };
|
|
198
|
-
//# sourceMappingURL=fakerGenerator-
|
|
198
|
+
//# sourceMappingURL=fakerGenerator-E5O0u3li.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fakerGenerator-
|
|
1
|
+
{"version":3,"file":"fakerGenerator-E5O0u3li.js","names":["options"],"sources":["../src/generators/fakerGenerator.tsx"],"sourcesContent":["import { useMode, usePluginManager } from '@kubb/core/hooks'\nimport { type OperationSchema as OperationSchemaType, SchemaGenerator, schemaKeywords } from '@kubb/plugin-oas'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas, useOperationManager, useSchemaManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File, Fragment } from '@kubb/react-fabric'\nimport { Faker } from '../components'\nimport type { PluginFaker } from '../types'\n\nexport const fakerGenerator = createReactGenerator<PluginFaker>({\n name: 'faker',\n Operation({ operation, generator, plugin }) {\n const {\n options,\n options: { dateParser, regexGenerator, seed, mapper },\n } = plugin\n const mode = useMode()\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n const { getSchemas, getFile, getGroup } = useOperationManager(generator)\n const schemaManager = useSchemaManager()\n\n const file = getFile(operation)\n const schemas = getSchemas(operation)\n const schemaGenerator = new SchemaGenerator(options, {\n fabric: generator.context.fabric,\n oas,\n plugin,\n events: generator.context.events,\n 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) => {\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 <Fragment>\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 </Fragment>\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, plugin }) {\n const { getName, getFile, getImports } = useSchemaManager()\n const {\n options: { output, dateParser, regexGenerator, seed, mapper },\n } = plugin\n const pluginManager = usePluginManager()\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 keyword === schemaKeywords.string ||\n keyword === schemaKeywords.integer ||\n keyword === schemaKeywords.number,\n )\n\n return (\n <File\n baseName={faker.file.baseName}\n path={faker.file.path}\n meta={faker.file.meta}\n banner={getBanner({ oas, output, config: 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"],"mappings":";;;;;;;;;;;AAUA,MAAa,iBAAiB,qBAAkC;CAC9D,MAAM;CACN,UAAU,EAAE,WAAW,WAAW,UAAU;EAC1C,MAAM,EACJ,SACA,SAAS,EAAE,YAAY,gBAAgB,MAAM,aAC3C;EACJ,MAAM,OAAO,SAAS;EACtB,MAAM,gBAAgB,kBAAkB;EAExC,MAAM,MAAM,QAAQ;EACpB,MAAM,EAAE,YAAY,SAAS,aAAa,oBAAoB,UAAU;EACxE,MAAM,gBAAgB,kBAAkB;EAExC,MAAM,OAAO,QAAQ,UAAU;EAC/B,MAAM,UAAU,WAAW,UAAU;EACrC,MAAM,kBAAkB,IAAI,gBAAgB,SAAS;GACnD,QAAQ,UAAU,QAAQ;GAC1B;GACA;GACA,QAAQ,UAAU,QAAQ;GAC1B;GACA;GACA,UAAU,QAAQ;GACnB,CAAC;EAEF,MAAM,mBAAmB;GAAC,QAAQ;GAAY,QAAQ;GAAa,QAAQ;GAAc,QAAQ;GAAa,QAAQ;GAAS,QAAQ;GAAS,CAC7I,MAAM,CACN,OAAO,QAAQ;EAElB,MAAM,sBAAsB,EAAE,MAAM,QAAQ,cAAc,aAAa,GAAGA,gBAAmC;GAC3G,MAAM,OAAO,gBAAgB,MAAM;IAAE;IAAc;IAAM,CAAC;GAC1D,MAAM,UAAU,cAAc,WAAW,KAAK;GAC9C,MAAM,QAAQA,UAAQ,YAAY,SAASA,UAAQ,UAAU,GAAG;GAEhE,MAAM,QAAQ;IACZ,MAAM,cAAc,QAAQ,MAAM,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,QACZ,oBAAC,KAAK;KAA4D,MAAM,MAAM,KAAK;KAAM,MAAM,IAAI;KAAM,MAAM,IAAI;OAAjG;KAAC,IAAI;KAAM,IAAI;KAAM,IAAI;KAAW,CAAC,KAAK,IAAI,CAA2D,CAC3H;IAEF,oBAAC;KACC,MAAM,MAAM;KACZ,UAAU,KAAK;KACf,aAAa,OAAO,MAAM;KAC1B,MAAM,OAAO;KACG;KACJ;KACJ;KACF;KACO;MACb;;IACG;;CAGZ,CAAC"}
|
package/dist/generators.cjs
CHANGED
package/dist/generators.d.cts
CHANGED
package/dist/generators.d.ts
CHANGED
package/dist/generators.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_components = require('./components-CYQi2D8d.cjs');
|
|
2
|
-
const require_fakerGenerator = require('./fakerGenerator-
|
|
2
|
+
const require_fakerGenerator = require('./fakerGenerator-CSSHNMRH.cjs');
|
|
3
3
|
let node_path = require("node:path");
|
|
4
4
|
node_path = require_components.__toESM(node_path);
|
|
5
5
|
let __kubb_core = require("@kubb/core");
|
|
@@ -64,7 +64,7 @@ const pluginFaker = (0, __kubb_core.definePlugin)((options) => {
|
|
|
64
64
|
fabric: this.fabric,
|
|
65
65
|
oas,
|
|
66
66
|
pluginManager: this.pluginManager,
|
|
67
|
-
|
|
67
|
+
events: this.events,
|
|
68
68
|
plugin: this.plugin,
|
|
69
69
|
contentType,
|
|
70
70
|
include: void 0,
|
|
@@ -77,7 +77,7 @@ const pluginFaker = (0, __kubb_core.definePlugin)((options) => {
|
|
|
77
77
|
fabric: this.fabric,
|
|
78
78
|
oas,
|
|
79
79
|
pluginManager: this.pluginManager,
|
|
80
|
-
|
|
80
|
+
events: this.events,
|
|
81
81
|
plugin: this.plugin,
|
|
82
82
|
contentType,
|
|
83
83
|
exclude,
|
|
@@ -90,8 +90,7 @@ const pluginFaker = (0, __kubb_core.definePlugin)((options) => {
|
|
|
90
90
|
type: output.barrelType ?? "named",
|
|
91
91
|
root,
|
|
92
92
|
output,
|
|
93
|
-
meta: { pluginKey: this.plugin.key }
|
|
94
|
-
logger: this.logger
|
|
93
|
+
meta: { pluginKey: this.plugin.key }
|
|
95
94
|
});
|
|
96
95
|
await this.upsertFile(...barrelFiles);
|
|
97
96
|
}
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["fakerGenerator","pluginOasName","pluginTsName","path","options","groupName: Group['name']","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 contentType,\n } = options\n\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 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
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["fakerGenerator","pluginOasName","pluginTsName","path","options","groupName: Group['name']","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 contentType,\n } = options\n\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 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,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;AAIJ,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,eAhBkB,EAAE;GAiBrB;EACD,KAAK,CAACC,iCAAeC,8BAAa;EAClC,YAAY,UAAU,UAAU,WAAS;GACvC,MAAM,OAAOC,kBAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;AAGpE,QAFa,qCAAoBA,kBAAK,QAAQ,MAAM,OAAO,KAAK,CAAC,MAEpD;;;;;AAKX,UAAOA,kBAAK,QAAQ,MAAM,OAAO,KAAK;AAGxC,OAAI,UAAUC,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,WAAOF,kBAAK,QACV,MACA,OAAO,MACP,UAAU,EACR,OAAO,MAAM,SAAS,SAASC,UAAQ,MAAM,OAAQA,UAAQ,MAAM,KACpE,CAAC,EACF,SACD;;AAGH,UAAOD,kBAAK,QAAQ,MAAM,OAAO,MAAM,SAAS;;EAElD,YAAY,MAAM,MAAM;GACtB,MAAM,uDAAyB,MAAM;IACnC,QAAQ,OAAO,WAAW;IAC1B,QAAQ,SAAS;IAClB,CAAC;AAEF,OAAI,KACF,QAAO,cAAc,OAAO,cAAc,KAAK,IAAI;AAGrD,UAAO;;EAET,MAAM,UAAU;GACd,MAAM,OAAOA,kBAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;GACpE,MAAM,gCAAeA,kBAAK,QAAQ,MAAM,OAAO,KAAK,CAAC;GACrD,MAAM,MAAM,MAAM,KAAK,QAAQ;GAe/B,MAAM,cAAc,MAbI,IAAIG,kCAAgB,KAAK,OAAO,SAAS;IAC/D,QAAQ,KAAK;IACb;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb,QAAQ,KAAK;IACb;IACA,SAAS;IACT;IACA;IACA,QAAQ,OAAO;IAChB,CAAC,CAEwC,MAAM,GAAG,WAAW;AAC9D,SAAM,KAAK,WAAW,GAAG,YAAY;GAerC,MAAM,iBAAiB,MAbI,IAAIC,qCAAmB,KAAK,OAAO,SAAS;IACrE,QAAQ,KAAK;IACb;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CAAC,CAE8C,MAAM,GAAG,WAAW;AACpE,SAAM,KAAK,WAAW,GAAG,eAAe;GAExC,MAAM,cAAc,sCAAqB,KAAK,OAAO,OAAO;IAC1D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACF,CAAC;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;EACD"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as UserPluginWithLifeCycle, n as PluginFaker, t as Options } from "./types-
|
|
1
|
+
import { a as UserPluginWithLifeCycle, n as PluginFaker, t as Options } from "./types-Blj03WRB.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-
|
|
1
|
+
import { a as UserPluginWithLifeCycle, n as PluginFaker, t as Options } from "./types-B0uUNfYF.js";
|
|
2
2
|
|
|
3
3
|
//#region src/plugin.d.ts
|
|
4
4
|
declare const pluginFakerName = "plugin-faker";
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as fakerGenerator } from "./fakerGenerator-
|
|
1
|
+
import { t as fakerGenerator } from "./fakerGenerator-E5O0u3li.js";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { definePlugin, getBarrelFiles, getMode } from "@kubb/core";
|
|
4
4
|
import { camelCase } from "@kubb/core/transformers";
|
|
@@ -62,7 +62,7 @@ const pluginFaker = definePlugin((options) => {
|
|
|
62
62
|
fabric: this.fabric,
|
|
63
63
|
oas,
|
|
64
64
|
pluginManager: this.pluginManager,
|
|
65
|
-
|
|
65
|
+
events: this.events,
|
|
66
66
|
plugin: this.plugin,
|
|
67
67
|
contentType,
|
|
68
68
|
include: void 0,
|
|
@@ -75,7 +75,7 @@ const pluginFaker = definePlugin((options) => {
|
|
|
75
75
|
fabric: this.fabric,
|
|
76
76
|
oas,
|
|
77
77
|
pluginManager: this.pluginManager,
|
|
78
|
-
|
|
78
|
+
events: this.events,
|
|
79
79
|
plugin: this.plugin,
|
|
80
80
|
contentType,
|
|
81
81
|
exclude,
|
|
@@ -88,8 +88,7 @@ const pluginFaker = definePlugin((options) => {
|
|
|
88
88
|
type: output.barrelType ?? "named",
|
|
89
89
|
root,
|
|
90
90
|
output,
|
|
91
|
-
meta: { pluginKey: this.plugin.key }
|
|
92
|
-
logger: this.logger
|
|
91
|
+
meta: { pluginKey: this.plugin.key }
|
|
93
92
|
});
|
|
94
93
|
await this.upsertFile(...barrelFiles);
|
|
95
94
|
}
|
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'\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 contentType,\n } = options\n\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 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
|
|
1
|
+
{"version":3,"file":"index.js","names":["options","groupName: Group['name']","transformers"],"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 contentType,\n } = options\n\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 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;EA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K,OAAO,OAAO,KAAK;GACpE,MAAM,OAAO,QAAQ,KAAK,QAAQ,MAAM,OAAO,KAAK,CAAC;GACrD,MAAM,MAAM,MAAM,KAAK,QAAQ;GAe/B,MAAM,cAAc,MAbI,IAAI,gBAAgB,KAAK,OAAO,SAAS;IAC/D,QAAQ,KAAK;IACb;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb,QAAQ,KAAK;IACb;IACA,SAAS;IACT;IACA;IACA,QAAQ,OAAO;IAChB,CAAC,CAEwC,MAAM,GAAG,WAAW;AAC9D,SAAM,KAAK,WAAW,GAAG,YAAY;GAerC,MAAM,iBAAiB,MAbI,IAAI,mBAAmB,KAAK,OAAO,SAAS;IACrE,QAAQ,KAAK;IACb;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CAAC,CAE8C,MAAM,GAAG,WAAW;AACpE,SAAM,KAAK,WAAW,GAAG,eAAe;GAExC,MAAM,cAAc,MAAM,eAAe,KAAK,OAAO,OAAO;IAC1D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACF,CAAC;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;EACD"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { KubbFile } from "@kubb/fabric-core/types";
|
|
2
1
|
import { Fabric } from "@kubb/react-fabric";
|
|
3
|
-
import {
|
|
2
|
+
import { KubbFile } from "@kubb/fabric-core/types";
|
|
4
3
|
import * as OasTypes from "oas/types";
|
|
5
4
|
import { HttpMethods as HttpMethod, OASDocument, SchemaObject, User } from "oas/types";
|
|
6
5
|
import { Operation, Operation as Operation$1 } from "oas/operation";
|
|
@@ -23,75 +22,229 @@ declare abstract class BaseGenerator<TOptions = unknown, TContext = unknown> {
|
|
|
23
22
|
abstract build(...params: unknown[]): unknown;
|
|
24
23
|
}
|
|
25
24
|
//#endregion
|
|
26
|
-
//#region ../core/src/
|
|
27
|
-
declare class EventEmitter<TEvents extends Record<string, any>> {
|
|
28
|
-
#private;
|
|
29
|
-
constructor();
|
|
30
|
-
emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArg: TEvents[TEventName]): void;
|
|
31
|
-
on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
32
|
-
off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
33
|
-
removeAll(): void;
|
|
34
|
-
}
|
|
35
|
-
//#endregion
|
|
36
|
-
//#region ../core/src/logger.d.ts
|
|
25
|
+
//#region ../core/src/Kubb.d.ts
|
|
37
26
|
type DebugEvent = {
|
|
38
27
|
date: Date;
|
|
39
28
|
logs: string[];
|
|
40
29
|
fileName?: string;
|
|
30
|
+
};
|
|
31
|
+
type ProgressStartMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
32
|
+
hookName: H;
|
|
33
|
+
plugins: Array<Plugin>;
|
|
34
|
+
};
|
|
35
|
+
type ProgressStopMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
36
|
+
hookName: H;
|
|
37
|
+
};
|
|
38
|
+
type ExecutingMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
39
|
+
strategy: Strategy;
|
|
40
|
+
hookName: H;
|
|
41
|
+
plugin: Plugin;
|
|
42
|
+
parameters?: unknown[] | undefined;
|
|
43
|
+
output?: unknown;
|
|
44
|
+
};
|
|
45
|
+
type ExecutedMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
46
|
+
duration: number;
|
|
47
|
+
strategy: Strategy;
|
|
48
|
+
hookName: H;
|
|
49
|
+
plugin: Plugin;
|
|
50
|
+
parameters?: unknown[] | undefined;
|
|
51
|
+
output?: unknown;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Events emitted during the Kubb code generation lifecycle.
|
|
55
|
+
* These events can be listened to for logging, progress tracking, and custom integrations.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* import type { AsyncEventEmitter } from '@kubb/core'
|
|
60
|
+
* import type { KubbEvents } from '@kubb/core'
|
|
61
|
+
*
|
|
62
|
+
* const events: AsyncEventEmitter<KubbEvents> = new AsyncEventEmitter()
|
|
63
|
+
*
|
|
64
|
+
* events.on('lifecycle:start', () => {
|
|
65
|
+
* console.log('Starting Kubb generation')
|
|
66
|
+
* })
|
|
67
|
+
*
|
|
68
|
+
* events.on('plugin:end', (plugin, duration) => {
|
|
69
|
+
* console.log(`Plugin ${plugin.name} completed in ${duration}ms`)
|
|
70
|
+
* })
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
interface KubbEvents {
|
|
41
74
|
/**
|
|
42
|
-
*
|
|
43
|
-
* - 'setup': Initial configuration and environment setup
|
|
44
|
-
* - 'plugin': Plugin installation and execution
|
|
45
|
-
* - 'hook': Plugin hook execution details
|
|
46
|
-
* - 'schema': Schema parsing and generation
|
|
47
|
-
* - 'file': File operations (read/write/generate)
|
|
48
|
-
* - 'error': Error details and stack traces
|
|
49
|
-
* - undefined: Generic logs (always inline)
|
|
75
|
+
* Emitted at the beginning of the Kubb lifecycle, before any code generation starts.
|
|
50
76
|
*/
|
|
51
|
-
|
|
77
|
+
'lifecycle:start': [version: string];
|
|
52
78
|
/**
|
|
53
|
-
*
|
|
79
|
+
* Emitted at the end of the Kubb lifecycle, after all code generation is complete.
|
|
54
80
|
*/
|
|
55
|
-
|
|
81
|
+
'lifecycle:end': [];
|
|
56
82
|
/**
|
|
57
|
-
*
|
|
58
|
-
* - 'start': Start of plugin execution group
|
|
59
|
-
* - 'end': End of plugin execution group
|
|
83
|
+
* Emitted when configuration loading starts.
|
|
60
84
|
*/
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
85
|
+
'config:start': [];
|
|
86
|
+
/**
|
|
87
|
+
* Emitted when configuration loading is complete.
|
|
88
|
+
*/
|
|
89
|
+
'config:end': [configs: Array<Config>];
|
|
90
|
+
/**
|
|
91
|
+
* Emitted when code generation phase starts.
|
|
92
|
+
*/
|
|
93
|
+
'generation:start': [config: Config];
|
|
94
|
+
/**
|
|
95
|
+
* Emitted when code generation phase completes.
|
|
96
|
+
*/
|
|
97
|
+
'generation:end': [Config: Config];
|
|
98
|
+
/**
|
|
99
|
+
* Emitted with a summary of the generation results.
|
|
100
|
+
* Contains summary lines, title, and success status.
|
|
101
|
+
*/
|
|
102
|
+
'generation:summary': [Config: Config, {
|
|
103
|
+
failedPlugins: Set<{
|
|
104
|
+
plugin: Plugin;
|
|
105
|
+
error: Error;
|
|
106
|
+
}>;
|
|
107
|
+
status: 'success' | 'failed';
|
|
108
|
+
hrStart: [number, number];
|
|
109
|
+
filesCreated: number;
|
|
110
|
+
pluginTimings?: Map<string, number>;
|
|
79
111
|
}];
|
|
80
|
-
|
|
81
|
-
|
|
112
|
+
/**
|
|
113
|
+
* Emitted when code formatting starts (e.g., running Biome or Prettier).
|
|
114
|
+
*/
|
|
115
|
+
'format:start': [];
|
|
116
|
+
/**
|
|
117
|
+
* Emitted when code formatting completes.
|
|
118
|
+
*/
|
|
119
|
+
'format:end': [];
|
|
120
|
+
/**
|
|
121
|
+
* Emitted when linting starts.
|
|
122
|
+
*/
|
|
123
|
+
'lint:start': [];
|
|
124
|
+
/**
|
|
125
|
+
* Emitted when linting completes.
|
|
126
|
+
*/
|
|
127
|
+
'lint:end': [];
|
|
128
|
+
/**
|
|
129
|
+
* Emitted when plugin hooks execution starts.
|
|
130
|
+
*/
|
|
131
|
+
'hooks:start': [];
|
|
132
|
+
/**
|
|
133
|
+
* Emitted when plugin hooks execution completes.
|
|
134
|
+
*/
|
|
135
|
+
'hooks:end': [];
|
|
136
|
+
/**
|
|
137
|
+
* Emitted when a single hook execution starts.
|
|
138
|
+
*/
|
|
139
|
+
'hook:start': [command: string];
|
|
140
|
+
/**
|
|
141
|
+
* Emitted to execute a hook command (e.g., format or lint).
|
|
142
|
+
* The callback should be invoked when the command completes.
|
|
143
|
+
*/
|
|
144
|
+
'hook:execute': [{
|
|
145
|
+
command: string | URL;
|
|
146
|
+
args?: readonly string[];
|
|
147
|
+
}, cb: () => void];
|
|
148
|
+
/**
|
|
149
|
+
* Emitted when a single hook execution completes.
|
|
150
|
+
*/
|
|
151
|
+
'hook:end': [command: string];
|
|
152
|
+
/**
|
|
153
|
+
* Emitted when a new version of Kubb is available.
|
|
154
|
+
*/
|
|
155
|
+
'version:new': [currentVersion: string, latestVersion: string];
|
|
156
|
+
/**
|
|
157
|
+
* Informational message event.
|
|
158
|
+
*/
|
|
159
|
+
info: [message: string, info?: string];
|
|
160
|
+
/**
|
|
161
|
+
* Error event. Emitted when an error occurs during code generation.
|
|
162
|
+
*/
|
|
163
|
+
error: [error: Error, meta?: Record<string, unknown>];
|
|
164
|
+
/**
|
|
165
|
+
* Success message event.
|
|
166
|
+
*/
|
|
167
|
+
success: [message: string, info?: string];
|
|
168
|
+
/**
|
|
169
|
+
* Warning message event.
|
|
170
|
+
*/
|
|
171
|
+
warn: [message: string, info?: string];
|
|
172
|
+
/**
|
|
173
|
+
* Debug event for detailed logging.
|
|
174
|
+
* Contains timestamp, log messages, and optional filename.
|
|
175
|
+
*/
|
|
176
|
+
debug: [meta: DebugEvent];
|
|
177
|
+
/**
|
|
178
|
+
* Emitted when file processing starts.
|
|
179
|
+
* Contains the list of files to be processed.
|
|
180
|
+
*/
|
|
181
|
+
'files:processing:start': [files: Array<KubbFile.ResolvedFile>];
|
|
182
|
+
/**
|
|
183
|
+
* Emitted for each file being processed, providing progress updates.
|
|
184
|
+
* Contains processed count, total count, percentage, and file details.
|
|
185
|
+
*/
|
|
186
|
+
'file:processing:update': [{
|
|
187
|
+
/** Number of files processed so far */
|
|
188
|
+
processed: number;
|
|
189
|
+
/** Total number of files to process */
|
|
190
|
+
total: number;
|
|
191
|
+
/** Processing percentage (0-100) */
|
|
192
|
+
percentage: number;
|
|
193
|
+
/** Optional source identifier */
|
|
194
|
+
source?: string;
|
|
195
|
+
/** The file being processed */
|
|
196
|
+
file: KubbFile.ResolvedFile;
|
|
197
|
+
/**
|
|
198
|
+
* Kubb configuration (not present in Fabric).
|
|
199
|
+
* Provides access to the current config during file processing.
|
|
200
|
+
*/
|
|
201
|
+
config: Config;
|
|
82
202
|
}];
|
|
83
|
-
};
|
|
84
|
-
type Logger = {
|
|
85
203
|
/**
|
|
86
|
-
*
|
|
204
|
+
* Emitted when file processing completes.
|
|
205
|
+
* Contains the list of processed files.
|
|
87
206
|
*/
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
207
|
+
'files:processing:end': [files: KubbFile.ResolvedFile[]];
|
|
208
|
+
/**
|
|
209
|
+
* Emitted when a plugin starts executing.
|
|
210
|
+
*/
|
|
211
|
+
'plugin:start': [plugin: Plugin];
|
|
212
|
+
/**
|
|
213
|
+
* Emitted when a plugin completes execution.
|
|
214
|
+
*/
|
|
215
|
+
'plugin:end': [plugin: Plugin, duration: number];
|
|
216
|
+
/**
|
|
217
|
+
* Emitted when plugin hook progress tracking starts.
|
|
218
|
+
* Contains the hook name and list of plugins to execute.
|
|
219
|
+
*/
|
|
220
|
+
'plugins:hook:progress:start': [meta: ProgressStartMeta];
|
|
221
|
+
/**
|
|
222
|
+
* Emitted when plugin hook progress tracking ends.
|
|
223
|
+
* Contains the hook name that completed.
|
|
224
|
+
*/
|
|
225
|
+
'plugins:hook:progress:end': [meta: ProgressStopMeta];
|
|
226
|
+
/**
|
|
227
|
+
* Emitted when a plugin hook starts processing.
|
|
228
|
+
* Contains strategy, hook name, plugin, parameters, and output.
|
|
229
|
+
*/
|
|
230
|
+
'plugins:hook:processing:start': [meta: ExecutingMeta];
|
|
231
|
+
/**
|
|
232
|
+
* Emitted when a plugin hook completes processing.
|
|
233
|
+
* Contains duration, strategy, hook name, plugin, parameters, and output.
|
|
234
|
+
*/
|
|
235
|
+
'plugins:hook:processing:end': [meta: ExecutedMeta];
|
|
236
|
+
}
|
|
237
|
+
//#endregion
|
|
238
|
+
//#region ../core/src/utils/AsyncEventEmitter.d.ts
|
|
239
|
+
declare class AsyncEventEmitter<TEvents extends Record<string, any>> {
|
|
240
|
+
#private;
|
|
241
|
+
constructor(maxListener?: number);
|
|
242
|
+
emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArgs: TEvents[TEventName]): Promise<void>;
|
|
243
|
+
on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
244
|
+
onOnce<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArgs: TEvents[TEventName]) => void): void;
|
|
245
|
+
off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
246
|
+
removeAll(): void;
|
|
247
|
+
}
|
|
95
248
|
//#endregion
|
|
96
249
|
//#region ../core/src/utils/types.d.ts
|
|
97
250
|
type PossiblePromise<T> = Promise<T> | T;
|
|
@@ -355,7 +508,7 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
|
|
|
355
508
|
* merging multiple sources into the same output file
|
|
356
509
|
*/
|
|
357
510
|
upsertFile: (...file: Array<KubbFile.File>) => Promise<void>;
|
|
358
|
-
|
|
511
|
+
events: AsyncEventEmitter<KubbEvents>;
|
|
359
512
|
mode: KubbFile.Mode;
|
|
360
513
|
/**
|
|
361
514
|
* Current plugin
|
|
@@ -401,35 +554,6 @@ type Group = {
|
|
|
401
554
|
//#region ../core/src/PluginManager.d.ts
|
|
402
555
|
type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
|
403
556
|
type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
|
|
404
|
-
type ExecutingMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
405
|
-
strategy: Strategy;
|
|
406
|
-
hookName: H;
|
|
407
|
-
plugin: Plugin;
|
|
408
|
-
parameters?: unknown[] | undefined;
|
|
409
|
-
output?: unknown;
|
|
410
|
-
};
|
|
411
|
-
type ExecutedMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
412
|
-
duration: number;
|
|
413
|
-
strategy: Strategy;
|
|
414
|
-
hookName: H;
|
|
415
|
-
plugin: Plugin;
|
|
416
|
-
parameters?: unknown[] | undefined;
|
|
417
|
-
output?: unknown;
|
|
418
|
-
};
|
|
419
|
-
type ErrorMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
420
|
-
hookName: H;
|
|
421
|
-
duration: number;
|
|
422
|
-
strategy: Strategy;
|
|
423
|
-
parameters?: unknown[] | undefined;
|
|
424
|
-
plugin: Plugin;
|
|
425
|
-
};
|
|
426
|
-
type ProgressStartMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
427
|
-
hookName: H;
|
|
428
|
-
plugins: Array<Plugin>;
|
|
429
|
-
};
|
|
430
|
-
type ProgressStopMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
431
|
-
hookName: H;
|
|
432
|
-
};
|
|
433
557
|
type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
|
|
434
558
|
type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
|
|
435
559
|
result: Result;
|
|
@@ -437,19 +561,12 @@ type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseRe
|
|
|
437
561
|
};
|
|
438
562
|
type Options$2 = {
|
|
439
563
|
fabric: Fabric;
|
|
440
|
-
|
|
564
|
+
events: AsyncEventEmitter<KubbEvents>;
|
|
441
565
|
/**
|
|
442
566
|
* @default Number.POSITIVE_INFINITY
|
|
443
567
|
*/
|
|
444
568
|
concurrency?: number;
|
|
445
569
|
};
|
|
446
|
-
type Events = {
|
|
447
|
-
progress_start: [meta: ProgressStartMeta];
|
|
448
|
-
progress_stop: [meta: ProgressStopMeta];
|
|
449
|
-
executing: [meta: ExecutingMeta];
|
|
450
|
-
executed: [meta: ExecutedMeta];
|
|
451
|
-
error: [error: Error, meta: ErrorMeta];
|
|
452
|
-
};
|
|
453
570
|
type GetFileProps<TOptions = object> = {
|
|
454
571
|
name: string;
|
|
455
572
|
mode?: KubbFile.Mode;
|
|
@@ -459,10 +576,10 @@ type GetFileProps<TOptions = object> = {
|
|
|
459
576
|
};
|
|
460
577
|
declare class PluginManager {
|
|
461
578
|
#private;
|
|
462
|
-
readonly events: EventEmitter<Events>;
|
|
463
579
|
readonly config: Config;
|
|
464
580
|
readonly options: Options$2;
|
|
465
581
|
constructor(config: Config, options: Options$2);
|
|
582
|
+
get events(): AsyncEventEmitter<KubbEvents>;
|
|
466
583
|
getContext<TOptions extends PluginFactoryOptions>(plugin: Plugin<TOptions>): PluginContext<TOptions> & Record<string, any>;
|
|
467
584
|
get plugins(): Array<Plugin>;
|
|
468
585
|
getFile<TOptions = object>({
|
|
@@ -476,10 +593,6 @@ declare class PluginManager {
|
|
|
476
593
|
}>;
|
|
477
594
|
resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => KubbFile.Path;
|
|
478
595
|
resolveName: (params: ResolveNameParams) => string;
|
|
479
|
-
/**
|
|
480
|
-
* Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
|
|
481
|
-
*/
|
|
482
|
-
on<TEventName extends keyof Events & string>(eventName: TEventName, handler: (...eventArg: Events[TEventName]) => void): void;
|
|
483
596
|
/**
|
|
484
597
|
* Run a specific hookName for plugin x.
|
|
485
598
|
*/
|
|
@@ -698,7 +811,7 @@ type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
|
698
811
|
override: Array<Override<TOptions>> | undefined;
|
|
699
812
|
contentType: contentType | undefined;
|
|
700
813
|
pluginManager: PluginManager;
|
|
701
|
-
|
|
814
|
+
events?: AsyncEventEmitter<KubbEvents>;
|
|
702
815
|
/**
|
|
703
816
|
* Current plugin
|
|
704
817
|
*/
|
|
@@ -942,7 +1055,7 @@ type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
|
942
1055
|
fabric: Fabric;
|
|
943
1056
|
oas: Oas;
|
|
944
1057
|
pluginManager: PluginManager;
|
|
945
|
-
|
|
1058
|
+
events?: AsyncEventEmitter<KubbEvents>;
|
|
946
1059
|
/**
|
|
947
1060
|
* Current plugin
|
|
948
1061
|
*/
|
|
@@ -1142,4 +1255,4 @@ type ResolvedOptions = {
|
|
|
1142
1255
|
type PluginFaker = PluginFactoryOptions<'plugin-faker', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
1143
1256
|
//#endregion
|
|
1144
1257
|
export { UserPluginWithLifeCycle as a, Schema as i, PluginFaker as n, ReactGenerator as r, Options as t };
|
|
1145
|
-
//# sourceMappingURL=types-
|
|
1258
|
+
//# sourceMappingURL=types-B0uUNfYF.d.ts.map
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { Fabric } from "@kubb/react-fabric";
|
|
2
1
|
import { KubbFile } from "@kubb/fabric-core/types";
|
|
3
|
-
import {
|
|
2
|
+
import { Fabric } from "@kubb/react-fabric";
|
|
4
3
|
import * as OasTypes from "oas/types";
|
|
5
4
|
import { HttpMethods as HttpMethod, OASDocument, SchemaObject, User } from "oas/types";
|
|
6
5
|
import { Operation, Operation as Operation$1 } from "oas/operation";
|
|
@@ -23,75 +22,229 @@ declare abstract class BaseGenerator<TOptions = unknown, TContext = unknown> {
|
|
|
23
22
|
abstract build(...params: unknown[]): unknown;
|
|
24
23
|
}
|
|
25
24
|
//#endregion
|
|
26
|
-
//#region ../core/src/
|
|
27
|
-
declare class EventEmitter<TEvents extends Record<string, any>> {
|
|
28
|
-
#private;
|
|
29
|
-
constructor();
|
|
30
|
-
emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArg: TEvents[TEventName]): void;
|
|
31
|
-
on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
32
|
-
off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
33
|
-
removeAll(): void;
|
|
34
|
-
}
|
|
35
|
-
//#endregion
|
|
36
|
-
//#region ../core/src/logger.d.ts
|
|
25
|
+
//#region ../core/src/Kubb.d.ts
|
|
37
26
|
type DebugEvent = {
|
|
38
27
|
date: Date;
|
|
39
28
|
logs: string[];
|
|
40
29
|
fileName?: string;
|
|
30
|
+
};
|
|
31
|
+
type ProgressStartMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
32
|
+
hookName: H;
|
|
33
|
+
plugins: Array<Plugin>;
|
|
34
|
+
};
|
|
35
|
+
type ProgressStopMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
36
|
+
hookName: H;
|
|
37
|
+
};
|
|
38
|
+
type ExecutingMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
39
|
+
strategy: Strategy;
|
|
40
|
+
hookName: H;
|
|
41
|
+
plugin: Plugin;
|
|
42
|
+
parameters?: unknown[] | undefined;
|
|
43
|
+
output?: unknown;
|
|
44
|
+
};
|
|
45
|
+
type ExecutedMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
46
|
+
duration: number;
|
|
47
|
+
strategy: Strategy;
|
|
48
|
+
hookName: H;
|
|
49
|
+
plugin: Plugin;
|
|
50
|
+
parameters?: unknown[] | undefined;
|
|
51
|
+
output?: unknown;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Events emitted during the Kubb code generation lifecycle.
|
|
55
|
+
* These events can be listened to for logging, progress tracking, and custom integrations.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* import type { AsyncEventEmitter } from '@kubb/core'
|
|
60
|
+
* import type { KubbEvents } from '@kubb/core'
|
|
61
|
+
*
|
|
62
|
+
* const events: AsyncEventEmitter<KubbEvents> = new AsyncEventEmitter()
|
|
63
|
+
*
|
|
64
|
+
* events.on('lifecycle:start', () => {
|
|
65
|
+
* console.log('Starting Kubb generation')
|
|
66
|
+
* })
|
|
67
|
+
*
|
|
68
|
+
* events.on('plugin:end', (plugin, duration) => {
|
|
69
|
+
* console.log(`Plugin ${plugin.name} completed in ${duration}ms`)
|
|
70
|
+
* })
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
interface KubbEvents {
|
|
41
74
|
/**
|
|
42
|
-
*
|
|
43
|
-
* - 'setup': Initial configuration and environment setup
|
|
44
|
-
* - 'plugin': Plugin installation and execution
|
|
45
|
-
* - 'hook': Plugin hook execution details
|
|
46
|
-
* - 'schema': Schema parsing and generation
|
|
47
|
-
* - 'file': File operations (read/write/generate)
|
|
48
|
-
* - 'error': Error details and stack traces
|
|
49
|
-
* - undefined: Generic logs (always inline)
|
|
75
|
+
* Emitted at the beginning of the Kubb lifecycle, before any code generation starts.
|
|
50
76
|
*/
|
|
51
|
-
|
|
77
|
+
'lifecycle:start': [version: string];
|
|
52
78
|
/**
|
|
53
|
-
*
|
|
79
|
+
* Emitted at the end of the Kubb lifecycle, after all code generation is complete.
|
|
54
80
|
*/
|
|
55
|
-
|
|
81
|
+
'lifecycle:end': [];
|
|
56
82
|
/**
|
|
57
|
-
*
|
|
58
|
-
* - 'start': Start of plugin execution group
|
|
59
|
-
* - 'end': End of plugin execution group
|
|
83
|
+
* Emitted when configuration loading starts.
|
|
60
84
|
*/
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
85
|
+
'config:start': [];
|
|
86
|
+
/**
|
|
87
|
+
* Emitted when configuration loading is complete.
|
|
88
|
+
*/
|
|
89
|
+
'config:end': [configs: Array<Config>];
|
|
90
|
+
/**
|
|
91
|
+
* Emitted when code generation phase starts.
|
|
92
|
+
*/
|
|
93
|
+
'generation:start': [config: Config];
|
|
94
|
+
/**
|
|
95
|
+
* Emitted when code generation phase completes.
|
|
96
|
+
*/
|
|
97
|
+
'generation:end': [Config: Config];
|
|
98
|
+
/**
|
|
99
|
+
* Emitted with a summary of the generation results.
|
|
100
|
+
* Contains summary lines, title, and success status.
|
|
101
|
+
*/
|
|
102
|
+
'generation:summary': [Config: Config, {
|
|
103
|
+
failedPlugins: Set<{
|
|
104
|
+
plugin: Plugin;
|
|
105
|
+
error: Error;
|
|
106
|
+
}>;
|
|
107
|
+
status: 'success' | 'failed';
|
|
108
|
+
hrStart: [number, number];
|
|
109
|
+
filesCreated: number;
|
|
110
|
+
pluginTimings?: Map<string, number>;
|
|
79
111
|
}];
|
|
80
|
-
|
|
81
|
-
|
|
112
|
+
/**
|
|
113
|
+
* Emitted when code formatting starts (e.g., running Biome or Prettier).
|
|
114
|
+
*/
|
|
115
|
+
'format:start': [];
|
|
116
|
+
/**
|
|
117
|
+
* Emitted when code formatting completes.
|
|
118
|
+
*/
|
|
119
|
+
'format:end': [];
|
|
120
|
+
/**
|
|
121
|
+
* Emitted when linting starts.
|
|
122
|
+
*/
|
|
123
|
+
'lint:start': [];
|
|
124
|
+
/**
|
|
125
|
+
* Emitted when linting completes.
|
|
126
|
+
*/
|
|
127
|
+
'lint:end': [];
|
|
128
|
+
/**
|
|
129
|
+
* Emitted when plugin hooks execution starts.
|
|
130
|
+
*/
|
|
131
|
+
'hooks:start': [];
|
|
132
|
+
/**
|
|
133
|
+
* Emitted when plugin hooks execution completes.
|
|
134
|
+
*/
|
|
135
|
+
'hooks:end': [];
|
|
136
|
+
/**
|
|
137
|
+
* Emitted when a single hook execution starts.
|
|
138
|
+
*/
|
|
139
|
+
'hook:start': [command: string];
|
|
140
|
+
/**
|
|
141
|
+
* Emitted to execute a hook command (e.g., format or lint).
|
|
142
|
+
* The callback should be invoked when the command completes.
|
|
143
|
+
*/
|
|
144
|
+
'hook:execute': [{
|
|
145
|
+
command: string | URL;
|
|
146
|
+
args?: readonly string[];
|
|
147
|
+
}, cb: () => void];
|
|
148
|
+
/**
|
|
149
|
+
* Emitted when a single hook execution completes.
|
|
150
|
+
*/
|
|
151
|
+
'hook:end': [command: string];
|
|
152
|
+
/**
|
|
153
|
+
* Emitted when a new version of Kubb is available.
|
|
154
|
+
*/
|
|
155
|
+
'version:new': [currentVersion: string, latestVersion: string];
|
|
156
|
+
/**
|
|
157
|
+
* Informational message event.
|
|
158
|
+
*/
|
|
159
|
+
info: [message: string, info?: string];
|
|
160
|
+
/**
|
|
161
|
+
* Error event. Emitted when an error occurs during code generation.
|
|
162
|
+
*/
|
|
163
|
+
error: [error: Error, meta?: Record<string, unknown>];
|
|
164
|
+
/**
|
|
165
|
+
* Success message event.
|
|
166
|
+
*/
|
|
167
|
+
success: [message: string, info?: string];
|
|
168
|
+
/**
|
|
169
|
+
* Warning message event.
|
|
170
|
+
*/
|
|
171
|
+
warn: [message: string, info?: string];
|
|
172
|
+
/**
|
|
173
|
+
* Debug event for detailed logging.
|
|
174
|
+
* Contains timestamp, log messages, and optional filename.
|
|
175
|
+
*/
|
|
176
|
+
debug: [meta: DebugEvent];
|
|
177
|
+
/**
|
|
178
|
+
* Emitted when file processing starts.
|
|
179
|
+
* Contains the list of files to be processed.
|
|
180
|
+
*/
|
|
181
|
+
'files:processing:start': [files: Array<KubbFile.ResolvedFile>];
|
|
182
|
+
/**
|
|
183
|
+
* Emitted for each file being processed, providing progress updates.
|
|
184
|
+
* Contains processed count, total count, percentage, and file details.
|
|
185
|
+
*/
|
|
186
|
+
'file:processing:update': [{
|
|
187
|
+
/** Number of files processed so far */
|
|
188
|
+
processed: number;
|
|
189
|
+
/** Total number of files to process */
|
|
190
|
+
total: number;
|
|
191
|
+
/** Processing percentage (0-100) */
|
|
192
|
+
percentage: number;
|
|
193
|
+
/** Optional source identifier */
|
|
194
|
+
source?: string;
|
|
195
|
+
/** The file being processed */
|
|
196
|
+
file: KubbFile.ResolvedFile;
|
|
197
|
+
/**
|
|
198
|
+
* Kubb configuration (not present in Fabric).
|
|
199
|
+
* Provides access to the current config during file processing.
|
|
200
|
+
*/
|
|
201
|
+
config: Config;
|
|
82
202
|
}];
|
|
83
|
-
};
|
|
84
|
-
type Logger = {
|
|
85
203
|
/**
|
|
86
|
-
*
|
|
204
|
+
* Emitted when file processing completes.
|
|
205
|
+
* Contains the list of processed files.
|
|
87
206
|
*/
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
207
|
+
'files:processing:end': [files: KubbFile.ResolvedFile[]];
|
|
208
|
+
/**
|
|
209
|
+
* Emitted when a plugin starts executing.
|
|
210
|
+
*/
|
|
211
|
+
'plugin:start': [plugin: Plugin];
|
|
212
|
+
/**
|
|
213
|
+
* Emitted when a plugin completes execution.
|
|
214
|
+
*/
|
|
215
|
+
'plugin:end': [plugin: Plugin, duration: number];
|
|
216
|
+
/**
|
|
217
|
+
* Emitted when plugin hook progress tracking starts.
|
|
218
|
+
* Contains the hook name and list of plugins to execute.
|
|
219
|
+
*/
|
|
220
|
+
'plugins:hook:progress:start': [meta: ProgressStartMeta];
|
|
221
|
+
/**
|
|
222
|
+
* Emitted when plugin hook progress tracking ends.
|
|
223
|
+
* Contains the hook name that completed.
|
|
224
|
+
*/
|
|
225
|
+
'plugins:hook:progress:end': [meta: ProgressStopMeta];
|
|
226
|
+
/**
|
|
227
|
+
* Emitted when a plugin hook starts processing.
|
|
228
|
+
* Contains strategy, hook name, plugin, parameters, and output.
|
|
229
|
+
*/
|
|
230
|
+
'plugins:hook:processing:start': [meta: ExecutingMeta];
|
|
231
|
+
/**
|
|
232
|
+
* Emitted when a plugin hook completes processing.
|
|
233
|
+
* Contains duration, strategy, hook name, plugin, parameters, and output.
|
|
234
|
+
*/
|
|
235
|
+
'plugins:hook:processing:end': [meta: ExecutedMeta];
|
|
236
|
+
}
|
|
237
|
+
//#endregion
|
|
238
|
+
//#region ../core/src/utils/AsyncEventEmitter.d.ts
|
|
239
|
+
declare class AsyncEventEmitter<TEvents extends Record<string, any>> {
|
|
240
|
+
#private;
|
|
241
|
+
constructor(maxListener?: number);
|
|
242
|
+
emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArgs: TEvents[TEventName]): Promise<void>;
|
|
243
|
+
on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
244
|
+
onOnce<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArgs: TEvents[TEventName]) => void): void;
|
|
245
|
+
off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
246
|
+
removeAll(): void;
|
|
247
|
+
}
|
|
95
248
|
//#endregion
|
|
96
249
|
//#region ../core/src/utils/types.d.ts
|
|
97
250
|
type PossiblePromise<T> = Promise<T> | T;
|
|
@@ -355,7 +508,7 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
|
|
|
355
508
|
* merging multiple sources into the same output file
|
|
356
509
|
*/
|
|
357
510
|
upsertFile: (...file: Array<KubbFile.File>) => Promise<void>;
|
|
358
|
-
|
|
511
|
+
events: AsyncEventEmitter<KubbEvents>;
|
|
359
512
|
mode: KubbFile.Mode;
|
|
360
513
|
/**
|
|
361
514
|
* Current plugin
|
|
@@ -401,35 +554,6 @@ type Group = {
|
|
|
401
554
|
//#region ../core/src/PluginManager.d.ts
|
|
402
555
|
type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
|
403
556
|
type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
|
|
404
|
-
type ExecutingMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
405
|
-
strategy: Strategy;
|
|
406
|
-
hookName: H;
|
|
407
|
-
plugin: Plugin;
|
|
408
|
-
parameters?: unknown[] | undefined;
|
|
409
|
-
output?: unknown;
|
|
410
|
-
};
|
|
411
|
-
type ExecutedMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
412
|
-
duration: number;
|
|
413
|
-
strategy: Strategy;
|
|
414
|
-
hookName: H;
|
|
415
|
-
plugin: Plugin;
|
|
416
|
-
parameters?: unknown[] | undefined;
|
|
417
|
-
output?: unknown;
|
|
418
|
-
};
|
|
419
|
-
type ErrorMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
420
|
-
hookName: H;
|
|
421
|
-
duration: number;
|
|
422
|
-
strategy: Strategy;
|
|
423
|
-
parameters?: unknown[] | undefined;
|
|
424
|
-
plugin: Plugin;
|
|
425
|
-
};
|
|
426
|
-
type ProgressStartMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
427
|
-
hookName: H;
|
|
428
|
-
plugins: Array<Plugin>;
|
|
429
|
-
};
|
|
430
|
-
type ProgressStopMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
431
|
-
hookName: H;
|
|
432
|
-
};
|
|
433
557
|
type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
|
|
434
558
|
type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
|
|
435
559
|
result: Result;
|
|
@@ -437,19 +561,12 @@ type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseRe
|
|
|
437
561
|
};
|
|
438
562
|
type Options$2 = {
|
|
439
563
|
fabric: Fabric;
|
|
440
|
-
|
|
564
|
+
events: AsyncEventEmitter<KubbEvents>;
|
|
441
565
|
/**
|
|
442
566
|
* @default Number.POSITIVE_INFINITY
|
|
443
567
|
*/
|
|
444
568
|
concurrency?: number;
|
|
445
569
|
};
|
|
446
|
-
type Events = {
|
|
447
|
-
progress_start: [meta: ProgressStartMeta];
|
|
448
|
-
progress_stop: [meta: ProgressStopMeta];
|
|
449
|
-
executing: [meta: ExecutingMeta];
|
|
450
|
-
executed: [meta: ExecutedMeta];
|
|
451
|
-
error: [error: Error, meta: ErrorMeta];
|
|
452
|
-
};
|
|
453
570
|
type GetFileProps<TOptions = object> = {
|
|
454
571
|
name: string;
|
|
455
572
|
mode?: KubbFile.Mode;
|
|
@@ -459,10 +576,10 @@ type GetFileProps<TOptions = object> = {
|
|
|
459
576
|
};
|
|
460
577
|
declare class PluginManager {
|
|
461
578
|
#private;
|
|
462
|
-
readonly events: EventEmitter<Events>;
|
|
463
579
|
readonly config: Config;
|
|
464
580
|
readonly options: Options$2;
|
|
465
581
|
constructor(config: Config, options: Options$2);
|
|
582
|
+
get events(): AsyncEventEmitter<KubbEvents>;
|
|
466
583
|
getContext<TOptions extends PluginFactoryOptions>(plugin: Plugin<TOptions>): PluginContext<TOptions> & Record<string, any>;
|
|
467
584
|
get plugins(): Array<Plugin>;
|
|
468
585
|
getFile<TOptions = object>({
|
|
@@ -476,10 +593,6 @@ declare class PluginManager {
|
|
|
476
593
|
}>;
|
|
477
594
|
resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => KubbFile.Path;
|
|
478
595
|
resolveName: (params: ResolveNameParams) => string;
|
|
479
|
-
/**
|
|
480
|
-
* Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
|
|
481
|
-
*/
|
|
482
|
-
on<TEventName extends keyof Events & string>(eventName: TEventName, handler: (...eventArg: Events[TEventName]) => void): void;
|
|
483
596
|
/**
|
|
484
597
|
* Run a specific hookName for plugin x.
|
|
485
598
|
*/
|
|
@@ -698,7 +811,7 @@ type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
|
698
811
|
override: Array<Override<TOptions>> | undefined;
|
|
699
812
|
contentType: contentType | undefined;
|
|
700
813
|
pluginManager: PluginManager;
|
|
701
|
-
|
|
814
|
+
events?: AsyncEventEmitter<KubbEvents>;
|
|
702
815
|
/**
|
|
703
816
|
* Current plugin
|
|
704
817
|
*/
|
|
@@ -942,7 +1055,7 @@ type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
|
942
1055
|
fabric: Fabric;
|
|
943
1056
|
oas: Oas;
|
|
944
1057
|
pluginManager: PluginManager;
|
|
945
|
-
|
|
1058
|
+
events?: AsyncEventEmitter<KubbEvents>;
|
|
946
1059
|
/**
|
|
947
1060
|
* Current plugin
|
|
948
1061
|
*/
|
|
@@ -1142,4 +1255,4 @@ type ResolvedOptions = {
|
|
|
1142
1255
|
type PluginFaker = PluginFactoryOptions<'plugin-faker', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
1143
1256
|
//#endregion
|
|
1144
1257
|
export { UserPluginWithLifeCycle as a, Schema as i, PluginFaker as n, ReactGenerator as r, Options as t };
|
|
1145
|
-
//# sourceMappingURL=types-
|
|
1258
|
+
//# sourceMappingURL=types-Blj03WRB.d.cts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-faker",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.12.0",
|
|
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",
|
|
@@ -68,14 +68,14 @@
|
|
|
68
68
|
}
|
|
69
69
|
],
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@kubb/react-fabric": "0.
|
|
72
|
-
"@kubb/core": "4.
|
|
73
|
-
"@kubb/
|
|
74
|
-
"@kubb/oas": "4.
|
|
75
|
-
"@kubb/plugin-ts": "4.
|
|
71
|
+
"@kubb/react-fabric": "0.7.0",
|
|
72
|
+
"@kubb/core": "4.12.0",
|
|
73
|
+
"@kubb/oas": "4.12.0",
|
|
74
|
+
"@kubb/plugin-oas": "4.12.0",
|
|
75
|
+
"@kubb/plugin-ts": "4.12.0"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
|
-
"@kubb/plugin-oas": "4.
|
|
78
|
+
"@kubb/plugin-oas": "4.12.0"
|
|
79
79
|
},
|
|
80
80
|
"engines": {
|
|
81
81
|
"node": ">=20"
|
package/src/plugin.ts
CHANGED
|
@@ -101,7 +101,7 @@ export const pluginFaker = definePlugin<PluginFaker>((options) => {
|
|
|
101
101
|
fabric: this.fabric,
|
|
102
102
|
oas,
|
|
103
103
|
pluginManager: this.pluginManager,
|
|
104
|
-
|
|
104
|
+
events: this.events,
|
|
105
105
|
plugin: this.plugin,
|
|
106
106
|
contentType,
|
|
107
107
|
include: undefined,
|
|
@@ -117,7 +117,7 @@ export const pluginFaker = definePlugin<PluginFaker>((options) => {
|
|
|
117
117
|
fabric: this.fabric,
|
|
118
118
|
oas,
|
|
119
119
|
pluginManager: this.pluginManager,
|
|
120
|
-
|
|
120
|
+
events: this.events,
|
|
121
121
|
plugin: this.plugin,
|
|
122
122
|
contentType,
|
|
123
123
|
exclude,
|
|
@@ -136,7 +136,6 @@ export const pluginFaker = definePlugin<PluginFaker>((options) => {
|
|
|
136
136
|
meta: {
|
|
137
137
|
pluginKey: this.plugin.key,
|
|
138
138
|
},
|
|
139
|
-
logger: this.logger,
|
|
140
139
|
})
|
|
141
140
|
|
|
142
141
|
await this.upsertFile(...barrelFiles)
|