graphddb 0.8.1 → 0.9.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/dist/behaviors-DDltNivc.d.ts +217 -0
- package/dist/cdc/index.d.ts +5 -4
- package/dist/cdc/index.js +3 -3
- package/dist/{chunk-HNY2EJPV.js → chunk-7OCXY4R6.js} +1 -1
- package/dist/{chunk-L2NEDS7U.js → chunk-GWWRXIHF.js} +260 -12
- package/dist/{chunk-T44OB5GU.js → chunk-HLFNCKFV.js} +105 -11
- package/dist/{chunk-LAT64YCZ.js → chunk-MBJ4JVRM.js} +680 -25
- package/dist/{chunk-S2NI4PBW.js → chunk-PHXUFAY2.js} +7 -5
- package/dist/{chunk-GS4C5VGO.js → chunk-VECUS35D.js} +2 -2
- package/dist/{chunk-L4QRCHRQ.js → chunk-WOFRHRXY.js} +6 -25
- package/dist/cli.js +366 -80
- package/dist/index.d.ts +131 -5
- package/dist/index.js +121 -5
- package/dist/internal/index.d.ts +6 -5
- package/dist/internal/index.js +7 -7
- package/dist/{key-DZtjAQDh.d.ts → key-CWytoEaE.d.ts} +93 -5
- package/dist/linter/index.d.ts +6 -5
- package/dist/{linter-DQY7gUEk.d.ts → linter-jEwmZotm.d.ts} +1 -1
- package/dist/{prepared-artifact-HFealr1q.d.ts → prepared-artifact-CwH5ezFq.d.ts} +4 -4
- package/dist/spec/index.d.ts +225 -24
- package/dist/spec/index.js +17 -9
- package/dist/testing/index.d.ts +3 -2
- package/dist/testing/index.js +32 -5
- package/dist/transform/index.d.ts +2 -1
- package/dist/transform/index.js +2 -2
- package/dist/{types-2PMXEn5x.d.ts → types-CgXS-4Ox.d.ts} +299 -28
- package/dist/{types-DW__-Icc.d.ts → types-nk5okD7d.d.ts} +1 -1
- package/docs/python-bridge.md +33 -49
- package/package.json +11 -3
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Component } from 'behavior-contracts';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Parameter placeholders for the parameterized query / command definition DSL
|
|
3
5
|
* (issue #41, Python-bridge Phase 0a).
|
|
@@ -21,7 +23,7 @@
|
|
|
21
23
|
/** Brand tag preventing a plain object from structurally matching a {@link Param}. */
|
|
22
24
|
declare const PARAM_BRAND: unique symbol;
|
|
23
25
|
/** Runtime discriminant for a parameter placeholder. */
|
|
24
|
-
type ParamKind = 'string' | 'number' | 'literal' | 'array';
|
|
26
|
+
type ParamKind = 'string' | 'number' | 'literal' | 'array' | 'map';
|
|
25
27
|
/**
|
|
26
28
|
* A branded parameter placeholder representing a value of TypeScript type `T`
|
|
27
29
|
* that is bound at execution time rather than definition time.
|
|
@@ -64,6 +66,28 @@ type StringParam = Param<string>;
|
|
|
64
66
|
type NumberParam = Param<number>;
|
|
65
67
|
/** A `Param` whose represented value type is the literal union `L`. */
|
|
66
68
|
type LiteralParam<L extends string | number> = Param<L>;
|
|
69
|
+
/**
|
|
70
|
+
* A `Param` standing in for a **map / embedded object** value (issue #295): a
|
|
71
|
+
* JSON-serializable object written to a single DynamoDB `M` attribute. The
|
|
72
|
+
* `kind` is narrowed to the `'map'` literal so type-level dispatch works, and
|
|
73
|
+
* the represented value type `T` (default `Record<string, unknown>`) lets a
|
|
74
|
+
* typed domain value class ride the placeholder:
|
|
75
|
+
*
|
|
76
|
+
* ```ts
|
|
77
|
+
* type AvgValue = Record<string, Record<string, { sum: number; count: number }>>;
|
|
78
|
+
* param.map<AvgValue>(); // Param<AvgValue> bound to a `@map value!: AvgValue` field
|
|
79
|
+
* ```
|
|
80
|
+
*
|
|
81
|
+
* The value crosses every boundary as a **native DynamoDB `M` attribute**
|
|
82
|
+
* (never a JSON-string blob): the placeholder renders to a `{field}` token /
|
|
83
|
+
* `{ref:["field"]}` Expression-IR reference in the portable IR, and each
|
|
84
|
+
* runtime's (already recursive) attribute marshaller serializes the supplied
|
|
85
|
+
* object to `M`. Generated bindings type it as the language's native free-form
|
|
86
|
+
* map (`dict` / `map[string]any` / `serde_json::Value` / `array`).
|
|
87
|
+
*/
|
|
88
|
+
type MapParam<T extends Record<string, unknown> = Record<string, unknown>> = Param<T> & {
|
|
89
|
+
readonly kind: 'map';
|
|
90
|
+
};
|
|
67
91
|
/** The element-field descriptor shape accepted by {@link param.array}. */
|
|
68
92
|
type ArrayElementShape = Record<string, Param<unknown>>;
|
|
69
93
|
/**
|
|
@@ -131,6 +155,29 @@ declare const param: {
|
|
|
131
155
|
* ```
|
|
132
156
|
*/
|
|
133
157
|
readonly array: <const E extends ArrayElementShape>(element: E, options?: ParamOptions) => ArrayParam<E>;
|
|
158
|
+
/**
|
|
159
|
+
* A placeholder for a **map / embedded object** value written to a single
|
|
160
|
+
* DynamoDB `M` attribute (issue #295). Free-form by design: the model-side
|
|
161
|
+
* vocabulary (`@map` / `@embedded`) records no nested schema, so the param is
|
|
162
|
+
* typed as the language-native map in generated bindings (`dict` /
|
|
163
|
+
* `map[string]any` / `serde_json::Value` / `array`) while the optional type
|
|
164
|
+
* parameter `T` keeps the TS authoring surface precise.
|
|
165
|
+
*
|
|
166
|
+
* Legal at **value positions only** (a write descriptor's `input`, a
|
|
167
|
+
* transaction fragment value, a batch-write per-item payload field) — a map
|
|
168
|
+
* cannot compose a key, so a `param.map()` in a key position is rejected
|
|
169
|
+
* loudly at build time.
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```ts
|
|
173
|
+
* putLeaf: {
|
|
174
|
+
* upsert: TreeNode,
|
|
175
|
+
* key: { part: param.string(), child: param.string() },
|
|
176
|
+
* input: { value: param.map<AvgValue>(), computedAt: param.number() },
|
|
177
|
+
* }
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
180
|
+
readonly map: <T extends Record<string, unknown> = Record<string, unknown>>(options?: ParamOptions) => MapParam<T>;
|
|
134
181
|
};
|
|
135
182
|
|
|
136
183
|
/**
|
|
@@ -181,6 +228,27 @@ declare const SPEC_VERSION: "1.1";
|
|
|
181
228
|
* (#265/#266/#267) land and bump the supported constant with the wiring.
|
|
182
229
|
*/
|
|
183
230
|
declare const SPEC_VERSION_SCP: "1.2";
|
|
231
|
+
/**
|
|
232
|
+
* The schema version stamped on an operations document whose **read operations**
|
|
233
|
+
* carry the SCP IR Phase 2 Expression-IR key wiring (`keyExpr` / `valueExpr`,
|
|
234
|
+
* issue #289). This is the **operations IR 2.0 milestone** (the "2.0-rc" of the
|
|
235
|
+
* migration plan §3 Phase 2 / M3): a MAJOR bump (`1.x` → `2.x`), because the key
|
|
236
|
+
* wiring's serialization changed from a `{param}` string template to the portable
|
|
237
|
+
* Expression IR `concat`/`ref` closed vocabulary (behavior-contracts
|
|
238
|
+
* `expression-ir.md`). The BEHAVIOR is identical — the change is purely in IR
|
|
239
|
+
* serialization — but a major bump is correct: a pre-#289 runtime (supported
|
|
240
|
+
* `1.2`) `validateEnvelope`-rejects a `2.0` document (its `keyExpr` reader does
|
|
241
|
+
* not exist), which is the intended fail-closed break. Stamped **only** when a
|
|
242
|
+
* document actually carries a read op (a `queries` entry); a commands/transactions
|
|
243
|
+
* -only document has no read-path key wiring and keeps its `1.1`/`1.2` stamp,
|
|
244
|
+
* serializing byte-identically.
|
|
245
|
+
*
|
|
246
|
+
* The stamp string is the integer `<major>.<minor>` form `validateEnvelope`
|
|
247
|
+
* requires (`2.0`); "2.0-rc" is the migration MILESTONE label (dual-emit proven,
|
|
248
|
+
* flip landed), not the wire version — a `-rc` suffix is not a valid envelope
|
|
249
|
+
* version and would fail-closed in graphddb's own runtime.
|
|
250
|
+
*/
|
|
251
|
+
declare const SPEC_VERSION_KEY_EXPR: "2.0";
|
|
184
252
|
/**
|
|
185
253
|
* The HIGHEST spec-IR minor this **TS runtime** understands and will EXECUTE
|
|
186
254
|
* (issue #265, Phase 3 S5). The shared `validateEnvelope` fail-closed rule is
|
|
@@ -194,10 +262,19 @@ declare const SPEC_VERSION_SCP: "1.2";
|
|
|
194
262
|
* unknown `exprVersion` / operator still fail-closes (the expr evaluator rejects
|
|
195
263
|
* it). The py/rust/go runtimes bump in S6, PHP in S7 — the whole release column
|
|
196
264
|
* moves to `1.2` together.
|
|
265
|
+
*
|
|
266
|
+
* **SCP IR Phase 2 (#289): bumped to `2.0` (major).** The read-op key wiring is
|
|
267
|
+
* now portable Expression IR (`keyExpr` / `valueExpr`), a MAJOR serialization
|
|
268
|
+
* change. `validateEnvelope`'s rule is "major must match, minor ≤ supported", so
|
|
269
|
+
* a `2.0` runtime accepts `2.0` documents and **rejects every `1.x` document**
|
|
270
|
+
* (major mismatch) — and every `1.x` runtime rejects a `2.0` document. That is
|
|
271
|
+
* the intended breaking cut: the whole operations IR moves to `2.0` at once
|
|
272
|
+
* (migration plan §4). All 4 runtimes bump their supported constant to `2.0`
|
|
273
|
+
* together (one release column), mirroring the `1.2` bump discipline.
|
|
197
274
|
*/
|
|
198
|
-
declare const SPEC_VERSION_SUPPORTED: "
|
|
199
|
-
/** A spec version an operations document may carry (see {@link
|
|
200
|
-
type SpecVersion = typeof SPEC_VERSION | typeof SPEC_VERSION_SCP;
|
|
275
|
+
declare const SPEC_VERSION_SUPPORTED: "2.0";
|
|
276
|
+
/** A spec version an operations document may carry (see {@link SPEC_VERSION_KEY_EXPR}). */
|
|
277
|
+
type SpecVersion = typeof SPEC_VERSION | typeof SPEC_VERSION_SCP | typeof SPEC_VERSION_KEY_EXPR;
|
|
201
278
|
/** Field type as carried in the manifest (derived from the DynamoDB type). */
|
|
202
279
|
type ManifestFieldType = 'string' | 'number' | 'boolean' | 'binary' | 'stringSet' | 'numberSet' | 'list' | 'map';
|
|
203
280
|
interface ManifestField {
|
|
@@ -305,12 +382,17 @@ interface ManifestTable {
|
|
|
305
382
|
}
|
|
306
383
|
interface Manifest {
|
|
307
384
|
/**
|
|
308
|
-
*
|
|
309
|
-
* metadata only
|
|
310
|
-
*
|
|
311
|
-
*
|
|
385
|
+
* The IR SSoT version. Historically the base {@link SPEC_VERSION} (`1.1`): the
|
|
386
|
+
* manifest carries entity/schema metadata only, so the conditional `1.2`
|
|
387
|
+
* Expression-IR stamp never applied here. **SCP IR Phase 2 (#289): moved to
|
|
388
|
+
* {@link SPEC_VERSION_KEY_EXPR} (`2.0`).** The operations IR took a MAJOR bump
|
|
389
|
+
* (portable Expression IR key wiring), and `validateEnvelope`'s "major must
|
|
390
|
+
* match" rule is applied to the manifest AND the operations document against a
|
|
391
|
+
* single supported constant — so the manifest version must track the same major
|
|
392
|
+
* or every load would fail major-mismatch. The manifest CONTENT is unchanged;
|
|
393
|
+
* only its version stamp moves to `2.0` with the rest of the IR SSoT.
|
|
312
394
|
*/
|
|
313
|
-
readonly version: typeof
|
|
395
|
+
readonly version: typeof SPEC_VERSION_KEY_EXPR;
|
|
314
396
|
readonly tables: Readonly<Record<string, ManifestTable>>;
|
|
315
397
|
readonly entities: Readonly<Record<string, ManifestEntity>>;
|
|
316
398
|
}
|
|
@@ -332,12 +414,31 @@ interface ParamSpec {
|
|
|
332
414
|
*/
|
|
333
415
|
readonly description?: string;
|
|
334
416
|
}
|
|
335
|
-
/** A `begins_with` range condition on a sort key (
|
|
417
|
+
/** A `begins_with` range condition on a sort key (Expression-IR value). */
|
|
336
418
|
interface RangeConditionSpec {
|
|
337
419
|
readonly operator: 'begins_with';
|
|
338
420
|
readonly key: string;
|
|
339
|
-
/**
|
|
340
|
-
|
|
421
|
+
/**
|
|
422
|
+
* The range value as **Expression IR** (SCP IR Phase 2, issue #289): e.g.
|
|
423
|
+
* `"USER#"` (a bare literal) or `{concat:["USER#",{ref:["result","groupId"]}]}`.
|
|
424
|
+
* The runtime evaluates it with `evaluateExpression` — the same closed
|
|
425
|
+
* `concat`/`ref` vocabulary the key wiring uses (`key-expr.ts`). Replaces the
|
|
426
|
+
* pre-#289 `{param}` string template (dual-emitted and proven byte-identical
|
|
427
|
+
* through conformance before the template path was removed, P2-3).
|
|
428
|
+
*
|
|
429
|
+
* Optional only because the builders construct the raw range condition with
|
|
430
|
+
* `value` first and the `lowerOperationKeyExprs` pass fills `valueExpr` — every
|
|
431
|
+
* serialized range condition carries `valueExpr`.
|
|
432
|
+
*/
|
|
433
|
+
readonly valueExpr?: ExpressionNode;
|
|
434
|
+
/**
|
|
435
|
+
* @deprecated Phase 2 dual-emit (issue #289 P2-3): the pre-#289 `{param}`
|
|
436
|
+
* string template (`GROUP#{result.groupId}`), emitted ALONGSIDE
|
|
437
|
+
* {@link valueExpr} only during the migration so the runtimes' Expression-IR
|
|
438
|
+
* reading can be proven byte-identical to the template render before the
|
|
439
|
+
* template path is deleted. Removed at the flip.
|
|
440
|
+
*/
|
|
441
|
+
readonly value?: string;
|
|
341
442
|
}
|
|
342
443
|
/** Server-side declarative filter, carried verbatim for the runtime to compile. */
|
|
343
444
|
interface FilterSpec {
|
|
@@ -354,10 +455,28 @@ interface OperationSpec {
|
|
|
354
455
|
readonly tableName: string;
|
|
355
456
|
readonly indexName?: string;
|
|
356
457
|
/**
|
|
357
|
-
* Key condition
|
|
358
|
-
*
|
|
458
|
+
* Key condition as **Expression IR** (SCP IR Phase 2, issue #289): attribute
|
|
459
|
+
* name → an Expression IR node (`concat`/`ref`) that evaluates to the key
|
|
460
|
+
* value, e.g. `PK: {concat:["ARTICLE#",{ref:["input","articleId"]}]}`. For a
|
|
461
|
+
* `BatchGetItem` this is the per-key shape (one key per resolved source item).
|
|
462
|
+
* The runtime evaluates each node with `evaluateExpression` against the
|
|
463
|
+
* `{input, result}` scope — the universal Port-wiring vocabulary
|
|
464
|
+
* (scp-ir-architecture.md §5), lowered from the pre-#289 `{param}` string
|
|
465
|
+
* template by `key-expr.ts`.
|
|
466
|
+
*
|
|
467
|
+
* Optional only because the builders construct the raw op with `keyCondition`
|
|
468
|
+
* first and a single `lowerOperationKeyExprs` pass fills `keyExpr` from it
|
|
469
|
+
* (operations.ts) — every serialized op carries `keyExpr`.
|
|
470
|
+
*/
|
|
471
|
+
readonly keyExpr?: Readonly<Record<string, ExpressionNode>>;
|
|
472
|
+
/**
|
|
473
|
+
* @deprecated Phase 2 dual-emit (issue #289 P2-3): the pre-#289 `{param}`
|
|
474
|
+
* string-template key condition (`ARTICLE#{articleId}`), emitted ALONGSIDE
|
|
475
|
+
* {@link keyExpr} only during the migration so the runtimes' Expression-IR key
|
|
476
|
+
* reading can be proven byte-identical to the template render before the
|
|
477
|
+
* template path is deleted. Removed at the flip.
|
|
359
478
|
*/
|
|
360
|
-
readonly keyCondition
|
|
479
|
+
readonly keyCondition?: Readonly<Record<string, string>>;
|
|
361
480
|
readonly rangeCondition?: RangeConditionSpec;
|
|
362
481
|
/** Projected fields (entity field names). */
|
|
363
482
|
readonly projection: readonly string[];
|
|
@@ -412,6 +531,25 @@ interface SourceListSpec {
|
|
|
412
531
|
* the query's select projects the attribute itself (it stays in the result).
|
|
413
532
|
*/
|
|
414
533
|
readonly implicit?: boolean;
|
|
534
|
+
/**
|
|
535
|
+
* **SCP IR Phase 2 prep toward the universal Map node (issue #289 P2-5).** The
|
|
536
|
+
* shared IR expresses a fan-out as an SCP `map` node
|
|
537
|
+
* (`{ map: { over: <ref to the list>, as: "$el", component, ports } }`,
|
|
538
|
+
* scp-ir-architecture.md §5) — a single static node iterating a list Port. This
|
|
539
|
+
* `refs`/`sourceList` binding form is the DynamoDB-specific precursor of that
|
|
540
|
+
* Map. Phase 2 only PREPARES the migration (the full `map`-node emission +
|
|
541
|
+
* runtime expansion is Phase 3): {@link over} records the Expression-IR
|
|
542
|
+
* reference to the parent's list attribute the Map iterates
|
|
543
|
+
* (`{ ref: ["result", from] }`), and {@link as} records the per-element binding
|
|
544
|
+
* name (`"$<key>"`) the Phase-3 `map` body will reference. Both are ADDITIVE and
|
|
545
|
+
* DESCRIPTIVE only — the Phase-2 runtimes still execute the fan-out via
|
|
546
|
+
* {@link from}/{@link key} (unchanged behavior); Phase 3 lowers the body onto
|
|
547
|
+
* `over`/`as`. Carrying them now freezes the intended Map shape for review and
|
|
548
|
+
* lets a Phase-3 runtime resolve it without re-deriving.
|
|
549
|
+
*/
|
|
550
|
+
readonly over?: ExpressionNode;
|
|
551
|
+
/** The Phase-3 Map element binding name (`"$<key>"`); see {@link over}. */
|
|
552
|
+
readonly as?: string;
|
|
415
553
|
}
|
|
416
554
|
/**
|
|
417
555
|
* The **execution plan** for a multi-operation read (issue #70a). It is the
|
|
@@ -489,8 +627,15 @@ interface QuerySpec {
|
|
|
489
627
|
/**
|
|
490
628
|
* The Expression IR vocabulary version (behavior-contracts `expression-ir.md`
|
|
491
629
|
* §9). A runtime handed an unknown `exprVersion` MUST fail closed.
|
|
630
|
+
*
|
|
631
|
+
* **SCP IR Phase 2 (#289, G6): bumped `1` → `2`.** graphddb now follows the
|
|
632
|
+
* behavior-contracts `exprVersion: 2` vocabulary (the v1→v2 change is the `obj`
|
|
633
|
+
* node `__proto__` `FORBIDDEN_KEY` fail-closed hardening — additive/backward
|
|
634
|
+
* compatible, `expression-ir.md` §9), closing the minor-version lag the migration
|
|
635
|
+
* plan flagged (§2 G6). Every embedded {@link ExpressionSpec} — guards, scpExpr
|
|
636
|
+
* conditions, and the new `keyExpr` key wiring — stamps `exprVersion: 2`.
|
|
492
637
|
*/
|
|
493
|
-
declare const EXPR_VERSION:
|
|
638
|
+
declare const EXPR_VERSION: 2;
|
|
494
639
|
/**
|
|
495
640
|
* The closed operator vocabulary of Expression IR v1 (expression-ir.md §3).
|
|
496
641
|
* An operator node is a **single-key** object — key = operator name, value =
|
|
@@ -576,7 +721,9 @@ type WriteOperationType = 'PutItem' | 'UpdateItem' | 'DeleteItem';
|
|
|
576
721
|
* - `{ kind: 'attributeNotExists'; field }` → `attribute_not_exists(<field>)` — the
|
|
577
722
|
* named attribute must be absent (field-level uniqueness / first-write guard).
|
|
578
723
|
* - `{ kind: 'equals'; fields }` → `#f = :v AND …` field equality (each value a
|
|
579
|
-
* `{param}` / literal
|
|
724
|
+
* `{param}` string template or a typed literal — a `number` / `boolean` literal
|
|
725
|
+
* is carried verbatim so it compares as `N` / `BOOL`, not a stringified `S`,
|
|
726
|
+
* issue #299).
|
|
580
727
|
* - `{ kind: 'expr'; declarative }` → the full declarative operator tree (issue
|
|
581
728
|
* #114-A): comparison (`gt`/`ge`/`lt`/`le`/`ne`), `between`, `in`,
|
|
582
729
|
* `begins_with`/`contains`/`notContains`, `attributeType`, and the logical
|
|
@@ -598,7 +745,7 @@ type ConditionSpec = {
|
|
|
598
745
|
readonly field: string;
|
|
599
746
|
} | {
|
|
600
747
|
readonly kind: 'equals';
|
|
601
|
-
readonly fields: Readonly<Record<string,
|
|
748
|
+
readonly fields: Readonly<Record<string, TransactionValueLeaf>>;
|
|
602
749
|
} | {
|
|
603
750
|
readonly kind: 'expr';
|
|
604
751
|
readonly declarative: unknown;
|
|
@@ -647,10 +794,33 @@ interface CommandSpec {
|
|
|
647
794
|
* Absent for `PutItem` (the whole item is built from `item`).
|
|
648
795
|
*/
|
|
649
796
|
readonly keyCondition?: Readonly<Record<string, string>>;
|
|
650
|
-
/**
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
797
|
+
/**
|
|
798
|
+
* The full item template for `PutItem` (field name → template / typed literal).
|
|
799
|
+
* A string value is a template ({@link TransactionValueLeaf}); a `number` /
|
|
800
|
+
* `boolean` is a typed literal carried verbatim so it lands as `N` / `BOOL`
|
|
801
|
+
* rather than a stringified `S` (issue #299, mirroring the transaction #245).
|
|
802
|
+
*/
|
|
803
|
+
readonly item?: Readonly<Record<string, TransactionValueLeaf>>;
|
|
804
|
+
/**
|
|
805
|
+
* Field-level changes for `UpdateItem` (field name → template / typed literal).
|
|
806
|
+
* A string value is a template; a `number` / `boolean` is a typed literal
|
|
807
|
+
* carried verbatim (issue #299).
|
|
808
|
+
*/
|
|
809
|
+
readonly changes?: Readonly<Record<string, TransactionValueLeaf>>;
|
|
810
|
+
/**
|
|
811
|
+
* Atomic-`ADD` deltas for a standalone `UpdateItem` (issue #301): field name →
|
|
812
|
+
* template / typed literal. Distinct from {@link changes} (a SET): each entry emits
|
|
813
|
+
* `ADD #field :delta` — an atomic, read-free, concurrency-safe increment (the
|
|
814
|
+
* aggregate-tree `mark`'s `version++`). The delta rides as a `{token}` template
|
|
815
|
+
* resolved from a caller `param.number()`. When present together with
|
|
816
|
+
* {@link condition}, the ADD is UNCONDITIONAL and the runtime executes a transparent
|
|
817
|
+
* TWO-STAGE write: `ADD + SET` under the condition (1 write); on
|
|
818
|
+
* `ConditionalCheckFailedException`, a fallback `ADD`-only write (no SET, no
|
|
819
|
+
* condition — the counter still increments). read=0, retry=0. Absent unless the
|
|
820
|
+
* command declared `add`, so a command with no `add` serializes byte-identically to
|
|
821
|
+
* the pre-#301 spec.
|
|
822
|
+
*/
|
|
823
|
+
readonly add?: Readonly<Record<string, TransactionValueLeaf>>;
|
|
654
824
|
/** Optional write condition (subset). */
|
|
655
825
|
readonly condition?: ConditionSpec;
|
|
656
826
|
/**
|
|
@@ -878,8 +1048,12 @@ interface MaintainItemSpec {
|
|
|
878
1048
|
interface MaintainCounterSpec {
|
|
879
1049
|
/** The target attribute the counter increments (e.g. `postCount`). */
|
|
880
1050
|
readonly attribute: string;
|
|
881
|
-
/**
|
|
882
|
-
|
|
1051
|
+
/**
|
|
1052
|
+
* The signed `ADD` delta. A compile-time constant delta is carried as a typed
|
|
1053
|
+
* `number` (`1` / `-1`) so it marshals as `N` (issue #299); a `{param}` numeric
|
|
1054
|
+
* template rides as a string. (Pre-#299 a constant was stringified to `"1"`.)
|
|
1055
|
+
*/
|
|
1056
|
+
readonly delta: TransactionValueLeaf;
|
|
883
1057
|
}
|
|
884
1058
|
/** A declarative transaction definition's full execution spec. */
|
|
885
1059
|
interface TransactionSpec {
|
|
@@ -892,6 +1066,25 @@ interface TransactionSpec {
|
|
|
892
1066
|
* DynamoDB ≤25 limit after expansion).
|
|
893
1067
|
*/
|
|
894
1068
|
readonly maxItems?: number;
|
|
1069
|
+
/**
|
|
1070
|
+
* Marks a **BatchWriteItem** bulk form (issue #298): the spec is executed
|
|
1071
|
+
* NON-ATOMICALLY through DynamoDB `BatchWriteItem` — chunked ≤25 per request
|
|
1072
|
+
* with `UnprocessedItems` exponential retry, 1×WCU, no all-or-nothing
|
|
1073
|
+
* guarantee — instead of one atomic `TransactWriteItems`. Synthesized only by
|
|
1074
|
+
* the command-contract serializer for a `mode: 'batchWrite'` method (the
|
|
1075
|
+
* 0.9.0 default for an unconditional put / delete): a single `forEach`-over-
|
|
1076
|
+
* `items` write item whose element carries the FULL per-item payload (key +
|
|
1077
|
+
* input fields), so each item binds its own values.
|
|
1078
|
+
*
|
|
1079
|
+
* Fail-closed on both sides: the emitter only stamps this on a spec whose
|
|
1080
|
+
* every item is an **unconditional** `Put` / `Delete` `forEach` (DynamoDB's
|
|
1081
|
+
* `BatchWriteItem` carries no `ConditionExpression` and no `Update`), and the
|
|
1082
|
+
* runtimes' `executeTransaction` loud-rejects a marked spec (it must go
|
|
1083
|
+
* through `executeBatchWrite`) while `executeBatchWrite` loud-rejects an
|
|
1084
|
+
* unmarked one. Absent on every atomic transaction, so those serialize
|
|
1085
|
+
* byte-identically to the pre-#298 spec.
|
|
1086
|
+
*/
|
|
1087
|
+
readonly batchWrite?: true;
|
|
895
1088
|
}
|
|
896
1089
|
/**
|
|
897
1090
|
* Whether a contract is a public **read** (`'query'`) or **write** (`'command'`)
|
|
@@ -1084,6 +1277,20 @@ type CommandResolutionTarget =
|
|
|
1084
1277
|
| {
|
|
1085
1278
|
readonly mode: 'parallel';
|
|
1086
1279
|
readonly operation: string;
|
|
1280
|
+
}
|
|
1281
|
+
/**
|
|
1282
|
+
* A non-atomic **BatchWriteItem** bulk write with per-item values (issue
|
|
1283
|
+
* #298; the 0.9.0 DEFAULT for an unconditional put / delete). References the
|
|
1284
|
+
* synthesized `<Contract>__<method>__batchWrite` {@link TransactionSpec} in
|
|
1285
|
+
* `transactions` (stamped {@link TransactionSpec.batchWrite}): a single
|
|
1286
|
+
* `forEach`-over-`items` write whose array element carries the FULL per-item
|
|
1287
|
+
* payload (key + input fields). The runtimes execute it through their
|
|
1288
|
+
* `BatchWriteItem` machinery — any array size, chunked ≤25 per request with
|
|
1289
|
+
* `UnprocessedItems` exponential retry, 1×WCU, no conditions, non-atomic.
|
|
1290
|
+
*/
|
|
1291
|
+
| {
|
|
1292
|
+
readonly mode: 'batchWrite';
|
|
1293
|
+
readonly transaction: string;
|
|
1087
1294
|
};
|
|
1088
1295
|
/**
|
|
1089
1296
|
* The serialized spec of one **command** contract method. Symmetric to
|
|
@@ -1170,6 +1377,50 @@ interface ContextSpec {
|
|
|
1170
1377
|
/** Contract names owned by this context (sorted; `contracts` map keys). */
|
|
1171
1378
|
readonly contracts: readonly string[];
|
|
1172
1379
|
}
|
|
1380
|
+
/**
|
|
1381
|
+
* The PORTABLE form of a read operation — what `operations.json` actually
|
|
1382
|
+
* carries since SCP IR Phase 3 (#290 P3-5): the physical **root** op minus the
|
|
1383
|
+
* proprietary relation wiring (`resultPath` / `sourceField` / `sourceList`).
|
|
1384
|
+
* That wiring now exists ONLY inside the build pipeline ({@link OperationSpec},
|
|
1385
|
+
* feeding the `components[]` lowering and the TS AOT prepared plan) and never
|
|
1386
|
+
* reaches the portable IR — relation execution is expressed exclusively by the
|
|
1387
|
+
* universal SCP component graph (`components[]`).
|
|
1388
|
+
*/
|
|
1389
|
+
type PortableOperationSpec = Omit<OperationSpec, 'resultPath' | 'sourceField' | 'sourceList'>;
|
|
1390
|
+
/**
|
|
1391
|
+
* The PORTABLE form of a query (#290 P3-5). `operations` carries exactly ONE
|
|
1392
|
+
* entry — the root physical op (the still-live single-op surfaces: the contract
|
|
1393
|
+
* key-array point-batch reads its `keyExpr` / `projection`; `explain` renders
|
|
1394
|
+
* it). Relation fan-out and staging live ONLY in `components[]`, so the old
|
|
1395
|
+
* relation operations and the `executionPlan` are not emitted.
|
|
1396
|
+
*/
|
|
1397
|
+
interface PortableQuerySpec {
|
|
1398
|
+
readonly params: Readonly<Record<string, ParamSpec>>;
|
|
1399
|
+
/** Exactly one entry: the root physical operation. */
|
|
1400
|
+
readonly operations: readonly PortableOperationSpec[];
|
|
1401
|
+
/** See {@link QuerySpec.cardinality}. */
|
|
1402
|
+
readonly cardinality?: 'one' | 'many';
|
|
1403
|
+
/** See {@link QuerySpec.description}. */
|
|
1404
|
+
readonly description?: string;
|
|
1405
|
+
}
|
|
1406
|
+
/**
|
|
1407
|
+
* The PORTABLE form of a declarative transaction (#290 P3-5): only the input
|
|
1408
|
+
* contract (`params`, read by every runtime's `validate_params` surface). The
|
|
1409
|
+
* old templated item bodies (`items[]` with `forEach` / `{item.*}` templates)
|
|
1410
|
+
* are not emitted — the write plan lives ONLY in the transaction's
|
|
1411
|
+
* `components[]` entry, which the runtimes execute via `runBehavior`.
|
|
1412
|
+
*/
|
|
1413
|
+
interface PortableTransactionSpec {
|
|
1414
|
+
readonly params: Readonly<Record<string, ParamSpec>>;
|
|
1415
|
+
/**
|
|
1416
|
+
* Marks the `BatchWriteItem` bulk form (issue #298 — see
|
|
1417
|
+
* {@link TransactionSpec.batchWrite}). Portable ON PURPOSE: it is the
|
|
1418
|
+
* runtimes' fail-closed dispatch signal (`executeBatchWrite` requires it,
|
|
1419
|
+
* `executeTransaction` rejects it) and the codegen signal for the per-item
|
|
1420
|
+
* `*BatchWrite` generated-method shape. Absent on every atomic transaction.
|
|
1421
|
+
*/
|
|
1422
|
+
readonly batchWrite?: true;
|
|
1423
|
+
}
|
|
1173
1424
|
interface OperationsDocument {
|
|
1174
1425
|
/**
|
|
1175
1426
|
* `1.1` unless the document actually contains an SCP Expression IR node (a
|
|
@@ -1177,10 +1428,18 @@ interface OperationsDocument {
|
|
|
1177
1428
|
* (issue #261, conditional stamping — see {@link SPEC_VERSION_SCP}).
|
|
1178
1429
|
*/
|
|
1179
1430
|
readonly version: SpecVersion;
|
|
1180
|
-
|
|
1431
|
+
/**
|
|
1432
|
+
* Portable query specs (#290 P3-5): the root physical op + params only; the
|
|
1433
|
+
* relation wiring lives in {@link components}.
|
|
1434
|
+
*/
|
|
1435
|
+
readonly queries: Readonly<Record<string, PortableQuerySpec>>;
|
|
1181
1436
|
readonly commands: Readonly<Record<string, CommandSpec>>;
|
|
1182
|
-
/**
|
|
1183
|
-
|
|
1437
|
+
/**
|
|
1438
|
+
* Declarative transactions (issue #46). Absent in pre-#46 specs. Since #290
|
|
1439
|
+
* P3-5 only the params contract is emitted; the write plan lives in
|
|
1440
|
+
* {@link components}.
|
|
1441
|
+
*/
|
|
1442
|
+
readonly transactions?: Readonly<Record<string, PortableTransactionSpec>>;
|
|
1184
1443
|
/**
|
|
1185
1444
|
* The CQRS Contract layer (issue #59): contract name → {@link ContractSpec}.
|
|
1186
1445
|
* Layered **on top of** the existing `queries` / `commands` / `transactions`
|
|
@@ -1195,6 +1454,18 @@ interface OperationsDocument {
|
|
|
1195
1454
|
* foreign. **Absent** when no contexts are declared (backward compatibility).
|
|
1196
1455
|
*/
|
|
1197
1456
|
readonly contexts?: Readonly<Record<string, ContextSpec>>;
|
|
1457
|
+
/**
|
|
1458
|
+
* The universal SCP **component-graph** (issue #290, Phase 3). The queries /
|
|
1459
|
+
* transactions lifted into behavior-contracts `Component[]` (name /
|
|
1460
|
+
* inputPorts / body / output / plan, `scp-ir-architecture.md` §5). Since the
|
|
1461
|
+
* P3-5 flip this is the ONLY carrier of relation fan-out and transaction
|
|
1462
|
+
* write plans in the portable IR — every spec-consumer runtime
|
|
1463
|
+
* (py/php/rust/go) executes reads and transactions via `runBehavior` over
|
|
1464
|
+
* this graph, and the typed-binding / docs generators reconstruct the result
|
|
1465
|
+
* shape from it. **Absent** when the input defines no queries or
|
|
1466
|
+
* transactions (backward compatible).
|
|
1467
|
+
*/
|
|
1468
|
+
readonly components?: readonly Component[];
|
|
1198
1469
|
}
|
|
1199
1470
|
/** The full `{ manifest, operations }` bundle produced by the static planner. */
|
|
1200
1471
|
interface BridgeBundle {
|
|
@@ -1202,4 +1473,4 @@ interface BridgeBundle {
|
|
|
1202
1473
|
readonly operations: OperationsDocument;
|
|
1203
1474
|
}
|
|
1204
1475
|
|
|
1205
|
-
export { type
|
|
1476
|
+
export { type WriteOperationType as $, type ManifestEntity as A, type BridgeBundle as B, type ContractSpec as C, type ManifestField as D, type ExpressionSpec as E, type FilterSpec as F, type ManifestFieldType as G, type ManifestGsi as H, type ManifestKey as I, type ManifestRelation as J, type ManifestTable as K, type OperationSpec as L, type Manifest as M, type QueryContractMethodSpec as N, type OperationsDocument as O, type ParamSpec as P, type QuerySpec as Q, type RangeConditionSpec as R, SPEC_VERSION_KEY_EXPR as S, type TransactionSpec as T, type ReadOperationType as U, SPEC_VERSION as V, SPEC_VERSION_SCP as W, SPEC_VERSION_SUPPORTED as X, type TransactionItemSpec as Y, type TransactionItemType as Z, type WhenSpec as _, type CommandSpec as a, type LiteralParam as a0, type MapParam as a1, type NumberParam as a2, type Param as a3, type ParamKind as a4, type StringParam as a5, param as a6, type ContextSpec as b, type ConditionSpec as c, type SpecVersion as d, type CommandContractMethodSpec as e, type CommandResolutionTarget as f, type ComposeSpec as g, type CompositionPlanSpec as h, type ContractCardinality as i, type ContractCommandResult as j, type ContractInputArity as k, type ContractKeySpec as l, type ContractKind as m, type ContractResolution as n, EXPR_VERSION as o, type ExecutionPlanSpec as p, type ExpressionArrNode as q, type ExpressionFloatNode as r, type ExpressionIntNode as s, type ExpressionNode as t, type ExpressionObjNode as u, type ExpressionOpNode as v, type ExpressionOperator as w, type ExpressionRefNode as x, type ExpressionRefOptNode as y, type ExpressionScalar as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as SegmentedKey, e as ProjectionTransform, f as MaintainEvent, g as ProjectionMap, h as MaintainConsistency, i as MaintainUpdateMode, E as EffectPath, j as MembershipPredicate } from './key-
|
|
1
|
+
import { d as SegmentedKey, e as ProjectionTransform, f as MaintainEvent, g as ProjectionMap, h as MaintainConsistency, i as MaintainUpdateMode, E as EffectPath, j as MembershipPredicate } from './key-CWytoEaE.js';
|
|
2
2
|
|
|
3
3
|
type DynamoType = 'S' | 'N' | 'BOOL' | 'B' | 'SS' | 'NS' | 'L' | 'M';
|
|
4
4
|
interface FieldOptions {
|
package/docs/python-bridge.md
CHANGED
|
@@ -276,63 +276,46 @@ Every operation carries a `params` map of `ParamSpec`:
|
|
|
276
276
|
|
|
277
277
|
#### Queries
|
|
278
278
|
|
|
279
|
-
A `QuerySpec` has `params`, an
|
|
280
|
-
(`"one"` or `"many"`).
|
|
279
|
+
A `QuerySpec` has `params`, an `operations` array carrying exactly **one**
|
|
280
|
+
entry — the root physical op — and a `cardinality` (`"one"` or `"many"`).
|
|
281
|
+
Since SCP IR Phase 3 (#290 P3-5) relation fan-out is NOT part of `queries`:
|
|
282
|
+
it lives exclusively in the universal `components[]` graph (below). The root
|
|
283
|
+
`OperationSpec`:
|
|
281
284
|
|
|
282
285
|
```jsonc
|
|
283
286
|
{
|
|
284
287
|
"type": "Query", // "Query" | "GetItem" | "BatchGetItem"
|
|
285
288
|
"tableName": "UserPermissions",
|
|
286
289
|
"indexName": "GSI1", // omitted for base-table access
|
|
287
|
-
"keyCondition": { "GSI1PK": "EMAIL#{email}", "GSI1SK": "PROFILE" },
|
|
288
|
-
"rangeCondition": { "operator": "begins_with", "key": "SK", "value": "USER#" },
|
|
289
290
|
"projection": ["email", "name", "status", "userId"],
|
|
291
|
+
"keyExpr": { "GSI1PK": { "concat": ["EMAIL#", { "ref": ["input", "email"] }] },
|
|
292
|
+
"GSI1SK": "PROFILE" },
|
|
293
|
+
"rangeCondition": { "operator": "begins_with", "key": "SK", "valueExpr": "USER#" },
|
|
290
294
|
"limit": 20,
|
|
291
|
-
"filter": { /* declarative FilterExpression */ }
|
|
292
|
-
"resultPath": "$", // "$" or e.g. "$.groups.items"
|
|
293
|
-
"sourceField": "userId" // present on relation child operations
|
|
295
|
+
"filter": { /* declarative FilterExpression */ }
|
|
294
296
|
}
|
|
295
297
|
```
|
|
296
298
|
|
|
297
299
|
The operation type is chosen by the planner from the key shape: a full PK+SK is
|
|
298
300
|
a `GetItem`; a partial key with a contiguous sort-key prefix is a `Query` with a
|
|
299
301
|
`begins_with` `rangeCondition`; a partition-key-only access is a `Query`. The
|
|
300
|
-
`projection` is the set of scalar fields selected `true`.
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
A relation traversal is expressed as additional `OperationSpec` nodes in the same
|
|
319
|
-
query's `operations` array. Each child references its parent through
|
|
320
|
-
`{result.sourceField}` in its `keyCondition`, and its `resultPath` nests the
|
|
321
|
-
result under the parent (`$.groups.items` for a `hasMany`, `$.account` for a
|
|
322
|
-
`belongsTo` / `hasOne`). `belongsTo` / `hasOne` children are emitted as
|
|
323
|
-
`BatchGetItem`; `hasMany` children as `Query`.
|
|
324
|
-
|
|
325
|
-
A query may carry an `executionPlan`:
|
|
326
|
-
|
|
327
|
-
```jsonc
|
|
328
|
-
{ "groups": [[1, 2], [3]], "concurrency": 16 }
|
|
329
|
-
```
|
|
330
|
-
|
|
331
|
-
`groups` is an ordered list of stages of operation indices (the root, index 0,
|
|
332
|
-
is implicit and runs first). Operations within a stage are mutually independent
|
|
333
|
-
and may run concurrently; later stages may read `{result.*}` produced by earlier
|
|
334
|
-
ones. The same `deriveExecutionPlan` routine is used by the generator and by the
|
|
335
|
-
TypeScript runtime, so the staging cannot drift between them.
|
|
302
|
+
`projection` is the set of scalar fields selected `true`. The key wiring is
|
|
303
|
+
portable Expression IR (`keyExpr` / `valueExpr`, #289), derived by **symbolic
|
|
304
|
+
evaluation** of the model's key mapping. The runtime executes the root op via
|
|
305
|
+
its `components[]` entry; the emitted root op remains the validation /
|
|
306
|
+
`explain` / contract point-batch surface.
|
|
307
|
+
|
|
308
|
+
#### Relation chaining and staging (`components[]`)
|
|
309
|
+
|
|
310
|
+
A relation traversal is expressed as the query's entry in the top-level
|
|
311
|
+
`components[]` — the universal SCP component graph (behavior-contracts
|
|
312
|
+
`Component`): the root op becomes a `componentRef` body node, each relation a
|
|
313
|
+
`componentRef` / `map` node whose id is the dotted result path
|
|
314
|
+
(`groups.items`, `groups.items.group`), wired to its producer via `parent`
|
|
315
|
+
and executed by `run_behavior` with the DynamoDB catalog handlers. A
|
|
316
|
+
multi-node component carries a `plan` (`{ "groups": [[0], [1, 2]],
|
|
317
|
+
"concurrency": 16 }`) staging mutually-independent nodes; the shared executor
|
|
318
|
+
honors it.
|
|
336
319
|
|
|
337
320
|
#### Commands
|
|
338
321
|
|
|
@@ -581,8 +564,9 @@ resuming with a cursor for the wrong key is rejected.
|
|
|
581
564
|
|
|
582
565
|
### 7.6 Relations, Batch, and Concurrency
|
|
583
566
|
|
|
584
|
-
Relation
|
|
585
|
-
|
|
567
|
+
Relation nodes of the query's `components[]` entry are resolved against the
|
|
568
|
+
parents produced by earlier nodes and folded into the result at their node id
|
|
569
|
+
path:
|
|
586
570
|
|
|
587
571
|
- **`belongsTo` / `hasOne`** — source values from all parents are deduplicated
|
|
588
572
|
and fetched in a single `BatchGetItem`, then matched back to each parent (a
|
|
@@ -592,10 +576,10 @@ operations and merged into the result at their `resultPath`:
|
|
|
592
576
|
|
|
593
577
|
`BatchGetItem` requests are chunked at 100 keys, deduplicated, and retried on
|
|
594
578
|
`UnprocessedKeys` with capped exponential backoff (up to 10 attempts).
|
|
595
|
-
`BatchWriteItem` is chunked at 25 with the same `UnprocessedItems` retry.
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
579
|
+
`BatchWriteItem` is chunked at 25 with the same `UnprocessedItems` retry. Node
|
|
580
|
+
staging follows the component's `plan` inside the shared `run_behavior`
|
|
581
|
+
executor (deterministic in-order reference semantics). Result order is
|
|
582
|
+
preserved.
|
|
599
583
|
|
|
600
584
|
### 7.7 Transactions
|
|
601
585
|
|