Skip to content

Commit 6342479

Browse files
committed
chore: merge types
1 parent 87ab39a commit 6342479

File tree

2 files changed

+31
-41
lines changed

2 files changed

+31
-41
lines changed

packages/openapi-ts/src/plugins/@pinia/colada/config.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ export const defaultConfig: PiniaColadaPlugin['Config'] = {
99
errorHandling: 'specific',
1010
exportFromIndex: false,
1111
groupByTag: false,
12-
// importPath: PluginName,
12+
importPath: '@pinia/colada',
1313
includeTypes: true,
14-
// name: PluginName,
15-
// output: PluginName,
1614
prefixUse: true,
1715
resolveQuery: undefined,
1816
resolveQueryKey: undefined,
@@ -21,8 +19,8 @@ export const defaultConfig: PiniaColadaPlugin['Config'] = {
2119
},
2220
dependencies: ['@hey-api/typescript'],
2321
handler: handler as PiniaColadaPlugin['Handler'],
24-
name: '@tanstack/react-query',
25-
output: '@tanstack/react-query',
22+
name: '@pinia/colada',
23+
output: '@pinia/colada',
2624
resolveConfig: (plugin, context) => {
2725
// plugin.config.infiniteQueryKeys = context.valueToObject({
2826
// defaultValue: {

packages/openapi-ts/src/plugins/types.d.ts

Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -61,48 +61,40 @@ type BaseConfig = {
6161
exportFromIndex?: boolean;
6262
name: AnyPluginName;
6363
output?: string;
64-
}
65-
66-
interface Meta<Config extends BaseConfig> {
67-
/**
68-
* Dependency plugins will be always processed, regardless of whether user
69-
* explicitly defines them in their `plugins` config.
70-
*/
71-
_dependencies?: ReadonlyArray<AnyPluginName>;
72-
/**
73-
* Allows overriding config before it's sent to the parser. An example is
74-
* defining `validator` as `true` and the plugin figures out which plugin
75-
* should be used for validation.
76-
*/
77-
_infer?: (
78-
config: Config & Omit<Meta<Config>, '_infer'>,
79-
context: PluginContext,
80-
) => void;
81-
/**
82-
* Optional tags can be used to help with deciding plugin order and inferring
83-
* plugin configuration options.
84-
*/
85-
_tags?: ReadonlyArray<PluginTag>;
86-
}
87-
88-
export type DefaultPluginConfigs<T> = {
89-
[K in PluginNames]: BaseConfig &
90-
Meta<any> & {
91-
_handler: Plugin.Handler<Required<Extract<T, { name: K }>>>;
92-
_handlerLegacy?: Plugin.LegacyHandler<Required<Extract<T, { name: K }>>>;
93-
};
9464
};
9565

9666
/**
9767
* Public Plugin API.
9868
*/
9969
export namespace Plugin {
100-
export type Config<Config extends BaseConfig> = Config &
101-
Meta<Config> & {
102-
_handler: Plugin.Handler<Config>;
103-
_handlerLegacy?: Plugin.LegacyHandler<Config>;
104-
exportFromIndex?: boolean;
105-
};
70+
export type Config<T extends Types> = Pick<T, 'api'> & {
71+
config: Omit<T['config'], 'name' | 'output'>;
72+
/**
73+
* Dependency plugins will be always processed, regardless of whether user
74+
* explicitly defines them in their `plugins` config.
75+
*/
76+
dependencies?: ReadonlyArray<AnyPluginName>;
77+
handler: Handler<T>;
78+
handlerLegacy?: LegacyHandler<T>;
79+
name: T['config']['name'];
80+
output: NonNullable<T['config']['output']>;
81+
/**
82+
* Resolves static configuration values into their runtime equivalents. For
83+
* example, when `validator` is set to `true`, it figures out which plugin
84+
* should be used for validation.
85+
*/
86+
resolveConfig?: (
87+
plugin: Omit<Plugin.Config<T>, 'dependencies'> & {
88+
dependencies: Set<AnyPluginName>;
89+
},
90+
context: PluginContext,
91+
) => void;
92+
/**
93+
* Optional tags can be used to help with deciding plugin order and resolving
94+
* plugin configuration options.
95+
*/
96+
tags?: ReadonlyArray<PluginTag>;
97+
};
10698

10799
export type ConfigWithName<T extends Types> = Omit<Config<T>, 'config'> & {
108100
config: Omit<T['config'], 'output'>;

0 commit comments

Comments
 (0)