effect-dynamodb 1.27.0 → 1.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Batch.d.ts.map +1 -1
- package/dist/Batch.js +3 -2
- package/dist/Batch.js.map +1 -1
- package/dist/Entity.d.ts +24 -1
- package/dist/Entity.d.ts.map +1 -1
- package/dist/Entity.js +33 -17
- package/dist/Entity.js.map +1 -1
- package/dist/EventStore.d.ts +66 -5
- package/dist/EventStore.d.ts.map +1 -1
- package/dist/EventStore.js +100 -2
- package/dist/EventStore.js.map +1 -1
- package/dist/Transaction.d.ts.map +1 -1
- package/dist/Transaction.js +5 -2
- package/dist/Transaction.js.map +1 -1
- package/dist/change-feed/ChangeFeed.d.ts +203 -0
- package/dist/change-feed/ChangeFeed.d.ts.map +1 -0
- package/dist/change-feed/ChangeFeed.js +498 -0
- package/dist/change-feed/ChangeFeed.js.map +1 -0
- package/dist/change-feed/CheckpointStore.d.ts +113 -0
- package/dist/change-feed/CheckpointStore.d.ts.map +1 -0
- package/dist/change-feed/CheckpointStore.js +247 -0
- package/dist/change-feed/CheckpointStore.js.map +1 -0
- package/dist/change-feed/DynamoStreamsClient.d.ts +71 -0
- package/dist/change-feed/DynamoStreamsClient.d.ts.map +1 -0
- package/dist/change-feed/DynamoStreamsClient.js +92 -0
- package/dist/change-feed/DynamoStreamsClient.js.map +1 -0
- package/dist/change-feed/Errors.d.ts +84 -0
- package/dist/change-feed/Errors.d.ts.map +1 -0
- package/dist/change-feed/Errors.js +40 -0
- package/dist/change-feed/Errors.js.map +1 -0
- package/dist/change-feed/index.d.ts +36 -0
- package/dist/change-feed/index.d.ts.map +1 -0
- package/dist/change-feed/index.js +36 -0
- package/dist/change-feed/index.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/EntityOps.d.ts +7 -2
- package/dist/internal/EntityOps.d.ts.map +1 -1
- package/dist/internal/EntityOps.js.map +1 -1
- package/dist/internal/EventProjection.d.ts +782 -0
- package/dist/internal/EventProjection.d.ts.map +1 -0
- package/dist/internal/EventProjection.js +608 -0
- package/dist/internal/EventProjection.js.map +1 -0
- package/dist/internal/MultiProjection.d.ts +255 -0
- package/dist/internal/MultiProjection.d.ts.map +1 -0
- package/dist/internal/MultiProjection.js +377 -0
- package/dist/internal/MultiProjection.js.map +1 -0
- package/dist/internal/ProjectionEngine.d.ts +253 -0
- package/dist/internal/ProjectionEngine.d.ts.map +1 -0
- package/dist/internal/ProjectionEngine.js +837 -0
- package/dist/internal/ProjectionEngine.js.map +1 -0
- package/dist/internal/TransactWriteOps.d.ts.map +1 -1
- package/dist/internal/TransactWriteOps.js +12 -3
- package/dist/internal/TransactWriteOps.js.map +1 -1
- package/dist/internal/TransactableOps.d.ts +44 -1
- package/dist/internal/TransactableOps.d.ts.map +1 -1
- package/dist/internal/TransactableOps.js +52 -2
- package/dist/internal/TransactableOps.js.map +1 -1
- package/package.json +14 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventProjection.d.ts","sourceRoot":"","sources":["../../src/internal/EventProjection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,YAAY,EACjB,6BAA6B,EAC7B,KAAK,eAAe,EACrB,MAAM,mCAAmC,CAAA;AAC1C,OAAO,EACL,QAAQ,EACR,MAAM,EACN,MAAM,EACN,QAAQ,EAER,KAAK,QAAQ,EACb,KAAK,MAAM,EAEZ,MAAM,QAAQ,CAAA;AACf,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACzE,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAE/F,OAAO,KAAK,EAAE,KAA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CACzD,CAAA;CAaA,CAAA"}
|
|
@@ -0,0 +1,608 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EventStore projections (#151) — read models folded from a change feed that
|
|
3
|
+
* take their order from the event store, not from delivery.
|
|
4
|
+
*
|
|
5
|
+
* DynamoDB Streams orders records per item only, and a transaction's records
|
|
6
|
+
* carry no grouping or order, so a stream's events reach a consumer in any
|
|
7
|
+
* order. A projection groups a batch's events by row, sorts and
|
|
8
|
+
* deduplicates them, reads from the store only the versions the batch lacks
|
|
9
|
+
* (one strongly consistent `readFrom`), folds, and writes the read-model row
|
|
10
|
+
* once, conditioned on the checkpoint it read. See
|
|
11
|
+
* `docs/designs/eventstore-projections.md`.
|
|
12
|
+
*
|
|
13
|
+
* Re-exported from `EventStore`; this module only type-imports it.
|
|
14
|
+
*
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
import { StreamRecordIdentifierMissing, } from "@effect-dynamodb/schema/Errors.js";
|
|
18
|
+
import { Duration, Effect, Option, Pipeable, Result, Stream, } from "effect";
|
|
19
|
+
import * as Query from "../Query.js";
|
|
20
|
+
import { imageEntityType } from "./Packed.js";
|
|
21
|
+
import { addressed, keyId, makeEngine, modelFields, retrySchedule, } from "./ProjectionEngine.js";
|
|
22
|
+
/** @internal `revision`, resolved. */
|
|
23
|
+
export const resolveRevision = (revision) => revision === undefined
|
|
24
|
+
? undefined
|
|
25
|
+
: typeof revision === "string"
|
|
26
|
+
? { field: revision, initial: 1 }
|
|
27
|
+
: { field: revision.field, initial: revision.initial ?? 1 };
|
|
28
|
+
const identify = (record, index, options) => {
|
|
29
|
+
const [itemIdentifier, member] = "identifier" in options
|
|
30
|
+
? [options.identifier(record), "identifier"]
|
|
31
|
+
: options.source === "lambda"
|
|
32
|
+
? [record.dynamodb?.SequenceNumber, "dynamodb.SequenceNumber"]
|
|
33
|
+
: [record.eventID, "eventID"];
|
|
34
|
+
return typeof itemIdentifier === "string" && itemIdentifier.length > 0
|
|
35
|
+
? Effect.succeed(itemIdentifier)
|
|
36
|
+
: Effect.fail(new StreamRecordIdentifierMissing({ index, member }));
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* The partial batch response (`ReportBatchItemFailures`) for `failedRecords`:
|
|
40
|
+
* each identified by `dynamodb.SequenceNumber` for a Lambda event source
|
|
41
|
+
* mapping, by `eventID` for an EventBridge Pipe, or by your own `identifier`
|
|
42
|
+
* accessor.
|
|
43
|
+
*
|
|
44
|
+
* Lambda checkpoints at the lowest reported sequence number and redelivers
|
|
45
|
+
* every record from there, so reporting the earliest failed record of each
|
|
46
|
+
* row is enough. A record without an identifier fails with
|
|
47
|
+
* `StreamRecordIdentifierMissing` — an empty one would fail the whole batch
|
|
48
|
+
* silently — so fail the invocation, and the source redelivers the batch.
|
|
49
|
+
*/
|
|
50
|
+
export const batchResponse = (failedRecords, options) => Effect.forEach(failedRecords, (record, i) => identify(record, i, options)).pipe(Effect.map((ids) => ({ batchItemFailures: ids.map((itemIdentifier) => ({ itemIdentifier })) })));
|
|
51
|
+
const markerIndex = (operation, streams) => {
|
|
52
|
+
const index = new Map();
|
|
53
|
+
for (const entry of streams) {
|
|
54
|
+
const existing = index.get(entry[1].eventMarker);
|
|
55
|
+
if (existing !== undefined) {
|
|
56
|
+
throw new Error(`[EDD-9082] ${operation}: "${existing[0]}" and "${entry[0]}" both store events as ` +
|
|
57
|
+
`"${entry[1].eventMarker}", so their images can't be told apart. Give the streams ` +
|
|
58
|
+
"distinct names.");
|
|
59
|
+
}
|
|
60
|
+
index.set(entry[1].eventMarker, entry);
|
|
61
|
+
}
|
|
62
|
+
return index;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* One decoder for several streams' change-feed images. Name the streams in a
|
|
66
|
+
* record; `decode(image)` dispatches on the image's `__edd_e__` and returns
|
|
67
|
+
* `{ stream: <name>, event }`, or `Option.none()` for anything that is not one
|
|
68
|
+
* of their events (snapshots, idempotency sentinels, entities, other streams).
|
|
69
|
+
* The image is decoded by that stream's `decodeStreamImage`, so it accepts the
|
|
70
|
+
* same shapes (DynamoDB JSON with `B` as base64 or bytes, or unmarshalled).
|
|
71
|
+
*
|
|
72
|
+
* Two streams storing events under the same marker throw `[EDD-9082]`.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* const decode = EventStore.decoder({ Order: OrderEvents, Payment: PaymentEvents })
|
|
77
|
+
* const decoded = yield* decode(record.dynamodb.NewImage)
|
|
78
|
+
* if (Option.isSome(decoded) && decoded.value.stream === "Order") { ... }
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export const decoder = (streams) => {
|
|
82
|
+
const index = markerIndex("EventStore.decoder", Object.entries(streams));
|
|
83
|
+
return (image) => {
|
|
84
|
+
const entry = typeof image === "object" && image !== null && !Array.isArray(image)
|
|
85
|
+
? index.get(imageEntityType(image) ?? "")
|
|
86
|
+
: undefined;
|
|
87
|
+
if (entry === undefined)
|
|
88
|
+
return Effect.succeed(Option.none());
|
|
89
|
+
const [name, stream] = entry;
|
|
90
|
+
return stream
|
|
91
|
+
.decodeStreamImage(image)
|
|
92
|
+
.pipe(Effect.map((event) => Option.map(event, (e) => ({ stream: name, event: e }))));
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* The filter pattern that selects the `INSERT`s of these streams' event items
|
|
97
|
+
* — `JSON.stringify` it into `FilterCriteria.Filters[].Pattern` of a Lambda
|
|
98
|
+
* event source mapping or an EventBridge Pipe. Snapshots, idempotency
|
|
99
|
+
* sentinels and other items are filtered out before the function runs.
|
|
100
|
+
*/
|
|
101
|
+
export const eventFilterPattern = (streams) => {
|
|
102
|
+
const list = Array.isArray(streams)
|
|
103
|
+
? streams
|
|
104
|
+
: Object.values(streams);
|
|
105
|
+
const markers = [...new Set(list.map((s) => s.eventMarker))];
|
|
106
|
+
return { eventName: ["INSERT"], dynamodb: { NewImage: { __edd_e__: { S: markers } } } };
|
|
107
|
+
};
|
|
108
|
+
// ---------------------------------------------------------------------------
|
|
109
|
+
// EventProjection
|
|
110
|
+
// ---------------------------------------------------------------------------
|
|
111
|
+
const EventProjectionTypeId = Symbol.for("effect-dynamodb/EventProjection");
|
|
112
|
+
/**
|
|
113
|
+
* @internal How a projection takes part in a multi-projection batch: one
|
|
114
|
+
* route per source stream — its decode (under the bound context for a bound
|
|
115
|
+
* projection) and its `applyBatch`.
|
|
116
|
+
*/
|
|
117
|
+
export const ProjectionRoutes = Symbol.for("effect-dynamodb/EventProjection/Routes");
|
|
118
|
+
/** @internal Refusals shared by `projection` and `multiProjection` (`[EDD-9081]`). */
|
|
119
|
+
export const refuseReadModel = (label, readModel, options) => {
|
|
120
|
+
const refuse = (problem) => {
|
|
121
|
+
throw new Error(`[EDD-9081] ${label}: ${problem}`);
|
|
122
|
+
};
|
|
123
|
+
if (readModel.versioned) {
|
|
124
|
+
refuse("the read model is `versioned`. The projection's checkpoint is the row's version, and a " +
|
|
125
|
+
"versioned put adds its own lock — use a plain entity with a numeric checkpoint field " +
|
|
126
|
+
"(and `revision` for a write counter).");
|
|
127
|
+
}
|
|
128
|
+
if (readModel.softDelete) {
|
|
129
|
+
refuse("the read model has `softDelete`; projections remove rows with `removal` tombstones.");
|
|
130
|
+
}
|
|
131
|
+
if (readModel.timeSeries) {
|
|
132
|
+
refuse("the read model is a `timeSeries` entity, written by `append`, not `put`.");
|
|
133
|
+
}
|
|
134
|
+
const declared = modelFields(readModel.model);
|
|
135
|
+
for (const f of options.fields) {
|
|
136
|
+
if (declared !== undefined && !declared.includes(f)) {
|
|
137
|
+
refuse(`"${f}" is not a field of the read model.`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
const multiItem = readModel
|
|
141
|
+
._multiItemWriteFeatures;
|
|
142
|
+
if ((options.removal || options.outbox) && multiItem !== undefined && multiItem.length > 0) {
|
|
143
|
+
refuse(`\`${options.removal ? "removal" : "outbox"}\` writes the row's item itself, which a read ` +
|
|
144
|
+
`model with ${multiItem.join(", ")} can't take (its extra items would not be maintained).`);
|
|
145
|
+
}
|
|
146
|
+
if (options.outbox && options.revision === undefined) {
|
|
147
|
+
refuse("`outbox` orders a row's effects by its `revision`: declare one.");
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
/** @internal An outbox config, resolved. */
|
|
151
|
+
export const resolveOutbox = (outbox) => outbox === undefined
|
|
152
|
+
? undefined
|
|
153
|
+
: {
|
|
154
|
+
schema: outbox.schema,
|
|
155
|
+
effects: outbox.effects,
|
|
156
|
+
table: outbox.table,
|
|
157
|
+
pk: outbox.keys?.pk ?? "pk",
|
|
158
|
+
sk: outbox.keys?.sk ?? "sk",
|
|
159
|
+
index: outbox.index,
|
|
160
|
+
claimFor: Duration.fromInputUnsafe(outbox.claimFor ?? "30 seconds"),
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* Define a change-feed projection of `stream` into `readModel` — rows keyed by
|
|
164
|
+
* `key(streamId, event)` (one per stream instance when the key ignores the
|
|
165
|
+
* event), each folded from `initial(streamId, event)` through `evolve`, its
|
|
166
|
+
* checkpoint kept in `checkpoint`. See {@link EventProjection} for the
|
|
167
|
+
* operations.
|
|
168
|
+
*
|
|
169
|
+
* The read model must be a plain entity: `versioned` (the checkpoint is the
|
|
170
|
+
* version), `softDelete` (removal is `removal` tombstones) and `timeSeries`
|
|
171
|
+
* read models throw `[EDD-9081]`, as do a field the model lacks, a
|
|
172
|
+
* non-integer offset, `removal` / `outbox` on a read model with `unique`
|
|
173
|
+
* constraints, and `outbox` without `revision`.
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* ```ts
|
|
177
|
+
* const OrderSummaryProjection = EventStore.projection({
|
|
178
|
+
* stream: OrderEvents,
|
|
179
|
+
* readModel: OrderSummaries,
|
|
180
|
+
* key: (id) => ({ orderId: id.orderId }),
|
|
181
|
+
* initial: (id) => ({ orderId: id.orderId, status: "open", total: 0, version: 0 }),
|
|
182
|
+
* evolve: (state, event) => Effect.succeed(next(state, event.data)),
|
|
183
|
+
* checkpoint: "version",
|
|
184
|
+
* })
|
|
185
|
+
* ```
|
|
186
|
+
*/
|
|
187
|
+
export const projection = (config) => {
|
|
188
|
+
const { stream, readModel } = config;
|
|
189
|
+
const label = `EventStore.projection("${stream.streamName}" → "${readModel.entityType}")`;
|
|
190
|
+
const field = (typeof config.checkpoint === "string" ? config.checkpoint : config.checkpoint.field);
|
|
191
|
+
const offset = typeof config.checkpoint === "string" ? 0 : (config.checkpoint.offset ?? 0);
|
|
192
|
+
const revision = resolveRevision(config.revision);
|
|
193
|
+
refuseReadModel(label, readModel, {
|
|
194
|
+
fields: [field, ...(revision === undefined ? [] : [revision.field])],
|
|
195
|
+
removal: config.removal !== undefined,
|
|
196
|
+
outbox: config.outbox !== undefined,
|
|
197
|
+
revision: revision?.field,
|
|
198
|
+
});
|
|
199
|
+
if (!Number.isInteger(offset)) {
|
|
200
|
+
throw new Error(`[EDD-9081] ${label}: the checkpoint offset ${offset} is not an integer.`);
|
|
201
|
+
}
|
|
202
|
+
const source = {
|
|
203
|
+
name: "projection",
|
|
204
|
+
stream: stream,
|
|
205
|
+
key: config.key,
|
|
206
|
+
evolve: (state, event) => config.evolve(state, event),
|
|
207
|
+
mode: "fold",
|
|
208
|
+
terminal: config.terminal,
|
|
209
|
+
};
|
|
210
|
+
const engine = makeEngine({
|
|
211
|
+
label,
|
|
212
|
+
readModel: readModel,
|
|
213
|
+
sources: [source],
|
|
214
|
+
initial: (_key, context) => config.initial(context.streamId, context.event),
|
|
215
|
+
checkpoints: { kind: "scalar", field, offset },
|
|
216
|
+
revision,
|
|
217
|
+
toItem: config.toItem,
|
|
218
|
+
toItemContext: (key, work) => ({ streamId: work[0]?.streamId, key }),
|
|
219
|
+
retry: retrySchedule(config.retry),
|
|
220
|
+
removal: config.removal === undefined
|
|
221
|
+
? undefined
|
|
222
|
+
: {
|
|
223
|
+
ttl: config.removal.ttl === undefined
|
|
224
|
+
? undefined
|
|
225
|
+
: Duration.fromInputUnsafe(config.removal.ttl),
|
|
226
|
+
},
|
|
227
|
+
outbox: resolveOutbox(config.outbox),
|
|
228
|
+
});
|
|
229
|
+
const keyOf = (streamId, event) => engine.call("key", () => addressed(config.key(streamId, event)));
|
|
230
|
+
/** A row's engine result, as this projection reports it. */
|
|
231
|
+
const appliedOf = (streamIdStr, result) => {
|
|
232
|
+
const instance = result.instances[0];
|
|
233
|
+
return {
|
|
234
|
+
streamId: streamIdStr,
|
|
235
|
+
key: result.key,
|
|
236
|
+
applied: (instance?.applied ?? []),
|
|
237
|
+
rejected: (instance?.rejected ?? []),
|
|
238
|
+
alreadyApplied: (instance?.alreadyApplied ?? []),
|
|
239
|
+
state: result.state,
|
|
240
|
+
version: instance?.version ?? 0,
|
|
241
|
+
removed: result.removed,
|
|
242
|
+
enqueued: result.enqueued,
|
|
243
|
+
undelivered: Option.none(),
|
|
244
|
+
};
|
|
245
|
+
};
|
|
246
|
+
/** After a write with effects, drain the row when the caller passed `deliver`. */
|
|
247
|
+
const deliverAfter = (applied, deliver) => deliver === undefined || config.outbox === undefined || applied.enqueued === 0
|
|
248
|
+
? Effect.succeed(applied)
|
|
249
|
+
: engine.drain(applied.key, deliver).pipe(Effect.map((drained) => ({
|
|
250
|
+
...applied,
|
|
251
|
+
undelivered: drained.undelivered,
|
|
252
|
+
})));
|
|
253
|
+
const applyBatch = (events, options) => Effect.gen(function* () {
|
|
254
|
+
// By stream instance, in order of first delivery.
|
|
255
|
+
const streams = new Map();
|
|
256
|
+
events.forEach((event, position) => {
|
|
257
|
+
const group = streams.get(event.streamId);
|
|
258
|
+
if (group === undefined)
|
|
259
|
+
streams.set(event.streamId, [[position, event]]);
|
|
260
|
+
else
|
|
261
|
+
group.push([position, event]);
|
|
262
|
+
});
|
|
263
|
+
/** Positions of the events that address no row. */
|
|
264
|
+
const ignored = [];
|
|
265
|
+
// Then by row; each row's task is ordered by its first delivered event.
|
|
266
|
+
const tasks = [];
|
|
267
|
+
for (const [streamIdStr, group] of streams) {
|
|
268
|
+
const positions = group.map(([position]) => position);
|
|
269
|
+
// A stream id that does not parse, or a `key` that throws, fails the
|
|
270
|
+
// whole stream instance: its events can't be placed in rows.
|
|
271
|
+
const rows = yield* Effect.result(Effect.gen(function* () {
|
|
272
|
+
const streamId = (yield* stream.parseStreamId(streamIdStr));
|
|
273
|
+
const byRow = new Map();
|
|
274
|
+
for (const [position, event] of group) {
|
|
275
|
+
const key = yield* keyOf(streamId, event);
|
|
276
|
+
if (Option.isNone(key)) {
|
|
277
|
+
ignored.push(position);
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
280
|
+
const id = keyId(key.value);
|
|
281
|
+
const row = byRow.get(id);
|
|
282
|
+
if (row === undefined) {
|
|
283
|
+
byRow.set(id, { key: key.value, positions: [position], events: [event] });
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
row.positions.push(position);
|
|
287
|
+
row.events.push(event);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
return { streamId, rows: [...byRow.values()] };
|
|
291
|
+
}));
|
|
292
|
+
if (Result.isFailure(rows)) {
|
|
293
|
+
const error = rows.failure;
|
|
294
|
+
tasks.push({
|
|
295
|
+
first: positions[0],
|
|
296
|
+
run: Effect.succeed({
|
|
297
|
+
_tag: "Failed",
|
|
298
|
+
streamId: streamIdStr,
|
|
299
|
+
key: undefined,
|
|
300
|
+
positions,
|
|
301
|
+
error,
|
|
302
|
+
}),
|
|
303
|
+
});
|
|
304
|
+
continue;
|
|
305
|
+
}
|
|
306
|
+
const { streamId } = rows.success;
|
|
307
|
+
const delivered = new Set(group.map(([, event]) => event.version));
|
|
308
|
+
for (const row of rows.success.rows) {
|
|
309
|
+
// Sorted by version, one event per version (a redelivery is a duplicate).
|
|
310
|
+
const ordered = [...row.events]
|
|
311
|
+
.sort((a, b) => a.version - b.version)
|
|
312
|
+
.filter((e, i, sorted) => i === 0 || sorted[i - 1].version !== e.version);
|
|
313
|
+
const work = {
|
|
314
|
+
source,
|
|
315
|
+
streamIdStr,
|
|
316
|
+
streamId,
|
|
317
|
+
events: ordered,
|
|
318
|
+
top: 0,
|
|
319
|
+
delivered,
|
|
320
|
+
};
|
|
321
|
+
tasks.push({
|
|
322
|
+
first: row.positions[0],
|
|
323
|
+
run: Effect.result(engine.applyRow(row.key, [work]).pipe(Effect.flatMap((result) => deliverAfter(appliedOf(streamIdStr, result), options?.deliver)))).pipe(Effect.map((result) => Result.isSuccess(result)
|
|
324
|
+
? { _tag: "Applied", positions: row.positions, ...result.success }
|
|
325
|
+
: {
|
|
326
|
+
_tag: "Failed",
|
|
327
|
+
streamId: streamIdStr,
|
|
328
|
+
key: row.key,
|
|
329
|
+
positions: row.positions,
|
|
330
|
+
error: result.failure,
|
|
331
|
+
})),
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
tasks.sort((a, b) => a.first - b.first);
|
|
336
|
+
const outcomes = yield* Effect.forEach(tasks, (task) => task.run, {
|
|
337
|
+
concurrency: options?.concurrency ?? 10,
|
|
338
|
+
});
|
|
339
|
+
return {
|
|
340
|
+
outcomes,
|
|
341
|
+
failedPositions: outcomes
|
|
342
|
+
.filter((o) => o._tag === "Failed")
|
|
343
|
+
.map((o) => o.positions[0])
|
|
344
|
+
.sort((a, b) => a - b),
|
|
345
|
+
ignored: ignored.sort((a, b) => a - b),
|
|
346
|
+
};
|
|
347
|
+
});
|
|
348
|
+
/**
|
|
349
|
+
* `applyBatch([event])`, the row's failure in the error channel — wrapped in
|
|
350
|
+
* an `Option` when `key` returns one (none: the event addresses no row).
|
|
351
|
+
*/
|
|
352
|
+
const apply = (event) => Effect.gen(function* () {
|
|
353
|
+
const streamId = (yield* stream.parseStreamId(event.streamId));
|
|
354
|
+
const key = yield* engine.call("key", () => config.key(streamId, event));
|
|
355
|
+
const optional = Option.isOption(key);
|
|
356
|
+
if (optional && Option.isNone(key))
|
|
357
|
+
return Option.none();
|
|
358
|
+
const { outcomes } = yield* applyBatch([event]);
|
|
359
|
+
const outcome = outcomes[0];
|
|
360
|
+
if (outcome._tag === "Failed")
|
|
361
|
+
return yield* Effect.fail(outcome.error);
|
|
362
|
+
const { _tag, positions, ...applied } = outcome;
|
|
363
|
+
return optional ? Option.some(applied) : applied;
|
|
364
|
+
});
|
|
365
|
+
const joinStreamId = (streamId) => stream.streamIdFields.map((f) => streamId[f]).join("#");
|
|
366
|
+
const catchUp = (streamId) => Effect.gen(function* () {
|
|
367
|
+
// The latest event that addresses a row — usually the head, one page.
|
|
368
|
+
const pages = yield* Query.paginate(stream.query
|
|
369
|
+
.events(streamId)
|
|
370
|
+
.pipe(Query.reverse, Query.pageSize(25), (q) => Query.consistentRead(q)));
|
|
371
|
+
const latest = yield* pages.pipe(Stream.flatMap((page) => Stream.fromIterable(page)), Stream.mapEffect((event) => keyOf(streamId, event).pipe(Effect.map((key) => Option.map(key, (k) => [event, k])))), Stream.filter((found) => Option.isSome(found)), Stream.map((found) => Option.getOrThrow(found)), Stream.runHead);
|
|
372
|
+
if (Option.isNone(latest)) {
|
|
373
|
+
return {
|
|
374
|
+
key: Option.none(),
|
|
375
|
+
applied: [],
|
|
376
|
+
rejected: [],
|
|
377
|
+
state: Option.none(),
|
|
378
|
+
version: 0,
|
|
379
|
+
removed: false,
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
const [head, key] = latest.value;
|
|
383
|
+
const result = (yield* engine.applyRow(key, [
|
|
384
|
+
{
|
|
385
|
+
source,
|
|
386
|
+
streamIdStr: joinStreamId(streamId),
|
|
387
|
+
streamId,
|
|
388
|
+
events: undefined,
|
|
389
|
+
top: head.version,
|
|
390
|
+
delivered: new Set(),
|
|
391
|
+
},
|
|
392
|
+
]));
|
|
393
|
+
const applied = appliedOf(joinStreamId(streamId), result);
|
|
394
|
+
return {
|
|
395
|
+
key: Option.some(key),
|
|
396
|
+
applied: applied.applied,
|
|
397
|
+
rejected: applied.rejected,
|
|
398
|
+
state: applied.state,
|
|
399
|
+
version: applied.version,
|
|
400
|
+
removed: applied.removed,
|
|
401
|
+
};
|
|
402
|
+
});
|
|
403
|
+
const rebuild = (streamId) => Effect.gen(function* () {
|
|
404
|
+
const events = (yield* stream.read(streamId, { consistentRead: true }));
|
|
405
|
+
const delivered = new Set(events.map((e) => e.version));
|
|
406
|
+
const rows = new Map();
|
|
407
|
+
for (const event of events) {
|
|
408
|
+
const key = yield* keyOf(streamId, event);
|
|
409
|
+
if (Option.isNone(key))
|
|
410
|
+
continue;
|
|
411
|
+
const id = keyId(key.value);
|
|
412
|
+
const row = rows.get(id);
|
|
413
|
+
if (row === undefined)
|
|
414
|
+
rows.set(id, { key: key.value, events: [event] });
|
|
415
|
+
else
|
|
416
|
+
row.events.push(event);
|
|
417
|
+
}
|
|
418
|
+
const rebuilt = yield* Effect.forEach([...rows.values()], ({ key, events: rowEvents }) => engine.applyRow(key, [
|
|
419
|
+
{
|
|
420
|
+
source,
|
|
421
|
+
streamIdStr: joinStreamId(streamId),
|
|
422
|
+
streamId,
|
|
423
|
+
events: rowEvents,
|
|
424
|
+
top: rowEvents[rowEvents.length - 1].version,
|
|
425
|
+
delivered,
|
|
426
|
+
},
|
|
427
|
+
], { fromScratch: true }).pipe(Effect.map((result) => {
|
|
428
|
+
const applied = appliedOf(joinStreamId(streamId), result);
|
|
429
|
+
return {
|
|
430
|
+
key,
|
|
431
|
+
state: applied.state,
|
|
432
|
+
version: applied.version,
|
|
433
|
+
rejected: applied.rejected,
|
|
434
|
+
removed: applied.removed,
|
|
435
|
+
};
|
|
436
|
+
})), { concurrency: 10 });
|
|
437
|
+
return { rows: rebuilt };
|
|
438
|
+
});
|
|
439
|
+
const processBatch = (records, options) => runBatch(`${label}.processBatch`, records, options, [
|
|
440
|
+
{
|
|
441
|
+
name: "projection",
|
|
442
|
+
stream: stream,
|
|
443
|
+
decode: (image) => stream.decodeStreamImage(image),
|
|
444
|
+
applyBatch: (events, applyOptions) => applyBatch(events, applyOptions),
|
|
445
|
+
},
|
|
446
|
+
]).pipe(Effect.map(({ outcomes, unrouted: _, ...rest }) => ({
|
|
447
|
+
...rest,
|
|
448
|
+
outcomes: outcomes.projection,
|
|
449
|
+
})));
|
|
450
|
+
const outboxRequired = (operation) => Effect.die(new Error(`[EDD-9081] ${label}.${operation}: the projection declares no \`outbox\`.`));
|
|
451
|
+
return {
|
|
452
|
+
[EventProjectionTypeId]: EventProjectionTypeId,
|
|
453
|
+
pipe() {
|
|
454
|
+
// eslint-disable-next-line prefer-rest-params
|
|
455
|
+
return Pipeable.pipeArguments(this, arguments);
|
|
456
|
+
},
|
|
457
|
+
stream,
|
|
458
|
+
entityType: readModel.entityType,
|
|
459
|
+
[ProjectionRoutes]: (name) => [
|
|
460
|
+
{
|
|
461
|
+
name,
|
|
462
|
+
stream: stream,
|
|
463
|
+
decode: (image) => stream.decodeStreamImage(image),
|
|
464
|
+
applyBatch: (events, applyOptions) => applyBatch(events, applyOptions),
|
|
465
|
+
},
|
|
466
|
+
],
|
|
467
|
+
applyBatch,
|
|
468
|
+
apply,
|
|
469
|
+
catchUp,
|
|
470
|
+
rebuild,
|
|
471
|
+
processBatch,
|
|
472
|
+
drain: (key, deliver) => config.outbox === undefined ? outboxRequired("drain") : engine.drain(key, deliver),
|
|
473
|
+
drainPending: (deliver) => config.outbox === undefined ? outboxRequired("drainPending") : engine.drainPending(deliver),
|
|
474
|
+
};
|
|
475
|
+
};
|
|
476
|
+
/** The default `image` accessor: the `NewImage` of an `INSERT`. */
|
|
477
|
+
const insertImage = (record) => record.eventName !== undefined && record.eventName !== "INSERT"
|
|
478
|
+
? undefined
|
|
479
|
+
: record.dynamodb?.NewImage;
|
|
480
|
+
/**
|
|
481
|
+
* @internal Decode a batch once, route each event to the projections of its
|
|
482
|
+
* stream, apply each projection's events, and build one partial batch
|
|
483
|
+
* response — shared by {@link processBatch} and `projection.processBatch`.
|
|
484
|
+
*/
|
|
485
|
+
export const runBatch = (operation, records, options, routes,
|
|
486
|
+
/** Streams decoded without a projection: their events are returned as `unrouted`. */
|
|
487
|
+
decodeOnly = []) => {
|
|
488
|
+
return Effect.gen(function* () {
|
|
489
|
+
// One decode per stream, however many projections read it.
|
|
490
|
+
const streams = new Map();
|
|
491
|
+
for (const route of routes) {
|
|
492
|
+
const readers = streams.get(route.stream);
|
|
493
|
+
if (readers === undefined)
|
|
494
|
+
streams.set(route.stream, [route]);
|
|
495
|
+
else
|
|
496
|
+
readers.push(route);
|
|
497
|
+
}
|
|
498
|
+
// `streams` may name a stream a projection reads too: it is decoded once,
|
|
499
|
+
// applied, and returned as `unrouted` as well.
|
|
500
|
+
// The same stream bound or unbound shares its event schema; a different
|
|
501
|
+
// stream with the same marker stays a conflict (`[EDD-9082]`).
|
|
502
|
+
const schemaOf = (stream) => stream.eventSchema;
|
|
503
|
+
const routedSchemas = new Map([...streams.keys()].map((stream) => [stream.eventMarker, schemaOf(stream)]));
|
|
504
|
+
const decodeOnlyStreams = decodeOnly.filter(([, stream]) => !streams.has(stream) &&
|
|
505
|
+
!(routedSchemas.has(stream.eventMarker) &&
|
|
506
|
+
routedSchemas.get(stream.eventMarker) === schemaOf(stream)));
|
|
507
|
+
/** A marker's stream: the projections that read it, or its name when it has none. */
|
|
508
|
+
const byMarker = markerIndex(operation, [
|
|
509
|
+
...[...streams.keys()].map((stream) => [stream.streamName, stream]),
|
|
510
|
+
...decodeOnlyStreams,
|
|
511
|
+
]);
|
|
512
|
+
/** The names `streams` gives, by event marker. */
|
|
513
|
+
const unroutedNames = new Map(decodeOnly.map(([name, stream]) => [stream.eventMarker, name]));
|
|
514
|
+
const unrouted = [];
|
|
515
|
+
const image = options.image ?? insertImage;
|
|
516
|
+
/** Each projection's events, and the record each came from. */
|
|
517
|
+
const routed = new Map(routes.map((route) => [route.name, { events: [], recordOf: [] }]));
|
|
518
|
+
const decodeFailures = [];
|
|
519
|
+
const failed = new Set();
|
|
520
|
+
for (const [i, record] of records.entries()) {
|
|
521
|
+
const recordImage = image(record);
|
|
522
|
+
if (recordImage === undefined)
|
|
523
|
+
continue;
|
|
524
|
+
const entry = typeof recordImage === "object" && recordImage !== null && !Array.isArray(recordImage)
|
|
525
|
+
? byMarker.get(imageEntityType(recordImage) ?? "")
|
|
526
|
+
: undefined;
|
|
527
|
+
// Not an event of any stream named: nothing to apply.
|
|
528
|
+
if (entry === undefined)
|
|
529
|
+
continue;
|
|
530
|
+
const readers = streams.get(entry[1]);
|
|
531
|
+
const decoded = yield* Effect.result(readers === undefined
|
|
532
|
+
? entry[1].decodeStreamImage(recordImage)
|
|
533
|
+
: readers[0].decode(recordImage));
|
|
534
|
+
if (Result.isFailure(decoded)) {
|
|
535
|
+
decodeFailures.push({ record, error: decoded.failure });
|
|
536
|
+
if (options.onDecodeFailure !== "skip")
|
|
537
|
+
failed.add(i);
|
|
538
|
+
}
|
|
539
|
+
else if (Option.isSome(decoded.success)) {
|
|
540
|
+
const name = unroutedNames.get(entry[1].eventMarker);
|
|
541
|
+
if (name !== undefined) {
|
|
542
|
+
unrouted.push({ position: i, stream: name, event: decoded.success.value });
|
|
543
|
+
}
|
|
544
|
+
for (const route of readers ?? []) {
|
|
545
|
+
const target = routed.get(route.name);
|
|
546
|
+
target.events.push(route.tag === undefined
|
|
547
|
+
? decoded.success.value
|
|
548
|
+
: { stream: route.tag, event: decoded.success.value });
|
|
549
|
+
target.recordOf.push(i);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
const outcomes = {};
|
|
554
|
+
// One `applyBatch` per projection, however many of its sources routed here.
|
|
555
|
+
const projections = [...new Map(routes.map((route) => [route.name, route])).values()];
|
|
556
|
+
for (const route of projections) {
|
|
557
|
+
const { events, recordOf } = routed.get(route.name);
|
|
558
|
+
if (events.length === 0) {
|
|
559
|
+
outcomes[route.name] = [];
|
|
560
|
+
continue;
|
|
561
|
+
}
|
|
562
|
+
const batch = yield* route.applyBatch(events, {
|
|
563
|
+
...(options.concurrency === undefined ? {} : { concurrency: options.concurrency }),
|
|
564
|
+
...(options.deliver === undefined ? {} : { deliver: options.deliver }),
|
|
565
|
+
});
|
|
566
|
+
for (const position of batch.failedPositions)
|
|
567
|
+
failed.add(recordOf[position]);
|
|
568
|
+
// Positions index the records, not the decoded events.
|
|
569
|
+
outcomes[route.name] = batch.outcomes.map((outcome) => ({
|
|
570
|
+
...outcome,
|
|
571
|
+
positions: outcome.positions.map((position) => recordOf[position]),
|
|
572
|
+
}));
|
|
573
|
+
}
|
|
574
|
+
const failedRecords = [...failed].sort((a, b) => a - b).map((i) => records[i]);
|
|
575
|
+
const response = yield* batchResponse(failedRecords, ("identifier" in options && options.identifier !== undefined
|
|
576
|
+
? { identifier: options.identifier }
|
|
577
|
+
: { source: options.source }));
|
|
578
|
+
return { unrouted, outcomes, decodeFailures, failedRecords, response };
|
|
579
|
+
});
|
|
580
|
+
};
|
|
581
|
+
/**
|
|
582
|
+
* Process one change-feed batch for several projections — the usual shape
|
|
583
|
+
* when one table's feed carries several streams. Each record is decoded once
|
|
584
|
+
* and routed to every projection of its stream; records of other streams and
|
|
585
|
+
* items are skipped, as acknowledged. Each projection applies its events
|
|
586
|
+
* (see {@link EventProjection.applyBatch}), and one partial batch response
|
|
587
|
+
* names the earliest record of every failed row across all of them, plus the
|
|
588
|
+
* records that failed to decode (unless `onDecodeFailure: "skip"`). Outcome
|
|
589
|
+
* `positions` index `records`.
|
|
590
|
+
*
|
|
591
|
+
* Records are read as `StreamRecord`s, identified per `source`, or through
|
|
592
|
+
* `image` / `identifier` accessors for a shape of your own (a Pipe input
|
|
593
|
+
* template's). A failed record without an identifier fails the call with
|
|
594
|
+
* `StreamRecordIdentifierMissing`. `streams` names streams to decode without a
|
|
595
|
+
* projection: their events come back as `unrouted`. Two streams storing
|
|
596
|
+
* events under one marker die with `[EDD-9082]`.
|
|
597
|
+
*
|
|
598
|
+
* @example
|
|
599
|
+
* ```ts
|
|
600
|
+
* const result = yield* EventStore.processBatch(event.Records, {
|
|
601
|
+
* projections: { summaries: OrderSummaryProjection, balances: BalanceProjection },
|
|
602
|
+
* source: "lambda",
|
|
603
|
+
* })
|
|
604
|
+
* return result.response
|
|
605
|
+
* ```
|
|
606
|
+
*/
|
|
607
|
+
export const processBatch = (records, options) => runBatch("EventStore.processBatch", records, options, Object.entries(options.projections).flatMap(([name, projection]) => projection[ProjectionRoutes](name)), Object.entries((options.streams ?? {})));
|
|
608
|
+
//# sourceMappingURL=EventProjection.js.map
|