@hey-api/openapi-ts 0.62.3 → 0.63.1

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,21 @@ 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-next'
6377
+ | '@hey-api/client-nuxt'
6378
+ | 'legacy/angular'
6379
+ | 'legacy/axios'
6380
+ | 'legacy/fetch'
6381
+ | 'legacy/node'
6382
+ | 'legacy/xhr';
6383
+
6384
+ type PluginValidatorNames = 'zod';
6385
+
6373
6386
  type PluginNames =
6387
+ | PluginClientNames
6374
6388
  | '@hey-api/schemas'
6375
6389
  | '@hey-api/sdk'
6376
6390
  | '@hey-api/transformers'
@@ -6381,15 +6395,18 @@ type PluginNames =
6381
6395
  | '@tanstack/svelte-query'
6382
6396
  | '@tanstack/vue-query'
6383
6397
  | 'fastify'
6384
- | 'zod';
6398
+ | PluginValidatorNames;
6385
6399
 
6386
6400
  type AnyPluginName = PluginNames | (string & {});
6387
6401
 
6388
- type PluginTag = 'transformer' | 'validator';
6402
+ type PluginTag = 'client' | 'transformer' | 'validator';
6389
6403
 
6390
6404
  interface PluginContext {
6391
6405
  ensureDependency: (name: PluginNames | true) => void;
6392
- pluginByTag: (tag: PluginTag) => AnyPluginName | undefined;
6406
+ pluginByTag: (
6407
+ tag: PluginTag,
6408
+ errorMessage?: string,
6409
+ ) => AnyPluginName | undefined;
6393
6410
  }
6394
6411
 
6395
6412
  interface BaseConfig {
@@ -6424,6 +6441,41 @@ interface Meta<Config extends BaseConfig> {
6424
6441
  _tags?: ReadonlyArray<PluginTag>;
6425
6442
  }
6426
6443
 
6444
+ /**
6445
+ * Public Client API.
6446
+ */
6447
+ declare namespace Client {
6448
+ export type Config = {
6449
+ /**
6450
+ * Bundle the client module? Set this to true if don't want to declare it
6451
+ * as a separate dependency. When true, the client module will be generated
6452
+ * from the client package and bundled with the rest of the generated output.
6453
+ * This is useful if you're repackaging the output, publishing it to other
6454
+ * users, and you don't want them to install any dependencies.
6455
+ *
6456
+ * @default false
6457
+ */
6458
+ bundle?: boolean;
6459
+ /**
6460
+ * Name of the generated file.
6461
+ *
6462
+ * @default 'client'
6463
+ */
6464
+ output?: string;
6465
+ /**
6466
+ * Relative path to the runtime configuration file. This file must export
6467
+ * a `createClientConfig()` function. The `createClientConfig()` function
6468
+ * will be called on client initialization and the returned object will
6469
+ * become the client's initial configuration.
6470
+ *
6471
+ * You may want to initialize your client this way instead of calling
6472
+ * `setConfig()`. This is useful for example if you're using Next.js
6473
+ * to ensure your client always has the correct values.
6474
+ */
6475
+ runtimeConfigPath?: string;
6476
+ };
6477
+ }
6478
+
6427
6479
  /**
6428
6480
  * Public Plugin API.
6429
6481
  */
@@ -6480,6 +6532,63 @@ declare namespace Plugin {
6480
6532
  export type UserConfig<Config extends BaseConfig> = Omit<Config, 'output'>;
6481
6533
  }
6482
6534
 
6535
+ interface Config$k
6536
+ extends Plugin.Name<'@hey-api/client-axios'>,
6537
+ Client.Config {
6538
+ /**
6539
+ * Throw an error instead of returning it in the response?
6540
+ *
6541
+ * @default false
6542
+ */
6543
+ throwOnError?: boolean;
6544
+ }
6545
+
6546
+ interface Config$j
6547
+ extends Plugin.Name<'@hey-api/client-fetch'>,
6548
+ Client.Config {
6549
+ /**
6550
+ * Throw an error instead of returning it in the response?
6551
+ *
6552
+ * @default false
6553
+ */
6554
+ throwOnError?: boolean;
6555
+ }
6556
+
6557
+ interface Config$i
6558
+ extends Plugin.Name<'@hey-api/client-next'>,
6559
+ Client.Config {
6560
+ /**
6561
+ * Throw an error instead of returning it in the response?
6562
+ *
6563
+ * @default false
6564
+ */
6565
+ throwOnError?: boolean;
6566
+ }
6567
+
6568
+ interface Config$h
6569
+ extends Plugin.Name<'@hey-api/client-nuxt'>,
6570
+ Client.Config {}
6571
+
6572
+ interface Config$g
6573
+ extends Plugin.Name<'legacy/angular'>,
6574
+ Pick<Client.Config, 'output'> {}
6575
+
6576
+ interface Config$f
6577
+ extends Plugin.Name<'legacy/axios'>,
6578
+ Pick<Client.Config, 'output'> {}
6579
+
6580
+ interface Config$e
6581
+ extends Plugin.Name<'legacy/fetch'>,
6582
+ Pick<Client.Config, 'output'> {}
6583
+
6584
+ interface Config$d
6585
+ extends Plugin.Name<'legacy/node'>,
6586
+ Pick<Client.Config, 'output'> {}
6587
+
6588
+ interface Config$c
6589
+ extends Plugin.Name<'legacy/xhr'>,
6590
+ Pick<Client.Config, 'output'> {}
6591
+
6483
6592
  interface Config$b extends Plugin.Name<'@hey-api/schemas'> {
6484
6593
  /**
6485
6594
  * Customise the schema name. By default, `{{name}}Schema` is used. `name` is a
@@ -6498,6 +6607,7 @@ interface Config$b extends Plugin.Name<'@hey-api/schemas'> {
6498
6607
  ) => string;
6499
6608
  /**
6500
6609
  * Name of the generated file.
6610
+ *
6501
6611
  * @default 'schemas'
6502
6612
  */
6503
6613
  output?: string;
@@ -6505,6 +6615,7 @@ interface Config$b extends Plugin.Name<'@hey-api/schemas'> {
6505
6615
  * Choose schema type to generate. Select 'form' if you don't want
6506
6616
  * descriptions to reduce bundle size and you plan to use schemas
6507
6617
  * for form validation
6618
+ *
6508
6619
  * @default 'json'
6509
6620
  */
6510
6621
  type?: 'form' | 'json';
@@ -6531,6 +6642,18 @@ interface Config$a extends Plugin.Name<'@hey-api/sdk'> {
6531
6642
  * @default true
6532
6643
  */
6533
6644
  auth?: boolean;
6645
+ /**
6646
+ * Use an internal client instance to send HTTP requests? This is useful if
6647
+ * you don't want to manually pass the client to each SDK function.
6648
+ *
6649
+ * Ensure you have declared the selected library as a dependency to avoid
6650
+ * errors. You can customize the selected client output through its plugin.
6651
+ * You can also set `client` to `true` to automatically choose the client
6652
+ * from your defined plugins.
6653
+ *
6654
+ * @default true
6655
+ */
6656
+ client?: PluginClientNames | boolean;
6534
6657
  /**
6535
6658
  * @deprecated
6536
6659
  *
@@ -6567,11 +6690,11 @@ interface Config$a extends Plugin.Name<'@hey-api/sdk'> {
6567
6690
  */
6568
6691
  output?: string;
6569
6692
  /**
6693
+ * @deprecated
6694
+ *
6570
6695
  * Define shape of returned value from service calls
6571
6696
  *
6572
6697
  * @default 'body'
6573
- *
6574
- * @deprecated
6575
6698
  */
6576
6699
  response?: 'body' | 'response';
6577
6700
  /**
@@ -6583,12 +6706,6 @@ interface Config$a extends Plugin.Name<'@hey-api/sdk'> {
6583
6706
  * @default '{{name}}Service'
6584
6707
  */
6585
6708
  serviceNameBuilder?: string;
6586
- /**
6587
- * Throw an error instead of returning it in the response?
6588
- *
6589
- * @default false
6590
- */
6591
- throwOnError?: boolean;
6592
6709
  /**
6593
6710
  * Transform response data before returning. This is useful if you want to
6594
6711
  * convert for example ISO strings into Date objects. However, transformation
@@ -6614,7 +6731,7 @@ interface Config$a extends Plugin.Name<'@hey-api/sdk'> {
6614
6731
  *
6615
6732
  * @default false
6616
6733
  */
6617
- validator?: 'zod' | boolean;
6734
+ validator?: PluginValidatorNames | boolean;
6618
6735
  }
6619
6736
 
6620
6737
  interface Config$9 extends Plugin.Name<'@hey-api/transformers'> {
@@ -6710,22 +6827,26 @@ interface Config$7
6710
6827
  extends Plugin.Name<'@tanstack/angular-query-experimental'> {
6711
6828
  /**
6712
6829
  * 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.
6830
+ *
6713
6831
  * @default true
6714
6832
  */
6715
6833
  infiniteQueryOptions?: boolean;
6716
6834
  /**
6717
6835
  * 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.
6836
+ *
6718
6837
  * @default true
6719
6838
  */
6720
6839
  mutationOptions?: boolean;
6721
6840
  /**
6722
6841
  * Name of the generated file.
6842
+ *
6723
6843
  * @default '@tanstack/angular-query-experimental'
6724
6844
  */
6725
6845
  output?: string;
6726
6846
  /**
6727
6847
  * Generate {@link https://tanstack.com/query/v5/docs/framework/angular/reference/queryOptions `queryOptions()`} helpers?
6728
6848
  * These will be generated from all requests.
6849
+ *
6729
6850
  * @default true
6730
6851
  */
6731
6852
  queryOptions?: boolean;
@@ -6734,22 +6855,26 @@ interface Config$7
6734
6855
  interface Config$6 extends Plugin.Name<'@tanstack/react-query'> {
6735
6856
  /**
6736
6857
  * 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.
6858
+ *
6737
6859
  * @default true
6738
6860
  */
6739
6861
  infiniteQueryOptions?: boolean;
6740
6862
  /**
6741
6863
  * 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.
6864
+ *
6742
6865
  * @default true
6743
6866
  */
6744
6867
  mutationOptions?: boolean;
6745
6868
  /**
6746
6869
  * Name of the generated file.
6870
+ *
6747
6871
  * @default '@tanstack/react-query'
6748
6872
  */
6749
6873
  output?: string;
6750
6874
  /**
6751
6875
  * Generate {@link https://tanstack.com/query/v5/docs/framework/react/reference/queryOptions `queryOptions()`} helpers?
6752
6876
  * These will be generated from all requests.
6877
+ *
6753
6878
  * @default true
6754
6879
  */
6755
6880
  queryOptions?: boolean;
@@ -6758,22 +6883,26 @@ interface Config$6 extends Plugin.Name<'@tanstack/react-query'> {
6758
6883
  interface Config$5 extends Plugin.Name<'@tanstack/solid-query'> {
6759
6884
  /**
6760
6885
  * Generate `createInfiniteQuery()` helpers? These will be generated from GET and POST requests where a pagination parameter is detected.
6886
+ *
6761
6887
  * @default true
6762
6888
  */
6763
6889
  infiniteQueryOptions?: boolean;
6764
6890
  /**
6765
6891
  * Generate `createMutation()` helpers? These will be generated from DELETE, PATCH, POST, and PUT requests.
6892
+ *
6766
6893
  * @default true
6767
6894
  */
6768
6895
  mutationOptions?: boolean;
6769
6896
  /**
6770
6897
  * Name of the generated file.
6898
+ *
6771
6899
  * @default '@tanstack/solid-query'
6772
6900
  */
6773
6901
  output?: string;
6774
6902
  /**
6775
6903
  * Generate {@link https://tanstack.com/query/v5/docs/framework/solid/reference/createQuery `createQuery()`} helpers?
6776
6904
  * These will be generated from all requests.
6905
+ *
6777
6906
  * @default true
6778
6907
  */
6779
6908
  queryOptions?: boolean;
@@ -6782,22 +6911,26 @@ interface Config$5 extends Plugin.Name<'@tanstack/solid-query'> {
6782
6911
  interface Config$4 extends Plugin.Name<'@tanstack/svelte-query'> {
6783
6912
  /**
6784
6913
  * Generate `createInfiniteQuery()` helpers? These will be generated from GET and POST requests where a pagination parameter is detected.
6914
+ *
6785
6915
  * @default true
6786
6916
  */
6787
6917
  infiniteQueryOptions?: boolean;
6788
6918
  /**
6789
6919
  * 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.
6920
+ *
6790
6921
  * @default true
6791
6922
  */
6792
6923
  mutationOptions?: boolean;
6793
6924
  /**
6794
6925
  * Name of the generated file.
6926
+ *
6795
6927
  * @default '@tanstack/svelte-query'
6796
6928
  */
6797
6929
  output?: string;
6798
6930
  /**
6799
6931
  * Generate {@link https://tanstack.com/query/v5/docs/framework/svelte/reference/functions/createquery `createQuery()`} helpers?
6800
6932
  * These will be generated from all requests.
6933
+ *
6801
6934
  * @default true
6802
6935
  */
6803
6936
  queryOptions?: boolean;
@@ -6806,22 +6939,26 @@ interface Config$4 extends Plugin.Name<'@tanstack/svelte-query'> {
6806
6939
  interface Config$3 extends Plugin.Name<'@tanstack/vue-query'> {
6807
6940
  /**
6808
6941
  * 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.
6942
+ *
6809
6943
  * @default true
6810
6944
  */
6811
6945
  infiniteQueryOptions?: boolean;
6812
6946
  /**
6813
6947
  * 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.
6948
+ *
6814
6949
  * @default true
6815
6950
  */
6816
6951
  mutationOptions?: boolean;
6817
6952
  /**
6818
6953
  * Name of the generated file.
6954
+ *
6819
6955
  * @default '@tanstack/vue-query'
6820
6956
  */
6821
6957
  output?: string;
6822
6958
  /**
6823
6959
  * Generate {@link https://tanstack.com/query/v5/docs/framework/vue/guides/query-options `queryOptions()`} helpers?
6824
6960
  * These will be generated from all requests.
6961
+ *
6825
6962
  * @default true
6826
6963
  */
6827
6964
  queryOptions?: boolean;
@@ -6830,6 +6967,7 @@ interface Config$3 extends Plugin.Name<'@tanstack/vue-query'> {
6830
6967
  interface Config$2 extends Plugin.Name<'fastify'> {
6831
6968
  /**
6832
6969
  * Name of the generated file.
6970
+ *
6833
6971
  * @default 'fastify'
6834
6972
  */
6835
6973
  output?: string;
@@ -6846,6 +6984,7 @@ interface Config$1 extends Plugin.Name<'zod'> {
6846
6984
  // nameBuilder?: (model: IR.OperationObject | IR.SchemaObject) => string;
6847
6985
  /**
6848
6986
  * Name of the generated file.
6987
+ *
6849
6988
  * @default 'zod'
6850
6989
  */
6851
6990
  output?: string;
@@ -6854,38 +6993,16 @@ interface Config$1 extends Plugin.Name<'zod'> {
6854
6993
  /**
6855
6994
  * User-facing plugin types.
6856
6995
  */
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>;
6996
+ type UserPlugins = Plugin.UserConfig<Config$k> | 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
6997
  /**
6859
6998
  * Internal plugin types.
6860
6999
  */
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>;
7000
+ type ClientPlugins = Plugin.Config<Config$k> | 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
7001
 
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
7002
  type Formatters = 'biome' | 'prettier';
6866
7003
  type Linters = 'biome' | 'eslint' | 'oxlint';
6867
7004
  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
- };
7005
+ interface UserConfig {
6889
7006
  /**
6890
7007
  * Path to the config file. Set this value if you don't use the default
6891
7008
  * config file name, or it's not located in the project root.
@@ -7088,19 +7205,17 @@ interface ClientConfig {
7088
7205
  */
7089
7206
  useOptions?: boolean;
7090
7207
  }
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'], {
7208
+ type Config = Omit<Required<UserConfig>, 'base' | 'input' | 'logs' | 'name' | 'output' | 'plugins' | 'request' | 'watch'> & Pick<UserConfig, 'base' | 'name' | 'request'> & {
7209
+ input: ExtractWithDiscriminator<UserConfig['input'], {
7095
7210
  path: unknown;
7096
7211
  }>;
7097
- logs: Extract<Required<ClientConfig['logs']>, object>;
7098
- output: Extract<ClientConfig['output'], object>;
7212
+ logs: Extract<Required<UserConfig['logs']>, object>;
7213
+ output: Extract<UserConfig['output'], object>;
7099
7214
  pluginOrder: ReadonlyArray<ClientPlugins['name']>;
7100
7215
  plugins: ArrayOfObjectsToObjectMap<ExtractArrayOfObjects<ReadonlyArray<ClientPlugins>, {
7101
7216
  name: string;
7102
7217
  }>, 'name'>;
7103
- watch: Extract<ClientConfig['watch'], object>;
7218
+ watch: Extract<UserConfig['watch'], object>;
7104
7219
  };
7105
7220
 
7106
7221
  interface Identifier {
@@ -7137,6 +7252,7 @@ interface Namespaces {
7137
7252
  */
7138
7253
  value: Namespace;
7139
7254
  }
7255
+ type FileImportResult = Pick<ImportExportItemObject, 'asType' | 'name'>;
7140
7256
  declare class TypeScriptFile {
7141
7257
  /**
7142
7258
  * Should the exports from this file be re-exported in the index barrel file?
@@ -7176,11 +7292,13 @@ declare class TypeScriptFile {
7176
7292
  namespace: keyof Namespaces;
7177
7293
  }): Identifier;
7178
7294
  /**
7179
- * Adds an import to the provided module. Handles duplication, returns added import.
7295
+ * Adds an import to the provided module. Handles duplication, returns added
7296
+ * import. Returns the imported name. If we import an aliased export, `name`
7297
+ * will be equal to the specified `alias`.
7180
7298
  */
7181
7299
  import({ module, ...importedItem }: ImportExportItemObject & {
7182
7300
  module: string;
7183
- }): ImportExportItemObject;
7301
+ }): FileImportResult;
7184
7302
  isEmpty(): boolean;
7185
7303
  nameWithoutExtension(): string;
7186
7304
  relativePathToFile({ context, id, }: {