@hey-api/openapi-ts 0.64.0 → 0.64.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
@@ -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> = {
@@ -7025,28 +7040,39 @@ type UserPlugins = Plugin.UserConfig<Config$h> | Plugin.UserConfig<Config$k> | P
7025
7040
  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
7041
 
7027
7042
  type Formatters = 'biome' | 'prettier';
7043
+
7028
7044
  type Linters = 'biome' | 'eslint' | 'oxlint';
7029
- type StringCase = 'camelCase' | 'PascalCase' | 'preserve' | 'snake_case' | 'SCREAMING_SNAKE_CASE';
7045
+
7046
+ type StringCase =
7047
+ | 'camelCase'
7048
+ | 'PascalCase'
7049
+ | 'preserve'
7050
+ | 'snake_case'
7051
+ | 'SCREAMING_SNAKE_CASE';
7052
+
7030
7053
  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> | {
7054
+ /**
7055
+ * Path to the config file. Set this value if you don't use the default
7056
+ * config file name, or it's not located in the project root.
7057
+ */
7058
+ configFile?: string;
7059
+ /**
7060
+ * Skip writing files to disk?
7061
+ *
7062
+ * @default false
7063
+ */
7064
+ dryRun?: boolean;
7065
+ /**
7066
+ * Path to the OpenAPI specification. This can be either local or remote path.
7067
+ * Both JSON and YAML file formats are supported. You can also pass the parsed
7068
+ * object directly if you're fetching the file yourself.
7069
+ *
7070
+ * Alternatively, you can define a configuration object with more options.
7071
+ */
7072
+ input:
7073
+ | string
7074
+ | Record<string, unknown>
7075
+ | {
7050
7076
  /**
7051
7077
  * Prevent parts matching the regular expression from being processed.
7052
7078
  * You can select both operations and components by reference within
@@ -7074,13 +7100,15 @@ interface UserConfig {
7074
7100
  * object directly if you're fetching the file yourself.
7075
7101
  */
7076
7102
  path: string | Record<string, unknown>;
7077
- };
7078
- /**
7079
- * The relative location of the logs folder
7080
- *
7081
- * @default process.cwd()
7082
- */
7083
- logs?: string | {
7103
+ };
7104
+ /**
7105
+ * The relative location of the logs folder
7106
+ *
7107
+ * @default process.cwd()
7108
+ */
7109
+ logs?:
7110
+ | string
7111
+ | {
7084
7112
  /**
7085
7113
  * The logging level to control the verbosity of log output.
7086
7114
  * Determines which messages are logged based on their severity.
@@ -7098,18 +7126,27 @@ interface UserConfig {
7098
7126
  *
7099
7127
  * @default 'info'
7100
7128
  */
7101
- level?: 'debug' | 'error' | 'fatal' | 'info' | 'silent' | 'trace' | 'warn';
7129
+ level?:
7130
+ | 'debug'
7131
+ | 'error'
7132
+ | 'fatal'
7133
+ | 'info'
7134
+ | 'silent'
7135
+ | 'trace'
7136
+ | 'warn';
7102
7137
  /**
7103
7138
  * The relative location of the logs folder
7104
7139
  *
7105
7140
  * @default process.cwd()
7106
7141
  */
7107
7142
  path?: string;
7108
- };
7109
- /**
7110
- * The relative location of the output folder
7111
- */
7112
- output: string | {
7143
+ };
7144
+ /**
7145
+ * The relative location of the output folder
7146
+ */
7147
+ output:
7148
+ | string
7149
+ | {
7113
7150
  /**
7114
7151
  * Defines casing of the output fields. By default, we preserve `input`
7115
7152
  * values as data transforms incur a performance penalty at runtime.
@@ -7150,21 +7187,25 @@ interface UserConfig {
7150
7187
  * The relative location of the output folder
7151
7188
  */
7152
7189
  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 | {
7190
+ };
7191
+ /**
7192
+ * Plugins generate artifacts from `input`. By default, we generate SDK
7193
+ * functions and TypeScript interfaces. If you manually define `plugins`,
7194
+ * you need to include the default plugins if you wish to use them.
7195
+ *
7196
+ * @default ['@hey-api/typescript', '@hey-api/sdk']
7197
+ */
7198
+ plugins?: ReadonlyArray<UserPlugins['name'] | UserPlugins>;
7199
+ /**
7200
+ * Regenerate the client when the input file changes? You can alternatively
7201
+ * pass a numeric value for the interval in ms.
7202
+ *
7203
+ * @default false
7204
+ */
7205
+ watch?:
7206
+ | boolean
7207
+ | number
7208
+ | {
7168
7209
  /**
7169
7210
  * Regenerate the client when the input file changes?
7170
7211
  *
@@ -7172,76 +7213,94 @@ interface UserConfig {
7172
7213
  */
7173
7214
  enabled?: boolean;
7174
7215
  /**
7175
- * How often should we attempt to detect the input file change?
7216
+ * How often should we attempt to detect the input file change? (in ms)
7176
7217
  *
7177
7218
  * @default 1000
7178
7219
  */
7179
7220
  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
- }>;
7221
+ /**
7222
+ * How long will we wait before the request times out?
7223
+ *
7224
+ * @default 60_000
7225
+ */
7226
+ timeout?: number;
7227
+ };
7228
+ /**
7229
+ * @deprecated
7230
+ *
7231
+ * Manually set base in OpenAPI config instead of inferring from server value
7232
+ */
7233
+ // eslint-disable-next-line typescript-sort-keys/interface
7234
+ base?: string;
7235
+ /**
7236
+ * @deprecated
7237
+ *
7238
+ * Opt in to the experimental parser?
7239
+ *
7240
+ * @default true
7241
+ */
7242
+ experimentalParser?: boolean;
7243
+ /**
7244
+ * @deprecated
7245
+ *
7246
+ * Generate core client classes?
7247
+ *
7248
+ * @default true
7249
+ */
7250
+ exportCore?: boolean;
7251
+ /**
7252
+ * @deprecated
7253
+ *
7254
+ * Custom client class name. Please note this option is deprecated and
7255
+ * will be removed in favor of clients.
7256
+ *
7257
+ * @link https://heyapi.dev/openapi-ts/migrating.html#deprecated-name
7258
+ */
7259
+ name?: string;
7260
+ /**
7261
+ * @deprecated
7262
+ *
7263
+ * Path to custom request file. Please note this option is deprecated and
7264
+ * will be removed in favor of clients.
7265
+ *
7266
+ * @link https://heyapi.dev/openapi-ts/migrating.html#deprecated-request
7267
+ */
7268
+ request?: string;
7269
+ /**
7270
+ * @deprecated
7271
+ *
7272
+ * Use options or arguments functions. Please note this option is deprecated and
7273
+ * will be removed in favor of clients.
7274
+ *
7275
+ * @link https://heyapi.dev/openapi-ts/migrating.html#deprecated-useoptions
7276
+ *
7277
+ * @default true
7278
+ */
7279
+ useOptions?: boolean;
7280
+ }
7281
+
7282
+ type Config = Omit<
7283
+ Required<UserConfig>,
7284
+ | 'base'
7285
+ | 'input'
7286
+ | 'logs'
7287
+ | 'name'
7288
+ | 'output'
7289
+ | 'plugins'
7290
+ | 'request'
7291
+ | 'watch'
7292
+ > &
7293
+ Pick<UserConfig, 'base' | 'name' | 'request'> & {
7294
+ input: ExtractWithDiscriminator<UserConfig['input'], { path: unknown }>;
7237
7295
  logs: Extract<Required<UserConfig['logs']>, object>;
7238
7296
  output: Extract<UserConfig['output'], object>;
7239
7297
  pluginOrder: ReadonlyArray<ClientPlugins['name']>;
7240
- plugins: ArrayOfObjectsToObjectMap<ExtractArrayOfObjects<ReadonlyArray<ClientPlugins>, {
7241
- name: string;
7242
- }>, 'name'>;
7243
- watch: Extract<UserConfig['watch'], object>;
7244
- };
7298
+ plugins: ArrayOfObjectsToObjectMap<
7299
+ ExtractArrayOfObjects<ReadonlyArray<ClientPlugins>, { name: string }>,
7300
+ 'name'
7301
+ >;
7302
+ watch: Extract<Required<UserConfig['watch']>, object>;
7303
+ };
7245
7304
 
7246
7305
  interface Identifier {
7247
7306
  /**
@@ -7666,6 +7725,11 @@ declare namespace IR {
7666
7725
  export type ServerObject = IRServerObject;
7667
7726
  }
7668
7727
 
7728
+ /**
7729
+ * Default plugins used to generate artifacts if plugins aren't specified.
7730
+ */
7731
+ declare const defaultPlugins: readonly ["@hey-api/typescript", "@hey-api/sdk"];
7732
+
7669
7733
  declare namespace LegacyIR {
7670
7734
  export type LegacyOperation = Operation;
7671
7735
  }
@@ -7679,16 +7743,11 @@ declare const utils: {
7679
7743
  };
7680
7744
 
7681
7745
  /**
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.
7746
+ * Generate a client from the provided configuration.
7747
+ *
7748
+ * @param userConfig User provided {@link UserConfig} configuration.
7690
7749
  */
7691
- declare const defaultPlugins: readonly ["@hey-api/typescript", "@hey-api/sdk"];
7750
+ declare const createClient: (userConfig: UserConfig) => Promise<ReadonlyArray<Client$1 | IR.Context>>;
7692
7751
  /**
7693
7752
  * Type helper for openapi-ts.config.ts, returns {@link UserConfig} object
7694
7753
  */