@hey-api/openapi-ts 0.79.1 → 0.80.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.
@@ -1,5 +1,6 @@
1
- import { k as Config, c as IR, U as UserConfig, W as WatchValues } from './types.d-BRYhp7DX.cjs';
1
+ import { k as Config, c as IR, U as UserConfig, W as WatchValues } from './types.d-CXdSuWix.cjs';
2
2
  import { JSONSchema } from '@hey-api/json-schema-ref-parser';
3
+ import 'semver';
3
4
  import 'node:fs';
4
5
  import 'typescript';
5
6
 
@@ -8,18 +9,22 @@ import 'typescript';
8
9
  * Parse the resolved OpenAPI specification. This will populate and return
9
10
  * `context` with intermediate representation obtained from the parsed spec.
10
11
  */
11
- declare const parseOpenApiSpec: ({ config, spec, }: {
12
+ declare const parseOpenApiSpec: ({ config, dependencies, spec, }: {
12
13
  config: Config;
14
+ dependencies: Record<string, string>;
13
15
  spec: unknown;
14
16
  }) => IR.Context | undefined;
15
17
 
16
18
  /**
17
19
  * @internal
18
20
  */
19
- declare const initConfigs: (userConfig: UserConfig | undefined) => Promise<ReadonlyArray<{
20
- config: Config;
21
- errors: ReadonlyArray<Error>;
22
- }>>;
21
+ declare const initConfigs: (userConfig: UserConfig | undefined) => Promise<{
22
+ dependencies: Record<string, string>;
23
+ results: ReadonlyArray<{
24
+ config: Config;
25
+ errors: ReadonlyArray<Error>;
26
+ }>;
27
+ }>;
23
28
 
24
29
  interface SpecResponse {
25
30
  data: JSONSchema;
@@ -1,5 +1,6 @@
1
- import { k as Config, c as IR, U as UserConfig, W as WatchValues } from './types.d-BRYhp7DX.js';
1
+ import { k as Config, c as IR, U as UserConfig, W as WatchValues } from './types.d-CXdSuWix.js';
2
2
  import { JSONSchema } from '@hey-api/json-schema-ref-parser';
3
+ import 'semver';
3
4
  import 'node:fs';
4
5
  import 'typescript';
5
6
 
@@ -8,18 +9,22 @@ import 'typescript';
8
9
  * Parse the resolved OpenAPI specification. This will populate and return
9
10
  * `context` with intermediate representation obtained from the parsed spec.
10
11
  */
11
- declare const parseOpenApiSpec: ({ config, spec, }: {
12
+ declare const parseOpenApiSpec: ({ config, dependencies, spec, }: {
12
13
  config: Config;
14
+ dependencies: Record<string, string>;
13
15
  spec: unknown;
14
16
  }) => IR.Context | undefined;
15
17
 
16
18
  /**
17
19
  * @internal
18
20
  */
19
- declare const initConfigs: (userConfig: UserConfig | undefined) => Promise<ReadonlyArray<{
20
- config: Config;
21
- errors: ReadonlyArray<Error>;
22
- }>>;
21
+ declare const initConfigs: (userConfig: UserConfig | undefined) => Promise<{
22
+ dependencies: Record<string, string>;
23
+ results: ReadonlyArray<{
24
+ config: Config;
25
+ errors: ReadonlyArray<Error>;
26
+ }>;
27
+ }>;
23
28
 
24
29
  interface SpecResponse {
25
30
  data: JSONSchema;
package/dist/internal.js CHANGED
@@ -1,2 +1,2 @@
1
- import {createRequire}from'module';export{J as getSpec,I as initConfigs,G as parseOpenApiSpec}from'./chunk-H4ADXQ4D.js';createRequire(import.meta.url);//# sourceMappingURL=internal.js.map
1
+ import {createRequire}from'module';export{J as getSpec,I as initConfigs,G as parseOpenApiSpec}from'./chunk-AMRI65AJ.js';createRequire(import.meta.url);//# sourceMappingURL=internal.js.map
2
2
  //# sourceMappingURL=internal.js.map
@@ -1,3 +1,4 @@
1
+ import { SemVer, RangeOptions } from 'semver';
1
2
  import fs from 'node:fs';
2
3
  import ts__default from 'typescript';
3
4
 
@@ -2494,6 +2495,28 @@ type JsonSchemaTypes$1 =
2494
2495
  | 'object'
2495
2496
  | 'string';
2496
2497
 
2498
+ type Package = {
2499
+ /**
2500
+ * Get the installed version of a package.
2501
+ * @param name The name of the package to get the version for.
2502
+ * @returns A SemVer object containing version information, or undefined if the package is not installed
2503
+ * or the version string is invalid.
2504
+ */
2505
+ getVersion: (name: string) => SemVer | undefined;
2506
+ /**
2507
+ * Check if a given package is installed in the project.
2508
+ * @param name The name of the package to check.
2509
+ */
2510
+ isInstalled: (name: string) => boolean;
2511
+ /**
2512
+ * Check if the installed version of a package or a given SemVer object satisfies a semver range.
2513
+ * @param nameOrVersion The name of the package to check, or a SemVer object.
2514
+ * @param range The semver range to check against.
2515
+ * @returns True if the version satisfies the range, false otherwise.
2516
+ */
2517
+ satisfies: (nameOrVersion: string | SemVer, range: string, optionsOrLoose?: boolean | RangeOptions) => boolean;
2518
+ };
2519
+
2497
2520
  interface ImportExportItemObject<Name extends string | undefined = string | undefined, Alias extends string | undefined = undefined> {
2498
2521
  alias?: Alias;
2499
2522
  asType?: boolean;
@@ -7676,6 +7699,13 @@ declare class PluginInstance<T extends Plugin.Types = Plugin.Types> {
7676
7699
  private handler;
7677
7700
  name: T['resolvedConfig']['name'];
7678
7701
  output: Required<T['config']>['output'];
7702
+ /**
7703
+ * The package metadata and utilities for the current context, constructed
7704
+ * from the provided dependencies. Used for managing package-related
7705
+ * information such as name, version, and dependency resolution during
7706
+ * code generation.
7707
+ */
7708
+ package: IR.Context['package'];
7679
7709
  constructor(props: Pick<Required<Plugin.Config<T>>, 'config' | 'dependencies' | 'handler'> & {
7680
7710
  api?: T['api'];
7681
7711
  context: IR.Context<OpenApi$3.V2_0_X | OpenApi$3.V3_0_X | OpenApi$3.V3_1_X>;
@@ -7756,7 +7786,8 @@ type AnyPluginName = PluginNames | (string & {});
7756
7786
 
7757
7787
  type PluginTag = 'client' | 'transformer' | 'validator';
7758
7788
 
7759
- interface PluginContext {
7789
+ type PluginContext = {
7790
+ package: Package;
7760
7791
  pluginByTag: <T extends AnyPluginName | boolean = AnyPluginName>(
7761
7792
  tag: PluginTag,
7762
7793
  props?: {
@@ -7765,7 +7796,7 @@ interface PluginContext {
7765
7796
  },
7766
7797
  ) => Exclude<T, boolean> | undefined;
7767
7798
  valueToObject: ValueToObject;
7768
- }
7799
+ };
7769
7800
 
7770
7801
  type BaseApi = Record<string, unknown>;
7771
7802
 
@@ -8851,10 +8882,14 @@ type Config$7 = Plugin.Name<'@hey-api/typescript'> & {
8851
8882
  tree: boolean;
8852
8883
  };
8853
8884
 
8885
+ interface PluginState {
8886
+ usedTypeIDs: Set<string>;
8887
+ }
8888
+
8854
8889
  type HeyApiTypeScriptPlugin = DefinePlugin<UserConfig$8, Config$7, Api$2>;
8855
8890
 
8856
8891
  type OnRef = (id: string) => void;
8857
- declare const schemaToType: ({ onRef, plugin, schema, }: {
8892
+ declare const schemaToType: ({ onRef, plugin, schema, state, }: {
8858
8893
  /**
8859
8894
  * Callback that can be used to perform side-effects when we encounter a
8860
8895
  * reference. For example, we might want to import the referenced type.
@@ -8862,6 +8897,7 @@ declare const schemaToType: ({ onRef, plugin, schema, }: {
8862
8897
  onRef: OnRef | undefined;
8863
8898
  plugin: HeyApiTypeScriptPlugin["Instance"];
8864
8899
  schema: IR.SchemaObject;
8900
+ state: PluginState;
8865
8901
  }) => ts__default.TypeNode;
8866
8902
 
8867
8903
  type GetIdArgs$1 = {
@@ -11062,6 +11098,17 @@ type UserConfig = Plugin.Name<'zod'> & {
11062
11098
  * @default true
11063
11099
  */
11064
11100
  comments?: boolean;
11101
+ /**
11102
+ * The compatibility version to target for generated output.
11103
+ *
11104
+ * Can be:
11105
+ * - `4`: [Zod 4](https://zod.dev/packages/zod) (default).
11106
+ * - `3`: [Zod 3](https://v3.zod.dev/).
11107
+ * - `'mini'`: [Zod Mini](https://zod.dev/packages/mini).
11108
+ *
11109
+ * @default 4
11110
+ */
11111
+ compatibilityVersion?: 3 | 4 | 'mini';
11065
11112
  /**
11066
11113
  * Configuration for date handling in generated Zod schemas.
11067
11114
  *
@@ -11383,6 +11430,17 @@ type Config = Plugin.Name<'zod'> & {
11383
11430
  * @default true
11384
11431
  */
11385
11432
  comments: boolean;
11433
+ /**
11434
+ * The compatibility version to target for generated output.
11435
+ *
11436
+ * Can be:
11437
+ * - `4`: [Zod 4](https://zod.dev/packages/zod) (default).
11438
+ * - `3`: [Zod 3](https://v3.zod.dev/).
11439
+ * - `'mini'`: [Zod Mini](https://zod.dev/packages/mini).
11440
+ *
11441
+ * @default 4
11442
+ */
11443
+ compatibilityVersion: 3 | 4 | 'mini';
11386
11444
  /**
11387
11445
  * Configuration for date handling in generated Zod schemas.
11388
11446
  *
@@ -11703,6 +11761,13 @@ declare class IRContext<Spec extends Record<string, any> = any> {
11703
11761
  * Intermediate representation model obtained from `spec`.
11704
11762
  */
11705
11763
  ir: IR.Model;
11764
+ /**
11765
+ * The package metadata and utilities for the current context, constructed
11766
+ * from the provided dependencies. Used for managing package-related
11767
+ * information such as name, version, and dependency resolution during
11768
+ * code generation.
11769
+ */
11770
+ package: Package;
11706
11771
  /**
11707
11772
  * A map of registered plugin instances, keyed by plugin name. Plugins are
11708
11773
  * registered through the `registerPlugin` method and can be accessed by
@@ -11713,8 +11778,9 @@ declare class IRContext<Spec extends Record<string, any> = any> {
11713
11778
  * Resolved specification from `input`.
11714
11779
  */
11715
11780
  spec: Spec;
11716
- constructor({ config, spec }: {
11781
+ constructor({ config, dependencies, spec, }: {
11717
11782
  config: Config$9;
11783
+ dependencies: Record<string, string>;
11718
11784
  spec: Spec;
11719
11785
  });
11720
11786
  /**
@@ -11889,6 +11955,7 @@ interface IRSchemaObject
11889
11955
  | 'pattern'
11890
11956
  | 'required'
11891
11957
  | 'title'
11958
+ | 'example'
11892
11959
  > {
11893
11960
  /**
11894
11961
  * If the schema is intended to be used as an object property, it can be
@@ -1,3 +1,4 @@
1
+ import { SemVer, RangeOptions } from 'semver';
1
2
  import fs from 'node:fs';
2
3
  import ts__default from 'typescript';
3
4
 
@@ -2494,6 +2495,28 @@ type JsonSchemaTypes$1 =
2494
2495
  | 'object'
2495
2496
  | 'string';
2496
2497
 
2498
+ type Package = {
2499
+ /**
2500
+ * Get the installed version of a package.
2501
+ * @param name The name of the package to get the version for.
2502
+ * @returns A SemVer object containing version information, or undefined if the package is not installed
2503
+ * or the version string is invalid.
2504
+ */
2505
+ getVersion: (name: string) => SemVer | undefined;
2506
+ /**
2507
+ * Check if a given package is installed in the project.
2508
+ * @param name The name of the package to check.
2509
+ */
2510
+ isInstalled: (name: string) => boolean;
2511
+ /**
2512
+ * Check if the installed version of a package or a given SemVer object satisfies a semver range.
2513
+ * @param nameOrVersion The name of the package to check, or a SemVer object.
2514
+ * @param range The semver range to check against.
2515
+ * @returns True if the version satisfies the range, false otherwise.
2516
+ */
2517
+ satisfies: (nameOrVersion: string | SemVer, range: string, optionsOrLoose?: boolean | RangeOptions) => boolean;
2518
+ };
2519
+
2497
2520
  interface ImportExportItemObject<Name extends string | undefined = string | undefined, Alias extends string | undefined = undefined> {
2498
2521
  alias?: Alias;
2499
2522
  asType?: boolean;
@@ -7676,6 +7699,13 @@ declare class PluginInstance<T extends Plugin.Types = Plugin.Types> {
7676
7699
  private handler;
7677
7700
  name: T['resolvedConfig']['name'];
7678
7701
  output: Required<T['config']>['output'];
7702
+ /**
7703
+ * The package metadata and utilities for the current context, constructed
7704
+ * from the provided dependencies. Used for managing package-related
7705
+ * information such as name, version, and dependency resolution during
7706
+ * code generation.
7707
+ */
7708
+ package: IR.Context['package'];
7679
7709
  constructor(props: Pick<Required<Plugin.Config<T>>, 'config' | 'dependencies' | 'handler'> & {
7680
7710
  api?: T['api'];
7681
7711
  context: IR.Context<OpenApi$3.V2_0_X | OpenApi$3.V3_0_X | OpenApi$3.V3_1_X>;
@@ -7756,7 +7786,8 @@ type AnyPluginName = PluginNames | (string & {});
7756
7786
 
7757
7787
  type PluginTag = 'client' | 'transformer' | 'validator';
7758
7788
 
7759
- interface PluginContext {
7789
+ type PluginContext = {
7790
+ package: Package;
7760
7791
  pluginByTag: <T extends AnyPluginName | boolean = AnyPluginName>(
7761
7792
  tag: PluginTag,
7762
7793
  props?: {
@@ -7765,7 +7796,7 @@ interface PluginContext {
7765
7796
  },
7766
7797
  ) => Exclude<T, boolean> | undefined;
7767
7798
  valueToObject: ValueToObject;
7768
- }
7799
+ };
7769
7800
 
7770
7801
  type BaseApi = Record<string, unknown>;
7771
7802
 
@@ -8851,10 +8882,14 @@ type Config$7 = Plugin.Name<'@hey-api/typescript'> & {
8851
8882
  tree: boolean;
8852
8883
  };
8853
8884
 
8885
+ interface PluginState {
8886
+ usedTypeIDs: Set<string>;
8887
+ }
8888
+
8854
8889
  type HeyApiTypeScriptPlugin = DefinePlugin<UserConfig$8, Config$7, Api$2>;
8855
8890
 
8856
8891
  type OnRef = (id: string) => void;
8857
- declare const schemaToType: ({ onRef, plugin, schema, }: {
8892
+ declare const schemaToType: ({ onRef, plugin, schema, state, }: {
8858
8893
  /**
8859
8894
  * Callback that can be used to perform side-effects when we encounter a
8860
8895
  * reference. For example, we might want to import the referenced type.
@@ -8862,6 +8897,7 @@ declare const schemaToType: ({ onRef, plugin, schema, }: {
8862
8897
  onRef: OnRef | undefined;
8863
8898
  plugin: HeyApiTypeScriptPlugin["Instance"];
8864
8899
  schema: IR.SchemaObject;
8900
+ state: PluginState;
8865
8901
  }) => ts__default.TypeNode;
8866
8902
 
8867
8903
  type GetIdArgs$1 = {
@@ -11062,6 +11098,17 @@ type UserConfig = Plugin.Name<'zod'> & {
11062
11098
  * @default true
11063
11099
  */
11064
11100
  comments?: boolean;
11101
+ /**
11102
+ * The compatibility version to target for generated output.
11103
+ *
11104
+ * Can be:
11105
+ * - `4`: [Zod 4](https://zod.dev/packages/zod) (default).
11106
+ * - `3`: [Zod 3](https://v3.zod.dev/).
11107
+ * - `'mini'`: [Zod Mini](https://zod.dev/packages/mini).
11108
+ *
11109
+ * @default 4
11110
+ */
11111
+ compatibilityVersion?: 3 | 4 | 'mini';
11065
11112
  /**
11066
11113
  * Configuration for date handling in generated Zod schemas.
11067
11114
  *
@@ -11383,6 +11430,17 @@ type Config = Plugin.Name<'zod'> & {
11383
11430
  * @default true
11384
11431
  */
11385
11432
  comments: boolean;
11433
+ /**
11434
+ * The compatibility version to target for generated output.
11435
+ *
11436
+ * Can be:
11437
+ * - `4`: [Zod 4](https://zod.dev/packages/zod) (default).
11438
+ * - `3`: [Zod 3](https://v3.zod.dev/).
11439
+ * - `'mini'`: [Zod Mini](https://zod.dev/packages/mini).
11440
+ *
11441
+ * @default 4
11442
+ */
11443
+ compatibilityVersion: 3 | 4 | 'mini';
11386
11444
  /**
11387
11445
  * Configuration for date handling in generated Zod schemas.
11388
11446
  *
@@ -11703,6 +11761,13 @@ declare class IRContext<Spec extends Record<string, any> = any> {
11703
11761
  * Intermediate representation model obtained from `spec`.
11704
11762
  */
11705
11763
  ir: IR.Model;
11764
+ /**
11765
+ * The package metadata and utilities for the current context, constructed
11766
+ * from the provided dependencies. Used for managing package-related
11767
+ * information such as name, version, and dependency resolution during
11768
+ * code generation.
11769
+ */
11770
+ package: Package;
11706
11771
  /**
11707
11772
  * A map of registered plugin instances, keyed by plugin name. Plugins are
11708
11773
  * registered through the `registerPlugin` method and can be accessed by
@@ -11713,8 +11778,9 @@ declare class IRContext<Spec extends Record<string, any> = any> {
11713
11778
  * Resolved specification from `input`.
11714
11779
  */
11715
11780
  spec: Spec;
11716
- constructor({ config, spec }: {
11781
+ constructor({ config, dependencies, spec, }: {
11717
11782
  config: Config$9;
11783
+ dependencies: Record<string, string>;
11718
11784
  spec: Spec;
11719
11785
  });
11720
11786
  /**
@@ -11889,6 +11955,7 @@ interface IRSchemaObject
11889
11955
  | 'pattern'
11890
11956
  | 'required'
11891
11957
  | 'title'
11958
+ | 'example'
11892
11959
  > {
11893
11960
  /**
11894
11961
  * If the schema is intended to be used as an object property, it can be
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hey-api/openapi-ts",
3
- "version": "0.79.1",
3
+ "version": "0.80.0",
4
4
  "description": "🚀 The OpenAPI to TypeScript codegen. Generate clients, SDKs, validators, and more.",
5
5
  "homepage": "https://heyapi.dev/",
6
6
  "repository": {
@@ -82,7 +82,8 @@
82
82
  "color-support": "1.1.3",
83
83
  "commander": "13.0.0",
84
84
  "handlebars": "4.7.8",
85
- "open": "10.1.2"
85
+ "open": "10.1.2",
86
+ "semver": "7.7.2"
86
87
  },
87
88
  "peerDependencies": {
88
89
  "typescript": "^5.5.3"
@@ -91,6 +92,7 @@
91
92
  "@types/bun": "1.2.19",
92
93
  "@types/cross-spawn": "6.0.6",
93
94
  "@types/express": "4.17.21",
95
+ "@types/semver": "7.7.0",
94
96
  "axios": "1.8.2",
95
97
  "cross-spawn": "7.0.5",
96
98
  "eslint": "9.17.0",