@sequenceholdings/orm 2.1.1 → 2.2.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.
- package/README.md +3 -1
- package/dist/authoring.cjs +284 -99
- package/dist/authoring.cjs.map +1 -1
- package/dist/authoring.d.cts +31 -8
- package/dist/authoring.d.ts +31 -8
- package/dist/authoring.js +282 -100
- package/dist/authoring.js.map +1 -1
- package/dist/canonical.cjs +51 -3
- package/dist/canonical.cjs.map +1 -1
- package/dist/canonical.d.cts +838 -12
- package/dist/canonical.d.ts +838 -12
- package/dist/canonical.js +47 -4
- package/dist/canonical.js.map +1 -1
- package/dist/cli.cjs +5838 -4197
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +5838 -4197
- package/dist/cli.js.map +1 -1
- package/dist/client.cjs +49 -32
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +49 -6
- package/dist/client.d.ts +49 -6
- package/dist/client.js +49 -32
- package/dist/client.js.map +1 -1
- package/dist/compiler.cjs +1237 -263
- package/dist/compiler.cjs.map +1 -1
- package/dist/compiler.d.cts +57 -3
- package/dist/compiler.d.ts +57 -3
- package/dist/compiler.js +1230 -264
- package/dist/compiler.js.map +1 -1
- package/dist/{constants-YoFGjIBM.d.cts → constants-C6EG6Wq7.d.cts} +1 -1
- package/dist/{constants-YoFGjIBM.d.ts → constants-C6EG6Wq7.d.ts} +1 -1
- package/dist/definition-DjfC7Lll.d.cts +91 -0
- package/dist/definition-DjfC7Lll.d.ts +91 -0
- package/dist/dynamic-input.cjs +2 -1
- package/dist/dynamic-input.cjs.map +1 -1
- package/dist/dynamic-input.d.cts +9 -2
- package/dist/dynamic-input.d.ts +9 -2
- package/dist/dynamic-input.js +2 -1
- package/dist/dynamic-input.js.map +1 -1
- package/dist/index.cjs +1094 -321
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +479 -19
- package/dist/index.d.ts +479 -19
- package/dist/index.js +1083 -322
- package/dist/index.js.map +1 -1
- package/dist/ir.cjs +84 -10
- package/dist/ir.cjs.map +1 -1
- package/dist/ir.d.cts +138 -13
- package/dist/ir.d.ts +138 -13
- package/dist/ir.js +81 -11
- package/dist/ir.js.map +1 -1
- package/dist/predicate-v2.cjs +78 -9
- package/dist/predicate-v2.cjs.map +1 -1
- package/dist/predicate-v2.d.cts +1 -1
- package/dist/predicate-v2.d.ts +1 -1
- package/dist/predicate-v2.js +78 -9
- package/dist/predicate-v2.js.map +1 -1
- package/dist/sdl.cjs +156 -21
- package/dist/sdl.cjs.map +1 -1
- package/dist/sdl.d.cts +8 -1
- package/dist/sdl.d.ts +8 -1
- package/dist/sdl.js +156 -21
- package/dist/sdl.js.map +1 -1
- package/package.json +5 -4
- package/src/codegen-gql/server-fns.cjs +2 -2
- package/templates/orm-namespace/AGENTS.md +10 -0
- package/templates/orm-namespace/CLAUDE.md +1 -84
- package/templates/orm-namespace/package.json +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sequenceholdings/orm",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Sequence ORM v2 — TypeScript-defined governed tables and persisted GraphQL operations",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|
|
@@ -90,13 +90,14 @@
|
|
|
90
90
|
"README.md"
|
|
91
91
|
],
|
|
92
92
|
"dependencies": {
|
|
93
|
-
"
|
|
94
|
-
"jiti": "^2.4.2",
|
|
93
|
+
"@supabase/pg-parser": "0.1.7",
|
|
95
94
|
"drizzle-kit": "^0.31.9",
|
|
96
95
|
"drizzle-orm": "^0.45.2",
|
|
96
|
+
"graphql": "^16.11.0",
|
|
97
|
+
"jiti": "^2.4.2",
|
|
97
98
|
"js-yaml": "^4.3.2",
|
|
98
99
|
"zod": "^4.1.13",
|
|
99
|
-
"@sequenceholdings/custom-roles-manifest": "0.
|
|
100
|
+
"@sequenceholdings/custom-roles-manifest": "0.2.0"
|
|
100
101
|
},
|
|
101
102
|
"devDependencies": {
|
|
102
103
|
"@types/js-yaml": "^4.0.9",
|
|
@@ -45,8 +45,8 @@ export async function db${operationName}Full(variables: ${operationName}QueryVar
|
|
|
45
45
|
return result;
|
|
46
46
|
}`;
|
|
47
47
|
} else if (type === 'mutation') {
|
|
48
|
-
return `export async function db${operationName}(variables: ${operationName}MutationVariables) {
|
|
49
|
-
const result = await executeOperation({ op: '${name}', variables });
|
|
48
|
+
return `export async function db${operationName}(variables: ${operationName}MutationVariables, options: { idempotencyKey?: string } = {}) {
|
|
49
|
+
const result = await executeOperation({ op: '${name}', variables, ...options });
|
|
50
50
|
|
|
51
51
|
return result.${resultField};
|
|
52
52
|
}`;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Sequence development
|
|
2
|
+
|
|
3
|
+
Before every development task, read the live documentation for this project's
|
|
4
|
+
target environment. Find the environment's URL with `seq-studio envs list`
|
|
5
|
+
(or the project configuration), then open `<environment-url>/docs`.
|
|
6
|
+
|
|
7
|
+
Start with that site's `/docs/llms.txt` index and follow the relevant pages as
|
|
8
|
+
needed. The hosted docs are the single source of truth for platform usage;
|
|
9
|
+
do not duplicate their instructions in this file. If docs access is blocked,
|
|
10
|
+
open the same URL in the signed-in browser.
|
|
@@ -1,84 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
This directory defines ONE Sequence ORM namespace: TypeScript table
|
|
4
|
-
definitions with row-level policies, plus handwritten GraphQL operations.
|
|
5
|
-
`seq-studio orm apply` pushes it to Atlas, which validates, compiles, and
|
|
6
|
-
applies it. Your app never talks to Postgres — it calls the data plane with
|
|
7
|
-
`{ op: <hash>, variables }` through the generated hooks/functions.
|
|
8
|
-
|
|
9
|
-
## The loop
|
|
10
|
-
|
|
11
|
-
1. Edit `schema/*.ts` (tables, columns, links, policies) and/or
|
|
12
|
-
`graphql/**/*.ts` (operations).
|
|
13
|
-
2. `seq-studio orm generate` — refreshes `schema.graphql` + generated types.
|
|
14
|
-
3. `seq-studio orm diff` — preview the migration for a schema change.
|
|
15
|
-
4. `seq-studio orm apply -e <env>` — pushes. Schema changes write a reviewed
|
|
16
|
-
migration file into `migrations/`; operation-only edits take the fast path
|
|
17
|
-
(seconds, no migration).
|
|
18
|
-
5. Commit `schema/`, `graphql/`, `schema.graphql`, `generated/`, and
|
|
19
|
-
`migrations/` together.
|
|
20
|
-
|
|
21
|
-
## Hard rules
|
|
22
|
-
|
|
23
|
-
- **Never hand-edit `migrations/`.** Migration files are generated by
|
|
24
|
-
`seq-studio orm apply`/`diff` and replayed verbatim by the server. Editing
|
|
25
|
-
or deleting a committed migration breaks the ledger.
|
|
26
|
-
- **Never hand-edit `schema.graphql` or `generated/`.** Both are outputs of
|
|
27
|
-
`seq-studio orm generate`. To change the API surface, change `schema/*.ts`.
|
|
28
|
-
- **No raw SQL.** There is no query escape hatch: every read/write is a
|
|
29
|
-
GraphQL document in `graphql/`, compiled at push time. For genuinely exotic
|
|
30
|
-
multi-statement writes, declare a table `action` — parameterized, gated,
|
|
31
|
-
audited.
|
|
32
|
-
- **Every table needs row policies.** At minimum declare `read` plus either a
|
|
33
|
-
legacy `write` policy or split `insert` / `update` policies when create and
|
|
34
|
-
resolve are different actors. Policies are the row security boundary and are
|
|
35
|
-
compiled into every operation touching the table. There is no "no policy"
|
|
36
|
-
fallback — an unrestricted table must say so explicitly (`allow: true`
|
|
37
|
-
variant or a `true` policy) so the decision is reviewable.
|
|
38
|
-
- **Exactly one `defineNamespace`** (in `sequence.config.ts`), and every
|
|
39
|
-
table module must call `defineTable` at import time — the CLI collects
|
|
40
|
-
registrations by importing your files.
|
|
41
|
-
- **Renames need hints.** Renaming a column or table without
|
|
42
|
-
`.renamedFrom('old_name')` (column) / `renamedFrom` (table config) is a
|
|
43
|
-
DROP + CREATE — data loss. The diff will refuse ambiguous renames; add the
|
|
44
|
-
hint instead of forcing.
|
|
45
|
-
- **Capabilities are code, roles are data.** Capabilities are declared here; roles that bundle them are
|
|
46
|
-
created in Atlas and granted in the Permissions UI. Don't add role `definitions`
|
|
47
|
-
(a deprecated one-time seed) or check `role('…')` — check capabilities.
|
|
48
|
-
Never hardcode user identities in policies; use `claim('sub')` /
|
|
49
|
-
`claim('org')` and grants.
|
|
50
|
-
|
|
51
|
-
## Policy DSL quick reference
|
|
52
|
-
|
|
53
|
-
```
|
|
54
|
-
author_sub = claim('sub') -- row value vs caller claim
|
|
55
|
-
org = claim('org') and status = 'open' -- boolean algebra
|
|
56
|
-
exists(deal, org = claim('org')) -- traverse a declared link
|
|
57
|
-
capability('deals-read') -- boolean grant check
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
Variants widen access per grant (permissive union):
|
|
61
|
-
|
|
62
|
-
```ts
|
|
63
|
-
policies: {
|
|
64
|
-
read: {
|
|
65
|
-
default: "author_sub = claim('sub')",
|
|
66
|
-
variants: [
|
|
67
|
-
{ when: "capability('deals-read')", policy: "org = claim('org')" },
|
|
68
|
-
{ when: "capability('deals-admin')", allow: true },
|
|
69
|
-
],
|
|
70
|
-
},
|
|
71
|
-
}
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
## GraphQL operations
|
|
75
|
-
|
|
76
|
-
- Named operations only; one export per document; gate with
|
|
77
|
-
`@requires(capability: "…")`. Check capabilities, not roles — roles are
|
|
78
|
-
created in Atlas and can change there.
|
|
79
|
-
- Dynamic filters are policy-bounded: `$where: <Table>BoolExp` /
|
|
80
|
-
`$orderBy` / whole-input write objects are validated against a
|
|
81
|
-
schema-derived whitelist and AND-ed with the table policy at runtime —
|
|
82
|
-
they can never widen access.
|
|
83
|
-
- Joins follow declared links (`toOne` / `toMany` / `toPlatformUser`) — there
|
|
84
|
-
are no ad-hoc joins at query time. Declare the link, then select through it.
|
|
1
|
+
@AGENTS.md
|