@veloxts/client 0.6.101 → 0.6.103

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @veloxts/client
2
2
 
3
+ ## 0.6.103
4
+
5
+ ### Patch Changes
6
+
7
+ - chore(deps): upgrade Zod from v3 to v4
8
+
9
+ ## 0.6.102
10
+
11
+ ### Patch Changes
12
+
13
+ - chore: upgrade fastify to 5.7.4 across all packages
14
+
3
15
  ## 0.6.101
4
16
 
5
17
  ### Patch Changes
@@ -7,7 +7,7 @@
7
7
  * @module @veloxts/client/react/proxy-types
8
8
  */
9
9
  import type { QueryClient, UseMutationOptions, UseMutationResult, UseQueryOptions, UseQueryResult, UseSuspenseQueryOptions, UseSuspenseQueryResult } from '@tanstack/react-query';
10
- import type { ClientFromRouter, ClientProcedure, ProcedureCollection, ProcedureRecord, RouteMap } from '../types.js';
10
+ import type { ClientFromRouter, ProcedureCollection, ProcedureRecord, RouteMap } from '../types.js';
11
11
  import type { VeloxQueryKey } from './types.js';
12
12
  /**
13
13
  * Hook methods available for query procedures
@@ -319,18 +319,42 @@ export interface VeloxMutationOptions<TOutput, TInput, TContext = unknown> exten
319
319
  */
320
320
  autoInvalidate?: boolean | AutoInvalidationConfig;
321
321
  }
322
+ /**
323
+ * Extracts the input type from a procedure's inputSchema.parse return type
324
+ * Falls back to `void` when no input schema is defined (allows omitting the argument).
325
+ * @internal
326
+ */
327
+ type ExtractInput<T> = T extends {
328
+ readonly inputSchema: {
329
+ parse: (x: unknown) => infer I;
330
+ };
331
+ } ? I : undefined;
332
+ /**
333
+ * Extracts the output type from a procedure's outputSchema.parse return type
334
+ * Falls back to the handler's return type when no output schema is defined.
335
+ * @internal
336
+ */
337
+ type ExtractOutput<T> = T extends {
338
+ readonly outputSchema: {
339
+ parse: (x: unknown) => infer O;
340
+ };
341
+ } ? O : T extends {
342
+ readonly handler: (...args: never[]) => infer R;
343
+ } ? Awaited<R> : unknown;
322
344
  /**
323
345
  * Resolves a procedure to its appropriate hook interface
324
346
  * based on whether it's a query or mutation
325
347
  *
326
- * With the TType generic parameter preserved through the procedure builder chain,
327
- * we can now properly discriminate between query and mutation types.
328
- * The ClientProcedure<TInput, TOutput, TType> captures the literal 'query' or 'mutation'
329
- * type, enabling accurate type resolution.
348
+ * Uses direct property access to extract types from the procedure,
349
+ * which is more reliable than structural inference via
350
+ * `extends ClientProcedure<infer I, infer O, infer T>` when working
351
+ * with complex types like CompiledProcedure that have many fields.
330
352
  *
331
353
  * @internal
332
354
  */
333
- type VeloxProcedureHooks<TProcedure> = TProcedure extends ClientProcedure<infer TInput, infer TOutput, infer TType> ? TType extends 'mutation' ? VeloxMutationProcedure<TInput, TOutput> : TType extends 'query' ? VeloxQueryProcedure<TInput, TOutput> : VeloxQueryProcedure<TInput, TOutput> : never;
355
+ type VeloxProcedureHooks<TProcedure> = TProcedure extends {
356
+ readonly type: infer TType;
357
+ } ? TType extends 'mutation' ? VeloxMutationProcedure<ExtractInput<TProcedure>, ExtractOutput<TProcedure>> : VeloxQueryProcedure<ExtractInput<TProcedure>, ExtractOutput<TProcedure>> : never;
334
358
  /**
335
359
  * Maps a procedures record to hook interfaces
336
360
  *
package/dist/types.d.ts CHANGED
@@ -79,15 +79,25 @@ export interface ProcedureCollection<TNamespace extends string = string, TProced
79
79
  /**
80
80
  * Extracts the input type from a procedure
81
81
  *
82
- * Works with both ClientProcedure and @veloxts/router's CompiledProcedure
82
+ * Uses direct property access on inputSchema for reliable inference
83
+ * with both ClientProcedure and @veloxts/router's CompiledProcedure.
83
84
  */
84
- export type InferProcedureInput<T> = T extends ClientProcedure<infer I, unknown, ProcedureType> ? I : never;
85
+ export type InferProcedureInput<T> = T extends {
86
+ readonly inputSchema: {
87
+ parse: (x: unknown) => infer I;
88
+ };
89
+ } ? I : undefined;
85
90
  /**
86
91
  * Extracts the output type from a procedure
87
92
  *
88
- * Works with both ClientProcedure and @veloxts/router's CompiledProcedure
93
+ * Uses direct property access on outputSchema for reliable inference
94
+ * with both ClientProcedure and @veloxts/router's CompiledProcedure.
89
95
  */
90
- export type InferProcedureOutput<T> = T extends ClientProcedure<unknown, infer O, ProcedureType> ? O : never;
96
+ export type InferProcedureOutput<T> = T extends {
97
+ readonly outputSchema: {
98
+ parse: (x: unknown) => infer O;
99
+ };
100
+ } ? O : unknown;
91
101
  /**
92
102
  * Extracts the type (query/mutation) from a procedure
93
103
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veloxts/client",
3
- "version": "0.6.101",
3
+ "version": "0.6.103",
4
4
  "description": "Type-safe frontend API client for VeloxTS framework",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",