@kubb/swagger-ts 2.0.0-beta.2 → 2.0.0-beta.4

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.
@@ -0,0 +1,111 @@
1
+ import { ResolvePathOptions, Exclude, Include, Override, AppMeta as AppMeta$1, OasBuilder } from '@kubb/swagger';
2
+ import { PluginFactoryOptions, ResolveNameParams, KubbFile } from '@kubb/core';
3
+ import { ReactNode } from 'react';
4
+
5
+ type Options = {
6
+ /**
7
+ * Relative path to save the TypeScript types.
8
+ * When output is a file it will save all models inside that file else it will create a file per schema item.
9
+ * @default 'types'
10
+ */
11
+ output?: string;
12
+ /**
13
+ * Group the TypeScript types based on the provided name.
14
+ */
15
+ group?: {
16
+ /**
17
+ * Tag will group based on the operation tag inside the Swagger file.
18
+ */
19
+ type: 'tag';
20
+ /**
21
+ * Relative path to save the grouped TypeScript Types.
22
+ *
23
+ * `{{tag}}` will be replaced by the current tagName.
24
+ * @example `${output}/{{tag}}Controller` => `models/PetController`
25
+ * @default `${output}/{{tag}}Controller`
26
+ */
27
+ output?: string;
28
+ };
29
+ /**
30
+ * Name to be used for the `export * as {{exportAs}} from './`
31
+ */
32
+ exportAs?: string;
33
+ /**
34
+ * Array containing exclude paramaters to exclude/skip tags/operations/methods/paths.
35
+ */
36
+ exclude?: Array<Exclude>;
37
+ /**
38
+ * Array containing include paramaters to include tags/operations/methods/paths.
39
+ */
40
+ include?: Array<Include>;
41
+ /**
42
+ * Array containing override paramaters to override `options` based on tags/operations/methods/paths.
43
+ */
44
+ override?: Array<Override<Options>>;
45
+ /**
46
+ * Choose to use `enum` or `as const` for enums
47
+ * @default 'asConst'
48
+ */
49
+ enumType?: 'enum' | 'asConst' | 'asPascalConst';
50
+ /**
51
+ * Choose to use `date` or `datetime` as JavaScript `Date` instead of `string`.
52
+ * @default 'string'
53
+ */
54
+ dateType?: 'string' | 'date';
55
+ /**
56
+ * Choose what to use as mode for an optional value.
57
+ * @examples 'questionToken': type?: string
58
+ * @examples 'undefined': type: string | undefined
59
+ * @examples 'questionTokenAndUndefined': type?: string | undefined
60
+ * @default 'questionToken'
61
+ */
62
+ optionalType?: 'questionToken' | 'undefined' | 'questionTokenAndUndefined';
63
+ transformers?: {
64
+ /**
65
+ * Customize the names based on the type that is provided by the plugin.
66
+ */
67
+ name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
68
+ };
69
+ };
70
+ type ResolvedOptions = {
71
+ enumType: NonNullable<Options['enumType']>;
72
+ dateType: NonNullable<Options['dateType']>;
73
+ optionalType: NonNullable<Options['optionalType']>;
74
+ transformers: NonNullable<Options['transformers']>;
75
+ usedEnumNames: Record<string, number>;
76
+ };
77
+ type AppMeta = AppMeta$1;
78
+ type PluginOptions = PluginFactoryOptions<'swagger-ts', Options, ResolvedOptions, never, ResolvePathOptions, AppMeta>;
79
+ declare module '@kubb/core' {
80
+ interface _Register {
81
+ ['@kubb/swagger-ts']: PluginOptions;
82
+ }
83
+ }
84
+
85
+ declare class TypeBuilder extends OasBuilder<PluginOptions['resolvedOptions']> {
86
+ build(name?: string): Required<Pick<KubbFile.File, 'imports' | 'source'>>;
87
+ }
88
+
89
+ type Props$1 = {
90
+ builder: TypeBuilder;
91
+ };
92
+ declare function Mutation({ builder, }: Props$1): ReactNode;
93
+ declare namespace Mutation {
94
+ var File: ({ mode }: FileProps$1) => ReactNode;
95
+ }
96
+ type FileProps$1 = {
97
+ mode: KubbFile.Mode;
98
+ };
99
+
100
+ type Props = {
101
+ builder: TypeBuilder;
102
+ };
103
+ declare function Query({ builder, }: Props): ReactNode;
104
+ declare namespace Query {
105
+ var File: ({ mode }: FileProps) => ReactNode;
106
+ }
107
+ type FileProps = {
108
+ mode: KubbFile.Mode;
109
+ };
110
+
111
+ export { Mutation, Query };
@@ -0,0 +1,111 @@
1
+ import { ResolvePathOptions, Exclude, Include, Override, AppMeta as AppMeta$1, OasBuilder } from '@kubb/swagger';
2
+ import { PluginFactoryOptions, ResolveNameParams, KubbFile } from '@kubb/core';
3
+ import { ReactNode } from 'react';
4
+
5
+ type Options = {
6
+ /**
7
+ * Relative path to save the TypeScript types.
8
+ * When output is a file it will save all models inside that file else it will create a file per schema item.
9
+ * @default 'types'
10
+ */
11
+ output?: string;
12
+ /**
13
+ * Group the TypeScript types based on the provided name.
14
+ */
15
+ group?: {
16
+ /**
17
+ * Tag will group based on the operation tag inside the Swagger file.
18
+ */
19
+ type: 'tag';
20
+ /**
21
+ * Relative path to save the grouped TypeScript Types.
22
+ *
23
+ * `{{tag}}` will be replaced by the current tagName.
24
+ * @example `${output}/{{tag}}Controller` => `models/PetController`
25
+ * @default `${output}/{{tag}}Controller`
26
+ */
27
+ output?: string;
28
+ };
29
+ /**
30
+ * Name to be used for the `export * as {{exportAs}} from './`
31
+ */
32
+ exportAs?: string;
33
+ /**
34
+ * Array containing exclude paramaters to exclude/skip tags/operations/methods/paths.
35
+ */
36
+ exclude?: Array<Exclude>;
37
+ /**
38
+ * Array containing include paramaters to include tags/operations/methods/paths.
39
+ */
40
+ include?: Array<Include>;
41
+ /**
42
+ * Array containing override paramaters to override `options` based on tags/operations/methods/paths.
43
+ */
44
+ override?: Array<Override<Options>>;
45
+ /**
46
+ * Choose to use `enum` or `as const` for enums
47
+ * @default 'asConst'
48
+ */
49
+ enumType?: 'enum' | 'asConst' | 'asPascalConst';
50
+ /**
51
+ * Choose to use `date` or `datetime` as JavaScript `Date` instead of `string`.
52
+ * @default 'string'
53
+ */
54
+ dateType?: 'string' | 'date';
55
+ /**
56
+ * Choose what to use as mode for an optional value.
57
+ * @examples 'questionToken': type?: string
58
+ * @examples 'undefined': type: string | undefined
59
+ * @examples 'questionTokenAndUndefined': type?: string | undefined
60
+ * @default 'questionToken'
61
+ */
62
+ optionalType?: 'questionToken' | 'undefined' | 'questionTokenAndUndefined';
63
+ transformers?: {
64
+ /**
65
+ * Customize the names based on the type that is provided by the plugin.
66
+ */
67
+ name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
68
+ };
69
+ };
70
+ type ResolvedOptions = {
71
+ enumType: NonNullable<Options['enumType']>;
72
+ dateType: NonNullable<Options['dateType']>;
73
+ optionalType: NonNullable<Options['optionalType']>;
74
+ transformers: NonNullable<Options['transformers']>;
75
+ usedEnumNames: Record<string, number>;
76
+ };
77
+ type AppMeta = AppMeta$1;
78
+ type PluginOptions = PluginFactoryOptions<'swagger-ts', Options, ResolvedOptions, never, ResolvePathOptions, AppMeta>;
79
+ declare module '@kubb/core' {
80
+ interface _Register {
81
+ ['@kubb/swagger-ts']: PluginOptions;
82
+ }
83
+ }
84
+
85
+ declare class TypeBuilder extends OasBuilder<PluginOptions['resolvedOptions']> {
86
+ build(name?: string): Required<Pick<KubbFile.File, 'imports' | 'source'>>;
87
+ }
88
+
89
+ type Props$1 = {
90
+ builder: TypeBuilder;
91
+ };
92
+ declare function Mutation({ builder, }: Props$1): ReactNode;
93
+ declare namespace Mutation {
94
+ var File: ({ mode }: FileProps$1) => ReactNode;
95
+ }
96
+ type FileProps$1 = {
97
+ mode: KubbFile.Mode;
98
+ };
99
+
100
+ type Props = {
101
+ builder: TypeBuilder;
102
+ };
103
+ declare function Query({ builder, }: Props): ReactNode;
104
+ declare namespace Query {
105
+ var File: ({ mode }: FileProps) => ReactNode;
106
+ }
107
+ type FileProps = {
108
+ mode: KubbFile.Mode;
109
+ };
110
+
111
+ export { Mutation, Query };