@hey-api/openapi-ts 0.79.2 → 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-GwalOH_C.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-GwalOH_C.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-USY42MA2.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
 
@@ -11067,6 +11098,17 @@ type UserConfig = Plugin.Name<'zod'> & {
11067
11098
  * @default true
11068
11099
  */
11069
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';
11070
11112
  /**
11071
11113
  * Configuration for date handling in generated Zod schemas.
11072
11114
  *
@@ -11388,6 +11430,17 @@ type Config = Plugin.Name<'zod'> & {
11388
11430
  * @default true
11389
11431
  */
11390
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';
11391
11444
  /**
11392
11445
  * Configuration for date handling in generated Zod schemas.
11393
11446
  *
@@ -11708,6 +11761,13 @@ declare class IRContext<Spec extends Record<string, any> = any> {
11708
11761
  * Intermediate representation model obtained from `spec`.
11709
11762
  */
11710
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;
11711
11771
  /**
11712
11772
  * A map of registered plugin instances, keyed by plugin name. Plugins are
11713
11773
  * registered through the `registerPlugin` method and can be accessed by
@@ -11718,8 +11778,9 @@ declare class IRContext<Spec extends Record<string, any> = any> {
11718
11778
  * Resolved specification from `input`.
11719
11779
  */
11720
11780
  spec: Spec;
11721
- constructor({ config, spec }: {
11781
+ constructor({ config, dependencies, spec, }: {
11722
11782
  config: Config$9;
11783
+ dependencies: Record<string, string>;
11723
11784
  spec: Spec;
11724
11785
  });
11725
11786
  /**
@@ -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
 
@@ -11067,6 +11098,17 @@ type UserConfig = Plugin.Name<'zod'> & {
11067
11098
  * @default true
11068
11099
  */
11069
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';
11070
11112
  /**
11071
11113
  * Configuration for date handling in generated Zod schemas.
11072
11114
  *
@@ -11388,6 +11430,17 @@ type Config = Plugin.Name<'zod'> & {
11388
11430
  * @default true
11389
11431
  */
11390
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';
11391
11444
  /**
11392
11445
  * Configuration for date handling in generated Zod schemas.
11393
11446
  *
@@ -11708,6 +11761,13 @@ declare class IRContext<Spec extends Record<string, any> = any> {
11708
11761
  * Intermediate representation model obtained from `spec`.
11709
11762
  */
11710
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;
11711
11771
  /**
11712
11772
  * A map of registered plugin instances, keyed by plugin name. Plugins are
11713
11773
  * registered through the `registerPlugin` method and can be accessed by
@@ -11718,8 +11778,9 @@ declare class IRContext<Spec extends Record<string, any> = any> {
11718
11778
  * Resolved specification from `input`.
11719
11779
  */
11720
11780
  spec: Spec;
11721
- constructor({ config, spec }: {
11781
+ constructor({ config, dependencies, spec, }: {
11722
11782
  config: Config$9;
11783
+ dependencies: Record<string, string>;
11723
11784
  spec: Spec;
11724
11785
  });
11725
11786
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hey-api/openapi-ts",
3
- "version": "0.79.2",
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",