@hey-api/openapi-ts 0.64.0 → 0.64.2

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.cts CHANGED
@@ -6340,30 +6340,45 @@ declare namespace OpenApi {
6340
6340
  }
6341
6341
 
6342
6342
  interface Operation extends Omit<Operation$1, 'tags'> {
6343
- service: string;
6343
+ service: string;
6344
6344
  }
6345
+
6345
6346
  interface Service extends Pick<Model, '$refs' | 'imports' | 'name'> {
6346
- operations: Operation[];
6347
+ operations: Operation[];
6347
6348
  }
6349
+
6348
6350
  interface Client$1 extends Omit<Client$2, 'operations'> {
6349
- services: Service[];
6351
+ services: Service[];
6350
6352
  }
6351
6353
 
6352
- type ExtractWithDiscriminator<T, Discriminator> = T extends Discriminator ? T : never;
6354
+ type ExtractWithDiscriminator<T, Discriminator> = T extends Discriminator
6355
+ ? T
6356
+ : never;
6357
+
6353
6358
  /**
6354
6359
  * Accepts an array of elements union and attempts to extract only objects.
6355
6360
  * For example, Array<string | number | { id: string }> would result in
6356
6361
  * Array<{ id: string }>.
6357
6362
  */
6358
- type ExtractArrayOfObjects<T, Discriminator> = T extends Array<infer U> ? Array<ExtractWithDiscriminator<U, Discriminator>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<ExtractWithDiscriminator<U, Discriminator>> : never;
6363
+ type ExtractArrayOfObjects<T, Discriminator> =
6364
+ T extends Array<infer U>
6365
+ ? Array<ExtractWithDiscriminator<U, Discriminator>>
6366
+ : T extends ReadonlyArray<infer U>
6367
+ ? ReadonlyArray<ExtractWithDiscriminator<U, Discriminator>>
6368
+ : never;
6369
+
6359
6370
  type Files = Record<string, TypeScriptFile>;
6371
+
6360
6372
  /**
6361
6373
  * Transforms an array of objects into an optional object map.
6362
6374
  * For example, Array<{ id: string }> would result in
6363
6375
  * { [key: string]?: { id: string } }
6364
6376
  */
6365
- type ArrayOfObjectsToObjectMap<T extends ReadonlyArray<Record<string, any>>, D extends keyof T[number]> = {
6366
- [K in T[number][D]]?: Extract<T[number], Record<D, K>>;
6377
+ type ArrayOfObjectsToObjectMap<
6378
+ T extends ReadonlyArray<Record<string, any>>,
6379
+ D extends keyof T[number],
6380
+ > = {
6381
+ [K in T[number][D]]?: Extract<T[number], Record<D, K>>;
6367
6382
  };
6368
6383
 
6369
6384
  type OmitUnderscoreKeys<T> = {
@@ -6552,6 +6567,13 @@ declare namespace Client {
6552
6567
  * @default false
6553
6568
  */
6554
6569
  bundle?: boolean;
6570
+ /**
6571
+ * Should the exports from the generated files be re-exported in the index
6572
+ * barrel file?
6573
+ *
6574
+ * @default false
6575
+ */
6576
+ exportFromIndex?: boolean;
6555
6577
  /**
6556
6578
  * Name of the generated file.
6557
6579
  *
@@ -6615,6 +6637,13 @@ interface Config$c
6615
6637
  Pick<Client.Config, 'output'> {}
6616
6638
 
6617
6639
  interface Config$b extends Plugin.Name<'@hey-api/schemas'> {
6640
+ /**
6641
+ * Should the exports from the generated files be re-exported in the index
6642
+ * barrel file?
6643
+ *
6644
+ * @default false
6645
+ */
6646
+ exportFromIndex?: boolean;
6618
6647
  /**
6619
6648
  * Customise the schema name. By default, `{{name}}Schema` is used. `name` is a
6620
6649
  * valid JavaScript/TypeScript identifier, e.g. if your schema name is
@@ -6679,6 +6708,13 @@ interface Config$a extends Plugin.Name<'@hey-api/sdk'> {
6679
6708
  * @default true
6680
6709
  */
6681
6710
  client?: PluginClientNames | boolean;
6711
+ /**
6712
+ * Should the exports from the generated files be re-exported in the index
6713
+ * barrel file?
6714
+ *
6715
+ * @default true
6716
+ */
6717
+ exportFromIndex?: boolean;
6682
6718
  /**
6683
6719
  * @deprecated
6684
6720
  *
@@ -6772,6 +6808,13 @@ interface Config$9 extends Plugin.Name<'@hey-api/transformers'> {
6772
6808
  * @default true
6773
6809
  */
6774
6810
  dates?: boolean;
6811
+ /**
6812
+ * Should the exports from the generated files be re-exported in the index
6813
+ * barrel file?
6814
+ *
6815
+ * @default false
6816
+ */
6817
+ exportFromIndex?: boolean;
6775
6818
  /**
6776
6819
  * Name of the generated file.
6777
6820
  *
@@ -6796,6 +6839,13 @@ interface Config$8 extends Plugin.Name<'@hey-api/typescript'> {
6796
6839
  * @default 'SCREAMING_SNAKE_CASE'
6797
6840
  */
6798
6841
  enumsCase?: StringCase;
6842
+ /**
6843
+ * Should the exports from the generated files be re-exported in the index
6844
+ * barrel file?
6845
+ *
6846
+ * @default true
6847
+ */
6848
+ exportFromIndex?: boolean;
6799
6849
  /**
6800
6850
  * By default, inline enums (enums not defined as reusable components in
6801
6851
  * the input file) are generated as inlined union types. You can set
@@ -6850,6 +6900,13 @@ interface Config$8 extends Plugin.Name<'@hey-api/typescript'> {
6850
6900
 
6851
6901
  interface Config$7
6852
6902
  extends Plugin.Name<'@tanstack/angular-query-experimental'> {
6903
+ /**
6904
+ * Should the exports from the generated files be re-exported in the index
6905
+ * barrel file?
6906
+ *
6907
+ * @default false
6908
+ */
6909
+ exportFromIndex?: boolean;
6853
6910
  /**
6854
6911
  * 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.
6855
6912
  *
@@ -6878,6 +6935,13 @@ interface Config$7
6878
6935
  }
6879
6936
 
6880
6937
  interface Config$6 extends Plugin.Name<'@tanstack/react-query'> {
6938
+ /**
6939
+ * Should the exports from the generated files be re-exported in the index
6940
+ * barrel file?
6941
+ *
6942
+ * @default false
6943
+ */
6944
+ exportFromIndex?: boolean;
6881
6945
  /**
6882
6946
  * 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.
6883
6947
  *
@@ -6906,6 +6970,13 @@ interface Config$6 extends Plugin.Name<'@tanstack/react-query'> {
6906
6970
  }
6907
6971
 
6908
6972
  interface Config$5 extends Plugin.Name<'@tanstack/solid-query'> {
6973
+ /**
6974
+ * Should the exports from the generated files be re-exported in the index
6975
+ * barrel file?
6976
+ *
6977
+ * @default false
6978
+ */
6979
+ exportFromIndex?: boolean;
6909
6980
  /**
6910
6981
  * Generate `createInfiniteQuery()` helpers? These will be generated from GET and POST requests where a pagination parameter is detected.
6911
6982
  *
@@ -6934,6 +7005,13 @@ interface Config$5 extends Plugin.Name<'@tanstack/solid-query'> {
6934
7005
  }
6935
7006
 
6936
7007
  interface Config$4 extends Plugin.Name<'@tanstack/svelte-query'> {
7008
+ /**
7009
+ * Should the exports from the generated files be re-exported in the index
7010
+ * barrel file?
7011
+ *
7012
+ * @default false
7013
+ */
7014
+ exportFromIndex?: boolean;
6937
7015
  /**
6938
7016
  * Generate `createInfiniteQuery()` helpers? These will be generated from GET and POST requests where a pagination parameter is detected.
6939
7017
  *
@@ -6962,6 +7040,13 @@ interface Config$4 extends Plugin.Name<'@tanstack/svelte-query'> {
6962
7040
  }
6963
7041
 
6964
7042
  interface Config$3 extends Plugin.Name<'@tanstack/vue-query'> {
7043
+ /**
7044
+ * Should the exports from the generated files be re-exported in the index
7045
+ * barrel file?
7046
+ *
7047
+ * @default false
7048
+ */
7049
+ exportFromIndex?: boolean;
6965
7050
  /**
6966
7051
  * 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.
6967
7052
  *
@@ -6990,6 +7075,13 @@ interface Config$3 extends Plugin.Name<'@tanstack/vue-query'> {
6990
7075
  }
6991
7076
 
6992
7077
  interface Config$2 extends Plugin.Name<'fastify'> {
7078
+ /**
7079
+ * Should the exports from the generated files be re-exported in the index
7080
+ * barrel file?
7081
+ *
7082
+ * @default false
7083
+ */
7084
+ exportFromIndex?: boolean;
6993
7085
  /**
6994
7086
  * Name of the generated file.
6995
7087
  *
@@ -7002,6 +7094,13 @@ interface Config$2 extends Plugin.Name<'fastify'> {
7002
7094
 
7003
7095
 
7004
7096
  interface Config$1 extends Plugin.Name<'zod'> {
7097
+ /**
7098
+ * Should the exports from the generated files be re-exported in the index
7099
+ * barrel file?
7100
+ *
7101
+ * @default false
7102
+ */
7103
+ exportFromIndex?: boolean;
7005
7104
  /**
7006
7105
  * Customise the Zod schema name. By default, `z{{name}}` is used,
7007
7106
  * where `name` is a definition name or an operation name.
@@ -7025,28 +7124,39 @@ type UserPlugins = Plugin.UserConfig<Config$h> | Plugin.UserConfig<Config$k> | P
7025
7124
  type ClientPlugins = Plugin.Config<Config$h> | Plugin.Config<Config$k> | Plugin.Config<Config$j> | Plugin.Config<Config$i> | 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>;
7026
7125
 
7027
7126
  type Formatters = 'biome' | 'prettier';
7127
+
7028
7128
  type Linters = 'biome' | 'eslint' | 'oxlint';
7029
- type StringCase = 'camelCase' | 'PascalCase' | 'preserve' | 'snake_case' | 'SCREAMING_SNAKE_CASE';
7129
+
7130
+ type StringCase =
7131
+ | 'camelCase'
7132
+ | 'PascalCase'
7133
+ | 'preserve'
7134
+ | 'snake_case'
7135
+ | 'SCREAMING_SNAKE_CASE';
7136
+
7030
7137
  interface UserConfig {
7031
- /**
7032
- * Path to the config file. Set this value if you don't use the default
7033
- * config file name, or it's not located in the project root.
7034
- */
7035
- configFile?: string;
7036
- /**
7037
- * Skip writing files to disk?
7038
- *
7039
- * @default false
7040
- */
7041
- dryRun?: boolean;
7042
- /**
7043
- * Path to the OpenAPI specification. This can be either local or remote path.
7044
- * Both JSON and YAML file formats are supported. You can also pass the parsed
7045
- * object directly if you're fetching the file yourself.
7046
- *
7047
- * Alternatively, you can define a configuration object with more options.
7048
- */
7049
- input: string | Record<string, unknown> | {
7138
+ /**
7139
+ * Path to the config file. Set this value if you don't use the default
7140
+ * config file name, or it's not located in the project root.
7141
+ */
7142
+ configFile?: string;
7143
+ /**
7144
+ * Skip writing files to disk?
7145
+ *
7146
+ * @default false
7147
+ */
7148
+ dryRun?: boolean;
7149
+ /**
7150
+ * Path to the OpenAPI specification. This can be either local or remote path.
7151
+ * Both JSON and YAML file formats are supported. You can also pass the parsed
7152
+ * object directly if you're fetching the file yourself.
7153
+ *
7154
+ * Alternatively, you can define a configuration object with more options.
7155
+ */
7156
+ input:
7157
+ | string
7158
+ | Record<string, unknown>
7159
+ | {
7050
7160
  /**
7051
7161
  * Prevent parts matching the regular expression from being processed.
7052
7162
  * You can select both operations and components by reference within
@@ -7074,13 +7184,15 @@ interface UserConfig {
7074
7184
  * object directly if you're fetching the file yourself.
7075
7185
  */
7076
7186
  path: string | Record<string, unknown>;
7077
- };
7078
- /**
7079
- * The relative location of the logs folder
7080
- *
7081
- * @default process.cwd()
7082
- */
7083
- logs?: string | {
7187
+ };
7188
+ /**
7189
+ * The relative location of the logs folder
7190
+ *
7191
+ * @default process.cwd()
7192
+ */
7193
+ logs?:
7194
+ | string
7195
+ | {
7084
7196
  /**
7085
7197
  * The logging level to control the verbosity of log output.
7086
7198
  * Determines which messages are logged based on their severity.
@@ -7098,18 +7210,27 @@ interface UserConfig {
7098
7210
  *
7099
7211
  * @default 'info'
7100
7212
  */
7101
- level?: 'debug' | 'error' | 'fatal' | 'info' | 'silent' | 'trace' | 'warn';
7213
+ level?:
7214
+ | 'debug'
7215
+ | 'error'
7216
+ | 'fatal'
7217
+ | 'info'
7218
+ | 'silent'
7219
+ | 'trace'
7220
+ | 'warn';
7102
7221
  /**
7103
7222
  * The relative location of the logs folder
7104
7223
  *
7105
7224
  * @default process.cwd()
7106
7225
  */
7107
7226
  path?: string;
7108
- };
7109
- /**
7110
- * The relative location of the output folder
7111
- */
7112
- output: string | {
7227
+ };
7228
+ /**
7229
+ * The relative location of the output folder
7230
+ */
7231
+ output:
7232
+ | string
7233
+ | {
7113
7234
  /**
7114
7235
  * Defines casing of the output fields. By default, we preserve `input`
7115
7236
  * values as data transforms incur a performance penalty at runtime.
@@ -7150,21 +7271,25 @@ interface UserConfig {
7150
7271
  * The relative location of the output folder
7151
7272
  */
7152
7273
  path: string;
7153
- };
7154
- /**
7155
- * Plugins generate artifacts from `input`. By default, we generate SDK
7156
- * functions and TypeScript interfaces. If you manually define `plugins`,
7157
- * you need to include the default plugins if you wish to use them.
7158
- *
7159
- * @default ['@hey-api/typescript', '@hey-api/sdk']
7160
- */
7161
- plugins?: ReadonlyArray<UserPlugins['name'] | UserPlugins>;
7162
- /**
7163
- * Regenerate the client when the input file changes?
7164
- *
7165
- * @default false
7166
- */
7167
- watch?: boolean | number | {
7274
+ };
7275
+ /**
7276
+ * Plugins generate artifacts from `input`. By default, we generate SDK
7277
+ * functions and TypeScript interfaces. If you manually define `plugins`,
7278
+ * you need to include the default plugins if you wish to use them.
7279
+ *
7280
+ * @default ['@hey-api/typescript', '@hey-api/sdk']
7281
+ */
7282
+ plugins?: ReadonlyArray<UserPlugins['name'] | UserPlugins>;
7283
+ /**
7284
+ * Regenerate the client when the input file changes? You can alternatively
7285
+ * pass a numeric value for the interval in ms.
7286
+ *
7287
+ * @default false
7288
+ */
7289
+ watch?:
7290
+ | boolean
7291
+ | number
7292
+ | {
7168
7293
  /**
7169
7294
  * Regenerate the client when the input file changes?
7170
7295
  *
@@ -7172,76 +7297,94 @@ interface UserConfig {
7172
7297
  */
7173
7298
  enabled?: boolean;
7174
7299
  /**
7175
- * How often should we attempt to detect the input file change?
7300
+ * How often should we attempt to detect the input file change? (in ms)
7176
7301
  *
7177
7302
  * @default 1000
7178
7303
  */
7179
7304
  interval?: number;
7180
- };
7181
- /**
7182
- * @deprecated
7183
- *
7184
- * Manually set base in OpenAPI config instead of inferring from server value
7185
- */
7186
- base?: string;
7187
- /**
7188
- * @deprecated
7189
- *
7190
- * Opt in to the experimental parser?
7191
- *
7192
- * @default true
7193
- */
7194
- experimentalParser?: boolean;
7195
- /**
7196
- * @deprecated
7197
- *
7198
- * Generate core client classes?
7199
- *
7200
- * @default true
7201
- */
7202
- exportCore?: boolean;
7203
- /**
7204
- * @deprecated
7205
- *
7206
- * Custom client class name. Please note this option is deprecated and
7207
- * will be removed in favor of clients.
7208
- *
7209
- * @link https://heyapi.dev/openapi-ts/migrating.html#deprecated-name
7210
- */
7211
- name?: string;
7212
- /**
7213
- * @deprecated
7214
- *
7215
- * Path to custom request file. Please note this option is deprecated and
7216
- * will be removed in favor of clients.
7217
- *
7218
- * @link https://heyapi.dev/openapi-ts/migrating.html#deprecated-request
7219
- */
7220
- request?: string;
7221
- /**
7222
- * @deprecated
7223
- *
7224
- * Use options or arguments functions. Please note this option is deprecated and
7225
- * will be removed in favor of clients.
7226
- *
7227
- * @link https://heyapi.dev/openapi-ts/migrating.html#deprecated-useoptions
7228
- *
7229
- * @default true
7230
- */
7231
- useOptions?: boolean;
7232
- }
7233
- type Config = Omit<Required<UserConfig>, 'base' | 'input' | 'logs' | 'name' | 'output' | 'plugins' | 'request' | 'watch'> & Pick<UserConfig, 'base' | 'name' | 'request'> & {
7234
- input: ExtractWithDiscriminator<UserConfig['input'], {
7235
- path: unknown;
7236
- }>;
7305
+ /**
7306
+ * How long will we wait before the request times out?
7307
+ *
7308
+ * @default 60_000
7309
+ */
7310
+ timeout?: number;
7311
+ };
7312
+ /**
7313
+ * @deprecated
7314
+ *
7315
+ * Manually set base in OpenAPI config instead of inferring from server value
7316
+ */
7317
+ // eslint-disable-next-line typescript-sort-keys/interface
7318
+ base?: string;
7319
+ /**
7320
+ * @deprecated
7321
+ *
7322
+ * Opt in to the experimental parser?
7323
+ *
7324
+ * @default true
7325
+ */
7326
+ experimentalParser?: boolean;
7327
+ /**
7328
+ * @deprecated
7329
+ *
7330
+ * Generate core client classes?
7331
+ *
7332
+ * @default true
7333
+ */
7334
+ exportCore?: boolean;
7335
+ /**
7336
+ * @deprecated
7337
+ *
7338
+ * Custom client class name. Please note this option is deprecated and
7339
+ * will be removed in favor of clients.
7340
+ *
7341
+ * @link https://heyapi.dev/openapi-ts/migrating.html#deprecated-name
7342
+ */
7343
+ name?: string;
7344
+ /**
7345
+ * @deprecated
7346
+ *
7347
+ * Path to custom request file. Please note this option is deprecated and
7348
+ * will be removed in favor of clients.
7349
+ *
7350
+ * @link https://heyapi.dev/openapi-ts/migrating.html#deprecated-request
7351
+ */
7352
+ request?: string;
7353
+ /**
7354
+ * @deprecated
7355
+ *
7356
+ * Use options or arguments functions. Please note this option is deprecated and
7357
+ * will be removed in favor of clients.
7358
+ *
7359
+ * @link https://heyapi.dev/openapi-ts/migrating.html#deprecated-useoptions
7360
+ *
7361
+ * @default true
7362
+ */
7363
+ useOptions?: boolean;
7364
+ }
7365
+
7366
+ type Config = Omit<
7367
+ Required<UserConfig>,
7368
+ | 'base'
7369
+ | 'input'
7370
+ | 'logs'
7371
+ | 'name'
7372
+ | 'output'
7373
+ | 'plugins'
7374
+ | 'request'
7375
+ | 'watch'
7376
+ > &
7377
+ Pick<UserConfig, 'base' | 'name' | 'request'> & {
7378
+ input: ExtractWithDiscriminator<UserConfig['input'], { path: unknown }>;
7237
7379
  logs: Extract<Required<UserConfig['logs']>, object>;
7238
7380
  output: Extract<UserConfig['output'], object>;
7239
7381
  pluginOrder: ReadonlyArray<ClientPlugins['name']>;
7240
- plugins: ArrayOfObjectsToObjectMap<ExtractArrayOfObjects<ReadonlyArray<ClientPlugins>, {
7241
- name: string;
7242
- }>, 'name'>;
7243
- watch: Extract<UserConfig['watch'], object>;
7244
- };
7382
+ plugins: ArrayOfObjectsToObjectMap<
7383
+ ExtractArrayOfObjects<ReadonlyArray<ClientPlugins>, { name: string }>,
7384
+ 'name'
7385
+ >;
7386
+ watch: Extract<Required<UserConfig['watch']>, object>;
7387
+ };
7245
7388
 
7246
7389
  interface Identifier {
7247
7390
  /**
@@ -7666,6 +7809,11 @@ declare namespace IR {
7666
7809
  export type ServerObject = IRServerObject;
7667
7810
  }
7668
7811
 
7812
+ /**
7813
+ * Default plugins used to generate artifacts if plugins aren't specified.
7814
+ */
7815
+ declare const defaultPlugins: readonly ["@hey-api/typescript", "@hey-api/sdk"];
7816
+
7669
7817
  declare namespace LegacyIR {
7670
7818
  export type LegacyOperation = Operation;
7671
7819
  }
@@ -7679,16 +7827,11 @@ declare const utils: {
7679
7827
  };
7680
7828
 
7681
7829
  /**
7682
- * Generate the OpenAPI client. This method will read the OpenAPI specification and based on the
7683
- * given language it will generate the client, including the typed models, validation schemas,
7684
- * service layer, etc.
7685
- * @param userConfig {@link UserConfig} passed to the `createClient()` method
7686
- */
7687
- declare function createClient(userConfig: UserConfig): Promise<ReadonlyArray<Client$1 | IR.Context>>;
7688
- /**
7689
- * Default plugins used to generate artifacts if plugins aren't specified.
7830
+ * Generate a client from the provided configuration.
7831
+ *
7832
+ * @param userConfig User provided {@link UserConfig} configuration.
7690
7833
  */
7691
- declare const defaultPlugins: readonly ["@hey-api/typescript", "@hey-api/sdk"];
7834
+ declare const createClient: (userConfig: UserConfig) => Promise<ReadonlyArray<Client$1 | IR.Context>>;
7692
7835
  /**
7693
7836
  * Type helper for openapi-ts.config.ts, returns {@link UserConfig} object
7694
7837
  */