effect-dynamodb 1.39.0 → 1.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (190) hide show
  1. package/README.md +1 -1
  2. package/dist/Aggregate.d.ts +138 -16
  3. package/dist/Aggregate.d.ts.map +1 -1
  4. package/dist/Aggregate.js +4298 -725
  5. package/dist/Aggregate.js.map +1 -1
  6. package/dist/Batch.d.ts +9 -5
  7. package/dist/Batch.d.ts.map +1 -1
  8. package/dist/Batch.js +28 -44
  9. package/dist/Batch.js.map +1 -1
  10. package/dist/Collection.d.ts.map +1 -1
  11. package/dist/Collection.js +16 -9
  12. package/dist/Collection.js.map +1 -1
  13. package/dist/ConsumedCapacity.js +1 -1
  14. package/dist/ConsumedCapacity.js.map +1 -1
  15. package/dist/DynamoClient.d.ts +44 -21
  16. package/dist/DynamoClient.d.ts.map +1 -1
  17. package/dist/DynamoClient.js +342 -124
  18. package/dist/DynamoClient.js.map +1 -1
  19. package/dist/Entity.d.ts +246 -41
  20. package/dist/Entity.d.ts.map +1 -1
  21. package/dist/Entity.js +6818 -1166
  22. package/dist/Entity.js.map +1 -1
  23. package/dist/EventStore.d.ts +37 -15
  24. package/dist/EventStore.d.ts.map +1 -1
  25. package/dist/EventStore.js +403 -163
  26. package/dist/EventStore.js.map +1 -1
  27. package/dist/Expression.d.ts.map +1 -1
  28. package/dist/Expression.js +40 -24
  29. package/dist/Expression.js.map +1 -1
  30. package/dist/Marshaller.d.ts +72 -11
  31. package/dist/Marshaller.d.ts.map +1 -1
  32. package/dist/Marshaller.js +625 -71
  33. package/dist/Marshaller.js.map +1 -1
  34. package/dist/Query.d.ts +103 -5
  35. package/dist/Query.d.ts.map +1 -1
  36. package/dist/Query.js +262 -15
  37. package/dist/Query.js.map +1 -1
  38. package/dist/StorageEncoding.d.ts +7 -1
  39. package/dist/StorageEncoding.d.ts.map +1 -1
  40. package/dist/StorageEncoding.js +8 -2
  41. package/dist/StorageEncoding.js.map +1 -1
  42. package/dist/Table.d.ts +338 -16
  43. package/dist/Table.d.ts.map +1 -1
  44. package/dist/Table.js +30 -2
  45. package/dist/Table.js.map +1 -1
  46. package/dist/Transaction.d.ts.map +1 -1
  47. package/dist/Transaction.js +70 -7
  48. package/dist/Transaction.js.map +1 -1
  49. package/dist/VectorSearchEmulation.d.ts.map +1 -1
  50. package/dist/VectorSearchEmulation.js +4 -3
  51. package/dist/VectorSearchEmulation.js.map +1 -1
  52. package/dist/change-feed/ChangeFeed.d.ts +8 -3
  53. package/dist/change-feed/ChangeFeed.d.ts.map +1 -1
  54. package/dist/change-feed/ChangeFeed.js +76 -9
  55. package/dist/change-feed/ChangeFeed.js.map +1 -1
  56. package/dist/change-feed/CheckpointStore.js +1 -1
  57. package/dist/change-feed/CheckpointStore.js.map +1 -1
  58. package/dist/change-feed/DynamoStreamsClient.d.ts +19 -10
  59. package/dist/change-feed/DynamoStreamsClient.d.ts.map +1 -1
  60. package/dist/change-feed/DynamoStreamsClient.js +24 -14
  61. package/dist/change-feed/DynamoStreamsClient.js.map +1 -1
  62. package/dist/index.d.ts +2 -2
  63. package/dist/index.d.ts.map +1 -1
  64. package/dist/index.js +1 -1
  65. package/dist/index.js.map +1 -1
  66. package/dist/internal/BoundCrud.d.ts +78 -32
  67. package/dist/internal/BoundCrud.d.ts.map +1 -1
  68. package/dist/internal/BoundCrud.js +25 -0
  69. package/dist/internal/BoundCrud.js.map +1 -1
  70. package/dist/internal/BoundQuery.d.ts +46 -3
  71. package/dist/internal/BoundQuery.d.ts.map +1 -1
  72. package/dist/internal/BoundQuery.js +402 -37
  73. package/dist/internal/BoundQuery.js.map +1 -1
  74. package/dist/internal/BoundVectorQuery.d.ts +6 -0
  75. package/dist/internal/BoundVectorQuery.d.ts.map +1 -1
  76. package/dist/internal/BoundVectorQuery.js +7 -4
  77. package/dist/internal/BoundVectorQuery.js.map +1 -1
  78. package/dist/internal/Capacity.d.ts +46 -5
  79. package/dist/internal/Capacity.d.ts.map +1 -1
  80. package/dist/internal/Capacity.js +177 -26
  81. package/dist/internal/Capacity.js.map +1 -1
  82. package/dist/internal/ClientOptions.d.ts +144 -0
  83. package/dist/internal/ClientOptions.d.ts.map +1 -0
  84. package/dist/internal/ClientOptions.js +290 -0
  85. package/dist/internal/ClientOptions.js.map +1 -0
  86. package/dist/internal/ConditionHolds.d.ts +29 -0
  87. package/dist/internal/ConditionHolds.d.ts.map +1 -0
  88. package/dist/internal/ConditionHolds.js +453 -0
  89. package/dist/internal/ConditionHolds.js.map +1 -0
  90. package/dist/internal/Cursor.d.ts +19 -10
  91. package/dist/internal/Cursor.d.ts.map +1 -1
  92. package/dist/internal/Cursor.js +25 -10
  93. package/dist/internal/Cursor.js.map +1 -1
  94. package/dist/internal/Digest.d.ts +20 -0
  95. package/dist/internal/Digest.d.ts.map +1 -0
  96. package/dist/internal/Digest.js +106 -0
  97. package/dist/internal/Digest.js.map +1 -0
  98. package/dist/internal/DynamoArithmetic.d.ts +33 -0
  99. package/dist/internal/DynamoArithmetic.d.ts.map +1 -0
  100. package/dist/internal/DynamoArithmetic.js +112 -0
  101. package/dist/internal/DynamoArithmetic.js.map +1 -0
  102. package/dist/internal/EntityCombinators.d.ts +23 -8
  103. package/dist/internal/EntityCombinators.d.ts.map +1 -1
  104. package/dist/internal/EntityCombinators.js +6 -2
  105. package/dist/internal/EntityCombinators.js.map +1 -1
  106. package/dist/internal/EntityOps.d.ts +69 -8
  107. package/dist/internal/EntityOps.d.ts.map +1 -1
  108. package/dist/internal/EntityOps.js.map +1 -1
  109. package/dist/internal/EventProjection.d.ts +18 -4
  110. package/dist/internal/EventProjection.d.ts.map +1 -1
  111. package/dist/internal/EventProjection.js +36 -8
  112. package/dist/internal/EventProjection.js.map +1 -1
  113. package/dist/internal/Expr.d.ts +72 -2
  114. package/dist/internal/Expr.d.ts.map +1 -1
  115. package/dist/internal/Expr.js +264 -5
  116. package/dist/internal/Expr.js.map +1 -1
  117. package/dist/internal/ExpressionLimits.d.ts +57 -1
  118. package/dist/internal/ExpressionLimits.d.ts.map +1 -1
  119. package/dist/internal/ExpressionLimits.js +97 -4
  120. package/dist/internal/ExpressionLimits.js.map +1 -1
  121. package/dist/internal/FormGuard.d.ts +52 -0
  122. package/dist/internal/FormGuard.d.ts.map +1 -0
  123. package/dist/internal/FormGuard.js +83 -0
  124. package/dist/internal/FormGuard.js.map +1 -0
  125. package/dist/internal/Hydrate.d.ts.map +1 -1
  126. package/dist/internal/Hydrate.js +2 -1
  127. package/dist/internal/Hydrate.js.map +1 -1
  128. package/dist/internal/InputForm.d.ts +24 -0
  129. package/dist/internal/InputForm.d.ts.map +1 -0
  130. package/dist/internal/InputForm.js +44 -0
  131. package/dist/internal/InputForm.js.map +1 -0
  132. package/dist/internal/InsertStatement.d.ts +15 -0
  133. package/dist/internal/InsertStatement.d.ts.map +1 -0
  134. package/dist/internal/InsertStatement.js +18 -0
  135. package/dist/internal/InsertStatement.js.map +1 -0
  136. package/dist/internal/ItemSize.d.ts +108 -4
  137. package/dist/internal/ItemSize.d.ts.map +1 -1
  138. package/dist/internal/ItemSize.js +190 -3
  139. package/dist/internal/ItemSize.js.map +1 -1
  140. package/dist/internal/MultiProjection.d.ts +7 -2
  141. package/dist/internal/MultiProjection.d.ts.map +1 -1
  142. package/dist/internal/MultiProjection.js +18 -12
  143. package/dist/internal/MultiProjection.js.map +1 -1
  144. package/dist/internal/OperandReaders.d.ts +36 -0
  145. package/dist/internal/OperandReaders.d.ts.map +1 -0
  146. package/dist/internal/OperandReaders.js +176 -0
  147. package/dist/internal/OperandReaders.js.map +1 -0
  148. package/dist/internal/Packed.d.ts.map +1 -1
  149. package/dist/internal/Packed.js +11 -10
  150. package/dist/internal/Packed.js.map +1 -1
  151. package/dist/internal/PathBuilder.d.ts +57 -8
  152. package/dist/internal/PathBuilder.d.ts.map +1 -1
  153. package/dist/internal/PathBuilder.js +98 -24
  154. package/dist/internal/PathBuilder.js.map +1 -1
  155. package/dist/internal/ProjectionEngine.d.ts +196 -3
  156. package/dist/internal/ProjectionEngine.d.ts.map +1 -1
  157. package/dist/internal/ProjectionEngine.js +1251 -86
  158. package/dist/internal/ProjectionEngine.js.map +1 -1
  159. package/dist/internal/Rekey.d.ts +187 -21
  160. package/dist/internal/Rekey.d.ts.map +1 -1
  161. package/dist/internal/Rekey.js +1349 -63
  162. package/dist/internal/Rekey.js.map +1 -1
  163. package/dist/internal/ReturnedItem.d.ts +23 -0
  164. package/dist/internal/ReturnedItem.d.ts.map +1 -0
  165. package/dist/internal/ReturnedItem.js +39 -0
  166. package/dist/internal/ReturnedItem.js.map +1 -0
  167. package/dist/internal/RoundTrip.d.ts +45 -0
  168. package/dist/internal/RoundTrip.d.ts.map +1 -0
  169. package/dist/internal/RoundTrip.js +106 -0
  170. package/dist/internal/RoundTrip.js.map +1 -0
  171. package/dist/internal/SentRequest.d.ts +14 -0
  172. package/dist/internal/SentRequest.d.ts.map +1 -0
  173. package/dist/internal/SentRequest.js +31 -0
  174. package/dist/internal/SentRequest.js.map +1 -0
  175. package/dist/internal/TransactPlan.d.ts.map +1 -1
  176. package/dist/internal/TransactPlan.js +4 -0
  177. package/dist/internal/TransactPlan.js.map +1 -1
  178. package/dist/internal/TransactWriteOps.d.ts +70 -15
  179. package/dist/internal/TransactWriteOps.d.ts.map +1 -1
  180. package/dist/internal/TransactWriteOps.js +166 -112
  181. package/dist/internal/TransactWriteOps.js.map +1 -1
  182. package/dist/internal/TransactableOps.d.ts +230 -27
  183. package/dist/internal/TransactableOps.d.ts.map +1 -1
  184. package/dist/internal/TransactableOps.js +549 -92
  185. package/dist/internal/TransactableOps.js.map +1 -1
  186. package/dist/internal/WriteDiagnosis.d.ts +66 -3
  187. package/dist/internal/WriteDiagnosis.d.ts.map +1 -1
  188. package/dist/internal/WriteDiagnosis.js +261 -15
  189. package/dist/internal/WriteDiagnosis.js.map +1 -1
  190. package/package.json +5 -5
@@ -17,9 +17,12 @@ import { ValidationError } from "@effect-dynamodb/schema/Errors.js";
17
17
  import { Effect } from "effect";
18
18
  import type { DynamoClient, DynamoClientError } from "../DynamoClient.js";
19
19
  import type { Entity, EntityDelete, EntityPut, EntityUpdate, PlanDeleteError, PlanUpdateError, PutVerdict, WriteCancellationReason } from "../Entity.js";
20
- import type { ExpressionResult } from "../Expression.js";
20
+ import type { ConditionInput, ExpressionResult } from "../Expression.js";
21
21
  import { type TableConfig } from "../Table.js";
22
22
  import type { BoundUpdateOp, BoundWriteOp } from "./BoundCrud.js";
23
+ import { type PutKind } from "./EntityOps.js";
24
+ import { type Expr } from "./Expr.js";
25
+ import { validateAndBuildPutItem } from "./TransactableOps.js";
23
26
  import type { TransactPlan } from "./TransactPlan.js";
24
27
  import { type KeyAttributes, type TransactItemTarget, transactItemTarget } from "./WriteDiagnosis.js";
25
28
  /** @internal */
@@ -196,22 +199,70 @@ export interface BuiltTransactWriteItems {
196
199
  */
197
200
  readonly keys: () => KeyAttributes;
198
201
  }
202
+ /** A put's item, built and validated (`validateAndBuildPutItem`). */
203
+ type BuiltPut = Effect.Success<ReturnType<typeof validateAndBuildPutItem>>;
204
+ /** One caller op, with everything its items need that takes no read. */
205
+ interface PreparedOp {
206
+ readonly type: "put" | "delete" | "conditionCheck" | "planned";
207
+ readonly putKind?: PutKind | undefined;
208
+ readonly entity: Entity;
209
+ /** Index into the caller's `operations` array — preserved for provenance. */
210
+ readonly opIndex: number;
211
+ readonly input?: Record<string, unknown> | undefined;
212
+ readonly condition?: ExpressionResult | undefined;
213
+ /** The caller's own condition — what a `create` over a tombstone keeps. */
214
+ readonly callerCondition?: Expr | ConditionInput | undefined;
215
+ /** A put's item. */
216
+ readonly built?: BuiltPut | undefined;
217
+ /** A delete's or a check's primary key. */
218
+ readonly primaryKey?: Record<string, unknown> | undefined;
219
+ /** A planned op's plan, from its own read: its key is already encoded and composed. */
220
+ readonly plan?: (() => Effect.Effect<TransactPlan, ValidationError | PlanUpdateError | PlanDeleteError, DynamoClient | TableConfig>) | undefined;
221
+ }
222
+ /**
223
+ * A transaction's ops checked and composed with nothing read
224
+ * ({@link prepareTransactWriteOps}): every refusal an op's own values decide,
225
+ * its keys and put items included, comes before the first read of any op.
226
+ */
227
+ export interface PreparedTransactWrite {
228
+ readonly count: number;
229
+ readonly ops: ReadonlyArray<PreparedOp>;
230
+ /** The nested stream appends, built, by caller op index. */
231
+ readonly streamOps: ReadonlyMap<number, BuiltStreamAppend>;
232
+ }
199
233
  /**
200
- * The read pre-pass that lets `Transaction.transactWrite` carry the ops the
201
- * build step below cannot: every `update`, and every `delete` of an entity
202
- * whose delete writes more than its own row (`unique`, `versioned: { retain:
203
- * true }`, `softDelete` — EDD-9048). Each is planned by the entity's own op
204
- * (`Entity._planUpdate` / `_planDelete`): the standalone op itself, run with
205
- * its write recorded instead of sent, so the transaction writes exactly what
206
- * the standalone op would have — every read, item and guard included.
234
+ * Check and compose every op of a transaction without reading: refuse what an
235
+ * op can't carry, compile its condition, build a put's item, compose a
236
+ * delete's or a check's key and build a nested stream append — so a value
237
+ * with no key text, a put or an event its schema refuses, or an append op
238
+ * with no events, fails the transaction before any op reads, whatever its
239
+ * place in it.
207
240
  *
208
- * Ops a planned write cannot carry are refused before anything is read
209
- * (EDD-9059 – EDD-9061, `rejectUnsupportedOp`). Returns the plans keyed by
210
- * index into `operations`; ops that need no plan are absent. Run on every
241
+ * With `plan`, `Transaction.transactWrite` carries the ops the build step
242
+ * cannot: every `update`, and every `delete` of an entity whose delete writes
243
+ * more than its own row (`unique`, `versioned: { retain: true }`,
244
+ * `softDelete` — EDD-9048). Each is planned by the entity's own op
245
+ * (`Entity._planUpdate` / `_planDelete`) in {@link planTransactWriteOps}; here
246
+ * its key is encoded and composed (`Entity._encodeKey`), what it can't carry
247
+ * refused (EDD-9059 – EDD-9061, `rejectUnsupportedOp`), and an update's own
248
+ * operands decided (`Entity._prepareUpdate`: its payload, and the keys the
249
+ * payload composes), which its plan reuses. Without `plan`
250
+ * (`EventStore.append`), such ops are refused.
251
+ */
252
+ export declare const prepareTransactWriteOps: (operations: ReadonlyArray<AppendWriteOp | TransactWriteUpdateOp>, operation: string, options?: {
253
+ readonly streams?: boolean | undefined;
254
+ readonly plan?: boolean | undefined;
255
+ } | undefined) => Effect.Effect<PreparedTransactWrite, ValidationError | DynamoClientError, TableConfig | DynamoClient>;
256
+ /**
257
+ * The read pass that lets `Transaction.transactWrite` carry its planned ops
258
+ * ({@link prepareTransactWriteOps}): each is the standalone op itself, run
259
+ * with its write recorded instead of sent, so the transaction writes exactly
260
+ * what the standalone op would have — every read, item and guard included.
261
+ * Returns the plans keyed by index into the caller's operations. Run on every
211
262
  * attempt, so a transaction cancelled by a lost race is planned again from
212
263
  * fresh reads.
213
264
  */
214
- export declare const planTransactWriteOps: (operations: ReadonlyArray<TransactWriteOp | TransactWriteUpdateOp>) => Effect.Effect<ReadonlyMap<number, TransactPlan>, ValidationError | PlanUpdateError | PlanDeleteError, DynamoClient | TableConfig>;
265
+ export declare const planTransactWriteOps: (prepared: PreparedTransactWrite) => Effect.Effect<ReadonlyMap<number, TransactPlan>, ValidationError | PlanUpdateError | PlanDeleteError, DynamoClient | TableConfig>;
215
266
  /**
216
267
  * Compile a list of Entity write ops into marshalled `TransactWriteItems` entries,
217
268
  * preserving caller order.
@@ -238,14 +289,18 @@ export declare const planTransactWriteOps: (operations: ReadonlyArray<TransactWr
238
289
  * `ValidationError` otherwise. Its items are built by the inner stream
239
290
  * (provenance `kind: "stream"`), recorded in `streams`, and left out of
240
291
  * `conditioned`.
292
+ *
293
+ * The ops are checked and composed first ({@link prepareTransactWriteOps}), or
294
+ * come so (`prepared`, with `plans`, from `transactWrite`), so nothing is read
295
+ * before every op's own refusals.
241
296
  */
242
297
  export declare const buildTransactWriteItems: (operations: ReadonlyArray<AppendWriteOp | TransactWriteUpdateOp>, operation: string, options?: {
243
298
  readonly streams?: boolean | undefined;
244
299
  /**
245
- * Updates and multi-item deletes, planned by {@link planTransactWriteOps}
246
- * and keyed by index into `operations`. A caller that runs no pre-pass
247
- * (`EventStore.append`) passes none, and such ops are refused.
300
+ * `operations` prepared with `plan` ({@link prepareTransactWriteOps}),
301
+ * and its planned ops' plans ({@link planTransactWriteOps}).
248
302
  */
303
+ readonly prepared?: PreparedTransactWrite | undefined;
249
304
  readonly plans?: ReadonlyMap<number, TransactPlan> | undefined;
250
305
  } | undefined) => Effect.Effect<BuiltTransactWriteItems, ValidationError | DynamoClientError, TableConfig | DynamoClient>;
251
306
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"TransactWriteOps.d.ts","sourceRoot":"","sources":["../../src/internal/TransactWriteOps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,KAAK,EACV,sBAAsB,EACtB,mBAAmB,EACnB,YAAY,EACZ,yBAAyB,EACzB,eAAe,EAChB,MAAM,mCAAmC,CAAA;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAA;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACzE,OAAO,KAAK,EACV,MAAM,EACN,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,eAAe,EACf,eAAe,EACf,UAAU,EACV,uBAAuB,EACxB,MAAM,cAAc,CAAA;AAErB,OAAO,KAAK,EAAkB,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAExE,OAAO,EAA2B,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AASjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,EACL,KAAK,aAAa,EAGlB,KAAK,kBAAkB,EACvB,kBAAkB,EACnB,MAAM,qBAAqB,CAAA;AAM5B,gBAAgB;AAChB,eAAO,MA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aAAa,CAAC,MAAM,CAAC,CAAA;CAAE,GAC1E;IACE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;IACtB,QAAQ,CAAC,KAAK,EAAE,mBAAmB,GAAG,sBAAsB,CAAA;IAC5D,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,UAAU,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC,QAAQ,CAAC,CAAA;CAC3E,GACD,SA+BH,CAAA"}
@@ -17,8 +17,8 @@ import { extractTransactable } from "../Entity.js";
17
17
  import { toAttributeMap } from "../Marshaller.js";
18
18
  import { resolveTtlAttributeName } from "../Table.js";
19
19
  import { withGuard } from "./EntityOps.js";
20
- import { compileExpr, emptyPartProblem, isExpr, parseShorthand } from "./Expr.js";
21
- import { composePrimaryKeyOrFail, rejectUnsupportedOp, resolveTableNames, validateAndBuildPutItem, } from "./TransactableOps.js";
20
+ import { compileExpr, emptyPartProblem, isExpr, operandsAsStored, parseShorthand, unsentIn, } from "./Expr.js";
21
+ import { andRaw, composePrimaryKeyOrFail, rejectUnsupportedOp, resolveTableNames, validateAndBuildPutItem, } from "./TransactableOps.js";
22
22
  import { keyAttributesOf, mergeKeyAttributes, transactItemTarget, } from "./WriteDiagnosis.js";
23
23
  // ---------------------------------------------------------------------------
24
24
  // ConditionCheck — composable from EntityGet + condition expression
@@ -42,7 +42,10 @@ const compileOpCondition = (entity, cond) => {
42
42
  if (cond === undefined)
43
43
  return undefined;
44
44
  const expr = isExpr(cond) ? cond : parseShorthand(cond);
45
- return compileExpr(expr, entity._resolveDbName);
45
+ // Its operands in the form the attribute holds, as the entity's own write sends them (#242), and
46
+ // an entry of a sparse map a `field:` rename stores whole asked where the row holds it (#238). A
47
+ // path below its field is named as stored (#238).
48
+ return compileExpr(entity._entryForms(operandsAsStored(expr, entity._storedFormAt)), entity._resolveDbName, entity._storedBelow);
46
49
  };
47
50
  /**
48
51
  * An op's condition with an empty part where none may be (#133) is refused
@@ -76,91 +79,26 @@ const conditionFields = (condition) => condition === undefined
76
79
  : {}),
77
80
  };
78
81
  /**
79
- * The read pre-pass that lets `Transaction.transactWrite` carry the ops the
80
- * build step below cannot: every `update`, and every `delete` of an entity
81
- * whose delete writes more than its own row (`unique`, `versioned: { retain:
82
- * true }`, `softDelete` — EDD-9048). Each is planned by the entity's own op
83
- * (`Entity._planUpdate` / `_planDelete`): the standalone op itself, run with
84
- * its write recorded instead of sent, so the transaction writes exactly what
85
- * the standalone op would have — every read, item and guard included.
82
+ * Check and compose every op of a transaction without reading: refuse what an
83
+ * op can't carry, compile its condition, build a put's item, compose a
84
+ * delete's or a check's key and build a nested stream append — so a value
85
+ * with no key text, a put or an event its schema refuses, or an append op
86
+ * with no events, fails the transaction before any op reads, whatever its
87
+ * place in it.
86
88
  *
87
- * Ops a planned write cannot carry are refused before anything is read
88
- * (EDD-9059 – EDD-9061, `rejectUnsupportedOp`). Returns the plans keyed by
89
- * index into `operations`; ops that need no plan are absent. Run on every
90
- * attempt, so a transaction cancelled by a lost race is planned again from
91
- * fresh reads.
89
+ * With `plan`, `Transaction.transactWrite` carries the ops the build step
90
+ * cannot: every `update`, and every `delete` of an entity whose delete writes
91
+ * more than its own row (`unique`, `versioned: { retain: true }`,
92
+ * `softDelete` — EDD-9048). Each is planned by the entity's own op
93
+ * (`Entity._planUpdate` / `_planDelete`) in {@link planTransactWriteOps}; here
94
+ * its key is encoded and composed (`Entity._encodeKey`), what it can't carry
95
+ * refused (EDD-9059 – EDD-9061, `rejectUnsupportedOp`), and an update's own
96
+ * operands decided (`Entity._prepareUpdate`: its payload, and the keys the
97
+ * payload composes), which its plan reuses. Without `plan`
98
+ * (`EventStore.append`), such ops are refused.
92
99
  */
93
- export const planTransactWriteOps = (operations) => Effect.gen(function* () {
94
- const plans = new Map();
95
- for (let opIndex = 0; opIndex < operations.length; opIndex++) {
96
- const op = operations[opIndex];
97
- if (op != null && typeof op === "object" && ConditionCheckTypeId in op)
98
- continue;
99
- const info = extractTransactable(op);
100
- if (info === undefined)
101
- continue;
102
- if (info.opType === "update" && info.updateState !== undefined) {
103
- yield* rejectUnsupportedOp(info.entity, "transactWrite", "update", undefined, undefined, {
104
- updateState: info.updateState,
105
- });
106
- plans.set(opIndex, yield* info.entity._planUpdate(info.key, info.updateState));
107
- }
108
- else if (info.opType === "delete" &&
109
- info.deleteRequest !== undefined &&
110
- info.entity._multiItemWriteFeatures.length > 0) {
111
- yield* rejectUnsupportedOp(info.entity, "transactWrite", "delete", undefined, undefined, {
112
- returnValues: info.deleteRequest.returnValues,
113
- readsStoredRow: true,
114
- });
115
- plans.set(opIndex, yield* info.entity._planDelete(info.key, {
116
- condition: info.deleteRequest.condition,
117
- mustExist: info.deleteRequest.mustExist,
118
- }));
119
- }
120
- }
121
- return plans;
122
- });
123
- /**
124
- * Compile a list of Entity write ops into marshalled `TransactWriteItems` entries,
125
- * preserving caller order.
126
- *
127
- * **One caller op may emit several items.** A put of a versioned or
128
- * unique-constrained entity is a guarded put (#133): it reads the item, and
129
- * emits the item guarded on what was read, plus its sentinel reservations and
130
- * releases and its retain snapshot (see {@link GuardedWrite}). `provenance`
131
- * records which caller op each emitted item belongs to; consumers that map
132
- * cancellation reasons positionally MUST use it instead of assuming 1:1, and
133
- * read a guarded put's reasons through {@link judgeCancellation}.
134
- *
135
- * DynamoDB's rules (one operation per item, 100 items, 4 MB, 400 KB per
136
- * item, 2048-byte partition and 1024-byte sort keys, the limits on one expression) are not
137
- * pre-checked: the caller sends the transaction and diagnoses DynamoDB's
138
- * rejection through `internal/WriteDiagnosis.ts`, which counts the EXPANDED
139
- * items and names the culprit through `targets` (and `keys`) — two ops
140
- * touching one item included, among them two puts that swap unique values
141
- * and so release and claim the same sentinels. A caller adding items of its
142
- * own appends their targets to these.
143
- *
144
- * A {@link StreamAppendOp} is accepted only with `{ streams: true }` — an
145
- * `EventStore` append's `additionalItems` — and is refused with
146
- * `ValidationError` otherwise. Its items are built by the inner stream
147
- * (provenance `kind: "stream"`), recorded in `streams`, and left out of
148
- * `conditioned`.
149
- */
150
- export const buildTransactWriteItems = (operations, operation, options) => Effect.gen(function* () {
151
- if (operations.length === 0) {
152
- return {
153
- items: [],
154
- provenance: [],
155
- targets: () => [],
156
- guarded: [],
157
- streams: [],
158
- conditioned: new Set(),
159
- keys: () => mergeKeyAttributes(),
160
- };
161
- }
162
- const opInfos = [];
163
- /** The nested stream appends, by caller op index. */
100
+ export const prepareTransactWriteOps = (operations, operation, options) => Effect.gen(function* () {
101
+ const ops = [];
164
102
  const streamOps = new Map();
165
103
  for (let opIndex = 0; opIndex < operations.length; opIndex++) {
166
104
  const op = operations[opIndex];
@@ -175,7 +113,9 @@ export const buildTransactWriteItems = (operations, operation, options) => Effec
175
113
  "additionalItems. Nothing was sent.",
176
114
  });
177
115
  }
178
- streamOps.set(opIndex, op);
116
+ // Built by its own stream, reading nothing: its refusals (no events, an
117
+ // event its schema refuses) come before any op reads.
118
+ streamOps.set(opIndex, yield* op._build(`operation ${opIndex}`));
179
119
  continue;
180
120
  }
181
121
  // Check for ConditionCheckOp first (has its own TypeId)
@@ -190,12 +130,23 @@ export const buildTransactWriteItems = (operations, operation, options) => Effec
190
130
  cause: `${operation}: Transaction.check() was given an empty condition. Nothing was sent.`,
191
131
  });
192
132
  }
193
- opInfos.push({
133
+ // `Expression.condition` compiled an operand without its map entry keyed `__proto__`
134
+ // (`EDD-9165`), as 1.40.0 did, and DynamoDB refused what that left on every path.
135
+ const unsent = unsentIn(checkOp._condition);
136
+ if (unsent !== undefined) {
137
+ return yield* new ValidationError({
138
+ entityType: checkOp._entity.entityType,
139
+ operation: `${operation}.check`,
140
+ cause: `${operation}: Transaction.check()'s condition compares with a value DynamoDB ` +
141
+ `can't store: ${unsent.describe()} Nothing was sent.`,
142
+ });
143
+ }
144
+ ops.push({
194
145
  type: "conditionCheck",
195
146
  entity: checkOp._entity,
196
147
  opIndex,
197
- key: checkOp._key,
198
148
  condition: checkOp._condition,
149
+ primaryKey: yield* composePrimaryKeyOrFail(checkOp._entity, checkOp._key, `${operation}.check`),
199
150
  });
200
151
  continue;
201
152
  }
@@ -207,19 +158,52 @@ export const buildTransactWriteItems = (operations, operation, options) => Effec
207
158
  cause: `${operation}: unrecognized operation type. Use EntityPut, EntityDelete, or Transaction.check().`,
208
159
  });
209
160
  }
210
- const plan = options?.plans?.get(opIndex);
211
- if (plan !== undefined) {
161
+ if (options?.plan === true && info.opType === "update" && info.updateState !== undefined) {
162
+ const { entity, key, updateState } = info;
163
+ yield* rejectUnsupportedOp(entity, operation, "update", undefined, undefined, {
164
+ updateState,
165
+ });
166
+ // Its condition, refused here as every op's is, before any op of the transaction reads:
167
+ // planning compiles it only after the reads (#236).
168
+ yield* refuseEmptyParts(entity, operation, "update", updateState.condition);
169
+ const encoded = yield* entity._encodeKey(key, `${operation}.update.decodeKey`);
170
+ // What the update decides from its own operands: refused here, and planned from.
171
+ const prepared = yield* entity._prepareUpdate(key, updateState, encoded);
212
172
  // No `condition` here, so a planned op is never in `conditioned`, even
213
173
  // with a `.condition()` of its own: its verdict reports that as
214
174
  // `"Condition"`. Only `EventStore.append` reads `conditioned`, and it
215
175
  // plans nothing — if it ever does, add planned ops to it.
216
- opInfos.push({ type: "planned", entity: info.entity, opIndex, plan });
176
+ ops.push({
177
+ type: "planned",
178
+ entity,
179
+ opIndex,
180
+ plan: () => entity._planUpdate(key, updateState, prepared),
181
+ });
182
+ continue;
183
+ }
184
+ if (options?.plan === true &&
185
+ info.opType === "delete" &&
186
+ info.deleteRequest !== undefined &&
187
+ info.entity._multiItemWriteFeatures.length > 0) {
188
+ const { entity, key, deleteRequest } = info;
189
+ yield* rejectUnsupportedOp(entity, operation, "delete", undefined, undefined, {
190
+ returnValues: deleteRequest.returnValues,
191
+ readsStoredRow: true,
192
+ });
193
+ yield* refuseEmptyParts(entity, operation, "delete", deleteRequest.condition);
194
+ const encoded = yield* entity._encodeKey(key, `${operation}.delete.decodeKey`);
195
+ ops.push({
196
+ type: "planned",
197
+ entity,
198
+ opIndex,
199
+ plan: () => entity._planDelete(key, { condition: deleteRequest.condition, mustExist: deleteRequest.mustExist }, encoded),
200
+ });
217
201
  continue;
218
202
  }
219
203
  if (info.opType === "put") {
220
204
  yield* rejectUnsupportedOp(info.entity, operation, "put", info.putKind, info.input);
221
205
  yield* refuseEmptyParts(info.entity, operation, "put", info.condition);
222
- opInfos.push({
206
+ ops.push({
223
207
  type: "put",
224
208
  putKind: info.putKind,
225
209
  entity: info.entity,
@@ -227,6 +211,7 @@ export const buildTransactWriteItems = (operations, operation, options) => Effec
227
211
  input: info.input,
228
212
  condition: compileOpCondition(info.entity, info.condition),
229
213
  callerCondition: info.callerCondition,
214
+ built: yield* validateAndBuildPutItem(info.entity, info.input, `${operation}.put`),
230
215
  });
231
216
  }
232
217
  else if (info.opType === "delete") {
@@ -234,12 +219,12 @@ export const buildTransactWriteItems = (operations, operation, options) => Effec
234
219
  returnValues: info.deleteRequest?.returnValues,
235
220
  });
236
221
  yield* refuseEmptyParts(info.entity, operation, "delete", info.condition);
237
- opInfos.push({
222
+ ops.push({
238
223
  type: "delete",
239
224
  entity: info.entity,
240
225
  opIndex,
241
- key: info.key,
242
226
  condition: compileOpCondition(info.entity, info.condition),
227
+ primaryKey: yield* composePrimaryKeyOrFail(info.entity, info.key, `${operation}.delete`),
243
228
  });
244
229
  }
245
230
  else {
@@ -254,6 +239,72 @@ export const buildTransactWriteItems = (operations, operation, options) => Effec
254
239
  });
255
240
  }
256
241
  }
242
+ return { count: operations.length, ops, streamOps };
243
+ });
244
+ /**
245
+ * The read pass that lets `Transaction.transactWrite` carry its planned ops
246
+ * ({@link prepareTransactWriteOps}): each is the standalone op itself, run
247
+ * with its write recorded instead of sent, so the transaction writes exactly
248
+ * what the standalone op would have — every read, item and guard included.
249
+ * Returns the plans keyed by index into the caller's operations. Run on every
250
+ * attempt, so a transaction cancelled by a lost race is planned again from
251
+ * fresh reads.
252
+ */
253
+ export const planTransactWriteOps = (prepared) => Effect.gen(function* () {
254
+ const plans = new Map();
255
+ for (const op of prepared.ops) {
256
+ if (op.plan !== undefined)
257
+ plans.set(op.opIndex, yield* op.plan());
258
+ }
259
+ return plans;
260
+ });
261
+ /**
262
+ * Compile a list of Entity write ops into marshalled `TransactWriteItems` entries,
263
+ * preserving caller order.
264
+ *
265
+ * **One caller op may emit several items.** A put of a versioned or
266
+ * unique-constrained entity is a guarded put (#133): it reads the item, and
267
+ * emits the item guarded on what was read, plus its sentinel reservations and
268
+ * releases and its retain snapshot (see {@link GuardedWrite}). `provenance`
269
+ * records which caller op each emitted item belongs to; consumers that map
270
+ * cancellation reasons positionally MUST use it instead of assuming 1:1, and
271
+ * read a guarded put's reasons through {@link judgeCancellation}.
272
+ *
273
+ * DynamoDB's rules (one operation per item, 100 items, 4 MB, 400 KB per
274
+ * item, 2048-byte partition and 1024-byte sort keys, the limits on one expression) are not
275
+ * pre-checked: the caller sends the transaction and diagnoses DynamoDB's
276
+ * rejection through `internal/WriteDiagnosis.ts`, which counts the EXPANDED
277
+ * items and names the culprit through `targets` (and `keys`) — two ops
278
+ * touching one item included, among them two puts that swap unique values
279
+ * and so release and claim the same sentinels. A caller adding items of its
280
+ * own appends their targets to these.
281
+ *
282
+ * A {@link StreamAppendOp} is accepted only with `{ streams: true }` — an
283
+ * `EventStore` append's `additionalItems` — and is refused with
284
+ * `ValidationError` otherwise. Its items are built by the inner stream
285
+ * (provenance `kind: "stream"`), recorded in `streams`, and left out of
286
+ * `conditioned`.
287
+ *
288
+ * The ops are checked and composed first ({@link prepareTransactWriteOps}), or
289
+ * come so (`prepared`, with `plans`, from `transactWrite`), so nothing is read
290
+ * before every op's own refusals.
291
+ */
292
+ export const buildTransactWriteItems = (operations, operation, options) => Effect.gen(function* () {
293
+ if (operations.length === 0) {
294
+ return {
295
+ items: [],
296
+ provenance: [],
297
+ targets: () => [],
298
+ guarded: [],
299
+ streams: [],
300
+ conditioned: new Set(),
301
+ keys: () => mergeKeyAttributes(),
302
+ };
303
+ }
304
+ const prepared = options?.prepared ??
305
+ (yield* prepareTransactWriteOps(operations, operation, { streams: options?.streams }));
306
+ const opInfos = prepared.ops;
307
+ const streamOps = prepared.streamOps;
257
308
  const tableNames = yield* resolveTableNames(opInfos);
258
309
  const items = [];
259
310
  const provenance = [];
@@ -277,9 +328,8 @@ export const buildTransactWriteItems = (operations, operation, options) => Effec
277
328
  };
278
329
  // The nested stream appends, built by their own streams, are pushed in
279
330
  // caller op order between the entity ops' items.
280
- const pushStreamOp = (opIndex) => Effect.gen(function* () {
281
- const op = streamOps.get(opIndex);
282
- const nested = yield* op._build(`operation ${opIndex}`);
331
+ const pushStreamOp = (opIndex) => {
332
+ const nested = streamOps.get(opIndex);
283
333
  streams.push({
284
334
  opIndex,
285
335
  start: items.length,
@@ -299,30 +349,34 @@ export const buildTransactWriteItems = (operations, operation, options) => Effec
299
349
  provenance.push({ opIndex, kind: "stream", entityType: nested.entityType });
300
350
  naming.push(() => nestedTarget(i));
301
351
  }
302
- });
352
+ };
303
353
  let nextOpIndex = 0;
304
- const flushStreamOpsBefore = (opIndex) => Effect.gen(function* () {
354
+ const flushStreamOpsBefore = (opIndex) => {
305
355
  for (; nextOpIndex < opIndex; nextOpIndex++) {
306
356
  if (streamOps.has(nextOpIndex))
307
- yield* pushStreamOp(nextOpIndex);
357
+ pushStreamOp(nextOpIndex);
308
358
  }
309
359
  nextOpIndex = opIndex + 1;
310
- });
360
+ };
311
361
  for (const op of opInfos) {
312
- yield* flushStreamOpsBefore(op.opIndex);
362
+ flushStreamOpsBefore(op.opIndex);
313
363
  tableName = tableNames.get(op.entity);
314
364
  const primary = op.entity.indexes.primary;
315
365
  keyFields = [primary.pk.field, primary.sk.field];
316
366
  if (op.type === "planned") {
317
367
  // Already marshalled and table-resolved; read like a guarded put's.
318
- guarded.push({ opIndex: op.opIndex, start: items.length, plan: op.plan });
319
- for (const [i, item] of op.plan.items.entries()) {
368
+ const plan = options?.plans?.get(op.opIndex);
369
+ if (plan === undefined) {
370
+ return yield* Effect.die(new Error(`${operation}: operation ${op.opIndex} was not planned`));
371
+ }
372
+ guarded.push({ opIndex: op.opIndex, start: items.length, plan });
373
+ for (const [i, item] of plan.items.entries()) {
320
374
  push(item, { opIndex: op.opIndex, kind: "guarded", entityType: op.entity.entityType }, i > 0);
321
375
  }
322
376
  continue;
323
377
  }
324
378
  if (op.type === "put") {
325
- const built = yield* validateAndBuildPutItem(op.entity, op.input, `${operation}.put`);
379
+ const built = op.built;
326
380
  if (op.entity._incarnationToken || op.entity._multiItemWriteFeatures.includes("unique")) {
327
381
  const plan = yield* op.entity._planPut({
328
382
  tableName,
@@ -333,7 +387,7 @@ export const buildTransactWriteItems = (operations, operation, options) => Effec
333
387
  userCondition: op.condition,
334
388
  create: op.putKind === "create",
335
389
  operation,
336
- key: op.input,
390
+ composeKeys: built.composeKeys,
337
391
  });
338
392
  guarded.push({ opIndex: op.opIndex, start: items.length, plan });
339
393
  for (const [i, item] of plan.items.entries()) {
@@ -344,14 +398,14 @@ export const buildTransactWriteItems = (operations, operation, options) => Effec
344
398
  // `create` over a projection tombstone (#154): take its place,
345
399
  // carrying its checkpoints over, guarded on that tombstone.
346
400
  const over = op.putKind === "create"
347
- ? yield* op.entity._overTombstone(tableName, built.item)
401
+ ? yield* op.entity._overTombstone(built.item)
348
402
  : Option.none();
349
403
  push({
350
404
  Put: {
351
405
  TableName: tableName,
352
406
  Item: Option.isSome(over) ? toAttributeMap(built.item) : built.marshalled,
353
407
  ...conditionFields(Option.isSome(over)
354
- ? compileOpCondition(op.entity, withGuard(over.value, op.callerCondition))
408
+ ? andRaw(compileOpCondition(op.entity, withGuard(over.value.guard, op.callerCondition)), over.value.term)
355
409
  : op.condition),
356
410
  },
357
411
  }, { opIndex: op.opIndex, kind: "main", entityType: op.entity.entityType });
@@ -360,7 +414,7 @@ export const buildTransactWriteItems = (operations, operation, options) => Effec
360
414
  push({
361
415
  Delete: {
362
416
  TableName: tableName,
363
- Key: toAttributeMap(yield* composePrimaryKeyOrFail(op.entity, op.key, `${operation}.delete`)),
417
+ Key: toAttributeMap(op.primaryKey),
364
418
  ...conditionFields(op.condition),
365
419
  },
366
420
  }, { opIndex: op.opIndex, kind: "main", entityType: op.entity.entityType });
@@ -369,14 +423,14 @@ export const buildTransactWriteItems = (operations, operation, options) => Effec
369
423
  push({
370
424
  ConditionCheck: {
371
425
  TableName: tableName,
372
- Key: toAttributeMap(yield* composePrimaryKeyOrFail(op.entity, op.key, `${operation}.check`)),
426
+ Key: toAttributeMap(op.primaryKey),
373
427
  ConditionExpression: op.condition.expression,
374
428
  ...conditionFields(op.condition),
375
429
  },
376
430
  }, { opIndex: op.opIndex, kind: "main", entityType: op.entity.entityType });
377
431
  }
378
432
  }
379
- yield* flushStreamOpsBefore(operations.length);
433
+ flushStreamOpsBefore(operations.length);
380
434
  const keys = () => mergeKeyAttributes(...opInfos.map((op) => keyAttributesOf(op.entity.indexes)), ...streamKeys.map((nested) => nested()));
381
435
  const targets = () => naming.map((name) => name());
382
436
  return { items, provenance, targets, guarded, streams, conditioned, keys };