@veloxts/router 0.7.2 → 0.7.3

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +10 -2
  2. package/GUIDE.md +14 -14
  3. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -1,13 +1,21 @@
1
1
  # @veloxts/router
2
2
 
3
+ ## 0.7.3
4
+
5
+ ### Patch Changes
6
+
7
+ - feat(cli): auto-populate Zod schemas from Prisma model fields
8
+ - Updated dependencies
9
+ - @veloxts/core@0.7.3
10
+ - @veloxts/validation@0.7.3
11
+
3
12
  ## 0.7.2
4
13
 
5
14
  ### Patch Changes
6
15
 
7
- - chore(auth,core,create,cli,client,orm,mcp,router,validation,web): simplify code for clarity and maintainability
16
+ - simplify code for clarity and maintainability
8
17
  - Updated dependencies
9
18
  - @veloxts/core@0.7.2
10
- - @veloxts/validation@0.7.2
11
19
 
12
20
  ## 0.7.1
13
21
 
package/GUIDE.md CHANGED
@@ -503,7 +503,7 @@ export const userProcedures = procedures('users', {
503
503
  .input(z.object({ id: z.string().uuid() }))
504
504
  .query(async ({ input, ctx }) => {
505
505
  const user = await ctx.db.user.findUniqueOrThrow({ where: { id: input.id } });
506
- return resource(user, UserSchema).forAnonymous();
506
+ return resource(user, UserSchema.public);
507
507
  }),
508
508
 
509
509
  // Conditional projection based on ownership
@@ -514,9 +514,9 @@ export const userProcedures = procedures('users', {
514
514
  const user = await ctx.db.user.findUniqueOrThrow({ where: { id: input.id } });
515
515
  // Show more fields if viewing own profile
516
516
  if (user.id === ctx.user?.id) {
517
- return resource(user, UserSchema).forAuthenticated();
517
+ return resource(user, UserSchema.authenticated);
518
518
  }
519
- return resource(user, UserSchema).forAnonymous();
519
+ return resource(user, UserSchema.public);
520
520
  }),
521
521
 
522
522
  // Admin with explicit projection
@@ -525,7 +525,7 @@ export const userProcedures = procedures('users', {
525
525
  .input(z.object({ id: z.string().uuid() }))
526
526
  .query(async ({ input, ctx }) => {
527
527
  const user = await ctx.db.user.findUniqueOrThrow({ where: { id: input.id } });
528
- return resource(user, UserSchema).forAdmin();
528
+ return resource(user, UserSchema.admin);
529
529
  }),
530
530
  });
531
531
  ```
@@ -554,7 +554,7 @@ const listUsersManual = procedure()
554
554
  .guard(authenticated)
555
555
  .query(async ({ ctx }) => {
556
556
  const users = await ctx.db.user.findMany({ take: 50 });
557
- return resourceCollection(users, UserSchema).forAuthenticated();
557
+ return resourceCollection(users, UserSchema.authenticated);
558
558
  });
559
559
  ```
560
560
 
@@ -577,9 +577,9 @@ const getUser = procedure()
577
577
 
578
578
  | Method | Fields Included | Use Case |
579
579
  |--------|-----------------|----------|
580
- | `.forAnonymous()` | `public` only | Public APIs, unauthenticated users |
581
- | `.forAuthenticated()` | `public` + `authenticated` | Logged-in users |
582
- | `.forAdmin()` | All fields | Admin dashboards, internal tools |
580
+ | `UserSchema.public` | `public` only | Public APIs, unauthenticated users |
581
+ | `UserSchema.authenticated` | `public` + `authenticated` | Logged-in users |
582
+ | `UserSchema.admin` | All fields | Admin dashboards, internal tools |
583
583
  | `.for(ctx)` | Auto-detected from context | Dynamic access control |
584
584
 
585
585
  ### Type Safety
@@ -596,14 +596,14 @@ const getProfile = procedure()
596
596
  });
597
597
  // Return type: { id: string; name: string; email: string; createdAt: Date }
598
598
 
599
- // Manual projection - type inferred from method
600
- const result = resource(user, UserSchema).forAnonymous();
599
+ // Tagged view projection - type inferred from schema view
600
+ const result = resource(user, UserSchema.public);
601
601
  // Type: { id: string; name: string }
602
602
 
603
- const authResult = resource(user, UserSchema).forAuthenticated();
603
+ const authResult = resource(user, UserSchema.authenticated);
604
604
  // Type: { id: string; name: string; email: string; createdAt: Date }
605
605
 
606
- const adminResult = resource(user, UserSchema).forAdmin();
606
+ const adminResult = resource(user, UserSchema.admin);
607
607
  // Type: { id: string; name: string; email: string; createdAt: Date; internalNotes: string | null; lastLoginIp: string | null }
608
608
  ```
609
609
 
@@ -612,8 +612,8 @@ const adminResult = resource(user, UserSchema).forAdmin();
612
612
  | Scenario | Approach |
613
613
  |----------|----------|
614
614
  | Guard determines access level | **Automatic** (`.guardNarrow().resource()`) |
615
- | Public endpoints (no guard) | Manual (`.forAnonymous()`) |
616
- | Conditional/dynamic projection | Manual (`.forX()` in handler) |
615
+ | Public endpoints (no guard) | Tagged view (`UserSchema.public`) |
616
+ | Conditional/dynamic projection | Tagged view or `.for(ctx)` in handler |
617
617
  | Simple, declarative code | **Automatic** |
618
618
  | Complex access logic | Manual
619
619
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veloxts/router",
3
- "version": "0.7.2",
3
+ "version": "0.7.3",
4
4
  "description": "Procedure definitions with tRPC and REST routing for VeloxTS framework",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -39,8 +39,8 @@
39
39
  "dependencies": {
40
40
  "@trpc/server": "11.10.0",
41
41
  "fastify": "5.7.4",
42
- "@veloxts/validation": "0.7.2",
43
- "@veloxts/core": "0.7.2"
42
+ "@veloxts/core": "0.7.3",
43
+ "@veloxts/validation": "0.7.3"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@vitest/coverage-v8": "4.0.18",