@effect-agent/storage-sqlite 0.1.0-beta.9 → 0.1.0-beta.91

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 (61) 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-DVWeaWLm.d.mts +86 -0
  14. package/dist/SqliteStorageError.d.mts +2 -0
  15. package/dist/SqliteStorageError.mjs +150 -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-BqmqX0CI.d.mts +11 -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 +1788 -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 +460 -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-Dy5v0HGe.mjs +346 -0
  39. package/dist/migrations-Dy5v0HGe.mjs.map +1 -0
  40. package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
  41. package/dist/sqlite-journal-CBOQDySe.mjs +998 -0
  42. package/dist/sqlite-journal-CBOQDySe.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} +10 -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} +912 -212
  53. package/src/SqliteSubscriptionStore.ts +55 -0
  54. package/src/SqliteThreadStore.ts +999 -0
  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} +156 -79
  58. package/src/internal/recovery-checkpoint-schema.ts +17 -0
  59. package/src/{sqlite-journal.ts → internal/sqlite-journal.ts} +751 -241
  60. package/dist/index.mjs.map +0 -1
  61. 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
+ );