graphddb 0.6.0 → 0.7.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.
@@ -1,4 +1,4 @@
1
- import { m as EntityMetadata } from './maintenance-view-adapter-CFeasCKo.js';
1
+ import { m as EntityMetadata } from './maintenance-view-adapter-NBTZbE8-.js';
2
2
 
3
3
  interface LintRule {
4
4
  id: string;
@@ -1,4 +1,4 @@
1
- import { b as Linter, L as LintRule } from './registry-DbqmFyab.js';
1
+ import { b as Linter, L as LintRule } from './registry-BndKbZbg.js';
2
2
 
3
3
  /**
4
4
  * Creates a Linter pre-loaded with rules safe for Entity registration.
@@ -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-CFeasCKo.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-CtJbTrfB.js';
3
- import '../registry-DbqmFyab.js';
1
+ export { a2 as BridgeBundle, a4 as CommandContractMethodSpec, a5 as CommandResolutionTarget, H as CommandSpec, a6 as CompiledFragment, a7 as CompiledMutationPlan, a8 as ComposeSpec, a9 as CompositionPlanSpec, a3 as ConditionSpec, J as ContextSpec, aa as ContractCardinality, ab as ContractCommandResult, ac as ContractInputArity, ad as ContractKeySpec, ae as ContractKind, af as ContractResolution, A as ContractSpec, ag as DerivedConditionCheck, ah as DerivedEdgeWrite, ai as DerivedIdempotencyGuard, aj as DerivedMaintainOutbox, ak as DerivedMaintainWrite, al as DerivedOutboxEvent, am as DerivedUniqueGuard, an as DerivedUpdate, ao as EntityRefResolver, ap as ExecutionPlanSpec, aq as FilterSpec, ar as MAX_TRANSACT_COMPOSE_ITEMS, a1 as Manifest, as as ManifestEntity, at as ManifestField, au as ManifestFieldType, av as ManifestGsi, aw as ManifestKey, ax as ManifestRelation, ay as ManifestTable, az as OperationSpec, $ as OperationsDocument, L as ParamSpec, aA as QueryContractMethodSpec, G as QuerySpec, aB as RangeConditionSpec, aC as ReadOperationType, K as SPEC_VERSION, aD as TransactionItemSpec, aE as TransactionItemType, I as TransactionSpec, aF as WhenSpec, aG as WriteOperationType, aH as assertNoCrossFragmentMaintainCollision, aI as compileFragment, aJ as compileMutationPlan, aK as compileSingleFragmentPlan, aL as resetMaintenanceGraphCache, aM as resolveLifecycle, aN as resolveMaintainers } from '../maintenance-view-adapter-NBTZbE8-.js';
2
+ export { A as AnyModelContract, B as BuiltContracts, C as ContextOwnership, b as ContextOwnershipMap, c as ContractBoundaryViolation, d as ContractInputs, e as ContractMap, f as ContractN1Violation, O as PREPARED_FORMAT_VERSION, Q as PreparedBindMap, g as PreparedBindSpec, a as PreparedPlanDocument, h as PreparedPlanSpec, i as PreparedReadRouteSpec, P as PreparedWriteOpSpec, s as assertBundleSerializable, t as assertContractBoundaries, u as assertContractN1Safe, v as assertJsonSerializable, w as assertSupportedCondition, x as buildBridgeBundle, y as buildContexts, z as buildContracts, D as buildManifest, E as buildOperations, R as buildPreparedPlanDocument, F as buildQuerySpec, G as buildTransactionSpec, H as buildTransactions, S as canonicalJson, I as collectContractBoundaryViolations, J as collectContractN1Violations, U as compilePreparedPlan, V as entityFingerprint, X as planFingerprint } from '../index-CvS9ATKB.js';
3
+ import '../registry-BndKbZbg.js';
4
4
  import '@aws-sdk/client-dynamodb';
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  MAX_TRANSACT_COMPOSE_ITEMS,
3
+ PREPARED_FORMAT_VERSION,
3
4
  SPEC_VERSION,
4
5
  assertBundleSerializable,
5
6
  assertContractBoundaries,
@@ -12,22 +13,28 @@ import {
12
13
  buildContracts,
13
14
  buildManifest,
14
15
  buildOperations,
16
+ buildPreparedPlanDocument,
15
17
  buildQuerySpec,
16
18
  buildTransactionSpec,
17
19
  buildTransactions,
20
+ canonicalJson,
18
21
  collectContractBoundaryViolations,
19
22
  collectContractN1Violations,
20
23
  compileFragment,
21
24
  compileMutationPlan,
25
+ compilePreparedPlan,
22
26
  compileSingleFragmentPlan,
27
+ entityFingerprint,
28
+ planFingerprint,
23
29
  resetMaintenanceGraphCache,
24
30
  resolveLifecycle,
25
31
  resolveMaintainers
26
- } from "../chunk-N5NQM3SO.js";
32
+ } from "../chunk-C5Q2NMRW.js";
27
33
  import "../chunk-F2DI3GTI.js";
28
34
  import "../chunk-PDUVTYC5.js";
29
35
  export {
30
36
  MAX_TRANSACT_COMPOSE_ITEMS,
37
+ PREPARED_FORMAT_VERSION,
31
38
  SPEC_VERSION,
32
39
  assertBundleSerializable,
33
40
  assertContractBoundaries,
@@ -40,14 +47,19 @@ export {
40
47
  buildContracts,
41
48
  buildManifest,
42
49
  buildOperations,
50
+ buildPreparedPlanDocument,
43
51
  buildQuerySpec,
44
52
  buildTransactionSpec,
45
53
  buildTransactions,
54
+ canonicalJson,
46
55
  collectContractBoundaryViolations,
47
56
  collectContractN1Violations,
48
57
  compileFragment,
49
58
  compileMutationPlan,
59
+ compilePreparedPlan,
50
60
  compileSingleFragmentPlan,
61
+ entityFingerprint,
62
+ planFingerprint,
51
63
  resetMaintenanceGraphCache,
52
64
  resolveLifecycle,
53
65
  resolveMaintainers
@@ -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-CFeasCKo.js';
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-NBTZbE8-.js';
2
2
  import '@aws-sdk/client-dynamodb';
3
3
 
4
4
  /**
@@ -0,0 +1,216 @@
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
+ /** Informational (#208 --aot check mode): a `DDBModel.prepare` call site not
120
+ * yet rewritten to the static-plan loader (`--aot … --write` rewrites it). */
121
+ | 'aot-pending';
122
+ /** One lint / transform diagnostic, positioned in the original source. */
123
+ interface PreparedDiagnostic {
124
+ readonly code: PreparedDiagnosticCode;
125
+ readonly category: 'error' | 'note';
126
+ readonly message: string;
127
+ readonly file: string;
128
+ /** 1-based line in the ORIGINAL source text. */
129
+ readonly line: number;
130
+ /** 1-based column in the ORIGINAL source text. */
131
+ readonly column: number;
132
+ }
133
+ /** Result of {@link transformPreparedSource} on one source file. */
134
+ interface PreparedTransformResult {
135
+ readonly fileName: string;
136
+ /** The transformed source (identical to the input when nothing changed). */
137
+ readonly text: string;
138
+ readonly changed: boolean;
139
+ /** Inline call sites normalized to a module lazy slot in THIS run. */
140
+ readonly hoistedCount: number;
141
+ /** Call sites already evaluated once per module load (left as-is). */
142
+ readonly moduleScopeCount: number;
143
+ /** Call sites already normalized by a previous run (idempotence). */
144
+ readonly alreadyHoistedCount: number;
145
+ readonly diagnostics: readonly PreparedDiagnostic[];
146
+ /** Count of `category: 'error'` diagnostics (a build gate: non-zero fails). */
147
+ readonly errorCount: number;
148
+ }
149
+ interface PreparedTransformOptions {
150
+ /**
151
+ * `transform` (default) verifies AND rewrites; `lint` only verifies (the
152
+ * build-lint gate) and reports inline call sites as `hoistable` notes.
153
+ */
154
+ readonly mode?: 'transform' | 'lint';
155
+ }
156
+ /** The identifier prefix used for generated module lazy slots. */
157
+ declare const HOIST_SLOT_PREFIX = "__gddbPrepared";
158
+ /**
159
+ * Lint (and, in `transform` mode, hoist-normalize) every `DDBModel.prepare`
160
+ * call site in one source file. See the module doc for the full contract.
161
+ */
162
+ declare function transformPreparedSource(fileName: string, sourceText: string, options?: PreparedTransformOptions): PreparedTransformResult;
163
+ /**
164
+ * The build-lint gate: verify no-runtime-capture on every `DDBModel.prepare`
165
+ * body in the file WITHOUT rewriting. Inline (hoistable) call sites are
166
+ * reported as `hoistable` notes so a build can surface silent-slow fallbacks.
167
+ */
168
+ declare function lintPreparedSource(fileName: string, sourceText: string): readonly PreparedDiagnostic[];
169
+ /** The local identifier the rewrite binds `loadPreparedPlan` to. */
170
+ declare const AOT_LOADER_LOCAL = "__gddbLoadPreparedPlan";
171
+ /** The local identifier the rewrite binds the artifact document to. */
172
+ declare const AOT_PLANS_LOCAL = "__gddbPreparedPlans";
173
+ /** The named export of an evaluation shim: `{ <siteIndex>: <bodyFn> }`. */
174
+ declare const AOT_SHIM_EXPORT = "__gddbAotBodies";
175
+ /** One discovered prepared call site (either form), verified and numbered. */
176
+ interface PreparedAotSite {
177
+ /** 1-based document-order index within the file. */
178
+ readonly index: number;
179
+ /** The stable plan id: `<planIdPrefix>#<index>`. */
180
+ readonly planId: string;
181
+ /** `prepare` (original form) or `aot` (already rewritten). */
182
+ readonly form: 'prepare' | 'aot';
183
+ }
184
+ /** The per-file result of the AOT pass. */
185
+ interface PreparedAotFileResult {
186
+ readonly fileName: string;
187
+ /** The rewritten source (identical to the input in check mode / no change). */
188
+ readonly text: string;
189
+ readonly changed: boolean;
190
+ readonly sites: readonly PreparedAotSite[];
191
+ /**
192
+ * The evaluation-shim module source (present when the file has ≥1 verified
193
+ * site and no violations). Importing it yields `{ [AOT_SHIM_EXPORT]:
194
+ * Record<siteIndex, PreparedBody> }`.
195
+ */
196
+ readonly shimSource?: string;
197
+ readonly diagnostics: readonly PreparedDiagnostic[];
198
+ readonly errorCount: number;
199
+ }
200
+ interface PreparedAotOptions {
201
+ /** `transform` rewrites call sites; `check` only discovers + lints (drift mode). */
202
+ readonly mode: 'transform' | 'check';
203
+ /** The plan-id prefix — the project-relative source path (POSIX separators). */
204
+ readonly planIdPrefix: string;
205
+ /** The module specifier the rewrite imports the artifact document from. */
206
+ readonly artifactImport: string;
207
+ }
208
+ /**
209
+ * The #208 AOT pass over one source file: discover + verify every prepared call
210
+ * site (both forms), assign stable plan ids, build the evaluation shim, and (in
211
+ * `transform` mode) rewrite `DDBModel.prepare` sites to the static-plan loader.
212
+ * See the section header above for the full contract.
213
+ */
214
+ declare function transformPreparedSourceAot(fileName: string, sourceText: string, options: PreparedAotOptions): PreparedAotFileResult;
215
+
216
+ export { AOT_LOADER_LOCAL, AOT_PLANS_LOCAL, AOT_SHIM_EXPORT, HOIST_SLOT_PREFIX, type PreparedAotFileResult, type PreparedAotOptions, type PreparedAotSite, type PreparedDiagnostic, type PreparedDiagnosticCode, type PreparedTransformOptions, type PreparedTransformResult, lintPreparedSource, transformPreparedSource, transformPreparedSourceAot };