graphddb 0.7.9 → 0.7.10
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 +3 -2
- package/dist/cdc/index.js +3 -2
- package/dist/chunk-3UD3XIF2.js +860 -0
- package/dist/{chunk-PFFPLD4B.js → chunk-3ZU2VW3L.js} +2 -1190
- package/dist/{chunk-ZPNRLOKA.js → chunk-AD6ZQTTE.js} +4 -2
- package/dist/chunk-DFUKGU2Q.js +1197 -0
- package/dist/{chunk-NYM7K2ST.js → chunk-EOJDN3SA.js} +148 -660
- package/dist/cli.js +4 -2
- package/dist/{from-change-DanwjE5b.d.ts → from-change-Ty95KA8C.d.ts} +1 -1
- package/dist/{index-CtPJSMrc.d.ts → index-Dc7d8mWI.d.ts} +161 -6
- package/dist/index.d.ts +9 -7
- package/dist/index.js +108 -30
- package/dist/linter/index.d.ts +5 -4
- package/dist/{maintenance-view-adapter-BATUh_I8.d.ts → maintenance-view-adapter-BAZ9uBGe.d.ts} +20 -1051
- package/dist/{registry-CXhP4TaE.d.ts → registry-LWE54Sdc.d.ts} +1 -1
- package/dist/{relation-depth-Dg3yhl7S.d.ts → relation-depth-BRS513Tq.d.ts} +1 -1
- package/dist/spec/index.d.ts +4 -3
- package/dist/spec/index.js +18 -3
- package/dist/testing/index.d.ts +2 -1
- package/dist/testing/index.js +3 -2
- package/dist/transform/index.d.ts +460 -1
- package/dist/transform/index.js +2084 -1
- package/dist/types-BQLzTEqh.d.ts +1207 -0
- package/docs/python-bridge.md +17 -1
- package/package.json +7 -2
package/dist/{maintenance-view-adapter-BATUh_I8.d.ts → maintenance-view-adapter-BAZ9uBGe.d.ts}
RENAMED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
|
|
2
|
+
import { c as Param, E as ExpressionSpec, a0 as ParamKind, Y as TransactionItemSpec } from './types-BQLzTEqh.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* CDC emulator types (issue #72). These types are **cdc-module-owned**; core
|
|
@@ -291,138 +292,6 @@ type ResolvedKey = {
|
|
|
291
292
|
inputFieldNames: string[];
|
|
292
293
|
};
|
|
293
294
|
|
|
294
|
-
/**
|
|
295
|
-
* Parameter placeholders for the parameterized query / command definition DSL
|
|
296
|
-
* (issue #41, Python-bridge Phase 0a).
|
|
297
|
-
*
|
|
298
|
-
* A `Param<T>` is a **branded placeholder** standing in for a value that is not
|
|
299
|
-
* known at definition time but is supplied later (at execution, e.g. from
|
|
300
|
-
* Python). It carries:
|
|
301
|
-
*
|
|
302
|
-
* - the **TypeScript value type** `T` it represents (`string`, `number`, or a
|
|
303
|
-
* string-literal union), preserved through the IR and the inferred return
|
|
304
|
-
* types of `defineQueries` / `defineCommands`; and
|
|
305
|
-
* - a **runtime descriptor** (`kind` + optional `literals`) that the static
|
|
306
|
-
* planner (#42) and the code generator read to emit `operations.json`.
|
|
307
|
-
*
|
|
308
|
-
* Placeholders are created with `param.string()`, `param.number()`, and
|
|
309
|
-
* `param.literal(...)`. They are *only* legal at value positions inside a
|
|
310
|
-
* parameterized key / changes structure passed to the `define*` entry points —
|
|
311
|
-
* never to the live `Model.query` / `Model.putItem` runtime API, whose types remain
|
|
312
|
-
* uncontaminated by params.
|
|
313
|
-
*/
|
|
314
|
-
/** Brand tag preventing a plain object from structurally matching a {@link Param}. */
|
|
315
|
-
declare const PARAM_BRAND: unique symbol;
|
|
316
|
-
/** Runtime discriminant for a parameter placeholder. */
|
|
317
|
-
type ParamKind = 'string' | 'number' | 'literal' | 'array';
|
|
318
|
-
/**
|
|
319
|
-
* A branded parameter placeholder representing a value of TypeScript type `T`
|
|
320
|
-
* that is bound at execution time rather than definition time.
|
|
321
|
-
*
|
|
322
|
-
* The brand (`[PARAM_BRAND]: T`) keeps `Param<string>` and `Param<number>`
|
|
323
|
-
* distinct and prevents a bare value from being mistaken for a placeholder.
|
|
324
|
-
*
|
|
325
|
-
* @typeParam T - The value type this placeholder stands in for.
|
|
326
|
-
*/
|
|
327
|
-
interface Param<out T> {
|
|
328
|
-
/** @internal Type brand carrying the represented value type. */
|
|
329
|
-
readonly [PARAM_BRAND]: T;
|
|
330
|
-
/** Runtime discriminant: `'string'` | `'number'` | `'literal'` | `'array'`. */
|
|
331
|
-
readonly kind: ParamKind;
|
|
332
|
-
/**
|
|
333
|
-
* For `param.literal(...)`, the allowed literal values (preserved at runtime
|
|
334
|
-
* for the generator). `undefined` for `string` / `number`.
|
|
335
|
-
*/
|
|
336
|
-
readonly literals?: readonly T[];
|
|
337
|
-
/**
|
|
338
|
-
* For `param.array({...})`, the descriptor of each element's fields. Lets the
|
|
339
|
-
* transaction planner (#46) type `forEach` element references and emit the
|
|
340
|
-
* `{item.<field>}` templates. `undefined` for scalar params.
|
|
341
|
-
*/
|
|
342
|
-
readonly element?: Readonly<Record<string, Param<unknown>>>;
|
|
343
|
-
/**
|
|
344
|
-
* Optional human-readable description of the parameter (issue #154), supplied
|
|
345
|
-
* via `param.string({ description })` etc. Pure documentation metadata — it does
|
|
346
|
-
* NOT affect the runtime descriptor (`kind` / `literals`) the planner reads for
|
|
347
|
-
* execution. When present it is propagated to the param's {@link
|
|
348
|
-
* import('./ir.js').ParamDescriptor} and then to the serialized
|
|
349
|
-
* {@link import('../spec/types.js').ParamSpec} in `operations.json`. Absent →
|
|
350
|
-
* unchanged output (backward compatible).
|
|
351
|
-
*/
|
|
352
|
-
readonly description?: string;
|
|
353
|
-
}
|
|
354
|
-
/** A `Param` whose represented value type is `string`. */
|
|
355
|
-
type StringParam = Param<string>;
|
|
356
|
-
/** A `Param` whose represented value type is `number`. */
|
|
357
|
-
type NumberParam = Param<number>;
|
|
358
|
-
/** A `Param` whose represented value type is the literal union `L`. */
|
|
359
|
-
type LiteralParam<L extends string | number> = Param<L>;
|
|
360
|
-
/** The element-field descriptor shape accepted by {@link param.array}. */
|
|
361
|
-
type ArrayElementShape = Record<string, Param<unknown>>;
|
|
362
|
-
/**
|
|
363
|
-
* The TypeScript element type implied by an {@link ArrayElementShape} `E`: each
|
|
364
|
-
* field carries the value type its placeholder represents.
|
|
365
|
-
*/
|
|
366
|
-
type ElementOf<E extends ArrayElementShape> = {
|
|
367
|
-
[K in keyof E]: E[K] extends Param<infer V> ? V : never;
|
|
368
|
-
};
|
|
369
|
-
/** A `Param` standing in for an **array** whose elements have shape `E`. */
|
|
370
|
-
type ArrayParam<E extends ArrayElementShape> = Param<ElementOf<E>[]> & {
|
|
371
|
-
readonly element: E;
|
|
372
|
-
};
|
|
373
|
-
/** Allowed scalar value types a placeholder may stand in for. */
|
|
374
|
-
type ParamValue = string | number;
|
|
375
|
-
/**
|
|
376
|
-
* Options accepted by the placeholder factories (issue #154). Currently carries
|
|
377
|
-
* only the optional human-readable {@link Param.description} — pure documentation
|
|
378
|
-
* metadata that does not affect the runtime descriptor. The object form is
|
|
379
|
-
* additive: `param.string()` (no options) is unchanged.
|
|
380
|
-
*/
|
|
381
|
-
interface ParamOptions {
|
|
382
|
-
/** Optional human-readable description, propagated to `operations.json`. */
|
|
383
|
-
readonly description?: string;
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
* Placeholder factory. Each call returns a branded {@link Param} carrying both
|
|
387
|
-
* the TypeScript value type and a runtime descriptor. Each scalar factory accepts
|
|
388
|
-
* an optional {@link ParamOptions} (issue #154) carrying a `description` — pure
|
|
389
|
-
* documentation propagated to `operations.json`; the no-argument call is unchanged.
|
|
390
|
-
*/
|
|
391
|
-
declare const param: {
|
|
392
|
-
/** A placeholder for a `string` value. */
|
|
393
|
-
readonly string: (options?: ParamOptions) => StringParam;
|
|
394
|
-
/** A placeholder for a `number` value. */
|
|
395
|
-
readonly number: (options?: ParamOptions) => NumberParam;
|
|
396
|
-
/**
|
|
397
|
-
* A placeholder constrained to one of the given literal values. The value
|
|
398
|
-
* type of the resulting {@link Param} is the **union of the literals**, so it
|
|
399
|
-
* is preserved precisely in the IR and the inferred definition types. A final
|
|
400
|
-
* plain-object argument is read as {@link ParamOptions} (a `description`),
|
|
401
|
-
* distinguished from the `string` / `number` literal values.
|
|
402
|
-
*
|
|
403
|
-
* @example
|
|
404
|
-
* ```ts
|
|
405
|
-
* param.literal('active', 'disabled'); // Param<'active' | 'disabled'>
|
|
406
|
-
* param.literal('active', 'disabled', { description: 'Account state.' });
|
|
407
|
-
* ```
|
|
408
|
-
*/
|
|
409
|
-
readonly literal: <const L extends readonly [ParamValue, ...ParamValue[]]>(...valuesAndOptions: [...L] | [...L, ParamOptions]) => LiteralParam<L[number]>;
|
|
410
|
-
/**
|
|
411
|
-
* A placeholder for an **array** parameter whose elements have the given field
|
|
412
|
-
* shape. Used by `defineTransaction`'s `tx.forEach(p.<arrayParam>, …)` to bind
|
|
413
|
-
* each element's fields to `{item.<field>}` templates.
|
|
414
|
-
*
|
|
415
|
-
* @example
|
|
416
|
-
* ```ts
|
|
417
|
-
* param.array({ userId: param.string(), role: param.string() });
|
|
418
|
-
* // Param<{ userId: string; role: string }[]>
|
|
419
|
-
* ```
|
|
420
|
-
*/
|
|
421
|
-
readonly array: <const E extends ArrayElementShape>(element: E, options?: ParamOptions) => ArrayParam<E>;
|
|
422
|
-
};
|
|
423
|
-
/** Runtime type guard: is `value` a parameter placeholder? */
|
|
424
|
-
declare function isParam(value: unknown): value is Param<unknown>;
|
|
425
|
-
|
|
426
295
|
/**
|
|
427
296
|
* Internal brand identifying a {@link RawCondition} produced by {@link cond}.
|
|
428
297
|
*/
|
|
@@ -1952,6 +1821,8 @@ type ConditionInput<X = never> = {
|
|
|
1952
1821
|
readonly attributeExists: string;
|
|
1953
1822
|
} | {
|
|
1954
1823
|
readonly attributeNotExists: string;
|
|
1824
|
+
} | {
|
|
1825
|
+
readonly scpExpr: ExpressionSpec;
|
|
1955
1826
|
} | RawCondition | ConditionTree<X>;
|
|
1956
1827
|
/** A recursive declarative condition tree (field clauses + logical groups). */
|
|
1957
1828
|
interface ConditionTree<X = never> {
|
|
@@ -2905,6 +2776,13 @@ interface MutationEntityRef {
|
|
|
2905
2776
|
* `.<field>` access (when used as an alias root). Any other access / coercion
|
|
2906
2777
|
* throws — the binding stays declarative (only a direct `$.field` / `$.alias.field`
|
|
2907
2778
|
* reference or a literal is representable, never a transform).
|
|
2779
|
+
*
|
|
2780
|
+
* **Input Port 統一 (issue #264)**: this proxy is one of the three authoring
|
|
2781
|
+
* spellings of the SAME Input Port reference model — see the unification note
|
|
2782
|
+
* on {@link import('./transaction.js').ParamProxy} (`defineTransaction`'s
|
|
2783
|
+
* `p.*` proxy is the model; `{<field>}` templates and `{ref:["input","<field>"]}`
|
|
2784
|
+
* expression refs are the two serialized mirrors of one declared-input
|
|
2785
|
+
* namespace). Behavior here is unchanged in 0.7.x (interop kept).
|
|
2908
2786
|
*/
|
|
2909
2787
|
type MutationInputProxy = Record<string, MutationInputRef>;
|
|
2910
2788
|
declare const FRAGMENT_BRAND: unique symbol;
|
|
@@ -4245,923 +4123,6 @@ interface MaintenanceGraph {
|
|
|
4245
4123
|
*/
|
|
4246
4124
|
declare function buildMaintenanceGraph(registry?: ReadonlyMap<Function, EntityMetadata>, views?: readonly ViewDefinition[]): MaintenanceGraph;
|
|
4247
4125
|
|
|
4248
|
-
/**
|
|
4249
|
-
* Serializable static operation specs and manifest (issue #42, Python-bridge
|
|
4250
|
-
* Phase 0b).
|
|
4251
|
-
*
|
|
4252
|
-
* Everything in this module is **JSON-serializable** by construction (only
|
|
4253
|
-
* strings / numbers / booleans / arrays / plain objects — no functions, classes,
|
|
4254
|
-
* `Date`, `Set`, or `undefined`-valued fields are emitted). These types mirror
|
|
4255
|
-
* the `graphddb_manifest.json` / `graphddb_operations.json` shapes sketched in
|
|
4256
|
-
* `docs/python-bridge.md`. The generator (#43) writes them to disk; the
|
|
4257
|
-
* Python runtime (#44+) interprets them.
|
|
4258
|
-
*
|
|
4259
|
-
* ## Templates and placeholders
|
|
4260
|
-
*
|
|
4261
|
-
* Key-condition / range / item / change *values* are **template strings** with
|
|
4262
|
-
* two placeholder forms:
|
|
4263
|
-
*
|
|
4264
|
-
* - `{paramName}` — bound from the caller-supplied params at execution time.
|
|
4265
|
-
* - `{result.sourceField}` — bound from a field of the **prior** operation's
|
|
4266
|
-
* result item(s), used to chain relation operations.
|
|
4267
|
-
*
|
|
4268
|
-
* A value with no `{...}` is a literal (e.g. a fixed sort-key discriminator
|
|
4269
|
-
* `PROFILE`).
|
|
4270
|
-
*/
|
|
4271
|
-
|
|
4272
|
-
/**
|
|
4273
|
-
* The schema version emitted in every manifest / operations document.
|
|
4274
|
-
*
|
|
4275
|
-
* `1.1` (issue #208, B案): the operation IR gained the **list fan-out binding
|
|
4276
|
-
* form** ({@link SourceListSpec} on a `BatchGetItem` relation op), lifting the
|
|
4277
|
-
* #197 `refs` loud-reject. The op vocabulary (the physical DynamoDB API surface)
|
|
4278
|
-
* is unchanged — only the dataflow (source→key) binding grammar grew. Purely
|
|
4279
|
-
* additive: every `1.0` document is a valid `1.1` document, and a document that
|
|
4280
|
-
* uses no `refs` relation serializes byte-identically apart from this version.
|
|
4281
|
-
*/
|
|
4282
|
-
declare const SPEC_VERSION: "1.1";
|
|
4283
|
-
/** Field type as carried in the manifest (derived from the DynamoDB type). */
|
|
4284
|
-
type ManifestFieldType = 'string' | 'number' | 'boolean' | 'binary' | 'stringSet' | 'numberSet' | 'list' | 'map';
|
|
4285
|
-
interface ManifestField {
|
|
4286
|
-
readonly type: ManifestFieldType;
|
|
4287
|
-
/**
|
|
4288
|
-
* Semantic format for `string` fields that carry a serialized temporal value.
|
|
4289
|
-
* `datetime` → ISO 8601 instant, `date` → `YYYY-MM-DD`. Absent for plain
|
|
4290
|
-
* fields. The Python runtime uses this to restore `datetime` on hydration,
|
|
4291
|
-
* mirroring the TS hydrator's `format`-driven `Date` reconstruction.
|
|
4292
|
-
*/
|
|
4293
|
-
readonly format?: 'datetime' | 'date';
|
|
4294
|
-
/**
|
|
4295
|
-
* Optional human-readable description of the field (issue #154), from a field
|
|
4296
|
-
* decorator option (`@string({ description })`). Pure documentation — absent
|
|
4297
|
-
* unless declared, so a field with no description serializes byte-identically
|
|
4298
|
-
* to the pre-#154 manifest. Surfaces as a field comment in the generated Python.
|
|
4299
|
-
*/
|
|
4300
|
-
readonly description?: string;
|
|
4301
|
-
}
|
|
4302
|
-
/** A key (PK or GSI) template descriptor in the manifest. */
|
|
4303
|
-
interface ManifestKey {
|
|
4304
|
-
/** Input field names the key is composed from (in declaration order). */
|
|
4305
|
-
readonly inputFields: readonly string[];
|
|
4306
|
-
/** Template for the partition-key value, e.g. `EMAIL#{email}`. */
|
|
4307
|
-
readonly pkTemplate: string;
|
|
4308
|
-
/** Template for the sort-key value, or `null` when the key has no sort key. */
|
|
4309
|
-
readonly skTemplate: string | null;
|
|
4310
|
-
}
|
|
4311
|
-
interface ManifestGsi extends ManifestKey {
|
|
4312
|
-
readonly indexName: string;
|
|
4313
|
-
readonly unique: boolean;
|
|
4314
|
-
/**
|
|
4315
|
-
* Optional human-readable description of the index (issue #166, follow-up of #154),
|
|
4316
|
-
* from `gsi(name, key, { description })`. Pure documentation — absent unless declared,
|
|
4317
|
-
* so a GSI with no description serializes byte-identically to the pre-#166 manifest.
|
|
4318
|
-
* The Python codegen surfaces it as the docstring of a generated query method that
|
|
4319
|
-
* reads through this index.
|
|
4320
|
-
*/
|
|
4321
|
-
readonly description?: string;
|
|
4322
|
-
}
|
|
4323
|
-
interface ManifestRelation {
|
|
4324
|
-
readonly type: 'hasMany' | 'hasOne' | 'belongsTo' | 'refs';
|
|
4325
|
-
/** Target entity (model class) name. */
|
|
4326
|
-
readonly target: string;
|
|
4327
|
-
/** target field → source field (on this entity). */
|
|
4328
|
-
readonly keyBinding: Readonly<Record<string, string>>;
|
|
4329
|
-
/**
|
|
4330
|
-
* List-valued source descriptor for a `refs` relation (issue #197). Present IFF
|
|
4331
|
-
* `type === 'refs'`: `from` is the parent LIST attribute holding the inline
|
|
4332
|
-
* reference elements (e.g. `'tagRefs'`), `key` the field read off each element
|
|
4333
|
-
* (e.g. `'tagId'`). Absent for every scalar-keyed relation (byte-identical to
|
|
4334
|
-
* the pre-#197 manifest). Carried so a manifest consumer can reconstruct where a
|
|
4335
|
-
* `refs` relation's BatchGet keys come from.
|
|
4336
|
-
*/
|
|
4337
|
-
readonly refs?: Readonly<{
|
|
4338
|
-
from: string;
|
|
4339
|
-
key: string;
|
|
4340
|
-
}>;
|
|
4341
|
-
/**
|
|
4342
|
-
* Optional human-readable description of the relation (issue #166, follow-up of
|
|
4343
|
-
* #154), from `@hasMany/@belongsTo/@hasOne(..., { description })`. Pure documentation
|
|
4344
|
-
* — absent unless declared, so a relation with no description serializes
|
|
4345
|
-
* byte-identically to the pre-#166 manifest. The Python codegen surfaces it as a
|
|
4346
|
-
* trailing `# …` comment on the relation's field in the generated result type.
|
|
4347
|
-
*/
|
|
4348
|
-
readonly description?: string;
|
|
4349
|
-
}
|
|
4350
|
-
interface ManifestEntity {
|
|
4351
|
-
/** Declared (logical) table name. */
|
|
4352
|
-
readonly table: string;
|
|
4353
|
-
/** Physical table name (after `TableMapping` resolution). */
|
|
4354
|
-
readonly physicalName: string;
|
|
4355
|
-
/** PK prefix, e.g. `USER#`. */
|
|
4356
|
-
readonly prefix: string;
|
|
4357
|
-
readonly fields: Readonly<Record<string, ManifestField>>;
|
|
4358
|
-
/** Primary key, or `null` when the entity has none. */
|
|
4359
|
-
readonly key: ManifestKey | null;
|
|
4360
|
-
readonly gsis: readonly ManifestGsi[];
|
|
4361
|
-
readonly relations: Readonly<Record<string, ManifestRelation>>;
|
|
4362
|
-
/**
|
|
4363
|
-
* Optional human-readable description of the entity (issue #154), from
|
|
4364
|
-
* `@model({ description })`. Pure documentation — absent unless declared, so an
|
|
4365
|
-
* entity with no description serializes byte-identically to the pre-#154
|
|
4366
|
-
* manifest. Surfaces as the generated Python class docstring.
|
|
4367
|
-
*/
|
|
4368
|
-
readonly description?: string;
|
|
4369
|
-
/**
|
|
4370
|
-
* The physical attribute name of the model's DynamoDB **Time-To-Live** field,
|
|
4371
|
-
* when one is declared via `@ttl` (issue #172, Epic #167 — CFn generator C4).
|
|
4372
|
-
* Unlike the maintenance/stream signals (a maintenance-IR concern kept OFF the
|
|
4373
|
-
* manifest), TTL is a **physical schema** fact, and the CloudFormation emitter
|
|
4374
|
-
* consumes the manifest — so the TTL attribute name flows here and the emitter
|
|
4375
|
-
* renders `TimeToLiveSpecification { AttributeName: <this>, Enabled: true }`. The
|
|
4376
|
-
* attribute is deliberately NOT added to the table's key `AttributeDefinitions`
|
|
4377
|
-
* (that list holds ONLY key/index attributes; `TimeToLiveSpecification` legitimately
|
|
4378
|
-
* names a non-key attribute). **Absent** when the model declares no `@ttl`, so a
|
|
4379
|
-
* TTL-free model serializes byte-identically to the pre-#172 manifest (backward
|
|
4380
|
-
* compatible). DynamoDB permits exactly one TTL attribute per physical table; the
|
|
4381
|
-
* single-per-table rule is enforced at manifest build.
|
|
4382
|
-
*/
|
|
4383
|
-
readonly ttlAttribute?: string;
|
|
4384
|
-
}
|
|
4385
|
-
interface ManifestTable {
|
|
4386
|
-
readonly physicalName: string;
|
|
4387
|
-
}
|
|
4388
|
-
interface Manifest {
|
|
4389
|
-
readonly version: typeof SPEC_VERSION;
|
|
4390
|
-
readonly tables: Readonly<Record<string, ManifestTable>>;
|
|
4391
|
-
readonly entities: Readonly<Record<string, ManifestEntity>>;
|
|
4392
|
-
}
|
|
4393
|
-
interface ParamSpec {
|
|
4394
|
-
readonly type: ParamKind;
|
|
4395
|
-
readonly required: boolean;
|
|
4396
|
-
/** Allowed literal values for `literal` params; omitted otherwise. */
|
|
4397
|
-
readonly literals?: readonly (string | number)[];
|
|
4398
|
-
/**
|
|
4399
|
-
* For an `array` param (transaction `forEach` source), the per-element field
|
|
4400
|
-
* descriptors (field name → element param spec). Omitted for scalar params.
|
|
4401
|
-
*/
|
|
4402
|
-
readonly element?: Readonly<Record<string, ParamSpec>>;
|
|
4403
|
-
/**
|
|
4404
|
-
* Optional human-readable description of the parameter (issue #154), from a
|
|
4405
|
-
* `param.*({ description })` placeholder. Pure documentation — absent unless
|
|
4406
|
-
* declared, so a param with no description serializes byte-identically to the
|
|
4407
|
-
* pre-#154 spec. The Python runtime never reads it for execution.
|
|
4408
|
-
*/
|
|
4409
|
-
readonly description?: string;
|
|
4410
|
-
}
|
|
4411
|
-
/** A `begins_with` range condition on a sort key (templated value). */
|
|
4412
|
-
interface RangeConditionSpec {
|
|
4413
|
-
readonly operator: 'begins_with';
|
|
4414
|
-
readonly key: string;
|
|
4415
|
-
/** Template value, e.g. `GROUP#` or `GROUP#{result.groupId}`. */
|
|
4416
|
-
readonly value: string;
|
|
4417
|
-
}
|
|
4418
|
-
/** Server-side declarative filter, carried verbatim for the runtime to compile. */
|
|
4419
|
-
interface FilterSpec {
|
|
4420
|
-
/** The declarative {@link FilterInput} tree (JSON-safe). */
|
|
4421
|
-
readonly declarative: unknown;
|
|
4422
|
-
}
|
|
4423
|
-
type ReadOperationType = 'Query' | 'GetItem' | 'BatchGetItem';
|
|
4424
|
-
/**
|
|
4425
|
-
* A single static read operation. Relation chains are expressed as multiple
|
|
4426
|
-
* operations whose `resultPath` / templated key conditions wire them together.
|
|
4427
|
-
*/
|
|
4428
|
-
interface OperationSpec {
|
|
4429
|
-
readonly type: ReadOperationType;
|
|
4430
|
-
readonly tableName: string;
|
|
4431
|
-
readonly indexName?: string;
|
|
4432
|
-
/**
|
|
4433
|
-
* Key condition: attribute name → template value. For a `BatchGetItem` this is
|
|
4434
|
-
* the per-key shape (one key per resolved source item at runtime).
|
|
4435
|
-
*/
|
|
4436
|
-
readonly keyCondition: Readonly<Record<string, string>>;
|
|
4437
|
-
readonly rangeCondition?: RangeConditionSpec;
|
|
4438
|
-
/** Projected fields (entity field names). */
|
|
4439
|
-
readonly projection: readonly string[];
|
|
4440
|
-
readonly limit?: number;
|
|
4441
|
-
readonly filter?: FilterSpec;
|
|
4442
|
-
/**
|
|
4443
|
-
* Where the result of this operation is placed in the assembled result.
|
|
4444
|
-
* `$` is the root; `$.groups.items` a relation connection's items, etc.
|
|
4445
|
-
*/
|
|
4446
|
-
readonly resultPath: string;
|
|
4447
|
-
/**
|
|
4448
|
-
* For relation operations: the source field on the prior result whose value(s)
|
|
4449
|
-
* drive this operation's `{result.*}` placeholders. Absent on the root op.
|
|
4450
|
-
*/
|
|
4451
|
-
readonly sourceField?: string;
|
|
4452
|
-
/**
|
|
4453
|
-
* The **list fan-out binding form** (issue #208, B案 — the shared-IR
|
|
4454
|
-
* generalization that lifted the #197 `refs` loud-reject). Present only on a
|
|
4455
|
-
* `BatchGetItem` relation operation that resolves a `refs` relation: instead of
|
|
4456
|
-
* reading ONE scalar `parent[sourceField]`, the runtime reads the parent **list
|
|
4457
|
-
* attribute** {@link SourceListSpec.from} and binds `{result.<sourceField>}`
|
|
4458
|
-
* once per element — `element[key]` for an object element, the element itself
|
|
4459
|
-
* for a bare scalar — skipping null/undefined refs. All element keys across all
|
|
4460
|
-
* parents fan into ONE deduped `BatchGetItem` (the existing chunk/retry
|
|
4461
|
-
* machinery), and the operation's `resultPath` (`…<prop>.items`) receives a
|
|
4462
|
-
* connection `{ items, cursor: null }` whose items are the resolved child
|
|
4463
|
-
* bodies in **first-seen element order**, deduped, with missing bodies dropped
|
|
4464
|
-
* — byte-matching the TS in-process `fetchRefsList` semantics. Absent on every
|
|
4465
|
-
* scalar-bound relation op (a pre-#208 document is byte-identical).
|
|
4466
|
-
*/
|
|
4467
|
-
readonly sourceList?: SourceListSpec;
|
|
4468
|
-
}
|
|
4469
|
-
/**
|
|
4470
|
-
* The list-valued source descriptor of a fan-out `BatchGetItem` operation (issue
|
|
4471
|
-
* #208 B案; the operation-IR mirror of the manifest's `ManifestRelation.refs`).
|
|
4472
|
-
*/
|
|
4473
|
-
interface SourceListSpec {
|
|
4474
|
-
/** The parent LIST attribute holding the inline reference elements (e.g. `tagRefs`). */
|
|
4475
|
-
readonly from: string;
|
|
4476
|
-
/**
|
|
4477
|
-
* The field read off each element (e.g. `tagId`). Always equals the operation's
|
|
4478
|
-
* `sourceField` (the `{result.<sourceField>}` token name); carried explicitly so
|
|
4479
|
-
* the op is self-describing.
|
|
4480
|
-
*/
|
|
4481
|
-
readonly key: string;
|
|
4482
|
-
/**
|
|
4483
|
-
* `true` when the parent list attribute was NOT selected by the query and was
|
|
4484
|
-
* projected onto the parent operation **solely** to drive this fan-out. The
|
|
4485
|
-
* runtime must then delete `from` from every parent node after ALL relation
|
|
4486
|
-
* operations are applied — mirroring the TS hydrator, which projects implicit
|
|
4487
|
-
* relation-source fields but strips them from the assembled result. Absent when
|
|
4488
|
-
* the query's select projects the attribute itself (it stays in the result).
|
|
4489
|
-
*/
|
|
4490
|
-
readonly implicit?: boolean;
|
|
4491
|
-
}
|
|
4492
|
-
/**
|
|
4493
|
-
* The **execution plan** for a multi-operation read (issue #70a). It is the
|
|
4494
|
-
* Single Source of Truth for *how* a query's {@link OperationSpec}[] is staged:
|
|
4495
|
-
* which operations are independent (may run concurrently) and which must wait for
|
|
4496
|
-
* a prior operation's result. Every runtime that honors it produces identical
|
|
4497
|
-
* effects with identical concurrency discipline — the staging is **serialized,
|
|
4498
|
-
* not re-derived** (cf. the contract decided-facts discipline).
|
|
4499
|
-
*
|
|
4500
|
-
* - `groups` is an ordered list of **stages**; each stage is a list of indices
|
|
4501
|
-
* into the query's `operations[]`. Operations **within** a stage are mutually
|
|
4502
|
-
* independent and may be issued concurrently; stages run **in order** because a
|
|
4503
|
-
* later stage reads a `{result.*}` value produced by an earlier one. Stage 0 is
|
|
4504
|
-
* always `[0]` (the root). Every operation index appears in exactly one stage,
|
|
4505
|
-
* and the stages are a topological layering of the result-dependency graph.
|
|
4506
|
-
* - `concurrency` is the declared in-flight bound a runtime applies **within**
|
|
4507
|
-
* each stage (the shared {@link RELATION_TRAVERSAL_CONCURRENCY} = 16): at most
|
|
4508
|
-
* this many operations of a stage are issued at once.
|
|
4509
|
-
*
|
|
4510
|
-
* ## Derivation (see `buildReadOperations` / `deriveExecutionPlan`)
|
|
4511
|
-
*
|
|
4512
|
-
* The planner emits `operations[]` in a deterministic pre-order: the root at
|
|
4513
|
-
* index 0, then each relation child immediately followed by its own descendants.
|
|
4514
|
-
* A child's key templates reference `{result.<sourceField>}` of the **operation
|
|
4515
|
-
* whose `resultPath` is the child's parent path** — that producer is the child's
|
|
4516
|
-
* sole dependency. The stage of an operation is therefore `1 + stage(parent)`:
|
|
4517
|
-
* the root is stage 0; sibling relations that share a parent path land in the
|
|
4518
|
-
* **same** stage (no inter-`{result.*}` dependency between siblings, so they are
|
|
4519
|
-
* independent and concurrency-eligible); a grandchild that reads its parent's
|
|
4520
|
-
* `{result.*}` lands one stage later. This mirrors exactly the level-by-level
|
|
4521
|
-
* fan-out the TS relation runtime performs at runtime (`resolveRelations` issues
|
|
4522
|
-
* sibling relations together under the same bound) — #70a only *records* it.
|
|
4523
|
-
*
|
|
4524
|
-
* Absent on a single-operation spec and on specs produced before #70a; a consumer
|
|
4525
|
-
* without a plan falls back to one-operation-per-stage **sequential** execution
|
|
4526
|
-
* (the pre-#70 behavior), so an absent plan never changes results.
|
|
4527
|
-
*/
|
|
4528
|
-
interface ExecutionPlanSpec {
|
|
4529
|
-
/** Ordered stages; each stage is indices into `operations[]` (stage 0 = `[0]`). */
|
|
4530
|
-
readonly groups: readonly (readonly number[])[];
|
|
4531
|
-
/** The declared in-flight bound applied within each stage (16). */
|
|
4532
|
-
readonly concurrency: number;
|
|
4533
|
-
}
|
|
4534
|
-
/** A query (read) definition's full execution spec. */
|
|
4535
|
-
interface QuerySpec {
|
|
4536
|
-
readonly params: Readonly<Record<string, ParamSpec>>;
|
|
4537
|
-
readonly operations: readonly OperationSpec[];
|
|
4538
|
-
/**
|
|
4539
|
-
* Result cardinality of the **root** (`$`) operation, derived from the
|
|
4540
|
-
* definition kind: `'one'` for `defineQuery` (a single entity object, with any
|
|
4541
|
-
* relations attached directly), `'many'` for `defineList` (a `{ items, cursor }`
|
|
4542
|
-
* connection). The relation runtime (#45) uses this to shape the root result:
|
|
4543
|
-
* a `'one'` Query root takes the first matched item rather than returning a
|
|
4544
|
-
* connection. Absent in specs produced before #45; consumers should treat an
|
|
4545
|
-
* absent value as `'many'` for a `Query`/`BatchGetItem` root and `'one'` for a
|
|
4546
|
-
* `GetItem` root (the pre-#45 behavior).
|
|
4547
|
-
*/
|
|
4548
|
-
readonly cardinality?: 'one' | 'many';
|
|
4549
|
-
/**
|
|
4550
|
-
* The staged execution plan (issue #70a): which {@link operations} are
|
|
4551
|
-
* independent (concurrency-eligible) vs. result-dependent. Present only when the
|
|
4552
|
-
* query has more than one operation (a relation chain); a single-operation read
|
|
4553
|
-
* needs no plan. See {@link ExecutionPlanSpec} for the derivation and the
|
|
4554
|
-
* backward-compatible (plan-absent → sequential) fallback.
|
|
4555
|
-
*/
|
|
4556
|
-
readonly executionPlan?: ExecutionPlanSpec;
|
|
4557
|
-
/**
|
|
4558
|
-
* Optional human-readable description of the query (issue #154), from
|
|
4559
|
-
* `defineQuery(..., { description })`. Pure documentation — absent unless
|
|
4560
|
-
* declared, so a query with no description serializes byte-identically to the
|
|
4561
|
-
* pre-#154 spec. Surfaces as the generated Python repository-method docstring.
|
|
4562
|
-
*/
|
|
4563
|
-
readonly description?: string;
|
|
4564
|
-
}
|
|
4565
|
-
type WriteOperationType = 'PutItem' | 'UpdateItem' | 'DeleteItem';
|
|
4566
|
-
/**
|
|
4567
|
-
* A condition expression on a write, as a JSON-serializable spec (issues #46,
|
|
4568
|
-
* #81). The supported subset:
|
|
4569
|
-
*
|
|
4570
|
-
* - `{ kind: 'notExists' }` → `attribute_not_exists(PK)` (legacy whole-row guard).
|
|
4571
|
-
* - `{ kind: 'attributeExists'; field }` → `attribute_exists(<field>)` — the named
|
|
4572
|
-
* attribute (any field, incl. PK/SK) must be present. The foundation for
|
|
4573
|
-
* referential-integrity derivation.
|
|
4574
|
-
* - `{ kind: 'attributeNotExists'; field }` → `attribute_not_exists(<field>)` — the
|
|
4575
|
-
* named attribute must be absent (field-level uniqueness / first-write guard).
|
|
4576
|
-
* - `{ kind: 'equals'; fields }` → `#f = :v AND …` field equality (each value a
|
|
4577
|
-
* `{param}` / literal template).
|
|
4578
|
-
* - `{ kind: 'expr'; declarative }` → the full declarative operator tree (issue
|
|
4579
|
-
* #114-A): comparison (`gt`/`ge`/`lt`/`le`/`ne`), `between`, `in`,
|
|
4580
|
-
* `begins_with`/`contains`/`notContains`, `attributeType`, and the logical
|
|
4581
|
-
* `and`/`or`/`not` groups, mirroring the read-side {@link FilterSpec}. The tree
|
|
4582
|
-
* is JSON-safe: each leaf value is either a native literal (string / number /
|
|
4583
|
-
* boolean) or a {@link ConditionParamLeaf} (`{ $param }`) marking a caller
|
|
4584
|
-
* param bound at execution time. The runtime resolves the param leaves against
|
|
4585
|
-
* the caller params, then compiles the tree to a DynamoDB `ConditionExpression`
|
|
4586
|
-
* with the SAME mechanics the filter compiler uses (so TS and Python emit an
|
|
4587
|
-
* identical expression / semantics).
|
|
4588
|
-
*/
|
|
4589
|
-
type ConditionSpec = {
|
|
4590
|
-
readonly kind: 'notExists';
|
|
4591
|
-
} | {
|
|
4592
|
-
readonly kind: 'attributeExists';
|
|
4593
|
-
readonly field: string;
|
|
4594
|
-
} | {
|
|
4595
|
-
readonly kind: 'attributeNotExists';
|
|
4596
|
-
readonly field: string;
|
|
4597
|
-
} | {
|
|
4598
|
-
readonly kind: 'equals';
|
|
4599
|
-
readonly fields: Readonly<Record<string, string>>;
|
|
4600
|
-
} | {
|
|
4601
|
-
readonly kind: 'expr';
|
|
4602
|
-
readonly declarative: unknown;
|
|
4603
|
-
} | {
|
|
4604
|
-
/**
|
|
4605
|
-
* A raw DynamoDB condition produced by the `cond` escape hatch (issue
|
|
4606
|
-
* #114-B), for write conditions that the declarative operator subset
|
|
4607
|
-
* cannot express. It is **pre-compiled and deterministic**: the
|
|
4608
|
-
* `expression` is a finished DynamoDB `ConditionExpression` whose name
|
|
4609
|
-
* placeholders are stable `#cr_<field>` aliases (reused per distinct
|
|
4610
|
-
* column) and whose value placeholders are sequential `:cr0`, `:cr1`, …
|
|
4611
|
-
* (assigned in template order), so the serialized golden is stable. The
|
|
4612
|
-
* names map binds each `#cr_<field>` alias to its entity field; the values
|
|
4613
|
-
* map binds each `:crN` alias to either a native literal (an embedded
|
|
4614
|
-
* `cond` value — in-process the concrete value) or a {@link ConditionParamLeaf}
|
|
4615
|
-
* (`{ $param }`) marker bound from a caller param at execution time (the
|
|
4616
|
-
* public-contract slot). The runtime substitutes the param leaves, then
|
|
4617
|
-
* attaches `expression` / `names` / serialized `values` to the write —
|
|
4618
|
-
* TS and Python build the identical DynamoDB expression.
|
|
4619
|
-
*/
|
|
4620
|
-
readonly kind: 'raw';
|
|
4621
|
-
readonly expression: string;
|
|
4622
|
-
readonly names: Readonly<Record<string, string>>;
|
|
4623
|
-
readonly values: Readonly<Record<string, unknown>>;
|
|
4624
|
-
};
|
|
4625
|
-
interface CommandSpec {
|
|
4626
|
-
readonly type: WriteOperationType;
|
|
4627
|
-
readonly tableName: string;
|
|
4628
|
-
readonly entity: string;
|
|
4629
|
-
readonly params: Readonly<Record<string, ParamSpec>>;
|
|
4630
|
-
/**
|
|
4631
|
-
* Key condition for `UpdateItem` / `DeleteItem` (attribute name → template).
|
|
4632
|
-
* Absent for `PutItem` (the whole item is built from `item`).
|
|
4633
|
-
*/
|
|
4634
|
-
readonly keyCondition?: Readonly<Record<string, string>>;
|
|
4635
|
-
/** The full item template for `PutItem` (field name → template / literal). */
|
|
4636
|
-
readonly item?: Readonly<Record<string, string>>;
|
|
4637
|
-
/** Field-level changes for `UpdateItem` (field name → template / literal). */
|
|
4638
|
-
readonly changes?: Readonly<Record<string, string>>;
|
|
4639
|
-
/** Optional write condition (subset). */
|
|
4640
|
-
readonly condition?: ConditionSpec;
|
|
4641
|
-
/**
|
|
4642
|
-
* Optional human-readable description of the command (issue #154), from
|
|
4643
|
-
* `definePut`/`defineUpdate`/`defineDelete(..., { description })`. Pure
|
|
4644
|
-
* documentation — absent unless declared, so a command with no description
|
|
4645
|
-
* serializes byte-identically to the pre-#154 spec. Surfaces as the generated
|
|
4646
|
-
* Python repository-method docstring.
|
|
4647
|
-
*/
|
|
4648
|
-
readonly description?: string;
|
|
4649
|
-
}
|
|
4650
|
-
/**
|
|
4651
|
-
* A declarative `when` guard on a transaction item (issue #46). Compares a
|
|
4652
|
-
* templated left-hand value against a templated right-hand value; the item is
|
|
4653
|
-
* skipped when the comparison does not hold. Both values are template strings
|
|
4654
|
-
* (`{param}` / `{item.<field>}` / literal), resolved by the runtime before the
|
|
4655
|
-
* comparison. The runtime compares the resolved **string** values.
|
|
4656
|
-
*/
|
|
4657
|
-
interface WhenSpec {
|
|
4658
|
-
readonly op: 'eq' | 'ne';
|
|
4659
|
-
/** Templated left-hand value (typically an `{item.<field>}` or `{param}`). */
|
|
4660
|
-
readonly left: string;
|
|
4661
|
-
/** Templated right-hand value (literal or another reference). */
|
|
4662
|
-
readonly right: string;
|
|
4663
|
-
}
|
|
4664
|
-
/**
|
|
4665
|
-
* The kind of a transaction item. The three write kinds (`Put` / `Update` /
|
|
4666
|
-
* `Delete`) mutate an item; `ConditionCheck` (issue #81) is a **read-only
|
|
4667
|
-
* assertion** on another item — it asserts a {@link ConditionSpec} holds for the
|
|
4668
|
-
* keyed row without modifying it, and its failure cancels the **whole**
|
|
4669
|
-
* `TransactWriteItems` atomically. It is the foundation for referential-integrity
|
|
4670
|
-
* derivation (proposal: `requires <Entity> exists` → a `ConditionCheck` with
|
|
4671
|
-
* `attribute_exists`).
|
|
4672
|
-
*/
|
|
4673
|
-
type TransactionItemType = 'Put' | 'Update' | 'Delete' | 'ConditionCheck';
|
|
4674
|
-
/**
|
|
4675
|
-
* A value leaf of a transaction `item` / `changes` / `add` map (issue #245).
|
|
4676
|
-
*
|
|
4677
|
-
* - a **string** carries a template: a `{param}` / `{item.field}` placeholder, a
|
|
4678
|
-
* composite (`PREFIX#{param}`), or a plain string literal — resolved by the
|
|
4679
|
-
* runtimes' template machinery (a whole-placeholder string keeps the bound
|
|
4680
|
-
* param's *type*, a composite / plain string resolves to a string);
|
|
4681
|
-
* - a **number** / **boolean** carries a *typed literal* verbatim, so a numeric
|
|
4682
|
-
* literal in a `put` item / `update` changes (`version: 0`) survives to DynamoDB
|
|
4683
|
-
* as an `N` / `BOOL` instead of being stringified to an `S` (the pre-#245 bug).
|
|
4684
|
-
*
|
|
4685
|
-
* A `Date` literal is serialized to its ISO-8601 **string** at build time (a
|
|
4686
|
-
* `@datetime` / `@date` field is stored as `S`), so it stays a string leaf.
|
|
4687
|
-
*/
|
|
4688
|
-
type TransactionValueLeaf = string | number | boolean;
|
|
4689
|
-
/**
|
|
4690
|
-
* A single templated item in a transaction. When `forEach` is present, the item
|
|
4691
|
-
* is expanded **once per element** of the named array param, with each element's
|
|
4692
|
-
* fields bound to the item's `{item.<field>}` placeholders.
|
|
4693
|
-
*
|
|
4694
|
-
* Field presence by `type`:
|
|
4695
|
-
*
|
|
4696
|
-
* | type | item | keyCondition | changes | add | condition |
|
|
4697
|
-
* |----------------|------|--------------|---------|-----|--------------------------|
|
|
4698
|
-
* | `Put` | ✓ | — | — | — | optional |
|
|
4699
|
-
* | `Update` | — | ✓ | ✓ / — | ✓ / — | optional |
|
|
4700
|
-
* | `Delete` | — | ✓ | — | — | optional |
|
|
4701
|
-
* | `ConditionCheck` | — | ✓ | — | — | **required** (the assert) |
|
|
4702
|
-
*
|
|
4703
|
-
* An `Update` carries `changes` (a `SET` of named fields) and/or `add` (an atomic
|
|
4704
|
-
* `ADD` of named numeric fields, issue #85) — at least one of the two. The two are
|
|
4705
|
-
* distinct DynamoDB update actions: `SET #f = :v` **overwrites**, while
|
|
4706
|
-
* `ADD #f :delta` **atomically increments** without a read (concurrency-safe), so
|
|
4707
|
-
* a derived counter (`User.postCount += 1`) MUST be an `add`, never a `changes`
|
|
4708
|
-
* `SET` (which would clobber a concurrent increment).
|
|
4709
|
-
*/
|
|
4710
|
-
interface TransactionItemSpec {
|
|
4711
|
-
readonly type: TransactionItemType;
|
|
4712
|
-
readonly tableName: string;
|
|
4713
|
-
readonly entity: string;
|
|
4714
|
-
/**
|
|
4715
|
-
* Put: the full item template (field → template / typed literal). A string
|
|
4716
|
-
* value is a template ({@link TransactionValueLeaf}); a `number` / `boolean` is
|
|
4717
|
-
* a typed literal carried verbatim (issue #245).
|
|
4718
|
-
*/
|
|
4719
|
-
readonly item?: Readonly<Record<string, TransactionValueLeaf>>;
|
|
4720
|
-
/** Update / Delete / ConditionCheck: the key template (attribute → template). */
|
|
4721
|
-
readonly keyCondition?: Readonly<Record<string, string>>;
|
|
4722
|
-
/**
|
|
4723
|
-
* Update: field-level `SET` change templates (overwrite). A string value is a
|
|
4724
|
-
* template; a `number` / `boolean` is a typed literal carried verbatim (#245).
|
|
4725
|
-
*/
|
|
4726
|
-
readonly changes?: Readonly<Record<string, TransactionValueLeaf>>;
|
|
4727
|
-
/**
|
|
4728
|
-
* Update: field-level atomic `ADD` deltas (issue #85, derived counters). Each
|
|
4729
|
-
* value is a numeric template (`{param}` / a literal number string) or a typed
|
|
4730
|
-
* numeric literal (issue #245); the runtime applies `ADD #field :delta`, an
|
|
4731
|
-
* atomic increment that needs no prior read and is safe under concurrency. A
|
|
4732
|
-
* negative delta decrements (e.g. `-1` on a remove).
|
|
4733
|
-
*/
|
|
4734
|
-
readonly add?: Readonly<Record<string, TransactionValueLeaf>>;
|
|
4735
|
-
/**
|
|
4736
|
-
* The write / assertion condition (subset). Optional on `Put` / `Update` /
|
|
4737
|
-
* `Delete`; **required** on a `ConditionCheck` (the assertion it makes).
|
|
4738
|
-
*/
|
|
4739
|
-
readonly condition?: ConditionSpec;
|
|
4740
|
-
/** Optional declarative guard; the item is skipped when it does not hold. */
|
|
4741
|
-
readonly when?: WhenSpec;
|
|
4742
|
-
/** When present, expand this item once per element of the named array param. */
|
|
4743
|
-
readonly forEach?: {
|
|
4744
|
-
readonly source: string;
|
|
4745
|
-
};
|
|
4746
|
-
/**
|
|
4747
|
-
* Marks a **raw marker-row** write (issue #86 uniqueness guard): the row is NOT a
|
|
4748
|
-
* modeled entity, so its primary key is carried **literally** rather than derived
|
|
4749
|
-
* from manifest metadata. When `true`:
|
|
4750
|
-
*
|
|
4751
|
-
* - a `Put` writes its `item` record **verbatim** as the stored item — the `item`
|
|
4752
|
-
* already carries the synthetic `PK` / `SK` templates (`UNIQUE#…`), so the
|
|
4753
|
-
* runtimes do NOT prepend a model prefix or compute GSI attributes;
|
|
4754
|
-
* - a `Delete` uses its `keyCondition` (the `PK` / `SK` templates) as the row Key
|
|
4755
|
-
* verbatim.
|
|
4756
|
-
*
|
|
4757
|
-
* The companion {@link entity} is the {@link MARKER_ROW_ENTITY} sentinel (there is
|
|
4758
|
-
* no manifest entity to resolve). Absent / `false` on every modeled write (a base
|
|
4759
|
-
* entity / edge / counter / ConditionCheck item), so those paths are unchanged.
|
|
4760
|
-
*/
|
|
4761
|
-
readonly literalKey?: boolean;
|
|
4762
|
-
/**
|
|
4763
|
-
* A **relation-side maintenance write** (Epic #118, issue #129 — the JSON-SSoT /
|
|
4764
|
-
* Python mirror of the TS in-process `renderMaintainWriteItem`). Present ONLY on an
|
|
4765
|
-
* `Update` item that materializes a maintained access path: a projected
|
|
4766
|
-
* {@link DerivedMaintainWrite} of a just-written source row into a SEPARATE owner
|
|
4767
|
-
* (destination) row, in the SAME atomic transaction as the source write.
|
|
4768
|
-
*
|
|
4769
|
-
* The item's {@link keyCondition} carries the owner row's key templates (bound from
|
|
4770
|
-
* the source payload — `{sourceInputField}`), so the same key derivation / collapse
|
|
4771
|
-
* signature the other `Update` items use applies unchanged. This `maintain` payload
|
|
4772
|
-
* carries the projection transform IR (`identity` / `preview`) the runtimes apply
|
|
4773
|
-
* IDENTICALLY when rendering the `SET … = :v` (snapshot) / `list_append(…)`
|
|
4774
|
-
* (collection) `UpdateExpression`, so the maintained row is byte-consistent across
|
|
4775
|
-
* TS and Python. The `changes` / `add` fields are NOT used when this is present.
|
|
4776
|
-
*/
|
|
4777
|
-
readonly maintain?: MaintainItemSpec;
|
|
4778
|
-
}
|
|
4779
|
-
/**
|
|
4780
|
-
* The transform op applied to one projected maintenance attribute (Epic #118).
|
|
4781
|
-
* Mirrors `ProjectionTransformOp` from `src/define/entity-writes.ts`: `identity`
|
|
4782
|
-
* copies the source value through unchanged; `preview` keeps the first `n`
|
|
4783
|
-
* characters of (the string form of) the source value. The runtimes apply this
|
|
4784
|
-
* IDENTICALLY so the maintained row is byte-consistent.
|
|
4785
|
-
*/
|
|
4786
|
-
type MaintainProjectionOp = 'identity' | 'preview';
|
|
4787
|
-
/**
|
|
4788
|
-
* One projected maintenance attribute: the source value is read from the mutation
|
|
4789
|
-
* input field {@link inputField} (payload 同梱 — the just-written source row image),
|
|
4790
|
-
* then run through {@link op} with {@link args} (e.g. `preview`'s length bound).
|
|
4791
|
-
*/
|
|
4792
|
-
interface MaintainProjectionEntry {
|
|
4793
|
-
/** The transform op applied to the source value (`identity` / `preview`). */
|
|
4794
|
-
readonly op: MaintainProjectionOp;
|
|
4795
|
-
/** The op's positional arguments (`[n]` for `preview`; empty for `identity`). */
|
|
4796
|
-
readonly args: readonly unknown[];
|
|
4797
|
-
/** The mutation-input field the source value is read from (`{inputField}`). */
|
|
4798
|
-
readonly inputField: string;
|
|
4799
|
-
}
|
|
4800
|
-
/**
|
|
4801
|
-
* The bounded-collection options a `collection` maintenance write carries. Phase 1
|
|
4802
|
-
* is **append-only**: `maxItems` / `orderBy` are recorded for the future async trim
|
|
4803
|
-
* (#130) but NOT applied synchronously — a single `UpdateExpression` cannot
|
|
4804
|
-
* read-modify-write a bounded/ordered list.
|
|
4805
|
-
*/
|
|
4806
|
-
interface MaintainCollectionSpec {
|
|
4807
|
-
/** The target attribute that holds the maintained collection. */
|
|
4808
|
-
readonly field: string;
|
|
4809
|
-
/** Cap on the collection size (recorded for #130; not trimmed in Phase 1). */
|
|
4810
|
-
readonly maxItems?: number;
|
|
4811
|
-
/** The mutation-input field the items are ordered by (recorded for #130). */
|
|
4812
|
-
readonly orderBy?: string;
|
|
4813
|
-
/** The direction `orderBy` sorts by, from the relation's `read.order` (recorded for #130). */
|
|
4814
|
-
readonly orderDir?: 'ASC' | 'DESC';
|
|
4815
|
-
}
|
|
4816
|
-
/**
|
|
4817
|
-
* The maintenance payload an `Update` {@link TransactionItemSpec} carries when it
|
|
4818
|
-
* materializes a maintained access path (Epic #118 / #129). A `snapshot` mirrors
|
|
4819
|
-
* the projection onto the owner row via `SET`; a `collection` appends the projection
|
|
4820
|
-
* as an item into the bounded list named by {@link collection} via `list_append`.
|
|
4821
|
-
*/
|
|
4822
|
-
interface MaintainItemSpec {
|
|
4823
|
-
/**
|
|
4824
|
-
* Whether the write mirrors a single row (`snapshot`), appends a collection item
|
|
4825
|
-
* (`collection`), or applies a scalar `ADD` counter (`counter`, Epic #118 / #141).
|
|
4826
|
-
*/
|
|
4827
|
-
readonly kind: 'snapshot' | 'collection' | 'counter';
|
|
4828
|
-
/** The relation property / `@aggregate` field that declared this maintenance (documentary). */
|
|
4829
|
-
readonly relationProperty: string;
|
|
4830
|
-
/** The trigger (`<sourceLogicalName>.<event>`) that fired this maintenance. */
|
|
4831
|
-
readonly trigger: string;
|
|
4832
|
-
/** target attribute → its projection transform (source field + op + args). Empty for `counter`. */
|
|
4833
|
-
readonly projection: Readonly<Record<string, MaintainProjectionEntry>>;
|
|
4834
|
-
/** The bounded-collection options; present only for `kind: 'collection'`. */
|
|
4835
|
-
readonly collection?: MaintainCollectionSpec;
|
|
4836
|
-
/**
|
|
4837
|
-
* The scalar counter `ADD`; present only for `kind: 'counter'` (#141). The runtimes
|
|
4838
|
-
* render `ADD #attr :delta` — an atomic, concurrency-safe increment that MERGES with
|
|
4839
|
-
* a same-row counter ADD (#92), the maintenance-pipeline analogue of the
|
|
4840
|
-
* self-lifecycle derived counter's `add` slot. `delta` is a numeric template string
|
|
4841
|
-
* (the compile-time constant `+1` created / `-1` removed).
|
|
4842
|
-
*/
|
|
4843
|
-
readonly counter?: MaintainCounterSpec;
|
|
4844
|
-
}
|
|
4845
|
-
/**
|
|
4846
|
-
* The scalar counter a `counter` maintenance write applies (Epic #118 / #141): an
|
|
4847
|
-
* atomic `ADD #attribute :delta`. `delta` is a literal numeric template string (the
|
|
4848
|
-
* compile-time constant the trigger fixed — `"1"` created / `"-1"` removed); the
|
|
4849
|
-
* runtimes serialize it as a number. Only `count()` is realized synchronously
|
|
4850
|
-
* (`max(field)` is rejected for the synchronous path — #130 / Phase 2).
|
|
4851
|
-
*/
|
|
4852
|
-
interface MaintainCounterSpec {
|
|
4853
|
-
/** The target attribute the counter increments (e.g. `postCount`). */
|
|
4854
|
-
readonly attribute: string;
|
|
4855
|
-
/** The signed `ADD` delta as a numeric template string (`"1"` / `"-1"`). */
|
|
4856
|
-
readonly delta: string;
|
|
4857
|
-
}
|
|
4858
|
-
/** A declarative transaction definition's full execution spec. */
|
|
4859
|
-
interface TransactionSpec {
|
|
4860
|
-
readonly params: Readonly<Record<string, ParamSpec>>;
|
|
4861
|
-
readonly items: readonly TransactionItemSpec[];
|
|
4862
|
-
/**
|
|
4863
|
-
* A static upper bound on the expanded item count when computable (no `forEach`
|
|
4864
|
-
* present → the exact count; with `forEach` it is left absent because the
|
|
4865
|
-
* element count is only known at execution — the runtime then enforces the
|
|
4866
|
-
* DynamoDB ≤25 limit after expansion).
|
|
4867
|
-
*/
|
|
4868
|
-
readonly maxItems?: number;
|
|
4869
|
-
}
|
|
4870
|
-
/**
|
|
4871
|
-
* Whether a contract is a public **read** (`'query'`) or **write** (`'command'`)
|
|
4872
|
-
* interface. Mirrors {@link QueryModelContract} / {@link CommandModelContract}'s
|
|
4873
|
-
* `kind` discriminant from the Contract IR (#58).
|
|
4874
|
-
*/
|
|
4875
|
-
type ContractKind = 'query' | 'command';
|
|
4876
|
-
/**
|
|
4877
|
-
* The resolution kind of a contract query method, **derived** by the planner from
|
|
4878
|
-
* the internal op (never hand-written; see proposal "N+1 Safety"):
|
|
4879
|
-
*
|
|
4880
|
-
* - `'point'` — target keys are known (unique-key `query` / `GetItem`); a key
|
|
4881
|
-
* array coalesces to one `BatchGetItem`.
|
|
4882
|
-
* - `'range'` — target key set is unknown (partition `list` / `Query`); one
|
|
4883
|
-
* request per partition key, so it is only ever safe for a single key.
|
|
4884
|
-
*/
|
|
4885
|
-
type ContractResolution = 'point' | 'range';
|
|
4886
|
-
/**
|
|
4887
|
-
* What input arity a contract method accepts, **derived** from its resolution:
|
|
4888
|
-
*
|
|
4889
|
-
* - `'either'` — a single key **or** an array (a `point` read / a known-key
|
|
4890
|
-
* write; the array form is one `BatchGetItem` / batched write).
|
|
4891
|
-
* - `'single'` — a single key only (a `range` read; an array would be an N+1
|
|
4892
|
-
* fan-out and is rejected by construction).
|
|
4893
|
-
* - `'array'` — an array only (reserved; not produced by the current resolvers).
|
|
4894
|
-
*/
|
|
4895
|
-
type ContractInputArity = 'single' | 'array' | 'either';
|
|
4896
|
-
/**
|
|
4897
|
-
* The per-key result cardinality of a contract query method, **derived** from the
|
|
4898
|
-
* internal op kind (proposal "Cardinality matrix"):
|
|
4899
|
-
*
|
|
4900
|
-
* - `'one'` — at most one item per key (a `point` read).
|
|
4901
|
-
* - `'many'` — a connection (`{ items, cursor }`) per key (a `range` read).
|
|
4902
|
-
*
|
|
4903
|
-
* This is the per-key shape; the input arity (single vs. array) then decides
|
|
4904
|
-
* whether the overall result is bare or keyed.
|
|
4905
|
-
*/
|
|
4906
|
-
type ContractCardinality = 'one' | 'many';
|
|
4907
|
-
/**
|
|
4908
|
-
* The category of a contract command method's declared result, part of the
|
|
4909
|
-
* contract (it surfaces in OpenAPI and every binding; proposal "Return values"):
|
|
4910
|
-
*
|
|
4911
|
-
* - `'void'` — fire-and-forget write (no body).
|
|
4912
|
-
* - `'result'` — an outcome / status object (e.g. `{ ok, version }`).
|
|
4913
|
-
* - `'entity'` — the updated entity (the post-write projection).
|
|
4914
|
-
*/
|
|
4915
|
-
type ContractCommandResult = 'void' | 'result' | 'entity';
|
|
4916
|
-
/** The Key of a contract: the field names that compose its access / join key. */
|
|
4917
|
-
interface ContractKeySpec {
|
|
4918
|
-
/** The key field names, in declaration order (e.g. `["articleId"]`). */
|
|
4919
|
-
readonly fields: readonly string[];
|
|
4920
|
-
}
|
|
4921
|
-
/**
|
|
4922
|
-
* One External Query (Query Composition) binding on a contract query method
|
|
4923
|
-
* (proposal "External Query"). It is a **build-time, in-process** read dependency
|
|
4924
|
-
* on another contract referenced by name in the same SSoT — there is no protocol
|
|
4925
|
-
* or transport. The runtime collects every parent key produced at this level and
|
|
4926
|
-
* resolves the referenced contract **once, batched**, for all of them.
|
|
4927
|
-
*
|
|
4928
|
-
* A composed child MUST be `point` (proposal "N+1 Safety"): the parent step may
|
|
4929
|
-
* yield N records, so a `range` child would be an N+1 fan-out.
|
|
4930
|
-
*/
|
|
4931
|
-
interface ComposeSpec {
|
|
4932
|
-
/** The result property the composed value is attached to (e.g. `billing`). */
|
|
4933
|
-
readonly as: string;
|
|
4934
|
-
/** The referenced contract name (a symbol in the same SSoT). */
|
|
4935
|
-
readonly contract: string;
|
|
4936
|
-
/** The referenced method on that contract (e.g. `get`). */
|
|
4937
|
-
readonly method: string;
|
|
4938
|
-
/**
|
|
4939
|
-
* An optional **logical** owner label (the bounded context that owns the
|
|
4940
|
-
* referenced contract) — not a network address. Omitted when unlabeled.
|
|
4941
|
-
*/
|
|
4942
|
-
readonly context?: string;
|
|
4943
|
-
/**
|
|
4944
|
-
* The child-key binding: child key field → a `from` source path on the parent
|
|
4945
|
-
* result, e.g. `{ accountId: "$.billingAccountId" }`.
|
|
4946
|
-
*/
|
|
4947
|
-
readonly bind: Readonly<Record<string, string>>;
|
|
4948
|
-
/**
|
|
4949
|
-
* The composed child's resolution. It MUST be `'point'` in a valid contract — a
|
|
4950
|
-
* composed child coalesces to one `BatchGetItem` across all parent keys, so a
|
|
4951
|
-
* `range` child (a partition `Query` that cannot be batched across the parent's
|
|
4952
|
-
* keys) is an N+1 fan-out. The N+1 static checker (#60,
|
|
4953
|
-
* {@link assertContractN1Safe}) rejects a `'range'` value on the build path; the
|
|
4954
|
-
* field is widened to {@link ContractResolution} so the offending node can be
|
|
4955
|
-
* carried into the assembled {@link ContractSpec} for the checker to inspect and
|
|
4956
|
-
* reject with a clear message, rather than being silently unrepresentable.
|
|
4957
|
-
*/
|
|
4958
|
-
readonly resolution: ContractResolution;
|
|
4959
|
-
/** The composed child's per-key cardinality (`'one'` for a valid `point`). */
|
|
4960
|
-
readonly cardinality: ContractCardinality;
|
|
4961
|
-
}
|
|
4962
|
-
/**
|
|
4963
|
-
* The **composition execution plan** for one query contract method (issue #70a),
|
|
4964
|
-
* the contract-layer mirror of {@link ExecutionPlanSpec}. It records how a method's
|
|
4965
|
-
* External Query compositions (`compose[]`) are staged relative to the parent read
|
|
4966
|
-
* and to one another, and the batching discipline each composed child obeys:
|
|
4967
|
-
*
|
|
4968
|
-
* - `stages` is an ordered list whose entries are indices into the method's
|
|
4969
|
-
* `compose[]`. The parent read (the referenced `operation`) is the implicit
|
|
4970
|
-
* stage before all of these. Every compose child binds its child key purely from
|
|
4971
|
-
* the **parent** result (`from('$.…')` paths), so sibling compositions are
|
|
4972
|
-
* mutually independent: they form a single stage `[0, 1, …]` and may be resolved
|
|
4973
|
-
* concurrently. (A composed child cannot, today, bind from another composed
|
|
4974
|
-
* child — the #63 DSL only exposes parent `from` paths — so there is never a
|
|
4975
|
-
* cross-composition dependency; the field is a list of stages so the shape can
|
|
4976
|
-
* carry one if a future primitive introduces it.)
|
|
4977
|
-
* - `concurrency` is the declared in-flight bound applied **within** a stage (the
|
|
4978
|
-
* shared {@link RELATION_TRAVERSAL_CONCURRENCY} = 16).
|
|
4979
|
-
* - `batchChunkSize` is the per-request key cap for a composed child read (100,
|
|
4980
|
-
* the DynamoDB `BatchGetItem` limit): a composition resolves **one batched
|
|
4981
|
-
* call** across all parent records (chunked at this size), never an N+1 fan-out
|
|
4982
|
-
* (the composed child is `point`, enforced by the #60 N+1 checker).
|
|
4983
|
-
*
|
|
4984
|
-
* Emitted only when the method declares at least one composition. A method without
|
|
4985
|
-
* compositions carries no plan, and a runtime without one resolves any
|
|
4986
|
-
* compositions sequentially (the pre-#70 behavior) — so an absent plan never
|
|
4987
|
-
* changes results.
|
|
4988
|
-
*/
|
|
4989
|
-
interface CompositionPlanSpec {
|
|
4990
|
-
/** Ordered stages of indices into `compose[]` (independent siblings share a stage). */
|
|
4991
|
-
readonly stages: readonly (readonly number[])[];
|
|
4992
|
-
/** The declared in-flight bound applied within each composition stage (16). */
|
|
4993
|
-
readonly concurrency: number;
|
|
4994
|
-
/** Per-request key cap for a composed child's batched read (100, BatchGetItem limit). */
|
|
4995
|
-
readonly batchChunkSize: number;
|
|
4996
|
-
}
|
|
4997
|
-
/**
|
|
4998
|
-
* The serialized spec of one **query** contract method. Carries the decided facts
|
|
4999
|
-
* (`resolution` / `inputArity` / `cardinality`) the planner derived in #58, a
|
|
5000
|
-
* reference into `queries` by name (the internal op), and any External Query
|
|
5001
|
-
* compositions. The decided facts are **serialized, not re-derived** — every
|
|
5002
|
-
* runtime honors them.
|
|
5003
|
-
*/
|
|
5004
|
-
interface QueryContractMethodSpec {
|
|
5005
|
-
/** Derived: `'point'` (unique-key query) or `'range'` (partition list). */
|
|
5006
|
-
readonly resolution: ContractResolution;
|
|
5007
|
-
/** Derived: `'either'` for `point`, `'single'` for `range`. */
|
|
5008
|
-
readonly inputArity: ContractInputArity;
|
|
5009
|
-
/** Derived per-key result shape: `'one'` (point) or `'many'` (range). */
|
|
5010
|
-
readonly cardinality: ContractCardinality;
|
|
5011
|
-
/** The referenced read op name in `queries` (e.g. `ArticleById__get`). */
|
|
5012
|
-
readonly operation: string;
|
|
5013
|
-
/** External Query compositions on this method; omitted when there are none. */
|
|
5014
|
-
readonly compose?: readonly ComposeSpec[];
|
|
5015
|
-
/**
|
|
5016
|
-
* The composition staging + batch plan (issue #70a); present only when `compose`
|
|
5017
|
-
* is. See {@link CompositionPlanSpec}: independent compositions form one
|
|
5018
|
-
* concurrency-eligible stage after the parent read, each resolved as one batched
|
|
5019
|
-
* call (chunk ≤100). Absent → resolve compositions sequentially (pre-#70).
|
|
5020
|
-
*/
|
|
5021
|
-
readonly compositionPlan?: CompositionPlanSpec;
|
|
5022
|
-
/**
|
|
5023
|
-
* Optional human-readable description of the read use case (issue #154), from the
|
|
5024
|
-
* descriptor's `description`. Pure documentation — absent unless declared, so a
|
|
5025
|
-
* method with no description serializes byte-identically to the pre-#154 spec.
|
|
5026
|
-
* The same string appears in the TS contract IR and (via the SSoT) in any
|
|
5027
|
-
* generated binding, so TS↔Python carry an identical description.
|
|
5028
|
-
*/
|
|
5029
|
-
readonly description?: string;
|
|
5030
|
-
}
|
|
5031
|
-
/**
|
|
5032
|
-
* How a contract command method resolves a single key vs. an array of keys to the
|
|
5033
|
-
* underlying write surface (proposal "Consistency with the existing write
|
|
5034
|
-
* surface"). A single key → one write op (or one transaction); an array → a
|
|
5035
|
-
* batched write — a `TransactWriteItems` when atomicity / per-item conditions are
|
|
5036
|
-
* required, or a `BatchWriteItem` when neither is.
|
|
5037
|
-
*/
|
|
5038
|
-
type CommandResolutionTarget =
|
|
5039
|
-
/** One write op, referenced by name in `commands`. */
|
|
5040
|
-
{
|
|
5041
|
-
readonly mode: 'op';
|
|
5042
|
-
readonly operation: string;
|
|
5043
|
-
}
|
|
5044
|
-
/** One transaction, referenced by name in `transactions`. */
|
|
5045
|
-
| {
|
|
5046
|
-
readonly mode: 'transaction';
|
|
5047
|
-
readonly transaction: string;
|
|
5048
|
-
}
|
|
5049
|
-
/**
|
|
5050
|
-
* A non-atomic **parallel** fan-out over the per-key write op (#101). The op
|
|
5051
|
-
* MAY carry a condition (guarded create / conditioned update). Unconditioned
|
|
5052
|
-
* `put`/`delete` ops coalesce into a `BatchWriteItem` (with `UnprocessedItems`
|
|
5053
|
-
* retry); conditioned/update ops issue individual conditional writes
|
|
5054
|
-
* concurrently. Per-op success/failure is reported (partial success); a
|
|
5055
|
-
* per-op failure never aborts the others. References the per-key write op in
|
|
5056
|
-
* `commands`.
|
|
5057
|
-
*/
|
|
5058
|
-
| {
|
|
5059
|
-
readonly mode: 'parallel';
|
|
5060
|
-
readonly operation: string;
|
|
5061
|
-
};
|
|
5062
|
-
/**
|
|
5063
|
-
* The serialized spec of one **command** contract method. Symmetric to
|
|
5064
|
-
* {@link QueryContractMethodSpec}: it carries the declared `result` type and the
|
|
5065
|
-
* `single` / `batch` resolution targets into the existing write specs.
|
|
5066
|
-
*/
|
|
5067
|
-
interface CommandContractMethodSpec {
|
|
5068
|
-
/** Derived input arity: writes accept `'either'` (single key or key array). */
|
|
5069
|
-
readonly inputArity: ContractInputArity;
|
|
5070
|
-
/** The declared result type (`void` | a `Result` | the updated entity). */
|
|
5071
|
-
readonly result: ContractCommandResult;
|
|
5072
|
-
/** How a single key resolves (one op / one transaction). */
|
|
5073
|
-
readonly single: CommandResolutionTarget;
|
|
5074
|
-
/**
|
|
5075
|
-
* How an array of keys resolves (a transaction / `BatchWriteItem`); omitted
|
|
5076
|
-
* when the contract does not declare a batched write form.
|
|
5077
|
-
*/
|
|
5078
|
-
readonly batch?: CommandResolutionTarget;
|
|
5079
|
-
/**
|
|
5080
|
-
* The **return projection** of a `mutation`-derived command method (issue #83;
|
|
5081
|
-
* proposal §3, "return selection as a read projection"). A JSON-safe boolean
|
|
5082
|
-
* field map: after the write commits, the runtime issues a **`GetItem` with
|
|
5083
|
-
* `ConsistentRead`** of the written entity's primary key and applies this
|
|
5084
|
-
* projection via the existing read-projection machinery, returning the projected
|
|
5085
|
-
* item. This is the **uniform** return mechanism for both a single-op command
|
|
5086
|
-
* and a future transaction (a `TransactWriteItems` cannot return item images),
|
|
5087
|
-
* so TS and Python return an **identical** projected item.
|
|
5088
|
-
*
|
|
5089
|
-
* The consistent read-back is issued against the read op named
|
|
5090
|
-
* `<Contract>__<method>__readback` (a synthesized {@link QuerySpec}: a `GetItem`
|
|
5091
|
-
* on the written entity's primary key projecting these fields). Present only on
|
|
5092
|
-
* a `.plan(mutation)` method; a hand-written #64 command omits it (its
|
|
5093
|
-
* {@link result} stays `'void'` / `'entity'` and it returns no projected item).
|
|
5094
|
-
*/
|
|
5095
|
-
readonly returnSelection?: Readonly<Record<string, boolean>>;
|
|
5096
|
-
/**
|
|
5097
|
-
* Optional human-readable description of the write use case (issue #154), from
|
|
5098
|
-
* the descriptor's `description`. Pure documentation — absent unless declared, so
|
|
5099
|
-
* a method with no description serializes byte-identically to the pre-#154 spec.
|
|
5100
|
-
*/
|
|
5101
|
-
readonly description?: string;
|
|
5102
|
-
}
|
|
5103
|
-
/**
|
|
5104
|
-
* A serialized contract — a keyed public read (`'query'`) or write (`'command'`)
|
|
5105
|
-
* interface holding one or more named methods. Each method references an existing
|
|
5106
|
-
* operation spec by name and adds the decided contract facts. The existing
|
|
5107
|
-
* operation-spec shapes are unchanged, so the current runtime keeps working.
|
|
5108
|
-
*/
|
|
5109
|
-
interface ContractSpec {
|
|
5110
|
-
/** Whether this is a read (`'query'`) or write (`'command'`) contract. */
|
|
5111
|
-
readonly kind: ContractKind;
|
|
5112
|
-
/** The contract Key (the access pattern / join / batch key). */
|
|
5113
|
-
readonly key: ContractKeySpec;
|
|
5114
|
-
/**
|
|
5115
|
-
* The named methods (use cases over the same Key). A query contract's methods
|
|
5116
|
-
* are {@link QueryContractMethodSpec}; a command contract's are
|
|
5117
|
-
* {@link CommandContractMethodSpec}. The map is keyed by contract `kind`.
|
|
5118
|
-
*/
|
|
5119
|
-
readonly methods: Readonly<Record<string, QueryContractMethodSpec>> | Readonly<Record<string, CommandContractMethodSpec>>;
|
|
5120
|
-
}
|
|
5121
|
-
/**
|
|
5122
|
-
* One bounded context's membership (issue #59, "context ownership"). Lists the
|
|
5123
|
-
* Models and Contracts that belong to the same context, so the future boundary
|
|
5124
|
-
* lint (#61) can tell **own** from **foreign**: a contract may resolve its own
|
|
5125
|
-
* context's Models directly, but may only reach another context through that
|
|
5126
|
-
* context's published Contract (direct use of a foreign Model is a build error).
|
|
5127
|
-
*
|
|
5128
|
-
* This issue only **serializes / emits** this declaration; it does not enforce
|
|
5129
|
-
* it. Both lists are entity / contract *names* (matching `manifest.entities` keys
|
|
5130
|
-
* and `contracts` keys respectively).
|
|
5131
|
-
*/
|
|
5132
|
-
interface ContextSpec {
|
|
5133
|
-
/** Model (entity) names owned by this context (sorted; manifest entity keys). */
|
|
5134
|
-
readonly models: readonly string[];
|
|
5135
|
-
/** Contract names owned by this context (sorted; `contracts` map keys). */
|
|
5136
|
-
readonly contracts: readonly string[];
|
|
5137
|
-
}
|
|
5138
|
-
interface OperationsDocument {
|
|
5139
|
-
readonly version: typeof SPEC_VERSION;
|
|
5140
|
-
readonly queries: Readonly<Record<string, QuerySpec>>;
|
|
5141
|
-
readonly commands: Readonly<Record<string, CommandSpec>>;
|
|
5142
|
-
/** Declarative transactions (issue #46). Absent in pre-#46 specs. */
|
|
5143
|
-
readonly transactions?: Readonly<Record<string, TransactionSpec>>;
|
|
5144
|
-
/**
|
|
5145
|
-
* The CQRS Contract layer (issue #59): contract name → {@link ContractSpec}.
|
|
5146
|
-
* Layered **on top of** the existing `queries` / `commands` / `transactions`
|
|
5147
|
-
* (each method references one of them by name). **Absent** when the input
|
|
5148
|
-
* defines no contracts — so a contract-free input produces a byte-identical
|
|
5149
|
-
* pre-#59 operations document (backward compatibility).
|
|
5150
|
-
*/
|
|
5151
|
-
readonly contracts?: Readonly<Record<string, ContractSpec>>;
|
|
5152
|
-
/**
|
|
5153
|
-
* Context-ownership declarations (issue #59): context name →
|
|
5154
|
-
* {@link ContextSpec}. Used by the boundary lint (#61) to tell own from
|
|
5155
|
-
* foreign. **Absent** when no contexts are declared (backward compatibility).
|
|
5156
|
-
*/
|
|
5157
|
-
readonly contexts?: Readonly<Record<string, ContextSpec>>;
|
|
5158
|
-
}
|
|
5159
|
-
/** The full `{ manifest, operations }` bundle produced by the static planner. */
|
|
5160
|
-
interface BridgeBundle {
|
|
5161
|
-
readonly manifest: Manifest;
|
|
5162
|
-
readonly operations: OperationsDocument;
|
|
5163
|
-
}
|
|
5164
|
-
|
|
5165
4126
|
/**
|
|
5166
4127
|
* A **referential-integrity assertion** derived from a `requires`
|
|
5167
4128
|
* ({@link RequiresEffect}) effect (issue #84; proposal §2/§3). It is the
|
|
@@ -6606,7 +5567,15 @@ interface PreparedParamRef {
|
|
|
6606
5567
|
declare function isPreparedParamRef(value: unknown): value is PreparedParamRef;
|
|
6607
5568
|
/** The placeholder proxy handed to a `prepare` body as `$`. Every `$.<name>` read
|
|
6608
5569
|
* mints a {@link PreparedParamRef}; any further access / coercion throws so the
|
|
6609
|
-
* body stays a pure, params-independent template (no runtime capture).
|
|
5570
|
+
* body stays a pure, params-independent template (no runtime capture).
|
|
5571
|
+
*
|
|
5572
|
+
* **Input Port 統一 (issue #264)**: this proxy is one of the three authoring
|
|
5573
|
+
* spellings of the SAME Input Port reference model — see the unification note
|
|
5574
|
+
* on {@link import('../define/transaction.js').ParamProxy} (`defineTransaction`'s
|
|
5575
|
+
* `p.*` proxy is the model; a `$.<name>` read here is the same "declared
|
|
5576
|
+
* input field, bound at execution" reference that serializes as `{<name>}`
|
|
5577
|
+
* templates / `{ref:["input","<name>"]}` expression refs elsewhere). Behavior
|
|
5578
|
+
* here is unchanged in 0.7.x (interop kept). */
|
|
6610
5579
|
type PreparedInputProxy = Record<string, PreparedParamRef>;
|
|
6611
5580
|
/** A `prepare` write route: `{ create|update|remove: () => Model, key, input?, condition?, result? }`. */
|
|
6612
5581
|
interface PreparedWriteRoute {
|
|
@@ -7597,4 +6566,4 @@ interface ViewDefinition {
|
|
|
7597
6566
|
*/
|
|
7598
6567
|
declare function collectViewDefinitions(registry?: ReadonlyMap<Function, EntityMetadata>): ViewDefinition[];
|
|
7599
6568
|
|
|
7600
|
-
export { type
|
|
6569
|
+
export { type DerivedOutboxEvent as $, type ParamDescriptor as A, type BatchResult as B, type CdcEmulatorOptions as C, type DynamoDBOperation as D, type EventLog as E, type FaultSpec as F, type EntityRef as G, type ConditionInput as H, type DefinitionMap as I, type AnyOperationDefinition as J, type PreparedBody as K, type CompiledFragment as L, type ModelStatic as M, type CompiledMutationPlan as N, type DerivedConditionCheck as O, type PutInput as P, type QueryModelContract as Q, type ReplayOptions as R, type ShardId as S, type TransactWriteExecItem as T, type Unsubscribe as U, type ViewDefinition as V, type WriteExecOptions as W, type DerivedEdgeWrite as X, type DerivedIdempotencyGuard as Y, type DerivedMaintainOutbox as Z, type DerivedMaintainWrite as _, type CdcMode as a, type CdcModelRegistry as a$, type DerivedUniqueGuard as a0, type DerivedUpdate as a1, type EntityRefResolver as a2, MAX_TRANSACT_COMPOSE_ITEMS as a3, assertNoCrossFragmentMaintainCollision as a4, compileFragment as a5, compileMutationPlan as a6, compileSingleFragmentPlan as a7, resetMaintenanceGraphCache as a8, resolveLifecycle as a9, type SelectBuilderSpec as aA, type RawCondition as aB, type ExecutionPlan as aC, type FieldMetadata as aD, type ResolvedKey as aE, type Slot as aF, type PreparedWriteExecOptions as aG, type CommandReturn as aH, type ParallelOpResult as aI, type PreparedStatement as aJ, type RelationMetadata as aK, type MaintainEffect as aL, type OperationDefinition as aM, type WriteDefinitionOptions as aN, type PartialQueryKeyOf as aO, type StrictSelectSpec as aP, type ReadDefinitionOptions as aQ, type EntityInput as aR, type UniqueQueryKeyOf as aS, type AggregateMetadata as aT, type BatchDeleteRequest as aU, type BatchGetOptions as aV, type BatchGetRequest as aW, BatchGetResult as aX, type BatchPutRequest as aY, type BatchWriteRequest as aZ, CONTRACT_RANGE_FANOUT_CONCURRENCY as a_, resolveMaintainers as aa, type SelectableOf as ab, type PrimaryKeyOf as ac, type RequestContext as ad, type Middleware as ae, type ReadRequestKind as af, type CtxModel as ag, type ReadParams as ah, type ReadRequestCtx as ai, type Item as aj, type RetryPolicy as ak, type RetryOverride as al, type KeyDefinition as am, type GsiDefinition as an, type ModelKind as ao, type FieldOptions as ap, type DynamoType as aq, type ProjectionTransform as ar, type MaintainEvent as as, type MembershipPredicate as at, type MaintainConsistency as au, type MaintainUpdateMode as av, type MembershipPredicateOp as aw, type RelationOptions as ax, type AggregateOptions as ay, type AggregateValue as az, type ChangeBatch as b, type MembershipEffect as b$, type CdcSubscribeHandlers as b0, type Change as b1, type CollectionEffect as b2, type CollectionOptions as b3, type Column as b4, type ColumnMap as b5, type CommandInputShape as b6, type CommandMethod as b7, type CommandPlan as b8, type CommandResultKind as b9, type EmbeddedMetadata as bA, type EmitEffect as bB, type EntityWritesDefinition as bC, type EntityWritesShape as bD, type ExecutableCommandContract as bE, type ExecutableQueryContract as bF, type FilterInput as bG, type FragmentCondition as bH, type FragmentConditionOperatorObject as bI, type FragmentInput as bJ, type GsiDefinitionMarker as bK, type GsiOptions as bL, type IdempotencyEffect as bM, type InProcessWriteDescriptor as bN, type InlineSnapshotSpec as bO, type InputArity as bP, type KeyDefinitionMarker as bQ, type KeySegment as bR, type KeySlot as bS, type KeyStructure as bT, type KeyedResult as bU, LIFECYCLE_CONTRACT_MARKER as bV, type LifecycleContract as bW, type LifecycleEffects as bX, type MaintainItem as bY, type MaintainTrigger as bZ, type MaintenanceGraph as b_, type CommandSelectShape as ba, type CondSlot as bb, type ConditionCheckInput as bc, type Connection as bd, type ContractCallSignature as be, type ContractCommandParams as bf, type ContractComposeNode as bg, type ContractFromRef as bh, type ContractItem as bi, type ContractKeyFieldRef as bj, type ContractKeyInput as bk, type ContractKeyRef as bl, type ContractMethodOp as bm, type ContractParamRef as bn, type ContractQueryParams as bo, type CounterAggregate as bp, type CounterEffect as bq, type CtxBase as br, DEFAULT_MAX_ATTEMPTS as bs, DEFAULT_RETRY_POLICY as bt, type DeleteOptions as bu, type DeriveEffect as bv, type DescriptorBinding as bw, ENTITY_WRITES_MARKER as bx, type EdgeEffect as by, type EffectPath as bz, type ChangeEvent as c, type WriteDescriptor as c$, type ModelRef as c0, type MutateMode as c1, type MutateOptions as c2, type MutateParallelResult as c3, type MutateTransactionResult as c4, type MutationBody as c5, type MutationDescriptorMap as c6, type MutationFragment as c7, type MutationInputProxy as c8, type MutationInputRef as c9, type ReadRouteResult as cA, type RecordedCompose as cB, type RelationBuilder as cC, type RelationConsistency as cD, type RelationLimitOptions as cE, type RelationPattern as cF, type RelationProjection as cG, type RelationReadOptions as cH, type RelationSelect as cI, type RelationSpec as cJ, type RelationUpdateMode as cK, type RelationWriteOptions as cL, type RequiresEffect as cM, type Resolution as cN, type RetryInfo as cO, type RetryOperationKind as cP, type SegmentSpec as cQ, type SegmentedKey as cR, type SelectBuilder as cS, type SelectOf as cT, type SnapshotEffect as cU, TransactionContext as cV, type UniqueEffect as cW, type Updatable as cX, type UpdateOptions as cY, type ViewSourceSlice as cZ, type WriteCtx as c_, type MutationIntent as ca, type OperationKind as cb, PREPARE_CACHE_MAX as cc, type ParamStructure as cd, type PersistCtx as ce, type PersistOrigin as cf, type PlannedCommandMethod as cg, type PreparedInputProxy as ch, type PreparedParamRef as ci, type PreparedReadExecOptions as cj, type PreparedReadRoute as ck, PreparedReadStatement as cl, type PreparedWriteRoute as cm, PreparedWriteStatement as cn, type ProjectionMap as co, type ProjectionTransformOp as cp, type PutOptions as cq, type QueryEnvelopeResult as cr, type QueryKeyOf as cs, type QueryMethod as ct, type QueryResult as cu, type ReadEnvelope as cv, type ReadOpCtx as cw, type ReadOpKind as cx, type ReadRouteDescriptor as cy, type ReadRouteOptions as cz, type ChangeEventName as d, wholeKeysSentinel as d$, type WriteEnvelope as d0, type WriteInput as d1, type WriteKind as d2, type WriteLifecyclePhase as d3, type WriteMiddleware as d4, type WriteRecorder as d5, type WriteResultProjection as d6, attachModelClass as d7, buildDeleteInput as d8, buildMaintenanceGraph as d9, isContractFromRef as dA, isContractKeyFieldRef as dB, isContractKeyRef as dC, isContractParamRef as dD, isEntityWritesDefinition as dE, isKeySegment as dF, isLifecycleContract as dG, isMaintainTrigger as dH, isMutationFragment as dI, isMutationInputRef as dJ, isPlannedCommandMethod as dK, isPreparedParamRef as dL, isQueryModelContract as dM, isRetryableError as dN, isRetryableTransactionCancellation as dO, k as dP, key as dQ, lifecyclePhaseForIntent as dR, maintainTrigger as dS, mintContractKeyFieldRef as dT, mintContractParamRef as dU, mutation as dV, prepare as dW, preview as dX, publicCommandModel as dY, publicQueryModel as dZ, query as d_, buildPutInput as da, buildUpdateInput as db, collectViewDefinitions as dc, cond as dd, contractOfMethodSpec as de, definePlan as df, entityWrites as dg, executeBatchGet as dh, executeBatchWrite as di, executeCommandMethod as dj, executeDelete as dk, executeKeyedBatchGet as dl, executePut as dm, executeQueryMethod as dn, executeRangeFanout as dp, executeTransaction as dq, executeUpdate as dr, from as ds, getEntityWrites as dt, gsi as du, identity as dv, isColumn as dw, isCommandModelContract as dx, isCommandPlan as dy, isContractComposeNode as dz, type ChangeHandler as e, type ClockMode as f, type ConcurrentRecomputeRef as g, type StartingPosition as h, type StreamViewType as i, type SubscribeHandler as j, type SubscribeHandlers as k, buildSubscribeHandler as l, type EntityMetadata as m, type Executor as n, type ReadExecOptions as o, type ExecutorResult as p, type BatchGetExecInput as q, type WriteResult as r, type UpdateInput as s, type DeleteInput as t, type BatchWriteExecItem as u, type BatchExecOptions as v, DDBModel as w, type QueryMethodSpec as x, type CommandModelContract as y, type CommandMethodSpec as z };
|