@sequenceholdings/orm 2.1.1 → 2.3.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 (68) hide show
  1. package/README.md +3 -1
  2. package/dist/authoring.cjs +284 -99
  3. package/dist/authoring.cjs.map +1 -1
  4. package/dist/authoring.d.cts +31 -8
  5. package/dist/authoring.d.ts +31 -8
  6. package/dist/authoring.js +282 -100
  7. package/dist/authoring.js.map +1 -1
  8. package/dist/canonical.cjs +51 -3
  9. package/dist/canonical.cjs.map +1 -1
  10. package/dist/canonical.d.cts +838 -12
  11. package/dist/canonical.d.ts +838 -12
  12. package/dist/canonical.js +47 -4
  13. package/dist/canonical.js.map +1 -1
  14. package/dist/cli.cjs +5876 -4198
  15. package/dist/cli.cjs.map +1 -1
  16. package/dist/cli.js +5876 -4198
  17. package/dist/cli.js.map +1 -1
  18. package/dist/client.cjs +49 -32
  19. package/dist/client.cjs.map +1 -1
  20. package/dist/client.d.cts +49 -6
  21. package/dist/client.d.ts +49 -6
  22. package/dist/client.js +49 -32
  23. package/dist/client.js.map +1 -1
  24. package/dist/compiler.cjs +1275 -264
  25. package/dist/compiler.cjs.map +1 -1
  26. package/dist/compiler.d.cts +57 -3
  27. package/dist/compiler.d.ts +57 -3
  28. package/dist/compiler.js +1268 -265
  29. package/dist/compiler.js.map +1 -1
  30. package/dist/{constants-YoFGjIBM.d.cts → constants-C6EG6Wq7.d.cts} +1 -1
  31. package/dist/{constants-YoFGjIBM.d.ts → constants-C6EG6Wq7.d.ts} +1 -1
  32. package/dist/definition-DjfC7Lll.d.cts +91 -0
  33. package/dist/definition-DjfC7Lll.d.ts +91 -0
  34. package/dist/dynamic-input.cjs +2 -1
  35. package/dist/dynamic-input.cjs.map +1 -1
  36. package/dist/dynamic-input.d.cts +9 -2
  37. package/dist/dynamic-input.d.ts +9 -2
  38. package/dist/dynamic-input.js +2 -1
  39. package/dist/dynamic-input.js.map +1 -1
  40. package/dist/index.cjs +1103 -322
  41. package/dist/index.cjs.map +1 -1
  42. package/dist/index.d.cts +479 -19
  43. package/dist/index.d.ts +479 -19
  44. package/dist/index.js +1090 -323
  45. package/dist/index.js.map +1 -1
  46. package/dist/ir.cjs +93 -11
  47. package/dist/ir.cjs.map +1 -1
  48. package/dist/ir.d.cts +226 -15
  49. package/dist/ir.d.ts +226 -15
  50. package/dist/ir.js +88 -12
  51. package/dist/ir.js.map +1 -1
  52. package/dist/predicate-v2.cjs +116 -10
  53. package/dist/predicate-v2.cjs.map +1 -1
  54. package/dist/predicate-v2.d.cts +11 -3
  55. package/dist/predicate-v2.d.ts +11 -3
  56. package/dist/predicate-v2.js +116 -10
  57. package/dist/predicate-v2.js.map +1 -1
  58. package/dist/sdl.cjs +158 -22
  59. package/dist/sdl.cjs.map +1 -1
  60. package/dist/sdl.d.cts +8 -1
  61. package/dist/sdl.d.ts +8 -1
  62. package/dist/sdl.js +158 -22
  63. package/dist/sdl.js.map +1 -1
  64. package/package.json +5 -4
  65. package/src/codegen-gql/server-fns.cjs +2 -2
  66. package/templates/orm-namespace/AGENTS.md +10 -0
  67. package/templates/orm-namespace/CLAUDE.md +1 -84
  68. 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.1.1",
3
+ "version": "2.3.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
- "graphql": "^16.11.0",
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.1.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
- # Sequence ORM namespace
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
@@ -12,7 +12,7 @@
12
12
  "dependencies": {
13
13
  "@apollo/client": "^3.11.0",
14
14
  "@graphql-typed-document-node/core": "^3.2.0",
15
- "@sequenceholdings/orm": "^2.1.1",
15
+ "@sequenceholdings/orm": "^2.2.0",
16
16
  "graphql": "^16.11.0"
17
17
  },
18
18
  "devDependencies": {