@effect-agent/storage-cloudflare 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/do-ledger.ts +24 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect-agent/storage-cloudflare",
|
|
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-browser": "4.0.0-beta.107",
|
|
13
13
|
"@effect/sql-sqlite-do": "4.0.0-beta.107",
|
|
14
14
|
"effect": "4.0.0-beta.107"
|
package/src/do-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,
|
|
@@ -1593,6 +1594,27 @@ const makeServices = Effect.fn("DoSubmissionLedger.makeServices")(function* () {
|
|
|
1593
1594
|
existingOutcome: reservation.value.outcome,
|
|
1594
1595
|
});
|
|
1595
1596
|
}
|
|
1597
|
+
const reservationRecord = yield* decodeRecordEnvelopeText(
|
|
1598
|
+
reservation.value.record_json,
|
|
1599
|
+
).pipe(
|
|
1600
|
+
Effect.mapError((error) =>
|
|
1601
|
+
corruptionFailure(
|
|
1602
|
+
operation,
|
|
1603
|
+
"effect_agent_settlement_reservations",
|
|
1604
|
+
validated.submissionId,
|
|
1605
|
+
error.message,
|
|
1606
|
+
),
|
|
1607
|
+
),
|
|
1608
|
+
);
|
|
1609
|
+
const settlementFailure = settlementFailureFromRecord(reservationRecord);
|
|
1610
|
+
if ((reservation.value.outcome === "failed") !== (settlementFailure !== undefined)) {
|
|
1611
|
+
return yield* corruptionFailure(
|
|
1612
|
+
operation,
|
|
1613
|
+
"effect_agent_settlement_reservations",
|
|
1614
|
+
validated.submissionId,
|
|
1615
|
+
"The reserved outcome and canonical failure diagnostic disagree.",
|
|
1616
|
+
);
|
|
1617
|
+
}
|
|
1596
1618
|
const submission = yield* requireSubmission(operation, validated.submissionId);
|
|
1597
1619
|
if (submission.state === "settled") {
|
|
1598
1620
|
if (reservation.value.finalized_at === null) {
|
|
@@ -1608,6 +1630,7 @@ const makeServices = Effect.fn("DoSubmissionLedger.makeServices")(function* () {
|
|
|
1608
1630
|
settlementId: validated.settlementId,
|
|
1609
1631
|
receiptId: submission.receipt_id,
|
|
1610
1632
|
outcome: reservation.value.outcome,
|
|
1633
|
+
...(settlementFailure === undefined ? {} : { failure: settlementFailure }),
|
|
1611
1634
|
settledAt: reservation.value.finalized_at,
|
|
1612
1635
|
}).pipe(Effect.mapError(internalFailure(operation)));
|
|
1613
1636
|
}
|
|
@@ -1631,6 +1654,7 @@ const makeServices = Effect.fn("DoSubmissionLedger.makeServices")(function* () {
|
|
|
1631
1654
|
settlementId: validated.settlementId,
|
|
1632
1655
|
receiptId: submission.receipt_id,
|
|
1633
1656
|
outcome: reservation.value.outcome,
|
|
1657
|
+
...(settlementFailure === undefined ? {} : { failure: settlementFailure }),
|
|
1634
1658
|
settledAt: now.iso,
|
|
1635
1659
|
}).pipe(Effect.mapError(internalFailure(operation)));
|
|
1636
1660
|
}),
|