@hey-api/openapi-ts 0.92.3 → 0.92.4

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.
@@ -53,10 +53,11 @@ export const createClient = (config: Config = {}): Client => {
53
53
  >();
54
54
 
55
55
  const requestOptions = <
56
+ TData = unknown,
56
57
  ThrowOnError extends boolean = false,
57
58
  TResponseStyle extends ResponseStyle = 'fields',
58
59
  >(
59
- options: RequestOptions<unknown, TResponseStyle, ThrowOnError>,
60
+ options: RequestOptions<TData, TResponseStyle, ThrowOnError>,
60
61
  ) => {
61
62
  const opts = {
62
63
  ..._config,
@@ -170,11 +170,12 @@ type RequestFn = <
170
170
  ) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
171
171
 
172
172
  type RequestOptionsFn = <
173
+ T,
173
174
  ThrowOnError extends boolean = false,
174
175
  TResponseStyle extends ResponseStyle = 'fields',
175
176
  >(
176
- options: RequestOptions<unknown, TResponseStyle, ThrowOnError>,
177
- ) => HttpRequest<unknown>;
177
+ options: RequestOptions<T, TResponseStyle, ThrowOnError>,
178
+ ) => HttpRequest<T>;
178
179
 
179
180
  type BuildUrlFn = <
180
181
  TData extends {
@@ -1,5 +1,5 @@
1
1
  import { useAsyncData, useFetch, useLazyAsyncData, useLazyFetch } from 'nuxt/app';
2
- import { reactive, ref, watch } from 'vue';
2
+ import { reactive, ref, toValue, watch } from 'vue';
3
3
 
4
4
  import { createSseClient } from '../core/serverSentEvents';
5
5
  import type { HttpMethod } from '../core/types';
@@ -136,14 +136,14 @@ export const createClient = (config: Config = {}): Client => {
136
136
  body: opts.body,
137
137
  bodySerializer: opts.bodySerializer,
138
138
  });
139
- const body = ref(serializeBody(opts));
139
+ const body = ref(serializeBody({ ...opts, body: toValue(opts.body) }));
140
140
  opts.body = body;
141
141
  watch(bodyParams, (changed) => {
142
142
  body.value = serializeBody(changed);
143
143
  });
144
144
  return composable === 'useLazyFetch'
145
- ? useLazyFetch(() => buildUrl(opts), opts)
146
- : useFetch(() => buildUrl(opts), opts);
145
+ ? useLazyFetch(() => buildUrl(opts), { ...opts, ...asyncDataOptions })
146
+ : useFetch(() => buildUrl(opts), { ...opts, ...asyncDataOptions });
147
147
  }
148
148
 
149
149
  const handler: any = () =>
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { n as UserConfig } from "./types-Ba27ofyy.mjs";
2
2
  import * as _hey_api_codegen_core0 from "@hey-api/codegen-core";
3
3
  import { AnalysisContext, BindingKind, ExportModule, File, FromRef, ImportModule, Language, Logger, Logger as Logger$1, Node, NodeName, NodeNameSanitizer, NodeRelationship, NodeScope, Ref, Refs, RenderContext, Renderer, Symbol, SymbolMeta } from "@hey-api/codegen-core";
4
- import { Casing, Context, DefinePlugin, DefinePlugin as DefinePlugin$1, FeatureToggle, IR, IR as IR$1, LinguistLanguages, NameTransformer, NamingConfig, NamingOptions, NamingRule, OpenApi, OpenApiMetaObject, OpenApiOperationObject, OpenApiParameterObject, OpenApiRequestBodyObject, OpenApiResponseObject, OpenApiSchemaObject, OpenApiV2_0_XTypes, OpenApiV3_0_XTypes, OpenApiV3_1_XTypes, OperationPath, OperationPathStrategy, OperationStrategy, OperationsStrategy, Plugin, Plugin as Plugin$1, SchemaWithType, defaultPaginationKeywords, definePluginConfig, utils } from "@hey-api/shared";
4
+ import { Casing, Context, DefinePlugin, DefinePlugin as DefinePlugin$1, FeatureToggle, IR, IR as IR$1, LinguistLanguages, NameTransformer, NamingConfig, NamingOptions, NamingRule, OpenApi, OpenApiMetaObject, OpenApiOperationObject, OpenApiParameterObject, OpenApiRequestBodyObject, OpenApiResponseObject, OpenApiSchemaObject, OpenApiV2_0_XTypes, OpenApiV3_0_XTypes, OpenApiV3_1_XTypes, OperationPath, OperationPathStrategy, OperationStrategy, OperationsStrategy, Plugin, Plugin as Plugin$1, SchemaExtractor, SchemaProcessorContext, SchemaWithType, defaultPaginationKeywords, definePluginConfig, utils } from "@hey-api/shared";
5
5
  import ts from "typescript";
6
6
  import { AnyString, LazyOrAsync, MaybeArray, MaybeFunc } from "@hey-api/types";
7
7
  import { HttpClient, HttpErrorResponse, HttpHeaders, HttpRequest, HttpResponse } from "@angular/common/http";
@@ -2620,7 +2620,7 @@ interface ClientOptions$5 {
2620
2620
  type MethodFn$5 = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle$2 = 'fields'>(options: Omit<RequestOptions$5<TData, TResponseStyle, ThrowOnError>, 'method'>) => RequestResult$5<TData, TError, ThrowOnError, TResponseStyle>;
2621
2621
  type SseFn$5 = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle$2 = 'fields'>(options: Omit<RequestOptions$5<TData, TResponseStyle, ThrowOnError>, 'method'>) => Promise<ServerSentEventsResult<TData, TError>>;
2622
2622
  type RequestFn$5 = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle$2 = 'fields'>(options: Omit<RequestOptions$5<TData, TResponseStyle, ThrowOnError>, 'method'> & Pick<Required<RequestOptions$5<TData, TResponseStyle, ThrowOnError>>, 'method'>) => RequestResult$5<TData, TError, ThrowOnError, TResponseStyle>;
2623
- type RequestOptionsFn = <ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle$2 = 'fields'>(options: RequestOptions$5<unknown, TResponseStyle, ThrowOnError>) => HttpRequest<unknown>;
2623
+ type RequestOptionsFn = <T, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle$2 = 'fields'>(options: RequestOptions$5<T, TResponseStyle, ThrowOnError>) => HttpRequest<T>;
2624
2624
  type BuildUrlFn$5 = <TData extends {
2625
2625
  body?: unknown;
2626
2626
  path?: Record<string, unknown>;
@@ -3919,20 +3919,25 @@ type Config$11 = Plugin$1.Name<'@hey-api/transformers'> & Plugin$1.Hooks & Plugi
3919
3919
  type HeyApiTransformersPlugin = DefinePlugin$1<UserConfig$13, Config$11>;
3920
3920
  //#endregion
3921
3921
  //#region src/plugins/@hey-api/typescript/shared/types.d.ts
3922
- type IrSchemaToAstOptions = {
3922
+ type IrSchemaToAstOptions$1 = {
3923
+ /** The plugin instance. */
3923
3924
  plugin: HeyApiTypeScriptPlugin['Instance'];
3925
+ /** Optional schema extractor function. */
3926
+ schemaExtractor?: SchemaExtractor;
3927
+ /** The plugin state references. */
3924
3928
  state: Refs<PluginState$2>;
3925
3929
  };
3926
3930
  type PluginState$2 = Pick<Required<SymbolMeta>, 'path'> & Pick<Partial<SymbolMeta>, 'tags'>;
3927
3931
  //#endregion
3928
3932
  //#region src/plugins/@hey-api/typescript/v1/plugin.d.ts
3929
- declare const irSchemaToAst: ({
3933
+ declare function irSchemaToAst({
3930
3934
  plugin,
3931
3935
  schema,
3936
+ schemaExtractor,
3932
3937
  state
3933
- }: IrSchemaToAstOptions & {
3938
+ }: IrSchemaToAstOptions$1 & {
3934
3939
  schema: IR$1.SchemaObject;
3935
- }) => MaybeTsDsl<TypeTsDsl>;
3940
+ }): MaybeTsDsl<TypeTsDsl>;
3936
3941
  //#endregion
3937
3942
  //#region src/plugins/@hey-api/typescript/api.d.ts
3938
3943
  type IApi$3 = {
@@ -7393,12 +7398,26 @@ interface PipesUtils {
7393
7398
  toNode: PipesToNode;
7394
7399
  }
7395
7400
  //#endregion
7401
+ //#region src/plugins/valibot/shared/processor.d.ts
7402
+ type ProcessorContext = Pick<IrSchemaToAstOptions, 'plugin'> & SchemaProcessorContext & {
7403
+ naming: NamingConfig;
7404
+ schema: IR$1.SchemaObject;
7405
+ };
7406
+ //#endregion
7396
7407
  //#region src/plugins/valibot/shared/types.d.ts
7397
7408
  type Ast$1 = {
7398
7409
  hasLazyExpression?: boolean;
7399
7410
  pipes: Pipes;
7400
7411
  typeName?: string | ts.Identifier;
7401
7412
  };
7413
+ type IrSchemaToAstOptions = {
7414
+ /** The plugin instance. */
7415
+ plugin: ValibotPlugin['Instance'];
7416
+ /** Optional schema extractor function. */
7417
+ schemaExtractor?: SchemaExtractor<ProcessorContext>;
7418
+ /** The plugin state references. */
7419
+ state: Refs<PluginState$1>;
7420
+ };
7402
7421
  type PluginState$1 = Pick<Required<SymbolMeta>, 'path'> & Pick<Partial<SymbolMeta>, 'tags'> & {
7403
7422
  hasLazyExpression: boolean;
7404
7423
  };
@@ -7486,7 +7505,7 @@ type Resolvers$1 = Plugin$1.Resolvers<{
7486
7505
  };
7487
7506
  }>;
7488
7507
  type ValidatorResolver$1 = (ctx: ValidatorResolverContext$1) => PipeResult | null | undefined;
7489
- interface BaseContext$1 extends DollarTsDsl {
7508
+ type BaseContext$1 = DollarTsDsl & Pick<IrSchemaToAstOptions, 'plugin' | 'schemaExtractor'> & {
7490
7509
  /**
7491
7510
  * Functions for working with pipes.
7492
7511
  */
@@ -7502,17 +7521,13 @@ interface BaseContext$1 extends DollarTsDsl {
7502
7521
  */
7503
7522
  current: Pipes;
7504
7523
  };
7505
- /**
7506
- * The plugin instance.
7507
- */
7508
- plugin: ValibotPlugin['Instance'];
7509
7524
  /**
7510
7525
  * Provides access to commonly used symbols within the plugin.
7511
7526
  */
7512
7527
  symbols: {
7513
7528
  v: Symbol;
7514
7529
  };
7515
- }
7530
+ };
7516
7531
  interface EnumResolverContext$1 extends BaseContext$1 {
7517
7532
  /**
7518
7533
  * Nodes used to build different parts of the enum schema.
@@ -7633,6 +7648,8 @@ type UserConfig$2 = Plugin$1.Name<'valibot'> & Plugin$1.Hooks & Plugin$1.UserCom
7633
7648
  * - `boolean`: Shorthand for `{ enabled: boolean }`
7634
7649
  * - `string` or `function`: Shorthand for `{ name: string | function }`
7635
7650
  * - `object`: Full configuration object
7651
+ *
7652
+ * @default true
7636
7653
  */
7637
7654
  definitions?: boolean | NameTransformer | {
7638
7655
  /**
@@ -7672,6 +7689,8 @@ type UserConfig$2 = Plugin$1.Name<'valibot'> & Plugin$1.Hooks & Plugin$1.UserCom
7672
7689
  * - `boolean`: Shorthand for `{ enabled: boolean }`
7673
7690
  * - `string` or `function`: Shorthand for `{ name: string | function }`
7674
7691
  * - `object`: Full configuration object
7692
+ *
7693
+ * @default true
7675
7694
  */
7676
7695
  requests?: boolean | NameTransformer | {
7677
7696
  /**
@@ -7703,6 +7722,8 @@ type UserConfig$2 = Plugin$1.Name<'valibot'> & Plugin$1.Hooks & Plugin$1.UserCom
7703
7722
  * - `boolean`: Shorthand for `{ enabled: boolean }`
7704
7723
  * - `string` or `function`: Shorthand for `{ name: string | function }`
7705
7724
  * - `object`: Full configuration object
7725
+ *
7726
+ * @default true
7706
7727
  */
7707
7728
  responses?: boolean | NameTransformer | {
7708
7729
  /**
@@ -7758,44 +7779,17 @@ type UserConfig$2 = Plugin$1.Name<'valibot'> & Plugin$1.Hooks & Plugin$1.UserCom
7758
7779
  };
7759
7780
  };
7760
7781
  type Config$1 = Plugin$1.Name<'valibot'> & Plugin$1.Hooks & Plugin$1.Comments & Plugin$1.Exports & Resolvers$1 & {
7761
- /**
7762
- * Casing convention for generated names.
7763
- */
7782
+ /** Casing convention for generated names. */
7764
7783
  case: Casing;
7765
- /**
7766
- * Configuration for reusable schema definitions.
7767
- *
7768
- * Controls generation of shared Valibot schemas that can be referenced
7769
- * across requests and responses.
7770
- */
7784
+ /** Configuration for reusable schema definitions. */
7771
7785
  definitions: NamingOptions & FeatureToggle;
7772
- /**
7773
- * Enable Valibot metadata support? It's often useful to associate a schema
7774
- * with some additional metadata for documentation, code generation, AI
7775
- * structured outputs, form validation, and other purposes.
7776
- *
7777
- * @default false
7778
- */
7786
+ /** Enable Valibot metadata support? */
7779
7787
  metadata: boolean;
7780
- /**
7781
- * Configuration for request-specific Valibot schemas.
7782
- *
7783
- * Controls generation of Valibot schemas for request bodies, query
7784
- * parameters, path parameters, and headers.
7785
- */
7788
+ /** Configuration for request-specific Valibot schemas. */
7786
7789
  requests: NamingOptions & FeatureToggle;
7787
- /**
7788
- * Configuration for response-specific Valibot schemas.
7789
- *
7790
- * Controls generation of Valibot schemas for response bodies, error
7791
- * responses, and status codes.
7792
- */
7790
+ /** Configuration for response-specific Valibot schemas. */
7793
7791
  responses: NamingOptions & FeatureToggle;
7794
- /**
7795
- * Configuration for webhook-specific Valibot schemas.
7796
- *
7797
- * Controls generation of Valibot schemas for webhook payloads.
7798
- */
7792
+ /** Configuration for webhook-specific Valibot schemas. */
7799
7793
  webhooks: NamingOptions & FeatureToggle;
7800
7794
  };
7801
7795
  type ValibotPlugin = DefinePlugin$1<UserConfig$2, Config$1, IApi$1>;
@@ -7809,6 +7803,13 @@ type Ast = {
7809
7803
  type PluginState = Pick<Required<SymbolMeta>, 'path'> & Pick<Partial<SymbolMeta>, 'tags'> & {
7810
7804
  hasLazyExpression: boolean;
7811
7805
  };
7806
+ type TypeOptions = {
7807
+ /** Configuration for TypeScript type generation from Zod schemas. */
7808
+ types: {
7809
+ /** Configuration for `infer` types. */
7810
+ infer: NamingOptions & FeatureToggle;
7811
+ };
7812
+ };
7812
7813
  type ValidatorArgs = {
7813
7814
  operation: IR$1.OperationObject;
7814
7815
  plugin: ZodPlugin['Instance'];
@@ -8387,146 +8388,35 @@ type UserConfig$1 = Plugin$1.Name<'zod'> & Plugin$1.Hooks & Plugin$1.UserComment
8387
8388
  };
8388
8389
  };
8389
8390
  type Config = Plugin$1.Name<'zod'> & Plugin$1.Hooks & Plugin$1.Comments & Plugin$1.Exports & Resolvers & {
8390
- /**
8391
- * Casing convention for generated names.
8392
- */
8391
+ /** Casing convention for generated names. */
8393
8392
  case: Casing;
8394
- /**
8395
- * The compatibility version to target for generated output.
8396
- *
8397
- * Can be:
8398
- * - `4`: [Zod 4](https://zod.dev/packages/zod) (default).
8399
- * - `3`: [Zod 3](https://v3.zod.dev/).
8400
- * - `'mini'`: [Zod Mini](https://zod.dev/packages/mini).
8401
- *
8402
- * @default 4
8403
- */
8393
+ /** The compatibility version to target for generated output. */
8404
8394
  compatibilityVersion: 3 | 4 | 'mini';
8405
- /**
8406
- * Configuration for date handling in generated Zod schemas.
8407
- *
8408
- * Controls how date values are processed and validated using Zod's
8409
- * date validation features.
8410
- */
8395
+ /** Configuration for date handling in generated Zod schemas. */
8411
8396
  dates: {
8412
- /**
8413
- * Whether to allow unqualified (timezone-less) datetimes:
8414
- *
8415
- * When enabled, Zod will accept datetime strings without timezone information.
8416
- * When disabled, Zod will require timezone information in datetime strings.
8417
- *
8418
- * @default false
8419
- */
8397
+ /** Whether to allow unqualified (timezone-less) datetimes. */
8420
8398
  local: boolean;
8421
- /**
8422
- * Whether to include timezone offset information when handling dates.
8423
- *
8424
- * When enabled, date strings will preserve timezone information.
8425
- * When disabled, dates will be treated as local time.
8426
- *
8427
- * @default false
8428
- */
8399
+ /** Whether to include timezone offset information when handling dates. */
8429
8400
  offset: boolean;
8430
8401
  };
8431
- /**
8432
- * Configuration for reusable schema definitions.
8433
- *
8434
- * Controls generation of shared Zod schemas that can be referenced across
8435
- * requests and responses.
8436
- */
8437
- definitions: NamingOptions & FeatureToggle & {
8438
- /**
8439
- * Configuration for TypeScript type generation from Zod schemas.
8440
- *
8441
- * Controls generation of TypeScript types based on the generated Zod schemas.
8442
- */
8443
- types: {
8444
- /**
8445
- * Configuration for `infer` types.
8446
- */
8447
- infer: NamingOptions & FeatureToggle;
8448
- };
8449
- };
8450
- /**
8451
- * Enable Zod metadata support? It's often useful to associate a schema with
8452
- * some additional metadata for documentation, code generation, AI
8453
- * structured outputs, form validation, and other purposes.
8454
- *
8455
- * @default false
8456
- */
8402
+ /** Configuration for reusable schema definitions. */
8403
+ definitions: NamingOptions & FeatureToggle & TypeOptions;
8404
+ /** Enable Zod metadata support? */
8457
8405
  metadata: boolean;
8458
- /**
8459
- * Configuration for request-specific Zod schemas.
8460
- *
8461
- * Controls generation of Zod schemas for request bodies, query parameters, path
8462
- * parameters, and headers.
8463
- */
8464
- requests: NamingOptions & FeatureToggle & {
8465
- /**
8466
- * Configuration for TypeScript type generation from Zod schemas.
8467
- *
8468
- * Controls generation of TypeScript types based on the generated Zod schemas.
8469
- */
8470
- types: {
8471
- /**
8472
- * Configuration for `infer` types.
8473
- */
8474
- infer: NamingOptions & FeatureToggle;
8475
- };
8476
- };
8477
- /**
8478
- * Configuration for response-specific Zod schemas.
8479
- *
8480
- * Controls generation of Zod schemas for response bodies, error responses,
8481
- * and status codes.
8482
- */
8483
- responses: NamingOptions & FeatureToggle & {
8484
- /**
8485
- * Configuration for TypeScript type generation from Zod schemas.
8486
- *
8487
- * Controls generation of TypeScript types based on the generated Zod schemas.
8488
- */
8489
- types: {
8490
- /**
8491
- * Configuration for `infer` types.
8492
- */
8493
- infer: NamingOptions & FeatureToggle;
8494
- };
8495
- };
8496
- /**
8497
- * Configuration for TypeScript type generation from Zod schemas.
8498
- *
8499
- * Controls generation of TypeScript types based on the generated Zod schemas.
8500
- */
8406
+ /** Configuration for request-specific Zod schemas. */
8407
+ requests: NamingOptions & FeatureToggle & TypeOptions;
8408
+ /** Configuration for response-specific Zod schemas. */
8409
+ responses: NamingOptions & FeatureToggle & TypeOptions;
8410
+ /** Configuration for TypeScript type generation from Zod schemas. */
8501
8411
  types: {
8502
- /**
8503
- * Configuration for `infer` types.
8504
- */
8412
+ /** Configuration for `infer` types. */
8505
8413
  infer: FeatureToggle & {
8506
- /**
8507
- * Casing convention for generated names.
8508
- */
8414
+ /** Casing convention for generated names. */
8509
8415
  case: Casing;
8510
8416
  };
8511
8417
  };
8512
- /**
8513
- * Configuration for webhook-specific Zod schemas.
8514
- *
8515
- * Controls generation of Zod schemas for webhook payloads.
8516
- */
8517
- webhooks: NamingOptions & FeatureToggle & {
8518
- /**
8519
- * Configuration for TypeScript type generation from Zod schemas.
8520
- *
8521
- * Controls generation of TypeScript types based on the generated Zod schemas.
8522
- */
8523
- types: {
8524
- /**
8525
- * Configuration for `infer` types.
8526
- */
8527
- infer: NamingOptions & FeatureToggle;
8528
- };
8529
- };
8418
+ /** Configuration for webhook-specific Zod schemas. */
8419
+ webhooks: NamingOptions & FeatureToggle & TypeOptions;
8530
8420
  };
8531
8421
  type ZodPlugin = DefinePlugin$1<UserConfig$1, Config, IApi>;
8532
8422
  //#endregion