@kubb/plugin-faker 4.4.1 → 4.5.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-DdXRywj6.js → components-B6wjVu4Y.js} +32 -25
- package/dist/components-B6wjVu4Y.js.map +1 -0
- package/dist/{components-BtFAhtPK.cjs → components-Dq57kUQf.cjs} +32 -25
- package/dist/components-Dq57kUQf.cjs.map +1 -0
- package/dist/components.cjs +1 -1
- package/dist/components.d.cts +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/components.js +1 -1
- package/dist/{fakerGenerator-6YTX8ENZ.cjs → fakerGenerator-CYRnwp6R.cjs} +40 -47
- package/dist/fakerGenerator-CYRnwp6R.cjs.map +1 -0
- package/dist/{fakerGenerator-D3zaPh1_.js → fakerGenerator-CfTiMdtr.js} +41 -48
- package/dist/fakerGenerator-CfTiMdtr.js.map +1 -0
- package/dist/generators.cjs +2 -2
- package/dist/generators.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/generators.js +2 -2
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/{types-Dda1jVMe.d.ts → types-CEWRTyrN.d.ts} +168 -174
- package/dist/{types-DRMQqYat.d.cts → types-NHbH6Svj.d.cts} +168 -174
- package/package.json +8 -8
- package/src/components/Faker.tsx +1 -3
- package/src/generators/__snapshots__/enumNames.ts +1 -1
- package/src/generators/__snapshots__/enumVarNames.ts +1 -1
- package/src/generators/fakerGenerator.tsx +17 -18
- package/src/parser.ts +9 -13
- package/src/types.ts +2 -1
- package/dist/components-BtFAhtPK.cjs.map +0 -1
- package/dist/components-DdXRywj6.js.map +0 -1
- package/dist/fakerGenerator-6YTX8ENZ.cjs.map +0 -1
- package/dist/fakerGenerator-D3zaPh1_.js.map +0 -1
|
@@ -1,28 +1,27 @@
|
|
|
1
|
-
import { t as Faker } from "./components-
|
|
2
|
-
import { SchemaGenerator,
|
|
1
|
+
import { t as Faker } from "./components-B6wjVu4Y.js";
|
|
2
|
+
import { SchemaGenerator, schemaKeywords } from "@kubb/plugin-oas";
|
|
3
3
|
import { pluginTsName } from "@kubb/plugin-ts";
|
|
4
|
-
import { useMode,
|
|
5
|
-
import {
|
|
4
|
+
import { useMode, usePluginManager } from "@kubb/core/hooks";
|
|
5
|
+
import { createReactGenerator } from "@kubb/plugin-oas/generators";
|
|
6
6
|
import { useOas, useOperationManager, useSchemaManager } from "@kubb/plugin-oas/hooks";
|
|
7
7
|
import { getBanner, getFooter } from "@kubb/plugin-oas/utils";
|
|
8
|
-
import { File } from "@kubb/react-fabric";
|
|
8
|
+
import { File, Fragment } from "@kubb/react-fabric";
|
|
9
9
|
import { jsx, jsxs } from "@kubb/react-fabric/jsx-runtime";
|
|
10
10
|
|
|
11
11
|
//#region src/generators/fakerGenerator.tsx
|
|
12
12
|
const fakerGenerator = createReactGenerator({
|
|
13
13
|
name: "faker",
|
|
14
|
-
Operation({ operation,
|
|
15
|
-
const { dateParser, regexGenerator, seed, mapper } =
|
|
16
|
-
const plugin = usePlugin();
|
|
14
|
+
Operation({ operation, generator, plugin }) {
|
|
15
|
+
const { options, options: { dateParser, regexGenerator, seed, mapper } } = plugin;
|
|
17
16
|
const mode = useMode();
|
|
18
17
|
const pluginManager = usePluginManager();
|
|
19
18
|
const oas = useOas();
|
|
20
|
-
const { getSchemas, getFile, getGroup } = useOperationManager();
|
|
19
|
+
const { getSchemas, getFile, getGroup } = useOperationManager(generator);
|
|
21
20
|
const schemaManager = useSchemaManager();
|
|
22
21
|
const file = getFile(operation);
|
|
23
22
|
const schemas = getSchemas(operation);
|
|
24
23
|
const schemaGenerator = new SchemaGenerator(options, {
|
|
25
|
-
fabric:
|
|
24
|
+
fabric: generator.context.fabric,
|
|
26
25
|
oas,
|
|
27
26
|
plugin,
|
|
28
27
|
pluginManager,
|
|
@@ -37,7 +36,7 @@ const fakerGenerator = createReactGenerator({
|
|
|
37
36
|
schemas.request,
|
|
38
37
|
schemas.response
|
|
39
38
|
].flat().filter(Boolean);
|
|
40
|
-
const mapOperationSchema = ({ name, schema: schemaObject, description,...options$1 }
|
|
39
|
+
const mapOperationSchema = ({ name, schema: schemaObject, description,...options$1 }) => {
|
|
41
40
|
const tree = schemaGenerator.parse({
|
|
42
41
|
schemaObject,
|
|
43
42
|
name
|
|
@@ -59,39 +58,34 @@ const fakerGenerator = createReactGenerator({
|
|
|
59
58
|
})
|
|
60
59
|
};
|
|
61
60
|
const canOverride = tree.some(({ keyword }) => keyword === schemaKeywords.array || keyword === schemaKeywords.and || keyword === schemaKeywords.object || keyword === schemaKeywords.union || keyword === schemaKeywords.tuple);
|
|
62
|
-
return /* @__PURE__ */ jsxs(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
seed,
|
|
91
|
-
canOverride
|
|
92
|
-
})
|
|
93
|
-
]
|
|
94
|
-
}, i);
|
|
61
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
62
|
+
canOverride && /* @__PURE__ */ jsx(File.Import, {
|
|
63
|
+
isTypeOnly: true,
|
|
64
|
+
root: file.path,
|
|
65
|
+
path: type.file.path,
|
|
66
|
+
name: [type.name]
|
|
67
|
+
}),
|
|
68
|
+
imports.map((imp) => /* @__PURE__ */ jsx(File.Import, {
|
|
69
|
+
root: file.path,
|
|
70
|
+
path: imp.path,
|
|
71
|
+
name: imp.name
|
|
72
|
+
}, [
|
|
73
|
+
imp.path,
|
|
74
|
+
imp.name,
|
|
75
|
+
imp.isTypeOnly
|
|
76
|
+
].join("-"))),
|
|
77
|
+
/* @__PURE__ */ jsx(Faker, {
|
|
78
|
+
name: faker.name,
|
|
79
|
+
typeName: type.name,
|
|
80
|
+
description,
|
|
81
|
+
tree,
|
|
82
|
+
regexGenerator,
|
|
83
|
+
dateParser,
|
|
84
|
+
mapper,
|
|
85
|
+
seed,
|
|
86
|
+
canOverride
|
|
87
|
+
})
|
|
88
|
+
] });
|
|
95
89
|
};
|
|
96
90
|
return /* @__PURE__ */ jsxs(File, {
|
|
97
91
|
baseName: file.baseName,
|
|
@@ -123,10 +117,9 @@ const fakerGenerator = createReactGenerator({
|
|
|
123
117
|
]
|
|
124
118
|
});
|
|
125
119
|
},
|
|
126
|
-
Schema({ schema,
|
|
127
|
-
const { dateParser, regexGenerator, seed, mapper } = options;
|
|
120
|
+
Schema({ schema, plugin }) {
|
|
128
121
|
const { getName, getFile, getImports } = useSchemaManager();
|
|
129
|
-
const { options: { output } } =
|
|
122
|
+
const { options: { output, dateParser, regexGenerator, seed, mapper } } = plugin;
|
|
130
123
|
const pluginManager = usePluginManager();
|
|
131
124
|
const oas = useOas();
|
|
132
125
|
const imports = getImports(schema.tree);
|
|
@@ -201,4 +194,4 @@ const fakerGenerator = createReactGenerator({
|
|
|
201
194
|
|
|
202
195
|
//#endregion
|
|
203
196
|
export { fakerGenerator as t };
|
|
204
|
-
//# sourceMappingURL=fakerGenerator-
|
|
197
|
+
//# sourceMappingURL=fakerGenerator-CfTiMdtr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fakerGenerator-CfTiMdtr.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,YAAa,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;IAClC;GAED,MAAM,OAAO;IACX,MAAM,cAAc,QAAQ,MAAM;KAAE,MAAM;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AAI;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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require('./components-
|
|
2
|
-
const require_fakerGenerator = require('./fakerGenerator-
|
|
1
|
+
require('./components-Dq57kUQf.cjs');
|
|
2
|
+
const require_fakerGenerator = require('./fakerGenerator-CYRnwp6R.cjs');
|
|
3
3
|
|
|
4
4
|
exports.fakerGenerator = require_fakerGenerator.fakerGenerator;
|
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
|
-
const require_components = require('./components-
|
|
2
|
-
const require_fakerGenerator = require('./fakerGenerator-
|
|
1
|
+
const require_components = require('./components-Dq57kUQf.cjs');
|
|
2
|
+
const require_fakerGenerator = require('./fakerGenerator-CYRnwp6R.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");
|
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-NHbH6Svj.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-CEWRTyrN.js";
|
|
2
2
|
|
|
3
3
|
//#region src/plugin.d.ts
|
|
4
4
|
declare const pluginFakerName = "plugin-faker";
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./components-
|
|
2
|
-
import { t as fakerGenerator } from "./fakerGenerator-
|
|
1
|
+
import "./components-B6wjVu4Y.js";
|
|
2
|
+
import { t as fakerGenerator } from "./fakerGenerator-CfTiMdtr.js";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { PluginManager, createPlugin, getBarrelFiles, getMode } from "@kubb/core";
|
|
5
5
|
import { camelCase } from "@kubb/core/transformers";
|
|
@@ -556,170 +556,6 @@ declare class Oas<const TOAS = unknown> extends BaseOas {
|
|
|
556
556
|
valdiate(): Promise<oas_normalize_lib_types0.ValidationResult>;
|
|
557
557
|
}
|
|
558
558
|
//#endregion
|
|
559
|
-
//#region ../plugin-oas/src/generators/createReactGenerator.d.ts
|
|
560
|
-
type ReactGenerator<TOptions extends PluginFactoryOptions> = {
|
|
561
|
-
name: string;
|
|
562
|
-
type: 'react';
|
|
563
|
-
Operations: (props: OperationsProps<TOptions>) => KubbNode;
|
|
564
|
-
Operation: (props: OperationProps<TOptions>) => KubbNode;
|
|
565
|
-
Schema: (props: SchemaProps$1<TOptions>) => KubbNode;
|
|
566
|
-
};
|
|
567
|
-
//#endregion
|
|
568
|
-
//#region ../plugin-oas/src/generators/types.d.ts
|
|
569
|
-
type OperationsProps<TOptions extends PluginFactoryOptions> = {
|
|
570
|
-
/**
|
|
571
|
-
* @deprecated
|
|
572
|
-
*/
|
|
573
|
-
instance: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
574
|
-
options: TOptions['resolvedOptions'];
|
|
575
|
-
operations: Array<Operation$1>;
|
|
576
|
-
};
|
|
577
|
-
type OperationProps<TOptions extends PluginFactoryOptions> = {
|
|
578
|
-
/**
|
|
579
|
-
* @deprecated
|
|
580
|
-
*/
|
|
581
|
-
instance: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
582
|
-
options: TOptions['resolvedOptions'];
|
|
583
|
-
operation: Operation$1;
|
|
584
|
-
};
|
|
585
|
-
type SchemaProps$1<TOptions extends PluginFactoryOptions> = {
|
|
586
|
-
instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
|
|
587
|
-
options: TOptions['resolvedOptions'];
|
|
588
|
-
schema: {
|
|
589
|
-
name: string;
|
|
590
|
-
tree: Array<Schema>;
|
|
591
|
-
value: SchemaObject$1;
|
|
592
|
-
};
|
|
593
|
-
};
|
|
594
|
-
type Generator<TOptions extends PluginFactoryOptions> = CoreGenerator<TOptions> | ReactGenerator<TOptions>;
|
|
595
|
-
//#endregion
|
|
596
|
-
//#region ../plugin-oas/src/generators/createGenerator.d.ts
|
|
597
|
-
type CoreGenerator<TOptions extends PluginFactoryOptions> = {
|
|
598
|
-
name: string;
|
|
599
|
-
type: 'core';
|
|
600
|
-
operations: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
601
|
-
operation: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
602
|
-
schema: (props: SchemaProps$1<TOptions>) => Promise<KubbFile.File[]>;
|
|
603
|
-
};
|
|
604
|
-
//#endregion
|
|
605
|
-
//#region ../plugin-oas/src/types.d.ts
|
|
606
|
-
type ResolvePathOptions = {
|
|
607
|
-
pluginKey?: Plugin['key'];
|
|
608
|
-
group?: {
|
|
609
|
-
tag?: string;
|
|
610
|
-
path?: string;
|
|
611
|
-
};
|
|
612
|
-
type?: ResolveNameParams['type'];
|
|
613
|
-
};
|
|
614
|
-
/**
|
|
615
|
-
* `propertyName` is the ref name + resolved with the nameResolver
|
|
616
|
-
* @example import { Pet } from './Pet'
|
|
617
|
-
*
|
|
618
|
-
* `originalName` is the original name used(in PascalCase), only used to remove duplicates
|
|
619
|
-
*
|
|
620
|
-
* `pluginKey` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
|
|
621
|
-
* @example import a type(plugin-ts) for a mock file(swagger-faker)
|
|
622
|
-
*/
|
|
623
|
-
type Ref = {
|
|
624
|
-
propertyName: string;
|
|
625
|
-
originalName: string;
|
|
626
|
-
path: KubbFile.OptionalPath;
|
|
627
|
-
pluginKey?: Plugin['key'];
|
|
628
|
-
};
|
|
629
|
-
type Refs = Record<string, Ref>;
|
|
630
|
-
type OperationSchema = {
|
|
631
|
-
/**
|
|
632
|
-
* Converted name, contains already `PathParams`, `QueryParams`, ...
|
|
633
|
-
*/
|
|
634
|
-
name: string;
|
|
635
|
-
schema: SchemaObject$1;
|
|
636
|
-
operation?: Operation$1;
|
|
637
|
-
/**
|
|
638
|
-
* OperationName in PascalCase, only being used in OperationGenerator
|
|
639
|
-
*/
|
|
640
|
-
operationName: string;
|
|
641
|
-
description?: string;
|
|
642
|
-
statusCode?: number;
|
|
643
|
-
keys?: string[];
|
|
644
|
-
keysToOmit?: string[];
|
|
645
|
-
withData?: boolean;
|
|
646
|
-
};
|
|
647
|
-
type OperationSchemas = {
|
|
648
|
-
pathParams?: OperationSchema & {
|
|
649
|
-
keysToOmit?: never;
|
|
650
|
-
};
|
|
651
|
-
queryParams?: OperationSchema & {
|
|
652
|
-
keysToOmit?: never;
|
|
653
|
-
};
|
|
654
|
-
headerParams?: OperationSchema & {
|
|
655
|
-
keysToOmit?: never;
|
|
656
|
-
};
|
|
657
|
-
request?: OperationSchema;
|
|
658
|
-
response: OperationSchema;
|
|
659
|
-
responses: Array<OperationSchema>;
|
|
660
|
-
statusCodes?: Array<OperationSchema>;
|
|
661
|
-
errors?: Array<OperationSchema>;
|
|
662
|
-
};
|
|
663
|
-
type ByTag = {
|
|
664
|
-
type: 'tag';
|
|
665
|
-
pattern: string | RegExp;
|
|
666
|
-
};
|
|
667
|
-
type ByOperationId = {
|
|
668
|
-
type: 'operationId';
|
|
669
|
-
pattern: string | RegExp;
|
|
670
|
-
};
|
|
671
|
-
type ByPath = {
|
|
672
|
-
type: 'path';
|
|
673
|
-
pattern: string | RegExp;
|
|
674
|
-
};
|
|
675
|
-
type ByMethod = {
|
|
676
|
-
type: 'method';
|
|
677
|
-
pattern: HttpMethod | RegExp;
|
|
678
|
-
};
|
|
679
|
-
type BySchemaName = {
|
|
680
|
-
type: 'schemaName';
|
|
681
|
-
pattern: string | RegExp;
|
|
682
|
-
};
|
|
683
|
-
type ByContentType = {
|
|
684
|
-
type: 'contentType';
|
|
685
|
-
pattern: string | RegExp;
|
|
686
|
-
};
|
|
687
|
-
type Exclude$1 = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
688
|
-
type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
689
|
-
type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
|
|
690
|
-
options: Partial<TOptions>;
|
|
691
|
-
};
|
|
692
|
-
//#endregion
|
|
693
|
-
//#region ../plugin-oas/src/OperationGenerator.d.ts
|
|
694
|
-
type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
695
|
-
fabric: Fabric;
|
|
696
|
-
oas: Oas;
|
|
697
|
-
exclude: Array<Exclude$1> | undefined;
|
|
698
|
-
include: Array<Include> | undefined;
|
|
699
|
-
override: Array<Override<TOptions>> | undefined;
|
|
700
|
-
contentType: contentType | undefined;
|
|
701
|
-
pluginManager: PluginManager;
|
|
702
|
-
/**
|
|
703
|
-
* Current plugin
|
|
704
|
-
*/
|
|
705
|
-
plugin: Plugin<TPluginOptions>;
|
|
706
|
-
mode: KubbFile.Mode;
|
|
707
|
-
};
|
|
708
|
-
declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context$1<TPluginOptions['resolvedOptions'], TPluginOptions>> {
|
|
709
|
-
#private;
|
|
710
|
-
getSchemas(operation: Operation$1, {
|
|
711
|
-
resolveName
|
|
712
|
-
}?: {
|
|
713
|
-
resolveName?: (name: string) => string;
|
|
714
|
-
}): OperationSchemas;
|
|
715
|
-
getOperations(): Promise<Array<{
|
|
716
|
-
path: string;
|
|
717
|
-
method: HttpMethod;
|
|
718
|
-
operation: Operation$1;
|
|
719
|
-
}>>;
|
|
720
|
-
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
721
|
-
}
|
|
722
|
-
//#endregion
|
|
723
559
|
//#region ../plugin-oas/src/SchemaMapper.d.ts
|
|
724
560
|
type SchemaKeywordMapper = {
|
|
725
561
|
object: {
|
|
@@ -937,8 +773,96 @@ type Schema = {
|
|
|
937
773
|
keyword: string;
|
|
938
774
|
} | SchemaKeywordMapper[keyof SchemaKeywordMapper];
|
|
939
775
|
//#endregion
|
|
776
|
+
//#region ../plugin-oas/src/types.d.ts
|
|
777
|
+
type ResolvePathOptions = {
|
|
778
|
+
pluginKey?: Plugin['key'];
|
|
779
|
+
group?: {
|
|
780
|
+
tag?: string;
|
|
781
|
+
path?: string;
|
|
782
|
+
};
|
|
783
|
+
type?: ResolveNameParams['type'];
|
|
784
|
+
};
|
|
785
|
+
/**
|
|
786
|
+
* `propertyName` is the ref name + resolved with the nameResolver
|
|
787
|
+
* @example import { Pet } from './Pet'
|
|
788
|
+
*
|
|
789
|
+
* `originalName` is the original name used(in PascalCase), only used to remove duplicates
|
|
790
|
+
*
|
|
791
|
+
* `pluginKey` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
|
|
792
|
+
* @example import a type(plugin-ts) for a mock file(swagger-faker)
|
|
793
|
+
*/
|
|
794
|
+
type Ref = {
|
|
795
|
+
propertyName: string;
|
|
796
|
+
originalName: string;
|
|
797
|
+
path: KubbFile.OptionalPath;
|
|
798
|
+
pluginKey?: Plugin['key'];
|
|
799
|
+
};
|
|
800
|
+
type Refs = Record<string, Ref>;
|
|
801
|
+
type OperationSchema = {
|
|
802
|
+
/**
|
|
803
|
+
* Converted name, contains already `PathParams`, `QueryParams`, ...
|
|
804
|
+
*/
|
|
805
|
+
name: string;
|
|
806
|
+
schema: SchemaObject$1;
|
|
807
|
+
operation?: Operation$1;
|
|
808
|
+
/**
|
|
809
|
+
* OperationName in PascalCase, only being used in OperationGenerator
|
|
810
|
+
*/
|
|
811
|
+
operationName: string;
|
|
812
|
+
description?: string;
|
|
813
|
+
statusCode?: number;
|
|
814
|
+
keys?: string[];
|
|
815
|
+
keysToOmit?: string[];
|
|
816
|
+
withData?: boolean;
|
|
817
|
+
};
|
|
818
|
+
type OperationSchemas = {
|
|
819
|
+
pathParams?: OperationSchema & {
|
|
820
|
+
keysToOmit?: never;
|
|
821
|
+
};
|
|
822
|
+
queryParams?: OperationSchema & {
|
|
823
|
+
keysToOmit?: never;
|
|
824
|
+
};
|
|
825
|
+
headerParams?: OperationSchema & {
|
|
826
|
+
keysToOmit?: never;
|
|
827
|
+
};
|
|
828
|
+
request?: OperationSchema;
|
|
829
|
+
response: OperationSchema;
|
|
830
|
+
responses: Array<OperationSchema>;
|
|
831
|
+
statusCodes?: Array<OperationSchema>;
|
|
832
|
+
errors?: Array<OperationSchema>;
|
|
833
|
+
};
|
|
834
|
+
type ByTag = {
|
|
835
|
+
type: 'tag';
|
|
836
|
+
pattern: string | RegExp;
|
|
837
|
+
};
|
|
838
|
+
type ByOperationId = {
|
|
839
|
+
type: 'operationId';
|
|
840
|
+
pattern: string | RegExp;
|
|
841
|
+
};
|
|
842
|
+
type ByPath = {
|
|
843
|
+
type: 'path';
|
|
844
|
+
pattern: string | RegExp;
|
|
845
|
+
};
|
|
846
|
+
type ByMethod = {
|
|
847
|
+
type: 'method';
|
|
848
|
+
pattern: HttpMethod | RegExp;
|
|
849
|
+
};
|
|
850
|
+
type BySchemaName = {
|
|
851
|
+
type: 'schemaName';
|
|
852
|
+
pattern: string | RegExp;
|
|
853
|
+
};
|
|
854
|
+
type ByContentType = {
|
|
855
|
+
type: 'contentType';
|
|
856
|
+
pattern: string | RegExp;
|
|
857
|
+
};
|
|
858
|
+
type Exclude$1 = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
859
|
+
type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
860
|
+
type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
|
|
861
|
+
options: Partial<TOptions>;
|
|
862
|
+
};
|
|
863
|
+
//#endregion
|
|
940
864
|
//#region ../plugin-oas/src/SchemaGenerator.d.ts
|
|
941
|
-
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
865
|
+
type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
942
866
|
fabric: Fabric;
|
|
943
867
|
oas: Oas;
|
|
944
868
|
pluginManager: PluginManager;
|
|
@@ -971,15 +895,15 @@ type SchemaGeneratorOptions = {
|
|
|
971
895
|
* TODO TODO add docs
|
|
972
896
|
* @beta
|
|
973
897
|
*/
|
|
974
|
-
schema?: (schemaProps: SchemaProps, defaultSchemas: Schema[]) => Schema[] | undefined;
|
|
898
|
+
schema?: (schemaProps: SchemaProps$1, defaultSchemas: Schema[]) => Schema[] | undefined;
|
|
975
899
|
};
|
|
976
900
|
};
|
|
977
|
-
type SchemaProps = {
|
|
901
|
+
type SchemaProps$1 = {
|
|
978
902
|
schemaObject?: SchemaObject$1;
|
|
979
903
|
name?: string;
|
|
980
904
|
parentName?: string;
|
|
981
905
|
};
|
|
982
|
-
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context<TOptions, TPluginOptions>> {
|
|
906
|
+
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context$1<TOptions, TPluginOptions>> {
|
|
983
907
|
#private;
|
|
984
908
|
refs: Refs;
|
|
985
909
|
/**
|
|
@@ -987,16 +911,86 @@ declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGe
|
|
|
987
911
|
* Delegates to getBaseTypeFromSchema internally and
|
|
988
912
|
* optionally adds a union with null.
|
|
989
913
|
*/
|
|
990
|
-
parse(props: SchemaProps): Schema[];
|
|
991
|
-
deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
992
|
-
find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
914
|
+
parse(props: SchemaProps$1): Schema[];
|
|
993
915
|
static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
994
|
-
static findInObject<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
995
916
|
static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
996
917
|
static combineObjects(tree: Schema[] | undefined): Schema[];
|
|
997
918
|
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
998
919
|
}
|
|
999
920
|
//#endregion
|
|
921
|
+
//#region ../plugin-oas/src/generators/createGenerator.d.ts
|
|
922
|
+
type CoreGenerator<TOptions extends PluginFactoryOptions> = {
|
|
923
|
+
name: string;
|
|
924
|
+
type: 'core';
|
|
925
|
+
operations: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
926
|
+
operation: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
927
|
+
schema: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
928
|
+
};
|
|
929
|
+
//#endregion
|
|
930
|
+
//#region ../plugin-oas/src/generators/createReactGenerator.d.ts
|
|
931
|
+
type ReactGenerator<TOptions extends PluginFactoryOptions> = {
|
|
932
|
+
name: string;
|
|
933
|
+
type: 'react';
|
|
934
|
+
Operations: (props: OperationsProps<TOptions>) => KubbNode;
|
|
935
|
+
Operation: (props: OperationProps<TOptions>) => KubbNode;
|
|
936
|
+
Schema: (props: SchemaProps<TOptions>) => KubbNode;
|
|
937
|
+
};
|
|
938
|
+
//#endregion
|
|
939
|
+
//#region ../plugin-oas/src/generators/types.d.ts
|
|
940
|
+
type OperationsProps<TOptions extends PluginFactoryOptions> = {
|
|
941
|
+
config: Config;
|
|
942
|
+
generator: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
943
|
+
plugin: Plugin<TOptions>;
|
|
944
|
+
operations: Array<Operation$1>;
|
|
945
|
+
};
|
|
946
|
+
type OperationProps<TOptions extends PluginFactoryOptions> = {
|
|
947
|
+
config: Config;
|
|
948
|
+
generator: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
949
|
+
plugin: Plugin<TOptions>;
|
|
950
|
+
operation: Operation$1;
|
|
951
|
+
};
|
|
952
|
+
type SchemaProps<TOptions extends PluginFactoryOptions> = {
|
|
953
|
+
config: Config;
|
|
954
|
+
generator: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
|
|
955
|
+
plugin: Plugin<TOptions>;
|
|
956
|
+
schema: {
|
|
957
|
+
name: string;
|
|
958
|
+
tree: Array<Schema>;
|
|
959
|
+
value: SchemaObject$1;
|
|
960
|
+
};
|
|
961
|
+
};
|
|
962
|
+
type Generator<TOptions extends PluginFactoryOptions> = CoreGenerator<TOptions> | ReactGenerator<TOptions>;
|
|
963
|
+
//#endregion
|
|
964
|
+
//#region ../plugin-oas/src/OperationGenerator.d.ts
|
|
965
|
+
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
966
|
+
fabric: Fabric;
|
|
967
|
+
oas: Oas;
|
|
968
|
+
exclude: Array<Exclude$1> | undefined;
|
|
969
|
+
include: Array<Include> | undefined;
|
|
970
|
+
override: Array<Override<TOptions>> | undefined;
|
|
971
|
+
contentType: contentType | undefined;
|
|
972
|
+
pluginManager: PluginManager;
|
|
973
|
+
/**
|
|
974
|
+
* Current plugin
|
|
975
|
+
*/
|
|
976
|
+
plugin: Plugin<TPluginOptions>;
|
|
977
|
+
mode: KubbFile.Mode;
|
|
978
|
+
};
|
|
979
|
+
declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context<TPluginOptions['resolvedOptions'], TPluginOptions>> {
|
|
980
|
+
#private;
|
|
981
|
+
getSchemas(operation: Operation$1, {
|
|
982
|
+
resolveName
|
|
983
|
+
}?: {
|
|
984
|
+
resolveName?: (name: string) => string;
|
|
985
|
+
}): OperationSchemas;
|
|
986
|
+
getOperations(): Promise<Array<{
|
|
987
|
+
path: string;
|
|
988
|
+
method: HttpMethod;
|
|
989
|
+
operation: Operation$1;
|
|
990
|
+
}>>;
|
|
991
|
+
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
992
|
+
}
|
|
993
|
+
//#endregion
|
|
1000
994
|
//#region src/types.d.ts
|
|
1001
995
|
type Options$1 = {
|
|
1002
996
|
/**
|
|
@@ -1100,5 +1094,5 @@ type ResolvedOptions = {
|
|
|
1100
1094
|
};
|
|
1101
1095
|
type PluginFaker = PluginFactoryOptions<'plugin-faker', Options$1, ResolvedOptions, never, ResolvePathOptions>;
|
|
1102
1096
|
//#endregion
|
|
1103
|
-
export { UserPluginWithLifeCycle as a,
|
|
1104
|
-
//# sourceMappingURL=types-
|
|
1097
|
+
export { UserPluginWithLifeCycle as a, Schema as i, PluginFaker as n, ReactGenerator as r, Options$1 as t };
|
|
1098
|
+
//# sourceMappingURL=types-CEWRTyrN.d.ts.map
|