@hey-api/openapi-ts 0.62.3 → 0.63.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.ts CHANGED
@@ -6370,7 +6370,20 @@ type OmitUnderscoreKeys<T> = {
6370
6370
  [K in keyof T as K extends `_${string}` ? never : K]: T[K];
6371
6371
  };
6372
6372
 
6373
+ type PluginClientNames =
6374
+ | '@hey-api/client-axios'
6375
+ | '@hey-api/client-fetch'
6376
+ | '@hey-api/client-nuxt'
6377
+ | 'legacy/angular'
6378
+ | 'legacy/axios'
6379
+ | 'legacy/fetch'
6380
+ | 'legacy/node'
6381
+ | 'legacy/xhr';
6382
+
6383
+ type PluginValidatorNames = 'zod';
6384
+
6373
6385
  type PluginNames =
6386
+ | PluginClientNames
6374
6387
  | '@hey-api/schemas'
6375
6388
  | '@hey-api/sdk'
6376
6389
  | '@hey-api/transformers'
@@ -6381,15 +6394,18 @@ type PluginNames =
6381
6394
  | '@tanstack/svelte-query'
6382
6395
  | '@tanstack/vue-query'
6383
6396
  | 'fastify'
6384
- | 'zod';
6397
+ | PluginValidatorNames;
6385
6398
 
6386
6399
  type AnyPluginName = PluginNames | (string & {});
6387
6400
 
6388
- type PluginTag = 'transformer' | 'validator';
6401
+ type PluginTag = 'client' | 'transformer' | 'validator';
6389
6402
 
6390
6403
  interface PluginContext {
6391
6404
  ensureDependency: (name: PluginNames | true) => void;
6392
- pluginByTag: (tag: PluginTag) => AnyPluginName | undefined;
6405
+ pluginByTag: (
6406
+ tag: PluginTag,
6407
+ errorMessage?: string,
6408
+ ) => AnyPluginName | undefined;
6393
6409
  }
6394
6410
 
6395
6411
  interface BaseConfig {
@@ -6424,6 +6440,41 @@ interface Meta<Config extends BaseConfig> {
6424
6440
  _tags?: ReadonlyArray<PluginTag>;
6425
6441
  }
6426
6442
 
6443
+ /**
6444
+ * Public Client API.
6445
+ */
6446
+ declare namespace Client {
6447
+ export type Config = {
6448
+ /**
6449
+ * Bundle the client module? Set this to true if don't want to declare it
6450
+ * as a separate dependency. When true, the client module will be generated
6451
+ * from the client package and bundled with the rest of the generated output.
6452
+ * This is useful if you're repackaging the output, publishing it to other
6453
+ * users, and you don't want them to install any dependencies.
6454
+ *
6455
+ * @default false
6456
+ */
6457
+ bundle?: boolean;
6458
+ /**
6459
+ * Name of the generated file.
6460
+ *
6461
+ * @default 'client'
6462
+ */
6463
+ output?: string;
6464
+ /**
6465
+ * Relative path to the runtime configuration file. This file must export
6466
+ * a `createClientConfig()` function. The `createClientConfig()` function
6467
+ * will be called on client initialization and the returned object will
6468
+ * become the client's initial configuration.
6469
+ *
6470
+ * You may want to initialize your client this way instead of calling
6471
+ * `setConfig()`. This is useful for example if you're using Next.js
6472
+ * to ensure your client always has the correct values.
6473
+ */
6474
+ runtimeConfigPath?: string;
6475
+ };
6476
+ }
6477
+
6427
6478
  /**
6428
6479
  * Public Plugin API.
6429
6480
  */
@@ -6480,6 +6531,52 @@ declare namespace Plugin {
6480
6531
  export type UserConfig<Config extends BaseConfig> = Omit<Config, 'output'>;
6481
6532
  }
6482
6533
 
6534
+ interface Config$j
6535
+ extends Plugin.Name<'@hey-api/client-axios'>,
6536
+ Client.Config {
6537
+ /**
6538
+ * Throw an error instead of returning it in the response?
6539
+ *
6540
+ * @default false
6541
+ */
6542
+ throwOnError?: boolean;
6543
+ }
6544
+
6545
+ interface Config$i
6546
+ extends Plugin.Name<'@hey-api/client-fetch'>,
6547
+ Client.Config {
6548
+ /**
6549
+ * Throw an error instead of returning it in the response?
6550
+ *
6551
+ * @default false
6552
+ */
6553
+ throwOnError?: boolean;
6554
+ }
6555
+
6556
+ interface Config$h
6557
+ extends Plugin.Name<'@hey-api/client-nuxt'>,
6558
+ Client.Config {}
6559
+
6560
+ interface Config$g
6561
+ extends Plugin.Name<'legacy/angular'>,
6562
+ Pick<Client.Config, 'output'> {}
6563
+
6564
+ interface Config$f
6565
+ extends Plugin.Name<'legacy/axios'>,
6566
+ Pick<Client.Config, 'output'> {}
6567
+
6568
+ interface Config$e
6569
+ extends Plugin.Name<'legacy/fetch'>,
6570
+ Pick<Client.Config, 'output'> {}
6571
+
6572
+ interface Config$d
6573
+ extends Plugin.Name<'legacy/node'>,
6574
+ Pick<Client.Config, 'output'> {}
6575
+
6576
+ interface Config$c
6577
+ extends Plugin.Name<'legacy/xhr'>,
6578
+ Pick<Client.Config, 'output'> {}
6579
+
6483
6580
  interface Config$b extends Plugin.Name<'@hey-api/schemas'> {
6484
6581
  /**
6485
6582
  * Customise the schema name. By default, `{{name}}Schema` is used. `name` is a
@@ -6498,6 +6595,7 @@ interface Config$b extends Plugin.Name<'@hey-api/schemas'> {
6498
6595
  ) => string;
6499
6596
  /**
6500
6597
  * Name of the generated file.
6598
+ *
6501
6599
  * @default 'schemas'
6502
6600
  */
6503
6601
  output?: string;
@@ -6505,6 +6603,7 @@ interface Config$b extends Plugin.Name<'@hey-api/schemas'> {
6505
6603
  * Choose schema type to generate. Select 'form' if you don't want
6506
6604
  * descriptions to reduce bundle size and you plan to use schemas
6507
6605
  * for form validation
6606
+ *
6508
6607
  * @default 'json'
6509
6608
  */
6510
6609
  type?: 'form' | 'json';
@@ -6531,6 +6630,18 @@ interface Config$a extends Plugin.Name<'@hey-api/sdk'> {
6531
6630
  * @default true
6532
6631
  */
6533
6632
  auth?: boolean;
6633
+ /**
6634
+ * Use an internal client instance to send HTTP requests. This is useful if
6635
+ * you don't want to manually pass the client to each SDK function.
6636
+ *
6637
+ * Ensure you have declared the selected library as a dependency to avoid
6638
+ * errors. You can customize the selected client output through its plugin.
6639
+ * You can also set `client` to `true` to automatically choose the client
6640
+ * from your defined plugins.
6641
+ *
6642
+ * @default true
6643
+ */
6644
+ client?: PluginClientNames | boolean;
6534
6645
  /**
6535
6646
  * @deprecated
6536
6647
  *
@@ -6567,11 +6678,11 @@ interface Config$a extends Plugin.Name<'@hey-api/sdk'> {
6567
6678
  */
6568
6679
  output?: string;
6569
6680
  /**
6681
+ * @deprecated
6682
+ *
6570
6683
  * Define shape of returned value from service calls
6571
6684
  *
6572
6685
  * @default 'body'
6573
- *
6574
- * @deprecated
6575
6686
  */
6576
6687
  response?: 'body' | 'response';
6577
6688
  /**
@@ -6583,12 +6694,6 @@ interface Config$a extends Plugin.Name<'@hey-api/sdk'> {
6583
6694
  * @default '{{name}}Service'
6584
6695
  */
6585
6696
  serviceNameBuilder?: string;
6586
- /**
6587
- * Throw an error instead of returning it in the response?
6588
- *
6589
- * @default false
6590
- */
6591
- throwOnError?: boolean;
6592
6697
  /**
6593
6698
  * Transform response data before returning. This is useful if you want to
6594
6699
  * convert for example ISO strings into Date objects. However, transformation
@@ -6614,7 +6719,7 @@ interface Config$a extends Plugin.Name<'@hey-api/sdk'> {
6614
6719
  *
6615
6720
  * @default false
6616
6721
  */
6617
- validator?: 'zod' | boolean;
6722
+ validator?: PluginValidatorNames | boolean;
6618
6723
  }
6619
6724
 
6620
6725
  interface Config$9 extends Plugin.Name<'@hey-api/transformers'> {
@@ -6710,22 +6815,26 @@ interface Config$7
6710
6815
  extends Plugin.Name<'@tanstack/angular-query-experimental'> {
6711
6816
  /**
6712
6817
  * Generate {@link https://tanstack.com/query/v5/docs/framework/angular/reference/infiniteQueryOptions `infiniteQueryOptions()`} helpers? These will be generated from GET and POST requests where a pagination parameter is detected.
6818
+ *
6713
6819
  * @default true
6714
6820
  */
6715
6821
  infiniteQueryOptions?: boolean;
6716
6822
  /**
6717
6823
  * Generate {@link https://tanstack.com/query/v5/docs/framework/angular/reference/useMutation `useMutation()`} helpers? These will be generated from DELETE, PATCH, POST, and PUT requests.
6824
+ *
6718
6825
  * @default true
6719
6826
  */
6720
6827
  mutationOptions?: boolean;
6721
6828
  /**
6722
6829
  * Name of the generated file.
6830
+ *
6723
6831
  * @default '@tanstack/angular-query-experimental'
6724
6832
  */
6725
6833
  output?: string;
6726
6834
  /**
6727
6835
  * Generate {@link https://tanstack.com/query/v5/docs/framework/angular/reference/queryOptions `queryOptions()`} helpers?
6728
6836
  * These will be generated from all requests.
6837
+ *
6729
6838
  * @default true
6730
6839
  */
6731
6840
  queryOptions?: boolean;
@@ -6734,22 +6843,26 @@ interface Config$7
6734
6843
  interface Config$6 extends Plugin.Name<'@tanstack/react-query'> {
6735
6844
  /**
6736
6845
  * Generate {@link https://tanstack.com/query/v5/docs/framework/react/reference/infiniteQueryOptions `infiniteQueryOptions()`} helpers? These will be generated from GET and POST requests where a pagination parameter is detected.
6846
+ *
6737
6847
  * @default true
6738
6848
  */
6739
6849
  infiniteQueryOptions?: boolean;
6740
6850
  /**
6741
6851
  * Generate {@link https://tanstack.com/query/v5/docs/framework/react/reference/useMutation `useMutation()`} helpers? These will be generated from DELETE, PATCH, POST, and PUT requests.
6852
+ *
6742
6853
  * @default true
6743
6854
  */
6744
6855
  mutationOptions?: boolean;
6745
6856
  /**
6746
6857
  * Name of the generated file.
6858
+ *
6747
6859
  * @default '@tanstack/react-query'
6748
6860
  */
6749
6861
  output?: string;
6750
6862
  /**
6751
6863
  * Generate {@link https://tanstack.com/query/v5/docs/framework/react/reference/queryOptions `queryOptions()`} helpers?
6752
6864
  * These will be generated from all requests.
6865
+ *
6753
6866
  * @default true
6754
6867
  */
6755
6868
  queryOptions?: boolean;
@@ -6758,22 +6871,26 @@ interface Config$6 extends Plugin.Name<'@tanstack/react-query'> {
6758
6871
  interface Config$5 extends Plugin.Name<'@tanstack/solid-query'> {
6759
6872
  /**
6760
6873
  * Generate `createInfiniteQuery()` helpers? These will be generated from GET and POST requests where a pagination parameter is detected.
6874
+ *
6761
6875
  * @default true
6762
6876
  */
6763
6877
  infiniteQueryOptions?: boolean;
6764
6878
  /**
6765
6879
  * Generate `createMutation()` helpers? These will be generated from DELETE, PATCH, POST, and PUT requests.
6880
+ *
6766
6881
  * @default true
6767
6882
  */
6768
6883
  mutationOptions?: boolean;
6769
6884
  /**
6770
6885
  * Name of the generated file.
6886
+ *
6771
6887
  * @default '@tanstack/solid-query'
6772
6888
  */
6773
6889
  output?: string;
6774
6890
  /**
6775
6891
  * Generate {@link https://tanstack.com/query/v5/docs/framework/solid/reference/createQuery `createQuery()`} helpers?
6776
6892
  * These will be generated from all requests.
6893
+ *
6777
6894
  * @default true
6778
6895
  */
6779
6896
  queryOptions?: boolean;
@@ -6782,22 +6899,26 @@ interface Config$5 extends Plugin.Name<'@tanstack/solid-query'> {
6782
6899
  interface Config$4 extends Plugin.Name<'@tanstack/svelte-query'> {
6783
6900
  /**
6784
6901
  * Generate `createInfiniteQuery()` helpers? These will be generated from GET and POST requests where a pagination parameter is detected.
6902
+ *
6785
6903
  * @default true
6786
6904
  */
6787
6905
  infiniteQueryOptions?: boolean;
6788
6906
  /**
6789
6907
  * Generate {@link https://tanstack.com/query/v5/docs/framework/svelte/reference/functions/createmutation `createMutation()`} helpers? These will be generated from DELETE, PATCH, POST, and PUT requests.
6908
+ *
6790
6909
  * @default true
6791
6910
  */
6792
6911
  mutationOptions?: boolean;
6793
6912
  /**
6794
6913
  * Name of the generated file.
6914
+ *
6795
6915
  * @default '@tanstack/svelte-query'
6796
6916
  */
6797
6917
  output?: string;
6798
6918
  /**
6799
6919
  * Generate {@link https://tanstack.com/query/v5/docs/framework/svelte/reference/functions/createquery `createQuery()`} helpers?
6800
6920
  * These will be generated from all requests.
6921
+ *
6801
6922
  * @default true
6802
6923
  */
6803
6924
  queryOptions?: boolean;
@@ -6806,22 +6927,26 @@ interface Config$4 extends Plugin.Name<'@tanstack/svelte-query'> {
6806
6927
  interface Config$3 extends Plugin.Name<'@tanstack/vue-query'> {
6807
6928
  /**
6808
6929
  * Generate {@link https://tanstack.com/query/v5/docs/framework/vue/reference/infiniteQueryOptions `infiniteQueryOptions()`} helpers? These will be generated from GET and POST requests where a pagination parameter is detected.
6930
+ *
6809
6931
  * @default true
6810
6932
  */
6811
6933
  infiniteQueryOptions?: boolean;
6812
6934
  /**
6813
6935
  * Generate {@link https://tanstack.com/query/v5/docs/framework/vue/reference/useMutation `useMutation()`} helpers? These will be generated from DELETE, PATCH, POST, and PUT requests.
6936
+ *
6814
6937
  * @default true
6815
6938
  */
6816
6939
  mutationOptions?: boolean;
6817
6940
  /**
6818
6941
  * Name of the generated file.
6942
+ *
6819
6943
  * @default '@tanstack/vue-query'
6820
6944
  */
6821
6945
  output?: string;
6822
6946
  /**
6823
6947
  * Generate {@link https://tanstack.com/query/v5/docs/framework/vue/guides/query-options `queryOptions()`} helpers?
6824
6948
  * These will be generated from all requests.
6949
+ *
6825
6950
  * @default true
6826
6951
  */
6827
6952
  queryOptions?: boolean;
@@ -6830,6 +6955,7 @@ interface Config$3 extends Plugin.Name<'@tanstack/vue-query'> {
6830
6955
  interface Config$2 extends Plugin.Name<'fastify'> {
6831
6956
  /**
6832
6957
  * Name of the generated file.
6958
+ *
6833
6959
  * @default 'fastify'
6834
6960
  */
6835
6961
  output?: string;
@@ -6846,6 +6972,7 @@ interface Config$1 extends Plugin.Name<'zod'> {
6846
6972
  // nameBuilder?: (model: IR.OperationObject | IR.SchemaObject) => string;
6847
6973
  /**
6848
6974
  * Name of the generated file.
6975
+ *
6849
6976
  * @default 'zod'
6850
6977
  */
6851
6978
  output?: string;
@@ -6854,38 +6981,16 @@ interface Config$1 extends Plugin.Name<'zod'> {
6854
6981
  /**
6855
6982
  * User-facing plugin types.
6856
6983
  */
6857
- type UserPlugins = Plugin.UserConfig<Config$b> | Plugin.UserConfig<Config$a> | Plugin.UserConfig<Config$9> | Plugin.UserConfig<Config$8> | Plugin.UserConfig<Config$7> | Plugin.UserConfig<Config$6> | Plugin.UserConfig<Config$5> | Plugin.UserConfig<Config$4> | Plugin.UserConfig<Config$3> | Plugin.UserConfig<Config$2> | Plugin.UserConfig<Config$1>;
6984
+ type UserPlugins = Plugin.UserConfig<Config$j> | Plugin.UserConfig<Config$i> | Plugin.UserConfig<Config$h> | Plugin.UserConfig<Config$g> | Plugin.UserConfig<Config$f> | Plugin.UserConfig<Config$e> | Plugin.UserConfig<Config$d> | Plugin.UserConfig<Config$c> | Plugin.UserConfig<Config$b> | Plugin.UserConfig<Config$a> | Plugin.UserConfig<Config$9> | Plugin.UserConfig<Config$8> | Plugin.UserConfig<Config$7> | Plugin.UserConfig<Config$6> | Plugin.UserConfig<Config$5> | Plugin.UserConfig<Config$4> | Plugin.UserConfig<Config$3> | Plugin.UserConfig<Config$2> | Plugin.UserConfig<Config$1>;
6858
6985
  /**
6859
6986
  * Internal plugin types.
6860
6987
  */
6861
- type ClientPlugins = Plugin.Config<Config$b> | Plugin.Config<Config$a> | Plugin.Config<Config$9> | Plugin.Config<Config$8> | Plugin.Config<Config$7> | Plugin.Config<Config$6> | Plugin.Config<Config$5> | Plugin.Config<Config$4> | Plugin.Config<Config$3> | Plugin.Config<Config$2> | Plugin.Config<Config$1>;
6988
+ type ClientPlugins = Plugin.Config<Config$j> | Plugin.Config<Config$i> | Plugin.Config<Config$h> | Plugin.Config<Config$g> | Plugin.Config<Config$f> | Plugin.Config<Config$e> | Plugin.Config<Config$d> | Plugin.Config<Config$c> | Plugin.Config<Config$b> | Plugin.Config<Config$a> | Plugin.Config<Config$9> | Plugin.Config<Config$8> | Plugin.Config<Config$7> | Plugin.Config<Config$6> | Plugin.Config<Config$5> | Plugin.Config<Config$4> | Plugin.Config<Config$3> | Plugin.Config<Config$2> | Plugin.Config<Config$1>;
6862
6989
 
6863
- declare const CLIENTS: readonly ["@hey-api/client-axios", "@hey-api/client-fetch", "@hey-api/client-nuxt", "legacy/angular", "legacy/axios", "legacy/fetch", "legacy/node", "legacy/xhr"];
6864
- type Client = (typeof CLIENTS)[number];
6865
6990
  type Formatters = 'biome' | 'prettier';
6866
6991
  type Linters = 'biome' | 'eslint' | 'oxlint';
6867
6992
  type StringCase = 'camelCase' | 'PascalCase' | 'preserve' | 'snake_case' | 'SCREAMING_SNAKE_CASE';
6868
- interface ClientConfig {
6869
- /**
6870
- * HTTP client to generate
6871
- */
6872
- client?: Client | false | {
6873
- /**
6874
- * Bundle the client module? Set this to true if you're using a client
6875
- * package and don't want to declare it as a separate dependency.
6876
- * When true, the client module will be generated from the client
6877
- * package and bundled with the rest of the generated output. This is
6878
- * useful if you're repackaging the output, publishing it to other users,
6879
- * and you don't want them to install any dependencies.
6880
- *
6881
- * @default false
6882
- */
6883
- bundle?: boolean;
6884
- /**
6885
- * HTTP client to generate
6886
- */
6887
- name: Client;
6888
- };
6993
+ interface UserConfig {
6889
6994
  /**
6890
6995
  * Path to the config file. Set this value if you don't use the default
6891
6996
  * config file name, or it's not located in the project root.
@@ -7088,19 +7193,17 @@ interface ClientConfig {
7088
7193
  */
7089
7194
  useOptions?: boolean;
7090
7195
  }
7091
- type UserConfig = ClientConfig;
7092
- type Config = Omit<Required<ClientConfig>, 'base' | 'client' | 'input' | 'logs' | 'name' | 'output' | 'plugins' | 'request' | 'watch'> & Pick<ClientConfig, 'base' | 'name' | 'request'> & {
7093
- client: Extract<Required<ClientConfig>['client'], object>;
7094
- input: ExtractWithDiscriminator<ClientConfig['input'], {
7196
+ type Config = Omit<Required<UserConfig>, 'base' | 'input' | 'logs' | 'name' | 'output' | 'plugins' | 'request' | 'watch'> & Pick<UserConfig, 'base' | 'name' | 'request'> & {
7197
+ input: ExtractWithDiscriminator<UserConfig['input'], {
7095
7198
  path: unknown;
7096
7199
  }>;
7097
- logs: Extract<Required<ClientConfig['logs']>, object>;
7098
- output: Extract<ClientConfig['output'], object>;
7200
+ logs: Extract<Required<UserConfig['logs']>, object>;
7201
+ output: Extract<UserConfig['output'], object>;
7099
7202
  pluginOrder: ReadonlyArray<ClientPlugins['name']>;
7100
7203
  plugins: ArrayOfObjectsToObjectMap<ExtractArrayOfObjects<ReadonlyArray<ClientPlugins>, {
7101
7204
  name: string;
7102
7205
  }>, 'name'>;
7103
- watch: Extract<ClientConfig['watch'], object>;
7206
+ watch: Extract<UserConfig['watch'], object>;
7104
7207
  };
7105
7208
 
7106
7209
  interface Identifier {
@@ -7176,11 +7279,13 @@ declare class TypeScriptFile {
7176
7279
  namespace: keyof Namespaces;
7177
7280
  }): Identifier;
7178
7281
  /**
7179
- * Adds an import to the provided module. Handles duplication, returns added import.
7282
+ * Adds an import to the provided module. Handles duplication, returns added
7283
+ * import. Returns the imported name. If we import an aliased export, `name`
7284
+ * will be equal to the specified `alias`.
7180
7285
  */
7181
7286
  import({ module, ...importedItem }: ImportExportItemObject & {
7182
7287
  module: string;
7183
- }): ImportExportItemObject;
7288
+ }): Pick<ImportExportItemObject, 'asType' | 'name'>;
7184
7289
  isEmpty(): boolean;
7185
7290
  nameWithoutExtension(): string;
7186
7291
  relativePathToFile({ context, id, }: {