@hey-api/openapi-ts 0.72.2 → 0.74.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.
Files changed (40) hide show
  1. package/README.md +5 -12
  2. package/dist/chunk-WELTPW5K.js +39 -0
  3. package/dist/chunk-WELTPW5K.js.map +1 -0
  4. package/dist/clients/axios/client.ts +111 -0
  5. package/dist/clients/axios/index.ts +21 -0
  6. package/dist/clients/axios/types.ts +178 -0
  7. package/dist/clients/axios/utils.ts +286 -0
  8. package/dist/clients/core/auth.ts +40 -0
  9. package/dist/clients/core/bodySerializer.ts +84 -0
  10. package/dist/clients/core/params.ts +141 -0
  11. package/dist/clients/core/pathSerializer.ts +179 -0
  12. package/dist/clients/core/types.ts +98 -0
  13. package/dist/clients/fetch/client.ts +181 -0
  14. package/dist/clients/fetch/index.ts +22 -0
  15. package/dist/clients/fetch/types.ts +215 -0
  16. package/dist/clients/fetch/utils.ts +415 -0
  17. package/dist/clients/next/client.ts +163 -0
  18. package/dist/clients/next/index.ts +21 -0
  19. package/dist/clients/next/types.ts +166 -0
  20. package/dist/clients/next/utils.ts +404 -0
  21. package/dist/clients/nuxt/client.ts +145 -0
  22. package/dist/clients/nuxt/index.ts +22 -0
  23. package/dist/clients/nuxt/types.ts +192 -0
  24. package/dist/clients/nuxt/utils.ts +358 -0
  25. package/dist/index.cjs +169 -169
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.d.cts +21 -6
  28. package/dist/index.d.ts +21 -6
  29. package/dist/index.js +13 -13
  30. package/dist/index.js.map +1 -1
  31. package/dist/internal.cjs +10 -10
  32. package/dist/internal.cjs.map +1 -1
  33. package/dist/internal.d.cts +2 -2
  34. package/dist/internal.d.ts +2 -2
  35. package/dist/internal.js +1 -1
  36. package/dist/{types.d-DtkupL5A.d.cts → types.d-jQzOw4mx.d.cts} +293 -103
  37. package/dist/{types.d-DtkupL5A.d.ts → types.d-jQzOw4mx.d.ts} +293 -103
  38. package/package.json +4 -3
  39. package/dist/chunk-LC3ZVK3Y.js +0 -39
  40. package/dist/chunk-LC3ZVK3Y.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import { JSONSchema } from '@hey-api/json-schema-ref-parser';
2
- import { e as Config, I as IR, W as WatchValues } from './types.d-DtkupL5A.cjs';
3
- export { i as initConfigs } from './types.d-DtkupL5A.cjs';
2
+ import { e as Config, I as IR, W as WatchValues } from './types.d-jQzOw4mx.cjs';
3
+ export { i as initConfigs } from './types.d-jQzOw4mx.cjs';
4
4
  import 'node:fs';
5
5
  import 'typescript';
6
6
 
@@ -1,6 +1,6 @@
1
1
  import { JSONSchema } from '@hey-api/json-schema-ref-parser';
2
- import { e as Config, I as IR, W as WatchValues } from './types.d-DtkupL5A.js';
3
- export { i as initConfigs } from './types.d-DtkupL5A.js';
2
+ import { e as Config, I as IR, W as WatchValues } from './types.d-jQzOw4mx.js';
3
+ export { i as initConfigs } from './types.d-jQzOw4mx.js';
4
4
  import 'node:fs';
5
5
  import 'typescript';
6
6
 
package/dist/internal.js CHANGED
@@ -1,2 +1,2 @@
1
- import {createRequire}from'module';export{r as getSpec,F as initConfigs,A as parseOpenApiSpec}from'./chunk-LC3ZVK3Y.js';createRequire(import.meta.url);//# sourceMappingURL=internal.js.map
1
+ import {createRequire}from'module';export{r as getSpec,I as initConfigs,B as parseOpenApiSpec}from'./chunk-WELTPW5K.js';createRequire(import.meta.url);//# sourceMappingURL=internal.js.map
2
2
  //# sourceMappingURL=internal.js.map
@@ -3295,6 +3295,48 @@ interface OpenApi$2 {
3295
3295
 
3296
3296
  type OpenApi$1 = OpenApi$3 | OpenApi$2;
3297
3297
 
3298
+ interface Operation extends Omit<Operation$1, 'tags'> {
3299
+ service: string;
3300
+ }
3301
+
3302
+ interface Service extends Pick<Model, '$refs' | 'imports' | 'name'> {
3303
+ operations: Operation[];
3304
+ }
3305
+
3306
+ interface Client$1 extends Omit<Client$2, 'operations'> {
3307
+ services: Service[];
3308
+ }
3309
+
3310
+ type ExtractWithDiscriminator<T, Discriminator> = T extends Discriminator
3311
+ ? T
3312
+ : never;
3313
+
3314
+ /**
3315
+ * Accepts an array of elements union and attempts to extract only objects.
3316
+ * For example, Array<string | number | { id: string }> would result in
3317
+ * Array<{ id: string }>.
3318
+ */
3319
+ type ExtractArrayOfObjects<T, Discriminator> =
3320
+ T extends Array<infer U>
3321
+ ? Array<ExtractWithDiscriminator<U, Discriminator>>
3322
+ : T extends ReadonlyArray<infer U>
3323
+ ? ReadonlyArray<ExtractWithDiscriminator<U, Discriminator>>
3324
+ : never;
3325
+
3326
+ type Files = Record<string, TypeScriptFile>;
3327
+
3328
+ /**
3329
+ * Transforms an array of objects into an optional object map.
3330
+ * For example, Array<{ id: string }> would result in
3331
+ * { [key: string]?: { id: string } }
3332
+ */
3333
+ type ArrayOfObjectsToObjectMap<
3334
+ T extends ReadonlyArray<Record<string, any>>,
3335
+ D extends keyof T[number],
3336
+ > = {
3337
+ [K in T[number][D]]?: Extract<T[number], Record<D, K>>;
3338
+ };
3339
+
3298
3340
  interface JsonSchemaDraft4 extends EnumExtensions {
3299
3341
  /**
3300
3342
  * A schema can reference another schema using the `$ref` keyword. The value of `$ref` is a URI-reference that is resolved against the schema's {@link https://json-schema.org/understanding-json-schema/structuring#base-uri Base URI}. When evaluating a `$ref`, an implementation uses the resolved identifier to retrieve the referenced schema and applies that schema to the {@link https://json-schema.org/learn/glossary#instance instance}.
@@ -6397,52 +6439,41 @@ declare namespace OpenApiSchemaObject {
6397
6439
  export type V3_1_X = OpenApiV3_1_XTypes['SchemaObject'];
6398
6440
  }
6399
6441
 
6400
- interface Operation extends Omit<Operation$1, 'tags'> {
6401
- service: string;
6402
- }
6403
-
6404
- interface Service extends Pick<Model, '$refs' | 'imports' | 'name'> {
6405
- operations: Operation[];
6406
- }
6407
-
6408
- interface Client$1 extends Omit<Client$2, 'operations'> {
6409
- services: Service[];
6442
+ declare class PluginInstance<PluginConfig extends BaseConfig = BaseConfig> {
6443
+ config: Plugin.Config<PluginConfig>['config'];
6444
+ context: IR.Context;
6445
+ dependencies: Required<Plugin.Config<PluginConfig>>['dependencies'];
6446
+ private handler;
6447
+ name: Plugin.Config<PluginConfig>['name'];
6448
+ output: Required<PluginConfig>['output'];
6449
+ constructor(props: Pick<Required<Plugin.Config<PluginConfig>>, 'config' | 'dependencies' | 'handler'> & Pick<Required<PluginConfig>, 'output'> & {
6450
+ context: IR.Context<OpenApi.V2_0_X | OpenApi.V3_0_X | OpenApi.V3_1_X>;
6451
+ name: string;
6452
+ });
6453
+ createFile(file: IR.ContextFile): TypeScriptFile;
6454
+ /**
6455
+ * Retrieves a registered plugin instance by its name from the context. This
6456
+ * allows plugins to access other plugins that have been registered in the
6457
+ * same context, enabling cross-plugin communication and dependencies.
6458
+ *
6459
+ * @param name Plugin name as defined in the configuration.
6460
+ * @returns The plugin instance if found, undefined otherwise.
6461
+ */
6462
+ getPlugin<T extends keyof Config['plugins']>(name: T): IR.Context['plugins'][T];
6463
+ /**
6464
+ * Executes plugin's handler function.
6465
+ */
6466
+ run(): Promise<void>;
6467
+ /**
6468
+ * Subscribe to an input parser event.
6469
+ *
6470
+ * @param event Event type from the parser.
6471
+ * @param callbackFn Function to execute on event.
6472
+ * @returns void
6473
+ */
6474
+ subscribe<T extends keyof IR.ContextEvents>(event: T, callbackFn: IR.ContextEvents[T]): void;
6410
6475
  }
6411
6476
 
6412
- type ExtractWithDiscriminator<T, Discriminator> = T extends Discriminator
6413
- ? T
6414
- : never;
6415
-
6416
- /**
6417
- * Accepts an array of elements union and attempts to extract only objects.
6418
- * For example, Array<string | number | { id: string }> would result in
6419
- * Array<{ id: string }>.
6420
- */
6421
- type ExtractArrayOfObjects<T, Discriminator> =
6422
- T extends Array<infer U>
6423
- ? Array<ExtractWithDiscriminator<U, Discriminator>>
6424
- : T extends ReadonlyArray<infer U>
6425
- ? ReadonlyArray<ExtractWithDiscriminator<U, Discriminator>>
6426
- : never;
6427
-
6428
- type Files = Record<string, TypeScriptFile>;
6429
-
6430
- /**
6431
- * Transforms an array of objects into an optional object map.
6432
- * For example, Array<{ id: string }> would result in
6433
- * { [key: string]?: { id: string } }
6434
- */
6435
- type ArrayOfObjectsToObjectMap<
6436
- T extends ReadonlyArray<Record<string, any>>,
6437
- D extends keyof T[number],
6438
- > = {
6439
- [K in T[number][D]]?: Extract<T[number], Record<D, K>>;
6440
- };
6441
-
6442
- type OmitUnderscoreKeys<T> = {
6443
- [K in keyof T as K extends `_${string}` ? never : K]: T[K];
6444
- };
6445
-
6446
6477
  type PluginClientNames =
6447
6478
  | '@hey-api/client-axios'
6448
6479
  | '@hey-api/client-fetch'
@@ -6474,12 +6505,38 @@ type AnyPluginName = PluginNames | (string & {});
6474
6505
 
6475
6506
  type PluginTag = 'client' | 'transformer' | 'validator';
6476
6507
 
6508
+ type ObjectType<T> =
6509
+ Extract<T, Record<string, any>> extends never
6510
+ ? Record<string, any>
6511
+ : Extract<T, Record<string, any>>;
6512
+
6477
6513
  interface PluginContext {
6478
- ensureDependency: (name: PluginNames | true) => void;
6479
- pluginByTag: (
6514
+ pluginByTag: <T extends AnyPluginName | boolean = AnyPluginName>(
6480
6515
  tag: PluginTag,
6481
- errorMessage?: string,
6482
- ) => AnyPluginName | undefined;
6516
+ props?: {
6517
+ defaultPlugin?: Exclude<T, boolean>;
6518
+ errorMessage?: string;
6519
+ },
6520
+ ) => Exclude<T, boolean> | undefined;
6521
+ valueToObject: <
6522
+ T extends undefined | string | boolean | number | Record<string, any>,
6523
+ >(args: {
6524
+ defaultValue: ObjectType<T>;
6525
+ mappers: {
6526
+ boolean: T extends boolean
6527
+ ? (value: boolean) => Partial<ObjectType<T>>
6528
+ : never;
6529
+ number: T extends number
6530
+ ? (value: number) => Partial<ObjectType<T>>
6531
+ : never;
6532
+ string: T extends string
6533
+ ? (value: string) => Partial<ObjectType<T>>
6534
+ : never;
6535
+ } extends infer U
6536
+ ? { [K in keyof U as U[K] extends never ? never : K]: U[K] }
6537
+ : never;
6538
+ value: T;
6539
+ }) => ObjectType<T>;
6483
6540
  }
6484
6541
 
6485
6542
  interface BaseConfig {
@@ -6492,42 +6549,63 @@ interface BaseConfig {
6492
6549
  output?: string;
6493
6550
  }
6494
6551
 
6495
- interface Meta<Config extends BaseConfig> {
6552
+ interface Meta<
6553
+ Config extends BaseConfig,
6554
+ ResolvedConfig extends BaseConfig = Config,
6555
+ > {
6496
6556
  /**
6497
6557
  * Dependency plugins will be always processed, regardless of whether user
6498
6558
  * explicitly defines them in their `plugins` config.
6499
6559
  */
6500
- _dependencies?: ReadonlyArray<AnyPluginName>;
6560
+ dependencies?: ReadonlyArray<AnyPluginName>;
6501
6561
  /**
6502
- * Allows overriding config before it's sent to the parser. An example is
6503
- * defining `validator` as `true` and the plugin figures out which plugin
6562
+ * Resolves static configuration values into their runtime equivalents. For
6563
+ * example, when `validator` is set to `true`, it figures out which plugin
6504
6564
  * should be used for validation.
6505
6565
  */
6506
- _infer?: (
6507
- config: Config & Omit<Meta<Config>, '_infer'>,
6566
+ resolveConfig?: (
6567
+ plugin: Omit<Plugin.Config<Config, ResolvedConfig>, 'dependencies'> & {
6568
+ dependencies: Set<AnyPluginName>;
6569
+ },
6508
6570
  context: PluginContext,
6509
6571
  ) => void;
6510
6572
  /**
6511
- * Optional tags can be used to help with deciding plugin order and inferring
6573
+ * Optional tags can be used to help with deciding plugin order and resolving
6512
6574
  * plugin configuration options.
6513
6575
  */
6514
- _tags?: ReadonlyArray<PluginTag>;
6576
+ tags?: ReadonlyArray<PluginTag>;
6515
6577
  }
6516
6578
 
6517
6579
  /**
6518
6580
  * Public Plugin API.
6519
6581
  */
6520
6582
  declare namespace Plugin {
6521
- export type Config<Config extends BaseConfig> = Config &
6522
- Meta<Config> & {
6523
- _handler: Plugin.Handler<Config>;
6524
- _handlerLegacy: Plugin.LegacyHandler<Config>;
6525
- exportFromIndex?: boolean;
6583
+ export type Config<
6584
+ Config extends BaseConfig,
6585
+ ResolvedConfig extends BaseConfig = Config,
6586
+ > = Pick<Config, 'name' | 'output'> &
6587
+ Meta<Config, ResolvedConfig> & {
6588
+ config: Omit<Config, 'name' | 'output'>;
6589
+ handler: Plugin.Handler<
6590
+ Omit<ResolvedConfig, 'name'> & {
6591
+ name: any;
6592
+ }
6593
+ >;
6594
+ handlerLegacy: Plugin.LegacyHandler<
6595
+ Omit<ResolvedConfig, 'name'> & {
6596
+ name: any;
6597
+ }
6598
+ >;
6526
6599
  };
6527
6600
 
6528
- export type DefineConfig<Config extends BaseConfig> = (
6529
- config?: Plugin.UserConfig<Omit<Config, 'name'>>,
6530
- ) => Omit<Plugin.Config<Config>, 'name'> & {
6601
+ /** @deprecated - use `definePluginConfig()` instead */
6602
+ export type DefineConfig<
6603
+ Config extends BaseConfig,
6604
+ ResolvedConfig extends BaseConfig = Config,
6605
+ > = (config?: Plugin.UserConfig<Omit<Config, 'name'>>) => Omit<
6606
+ Plugin.Config<Config, ResolvedConfig>,
6607
+ 'name'
6608
+ > & {
6531
6609
  /**
6532
6610
  * Cast name to `any` so it doesn't throw type error in `plugins` array.
6533
6611
  * We could allow any `string` as plugin `name` in the object syntax, but
@@ -6541,12 +6619,10 @@ declare namespace Plugin {
6541
6619
  * Plugin implementation for experimental parser.
6542
6620
  */
6543
6621
  export type Handler<Config extends BaseConfig, ReturnType = void> = (args: {
6544
- context: IR.Context<OpenApi.V2_0_X | OpenApi.V3_0_X | OpenApi.V3_1_X>;
6545
6622
  plugin: Plugin.Instance<Config>;
6546
6623
  }) => ReturnType;
6547
6624
 
6548
- export type Instance<Config extends BaseConfig> = OmitUnderscoreKeys<Config> &
6549
- Pick<Required<BaseConfig>, 'exportFromIndex' | 'output'>;
6625
+ export type Instance<Config extends BaseConfig> = PluginInstance<Config>;
6550
6626
 
6551
6627
  /**
6552
6628
  * Plugin implementation for legacy parser.
@@ -6597,10 +6673,7 @@ interface Config$j
6597
6673
  Client.Config {}
6598
6674
 
6599
6675
  type PluginHandler<ReturnType = void> = Plugin.Handler<
6600
- Omit<
6601
- Config$i | Config$l | Config$k | Config$j,
6602
- 'name'
6603
- >,
6676
+ Config$i | Config$l | Config$k | Config$j,
6604
6677
  ReturnType
6605
6678
  >;
6606
6679
 
@@ -6624,25 +6697,12 @@ declare namespace Client {
6624
6697
  */
6625
6698
  baseUrl?: string | number | boolean;
6626
6699
  /**
6627
- * Bundle the client module? Set this to true if don't want to declare it
6628
- * as a separate dependency. When true, the client module will be generated
6629
- * from the client package and bundled with the rest of the generated output.
6630
- * This is useful if you're repackaging the output, publishing it to other
6631
- * users, and you don't want them to install any dependencies.
6700
+ * Bundle the client module? When `true`, the client module will be copied
6701
+ * from the client plugin and bundled with the generated output.
6632
6702
  *
6633
- * @default false
6703
+ * @default true
6634
6704
  */
6635
6705
  bundle?: boolean;
6636
- /**
6637
- * **This is an experimental feature.**
6638
- *
6639
- * When `bundle` is set to `true`, you can optionally set this option
6640
- * to `true` to bundle the client source code instead of the `dist` folder.
6641
- * This will copy the TypeScript files instead of CJS/ESM JavaScript files.
6642
- *
6643
- * @default false
6644
- */
6645
- bundleSource_EXPERIMENTAL?: boolean;
6646
6706
  /**
6647
6707
  * Should the exports from the generated files be re-exported in the index
6648
6708
  * barrel file?
@@ -6795,10 +6855,10 @@ interface Config$b extends Plugin.Name<'@hey-api/sdk'> {
6795
6855
  * Use an internal client instance to send HTTP requests? This is useful if
6796
6856
  * you don't want to manually pass the client to each SDK function.
6797
6857
  *
6798
- * Ensure you have declared the selected library as a dependency to avoid
6799
- * errors. You can customize the selected client output through its plugin.
6800
- * You can also set `client` to `true` to automatically choose the client
6801
- * from your defined plugins.
6858
+ * You can customize the selected client output through its plugin. You can
6859
+ * also set `client` to `true` to automatically choose the client from your
6860
+ * defined plugins. If we can't detect a client plugin when using `true`, we
6861
+ * will default to `@hey-api/client-fetch`.
6802
6862
  *
6803
6863
  * @default true
6804
6864
  */
@@ -7293,16 +7353,52 @@ interface Config$2 extends Plugin.Name<'valibot'> {
7293
7353
  output?: string;
7294
7354
  }
7295
7355
 
7296
- // import type { IR } from '../../ir/types';
7297
-
7298
-
7299
7356
  interface Config$1 extends Plugin.Name<'zod'> {
7357
+ /**
7358
+ * The casing convention to use for generated names.
7359
+ *
7360
+ * @default 'camelCase'
7361
+ */
7362
+ case?: StringCase;
7300
7363
  /**
7301
7364
  * Add comments from input to the generated Zod schemas?
7302
7365
  *
7303
7366
  * @default true
7304
7367
  */
7305
7368
  comments?: boolean;
7369
+ /**
7370
+ * Configuration for reusable schema definitions. Controls generation of
7371
+ * shared Zod schemas that can be referenced across requests and responses.
7372
+ *
7373
+ * Can be:
7374
+ * - `boolean`: Shorthand for `{ enabled: boolean }`
7375
+ * - `string`: Shorthand for `{ enabled: true; name: string }`
7376
+ * - `object`: Full configuration object
7377
+ */
7378
+ definitions?:
7379
+ | boolean
7380
+ | string
7381
+ | {
7382
+ /**
7383
+ * The casing convention to use for generated names.
7384
+ *
7385
+ * @default 'camelCase'
7386
+ */
7387
+ case?: StringCase;
7388
+ /**
7389
+ * Whether to generate Zod schemas for reusable definitions.
7390
+ *
7391
+ * @default true
7392
+ */
7393
+ enabled?: boolean;
7394
+ /**
7395
+ * Custom naming pattern for generated schema names. The name variable is
7396
+ * obtained from the schema name.
7397
+ *
7398
+ * @default 'z{{name}}'
7399
+ */
7400
+ name?: string | ((name: string) => string);
7401
+ };
7306
7402
  /**
7307
7403
  * Should the exports from the generated files be re-exported in the index
7308
7404
  * barrel file?
@@ -7318,17 +7414,78 @@ interface Config$1 extends Plugin.Name<'zod'> {
7318
7414
  * @default false
7319
7415
  */
7320
7416
  metadata?: boolean;
7321
- /**
7322
- * Customise the Zod schema name. By default, `z{{name}}` is used,
7323
- * where `name` is a definition name or an operation name.
7324
- */
7325
- // nameBuilder?: (model: IR.OperationObject | IR.SchemaObject) => string;
7326
7417
  /**
7327
7418
  * Name of the generated file.
7328
7419
  *
7329
7420
  * @default 'zod'
7330
7421
  */
7331
7422
  output?: string;
7423
+ /**
7424
+ * Configuration for request-specific Zod schemas.
7425
+ * Controls generation of Zod schemas for request bodies, query parameters, path parameters, and headers.
7426
+ *
7427
+ * Can be:
7428
+ * - `boolean`: Shorthand for `{ enabled: boolean }`
7429
+ * - `string`: Shorthand for `{ enabled: true; name: string }`
7430
+ * - `object`: Full configuration object
7431
+ */
7432
+ requests?:
7433
+ | boolean
7434
+ | string
7435
+ | {
7436
+ /**
7437
+ * The casing convention to use for generated names.
7438
+ *
7439
+ * @default 'camelCase'
7440
+ */
7441
+ case?: StringCase;
7442
+ /**
7443
+ * Whether to generate Zod schemas for request definitions.
7444
+ *
7445
+ * @default true
7446
+ */
7447
+ enabled?: boolean;
7448
+ /**
7449
+ * Custom naming pattern for generated schema names. The name variable is
7450
+ * obtained from the operation name.
7451
+ *
7452
+ * @default 'z{{name}}Data'
7453
+ */
7454
+ name?: string | ((name: string) => string);
7455
+ };
7456
+ /**
7457
+ * Configuration for response-specific Zod schemas.
7458
+ * Controls generation of Zod schemas for response bodies, error responses, and status codes.
7459
+ *
7460
+ * Can be:
7461
+ * - `boolean`: Shorthand for `{ enabled: boolean }`
7462
+ * - `string`: Shorthand for `{ enabled: true; name: string }`
7463
+ * - `object`: Full configuration object
7464
+ */
7465
+ responses?:
7466
+ | boolean
7467
+ | string
7468
+ | {
7469
+ /**
7470
+ * The casing convention to use for generated names.
7471
+ *
7472
+ * @default 'camelCase'
7473
+ */
7474
+ case?: StringCase;
7475
+ /**
7476
+ * Whether to generate Zod schemas for response definitions.
7477
+ *
7478
+ * @default true
7479
+ */
7480
+ enabled?: boolean;
7481
+ /**
7482
+ * Custom naming pattern for generated schema names. The name variable is
7483
+ * obtained from the operation name.
7484
+ *
7485
+ * @default 'z{{name}}Response'
7486
+ */
7487
+ name?: string | ((name: string) => string);
7488
+ };
7332
7489
  }
7333
7490
 
7334
7491
  /**
@@ -7978,6 +8135,7 @@ declare class TypeScriptFile {
7978
8135
  get exportFromIndex(): boolean;
7979
8136
  get id(): string;
7980
8137
  identifier(args: Pick<EnsureUniqueIdentifierData, '$ref' | 'count' | 'create' | 'nameTransformer'> & {
8138
+ case?: StringCase;
7981
8139
  namespace: Namespace;
7982
8140
  }): Identifier;
7983
8141
  /**
@@ -8012,10 +8170,18 @@ interface EnsureUniqueIdentifierData {
8012
8170
  /**
8013
8171
  * Transforms name obtained from `$ref` before it's passed to `stringCase()`.
8014
8172
  */
8015
- nameTransformer?: (name: string) => string;
8173
+ nameTransformer?: ((name: string) => string) | string;
8016
8174
  namespace: Namespace;
8017
8175
  }
8018
8176
 
8177
+ type ExtractConfig<T> = T extends {
8178
+ config: infer C;
8179
+ } ? C & {
8180
+ name: string;
8181
+ } : never;
8182
+ type PluginInstanceMap = {
8183
+ [K in keyof Config['plugins']]?: PluginInstance<ExtractConfig<Config['plugins'][K]>>;
8184
+ };
8019
8185
  interface ContextFile {
8020
8186
  /**
8021
8187
  * Should the exports from this file be re-exported in the index barrel file?
@@ -8031,6 +8197,7 @@ interface ContextFile {
8031
8197
  identifierCase?: StringCase;
8032
8198
  /**
8033
8199
  * Relative file path to the output path.
8200
+ *
8034
8201
  * @example
8035
8202
  * 'bar/foo.ts'
8036
8203
  */
@@ -8083,6 +8250,12 @@ declare class IRContext<Spec extends Record<string, any> = any> {
8083
8250
  * Intermediate representation model obtained from `spec`.
8084
8251
  */
8085
8252
  ir: IR.Model;
8253
+ /**
8254
+ * A map of registered plugin instances, keyed by plugin name. Plugins are
8255
+ * registered through the `registerPlugin` method and can be accessed by
8256
+ * their configured name from the config.
8257
+ */
8258
+ plugins: PluginInstanceMap;
8086
8259
  /**
8087
8260
  * Resolved specification from `input`.
8088
8261
  */
@@ -8114,6 +8287,18 @@ declare class IRContext<Spec extends Record<string, any> = any> {
8114
8287
  * Returns a specific file by ID from `files`.
8115
8288
  */
8116
8289
  file({ id }: Pick<ContextFile, 'id'>): TypeScriptFile | undefined;
8290
+ /**
8291
+ * Registers a new plugin to the global context.
8292
+ *
8293
+ * @param name Plugin name.
8294
+ * @returns Registered plugin instance.
8295
+ */
8296
+ private registerPlugin;
8297
+ /**
8298
+ * Generator that iterates through plugin order and registers each plugin.
8299
+ * Yields the registered plugin instance for each plugin name.
8300
+ */
8301
+ registerPlugins(): Generator<PluginInstance>;
8117
8302
  resolveIrRef<T>($ref: string): T;
8118
8303
  /**
8119
8304
  * Returns a resolved reference from `spec`.
@@ -8122,7 +8307,7 @@ declare class IRContext<Spec extends Record<string, any> = any> {
8122
8307
  /**
8123
8308
  * Register a new `event` listener.
8124
8309
  */
8125
- subscribe<T extends keyof Events>(event: T, callbackFn: Events[T], pluginName?: string): void;
8310
+ subscribe<T extends keyof Events>(event: T, callbackFn: Events[T], pluginName: string): void;
8126
8311
  }
8127
8312
 
8128
8313
  type IRMediaType = 'form-data' | 'json' | 'text' | 'url-search-params' | 'octet-stream';
@@ -8338,6 +8523,8 @@ declare namespace IR {
8338
8523
  export type BodyObject = IRBodyObject;
8339
8524
  export type ComponentsObject = IRComponentsObject;
8340
8525
  export type Context<Spec extends Record<string, any> = any> = IRContext<Spec>;
8526
+ export type ContextEvents = Events;
8527
+ export type ContextFile = ContextFile;
8341
8528
  export type Model = IRModel;
8342
8529
  export type OperationObject = IROperationObject;
8343
8530
  export type ParameterObject = IRParameterObject;
@@ -8359,7 +8546,10 @@ declare const defaultPlugins: readonly ["@hey-api/typescript", "@hey-api/sdk"];
8359
8546
  /**
8360
8547
  * @internal
8361
8548
  */
8362
- declare const initConfigs: (userConfig: UserConfig | undefined) => Promise<Config[]>;
8549
+ declare const initConfigs: (userConfig: UserConfig | undefined) => Promise<ReadonlyArray<{
8550
+ config: Config;
8551
+ errors: ReadonlyArray<Error>;
8552
+ }>>;
8363
8553
 
8364
8554
  declare namespace LegacyIR {
8365
8555
  export type LegacyOperation = Operation;
@@ -8383,4 +8573,4 @@ interface WatchValues {
8383
8573
  lastValue?: string;
8384
8574
  }
8385
8575
 
8386
- export { type Client$1 as C, IR as I, LegacyIR as L, OpenApi as O, type PluginHandler as P, type StringCase as S, type UserConfig as U, type WatchValues as W, OpenApiSchemaObject as a, Client as b, Plugin as c, defaultPlugins as d, type Config as e, initConfigs as i };
8576
+ export { type BaseConfig as B, type Client$1 as C, IR as I, LegacyIR as L, OpenApi as O, type PluginHandler as P, type StringCase as S, type UserConfig as U, type WatchValues as W, Plugin as a, OpenApiSchemaObject as b, Client as c, defaultPlugins as d, type Config as e, initConfigs as i };