@hey-api/shared 0.4.5 → 0.4.7
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/index.d.mts +247 -88
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +516 -271
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
package/dist/index.d.mts
CHANGED
|
@@ -164,6 +164,12 @@ type Input = {
|
|
|
164
164
|
* the first match will be returned.
|
|
165
165
|
*/
|
|
166
166
|
tags?: ReadonlyArray<string>;
|
|
167
|
+
/**
|
|
168
|
+
* **Requires `registry` to be `readme`**
|
|
169
|
+
*
|
|
170
|
+
* The unique identifier for the ReadMe API registry entry.
|
|
171
|
+
*/
|
|
172
|
+
uuid?: string;
|
|
167
173
|
/**
|
|
168
174
|
* **Requires `path` to start with `https://get.heyapi.dev` or be undefined**
|
|
169
175
|
*
|
|
@@ -206,11 +212,8 @@ declare function getInput(userConfig: {
|
|
|
206
212
|
watch?: UserWatch;
|
|
207
213
|
}): ReadonlyArray<Input>;
|
|
208
214
|
//#endregion
|
|
209
|
-
//#region src/config/input/path.d.ts
|
|
210
|
-
declare function compileInputPath(input: Omit<Input, 'watch'>): Pick<Partial<Input>, "api_key" | "branch" | "commit_sha" | "organization" | "project" | "registry" | "tags" | "version"> & Pick<Input, "path">;
|
|
211
|
-
declare function logInputPaths(inputPaths: ReadonlyArray<ReturnType<typeof compileInputPath>>, jobIndex: number): void;
|
|
212
|
-
//#endregion
|
|
213
215
|
//#region src/types/logs.d.ts
|
|
216
|
+
type LogLevel = 'debug' | 'error' | 'fatal' | 'info' | 'silent' | 'trace' | 'warn';
|
|
214
217
|
type Logs = {
|
|
215
218
|
/**
|
|
216
219
|
* Whether or not error logs should be written to a file or not
|
|
@@ -235,7 +238,7 @@ type Logs = {
|
|
|
235
238
|
*
|
|
236
239
|
* @default 'info'
|
|
237
240
|
*/
|
|
238
|
-
level?:
|
|
241
|
+
level?: LogLevel;
|
|
239
242
|
/**
|
|
240
243
|
* The relative location of the logs folder
|
|
241
244
|
*
|
|
@@ -244,8 +247,12 @@ type Logs = {
|
|
|
244
247
|
path?: string;
|
|
245
248
|
};
|
|
246
249
|
//#endregion
|
|
250
|
+
//#region src/config/input/path.d.ts
|
|
251
|
+
declare function compileInputPath(input: Omit<Input, 'watch'>): Pick<Partial<Input>, "api_key" | "branch" | "commit_sha" | "organization" | "project" | "registry" | "tags" | "uuid" | "version"> & Pick<Input, "path">;
|
|
252
|
+
declare function logInputPaths(inputPaths: ReadonlyArray<ReturnType<typeof compileInputPath>>, jobIndex: number, logLevel?: LogLevel): void;
|
|
253
|
+
//#endregion
|
|
247
254
|
//#region src/config/logs.d.ts
|
|
248
|
-
declare function getLogs(
|
|
255
|
+
declare function getLogs(input: string | Logs | undefined): Logs;
|
|
249
256
|
//#endregion
|
|
250
257
|
//#region src/config/output/postprocess.d.ts
|
|
251
258
|
type Output = {
|
|
@@ -291,29 +298,6 @@ type PostProcessor = {
|
|
|
291
298
|
};
|
|
292
299
|
declare function postprocessOutput(config: Output, postProcessors: Record<string, PostProcessor>, jobPrefix: string): void;
|
|
293
300
|
//#endregion
|
|
294
|
-
//#region src/config/utils/config.d.ts
|
|
295
|
-
type ObjectType<T> = Extract<T, Record<string, any>> extends never ? Record<string, any> : Extract<T, Record<string, any>>;
|
|
296
|
-
type NotArray<T> = T extends Array<any> ? never : T;
|
|
297
|
-
type NotFunction<T> = T extends ((...args: Array<any>) => any) ? never : T;
|
|
298
|
-
type PlainObject<T> = T extends object ? NotFunction<T> extends never ? never : NotArray<T> extends never ? never : T : never;
|
|
299
|
-
type MappersType<T> = {
|
|
300
|
-
boolean: T extends boolean ? (value: boolean) => Partial<ObjectType<T>> : never;
|
|
301
|
-
function: T extends ((...args: Array<any>) => any) ? (value: (...args: Array<any>) => any) => Partial<ObjectType<T>> : never;
|
|
302
|
-
number: T extends number ? (value: number) => Partial<ObjectType<T>> : never;
|
|
303
|
-
object?: PlainObject<T> extends never ? never : (value: Partial<PlainObject<T>>, defaultValue: PlainObject<T>) => Partial<ObjectType<T>>;
|
|
304
|
-
string: T extends string ? (value: string) => Partial<ObjectType<T>> : never;
|
|
305
|
-
} extends infer U ? { [K in keyof U as U[K] extends never ? never : K]: U[K] } : never;
|
|
306
|
-
type IsObjectOnly<T> = T extends Record<string, any> | undefined ? Extract<T, string | boolean | number | ((...args: Array<any>) => any)> extends never ? true : false : false;
|
|
307
|
-
type ValueToObject = <T extends undefined | string | boolean | number | ((...args: Array<any>) => any) | Record<string, any>>(args: {
|
|
308
|
-
defaultValue: ObjectType<T>;
|
|
309
|
-
value: T;
|
|
310
|
-
} & (IsObjectOnly<T> extends true ? {
|
|
311
|
-
mappers?: MappersType<T>;
|
|
312
|
-
} : {
|
|
313
|
-
mappers: MappersType<T>;
|
|
314
|
-
})) => PlainObject<T>;
|
|
315
|
-
declare const valueToObject: ValueToObject;
|
|
316
|
-
//#endregion
|
|
317
301
|
//#region src/config/utils/dependencies.d.ts
|
|
318
302
|
type Dependency = {
|
|
319
303
|
/**
|
|
@@ -339,6 +323,152 @@ type Dependency = {
|
|
|
339
323
|
declare const satisfies: typeof semver.satisfies;
|
|
340
324
|
declare function dependencyFactory(dependencies: Record<string, string>): Dependency;
|
|
341
325
|
//#endregion
|
|
326
|
+
//#region src/normalize/coerce.d.ts
|
|
327
|
+
declare const COERCER: unique symbol;
|
|
328
|
+
type Coercer<In = any, Out = any, TContext = unknown> = {
|
|
329
|
+
readonly [COERCER]: (value: In, context: TContext) => Out;
|
|
330
|
+
};
|
|
331
|
+
/**
|
|
332
|
+
* Wraps a function as a coercer — a field-level resolver that receives the
|
|
333
|
+
* raw user value and optional context, and returns the resolved field value.
|
|
334
|
+
*
|
|
335
|
+
* Unlike plain defaults, coercers run unconditionally on every resolution,
|
|
336
|
+
* giving full control over the output regardless of what the user provides.
|
|
337
|
+
*
|
|
338
|
+
* Use when a field's resolved value requires computation, context access,
|
|
339
|
+
* or delegation to another config normalizer.
|
|
340
|
+
*
|
|
341
|
+
* @param fn - Receives the raw input value and resolution context, returns
|
|
342
|
+
* the resolved field value.
|
|
343
|
+
*
|
|
344
|
+
* @example
|
|
345
|
+
* ```ts
|
|
346
|
+
* // Delegate watch resolution to a nested config normalizer
|
|
347
|
+
* watch: coerce((value) => watchConfig(value)),
|
|
348
|
+
*
|
|
349
|
+
* // Resolve a field from context
|
|
350
|
+
* output: coerce((value, ctx) => value ?? ctx.defaultOutput),
|
|
351
|
+
* ```
|
|
352
|
+
*/
|
|
353
|
+
declare function coerce<In, Out, TContext = unknown>(fn: (value: In, context: TContext) => Out): Coercer<In, Out, TContext>;
|
|
354
|
+
declare function isCoercer(value: unknown): value is Coercer;
|
|
355
|
+
//#endregion
|
|
356
|
+
//#region src/normalize/value.d.ts
|
|
357
|
+
type CoercerMap<TShape extends object = object> = {
|
|
358
|
+
boolean?: (value: boolean) => Partial<TShape>;
|
|
359
|
+
function?: (value: (...args: Array<any>) => any) => Partial<TShape>;
|
|
360
|
+
number?: (value: number) => Partial<TShape>;
|
|
361
|
+
string?: (value: string) => Partial<TShape>;
|
|
362
|
+
};
|
|
363
|
+
type CoercionEvent = {
|
|
364
|
+
type: 'boolean';
|
|
365
|
+
value: boolean;
|
|
366
|
+
} | {
|
|
367
|
+
type: 'function';
|
|
368
|
+
value: (...args: Array<any>) => any;
|
|
369
|
+
} | {
|
|
370
|
+
type: 'number';
|
|
371
|
+
value: number;
|
|
372
|
+
} | {
|
|
373
|
+
type: 'object';
|
|
374
|
+
value: Record<string, any>;
|
|
375
|
+
} | {
|
|
376
|
+
type: 'string';
|
|
377
|
+
value: string;
|
|
378
|
+
};
|
|
379
|
+
type TableDirectives<TShape extends object = object, TInput = unknown> = {
|
|
380
|
+
/**
|
|
381
|
+
* Keys resolved first, in order. Their resolved values are available as
|
|
382
|
+
* context to all subsequent fields in the same table.
|
|
383
|
+
*
|
|
384
|
+
* @example
|
|
385
|
+
* ```ts
|
|
386
|
+
* $cascade: ['strategy'],
|
|
387
|
+
* strategy: 'flat',
|
|
388
|
+
* methodName: coerce((value, context) => ({
|
|
389
|
+
* casing: 'camelCase',
|
|
390
|
+
* name: context.strategy === 'flat' ? '{{name}}Request' : undefined,
|
|
391
|
+
* })),
|
|
392
|
+
* ```
|
|
393
|
+
*/
|
|
394
|
+
readonly $cascade?: ReadonlyArray<keyof TShape & string>;
|
|
395
|
+
/**
|
|
396
|
+
* Per-type coercers. Each handler receives the raw user input of the matching
|
|
397
|
+
* type and returns a partial object merged into the resolved config.
|
|
398
|
+
* Applied after `$coerceAny`.
|
|
399
|
+
*
|
|
400
|
+
* @example
|
|
401
|
+
* ```ts
|
|
402
|
+
* $coerce: {
|
|
403
|
+
* string: (v) => ({ name: v }),
|
|
404
|
+
* function: (v) => ({ name: v }),
|
|
405
|
+
* }
|
|
406
|
+
* ```
|
|
407
|
+
*/
|
|
408
|
+
$coerce?: CoercerMap<TShape>;
|
|
409
|
+
/**
|
|
410
|
+
* Fires for any non-`undefined` input before type-specific `$coerce` handlers.
|
|
411
|
+
*
|
|
412
|
+
* @example
|
|
413
|
+
* ```ts
|
|
414
|
+
* $coerceAny: ({ type, value }) => ({ enabled: Boolean(value) })
|
|
415
|
+
* ```
|
|
416
|
+
*/
|
|
417
|
+
$coerceAny?: (event: CoercionEvent) => Partial<TShape>;
|
|
418
|
+
/**
|
|
419
|
+
* Fields whose resolved string values are registered as plugin dependencies
|
|
420
|
+
* after this table is resolved.
|
|
421
|
+
*
|
|
422
|
+
* @example
|
|
423
|
+
* ```ts
|
|
424
|
+
* $dependencies: ['client'],
|
|
425
|
+
* client: coerce((value, context) => context.resolveTag('client')),
|
|
426
|
+
* ```
|
|
427
|
+
*/
|
|
428
|
+
readonly $dependencies?: ReadonlyArray<keyof TShape & string>;
|
|
429
|
+
/**
|
|
430
|
+
* Runs after all fields in this scope have been resolved.
|
|
431
|
+
* Use for cross-field fixups that depend on multiple resolved values.
|
|
432
|
+
*
|
|
433
|
+
* @example
|
|
434
|
+
* ```ts
|
|
435
|
+
* $finalize(config) {
|
|
436
|
+
* if (config.output === 'cjs' && config.format === undefined) {
|
|
437
|
+
* config.format = 'commonjs';
|
|
438
|
+
* }
|
|
439
|
+
* }
|
|
440
|
+
* ```
|
|
441
|
+
*/
|
|
442
|
+
$finalize?: (config: TShape, input: TInput) => void;
|
|
443
|
+
};
|
|
444
|
+
type WithCoercers<T> = [T] extends [(...args: Array<any>) => any] ? T | Coercer<any, T, unknown> : [T] extends [object] ? ({ [K in keyof T]: WithCoercers<T[K]> } & TableDirectives<T>) | Coercer<any, T, unknown> : T | Coercer<any, T, unknown>;
|
|
445
|
+
declare function collectDeps(spec: Record<string, unknown>, resolved: Record<string, unknown>, deps: Set<string>): void;
|
|
446
|
+
//#endregion
|
|
447
|
+
//#region src/normalize/config.d.ts
|
|
448
|
+
type ObjectMember<T> = Extract<T, Record<string, any>> extends infer O ? O extends ((...args: Array<any>) => any) ? never : O : never;
|
|
449
|
+
type TableSpec<Out, In, TContext> = [Out] extends [(...args: Array<any>) => any] ? [NonNullable<In>] extends [Out] ? Out | Coercer<In, Out, TContext> : Coercer<In, Out, TContext> : Coercer<In, Out, TContext> | ([Out] extends [object] ? { [K in keyof Out]?: TableSpec<Out[K], K extends keyof ObjectMember<In> ? ObjectMember<In>[K] : undefined, TContext> } & TableDirectives<Out, In> : [NonNullable<In>] extends [Out] ? Out : never);
|
|
450
|
+
type ConfigTableEntries<TInput, TResolved, TContext = unknown> = { [K in keyof TResolved]?: TableSpec<TResolved[K], K extends keyof ObjectMember<TInput> ? ObjectMember<TInput>[K] : undefined, TContext> };
|
|
451
|
+
type ConfigTable<TInput, TResolved extends object> = ConfigTableEntries<TInput, TResolved> & TableDirectives<TResolved, TInput>;
|
|
452
|
+
type ConfigNormalizer<TInput, TResolved extends object> = ((config: TInput, externalContext?: Record<string, unknown>) => TResolved) & Coercer<TInput | undefined, TResolved>;
|
|
453
|
+
/**
|
|
454
|
+
* Creates a typed config normalizer from a resolution table.
|
|
455
|
+
*
|
|
456
|
+
* @example
|
|
457
|
+
* ```ts
|
|
458
|
+
* const normalizePlugin = defineConfig<PluginInput, PluginResolved>({
|
|
459
|
+
* $coerce: {
|
|
460
|
+
* boolean: (enabled) => ({ enabled }),
|
|
461
|
+
* function: (name) => ({ name, enabled: true }),
|
|
462
|
+
* string: (name) => ({ name, enabled: true }),
|
|
463
|
+
* },
|
|
464
|
+
* enabled: false,
|
|
465
|
+
* name: '',
|
|
466
|
+
* output: coerce((val, ctx) => val ?? ctx.defaultOutput),
|
|
467
|
+
* });
|
|
468
|
+
* ```
|
|
469
|
+
*/
|
|
470
|
+
declare function defineConfig<TInput = Record<string, unknown>, TResolved extends object = Record<string, unknown>>(table: ConfigTable<TInput, TResolved> | ((config: TInput) => ConfigTable<TInput, TResolved>)): ConfigNormalizer<TInput, TResolved>;
|
|
471
|
+
//#endregion
|
|
342
472
|
//#region src/ir/mediaType.d.ts
|
|
343
473
|
type IRMediaType = 'form-data' | 'json' | 'text' | 'url-search-params' | 'octet-stream';
|
|
344
474
|
//#endregion
|
|
@@ -503,7 +633,15 @@ interface IRSchemaObject extends Pick<JSONSchemaDraft2020_12.Document, '$ref' |
|
|
|
503
633
|
*/
|
|
504
634
|
type?: 'array' | 'boolean' | 'enum' | 'integer' | 'never' | 'null' | 'number' | 'object' | 'string' | 'tuple' | 'undefined' | 'unknown' | 'void';
|
|
505
635
|
}
|
|
506
|
-
type IRSecurityObject = OpenAPIV3_1.SecuritySchemeObject
|
|
636
|
+
type IRSecurityObject = OpenAPIV3_1.SecuritySchemeObject & {
|
|
637
|
+
/**
|
|
638
|
+
* Name of the entry under `components.securitySchemes` that this security
|
|
639
|
+
* object came from. Populated only when the spec defines two or more
|
|
640
|
+
* security schemes whose canonical `Auth` shape would otherwise collide,
|
|
641
|
+
* so consumers can disambiguate which token to return at runtime.
|
|
642
|
+
*/
|
|
643
|
+
key?: string;
|
|
644
|
+
};
|
|
507
645
|
interface IRServerObject extends OpenAPIV3_1.ServerObject {}
|
|
508
646
|
type IRWebhookObject = IRPathItemObject;
|
|
509
647
|
interface IRModel {
|
|
@@ -844,7 +982,7 @@ declare class PluginInstance<T extends Plugin.Types = Plugin.Types> {
|
|
|
844
982
|
api: T['api'];
|
|
845
983
|
config: Omit<T['resolvedConfig'], 'name'>;
|
|
846
984
|
context: Context;
|
|
847
|
-
dependencies:
|
|
985
|
+
dependencies: Set<AnyPluginName>;
|
|
848
986
|
private eventHooks;
|
|
849
987
|
gen: IProject;
|
|
850
988
|
private handler;
|
|
@@ -856,11 +994,13 @@ declare class PluginInstance<T extends Plugin.Types = Plugin.Types> {
|
|
|
856
994
|
* code generation.
|
|
857
995
|
*/
|
|
858
996
|
package: Dependency;
|
|
859
|
-
|
|
860
|
-
|
|
997
|
+
/** Symbols declared in the plugin config. */
|
|
998
|
+
symbols: T['symbols'];
|
|
999
|
+
constructor(props: Pick<Plugin.Config<T>, 'api' | 'handler' | 'name' | 'symbols'> & {
|
|
1000
|
+
config: Omit<T['resolvedConfig'], 'name'>;
|
|
861
1001
|
context: Context;
|
|
1002
|
+
dependencies: Set<AnyPluginName>;
|
|
862
1003
|
gen: IProject;
|
|
863
|
-
name: string;
|
|
864
1004
|
});
|
|
865
1005
|
external(resource: Required<SymbolMeta>['resource'], meta?: Omit<SymbolMeta, 'category' | 'resource'>): Symbol;
|
|
866
1006
|
/**
|
|
@@ -928,8 +1068,8 @@ declare class PluginInstance<T extends Plugin.Types = Plugin.Types> {
|
|
|
928
1068
|
* @returns The index of the added node or void if updated.
|
|
929
1069
|
*/
|
|
930
1070
|
node<T extends number | undefined = undefined>(node: Node | null, index?: T): T extends number ? void : number;
|
|
931
|
-
querySymbol(filter: SymbolMeta): Symbol<
|
|
932
|
-
querySymbols(filter: SymbolMeta): Array<Symbol<
|
|
1071
|
+
querySymbol<TNode extends Node = ResolvedNode>(filter: SymbolMeta, tags?: ReadonlyArray<NonNullable<TNode['~dsl']>>, predicate?: (symbol: Symbol<TNode>) => boolean): Symbol<TNode> | undefined;
|
|
1072
|
+
querySymbols<TNode extends Node = ResolvedNode>(filter: SymbolMeta, tags?: ReadonlyArray<NonNullable<TNode['~dsl']>>, predicate?: (symbol: Symbol<TNode>) => boolean): Array<Symbol<TNode>>;
|
|
933
1073
|
referenceSymbol(meta: SymbolMeta): Symbol<ResolvedNode>;
|
|
934
1074
|
/**
|
|
935
1075
|
* Alias for `symbol()` method with single argument.
|
|
@@ -947,6 +1087,7 @@ declare class PluginInstance<T extends Plugin.Types = Plugin.Types> {
|
|
|
947
1087
|
*/
|
|
948
1088
|
symbolOnce(name: SymbolIn['name'], symbol?: Omit<SymbolIn, 'name'>): Symbol;
|
|
949
1089
|
private buildEventHooks;
|
|
1090
|
+
private buildSymbols;
|
|
950
1091
|
private forEachError;
|
|
951
1092
|
private getSymbolExportFromFilePath;
|
|
952
1093
|
private getSymbolFilePath;
|
|
@@ -1213,13 +1354,45 @@ interface PluginConfigMap {}
|
|
|
1213
1354
|
type PluginNames = keyof PluginConfigMap extends never ? string : keyof PluginConfigMap;
|
|
1214
1355
|
type AnyPluginName = PluginNames | AnyString;
|
|
1215
1356
|
type PluginTag = 'client' | 'mocker' | 'sdk' | 'transformer' | 'validator';
|
|
1357
|
+
type ResolveTagOptions<T extends AnyPluginName = AnyPluginName> = {
|
|
1358
|
+
/**
|
|
1359
|
+
* Plugin to use if no plugin with the given tag is found in the user's
|
|
1360
|
+
* plugin list. Must itself carry the requested tag. If it does not exist
|
|
1361
|
+
* in the registry, resolution falls through to `fallback`.
|
|
1362
|
+
*/
|
|
1363
|
+
defaultPlugin?: T;
|
|
1364
|
+
/**
|
|
1365
|
+
* Value returned when no matching plugin is found and `defaultPlugin` is
|
|
1366
|
+
* absent or also unresolvable. Defaults to `false`.
|
|
1367
|
+
*/
|
|
1368
|
+
fallback?: T | false;
|
|
1369
|
+
/**
|
|
1370
|
+
* Warning message emitted when resolution falls back.
|
|
1371
|
+
*/
|
|
1372
|
+
warn?: string;
|
|
1373
|
+
};
|
|
1216
1374
|
type PluginContext = {
|
|
1217
1375
|
package: Dependency;
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1376
|
+
/**
|
|
1377
|
+
* Resolves the first plugin in the user's plugin list that carries `tag`.
|
|
1378
|
+
* Falls back to `options.defaultPlugin` if provided and registered, then
|
|
1379
|
+
* to `options.fallback` (default: `false`).
|
|
1380
|
+
*
|
|
1381
|
+
* @example
|
|
1382
|
+
* ```ts
|
|
1383
|
+
* client: coerce((value, context) => {
|
|
1384
|
+
* if (value === false) return false;
|
|
1385
|
+
* if (typeof value === 'string') return value;
|
|
1386
|
+
* return (context as PluginContext).resolveTag('client', {
|
|
1387
|
+
* defaultPlugin: '@hey-api/client-httpx',
|
|
1388
|
+
* });
|
|
1389
|
+
* }),
|
|
1390
|
+
* ```
|
|
1391
|
+
*/
|
|
1392
|
+
resolveTag: <T extends AnyPluginName = AnyPluginName>(tag: PluginTag, options?: ResolveTagOptions<T>) => T | false;
|
|
1393
|
+
};
|
|
1394
|
+
type PluginSymbols = {
|
|
1395
|
+
[key: string]: Symbol | PluginSymbols;
|
|
1223
1396
|
};
|
|
1224
1397
|
type BaseApi = Record<string, unknown>;
|
|
1225
1398
|
type PluginBaseConfig = UserIndexExportOption & {
|
|
@@ -1232,12 +1405,10 @@ type PluginBaseConfig = UserIndexExportOption & {
|
|
|
1232
1405
|
*/
|
|
1233
1406
|
'~hooks'?: Hooks;
|
|
1234
1407
|
};
|
|
1235
|
-
/**
|
|
1236
|
-
* Public Plugin API.
|
|
1237
|
-
*/
|
|
1408
|
+
/** Public Plugin API. */
|
|
1238
1409
|
declare namespace Plugin {
|
|
1239
1410
|
type Config<T extends Types> = Pick<T, 'api'> & {
|
|
1240
|
-
config: Omit<T['config'], 'name'>;
|
|
1411
|
+
config: ConfigTable<Omit<T['config'], 'name'>, T['resolvedConfig']>;
|
|
1241
1412
|
/**
|
|
1242
1413
|
* Dependency plugins will be always processed, regardless of whether user
|
|
1243
1414
|
* explicitly defines them in their `plugins` config.
|
|
@@ -1248,13 +1419,9 @@ declare namespace Plugin {
|
|
|
1248
1419
|
}) => void;
|
|
1249
1420
|
name: T['config']['name'];
|
|
1250
1421
|
/**
|
|
1251
|
-
*
|
|
1252
|
-
* example, when `validator` is set to `true`, it figures out which plugin
|
|
1253
|
-
* should be used for validation.
|
|
1422
|
+
* Symbols this plugin registers at construction time.
|
|
1254
1423
|
*/
|
|
1255
|
-
|
|
1256
|
-
dependencies: Set<AnyPluginName>;
|
|
1257
|
-
}, context: PluginContext) => void;
|
|
1424
|
+
symbols?: (plugin: PluginInstance<T>) => T['symbols'];
|
|
1258
1425
|
/**
|
|
1259
1426
|
* Tags can be used to help with deciding plugin order and resolving
|
|
1260
1427
|
* plugin configuration options.
|
|
@@ -1265,9 +1432,7 @@ declare namespace Plugin {
|
|
|
1265
1432
|
type UserComments = UserCommentsOption;
|
|
1266
1433
|
type Exports = IndexExportOption;
|
|
1267
1434
|
type UserExports = UserIndexExportOption;
|
|
1268
|
-
/**
|
|
1269
|
-
* Generic wrapper for plugin hooks.
|
|
1270
|
-
*/
|
|
1435
|
+
/** Generic wrapper for plugin hooks. */
|
|
1271
1436
|
type Hooks = Pick<PluginBaseConfig, '~hooks'>;
|
|
1272
1437
|
interface Name<Name extends PluginNames> {
|
|
1273
1438
|
name: Name;
|
|
@@ -1289,27 +1454,31 @@ declare namespace Plugin {
|
|
|
1289
1454
|
'~resolvers'?: T;
|
|
1290
1455
|
};
|
|
1291
1456
|
interface ResolverNodes<T> {
|
|
1292
|
-
/**
|
|
1293
|
-
* Nodes used to build different parts of the result.
|
|
1294
|
-
*/
|
|
1457
|
+
/** Nodes used to build different parts of the result. */
|
|
1295
1458
|
nodes: T;
|
|
1296
1459
|
}
|
|
1297
|
-
|
|
1460
|
+
/** Resolved plugin shape stored in Config['plugins'] after processing. */
|
|
1461
|
+
type Stored<T extends Types> = Omit<Plugin.Config<T>, 'config' | 'dependencies'> & {
|
|
1462
|
+
config: T['resolvedConfig'];
|
|
1463
|
+
dependencies: Set<AnyPluginName>;
|
|
1464
|
+
};
|
|
1465
|
+
type Types<Config extends PluginBaseConfig = PluginBaseConfig, ResolvedConfig extends PluginBaseConfig = Config, Api extends BaseApi = never, Symbols extends PluginSymbols = Record<never, never>> = ([Api] extends [never] ? {
|
|
1298
1466
|
api?: BaseApi;
|
|
1299
1467
|
} : {
|
|
1300
1468
|
api: Api;
|
|
1301
1469
|
}) & {
|
|
1302
1470
|
config: Config;
|
|
1303
1471
|
resolvedConfig: ResolvedConfig;
|
|
1472
|
+
symbols: Symbols;
|
|
1304
1473
|
};
|
|
1305
1474
|
}
|
|
1306
|
-
type DefinePlugin<Config extends PluginBaseConfig = PluginBaseConfig, ResolvedConfig extends PluginBaseConfig = Config, Api extends BaseApi = never
|
|
1307
|
-
Config: Plugin.Config<Plugin.Types<Config, ResolvedConfig, Api>>;
|
|
1475
|
+
type DefinePlugin<Config extends PluginBaseConfig = PluginBaseConfig, ResolvedConfig extends PluginBaseConfig = Config, Api extends BaseApi = never, Symbols extends PluginSymbols = Record<never, never>> = {
|
|
1476
|
+
Config: Plugin.Config<Plugin.Types<Config, ResolvedConfig, Api, Symbols>>;
|
|
1308
1477
|
Handler: (args: {
|
|
1309
|
-
plugin: PluginInstance<Plugin.Types<Config, ResolvedConfig, Api>>;
|
|
1478
|
+
plugin: PluginInstance<Plugin.Types<Config, ResolvedConfig, Api, Symbols>>;
|
|
1310
1479
|
}) => void; /** The plugin instance. */
|
|
1311
|
-
Instance: PluginInstance<Plugin.Types<Config, ResolvedConfig, Api>>;
|
|
1312
|
-
Types: Plugin.Types<Config, ResolvedConfig, Api>;
|
|
1480
|
+
Instance: PluginInstance<Plugin.Types<Config, ResolvedConfig, Api, Symbols>>;
|
|
1481
|
+
Types: Plugin.Types<Config, ResolvedConfig, Api, Symbols>;
|
|
1313
1482
|
};
|
|
1314
1483
|
//#endregion
|
|
1315
1484
|
//#region src/config/output/types.d.ts
|
|
@@ -2387,13 +2556,11 @@ type SourceConfig = FeatureToggle & {
|
|
|
2387
2556
|
};
|
|
2388
2557
|
//#endregion
|
|
2389
2558
|
//#region src/config/output/source/config.d.ts
|
|
2390
|
-
declare
|
|
2391
|
-
source?: boolean | UserSourceConfig;
|
|
2392
|
-
}): SourceConfig;
|
|
2559
|
+
declare const sourceConfig: ConfigNormalizer<boolean | UserSourceConfig, SourceConfig>;
|
|
2393
2560
|
//#endregion
|
|
2394
2561
|
//#region src/config/parser/config.d.ts
|
|
2395
2562
|
declare const defaultPaginationKeywords: readonly ["after", "before", "cursor", "offset", "page", "start"];
|
|
2396
|
-
declare function getParser(
|
|
2563
|
+
declare function getParser(input: {
|
|
2397
2564
|
parser?: UserParser;
|
|
2398
2565
|
}): Parser;
|
|
2399
2566
|
//#endregion
|
|
@@ -2922,7 +3089,8 @@ type PluginDefinition<TConfig extends PluginConfig = PluginConfig> = PluginNames
|
|
|
2922
3089
|
declare function warnOnConflictingDuplicatePlugins<TConfig extends PluginConfig>(plugins: ReadonlyArray<PluginDefinition<TConfig>>): void;
|
|
2923
3090
|
//#endregion
|
|
2924
3091
|
//#region src/plugins/shared/utils/config.d.ts
|
|
2925
|
-
declare
|
|
3092
|
+
declare function definePluginConfig<T extends Plugin.Types>(pluginConfig: Plugin.Config<T>): (userConfig?: Omit<T["config"], "name">) => {
|
|
3093
|
+
config: Plugin.Config<T>["config"];
|
|
2926
3094
|
/**
|
|
2927
3095
|
* Cast name to `any` so it doesn't throw type error in `plugins` array.
|
|
2928
3096
|
* We could allow any `string` as plugin `name` in the object syntax, but
|
|
@@ -2930,25 +3098,13 @@ declare const definePluginConfig: <T extends Plugin.Types>(defaultConfig: Plugin
|
|
|
2930
3098
|
* suggested auto completions, which is undesirable.
|
|
2931
3099
|
*/
|
|
2932
3100
|
name: any;
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
};
|
|
2941
|
-
readonly function: (name: (...args: Array<any>) => any) => {
|
|
2942
|
-
enabled: boolean;
|
|
2943
|
-
name: (...args: Array<any>) => any;
|
|
2944
|
-
};
|
|
2945
|
-
readonly object: (fields: Record<string, any>) => {
|
|
2946
|
-
enabled: boolean;
|
|
2947
|
-
};
|
|
2948
|
-
readonly string: (name: string) => {
|
|
2949
|
-
enabled: boolean;
|
|
2950
|
-
name: string;
|
|
2951
|
-
};
|
|
3101
|
+
api?: T["api"] | undefined;
|
|
3102
|
+
dependencies?: ReadonlyArray<AnyPluginName>;
|
|
3103
|
+
handler: (args: {
|
|
3104
|
+
plugin: PluginInstance<T>;
|
|
3105
|
+
}) => void;
|
|
3106
|
+
symbols?: ((plugin: PluginInstance<T>) => T["symbols"]) | undefined;
|
|
3107
|
+
tags?: ReadonlyArray<PluginTag>;
|
|
2952
3108
|
};
|
|
2953
3109
|
//#endregion
|
|
2954
3110
|
//#region src/plugins/symbol.d.ts
|
|
@@ -3159,6 +3315,9 @@ declare class MinHeap {
|
|
|
3159
3315
|
private sinkDown;
|
|
3160
3316
|
}
|
|
3161
3317
|
//#endregion
|
|
3318
|
+
//#region src/utils/object.d.ts
|
|
3319
|
+
declare function isPlainObject(value: unknown): value is Record<string, any>;
|
|
3320
|
+
//#endregion
|
|
3162
3321
|
//#region src/utils/path.d.ts
|
|
3163
3322
|
interface PathToNameOptions {
|
|
3164
3323
|
/**
|
|
@@ -3265,5 +3424,5 @@ interface Url {
|
|
|
3265
3424
|
}
|
|
3266
3425
|
declare function parseUrl(value: string): Url;
|
|
3267
3426
|
//#endregion
|
|
3268
|
-
export { type AnyConfig, type AnyPluginName, type BaseConfig, type BaseOutput, type BaseUserConfig, type BaseUserOutput, type Casing, type CommentsOption, ConfigError, ConfigValidationError, Context, type DefaultRequestValidatorLayers, type DefaultValidatorLayers, type DefinePlugin, type Dependency, type FeatureToggle, type Filters, type GetNameContext, HeyApiError, type Hooks, type IR, type IRModel, type IROperationObject, type IRParameterObject, type IRParametersObject, type IRSchemaObject, type IRServerObject, type IndexExportOption, type Input, InputError, IntentContext, JobError, type Logs, MinHeap, type NameTransformer, type NamingConfig, type NamingOptions, type NamingRule, type OpenApi, type OpenApiMetaObject, type OpenApiOperationObject, type OpenApiParameterObject, type OpenApiRequestBodyObject, type OpenApiResponseObject, type OpenApiSchemaObject, OperationPath, type OperationPathStrategy, OperationStrategy, type OperationStructureStrategy, type OperationsStrategy, type OutputHeader, type Parser, type Patch, type Plugin, type PluginConfigMap, type PluginContext, PluginInstance, type PluginInstanceTypes, type PluginNames, type PostProcessor, type RequestSchemaContext, type RequestValidatorLayer, type RequestValidatorLayers, type ResolveModuleFn, type ResolvedRequestValidatorLayer, type SchemaExtractor, type SchemaProcessor, type SchemaProcessorContext, type SchemaProcessorResult, type SchemaVisitor, type SchemaVisitorContext, type SchemaWithType, type SourceConfig, type UserCommentsOption, type UserIndexExportOption, type UserInput, type UserParser, type UserPostProcessor, type UserSourceConfig, type UserWatch, type ValidatorLayers, type
|
|
3427
|
+
export { type AnyConfig, type AnyPluginName, type BaseConfig, type BaseOutput, type BaseUserConfig, type BaseUserOutput, COERCER, type Casing, type Coercer, type CoercerMap, type CommentsOption, ConfigError, type ConfigNormalizer, type ConfigTable, ConfigValidationError, Context, type DefaultRequestValidatorLayers, type DefaultValidatorLayers, type DefinePlugin, type Dependency, type FeatureToggle, type Filters, type GetNameContext, HeyApiError, type Hooks, type IR, type IRModel, type IROperationObject, type IRParameterObject, type IRParametersObject, type IRSchemaObject, type IRServerObject, type IndexExportOption, type Input, InputError, IntentContext, JobError, type LogLevel, type Logs, MinHeap, type NameTransformer, type NamingConfig, type NamingOptions, type NamingRule, type OpenApi, type OpenApiMetaObject, type OpenApiOperationObject, type OpenApiParameterObject, type OpenApiRequestBodyObject, type OpenApiResponseObject, type OpenApiSchemaObject, OperationPath, type OperationPathStrategy, OperationStrategy, type OperationStructureStrategy, type OperationsStrategy, type OutputHeader, type Parser, type Patch, type Plugin, type PluginConfigMap, type PluginContext, PluginInstance, type PluginInstanceTypes, type PluginNames, type PluginSymbols, type PluginTag, type PostProcessor, type RequestSchemaContext, type RequestValidatorLayer, type RequestValidatorLayers, type ResolveModuleFn, type ResolvedRequestValidatorLayer, type SchemaExtractor, type SchemaProcessor, type SchemaProcessorContext, type SchemaProcessorResult, type SchemaVisitor, type SchemaVisitorContext, type SchemaWithType, type SourceConfig, type TableDirectives, type UserCommentsOption, type UserIndexExportOption, type UserInput, type UserParser, type UserPostProcessor, type UserSourceConfig, type UserWatch, type ValidatorLayers, type Walker, type Watch, type WatchValues, type WithCoercers, addItemsToSchema, applyNaming, buildGraph, buildSymbolIn, checkNodeVersion, childContext, coerce, collectDeps, compileInputPath, createOperationKey, createSchemaProcessor, createSchemaWalker, debugTools, deduplicateSchema, defaultPaginationKeywords, defineConfig, definePluginConfig, dependencyFactory, encodeJsonPointerSegment, ensureDirSync, escapeComment, findPackageJson, findTsConfigPath, getInput, getInputError, getLogs, getParser, getSpec, hasOperationDataRequired, hasParameterGroupObjectRequired, hasParametersObjectRequired, heyApiRegistryBaseUrl, inputToApiRegistry, isCoercer, isEnvironment, isPlainObject, isTopLevelComponent, jsonPointerToPath, loadPackageJson, logCrashReport, logInputPaths, normalizeJsonPointer, openGitHubIssueWithCrashReport, operationPagination, operationResponsesMap, outputHeaderToPrefix, parameterWithPagination, parseOpenApiSpec, parseUrl, parseV2_0_X, parseV3_0_X, parseV3_1_X, patchOpenApiSpec, pathToJsonPointer, pathToName, postprocessOutput, printCliIntro, printCrashReport, refToName, requestValidatorLayers, resolveNaming, resolveRef, resolveValidatorLayer, satisfies, shouldReportCrash, sourceConfig, statusCodeToGroup, toCase, utils, warnOnConflictingDuplicatePlugins };
|
|
3269
3428
|
//# sourceMappingURL=index.d.mts.map
|