@hey-api/shared 0.4.8 → 0.5.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/index.d.mts +185 -82
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +319 -196
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -2,8 +2,8 @@ import { PathLike } from "node:fs";
|
|
|
2
2
|
import * as semver from "semver";
|
|
3
3
|
import { RangeOptions, SemVer } from "semver";
|
|
4
4
|
import { getResolvedInput } from "@hey-api/json-schema-ref-parser";
|
|
5
|
-
import { IProject, Logger, NameConflictResolver, Node, Project, Ref, RenderContext, StructureLocation, Symbol, SymbolIdentifier, SymbolIn, SymbolMeta } from "@hey-api/codegen-core";
|
|
6
|
-
import { AnyString, MaybeArray, MaybeFunc, MaybePromise } from "@hey-api/types";
|
|
5
|
+
import { IProject, Logger, NameConflictResolver, Node, Project, Ref, RenderContext, StructureLocation, Symbol, SymbolIdentifier, SymbolIn, SymbolMeta, log } from "@hey-api/codegen-core";
|
|
6
|
+
import { AnyObject, AnyString, MaybeArray, MaybeFunc, MaybePromise } from "@hey-api/types";
|
|
7
7
|
import { CodeSampleObject, JSONSchemaDraft2020_12, OpenAPIV2, OpenAPIV3, OpenAPIV3_1, SpecExtensions } from "@hey-api/spec-types";
|
|
8
8
|
|
|
9
9
|
//#region src/cli.d.ts
|
|
@@ -585,6 +585,7 @@ interface IRSchemaObject extends Pick<JSONSchemaDraft2020_12.Document, '$ref' |
|
|
|
585
585
|
* discriminator for polymorphism.
|
|
586
586
|
*/
|
|
587
587
|
discriminator?: {
|
|
588
|
+
mapping?: Record<string, string>;
|
|
588
589
|
propertyName: string;
|
|
589
590
|
};
|
|
590
591
|
/**
|
|
@@ -845,25 +846,15 @@ declare class Context<Spec extends Record<string, any> = any, Config extends Any
|
|
|
845
846
|
* is a mix of user-provided and default values.
|
|
846
847
|
*/
|
|
847
848
|
config: Config;
|
|
848
|
-
/**
|
|
849
|
-
* The code generation project instance used to manage files, symbols,
|
|
850
|
-
*/
|
|
849
|
+
/** The code generation project instance used to manage files, symbols, */
|
|
851
850
|
gen: Project;
|
|
852
|
-
/**
|
|
853
|
-
* The dependency graph built from the intermediate representation.
|
|
854
|
-
*/
|
|
851
|
+
/** The dependency graph built from the intermediate representation. */
|
|
855
852
|
graph: Graph | undefined;
|
|
856
|
-
/**
|
|
857
|
-
* Intents declared by plugins.
|
|
858
|
-
*/
|
|
853
|
+
/** Intents declared by plugins. */
|
|
859
854
|
intents: Array<ExampleIntent>;
|
|
860
|
-
/**
|
|
861
|
-
* Intermediate representation model obtained from `spec`.
|
|
862
|
-
*/
|
|
855
|
+
/** Intermediate representation model obtained from `spec`. */
|
|
863
856
|
ir: IR.Model;
|
|
864
|
-
/**
|
|
865
|
-
* Logger instance.
|
|
866
|
-
*/
|
|
857
|
+
/** Logger instance. */
|
|
867
858
|
logger: Logger;
|
|
868
859
|
/**
|
|
869
860
|
* The package metadata and utilities for the current context, constructed
|
|
@@ -878,9 +869,7 @@ declare class Context<Spec extends Record<string, any> = any, Config extends Any
|
|
|
878
869
|
* their configured name from the config.
|
|
879
870
|
*/
|
|
880
871
|
plugins: Partial<Record<PluginNames, PluginInstance<PluginConfigMap[keyof PluginConfigMap]>>>;
|
|
881
|
-
/**
|
|
882
|
-
* Resolved specification from `input`.
|
|
883
|
-
*/
|
|
872
|
+
/** Resolved specification from `input`. */
|
|
884
873
|
spec: Spec;
|
|
885
874
|
constructor({
|
|
886
875
|
config,
|
|
@@ -944,7 +933,6 @@ declare class SymbolFactory {
|
|
|
944
933
|
project: IProject;
|
|
945
934
|
});
|
|
946
935
|
static buildEventHooks(scopes: ReadonlyArray<NonNullable<Hooks['events']> | undefined>): EventHooks;
|
|
947
|
-
external(resource: Required<SymbolMeta>['resource'], meta?: Omit<SymbolMeta, 'category' | 'resource'>): Symbol;
|
|
948
936
|
isRegistered(identifier: SymbolIdentifier): boolean;
|
|
949
937
|
query<TNode extends Node = ResolvedNode>(filter: SymbolMeta, tags?: ReadonlyArray<NonNullable<TNode['~dsl']>>, predicate?: (symbol: Symbol<TNode>) => boolean): Symbol<TNode> | undefined;
|
|
950
938
|
queryAll<TNode extends Node = ResolvedNode>(filter: SymbolMeta, tags?: ReadonlyArray<NonNullable<TNode['~dsl']>>, predicate?: (symbol: Symbol<TNode>) => boolean): Array<Symbol<TNode>>;
|
|
@@ -1006,6 +994,8 @@ declare class PluginInstance<T extends Plugin.Types = Plugin.Types> {
|
|
|
1006
994
|
private eventHooks;
|
|
1007
995
|
gen: IProject;
|
|
1008
996
|
private handler;
|
|
997
|
+
/** External symbols imported from other modules. */
|
|
998
|
+
imports: T['imports'];
|
|
1009
999
|
name: T['resolvedConfig']['name'];
|
|
1010
1000
|
/**
|
|
1011
1001
|
* The package metadata and utilities for the current context, constructed
|
|
@@ -1016,14 +1006,12 @@ declare class PluginInstance<T extends Plugin.Types = Plugin.Types> {
|
|
|
1016
1006
|
package: Dependency;
|
|
1017
1007
|
/** Factory for creating and managing symbols. */
|
|
1018
1008
|
symbolFactory: SymbolFactory;
|
|
1019
|
-
/**
|
|
1020
|
-
|
|
1021
|
-
readonly external: SymbolFactory['external'];
|
|
1009
|
+
/** Metadata merged into every symbol this plugin creates. */
|
|
1010
|
+
symbolMeta: Plugin.Config<T>['symbolMeta'];
|
|
1022
1011
|
readonly isSymbolRegistered: SymbolFactory['isRegistered'];
|
|
1023
1012
|
readonly querySymbol: SymbolFactory['query'];
|
|
1024
|
-
readonly querySymbols: SymbolFactory['queryAll'];
|
|
1025
1013
|
readonly referenceSymbol: SymbolFactory['reference'];
|
|
1026
|
-
constructor(props: Pick<Plugin.Config<T>, 'api' | 'handler' | 'name' | '
|
|
1014
|
+
constructor(props: Pick<Plugin.Config<T>, 'api' | 'handler' | 'imports' | 'name' | 'symbolMeta'> & {
|
|
1027
1015
|
config: Omit<T['resolvedConfig'], 'name'>;
|
|
1028
1016
|
context: Context;
|
|
1029
1017
|
dependencies: Set<AnyPluginName>;
|
|
@@ -1093,15 +1081,12 @@ declare class PluginInstance<T extends Plugin.Types = Plugin.Types> {
|
|
|
1093
1081
|
* @returns The index of the added node or void if updated.
|
|
1094
1082
|
*/
|
|
1095
1083
|
node<T extends number | undefined = undefined>(node: Node | null, index?: T): T extends number ? void : number;
|
|
1096
|
-
/**
|
|
1097
|
-
* Alias for `symbol()` method with single argument.
|
|
1098
|
-
*/
|
|
1099
|
-
registerSymbol(symbol: SymbolIn): Symbol<ResolvedNode>;
|
|
1100
1084
|
/**
|
|
1101
1085
|
* Executes plugin's handler function.
|
|
1102
1086
|
*/
|
|
1103
1087
|
run(): Promise<void>;
|
|
1104
1088
|
symbol(name: SymbolIn['name'], symbol?: Omit<SymbolIn, 'name'>): Symbol<ResolvedNode>;
|
|
1089
|
+
symbol(symbol: SymbolIn): Symbol<ResolvedNode>;
|
|
1105
1090
|
/**
|
|
1106
1091
|
* Registers a symbol only if it does not already exist based on the provided
|
|
1107
1092
|
* name and metadata. This prevents duplicate symbols from being created in
|
|
@@ -1365,6 +1350,8 @@ interface GetNameContext {
|
|
|
1365
1350
|
naming?: NamingConfig;
|
|
1366
1351
|
/** The operation object associated with the symbol. */
|
|
1367
1352
|
operation?: IROperationObject;
|
|
1353
|
+
/** Path to the resource this symbol represents. */
|
|
1354
|
+
path?: ReadonlyArray<string | number>;
|
|
1368
1355
|
/** The schema object associated with the symbol. */
|
|
1369
1356
|
schema?: IRSchemaObject;
|
|
1370
1357
|
}
|
|
@@ -1373,7 +1360,7 @@ interface GetNameContext {
|
|
|
1373
1360
|
interface PluginConfigMap {}
|
|
1374
1361
|
type PluginNames = keyof PluginConfigMap extends never ? string : keyof PluginConfigMap;
|
|
1375
1362
|
type AnyPluginName = PluginNames | AnyString;
|
|
1376
|
-
type PluginTag = 'client' | '
|
|
1363
|
+
type PluginTag = 'client' | 'handler' | 'sdk' | 'source' | 'transformer' | 'validator';
|
|
1377
1364
|
type ResolveTagOptions<T extends AnyPluginName = AnyPluginName> = {
|
|
1378
1365
|
/**
|
|
1379
1366
|
* Plugin to use if no plugin with the given tag is found in the user's
|
|
@@ -1411,17 +1398,18 @@ type PluginContext = {
|
|
|
1411
1398
|
*/
|
|
1412
1399
|
resolveTag: <T extends AnyPluginName = AnyPluginName>(tag: PluginTag, options?: ResolveTagOptions<T>) => T | false;
|
|
1413
1400
|
};
|
|
1414
|
-
|
|
1415
|
-
|
|
1401
|
+
/** Map of symbols imported from external modules. */
|
|
1402
|
+
type PluginImports = {
|
|
1403
|
+
[key: string]: Symbol | PluginImports;
|
|
1416
1404
|
};
|
|
1417
1405
|
type BaseApi = Record<string, unknown>;
|
|
1418
1406
|
type PluginBaseConfig = UserIndexExportOption & {
|
|
1407
|
+
/** Hooks to override default plugin behavior. */$hooks?: Hooks;
|
|
1419
1408
|
name: AnyPluginName;
|
|
1420
1409
|
/**
|
|
1421
|
-
*
|
|
1410
|
+
* Hooks to override default plugin behavior.
|
|
1422
1411
|
*
|
|
1423
|
-
* Use
|
|
1424
|
-
* or provide custom behavior for specific resources.
|
|
1412
|
+
* @deprecated Use `$hooks` instead.
|
|
1425
1413
|
*/
|
|
1426
1414
|
'~hooks'?: Hooks;
|
|
1427
1415
|
};
|
|
@@ -1436,12 +1424,10 @@ declare namespace Plugin {
|
|
|
1436
1424
|
dependencies?: ReadonlyArray<AnyPluginName>;
|
|
1437
1425
|
handler: (args: {
|
|
1438
1426
|
plugin: PluginInstance<T>;
|
|
1439
|
-
}) => void;
|
|
1440
|
-
|
|
1441
|
-
/**
|
|
1442
|
-
|
|
1443
|
-
*/
|
|
1444
|
-
symbols?: (plugin: PluginInstance<T>) => T['symbols'];
|
|
1427
|
+
}) => void; /** Declares symbols this plugin imports from external modules. */
|
|
1428
|
+
imports?: (plugin: PluginInstance<T>) => T['imports'];
|
|
1429
|
+
name: T['config']['name']; /** Metadata merged into every symbol this plugin creates. */
|
|
1430
|
+
symbolMeta?: (symbol: Omit<SymbolIn, 'name'>) => SymbolMeta;
|
|
1445
1431
|
/**
|
|
1446
1432
|
* Tags can be used to help with deciding plugin order and resolving
|
|
1447
1433
|
* plugin configuration options.
|
|
@@ -1453,24 +1439,33 @@ declare namespace Plugin {
|
|
|
1453
1439
|
type Exports = IndexExportOption;
|
|
1454
1440
|
type UserExports = UserIndexExportOption;
|
|
1455
1441
|
/** Generic wrapper for plugin hooks. */
|
|
1456
|
-
type Hooks = Pick<PluginBaseConfig, '~hooks'>;
|
|
1442
|
+
type Hooks = Pick<PluginBaseConfig, '$hooks' | '~hooks'>;
|
|
1457
1443
|
interface Name<Name extends PluginNames> {
|
|
1458
1444
|
name: Name;
|
|
1459
1445
|
}
|
|
1460
1446
|
/**
|
|
1461
1447
|
* Generic wrapper for plugin resolvers.
|
|
1462
1448
|
*
|
|
1463
|
-
* Provides a namespaced configuration entry (
|
|
1449
|
+
* Provides a namespaced configuration entry (`$resolvers`)
|
|
1464
1450
|
* where plugins can define how specific schema constructs
|
|
1465
1451
|
* should be resolved or overridden.
|
|
1466
1452
|
*/
|
|
1467
1453
|
type Resolvers<T extends Record<string, unknown> = Record<string, unknown>> = {
|
|
1468
1454
|
/**
|
|
1469
|
-
* Custom behavior resolvers
|
|
1455
|
+
* Custom behavior resolvers.
|
|
1470
1456
|
*
|
|
1471
1457
|
* Used to define how specific schema constructs are
|
|
1472
1458
|
* resolved into AST or runtime logic.
|
|
1473
1459
|
*/
|
|
1460
|
+
$resolvers?: T;
|
|
1461
|
+
/**
|
|
1462
|
+
* Custom behavior resolvers.
|
|
1463
|
+
*
|
|
1464
|
+
* Used to define how specific schema constructs are
|
|
1465
|
+
* resolved into AST or runtime logic.
|
|
1466
|
+
*
|
|
1467
|
+
* @deprecated Use `$resolvers` instead.
|
|
1468
|
+
*/
|
|
1474
1469
|
'~resolvers'?: T;
|
|
1475
1470
|
};
|
|
1476
1471
|
interface ResolverNodes<T> {
|
|
@@ -1482,23 +1477,38 @@ declare namespace Plugin {
|
|
|
1482
1477
|
config: T['resolvedConfig'];
|
|
1483
1478
|
dependencies: Set<AnyPluginName>;
|
|
1484
1479
|
};
|
|
1485
|
-
|
|
1480
|
+
/**
|
|
1481
|
+
* @typeParam Config - User-facing config shape.
|
|
1482
|
+
* @typeParam ResolvedConfig - Fully resolved config shape after normalization.
|
|
1483
|
+
* @typeParam Api - Public API surface exposed by this plugin to other plugins.
|
|
1484
|
+
* @typeParam Imports - Shape of the external symbol imports map.
|
|
1485
|
+
*/
|
|
1486
|
+
type Types<Config extends PluginBaseConfig = PluginBaseConfig, ResolvedConfig extends PluginBaseConfig = Config, Api extends BaseApi = never, Imports extends PluginImports = Record<never, never>> = ([Api] extends [never] ? {
|
|
1486
1487
|
api?: BaseApi;
|
|
1487
1488
|
} : {
|
|
1488
1489
|
api: Api;
|
|
1489
1490
|
}) & {
|
|
1490
1491
|
config: Config;
|
|
1492
|
+
imports: Imports;
|
|
1491
1493
|
resolvedConfig: ResolvedConfig;
|
|
1492
|
-
symbols: Symbols;
|
|
1493
1494
|
};
|
|
1494
1495
|
}
|
|
1495
|
-
|
|
1496
|
-
|
|
1496
|
+
/**
|
|
1497
|
+
* Convenience type that derives all plugin-related types from a single
|
|
1498
|
+
* set of type parameters.
|
|
1499
|
+
*
|
|
1500
|
+
* @typeParam Config - User-facing config shape.
|
|
1501
|
+
* @typeParam ResolvedConfig - Fully resolved config shape after normalization.
|
|
1502
|
+
* @typeParam Api - Public API surface exposed by this plugin to other plugins.
|
|
1503
|
+
* @typeParam Imports - Shape of the external symbol imports map.
|
|
1504
|
+
*/
|
|
1505
|
+
type DefinePlugin<Config extends PluginBaseConfig = PluginBaseConfig, ResolvedConfig extends PluginBaseConfig = Config, Api extends BaseApi = never, Imports extends PluginImports = Record<never, never>> = {
|
|
1506
|
+
Config: Plugin.Config<Plugin.Types<Config, ResolvedConfig, Api, Imports>>;
|
|
1497
1507
|
Handler: (args: {
|
|
1498
|
-
plugin: PluginInstance<Plugin.Types<Config, ResolvedConfig, Api,
|
|
1508
|
+
plugin: PluginInstance<Plugin.Types<Config, ResolvedConfig, Api, Imports>>;
|
|
1499
1509
|
}) => void; /** The plugin instance. */
|
|
1500
|
-
Instance: PluginInstance<Plugin.Types<Config, ResolvedConfig, Api,
|
|
1501
|
-
Types: Plugin.Types<Config, ResolvedConfig, Api,
|
|
1510
|
+
Instance: PluginInstance<Plugin.Types<Config, ResolvedConfig, Api, Imports>>;
|
|
1511
|
+
Types: Plugin.Types<Config, ResolvedConfig, Api, Imports>;
|
|
1502
1512
|
};
|
|
1503
1513
|
//#endregion
|
|
1504
1514
|
//#region src/config/output/types.d.ts
|
|
@@ -2161,6 +2171,16 @@ type Parser = {
|
|
|
2161
2171
|
validate_EXPERIMENTAL: false | 'strict' | 'warn';
|
|
2162
2172
|
};
|
|
2163
2173
|
//#endregion
|
|
2174
|
+
//#region src/config/presets.d.ts
|
|
2175
|
+
interface PresetPlugin {
|
|
2176
|
+
[key: string]: unknown;
|
|
2177
|
+
name: string;
|
|
2178
|
+
}
|
|
2179
|
+
interface Preset {
|
|
2180
|
+
/** Plugin configurations contributed by this preset. */
|
|
2181
|
+
plugins?: ReadonlyArray<string | PresetPlugin>;
|
|
2182
|
+
}
|
|
2183
|
+
//#endregion
|
|
2164
2184
|
//#region src/config/shared.d.ts
|
|
2165
2185
|
type FeatureToggle = {
|
|
2166
2186
|
/**
|
|
@@ -2413,6 +2433,8 @@ type BaseUserConfig<TOutput extends BaseUserOutput> = {
|
|
|
2413
2433
|
/**
|
|
2414
2434
|
* Path to the config file. Set this value if you don't use the default
|
|
2415
2435
|
* config file name, or it's not located in the project root.
|
|
2436
|
+
*
|
|
2437
|
+
* @default undefined
|
|
2416
2438
|
*/
|
|
2417
2439
|
configFile?: string;
|
|
2418
2440
|
/**
|
|
@@ -2460,8 +2482,16 @@ type BaseUserConfig<TOutput extends BaseUserOutput> = {
|
|
|
2460
2482
|
/**
|
|
2461
2483
|
* Customize how the input is parsed and transformed before it's passed to
|
|
2462
2484
|
* plugins.
|
|
2485
|
+
*
|
|
2486
|
+
* @default undefined
|
|
2463
2487
|
*/
|
|
2464
2488
|
parser?: UserParser;
|
|
2489
|
+
/**
|
|
2490
|
+
* Configuration presets.
|
|
2491
|
+
*
|
|
2492
|
+
* @default []
|
|
2493
|
+
*/
|
|
2494
|
+
presets?: ReadonlyArray<Preset>;
|
|
2465
2495
|
/**
|
|
2466
2496
|
* @deprecated use `input.watch` instead
|
|
2467
2497
|
*/
|
|
@@ -2764,27 +2794,27 @@ interface Pagination {
|
|
|
2764
2794
|
}
|
|
2765
2795
|
//#endregion
|
|
2766
2796
|
//#region src/ir/operation.d.ts
|
|
2767
|
-
declare
|
|
2768
|
-
declare
|
|
2797
|
+
declare function hasOperationDataRequired(operation: IR.OperationObject): boolean;
|
|
2798
|
+
declare function createOperationKey({
|
|
2769
2799
|
method,
|
|
2770
2800
|
path
|
|
2771
2801
|
}: {
|
|
2772
2802
|
method: string;
|
|
2773
2803
|
path: string;
|
|
2774
|
-
})
|
|
2775
|
-
declare
|
|
2804
|
+
}): string;
|
|
2805
|
+
declare function operationPagination({
|
|
2776
2806
|
context,
|
|
2777
2807
|
operation
|
|
2778
2808
|
}: {
|
|
2779
2809
|
context: Context;
|
|
2780
2810
|
operation: IR.OperationObject;
|
|
2781
|
-
})
|
|
2811
|
+
}): Pagination | undefined;
|
|
2782
2812
|
type StatusGroup = '1XX' | '2XX' | '3XX' | '4XX' | '5XX' | 'default';
|
|
2783
|
-
declare
|
|
2813
|
+
declare function statusCodeToGroup({
|
|
2784
2814
|
statusCode
|
|
2785
2815
|
}: {
|
|
2786
2816
|
statusCode: string;
|
|
2787
|
-
})
|
|
2817
|
+
}): StatusGroup;
|
|
2788
2818
|
interface OperationResponsesMap {
|
|
2789
2819
|
/**
|
|
2790
2820
|
* A deduplicated union of all error types. Unknown types are omitted.
|
|
@@ -2803,18 +2833,18 @@ interface OperationResponsesMap {
|
|
|
2803
2833
|
*/
|
|
2804
2834
|
responses?: IR.SchemaObject;
|
|
2805
2835
|
}
|
|
2806
|
-
declare
|
|
2836
|
+
declare function operationResponsesMap(operation: IR.OperationObject): OperationResponsesMap;
|
|
2807
2837
|
//#endregion
|
|
2808
2838
|
//#region src/ir/parameter.d.ts
|
|
2809
|
-
declare
|
|
2810
|
-
declare
|
|
2811
|
-
declare
|
|
2839
|
+
declare function hasParameterGroupObjectRequired(parameterGroup?: Record<string, IR.ParameterObject>): boolean;
|
|
2840
|
+
declare function hasParametersObjectRequired(parameters: IR.ParametersObject | undefined): boolean;
|
|
2841
|
+
declare function parameterWithPagination({
|
|
2812
2842
|
context,
|
|
2813
2843
|
parameters
|
|
2814
2844
|
}: {
|
|
2815
2845
|
context: Context;
|
|
2816
2846
|
parameters: IR.ParametersObject | undefined;
|
|
2817
|
-
})
|
|
2847
|
+
}): Pagination | undefined;
|
|
2818
2848
|
//#endregion
|
|
2819
2849
|
//#region src/ir/schema.d.ts
|
|
2820
2850
|
/**
|
|
@@ -3092,6 +3122,49 @@ declare const OperationPath: {
|
|
|
3092
3122
|
id: () => OperationPathStrategy;
|
|
3093
3123
|
};
|
|
3094
3124
|
//#endregion
|
|
3125
|
+
//#region src/openApi/shared/utils/discriminator.d.ts
|
|
3126
|
+
/**
|
|
3127
|
+
* Supported types for discriminator properties.
|
|
3128
|
+
*/
|
|
3129
|
+
type DiscriminatorPropertyType = 'boolean' | 'integer' | 'number' | 'string';
|
|
3130
|
+
/**
|
|
3131
|
+
* Converts a string discriminator mapping value to the appropriate type based on
|
|
3132
|
+
* the actual property type in the schema.
|
|
3133
|
+
*
|
|
3134
|
+
* OpenAPI discriminator mappings always use string keys, but the actual discriminator
|
|
3135
|
+
* property may be a boolean, number, or integer. This function converts the string
|
|
3136
|
+
* key to the correct runtime value and IR type.
|
|
3137
|
+
*/
|
|
3138
|
+
declare function convertDiscriminatorValue(value: string, propertyType: DiscriminatorPropertyType): {
|
|
3139
|
+
const: IR.SchemaObject['const'];
|
|
3140
|
+
type: IR.SchemaObject['type'];
|
|
3141
|
+
};
|
|
3142
|
+
declare function discriminatorValues($ref: string, mapping?: Record<string, string>, shouldUseRefAsValue?: () => boolean): ReadonlyArray<string>;
|
|
3143
|
+
interface DiscriminatedUnionMember {
|
|
3144
|
+
/** The discriminator value for this member. */
|
|
3145
|
+
discriminatedValue: unknown;
|
|
3146
|
+
/**
|
|
3147
|
+
* True when the referenced schema does not already define the discriminator
|
|
3148
|
+
* property as a const/literal. The plugin must inject it explicitly.
|
|
3149
|
+
*/
|
|
3150
|
+
needsExtend: boolean;
|
|
3151
|
+
/** The resolved $ref string for this member. */
|
|
3152
|
+
ref: string;
|
|
3153
|
+
}
|
|
3154
|
+
interface DiscriminatedUnionData {
|
|
3155
|
+
discriminatorKey: string;
|
|
3156
|
+
members: Array<DiscriminatedUnionMember>;
|
|
3157
|
+
}
|
|
3158
|
+
declare function buildDiscriminatedUnion({
|
|
3159
|
+
parentSchema,
|
|
3160
|
+
resolveIrRef,
|
|
3161
|
+
schemas
|
|
3162
|
+
}: {
|
|
3163
|
+
parentSchema: IR.SchemaObject;
|
|
3164
|
+
resolveIrRef: (ref: string) => IR.SchemaObject | undefined;
|
|
3165
|
+
schemas: ReadonlyArray<IR.SchemaObject>;
|
|
3166
|
+
}): DiscriminatedUnionData | null;
|
|
3167
|
+
//#endregion
|
|
3095
3168
|
//#region src/openApi/shared/utils/patch.d.ts
|
|
3096
3169
|
declare function patchOpenApiSpec({
|
|
3097
3170
|
patchOptions,
|
|
@@ -3101,14 +3174,7 @@ declare function patchOpenApiSpec({
|
|
|
3101
3174
|
spec: unknown;
|
|
3102
3175
|
}): Promise<void>;
|
|
3103
3176
|
//#endregion
|
|
3104
|
-
//#region src/plugins/
|
|
3105
|
-
type PluginConfig = {
|
|
3106
|
-
name: PluginNames;
|
|
3107
|
-
};
|
|
3108
|
-
type PluginDefinition<TConfig extends PluginConfig = PluginConfig> = PluginNames | TConfig;
|
|
3109
|
-
declare function warnOnConflictingDuplicatePlugins<TConfig extends PluginConfig>(plugins: ReadonlyArray<PluginDefinition<TConfig>>): void;
|
|
3110
|
-
//#endregion
|
|
3111
|
-
//#region src/plugins/shared/utils/config.d.ts
|
|
3177
|
+
//#region src/plugins/config.d.ts
|
|
3112
3178
|
declare function definePluginConfig<T extends Plugin.Types>(pluginConfig: Plugin.Config<T>): (userConfig?: Omit<T["config"], "name">) => {
|
|
3113
3179
|
config: Plugin.Config<T>["config"];
|
|
3114
3180
|
/**
|
|
@@ -3123,25 +3189,52 @@ declare function definePluginConfig<T extends Plugin.Types>(pluginConfig: Plugin
|
|
|
3123
3189
|
handler: (args: {
|
|
3124
3190
|
plugin: PluginInstance<T>;
|
|
3125
3191
|
}) => void;
|
|
3126
|
-
|
|
3192
|
+
imports?: ((plugin: PluginInstance<T>) => T["imports"]) | undefined;
|
|
3193
|
+
symbolMeta?: (symbol: Omit<log, "name">) => log;
|
|
3127
3194
|
tags?: ReadonlyArray<PluginTag>;
|
|
3128
3195
|
};
|
|
3196
|
+
interface PluginResolutionInput {
|
|
3197
|
+
/** Registry of built-in plugin definitions keyed by name. */
|
|
3198
|
+
defaultPluginConfigs: Partial<Record<string, any>>;
|
|
3199
|
+
/** Plugins to include when the user doesn't specify any. */
|
|
3200
|
+
defaultPlugins: ReadonlyArray<string>;
|
|
3201
|
+
/** Resolved project dependencies. */
|
|
3202
|
+
dependencies: Record<string, string>;
|
|
3203
|
+
/** Raw user configuration (only the `plugins` field is read). */
|
|
3204
|
+
userConfig: {
|
|
3205
|
+
plugins?: ReadonlyArray<string | {
|
|
3206
|
+
name: string;
|
|
3207
|
+
}>;
|
|
3208
|
+
presets?: ReadonlyArray<Preset>;
|
|
3209
|
+
};
|
|
3210
|
+
}
|
|
3211
|
+
interface PluginResolutionResult<TPluginNames extends string = string> {
|
|
3212
|
+
pluginOrder: ReadonlyArray<TPluginNames>;
|
|
3213
|
+
plugins: Record<string, any>;
|
|
3214
|
+
}
|
|
3215
|
+
declare function resolvePlugins<TPluginNames extends string = string>({
|
|
3216
|
+
defaultPluginConfigs,
|
|
3217
|
+
defaultPlugins,
|
|
3218
|
+
dependencies,
|
|
3219
|
+
userConfig
|
|
3220
|
+
}: PluginResolutionInput): PluginResolutionResult<TPluginNames>;
|
|
3221
|
+
//#endregion
|
|
3222
|
+
//#region src/plugins/helper.d.ts
|
|
3223
|
+
type PluginConfig<K extends keyof PluginConfigMap> = PluginConfigMap[K]['config'] & {
|
|
3224
|
+
name: K;
|
|
3225
|
+
};
|
|
3226
|
+
type PluginHelper<K extends keyof PluginConfigMap> = (config?: Omit<PluginConfigMap[K]['config'], 'name'>) => PluginConfig<K>;
|
|
3227
|
+
declare function pluginHelper<K extends keyof PluginConfigMap>(name: K): PluginHelper<K>;
|
|
3129
3228
|
//#endregion
|
|
3130
3229
|
//#region src/plugins/symbol.d.ts
|
|
3131
3230
|
/**
|
|
3132
|
-
*
|
|
3231
|
+
* Function to build the input for symbol registration, applying naming hooks if provided.
|
|
3133
3232
|
*/
|
|
3134
3233
|
declare function buildSymbolIn({
|
|
3135
3234
|
plugin,
|
|
3136
3235
|
...ctx
|
|
3137
3236
|
}: GetNameContext & {
|
|
3138
3237
|
plugin: {
|
|
3139
|
-
config: Pick<PluginInstance['config'], '~hooks'>;
|
|
3140
|
-
context: {
|
|
3141
|
-
config: {
|
|
3142
|
-
parser: Pick<PluginInstance['context']['config']['parser'], 'hooks'>;
|
|
3143
|
-
};
|
|
3144
|
-
};
|
|
3145
3238
|
getHooks: PluginInstance['getHooks'];
|
|
3146
3239
|
};
|
|
3147
3240
|
}): SymbolIn;
|
|
@@ -3222,6 +3315,11 @@ interface RequestSchemaContext<Plugin extends PluginInstance = PluginInstance> {
|
|
|
3222
3315
|
layers?: RequestValidatorLayers;
|
|
3223
3316
|
/** The operation object. */
|
|
3224
3317
|
operation: IR.OperationObject;
|
|
3318
|
+
/**
|
|
3319
|
+
* When `true` and every non-omitted layer is optional, wrap the entire
|
|
3320
|
+
* composite schema in an outer optional wrapper.
|
|
3321
|
+
*/
|
|
3322
|
+
outerOptional?: boolean;
|
|
3225
3323
|
/** The plugin instance. */
|
|
3226
3324
|
plugin: Plugin;
|
|
3227
3325
|
}
|
|
@@ -3336,7 +3434,8 @@ declare class MinHeap {
|
|
|
3336
3434
|
}
|
|
3337
3435
|
//#endregion
|
|
3338
3436
|
//#region src/utils/object.d.ts
|
|
3339
|
-
declare function isPlainObject(value: unknown): value is Record<string,
|
|
3437
|
+
declare function isPlainObject(value: unknown): value is Record<string, unknown>;
|
|
3438
|
+
declare function deepMerge<T extends AnyObject | Array<unknown>>(target: T, source: T): T;
|
|
3340
3439
|
//#endregion
|
|
3341
3440
|
//#region src/utils/path.d.ts
|
|
3342
3441
|
interface PathToNameOptions {
|
|
@@ -3442,7 +3541,11 @@ interface Url {
|
|
|
3442
3541
|
port: string;
|
|
3443
3542
|
protocol: string;
|
|
3444
3543
|
}
|
|
3544
|
+
/**
|
|
3545
|
+
* Resolve the base URL string if it's a valid URL or path.
|
|
3546
|
+
*/
|
|
3547
|
+
declare function getBaseUrl(config: string | number | boolean, ir: IR.Model): string | undefined;
|
|
3445
3548
|
declare function parseUrl(value: string): Url;
|
|
3446
3549
|
//#endregion
|
|
3447
|
-
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 EventHooks, 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
|
|
3550
|
+
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 DiscriminatedUnionData, type DiscriminatedUnionMember, type DiscriminatorPropertyType, type EventHooks, 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, type PluginImports, PluginInstance, type PluginInstanceTypes, type PluginNames, type PluginResolutionInput, type PluginResolutionResult, type PluginTag, type PostProcessor, type Preset, type PresetPlugin, type RequestSchemaContext, type RequestValidatorLayer, type RequestValidatorLayers, type ResolveModuleFn, type ResolvedNode, type ResolvedRequestValidatorLayer, type SchemaExtractor, type SchemaProcessor, type SchemaProcessorContext, type SchemaProcessorResult, type SchemaVisitor, type SchemaVisitorContext, type SchemaWithType, type SourceConfig, SymbolFactory, 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, buildDiscriminatedUnion, buildGraph, buildSymbolIn, checkNodeVersion, childContext, coerce, collectDeps, compileInputPath, convertDiscriminatorValue, createOperationKey, createSchemaProcessor, createSchemaWalker, debugTools, deduplicateSchema, deepMerge, defaultPaginationKeywords, defineConfig, definePluginConfig, dependencyFactory, discriminatorValues, encodeJsonPointerSegment, ensureDirSync, escapeComment, findPackageJson, findTsConfigPath, getBaseUrl, 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, pluginHelper, postprocessOutput, printCliIntro, printCrashReport, refToName, requestValidatorLayers, resolveNaming, resolvePlugins, resolveRef, resolveValidatorLayer, satisfies, shouldReportCrash, sourceConfig, statusCodeToGroup, toCase, utils };
|
|
3448
3551
|
//# sourceMappingURL=index.d.mts.map
|