@hey-api/openapi-ts 0.70.0 → 0.71.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.
@@ -5050,6 +5050,10 @@ interface XMLObject$1 {
5050
5050
  wrapped?: boolean;
5051
5051
  }
5052
5052
 
5053
+ interface OpenApiV2_0_XTypes {
5054
+ SchemaObject: SchemaObject$1;
5055
+ }
5056
+
5053
5057
  /**
5054
5058
  * This is the root object of the {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md#openapi-description OpenAPI Description}.
5055
5059
  *
@@ -6331,6 +6335,22 @@ type OpenApiSchemaFormats =
6331
6335
 
6332
6336
  type Format = JsonSchemaFormats | OpenApiSchemaFormats | (string & {});
6333
6337
 
6338
+ interface OpenApiV3_0_XTypes {
6339
+ ParameterObject: ParameterObject;
6340
+ ReferenceObject: ReferenceObject;
6341
+ RequestBodyObject: RequestBodyObject;
6342
+ ResponseObject: ResponseObject;
6343
+ SchemaObject: SchemaObject;
6344
+ }
6345
+
6346
+ interface OpenApiV3_1_XTypes {
6347
+ ParameterObject: ParameterObject$2;
6348
+ ReferenceObject: ReferenceObject$2;
6349
+ RequestBodyObject: RequestBodyObject$1;
6350
+ ResponseObject: ResponseObject$2;
6351
+ SchemaObject: SchemaObject$2;
6352
+ }
6353
+
6334
6354
  declare namespace OpenApi {
6335
6355
  export type V2_0_X = OpenApiV2_0_X;
6336
6356
 
@@ -6339,6 +6359,44 @@ declare namespace OpenApi {
6339
6359
  export type V3_1_X = OpenApiV3_1_X;
6340
6360
  }
6341
6361
 
6362
+ declare namespace OpenApiParameterObject {
6363
+ export type V3_0_X =
6364
+ | OpenApiV3_0_XTypes['ParameterObject']
6365
+ | OpenApiV3_0_XTypes['ReferenceObject'];
6366
+
6367
+ export type V3_1_X =
6368
+ | OpenApiV3_1_XTypes['ParameterObject']
6369
+ | OpenApiV3_1_XTypes['ReferenceObject'];
6370
+ }
6371
+
6372
+ declare namespace OpenApiRequestBodyObject {
6373
+ export type V3_0_X =
6374
+ | OpenApiV3_0_XTypes['RequestBodyObject']
6375
+ | OpenApiV3_0_XTypes['ReferenceObject'];
6376
+
6377
+ export type V3_1_X =
6378
+ | OpenApiV3_1_XTypes['RequestBodyObject']
6379
+ | OpenApiV3_1_XTypes['ReferenceObject'];
6380
+ }
6381
+
6382
+ declare namespace OpenApiResponseObject {
6383
+ export type V3_0_X =
6384
+ | OpenApiV3_0_XTypes['ResponseObject']
6385
+ | OpenApiV3_0_XTypes['ReferenceObject'];
6386
+
6387
+ export type V3_1_X =
6388
+ | OpenApiV3_1_XTypes['ResponseObject']
6389
+ | OpenApiV3_1_XTypes['ReferenceObject'];
6390
+ }
6391
+
6392
+ declare namespace OpenApiSchemaObject {
6393
+ export type V2_0_X = OpenApiV2_0_XTypes['SchemaObject'];
6394
+
6395
+ export type V3_0_X = OpenApiV3_0_XTypes['SchemaObject'];
6396
+
6397
+ export type V3_1_X = OpenApiV3_1_XTypes['SchemaObject'];
6398
+ }
6399
+
6342
6400
  interface Operation extends Omit<Operation$1, 'tags'> {
6343
6401
  service: string;
6344
6402
  }
@@ -6676,10 +6734,10 @@ interface Config$c extends Plugin.Name<'@hey-api/schemas'> {
6676
6734
  schema:
6677
6735
  | OpenApiSchema
6678
6736
  | OpenApiSchema$1
6679
- | SchemaObject$1
6680
- | ReferenceObject
6681
- | SchemaObject
6682
- | SchemaObject$2,
6737
+ | OpenApiV2_0_XTypes['SchemaObject']
6738
+ | OpenApiV3_0_XTypes['ReferenceObject']
6739
+ | OpenApiV3_0_XTypes['SchemaObject']
6740
+ | OpenApiV3_1_XTypes['SchemaObject'],
6683
6741
  ) => string);
6684
6742
  /**
6685
6743
  * Name of the generated file.
@@ -6699,9 +6757,9 @@ interface Config$c extends Plugin.Name<'@hey-api/schemas'> {
6699
6757
 
6700
6758
  interface Config$b extends Plugin.Name<'@hey-api/sdk'> {
6701
6759
  /**
6702
- * Group operation methods into classes? When enabled, you can
6703
- * select which classes to export with `sdk.include` and/or
6704
- * transform their names with `sdk.serviceNameBuilder`.
6760
+ * Group operation methods into classes? When enabled, you can select which
6761
+ * classes to export with `sdk.include` and/or transform their names with
6762
+ * `sdk.classNameBuilder`.
6705
6763
  *
6706
6764
  * Note that by enabling this option, your SDKs will **NOT**
6707
6765
  * support {@link https://developer.mozilla.org/docs/Glossary/Tree_shaking tree-shaking}.
@@ -6718,6 +6776,13 @@ interface Config$b extends Plugin.Name<'@hey-api/sdk'> {
6718
6776
  * @default true
6719
6777
  */
6720
6778
  auth?: boolean;
6779
+ /**
6780
+ * Customize the generated class names. The name variable is obtained from
6781
+ * your OpenAPI specification tags or `instance` value.
6782
+ *
6783
+ * This option has no effect if `sdk.asClass` is `false`.
6784
+ */
6785
+ classNameBuilder?: string | ((name: string) => string);
6721
6786
  /**
6722
6787
  * Use an internal client instance to send HTTP requests? This is useful if
6723
6788
  * you don't want to manually pass the client to each SDK function.
@@ -6743,6 +6808,14 @@ interface Config$b extends Plugin.Name<'@hey-api/sdk'> {
6743
6808
  * This option has no effect if `sdk.asClass` is `false`.
6744
6809
  */
6745
6810
  include?: string;
6811
+ /**
6812
+ * Set `instance` to create an instantiable SDK. Using `true` will use the
6813
+ * default instance name; in practice, you want to define your own by passing
6814
+ * a string value.
6815
+ *
6816
+ * @default false
6817
+ */
6818
+ instance?: string | boolean;
6746
6819
  /**
6747
6820
  * Customise the name of methods within the service. By default, {@link IR.OperationObject.id} or {@link Operation.name} is used.
6748
6821
  */
@@ -6768,15 +6841,6 @@ interface Config$b extends Plugin.Name<'@hey-api/sdk'> {
6768
6841
  * @default 'fields'
6769
6842
  */
6770
6843
  responseStyle?: 'data' | 'fields';
6771
- /**
6772
- * Customize the generated service class names. The name variable is
6773
- * obtained from your OpenAPI specification tags.
6774
- *
6775
- * This option has no effect if `sdk.asClass` is `false`.
6776
- *
6777
- * @default '{{name}}Service'
6778
- */
6779
- serviceNameBuilder?: string | ((name: string) => string);
6780
6844
  /**
6781
6845
  * Transform response data before returning. This is useful if you want to
6782
6846
  * convert for example ISO strings into Date objects. However, transformation
@@ -7224,38 +7288,6 @@ type UserPlugins = Plugin.UserConfig<Config$i> | Plugin.UserConfig<Config$l> | P
7224
7288
  */
7225
7289
  type ClientPlugins = Plugin.Config<Config$i> | Plugin.Config<Config$l> | Plugin.Config<Config$k> | Plugin.Config<Config$j> | 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$4> | Plugin.Config<Config$8> | Plugin.Config<Config$7> | Plugin.Config<Config$6> | Plugin.Config<Config$5> | Plugin.Config<Config$3> | Plugin.Config<Config$2> | Plugin.Config<Config$1>;
7226
7290
 
7227
- type Formatters = 'biome' | 'prettier';
7228
-
7229
- type Linters = 'biome' | 'eslint' | 'oxlint';
7230
-
7231
- type StringCase =
7232
- | 'camelCase'
7233
- | 'PascalCase'
7234
- | 'preserve'
7235
- | 'snake_case'
7236
- | 'SCREAMING_SNAKE_CASE';
7237
-
7238
- interface Watch {
7239
- /**
7240
- * Regenerate the client when the input file changes?
7241
- *
7242
- * @default false
7243
- */
7244
- enabled?: boolean;
7245
- /**
7246
- * How often should we attempt to detect the input file change? (in ms)
7247
- *
7248
- * @default 1000
7249
- */
7250
- interval?: number;
7251
- /**
7252
- * How long will we wait before the request times out?
7253
- *
7254
- * @default 60_000
7255
- */
7256
- timeout?: number;
7257
- }
7258
-
7259
7291
  interface Input {
7260
7292
  /**
7261
7293
  * **Requires `path` to start with `https://get.heyapi.dev` or be undefined**
@@ -7291,136 +7323,7 @@ interface Input {
7291
7323
  * Filters can be used to select a subset of your input before it's processed
7292
7324
  * by plugins.
7293
7325
  */
7294
- filters?: {
7295
- /**
7296
- * Include deprecated resources in the output?
7297
- *
7298
- * @default true
7299
- */
7300
- deprecated?: boolean;
7301
- operations?: {
7302
- /**
7303
- * Prevent operations matching the `exclude` filters from being processed.
7304
- *
7305
- * In case of conflicts, `exclude` takes precedence over `include`.
7306
- *
7307
- * @example ['GET /api/v1/foo']
7308
- */
7309
- exclude?: ReadonlyArray<string>;
7310
- /**
7311
- * Process only operations matching the `include` filters.
7312
- *
7313
- * In case of conflicts, `exclude` takes precedence over `include`.
7314
- *
7315
- * @example ['GET /api/v1/foo']
7316
- */
7317
- include?: ReadonlyArray<string>;
7318
- };
7319
- /**
7320
- * Keep reusable components without any references in the output? By
7321
- * default, we exclude orphaned resources.
7322
- *
7323
- * @default false
7324
- */
7325
- orphans?: boolean;
7326
- parameters?: {
7327
- /**
7328
- * Prevent parameters matching the `exclude` filters from being processed.
7329
- *
7330
- * In case of conflicts, `exclude` takes precedence over `include`.
7331
- *
7332
- * @example ['QueryParam']
7333
- */
7334
- exclude?: ReadonlyArray<string>;
7335
- /**
7336
- * Process only parameters matching the `include` filters.
7337
- *
7338
- * In case of conflicts, `exclude` takes precedence over `include`.
7339
- *
7340
- * @example ['QueryParam']
7341
- */
7342
- include?: ReadonlyArray<string>;
7343
- };
7344
- /**
7345
- * Should we preserve the key order when overwriting your input? This
7346
- * option is disabled by default to improve performance.
7347
- *
7348
- * @default false
7349
- */
7350
- preserveOrder?: boolean;
7351
- requestBodies?: {
7352
- /**
7353
- * Prevent request bodies matching the `exclude` filters from being processed.
7354
- *
7355
- * In case of conflicts, `exclude` takes precedence over `include`.
7356
- *
7357
- * @example ['Foo']
7358
- */
7359
- exclude?: ReadonlyArray<string>;
7360
- /**
7361
- * Process only request bodies matching the `include` filters.
7362
- *
7363
- * In case of conflicts, `exclude` takes precedence over `include`.
7364
- *
7365
- * @example ['Foo']
7366
- */
7367
- include?: ReadonlyArray<string>;
7368
- };
7369
- responses?: {
7370
- /**
7371
- * Prevent responses matching the `exclude` filters from being processed.
7372
- *
7373
- * In case of conflicts, `exclude` takes precedence over `include`.
7374
- *
7375
- * @example ['Foo']
7376
- */
7377
- exclude?: ReadonlyArray<string>;
7378
- /**
7379
- * Process only responses matching the `include` filters.
7380
- *
7381
- * In case of conflicts, `exclude` takes precedence over `include`.
7382
- *
7383
- * @example ['Foo']
7384
- */
7385
- include?: ReadonlyArray<string>;
7386
- };
7387
- schemas?: {
7388
- /**
7389
- * Prevent schemas matching the `exclude` filters from being processed.
7390
- *
7391
- * In case of conflicts, `exclude` takes precedence over `include`.
7392
- *
7393
- * @example ['Foo']
7394
- */
7395
- exclude?: ReadonlyArray<string>;
7396
- /**
7397
- * Process only schemas matching the `include` filters.
7398
- *
7399
- * In case of conflicts, `exclude` takes precedence over `include`.
7400
- *
7401
- * @example ['Foo']
7402
- */
7403
- include?: ReadonlyArray<string>;
7404
- };
7405
- tags?: {
7406
- /**
7407
- * Prevent tags matching the `exclude` filters from being processed.
7408
- *
7409
- * In case of conflicts, `exclude` takes precedence over `include`.
7410
- *
7411
- * @example ['foo']
7412
- */
7413
- exclude?: ReadonlyArray<string>;
7414
- /**
7415
- * Process only tags matching the `include` filters.
7416
- *
7417
- * In case of conflicts, `exclude` takes precedence over `include`.
7418
- *
7419
- * @example ['foo']
7420
- */
7421
- include?: ReadonlyArray<string>;
7422
- };
7423
- };
7326
+ filters?: Filters;
7424
7327
  /**
7425
7328
  * **Requires `path` to start with `https://get.heyapi.dev` or be undefined**
7426
7329
  *
@@ -7428,7 +7331,7 @@ interface Input {
7428
7331
  */
7429
7332
  organization?: string;
7430
7333
  /**
7431
- * Pagination configuration
7334
+ * Pagination configuration.
7432
7335
  */
7433
7336
  pagination?: {
7434
7337
  /**
@@ -7439,6 +7342,11 @@ interface Input {
7439
7342
  */
7440
7343
  keywords?: ReadonlyArray<string>;
7441
7344
  };
7345
+ /**
7346
+ * Custom input transformations to execute before parsing. This allows you
7347
+ * to modify, fix, or enhance input definitions before code generation.
7348
+ */
7349
+ patch?: Patch;
7442
7350
  /**
7443
7351
  * Path to the OpenAPI specification. This can be either local or remote path.
7444
7352
  * Both JSON and YAML file formats are supported. You can also pass the parsed
@@ -7488,6 +7396,229 @@ interface Input {
7488
7396
  watch?: boolean | number | Watch;
7489
7397
  }
7490
7398
 
7399
+ interface Filters {
7400
+ /**
7401
+ * Include deprecated resources in the output?
7402
+ *
7403
+ * @default true
7404
+ */
7405
+ deprecated?: boolean;
7406
+ operations?: {
7407
+ /**
7408
+ * Prevent operations matching the `exclude` filters from being processed.
7409
+ *
7410
+ * In case of conflicts, `exclude` takes precedence over `include`.
7411
+ *
7412
+ * @example ['GET /api/v1/foo']
7413
+ */
7414
+ exclude?: ReadonlyArray<string>;
7415
+ /**
7416
+ * Process only operations matching the `include` filters.
7417
+ *
7418
+ * In case of conflicts, `exclude` takes precedence over `include`.
7419
+ *
7420
+ * @example ['GET /api/v1/foo']
7421
+ */
7422
+ include?: ReadonlyArray<string>;
7423
+ };
7424
+ /**
7425
+ * Keep reusable components without any references in the output? By
7426
+ * default, we exclude orphaned resources.
7427
+ *
7428
+ * @default false
7429
+ */
7430
+ orphans?: boolean;
7431
+ parameters?: {
7432
+ /**
7433
+ * Prevent parameters matching the `exclude` filters from being processed.
7434
+ *
7435
+ * In case of conflicts, `exclude` takes precedence over `include`.
7436
+ *
7437
+ * @example ['QueryParam']
7438
+ */
7439
+ exclude?: ReadonlyArray<string>;
7440
+ /**
7441
+ * Process only parameters matching the `include` filters.
7442
+ *
7443
+ * In case of conflicts, `exclude` takes precedence over `include`.
7444
+ *
7445
+ * @example ['QueryParam']
7446
+ */
7447
+ include?: ReadonlyArray<string>;
7448
+ };
7449
+ /**
7450
+ * Should we preserve the key order when overwriting your input? This
7451
+ * option is disabled by default to improve performance.
7452
+ *
7453
+ * @default false
7454
+ */
7455
+ preserveOrder?: boolean;
7456
+ requestBodies?: {
7457
+ /**
7458
+ * Prevent request bodies matching the `exclude` filters from being processed.
7459
+ *
7460
+ * In case of conflicts, `exclude` takes precedence over `include`.
7461
+ *
7462
+ * @example ['Foo']
7463
+ */
7464
+ exclude?: ReadonlyArray<string>;
7465
+ /**
7466
+ * Process only request bodies matching the `include` filters.
7467
+ *
7468
+ * In case of conflicts, `exclude` takes precedence over `include`.
7469
+ *
7470
+ * @example ['Foo']
7471
+ */
7472
+ include?: ReadonlyArray<string>;
7473
+ };
7474
+ responses?: {
7475
+ /**
7476
+ * Prevent responses matching the `exclude` filters from being processed.
7477
+ *
7478
+ * In case of conflicts, `exclude` takes precedence over `include`.
7479
+ *
7480
+ * @example ['Foo']
7481
+ */
7482
+ exclude?: ReadonlyArray<string>;
7483
+ /**
7484
+ * Process only responses matching the `include` filters.
7485
+ *
7486
+ * In case of conflicts, `exclude` takes precedence over `include`.
7487
+ *
7488
+ * @example ['Foo']
7489
+ */
7490
+ include?: ReadonlyArray<string>;
7491
+ };
7492
+ schemas?: {
7493
+ /**
7494
+ * Prevent schemas matching the `exclude` filters from being processed.
7495
+ *
7496
+ * In case of conflicts, `exclude` takes precedence over `include`.
7497
+ *
7498
+ * @example ['Foo']
7499
+ */
7500
+ exclude?: ReadonlyArray<string>;
7501
+ /**
7502
+ * Process only schemas matching the `include` filters.
7503
+ *
7504
+ * In case of conflicts, `exclude` takes precedence over `include`.
7505
+ *
7506
+ * @example ['Foo']
7507
+ */
7508
+ include?: ReadonlyArray<string>;
7509
+ };
7510
+ tags?: {
7511
+ /**
7512
+ * Prevent tags matching the `exclude` filters from being processed.
7513
+ *
7514
+ * In case of conflicts, `exclude` takes precedence over `include`.
7515
+ *
7516
+ * @example ['foo']
7517
+ */
7518
+ exclude?: ReadonlyArray<string>;
7519
+ /**
7520
+ * Process only tags matching the `include` filters.
7521
+ *
7522
+ * In case of conflicts, `exclude` takes precedence over `include`.
7523
+ *
7524
+ * @example ['foo']
7525
+ */
7526
+ include?: ReadonlyArray<string>;
7527
+ };
7528
+ }
7529
+
7530
+ interface Patch {
7531
+ parameters?: Record<
7532
+ string,
7533
+ (
7534
+ parameter: OpenApiParameterObject.V3_0_X | OpenApiParameterObject.V3_1_X,
7535
+ ) => void
7536
+ >;
7537
+ requestBodies?: Record<
7538
+ string,
7539
+ (
7540
+ requestBody:
7541
+ | OpenApiRequestBodyObject.V3_0_X
7542
+ | OpenApiRequestBodyObject.V3_1_X,
7543
+ ) => void
7544
+ >;
7545
+ responses?: Record<
7546
+ string,
7547
+ (
7548
+ response: OpenApiResponseObject.V3_0_X | OpenApiResponseObject.V3_1_X,
7549
+ ) => void
7550
+ >;
7551
+ /**
7552
+ * Each function receives the schema object to be modified in place. Common
7553
+ * use cases include fixing incorrect data types, removing unwanted
7554
+ * properties, adding missing fields, or standardizing date/time formats.
7555
+ *
7556
+ * @example
7557
+ * ```js
7558
+ * schemas: {
7559
+ * Foo: (schema) => {
7560
+ * // convert date-time format to timestamp
7561
+ * delete schema.properties.updatedAt.format;
7562
+ * schema.properties.updatedAt.type = 'number';
7563
+ * },
7564
+ * Bar: (schema) => {
7565
+ * // add missing property
7566
+ * schema.properties.metadata = {
7567
+ * additionalProperties: true,
7568
+ * type: 'object',
7569
+ * };
7570
+ * schema.required = ['metadata'];
7571
+ * },
7572
+ * Baz: (schema) => {
7573
+ * // remove property
7574
+ * delete schema.properties.internalField;
7575
+ * }
7576
+ * }
7577
+ * ```
7578
+ */
7579
+ schemas?: Record<
7580
+ string,
7581
+ (
7582
+ schema:
7583
+ | OpenApiSchemaObject.V2_0_X
7584
+ | OpenApiSchemaObject.V3_0_X
7585
+ | OpenApiSchemaObject.V3_1_X,
7586
+ ) => void
7587
+ >;
7588
+ }
7589
+
7590
+ interface Watch {
7591
+ /**
7592
+ * Regenerate the client when the input file changes?
7593
+ *
7594
+ * @default false
7595
+ */
7596
+ enabled?: boolean;
7597
+ /**
7598
+ * How often should we attempt to detect the input file change? (in ms)
7599
+ *
7600
+ * @default 1000
7601
+ */
7602
+ interval?: number;
7603
+ /**
7604
+ * How long will we wait before the request times out?
7605
+ *
7606
+ * @default 60_000
7607
+ */
7608
+ timeout?: number;
7609
+ }
7610
+
7611
+ type Formatters = 'biome' | 'prettier';
7612
+
7613
+ type Linters = 'biome' | 'eslint' | 'oxlint';
7614
+
7615
+ type StringCase =
7616
+ | 'camelCase'
7617
+ | 'PascalCase'
7618
+ | 'preserve'
7619
+ | 'snake_case'
7620
+ | 'SCREAMING_SNAKE_CASE';
7621
+
7491
7622
  interface UserConfig {
7492
7623
  /**
7493
7624
  * Path to the config file. Set this value if you don't use the default
@@ -8191,4 +8322,4 @@ interface WatchValues {
8191
8322
  lastValue?: string;
8192
8323
  }
8193
8324
 
8194
- 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, Client as a, Plugin as b, type Config as c, defaultPlugins as d, initConfigs as i };
8325
+ 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hey-api/openapi-ts",
3
- "version": "0.70.0",
3
+ "version": "0.71.0",
4
4
  "description": "🚀 The OpenAPI to TypeScript codegen. Generate clients, SDKs, validators, and more.",
5
5
  "homepage": "https://heyapi.dev/",
6
6
  "repository": {