effect-dynamodb 1.26.0 → 1.28.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.
@@ -0,0 +1,597 @@
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 { ConcurrentModification, type ConditionalCheckFailed, type ItemNotFound, StreamRecordIdentifierMissing, ValidationError } from "@effect-dynamodb/schema/Errors.js";
18
+ import { Effect, Option, Pipeable, Schedule, type Schema } from "effect";
19
+ import type { DynamoClient, DynamoClientError } from "../DynamoClient.js";
20
+ import type { EventStream, StreamEvent, StreamIdInput, StreamMetadata } from "../EventStore.js";
21
+ import type { TableConfig } from "../Table.js";
22
+ import type { EntityGet, EntityPut } from "./EntityOps.js";
23
+ import { type StreamImage } from "./Packed.js";
24
+ /**
25
+ * The read model a projection writes: an unbound `Entity`. Its row is read
26
+ * with a strongly consistent `get` and written whole with `put` (or `create`
27
+ * for a new row), so the projection owns the row.
28
+ */
29
+ export interface ProjectionReadModel {
30
+ readonly entityType: string;
31
+ readonly model: Schema.Top;
32
+ readonly versioned: unknown;
33
+ readonly softDelete: unknown;
34
+ readonly timeSeries: unknown;
35
+ readonly get: (key: any) => EntityGet<any, any, any, any>;
36
+ readonly put: (input: any) => EntityPut<any, any, any, any>;
37
+ readonly create: (input: any) => EntityPut<any, any, any, any>;
38
+ readonly systemFields: {
39
+ readonly createdAt: string | null;
40
+ };
41
+ readonly _attachPrototype?: ((decoded: any) => any) | undefined;
42
+ }
43
+ /** The state a projection folds: the read model's model type. */
44
+ export type ProjectionState<RM> = RM extends {
45
+ readonly get: (key: any) => EntityGet<infer A, any, any, any>;
46
+ } ? A : never;
47
+ /** The read model's primary key, as its `get` takes it. */
48
+ export type ProjectionKey<RM> = RM extends {
49
+ readonly get: (key: infer K) => any;
50
+ } ? K : never;
51
+ /**
52
+ * What reading and writing the read-model row can fail with — its `get` (a
53
+ * missing row is not an error) and its `put`. The conditional write's
54
+ * `ConditionalCheckFailed` is the projection's own race signal, never surfaced.
55
+ */
56
+ export type ProjectionReadModelError<RM> = (RM extends {
57
+ readonly put: (input: any) => EntityPut<any, any, infer E, any>;
58
+ } ? Exclude<E, ConditionalCheckFailed> : never) | (RM extends {
59
+ readonly get: (key: any) => EntityGet<any, any, infer E, any>;
60
+ } ? Exclude<E, ItemNotFound> : never);
61
+ /** The read model's numeric fields — those a checkpoint may name. */
62
+ export type CheckpointField<S> = {
63
+ [K in keyof S]-?: S[K] extends number ? K : never;
64
+ }[keyof S] & string;
65
+ /**
66
+ * The read model's field holding the last applied stream version. With
67
+ * `{ field, offset }` the field stores `version + offset`: a read model that
68
+ * numbered versions from 0 adopts a projection with `offset: -1`, its stored
69
+ * values and readers unchanged.
70
+ */
71
+ export type ProjectionCheckpoint<S> = CheckpointField<S> | {
72
+ readonly field: CheckpointField<S>;
73
+ readonly offset?: number | undefined;
74
+ };
75
+ /** Configuration of {@link projection}. */
76
+ export interface ProjectionConfig<TEvent, TStreamIdFields extends ReadonlyArray<string>, TMetadata, RM extends ProjectionReadModel, E, R, KR extends ProjectionKey<RM> | Option.Option<ProjectionKey<RM>> = ProjectionKey<RM>> {
77
+ /** The source stream. One projection reads one stream. */
78
+ readonly stream: EventStream<TEvent, TStreamIdFields, TMetadata, any, any, any, any>;
79
+ /** The read model (an unbound `Entity`). */
80
+ readonly readModel: RM;
81
+ /**
82
+ * The row an event folds into. A function of the stream id alone gives one
83
+ * row per stream instance. One that also reads the event lets a stream feed
84
+ * several rows — each row is still fed by that one stream instance (a row
85
+ * fed by several streams needs a checkpoint per source, which projections
86
+ * don't keep). When a later event addresses a different row, the earlier
87
+ * row keeps what it had, and the new row folds only its own events.
88
+ *
89
+ * Return an `Option` to let an event address no row: `Option.none()`
90
+ * acknowledges it — no row is read or written, no checkpoint moves, and it
91
+ * is in no outcome (`ignored` lists its position). `apply` then returns an
92
+ * `Option` too.
93
+ */
94
+ readonly key: (streamId: StreamIdInput<TStreamIdFields>, event: StreamEvent<TEvent, StreamMetadata<TMetadata>>) => KR;
95
+ /**
96
+ * The state a row starts from, before `event` — the first event folded into
97
+ * a row that does not exist yet.
98
+ */
99
+ readonly initial: (streamId: StreamIdInput<TStreamIdFields>, event: StreamEvent<TEvent, StreamMetadata<TMetadata>>) => ProjectionState<RM>;
100
+ /**
101
+ * Apply one event. Return the state unchanged to ignore an event (the
102
+ * checkpoint still advances). A failure fails this row only, unless
103
+ * `terminal` accepts it. The library sets the checkpoint field after the
104
+ * fold; `evolve` need not.
105
+ */
106
+ readonly evolve: (state: ProjectionState<RM>, event: StreamEvent<TEvent, StreamMetadata<TMetadata>>) => Effect.Effect<ProjectionState<RM>, E, R>;
107
+ /** See {@link ProjectionCheckpoint}. */
108
+ readonly checkpoint: ProjectionCheckpoint<ProjectionState<RM>>;
109
+ /**
110
+ * The row as written, from the folded state (checkpoint set) — to recompute
111
+ * attributes kept for other readers (`Hidden` index fields, say) on every
112
+ * write. Default: the state as folded.
113
+ */
114
+ readonly toItem?: ((state: ProjectionState<RM>, context: {
115
+ readonly streamId: StreamIdInput<TStreamIdFields>;
116
+ readonly key: ProjectionKey<RM>;
117
+ }) => ProjectionState<RM>) | undefined;
118
+ /**
119
+ * The `evolve` failures that reject their event rather than fail the row —
120
+ * an update to a row that was never created, say. A rejected event is
121
+ * skipped and reported in the outcome's `rejected`; the fold continues, and
122
+ * a row that does not exist is not created by rejected events alone. The
123
+ * decision must be deterministic: a rejected event can be read again (to
124
+ * fill a later gap) and is rejected again. Any other failure fails the row,
125
+ * and keeps failing it on every redelivery.
126
+ *
127
+ * A row that is never created (every one of its events rejected) has no
128
+ * checkpoint, so each later delivery of its events gap-reads from version 1
129
+ * and reports the earlier rejections again — dedupe `rejected` by version
130
+ * when counting or logging them; the read grows with the stream.
131
+ */
132
+ readonly terminal?: ((error: E) => boolean) | undefined;
133
+ /**
134
+ * Retries after a lost race — another invocation advanced the row between
135
+ * this one's read and its conditional write. Each retry re-reads the row, so
136
+ * it usually finds the events applied and has nothing left to write. A
137
+ * number `n` is `Schedule.recurs(n)`. Default: up to 12 retries after a
138
+ * jittered delay growing from 5 ms by 1.5× (about 1.3 s in all). Exhausted,
139
+ * the row fails with `ConcurrentModification`.
140
+ */
141
+ readonly retry?: number | Schedule.Schedule<unknown, ConcurrentModification> | undefined;
142
+ }
143
+ /** An event `evolve` rejected — see {@link ProjectionConfig.terminal}. */
144
+ export interface ProjectionRejected<A, M, E> {
145
+ readonly event: StreamEvent<A, M>;
146
+ readonly error: E;
147
+ }
148
+ /** One row applied by {@link EventProjection.applyBatch} / `apply`. */
149
+ export interface ProjectionApplied<S, A, M, K = unknown, E = unknown> {
150
+ /** The stream instance (`StreamEvent.streamId`). */
151
+ readonly streamId: string;
152
+ /** The row's key. */
153
+ readonly key: K;
154
+ /**
155
+ * The events this call applied to the row, in version order — including
156
+ * any it read from the store to fill a gap. Each event is in exactly one
157
+ * call's `applied`: the one whose conditional write won. Side effects driven
158
+ * from it are at most once (a crash after the write loses them).
159
+ */
160
+ readonly applied: ReadonlyArray<StreamEvent<A, M>>;
161
+ /**
162
+ * The events `evolve` rejected (see {@link ProjectionConfig.terminal}), in
163
+ * version order. Reported by every call that reads them — again, if a row
164
+ * that does not exist is not created before the next read.
165
+ */
166
+ readonly rejected: ReadonlyArray<ProjectionRejected<A, M, E>>;
167
+ /**
168
+ * The batch's events this row had already applied (version at or below the
169
+ * checkpoint it read), in version order — a redelivery, or a late
170
+ * out-of-order delivery. Republishing their side effects gives at-least-once
171
+ * delivery, for consumers that tolerate duplicates.
172
+ */
173
+ readonly alreadyApplied: ReadonlyArray<StreamEvent<A, M>>;
174
+ /**
175
+ * The row as written, or as read when nothing was left to apply.
176
+ * `Option.none()` when there is no row: every event was rejected.
177
+ */
178
+ readonly state: Option.Option<S>;
179
+ /**
180
+ * The row's checkpoint, in store numbering (offset removed): every stream
181
+ * version up to it has been considered for this row.
182
+ */
183
+ readonly version: number;
184
+ }
185
+ /** The outcome of one row in {@link ProjectionBatchResult}. */
186
+ export type ProjectionOutcome<S, A, M, Err, K = unknown, E = unknown> = ({
187
+ readonly _tag: "Applied";
188
+ /** Positions of this row's events in the `applyBatch` input, ascending. */
189
+ readonly positions: ReadonlyArray<number>;
190
+ } & ProjectionApplied<S, A, M, K, E>) | {
191
+ readonly _tag: "Failed";
192
+ readonly streamId: string;
193
+ /** The row's key — `undefined` when the stream id could not be parsed. */
194
+ readonly key: K | undefined;
195
+ /** Positions of this row's events in the `applyBatch` input, ascending. */
196
+ readonly positions: ReadonlyArray<number>;
197
+ readonly error: Err;
198
+ };
199
+ /** Result of {@link EventProjection.applyBatch}. */
200
+ export interface ProjectionBatchResult<S, A, M, Err, K = unknown, E = unknown> {
201
+ /** One outcome per row, in order of first delivery. */
202
+ readonly outcomes: ReadonlyArray<ProjectionOutcome<S, A, M, Err, K, E>>;
203
+ /**
204
+ * The earliest input position of each failed row, ascending — the records
205
+ * to report in a partial batch response.
206
+ */
207
+ readonly failedPositions: ReadonlyArray<number>;
208
+ /** Input positions of the events whose `key` returned `Option.none()`, ascending. */
209
+ readonly ignored: ReadonlyArray<number>;
210
+ }
211
+ /** Result of {@link EventProjection.catchUp}. */
212
+ export interface ProjectionCaughtUp<S, A, M, K = unknown, E = unknown> {
213
+ /** The row of the stream's latest event — `Option.none()` for a stream with no events. */
214
+ readonly key: Option.Option<K>;
215
+ /** The events folded, in version order. Empty when the row was current. */
216
+ readonly applied: ReadonlyArray<StreamEvent<A, M>>;
217
+ /** The events `evolve` rejected, in version order. */
218
+ readonly rejected: ReadonlyArray<ProjectionRejected<A, M, E>>;
219
+ /** The row — `Option.none()` when there is none. */
220
+ readonly state: Option.Option<S>;
221
+ readonly version: number;
222
+ }
223
+ /** One row re-derived by {@link EventProjection.rebuild}. */
224
+ export interface ProjectionRebuiltRow<S, A, M, K = unknown, E = unknown> {
225
+ readonly key: K;
226
+ /** The row as written — as read, when every one of its events was rejected. */
227
+ readonly state: Option.Option<S>;
228
+ /** The version of the row's last event. */
229
+ readonly version: number;
230
+ readonly rejected: ReadonlyArray<ProjectionRejected<A, M, E>>;
231
+ }
232
+ /** Result of {@link EventProjection.rebuild}. */
233
+ export interface ProjectionRebuilt<S, A = unknown, M = unknown, K = unknown, E = unknown> {
234
+ /** Every row the stream's events address, in order of their first event. Empty for a stream with no events. */
235
+ readonly rows: ReadonlyArray<ProjectionRebuiltRow<S, A, M, K, E>>;
236
+ }
237
+ /** What a projection's operations fail with: `evolve`'s `E`, the read model's errors, and the store's. */
238
+ export type ProjectionError<RM, E> = E | ProjectionReadModelError<RM> | DynamoClientError | ValidationError | ConcurrentModification;
239
+ /** Options of {@link EventProjection.applyBatch}. */
240
+ export interface ApplyBatchOptions {
241
+ /** Rows applied concurrently. Default `10`. */
242
+ readonly concurrency?: number | "unbounded" | undefined;
243
+ }
244
+ /**
245
+ * A DynamoDB Streams record as a Lambda event source mapping or an
246
+ * EventBridge Pipe delivers it — only the members the projection reads.
247
+ * Structural, so no `aws-lambda` types are needed. A record of another shape
248
+ * (a Pipe input template's) is read through `image` / `identifier` accessors.
249
+ */
250
+ export interface StreamRecord {
251
+ readonly eventID?: string | undefined;
252
+ readonly eventName?: string | undefined;
253
+ readonly dynamodb?: {
254
+ readonly SequenceNumber?: string | undefined;
255
+ readonly NewImage?: StreamImage | undefined;
256
+ } | undefined;
257
+ }
258
+ /**
259
+ * Who reads the partial batch response. A Lambda event source mapping on a
260
+ * DynamoDB stream identifies a record by `dynamodb.SequenceNumber`; an
261
+ * EventBridge Pipe by `eventID`.
262
+ */
263
+ export type BatchResponseSource = "lambda" | "pipe";
264
+ /** The `ReportBatchItemFailures` response. */
265
+ export interface BatchItemFailuresResponse {
266
+ readonly batchItemFailures: Array<{
267
+ readonly itemIdentifier: string;
268
+ }>;
269
+ }
270
+ /** Identify records by their source's member — see {@link BatchResponseSource}. */
271
+ export interface IdentifyBySource {
272
+ readonly source: BatchResponseSource;
273
+ }
274
+ /** Identify records with an accessor — for a record shape of your own. */
275
+ export interface IdentifyWith<Rec> {
276
+ readonly identifier: (record: Rec) => string | undefined;
277
+ }
278
+ /** Options of {@link EventProjection.processBatch}, beside how records are identified. */
279
+ export interface ProcessBatchOptions<Rec> extends ApplyBatchOptions {
280
+ /**
281
+ * A record's image, `undefined` to skip it. Default: the `NewImage` of an
282
+ * `INSERT` (a record without an `eventName` counts as one).
283
+ */
284
+ readonly image?: ((record: Rec) => StreamImage | undefined) | undefined;
285
+ /**
286
+ * What to do with a record whose image does not decode. A decode failure is
287
+ * deterministic, so `"report"` (the default) makes the source redeliver it
288
+ * — and everything after it on its shard — until its retries or age run out.
289
+ * `"skip"` acknowledges it, to log and dead-letter it yourself. Either way it
290
+ * is in `decodeFailures`.
291
+ *
292
+ * Skipping acknowledges the record, not the stored event: the next event of
293
+ * the same row gap-fills through it, fails to decode it, and fails the row
294
+ * (that record is reported). It helps when the bad event is its stream's
295
+ * last, or once the stored item is repaired or removed.
296
+ */
297
+ readonly onDecodeFailure?: "report" | "skip" | undefined;
298
+ }
299
+ /** Result of {@link EventProjection.processBatch}. */
300
+ export interface ProcessBatchResult<S, A, M, Err, Rec, K = unknown, E = unknown> {
301
+ /**
302
+ * See {@link ProjectionBatchResult.outcomes} — with `positions` indexing the
303
+ * **records** passed in.
304
+ */
305
+ readonly outcomes: ReadonlyArray<ProjectionOutcome<S, A, M, Err, K, E>>;
306
+ /** Records whose image failed to decode. */
307
+ readonly decodeFailures: ReadonlyArray<{
308
+ readonly record: Rec;
309
+ readonly error: ValidationError;
310
+ }>;
311
+ /**
312
+ * The records the response reports, in delivery order: the earliest record
313
+ * of each failed row, and (with `onDecodeFailure: "report"`) every record
314
+ * that failed to decode.
315
+ */
316
+ readonly failedRecords: ReadonlyArray<Rec>;
317
+ /**
318
+ * The partial batch response for `failedRecords`. To fail more records (a
319
+ * side effect that failed, say), pass them with these to {@link batchResponse}.
320
+ */
321
+ readonly response: BatchItemFailuresResponse;
322
+ }
323
+ /**
324
+ * The partial batch response (`ReportBatchItemFailures`) for `failedRecords`:
325
+ * each identified by `dynamodb.SequenceNumber` for a Lambda event source
326
+ * mapping, by `eventID` for an EventBridge Pipe, or by your own `identifier`
327
+ * accessor.
328
+ *
329
+ * Lambda checkpoints at the lowest reported sequence number and redelivers
330
+ * every record from there, so reporting the earliest failed record of each
331
+ * row is enough. A record without an identifier fails with
332
+ * `StreamRecordIdentifierMissing` — an empty one would fail the whole batch
333
+ * silently — so fail the invocation, and the source redelivers the batch.
334
+ */
335
+ export declare const batchResponse: {
336
+ (failedRecords: ReadonlyArray<StreamRecord>, options: IdentifyBySource): Effect.Effect<BatchItemFailuresResponse, StreamRecordIdentifierMissing>;
337
+ <Rec>(failedRecords: ReadonlyArray<Rec>, options: IdentifyWith<Rec>): Effect.Effect<BatchItemFailuresResponse, StreamRecordIdentifierMissing>;
338
+ };
339
+ /** A stream {@link decoder} can dispatch to — an `EventStream` or a `BoundEventStream`. */
340
+ export interface DecodableStream {
341
+ readonly streamName: string;
342
+ readonly eventMarker: string;
343
+ decodeStreamImage(image: StreamImage): Effect.Effect<Option.Option<unknown>, ValidationError, any>;
344
+ }
345
+ /** The event a decodable stream decodes to. */
346
+ type DecodedEventOf<S> = S extends {
347
+ decodeStreamImage(image: any, options?: any): Effect.Effect<Option.Option<infer Ev>, any, any>;
348
+ } ? Ev : never;
349
+ /** What {@link decoder} returns for one of its streams' event images. */
350
+ export type DecodedStreamEvent<Streams extends {
351
+ readonly [name: string]: DecodableStream;
352
+ }> = {
353
+ readonly [K in keyof Streams & string]: {
354
+ readonly stream: K;
355
+ readonly event: DecodedEventOf<Streams[K]>;
356
+ };
357
+ }[keyof Streams & string];
358
+ /**
359
+ * One decoder for several streams' change-feed images. Name the streams in a
360
+ * record; `decode(image)` dispatches on the image's `__edd_e__` and returns
361
+ * `{ stream: <name>, event }`, or `Option.none()` for anything that is not one
362
+ * of their events (snapshots, idempotency sentinels, entities, other streams).
363
+ * The image is decoded by that stream's `decodeStreamImage`, so it accepts the
364
+ * same shapes (DynamoDB JSON with `B` as base64 or bytes, or unmarshalled).
365
+ *
366
+ * Two streams storing events under the same marker throw `[EDD-9082]`.
367
+ *
368
+ * @example
369
+ * ```ts
370
+ * const decode = EventStore.decoder({ Order: OrderEvents, Payment: PaymentEvents })
371
+ * const decoded = yield* decode(record.dynamodb.NewImage)
372
+ * if (Option.isSome(decoded) && decoded.value.stream === "Order") { ... }
373
+ * ```
374
+ */
375
+ export declare const decoder: <const Streams extends {
376
+ readonly [name: string]: DecodableStream;
377
+ }>(streams: Streams) => ((image: StreamImage) => Effect.Effect<Option.Option<DecodedStreamEvent<Streams>>, ValidationError, never>);
378
+ /** A Lambda event source mapping / EventBridge Pipe filter pattern. */
379
+ export interface EventFilterPattern {
380
+ readonly eventName: ReadonlyArray<"INSERT">;
381
+ readonly dynamodb: {
382
+ readonly NewImage: {
383
+ readonly __edd_e__: {
384
+ readonly S: ReadonlyArray<string>;
385
+ };
386
+ };
387
+ };
388
+ }
389
+ /**
390
+ * The filter pattern that selects the `INSERT`s of these streams' event items
391
+ * — `JSON.stringify` it into `FilterCriteria.Filters[].Pattern` of a Lambda
392
+ * event source mapping or an EventBridge Pipe. Snapshots, idempotency
393
+ * sentinels and other items are filtered out before the function runs.
394
+ */
395
+ export declare const eventFilterPattern: (streams: ReadonlyArray<DecodableStream> | {
396
+ readonly [name: string]: DecodableStream;
397
+ }) => EventFilterPattern;
398
+ declare const EventProjectionTypeId: unique symbol;
399
+ export type EventProjectionTypeId = typeof EventProjectionTypeId;
400
+ /** @internal See {@link EventProjection}'s decode member. */
401
+ export declare const ProjectionDecode: unique symbol;
402
+ /**
403
+ * A change-feed projection: one source stream folded into read-model rows —
404
+ * see {@link projection}. Its operations need `DynamoClient | TableConfig`
405
+ * (the stream's table and the read model's) and `evolve`'s requirements;
406
+ * {@link bindProjection} resolves them (`R = never`).
407
+ */
408
+ export interface EventProjection<S, A, TStreamIdFields extends ReadonlyArray<string>, M, Err, R, K = unknown, E = unknown, I extends boolean = false> extends Pipeable.Pipeable {
409
+ readonly [EventProjectionTypeId]: EventProjectionTypeId;
410
+ /** The source stream. */
411
+ readonly stream: EventStream<A, TStreamIdFields, any, any, any, any, any>;
412
+ /**
413
+ * @internal The stream's image decode — under the bound context for a
414
+ * bound projection, so a multi-projection batch decodes as its projections
415
+ * would.
416
+ */
417
+ readonly [ProjectionDecode]: (image: StreamImage) => Effect.Effect<Option.Option<StreamEvent<A, M>>, ValidationError, never>;
418
+ /** The read model's entity type. */
419
+ readonly entityType: string;
420
+ /**
421
+ * Apply one stream's decoded change-feed events — a batch, in delivery
422
+ * order. Per row (`key(streamId, event)`, concurrently across rows):
423
+ *
424
+ * 1. sort and deduplicate the row's events by version;
425
+ * 2. read the row (strongly consistent) and its checkpoint `c`; the events
426
+ * at or below `c` are `alreadyApplied`, and with none left the row is
427
+ * done;
428
+ * 3. if the rest are not exactly `c + 1 …` their highest version, read
429
+ * `c + 1 …` that version from the store with one strongly consistent
430
+ * `readFrom` and keep the row's events — so nothing waits for a delivery;
431
+ * 4. fold through `evolve` (skipping `terminal` rejections), set the
432
+ * checkpoint, and write the row once, conditioned on the checkpoint still
433
+ * being `c` (`create` for a new row; nothing when a new row's events were
434
+ * all rejected);
435
+ * 5. on a lost race, re-read and continue, under the `retry` policy.
436
+ *
437
+ * Never fails: each row's failure is its outcome, so one row's error can't
438
+ * hide the others' `applied`.
439
+ */
440
+ applyBatch(events: ReadonlyArray<StreamEvent<A, M>>, options?: ApplyBatchOptions | undefined): Effect.Effect<ProjectionBatchResult<S, A, M, Err, K, E>, never, R>;
441
+ /** {@link EventProjection.applyBatch} of one event, its failure in the error channel. */
442
+ apply(event: StreamEvent<A, M>): Effect.Effect<I extends true ? Option.Option<ProjectionApplied<S, A, M, K, E>> : ProjectionApplied<S, A, M, K, E>, Err, R>;
443
+ /**
444
+ * Bring the row of the stream's latest event up to the head: read that
445
+ * event (one strongly consistent `Query`), then the row's events after its
446
+ * checkpoint (one strongly consistent `readFrom`) — to repair a row whose
447
+ * last event never arrived (a dead-lettered record, say). An earlier missing
448
+ * event is filled in by the next delivery anyway. With one row per stream
449
+ * instance that is the only row; {@link EventProjection.rebuild} re-derives
450
+ * every row.
451
+ */
452
+ catchUp(streamId: StreamIdInput<TStreamIdFields>): Effect.Effect<ProjectionCaughtUp<S, A, M, K, E>, Err, R>;
453
+ /**
454
+ * Re-derive every row of a stream instance from version 1: fold the whole
455
+ * stream (strongly consistent) from `initial`, row by row, ignoring the rows'
456
+ * state, and write each conditioned on the checkpoint read. Returns no
457
+ * applied events, so a rebuild never replays side effects. A stream with no
458
+ * events writes nothing.
459
+ *
460
+ * Pause live delivery for the stream instance while it runs. The condition
461
+ * is the checkpoint, and a rebuild of a row already at the stream's head
462
+ * writes the same checkpoint back — so an `applyBatch` that read the row
463
+ * before the rebuild still holds a matching condition, and its later write
464
+ * (folded from the old state) replaces the rebuilt row.
465
+ */
466
+ rebuild(streamId: StreamIdInput<TStreamIdFields>): Effect.Effect<ProjectionRebuilt<S, A, M, K, E>, Err, R>;
467
+ /**
468
+ * Process a raw change-feed batch: decode each `INSERT`'s `NewImage` (other
469
+ * records, and images that are not this stream's events, are skipped), apply
470
+ * the events with {@link EventProjection.applyBatch}, and build the partial
471
+ * batch response — the earliest record of each failed row and every record
472
+ * that failed to decode (unless `onDecodeFailure: "skip"`), identified per
473
+ * `options.source` or by `options.identifier`. Outcome `positions` index
474
+ * `records`. A failed record without an identifier fails the call with
475
+ * `StreamRecordIdentifierMissing`: fail the invocation, and the source
476
+ * redelivers the batch.
477
+ */
478
+ processBatch<Rec extends StreamRecord>(records: ReadonlyArray<Rec>, options: ProcessBatchOptions<Rec> & (IdentifyBySource | IdentifyWith<Rec>)): Effect.Effect<ProcessBatchResult<S, A, M, Err, Rec, K, E>, StreamRecordIdentifierMissing, R>;
479
+ /** A record shape of your own, read through `image` and `identifier`. */
480
+ processBatch<Rec>(records: ReadonlyArray<Rec>, options: ProcessBatchOptions<Rec> & {
481
+ readonly image: (record: Rec) => StreamImage | undefined;
482
+ } & IdentifyWith<Rec>): Effect.Effect<ProcessBatchResult<S, A, M, Err, Rec, K, E>, StreamRecordIdentifierMissing, R>;
483
+ }
484
+ /**
485
+ * Define a change-feed projection of `stream` into `readModel` — rows keyed by
486
+ * `key(streamId, event)` (one per stream instance when the key ignores the
487
+ * event), each folded from `initial(streamId, event)` through `evolve`, its
488
+ * checkpoint kept in `checkpoint`. See {@link EventProjection} for the
489
+ * operations.
490
+ *
491
+ * The read model must be a plain entity: `versioned` (the checkpoint is the
492
+ * version), `softDelete` (rows are never deleted) and `timeSeries` read
493
+ * models throw `[EDD-9081]`, as do a checkpoint the model has no field for and
494
+ * a non-integer offset.
495
+ *
496
+ * @example
497
+ * ```ts
498
+ * const OrderSummaryProjection = EventStore.projection({
499
+ * stream: OrderEvents,
500
+ * readModel: OrderSummaries,
501
+ * key: (id) => ({ orderId: id.orderId }),
502
+ * initial: (id) => ({ orderId: id.orderId, status: "open", total: 0, version: 0 }),
503
+ * evolve: (state, event) => Effect.succeed(next(state, event.data)),
504
+ * checkpoint: "version",
505
+ * })
506
+ * ```
507
+ */
508
+ export declare const projection: <TEvent, TStreamIdFields extends ReadonlyArray<string>, TMetadata, RM extends ProjectionReadModel, E = never, R = never, KR extends ProjectionKey<RM> | Option.Option<ProjectionKey<RM>> = ProjectionKey<RM>>(config: ProjectionConfig<TEvent, TStreamIdFields, TMetadata, RM, E, R, KR>) => EventProjection<ProjectionState<RM>, TEvent, TStreamIdFields, StreamMetadata<TMetadata>, ProjectionError<RM, E>, R | DynamoClient | TableConfig, ProjectionKey<RM>, E, [Extract<KR, Option.Option<unknown>>] extends [never] ? false : true>;
509
+ /** Any projection, bound or unbound. */
510
+ export type AnyEventProjection = EventProjection<any, any, any, any, any, any, any, any, any>;
511
+ /** A projection's outcomes. */
512
+ export type ProjectionOutcomesOf<P> = P extends EventProjection<infer S, infer A, any, infer M, infer Err, any, infer K, infer E, any> ? ReadonlyArray<ProjectionOutcome<S, A, M, Err, K, E>> : never;
513
+ /** A projection's requirements. */
514
+ export type ProjectionRequirementsOf<P> = P extends EventProjection<any, any, any, any, any, infer R, any, any, any> ? R : never;
515
+ /** Result of {@link processBatch}. */
516
+ export interface ProcessBatchesResult<Projections extends {
517
+ readonly [name: string]: AnyEventProjection;
518
+ }, Rec, Streams extends {
519
+ readonly [name: string]: DecodableStream;
520
+ } = {}> {
521
+ /**
522
+ * The events of the `streams` named without a projection, in delivery order,
523
+ * each with its record's position — so a caller acting on them needs no
524
+ * second decode.
525
+ */
526
+ readonly unrouted: ReadonlyArray<{
527
+ readonly position: number;
528
+ } & DecodedStreamEvent<Streams>>;
529
+ /**
530
+ * Each projection's outcomes — `positions` index the **records** passed in.
531
+ * A projection whose stream had no events in the batch has none.
532
+ */
533
+ readonly outcomes: {
534
+ readonly [K in keyof Projections]: ProjectionOutcomesOf<Projections[K]>;
535
+ };
536
+ /** Records whose image failed to decode. */
537
+ readonly decodeFailures: ReadonlyArray<{
538
+ readonly record: Rec;
539
+ readonly error: ValidationError;
540
+ }>;
541
+ /**
542
+ * The records the response reports, in delivery order: the earliest record
543
+ * of each failed row of every projection, and (with
544
+ * `onDecodeFailure: "report"`) every record that failed to decode.
545
+ */
546
+ readonly failedRecords: ReadonlyArray<Rec>;
547
+ /** The partial batch response for `failedRecords`. */
548
+ readonly response: BatchItemFailuresResponse;
549
+ }
550
+ /**
551
+ * Process one change-feed batch for several projections — the usual shape
552
+ * when one table's feed carries several streams. Each record is decoded once
553
+ * and routed to every projection of its stream; records of other streams and
554
+ * items are skipped, as acknowledged. Each projection applies its events
555
+ * (see {@link EventProjection.applyBatch}), and one partial batch response
556
+ * names the earliest record of every failed row across all of them, plus the
557
+ * records that failed to decode (unless `onDecodeFailure: "skip"`). Outcome
558
+ * `positions` index `records`.
559
+ *
560
+ * Records are read as `StreamRecord`s, identified per `source`, or through
561
+ * `image` / `identifier` accessors for a shape of your own (a Pipe input
562
+ * template's). A failed record without an identifier fails the call with
563
+ * `StreamRecordIdentifierMissing`. `streams` names streams to decode without a
564
+ * projection: their events come back as `unrouted`. Two streams storing
565
+ * events under one marker die with `[EDD-9082]`.
566
+ *
567
+ * @example
568
+ * ```ts
569
+ * const result = yield* EventStore.processBatch(event.Records, {
570
+ * projections: { summaries: OrderSummaryProjection, balances: BalanceProjection },
571
+ * source: "lambda",
572
+ * })
573
+ * return result.response
574
+ * ```
575
+ */
576
+ export declare const processBatch: {
577
+ <const Projections extends {
578
+ readonly [name: string]: AnyEventProjection;
579
+ }, Rec extends StreamRecord, const Streams extends {
580
+ readonly [name: string]: DecodableStream;
581
+ } = {}>(records: ReadonlyArray<Rec>, options: ProcessBatchOptions<Rec> & (IdentifyBySource | IdentifyWith<Rec>) & {
582
+ readonly projections: Projections;
583
+ readonly streams?: Streams | undefined;
584
+ }): Effect.Effect<ProcessBatchesResult<Projections, Rec, Streams>, StreamRecordIdentifierMissing, ProjectionRequirementsOf<Projections[keyof Projections]>>;
585
+ <const Projections extends {
586
+ readonly [name: string]: AnyEventProjection;
587
+ }, Rec, const Streams extends {
588
+ readonly [name: string]: DecodableStream;
589
+ } = {}>(records: ReadonlyArray<Rec>, options: ProcessBatchOptions<Rec> & {
590
+ readonly image: (record: Rec) => StreamImage | undefined;
591
+ } & IdentifyWith<Rec> & {
592
+ readonly projections: Projections;
593
+ readonly streams?: Streams | undefined;
594
+ }): Effect.Effect<ProcessBatchesResult<Projections, Rec, Streams>, StreamRecordIdentifierMissing, ProjectionRequirementsOf<Projections[keyof Projections]>>;
595
+ };
596
+ export {};
597
+ //# sourceMappingURL=EventProjection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EventProjection.d.ts","sourceRoot":"","sources":["../../src/internal/EventProjection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EACL,sBAAsB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,YAAY,EACjB,6BAA6B,EAC7B,eAAe,EAChB,MAAM,mCAAmC,CAAA;AAC1C,OAAO,EAAY,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAU,QAAQ,EAAE,KAAK,MAAM,EAAU,MAAM,QAAQ,CAAA;AAClG,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,WAAW,EAAE,MAAM,aAAa,CAAA;AAM9C,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAiB,MAAM,gBAAgB,CAAA;AACzE,OAAO,EAAmB,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AAM/D;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,CAAA;IAC1B,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;IAC3B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAA;IAC5B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAA;IAC5B,QAAQ,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;IACzD,QAAQ,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,SAAS,CAAC,GAAG,EA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