@kubb/plugin-ts 3.0.0-alpha.9 → 3.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -5
- package/dist/{chunk-UVAKTXUA.js → chunk-AG2BUY33.js} +86 -398
- package/dist/chunk-AG2BUY33.js.map +1 -0
- package/dist/chunk-L7QZ6DBL.cjs +332 -0
- package/dist/chunk-L7QZ6DBL.cjs.map +1 -0
- package/dist/chunk-QZ2DBYXR.js +303 -0
- package/dist/chunk-QZ2DBYXR.js.map +1 -0
- package/dist/{chunk-PV5Q7I5O.cjs → chunk-XMTK3ZZE.cjs} +185 -470
- package/dist/chunk-XMTK3ZZE.cjs.map +1 -0
- package/dist/components.cjs +11 -12
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +14 -44
- package/dist/components.d.ts +14 -44
- package/dist/components.js +2 -16
- package/dist/components.js.map +1 -1
- package/dist/generators.cjs +17 -0
- package/dist/generators.cjs.map +1 -0
- package/dist/generators.d.cts +10 -0
- package/dist/generators.d.ts +10 -0
- package/dist/generators.js +4 -0
- package/dist/generators.js.map +1 -0
- package/dist/index.cjs +12 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -123
- package/dist/index.d.ts +4 -123
- package/dist/index.js +3 -9
- package/dist/index.js.map +1 -1
- package/dist/types-DoCOabdx.d.cts +98 -0
- package/dist/types-DoCOabdx.d.ts +98 -0
- package/package.json +21 -15
- package/src/components/OasType.tsx +3 -50
- package/src/components/{Schema.tsx → Type.tsx} +19 -54
- package/src/components/index.ts +1 -2
- package/src/generators/__snapshots__/bodyUploadFileApiAssetsPost.ts +6 -0
- package/src/generators/__snapshots__/catTypeAsConst.ts +11 -0
- package/src/generators/__snapshots__/createPet.ts +41 -0
- package/src/generators/__snapshots__/createPetWithUnknownTypeUnknown.ts +41 -0
- package/src/generators/__snapshots__/deletePet.ts +5 -0
- package/src/generators/__snapshots__/dogTypeAsConst.ts +11 -0
- package/src/generators/__snapshots__/enumAllOf.ts +10 -0
- package/src/generators/__snapshots__/enumArray.ts +19 -0
- package/src/generators/__snapshots__/enumInObject.ts +13 -0
- package/src/generators/__snapshots__/enumItems.ts +8 -0
- package/src/generators/__snapshots__/enumNames.ts +6 -0
- package/src/generators/__snapshots__/enumNamesConst.ts +6 -0
- package/src/generators/__snapshots__/enumNamesLiteral.ts +3 -0
- package/src/generators/__snapshots__/enumNamesPascalConst.ts +8 -0
- package/src/generators/__snapshots__/enumNamesType.ts +8 -0
- package/src/generators/__snapshots__/enumNullableMember.ts +8 -0
- package/src/generators/__snapshots__/enumNullableType.ts +8 -0
- package/src/generators/__snapshots__/enumString.ts +10 -0
- package/src/generators/__snapshots__/enumVarNamesType.ts +8 -0
- package/src/generators/__snapshots__/getPets.ts +27 -0
- package/src/generators/__snapshots__/mixedValueTypeConst.ts +9 -0
- package/src/generators/__snapshots__/nullConstNull.ts +7 -0
- package/src/generators/__snapshots__/numberValueConst.ts +9 -0
- package/src/generators/__snapshots__/petMapper.ts +15 -0
- package/src/generators/__snapshots__/petQuestionToken.ts +19 -0
- package/src/generators/__snapshots__/petQuestionTokenAndUndefined.ts +19 -0
- package/src/generators/__snapshots__/petUndefined.ts +19 -0
- package/src/generators/__snapshots__/pets.ts +14 -0
- package/src/generators/__snapshots__/petsStoreAdvancedDiscriminator.ts +31 -0
- package/src/generators/__snapshots__/petsStoreDiscriminator.ts +13 -0
- package/src/generators/__snapshots__/petsStoreRef.ts +1 -0
- package/src/generators/__snapshots__/plainDateDate.ts +1 -0
- package/src/generators/__snapshots__/plainDateString.ts +1 -0
- package/src/generators/__snapshots__/plainEmail.ts +1 -0
- package/src/generators/__snapshots__/plainFile.ts +1 -0
- package/src/generators/__snapshots__/plainTimeDate.ts +1 -0
- package/src/generators/__snapshots__/plainUuid.ts +1 -0
- package/src/generators/__snapshots__/readOnly.ts +20 -0
- package/src/{components/__snapshots__/Schema → generators/__snapshots__}/showPetById.ts +9 -9
- package/src/generators/__snapshots__/stringValueConst.ts +9 -0
- package/src/generators/index.ts +2 -0
- package/src/generators/oasGenerator.tsx +29 -0
- package/src/generators/typeGenerator.tsx +200 -0
- package/src/parser/index.ts +12 -3
- package/src/plugin.ts +26 -33
- package/src/types.ts +16 -52
- package/dist/chunk-PV5Q7I5O.cjs.map +0 -1
- package/dist/chunk-SEH6NUCX.cjs +0 -42
- package/dist/chunk-SEH6NUCX.cjs.map +0 -1
- package/dist/chunk-TTGZBH7H.js +0 -42
- package/dist/chunk-TTGZBH7H.js.map +0 -1
- package/dist/chunk-UVAKTXUA.js.map +0 -1
- package/dist/oas.cjs +0 -7
- package/dist/oas.cjs.map +0 -1
- package/dist/oas.d.cts +0 -1
- package/dist/oas.d.ts +0 -1
- package/dist/oas.js +0 -7
- package/dist/oas.js.map +0 -1
- package/src/OperationGenerator.tsx +0 -49
- package/src/SchemaGenerator.tsx +0 -31
- package/src/components/OperationSchema.tsx +0 -161
- package/src/components/__snapshots__/Schema/pets.ts +0 -27
- package/src/oas/index.ts +0 -1
package/dist/components.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { OasTypes } from '@kubb/oas';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
+
import { Schema } from '@kubb/plugin-oas';
|
|
4
|
+
import { P as PluginTs } from './types-DoCOabdx.js';
|
|
5
|
+
import '@kubb/core';
|
|
6
|
+
import 'typescript';
|
|
3
7
|
|
|
4
|
-
type
|
|
8
|
+
type Props$1 = {
|
|
5
9
|
/**
|
|
6
10
|
* Name of the function
|
|
7
11
|
*/
|
|
@@ -9,52 +13,18 @@ type TemplateProps = {
|
|
|
9
13
|
typeName: string;
|
|
10
14
|
api: OasTypes.OASDocument;
|
|
11
15
|
};
|
|
12
|
-
declare function
|
|
13
|
-
declare const defaultTemplates: {
|
|
14
|
-
readonly default: typeof Template;
|
|
15
|
-
};
|
|
16
|
-
type Props$2 = {
|
|
17
|
-
name: string;
|
|
18
|
-
typeName: string;
|
|
19
|
-
/**
|
|
20
|
-
* This will make it possible to override the default behaviour.
|
|
21
|
-
*/
|
|
22
|
-
Template?: React.ComponentType<React.ComponentProps<typeof Template>>;
|
|
23
|
-
};
|
|
24
|
-
declare function OasType({ name, typeName, Template }: Props$2): ReactNode;
|
|
25
|
-
declare namespace OasType {
|
|
26
|
-
var File: ({ name, typeName, templates }: FileProps$2) => ReactNode;
|
|
27
|
-
var templates: {
|
|
28
|
-
readonly default: typeof Template;
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
type FileProps$2 = {
|
|
32
|
-
name: string;
|
|
33
|
-
typeName: string;
|
|
34
|
-
/**
|
|
35
|
-
* This will make it possible to override the default behaviour.
|
|
36
|
-
*/
|
|
37
|
-
templates?: typeof defaultTemplates;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
type Props$1 = {
|
|
41
|
-
description?: string;
|
|
42
|
-
keysToOmit?: string[];
|
|
43
|
-
};
|
|
44
|
-
declare function OperationSchema({ keysToOmit, description }: Props$1): ReactNode;
|
|
45
|
-
declare namespace OperationSchema {
|
|
46
|
-
var File: ({}: FileProps$1) => ReactNode;
|
|
47
|
-
}
|
|
48
|
-
type FileProps$1 = {};
|
|
16
|
+
declare function OasType({ name, typeName, api }: Props$1): ReactNode;
|
|
49
17
|
|
|
50
18
|
type Props = {
|
|
19
|
+
name: string;
|
|
20
|
+
typedName: string;
|
|
21
|
+
tree: Array<Schema>;
|
|
22
|
+
optionalType: PluginTs['resolvedOptions']['optionalType'];
|
|
23
|
+
enumType: PluginTs['resolvedOptions']['enumType'];
|
|
24
|
+
mapper: PluginTs['resolvedOptions']['mapper'];
|
|
51
25
|
description?: string;
|
|
52
26
|
keysToOmit?: string[];
|
|
53
27
|
};
|
|
54
|
-
declare function
|
|
55
|
-
declare namespace Schema {
|
|
56
|
-
var File: ({}: FileProps) => ReactNode;
|
|
57
|
-
}
|
|
58
|
-
type FileProps = {};
|
|
28
|
+
declare function Type({ name, typedName, tree, keysToOmit, optionalType, enumType, mapper, description }: Props): ReactNode;
|
|
59
29
|
|
|
60
|
-
export { OasType,
|
|
30
|
+
export { OasType, Type };
|
package/dist/components.js
CHANGED
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
OperationSchema,
|
|
4
|
-
Schema
|
|
5
|
-
} from "./chunk-UVAKTXUA.js";
|
|
6
|
-
import {
|
|
7
|
-
init_esm_shims
|
|
8
|
-
} from "./chunk-TTGZBH7H.js";
|
|
9
|
-
|
|
10
|
-
// src/components/index.ts
|
|
11
|
-
init_esm_shims();
|
|
12
|
-
export {
|
|
13
|
-
OasType,
|
|
14
|
-
OperationSchema,
|
|
15
|
-
Schema
|
|
16
|
-
};
|
|
1
|
+
export { OasType, Type } from './chunk-AG2BUY33.js';
|
|
2
|
+
//# sourceMappingURL=components.js.map
|
|
17
3
|
//# sourceMappingURL=components.js.map
|
package/dist/components.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"components.js"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkL7QZ6DBL_cjs = require('./chunk-L7QZ6DBL.cjs');
|
|
4
|
+
require('./chunk-XMTK3ZZE.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, "oasGenerator", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return chunkL7QZ6DBL_cjs.oasGenerator; }
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "typeGenerator", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return chunkL7QZ6DBL_cjs.typeGenerator; }
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=generators.cjs.map
|
|
17
|
+
//# sourceMappingURL=generators.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"generators.cjs"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as _kubb_plugin_oas from '@kubb/plugin-oas';
|
|
2
|
+
import { P as PluginTs } from './types-DoCOabdx.cjs';
|
|
3
|
+
import '@kubb/core';
|
|
4
|
+
import 'typescript';
|
|
5
|
+
|
|
6
|
+
declare const typeGenerator: _kubb_plugin_oas.Generator<PluginTs>;
|
|
7
|
+
|
|
8
|
+
declare const oasGenerator: _kubb_plugin_oas.Generator<PluginTs>;
|
|
9
|
+
|
|
10
|
+
export { oasGenerator, typeGenerator };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as _kubb_plugin_oas from '@kubb/plugin-oas';
|
|
2
|
+
import { P as PluginTs } from './types-DoCOabdx.js';
|
|
3
|
+
import '@kubb/core';
|
|
4
|
+
import 'typescript';
|
|
5
|
+
|
|
6
|
+
declare const typeGenerator: _kubb_plugin_oas.Generator<PluginTs>;
|
|
7
|
+
|
|
8
|
+
declare const oasGenerator: _kubb_plugin_oas.Generator<PluginTs>;
|
|
9
|
+
|
|
10
|
+
export { oasGenerator, typeGenerator };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"generators.js"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
|
+
var chunkL7QZ6DBL_cjs = require('./chunk-L7QZ6DBL.cjs');
|
|
4
|
+
require('./chunk-XMTK3ZZE.cjs');
|
|
3
5
|
|
|
4
|
-
var _chunkPV5Q7I5Ocjs = require('./chunk-PV5Q7I5O.cjs');
|
|
5
|
-
require('./chunk-SEH6NUCX.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
Object.defineProperty(exports, "pluginTs", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return chunkL7QZ6DBL_cjs.pluginTs; }
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "pluginTsName", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return chunkL7QZ6DBL_cjs.pluginTsName; }
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=index.cjs.map
|
|
10
17
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,128 +1,9 @@
|
|
|
1
1
|
import * as _kubb_core from '@kubb/core';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { ResolvePathOptions, Exclude, Include, Override } from '@kubb/plugin-oas';
|
|
6
|
-
|
|
7
|
-
type Options = {
|
|
8
|
-
output?: {
|
|
9
|
-
/**
|
|
10
|
-
* Relative path to save the TypeScript types.
|
|
11
|
-
* When output is a file it will save all models inside that file else it will create a file per schema item.
|
|
12
|
-
* @default 'types'
|
|
13
|
-
*/
|
|
14
|
-
path: string;
|
|
15
|
-
/**
|
|
16
|
-
* Name to be used for the `export * as {{exportAs}} from './'`
|
|
17
|
-
*/
|
|
18
|
-
exportAs?: string;
|
|
19
|
-
/**
|
|
20
|
-
* Add an extension to the generated imports and exports, default it will not use an extension
|
|
21
|
-
*/
|
|
22
|
-
extName?: KubbFile.Extname;
|
|
23
|
-
/**
|
|
24
|
-
* Define what needs to exported, here you can also disable the export of barrel files
|
|
25
|
-
* @default `'barrel'`
|
|
26
|
-
*/
|
|
27
|
-
exportType?: 'barrel' | 'barrelNamed' | false;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Group the TypeScript types based on the provided name.
|
|
31
|
-
*/
|
|
32
|
-
group?: {
|
|
33
|
-
/**
|
|
34
|
-
* Tag will group based on the operation tag inside the Swagger file.
|
|
35
|
-
*/
|
|
36
|
-
type: 'tag';
|
|
37
|
-
/**
|
|
38
|
-
* Relative path to save the grouped TypeScript Types.
|
|
39
|
-
*
|
|
40
|
-
* `{{tag}}` will be replaced by the current tagName.
|
|
41
|
-
* @example `${output}/{{tag}}Controller` => `models/PetController`
|
|
42
|
-
* @default `${output}/{{tag}}Controller`
|
|
43
|
-
*/
|
|
44
|
-
output?: string;
|
|
45
|
-
};
|
|
46
|
-
/**
|
|
47
|
-
* Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
|
|
48
|
-
*/
|
|
49
|
-
exclude?: Array<Exclude>;
|
|
50
|
-
/**
|
|
51
|
-
* Array containing include parameters to include tags/operations/methods/paths.
|
|
52
|
-
*/
|
|
53
|
-
include?: Array<Include>;
|
|
54
|
-
/**
|
|
55
|
-
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
56
|
-
*/
|
|
57
|
-
override?: Array<Override<ResolvedOptions>>;
|
|
58
|
-
/**
|
|
59
|
-
* Choose to use `enum` or `as const` for enums
|
|
60
|
-
* @default 'asConst'
|
|
61
|
-
* asPascalConst is deprecated
|
|
62
|
-
*/
|
|
63
|
-
enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal';
|
|
64
|
-
/**
|
|
65
|
-
* Set a suffix for the generated enums.
|
|
66
|
-
* @default ''
|
|
67
|
-
* Default will be `'enum'` in version 3 of Kubb
|
|
68
|
-
*/
|
|
69
|
-
enumSuffix?: string;
|
|
70
|
-
/**
|
|
71
|
-
* Choose to use `date` or `datetime` as JavaScript `Date` instead of `string`.
|
|
72
|
-
* @default 'string'
|
|
73
|
-
*/
|
|
74
|
-
dateType?: 'string' | 'date';
|
|
75
|
-
/**
|
|
76
|
-
* Which type to use when the Swagger/OpenAPI file is not providing more information.
|
|
77
|
-
* @default 'any'
|
|
78
|
-
*/
|
|
79
|
-
unknownType?: 'any' | 'unknown';
|
|
80
|
-
/**
|
|
81
|
-
* Choose what to use as mode for an optional value.
|
|
82
|
-
* @examples 'questionToken': type?: string
|
|
83
|
-
* @examples 'undefined': type: string | undefined
|
|
84
|
-
* @examples 'questionTokenAndUndefined': type?: string | undefined
|
|
85
|
-
* @default 'questionToken'
|
|
86
|
-
*/
|
|
87
|
-
optionalType?: 'questionToken' | 'undefined' | 'questionTokenAndUndefined';
|
|
88
|
-
transformers?: {
|
|
89
|
-
/**
|
|
90
|
-
* Customize the names based on the type that is provided by the plugin.
|
|
91
|
-
*/
|
|
92
|
-
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
93
|
-
};
|
|
94
|
-
/**
|
|
95
|
-
* Export an Oas object as Oas type with `import type { Infer } from '@kubb/oas'`
|
|
96
|
-
*/
|
|
97
|
-
oasType?: 'infer' | false;
|
|
98
|
-
/**
|
|
99
|
-
* @example
|
|
100
|
-
* Use https://ts-ast-viewer.com to generate factory code(see createPropertySignature)
|
|
101
|
-
* category: factory.createPropertySignature(
|
|
102
|
-
* undefined,
|
|
103
|
-
* factory.createIdentifier("category"),
|
|
104
|
-
* factory.createToken(ts.SyntaxKind.QuestionToken),
|
|
105
|
-
* factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword)
|
|
106
|
-
* )
|
|
107
|
-
*/
|
|
108
|
-
mapper?: Record<string, ts.PropertySignature>;
|
|
109
|
-
};
|
|
110
|
-
type ResolvedOptions = {
|
|
111
|
-
extName: KubbFile.Extname | undefined;
|
|
112
|
-
enumType: NonNullable<Options['enumType']>;
|
|
113
|
-
enumSuffix: NonNullable<Options['enumSuffix']>;
|
|
114
|
-
dateType: NonNullable<Options['dateType']>;
|
|
115
|
-
unknownType: NonNullable<Options['unknownType']>;
|
|
116
|
-
optionalType: NonNullable<Options['optionalType']>;
|
|
117
|
-
override: NonNullable<Options['override']>;
|
|
118
|
-
transformers: NonNullable<Options['transformers']>;
|
|
119
|
-
oasType: NonNullable<Options['oasType']>;
|
|
120
|
-
usedEnumNames: Record<string, number>;
|
|
121
|
-
mapper: Record<string, any>;
|
|
122
|
-
};
|
|
123
|
-
type PluginTs = PluginFactoryOptions<'plugin-ts', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
2
|
+
import { O as Options, P as PluginTs } from './types-DoCOabdx.cjs';
|
|
3
|
+
import '@kubb/plugin-oas';
|
|
4
|
+
import 'typescript';
|
|
124
5
|
|
|
125
6
|
declare const pluginTsName = "plugin-ts";
|
|
126
7
|
declare const pluginTs: (options?: Options | undefined) => _kubb_core.UserPluginWithLifeCycle<PluginTs>;
|
|
127
8
|
|
|
128
|
-
export {
|
|
9
|
+
export { PluginTs, pluginTs, pluginTsName };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,128 +1,9 @@
|
|
|
1
1
|
import * as _kubb_core from '@kubb/core';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { ResolvePathOptions, Exclude, Include, Override } from '@kubb/plugin-oas';
|
|
6
|
-
|
|
7
|
-
type Options = {
|
|
8
|
-
output?: {
|
|
9
|
-
/**
|
|
10
|
-
* Relative path to save the TypeScript types.
|
|
11
|
-
* When output is a file it will save all models inside that file else it will create a file per schema item.
|
|
12
|
-
* @default 'types'
|
|
13
|
-
*/
|
|
14
|
-
path: string;
|
|
15
|
-
/**
|
|
16
|
-
* Name to be used for the `export * as {{exportAs}} from './'`
|
|
17
|
-
*/
|
|
18
|
-
exportAs?: string;
|
|
19
|
-
/**
|
|
20
|
-
* Add an extension to the generated imports and exports, default it will not use an extension
|
|
21
|
-
*/
|
|
22
|
-
extName?: KubbFile.Extname;
|
|
23
|
-
/**
|
|
24
|
-
* Define what needs to exported, here you can also disable the export of barrel files
|
|
25
|
-
* @default `'barrel'`
|
|
26
|
-
*/
|
|
27
|
-
exportType?: 'barrel' | 'barrelNamed' | false;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Group the TypeScript types based on the provided name.
|
|
31
|
-
*/
|
|
32
|
-
group?: {
|
|
33
|
-
/**
|
|
34
|
-
* Tag will group based on the operation tag inside the Swagger file.
|
|
35
|
-
*/
|
|
36
|
-
type: 'tag';
|
|
37
|
-
/**
|
|
38
|
-
* Relative path to save the grouped TypeScript Types.
|
|
39
|
-
*
|
|
40
|
-
* `{{tag}}` will be replaced by the current tagName.
|
|
41
|
-
* @example `${output}/{{tag}}Controller` => `models/PetController`
|
|
42
|
-
* @default `${output}/{{tag}}Controller`
|
|
43
|
-
*/
|
|
44
|
-
output?: string;
|
|
45
|
-
};
|
|
46
|
-
/**
|
|
47
|
-
* Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
|
|
48
|
-
*/
|
|
49
|
-
exclude?: Array<Exclude>;
|
|
50
|
-
/**
|
|
51
|
-
* Array containing include parameters to include tags/operations/methods/paths.
|
|
52
|
-
*/
|
|
53
|
-
include?: Array<Include>;
|
|
54
|
-
/**
|
|
55
|
-
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
56
|
-
*/
|
|
57
|
-
override?: Array<Override<ResolvedOptions>>;
|
|
58
|
-
/**
|
|
59
|
-
* Choose to use `enum` or `as const` for enums
|
|
60
|
-
* @default 'asConst'
|
|
61
|
-
* asPascalConst is deprecated
|
|
62
|
-
*/
|
|
63
|
-
enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal';
|
|
64
|
-
/**
|
|
65
|
-
* Set a suffix for the generated enums.
|
|
66
|
-
* @default ''
|
|
67
|
-
* Default will be `'enum'` in version 3 of Kubb
|
|
68
|
-
*/
|
|
69
|
-
enumSuffix?: string;
|
|
70
|
-
/**
|
|
71
|
-
* Choose to use `date` or `datetime` as JavaScript `Date` instead of `string`.
|
|
72
|
-
* @default 'string'
|
|
73
|
-
*/
|
|
74
|
-
dateType?: 'string' | 'date';
|
|
75
|
-
/**
|
|
76
|
-
* Which type to use when the Swagger/OpenAPI file is not providing more information.
|
|
77
|
-
* @default 'any'
|
|
78
|
-
*/
|
|
79
|
-
unknownType?: 'any' | 'unknown';
|
|
80
|
-
/**
|
|
81
|
-
* Choose what to use as mode for an optional value.
|
|
82
|
-
* @examples 'questionToken': type?: string
|
|
83
|
-
* @examples 'undefined': type: string | undefined
|
|
84
|
-
* @examples 'questionTokenAndUndefined': type?: string | undefined
|
|
85
|
-
* @default 'questionToken'
|
|
86
|
-
*/
|
|
87
|
-
optionalType?: 'questionToken' | 'undefined' | 'questionTokenAndUndefined';
|
|
88
|
-
transformers?: {
|
|
89
|
-
/**
|
|
90
|
-
* Customize the names based on the type that is provided by the plugin.
|
|
91
|
-
*/
|
|
92
|
-
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
93
|
-
};
|
|
94
|
-
/**
|
|
95
|
-
* Export an Oas object as Oas type with `import type { Infer } from '@kubb/oas'`
|
|
96
|
-
*/
|
|
97
|
-
oasType?: 'infer' | false;
|
|
98
|
-
/**
|
|
99
|
-
* @example
|
|
100
|
-
* Use https://ts-ast-viewer.com to generate factory code(see createPropertySignature)
|
|
101
|
-
* category: factory.createPropertySignature(
|
|
102
|
-
* undefined,
|
|
103
|
-
* factory.createIdentifier("category"),
|
|
104
|
-
* factory.createToken(ts.SyntaxKind.QuestionToken),
|
|
105
|
-
* factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword)
|
|
106
|
-
* )
|
|
107
|
-
*/
|
|
108
|
-
mapper?: Record<string, ts.PropertySignature>;
|
|
109
|
-
};
|
|
110
|
-
type ResolvedOptions = {
|
|
111
|
-
extName: KubbFile.Extname | undefined;
|
|
112
|
-
enumType: NonNullable<Options['enumType']>;
|
|
113
|
-
enumSuffix: NonNullable<Options['enumSuffix']>;
|
|
114
|
-
dateType: NonNullable<Options['dateType']>;
|
|
115
|
-
unknownType: NonNullable<Options['unknownType']>;
|
|
116
|
-
optionalType: NonNullable<Options['optionalType']>;
|
|
117
|
-
override: NonNullable<Options['override']>;
|
|
118
|
-
transformers: NonNullable<Options['transformers']>;
|
|
119
|
-
oasType: NonNullable<Options['oasType']>;
|
|
120
|
-
usedEnumNames: Record<string, number>;
|
|
121
|
-
mapper: Record<string, any>;
|
|
122
|
-
};
|
|
123
|
-
type PluginTs = PluginFactoryOptions<'plugin-ts', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
2
|
+
import { O as Options, P as PluginTs } from './types-DoCOabdx.js';
|
|
3
|
+
import '@kubb/plugin-oas';
|
|
4
|
+
import 'typescript';
|
|
124
5
|
|
|
125
6
|
declare const pluginTsName = "plugin-ts";
|
|
126
7
|
declare const pluginTs: (options?: Options | undefined) => _kubb_core.UserPluginWithLifeCycle<PluginTs>;
|
|
127
8
|
|
|
128
|
-
export {
|
|
9
|
+
export { PluginTs, pluginTs, pluginTsName };
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from "./chunk-UVAKTXUA.js";
|
|
5
|
-
import "./chunk-TTGZBH7H.js";
|
|
6
|
-
export {
|
|
7
|
-
pluginTs,
|
|
8
|
-
pluginTsName
|
|
9
|
-
};
|
|
1
|
+
export { pluginTs, pluginTsName } from './chunk-QZ2DBYXR.js';
|
|
2
|
+
import './chunk-AG2BUY33.js';
|
|
3
|
+
//# sourceMappingURL=index.js.map
|
|
10
4
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { PluginFactoryOptions, Output, Group, ResolveNameParams } from '@kubb/core';
|
|
2
|
+
import { ResolvePathOptions, Exclude, Include, Override, Generator } from '@kubb/plugin-oas';
|
|
3
|
+
import ts from 'typescript';
|
|
4
|
+
|
|
5
|
+
type Options = {
|
|
6
|
+
/**
|
|
7
|
+
* Specify the export location for the files and define the behavior of the output
|
|
8
|
+
* @default { path: 'types', barrelType: 'named' }
|
|
9
|
+
*/
|
|
10
|
+
output?: Output;
|
|
11
|
+
/**
|
|
12
|
+
* Group the clients based on the provided name.
|
|
13
|
+
*/
|
|
14
|
+
group?: Group;
|
|
15
|
+
/**
|
|
16
|
+
* Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
|
|
17
|
+
*/
|
|
18
|
+
exclude?: Array<Exclude>;
|
|
19
|
+
/**
|
|
20
|
+
* Array containing include parameters to include tags/operations/methods/paths.
|
|
21
|
+
*/
|
|
22
|
+
include?: Array<Include>;
|
|
23
|
+
/**
|
|
24
|
+
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
25
|
+
*/
|
|
26
|
+
override?: Array<Override<ResolvedOptions>>;
|
|
27
|
+
/**
|
|
28
|
+
* Choose to use `enum` or `as const` for enums
|
|
29
|
+
* @default 'asConst'
|
|
30
|
+
* asPascalConst is deprecated
|
|
31
|
+
*/
|
|
32
|
+
enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal';
|
|
33
|
+
/**
|
|
34
|
+
* Set a suffix for the generated enums.
|
|
35
|
+
* @default ''
|
|
36
|
+
* Default will be `'enum'` in version 3 of Kubb
|
|
37
|
+
*/
|
|
38
|
+
enumSuffix?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Choose to use `date` or `datetime` as JavaScript `Date` instead of `string`.
|
|
41
|
+
* @default 'string'
|
|
42
|
+
*/
|
|
43
|
+
dateType?: 'string' | 'date';
|
|
44
|
+
/**
|
|
45
|
+
* Which type to use when the Swagger/OpenAPI file is not providing more information.
|
|
46
|
+
* @default 'any'
|
|
47
|
+
*/
|
|
48
|
+
unknownType?: 'any' | 'unknown';
|
|
49
|
+
/**
|
|
50
|
+
* Choose what to use as mode for an optional value.
|
|
51
|
+
* @examples 'questionToken': type?: string
|
|
52
|
+
* @examples 'undefined': type: string | undefined
|
|
53
|
+
* @examples 'questionTokenAndUndefined': type?: string | undefined
|
|
54
|
+
* @default 'questionToken'
|
|
55
|
+
*/
|
|
56
|
+
optionalType?: 'questionToken' | 'undefined' | 'questionTokenAndUndefined';
|
|
57
|
+
transformers?: {
|
|
58
|
+
/**
|
|
59
|
+
* Customize the names based on the type that is provided by the plugin.
|
|
60
|
+
*/
|
|
61
|
+
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Export an Oas object as Oas type with `import type { Infer } from '@kubb/oas'`
|
|
65
|
+
*/
|
|
66
|
+
oasType?: 'infer' | false;
|
|
67
|
+
/**
|
|
68
|
+
* @example
|
|
69
|
+
* Use https://ts-ast-viewer.com to generate factory code(see createPropertySignature)
|
|
70
|
+
* category: factory.createPropertySignature(
|
|
71
|
+
* undefined,
|
|
72
|
+
* factory.createIdentifier("category"),
|
|
73
|
+
* factory.createToken(ts.SyntaxKind.QuestionToken),
|
|
74
|
+
* factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword)
|
|
75
|
+
* )
|
|
76
|
+
*/
|
|
77
|
+
mapper?: Record<string, ts.PropertySignature>;
|
|
78
|
+
/**
|
|
79
|
+
* Define some generators next to the ts generators
|
|
80
|
+
*/
|
|
81
|
+
generators?: Array<Generator<PluginTs>>;
|
|
82
|
+
};
|
|
83
|
+
type ResolvedOptions = {
|
|
84
|
+
output: Output;
|
|
85
|
+
override: NonNullable<Options['override']>;
|
|
86
|
+
enumType: NonNullable<Options['enumType']>;
|
|
87
|
+
enumSuffix: NonNullable<Options['enumSuffix']>;
|
|
88
|
+
dateType: NonNullable<Options['dateType']>;
|
|
89
|
+
unknownType: NonNullable<Options['unknownType']>;
|
|
90
|
+
optionalType: NonNullable<Options['optionalType']>;
|
|
91
|
+
transformers: NonNullable<Options['transformers']>;
|
|
92
|
+
oasType: NonNullable<Options['oasType']>;
|
|
93
|
+
usedEnumNames: Record<string, number>;
|
|
94
|
+
mapper: Record<string, any>;
|
|
95
|
+
};
|
|
96
|
+
type PluginTs = PluginFactoryOptions<'plugin-ts', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
97
|
+
|
|
98
|
+
export type { Options as O, PluginTs as P };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { PluginFactoryOptions, Output, Group, ResolveNameParams } from '@kubb/core';
|
|
2
|
+
import { ResolvePathOptions, Exclude, Include, Override, Generator } from '@kubb/plugin-oas';
|
|
3
|
+
import ts from 'typescript';
|
|
4
|
+
|
|
5
|
+
type Options = {
|
|
6
|
+
/**
|
|
7
|
+
* Specify the export location for the files and define the behavior of the output
|
|
8
|
+
* @default { path: 'types', barrelType: 'named' }
|
|
9
|
+
*/
|
|
10
|
+
output?: Output;
|
|
11
|
+
/**
|
|
12
|
+
* Group the clients based on the provided name.
|
|
13
|
+
*/
|
|
14
|
+
group?: Group;
|
|
15
|
+
/**
|
|
16
|
+
* Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
|
|
17
|
+
*/
|
|
18
|
+
exclude?: Array<Exclude>;
|
|
19
|
+
/**
|
|
20
|
+
* Array containing include parameters to include tags/operations/methods/paths.
|
|
21
|
+
*/
|
|
22
|
+
include?: Array<Include>;
|
|
23
|
+
/**
|
|
24
|
+
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
25
|
+
*/
|
|
26
|
+
override?: Array<Override<ResolvedOptions>>;
|
|
27
|
+
/**
|
|
28
|
+
* Choose to use `enum` or `as const` for enums
|
|
29
|
+
* @default 'asConst'
|
|
30
|
+
* asPascalConst is deprecated
|
|
31
|
+
*/
|
|
32
|
+
enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal';
|
|
33
|
+
/**
|
|
34
|
+
* Set a suffix for the generated enums.
|
|
35
|
+
* @default ''
|
|
36
|
+
* Default will be `'enum'` in version 3 of Kubb
|
|
37
|
+
*/
|
|
38
|
+
enumSuffix?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Choose to use `date` or `datetime` as JavaScript `Date` instead of `string`.
|
|
41
|
+
* @default 'string'
|
|
42
|
+
*/
|
|
43
|
+
dateType?: 'string' | 'date';
|
|
44
|
+
/**
|
|
45
|
+
* Which type to use when the Swagger/OpenAPI file is not providing more information.
|
|
46
|
+
* @default 'any'
|
|
47
|
+
*/
|
|
48
|
+
unknownType?: 'any' | 'unknown';
|
|
49
|
+
/**
|
|
50
|
+
* Choose what to use as mode for an optional value.
|
|
51
|
+
* @examples 'questionToken': type?: string
|
|
52
|
+
* @examples 'undefined': type: string | undefined
|
|
53
|
+
* @examples 'questionTokenAndUndefined': type?: string | undefined
|
|
54
|
+
* @default 'questionToken'
|
|
55
|
+
*/
|
|
56
|
+
optionalType?: 'questionToken' | 'undefined' | 'questionTokenAndUndefined';
|
|
57
|
+
transformers?: {
|
|
58
|
+
/**
|
|
59
|
+
* Customize the names based on the type that is provided by the plugin.
|
|
60
|
+
*/
|
|
61
|
+
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Export an Oas object as Oas type with `import type { Infer } from '@kubb/oas'`
|
|
65
|
+
*/
|
|
66
|
+
oasType?: 'infer' | false;
|
|
67
|
+
/**
|
|
68
|
+
* @example
|
|
69
|
+
* Use https://ts-ast-viewer.com to generate factory code(see createPropertySignature)
|
|
70
|
+
* category: factory.createPropertySignature(
|
|
71
|
+
* undefined,
|
|
72
|
+
* factory.createIdentifier("category"),
|
|
73
|
+
* factory.createToken(ts.SyntaxKind.QuestionToken),
|
|
74
|
+
* factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword)
|
|
75
|
+
* )
|
|
76
|
+
*/
|
|
77
|
+
mapper?: Record<string, ts.PropertySignature>;
|
|
78
|
+
/**
|
|
79
|
+
* Define some generators next to the ts generators
|
|
80
|
+
*/
|
|
81
|
+
generators?: Array<Generator<PluginTs>>;
|
|
82
|
+
};
|
|
83
|
+
type ResolvedOptions = {
|
|
84
|
+
output: Output;
|
|
85
|
+
override: NonNullable<Options['override']>;
|
|
86
|
+
enumType: NonNullable<Options['enumType']>;
|
|
87
|
+
enumSuffix: NonNullable<Options['enumSuffix']>;
|
|
88
|
+
dateType: NonNullable<Options['dateType']>;
|
|
89
|
+
unknownType: NonNullable<Options['unknownType']>;
|
|
90
|
+
optionalType: NonNullable<Options['optionalType']>;
|
|
91
|
+
transformers: NonNullable<Options['transformers']>;
|
|
92
|
+
oasType: NonNullable<Options['oasType']>;
|
|
93
|
+
usedEnumNames: Record<string, number>;
|
|
94
|
+
mapper: Record<string, any>;
|
|
95
|
+
};
|
|
96
|
+
type PluginTs = PluginFactoryOptions<'plugin-ts', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
97
|
+
|
|
98
|
+
export type { Options as O, PluginTs as P };
|