@hey-api/shared 0.4.7 → 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 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,
@@ -927,6 +916,30 @@ declare class Context<Spec extends Record<string, any> = any, Config extends Any
927
916
  declare const irTopLevelKinds: readonly ["operation", "parameter", "requestBody", "schema", "server", "webhook"];
928
917
  type IrTopLevelKind = (typeof irTopLevelKinds)[number];
929
918
  //#endregion
919
+ //#region src/utils/symbols.d.ts
920
+ interface PluginInstanceTypes {}
921
+ /**
922
+ * Resolves the Node type, falling back to base Node if not augmented.
923
+ */
924
+ type ResolvedNode = 'Node' extends keyof PluginInstanceTypes ? PluginInstanceTypes['Node'] : Node;
925
+ type EventHooks = { [K in keyof Required<NonNullable<Hooks['events']>>]: Array<NonNullable<NonNullable<Hooks['events']>[K]>> };
926
+ declare class SymbolFactory {
927
+ private readonly eventHooks;
928
+ private readonly project;
929
+ private readonly plugin?;
930
+ constructor(props: {
931
+ eventHooks: EventHooks;
932
+ plugin?: PluginInstance;
933
+ project: IProject;
934
+ });
935
+ static buildEventHooks(scopes: ReadonlyArray<NonNullable<Hooks['events']> | undefined>): EventHooks;
936
+ isRegistered(identifier: SymbolIdentifier): boolean;
937
+ query<TNode extends Node = ResolvedNode>(filter: SymbolMeta, tags?: ReadonlyArray<NonNullable<TNode['~dsl']>>, predicate?: (symbol: Symbol<TNode>) => boolean): Symbol<TNode> | undefined;
938
+ queryAll<TNode extends Node = ResolvedNode>(filter: SymbolMeta, tags?: ReadonlyArray<NonNullable<TNode['~dsl']>>, predicate?: (symbol: Symbol<TNode>) => boolean): Array<Symbol<TNode>>;
939
+ reference(meta: SymbolMeta): Symbol<ResolvedNode>;
940
+ register(name: SymbolIn['name'], symbol?: Omit<SymbolIn, 'name'>): Symbol<ResolvedNode>;
941
+ }
942
+ //#endregion
930
943
  //#region src/plugins/shared/types/instance.d.ts
931
944
  type BaseEvent = {
932
945
  /**
@@ -973,11 +986,6 @@ type WalkEvent<T extends IrTopLevelKind = IrTopLevelKind> = Extract<WalkEvents,
973
986
  }>;
974
987
  //#endregion
975
988
  //#region src/plugins/shared/utils/instance.d.ts
976
- interface PluginInstanceTypes {}
977
- /**
978
- * Resolves the Node type, falling back to base Node if not augmented.
979
- */
980
- type ResolvedNode = 'Node' extends keyof PluginInstanceTypes ? PluginInstanceTypes['Node'] : Node;
981
989
  declare class PluginInstance<T extends Plugin.Types = Plugin.Types> {
982
990
  api: T['api'];
983
991
  config: Omit<T['resolvedConfig'], 'name'>;
@@ -986,6 +994,8 @@ declare class PluginInstance<T extends Plugin.Types = Plugin.Types> {
986
994
  private eventHooks;
987
995
  gen: IProject;
988
996
  private handler;
997
+ /** External symbols imported from other modules. */
998
+ imports: T['imports'];
989
999
  name: T['resolvedConfig']['name'];
990
1000
  /**
991
1001
  * The package metadata and utilities for the current context, constructed
@@ -994,15 +1004,19 @@ declare class PluginInstance<T extends Plugin.Types = Plugin.Types> {
994
1004
  * code generation.
995
1005
  */
996
1006
  package: Dependency;
997
- /** Symbols declared in the plugin config. */
998
- symbols: T['symbols'];
999
- constructor(props: Pick<Plugin.Config<T>, 'api' | 'handler' | 'name' | 'symbols'> & {
1007
+ /** Factory for creating and managing symbols. */
1008
+ symbolFactory: SymbolFactory;
1009
+ /** Metadata merged into every symbol this plugin creates. */
1010
+ symbolMeta: Plugin.Config<T>['symbolMeta'];
1011
+ readonly isSymbolRegistered: SymbolFactory['isRegistered'];
1012
+ readonly querySymbol: SymbolFactory['query'];
1013
+ readonly referenceSymbol: SymbolFactory['reference'];
1014
+ constructor(props: Pick<Plugin.Config<T>, 'api' | 'handler' | 'imports' | 'name' | 'symbolMeta'> & {
1000
1015
  config: Omit<T['resolvedConfig'], 'name'>;
1001
1016
  context: Context;
1002
1017
  dependencies: Set<AnyPluginName>;
1003
1018
  gen: IProject;
1004
1019
  });
1005
- external(resource: Required<SymbolMeta>['resource'], meta?: Omit<SymbolMeta, 'category' | 'resource'>): Symbol;
1006
1020
  /**
1007
1021
  * Iterates over various input elements as specified by the event types, in
1008
1022
  * a specific order: servers, schemas, parameters, request bodies, then
@@ -1059,7 +1073,6 @@ declare class PluginInstance<T extends Plugin.Types = Plugin.Types> {
1059
1073
  * @returns void
1060
1074
  */
1061
1075
  intent(intent: ExampleIntent): void;
1062
- isSymbolRegistered(identifier: SymbolIdentifier): boolean;
1063
1076
  /**
1064
1077
  * Sets or adds a node to the project graph.
1065
1078
  *
@@ -1068,26 +1081,18 @@ declare class PluginInstance<T extends Plugin.Types = Plugin.Types> {
1068
1081
  * @returns The index of the added node or void if updated.
1069
1082
  */
1070
1083
  node<T extends number | undefined = undefined>(node: Node | null, index?: T): T extends number ? void : number;
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>>;
1073
- referenceSymbol(meta: SymbolMeta): Symbol<ResolvedNode>;
1074
- /**
1075
- * Alias for `symbol()` method with single argument.
1076
- */
1077
- registerSymbol(symbol: SymbolIn): Symbol<ResolvedNode>;
1078
1084
  /**
1079
1085
  * Executes plugin's handler function.
1080
1086
  */
1081
1087
  run(): Promise<void>;
1082
1088
  symbol(name: SymbolIn['name'], symbol?: Omit<SymbolIn, 'name'>): Symbol<ResolvedNode>;
1089
+ symbol(symbol: SymbolIn): Symbol<ResolvedNode>;
1083
1090
  /**
1084
1091
  * Registers a symbol only if it does not already exist based on the provided
1085
1092
  * name and metadata. This prevents duplicate symbols from being created in
1086
1093
  * the project.
1087
1094
  */
1088
1095
  symbolOnce(name: SymbolIn['name'], symbol?: Omit<SymbolIn, 'name'>): Symbol;
1089
- private buildEventHooks;
1090
- private buildSymbols;
1091
1096
  private forEachError;
1092
1097
  private getSymbolExportFromFilePath;
1093
1098
  private getSymbolFilePath;
@@ -1188,7 +1193,7 @@ type Hooks = {
1188
1193
  * @returns void
1189
1194
  */
1190
1195
  'symbol:register:after'?: (args: {
1191
- /** Plugin that registered the symbol. */plugin: PluginInstance; /** The registered symbol. */
1196
+ /** Plugin that registered the symbol, if available. */plugin?: PluginInstance; /** The registered symbol. */
1192
1197
  symbol: Symbol;
1193
1198
  }) => void;
1194
1199
  /**
@@ -1200,7 +1205,7 @@ type Hooks = {
1200
1205
  * @returns void
1201
1206
  */
1202
1207
  'symbol:register:before'?: (args: {
1203
- /** Plugin registering the symbol. */plugin: PluginInstance; /** Symbol to register. */
1208
+ /** Plugin registering the symbol, if available. */plugin?: PluginInstance; /** Symbol to register. */
1204
1209
  symbol: SymbolIn;
1205
1210
  }) => void;
1206
1211
  };
@@ -1345,6 +1350,8 @@ interface GetNameContext {
1345
1350
  naming?: NamingConfig;
1346
1351
  /** The operation object associated with the symbol. */
1347
1352
  operation?: IROperationObject;
1353
+ /** Path to the resource this symbol represents. */
1354
+ path?: ReadonlyArray<string | number>;
1348
1355
  /** The schema object associated with the symbol. */
1349
1356
  schema?: IRSchemaObject;
1350
1357
  }
@@ -1353,7 +1360,7 @@ interface GetNameContext {
1353
1360
  interface PluginConfigMap {}
1354
1361
  type PluginNames = keyof PluginConfigMap extends never ? string : keyof PluginConfigMap;
1355
1362
  type AnyPluginName = PluginNames | AnyString;
1356
- type PluginTag = 'client' | 'mocker' | 'sdk' | 'transformer' | 'validator';
1363
+ type PluginTag = 'client' | 'handler' | 'sdk' | 'source' | 'transformer' | 'validator';
1357
1364
  type ResolveTagOptions<T extends AnyPluginName = AnyPluginName> = {
1358
1365
  /**
1359
1366
  * Plugin to use if no plugin with the given tag is found in the user's
@@ -1391,17 +1398,18 @@ type PluginContext = {
1391
1398
  */
1392
1399
  resolveTag: <T extends AnyPluginName = AnyPluginName>(tag: PluginTag, options?: ResolveTagOptions<T>) => T | false;
1393
1400
  };
1394
- type PluginSymbols = {
1395
- [key: string]: Symbol | PluginSymbols;
1401
+ /** Map of symbols imported from external modules. */
1402
+ type PluginImports = {
1403
+ [key: string]: Symbol | PluginImports;
1396
1404
  };
1397
1405
  type BaseApi = Record<string, unknown>;
1398
1406
  type PluginBaseConfig = UserIndexExportOption & {
1407
+ /** Hooks to override default plugin behavior. */$hooks?: Hooks;
1399
1408
  name: AnyPluginName;
1400
1409
  /**
1401
- * Optional hooks to override default plugin behavior.
1410
+ * Hooks to override default plugin behavior.
1402
1411
  *
1403
- * Use these to classify resources, control which outputs are generated,
1404
- * or provide custom behavior for specific resources.
1412
+ * @deprecated Use `$hooks` instead.
1405
1413
  */
1406
1414
  '~hooks'?: Hooks;
1407
1415
  };
@@ -1416,12 +1424,10 @@ declare namespace Plugin {
1416
1424
  dependencies?: ReadonlyArray<AnyPluginName>;
1417
1425
  handler: (args: {
1418
1426
  plugin: PluginInstance<T>;
1419
- }) => void;
1420
- name: T['config']['name'];
1421
- /**
1422
- * Symbols this plugin registers at construction time.
1423
- */
1424
- 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;
1425
1431
  /**
1426
1432
  * Tags can be used to help with deciding plugin order and resolving
1427
1433
  * plugin configuration options.
@@ -1433,23 +1439,32 @@ declare namespace Plugin {
1433
1439
  type Exports = IndexExportOption;
1434
1440
  type UserExports = UserIndexExportOption;
1435
1441
  /** Generic wrapper for plugin hooks. */
1436
- type Hooks = Pick<PluginBaseConfig, '~hooks'>;
1442
+ type Hooks = Pick<PluginBaseConfig, '$hooks' | '~hooks'>;
1437
1443
  interface Name<Name extends PluginNames> {
1438
1444
  name: Name;
1439
1445
  }
1440
1446
  /**
1441
1447
  * Generic wrapper for plugin resolvers.
1442
1448
  *
1443
- * Provides a namespaced configuration entry (`~resolvers`)
1449
+ * Provides a namespaced configuration entry (`$resolvers`)
1444
1450
  * where plugins can define how specific schema constructs
1445
1451
  * should be resolved or overridden.
1446
1452
  */
1447
1453
  type Resolvers<T extends Record<string, unknown> = Record<string, unknown>> = {
1448
1454
  /**
1449
- * Custom behavior resolvers for a plugin.
1455
+ * Custom behavior resolvers.
1456
+ *
1457
+ * Used to define how specific schema constructs are
1458
+ * resolved into AST or runtime logic.
1459
+ */
1460
+ $resolvers?: T;
1461
+ /**
1462
+ * Custom behavior resolvers.
1450
1463
  *
1451
1464
  * Used to define how specific schema constructs are
1452
1465
  * resolved into AST or runtime logic.
1466
+ *
1467
+ * @deprecated Use `$resolvers` instead.
1453
1468
  */
1454
1469
  '~resolvers'?: T;
1455
1470
  };
@@ -1462,27 +1477,42 @@ declare namespace Plugin {
1462
1477
  config: T['resolvedConfig'];
1463
1478
  dependencies: Set<AnyPluginName>;
1464
1479
  };
1465
- type Types<Config extends PluginBaseConfig = PluginBaseConfig, ResolvedConfig extends PluginBaseConfig = Config, Api extends BaseApi = never, Symbols extends PluginSymbols = Record<never, never>> = ([Api] extends [never] ? {
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] ? {
1466
1487
  api?: BaseApi;
1467
1488
  } : {
1468
1489
  api: Api;
1469
1490
  }) & {
1470
1491
  config: Config;
1492
+ imports: Imports;
1471
1493
  resolvedConfig: ResolvedConfig;
1472
- symbols: Symbols;
1473
1494
  };
1474
1495
  }
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>>;
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>>;
1477
1507
  Handler: (args: {
1478
- plugin: PluginInstance<Plugin.Types<Config, ResolvedConfig, Api, Symbols>>;
1508
+ plugin: PluginInstance<Plugin.Types<Config, ResolvedConfig, Api, Imports>>;
1479
1509
  }) => void; /** The plugin instance. */
1480
- Instance: PluginInstance<Plugin.Types<Config, ResolvedConfig, Api, Symbols>>;
1481
- Types: Plugin.Types<Config, ResolvedConfig, Api, Symbols>;
1510
+ Instance: PluginInstance<Plugin.Types<Config, ResolvedConfig, Api, Imports>>;
1511
+ Types: Plugin.Types<Config, ResolvedConfig, Api, Imports>;
1482
1512
  };
1483
1513
  //#endregion
1484
1514
  //#region src/config/output/types.d.ts
1485
- type OutputHeader = MaybeFunc<(ctx: Pick<RenderContext, 'meta' | 'project'> & Pick<Partial<RenderContext>, 'file'> & {
1515
+ type OutputHeader = MaybeFunc<(ctx: Pick<RenderContext, 'project'> & Pick<Partial<RenderContext>, 'file'> & {
1486
1516
  /** The default header value. */defaultValue: ReadonlyArray<string>;
1487
1517
  }) => MaybeArray<string> | null | undefined>;
1488
1518
  //#endregion
@@ -2141,6 +2171,16 @@ type Parser = {
2141
2171
  validate_EXPERIMENTAL: false | 'strict' | 'warn';
2142
2172
  };
2143
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
2144
2184
  //#region src/config/shared.d.ts
2145
2185
  type FeatureToggle = {
2146
2186
  /**
@@ -2393,6 +2433,8 @@ type BaseUserConfig<TOutput extends BaseUserOutput> = {
2393
2433
  /**
2394
2434
  * Path to the config file. Set this value if you don't use the default
2395
2435
  * config file name, or it's not located in the project root.
2436
+ *
2437
+ * @default undefined
2396
2438
  */
2397
2439
  configFile?: string;
2398
2440
  /**
@@ -2440,8 +2482,16 @@ type BaseUserConfig<TOutput extends BaseUserOutput> = {
2440
2482
  /**
2441
2483
  * Customize how the input is parsed and transformed before it's passed to
2442
2484
  * plugins.
2485
+ *
2486
+ * @default undefined
2443
2487
  */
2444
2488
  parser?: UserParser;
2489
+ /**
2490
+ * Configuration presets.
2491
+ *
2492
+ * @default []
2493
+ */
2494
+ presets?: ReadonlyArray<Preset>;
2445
2495
  /**
2446
2496
  * @deprecated use `input.watch` instead
2447
2497
  */
@@ -2744,27 +2794,27 @@ interface Pagination {
2744
2794
  }
2745
2795
  //#endregion
2746
2796
  //#region src/ir/operation.d.ts
2747
- declare const hasOperationDataRequired: (operation: IR.OperationObject) => boolean;
2748
- declare const createOperationKey: ({
2797
+ declare function hasOperationDataRequired(operation: IR.OperationObject): boolean;
2798
+ declare function createOperationKey({
2749
2799
  method,
2750
2800
  path
2751
2801
  }: {
2752
2802
  method: string;
2753
2803
  path: string;
2754
- }) => string;
2755
- declare const operationPagination: ({
2804
+ }): string;
2805
+ declare function operationPagination({
2756
2806
  context,
2757
2807
  operation
2758
2808
  }: {
2759
2809
  context: Context;
2760
2810
  operation: IR.OperationObject;
2761
- }) => Pagination | undefined;
2811
+ }): Pagination | undefined;
2762
2812
  type StatusGroup = '1XX' | '2XX' | '3XX' | '4XX' | '5XX' | 'default';
2763
- declare const statusCodeToGroup: ({
2813
+ declare function statusCodeToGroup({
2764
2814
  statusCode
2765
2815
  }: {
2766
2816
  statusCode: string;
2767
- }) => StatusGroup;
2817
+ }): StatusGroup;
2768
2818
  interface OperationResponsesMap {
2769
2819
  /**
2770
2820
  * A deduplicated union of all error types. Unknown types are omitted.
@@ -2783,18 +2833,18 @@ interface OperationResponsesMap {
2783
2833
  */
2784
2834
  responses?: IR.SchemaObject;
2785
2835
  }
2786
- declare const operationResponsesMap: (operation: IR.OperationObject) => OperationResponsesMap;
2836
+ declare function operationResponsesMap(operation: IR.OperationObject): OperationResponsesMap;
2787
2837
  //#endregion
2788
2838
  //#region src/ir/parameter.d.ts
2789
- declare const hasParameterGroupObjectRequired: (parameterGroup?: Record<string, IR.ParameterObject>) => boolean;
2790
- declare const hasParametersObjectRequired: (parameters: IR.ParametersObject | undefined) => boolean;
2791
- declare const parameterWithPagination: ({
2839
+ declare function hasParameterGroupObjectRequired(parameterGroup?: Record<string, IR.ParameterObject>): boolean;
2840
+ declare function hasParametersObjectRequired(parameters: IR.ParametersObject | undefined): boolean;
2841
+ declare function parameterWithPagination({
2792
2842
  context,
2793
2843
  parameters
2794
2844
  }: {
2795
2845
  context: Context;
2796
2846
  parameters: IR.ParametersObject | undefined;
2797
- }) => Pagination | undefined;
2847
+ }): Pagination | undefined;
2798
2848
  //#endregion
2799
2849
  //#region src/ir/schema.d.ts
2800
2850
  /**
@@ -3072,6 +3122,49 @@ declare const OperationPath: {
3072
3122
  id: () => OperationPathStrategy;
3073
3123
  };
3074
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
3075
3168
  //#region src/openApi/shared/utils/patch.d.ts
3076
3169
  declare function patchOpenApiSpec({
3077
3170
  patchOptions,
@@ -3081,14 +3174,7 @@ declare function patchOpenApiSpec({
3081
3174
  spec: unknown;
3082
3175
  }): Promise<void>;
3083
3176
  //#endregion
3084
- //#region src/plugins/duplicate.d.ts
3085
- type PluginConfig = {
3086
- name: PluginNames;
3087
- };
3088
- type PluginDefinition<TConfig extends PluginConfig = PluginConfig> = PluginNames | TConfig;
3089
- declare function warnOnConflictingDuplicatePlugins<TConfig extends PluginConfig>(plugins: ReadonlyArray<PluginDefinition<TConfig>>): void;
3090
- //#endregion
3091
- //#region src/plugins/shared/utils/config.d.ts
3177
+ //#region src/plugins/config.d.ts
3092
3178
  declare function definePluginConfig<T extends Plugin.Types>(pluginConfig: Plugin.Config<T>): (userConfig?: Omit<T["config"], "name">) => {
3093
3179
  config: Plugin.Config<T>["config"];
3094
3180
  /**
@@ -3103,25 +3189,52 @@ declare function definePluginConfig<T extends Plugin.Types>(pluginConfig: Plugin
3103
3189
  handler: (args: {
3104
3190
  plugin: PluginInstance<T>;
3105
3191
  }) => void;
3106
- symbols?: ((plugin: PluginInstance<T>) => T["symbols"]) | undefined;
3192
+ imports?: ((plugin: PluginInstance<T>) => T["imports"]) | undefined;
3193
+ symbolMeta?: (symbol: Omit<log, "name">) => log;
3107
3194
  tags?: ReadonlyArray<PluginTag>;
3108
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>;
3109
3228
  //#endregion
3110
3229
  //#region src/plugins/symbol.d.ts
3111
3230
  /**
3112
- * Helper function to build the input for symbol registration, applying naming hooks if provided.
3231
+ * Function to build the input for symbol registration, applying naming hooks if provided.
3113
3232
  */
3114
3233
  declare function buildSymbolIn({
3115
3234
  plugin,
3116
3235
  ...ctx
3117
3236
  }: GetNameContext & {
3118
3237
  plugin: {
3119
- config: Pick<PluginInstance['config'], '~hooks'>;
3120
- context: {
3121
- config: {
3122
- parser: Pick<PluginInstance['context']['config']['parser'], 'hooks'>;
3123
- };
3124
- };
3125
3238
  getHooks: PluginInstance['getHooks'];
3126
3239
  };
3127
3240
  }): SymbolIn;
@@ -3202,6 +3315,11 @@ interface RequestSchemaContext<Plugin extends PluginInstance = PluginInstance> {
3202
3315
  layers?: RequestValidatorLayers;
3203
3316
  /** The operation object. */
3204
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;
3205
3323
  /** The plugin instance. */
3206
3324
  plugin: Plugin;
3207
3325
  }
@@ -3316,7 +3434,8 @@ declare class MinHeap {
3316
3434
  }
3317
3435
  //#endregion
3318
3436
  //#region src/utils/object.d.ts
3319
- declare function isPlainObject(value: unknown): value is Record<string, any>;
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;
3320
3439
  //#endregion
3321
3440
  //#region src/utils/path.d.ts
3322
3441
  interface PathToNameOptions {
@@ -3422,7 +3541,11 @@ interface Url {
3422
3541
  port: string;
3423
3542
  protocol: string;
3424
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;
3425
3548
  declare function parseUrl(value: string): Url;
3426
3549
  //#endregion
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 };
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 };
3428
3551
  //# sourceMappingURL=index.d.mts.map