@kubb/plugin-faker 4.11.1 → 4.11.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components.d.cts +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/{fakerGenerator-B9W9XQri.cjs → fakerGenerator-B7NcLOvg.cjs} +2 -1
- package/dist/fakerGenerator-B7NcLOvg.cjs.map +1 -0
- package/dist/{fakerGenerator-C6oIiou1.js → fakerGenerator-wJgFsJ4k.js} +2 -1
- package/dist/fakerGenerator-wJgFsJ4k.js.map +1 -0
- 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 +3 -1
- 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 +3 -1
- package/dist/index.js.map +1 -1
- package/dist/{types-DgJG4t24.d.ts → types-CZCTeVpk.d.cts} +62 -29
- package/dist/{types-B1FgdqYL.d.cts → types-CfzJF-pQ.d.ts} +62 -29
- package/package.json +6 -6
- package/src/generators/fakerGenerator.tsx +1 -0
- package/src/plugin.ts +2 -0
- package/dist/fakerGenerator-B9W9XQri.cjs.map +0 -1
- package/dist/fakerGenerator-C6oIiou1.js.map +0 -1
package/dist/components.d.cts
CHANGED
package/dist/components.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ const fakerGenerator = (0, __kubb_plugin_oas_generators.createReactGenerator)({
|
|
|
24
24
|
fabric: generator.context.fabric,
|
|
25
25
|
oas,
|
|
26
26
|
plugin,
|
|
27
|
+
logger: generator.context.logger,
|
|
27
28
|
pluginManager,
|
|
28
29
|
mode,
|
|
29
30
|
override: options.override
|
|
@@ -199,4 +200,4 @@ Object.defineProperty(exports, 'fakerGenerator', {
|
|
|
199
200
|
return fakerGenerator;
|
|
200
201
|
}
|
|
201
202
|
});
|
|
202
|
-
//# sourceMappingURL=fakerGenerator-
|
|
203
|
+
//# sourceMappingURL=fakerGenerator-B7NcLOvg.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fakerGenerator-B7NcLOvg.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 logger: generator.context.logger,\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,OAAO,QAAQ;EAElB,MAAM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AAK;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,6 +24,7 @@ const fakerGenerator = createReactGenerator({
|
|
|
24
24
|
fabric: generator.context.fabric,
|
|
25
25
|
oas,
|
|
26
26
|
plugin,
|
|
27
|
+
logger: generator.context.logger,
|
|
27
28
|
pluginManager,
|
|
28
29
|
mode,
|
|
29
30
|
override: options.override
|
|
@@ -194,4 +195,4 @@ const fakerGenerator = createReactGenerator({
|
|
|
194
195
|
|
|
195
196
|
//#endregion
|
|
196
197
|
export { fakerGenerator as t };
|
|
197
|
-
//# sourceMappingURL=fakerGenerator-
|
|
198
|
+
//# sourceMappingURL=fakerGenerator-wJgFsJ4k.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fakerGenerator-wJgFsJ4k.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 logger: generator.context.logger,\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,EAAE,MAAM,YAAY,CAAC;IACvD,MAAM,cAAc,QAAQ,KAAK;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M,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-B7NcLOvg.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,6 +64,7 @@ const pluginFaker = (0, __kubb_core.definePlugin)((options) => {
|
|
|
64
64
|
fabric: this.fabric,
|
|
65
65
|
oas,
|
|
66
66
|
pluginManager: this.pluginManager,
|
|
67
|
+
logger: this.logger,
|
|
67
68
|
plugin: this.plugin,
|
|
68
69
|
contentType,
|
|
69
70
|
include: void 0,
|
|
@@ -76,6 +77,7 @@ const pluginFaker = (0, __kubb_core.definePlugin)((options) => {
|
|
|
76
77
|
fabric: this.fabric,
|
|
77
78
|
oas,
|
|
78
79
|
pluginManager: this.pluginManager,
|
|
80
|
+
logger: this.logger,
|
|
79
81
|
plugin: this.plugin,
|
|
80
82
|
contentType,
|
|
81
83
|
exclude,
|
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 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 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 logger: this.logger,\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;
|
|
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 logger: this.logger,\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 logger: this.logger,\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 logger: this.logger,\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,MAAM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AO;IAC1D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACD,QAAQ,KAAK;IACd,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-CZCTeVpk.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-CfzJF-pQ.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-wJgFsJ4k.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,6 +62,7 @@ const pluginFaker = definePlugin((options) => {
|
|
|
62
62
|
fabric: this.fabric,
|
|
63
63
|
oas,
|
|
64
64
|
pluginManager: this.pluginManager,
|
|
65
|
+
logger: this.logger,
|
|
65
66
|
plugin: this.plugin,
|
|
66
67
|
contentType,
|
|
67
68
|
include: void 0,
|
|
@@ -74,6 +75,7 @@ const pluginFaker = definePlugin((options) => {
|
|
|
74
75
|
fabric: this.fabric,
|
|
75
76
|
oas,
|
|
76
77
|
pluginManager: this.pluginManager,
|
|
78
|
+
logger: this.logger,
|
|
77
79
|
plugin: this.plugin,
|
|
78
80
|
contentType,
|
|
79
81
|
exclude,
|
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 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 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 logger: this.logger,\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;AAQA,MAAa,kBAAkB;AAE/B,MAAa,cAAc,cAA2B,YAAY;CAChE,MAAM,EACJ,SAAS;EAAE,MAAM;EAAS,YAAY;EAAS,EAC/C,MACA,OACA,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,+BAAe,EAAE,EACjB,SAAS,EAAE,EACX,cAAc,OACd,kBAAkB,aAClB,WAAW,UACX,aAAa,SACb,aAAa,CAAC,eAAe,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,CAAC,eAAe,aAAa;EAClC,YAAY,UAAU,UAAU,WAAS;GACvC,MAAM,OAAO,KAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;AAGpE,QAFa,YAAY,QAAQ,KAAK,QAAQ,MAAM,OAAO,KAAK,CAAC,MAEpD;;;;;AAKX,UAAO,KAAK,QAAQ,MAAM,OAAO,KAAK;AAGxC,OAAI,UAAUA,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,GAAG,UAAU,IAAI,MAAM,CAAC;;AAGrC,WAAO,KAAK,QACV,MACA,OAAO,MACP,UAAU,EACR,OAAO,MAAM,SAAS,SAASD,UAAQ,MAAM,OAAQA,UAAQ,MAAM,KACpE,CAAC,EACF,SACD;;AAGH,UAAO,KAAK,QAAQ,MAAM,OAAO,MAAM,SAAS;;EAElD,YAAY,MAAM,MAAM;GACtB,MAAM,eAAe,UAAU,MAAM;IACnC,QAAQ,OAAO,WAAW;IAC1B,QAAQ,SAAS;IAClB,CAAC;AAEF,OAAI,KACF,QAAOE,gBAAc,OAAO,cAAc,KAAK,IAAI;AAGrD,UAAO;;EAET,MAAM,UAAU;GACd,MAAM,OAAO,KAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;GACpE,MAAM,OAAO,QAAQ,KAAK,QAAQ,MAAM,OAAO,KAAK,CAAC;GACrD,MAAM,MAAM,MAAM,KAAK,QAAQ;
|
|
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 logger: this.logger,\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 logger: this.logger,\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 logger: this.logger,\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;AAQA,MAAa,kBAAkB;AAE/B,MAAa,cAAc,cAA2B,YAAY;CAChE,MAAM,EACJ,SAAS;EAAE,MAAM;EAAS,YAAY;EAAS,EAC/C,MACA,OACA,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,+BAAe,EAAE,EACjB,SAAS,EAAE,EACX,cAAc,OACd,kBAAkB,aAClB,WAAW,UACX,aAAa,SACb,aAAa,CAAC,eAAe,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,CAAC,eAAe,aAAa;EAClC,YAAY,UAAU,UAAU,WAAS;GACvC,MAAM,OAAO,KAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;AAGp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A,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;IACD,QAAQ,KAAK;IACd,CAAC;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;EACD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Fabric } from "@kubb/react-fabric";
|
|
2
1
|
import { KubbFile } from "@kubb/fabric-core/types";
|
|
2
|
+
import { Fabric } from "@kubb/react-fabric";
|
|
3
3
|
import { ConsolaInstance, LogLevel } from "consola";
|
|
4
4
|
import * as OasTypes from "oas/types";
|
|
5
5
|
import { HttpMethods as HttpMethod, OASDocument, SchemaObject, User } from "oas/types";
|
|
@@ -38,13 +38,35 @@ type DebugEvent = {
|
|
|
38
38
|
date: Date;
|
|
39
39
|
logs: string[];
|
|
40
40
|
fileName?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Category of the debug log, used for GitHub Actions grouping
|
|
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)
|
|
50
|
+
*/
|
|
51
|
+
category?: 'setup' | 'plugin' | 'hook' | 'schema' | 'file' | 'error';
|
|
52
|
+
/**
|
|
53
|
+
* Plugin name for grouping plugin-specific logs together
|
|
54
|
+
*/
|
|
55
|
+
pluginName?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Indicates if this is the start or end of a plugin's execution
|
|
58
|
+
* - 'start': Start of plugin execution group
|
|
59
|
+
* - 'end': End of plugin execution group
|
|
60
|
+
*/
|
|
61
|
+
pluginGroupMarker?: 'start' | 'end';
|
|
41
62
|
};
|
|
42
63
|
type Events$1 = {
|
|
43
64
|
start: [message: string];
|
|
44
65
|
success: [message: string];
|
|
45
|
-
error: [message: string,
|
|
66
|
+
error: [message: string, error: Error];
|
|
46
67
|
warning: [message: string];
|
|
47
68
|
debug: [DebugEvent];
|
|
69
|
+
verbose: [DebugEvent];
|
|
48
70
|
info: [message: string];
|
|
49
71
|
progress_start: [{
|
|
50
72
|
id: string;
|
|
@@ -68,7 +90,7 @@ type Logger = {
|
|
|
68
90
|
consola?: ConsolaInstance;
|
|
69
91
|
on: EventEmitter<Events$1>['on'];
|
|
70
92
|
emit: EventEmitter<Events$1>['emit'];
|
|
71
|
-
writeLogs: () => Promise<
|
|
93
|
+
writeLogs: () => Promise<void>;
|
|
72
94
|
};
|
|
73
95
|
//#endregion
|
|
74
96
|
//#region ../core/src/utils/types.d.ts
|
|
@@ -379,14 +401,35 @@ type Group = {
|
|
|
379
401
|
//#region ../core/src/PluginManager.d.ts
|
|
380
402
|
type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
|
381
403
|
type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
|
|
382
|
-
type
|
|
383
|
-
|
|
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;
|
|
384
413
|
strategy: Strategy;
|
|
385
414
|
hookName: H;
|
|
386
415
|
plugin: Plugin;
|
|
387
416
|
parameters?: unknown[] | undefined;
|
|
388
417
|
output?: unknown;
|
|
389
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
|
+
};
|
|
390
433
|
type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
|
|
391
434
|
type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
|
|
392
435
|
result: Result;
|
|
@@ -401,9 +444,11 @@ type Options$2 = {
|
|
|
401
444
|
concurrency?: number;
|
|
402
445
|
};
|
|
403
446
|
type Events = {
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
447
|
+
progress_start: [meta: ProgressStartMeta];
|
|
448
|
+
progress_stop: [meta: ProgressStopMeta];
|
|
449
|
+
executing: [meta: ExecutingMeta];
|
|
450
|
+
executed: [meta: ExecutedMeta];
|
|
451
|
+
error: [error: Error, meta: ErrorMeta];
|
|
407
452
|
};
|
|
408
453
|
type GetFileProps<TOptions = object> = {
|
|
409
454
|
name: string;
|
|
@@ -416,8 +461,6 @@ declare class PluginManager {
|
|
|
416
461
|
#private;
|
|
417
462
|
readonly events: EventEmitter<Events>;
|
|
418
463
|
readonly config: Config;
|
|
419
|
-
readonly executed: Array<Executer>;
|
|
420
|
-
readonly logger: Logger;
|
|
421
464
|
readonly options: Options$2;
|
|
422
465
|
constructor(config: Config, options: Options$2);
|
|
423
466
|
getContext<TOptions extends PluginFactoryOptions>(plugin: Plugin<TOptions>): PluginContext<TOptions> & Record<string, any>;
|
|
@@ -443,13 +486,11 @@ declare class PluginManager {
|
|
|
443
486
|
hookForPlugin<H extends PluginLifecycleHooks>({
|
|
444
487
|
pluginKey,
|
|
445
488
|
hookName,
|
|
446
|
-
parameters
|
|
447
|
-
message
|
|
489
|
+
parameters
|
|
448
490
|
}: {
|
|
449
491
|
pluginKey: Plugin['key'];
|
|
450
492
|
hookName: H;
|
|
451
493
|
parameters: PluginParameter<H>;
|
|
452
|
-
message: string;
|
|
453
494
|
}): Promise<Array<ReturnType<ParseResult<H>> | null>>;
|
|
454
495
|
/**
|
|
455
496
|
* Run a specific hookName for plugin x.
|
|
@@ -457,13 +498,11 @@ declare class PluginManager {
|
|
|
457
498
|
hookForPluginSync<H extends PluginLifecycleHooks>({
|
|
458
499
|
pluginKey,
|
|
459
500
|
hookName,
|
|
460
|
-
parameters
|
|
461
|
-
message
|
|
501
|
+
parameters
|
|
462
502
|
}: {
|
|
463
503
|
pluginKey: Plugin['key'];
|
|
464
504
|
hookName: H;
|
|
465
505
|
parameters: PluginParameter<H>;
|
|
466
|
-
message: string;
|
|
467
506
|
}): Array<ReturnType<ParseResult<H>>> | null;
|
|
468
507
|
/**
|
|
469
508
|
* First non-null result stops and will return it's value.
|
|
@@ -471,13 +510,11 @@ declare class PluginManager {
|
|
|
471
510
|
hookFirst<H extends PluginLifecycleHooks>({
|
|
472
511
|
hookName,
|
|
473
512
|
parameters,
|
|
474
|
-
skipped
|
|
475
|
-
message
|
|
513
|
+
skipped
|
|
476
514
|
}: {
|
|
477
515
|
hookName: H;
|
|
478
516
|
parameters: PluginParameter<H>;
|
|
479
517
|
skipped?: ReadonlySet<Plugin> | null;
|
|
480
|
-
message: string;
|
|
481
518
|
}): Promise<SafeParseResult<H>>;
|
|
482
519
|
/**
|
|
483
520
|
* First non-null result stops and will return it's value.
|
|
@@ -485,37 +522,31 @@ declare class PluginManager {
|
|
|
485
522
|
hookFirstSync<H extends PluginLifecycleHooks>({
|
|
486
523
|
hookName,
|
|
487
524
|
parameters,
|
|
488
|
-
skipped
|
|
489
|
-
message
|
|
525
|
+
skipped
|
|
490
526
|
}: {
|
|
491
527
|
hookName: H;
|
|
492
528
|
parameters: PluginParameter<H>;
|
|
493
529
|
skipped?: ReadonlySet<Plugin> | null;
|
|
494
|
-
message: string;
|
|
495
530
|
}): SafeParseResult<H>;
|
|
496
531
|
/**
|
|
497
532
|
* Run all plugins in parallel(order will be based on `this.plugin` and if `pre` or `post` is set).
|
|
498
533
|
*/
|
|
499
534
|
hookParallel<H extends PluginLifecycleHooks, TOuput = void>({
|
|
500
535
|
hookName,
|
|
501
|
-
parameters
|
|
502
|
-
message
|
|
536
|
+
parameters
|
|
503
537
|
}: {
|
|
504
538
|
hookName: H;
|
|
505
539
|
parameters?: Parameters<RequiredPluginLifecycle[H]> | undefined;
|
|
506
|
-
message: string;
|
|
507
540
|
}): Promise<Awaited<TOuput>[]>;
|
|
508
541
|
/**
|
|
509
542
|
* Chains plugins
|
|
510
543
|
*/
|
|
511
544
|
hookSeq<H extends PluginLifecycleHooks>({
|
|
512
545
|
hookName,
|
|
513
|
-
parameters
|
|
514
|
-
message
|
|
546
|
+
parameters
|
|
515
547
|
}: {
|
|
516
548
|
hookName: H;
|
|
517
549
|
parameters?: PluginParameter<H>;
|
|
518
|
-
message: string;
|
|
519
550
|
}): Promise<void>;
|
|
520
551
|
getPluginByKey(pluginKey: Plugin['key']): Plugin | undefined;
|
|
521
552
|
getPluginsByKey(hookName: keyof PluginWithLifeCycle, pluginKey: Plugin['key']): Plugin[];
|
|
@@ -667,6 +698,7 @@ type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
|
667
698
|
override: Array<Override<TOptions>> | undefined;
|
|
668
699
|
contentType: contentType | undefined;
|
|
669
700
|
pluginManager: PluginManager;
|
|
701
|
+
logger?: Logger;
|
|
670
702
|
/**
|
|
671
703
|
* Current plugin
|
|
672
704
|
*/
|
|
@@ -910,6 +942,7 @@ type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
|
910
942
|
fabric: Fabric;
|
|
911
943
|
oas: Oas;
|
|
912
944
|
pluginManager: PluginManager;
|
|
945
|
+
logger?: Logger;
|
|
913
946
|
/**
|
|
914
947
|
* Current plugin
|
|
915
948
|
*/
|
|
@@ -1109,4 +1142,4 @@ type ResolvedOptions = {
|
|
|
1109
1142
|
type PluginFaker = PluginFactoryOptions<'plugin-faker', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
1110
1143
|
//#endregion
|
|
1111
1144
|
export { UserPluginWithLifeCycle as a, Schema as i, PluginFaker as n, ReactGenerator as r, Options as t };
|
|
1112
|
-
//# sourceMappingURL=types-
|
|
1145
|
+
//# sourceMappingURL=types-CZCTeVpk.d.cts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { KubbFile } from "@kubb/fabric-core/types";
|
|
2
1
|
import { Fabric } from "@kubb/react-fabric";
|
|
2
|
+
import { KubbFile } from "@kubb/fabric-core/types";
|
|
3
3
|
import { ConsolaInstance, LogLevel } from "consola";
|
|
4
4
|
import * as OasTypes from "oas/types";
|
|
5
5
|
import { HttpMethods as HttpMethod, OASDocument, SchemaObject, User } from "oas/types";
|
|
@@ -38,13 +38,35 @@ type DebugEvent = {
|
|
|
38
38
|
date: Date;
|
|
39
39
|
logs: string[];
|
|
40
40
|
fileName?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Category of the debug log, used for GitHub Actions grouping
|
|
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)
|
|
50
|
+
*/
|
|
51
|
+
category?: 'setup' | 'plugin' | 'hook' | 'schema' | 'file' | 'error';
|
|
52
|
+
/**
|
|
53
|
+
* Plugin name for grouping plugin-specific logs together
|
|
54
|
+
*/
|
|
55
|
+
pluginName?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Indicates if this is the start or end of a plugin's execution
|
|
58
|
+
* - 'start': Start of plugin execution group
|
|
59
|
+
* - 'end': End of plugin execution group
|
|
60
|
+
*/
|
|
61
|
+
pluginGroupMarker?: 'start' | 'end';
|
|
41
62
|
};
|
|
42
63
|
type Events$1 = {
|
|
43
64
|
start: [message: string];
|
|
44
65
|
success: [message: string];
|
|
45
|
-
error: [message: string,
|
|
66
|
+
error: [message: string, error: Error];
|
|
46
67
|
warning: [message: string];
|
|
47
68
|
debug: [DebugEvent];
|
|
69
|
+
verbose: [DebugEvent];
|
|
48
70
|
info: [message: string];
|
|
49
71
|
progress_start: [{
|
|
50
72
|
id: string;
|
|
@@ -68,7 +90,7 @@ type Logger = {
|
|
|
68
90
|
consola?: ConsolaInstance;
|
|
69
91
|
on: EventEmitter<Events$1>['on'];
|
|
70
92
|
emit: EventEmitter<Events$1>['emit'];
|
|
71
|
-
writeLogs: () => Promise<
|
|
93
|
+
writeLogs: () => Promise<void>;
|
|
72
94
|
};
|
|
73
95
|
//#endregion
|
|
74
96
|
//#region ../core/src/utils/types.d.ts
|
|
@@ -379,14 +401,35 @@ type Group = {
|
|
|
379
401
|
//#region ../core/src/PluginManager.d.ts
|
|
380
402
|
type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
|
381
403
|
type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
|
|
382
|
-
type
|
|
383
|
-
|
|
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;
|
|
384
413
|
strategy: Strategy;
|
|
385
414
|
hookName: H;
|
|
386
415
|
plugin: Plugin;
|
|
387
416
|
parameters?: unknown[] | undefined;
|
|
388
417
|
output?: unknown;
|
|
389
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
|
+
};
|
|
390
433
|
type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
|
|
391
434
|
type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
|
|
392
435
|
result: Result;
|
|
@@ -401,9 +444,11 @@ type Options$2 = {
|
|
|
401
444
|
concurrency?: number;
|
|
402
445
|
};
|
|
403
446
|
type Events = {
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
447
|
+
progress_start: [meta: ProgressStartMeta];
|
|
448
|
+
progress_stop: [meta: ProgressStopMeta];
|
|
449
|
+
executing: [meta: ExecutingMeta];
|
|
450
|
+
executed: [meta: ExecutedMeta];
|
|
451
|
+
error: [error: Error, meta: ErrorMeta];
|
|
407
452
|
};
|
|
408
453
|
type GetFileProps<TOptions = object> = {
|
|
409
454
|
name: string;
|
|
@@ -416,8 +461,6 @@ declare class PluginManager {
|
|
|
416
461
|
#private;
|
|
417
462
|
readonly events: EventEmitter<Events>;
|
|
418
463
|
readonly config: Config;
|
|
419
|
-
readonly executed: Array<Executer>;
|
|
420
|
-
readonly logger: Logger;
|
|
421
464
|
readonly options: Options$2;
|
|
422
465
|
constructor(config: Config, options: Options$2);
|
|
423
466
|
getContext<TOptions extends PluginFactoryOptions>(plugin: Plugin<TOptions>): PluginContext<TOptions> & Record<string, any>;
|
|
@@ -443,13 +486,11 @@ declare class PluginManager {
|
|
|
443
486
|
hookForPlugin<H extends PluginLifecycleHooks>({
|
|
444
487
|
pluginKey,
|
|
445
488
|
hookName,
|
|
446
|
-
parameters
|
|
447
|
-
message
|
|
489
|
+
parameters
|
|
448
490
|
}: {
|
|
449
491
|
pluginKey: Plugin['key'];
|
|
450
492
|
hookName: H;
|
|
451
493
|
parameters: PluginParameter<H>;
|
|
452
|
-
message: string;
|
|
453
494
|
}): Promise<Array<ReturnType<ParseResult<H>> | null>>;
|
|
454
495
|
/**
|
|
455
496
|
* Run a specific hookName for plugin x.
|
|
@@ -457,13 +498,11 @@ declare class PluginManager {
|
|
|
457
498
|
hookForPluginSync<H extends PluginLifecycleHooks>({
|
|
458
499
|
pluginKey,
|
|
459
500
|
hookName,
|
|
460
|
-
parameters
|
|
461
|
-
message
|
|
501
|
+
parameters
|
|
462
502
|
}: {
|
|
463
503
|
pluginKey: Plugin['key'];
|
|
464
504
|
hookName: H;
|
|
465
505
|
parameters: PluginParameter<H>;
|
|
466
|
-
message: string;
|
|
467
506
|
}): Array<ReturnType<ParseResult<H>>> | null;
|
|
468
507
|
/**
|
|
469
508
|
* First non-null result stops and will return it's value.
|
|
@@ -471,13 +510,11 @@ declare class PluginManager {
|
|
|
471
510
|
hookFirst<H extends PluginLifecycleHooks>({
|
|
472
511
|
hookName,
|
|
473
512
|
parameters,
|
|
474
|
-
skipped
|
|
475
|
-
message
|
|
513
|
+
skipped
|
|
476
514
|
}: {
|
|
477
515
|
hookName: H;
|
|
478
516
|
parameters: PluginParameter<H>;
|
|
479
517
|
skipped?: ReadonlySet<Plugin> | null;
|
|
480
|
-
message: string;
|
|
481
518
|
}): Promise<SafeParseResult<H>>;
|
|
482
519
|
/**
|
|
483
520
|
* First non-null result stops and will return it's value.
|
|
@@ -485,37 +522,31 @@ declare class PluginManager {
|
|
|
485
522
|
hookFirstSync<H extends PluginLifecycleHooks>({
|
|
486
523
|
hookName,
|
|
487
524
|
parameters,
|
|
488
|
-
skipped
|
|
489
|
-
message
|
|
525
|
+
skipped
|
|
490
526
|
}: {
|
|
491
527
|
hookName: H;
|
|
492
528
|
parameters: PluginParameter<H>;
|
|
493
529
|
skipped?: ReadonlySet<Plugin> | null;
|
|
494
|
-
message: string;
|
|
495
530
|
}): SafeParseResult<H>;
|
|
496
531
|
/**
|
|
497
532
|
* Run all plugins in parallel(order will be based on `this.plugin` and if `pre` or `post` is set).
|
|
498
533
|
*/
|
|
499
534
|
hookParallel<H extends PluginLifecycleHooks, TOuput = void>({
|
|
500
535
|
hookName,
|
|
501
|
-
parameters
|
|
502
|
-
message
|
|
536
|
+
parameters
|
|
503
537
|
}: {
|
|
504
538
|
hookName: H;
|
|
505
539
|
parameters?: Parameters<RequiredPluginLifecycle[H]> | undefined;
|
|
506
|
-
message: string;
|
|
507
540
|
}): Promise<Awaited<TOuput>[]>;
|
|
508
541
|
/**
|
|
509
542
|
* Chains plugins
|
|
510
543
|
*/
|
|
511
544
|
hookSeq<H extends PluginLifecycleHooks>({
|
|
512
545
|
hookName,
|
|
513
|
-
parameters
|
|
514
|
-
message
|
|
546
|
+
parameters
|
|
515
547
|
}: {
|
|
516
548
|
hookName: H;
|
|
517
549
|
parameters?: PluginParameter<H>;
|
|
518
|
-
message: string;
|
|
519
550
|
}): Promise<void>;
|
|
520
551
|
getPluginByKey(pluginKey: Plugin['key']): Plugin | undefined;
|
|
521
552
|
getPluginsByKey(hookName: keyof PluginWithLifeCycle, pluginKey: Plugin['key']): Plugin[];
|
|
@@ -667,6 +698,7 @@ type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
|
667
698
|
override: Array<Override<TOptions>> | undefined;
|
|
668
699
|
contentType: contentType | undefined;
|
|
669
700
|
pluginManager: PluginManager;
|
|
701
|
+
logger?: Logger;
|
|
670
702
|
/**
|
|
671
703
|
* Current plugin
|
|
672
704
|
*/
|
|
@@ -910,6 +942,7 @@ type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
|
910
942
|
fabric: Fabric;
|
|
911
943
|
oas: Oas;
|
|
912
944
|
pluginManager: PluginManager;
|
|
945
|
+
logger?: Logger;
|
|
913
946
|
/**
|
|
914
947
|
* Current plugin
|
|
915
948
|
*/
|
|
@@ -1109,4 +1142,4 @@ type ResolvedOptions = {
|
|
|
1109
1142
|
type PluginFaker = PluginFactoryOptions<'plugin-faker', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
1110
1143
|
//#endregion
|
|
1111
1144
|
export { UserPluginWithLifeCycle as a, Schema as i, PluginFaker as n, ReactGenerator as r, Options as t };
|
|
1112
|
-
//# sourceMappingURL=types-
|
|
1145
|
+
//# sourceMappingURL=types-CfzJF-pQ.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-faker",
|
|
3
|
-
"version": "4.11.
|
|
3
|
+
"version": "4.11.3",
|
|
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",
|
|
@@ -69,13 +69,13 @@
|
|
|
69
69
|
],
|
|
70
70
|
"dependencies": {
|
|
71
71
|
"@kubb/react-fabric": "0.5.4",
|
|
72
|
-
"@kubb/core": "4.11.
|
|
73
|
-
"@kubb/plugin-oas": "4.11.
|
|
74
|
-
"@kubb/
|
|
75
|
-
"@kubb/
|
|
72
|
+
"@kubb/core": "4.11.3",
|
|
73
|
+
"@kubb/plugin-oas": "4.11.3",
|
|
74
|
+
"@kubb/oas": "4.11.3",
|
|
75
|
+
"@kubb/plugin-ts": "4.11.3"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
|
-
"@kubb/plugin-oas": "4.11.
|
|
78
|
+
"@kubb/plugin-oas": "4.11.3"
|
|
79
79
|
},
|
|
80
80
|
"engines": {
|
|
81
81
|
"node": ">=20"
|
package/src/plugin.ts
CHANGED
|
@@ -101,6 +101,7 @@ export const pluginFaker = definePlugin<PluginFaker>((options) => {
|
|
|
101
101
|
fabric: this.fabric,
|
|
102
102
|
oas,
|
|
103
103
|
pluginManager: this.pluginManager,
|
|
104
|
+
logger: this.logger,
|
|
104
105
|
plugin: this.plugin,
|
|
105
106
|
contentType,
|
|
106
107
|
include: undefined,
|
|
@@ -116,6 +117,7 @@ export const pluginFaker = definePlugin<PluginFaker>((options) => {
|
|
|
116
117
|
fabric: this.fabric,
|
|
117
118
|
oas,
|
|
118
119
|
pluginManager: this.pluginManager,
|
|
120
|
+
logger: this.logger,
|
|
119
121
|
plugin: this.plugin,
|
|
120
122
|
contentType,
|
|
121
123
|
exclude,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fakerGenerator-B9W9XQri.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 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,SA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AACA,8BAAa,EAAE,CAAC;GAC1D;EAED,MAAM,cAAc,OAAO,KAAK,MAC7B,EAAE,cACD,YAAYC,iCAAe,SAC3B,YAAYA,iCAAe,OAC3B,YAAYA,iCAAe,UAC3B,YAAYA,iCAAe,SAC3B,YAAYA,iCAAe,SAC3B,YAAYA,iCAAe,UAC3B,YAAYA,iCAAe,WAC3B,YAAYA,iCAAe,OAC9B;AAED,SACE,0DAACE;GACC,UAAU,MAAM,KAAK;GACrB,MAAM,MAAM,KAAK;GACjB,MAAM,MAAM,KAAK;GACjB,+CAAkB;IAAE;IAAK;IAAQ,QAAQ,cAAc;IAAQ,CAAC;GAChE,+CAAkB;IAAE;IAAK;IAAQ,CAAC;;IAElC,yDAACA,yBAAK;KAAO,MAAM,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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fakerGenerator-C6oIiou1.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 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;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,MAA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