@effect-agent/storage-cloudflare 0.1.0-beta.48 → 0.1.0-beta.50
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/DoSubmissionLedger.mjs +47 -2
- package/dist/DoSubmissionLedger.mjs.map +1 -1
- package/dist/DoSubscriptionStore.mjs +6 -566
- package/dist/DoSubscriptionStore.mjs.map +1 -1
- package/dist/PortProtocol.d.mts +8 -4
- package/dist/PortRouting.mjs +1 -0
- package/dist/PortRouting.mjs.map +1 -1
- package/package.json +1 -1
- package/src/DoSubmissionLedger.ts +82 -0
- package/src/DoSubscriptionStore.ts +13 -1005
- package/src/PortRouting.ts +9 -0
|
@@ -8,7 +8,7 @@ import { Clock, Context, Crypto, DateTime, Effect, Layer, Option, Schema, Stream
|
|
|
8
8
|
import * as SqlClientService from "effect/unstable/sql/SqlClient";
|
|
9
9
|
import { ApprovalDecision, CanonicalSequence, DefinitionDigests, Digest, PersistedJson, ProducerEpoch, RecordEnvelope, SettlementOutcome } from "@effect-agent/thread/Records";
|
|
10
10
|
import { EMPTY_TAIL_DIGEST } from "@effect-agent/thread/Digest";
|
|
11
|
-
import { AbortCommand, AbortIntent, AdmissionAdmitted, AdmissionConflict, AdmissionNotAdmitted, AdmissionRequest, AdmissionResult, ApprovalConflict, ApprovalDecisionCommand, ApprovalDecisionIntent, AttachChildToReservationRequest, BeginChildBudgetReleaseRequest, ChildAttachmentSnapshot, ChildBudgetReservationRequest, ChildBudgetReservationSnapshot, ChildReservationConflict, ChildReservationStatus, ChildSettledNotification, Claim, ClaimJoiningRequest, ClaimRequest, InputAppliedMarker, JoinSnapshot, JoinedToHost, JoiningClaim, LedgerCapabilities, LedgerError, MarkInputAppliedRequest, MarkJoinedRequest, MarkReadyRequest, MarkUnknownRequest, OwnershipLost, OwnershipRenewal, OwnershipSnapshot, ParentLinkage, QueueSequence, RecoverySnapshot, RecoverySnapshotRequest, ReleaseChildBudgetRequest, ReleaseOwnershipRequest, RenewOwnershipRequest, ReservedChildBudget, ReservedSettlement, RevertJoiningRequest, Settlement, SettlementConflict, SettlementFinalization, SettlementReservation, SettlementReservationSnapshot, SubmissionLedger, SubmissionLookup, SubmissionLookupByKey, SubmissionSnapshot, SubmissionState, SuspendRequest, SuspensionReason, SuspensionSnapshot, UnknownResolution, UnknownResolutionCommand, UnknownResolutionConflict, UnknownResolutionIntent, settlementFailureFromRecord, submissionAbortRecordId } from "@effect-agent/thread/SubmissionLedger";
|
|
11
|
+
import { AbortCommand, AbortIntent, AbortIntentRequest, AdmissionAdmitted, AdmissionConflict, AdmissionNotAdmitted, AdmissionRequest, AdmissionResult, ApprovalConflict, ApprovalDecisionCommand, ApprovalDecisionIntent, AttachChildToReservationRequest, BeginChildBudgetReleaseRequest, ChildAttachmentSnapshot, ChildBudgetReservationRequest, ChildBudgetReservationSnapshot, ChildReservationConflict, ChildReservationStatus, ChildSettledNotification, Claim, ClaimJoiningRequest, ClaimRequest, InputAppliedMarker, JoinSnapshot, JoinedToHost, JoiningClaim, LedgerCapabilities, LedgerError, MarkInputAppliedRequest, MarkJoinedRequest, MarkReadyRequest, MarkUnknownRequest, OwnershipLost, OwnershipRenewal, OwnershipSnapshot, ParentLinkage, QueueSequence, RecoverySnapshot, RecoverySnapshotRequest, ReleaseChildBudgetRequest, ReleaseOwnershipRequest, RenewOwnershipRequest, ReservedChildBudget, ReservedSettlement, RevertJoiningRequest, Settlement, SettlementConflict, SettlementFinalization, SettlementReservation, SettlementReservationSnapshot, SubmissionLedger, SubmissionLookup, SubmissionLookupByKey, SubmissionSnapshot, SubmissionState, SuspendRequest, SuspensionReason, SuspensionSnapshot, UnknownResolution, UnknownResolutionCommand, UnknownResolutionConflict, UnknownResolutionIntent, settlementFailureFromRecord, submissionAbortRecordId } from "@effect-agent/thread/SubmissionLedger";
|
|
12
12
|
import { BrowserCrypto } from "@effect/platform-browser";
|
|
13
13
|
//#region src/DoSubmissionLedger.ts
|
|
14
14
|
var DoSubmissionLedger_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -117,6 +117,14 @@ var AbortIntentRow = class extends Schema.Class("AbortIntentRow")({
|
|
|
117
117
|
canonical_record_id: Schema.NullOr(BoundedIdentifier)
|
|
118
118
|
}) {};
|
|
119
119
|
var MaxQueueSequenceRow = class extends Schema.Class("MaxQueueSequenceRow")({ max_queue_sequence: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)) }) {};
|
|
120
|
+
var AbortIntentLookupRow = class extends Schema.Class("AbortIntentLookupRow")({
|
|
121
|
+
submission_id: BoundedIdentifier,
|
|
122
|
+
abort_submission_id: Schema.NullOr(BoundedIdentifier),
|
|
123
|
+
author: Schema.NullOr(BoundedIdentifier),
|
|
124
|
+
reason: Schema.NullOr(BoundedStoredText),
|
|
125
|
+
requested_at: Schema.NullOr(BoundedTimestamp),
|
|
126
|
+
canonical_record_id: Schema.NullOr(BoundedIdentifier)
|
|
127
|
+
}) {};
|
|
120
128
|
var CanonicalRecordIdRow = class extends Schema.Class("CanonicalRecordIdRow")({ record_id: BoundedIdentifier }) {};
|
|
121
129
|
const SUBMISSION_COLUMNS = `
|
|
122
130
|
submission_id,
|
|
@@ -1555,6 +1563,42 @@ const makeServices = Effect.fn("DoSubmissionLedger.makeServices")(function* () {
|
|
|
1555
1563
|
})];
|
|
1556
1564
|
});
|
|
1557
1565
|
const scanNonterminal = Stream.paginate(void 0, scanPage);
|
|
1566
|
+
const readAbortIntentForSubmission = Effect.fn("DoSubmissionLedger.readAbortIntentForSubmission")(function* (request) {
|
|
1567
|
+
const operation = "ledger read abort intent";
|
|
1568
|
+
const validated = yield* Schema.decodeUnknownEffect(Schema.toType(AbortIntentRequest))(request).pipe(Effect.mapError(internalFailure(operation)));
|
|
1569
|
+
const recordId = submissionAbortRecordId(validated.submissionId);
|
|
1570
|
+
const rows = yield* sql`
|
|
1571
|
+
SELECT
|
|
1572
|
+
submission.submission_id,
|
|
1573
|
+
abort.submission_id AS abort_submission_id,
|
|
1574
|
+
abort.author,
|
|
1575
|
+
abort.reason,
|
|
1576
|
+
abort.requested_at,
|
|
1577
|
+
canonical.record_id AS canonical_record_id
|
|
1578
|
+
FROM effect_agent_submissions AS submission
|
|
1579
|
+
LEFT JOIN effect_agent_abort_intents AS abort
|
|
1580
|
+
ON abort.submission_id = submission.submission_id
|
|
1581
|
+
LEFT JOIN effect_agent_canonical_records AS canonical
|
|
1582
|
+
ON canonical.thread_id = submission.thread_id
|
|
1583
|
+
AND canonical.record_id = ${recordId}
|
|
1584
|
+
WHERE submission.submission_id = ${validated.submissionId}
|
|
1585
|
+
`.pipe(Effect.mapError(sqlFailure(operation)));
|
|
1586
|
+
const decoded = yield* decodeRows(Schema.Array(AbortIntentLookupRow), "effect_agent_abort_intents", validated.submissionId, rows).pipe(Effect.mapError(internalFailure(operation)));
|
|
1587
|
+
if (decoded.length === 0) return yield* LedgerError.make({
|
|
1588
|
+
operation,
|
|
1589
|
+
message: `Unknown submission ${validated.submissionId}.`
|
|
1590
|
+
});
|
|
1591
|
+
if (decoded.length !== 1) return yield* corruptionFailure(operation, "effect_agent_abort_intents", validated.submissionId, "An abort intent lookup returned more than one row.");
|
|
1592
|
+
const row = decoded[0];
|
|
1593
|
+
if (row.abort_submission_id === null) return void 0;
|
|
1594
|
+
return yield* decodeAbortIntent({
|
|
1595
|
+
submissionId: row.abort_submission_id,
|
|
1596
|
+
author: row.author,
|
|
1597
|
+
reason: row.reason,
|
|
1598
|
+
requestedAt: row.requested_at,
|
|
1599
|
+
...row.canonical_record_id === null ? {} : { canonicalRecordId: row.canonical_record_id }
|
|
1600
|
+
}).pipe(Effect.mapError((error) => corruptionFailure(operation, "effect_agent_abort_intents", validated.submissionId, error.message)));
|
|
1601
|
+
});
|
|
1558
1602
|
const loadRecoverySnapshot = Effect.fn("DoSubmissionLedger.loadRecoverySnapshot")(function* (request) {
|
|
1559
1603
|
const operation = "ledger load recovery snapshot";
|
|
1560
1604
|
const validated = yield* Schema.decodeUnknownEffect(Schema.toType(RecoverySnapshotRequest))(request).pipe(Effect.mapError(internalFailure(operation)));
|
|
@@ -1696,7 +1740,8 @@ const makeServices = Effect.fn("DoSubmissionLedger.makeServices")(function* () {
|
|
|
1696
1740
|
beginChildBudgetRelease,
|
|
1697
1741
|
releaseChildBudget,
|
|
1698
1742
|
scanNonterminal,
|
|
1699
|
-
loadRecoverySnapshot
|
|
1743
|
+
loadRecoverySnapshot,
|
|
1744
|
+
readAbortIntent: readAbortIntentForSubmission
|
|
1700
1745
|
}));
|
|
1701
1746
|
});
|
|
1702
1747
|
/**
|