graphddb 0.6.0 → 0.7.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/dist/cdc/index.d.ts +2 -2
- package/dist/{chunk-N5NQM3SO.js → chunk-GFGVDF4W.js} +500 -12
- package/dist/cli.js +155 -6
- package/dist/{from-change-CFzBy7aU.d.ts → from-change-pnURY-cV.d.ts} +1 -1
- package/dist/{index-CtJbTrfB.d.ts → index-Eg94ChE1.d.ts} +2 -2
- package/dist/index.d.ts +6 -6
- package/dist/index.js +11 -1
- package/dist/linter/index.d.ts +4 -4
- package/dist/{maintenance-view-adapter-CFeasCKo.d.ts → maintenance-view-adapter-BP2CJDdz.d.ts} +2489 -2245
- package/dist/{registry-DbqmFyab.d.ts → registry-Cv9nl_3i.d.ts} +1 -1
- package/dist/{relation-depth-0TiWr5OW.d.ts → relation-depth-BR0y7Q1i.d.ts} +1 -1
- package/dist/spec/index.d.ts +3 -3
- package/dist/spec/index.js +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/transform/index.d.ts +167 -0
- package/dist/transform/index.js +719 -0
- package/docs/prepared-statements.md +165 -0
- package/package.json +5 -1
package/dist/spec/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { $ as BridgeBundle, a1 as CommandContractMethodSpec, a2 as CommandResolutionTarget, L as CommandSpec, a3 as CompiledFragment, a4 as CompiledMutationPlan, a5 as ComposeSpec, a6 as CompositionPlanSpec, a0 as ConditionSpec, O as ContextSpec, a7 as ContractCardinality, a8 as ContractCommandResult, a9 as ContractInputArity, aa as ContractKeySpec, ab as ContractKind, ac as ContractResolution, J as ContractSpec, ad as DerivedConditionCheck, ae as DerivedEdgeWrite, af as DerivedIdempotencyGuard, ag as DerivedMaintainOutbox, ah as DerivedMaintainWrite, ai as DerivedOutboxEvent, aj as DerivedUniqueGuard, ak as DerivedUpdate, al as EntityRefResolver, am as ExecutionPlanSpec, an as FilterSpec, ao as MAX_TRANSACT_COMPOSE_ITEMS, _ as Manifest, ap as ManifestEntity, aq as ManifestField, ar as ManifestFieldType, as as ManifestGsi, at as ManifestKey, au as ManifestRelation, av as ManifestTable, aw as OperationSpec, Y as OperationsDocument, ax as ParamSpec, ay as QueryContractMethodSpec, K as QuerySpec, az as RangeConditionSpec, aA as ReadOperationType, aB as SPEC_VERSION, aC as TransactionItemSpec, aD as TransactionItemType, N as TransactionSpec, aE as WhenSpec, aF as WriteOperationType, aG as assertNoCrossFragmentMaintainCollision, aH as compileFragment, aI as compileMutationPlan, aJ as compileSingleFragmentPlan, aK as resetMaintenanceGraphCache, aL as resolveLifecycle, aM as resolveMaintainers } from '../maintenance-view-adapter-
|
|
2
|
-
export { A as AnyModelContract, B as BuiltContracts, C as ContextOwnership, a as ContextOwnershipMap, b as ContractBoundaryViolation, c as ContractInputs, d as ContractMap, e as ContractN1Violation, o as assertBundleSerializable, p as assertContractBoundaries, q as assertContractN1Safe, r as assertJsonSerializable, s as assertSupportedCondition, t as buildBridgeBundle, u as buildContexts, v as buildContracts, w as buildManifest, x as buildOperations, y as buildQuerySpec, z as buildTransactionSpec, D as buildTransactions, E as collectContractBoundaryViolations, F as collectContractN1Violations } from '../index-
|
|
3
|
-
import '../registry-
|
|
1
|
+
export { $ as BridgeBundle, a1 as CommandContractMethodSpec, a2 as CommandResolutionTarget, L as CommandSpec, a3 as CompiledFragment, a4 as CompiledMutationPlan, a5 as ComposeSpec, a6 as CompositionPlanSpec, a0 as ConditionSpec, O as ContextSpec, a7 as ContractCardinality, a8 as ContractCommandResult, a9 as ContractInputArity, aa as ContractKeySpec, ab as ContractKind, ac as ContractResolution, J as ContractSpec, ad as DerivedConditionCheck, ae as DerivedEdgeWrite, af as DerivedIdempotencyGuard, ag as DerivedMaintainOutbox, ah as DerivedMaintainWrite, ai as DerivedOutboxEvent, aj as DerivedUniqueGuard, ak as DerivedUpdate, al as EntityRefResolver, am as ExecutionPlanSpec, an as FilterSpec, ao as MAX_TRANSACT_COMPOSE_ITEMS, _ as Manifest, ap as ManifestEntity, aq as ManifestField, ar as ManifestFieldType, as as ManifestGsi, at as ManifestKey, au as ManifestRelation, av as ManifestTable, aw as OperationSpec, Y as OperationsDocument, ax as ParamSpec, ay as QueryContractMethodSpec, K as QuerySpec, az as RangeConditionSpec, aA as ReadOperationType, aB as SPEC_VERSION, aC as TransactionItemSpec, aD as TransactionItemType, N as TransactionSpec, aE as WhenSpec, aF as WriteOperationType, aG as assertNoCrossFragmentMaintainCollision, aH as compileFragment, aI as compileMutationPlan, aJ as compileSingleFragmentPlan, aK as resetMaintenanceGraphCache, aL as resolveLifecycle, aM as resolveMaintainers } from '../maintenance-view-adapter-BP2CJDdz.js';
|
|
2
|
+
export { A as AnyModelContract, B as BuiltContracts, C as ContextOwnership, a as ContextOwnershipMap, b as ContractBoundaryViolation, c as ContractInputs, d as ContractMap, e as ContractN1Violation, o as assertBundleSerializable, p as assertContractBoundaries, q as assertContractN1Safe, r as assertJsonSerializable, s as assertSupportedCondition, t as buildBridgeBundle, u as buildContexts, v as buildContracts, w as buildManifest, x as buildOperations, y as buildQuerySpec, z as buildTransactionSpec, D as buildTransactions, E as collectContractBoundaryViolations, F as collectContractN1Violations } from '../index-Eg94ChE1.js';
|
|
3
|
+
import '../registry-Cv9nl_3i.js';
|
|
4
4
|
import '@aws-sdk/client-dynamodb';
|
package/dist/spec/index.js
CHANGED
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as Executor, D as DynamoDBOperation, o as ReadExecOptions, p as ExecutorResult, q as BatchGetExecInput, P as PutInput, W as WriteExecOptions, r as WriteResult, s as UpdateInput, t as DeleteInput, u as BatchWriteExecItem, v as BatchExecOptions, T as TransactWriteExecItem, M as ModelStatic, w as DDBModel, c as ChangeEvent } from '../maintenance-view-adapter-
|
|
1
|
+
import { n as Executor, D as DynamoDBOperation, o as ReadExecOptions, p as ExecutorResult, q as BatchGetExecInput, P as PutInput, W as WriteExecOptions, r as WriteResult, s as UpdateInput, t as DeleteInput, u as BatchWriteExecItem, v as BatchExecOptions, T as TransactWriteExecItem, M as ModelStatic, w as DDBModel, c as ChangeEvent } from '../maintenance-view-adapter-BP2CJDdz.js';
|
|
2
2
|
import '@aws-sdk/client-dynamodb';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compile-time hoist transform + no-runtime-capture build lint for
|
|
3
|
+
* `DDBModel.prepare` (issue #206, design #203 — phase 2 on top of the phase-1
|
|
4
|
+
* runtime in `src/runtime/prepared.ts`).
|
|
5
|
+
*
|
|
6
|
+
* ## What it does
|
|
7
|
+
*
|
|
8
|
+
* A **source-to-source** pass (TypeScript compiler API, purely syntactic — no
|
|
9
|
+
* type checker, no module loading) over user source files:
|
|
10
|
+
*
|
|
11
|
+
* 1. **Detect** every `DDBModel.prepare(fn)` call site (through import aliases,
|
|
12
|
+
* namespace imports, module-const aliases, and same-file `extends DDBModel`
|
|
13
|
+
* subclasses).
|
|
14
|
+
* 2. **Statically verify no-runtime-capture** — the design's key constraint
|
|
15
|
+
* (#203): the body may reference only its own `$` parameter (per-call
|
|
16
|
+
* values) and **module-static** bindings (imports, module-scope `const` /
|
|
17
|
+
* `class` / `function` / `enum` — the `() => Model` refs). Any reference to
|
|
18
|
+
* an enclosing function's binding (a parameter, an outer `let` / `const`,
|
|
19
|
+
* `this`), any mutable module state (`let` / `var`), any call / `new` /
|
|
20
|
+
* conditional / computed expression inside the body — including **indirect
|
|
21
|
+
* capture via helper calls** — is a **loud build error**.
|
|
22
|
+
* 3. **Hoist** each verified inline call site: the call expression is wrapped
|
|
23
|
+
* into a module-scope **lazy memoization slot** —
|
|
24
|
+
*
|
|
25
|
+
* ```ts
|
|
26
|
+
* let __gddbPrepared1; // module scope, after imports
|
|
27
|
+
* // ... inside the hot function, the call site becomes:
|
|
28
|
+
* (__gddbPrepared1 ??= DDBModel.prepare(($) => ({ ... }))).execute(params)
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* so the body is evaluated and the plan compiled **exactly once** for the
|
|
32
|
+
* module (first call), and every subsequent call is a single nullish check
|
|
33
|
+
* straight into `.execute` — **zero per-op planning / compiling / structure
|
|
34
|
+
* hashing**, identical to a hand-hoisted module-level handle.
|
|
35
|
+
*
|
|
36
|
+
* ## Why a lazy slot and not an eager module `const`
|
|
37
|
+
*
|
|
38
|
+
* `prepare()` resolves its `() => Model` thunks immediately. An eager
|
|
39
|
+
* `const __p = DDBModel.prepare(...)` hoisted above a `class User` declared
|
|
40
|
+
* later in the same file would hit the TDZ at module init; hoisted below it, a
|
|
41
|
+
* mid-file IIFE could still observe the TDZ. The lazy slot keeps the original
|
|
42
|
+
* expression **lexically in place** (every reference resolves exactly as
|
|
43
|
+
* before) and defers the one-time compile to the first call — the same moment
|
|
44
|
+
* the untransformed code would have compiled it. Evaluation ORDER and error
|
|
45
|
+
* timing are therefore identical to the untransformed build for the first
|
|
46
|
+
* call, and per-op cost is zero afterwards. Results are identical by
|
|
47
|
+
* construction: the transform never rewrites the body, only memoizes the
|
|
48
|
+
* handle (which the phase-1 runtime already guarantees is reusable — that is
|
|
49
|
+
* what its structural-memoization fallback relies on).
|
|
50
|
+
*
|
|
51
|
+
* ## The static lint: a declarative whitelist, transitively applied
|
|
52
|
+
*
|
|
53
|
+
* Rather than trying to enumerate the infinite ways a per-call value can leak
|
|
54
|
+
* into the body (blacklisting), the lint accepts only the **declarative
|
|
55
|
+
* grammar** the prepared runtime itself accepts — everything else is a loud
|
|
56
|
+
* error:
|
|
57
|
+
*
|
|
58
|
+
* - object / array literals (non-computed keys), string / number / boolean /
|
|
59
|
+
* bigint / `null` literals, no-substitution template literals, unary `+`/`-`
|
|
60
|
+
* on numeric literals, `as` / `satisfies` / parenthesized wrappers;
|
|
61
|
+
* - `$.<name>` — exactly one property level on the body's own parameter
|
|
62
|
+
* (deeper access is rejected, mirroring the runtime proxy);
|
|
63
|
+
* - identifiers / property chains that resolve to **module-static** bindings
|
|
64
|
+
* (imports, module `const` / `class` / `function` / `enum`). A module-const
|
|
65
|
+
* initializer referenced from a body (a shared select template, a
|
|
66
|
+
* module-const alias) is **transitively linted** against the same
|
|
67
|
+
* whitelist, so an indirect capture through a same-file "helper constant"
|
|
68
|
+
* is caught;
|
|
69
|
+
* - zero-parameter arrows / functions whose body is a single reference chain
|
|
70
|
+
* to a module-static binding (the `() => Model` refs).
|
|
71
|
+
*
|
|
72
|
+
* Rejected (loud, with the precise source position): references that resolve
|
|
73
|
+
* to an **enclosing function scope** (direct capture — parameters, outer
|
|
74
|
+
* `let`/`const`/`var`); module-scope `let` / `var` (mutable module state — a
|
|
75
|
+
* hoisted body would freeze it, an inline body would not; results MUST match);
|
|
76
|
+
* **any call or `new` expression** (a helper call is an indirect-capture
|
|
77
|
+
* channel the pass cannot see through, and even a pure-looking global like
|
|
78
|
+
* `Date.now()` is a fresh per-call value); unresolved (global) identifiers;
|
|
79
|
+
* conditionals / binary operators / substitution templates / computed keys
|
|
80
|
+
* (per-call control flow); `this`; bodies that are not statically visible
|
|
81
|
+
* functions (a body passed through a variable of function scope, a call
|
|
82
|
+
* result).
|
|
83
|
+
*
|
|
84
|
+
* ### Known limits (documented, backstopped at runtime)
|
|
85
|
+
*
|
|
86
|
+
* The pass is per-file and syntactic. Two things it cannot prove:
|
|
87
|
+
*
|
|
88
|
+
* - a binding **imported from another module** is accepted as module-static
|
|
89
|
+
* (that is the design's allowance — `() => Model` refs are imports); a
|
|
90
|
+
* pathological mutable re-exported `let`, or a cross-module template
|
|
91
|
+
* object mutated elsewhere, is not visible per-file;
|
|
92
|
+
* - mutation of a same-file module-const **object** between calls.
|
|
93
|
+
*
|
|
94
|
+
* Both are backstopped by the phase-1 **runtime** no-capture guard
|
|
95
|
+
* (`assertNoRuntimeCapture` — only `$`-refs and scalar static literals are
|
|
96
|
+
* bindable value leaves), so a per-call object smuggled through module state
|
|
97
|
+
* still rejects loudly at runtime; and by the fact that the transform never
|
|
98
|
+
* changes results — an unhoistable site left untransformed falls back to the
|
|
99
|
+
* phase-1 structural-memoization path (correct, merely warmer).
|
|
100
|
+
*/
|
|
101
|
+
/** Diagnostic codes emitted by the lint / transform pass. */
|
|
102
|
+
type PreparedDiagnosticCode =
|
|
103
|
+
/** A reference to an enclosing function's binding (direct per-call capture). */
|
|
104
|
+
'runtime-capture'
|
|
105
|
+
/** A reference to module-scope `let` / `var` (mutable module state). */
|
|
106
|
+
| 'mutable-module-state'
|
|
107
|
+
/** An unresolved (global / ambient) identifier — not `$`, not module-static. */
|
|
108
|
+
| 'non-static-reference'
|
|
109
|
+
/** A call / `new` inside the body — the indirect-capture channel. */
|
|
110
|
+
| 'call-in-body'
|
|
111
|
+
/** A non-declarative expression (conditional, binary op, template subst, …). */
|
|
112
|
+
| 'impure-expression'
|
|
113
|
+
/** `$.<a>.<b>` — deeper than the single supported property level. */
|
|
114
|
+
| 'param-deep-access'
|
|
115
|
+
/** The `prepare` argument is not a statically visible function body. */
|
|
116
|
+
| 'unverifiable-body'
|
|
117
|
+
/** Informational: an inline call site the transform hoists (check mode). */
|
|
118
|
+
| 'hoistable';
|
|
119
|
+
/** One lint / transform diagnostic, positioned in the original source. */
|
|
120
|
+
interface PreparedDiagnostic {
|
|
121
|
+
readonly code: PreparedDiagnosticCode;
|
|
122
|
+
readonly category: 'error' | 'note';
|
|
123
|
+
readonly message: string;
|
|
124
|
+
readonly file: string;
|
|
125
|
+
/** 1-based line in the ORIGINAL source text. */
|
|
126
|
+
readonly line: number;
|
|
127
|
+
/** 1-based column in the ORIGINAL source text. */
|
|
128
|
+
readonly column: number;
|
|
129
|
+
}
|
|
130
|
+
/** Result of {@link transformPreparedSource} on one source file. */
|
|
131
|
+
interface PreparedTransformResult {
|
|
132
|
+
readonly fileName: string;
|
|
133
|
+
/** The transformed source (identical to the input when nothing changed). */
|
|
134
|
+
readonly text: string;
|
|
135
|
+
readonly changed: boolean;
|
|
136
|
+
/** Inline call sites normalized to a module lazy slot in THIS run. */
|
|
137
|
+
readonly hoistedCount: number;
|
|
138
|
+
/** Call sites already evaluated once per module load (left as-is). */
|
|
139
|
+
readonly moduleScopeCount: number;
|
|
140
|
+
/** Call sites already normalized by a previous run (idempotence). */
|
|
141
|
+
readonly alreadyHoistedCount: number;
|
|
142
|
+
readonly diagnostics: readonly PreparedDiagnostic[];
|
|
143
|
+
/** Count of `category: 'error'` diagnostics (a build gate: non-zero fails). */
|
|
144
|
+
readonly errorCount: number;
|
|
145
|
+
}
|
|
146
|
+
interface PreparedTransformOptions {
|
|
147
|
+
/**
|
|
148
|
+
* `transform` (default) verifies AND rewrites; `lint` only verifies (the
|
|
149
|
+
* build-lint gate) and reports inline call sites as `hoistable` notes.
|
|
150
|
+
*/
|
|
151
|
+
readonly mode?: 'transform' | 'lint';
|
|
152
|
+
}
|
|
153
|
+
/** The identifier prefix used for generated module lazy slots. */
|
|
154
|
+
declare const HOIST_SLOT_PREFIX = "__gddbPrepared";
|
|
155
|
+
/**
|
|
156
|
+
* Lint (and, in `transform` mode, hoist-normalize) every `DDBModel.prepare`
|
|
157
|
+
* call site in one source file. See the module doc for the full contract.
|
|
158
|
+
*/
|
|
159
|
+
declare function transformPreparedSource(fileName: string, sourceText: string, options?: PreparedTransformOptions): PreparedTransformResult;
|
|
160
|
+
/**
|
|
161
|
+
* The build-lint gate: verify no-runtime-capture on every `DDBModel.prepare`
|
|
162
|
+
* body in the file WITHOUT rewriting. Inline (hoistable) call sites are
|
|
163
|
+
* reported as `hoistable` notes so a build can surface silent-slow fallbacks.
|
|
164
|
+
*/
|
|
165
|
+
declare function lintPreparedSource(fileName: string, sourceText: string): readonly PreparedDiagnostic[];
|
|
166
|
+
|
|
167
|
+
export { HOIST_SLOT_PREFIX, type PreparedDiagnostic, type PreparedDiagnosticCode, type PreparedTransformOptions, type PreparedTransformResult, lintPreparedSource, transformPreparedSource };
|