@effect-agent/storage-sqlite 0.1.0-beta.9 → 0.1.0-beta.90
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/SqliteActivityStore.d.mts +14 -0
- package/dist/SqliteActivityStore.mjs +310 -0
- package/dist/SqliteActivityStore.mjs.map +1 -0
- package/dist/SqliteMessageDeliveryStore.d.mts +14 -0
- package/dist/SqliteMessageDeliveryStore.mjs +24 -0
- package/dist/SqliteMessageDeliveryStore.mjs.map +1 -0
- package/dist/SqliteScheduleStore.d.mts +14 -0
- package/dist/SqliteScheduleStore.mjs +255 -0
- package/dist/SqliteScheduleStore.mjs.map +1 -0
- package/dist/SqliteStorageConfig.d.mts +34 -0
- package/dist/SqliteStorageConfig.mjs +39 -0
- package/dist/SqliteStorageConfig.mjs.map +1 -0
- package/dist/SqliteStorageError-DVWeaWLm.d.mts +86 -0
- package/dist/SqliteStorageError.d.mts +2 -0
- package/dist/SqliteStorageError.mjs +150 -0
- package/dist/SqliteStorageError.mjs.map +1 -0
- package/dist/SqliteStorageFailpoint.d.mts +17 -0
- package/dist/SqliteStorageFailpoint.mjs +14 -0
- package/dist/SqliteStorageFailpoint.mjs.map +1 -0
- package/dist/SqliteStorageFailpointTesting.d.mts +15 -0
- package/dist/SqliteStorageFailpointTesting.mjs +19 -0
- package/dist/SqliteStorageFailpointTesting.mjs.map +1 -0
- package/dist/SqliteStorageVersion-BqmqX0CI.d.mts +11 -0
- package/dist/SqliteStorageVersion.d.mts +2 -0
- package/dist/SqliteStorageVersion.mjs +8 -0
- package/dist/SqliteStorageVersion.mjs.map +1 -0
- package/dist/SqliteSubmissionLedger.d.mts +23 -0
- package/dist/SqliteSubmissionLedger.mjs +1788 -0
- package/dist/SqliteSubmissionLedger.mjs.map +1 -0
- package/dist/SqliteSubscriptionStore.d.mts +13 -0
- package/dist/SqliteSubscriptionStore.mjs +28 -0
- package/dist/SqliteSubscriptionStore.mjs.map +1 -0
- package/dist/SqliteThreadStore.d.mts +49 -0
- package/dist/SqliteThreadStore.mjs +460 -0
- package/dist/SqliteThreadStore.mjs.map +1 -0
- package/dist/index.d.mts +11 -193
- package/dist/index.mjs +11 -3082
- package/dist/migrations-Dy5v0HGe.mjs +346 -0
- package/dist/migrations-Dy5v0HGe.mjs.map +1 -0
- package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
- package/dist/sqlite-journal-CBOQDySe.mjs +998 -0
- package/dist/sqlite-journal-CBOQDySe.mjs.map +1 -0
- package/package.json +1 -41
- package/src/SqliteActivityStore.ts +556 -0
- package/src/SqliteMessageDeliveryStore.ts +42 -0
- package/src/SqliteScheduleStore.ts +404 -0
- package/src/{sqlite-storage-config.ts → SqliteStorageConfig.ts} +1 -1
- package/src/{errors.ts → SqliteStorageError.ts} +10 -3
- package/src/SqliteStorageFailpoint.ts +23 -0
- package/src/{sqlite-storage-failpoint.ts → SqliteStorageFailpointTesting.ts} +7 -18
- package/src/SqliteStorageVersion.ts +2 -0
- package/src/{sqlite-ledger.ts → SqliteSubmissionLedger.ts} +912 -212
- package/src/SqliteSubscriptionStore.ts +55 -0
- package/src/SqliteThreadStore.ts +999 -0
- package/src/index.ts +10 -6
- package/src/internal/message-delivery-schema.ts +24 -0
- package/src/{migrations.ts → internal/migrations.ts} +156 -79
- package/src/internal/recovery-checkpoint-schema.ts +17 -0
- package/src/{sqlite-journal.ts → internal/sqlite-journal.ts} +751 -241
- package/dist/index.mjs.map +0 -1
- package/src/sqlite-conversation-store.ts +0 -841
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Effect, Layer, Schema } from "effect";
|
|
2
|
+
import {
|
|
3
|
+
makeSqlSubscriptionStore,
|
|
4
|
+
SqlSubscriptionTransaction,
|
|
5
|
+
} from "effect-agent/sql-subscription-store";
|
|
6
|
+
import { SourcePartition, SubscriptionError, SubscriptionStore } from "effect-agent/subscription";
|
|
7
|
+
import * as SqlClientService from "effect/unstable/sql/SqlClient";
|
|
8
|
+
|
|
9
|
+
import { initializeSqliteJournal } from "./internal/sqlite-journal.ts";
|
|
10
|
+
import type { SqliteStorageConfig } from "./SqliteStorageConfig.ts";
|
|
11
|
+
import type { SqliteStorageFailpoint } from "./SqliteStorageFailpoint.ts";
|
|
12
|
+
import type { SqliteStorageInitializationError } from "./SqliteThreadStore.ts";
|
|
13
|
+
|
|
14
|
+
const transactionLayer = Layer.effect(
|
|
15
|
+
SqlSubscriptionTransaction,
|
|
16
|
+
Effect.gen(function* () {
|
|
17
|
+
const sql = yield* SqlClientService.SqlClient;
|
|
18
|
+
|
|
19
|
+
return SqlSubscriptionTransaction.of({
|
|
20
|
+
run: (body) =>
|
|
21
|
+
sql
|
|
22
|
+
.withTransaction(body)
|
|
23
|
+
.pipe(
|
|
24
|
+
Effect.catchTag("SqlError", () =>
|
|
25
|
+
Effect.fail(SubscriptionError.make({ reason: "storage", code: "transaction" })),
|
|
26
|
+
),
|
|
27
|
+
),
|
|
28
|
+
});
|
|
29
|
+
}),
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
const makeSubscriptionStore = Effect.fn("SqliteSubscriptionStore.make")(function* (
|
|
33
|
+
owned: SourcePartition,
|
|
34
|
+
) {
|
|
35
|
+
const partition = yield* Schema.decodeEffect(SourcePartition)(owned).pipe(
|
|
36
|
+
Effect.mapError(() => SubscriptionError.make({ reason: "validation", code: "partition" })),
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
yield* initializeSqliteJournal();
|
|
40
|
+
|
|
41
|
+
return yield* makeSqlSubscriptionStore(partition, {
|
|
42
|
+
maxStoredJsonLength: 16 * 1024 * 1024,
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
export const subscriptionStoreLayer = (
|
|
47
|
+
partition: SourcePartition,
|
|
48
|
+
): Layer.Layer<
|
|
49
|
+
SubscriptionStore,
|
|
50
|
+
SqliteStorageInitializationError | SubscriptionError,
|
|
51
|
+
SqliteStorageConfig | SqliteStorageFailpoint | SqlClientService.SqlClient
|
|
52
|
+
> =>
|
|
53
|
+
Layer.effect(SubscriptionStore, makeSubscriptionStore(partition)).pipe(
|
|
54
|
+
Layer.provide(transactionLayer),
|
|
55
|
+
);
|