@hey-api/openapi-ts 0.59.2 → 0.60.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/LICENSE.md +8 -97
- package/README.md +9 -7
- package/dist/index.cjs +19 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +56 -11
- package/dist/index.d.ts +56 -11
- package/dist/index.js +14 -14
- package/dist/index.js.map +1 -1
- package/package.json +21 -21
package/dist/index.d.cts
CHANGED
|
@@ -24,6 +24,10 @@ type ArrayOfObjectsToObjectMap<T extends ReadonlyArray<Record<string, any>>, D e
|
|
|
24
24
|
[K in T[number][D]]?: Extract<T[number], Record<D, K>>;
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
+
type OmitUnderscoreKeys<T> = {
|
|
28
|
+
[K in keyof T as K extends `_${string}` ? never : K]: T[K];
|
|
29
|
+
};
|
|
30
|
+
|
|
27
31
|
type PluginNames =
|
|
28
32
|
| '@hey-api/schemas'
|
|
29
33
|
| '@hey-api/sdk'
|
|
@@ -37,23 +41,39 @@ type PluginNames =
|
|
|
37
41
|
| 'fastify'
|
|
38
42
|
| 'zod';
|
|
39
43
|
|
|
44
|
+
type PluginTag = 'transformer' | 'validator';
|
|
45
|
+
|
|
46
|
+
interface PluginContext {
|
|
47
|
+
ensureDependency: (name: PluginNames | true) => void;
|
|
48
|
+
pluginByTag: (tag: PluginTag) => PluginNames | undefined;
|
|
49
|
+
}
|
|
50
|
+
|
|
40
51
|
interface BaseConfig {
|
|
41
52
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
42
53
|
name: PluginNames | (string & {});
|
|
43
54
|
output?: string;
|
|
44
55
|
}
|
|
45
56
|
|
|
46
|
-
interface
|
|
57
|
+
interface Meta<Config extends BaseConfig> {
|
|
47
58
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
59
|
+
* Dependency plugins will be always processed, regardless of whether user
|
|
60
|
+
* explicitly defines them in their `plugins` config.
|
|
50
61
|
*/
|
|
51
62
|
_dependencies?: ReadonlyArray<PluginNames>;
|
|
52
63
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
64
|
+
* Allows overriding config before it's sent to the parser. An example is
|
|
65
|
+
* defining `validator` as `true` and the plugin figures out which plugin
|
|
66
|
+
* should be used for validation.
|
|
55
67
|
*/
|
|
56
|
-
|
|
68
|
+
_infer?: (
|
|
69
|
+
config: Config & Omit<Meta<Config>, '_infer'>,
|
|
70
|
+
context: PluginContext,
|
|
71
|
+
) => void;
|
|
72
|
+
/**
|
|
73
|
+
* Optional tags can be used to help with deciding plugin order and inferring
|
|
74
|
+
* plugin configuration options.
|
|
75
|
+
*/
|
|
76
|
+
_tags?: ReadonlyArray<PluginTag>;
|
|
57
77
|
}
|
|
58
78
|
|
|
59
79
|
/**
|
|
@@ -61,7 +81,7 @@ interface Dependencies {
|
|
|
61
81
|
*/
|
|
62
82
|
declare namespace Plugin {
|
|
63
83
|
export type Config<Config extends BaseConfig> = Config &
|
|
64
|
-
|
|
84
|
+
Meta<Config> & {
|
|
65
85
|
_handler: Plugin.Handler<Config>;
|
|
66
86
|
_handlerLegacy: Plugin.LegacyHandler<Config>;
|
|
67
87
|
};
|
|
@@ -78,10 +98,7 @@ declare namespace Plugin {
|
|
|
78
98
|
plugin: Plugin.Instance<Config>;
|
|
79
99
|
}) => void;
|
|
80
100
|
|
|
81
|
-
export type Instance<Config extends BaseConfig> =
|
|
82
|
-
Config,
|
|
83
|
-
'_dependencies' | '_handler' | '_handlerLegacy' | '_optionalDependencies'
|
|
84
|
-
> &
|
|
101
|
+
export type Instance<Config extends BaseConfig> = OmitUnderscoreKeys<Config> &
|
|
85
102
|
Pick<Required<Config>, 'output'>;
|
|
86
103
|
|
|
87
104
|
/**
|
|
@@ -4176,6 +4193,34 @@ interface Config$a extends Plugin.Name<'@hey-api/sdk'> {
|
|
|
4176
4193
|
* @default '{{name}}Service'
|
|
4177
4194
|
*/
|
|
4178
4195
|
serviceNameBuilder?: string;
|
|
4196
|
+
/**
|
|
4197
|
+
* Transform response data before returning. This is useful if you want to
|
|
4198
|
+
* convert for example ISO strings into Date objects. However, transformation
|
|
4199
|
+
* adds runtime overhead, so it's not recommended to use unless necessary.
|
|
4200
|
+
*
|
|
4201
|
+
* You can customize the selected transformer output through its plugin. You
|
|
4202
|
+
* can also set `transformer` to `true` to automatically choose the
|
|
4203
|
+
* transformer from your defined plugins.
|
|
4204
|
+
*
|
|
4205
|
+
* @default false
|
|
4206
|
+
*/
|
|
4207
|
+
transformer?: '@hey-api/transformers' | boolean;
|
|
4208
|
+
/**
|
|
4209
|
+
* **This feature works only with the experimental parser**
|
|
4210
|
+
*
|
|
4211
|
+
* Validate response data against schema before returning. This is useful
|
|
4212
|
+
* if you want to ensure the response conforms to a desired shape. However,
|
|
4213
|
+
* validation adds runtime overhead, so it's not recommended to use unless
|
|
4214
|
+
* absolutely necessary.
|
|
4215
|
+
*
|
|
4216
|
+
* Ensure you have declared the selected library as a dependency to avoid
|
|
4217
|
+
* errors. You can customize the selected validator output through its
|
|
4218
|
+
* plugin. You can also set `validator` to `true` to automatically choose
|
|
4219
|
+
* the validator from your defined plugins.
|
|
4220
|
+
*
|
|
4221
|
+
* @default false
|
|
4222
|
+
*/
|
|
4223
|
+
validator?: 'zod' | boolean;
|
|
4179
4224
|
}
|
|
4180
4225
|
|
|
4181
4226
|
interface Config$9 extends Plugin.Name<'@hey-api/transformers'> {
|
package/dist/index.d.ts
CHANGED
|
@@ -24,6 +24,10 @@ type ArrayOfObjectsToObjectMap<T extends ReadonlyArray<Record<string, any>>, D e
|
|
|
24
24
|
[K in T[number][D]]?: Extract<T[number], Record<D, K>>;
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
+
type OmitUnderscoreKeys<T> = {
|
|
28
|
+
[K in keyof T as K extends `_${string}` ? never : K]: T[K];
|
|
29
|
+
};
|
|
30
|
+
|
|
27
31
|
type PluginNames =
|
|
28
32
|
| '@hey-api/schemas'
|
|
29
33
|
| '@hey-api/sdk'
|
|
@@ -37,23 +41,39 @@ type PluginNames =
|
|
|
37
41
|
| 'fastify'
|
|
38
42
|
| 'zod';
|
|
39
43
|
|
|
44
|
+
type PluginTag = 'transformer' | 'validator';
|
|
45
|
+
|
|
46
|
+
interface PluginContext {
|
|
47
|
+
ensureDependency: (name: PluginNames | true) => void;
|
|
48
|
+
pluginByTag: (tag: PluginTag) => PluginNames | undefined;
|
|
49
|
+
}
|
|
50
|
+
|
|
40
51
|
interface BaseConfig {
|
|
41
52
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
42
53
|
name: PluginNames | (string & {});
|
|
43
54
|
output?: string;
|
|
44
55
|
}
|
|
45
56
|
|
|
46
|
-
interface
|
|
57
|
+
interface Meta<Config extends BaseConfig> {
|
|
47
58
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
59
|
+
* Dependency plugins will be always processed, regardless of whether user
|
|
60
|
+
* explicitly defines them in their `plugins` config.
|
|
50
61
|
*/
|
|
51
62
|
_dependencies?: ReadonlyArray<PluginNames>;
|
|
52
63
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
64
|
+
* Allows overriding config before it's sent to the parser. An example is
|
|
65
|
+
* defining `validator` as `true` and the plugin figures out which plugin
|
|
66
|
+
* should be used for validation.
|
|
55
67
|
*/
|
|
56
|
-
|
|
68
|
+
_infer?: (
|
|
69
|
+
config: Config & Omit<Meta<Config>, '_infer'>,
|
|
70
|
+
context: PluginContext,
|
|
71
|
+
) => void;
|
|
72
|
+
/**
|
|
73
|
+
* Optional tags can be used to help with deciding plugin order and inferring
|
|
74
|
+
* plugin configuration options.
|
|
75
|
+
*/
|
|
76
|
+
_tags?: ReadonlyArray<PluginTag>;
|
|
57
77
|
}
|
|
58
78
|
|
|
59
79
|
/**
|
|
@@ -61,7 +81,7 @@ interface Dependencies {
|
|
|
61
81
|
*/
|
|
62
82
|
declare namespace Plugin {
|
|
63
83
|
export type Config<Config extends BaseConfig> = Config &
|
|
64
|
-
|
|
84
|
+
Meta<Config> & {
|
|
65
85
|
_handler: Plugin.Handler<Config>;
|
|
66
86
|
_handlerLegacy: Plugin.LegacyHandler<Config>;
|
|
67
87
|
};
|
|
@@ -78,10 +98,7 @@ declare namespace Plugin {
|
|
|
78
98
|
plugin: Plugin.Instance<Config>;
|
|
79
99
|
}) => void;
|
|
80
100
|
|
|
81
|
-
export type Instance<Config extends BaseConfig> =
|
|
82
|
-
Config,
|
|
83
|
-
'_dependencies' | '_handler' | '_handlerLegacy' | '_optionalDependencies'
|
|
84
|
-
> &
|
|
101
|
+
export type Instance<Config extends BaseConfig> = OmitUnderscoreKeys<Config> &
|
|
85
102
|
Pick<Required<Config>, 'output'>;
|
|
86
103
|
|
|
87
104
|
/**
|
|
@@ -4176,6 +4193,34 @@ interface Config$a extends Plugin.Name<'@hey-api/sdk'> {
|
|
|
4176
4193
|
* @default '{{name}}Service'
|
|
4177
4194
|
*/
|
|
4178
4195
|
serviceNameBuilder?: string;
|
|
4196
|
+
/**
|
|
4197
|
+
* Transform response data before returning. This is useful if you want to
|
|
4198
|
+
* convert for example ISO strings into Date objects. However, transformation
|
|
4199
|
+
* adds runtime overhead, so it's not recommended to use unless necessary.
|
|
4200
|
+
*
|
|
4201
|
+
* You can customize the selected transformer output through its plugin. You
|
|
4202
|
+
* can also set `transformer` to `true` to automatically choose the
|
|
4203
|
+
* transformer from your defined plugins.
|
|
4204
|
+
*
|
|
4205
|
+
* @default false
|
|
4206
|
+
*/
|
|
4207
|
+
transformer?: '@hey-api/transformers' | boolean;
|
|
4208
|
+
/**
|
|
4209
|
+
* **This feature works only with the experimental parser**
|
|
4210
|
+
*
|
|
4211
|
+
* Validate response data against schema before returning. This is useful
|
|
4212
|
+
* if you want to ensure the response conforms to a desired shape. However,
|
|
4213
|
+
* validation adds runtime overhead, so it's not recommended to use unless
|
|
4214
|
+
* absolutely necessary.
|
|
4215
|
+
*
|
|
4216
|
+
* Ensure you have declared the selected library as a dependency to avoid
|
|
4217
|
+
* errors. You can customize the selected validator output through its
|
|
4218
|
+
* plugin. You can also set `validator` to `true` to automatically choose
|
|
4219
|
+
* the validator from your defined plugins.
|
|
4220
|
+
*
|
|
4221
|
+
* @default false
|
|
4222
|
+
*/
|
|
4223
|
+
validator?: 'zod' | boolean;
|
|
4179
4224
|
}
|
|
4180
4225
|
|
|
4181
4226
|
interface Config$9 extends Plugin.Name<'@hey-api/transformers'> {
|