@effect-agent/storage-sqlite 0.1.0-beta.18 → 0.1.0-beta.19
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/index.mjs +5 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/sqlite-ledger.ts +24 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect-agent/storage-sqlite",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.19",
|
|
4
4
|
"exports": {
|
|
5
5
|
".": {
|
|
6
6
|
"types": "./dist/index.d.mts",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
}
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@effect-agent/session": "0.1.0-beta.
|
|
11
|
+
"@effect-agent/session": "0.1.0-beta.19",
|
|
12
12
|
"@effect/platform-node": "4.0.0-beta.107",
|
|
13
13
|
"@effect/sql-sqlite-node": "4.0.0-beta.107",
|
|
14
14
|
"effect": "4.0.0-beta.107"
|
package/src/sqlite-ledger.ts
CHANGED
|
@@ -62,6 +62,7 @@ import {
|
|
|
62
62
|
SubmissionSnapshot,
|
|
63
63
|
SubmissionState,
|
|
64
64
|
SettlementReservationSnapshot,
|
|
65
|
+
settlementFailureFromRecord,
|
|
65
66
|
SuspendRequest,
|
|
66
67
|
SuspensionReason,
|
|
67
68
|
SuspensionSnapshot,
|
|
@@ -1523,6 +1524,27 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
1523
1524
|
existingOutcome: reservation.value.outcome,
|
|
1524
1525
|
});
|
|
1525
1526
|
}
|
|
1527
|
+
const reservationRecord = yield* decodeRecordEnvelopeText(
|
|
1528
|
+
reservation.value.record_json,
|
|
1529
|
+
).pipe(
|
|
1530
|
+
Effect.mapError((error) =>
|
|
1531
|
+
corruptionFailure(
|
|
1532
|
+
operation,
|
|
1533
|
+
"effect_agent_settlement_reservations",
|
|
1534
|
+
validated.submissionId,
|
|
1535
|
+
error.message,
|
|
1536
|
+
),
|
|
1537
|
+
),
|
|
1538
|
+
);
|
|
1539
|
+
const settlementFailure = settlementFailureFromRecord(reservationRecord);
|
|
1540
|
+
if ((reservation.value.outcome === "failed") !== (settlementFailure !== undefined)) {
|
|
1541
|
+
return yield* corruptionFailure(
|
|
1542
|
+
operation,
|
|
1543
|
+
"effect_agent_settlement_reservations",
|
|
1544
|
+
validated.submissionId,
|
|
1545
|
+
"The reserved outcome and canonical failure diagnostic disagree.",
|
|
1546
|
+
);
|
|
1547
|
+
}
|
|
1526
1548
|
const submission = yield* requireSubmission(operation, validated.submissionId);
|
|
1527
1549
|
if (submission.state === "settled") {
|
|
1528
1550
|
if (reservation.value.finalized_at === null) {
|
|
@@ -1538,6 +1560,7 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
1538
1560
|
settlementId: validated.settlementId,
|
|
1539
1561
|
receiptId: submission.receipt_id,
|
|
1540
1562
|
outcome: reservation.value.outcome,
|
|
1563
|
+
...(settlementFailure === undefined ? {} : { failure: settlementFailure }),
|
|
1541
1564
|
settledAt: reservation.value.finalized_at,
|
|
1542
1565
|
}).pipe(Effect.mapError(internalFailure(operation)));
|
|
1543
1566
|
}
|
|
@@ -1561,6 +1584,7 @@ const makeServices = Effect.fn("SqliteSubmissionLedger.makeServices")(function*
|
|
|
1561
1584
|
settlementId: validated.settlementId,
|
|
1562
1585
|
receiptId: submission.receipt_id,
|
|
1563
1586
|
outcome: reservation.value.outcome,
|
|
1587
|
+
...(settlementFailure === undefined ? {} : { failure: settlementFailure }),
|
|
1564
1588
|
settledAt: now.iso,
|
|
1565
1589
|
}).pipe(Effect.mapError(internalFailure(operation)));
|
|
1566
1590
|
}),
|