@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 +12 -0
- package/dist/react/proxy-types.d.ts +30 -6
- package/dist/types.d.ts +14 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -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,
|
|
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
|
-
*
|
|
327
|
-
*
|
|
328
|
-
*
|
|
329
|
-
*
|
|
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
|
|
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
|
-
*
|
|
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
|
|
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
|
-
*
|
|
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
|
|
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
|
*
|