@hey-api/openapi-ts 0.78.0 → 0.78.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.
@@ -1,4 +1,4 @@
1
- import { i as Config, I as IR, U as UserConfig, W as WatchValues } from './types.d-BsTxgeRq.cjs';
1
+ import { k as Config, c as IR, U as UserConfig, W as WatchValues } from './types.d-CaH9PF-K.cjs';
2
2
  import { JSONSchema } from '@hey-api/json-schema-ref-parser';
3
3
  import 'node:fs';
4
4
  import 'typescript';
@@ -1,4 +1,4 @@
1
- import { i as Config, I as IR, U as UserConfig, W as WatchValues } from './types.d-BsTxgeRq.js';
1
+ import { k as Config, c as IR, U as UserConfig, W as WatchValues } from './types.d-CaH9PF-K.js';
2
2
  import { JSONSchema } from '@hey-api/json-schema-ref-parser';
3
3
  import 'node:fs';
4
4
  import 'typescript';
package/dist/internal.js CHANGED
@@ -1,2 +1,2 @@
1
- import {createRequire}from'module';export{I as getSpec,H as initConfigs,F as parseOpenApiSpec}from'./chunk-RASXZ2HF.js';createRequire(import.meta.url);//# sourceMappingURL=internal.js.map
1
+ import {createRequire}from'module';export{I as getSpec,H as initConfigs,F as parseOpenApiSpec}from'./chunk-YJGQGZQU.js';createRequire(import.meta.url);//# sourceMappingURL=internal.js.map
2
2
  //# sourceMappingURL=internal.js.map
@@ -1,5 +1,5 @@
1
1
  import fs from 'node:fs';
2
- import ts from 'typescript';
2
+ import ts__default from 'typescript';
3
3
 
4
4
  interface EnumExtensions {
5
5
  /**
@@ -2499,6 +2499,27 @@ interface ImportExportItemObject {
2499
2499
  asType?: boolean;
2500
2500
  name: string;
2501
2501
  }
2502
+ /**
2503
+ * Print a TypeScript node to a string.
2504
+ * @param node the node to print
2505
+ * @returns string
2506
+ */
2507
+ declare function tsNodeToString({ node, unescape, }: {
2508
+ node: ts__default.Node;
2509
+ unescape?: boolean;
2510
+ }): string;
2511
+ /**
2512
+ * Convert a string to a TypeScript Node
2513
+ * @param value the string to convert.
2514
+ * @returns ts.Node
2515
+ */
2516
+ declare function stringToTsNodes(value: string): ts__default.Node;
2517
+ type CommentLines = Array<string | null | false | undefined>;
2518
+ type CommentObject = {
2519
+ jsdoc?: boolean;
2520
+ lines: CommentLines;
2521
+ };
2522
+ type Comments = CommentLines | Array<CommentObject>;
2502
2523
 
2503
2524
  type StringCase =
2504
2525
  | 'camelCase'
@@ -2588,7 +2609,7 @@ declare class TypeScriptFile {
2588
2609
  identifierCase?: StringCase;
2589
2610
  name: string;
2590
2611
  });
2591
- add(...nodes: Array<ts.Node | string>): void;
2612
+ add(...nodes: Array<ts__default.Node | string>): void;
2592
2613
  /**
2593
2614
  * Prevents a specific identifier from being created. This is useful for
2594
2615
  * transformers where we know a certain transformer won't be needed, and
@@ -2624,7 +2645,7 @@ declare class TypeScriptFile {
2624
2645
  removeNode(): void;
2625
2646
  private _setName;
2626
2647
  private _toString;
2627
- write(separator?: string, tsConfig?: ts.ParsedCommandLine | null): void;
2648
+ write(separator?: string, tsConfig?: ts__default.ParsedCommandLine | null): void;
2628
2649
  }
2629
2650
  interface EnsureUniqueIdentifierData {
2630
2651
  $ref: string;
@@ -2640,18 +2661,23 @@ interface EnsureUniqueIdentifierData {
2640
2661
  }
2641
2662
 
2642
2663
  type ObjectType<T> = Extract<T, Record<string, any>> extends never ? Record<string, any> : Extract<T, Record<string, any>>;
2664
+ type MappersType<T> = {
2665
+ boolean: T extends boolean ? (value: boolean) => Partial<ObjectType<T>> : never;
2666
+ number: T extends number ? (value: number) => Partial<ObjectType<T>> : never;
2667
+ object?: (value: Partial<ObjectType<T>>) => Partial<ObjectType<T>>;
2668
+ string: T extends string ? (value: string) => Partial<ObjectType<T>> : never;
2669
+ } extends infer U ? {
2670
+ [K in keyof U as U[K] extends never ? never : K]: U[K];
2671
+ } : never;
2672
+ type IsObjectOnly<T> = T extends Record<string, any> | undefined ? Extract<T, string | boolean | number> extends never ? true : false : false;
2643
2673
  type ValueToObject = <T extends undefined | string | boolean | number | Record<string, any>>(args: {
2644
2674
  defaultValue: ObjectType<T>;
2645
- mappers: {
2646
- boolean: T extends boolean ? (value: boolean) => Partial<ObjectType<T>> : never;
2647
- number: T extends number ? (value: number) => Partial<ObjectType<T>> : never;
2648
- object?: (value: Partial<ObjectType<T>>) => Partial<ObjectType<T>>;
2649
- string: T extends string ? (value: string) => Partial<ObjectType<T>> : never;
2650
- } extends infer U ? {
2651
- [K in keyof U as U[K] extends never ? never : K]: U[K];
2652
- } : never;
2653
2675
  value: T;
2654
- }) => ObjectType<T>;
2676
+ } & (IsObjectOnly<T> extends true ? {
2677
+ mappers?: MappersType<T>;
2678
+ } : {
2679
+ mappers: MappersType<T>;
2680
+ })) => ObjectType<T>;
2655
2681
 
2656
2682
  type Input = {
2657
2683
  /**
@@ -8214,6 +8240,13 @@ type ResolvedConfig$8 = Plugin.Name<'@hey-api/sdk'> & {
8214
8240
 
8215
8241
  type HeyApiSdkPlugin = DefinePlugin<Config$a, ResolvedConfig$8>;
8216
8242
 
8243
+ type ExpressionTransformer = ({ config, dataExpression, file, schema, }: {
8244
+ config: Omit<Config$9, 'name'>;
8245
+ dataExpression?: ts__default.Expression | string;
8246
+ file: TypeScriptFile;
8247
+ schema: IR.SchemaObject;
8248
+ }) => Array<ts__default.Expression> | undefined;
8249
+
8217
8250
  type Config$9 = Plugin.Name<'@hey-api/transformers'> & {
8218
8251
  /**
8219
8252
  * Convert long integers into BigInt values?
@@ -8240,6 +8273,10 @@ type Config$9 = Plugin.Name<'@hey-api/transformers'> & {
8240
8273
  * @default 'transformers'
8241
8274
  */
8242
8275
  output?: string;
8276
+ /**
8277
+ * Custom transforms to apply to the generated code.
8278
+ */
8279
+ transformers?: ReadonlyArray<ExpressionTransformer>;
8243
8280
  };
8244
8281
 
8245
8282
  type HeyApiTransformersPlugin = DefinePlugin<Config$9>;
@@ -9777,12 +9814,12 @@ type Api$1 = {
9777
9814
  file: TypeScriptFile;
9778
9815
  operation: IR.OperationObject;
9779
9816
  plugin: ValibotPlugin['Instance'];
9780
- }) => ts.ArrowFunction | undefined;
9817
+ }) => ts__default.ArrowFunction | undefined;
9781
9818
  createResponseValidator: (args: {
9782
9819
  file: TypeScriptFile;
9783
9820
  operation: IR.OperationObject;
9784
9821
  plugin: ValibotPlugin['Instance'];
9785
- }) => ts.ArrowFunction | undefined;
9822
+ }) => ts__default.ArrowFunction | undefined;
9786
9823
  };
9787
9824
 
9788
9825
  type Config = Plugin.Name<'zod'> & {
@@ -9798,6 +9835,23 @@ type Config = Plugin.Name<'zod'> & {
9798
9835
  * @default true
9799
9836
  */
9800
9837
  comments?: boolean;
9838
+ /**
9839
+ * Configuration for date handling in generated Zod schemas.
9840
+ *
9841
+ * Controls how date values are processed and validated using Zod's
9842
+ * date validation features.
9843
+ */
9844
+ dates?: {
9845
+ /**
9846
+ * Whether to include timezone offset information when handling dates.
9847
+ *
9848
+ * When enabled, date strings will preserve timezone information.
9849
+ * When disabled, dates will be treated as local time.
9850
+ *
9851
+ * @default false
9852
+ */
9853
+ offset?: boolean;
9854
+ };
9801
9855
  /**
9802
9856
  * Configuration for reusable schema definitions.
9803
9857
  *
@@ -9939,6 +9993,23 @@ type ResolvedConfig = Plugin.Name<'zod'> & {
9939
9993
  * @default true
9940
9994
  */
9941
9995
  comments: boolean;
9996
+ /**
9997
+ * Configuration for date handling in generated Zod schemas.
9998
+ *
9999
+ * Controls how date values are processed and validated using Zod's
10000
+ * date validation features.
10001
+ */
10002
+ dates: {
10003
+ /**
10004
+ * Whether to include timezone offset information when handling dates.
10005
+ *
10006
+ * When enabled, date strings will preserve timezone information.
10007
+ * When disabled, dates will be treated as local time.
10008
+ *
10009
+ * @default false
10010
+ */
10011
+ offset: boolean;
10012
+ };
9942
10013
  /**
9943
10014
  * Configuration for reusable schema definitions.
9944
10015
  *
@@ -10050,12 +10121,12 @@ type Api = {
10050
10121
  file: TypeScriptFile;
10051
10122
  operation: IR.OperationObject;
10052
10123
  plugin: ZodPlugin['Instance'];
10053
- }) => ts.ArrowFunction | undefined;
10124
+ }) => ts__default.ArrowFunction | undefined;
10054
10125
  createResponseValidator: (args: {
10055
10126
  file: TypeScriptFile;
10056
10127
  operation: IR.OperationObject;
10057
10128
  plugin: ZodPlugin['Instance'];
10058
- }) => ts.ArrowFunction | undefined;
10129
+ }) => ts__default.ArrowFunction | undefined;
10059
10130
  };
10060
10131
 
10061
10132
  interface PluginConfigMap {
@@ -10418,4 +10489,4 @@ interface WatchValues {
10418
10489
  lastValue?: string;
10419
10490
  }
10420
10491
 
10421
- export { type Client$1 as C, type DefinePlugin as D, IR as I, LegacyIR as L, OpenApi$3 as O, type PluginHandler as P, type StringCase as S, type UserConfig as U, type WatchValues as W, Plugin as a, OpenApiMetaObject as b, OpenApiOperationObject as c, OpenApiParameterObject as d, OpenApiRequestBodyObject as e, OpenApiResponseObject as f, OpenApiSchemaObject as g, Client as h, type Config$l as i };
10492
+ export { type Comments as C, type DefinePlugin as D, type ExpressionTransformer as E, type ImportExportItemObject as I, LegacyIR as L, OpenApi$3 as O, type PluginHandler as P, type StringCase as S, type UserConfig as U, type WatchValues as W, Plugin as a, type Client$1 as b, IR as c, OpenApiMetaObject as d, OpenApiOperationObject as e, OpenApiParameterObject as f, OpenApiRequestBodyObject as g, OpenApiResponseObject as h, OpenApiSchemaObject as i, Client as j, type Config$l as k, stringToTsNodes as s, tsNodeToString as t };
@@ -1,5 +1,5 @@
1
1
  import fs from 'node:fs';
2
- import ts from 'typescript';
2
+ import ts__default from 'typescript';
3
3
 
4
4
  interface EnumExtensions {
5
5
  /**
@@ -2499,6 +2499,27 @@ interface ImportExportItemObject {
2499
2499
  asType?: boolean;
2500
2500
  name: string;
2501
2501
  }
2502
+ /**
2503
+ * Print a TypeScript node to a string.
2504
+ * @param node the node to print
2505
+ * @returns string
2506
+ */
2507
+ declare function tsNodeToString({ node, unescape, }: {
2508
+ node: ts__default.Node;
2509
+ unescape?: boolean;
2510
+ }): string;
2511
+ /**
2512
+ * Convert a string to a TypeScript Node
2513
+ * @param value the string to convert.
2514
+ * @returns ts.Node
2515
+ */
2516
+ declare function stringToTsNodes(value: string): ts__default.Node;
2517
+ type CommentLines = Array<string | null | false | undefined>;
2518
+ type CommentObject = {
2519
+ jsdoc?: boolean;
2520
+ lines: CommentLines;
2521
+ };
2522
+ type Comments = CommentLines | Array<CommentObject>;
2502
2523
 
2503
2524
  type StringCase =
2504
2525
  | 'camelCase'
@@ -2588,7 +2609,7 @@ declare class TypeScriptFile {
2588
2609
  identifierCase?: StringCase;
2589
2610
  name: string;
2590
2611
  });
2591
- add(...nodes: Array<ts.Node | string>): void;
2612
+ add(...nodes: Array<ts__default.Node | string>): void;
2592
2613
  /**
2593
2614
  * Prevents a specific identifier from being created. This is useful for
2594
2615
  * transformers where we know a certain transformer won't be needed, and
@@ -2624,7 +2645,7 @@ declare class TypeScriptFile {
2624
2645
  removeNode(): void;
2625
2646
  private _setName;
2626
2647
  private _toString;
2627
- write(separator?: string, tsConfig?: ts.ParsedCommandLine | null): void;
2648
+ write(separator?: string, tsConfig?: ts__default.ParsedCommandLine | null): void;
2628
2649
  }
2629
2650
  interface EnsureUniqueIdentifierData {
2630
2651
  $ref: string;
@@ -2640,18 +2661,23 @@ interface EnsureUniqueIdentifierData {
2640
2661
  }
2641
2662
 
2642
2663
  type ObjectType<T> = Extract<T, Record<string, any>> extends never ? Record<string, any> : Extract<T, Record<string, any>>;
2664
+ type MappersType<T> = {
2665
+ boolean: T extends boolean ? (value: boolean) => Partial<ObjectType<T>> : never;
2666
+ number: T extends number ? (value: number) => Partial<ObjectType<T>> : never;
2667
+ object?: (value: Partial<ObjectType<T>>) => Partial<ObjectType<T>>;
2668
+ string: T extends string ? (value: string) => Partial<ObjectType<T>> : never;
2669
+ } extends infer U ? {
2670
+ [K in keyof U as U[K] extends never ? never : K]: U[K];
2671
+ } : never;
2672
+ type IsObjectOnly<T> = T extends Record<string, any> | undefined ? Extract<T, string | boolean | number> extends never ? true : false : false;
2643
2673
  type ValueToObject = <T extends undefined | string | boolean | number | Record<string, any>>(args: {
2644
2674
  defaultValue: ObjectType<T>;
2645
- mappers: {
2646
- boolean: T extends boolean ? (value: boolean) => Partial<ObjectType<T>> : never;
2647
- number: T extends number ? (value: number) => Partial<ObjectType<T>> : never;
2648
- object?: (value: Partial<ObjectType<T>>) => Partial<ObjectType<T>>;
2649
- string: T extends string ? (value: string) => Partial<ObjectType<T>> : never;
2650
- } extends infer U ? {
2651
- [K in keyof U as U[K] extends never ? never : K]: U[K];
2652
- } : never;
2653
2675
  value: T;
2654
- }) => ObjectType<T>;
2676
+ } & (IsObjectOnly<T> extends true ? {
2677
+ mappers?: MappersType<T>;
2678
+ } : {
2679
+ mappers: MappersType<T>;
2680
+ })) => ObjectType<T>;
2655
2681
 
2656
2682
  type Input = {
2657
2683
  /**
@@ -8214,6 +8240,13 @@ type ResolvedConfig$8 = Plugin.Name<'@hey-api/sdk'> & {
8214
8240
 
8215
8241
  type HeyApiSdkPlugin = DefinePlugin<Config$a, ResolvedConfig$8>;
8216
8242
 
8243
+ type ExpressionTransformer = ({ config, dataExpression, file, schema, }: {
8244
+ config: Omit<Config$9, 'name'>;
8245
+ dataExpression?: ts__default.Expression | string;
8246
+ file: TypeScriptFile;
8247
+ schema: IR.SchemaObject;
8248
+ }) => Array<ts__default.Expression> | undefined;
8249
+
8217
8250
  type Config$9 = Plugin.Name<'@hey-api/transformers'> & {
8218
8251
  /**
8219
8252
  * Convert long integers into BigInt values?
@@ -8240,6 +8273,10 @@ type Config$9 = Plugin.Name<'@hey-api/transformers'> & {
8240
8273
  * @default 'transformers'
8241
8274
  */
8242
8275
  output?: string;
8276
+ /**
8277
+ * Custom transforms to apply to the generated code.
8278
+ */
8279
+ transformers?: ReadonlyArray<ExpressionTransformer>;
8243
8280
  };
8244
8281
 
8245
8282
  type HeyApiTransformersPlugin = DefinePlugin<Config$9>;
@@ -9777,12 +9814,12 @@ type Api$1 = {
9777
9814
  file: TypeScriptFile;
9778
9815
  operation: IR.OperationObject;
9779
9816
  plugin: ValibotPlugin['Instance'];
9780
- }) => ts.ArrowFunction | undefined;
9817
+ }) => ts__default.ArrowFunction | undefined;
9781
9818
  createResponseValidator: (args: {
9782
9819
  file: TypeScriptFile;
9783
9820
  operation: IR.OperationObject;
9784
9821
  plugin: ValibotPlugin['Instance'];
9785
- }) => ts.ArrowFunction | undefined;
9822
+ }) => ts__default.ArrowFunction | undefined;
9786
9823
  };
9787
9824
 
9788
9825
  type Config = Plugin.Name<'zod'> & {
@@ -9798,6 +9835,23 @@ type Config = Plugin.Name<'zod'> & {
9798
9835
  * @default true
9799
9836
  */
9800
9837
  comments?: boolean;
9838
+ /**
9839
+ * Configuration for date handling in generated Zod schemas.
9840
+ *
9841
+ * Controls how date values are processed and validated using Zod's
9842
+ * date validation features.
9843
+ */
9844
+ dates?: {
9845
+ /**
9846
+ * Whether to include timezone offset information when handling dates.
9847
+ *
9848
+ * When enabled, date strings will preserve timezone information.
9849
+ * When disabled, dates will be treated as local time.
9850
+ *
9851
+ * @default false
9852
+ */
9853
+ offset?: boolean;
9854
+ };
9801
9855
  /**
9802
9856
  * Configuration for reusable schema definitions.
9803
9857
  *
@@ -9939,6 +9993,23 @@ type ResolvedConfig = Plugin.Name<'zod'> & {
9939
9993
  * @default true
9940
9994
  */
9941
9995
  comments: boolean;
9996
+ /**
9997
+ * Configuration for date handling in generated Zod schemas.
9998
+ *
9999
+ * Controls how date values are processed and validated using Zod's
10000
+ * date validation features.
10001
+ */
10002
+ dates: {
10003
+ /**
10004
+ * Whether to include timezone offset information when handling dates.
10005
+ *
10006
+ * When enabled, date strings will preserve timezone information.
10007
+ * When disabled, dates will be treated as local time.
10008
+ *
10009
+ * @default false
10010
+ */
10011
+ offset: boolean;
10012
+ };
9942
10013
  /**
9943
10014
  * Configuration for reusable schema definitions.
9944
10015
  *
@@ -10050,12 +10121,12 @@ type Api = {
10050
10121
  file: TypeScriptFile;
10051
10122
  operation: IR.OperationObject;
10052
10123
  plugin: ZodPlugin['Instance'];
10053
- }) => ts.ArrowFunction | undefined;
10124
+ }) => ts__default.ArrowFunction | undefined;
10054
10125
  createResponseValidator: (args: {
10055
10126
  file: TypeScriptFile;
10056
10127
  operation: IR.OperationObject;
10057
10128
  plugin: ZodPlugin['Instance'];
10058
- }) => ts.ArrowFunction | undefined;
10129
+ }) => ts__default.ArrowFunction | undefined;
10059
10130
  };
10060
10131
 
10061
10132
  interface PluginConfigMap {
@@ -10418,4 +10489,4 @@ interface WatchValues {
10418
10489
  lastValue?: string;
10419
10490
  }
10420
10491
 
10421
- export { type Client$1 as C, type DefinePlugin as D, IR as I, LegacyIR as L, OpenApi$3 as O, type PluginHandler as P, type StringCase as S, type UserConfig as U, type WatchValues as W, Plugin as a, OpenApiMetaObject as b, OpenApiOperationObject as c, OpenApiParameterObject as d, OpenApiRequestBodyObject as e, OpenApiResponseObject as f, OpenApiSchemaObject as g, Client as h, type Config$l as i };
10492
+ export { type Comments as C, type DefinePlugin as D, type ExpressionTransformer as E, type ImportExportItemObject as I, LegacyIR as L, OpenApi$3 as O, type PluginHandler as P, type StringCase as S, type UserConfig as U, type WatchValues as W, Plugin as a, type Client$1 as b, IR as c, OpenApiMetaObject as d, OpenApiOperationObject as e, OpenApiParameterObject as f, OpenApiRequestBodyObject as g, OpenApiResponseObject as h, OpenApiSchemaObject as i, Client as j, type Config$l as k, stringToTsNodes as s, tsNodeToString as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hey-api/openapi-ts",
3
- "version": "0.78.0",
3
+ "version": "0.78.2",
4
4
  "description": "🚀 The OpenAPI to TypeScript codegen. Generate clients, SDKs, validators, and more.",
5
5
  "homepage": "https://heyapi.dev/",
6
6
  "repository": {