@zanzojs/drizzle 0.1.0-beta.1 → 0.1.0

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 +30 -0
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -70,6 +70,36 @@ The SQL adapter prioritizes extreme read performance. As a trade-off, it relies
70
70
 
71
71
  To make this work, **you must use `@zanzojs/core`'s `expandTuples()` function when writing to the database.** If you skip `expandTuples()` during mutations, deep permission paths will not resolve correctly during Drizzle queries.
72
72
 
73
+ ```typescript
74
+ import { expandTuples } from '@zanzojs/core';
75
+
76
+ async function grantAccess(userId: string, projectId: string) {
77
+ const baseTuple = {
78
+ subject: `User:${userId}`,
79
+ relation: 'owner',
80
+ object: `Project:${projectId}`,
81
+ };
82
+
83
+ const derived = await expandTuples({
84
+ schema: engine.getSchema(),
85
+ newTuple: baseTuple,
86
+ fetchChildren: async (parentObject, relation) => {
87
+ // Return child object IDs linked to parentObject via relation
88
+ const rows = await db.select({ subject: zanzoTuples.subject })
89
+ .from(zanzoTuples)
90
+ .where(and(
91
+ eq(zanzoTuples.subject, parentObject),
92
+ eq(zanzoTuples.relation, relation),
93
+ ));
94
+ return rows.map(r => r.object);
95
+ },
96
+ });
97
+
98
+ // Insert base tuple + all derived tuples atomically
99
+ await db.insert(zanzoTuples).values([baseTuple, ...derived]);
100
+ }
101
+ ```
102
+
73
103
  ## Documentation
74
104
 
75
105
  For full architecture details, refer to the [ZanzoJS Monorepo](https://github.com/GonzaloJeria/zanzo).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zanzojs/drizzle",
3
- "version": "0.1.0-beta.1",
3
+ "version": "0.1.0",
4
4
  "description": "Drizzle ORM adapter for Zanzo ReBAC. Zero-config Zanzibar Tuple Pattern with parameterized SQL.",
5
5
  "keywords": [
6
6
  "@zanzojs/core",
@@ -46,7 +46,7 @@
46
46
  "typescript": "^5.7.2",
47
47
  "tsup": "latest",
48
48
  "vitest": "latest",
49
- "@zanzojs/core": "0.1.0-beta.1"
49
+ "@zanzojs/core": "0.1.0"
50
50
  },
51
51
  "scripts": {
52
52
  "build": "tsup",