@veloxts/client 0.6.79 → 0.6.80
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 +6 -0
- package/dist/react/proxy-types.d.ts +5 -6
- package/dist/types.d.ts +12 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -323,15 +323,14 @@ export interface VeloxMutationOptions<TOutput, TInput, TContext = unknown> exten
|
|
|
323
323
|
* Resolves a procedure to its appropriate hook interface
|
|
324
324
|
* based on whether it's a query or mutation
|
|
325
325
|
*
|
|
326
|
-
*
|
|
327
|
-
*
|
|
328
|
-
*
|
|
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.
|
|
329
330
|
*
|
|
330
331
|
* @internal
|
|
331
332
|
*/
|
|
332
|
-
type VeloxProcedureHooks<TProcedure> = TProcedure extends ClientProcedure<infer TInput, infer TOutput> ?
|
|
333
|
-
readonly type: 'mutation';
|
|
334
|
-
} ? VeloxMutationProcedure<TInput, TOutput> : VeloxQueryProcedure<TInput, TOutput> : never;
|
|
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;
|
|
335
334
|
/**
|
|
336
335
|
* Maps a procedures record to hook interfaces
|
|
337
336
|
*
|
package/dist/types.d.ts
CHANGED
|
@@ -19,12 +19,13 @@ export type ProcedureType = 'query' | 'mutation';
|
|
|
19
19
|
*
|
|
20
20
|
* @template TInput - The validated input type
|
|
21
21
|
* @template TOutput - The handler output type
|
|
22
|
+
* @template TType - The procedure type literal ('query' or 'mutation')
|
|
22
23
|
*
|
|
23
24
|
* @see {@link https://github.com/veloxts/velox-ts-framework/velox | @veloxts/router CompiledProcedure}
|
|
24
25
|
*/
|
|
25
|
-
export interface ClientProcedure<TInput = unknown, TOutput = unknown> {
|
|
26
|
+
export interface ClientProcedure<TInput = unknown, TOutput = unknown, TType extends ProcedureType = ProcedureType> {
|
|
26
27
|
/** Whether this is a query or mutation */
|
|
27
|
-
readonly type:
|
|
28
|
+
readonly type: TType;
|
|
28
29
|
/** The procedure handler function - uses `any` for ctx to enable contravariant matching with CompiledProcedure */
|
|
29
30
|
readonly handler: (args: {
|
|
30
31
|
input: TInput;
|
|
@@ -58,7 +59,7 @@ export interface ClientProcedure<TInput = unknown, TOutput = unknown> {
|
|
|
58
59
|
*
|
|
59
60
|
* NOTE: Uses `any` for variance compatibility with @veloxts/router's ProcedureRecord
|
|
60
61
|
*/
|
|
61
|
-
export type ProcedureRecord = Record<string, ClientProcedure<any, any>>;
|
|
62
|
+
export type ProcedureRecord = Record<string, ClientProcedure<any, any, any>>;
|
|
62
63
|
/**
|
|
63
64
|
* Procedure collection with namespace
|
|
64
65
|
*
|
|
@@ -80,13 +81,19 @@ export interface ProcedureCollection<TNamespace extends string = string, TProced
|
|
|
80
81
|
*
|
|
81
82
|
* Works with both ClientProcedure and @veloxts/router's CompiledProcedure
|
|
82
83
|
*/
|
|
83
|
-
export type InferProcedureInput<T> = T extends ClientProcedure<infer I, unknown> ? I : never;
|
|
84
|
+
export type InferProcedureInput<T> = T extends ClientProcedure<infer I, unknown, ProcedureType> ? I : never;
|
|
84
85
|
/**
|
|
85
86
|
* Extracts the output type from a procedure
|
|
86
87
|
*
|
|
87
88
|
* Works with both ClientProcedure and @veloxts/router's CompiledProcedure
|
|
88
89
|
*/
|
|
89
|
-
export type InferProcedureOutput<T> = T extends ClientProcedure<unknown, infer O> ? O : never;
|
|
90
|
+
export type InferProcedureOutput<T> = T extends ClientProcedure<unknown, infer O, ProcedureType> ? O : never;
|
|
91
|
+
/**
|
|
92
|
+
* Extracts the type (query/mutation) from a procedure
|
|
93
|
+
*
|
|
94
|
+
* Works with both ClientProcedure and @veloxts/router's CompiledProcedure
|
|
95
|
+
*/
|
|
96
|
+
export type InferProcedureType<T> = T extends ClientProcedure<unknown, unknown, infer TType> ? TType : never;
|
|
90
97
|
/**
|
|
91
98
|
* Builds a callable client interface from a single procedure collection
|
|
92
99
|
*
|