@effect-agent/storage-cloudflare 0.1.0-beta.84 → 0.1.0-beta.86
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/DoMemoryStore.d.mts +3 -3
- package/dist/DoMemoryStore.mjs +3 -3
- package/dist/DoMemoryStore.mjs.map +1 -1
- package/dist/DoMessageDeliveryStore.d.mts +1 -1
- package/dist/DoMessageDeliveryStore.mjs +3 -3
- package/dist/DoMessageDeliveryStore.mjs.map +1 -1
- package/dist/DoScheduleStore.d.mts +1 -1
- package/dist/DoScheduleStore.mjs +5 -5
- package/dist/DoScheduleStore.mjs.map +1 -1
- package/dist/DoStorageError.mjs +1 -1
- package/dist/DoStorageError.mjs.map +1 -1
- package/dist/DoSubmissionLedger.d.mts +1 -1
- package/dist/DoSubmissionLedger.mjs +35 -35
- package/dist/DoSubmissionLedger.mjs.map +1 -1
- package/dist/DoSubscriptionStore.d.mts +1 -1
- package/dist/DoSubscriptionStore.mjs +4 -4
- package/dist/DoSubscriptionStore.mjs.map +1 -1
- package/dist/DoThreadStore.d.mts +2 -2
- package/dist/DoThreadStore.mjs +26 -26
- package/dist/DoThreadStore.mjs.map +1 -1
- package/dist/MemoryProtocol.d.mts +272 -272
- package/dist/MemoryProtocol.mjs +8 -8
- package/dist/MemoryProtocol.mjs.map +1 -1
- package/dist/PortProtocol.d.mts +645 -48
- package/dist/PortProtocol.mjs +3 -3
- package/dist/PortProtocol.mjs.map +1 -1
- package/dist/PortRouting.d.mts +2 -2
- package/dist/PortRouting.mjs +2 -2
- package/dist/PortRouting.mjs.map +1 -1
- package/dist/{do-journal-DHqCQeBU.mjs → do-journal-dJ01KSKf.mjs} +7 -7
- package/dist/do-journal-dJ01KSKf.mjs.map +1 -0
- package/package.json +1 -1
- package/src/DoMemoryStore.ts +3 -6
- package/src/DoMessageDeliveryStore.ts +3 -3
- package/src/DoScheduleStore.ts +6 -6
- package/src/DoStorageError.ts +1 -1
- package/src/DoSubmissionLedger.ts +67 -67
- package/src/DoSubscriptionStore.ts +6 -6
- package/src/DoThreadStore.ts +51 -53
- package/src/MemoryProtocol.ts +9 -13
- package/src/PortProtocol.ts +4 -4
- package/src/PortRouting.ts +3 -3
- package/src/internal/do-journal.ts +8 -8
- package/dist/do-journal-DHqCQeBU.mjs.map +0 -1
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { BrowserCrypto } from "@effect/platform-browser";
|
|
2
|
+
import { SqliteClient } from "@effect/sql-sqlite-do";
|
|
3
|
+
import { Clock, Context, Crypto, DateTime, Effect, Layer, Option, Schema, Stream } from "effect";
|
|
4
|
+
import { EMPTY_TAIL_DIGEST } from "effect-agent/digest";
|
|
5
|
+
import { InputMessage } from "effect-agent/messaging";
|
|
3
6
|
import {
|
|
4
7
|
ApprovalDecision,
|
|
5
8
|
CanonicalSequence,
|
|
@@ -10,7 +13,7 @@ import {
|
|
|
10
13
|
ProducerEpoch,
|
|
11
14
|
RecordEnvelope,
|
|
12
15
|
SettlementOutcome,
|
|
13
|
-
} from "
|
|
16
|
+
} from "effect-agent/records";
|
|
14
17
|
import {
|
|
15
18
|
AbortCommand,
|
|
16
19
|
AbortIntent,
|
|
@@ -82,10 +85,7 @@ import {
|
|
|
82
85
|
submissionAbortRecordId,
|
|
83
86
|
type ChildSettledOutcome,
|
|
84
87
|
type SuspensionOutcome,
|
|
85
|
-
} from "
|
|
86
|
-
import { BrowserCrypto } from "@effect/platform-browser";
|
|
87
|
-
import { SqliteClient } from "@effect/sql-sqlite-do";
|
|
88
|
-
import { Clock, Context, Crypto, DateTime, Effect, Layer, Option, Schema, Stream } from "effect";
|
|
88
|
+
} from "effect-agent/submission-ledger";
|
|
89
89
|
import * as SqlClientService from "effect/unstable/sql/SqlClient";
|
|
90
90
|
import type { SqlError } from "effect/unstable/sql/SqlError";
|
|
91
91
|
|
|
@@ -516,9 +516,9 @@ const makeServices = Effect.fn("DoSubmissionLedger.makeServices")(function* () {
|
|
|
516
516
|
if (Option.isNone(ownership) || ownership.value.ownership_token !== ownershipToken) {
|
|
517
517
|
const actualEpoch = yield* threadEpoch(operation, submission.thread_id);
|
|
518
518
|
|
|
519
|
-
const submissionId = yield* Schema.
|
|
520
|
-
|
|
521
|
-
)
|
|
519
|
+
const submissionId = yield* Schema.decodeEffect(SubmissionSnapshot.fields.submissionId)(
|
|
520
|
+
submission.submission_id,
|
|
521
|
+
).pipe(Effect.mapError(internalFailure(operation)));
|
|
522
522
|
|
|
523
523
|
return yield* OwnershipLost.make({ submissionId, actualEpoch });
|
|
524
524
|
}
|
|
@@ -1041,9 +1041,9 @@ const makeServices = Effect.fn("DoSubmissionLedger.makeServices")(function* () {
|
|
|
1041
1041
|
function* (request: AdmissionRequest) {
|
|
1042
1042
|
const operation = "ledger admit";
|
|
1043
1043
|
|
|
1044
|
-
const validated = yield* Schema.
|
|
1045
|
-
|
|
1046
|
-
)
|
|
1044
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(AdmissionRequest))(request).pipe(
|
|
1045
|
+
Effect.mapError(internalFailure(operation)),
|
|
1046
|
+
);
|
|
1047
1047
|
|
|
1048
1048
|
const inputJson = yield* encodePersistedJsonText(validated.inputPayload).pipe(
|
|
1049
1049
|
Effect.mapError(internalFailure(operation)),
|
|
@@ -1075,7 +1075,7 @@ const makeServices = Effect.fn("DoSubmissionLedger.makeServices")(function* () {
|
|
|
1075
1075
|
const messageAdmissionJson =
|
|
1076
1076
|
validated.messageAdmission === undefined
|
|
1077
1077
|
? null
|
|
1078
|
-
: yield* Schema.encodeEffect(Schema.fromJsonString(
|
|
1078
|
+
: yield* Schema.encodeEffect(Schema.fromJsonString(InputMessage))(
|
|
1079
1079
|
validated.messageAdmission,
|
|
1080
1080
|
).pipe(Effect.mapError(internalFailure(operation)));
|
|
1081
1081
|
|
|
@@ -1161,10 +1161,10 @@ const makeServices = Effect.fn("DoSubmissionLedger.makeServices")(function* () {
|
|
|
1161
1161
|
existing[0].worker_admission_json,
|
|
1162
1162
|
).pipe(Effect.mapError(internalFailure(operation)));
|
|
1163
1163
|
|
|
1164
|
-
const
|
|
1164
|
+
const retainedInputMessage =
|
|
1165
1165
|
existing[0].message_admission_json === null
|
|
1166
1166
|
? undefined
|
|
1167
|
-
: yield* Schema.decodeEffect(Schema.fromJsonString(
|
|
1167
|
+
: yield* Schema.decodeEffect(Schema.fromJsonString(InputMessage))(
|
|
1168
1168
|
existing[0].message_admission_json,
|
|
1169
1169
|
).pipe(Effect.mapError(internalFailure(operation)));
|
|
1170
1170
|
|
|
@@ -1181,8 +1181,8 @@ const makeServices = Effect.fn("DoSubmissionLedger.makeServices")(function* () {
|
|
|
1181
1181
|
retainedWorkerAdmission,
|
|
1182
1182
|
validated.workerAdmission,
|
|
1183
1183
|
) ||
|
|
1184
|
-
!Schema.toEquivalence(Schema.optional(
|
|
1185
|
-
|
|
1184
|
+
!Schema.toEquivalence(Schema.optional(InputMessage))(
|
|
1185
|
+
retainedInputMessage,
|
|
1186
1186
|
validated.messageAdmission,
|
|
1187
1187
|
) ||
|
|
1188
1188
|
!Schema.toEquivalence(Schema.optional(AdmissionFence))(
|
|
@@ -1340,9 +1340,9 @@ const makeServices = Effect.fn("DoSubmissionLedger.makeServices")(function* () {
|
|
|
1340
1340
|
)(function* (request: MarkReadyRequest) {
|
|
1341
1341
|
const operation = "ledger mark ready";
|
|
1342
1342
|
|
|
1343
|
-
const validated = yield* Schema.
|
|
1344
|
-
|
|
1345
|
-
)
|
|
1343
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(MarkReadyRequest))(request).pipe(
|
|
1344
|
+
Effect.mapError(internalFailure(operation)),
|
|
1345
|
+
);
|
|
1346
1346
|
|
|
1347
1347
|
yield* hitFailpoint("ledger:mark-ready:before", operation);
|
|
1348
1348
|
yield* inWriteTransaction(
|
|
@@ -1367,9 +1367,9 @@ const makeServices = Effect.fn("DoSubmissionLedger.makeServices")(function* () {
|
|
|
1367
1367
|
function* (request: SubmissionLookup) {
|
|
1368
1368
|
const operation = "ledger lookup";
|
|
1369
1369
|
|
|
1370
|
-
const validated = yield* Schema.
|
|
1371
|
-
|
|
1372
|
-
)
|
|
1370
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(SubmissionLookup))(request).pipe(
|
|
1371
|
+
Effect.mapError(internalFailure(operation)),
|
|
1372
|
+
);
|
|
1373
1373
|
|
|
1374
1374
|
if (validated._tag === "SubmissionLookupById") {
|
|
1375
1375
|
const row = yield* readSubmission(operation, validated.submissionId);
|
|
@@ -1416,7 +1416,7 @@ const makeServices = Effect.fn("DoSubmissionLedger.makeServices")(function* () {
|
|
|
1416
1416
|
)(function* (request: SubmissionLookupByKey) {
|
|
1417
1417
|
const operation = "ledger resolve admission";
|
|
1418
1418
|
|
|
1419
|
-
const validated = yield* Schema.
|
|
1419
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(SubmissionLookupByKey))(
|
|
1420
1420
|
request,
|
|
1421
1421
|
).pipe(Effect.mapError(internalFailure(operation)));
|
|
1422
1422
|
|
|
@@ -1453,9 +1453,9 @@ const makeServices = Effect.fn("DoSubmissionLedger.makeServices")(function* () {
|
|
|
1453
1453
|
function* (request: ClaimRequest) {
|
|
1454
1454
|
const operation = "ledger claim";
|
|
1455
1455
|
|
|
1456
|
-
const validated = yield* Schema.
|
|
1457
|
-
|
|
1458
|
-
)
|
|
1456
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(ClaimRequest))(request).pipe(
|
|
1457
|
+
Effect.mapError(internalFailure(operation)),
|
|
1458
|
+
);
|
|
1459
1459
|
|
|
1460
1460
|
const attemptId = `attempt-${yield* mintUuid(operation)}`;
|
|
1461
1461
|
const ownershipToken = `owner-${yield* mintUuid(operation)}`;
|
|
@@ -1630,7 +1630,7 @@ const makeServices = Effect.fn("DoSubmissionLedger.makeServices")(function* () {
|
|
|
1630
1630
|
)(function* (request: RenewOwnershipRequest) {
|
|
1631
1631
|
const operation = "ledger renew ownership";
|
|
1632
1632
|
|
|
1633
|
-
const validated = yield* Schema.
|
|
1633
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(RenewOwnershipRequest))(
|
|
1634
1634
|
request,
|
|
1635
1635
|
).pipe(Effect.mapError(internalFailure(operation)));
|
|
1636
1636
|
|
|
@@ -1668,7 +1668,7 @@ const makeServices = Effect.fn("DoSubmissionLedger.makeServices")(function* () {
|
|
|
1668
1668
|
)(function* (request: ReleaseOwnershipRequest) {
|
|
1669
1669
|
const operation = "ledger release ownership";
|
|
1670
1670
|
|
|
1671
|
-
const validated = yield* Schema.
|
|
1671
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(ReleaseOwnershipRequest))(
|
|
1672
1672
|
request,
|
|
1673
1673
|
).pipe(Effect.mapError(internalFailure(operation)));
|
|
1674
1674
|
|
|
@@ -1700,7 +1700,7 @@ const makeServices = Effect.fn("DoSubmissionLedger.makeServices")(function* () {
|
|
|
1700
1700
|
)(function* (request: MarkInputAppliedRequest) {
|
|
1701
1701
|
const operation = "ledger mark input applied";
|
|
1702
1702
|
|
|
1703
|
-
const validated = yield* Schema.
|
|
1703
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(MarkInputAppliedRequest))(
|
|
1704
1704
|
request,
|
|
1705
1705
|
).pipe(Effect.mapError(internalFailure(operation)));
|
|
1706
1706
|
|
|
@@ -1747,7 +1747,7 @@ const makeServices = Effect.fn("DoSubmissionLedger.makeServices")(function* () {
|
|
|
1747
1747
|
)(function* (request: SettlementReservation) {
|
|
1748
1748
|
const operation = "ledger reserve settlement";
|
|
1749
1749
|
|
|
1750
|
-
const validated = yield* Schema.
|
|
1750
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(SettlementReservation))(
|
|
1751
1751
|
request,
|
|
1752
1752
|
).pipe(Effect.mapError(internalFailure(operation)));
|
|
1753
1753
|
|
|
@@ -1963,7 +1963,7 @@ const makeServices = Effect.fn("DoSubmissionLedger.makeServices")(function* () {
|
|
|
1963
1963
|
)(function* (request: SettlementFinalization) {
|
|
1964
1964
|
const operation = "ledger finalize settlement";
|
|
1965
1965
|
|
|
1966
|
-
const validated = yield* Schema.
|
|
1966
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(SettlementFinalization))(
|
|
1967
1967
|
request,
|
|
1968
1968
|
).pipe(Effect.mapError(internalFailure(operation)));
|
|
1969
1969
|
|
|
@@ -2070,7 +2070,7 @@ const makeServices = Effect.fn("DoSubmissionLedger.makeServices")(function* () {
|
|
|
2070
2070
|
)(function* (request: AbortCommand) {
|
|
2071
2071
|
const operation = "ledger request abort";
|
|
2072
2072
|
|
|
2073
|
-
const validated = yield* Schema.
|
|
2073
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(AbortCommand))(request).pipe(
|
|
2074
2074
|
Effect.mapError(internalFailure(operation)),
|
|
2075
2075
|
);
|
|
2076
2076
|
|
|
@@ -2170,9 +2170,9 @@ const makeServices = Effect.fn("DoSubmissionLedger.makeServices")(function* () {
|
|
|
2170
2170
|
)(function* (request: ClaimJoiningRequest) {
|
|
2171
2171
|
const operation = "ledger claim joining";
|
|
2172
2172
|
|
|
2173
|
-
const validated = yield* Schema.
|
|
2174
|
-
|
|
2175
|
-
)
|
|
2173
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(ClaimJoiningRequest))(request).pipe(
|
|
2174
|
+
Effect.mapError(internalFailure(operation)),
|
|
2175
|
+
);
|
|
2176
2176
|
|
|
2177
2177
|
yield* hitFailpoint("ledger:claim-joining:before", operation);
|
|
2178
2178
|
|
|
@@ -2258,9 +2258,9 @@ const makeServices = Effect.fn("DoSubmissionLedger.makeServices")(function* () {
|
|
|
2258
2258
|
)(function* (request: MarkJoinedRequest) {
|
|
2259
2259
|
const operation = "ledger mark joined";
|
|
2260
2260
|
|
|
2261
|
-
const validated = yield* Schema.
|
|
2262
|
-
|
|
2263
|
-
)
|
|
2261
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(MarkJoinedRequest))(request).pipe(
|
|
2262
|
+
Effect.mapError(internalFailure(operation)),
|
|
2263
|
+
);
|
|
2264
2264
|
|
|
2265
2265
|
yield* hitFailpoint("ledger:mark-joined:before", operation);
|
|
2266
2266
|
yield* inWriteTransaction(
|
|
@@ -2318,9 +2318,9 @@ const makeServices = Effect.fn("DoSubmissionLedger.makeServices")(function* () {
|
|
|
2318
2318
|
)(function* (request: RevertJoiningRequest) {
|
|
2319
2319
|
const operation = "ledger revert joining";
|
|
2320
2320
|
|
|
2321
|
-
const validated = yield* Schema.
|
|
2322
|
-
|
|
2323
|
-
)
|
|
2321
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(RevertJoiningRequest))(request).pipe(
|
|
2322
|
+
Effect.mapError(internalFailure(operation)),
|
|
2323
|
+
);
|
|
2324
2324
|
|
|
2325
2325
|
yield* hitFailpoint("ledger:revert-joining:before", operation);
|
|
2326
2326
|
yield* inWriteTransaction(
|
|
@@ -2345,9 +2345,9 @@ const makeServices = Effect.fn("DoSubmissionLedger.makeServices")(function* () {
|
|
|
2345
2345
|
function* (request: SuspendRequest) {
|
|
2346
2346
|
const operation = "ledger suspend";
|
|
2347
2347
|
|
|
2348
|
-
const validated = yield* Schema.
|
|
2349
|
-
|
|
2350
|
-
)
|
|
2348
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(SuspendRequest))(request).pipe(
|
|
2349
|
+
Effect.mapError(internalFailure(operation)),
|
|
2350
|
+
);
|
|
2351
2351
|
|
|
2352
2352
|
const reasonJson = yield* encodeSuspensionReasonText(validated.reason).pipe(
|
|
2353
2353
|
Effect.mapError(internalFailure(operation)),
|
|
@@ -2492,7 +2492,7 @@ const makeServices = Effect.fn("DoSubmissionLedger.makeServices")(function* () {
|
|
|
2492
2492
|
)(function* (command: ApprovalDecisionCommand) {
|
|
2493
2493
|
const operation = "ledger record approval decision";
|
|
2494
2494
|
|
|
2495
|
-
const validated = yield* Schema.
|
|
2495
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(ApprovalDecisionCommand))(
|
|
2496
2496
|
command,
|
|
2497
2497
|
).pipe(Effect.mapError(internalFailure(operation)));
|
|
2498
2498
|
|
|
@@ -2576,9 +2576,9 @@ const makeServices = Effect.fn("DoSubmissionLedger.makeServices")(function* () {
|
|
|
2576
2576
|
)(function* (request: MarkUnknownRequest) {
|
|
2577
2577
|
const operation = "ledger mark unknown";
|
|
2578
2578
|
|
|
2579
|
-
const validated = yield* Schema.
|
|
2580
|
-
|
|
2581
|
-
)
|
|
2579
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(MarkUnknownRequest))(request).pipe(
|
|
2580
|
+
Effect.mapError(internalFailure(operation)),
|
|
2581
|
+
);
|
|
2582
2582
|
|
|
2583
2583
|
yield* hitFailpoint("ledger:mark-unknown:before", operation);
|
|
2584
2584
|
yield* inWriteTransaction(
|
|
@@ -2643,7 +2643,7 @@ const makeServices = Effect.fn("DoSubmissionLedger.makeServices")(function* () {
|
|
|
2643
2643
|
)(function* (command: UnknownResolutionCommand) {
|
|
2644
2644
|
const operation = "ledger record unknown resolution";
|
|
2645
2645
|
|
|
2646
|
-
const validated = yield* Schema.
|
|
2646
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(UnknownResolutionCommand))(
|
|
2647
2647
|
command,
|
|
2648
2648
|
).pipe(Effect.mapError(internalFailure(operation)));
|
|
2649
2649
|
|
|
@@ -2764,7 +2764,7 @@ const makeServices = Effect.fn("DoSubmissionLedger.makeServices")(function* () {
|
|
|
2764
2764
|
)(function* (request: ChildSettledNotification) {
|
|
2765
2765
|
const operation = "ledger record child settled";
|
|
2766
2766
|
|
|
2767
|
-
const validated = yield* Schema.
|
|
2767
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(ChildSettledNotification))(
|
|
2768
2768
|
request,
|
|
2769
2769
|
).pipe(Effect.mapError(internalFailure(operation)));
|
|
2770
2770
|
|
|
@@ -2885,9 +2885,9 @@ const makeServices = Effect.fn("DoSubmissionLedger.makeServices")(function* () {
|
|
|
2885
2885
|
)(function* (request: ChildBudgetReservationRequest) {
|
|
2886
2886
|
const operation = "ledger reserve child budget";
|
|
2887
2887
|
|
|
2888
|
-
const validated = yield* Schema.
|
|
2889
|
-
|
|
2890
|
-
)
|
|
2888
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(ChildBudgetReservationRequest))(
|
|
2889
|
+
request,
|
|
2890
|
+
).pipe(Effect.mapError(internalFailure(operation)));
|
|
2891
2891
|
|
|
2892
2892
|
const allocationJson = yield* encodePersistedJsonText(validated.allocation).pipe(
|
|
2893
2893
|
Effect.mapError(internalFailure(operation)),
|
|
@@ -2997,9 +2997,9 @@ const makeServices = Effect.fn("DoSubmissionLedger.makeServices")(function* () {
|
|
|
2997
2997
|
) {
|
|
2998
2998
|
const operation = "ledger attach child to reservation";
|
|
2999
2999
|
|
|
3000
|
-
const validated = yield* Schema.
|
|
3001
|
-
|
|
3002
|
-
)
|
|
3000
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(AttachChildToReservationRequest))(
|
|
3001
|
+
request,
|
|
3002
|
+
).pipe(Effect.mapError(internalFailure(operation)));
|
|
3003
3003
|
|
|
3004
3004
|
yield* hitFailpoint("ledger:child-attach:before", operation);
|
|
3005
3005
|
|
|
@@ -3070,9 +3070,9 @@ const makeServices = Effect.fn("DoSubmissionLedger.makeServices")(function* () {
|
|
|
3070
3070
|
)(function* (request: BeginChildBudgetReleaseRequest) {
|
|
3071
3071
|
const operation = "ledger begin child budget release";
|
|
3072
3072
|
|
|
3073
|
-
const validated = yield* Schema.
|
|
3074
|
-
|
|
3075
|
-
)
|
|
3073
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(BeginChildBudgetReleaseRequest))(
|
|
3074
|
+
request,
|
|
3075
|
+
).pipe(Effect.mapError(internalFailure(operation)));
|
|
3076
3076
|
|
|
3077
3077
|
const accountingJson = yield* encodePersistedJsonText(validated.accounting).pipe(
|
|
3078
3078
|
Effect.mapError(internalFailure(operation)),
|
|
@@ -3147,7 +3147,7 @@ const makeServices = Effect.fn("DoSubmissionLedger.makeServices")(function* () {
|
|
|
3147
3147
|
)(function* (request: ReleaseChildBudgetRequest) {
|
|
3148
3148
|
const operation = "ledger release child budget";
|
|
3149
3149
|
|
|
3150
|
-
const validated = yield* Schema.
|
|
3150
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(ReleaseChildBudgetRequest))(
|
|
3151
3151
|
request,
|
|
3152
3152
|
).pipe(Effect.mapError(internalFailure(operation)));
|
|
3153
3153
|
|
|
@@ -3265,9 +3265,9 @@ const makeServices = Effect.fn("DoSubmissionLedger.makeServices")(function* () {
|
|
|
3265
3265
|
)(function* (request) {
|
|
3266
3266
|
const operation = "ledger read abort intent";
|
|
3267
3267
|
|
|
3268
|
-
const validated = yield* Schema.
|
|
3269
|
-
|
|
3270
|
-
)
|
|
3268
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(AbortIntentRequest))(request).pipe(
|
|
3269
|
+
Effect.mapError(internalFailure(operation)),
|
|
3270
|
+
);
|
|
3271
3271
|
|
|
3272
3272
|
const recordId = submissionAbortRecordId(validated.submissionId);
|
|
3273
3273
|
|
|
@@ -3336,7 +3336,7 @@ const makeServices = Effect.fn("DoSubmissionLedger.makeServices")(function* () {
|
|
|
3336
3336
|
)(function* (request: RecoverySnapshotRequest) {
|
|
3337
3337
|
const operation = "ledger load recovery snapshot";
|
|
3338
3338
|
|
|
3339
|
-
const validated = yield* Schema.
|
|
3339
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(RecoverySnapshotRequest))(
|
|
3340
3340
|
request,
|
|
3341
3341
|
).pipe(Effect.mapError(internalFailure(operation)));
|
|
3342
3342
|
|
|
@@ -3385,7 +3385,7 @@ const makeServices = Effect.fn("DoSubmissionLedger.makeServices")(function* () {
|
|
|
3385
3385
|
),
|
|
3386
3386
|
);
|
|
3387
3387
|
|
|
3388
|
-
const settlementId = yield* Schema.
|
|
3388
|
+
const settlementId = yield* Schema.decodeEffect(
|
|
3389
3389
|
SettlementReservationSnapshot.fields.settlementId,
|
|
3390
3390
|
)(reservationRow.value.settlement_id).pipe(Effect.mapError(internalFailure(operation)));
|
|
3391
3391
|
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BrowserCrypto } from "@effect/platform-browser";
|
|
2
|
+
import { Context, Effect, Layer, Schema } from "effect";
|
|
3
|
+
import { upgradeV2Subscriptions } from "effect-agent/sql-storage-v2-upgrade";
|
|
2
4
|
import {
|
|
3
5
|
makeSqlSubscriptionStore,
|
|
4
6
|
SqlSubscriptionTransaction,
|
|
5
|
-
} from "
|
|
7
|
+
} from "effect-agent/sql-subscription-store";
|
|
6
8
|
import {
|
|
7
9
|
SourcePartition,
|
|
8
10
|
SubscriptionError,
|
|
9
11
|
SubscriptionFailpoint,
|
|
10
12
|
type SubscriptionFailpointError,
|
|
11
13
|
SubscriptionStore,
|
|
12
|
-
} from "
|
|
13
|
-
import { BrowserCrypto } from "@effect/platform-browser";
|
|
14
|
-
import { Context, Effect, Layer, Schema } from "effect";
|
|
14
|
+
} from "effect-agent/subscription";
|
|
15
15
|
import * as SqlClientService from "effect/unstable/sql/SqlClient";
|
|
16
16
|
import type { SqlError } from "effect/unstable/sql/SqlError";
|
|
17
17
|
|
|
@@ -299,7 +299,7 @@ const makeSubscriptionStore = Effect.fn("DoSubscriptionStore.make")(function* (
|
|
|
299
299
|
|
|
300
300
|
const store = yield* makeSqlSubscriptionStore(partition, {
|
|
301
301
|
maxStoredJsonLength: 1_900_000,
|
|
302
|
-
}).pipe(Effect.
|
|
302
|
+
}).pipe(Effect.provideService(SqlSubscriptionTransaction, { run: transact }));
|
|
303
303
|
|
|
304
304
|
const prearm = Effect.fn("DoSubscriptionStore.prearm")(function* (deadlineAtMillis: number) {
|
|
305
305
|
yield* transactions.run((replace) => replaceAlarm(replace, deadlineAtMillis));
|
package/src/DoThreadStore.ts
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BrowserCrypto } from "@effect/platform-browser";
|
|
2
|
+
import { SqliteClient } from "@effect/sql-sqlite-do";
|
|
3
|
+
import {
|
|
4
|
+
Clock,
|
|
5
|
+
Context,
|
|
6
|
+
Crypto,
|
|
7
|
+
Duration,
|
|
8
|
+
Effect,
|
|
9
|
+
Layer,
|
|
10
|
+
Option,
|
|
11
|
+
Ref,
|
|
12
|
+
Schema,
|
|
13
|
+
Stream,
|
|
14
|
+
} from "effect";
|
|
15
|
+
import { digestCanonicalBatch, EMPTY_TAIL_DIGEST } from "effect-agent/digest";
|
|
2
16
|
import {
|
|
3
17
|
CanonicalBatch,
|
|
4
18
|
CanonicalRecord,
|
|
@@ -6,8 +20,8 @@ import {
|
|
|
6
20
|
CanonicalSequence,
|
|
7
21
|
Digest,
|
|
8
22
|
ObservationOffset,
|
|
9
|
-
} from "
|
|
10
|
-
import { DEFAULT_OWNERSHIP_LEASE_DURATION } from "
|
|
23
|
+
} from "effect-agent/records";
|
|
24
|
+
import { DEFAULT_OWNERSHIP_LEASE_DURATION } from "effect-agent/submission-ledger";
|
|
11
25
|
import {
|
|
12
26
|
AppendConflict,
|
|
13
27
|
AppendResult,
|
|
@@ -31,21 +45,7 @@ import {
|
|
|
31
45
|
SaveRecoveryCheckpointRequest,
|
|
32
46
|
MAX_THREAD_EXPORT_RECORDS,
|
|
33
47
|
type ThreadRecoveryCheckpoints,
|
|
34
|
-
} from "
|
|
35
|
-
import { BrowserCrypto } from "@effect/platform-browser";
|
|
36
|
-
import { SqliteClient } from "@effect/sql-sqlite-do";
|
|
37
|
-
import {
|
|
38
|
-
Clock,
|
|
39
|
-
Context,
|
|
40
|
-
Crypto,
|
|
41
|
-
Duration,
|
|
42
|
-
Effect,
|
|
43
|
-
Layer,
|
|
44
|
-
Option,
|
|
45
|
-
Ref,
|
|
46
|
-
Schema,
|
|
47
|
-
Stream,
|
|
48
|
-
} from "effect";
|
|
48
|
+
} from "effect-agent/thread-store";
|
|
49
49
|
import * as SqlClientService from "effect/unstable/sql/SqlClient";
|
|
50
50
|
|
|
51
51
|
import {
|
|
@@ -81,7 +81,7 @@ export interface DoStorageOptions {
|
|
|
81
81
|
readonly observationPollInterval?: number | undefined;
|
|
82
82
|
/**
|
|
83
83
|
* Submission ownership lease duration in milliseconds (D5). Defaults to
|
|
84
|
-
* `DEFAULT_OWNERSHIP_LEASE_DURATION` from
|
|
84
|
+
* `DEFAULT_OWNERSHIP_LEASE_DURATION` from `effect-agent/submission-ledger`.
|
|
85
85
|
*/
|
|
86
86
|
readonly ownershipLeaseDuration?: number | undefined;
|
|
87
87
|
/**
|
|
@@ -129,9 +129,9 @@ const makeOffset = Effect.fn(function* (
|
|
|
129
129
|
threadId: ThreadMaterialization["threadId"],
|
|
130
130
|
sequence: number,
|
|
131
131
|
): Effect.fn.Return<ObservationOffset, ThreadStoreError> {
|
|
132
|
-
return yield* Schema.
|
|
132
|
+
return yield* Schema.decodeEffect(CanonicalSequence)(sequence).pipe(
|
|
133
133
|
Effect.flatMap((validatedSequence) =>
|
|
134
|
-
Schema.
|
|
134
|
+
Schema.decodeEffect(ObservationOffset)(
|
|
135
135
|
`${DO_OFFSET_PREFIX}${encodeURIComponent(threadId)}:${validatedSequence}`,
|
|
136
136
|
),
|
|
137
137
|
),
|
|
@@ -145,7 +145,7 @@ const parseOffset = Effect.fn(function* (
|
|
|
145
145
|
): Effect.fn.Return<CanonicalSequence, ThreadStoreError> {
|
|
146
146
|
if (offset === undefined) return ZERO_CANONICAL_SEQUENCE;
|
|
147
147
|
|
|
148
|
-
const text = yield* Schema.
|
|
148
|
+
const text = yield* Schema.decodeEffect(OffsetText)(offset).pipe(
|
|
149
149
|
Effect.mapError((error) => schemaStoreError("decode observation offset", error)),
|
|
150
150
|
);
|
|
151
151
|
|
|
@@ -166,7 +166,7 @@ const parseOffset = Effect.fn(function* (
|
|
|
166
166
|
});
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
return yield* Schema.
|
|
169
|
+
return yield* Schema.decodeEffect(CanonicalSequence)(Number(sequenceText)).pipe(
|
|
170
170
|
Effect.mapError((error) => schemaStoreError("decode observation offset", error)),
|
|
171
171
|
);
|
|
172
172
|
});
|
|
@@ -219,13 +219,13 @@ const decodeEnvelope = Effect.fn(function* (row: {
|
|
|
219
219
|
),
|
|
220
220
|
);
|
|
221
221
|
|
|
222
|
-
const threadId = yield* Schema.
|
|
222
|
+
const threadId = yield* Schema.decodeEffect(CanonicalRecordEnvelope.fields.threadId)(
|
|
223
223
|
row.thread_id,
|
|
224
224
|
).pipe(Effect.mapError((error) => schemaStoreError("decode thread identity", error)));
|
|
225
225
|
|
|
226
226
|
const offset = yield* makeOffset(threadId, row.sequence);
|
|
227
227
|
|
|
228
|
-
const batchId = yield* Schema.
|
|
228
|
+
const batchId = yield* Schema.decodeEffect(CanonicalRecordEnvelope.fields.batchId)(
|
|
229
229
|
row.batch_id,
|
|
230
230
|
).pipe(Effect.mapError((error) => schemaStoreError("decode batch identity", error)));
|
|
231
231
|
|
|
@@ -279,7 +279,7 @@ const tailDigestAt = Effect.fn("DoThreadStore.tailDigestAt")(function* (
|
|
|
279
279
|
});
|
|
280
280
|
}
|
|
281
281
|
|
|
282
|
-
return yield* Schema.
|
|
282
|
+
return yield* Schema.decodeEffect(Digest)(digests[0]).pipe(
|
|
283
283
|
Effect.mapError((error) => schemaStoreError("decode checkpoint digest", error)),
|
|
284
284
|
);
|
|
285
285
|
});
|
|
@@ -520,7 +520,7 @@ const makeServices = Effect.fn("DoThreadStore.makeServices")(function* () {
|
|
|
520
520
|
|
|
521
521
|
const materialize: ThreadStore["Service"]["materialize"] = Effect.fn("DoThreadStore.materialize")(
|
|
522
522
|
function* (request: ThreadMaterialization) {
|
|
523
|
-
const validated = yield* Schema.
|
|
523
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(ThreadMaterialization))(
|
|
524
524
|
request,
|
|
525
525
|
).pipe(Effect.mapError((error) => schemaStoreError("validate materialization", error)));
|
|
526
526
|
|
|
@@ -548,9 +548,9 @@ const makeServices = Effect.fn("DoThreadStore.makeServices")(function* () {
|
|
|
548
548
|
const append: ThreadStore["Service"]["append"] = Effect.fn("DoThreadStore.append")(function* (
|
|
549
549
|
request: FencedAppendRequest,
|
|
550
550
|
) {
|
|
551
|
-
const validated = yield* Schema.
|
|
552
|
-
|
|
553
|
-
)
|
|
551
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(FencedAppendRequest))(request).pipe(
|
|
552
|
+
Effect.mapError((error) => schemaStoreError("validate canonical append", error)),
|
|
553
|
+
);
|
|
554
554
|
|
|
555
555
|
yield* requireThread(journal, validated.threadId);
|
|
556
556
|
|
|
@@ -569,7 +569,7 @@ const makeServices = Effect.fn("DoThreadStore.makeServices")(function* () {
|
|
|
569
569
|
),
|
|
570
570
|
);
|
|
571
571
|
|
|
572
|
-
const rawRequest = yield* Schema.
|
|
572
|
+
const rawRequest = yield* Schema.decodeEffect(RawAppendRequest)({
|
|
573
573
|
threadId: validated.threadId,
|
|
574
574
|
batchId: validated.batch.batchId,
|
|
575
575
|
batchDigest: tailDigest,
|
|
@@ -607,7 +607,7 @@ const makeServices = Effect.fn("DoThreadStore.makeServices")(function* () {
|
|
|
607
607
|
return storeError("append canonical batch", error);
|
|
608
608
|
}),
|
|
609
609
|
Effect.flatMap((result) =>
|
|
610
|
-
Schema.
|
|
610
|
+
Schema.decodeEffect(AppendResult)(result).pipe(
|
|
611
611
|
Effect.mapError((error) => schemaStoreError("decode append result", error)),
|
|
612
612
|
),
|
|
613
613
|
),
|
|
@@ -633,7 +633,7 @@ const makeServices = Effect.fn("DoThreadStore.makeServices")(function* () {
|
|
|
633
633
|
});
|
|
634
634
|
|
|
635
635
|
const readEffect = Effect.fn("DoThreadStore.read")(function* (request: ThreadRead) {
|
|
636
|
-
const validated = yield* Schema.
|
|
636
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(ThreadRead))(request).pipe(
|
|
637
637
|
Effect.mapError((error) => schemaStoreError("validate thread read", error)),
|
|
638
638
|
);
|
|
639
639
|
|
|
@@ -653,9 +653,9 @@ const makeServices = Effect.fn("DoThreadStore.makeServices")(function* () {
|
|
|
653
653
|
const read: ThreadStore["Service"]["read"] = (request) => Stream.unwrap(readEffect(request));
|
|
654
654
|
|
|
655
655
|
const observeEffect = Effect.fn("DoThreadStore.observe")(function* (request: ThreadObservation) {
|
|
656
|
-
const validated = yield* Schema.
|
|
657
|
-
|
|
658
|
-
)
|
|
656
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(ThreadObservation))(request).pipe(
|
|
657
|
+
Effect.mapError((error) => schemaStoreError("validate thread observation", error)),
|
|
658
|
+
);
|
|
659
659
|
|
|
660
660
|
yield* requireThread(journal, validated.threadId);
|
|
661
661
|
const initialSequence = yield* parseOffset(validated.threadId, validated.afterOffset);
|
|
@@ -689,7 +689,7 @@ const makeServices = Effect.fn("DoThreadStore.makeServices")(function* () {
|
|
|
689
689
|
|
|
690
690
|
const exportThread: ThreadStore["Service"]["export"] = Effect.fn("DoThreadStore.export")(
|
|
691
691
|
function* (request: ThreadExportRequest) {
|
|
692
|
-
const validated = yield* Schema.
|
|
692
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(ThreadExportRequest))(
|
|
693
693
|
request,
|
|
694
694
|
).pipe(Effect.mapError((error) => schemaStoreError("validate thread export", error)));
|
|
695
695
|
|
|
@@ -708,9 +708,9 @@ const makeServices = Effect.fn("DoThreadStore.makeServices")(function* () {
|
|
|
708
708
|
});
|
|
709
709
|
}
|
|
710
710
|
|
|
711
|
-
const tailDigest = yield* Schema.
|
|
712
|
-
|
|
713
|
-
)
|
|
711
|
+
const tailDigest = yield* Schema.decodeEffect(Digest)(exported.thread.tail_digest).pipe(
|
|
712
|
+
Effect.mapError((error) => schemaStoreError("decode export tail digest", error)),
|
|
713
|
+
);
|
|
714
714
|
|
|
715
715
|
return ThreadExport.make({
|
|
716
716
|
format: "effect-agent/thread@1",
|
|
@@ -724,13 +724,13 @@ const makeServices = Effect.fn("DoThreadStore.makeServices")(function* () {
|
|
|
724
724
|
|
|
725
725
|
const inspectTail: ThreadStore["Service"]["inspectTail"] = Effect.fn("DoThreadStore.inspectTail")(
|
|
726
726
|
function* (request: ThreadTailRequest) {
|
|
727
|
-
const validated = yield* Schema.
|
|
728
|
-
|
|
729
|
-
)
|
|
727
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(ThreadTailRequest))(request).pipe(
|
|
728
|
+
Effect.mapError((error) => schemaStoreError("validate tail inspection", error)),
|
|
729
|
+
);
|
|
730
730
|
|
|
731
731
|
const thread = yield* requireThread(journal, validated.threadId);
|
|
732
732
|
|
|
733
|
-
const tailDigest = yield* Schema.
|
|
733
|
+
const tailDigest = yield* Schema.decodeEffect(Digest)(thread.tail_digest).pipe(
|
|
734
734
|
Effect.mapError((error) => schemaStoreError("decode tail digest", error)),
|
|
735
735
|
);
|
|
736
736
|
|
|
@@ -745,7 +745,7 @@ const makeServices = Effect.fn("DoThreadStore.makeServices")(function* () {
|
|
|
745
745
|
|
|
746
746
|
const saveCheckpoint: ThreadCheckpoints["save"] = Effect.fn("DoThreadStore.saveCheckpoint")(
|
|
747
747
|
function* (request: SaveCheckpointRequest) {
|
|
748
|
-
const validated = yield* Schema.
|
|
748
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(SaveCheckpointRequest))(
|
|
749
749
|
request,
|
|
750
750
|
).pipe(Effect.mapError((error) => schemaStoreError("validate checkpoint", error)));
|
|
751
751
|
|
|
@@ -796,7 +796,7 @@ const makeServices = Effect.fn("DoThreadStore.makeServices")(function* () {
|
|
|
796
796
|
|
|
797
797
|
const loadCheckpoint: ThreadCheckpoints["load"] = Effect.fn("DoThreadStore.loadCheckpoint")(
|
|
798
798
|
function* (request: LoadCheckpointRequest) {
|
|
799
|
-
const validated = yield* Schema.
|
|
799
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(LoadCheckpointRequest))(
|
|
800
800
|
request,
|
|
801
801
|
).pipe(Effect.mapError((error) => schemaStoreError("validate checkpoint lookup", error)));
|
|
802
802
|
|
|
@@ -848,11 +848,9 @@ const makeServices = Effect.fn("DoThreadStore.makeServices")(function* () {
|
|
|
848
848
|
const saveRecoveryCheckpoint: ThreadRecoveryCheckpoints["save"] = Effect.fn(
|
|
849
849
|
"DoThreadStore.saveRecoveryCheckpoint",
|
|
850
850
|
)(function* (request) {
|
|
851
|
-
const validated = yield* Schema.
|
|
852
|
-
|
|
853
|
-
)
|
|
854
|
-
Effect.mapError((error) => schemaStoreError("validate recovery checkpoint", error)),
|
|
855
|
-
);
|
|
851
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(SaveRecoveryCheckpointRequest))(
|
|
852
|
+
request,
|
|
853
|
+
).pipe(Effect.mapError((error) => schemaStoreError("validate recovery checkpoint", error)));
|
|
856
854
|
|
|
857
855
|
const checkpointJson = yield* encodeCheckpoint(validated.checkpoint);
|
|
858
856
|
|
|
@@ -872,7 +870,7 @@ const makeServices = Effect.fn("DoThreadStore.makeServices")(function* () {
|
|
|
872
870
|
const loadRecoveryCheckpoint: ThreadRecoveryCheckpoints["load"] = Effect.fn(
|
|
873
871
|
"DoThreadStore.loadRecoveryCheckpoint",
|
|
874
872
|
)(function* (request) {
|
|
875
|
-
const validated = yield* Schema.
|
|
873
|
+
const validated = yield* Schema.decodeEffect(Schema.toType(LoadCheckpointRequest))(
|
|
876
874
|
request,
|
|
877
875
|
).pipe(
|
|
878
876
|
Effect.mapError((error) => schemaStoreError("validate recovery checkpoint lookup", error)),
|
|
@@ -964,7 +962,7 @@ export const storageConfigLayer = (
|
|
|
964
962
|
options: DoStorageOptions,
|
|
965
963
|
): Layer.Layer<DoStorageConfig, DoStorageError> =>
|
|
966
964
|
Layer.effect(DoStorageConfig)(
|
|
967
|
-
Schema.
|
|
965
|
+
Schema.decodeEffect(DoStorageConfigValue)({
|
|
968
966
|
observationPollInterval: options.observationPollInterval ?? 25,
|
|
969
967
|
ownershipLeaseDuration:
|
|
970
968
|
options.ownershipLeaseDuration ?? Duration.toMillis(DEFAULT_OWNERSHIP_LEASE_DURATION),
|