@veloxts/web 0.6.92 → 0.6.93

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 +11 -0
  2. package/GUIDE.md +34 -0
  3. package/package.json +9 -9
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @veloxts/web
2
2
 
3
+ ## 0.6.93
4
+
5
+ ### Patch Changes
6
+
7
+ - feat(router): add Resource API with phantom types for context-dependent outputs
8
+ - Updated dependencies
9
+ - @veloxts/auth@0.6.93
10
+ - @veloxts/client@0.6.93
11
+ - @veloxts/core@0.6.93
12
+ - @veloxts/router@0.6.93
13
+
3
14
  ## 0.6.92
4
15
 
5
16
  ### Patch Changes
package/GUIDE.md CHANGED
@@ -57,6 +57,40 @@ export const updateProfile = action()
57
57
  });
58
58
  ```
59
59
 
60
+ ### Context-Dependent Outputs with Resource API
61
+
62
+ For role-based field visibility, use the Resource API:
63
+
64
+ ```typescript
65
+ import { action } from '@veloxts/web';
66
+ import { resourceSchema, resource } from '@veloxts/router';
67
+ import { z } from 'zod';
68
+
69
+ const UserSchema = resourceSchema()
70
+ .public('id', z.string())
71
+ .public('name', z.string())
72
+ .authenticated('email', z.string())
73
+ .admin('internalNotes', z.string().nullable())
74
+ .build();
75
+
76
+ // Public action - returns { id, name } only
77
+ export const getPublicUser = action()
78
+ .input(z.object({ id: z.string() }))
79
+ .handler(async (input) => {
80
+ const user = await db.user.findUniqueOrThrow({ where: { id: input.id } });
81
+ return resource(user, UserSchema).forAnonymous();
82
+ });
83
+
84
+ // Protected action - returns { id, name, email }
85
+ export const getUser = action()
86
+ .input(z.object({ id: z.string() }))
87
+ .protected()
88
+ .handler(async (input, ctx) => {
89
+ const user = await db.user.findUniqueOrThrow({ where: { id: input.id } });
90
+ return resource(user, UserSchema).forAuthenticated();
91
+ });
92
+ ```
93
+
60
94
  Use in React components:
61
95
 
62
96
  ```tsx
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veloxts/web",
3
- "version": "0.6.92",
3
+ "version": "0.6.93",
4
4
  "description": "React Server Components integration for VeloxTS framework using Vinxi",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -72,10 +72,10 @@
72
72
  "peerDependencies": {
73
73
  "react": ">=19.2.0",
74
74
  "react-dom": ">=19.2.0",
75
- "@veloxts/auth": "0.6.92",
76
- "@veloxts/client": "0.6.92",
77
- "@veloxts/core": "0.6.92",
78
- "@veloxts/router": "0.6.92"
75
+ "@veloxts/auth": "0.6.93",
76
+ "@veloxts/client": "0.6.93",
77
+ "@veloxts/router": "0.6.93",
78
+ "@veloxts/core": "0.6.93"
79
79
  },
80
80
  "peerDependenciesMeta": {
81
81
  "@veloxts/auth": {
@@ -98,10 +98,10 @@
98
98
  "react-server-dom-webpack": "19.2.4",
99
99
  "typescript": "5.9.3",
100
100
  "vitest": "4.0.18",
101
- "@veloxts/client": "0.6.92",
102
- "@veloxts/router": "0.6.92",
103
- "@veloxts/core": "0.6.92",
104
- "@veloxts/auth": "0.6.92"
101
+ "@veloxts/auth": "0.6.93",
102
+ "@veloxts/client": "0.6.93",
103
+ "@veloxts/core": "0.6.93",
104
+ "@veloxts/router": "0.6.93"
105
105
  },
106
106
  "keywords": [
107
107
  "velox",