@zanzojs/react 0.1.0-beta.1 → 0.1.0-beta.2

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 (2) hide show
  1. package/README.md +6 -5
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -24,8 +24,8 @@ pnpm add @zanzojs/core @zanzojs/react
24
24
  When a user logs into your app, or loads a Server Component in Next.js, you calculate their entire permission graph once by providing their tuples to the `ZanzoEngine` and generating a snapshot.
25
25
 
26
26
  ```typescript
27
- import { createZanzoSnapshot } from '@zanzojs/core';
28
- import { engine } from './zanzo.config';
27
+ import { createZanzoSnapshot, ZanzoEngine } from '@zanzojs/core';
28
+ import { schema } from './zanzo.config';
29
29
  import { db, zanzoTuples } from './db';
30
30
  import { like } from 'drizzle-orm';
31
31
 
@@ -33,11 +33,12 @@ export async function getUserSnapshot(userId: string) {
33
33
  // Fetch all tuples related to this user from the DB
34
34
  const userTuples = await db.select().from(zanzoTuples).where(like(zanzoTuples.subject, `User:${userId}%`));
35
35
 
36
- // Temporarily load them into the engine
37
- engine.addTuples(userTuples);
36
+ // Create a fresh engine per request — never reuse a shared instance
37
+ const requestEngine = new ZanzoEngine(schema);
38
+ requestEngine.addTuples(userTuples);
38
39
 
39
40
  // Extract a flattened JSON dictionary
40
- return createZanzoSnapshot(engine, `User:${userId}`);
41
+ return createZanzoSnapshot(requestEngine, `User:${userId}`);
41
42
  }
42
43
  ```
43
44
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zanzojs/react",
3
- "version": "0.1.0-beta.1",
3
+ "version": "0.1.0-beta.2",
4
4
  "description": "React bindings for Zanzo ReBAC. O(1) permission checks via ZanzoProvider and useZanzo hook.",
5
5
  "keywords": [
6
6
  "@zanzojs/core",
@@ -52,7 +52,7 @@
52
52
  "tsup": "latest",
53
53
  "typescript": "^5.7.2",
54
54
  "vitest": "latest",
55
- "@zanzojs/core": "0.1.0-beta.1"
55
+ "@zanzojs/core": "0.1.0-beta.2"
56
56
  },
57
57
  "scripts": {
58
58
  "build": "tsup",