graphddb 0.7.10 → 0.8.1
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 +6 -6
- package/dist/cdc/index.d.ts +389 -5
- package/dist/cdc/index.js +4 -4
- package/dist/{chunk-AD6ZQTTE.js → chunk-GS4C5VGO.js} +2 -6
- package/dist/{chunk-DFUKGU2Q.js → chunk-HNY2EJPV.js} +216 -229
- package/dist/{chunk-3ZU2VW3L.js → chunk-L2NEDS7U.js} +582 -781
- package/dist/chunk-L4QRCHRQ.js +278 -0
- package/dist/chunk-LAT64YCZ.js +1987 -0
- package/dist/chunk-S2NI4PBW.js +187 -0
- package/dist/{chunk-EOJDN3SA.js → chunk-T44OB5GU.js} +3757 -6138
- package/dist/{chunk-PDUVTYC5.js → chunk-XTWXMOHD.js} +0 -1
- package/dist/cli.js +63 -254
- package/dist/index.d.ts +23 -1550
- package/dist/index.js +94 -1850
- package/dist/internal/index.d.ts +84 -0
- package/dist/internal/index.js +701 -0
- package/dist/{maintenance-view-adapter-BAZ9uBGe.d.ts → key-DZtjAQDh.d.ts} +573 -1817
- package/dist/linter/index.d.ts +39 -7
- package/dist/linter/index.js +22 -4
- package/dist/{registry-LWE54Sdc.d.ts → linter-DQY7gUEk.d.ts} +22 -22
- package/dist/prepared-artifact-HFealr1q.d.ts +281 -0
- package/dist/spec/index.d.ts +506 -5
- package/dist/spec/index.js +22 -18
- package/dist/testing/index.d.ts +2 -3
- package/dist/testing/index.js +4 -4
- package/dist/transform/index.d.ts +1 -1
- package/dist/transform/index.js +4 -4
- package/dist/{types-BQLzTEqh.d.ts → types-2PMXEn5x.d.ts} +8 -10
- package/dist/types-DW__-Icc.d.ts +450 -0
- package/docs/cdc-projection.md +5 -5
- package/docs/class-hydration.md +1 -1
- package/docs/cqrs-contract.md +79 -20
- package/docs/design-patterns.md +5 -5
- package/docs/docs-generation.md +6 -6
- package/docs/middleware.md +15 -15
- package/docs/mutation-command-derivation.md +52 -42
- package/docs/prepared-statements.md +14 -14
- package/docs/python-bridge.md +96 -65
- package/docs/spec.md +153 -124
- package/docs/testing.md +9 -8
- package/package.json +14 -4
- package/dist/chunk-3UD3XIF2.js +0 -860
- package/dist/chunk-MMVHOUM4.js +0 -24
- package/dist/from-change-Ty95KA8C.d.ts +0 -327
- package/dist/index-Dc7d8mWI.d.ts +0 -1089
- package/dist/relation-depth-BRS513Tq.d.ts +0 -36
package/docs/python-bridge.md
CHANGED
|
@@ -33,7 +33,7 @@ access patterns that TypeScript has already defined and validated.
|
|
|
33
33
|
```text
|
|
34
34
|
TypeScript (design-time / build-time SSoT)
|
|
35
35
|
├─ Entity / Key / GSI / Relation models
|
|
36
|
-
├─ Parameterized query / command
|
|
36
|
+
├─ Parameterized query / command contracts (param + graphddb.publish*)
|
|
37
37
|
├─ Static parameterized planner (symbolic key evaluation)
|
|
38
38
|
├─ Bridge guard (reject non-declarative / non-serializable specs)
|
|
39
39
|
└─ Bridge bundle: manifest.json + operations.json
|
|
@@ -51,7 +51,7 @@ boto3 DynamoDB client
|
|
|
51
51
|
| Layer | Responsibility |
|
|
52
52
|
|---|---|
|
|
53
53
|
| TypeScript model | Entity / key / GSI / relation definitions |
|
|
54
|
-
|
|
|
54
|
+
| Contract DSL (`param`, `graphddb.publish*`) | The permitted, parameterized queries and commands |
|
|
55
55
|
| Static planner (`src/spec/*`) | Symbolic key evaluation → `manifest.json` / `operations.json` |
|
|
56
56
|
| Generator (`src/codegen/python.ts`, `src/cli/*`) | Python repositories, result types, package exports |
|
|
57
57
|
| Python repository | Stable application-facing interface |
|
|
@@ -69,68 +69,96 @@ runtime descriptor (`kind`, optional `literals`, optional element shape) that
|
|
|
69
69
|
the planner and generator read. `param.literal('active', 'disabled')` has value
|
|
70
70
|
type `'active' | 'disabled'`; the literal set is preserved in the spec.
|
|
71
71
|
|
|
72
|
-
Parameters are legal only inside the structures passed to the
|
|
73
|
-
points
|
|
74
|
-
remain free of
|
|
72
|
+
Parameters are legal only inside the structures passed to the contract authoring
|
|
73
|
+
entry points (`graphddb.publishQuery` / `graphddb.publishCommand`) — never to the
|
|
74
|
+
live `Model.query` / `Model.putItem` runtime API, whose types remain free of
|
|
75
|
+
parameter placeholders.
|
|
75
76
|
|
|
76
|
-
### 3.2
|
|
77
|
+
### 3.2 Contract Authoring Entry Points
|
|
77
78
|
|
|
78
|
-
|
|
79
|
+
Public reads and writes are authored through the CQRS contract layer, the sole
|
|
80
|
+
read/write authoring surface. Import the `graphddb` namespace and publish keyed
|
|
81
|
+
contracts whose methods are declarative descriptors, each accepting `param`
|
|
79
82
|
placeholders at scalar leaves while checking field names, value types, the key
|
|
80
83
|
boundary, and the strict select against the model:
|
|
81
84
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
- `defineUpdate(Model, key, changes, options?)` — update.
|
|
86
|
-
- `defineDelete(Model, key, options?)` — delete.
|
|
85
|
+
```ts
|
|
86
|
+
import { graphddb, param } from 'graphddb';
|
|
87
|
+
```
|
|
87
88
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
name
|
|
89
|
+
- `graphddb.publishQuery({ name: { get: { query: Model, key, select } } })` —
|
|
90
|
+
single-item read (unique key).
|
|
91
|
+
- `graphddb.publishQuery({ name: { list: { list: Model, key, select } } })` —
|
|
92
|
+
partition read (partial / partition key).
|
|
93
|
+
- `graphddb.publishCommand({ name: { create: Model, key, input } })` — put.
|
|
94
|
+
- `graphddb.publishCommand({ name: { update: Model, key, input } })` — update.
|
|
95
|
+
- `graphddb.publishCommand({ name: { remove: Model, key } })` — delete.
|
|
91
96
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
97
|
+
A command method descriptor accepts an optional `condition` (see §6.2) and an
|
|
98
|
+
optional `result: { select }` read-back projection. Each published contract
|
|
99
|
+
collects its placeholders into a `name → ParamDescriptor` map; a parameter name
|
|
100
|
+
used twice with conflicting types is rejected at definition time.
|
|
101
|
+
|
|
102
|
+
> Design note: the authoring surface is `graphddb.publishQuery` /
|
|
103
|
+
> `graphddb.publishCommand` (not `Model.query(...)` overloads), so the live
|
|
104
|
+
> runtime model API is never widened to accept parameter placeholders.
|
|
95
105
|
|
|
96
106
|
### 3.3 Grouping
|
|
97
107
|
|
|
98
|
-
`
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
108
|
+
`graphddb.publishQuery({ ... })` publishes a keyed read contract whose methods
|
|
109
|
+
resolve to `get` / `list` descriptors; `graphddb.publishCommand({ ... })`
|
|
110
|
+
publishes a keyed write contract whose methods resolve to `create` / `update` /
|
|
111
|
+
`remove` descriptors. Each validates that every method is the correct operation
|
|
112
|
+
kind and returns the typed contract that the planner consumes. Atomic multi-op
|
|
113
|
+
writes are declared with a `mode: 'transaction'` descriptor and compile to a
|
|
114
|
+
declarative `TransactionSpec` (see §6.3).
|
|
103
115
|
|
|
104
116
|
```ts
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
117
|
+
import { graphddb, param } from 'graphddb';
|
|
118
|
+
|
|
119
|
+
export const UserByEmail = graphddb.publishQuery({
|
|
120
|
+
get: {
|
|
121
|
+
query: User,
|
|
122
|
+
key: { email: param.string() },
|
|
123
|
+
select: { userId: true, name: true, email: true, status: true },
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
export const MembersByGroup = graphddb.publishQuery({
|
|
128
|
+
list: {
|
|
129
|
+
list: GroupMembership,
|
|
130
|
+
key: { groupId: param.string() },
|
|
131
|
+
select: { userId: true, role: true, joinedAt: true },
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
export const MembershipCommands = graphddb.publishCommand({
|
|
136
|
+
addGroupMember: {
|
|
137
|
+
create: GroupMembership,
|
|
138
|
+
key: { groupId: param.string(), userId: param.string() },
|
|
139
|
+
input: { role: param.string() },
|
|
140
|
+
},
|
|
141
|
+
deleteGroupMember: {
|
|
142
|
+
remove: GroupMembership,
|
|
143
|
+
key: { groupId: param.string(), userId: param.string() },
|
|
144
|
+
},
|
|
116
145
|
});
|
|
117
146
|
|
|
118
|
-
export const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
userId: param.string(),
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
disableUser: defineUpdate(
|
|
125
|
-
User,
|
|
126
|
-
{ userId: param.string() },
|
|
127
|
-
{ status: param.literal('disabled') },
|
|
128
|
-
),
|
|
129
|
-
deleteGroupMember: defineDelete(GroupMembership, {
|
|
130
|
-
groupId: param.string(),
|
|
131
|
-
userId: param.string(),
|
|
132
|
-
}),
|
|
147
|
+
export const UserCommands = graphddb.publishCommand({
|
|
148
|
+
disableUser: {
|
|
149
|
+
update: User,
|
|
150
|
+
key: { userId: param.string() },
|
|
151
|
+
input: { status: param.literal('disabled') },
|
|
152
|
+
},
|
|
133
153
|
});
|
|
154
|
+
|
|
155
|
+
// The `contracts` map the generator consumes (see §5).
|
|
156
|
+
export const contracts = {
|
|
157
|
+
UserByEmail,
|
|
158
|
+
MembersByGroup,
|
|
159
|
+
MembershipCommands,
|
|
160
|
+
UserCommands,
|
|
161
|
+
};
|
|
134
162
|
```
|
|
135
163
|
|
|
136
164
|
## 4. The Bridge Bundle
|
|
@@ -330,20 +358,17 @@ GSI-keyed write is rejected by the planner.
|
|
|
330
358
|
```bash
|
|
331
359
|
graphddb generate python \
|
|
332
360
|
--entry src/models/index.ts \
|
|
333
|
-
--
|
|
334
|
-
--commands src/models/commands.ts \
|
|
361
|
+
--contracts src/models/contracts.ts \
|
|
335
362
|
--out generated/graphddb
|
|
336
363
|
```
|
|
337
364
|
|
|
338
365
|
| Flag | Required | Default | Meaning |
|
|
339
366
|
|---|---|---|---|
|
|
340
|
-
| `--entry`, `-e` | yes | — | Module that registers entity models (imported for side effects); may also export
|
|
367
|
+
| `--entry`, `-e` | yes | — | Module that registers entity models (imported for side effects); may also export `contracts` / `contexts` / `transactions`. |
|
|
341
368
|
| `--out`, `-o` | yes | — | Output directory (created if absent). |
|
|
342
|
-
| `--
|
|
343
|
-
| `--commands`, `-c` | no | `--entry` | Module exporting `commands`. |
|
|
344
|
-
| `--transactions`, `-t` | no | `--commands` then `--entry` | Module exporting `transactions`. |
|
|
345
|
-
| `--contracts` | no | `--entry` | Module exporting CQRS `contracts`. |
|
|
369
|
+
| `--contracts` | no | `--entry` | Module exporting the CQRS `contracts` map (`graphddb.publishQuery` / `graphddb.publishCommand` results). |
|
|
346
370
|
| `--contexts` | no | `--contracts` then `--entry` | Module exporting context ownership. |
|
|
371
|
+
| `--transactions`, `-t` | no | `--entry` | Module exporting `transactions`. |
|
|
347
372
|
| `--dataclass` | no | `false` | Emit `@dataclass` result types instead of `TypedDict`. |
|
|
348
373
|
|
|
349
374
|
TypeScript definition modules are transpiled on the fly (via tsx/esbuild — the
|
|
@@ -455,15 +480,21 @@ the serialized `expr` tree). (Per-item conditions are not available on
|
|
|
455
480
|
|
|
456
481
|
### 6.3 Transactions (declarative subset)
|
|
457
482
|
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
`
|
|
463
|
-
|
|
464
|
-
`condition
|
|
465
|
-
|
|
466
|
-
`forEach
|
|
483
|
+
An atomic multi-op write — a `mode: 'transaction'` command descriptor, or the
|
|
484
|
+
derived effects of any command (edges, counters, uniqueness guards, outbox,
|
|
485
|
+
idempotency, maintenance writes) — compiles to a declarative `TransactionSpec`.
|
|
486
|
+
Its `items` write with field references or literals at scalar leaves; a bulk
|
|
487
|
+
`key: K[]` command lowers to a single `forEach`-over-keys item; and each item may
|
|
488
|
+
carry a declarative `when` comparison (`eq` / `ne`) and/or a supported
|
|
489
|
+
`condition`. The `TransactionSpec` `items` carry rendered templates (`{param}`,
|
|
490
|
+
`{item.field}` for `forEach` elements), optional `condition`, optional `when`, and
|
|
491
|
+
optional `forEach: { source }`. A transaction with no `forEach` is rejected at
|
|
492
|
+
build time if it exceeds 25 items; with `forEach`, the 25-item limit is enforced
|
|
493
|
+
by the runtime after expansion.
|
|
494
|
+
|
|
495
|
+
(The internal declarative-transaction recorder that produces this IR is the
|
|
496
|
+
`publishCommand` / `mutate` compile backend and the `graphddb transform`
|
|
497
|
+
lowering target — it is not a public authoring verb.)
|
|
467
498
|
|
|
468
499
|
## 7. The Python Runtime (`graphddb_runtime`)
|
|
469
500
|
|