@kubb/swagger-ts 2.6.6 → 2.7.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/dist/{chunk-UUY4IHAG.js → chunk-AXUXMMYD.js} +131 -86
- package/dist/chunk-AXUXMMYD.js.map +1 -0
- package/dist/{chunk-3QUKTW23.cjs → chunk-T5JLEKOF.cjs} +214 -199
- package/dist/chunk-T5JLEKOF.cjs.map +1 -0
- package/dist/components.cjs +6 -15
- package/dist/components.js +10 -2
- package/dist/components.js.map +1 -1
- package/dist/index.cjs +11 -25
- package/dist/index.d.cts +5 -572
- package/dist/index.d.ts +5 -572
- package/dist/index.js +11 -2
- package/dist/index.js.map +1 -1
- package/dist/oas.cjs +1 -4
- package/dist/oas.js +0 -2
- package/dist/oas.js.map +1 -1
- package/package.json +10 -10
- package/src/components/Mutation.tsx +3 -3
- package/src/components/Oas.tsx +14 -12
- package/src/components/Query.tsx +3 -3
- package/dist/chunk-3QUKTW23.cjs.map +0 -1
- package/dist/chunk-UUY4IHAG.js.map +0 -1
package/dist/index.d.cts
CHANGED
@@ -1,583 +1,16 @@
|
|
1
|
-
import
|
2
|
-
import
|
3
|
-
import { DirectoryTreeOptions } from 'directory-tree';
|
4
|
-
import { Ora } from 'ora';
|
5
|
-
import { P as PluginOptions, O as Options$3 } from './types-WZh-GEfj.cjs';
|
1
|
+
import * as _kubb_core from '@kubb/core';
|
2
|
+
import { P as PluginOptions, O as Options } from './types-WZh-GEfj.cjs';
|
6
3
|
export { F as FileMeta } from './types-WZh-GEfj.cjs';
|
7
4
|
export { i as Oas } from './index-BKDH3fXc.cjs';
|
8
|
-
import '@kubb/core';
|
9
5
|
import '@kubb/swagger';
|
10
6
|
import 'hotscript';
|
11
7
|
import 'ts-toolbelt';
|
12
8
|
import '@kubb/swagger/oas';
|
13
9
|
import 'json-schema-to-ts';
|
14
|
-
|
15
|
-
declare function read(path: string): Promise<string>;
|
16
|
-
|
17
|
-
type Options$2 = {
|
18
|
-
sanity?: boolean;
|
19
|
-
};
|
20
|
-
declare function write(data: string, path: string, options?: Options$2): Promise<string | undefined>;
|
21
|
-
|
22
|
-
type BarrelManagerOptions = {
|
23
|
-
treeNode?: DirectoryTreeOptions;
|
24
|
-
isTypeOnly?: boolean;
|
25
|
-
/**
|
26
|
-
* Add .ts or .js
|
27
|
-
*/
|
28
|
-
extName?: KubbFile.Extname;
|
29
|
-
};
|
30
|
-
|
31
|
-
type BasePath<T extends string = string> = `${T}/`;
|
32
|
-
declare namespace KubbFile {
|
33
|
-
type Import = {
|
34
|
-
/**
|
35
|
-
* Import name to be used
|
36
|
-
* @example ["useState"]
|
37
|
-
* @example "React"
|
38
|
-
*/
|
39
|
-
name: string | Array<string | {
|
40
|
-
propertyName: string;
|
41
|
-
name?: string;
|
42
|
-
}>;
|
43
|
-
/**
|
44
|
-
* Path for the import
|
45
|
-
* @xample '@kubb/core'
|
46
|
-
*/
|
47
|
-
path: string;
|
48
|
-
/**
|
49
|
-
* Add `type` prefix to the import, this will result in: `import type { Type } from './path'`.
|
50
|
-
*/
|
51
|
-
isTypeOnly?: boolean;
|
52
|
-
/**
|
53
|
-
* Add `* as` prefix to the import, this will result in: `import * as path from './path'`.
|
54
|
-
*/
|
55
|
-
isNameSpace?: boolean;
|
56
|
-
/**
|
57
|
-
* When root is set it will get the path with relative getRelativePath(root, path).
|
58
|
-
*/
|
59
|
-
root?: string;
|
60
|
-
};
|
61
|
-
type Export = {
|
62
|
-
/**
|
63
|
-
* Export name to be used.
|
64
|
-
* @example ["useState"]
|
65
|
-
* @example "React"
|
66
|
-
*/
|
67
|
-
name?: string | Array<string>;
|
68
|
-
/**
|
69
|
-
* Path for the import.
|
70
|
-
* @xample '@kubb/core'
|
71
|
-
*/
|
72
|
-
path: string;
|
73
|
-
/**
|
74
|
-
* Add `type` prefix to the export, this will result in: `export type { Type } from './path'`.
|
75
|
-
*/
|
76
|
-
isTypeOnly?: boolean;
|
77
|
-
/**
|
78
|
-
* Make it possible to override the name, this will result in: `export * as aliasName from './path'`.
|
79
|
-
*/
|
80
|
-
asAlias?: boolean;
|
81
|
-
};
|
82
|
-
const dataTagSymbol: unique symbol;
|
83
|
-
type DataTag<Type, Value> = Type & {
|
84
|
-
[dataTagSymbol]: Value;
|
85
|
-
};
|
86
|
-
type UUID = string;
|
87
|
-
type Source = string;
|
88
|
-
type Extname = '.ts' | '.js' | '.tsx' | '.json' | `.${string}`;
|
89
|
-
type Mode = 'file' | 'directory';
|
90
|
-
/**
|
91
|
-
* Name to be used to dynamicly create the baseName(based on input.path)
|
92
|
-
* Based on UNIX basename
|
93
|
-
* @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
|
94
|
-
*/
|
95
|
-
type BaseName = `${string}${Extname}`;
|
96
|
-
/**
|
97
|
-
* Path will be full qualified path to a specified file
|
98
|
-
*/
|
99
|
-
type Path = string;
|
100
|
-
type AdvancedPath<T extends BaseName = BaseName> = `${BasePath}${T}`;
|
101
|
-
type OptionalPath = Path | undefined | null;
|
102
|
-
type FileMetaBase = {
|
103
|
-
pluginKey?: Plugin['key'];
|
104
|
-
};
|
105
|
-
type File<TMeta extends FileMetaBase = FileMetaBase, TBaseName extends BaseName = BaseName> = {
|
106
|
-
/**
|
107
|
-
* Unique identifier to reuse later
|
108
|
-
* @default crypto.randomUUID()
|
109
|
-
*/
|
110
|
-
id?: string;
|
111
|
-
/**
|
112
|
-
* Name to be used to create the path
|
113
|
-
* Based on UNIX basename, `${name}.extName`
|
114
|
-
* @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
|
115
|
-
*/
|
116
|
-
baseName: TBaseName;
|
117
|
-
/**
|
118
|
-
* Path will be full qualified path to a specified file
|
119
|
-
*/
|
120
|
-
path: AdvancedPath<TBaseName> | Path;
|
121
|
-
source: Source;
|
122
|
-
imports?: Import[];
|
123
|
-
exports?: Export[];
|
124
|
-
/**
|
125
|
-
* This will call fileManager.add instead of fileManager.addOrAppend, adding the source when the files already exists
|
126
|
-
* This will also ignore the combinefiles utils
|
127
|
-
* @default `false`
|
128
|
-
*/
|
129
|
-
override?: boolean;
|
130
|
-
/**
|
131
|
-
* Use extra meta, this is getting used to generate the barrel/index files.
|
132
|
-
*/
|
133
|
-
meta?: TMeta;
|
134
|
-
/**
|
135
|
-
* This will override `process.env[key]` inside the `source`, see `getFileSource`.
|
136
|
-
*/
|
137
|
-
env?: NodeJS.ProcessEnv;
|
138
|
-
};
|
139
|
-
type ResolvedFile<TMeta extends FileMetaBase = FileMetaBase, TBaseName extends BaseName = BaseName> = KubbFile.File<TMeta, TBaseName> & {
|
140
|
-
/**
|
141
|
-
* @default crypto.randomUUID()
|
142
|
-
*/
|
143
|
-
id: UUID;
|
144
|
-
/**
|
145
|
-
* Contains the first part of the baseName, generated based on baseName
|
146
|
-
* @link https://nodejs.org/api/path.html#pathformatpathobject
|
147
|
-
*/
|
148
|
-
name: string;
|
149
|
-
};
|
150
|
-
}
|
151
|
-
type AddResult<T extends Array<KubbFile.File>> = Promise<Awaited<GreaterThan<T['length'], 1> extends true ? Promise<KubbFile.ResolvedFile[]> : Promise<KubbFile.ResolvedFile>>>;
|
152
|
-
type AddIndexesProps = {
|
153
|
-
/**
|
154
|
-
* Root based on root and output.path specified in the config
|
155
|
-
*/
|
156
|
-
root: string;
|
157
|
-
/**
|
158
|
-
* Output for plugin
|
159
|
-
*/
|
160
|
-
output: {
|
161
|
-
path: string;
|
162
|
-
exportAs?: string;
|
163
|
-
extName?: KubbFile.Extname;
|
164
|
-
exportType?: 'barrel' | 'barrelNamed' | false;
|
165
|
-
};
|
166
|
-
options?: BarrelManagerOptions;
|
167
|
-
meta?: KubbFile.File['meta'];
|
168
|
-
};
|
169
|
-
type Options$1 = {
|
170
|
-
queue?: PQueue;
|
171
|
-
task?: (file: KubbFile.ResolvedFile) => Promise<KubbFile.ResolvedFile>;
|
172
|
-
};
|
173
|
-
declare class FileManager {
|
174
|
-
#private;
|
175
|
-
constructor({ task, queue }?: Options$1);
|
176
|
-
get files(): Array<KubbFile.File>;
|
177
|
-
get isExecuting(): boolean;
|
178
|
-
add<T extends Array<KubbFile.File> = Array<KubbFile.File>>(...files: T): AddResult<T>;
|
179
|
-
addIndexes({ root, output, meta, options }: AddIndexesProps): Promise<void>;
|
180
|
-
getCacheByUUID(UUID: KubbFile.UUID): KubbFile.File | undefined;
|
181
|
-
get(path: KubbFile.Path): Array<KubbFile.File> | undefined;
|
182
|
-
remove(path: KubbFile.Path): void;
|
183
|
-
write(...params: Parameters<typeof write>): Promise<string | undefined>;
|
184
|
-
read(...params: Parameters<typeof read>): Promise<string>;
|
185
|
-
static getSource<TMeta extends KubbFile.FileMetaBase = KubbFile.FileMetaBase>(file: KubbFile.File<TMeta>): string;
|
186
|
-
static combineFiles<TMeta extends KubbFile.FileMetaBase = KubbFile.FileMetaBase>(files: Array<KubbFile.File<TMeta> | null>): Array<KubbFile.File<TMeta>>;
|
187
|
-
static getMode(path: string | undefined | null): KubbFile.Mode;
|
188
|
-
static get extensions(): Array<KubbFile.Extname>;
|
189
|
-
static isExtensionAllowed(baseName: string): boolean;
|
190
|
-
}
|
191
|
-
|
192
|
-
declare class EventEmitter<TEvents extends Record<string, any>> {
|
193
|
-
#private;
|
194
|
-
constructor();
|
195
|
-
emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArg: TEvents[TEventName]): void;
|
196
|
-
on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
197
|
-
off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
198
|
-
removeAll(): void;
|
199
|
-
}
|
200
|
-
|
201
|
-
declare const LogLevel: {
|
202
|
-
readonly silent: "silent";
|
203
|
-
readonly info: "info";
|
204
|
-
readonly debug: "debug";
|
205
|
-
};
|
206
|
-
type LogLevel = keyof typeof LogLevel;
|
207
|
-
type Events$1 = {
|
208
|
-
start: [message: string];
|
209
|
-
end: [message: string];
|
210
|
-
error: [message: string];
|
211
|
-
warning: [message: string];
|
212
|
-
debug: [logs: string[]];
|
213
|
-
};
|
214
|
-
type Logger = {
|
215
|
-
/**
|
216
|
-
* Optional config name to show in CLI output
|
217
|
-
*/
|
218
|
-
name?: string;
|
219
|
-
logLevel: LogLevel;
|
220
|
-
spinner?: Ora;
|
221
|
-
on: EventEmitter<Events$1>['on'];
|
222
|
-
emit: EventEmitter<Events$1>['emit'];
|
223
|
-
};
|
224
|
-
|
225
|
-
type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
226
|
-
/**
|
227
|
-
* Get the type of the first argument in a function.
|
228
|
-
* @example Arg0<(a: string, b: number) => void> -> string
|
229
|
-
*/
|
230
|
-
type Argument0<H extends keyof PluginLifecycle> = Parameters<RequiredPluginLifecycle[H]>[0];
|
231
|
-
type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookReduceArg0' | 'hookSeq';
|
232
|
-
type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
233
|
-
strategy: Strategy;
|
234
|
-
hookName: H;
|
235
|
-
plugin: Plugin;
|
236
|
-
parameters?: unknown[] | undefined;
|
237
|
-
output?: unknown;
|
238
|
-
};
|
239
|
-
type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
|
240
|
-
type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
|
241
|
-
result: Result;
|
242
|
-
plugin: Plugin;
|
243
|
-
};
|
244
|
-
type Options = {
|
245
|
-
logger: Logger;
|
246
|
-
/**
|
247
|
-
* Task for the FileManager
|
248
|
-
*/
|
249
|
-
task: (file: KubbFile.ResolvedFile) => Promise<KubbFile.ResolvedFile>;
|
250
|
-
};
|
251
|
-
type Events = {
|
252
|
-
execute: [executer: Executer];
|
253
|
-
executed: [executer: Executer];
|
254
|
-
error: [error: Error];
|
255
|
-
};
|
256
|
-
declare class PluginManager {
|
257
|
-
#private;
|
258
|
-
readonly plugins: PluginWithLifeCycle[];
|
259
|
-
readonly fileManager: FileManager;
|
260
|
-
readonly events: EventEmitter<Events>;
|
261
|
-
readonly config: Config;
|
262
|
-
readonly executed: Array<Executer>;
|
263
|
-
readonly logger: Logger;
|
264
|
-
readonly queue: PQueue;
|
265
|
-
constructor(config: Config, options: Options);
|
266
|
-
resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => KubbFile.OptionalPath;
|
267
|
-
resolveName: (params: ResolveNameParams) => string;
|
268
|
-
/**
|
269
|
-
* Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
|
270
|
-
*/
|
271
|
-
on<TEventName extends keyof Events & string>(eventName: TEventName, handler: (...eventArg: Events[TEventName]) => void): void;
|
272
|
-
/**
|
273
|
-
* Run a specific hookName for plugin x.
|
274
|
-
*/
|
275
|
-
hookForPlugin<H extends PluginLifecycleHooks>({ pluginKey, hookName, parameters, }: {
|
276
|
-
pluginKey: Plugin['key'];
|
277
|
-
hookName: H;
|
278
|
-
parameters: PluginParameter<H>;
|
279
|
-
}): Promise<Array<ReturnType<ParseResult<H>> | null>> | null;
|
280
|
-
/**
|
281
|
-
* Run a specific hookName for plugin x.
|
282
|
-
*/
|
283
|
-
hookForPluginSync<H extends PluginLifecycleHooks>({ pluginKey, hookName, parameters, }: {
|
284
|
-
pluginKey: Plugin['key'];
|
285
|
-
hookName: H;
|
286
|
-
parameters: PluginParameter<H>;
|
287
|
-
}): Array<ReturnType<ParseResult<H>>> | null;
|
288
|
-
/**
|
289
|
-
* First non-null result stops and will return it's value.
|
290
|
-
*/
|
291
|
-
hookFirst<H extends PluginLifecycleHooks>({ hookName, parameters, skipped, }: {
|
292
|
-
hookName: H;
|
293
|
-
parameters: PluginParameter<H>;
|
294
|
-
skipped?: ReadonlySet<Plugin> | null;
|
295
|
-
}): Promise<SafeParseResult<H>>;
|
296
|
-
/**
|
297
|
-
* First non-null result stops and will return it's value.
|
298
|
-
*/
|
299
|
-
hookFirstSync<H extends PluginLifecycleHooks>({ hookName, parameters, skipped, }: {
|
300
|
-
hookName: H;
|
301
|
-
parameters: PluginParameter<H>;
|
302
|
-
skipped?: ReadonlySet<Plugin> | null;
|
303
|
-
}): SafeParseResult<H>;
|
304
|
-
/**
|
305
|
-
* Run all plugins in parallel(order will be based on `this.plugin` and if `pre` or `post` is set).
|
306
|
-
*/
|
307
|
-
hookParallel<H extends PluginLifecycleHooks, TOuput = void>({ hookName, parameters, }: {
|
308
|
-
hookName: H;
|
309
|
-
parameters?: Parameters<RequiredPluginLifecycle[H]> | undefined;
|
310
|
-
}): Promise<Awaited<TOuput>[]>;
|
311
|
-
/**
|
312
|
-
* Chain all plugins, `reduce` can be passed through to handle every returned value. The return value of the first plugin will be used as the first parameter for the plugin after that.
|
313
|
-
*/
|
314
|
-
hookReduceArg0<H extends PluginLifecycleHooks>({ hookName, parameters, reduce, }: {
|
315
|
-
hookName: H;
|
316
|
-
parameters: PluginParameter<H>;
|
317
|
-
reduce: (reduction: Argument0<H>, result: ReturnType<ParseResult<H>>, plugin: Plugin) => PossiblePromise<Argument0<H> | null>;
|
318
|
-
}): Promise<Argument0<H>>;
|
319
|
-
/**
|
320
|
-
* Chains plugins
|
321
|
-
*/
|
322
|
-
hookSeq<H extends PluginLifecycleHooks>({ hookName, parameters }: {
|
323
|
-
hookName: H;
|
324
|
-
parameters?: PluginParameter<H>;
|
325
|
-
}): Promise<void>;
|
326
|
-
getPluginsByKey(hookName: keyof PluginLifecycle, pluginKey: Plugin['key']): Plugin[];
|
327
|
-
static getDependedPlugins<T1 extends PluginFactoryOptions, T2 extends PluginFactoryOptions = never, T3 extends PluginFactoryOptions = never, TOutput = T3 extends never ? T2 extends never ? [T1: Plugin<T1>] : [T1: Plugin<T1>, T2: Plugin<T2>] : [T1: Plugin<T1>, T2: Plugin<T2>, T3: Plugin<T3>]>(plugins: Array<Plugin>, dependedPluginNames: string | string[]): TOutput;
|
328
|
-
static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "load", "transform", "writeFile", "buildEnd"];
|
329
|
-
}
|
330
|
-
|
331
|
-
interface Cache<TStore extends object = object> {
|
332
|
-
delete(id: keyof TStore): boolean;
|
333
|
-
get(id: keyof TStore): TStore[keyof TStore] | null;
|
334
|
-
has(id: keyof TStore): boolean;
|
335
|
-
set(id: keyof TStore, value: unknown): void;
|
336
|
-
}
|
337
|
-
|
338
|
-
type InputPath = {
|
339
|
-
/**
|
340
|
-
* Path to be used as the input. This can be an absolute path or a path relative to the `root`.
|
341
|
-
*/
|
342
|
-
path: string;
|
343
|
-
};
|
344
|
-
type InputData = {
|
345
|
-
/**
|
346
|
-
* `string` or `object` containing the data.
|
347
|
-
*/
|
348
|
-
data: string | unknown;
|
349
|
-
};
|
350
|
-
type Input = InputPath | InputData;
|
351
|
-
/**
|
352
|
-
* @private
|
353
|
-
*/
|
354
|
-
type Config<TInput = Input> = {
|
355
|
-
/**
|
356
|
-
* Optional config name to show in CLI output
|
357
|
-
*/
|
358
|
-
name?: string;
|
359
|
-
/**
|
360
|
-
* Project root directory. Can be an absolute path, or a path relative from
|
361
|
-
* the location of the config file itself.
|
362
|
-
* @default process.cwd()
|
363
|
-
*/
|
364
|
-
root: string;
|
365
|
-
input: TInput;
|
366
|
-
output: {
|
367
|
-
/**
|
368
|
-
* Path to be used to export all generated files.
|
369
|
-
* This can be an absolute path, or a path relative based of the defined `root` option.
|
370
|
-
*/
|
371
|
-
path: string;
|
372
|
-
/**
|
373
|
-
* Clean output directory before each build.
|
374
|
-
*/
|
375
|
-
clean?: boolean;
|
376
|
-
/**
|
377
|
-
* Write files to the fileSystem
|
378
|
-
* This is being used for the playground.
|
379
|
-
* @default true
|
380
|
-
*/
|
381
|
-
write?: boolean;
|
382
|
-
};
|
383
|
-
/**
|
384
|
-
* Array of Kubb plugins to use.
|
385
|
-
* The plugin/package can forsee some options that you need to pass through.
|
386
|
-
* Sometimes a plugin is depended on another plugin, if that's the case you will get an error back from the plugin you installed.
|
387
|
-
*/
|
388
|
-
plugins?: Array<Plugin>;
|
389
|
-
/**
|
390
|
-
* Hooks that will be called when a specific action is triggered in Kubb.
|
391
|
-
*/
|
392
|
-
hooks?: {
|
393
|
-
/**
|
394
|
-
* Hook that will be triggered at the end of all executions.
|
395
|
-
* Useful for running Prettier or ESLint to format/lint your code.
|
396
|
-
*/
|
397
|
-
done?: string | Array<string>;
|
398
|
-
};
|
399
|
-
};
|
400
|
-
type PluginFactoryOptions<
|
401
|
-
/**
|
402
|
-
* Name to be used for the plugin, this will also be used for they key.
|
403
|
-
*/
|
404
|
-
TName extends string = string,
|
405
|
-
/**
|
406
|
-
* Options of the plugin.
|
407
|
-
*/
|
408
|
-
TOptions extends object = object,
|
409
|
-
/**
|
410
|
-
* Options of the plugin that can be used later on, see `options` inside your plugin config.
|
411
|
-
*/
|
412
|
-
TResolvedOptions extends object = TOptions,
|
413
|
-
/**
|
414
|
-
* API that you want to expose to other plugins.
|
415
|
-
*/
|
416
|
-
TAPI = any,
|
417
|
-
/**
|
418
|
-
* When calling `resolvePath` you can specify better types.
|
419
|
-
*/
|
420
|
-
TResolvePathOptions extends object = object,
|
421
|
-
/**
|
422
|
-
* When using @kubb/react(based on React) you can specify here which types should be used when calling render.
|
423
|
-
* Always extend from `AppMeta` of the core.
|
424
|
-
*/
|
425
|
-
TAppMeta = unknown> = {
|
426
|
-
name: TName;
|
427
|
-
/**
|
428
|
-
* Same behaviour like what has been done with `QueryKey` in `@tanstack/react-query`
|
429
|
-
*/
|
430
|
-
key: [name: TName | string, identifier?: string | number];
|
431
|
-
options: TOptions;
|
432
|
-
resolvedOptions: TResolvedOptions;
|
433
|
-
api: TAPI;
|
434
|
-
resolvePathOptions: TResolvePathOptions;
|
435
|
-
appMeta: {
|
436
|
-
pluginManager: PluginManager;
|
437
|
-
plugin: Plugin<PluginFactoryOptions<TName, TOptions, TResolvedOptions, TAPI, TResolvePathOptions, TAppMeta>>;
|
438
|
-
} & TAppMeta;
|
439
|
-
};
|
440
|
-
type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
441
|
-
/**
|
442
|
-
* Unique name used for the plugin
|
443
|
-
* The name of the plugin follows the format scope:foo-bar or foo-bar, adding scope: can avoid naming conflicts with other plugins.
|
444
|
-
* @example @kubb/typescript
|
445
|
-
*/
|
446
|
-
name: TOptions['name'];
|
447
|
-
/**
|
448
|
-
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
449
|
-
*/
|
450
|
-
options: TOptions['resolvedOptions'];
|
451
|
-
/**
|
452
|
-
* 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.
|
453
|
-
* Can be used to validate depended plugins.
|
454
|
-
*/
|
455
|
-
pre?: Array<string>;
|
456
|
-
/**
|
457
|
-
* 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.
|
458
|
-
*/
|
459
|
-
post?: Array<string>;
|
460
|
-
} & (TOptions['api'] extends never ? {
|
461
|
-
api?: never;
|
462
|
-
} : {
|
463
|
-
api: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['api'];
|
464
|
-
});
|
465
|
-
type UserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions> & PluginLifecycle<TOptions>;
|
466
|
-
type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
467
|
-
/**
|
468
|
-
* Unique name used for the plugin
|
469
|
-
* @example @kubb/typescript
|
470
|
-
*/
|
471
|
-
name: TOptions['name'];
|
472
|
-
/**
|
473
|
-
* Internal key used when a developer uses more than one of the same plugin
|
474
|
-
* @private
|
475
|
-
*/
|
476
|
-
key: TOptions['key'];
|
477
|
-
/**
|
478
|
-
* 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.
|
479
|
-
* Can be used to validate depended plugins.
|
480
|
-
*/
|
481
|
-
pre?: Array<string>;
|
482
|
-
/**
|
483
|
-
* 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.
|
484
|
-
*/
|
485
|
-
post?: Array<string>;
|
486
|
-
/**
|
487
|
-
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
488
|
-
*/
|
489
|
-
options: TOptions['resolvedOptions'];
|
490
|
-
} & (TOptions['api'] extends never ? {
|
491
|
-
api?: never;
|
492
|
-
} : {
|
493
|
-
api: TOptions['api'];
|
494
|
-
});
|
495
|
-
type PluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & PluginLifecycle<TOptions>;
|
496
|
-
type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
497
|
-
/**
|
498
|
-
* Start of the lifecycle of a plugin.
|
499
|
-
* @type hookParallel
|
500
|
-
*/
|
501
|
-
buildStart?: (this: PluginContext<TOptions>, Config: Config) => PossiblePromise<void>;
|
502
|
-
/**
|
503
|
-
* Resolve to a Path based on a baseName(example: `./Pet.ts`) and directory(example: `./models`).
|
504
|
-
* Options can als be included.
|
505
|
-
* @type hookFirst
|
506
|
-
* @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
|
507
|
-
*/
|
508
|
-
resolvePath?: (this: PluginContext<TOptions>, baseName: string, directory?: string, options?: TOptions['resolvePathOptions']) => KubbFile.OptionalPath;
|
509
|
-
/**
|
510
|
-
* Resolve to a name based on a string.
|
511
|
-
* Useful when converting to PascalCase or camelCase.
|
512
|
-
* @type hookFirst
|
513
|
-
* @example ('pet') => 'Pet'
|
514
|
-
*/
|
515
|
-
resolveName?: (this: PluginContext<TOptions>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
516
|
-
/**
|
517
|
-
* Makes it possible to run async logic to override the path defined previously by `resolvePath`.
|
518
|
-
* @type hookFirst
|
519
|
-
*/
|
520
|
-
load?: (this: Omit<PluginContext<TOptions>, 'addFile'>, path: KubbFile.Path) => PossiblePromise<TransformResult | null>;
|
521
|
-
/**
|
522
|
-
* Transform the source-code.
|
523
|
-
* @type hookReduceArg0
|
524
|
-
*/
|
525
|
-
transform?: (this: Omit<PluginContext<TOptions>, 'addFile'>, source: string, path: KubbFile.Path) => PossiblePromise<TransformResult>;
|
526
|
-
/**
|
527
|
-
* Write the result to the file-system based on the id(defined by `resolvePath` or changed by `load`).
|
528
|
-
* @type hookParallel
|
529
|
-
*/
|
530
|
-
writeFile?: (this: Omit<PluginContext<TOptions>, 'addFile'>, source: string | undefined, path: KubbFile.Path) => PossiblePromise<string | void>;
|
531
|
-
/**
|
532
|
-
* End of the plugin lifecycle.
|
533
|
-
* @type hookParallel
|
534
|
-
*/
|
535
|
-
buildEnd?: (this: PluginContext<TOptions>) => PossiblePromise<void>;
|
536
|
-
};
|
537
|
-
type PluginLifecycleHooks = keyof PluginLifecycle;
|
538
|
-
type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
|
539
|
-
type PluginCache = Record<string, [number, unknown]>;
|
540
|
-
type ResolvePathParams<TOptions = object> = {
|
541
|
-
pluginKey?: Plugin['key'];
|
542
|
-
baseName: string;
|
543
|
-
directory?: string | undefined;
|
544
|
-
/**
|
545
|
-
* Options to be passed to 'resolvePath' 3th parameter
|
546
|
-
*/
|
547
|
-
options?: TOptions;
|
548
|
-
};
|
549
|
-
type ResolveNameParams = {
|
550
|
-
name: string;
|
551
|
-
pluginKey?: Plugin['key'];
|
552
|
-
/**
|
553
|
-
* `file` will be used to customize the name of the created file(use of camelCase)
|
554
|
-
* `function` can be used used to customize the exported functions(use of camelCase)
|
555
|
-
* `type` is a special type for TypeScript(use of PascalCase)
|
556
|
-
*/
|
557
|
-
type?: 'file' | 'function' | 'type';
|
558
|
-
};
|
559
|
-
type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
560
|
-
config: Config;
|
561
|
-
cache: Cache<PluginCache>;
|
562
|
-
fileManager: FileManager;
|
563
|
-
pluginManager: PluginManager;
|
564
|
-
addFile: (...file: Array<KubbFile.File>) => Promise<Array<KubbFile.File>>;
|
565
|
-
resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => KubbFile.OptionalPath;
|
566
|
-
resolveName: (params: ResolveNameParams) => string;
|
567
|
-
logger: Logger;
|
568
|
-
/**
|
569
|
-
* All plugins
|
570
|
-
*/
|
571
|
-
plugins: Plugin[];
|
572
|
-
/**
|
573
|
-
* Current plugin
|
574
|
-
*/
|
575
|
-
plugin: Plugin<TOptions>;
|
576
|
-
};
|
577
|
-
type TransformResult = string | null;
|
10
|
+
import '@kubb/types';
|
578
11
|
|
579
12
|
declare const pluginName = "swagger-ts";
|
580
13
|
declare const pluginKey: PluginOptions['key'];
|
581
|
-
declare const definePlugin: (options: Options
|
14
|
+
declare const definePlugin: (options: Options) => _kubb_core.UserPluginWithLifeCycle<PluginOptions>;
|
582
15
|
|
583
|
-
export { Options
|
16
|
+
export { Options, PluginOptions, definePlugin as default, definePlugin, pluginKey, pluginName };
|