@effect-agent/storage-sqlite 0.1.0-beta.6 → 0.1.0-beta.60

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.
Files changed (59) hide show
  1. package/dist/SqliteActivityStore.d.mts +14 -0
  2. package/dist/SqliteActivityStore.mjs +310 -0
  3. package/dist/SqliteActivityStore.mjs.map +1 -0
  4. package/dist/SqliteMessageDeliveryStore.d.mts +14 -0
  5. package/dist/SqliteMessageDeliveryStore.mjs +24 -0
  6. package/dist/SqliteMessageDeliveryStore.mjs.map +1 -0
  7. package/dist/SqliteScheduleStore.d.mts +14 -0
  8. package/dist/SqliteScheduleStore.mjs +255 -0
  9. package/dist/SqliteScheduleStore.mjs.map +1 -0
  10. package/dist/SqliteStorageConfig.d.mts +34 -0
  11. package/dist/SqliteStorageConfig.mjs +39 -0
  12. package/dist/SqliteStorageConfig.mjs.map +1 -0
  13. package/dist/SqliteStorageError-CzKmwCLl.d.mts +86 -0
  14. package/dist/SqliteStorageError.d.mts +2 -0
  15. package/dist/SqliteStorageError.mjs +148 -0
  16. package/dist/SqliteStorageError.mjs.map +1 -0
  17. package/dist/SqliteStorageFailpoint.d.mts +17 -0
  18. package/dist/SqliteStorageFailpoint.mjs +14 -0
  19. package/dist/SqliteStorageFailpoint.mjs.map +1 -0
  20. package/dist/SqliteStorageFailpointTesting.d.mts +15 -0
  21. package/dist/SqliteStorageFailpointTesting.mjs +19 -0
  22. package/dist/SqliteStorageFailpointTesting.mjs.map +1 -0
  23. package/dist/SqliteStorageVersion-gA7_96xM.d.mts +9 -0
  24. package/dist/SqliteStorageVersion.d.mts +2 -0
  25. package/dist/SqliteStorageVersion.mjs +8 -0
  26. package/dist/SqliteStorageVersion.mjs.map +1 -0
  27. package/dist/SqliteSubmissionLedger.d.mts +23 -0
  28. package/dist/SqliteSubmissionLedger.mjs +1765 -0
  29. package/dist/SqliteSubmissionLedger.mjs.map +1 -0
  30. package/dist/SqliteSubscriptionStore.d.mts +13 -0
  31. package/dist/SqliteSubscriptionStore.mjs +28 -0
  32. package/dist/SqliteSubscriptionStore.mjs.map +1 -0
  33. package/dist/SqliteThreadStore.d.mts +49 -0
  34. package/dist/SqliteThreadStore.mjs +427 -0
  35. package/dist/SqliteThreadStore.mjs.map +1 -0
  36. package/dist/index.d.mts +11 -193
  37. package/dist/index.mjs +11 -3082
  38. package/dist/migrations-dnTR0RKq.mjs +326 -0
  39. package/dist/migrations-dnTR0RKq.mjs.map +1 -0
  40. package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
  41. package/dist/sqlite-journal-lDduEakl.mjs +887 -0
  42. package/dist/sqlite-journal-lDduEakl.mjs.map +1 -0
  43. package/package.json +1 -41
  44. package/src/SqliteActivityStore.ts +556 -0
  45. package/src/SqliteMessageDeliveryStore.ts +42 -0
  46. package/src/SqliteScheduleStore.ts +404 -0
  47. package/src/{sqlite-storage-config.ts → SqliteStorageConfig.ts} +1 -1
  48. package/src/{errors.ts → SqliteStorageError.ts} +8 -3
  49. package/src/SqliteStorageFailpoint.ts +23 -0
  50. package/src/{sqlite-storage-failpoint.ts → SqliteStorageFailpointTesting.ts} +7 -18
  51. package/src/SqliteStorageVersion.ts +2 -0
  52. package/src/{sqlite-ledger.ts → SqliteSubmissionLedger.ts} +753 -118
  53. package/src/SqliteSubscriptionStore.ts +59 -0
  54. package/src/{sqlite-conversation-store.ts → SqliteThreadStore.ts} +372 -302
  55. package/src/index.ts +10 -6
  56. package/src/internal/message-delivery-schema.ts +24 -0
  57. package/src/{migrations.ts → internal/migrations.ts} +145 -79
  58. package/src/{sqlite-journal.ts → internal/sqlite-journal.ts} +534 -222
  59. package/dist/index.mjs.map +0 -1
@@ -0,0 +1,59 @@
1
+ import {
2
+ makeSqlSubscriptionStore,
3
+ SqlSubscriptionTransaction,
4
+ } from "@effect-agent/thread/SqlSubscriptionStore";
5
+ import {
6
+ SourcePartition,
7
+ SubscriptionError,
8
+ SubscriptionStore,
9
+ } from "@effect-agent/thread/Subscription";
10
+ import { Effect, Layer, Schema } from "effect";
11
+ import * as SqlClientService from "effect/unstable/sql/SqlClient";
12
+
13
+ import { initializeSqliteJournal } from "./internal/sqlite-journal.ts";
14
+ import type { SqliteStorageConfig } from "./SqliteStorageConfig.ts";
15
+ import type { SqliteStorageFailpoint } from "./SqliteStorageFailpoint.ts";
16
+ import type { SqliteStorageInitializationError } from "./SqliteThreadStore.ts";
17
+
18
+ const transactionLayer = Layer.effect(
19
+ SqlSubscriptionTransaction,
20
+ Effect.gen(function* () {
21
+ const sql = yield* SqlClientService.SqlClient;
22
+
23
+ return SqlSubscriptionTransaction.of({
24
+ run: (body) =>
25
+ sql
26
+ .withTransaction(body)
27
+ .pipe(
28
+ Effect.catchTag("SqlError", () =>
29
+ Effect.fail(SubscriptionError.make({ reason: "storage", code: "transaction" })),
30
+ ),
31
+ ),
32
+ });
33
+ }),
34
+ );
35
+
36
+ const makeSubscriptionStore = Effect.fn("SqliteSubscriptionStore.make")(function* (
37
+ owned: SourcePartition,
38
+ ) {
39
+ const partition = yield* Schema.decodeUnknownEffect(SourcePartition)(owned).pipe(
40
+ Effect.mapError(() => SubscriptionError.make({ reason: "validation", code: "partition" })),
41
+ );
42
+
43
+ yield* initializeSqliteJournal();
44
+
45
+ return yield* makeSqlSubscriptionStore(partition, {
46
+ maxStoredJsonLength: 16 * 1024 * 1024,
47
+ });
48
+ });
49
+
50
+ export const subscriptionStoreLayer = (
51
+ partition: SourcePartition,
52
+ ): Layer.Layer<
53
+ SubscriptionStore,
54
+ SqliteStorageInitializationError | SubscriptionError,
55
+ SqliteStorageConfig | SqliteStorageFailpoint | SqlClientService.SqlClient
56
+ > =>
57
+ Layer.effect(SubscriptionStore, makeSubscriptionStore(partition)).pipe(
58
+ Layer.provide(transactionLayer),
59
+ );