@veloxts/router 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 CHANGED
@@ -1,5 +1,14 @@
1
1
  # @veloxts/router
2
2
 
3
+ ## 0.6.80
4
+
5
+ ### Patch Changes
6
+
7
+ - fix(router,client): preserve procedure type literals for query/mutation discrimination + lint fixes
8
+ - Updated dependencies
9
+ - @veloxts/core@0.6.80
10
+ - @veloxts/validation@0.6.80
11
+
3
12
  ## 0.6.79
4
13
 
5
14
  ### Patch Changes
@@ -268,7 +268,7 @@ export interface ProcedureBuilder<TInput = unknown, TOutput = unknown, TContext
268
268
  * })
269
269
  * ```
270
270
  */
271
- query(handler: ProcedureHandler<TInput, TOutput, TContext>): CompiledProcedure<TInput, TOutput, TContext>;
271
+ query(handler: ProcedureHandler<TInput, TOutput, TContext>): CompiledProcedure<TInput, TOutput, TContext, 'query'>;
272
272
  /**
273
273
  * Finalizes the procedure as a mutation (write operation)
274
274
  *
@@ -287,7 +287,7 @@ export interface ProcedureBuilder<TInput = unknown, TOutput = unknown, TContext
287
287
  * })
288
288
  * ```
289
289
  */
290
- mutation(handler: ProcedureHandler<TInput, TOutput, TContext>): CompiledProcedure<TInput, TOutput, TContext>;
290
+ mutation(handler: ProcedureHandler<TInput, TOutput, TContext>): CompiledProcedure<TInput, TOutput, TContext, 'mutation'>;
291
291
  }
292
292
  /**
293
293
  * Internal runtime state for the procedure builder
@@ -322,7 +322,7 @@ export interface BuilderRuntimeState {
322
322
  * The actual type safety is preserved through InferProcedures<T> which captures
323
323
  * the concrete types at definition time. This `any` only allows the assignment.
324
324
  */
325
- export type ProcedureDefinitions = Record<string, CompiledProcedure<any, any, any>>;
325
+ export type ProcedureDefinitions = Record<string, CompiledProcedure<any, any, any, any>>;
326
326
  /**
327
327
  * Type helper to preserve procedure types in a collection
328
328
  *
package/dist/types.d.ts CHANGED
@@ -227,10 +227,11 @@ export interface ParentResourceConfig {
227
227
  * @template TInput - The validated input type
228
228
  * @template TOutput - The handler output type
229
229
  * @template TContext - The context type
230
+ * @template TType - The procedure type literal ('query' or 'mutation')
230
231
  */
231
- export interface CompiledProcedure<TInput = unknown, TOutput = unknown, TContext extends BaseContext = BaseContext> {
232
+ export interface CompiledProcedure<TInput = unknown, TOutput = unknown, TContext extends BaseContext = BaseContext, TType extends ProcedureType = ProcedureType> {
232
233
  /** Whether this is a query or mutation */
233
- readonly type: ProcedureType;
234
+ readonly type: TType;
234
235
  /** The procedure handler function */
235
236
  readonly handler: ProcedureHandler<TInput, TOutput, TContext>;
236
237
  /** Input validation schema (if specified) */
@@ -277,7 +278,7 @@ export interface CompiledProcedure<TInput = unknown, TOutput = unknown, TContext
277
278
  *
278
279
  * NOTE: Uses `any` for variance compatibility - see ProcedureDefinitions for explanation.
279
280
  */
280
- export type ProcedureRecord = Record<string, CompiledProcedure<any, any, any>>;
281
+ export type ProcedureRecord = Record<string, CompiledProcedure<any, any, any, any>>;
281
282
  /**
282
283
  * Procedure collection with namespace
283
284
  *
@@ -295,15 +296,19 @@ export interface ProcedureCollection<TNamespace extends string = string, TProced
295
296
  /**
296
297
  * Extracts the input type from a compiled procedure
297
298
  */
298
- export type InferProcedureInput<T> = T extends CompiledProcedure<infer I, unknown, BaseContext> ? I : never;
299
+ export type InferProcedureInput<T> = T extends CompiledProcedure<infer I, unknown, BaseContext, ProcedureType> ? I : never;
299
300
  /**
300
301
  * Extracts the output type from a compiled procedure
301
302
  */
302
- export type InferProcedureOutput<T> = T extends CompiledProcedure<unknown, infer O, BaseContext> ? O : never;
303
+ export type InferProcedureOutput<T> = T extends CompiledProcedure<unknown, infer O, BaseContext, ProcedureType> ? O : never;
303
304
  /**
304
305
  * Extracts the context type from a compiled procedure
305
306
  */
306
- export type InferProcedureContext<T> = T extends CompiledProcedure<unknown, unknown, infer C> ? C : never;
307
+ export type InferProcedureContext<T> = T extends CompiledProcedure<unknown, unknown, infer C, ProcedureType> ? C : never;
308
+ /**
309
+ * Extracts the type (query/mutation) from a compiled procedure
310
+ */
311
+ export type InferProcedureType<T> = T extends CompiledProcedure<unknown, unknown, BaseContext, infer TType> ? TType : never;
307
312
  /**
308
313
  * Extracts procedure types from a collection
309
314
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veloxts/router",
3
- "version": "0.6.79",
3
+ "version": "0.6.80",
4
4
  "description": "Procedure definitions with tRPC and REST routing for VeloxTS framework",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -40,8 +40,8 @@
40
40
  "@trpc/server": "11.8.0",
41
41
  "fastify": "5.6.2",
42
42
  "zod-to-json-schema": "3.24.5",
43
- "@veloxts/core": "0.6.79",
44
- "@veloxts/validation": "0.6.79"
43
+ "@veloxts/core": "0.6.80",
44
+ "@veloxts/validation": "0.6.80"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@vitest/coverage-v8": "4.0.16",