@kubb/plugin-msw 4.1.4 → 4.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{components-Bcz4mvn3.cjs → components-CULOceYX.cjs} +34 -1
- package/dist/components-CULOceYX.cjs.map +1 -0
- package/dist/{components-Ba13vW1_.js → components-DcRndqwD.js} +29 -2
- package/dist/components-DcRndqwD.js.map +1 -0
- package/dist/components.cjs +3 -2
- package/dist/components.d.cts +21 -8
- package/dist/components.d.ts +21 -8
- package/dist/components.js +2 -2
- package/dist/{generators-DgwpklSC.cjs → generators-BpCsxN0-.cjs} +31 -7
- package/dist/generators-BpCsxN0-.cjs.map +1 -0
- package/dist/{generators-lMP39igU.js → generators-itHERcU2.js} +31 -8
- package/dist/generators-itHERcU2.js.map +1 -0
- package/dist/generators.cjs +2 -2
- package/dist/generators.d.cts +2 -2
- package/dist/generators.d.ts +2 -2
- package/dist/generators.js +2 -2
- package/dist/index.cjs +7 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +7 -7
- package/dist/index.js.map +1 -1
- package/dist/{types-BOMj2hjt.d.ts → types-8ZXwr93_.d.cts} +2 -2
- package/dist/{types-BdC96j80.d.ts → types-BB6ZV1EN.d.cts} +79 -123
- package/dist/{types-DLxzBV0T.d.cts → types-BLiYk9M7.d.ts} +79 -123
- package/dist/{types-DYAniEBx.d.cts → types-IbHKcY02.d.ts} +2 -2
- package/package.json +8 -10
- package/src/components/Handlers.tsx +1 -2
- package/src/components/Mock.tsx +1 -2
- package/src/components/MockWithFaker.tsx +1 -2
- package/src/components/Response.tsx +42 -0
- package/src/components/index.ts +1 -0
- package/src/generators/__snapshots__/createPet.ts +6 -0
- package/src/generators/__snapshots__/createPetFaker.ts +6 -0
- package/src/generators/__snapshots__/getPets.ts +15 -0
- package/src/generators/__snapshots__/getPetsFaker.ts +15 -0
- package/src/generators/__snapshots__/showPetById.ts +9 -0
- package/src/generators/handlersGenerator.tsx +5 -2
- package/src/generators/mswGenerator.tsx +37 -8
- package/src/plugin.ts +6 -9
- package/dist/components-Ba13vW1_.js.map +0 -1
- package/dist/components-Bcz4mvn3.cjs.map +0 -1
- package/dist/generators-DgwpklSC.cjs.map +0 -1
- package/dist/generators-lMP39igU.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import "./components-
|
|
2
|
-
import {
|
|
1
|
+
import "./components-DcRndqwD.js";
|
|
2
|
+
import { n as mswGenerator, t as handlersGenerator } from "./generators-itHERcU2.js";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import {
|
|
4
|
+
import { PluginManager, createPlugin, getBarrelFiles, getMode } from "@kubb/core";
|
|
5
5
|
import { camelCase } from "@kubb/core/transformers";
|
|
6
|
-
import { OperationGenerator, pluginOasName } from "@kubb/plugin-oas";
|
|
7
6
|
import { pluginFakerName } from "@kubb/plugin-faker";
|
|
7
|
+
import { OperationGenerator, pluginOasName } from "@kubb/plugin-oas";
|
|
8
8
|
import { pluginTsName } from "@kubb/plugin-ts";
|
|
9
9
|
|
|
10
10
|
//#region src/plugin.ts
|
|
@@ -29,7 +29,7 @@ const pluginMsw = createPlugin((options) => {
|
|
|
29
29
|
].filter(Boolean),
|
|
30
30
|
resolvePath(baseName, pathMode, options$1) {
|
|
31
31
|
const root = path.resolve(this.config.root, this.config.output.path);
|
|
32
|
-
if ((pathMode ??
|
|
32
|
+
if ((pathMode ?? getMode(path.resolve(root, output.path))) === "single")
|
|
33
33
|
/**
|
|
34
34
|
* when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
|
|
35
35
|
* Other plugins then need to call addOrAppend instead of just add from the fileManager class
|
|
@@ -56,7 +56,7 @@ const pluginMsw = createPlugin((options) => {
|
|
|
56
56
|
const [swaggerPlugin] = PluginManager.getDependedPlugins(this.plugins, [pluginOasName]);
|
|
57
57
|
const oas = await swaggerPlugin.context.getOas();
|
|
58
58
|
const root = path.resolve(this.config.root, this.config.output.path);
|
|
59
|
-
const mode =
|
|
59
|
+
const mode = getMode(path.resolve(root, output.path));
|
|
60
60
|
const files = await new OperationGenerator(this.plugin.options, {
|
|
61
61
|
oas,
|
|
62
62
|
pluginManager: this.pluginManager,
|
|
@@ -68,7 +68,7 @@ const pluginMsw = createPlugin((options) => {
|
|
|
68
68
|
mode
|
|
69
69
|
}).build(...generators);
|
|
70
70
|
await this.addFile(...files);
|
|
71
|
-
const barrelFiles = await this.fileManager.
|
|
71
|
+
const barrelFiles = await getBarrelFiles(this.fileManager.files, {
|
|
72
72
|
type: output.barrelType ?? "named",
|
|
73
73
|
root,
|
|
74
74
|
output,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["options","groupName: Group['name']"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\
|
|
1
|
+
{"version":3,"file":"index.js","names":["options","groupName: Group['name']"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { createPlugin, type Group, getBarrelFiles, getMode, type Plugin, PluginManager } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\n\nimport { pluginFakerName } from '@kubb/plugin-faker'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { handlersGenerator, mswGenerator } from './generators'\nimport type { PluginMsw } from './types.ts'\n\nexport const pluginMswName = 'plugin-msw' satisfies PluginMsw['name']\n\nexport const pluginMsw = createPlugin<PluginMsw>((options) => {\n const {\n output = { path: 'handlers', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n transformers = {},\n handlers = false,\n parser = 'data',\n generators = [mswGenerator, handlers ? handlersGenerator : undefined].filter(Boolean),\n contentType,\n baseURL,\n } = options\n\n return {\n name: pluginMswName,\n options: {\n output,\n parser,\n group,\n baseURL,\n },\n pre: [pluginOasName, pluginTsName, parser === 'faker' ? pluginFakerName : undefined].filter(Boolean),\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 suffix: type ? 'handler' : undefined,\n isFile: type === 'file',\n })\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build(...generators)\n await this.addFile(...files)\n\n const barrelFiles = await getBarrelFiles(this.fileManager.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;AAWA,MAAa,gBAAgB;AAE7B,MAAa,YAAY,cAAyB,YAAY;CAC5D,MAAM,EACJ,SAAS;EAAE,MAAM;EAAY,YAAY;EAAS,EAClD,OACA,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,eAAe,EAAE,EACjB,WAAW,OACX,SAAS,QACT,aAAa,CAAC,cAAc,WAAW,oBAAoB,OAAU,CAAC,OAAO,QAAQ,EACrF,aACA,YACE;AAEJ,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA;GACA;GACA;GACD;EACD,KAAK;GAAC;GAAe;GAAc,WAAW,UAAU,kBAAkB;GAAU,CAAC,OAAO,QAAQ;EACpG,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,YAAY;IAC3B,QAAQ,SAAS;IAClB,CAAC;AAEF,OAAI,KACF,QAAO,cAAc,OAAO,cAAc,KAAK,IAAI;AAGrD,UAAO;;EAET,MAAM,aAAa;GACjB,MAAM,CAAC,iBAAiD,cAAc,mBAAyC,KAAK,SAAS,CAAC,cAAc,CAAC;GAE7I,MAAM,MAAM,MAAM,cAAc,QAAQ,QAAQ;GAChD,MAAM,OAAO,KAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;GACpE,MAAM,OAAO,QAAQ,KAAK,QAAQ,MAAM,OAAO,KAAK,CAAC;GAarD,MAAM,QAAQ,MAXa,IAAI,mBAAmB,KAAK,OAAO,SAAS;IACrE;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CAAC,CAEqC,MAAM,GAAG,WAAW;AAC3D,SAAM,KAAK,QAAQ,GAAG,MAAM;GAE5B,MAAM,cAAc,MAAM,eAAe,KAAK,YAAY,OAAO;IAC/D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACD,QAAQ,KAAK;IACd,CAAC;AAEF,SAAM,KAAK,QAAQ,GAAG,YAAY;;EAErC;EACD"}
|
|
@@ -9,5 +9,5 @@ type SchemaObject$1 = OasTypes.SchemaObject & {
|
|
|
9
9
|
$ref?: string;
|
|
10
10
|
};
|
|
11
11
|
//#endregion
|
|
12
|
-
export {
|
|
13
|
-
//# sourceMappingURL=types-
|
|
12
|
+
export { contentType as a, SchemaObject$1 as i, OasTypes as n, Operation$1 as r, HttpMethod as t };
|
|
13
|
+
//# sourceMappingURL=types-8ZXwr93_.d.cts.map
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as contentType, i as SchemaObject$1, n as OasTypes, r as Operation$1, t as HttpMethod } from "./types-8ZXwr93_.cjs";
|
|
2
2
|
import { OASDocument, SchemaObject, User } from "oas/types";
|
|
3
3
|
import { Operation } from "oas/operation";
|
|
4
4
|
import { OpenAPIV3 } from "openapi-types";
|
|
5
5
|
import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
|
|
6
6
|
import BaseOas from "oas";
|
|
7
7
|
import { ConsolaInstance, LogLevel } from "consola";
|
|
8
|
+
import { FileManager } from "@kubb/fabric-core";
|
|
8
9
|
|
|
9
10
|
//#region ../oas/src/Oas.d.ts
|
|
10
11
|
type Options$3 = {
|
|
@@ -39,17 +40,17 @@ declare class Oas<const TOAS = unknown> extends BaseOas {
|
|
|
39
40
|
* Abstract class that contains the building blocks for plugins to create their own Generator
|
|
40
41
|
* @link idea based on https://github.com/colinhacks/zod/blob/master/src/types.ts#L137
|
|
41
42
|
*/
|
|
42
|
-
declare abstract class BaseGenerator<TOptions = unknown, TContext = unknown> {
|
|
43
|
+
declare abstract class BaseGenerator<TOptions$1 = unknown, TContext = unknown> {
|
|
43
44
|
#private;
|
|
44
|
-
constructor(options?: TOptions, context?: TContext);
|
|
45
|
-
get options(): TOptions;
|
|
45
|
+
constructor(options?: TOptions$1, context?: TContext);
|
|
46
|
+
get options(): TOptions$1;
|
|
46
47
|
get context(): TContext;
|
|
47
|
-
set options(options: TOptions);
|
|
48
|
+
set options(options: TOptions$1);
|
|
48
49
|
abstract build(...params: unknown[]): unknown;
|
|
49
50
|
}
|
|
50
51
|
//#endregion
|
|
51
52
|
//#region ../core/src/fs/types.d.ts
|
|
52
|
-
type BasePath<T extends string = string> = `${T}/`;
|
|
53
|
+
type BasePath<T$1 extends string = string> = `${T$1}/`;
|
|
53
54
|
type Import = {
|
|
54
55
|
/**
|
|
55
56
|
* Import name to be used
|
|
@@ -123,7 +124,7 @@ type BaseName = `${string}.${string}`;
|
|
|
123
124
|
* Path will be full qualified path to a specified file
|
|
124
125
|
*/
|
|
125
126
|
type Path = string;
|
|
126
|
-
type AdvancedPath<T extends BaseName = BaseName> = `${BasePath}${T}`;
|
|
127
|
+
type AdvancedPath<T$1 extends BaseName = BaseName> = `${BasePath}${T$1}`;
|
|
127
128
|
type OptionalPath = Path | undefined | null;
|
|
128
129
|
type File<TMeta extends object = object> = {
|
|
129
130
|
/**
|
|
@@ -212,9 +213,7 @@ type Logger = {
|
|
|
212
213
|
};
|
|
213
214
|
//#endregion
|
|
214
215
|
//#region ../core/src/utils/types.d.ts
|
|
215
|
-
type PossiblePromise<T> = Promise<T> | T;
|
|
216
|
-
type ArrayWithLength<T extends number, U extends any[] = []> = U['length'] extends T ? U : ArrayWithLength<T, [true, ...U]>;
|
|
217
|
-
type GreaterThan<T extends number, U extends number> = ArrayWithLength<U> extends [...ArrayWithLength<T>, ...infer _] ? false : true;
|
|
216
|
+
type PossiblePromise<T$1> = Promise<T$1> | T$1;
|
|
218
217
|
//#endregion
|
|
219
218
|
//#region ../core/src/types.d.ts
|
|
220
219
|
type InputPath = {
|
|
@@ -327,11 +326,11 @@ TName extends string = string,
|
|
|
327
326
|
/**
|
|
328
327
|
* Options of the plugin.
|
|
329
328
|
*/
|
|
330
|
-
TOptions extends object = object,
|
|
329
|
+
TOptions$1 extends object = object,
|
|
331
330
|
/**
|
|
332
331
|
* Options of the plugin that can be used later on, see `options` inside your plugin config.
|
|
333
332
|
*/
|
|
334
|
-
TResolvedOptions extends object = TOptions,
|
|
333
|
+
TResolvedOptions extends object = TOptions$1,
|
|
335
334
|
/**
|
|
336
335
|
* Context that you want to expose to other plugins.
|
|
337
336
|
*/
|
|
@@ -345,23 +344,23 @@ TResolvePathOptions extends object = object> = {
|
|
|
345
344
|
* Same behaviour like what has been done with `QueryKey` in `@tanstack/react-query`
|
|
346
345
|
*/
|
|
347
346
|
key: PluginKey<TName | string>;
|
|
348
|
-
options: TOptions;
|
|
347
|
+
options: TOptions$1;
|
|
349
348
|
resolvedOptions: TResolvedOptions;
|
|
350
349
|
context: TContext;
|
|
351
350
|
resolvePathOptions: TResolvePathOptions;
|
|
352
351
|
};
|
|
353
352
|
type PluginKey<TName> = [name: TName, identifier?: string | number];
|
|
354
|
-
type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
353
|
+
type UserPlugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
355
354
|
/**
|
|
356
355
|
* Unique name used for the plugin
|
|
357
356
|
* The name of the plugin follows the format scope:foo-bar or foo-bar, adding scope: can avoid naming conflicts with other plugins.
|
|
358
357
|
* @example @kubb/typescript
|
|
359
358
|
*/
|
|
360
|
-
name: TOptions['name'];
|
|
359
|
+
name: TOptions$1['name'];
|
|
361
360
|
/**
|
|
362
361
|
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
363
362
|
*/
|
|
364
|
-
options: TOptions['resolvedOptions'];
|
|
363
|
+
options: TOptions$1['resolvedOptions'];
|
|
365
364
|
/**
|
|
366
365
|
* Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin will be executed after these plugins.
|
|
367
366
|
* Can be used to validate dependent plugins.
|
|
@@ -371,23 +370,23 @@ type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
|
|
|
371
370
|
* Specifies the succeeding plugins for the current plugin. You can pass an array of succeeding plugin names, and the current plugin will be executed before these plugins.
|
|
372
371
|
*/
|
|
373
372
|
post?: Array<string>;
|
|
374
|
-
} & (TOptions['context'] extends never ? {
|
|
373
|
+
} & (TOptions$1['context'] extends never ? {
|
|
375
374
|
context?: never;
|
|
376
375
|
} : {
|
|
377
|
-
context: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['context'];
|
|
376
|
+
context: (this: TOptions$1['name'] extends 'core' ? null : Omit<PluginContext<TOptions$1>, 'addFile'>) => TOptions$1['context'];
|
|
378
377
|
});
|
|
379
|
-
type UserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions> & PluginLifecycle<TOptions>;
|
|
380
|
-
type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
378
|
+
type UserPluginWithLifeCycle<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions$1> & PluginLifecycle<TOptions$1>;
|
|
379
|
+
type Plugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
381
380
|
/**
|
|
382
381
|
* Unique name used for the plugin
|
|
383
382
|
* @example @kubb/typescript
|
|
384
383
|
*/
|
|
385
|
-
name: TOptions['name'];
|
|
384
|
+
name: TOptions$1['name'];
|
|
386
385
|
/**
|
|
387
386
|
* Internal key used when a developer uses more than one of the same plugin
|
|
388
387
|
* @private
|
|
389
388
|
*/
|
|
390
|
-
key: TOptions['key'];
|
|
389
|
+
key: TOptions$1['key'];
|
|
391
390
|
/**
|
|
392
391
|
* Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin will be executed after these plugins.
|
|
393
392
|
* Can be used to validate dependent plugins.
|
|
@@ -400,49 +399,49 @@ type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
|
400
399
|
/**
|
|
401
400
|
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
402
401
|
*/
|
|
403
|
-
options: TOptions['resolvedOptions'];
|
|
404
|
-
} & (TOptions['context'] extends never ? {
|
|
402
|
+
options: TOptions$1['resolvedOptions'];
|
|
403
|
+
} & (TOptions$1['context'] extends never ? {
|
|
405
404
|
context?: never;
|
|
406
405
|
} : {
|
|
407
|
-
context: TOptions['context'];
|
|
406
|
+
context: TOptions$1['context'];
|
|
408
407
|
});
|
|
409
|
-
type PluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & PluginLifecycle<TOptions>;
|
|
410
|
-
type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
408
|
+
type PluginWithLifeCycle<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions$1> & PluginLifecycle<TOptions$1>;
|
|
409
|
+
type PluginLifecycle<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
411
410
|
/**
|
|
412
411
|
* Start of the lifecycle of a plugin.
|
|
413
412
|
* @type hookParallel
|
|
414
413
|
*/
|
|
415
|
-
buildStart?: (this: PluginContext<TOptions>, Config: Config) => PossiblePromise<void>;
|
|
414
|
+
buildStart?: (this: PluginContext<TOptions$1>, Config: Config) => PossiblePromise<void>;
|
|
416
415
|
/**
|
|
417
416
|
* Resolve to a Path based on a baseName(example: `./Pet.ts`) and directory(example: `./models`).
|
|
418
417
|
* Options can als be included.
|
|
419
418
|
* @type hookFirst
|
|
420
419
|
* @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
|
|
421
420
|
*/
|
|
422
|
-
resolvePath?: (this: PluginContext<TOptions>, baseName: BaseName, mode?: Mode, options?: TOptions['resolvePathOptions']) => OptionalPath;
|
|
421
|
+
resolvePath?: (this: PluginContext<TOptions$1>, baseName: BaseName, mode?: Mode, options?: TOptions$1['resolvePathOptions']) => OptionalPath;
|
|
423
422
|
/**
|
|
424
423
|
* Resolve to a name based on a string.
|
|
425
424
|
* Useful when converting to PascalCase or camelCase.
|
|
426
425
|
* @type hookFirst
|
|
427
426
|
* @example ('pet') => 'Pet'
|
|
428
427
|
*/
|
|
429
|
-
resolveName?: (this: PluginContext<TOptions>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
428
|
+
resolveName?: (this: PluginContext<TOptions$1>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
430
429
|
/**
|
|
431
430
|
* End of the plugin lifecycle.
|
|
432
431
|
* @type hookParallel
|
|
433
432
|
*/
|
|
434
|
-
buildEnd?: (this: PluginContext<TOptions>) => PossiblePromise<void>;
|
|
433
|
+
buildEnd?: (this: PluginContext<TOptions$1>) => PossiblePromise<void>;
|
|
435
434
|
};
|
|
436
435
|
type PluginLifecycleHooks = keyof PluginLifecycle;
|
|
437
|
-
type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
|
|
438
|
-
type ResolvePathParams<TOptions = object> = {
|
|
436
|
+
type PluginParameter<H$1 extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H$1]>;
|
|
437
|
+
type ResolvePathParams<TOptions$1 = object> = {
|
|
439
438
|
pluginKey?: Plugin['key'];
|
|
440
439
|
baseName: BaseName;
|
|
441
440
|
mode?: Mode;
|
|
442
441
|
/**
|
|
443
442
|
* Options to be passed to 'resolvePath' 3th parameter
|
|
444
443
|
*/
|
|
445
|
-
options?: TOptions;
|
|
444
|
+
options?: TOptions$1;
|
|
446
445
|
};
|
|
447
446
|
type ResolveNameParams = {
|
|
448
447
|
name: string;
|
|
@@ -455,12 +454,15 @@ type ResolveNameParams = {
|
|
|
455
454
|
*/
|
|
456
455
|
type?: 'file' | 'function' | 'type' | 'const';
|
|
457
456
|
};
|
|
458
|
-
type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
457
|
+
type PluginContext<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
459
458
|
config: Config;
|
|
459
|
+
/**
|
|
460
|
+
* @deprecated
|
|
461
|
+
*/
|
|
460
462
|
fileManager: FileManager;
|
|
461
463
|
pluginManager: PluginManager;
|
|
462
464
|
addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
|
|
463
|
-
resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => OptionalPath;
|
|
465
|
+
resolvePath: (params: ResolvePathParams<TOptions$1['resolvePathOptions']>) => OptionalPath;
|
|
464
466
|
resolveName: (params: ResolveNameParams) => string;
|
|
465
467
|
logger: Logger;
|
|
466
468
|
/**
|
|
@@ -470,12 +472,12 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
|
|
|
470
472
|
/**
|
|
471
473
|
* Current plugin
|
|
472
474
|
*/
|
|
473
|
-
plugin: Plugin<TOptions>;
|
|
475
|
+
plugin: Plugin<TOptions$1>;
|
|
474
476
|
};
|
|
475
477
|
/**
|
|
476
478
|
* Specify the export location for the files and define the behavior of the output
|
|
477
479
|
*/
|
|
478
|
-
type Output<TOptions> = {
|
|
480
|
+
type Output<TOptions$1> = {
|
|
479
481
|
/**
|
|
480
482
|
* Path to the output folder or file that will contain the generated code
|
|
481
483
|
*/
|
|
@@ -488,11 +490,11 @@ type Output<TOptions> = {
|
|
|
488
490
|
/**
|
|
489
491
|
* Add a banner text in the beginning of every file
|
|
490
492
|
*/
|
|
491
|
-
banner?: string | ((options: TOptions) => string);
|
|
493
|
+
banner?: string | ((options: TOptions$1) => string);
|
|
492
494
|
/**
|
|
493
495
|
* Add a footer text in the beginning of every file
|
|
494
496
|
*/
|
|
495
|
-
footer?: string | ((options: TOptions) => string);
|
|
497
|
+
footer?: string | ((options: TOptions$1) => string);
|
|
496
498
|
};
|
|
497
499
|
type GroupContext = {
|
|
498
500
|
group: string;
|
|
@@ -508,73 +510,19 @@ type Group = {
|
|
|
508
510
|
name?: (context: GroupContext) => string;
|
|
509
511
|
};
|
|
510
512
|
//#endregion
|
|
511
|
-
//#region ../core/src/FileManager.d.ts
|
|
512
|
-
type FileMetaBase = {
|
|
513
|
-
pluginKey?: Plugin['key'];
|
|
514
|
-
};
|
|
515
|
-
type AddResult<T extends Array<File>> = Promise<Awaited<GreaterThan<T['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
|
|
516
|
-
type AddIndexesProps = {
|
|
517
|
-
type: BarrelType | false | undefined;
|
|
518
|
-
/**
|
|
519
|
-
* Root based on root and output.path specified in the config
|
|
520
|
-
*/
|
|
521
|
-
root: string;
|
|
522
|
-
/**
|
|
523
|
-
* Output for plugin
|
|
524
|
-
*/
|
|
525
|
-
output: {
|
|
526
|
-
path: string;
|
|
527
|
-
};
|
|
528
|
-
group?: {
|
|
529
|
-
output: string;
|
|
530
|
-
exportAs: string;
|
|
531
|
-
};
|
|
532
|
-
logger?: Logger;
|
|
533
|
-
meta?: FileMetaBase;
|
|
534
|
-
};
|
|
535
|
-
type WriteFilesProps = {
|
|
536
|
-
root: Config['root'];
|
|
537
|
-
extension?: Record<Extname, Extname | ''>;
|
|
538
|
-
logger?: Logger;
|
|
539
|
-
dryRun?: boolean;
|
|
540
|
-
};
|
|
541
|
-
declare class FileManager {
|
|
542
|
-
#private;
|
|
543
|
-
constructor();
|
|
544
|
-
add<T extends Array<File> = Array<File>>(...files: T): AddResult<T>;
|
|
545
|
-
getByPath(path: Path): Promise<ResolvedFile | null>;
|
|
546
|
-
deleteByPath(path: Path): Promise<void>;
|
|
547
|
-
clear(): Promise<void>;
|
|
548
|
-
getFiles(): Promise<Array<ResolvedFile>>;
|
|
549
|
-
processFiles({
|
|
550
|
-
dryRun,
|
|
551
|
-
root,
|
|
552
|
-
extension,
|
|
553
|
-
logger
|
|
554
|
-
}: WriteFilesProps): Promise<Array<ResolvedFile>>;
|
|
555
|
-
getBarrelFiles({
|
|
556
|
-
type,
|
|
557
|
-
meta,
|
|
558
|
-
root,
|
|
559
|
-
output,
|
|
560
|
-
logger
|
|
561
|
-
}: AddIndexesProps): Promise<File[]>;
|
|
562
|
-
static getMode(path: string | undefined | null): Mode;
|
|
563
|
-
}
|
|
564
|
-
//#endregion
|
|
565
513
|
//#region ../core/src/PluginManager.d.ts
|
|
566
514
|
type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
|
567
515
|
type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
|
|
568
|
-
type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
516
|
+
type Executer<H$1 extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
569
517
|
message: string;
|
|
570
518
|
strategy: Strategy;
|
|
571
|
-
hookName: H;
|
|
519
|
+
hookName: H$1;
|
|
572
520
|
plugin: Plugin;
|
|
573
521
|
parameters?: unknown[] | undefined;
|
|
574
522
|
output?: unknown;
|
|
575
523
|
};
|
|
576
|
-
type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
|
|
577
|
-
type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
|
|
524
|
+
type ParseResult<H$1 extends PluginLifecycleHooks> = RequiredPluginLifecycle[H$1];
|
|
525
|
+
type SafeParseResult<H$1 extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H$1>>> = {
|
|
578
526
|
result: Result;
|
|
579
527
|
plugin: Plugin;
|
|
580
528
|
};
|
|
@@ -590,16 +538,19 @@ type Events = {
|
|
|
590
538
|
executed: [executer: Executer];
|
|
591
539
|
error: [error: Error];
|
|
592
540
|
};
|
|
593
|
-
type GetFileProps<TOptions = object> = {
|
|
541
|
+
type GetFileProps<TOptions$1 = object> = {
|
|
594
542
|
name: string;
|
|
595
543
|
mode?: Mode;
|
|
596
544
|
extname: Extname;
|
|
597
545
|
pluginKey: Plugin['key'];
|
|
598
|
-
options?: TOptions;
|
|
546
|
+
options?: TOptions$1;
|
|
599
547
|
};
|
|
600
548
|
declare class PluginManager {
|
|
601
549
|
#private;
|
|
602
550
|
readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
|
|
551
|
+
/**
|
|
552
|
+
* @deprecated do not use from pluginManager
|
|
553
|
+
*/
|
|
603
554
|
readonly fileManager: FileManager;
|
|
604
555
|
readonly events: EventEmitter<Events>;
|
|
605
556
|
readonly config: Config;
|
|
@@ -708,6 +659,11 @@ declare class PluginManager {
|
|
|
708
659
|
static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "buildEnd"];
|
|
709
660
|
}
|
|
710
661
|
//#endregion
|
|
662
|
+
//#region ../core/src/FileManager.d.ts
|
|
663
|
+
type FileMetaBase = {
|
|
664
|
+
pluginKey?: Plugin['key'];
|
|
665
|
+
};
|
|
666
|
+
//#endregion
|
|
711
667
|
//#region ../plugin-oas/src/SchemaMapper.d.ts
|
|
712
668
|
type SchemaKeywordMapper = {
|
|
713
669
|
object: {
|
|
@@ -1001,12 +957,12 @@ type ByContentType = {
|
|
|
1001
957
|
};
|
|
1002
958
|
type Exclude$1 = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
1003
959
|
type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
1004
|
-
type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
|
|
1005
|
-
options: Partial<TOptions>;
|
|
960
|
+
type Override<TOptions$1> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
|
|
961
|
+
options: Partial<TOptions$1>;
|
|
1006
962
|
};
|
|
1007
963
|
//#endregion
|
|
1008
964
|
//#region ../plugin-oas/src/SchemaGenerator.d.ts
|
|
1009
|
-
type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
965
|
+
type Context$1<TOptions$1, TPluginOptions extends PluginFactoryOptions> = {
|
|
1010
966
|
oas: Oas;
|
|
1011
967
|
pluginManager: PluginManager;
|
|
1012
968
|
/**
|
|
@@ -1015,7 +971,7 @@ type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
|
1015
971
|
plugin: Plugin<TPluginOptions>;
|
|
1016
972
|
mode: Mode;
|
|
1017
973
|
include?: Array<'schemas' | 'responses' | 'requestBodies'>;
|
|
1018
|
-
override: Array<Override<TOptions>> | undefined;
|
|
974
|
+
override: Array<Override<TOptions$1>> | undefined;
|
|
1019
975
|
contentType?: contentType;
|
|
1020
976
|
output?: string;
|
|
1021
977
|
};
|
|
@@ -1046,7 +1002,7 @@ type SchemaProps$1 = {
|
|
|
1046
1002
|
name?: string;
|
|
1047
1003
|
parentName?: string;
|
|
1048
1004
|
};
|
|
1049
|
-
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context$1<TOptions, TPluginOptions>> {
|
|
1005
|
+
declare class SchemaGenerator<TOptions$1 extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions$1, Context$1<TOptions$1, TPluginOptions>> {
|
|
1050
1006
|
#private;
|
|
1051
1007
|
refs: Refs;
|
|
1052
1008
|
/**
|
|
@@ -1065,39 +1021,39 @@ declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGe
|
|
|
1065
1021
|
}
|
|
1066
1022
|
//#endregion
|
|
1067
1023
|
//#region ../plugin-oas/src/generator.d.ts
|
|
1068
|
-
type OperationsProps<TOptions extends PluginFactoryOptions> = {
|
|
1069
|
-
instance: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
1070
|
-
options: TOptions['resolvedOptions'];
|
|
1024
|
+
type OperationsProps<TOptions$1 extends PluginFactoryOptions> = {
|
|
1025
|
+
instance: Omit<OperationGenerator<TOptions$1>, 'build'>;
|
|
1026
|
+
options: TOptions$1['resolvedOptions'];
|
|
1071
1027
|
operations: Array<Operation$1>;
|
|
1072
1028
|
};
|
|
1073
|
-
type OperationProps<TOptions extends PluginFactoryOptions> = {
|
|
1074
|
-
instance: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
1075
|
-
options: TOptions['resolvedOptions'];
|
|
1029
|
+
type OperationProps<TOptions$1 extends PluginFactoryOptions> = {
|
|
1030
|
+
instance: Omit<OperationGenerator<TOptions$1>, 'build'>;
|
|
1031
|
+
options: TOptions$1['resolvedOptions'];
|
|
1076
1032
|
operation: Operation$1;
|
|
1077
1033
|
};
|
|
1078
|
-
type SchemaProps<TOptions extends PluginFactoryOptions> = {
|
|
1079
|
-
instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
|
|
1080
|
-
options: TOptions['resolvedOptions'];
|
|
1034
|
+
type SchemaProps<TOptions$1 extends PluginFactoryOptions> = {
|
|
1035
|
+
instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions$1>, 'build'>;
|
|
1036
|
+
options: TOptions$1['resolvedOptions'];
|
|
1081
1037
|
schema: {
|
|
1082
1038
|
name: string;
|
|
1083
1039
|
tree: Array<Schema>;
|
|
1084
1040
|
value: SchemaObject$1;
|
|
1085
1041
|
};
|
|
1086
1042
|
};
|
|
1087
|
-
type GeneratorOptions<TOptions extends PluginFactoryOptions> = {
|
|
1043
|
+
type GeneratorOptions<TOptions$1 extends PluginFactoryOptions> = {
|
|
1088
1044
|
name: string;
|
|
1089
|
-
operations?: (this: GeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => Promise<File[]>;
|
|
1090
|
-
operation?: (this: GeneratorOptions<TOptions>, props: OperationProps<TOptions>) => Promise<File[]>;
|
|
1091
|
-
schema?: (this: GeneratorOptions<TOptions>, props: SchemaProps<TOptions>) => Promise<File[]>;
|
|
1045
|
+
operations?: (this: GeneratorOptions<TOptions$1>, props: OperationsProps<TOptions$1>) => Promise<File[]>;
|
|
1046
|
+
operation?: (this: GeneratorOptions<TOptions$1>, props: OperationProps<TOptions$1>) => Promise<File[]>;
|
|
1047
|
+
schema?: (this: GeneratorOptions<TOptions$1>, props: SchemaProps<TOptions$1>) => Promise<File[]>;
|
|
1092
1048
|
};
|
|
1093
|
-
type Generator<TOptions extends PluginFactoryOptions> = GeneratorOptions<TOptions>;
|
|
1049
|
+
type Generator<TOptions$1 extends PluginFactoryOptions> = GeneratorOptions<TOptions$1>;
|
|
1094
1050
|
//#endregion
|
|
1095
1051
|
//#region ../plugin-oas/src/OperationGenerator.d.ts
|
|
1096
|
-
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
1052
|
+
type Context<TOptions$1, TPluginOptions extends PluginFactoryOptions> = {
|
|
1097
1053
|
oas: Oas;
|
|
1098
1054
|
exclude: Array<Exclude$1> | undefined;
|
|
1099
1055
|
include: Array<Include> | undefined;
|
|
1100
|
-
override: Array<Override<TOptions>> | undefined;
|
|
1056
|
+
override: Array<Override<TOptions$1>> | undefined;
|
|
1101
1057
|
contentType: contentType | undefined;
|
|
1102
1058
|
pluginManager: PluginManager;
|
|
1103
1059
|
/**
|
|
@@ -1181,5 +1137,5 @@ type ResolvedOptions = {
|
|
|
1181
1137
|
};
|
|
1182
1138
|
type PluginMsw = PluginFactoryOptions<'plugin-msw', Options$1, ResolvedOptions, never, ResolvePathOptions>;
|
|
1183
1139
|
//#endregion
|
|
1184
|
-
export { Generator, Options$1 as
|
|
1185
|
-
//# sourceMappingURL=types-
|
|
1140
|
+
export { UserPluginWithLifeCycle as i, PluginMsw as n, Generator as r, Options$1 as t };
|
|
1141
|
+
//# sourceMappingURL=types-BB6ZV1EN.d.cts.map
|