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,247 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CheckpointStore — where a change feed keeps its per-shard checkpoints and
|
|
3
|
+
* its lease. Two implementations: in memory, and a DynamoDB table.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { isAwsConditionalCheckFailed } from "@effect-dynamodb/schema/Errors.js";
|
|
8
|
+
import { Clock, Context, Duration, Effect, Layer, Option } from "effect";
|
|
9
|
+
import { DynamoClient } from "../DynamoClient.js";
|
|
10
|
+
import { ChangeFeedLeaseHeld, ChangeFeedLeaseLost, CheckpointStoreError } from "./Errors.js";
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
// In memory
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
/** A checkpoint store held in memory — for tests and single-process feeds that may start over. */
|
|
15
|
+
export const makeMemory = () => {
|
|
16
|
+
const checkpoints = new Map();
|
|
17
|
+
const leases = new Map();
|
|
18
|
+
const keyOf = (feed) => `${feed.consumer}#${feed.streamArn}`;
|
|
19
|
+
return {
|
|
20
|
+
load: (feed) => Effect.sync(() => new Map(checkpoints.get(keyOf(feed)) ?? new Map())),
|
|
21
|
+
commit: (feed, shardId, checkpoint) => Effect.sync(() => {
|
|
22
|
+
const key = keyOf(feed);
|
|
23
|
+
const shards = checkpoints.get(key) ?? new Map();
|
|
24
|
+
shards.set(shardId, checkpoint);
|
|
25
|
+
checkpoints.set(key, shards);
|
|
26
|
+
}),
|
|
27
|
+
acquireLease: (feed, owner, duration) => Effect.gen(function* () {
|
|
28
|
+
const now = yield* Clock.currentTimeMillis;
|
|
29
|
+
const held = leases.get(keyOf(feed));
|
|
30
|
+
if (held !== undefined && held.owner !== owner && held.expiresAt > now) {
|
|
31
|
+
return yield* new ChangeFeedLeaseHeld({
|
|
32
|
+
streamArn: feed.streamArn,
|
|
33
|
+
consumer: feed.consumer,
|
|
34
|
+
owner: held.owner,
|
|
35
|
+
expiresAt: held.expiresAt,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
leases.set(keyOf(feed), { owner, expiresAt: now + Duration.toMillis(duration) });
|
|
39
|
+
}),
|
|
40
|
+
renewLease: (feed, owner, duration) => Effect.gen(function* () {
|
|
41
|
+
const now = yield* Clock.currentTimeMillis;
|
|
42
|
+
const held = leases.get(keyOf(feed));
|
|
43
|
+
if (held === undefined || held.owner !== owner) {
|
|
44
|
+
return yield* new ChangeFeedLeaseLost({
|
|
45
|
+
streamArn: feed.streamArn,
|
|
46
|
+
consumer: feed.consumer,
|
|
47
|
+
owner,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
leases.set(keyOf(feed), { owner, expiresAt: now + Duration.toMillis(duration) });
|
|
51
|
+
}),
|
|
52
|
+
releaseLease: (feed, owner) => Effect.sync(() => {
|
|
53
|
+
if (leases.get(keyOf(feed))?.owner === owner)
|
|
54
|
+
leases.delete(keyOf(feed));
|
|
55
|
+
}),
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
const SHARD_PREFIX = "shard#";
|
|
59
|
+
const LEASE_SK = "lease";
|
|
60
|
+
/**
|
|
61
|
+
* The checkpoint table's `CreateTable` input: `pk` (S, HASH) + `sk` (S, RANGE),
|
|
62
|
+
* on-demand billing. A shard checkpoint is `{ pk: "<consumer>#<streamArn>",
|
|
63
|
+
* sk: "shard#<shardId>", sequenceNumber | finished, updatedAt, ttl? }`; the
|
|
64
|
+
* lease is `{ pk, sk: "lease", owner, expiresAt }`. Enable TTL on `ttl` to
|
|
65
|
+
* expire `Finished` checkpoints.
|
|
66
|
+
*/
|
|
67
|
+
export const tableDefinition = (tableName) => ({
|
|
68
|
+
TableName: tableName,
|
|
69
|
+
BillingMode: "PAY_PER_REQUEST",
|
|
70
|
+
KeySchema: [
|
|
71
|
+
{ AttributeName: "pk", KeyType: "HASH" },
|
|
72
|
+
{ AttributeName: "sk", KeyType: "RANGE" },
|
|
73
|
+
],
|
|
74
|
+
AttributeDefinitions: [
|
|
75
|
+
{ AttributeName: "pk", AttributeType: "S" },
|
|
76
|
+
{ AttributeName: "sk", AttributeType: "S" },
|
|
77
|
+
],
|
|
78
|
+
});
|
|
79
|
+
const storeError = (operation) => (cause) => new CheckpointStoreError({ operation, cause });
|
|
80
|
+
const isConditionFailed = (error) => isAwsConditionalCheckFailed(error.cause);
|
|
81
|
+
/** A checkpoint store on a DynamoDB table, through `DynamoClient`. */
|
|
82
|
+
/**
|
|
83
|
+
* The shortest `finishedTtl` accepted: 28 hours. A `Finished` checkpoint must
|
|
84
|
+
* outlive every shard that depends on it being there — the shard itself, listed
|
|
85
|
+
* up to 24 hours after it closes, and the children of a parent already gone at
|
|
86
|
+
* a fresh start, which can stay listed for a shard's lifetime (about 4 hours)
|
|
87
|
+
* plus those 24 hours. A checkpoint expired earlier makes a restart report
|
|
88
|
+
* `ChangeFeedTrimmed` for records that were never lost.
|
|
89
|
+
*/
|
|
90
|
+
export const MIN_FINISHED_TTL = Duration.hours(28);
|
|
91
|
+
export const makeDynamoDB = (options) => {
|
|
92
|
+
const finishedTtl = Duration.fromInputUnsafe(options.finishedTtl ?? "2 days");
|
|
93
|
+
if (Duration.toMillis(finishedTtl) < Duration.toMillis(MIN_FINISHED_TTL)) {
|
|
94
|
+
throw new Error(`[EDD-9084] CheckpointStore.layerDynamoDB("${options.tableName}"): finishedTtl ` +
|
|
95
|
+
`(${Duration.toMillis(finishedTtl)} ms) is shorter than 28 hours. A finished shard's ` +
|
|
96
|
+
"checkpoint must outlive the shards that depend on it (24 hours of retention plus a " +
|
|
97
|
+
"shard's lifetime), or a restart reports lost records that were not lost.");
|
|
98
|
+
}
|
|
99
|
+
return Effect.gen(function* () {
|
|
100
|
+
const client = yield* DynamoClient;
|
|
101
|
+
const TableName = options.tableName;
|
|
102
|
+
const finishedTtlSeconds = Math.ceil(Duration.toMillis(finishedTtl) / 1000);
|
|
103
|
+
const pkOf = (feed) => ({ S: `${feed.consumer}#${feed.streamArn}` });
|
|
104
|
+
const leaseKey = (feed) => ({ pk: pkOf(feed), sk: { S: LEASE_SK } });
|
|
105
|
+
const load = (feed) => Effect.gen(function* () {
|
|
106
|
+
const shards = new Map();
|
|
107
|
+
let ExclusiveStartKey;
|
|
108
|
+
do {
|
|
109
|
+
const page = yield* client
|
|
110
|
+
.query({
|
|
111
|
+
TableName,
|
|
112
|
+
KeyConditionExpression: "#pk = :pk AND begins_with(#sk, :prefix)",
|
|
113
|
+
ExpressionAttributeNames: { "#pk": "pk", "#sk": "sk" },
|
|
114
|
+
ExpressionAttributeValues: { ":pk": pkOf(feed), ":prefix": { S: SHARD_PREFIX } },
|
|
115
|
+
ConsistentRead: true,
|
|
116
|
+
...(ExclusiveStartKey === undefined ? {} : { ExclusiveStartKey }),
|
|
117
|
+
})
|
|
118
|
+
.pipe(Effect.mapError(storeError("CheckpointStore.load")));
|
|
119
|
+
for (const item of page.Items ?? []) {
|
|
120
|
+
const shardId = item.sk?.S?.slice(SHARD_PREFIX.length);
|
|
121
|
+
if (shardId === undefined)
|
|
122
|
+
continue;
|
|
123
|
+
if (item.finished?.BOOL === true)
|
|
124
|
+
shards.set(shardId, { _tag: "Finished" });
|
|
125
|
+
else if (item.sequenceNumber?.S !== undefined) {
|
|
126
|
+
shards.set(shardId, { _tag: "Sequence", sequenceNumber: item.sequenceNumber.S });
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
ExclusiveStartKey = page.LastEvaluatedKey;
|
|
130
|
+
} while (ExclusiveStartKey !== undefined);
|
|
131
|
+
return shards;
|
|
132
|
+
});
|
|
133
|
+
const commit = (feed, shardId, checkpoint) => Effect.gen(function* () {
|
|
134
|
+
const now = yield* Clock.currentTimeMillis;
|
|
135
|
+
const Item = {
|
|
136
|
+
pk: pkOf(feed),
|
|
137
|
+
sk: { S: `${SHARD_PREFIX}${shardId}` },
|
|
138
|
+
updatedAt: { N: String(now) },
|
|
139
|
+
...(checkpoint._tag === "Finished"
|
|
140
|
+
? {
|
|
141
|
+
finished: { BOOL: true },
|
|
142
|
+
ttl: { N: String(Math.floor(now / 1000) + finishedTtlSeconds) },
|
|
143
|
+
}
|
|
144
|
+
: { sequenceNumber: { S: checkpoint.sequenceNumber } }),
|
|
145
|
+
};
|
|
146
|
+
yield* client
|
|
147
|
+
.putItem({ TableName, Item })
|
|
148
|
+
.pipe(Effect.mapError(storeError("CheckpointStore.commit")));
|
|
149
|
+
});
|
|
150
|
+
const readLease = (feed) => client.getItem({ TableName, Key: leaseKey(feed), ConsistentRead: true }).pipe(Effect.map((result) => Option.fromNullishOr(result.Item).pipe(Option.map((item) => ({
|
|
151
|
+
owner: item.owner?.S,
|
|
152
|
+
expiresAt: item.expiresAt?.N === undefined ? undefined : Number(item.expiresAt.N),
|
|
153
|
+
})))), Effect.mapError(storeError("CheckpointStore.acquireLease")));
|
|
154
|
+
const acquireLease = (feed, owner, duration) => Effect.gen(function* () {
|
|
155
|
+
const now = yield* Clock.currentTimeMillis;
|
|
156
|
+
const result = yield* client
|
|
157
|
+
.putItem({
|
|
158
|
+
TableName,
|
|
159
|
+
Item: {
|
|
160
|
+
...leaseKey(feed),
|
|
161
|
+
owner: { S: owner },
|
|
162
|
+
expiresAt: { N: String(now + Duration.toMillis(duration)) },
|
|
163
|
+
},
|
|
164
|
+
ConditionExpression: "attribute_not_exists(#pk) OR #owner = :owner OR #expiresAt < :now",
|
|
165
|
+
ExpressionAttributeNames: { "#pk": "pk", "#owner": "owner", "#expiresAt": "expiresAt" },
|
|
166
|
+
ExpressionAttributeValues: { ":owner": { S: owner }, ":now": { N: String(now) } },
|
|
167
|
+
})
|
|
168
|
+
.pipe(Effect.result);
|
|
169
|
+
if (result._tag === "Success")
|
|
170
|
+
return;
|
|
171
|
+
if (!isConditionFailed(result.failure)) {
|
|
172
|
+
return yield* storeError("CheckpointStore.acquireLease")(result.failure);
|
|
173
|
+
}
|
|
174
|
+
const held = yield* readLease(feed);
|
|
175
|
+
return yield* new ChangeFeedLeaseHeld({
|
|
176
|
+
streamArn: feed.streamArn,
|
|
177
|
+
consumer: feed.consumer,
|
|
178
|
+
owner: Option.isSome(held) ? held.value.owner : undefined,
|
|
179
|
+
expiresAt: Option.isSome(held) ? held.value.expiresAt : undefined,
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
const renewLease = (feed, owner, duration) => Effect.gen(function* () {
|
|
183
|
+
const now = yield* Clock.currentTimeMillis;
|
|
184
|
+
const result = yield* client
|
|
185
|
+
.updateItem({
|
|
186
|
+
TableName,
|
|
187
|
+
Key: leaseKey(feed),
|
|
188
|
+
UpdateExpression: "SET #expiresAt = :expiresAt",
|
|
189
|
+
ConditionExpression: "#owner = :owner",
|
|
190
|
+
ExpressionAttributeNames: { "#owner": "owner", "#expiresAt": "expiresAt" },
|
|
191
|
+
ExpressionAttributeValues: {
|
|
192
|
+
":owner": { S: owner },
|
|
193
|
+
":expiresAt": { N: String(now + Duration.toMillis(duration)) },
|
|
194
|
+
},
|
|
195
|
+
})
|
|
196
|
+
.pipe(Effect.result);
|
|
197
|
+
if (result._tag === "Success")
|
|
198
|
+
return;
|
|
199
|
+
if (isConditionFailed(result.failure)) {
|
|
200
|
+
return yield* new ChangeFeedLeaseLost({
|
|
201
|
+
streamArn: feed.streamArn,
|
|
202
|
+
consumer: feed.consumer,
|
|
203
|
+
owner,
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
return yield* storeError("CheckpointStore.renewLease")(result.failure);
|
|
207
|
+
});
|
|
208
|
+
const releaseLease = (feed, owner) => client
|
|
209
|
+
.deleteItem({
|
|
210
|
+
TableName,
|
|
211
|
+
Key: leaseKey(feed),
|
|
212
|
+
ConditionExpression: "#owner = :owner",
|
|
213
|
+
ExpressionAttributeNames: { "#owner": "owner" },
|
|
214
|
+
ExpressionAttributeValues: { ":owner": { S: owner } },
|
|
215
|
+
})
|
|
216
|
+
.pipe(Effect.asVoid, Effect.catchIf(isConditionFailed, () => Effect.void), Effect.mapError(storeError("CheckpointStore.releaseLease")));
|
|
217
|
+
return { load, commit, acquireLease, renewLease, releaseLease };
|
|
218
|
+
});
|
|
219
|
+
};
|
|
220
|
+
/**
|
|
221
|
+
* Effect `Context.Service` for the change feed's checkpoint store.
|
|
222
|
+
*
|
|
223
|
+
* @example
|
|
224
|
+
* ```typescript
|
|
225
|
+
* import { CheckpointStore } from "effect-dynamodb/change-feed"
|
|
226
|
+
*
|
|
227
|
+
* // In memory (tests, or a feed that may start over)
|
|
228
|
+
* const Memory = CheckpointStore.layerMemory
|
|
229
|
+
* // In a DynamoDB table (needs DynamoClient)
|
|
230
|
+
* const Durable = CheckpointStore.layerDynamoDB({ tableName: "change-feed-checkpoints" })
|
|
231
|
+
* ```
|
|
232
|
+
*/
|
|
233
|
+
export class CheckpointStore extends Context.Service()("@effect-dynamodb/CheckpointStore") {
|
|
234
|
+
/** A fresh in-memory store per layer build; its lease is process-local. */
|
|
235
|
+
static layerMemory = Layer.sync(CheckpointStore, makeMemory);
|
|
236
|
+
/** The shortest `finishedTtl` accepted — see {@link MIN_FINISHED_TTL}. */
|
|
237
|
+
static minFinishedTtl = MIN_FINISHED_TTL;
|
|
238
|
+
/** A store on a DynamoDB table — see {@link tableDefinition}. */
|
|
239
|
+
static layerDynamoDB = (options) => Layer.effect(CheckpointStore, makeDynamoDB(options));
|
|
240
|
+
/** {@link tableDefinition}: the checkpoint table's `CreateTable` input. */
|
|
241
|
+
static tableDefinition = tableDefinition;
|
|
242
|
+
/** {@link makeMemory}: an in-memory store, as a value. */
|
|
243
|
+
static makeMemory = makeMemory;
|
|
244
|
+
/** {@link makeDynamoDB}: a DynamoDB-table store, as a value. */
|
|
245
|
+
static makeDynamoDB = makeDynamoDB;
|
|
246
|
+
}
|
|
247
|
+
//# sourceMappingURL=CheckpointStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CheckpointStore.js","sourceRoot":"","sources":["../../src/change-feed/CheckpointStore.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAA;AAC/E,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AACxE,OAAO,EAAE,YAAY,EAA0B,MAAM,oBAAoB,CAAA;AACzE,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAoD5F,8EAA8E;AAC9E,YAAY;AACZ,8EAA8E;AAE9E,kGAAkG;AAClG,MAAM,CAAC,MAAM,UAAU,GAAG,GAA2B,EAAE;IACrD,MAAM,WAAW,GAAG,IAAI,GAAG,EAAwC,CAAA;IACnE,MAAM,MAAM,GAAG,IAAI,GAAG,EAAgD,CAAA;IACtE,MAAM,KAAK,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,S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E,YAAY,CAAC,OAAO,CAAC,CAAC,CAAA;IAEtD,2EAA2E;IAC3E,MAAM,CAAU,eAAe,GAAG,eAAe,CAAA;IAEjD,0DAA0D;IAC1D,MAAM,CAAU,UAAU,GAAG,UAAU,CAAA;IAEvC,gEAAgE;IAChE,MAAM,CAAU,YAAY,GAAG,YAAY,CAAA"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DynamoStreamsClient — Effect service wrapping the AWS SDK
|
|
3
|
+
* `DynamoDBStreamsClient` (`@aws-sdk/client-dynamodb-streams`, an optional
|
|
4
|
+
* peer dependency of `effect-dynamodb`).
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import { type DescribeStreamCommandInput, type DescribeStreamCommandOutput, DynamoDBStreamsClient, type GetRecordsCommandInput, type GetRecordsCommandOutput, type GetShardIteratorCommandInput, type GetShardIteratorCommandOutput, type ListStreamsCommandInput, type ListStreamsCommandOutput } from "@aws-sdk/client-dynamodb-streams";
|
|
9
|
+
import { DynamoError, DynamoValidationError, InternalServerError, ResourceNotFoundError, ThrottlingError } from "@effect-dynamodb/schema/Errors.js";
|
|
10
|
+
import { Config, Context, Effect, Layer } from "effect";
|
|
11
|
+
import { ShardIteratorExpired, StreamDataTrimmed } from "./Errors.js";
|
|
12
|
+
/** What a {@link DynamoStreamsClient} operation fails with. */
|
|
13
|
+
export type DynamoStreamsClientError = DynamoError | ThrottlingError | DynamoValidationError | InternalServerError | ResourceNotFoundError | ShardIteratorExpired | StreamDataTrimmed;
|
|
14
|
+
/**
|
|
15
|
+
* The DynamoDB Streams operations, each wrapping one SDK command as an
|
|
16
|
+
* `Effect`.
|
|
17
|
+
*/
|
|
18
|
+
export interface DynamoStreamsClientService {
|
|
19
|
+
readonly describeStream: (input: DescribeStreamCommandInput) => Effect.Effect<DescribeStreamCommandOutput, DynamoStreamsClientError>;
|
|
20
|
+
readonly getShardIterator: (input: GetShardIteratorCommandInput) => Effect.Effect<GetShardIteratorCommandOutput, DynamoStreamsClientError>;
|
|
21
|
+
readonly getRecords: (input: GetRecordsCommandInput) => Effect.Effect<GetRecordsCommandOutput, DynamoStreamsClientError>;
|
|
22
|
+
readonly listStreams: (input: ListStreamsCommandInput) => Effect.Effect<ListStreamsCommandOutput, DynamoStreamsClientError>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Map an SDK failure to its tagged error. `LimitExceededException` (the
|
|
26
|
+
* Streams API's throttling) is a `ThrottlingError`, like DynamoDB's own.
|
|
27
|
+
*/
|
|
28
|
+
export declare const classifyStreamsError: (operation: string) => (cause: unknown) => DynamoStreamsClientError;
|
|
29
|
+
type Credentials = {
|
|
30
|
+
readonly accessKeyId: string;
|
|
31
|
+
readonly secretAccessKey: string;
|
|
32
|
+
};
|
|
33
|
+
/** Static client configuration accepted by {@link DynamoStreamsClient.layer}. */
|
|
34
|
+
export interface DynamoStreamsClientConfig {
|
|
35
|
+
readonly region: string;
|
|
36
|
+
/** Endpoint override — DynamoDB Local serves the Streams API on its own endpoint. */
|
|
37
|
+
readonly endpoint?: string | undefined;
|
|
38
|
+
readonly credentials?: Credentials | undefined;
|
|
39
|
+
}
|
|
40
|
+
/** Config-provider configuration accepted by {@link DynamoStreamsClient.layerConfig}. */
|
|
41
|
+
export interface DynamoStreamsClientConfigFromConfig {
|
|
42
|
+
readonly region: Config.Config<string>;
|
|
43
|
+
readonly endpoint?: Config.Config<string> | undefined;
|
|
44
|
+
readonly credentials?: Config.Config<Credentials> | undefined;
|
|
45
|
+
}
|
|
46
|
+
/** Wrap an SDK client as the service. */
|
|
47
|
+
export declare const fromSdkClient: (client: DynamoDBStreamsClient) => DynamoStreamsClientService;
|
|
48
|
+
declare const DynamoStreamsClient_base: Context.ServiceClass<DynamoStreamsClient, "@effect-dynamodb/DynamoStreamsClient", DynamoStreamsClientService>;
|
|
49
|
+
/**
|
|
50
|
+
* Effect `Context.Service` for the DynamoDB Streams client.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* import { DynamoStreamsClient } from "effect-dynamodb/change-feed"
|
|
55
|
+
*
|
|
56
|
+
* const StreamsLive = DynamoStreamsClient.layer({ region: "us-east-1" })
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare class DynamoStreamsClient extends DynamoStreamsClient_base {
|
|
60
|
+
/**
|
|
61
|
+
* A live layer managing a `DynamoDBStreamsClient` — created when the layer
|
|
62
|
+
* is built, destroyed when its scope closes.
|
|
63
|
+
*/
|
|
64
|
+
static readonly layer: (config: DynamoStreamsClientConfig) => Layer.Layer<DynamoStreamsClient>;
|
|
65
|
+
/** A layer over an SDK client you construct and own (custom configuration). */
|
|
66
|
+
static readonly layerFromSdkClient: (client: DynamoDBStreamsClient) => Layer.Layer<DynamoStreamsClient>;
|
|
67
|
+
/** A live layer reading its configuration from Effect `Config` providers. */
|
|
68
|
+
static readonly layerConfig: (config: DynamoStreamsClientConfigFromConfig) => Layer.Layer<DynamoStreamsClient, Config.ConfigError>;
|
|
69
|
+
}
|
|
70
|
+
export {};
|
|
71
|
+
//# sourceMappingURL=DynamoStreamsClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DynamoStreamsClient.d.ts","sourceRoot":"","sources":["../../src/change-feed/DynamoStreamsClient.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAEL,KAAK,0BAA0B,EAC/B,KAAK,2BAA2B,EAChC,qBAAqB,EAErB,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAE5B,KAAK,4BAA4B,EACjC,KAAK,6BAA6B,EAElC,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,EAC9B,MAAM,kCAAkC,CAAA;AACzC,OAAO,EACL,WAAW,EACX,qBAAqB,EACrB,mBAAmB,EAKnB,qBAAqB,EACrB,eAAe,EAChB,MAAM,mCAAmC,CAAA;AAC1C,OAAO,EAAE,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AAE,WAAW,GAAG,SAAS,CAAA;CAC/C;AAED,yFAAyF;AACzF,MAAM,WAAW,mCAAmC;IAClD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IACtC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,SAAS,CAAA;IACrD,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,SAAS,CAAA;CAC9D;AAED,yCAAyC;AACzC,eAAO,MAAM,aAAa,GAAI,QAAQ,qBAAqB,KAAG,0BAqB5D,CAAA;;AAkBF;;;;;;;;;GASG;AACH,qBAAa,mBAAoB,SAAQ,wBAGE;IACzC;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,KAAK,GAAI,QAAQ,yBAAyB,KAAG,KAAK,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAI1F;IAEH,+EAA+E;IAC/E,MAAM,CAAC,QAAQ,CAAC,kBAAkB,GAChC,QAAQ,qBAAqB,KAC5B,KAAK,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAA6D;IAEhG,6EAA6E;IAC7E,MAAM,CAAC,QAAQ,CAAC,WAAW,GACzB,QAAQ,mCAAmC,KAC1C,KAAK,CAAC,KAAK,CAAC,mBAAmB,EAAE,MAAM,CAAC,WAAW,CAAC,CAepD;CACJ"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DynamoStreamsClient — Effect service wrapping the AWS SDK
|
|
3
|
+
* `DynamoDBStreamsClient` (`@aws-sdk/client-dynamodb-streams`, an optional
|
|
4
|
+
* peer dependency of `effect-dynamodb`).
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import { DescribeStreamCommand, DynamoDBStreamsClient, GetRecordsCommand, GetShardIteratorCommand, ListStreamsCommand, } from "@aws-sdk/client-dynamodb-streams";
|
|
9
|
+
import { DynamoError, DynamoValidationError, InternalServerError, isAwsInternalServerError, isAwsResourceNotFound, isAwsThrottling, isAwsValidationError, ResourceNotFoundError, ThrottlingError, } from "@effect-dynamodb/schema/Errors.js";
|
|
10
|
+
import { Config, Context, Effect, Layer } from "effect";
|
|
11
|
+
import { ShardIteratorExpired, StreamDataTrimmed } from "./Errors.js";
|
|
12
|
+
const errorName = (cause) => typeof cause === "object" && cause !== null && "name" in cause
|
|
13
|
+
? String(cause.name)
|
|
14
|
+
: undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Map an SDK failure to its tagged error. `LimitExceededException` (the
|
|
17
|
+
* Streams API's throttling) is a `ThrottlingError`, like DynamoDB's own.
|
|
18
|
+
*/
|
|
19
|
+
export const classifyStreamsError = (operation) => (cause) => {
|
|
20
|
+
const name = errorName(cause);
|
|
21
|
+
if (name === "ExpiredIteratorException")
|
|
22
|
+
return new ShardIteratorExpired({ operation, cause });
|
|
23
|
+
if (name === "TrimmedDataAccessException")
|
|
24
|
+
return new StreamDataTrimmed({ operation, cause });
|
|
25
|
+
if (name === "LimitExceededException" || isAwsThrottling(cause)) {
|
|
26
|
+
return new ThrottlingError({ operation, cause });
|
|
27
|
+
}
|
|
28
|
+
if (isAwsValidationError(cause))
|
|
29
|
+
return new DynamoValidationError({ operation, cause });
|
|
30
|
+
if (isAwsInternalServerError(cause))
|
|
31
|
+
return new InternalServerError({ operation, cause });
|
|
32
|
+
if (isAwsResourceNotFound(cause))
|
|
33
|
+
return new ResourceNotFoundError({ operation, cause });
|
|
34
|
+
return new DynamoError({ operation, cause });
|
|
35
|
+
};
|
|
36
|
+
/** Wrap an SDK client as the service. */
|
|
37
|
+
export const fromSdkClient = (client) => ({
|
|
38
|
+
describeStream: (input) => Effect.tryPromise({
|
|
39
|
+
try: () => client.send(new DescribeStreamCommand(input)),
|
|
40
|
+
catch: classifyStreamsError("DescribeStream"),
|
|
41
|
+
}),
|
|
42
|
+
getShardIterator: (input) => Effect.tryPromise({
|
|
43
|
+
try: () => client.send(new GetShardIteratorCommand(input)),
|
|
44
|
+
catch: classifyStreamsError("GetShardIterator"),
|
|
45
|
+
}),
|
|
46
|
+
getRecords: (input) => Effect.tryPromise({
|
|
47
|
+
try: () => client.send(new GetRecordsCommand(input)),
|
|
48
|
+
catch: classifyStreamsError("GetRecords"),
|
|
49
|
+
}),
|
|
50
|
+
listStreams: (input) => Effect.tryPromise({
|
|
51
|
+
try: () => client.send(new ListStreamsCommand(input)),
|
|
52
|
+
catch: classifyStreamsError("ListStreams"),
|
|
53
|
+
}),
|
|
54
|
+
});
|
|
55
|
+
const buildService = (region, endpoint, credentials) => Effect.gen(function* () {
|
|
56
|
+
const clientConfig = { region };
|
|
57
|
+
if (endpoint !== undefined)
|
|
58
|
+
clientConfig.endpoint = endpoint;
|
|
59
|
+
if (credentials !== undefined)
|
|
60
|
+
clientConfig.credentials = credentials;
|
|
61
|
+
const client = yield* Effect.acquireRelease(Effect.sync(() => new DynamoDBStreamsClient(clientConfig)), (c) => Effect.sync(() => c.destroy()));
|
|
62
|
+
return fromSdkClient(client);
|
|
63
|
+
});
|
|
64
|
+
/**
|
|
65
|
+
* Effect `Context.Service` for the DynamoDB Streams client.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* import { DynamoStreamsClient } from "effect-dynamodb/change-feed"
|
|
70
|
+
*
|
|
71
|
+
* const StreamsLive = DynamoStreamsClient.layer({ region: "us-east-1" })
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export class DynamoStreamsClient extends Context.Service()("@effect-dynamodb/DynamoStreamsClient") {
|
|
75
|
+
/**
|
|
76
|
+
* A live layer managing a `DynamoDBStreamsClient` — created when the layer
|
|
77
|
+
* is built, destroyed when its scope closes.
|
|
78
|
+
*/
|
|
79
|
+
static layer = (config) => Layer.effect(DynamoStreamsClient, buildService(config.region, config.endpoint, config.credentials));
|
|
80
|
+
/** A layer over an SDK client you construct and own (custom configuration). */
|
|
81
|
+
static layerFromSdkClient = (client) => Layer.succeed(DynamoStreamsClient, fromSdkClient(client));
|
|
82
|
+
/** A live layer reading its configuration from Effect `Config` providers. */
|
|
83
|
+
static layerConfig = (config) => Layer.effect(DynamoStreamsClient, Effect.gen(function* () {
|
|
84
|
+
const region = yield* config.region;
|
|
85
|
+
const endpoint = config.endpoint ? yield* Config.option(config.endpoint) : undefined;
|
|
86
|
+
const credentials = config.credentials
|
|
87
|
+
? yield* Config.option(config.credentials)
|
|
88
|
+
: undefined;
|
|
89
|
+
return yield* buildService(region, endpoint && endpoint._tag === "Some" ? endpoint.value : undefined, credentials && credentials._tag === "Some" ? credentials.value : undefined);
|
|
90
|
+
}));
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=DynamoStreamsClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DynamoStreamsClient.js","sourceRoot":"","sources":["../../src/change-feed/DynamoStreamsClient.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,qBAAqB,EAGrB,qBAAqB,EACrB,iBAAiB,EAGjB,uBAAuB,EAGvB,kBAAkB,GAGnB,MAAM,kCAAkC,CAAA;AACzC,OAAO,EACL,WAAW,EACX,qBAAqB,EACrB,mBAAmB,EACnB,wBAAwB,EACxB,qBAAqB,EACrB,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,GAChB,MAAM,mCAAmC,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AACvD,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AA+BrE,MAAM,SAAS,GAAG,CAAC,KAAc,EAAsB,EAAE,CACvD,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,MAAM,IAAI,KAAK;IAC5D,CAAC,CAAC,MAAM,CAAE,KAAo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,CAAA;QACb,OAAO,KAAK,CAAC,CAAC,YAAY,CACxB,MAAM,EACN,QAAQ,IAAI,QAAQ,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,EACjE,WAAW,IAAI,WAAW,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAC3E,CAAA;IACH,CAAC,CAAC,CACH,CAAA"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Errors of the `effect-dynamodb/change-feed` subpath.
|
|
3
|
+
*
|
|
4
|
+
* They are raised only by this subpath, so they live beside it rather than in
|
|
5
|
+
* the AWS-free `@effect-dynamodb/schema` package.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
declare const ShardIteratorExpired_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
10
|
+
readonly _tag: "ShardIteratorExpired";
|
|
11
|
+
} & Readonly<A>;
|
|
12
|
+
/**
|
|
13
|
+
* `GetRecords` was given a shard iterator older than 15 minutes
|
|
14
|
+
* (`ExpiredIteratorException`). The change feed re-acquires one from the
|
|
15
|
+
* shard's position; a direct caller of {@link DynamoStreamsClient} sees it.
|
|
16
|
+
*/
|
|
17
|
+
export declare class ShardIteratorExpired extends ShardIteratorExpired_base<{
|
|
18
|
+
readonly operation: string;
|
|
19
|
+
readonly cause: unknown;
|
|
20
|
+
}> {
|
|
21
|
+
}
|
|
22
|
+
declare const StreamDataTrimmed_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
23
|
+
readonly _tag: "StreamDataTrimmed";
|
|
24
|
+
} & Readonly<A>;
|
|
25
|
+
/**
|
|
26
|
+
* The requested position is older than the stream's 24-hour retention
|
|
27
|
+
* (`TrimmedDataAccessException`): records between it and the trim horizon were
|
|
28
|
+
* lost. The change feed raises it as {@link ChangeFeedTrimmed}.
|
|
29
|
+
*/
|
|
30
|
+
export declare class StreamDataTrimmed extends StreamDataTrimmed_base<{
|
|
31
|
+
readonly operation: string;
|
|
32
|
+
readonly cause: unknown;
|
|
33
|
+
}> {
|
|
34
|
+
}
|
|
35
|
+
declare const ChangeFeedTrimmed_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
36
|
+
readonly _tag: "ChangeFeedTrimmed";
|
|
37
|
+
} & Readonly<A>;
|
|
38
|
+
/**
|
|
39
|
+
* A shard's position is past the stream's retention: the records between the
|
|
40
|
+
* checkpoint and the trim horizon were lost. Rebuild what the feed maintains,
|
|
41
|
+
* then clear the consumer's checkpoints to start over.
|
|
42
|
+
*/
|
|
43
|
+
export declare class ChangeFeedTrimmed extends ChangeFeedTrimmed_base<{
|
|
44
|
+
readonly streamArn: string;
|
|
45
|
+
readonly shardId: string;
|
|
46
|
+
/** The last acknowledged sequence number — `undefined` before any. */
|
|
47
|
+
readonly sequenceNumber: string | undefined;
|
|
48
|
+
readonly cause: unknown;
|
|
49
|
+
}> {
|
|
50
|
+
}
|
|
51
|
+
declare const ChangeFeedLeaseHeld_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
52
|
+
readonly _tag: "ChangeFeedLeaseHeld";
|
|
53
|
+
} & Readonly<A>;
|
|
54
|
+
/** Another process holds the feed's lease. */
|
|
55
|
+
export declare class ChangeFeedLeaseHeld extends ChangeFeedLeaseHeld_base<{
|
|
56
|
+
readonly streamArn: string;
|
|
57
|
+
readonly consumer: string;
|
|
58
|
+
/** The holder's owner id — `undefined` when it could not be read. */
|
|
59
|
+
readonly owner: string | undefined;
|
|
60
|
+
/** When the holder's lease expires (epoch ms) — `undefined` when unknown. */
|
|
61
|
+
readonly expiresAt: number | undefined;
|
|
62
|
+
}> {
|
|
63
|
+
}
|
|
64
|
+
declare const ChangeFeedLeaseLost_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
65
|
+
readonly _tag: "ChangeFeedLeaseLost";
|
|
66
|
+
} & Readonly<A>;
|
|
67
|
+
/** The feed's lease was taken over by another process while this one ran. */
|
|
68
|
+
export declare class ChangeFeedLeaseLost extends ChangeFeedLeaseLost_base<{
|
|
69
|
+
readonly streamArn: string;
|
|
70
|
+
readonly consumer: string;
|
|
71
|
+
readonly owner: string;
|
|
72
|
+
}> {
|
|
73
|
+
}
|
|
74
|
+
declare const CheckpointStoreError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
75
|
+
readonly _tag: "CheckpointStoreError";
|
|
76
|
+
} & Readonly<A>;
|
|
77
|
+
/** A checkpoint store operation failed. */
|
|
78
|
+
export declare class CheckpointStoreError extends CheckpointStoreError_base<{
|
|
79
|
+
readonly operation: string;
|
|
80
|
+
readonly cause: unknown;
|
|
81
|
+
}> {
|
|
82
|
+
}
|
|
83
|
+
export {};
|
|
84
|
+
//# sourceMappingURL=Errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Errors.d.ts","sourceRoot":"","sources":["../../src/change-feed/Errors.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;;;;AAIH;;;;GAIG;AACH,qBAAa,oBAAqB,SAAQ,0BAAyC;IACjF,QAAQ,CAAC,SAAS,EAAE,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**
|
|
2
|
+
* Errors of the `effect-dynamodb/change-feed` subpath.
|
|
3
|
+
*
|
|
4
|
+
* They are raised only by this subpath, so they live beside it rather than in
|
|
5
|
+
* the AWS-free `@effect-dynamodb/schema` package.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import { Data } from "effect";
|
|
10
|
+
/**
|
|
11
|
+
* `GetRecords` was given a shard iterator older than 15 minutes
|
|
12
|
+
* (`ExpiredIteratorException`). The change feed re-acquires one from the
|
|
13
|
+
* shard's position; a direct caller of {@link DynamoStreamsClient} sees it.
|
|
14
|
+
*/
|
|
15
|
+
export class ShardIteratorExpired extends Data.TaggedError("ShardIteratorExpired") {
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The requested position is older than the stream's 24-hour retention
|
|
19
|
+
* (`TrimmedDataAccessException`): records between it and the trim horizon were
|
|
20
|
+
* lost. The change feed raises it as {@link ChangeFeedTrimmed}.
|
|
21
|
+
*/
|
|
22
|
+
export class StreamDataTrimmed extends Data.TaggedError("StreamDataTrimmed") {
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* A shard's position is past the stream's retention: the records between the
|
|
26
|
+
* checkpoint and the trim horizon were lost. Rebuild what the feed maintains,
|
|
27
|
+
* then clear the consumer's checkpoints to start over.
|
|
28
|
+
*/
|
|
29
|
+
export class ChangeFeedTrimmed extends Data.TaggedError("ChangeFeedTrimmed") {
|
|
30
|
+
}
|
|
31
|
+
/** Another process holds the feed's lease. */
|
|
32
|
+
export class ChangeFeedLeaseHeld extends Data.TaggedError("ChangeFeedLeaseHeld") {
|
|
33
|
+
}
|
|
34
|
+
/** The feed's lease was taken over by another process while this one ran. */
|
|
35
|
+
export class ChangeFeedLeaseLost extends Data.TaggedError("ChangeFeedLeaseLost") {
|
|
36
|
+
}
|
|
37
|
+
/** A checkpoint store operation failed. */
|
|
38
|
+
export class CheckpointStoreError extends Data.TaggedError("CheckpointStoreError") {
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=Errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Errors.js","sourceRoot":"","sources":["../../src/change-feed/Errors.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAE7B;;;;GAIG;AACH,MAAM,OAAO,oBAAqB,SAAQ,IAAI,CAAC,WAAW,CAAC,sBAAsB,CAG/E;CAAG;AAEL;;;;GAIG;AACH,MAAM,OAAO,iBAAkB,SAAQ,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAGzE;CAAG;AAEL;;;;GAIG;AACH,MAAM,OAAO,iBAAkB,SAAQ,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAMzE;CAAG;AAEL,8CAA8C;AAC9C,MAAM,OAAO,mBAAoB,SAAQ,IAAI,CAAC,WAAW,CAAC,qBAAqB,CAO7E;CAAG;AAEL,6EAA6E;AAC7E,MAAM,OAAO,mBAAoB,SAAQ,IAAI,CAAC,WAAW,CAAC,qBAAqB,CAI7E;CAAG;AAEL,2CAA2C;AAC3C,MAAM,OAAO,oBAAqB,SAAQ,IAAI,CAAC,WAAW,CAAC,sBAAsB,CAG/E;CAAG"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `effect-dynamodb/change-feed` — a polled change feed over DynamoDB Streams,
|
|
3
|
+
* for consumers outside Lambda and EventBridge Pipes: a long-running service,
|
|
4
|
+
* a container, an edge device running DynamoDB Local.
|
|
5
|
+
*
|
|
6
|
+
* Needs `@aws-sdk/client-dynamodb-streams` (an optional peer dependency); the
|
|
7
|
+
* main `effect-dynamodb` entry never imports it.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { DynamoClient, EventStore } from "effect-dynamodb"
|
|
12
|
+
* import {
|
|
13
|
+
* CheckpointStore,
|
|
14
|
+
* changeFeed,
|
|
15
|
+
* DynamoStreamsClient,
|
|
16
|
+
* runChangeFeed,
|
|
17
|
+
* } from "effect-dynamodb/change-feed"
|
|
18
|
+
*
|
|
19
|
+
* const program = runChangeFeed(changeFeed({ streamArn }), {
|
|
20
|
+
* projections: { summaries: OrderSummaryProjection },
|
|
21
|
+
* })
|
|
22
|
+
*
|
|
23
|
+
* program.pipe(
|
|
24
|
+
* Effect.provide(CheckpointStore.layerDynamoDB({ tableName: "checkpoints" })),
|
|
25
|
+
* Effect.provide(DynamoStreamsClient.layer({ region: "us-east-1" })),
|
|
26
|
+
* Effect.provide(DynamoClient.layer({ region: "us-east-1" })),
|
|
27
|
+
* )
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @module
|
|
31
|
+
*/
|
|
32
|
+
export { type ChangeFeedBatch, type ChangeFeedError, type ChangeFeedLeaseOptions, type ChangeFeedOptions, type ChangeFeedRecord, changeFeed, type RunChangeFeedOptions, runChangeFeed, type StartingPosition, } from "./ChangeFeed.js";
|
|
33
|
+
export { CheckpointStore, type CheckpointStoreService, type DynamoDBCheckpointStoreOptions, type FeedId, type ShardCheckpoint, } from "./CheckpointStore.js";
|
|
34
|
+
export { DynamoStreamsClient, type DynamoStreamsClientConfig, type DynamoStreamsClientConfigFromConfig, type DynamoStreamsClientError, type DynamoStreamsClientService, } from "./DynamoStreamsClient.js";
|
|
35
|
+
export { ChangeFeedLeaseHeld, ChangeFeedLeaseLost, ChangeFeedTrimmed, CheckpointStoreError, ShardIteratorExpired, StreamDataTrimmed, } from "./Errors.js";
|
|
36
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/change-feed/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,UAAU,EACV,KAAK,oBAAoB,EACzB,aAAa,EACb,KAAK,gBAAgB,GACtB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,eAAe,EACf,KAAK,sBAAsB,EAC3B,KAAK,8BAA8B,EACnC,KAAK,MAAM,EACX,KAAK,eAAe,GACrB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACL,mBAAmB,EACnB,KAAK,yBAAyB,EAC9B,KAAK,mCAAmC,EACxC,KAAK,wBAAwB,EAC7B,KAAK,0BAA0B,GAChC,MAAM,0BAA0B,CAAA;AACjC,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,aAAa,CAAA"}
|