@yieldstar/sqlite-runtime 0.5.0 → 0.6.0

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 (81) hide show
  1. package/dist/bun.js +15 -17
  2. package/dist/dao/effect-waiters-dao.d.ts +19 -0
  3. package/dist/dao/effect-waiters-dao.d.ts.map +1 -0
  4. package/dist/dao/effects-dao.d.ts +17 -0
  5. package/dist/dao/effects-dao.d.ts.map +1 -0
  6. package/dist/dao/executions-dao.d.ts +23 -0
  7. package/dist/dao/executions-dao.d.ts.map +1 -0
  8. package/dist/dao/start-requests-dao.d.ts +15 -0
  9. package/dist/dao/start-requests-dao.d.ts.map +1 -0
  10. package/dist/dao/step-response-dao.d.ts +1 -0
  11. package/dist/dao/step-response-dao.d.ts.map +1 -1
  12. package/dist/dao/store-waiters-dao.d.ts +26 -0
  13. package/dist/dao/store-waiters-dao.d.ts.map +1 -0
  14. package/dist/index-083bmj5k.js +800 -0
  15. package/dist/index-4kybaxga.js +798 -0
  16. package/dist/index-a8thbaee.js +718 -0
  17. package/dist/index-ag93sv33.js +664 -0
  18. package/dist/index-eabcgmaa.js +996 -0
  19. package/dist/index-gjfs8rn6.js +997 -0
  20. package/dist/index-h3h7r4b6.js +981 -0
  21. package/dist/index-ma984fze.js +718 -0
  22. package/dist/index-ne28djfn.js +718 -0
  23. package/dist/index-v6rn0pr6.js +664 -0
  24. package/dist/index-wx6vk994.js +669 -0
  25. package/dist/index.d.ts +3 -4
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +11 -13
  28. package/dist/node.js +15 -17
  29. package/dist/sqlite-effect.d.ts +30 -0
  30. package/dist/sqlite-effect.d.ts.map +1 -0
  31. package/dist/sqlite-execution.d.ts +54 -0
  32. package/dist/sqlite-execution.d.ts.map +1 -0
  33. package/dist/sqlite-heap.d.ts +12 -4
  34. package/dist/sqlite-heap.d.ts.map +1 -1
  35. package/dist/sqlite-runtime.d.ts +22 -0
  36. package/dist/sqlite-runtime.d.ts.map +1 -0
  37. package/dist/sqlite-store.d.ts +31 -25
  38. package/dist/sqlite-store.d.ts.map +1 -1
  39. package/dist/sqlite-transaction.d.ts +9 -0
  40. package/dist/sqlite-transaction.d.ts.map +1 -0
  41. package/package.json +2 -2
  42. package/src/dao/effect-waiters-dao.ts +63 -0
  43. package/src/dao/effects-dao.ts +123 -0
  44. package/src/dao/executions-dao.ts +188 -0
  45. package/src/dao/start-requests-dao.ts +72 -0
  46. package/src/dao/step-response-dao.ts +16 -1
  47. package/src/dao/store-waiters-dao.ts +92 -0
  48. package/src/index.ts +6 -4
  49. package/src/sqlite-effect.ts +99 -0
  50. package/src/sqlite-execution.ts +238 -0
  51. package/src/sqlite-heap.ts +64 -12
  52. package/src/sqlite-runtime.ts +36 -0
  53. package/src/sqlite-store.ts +184 -520
  54. package/src/sqlite-transaction.ts +19 -0
  55. package/dist/dao/task-queue-dao.d.ts +0 -21
  56. package/dist/dao/task-queue-dao.d.ts.map +0 -1
  57. package/dist/dao/timers-dao.d.ts +0 -22
  58. package/dist/dao/timers-dao.d.ts.map +0 -1
  59. package/dist/index-4vq70w0r.js +0 -796
  60. package/dist/index-s8wqgfwt.js +0 -19
  61. package/dist/index-x891hxwg.js +0 -796
  62. package/dist/node-driver.d.ts +0 -10
  63. package/dist/node-driver.d.ts.map +0 -1
  64. package/dist/sqlite-event-loop.d.ts +0 -18
  65. package/dist/sqlite-event-loop.d.ts.map +0 -1
  66. package/dist/sqlite-scheduler.d.ts +0 -13
  67. package/dist/sqlite-scheduler.d.ts.map +0 -1
  68. package/dist/sqlite-store.test.d.ts +0 -2
  69. package/dist/sqlite-store.test.d.ts.map +0 -1
  70. package/dist/sqlite-task-queue.d.ts +0 -26
  71. package/dist/sqlite-task-queue.d.ts.map +0 -1
  72. package/dist/sqlite-timers.d.ts +0 -18
  73. package/dist/sqlite-timers.d.ts.map +0 -1
  74. package/src/dao/task-queue-dao.ts +0 -79
  75. package/src/dao/timers-dao.ts +0 -81
  76. package/src/sqlite-event-loop.ts +0 -41
  77. package/src/sqlite-scheduler.ts +0 -24
  78. package/src/sqlite-task-queue.ts +0 -64
  79. package/src/sqlite-timers.ts +0 -40
  80. package/tsconfig.tsbuildinfo +0 -1
  81. /package/dist/{index-h7bm9xg4.js → index-dapqh99v.js} +0 -0
package/dist/bun.js CHANGED
@@ -1,15 +1,14 @@
1
+ import {
2
+ SqliteExecutionClient2,
3
+ SqliteEffectClient2,
4
+ SqliteHeapClient2,
5
+ SqliteStoreClient2,
6
+ SqliteRuntime2
7
+ } from "./index-h3h7r4b6.js";
1
8
  import {
2
9
  createSqliteDriver,
3
10
  wrapSqliteStatement
4
- } from "./index-h7bm9xg4.js";
5
- import {
6
- SqliteEventLoop,
7
- SqliteHeapClient,
8
- SqliteSchedulerClient,
9
- SqliteStoreClient,
10
- SqliteTaskQueueClient,
11
- SqliteTimersClient
12
- } from "./index-4vq70w0r.js";
11
+ } from "./index-dapqh99v.js";
13
12
 
14
13
  // src/bun.ts
15
14
  import { Database } from "bun:sqlite";
@@ -32,12 +31,11 @@ function createSqliteDb(opts) {
32
31
  return createSqliteDriver((path) => new BunSqliteDriver(new Database(path, { create: true })), opts);
33
32
  }
34
33
  export {
35
- createSqliteDb,
36
- SqliteTimersClient,
37
- SqliteTaskQueueClient,
38
- SqliteStoreClient,
39
- SqliteSchedulerClient,
40
- SqliteHeapClient,
41
- SqliteEventLoop,
42
- BunSqliteDriver
34
+ BunSqliteDriver,
35
+ SqliteEffectClient2 as SqliteEffectClient,
36
+ SqliteExecutionClient2 as SqliteExecutionClient,
37
+ SqliteHeapClient2 as SqliteHeapClient,
38
+ SqliteRuntime2 as SqliteRuntime,
39
+ SqliteStoreClient2 as SqliteStoreClient,
40
+ createSqliteDb
43
41
  };
@@ -0,0 +1,19 @@
1
+ import type { SqliteDriver } from "../sqlite-driver";
2
+ /**
3
+ * Effect waiters live in the same database as step records, so the heap can
4
+ * delete a waiter in the same transaction that records its step's result.
5
+ * Callers own the surrounding transaction.
6
+ */
7
+ export declare class EffectWaitersDao {
8
+ private db;
9
+ constructor(db: SqliteDriver);
10
+ setupDb(): void;
11
+ upsertWaiter(waiter: {
12
+ effectId: string;
13
+ executionId: string;
14
+ stepKey: string;
15
+ }): void;
16
+ getWaitingExecutionIds(effectId: string): string[];
17
+ deleteStepWaiters(executionId: string, stepKey: string): void;
18
+ }
19
+ //# sourceMappingURL=effect-waiters-dao.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"effect-waiters-dao.d.ts","sourceRoot":"","sources":["../../src/dao/effect-waiters-dao.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAMrD;;;;GAIG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,EAAE,CAAe;gBAEb,EAAE,EAAE,YAAY;IAK5B,OAAO;IAaP,YAAY,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE;IAc/E,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE;IASlD,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAOvD"}
@@ -0,0 +1,17 @@
1
+ import type { EffectState } from "@yieldstar/core";
2
+ import type { SqliteDriver } from "../sqlite-driver";
3
+ /**
4
+ * Effect records and their conflict reports. Neither is deleted with an
5
+ * execution. Callers own the surrounding transaction.
6
+ */
7
+ export declare class EffectsDao {
8
+ private db;
9
+ constructor(db: SqliteDriver);
10
+ setupDb(): void;
11
+ getState(effectId: string): EffectState | undefined;
12
+ insertState(state: EffectState): void;
13
+ /** Writes a transition from `before` to `after`: the settlement and any new conflict reports. */
14
+ updateState(before: EffectState, after: EffectState): void;
15
+ private insertConflict;
16
+ }
17
+ //# sourceMappingURL=effects-dao.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"effects-dao.d.ts","sourceRoot":"","sources":["../../src/dao/effects-dao.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAuB,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAgBrD;;;GAGG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,EAAE,CAAe;gBAEb,EAAE,EAAE,YAAY;IAK5B,OAAO;IAmBP,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;IA2BnD,WAAW,CAAC,KAAK,EAAE,WAAW;IAe9B,iGAAiG;IACjG,WAAW,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW;IAkBnD,OAAO,CAAC,cAAc;CAavB"}
@@ -0,0 +1,23 @@
1
+ import type { ExecutionState } from "@yieldstar/core";
2
+ import type { SqliteDriver } from "../sqlite-driver";
3
+ /**
4
+ * Persists every ExecutionState field, plus `next_claim_at` (derived with
5
+ * nextClaimAt) so claimDue can find due executions through an index.
6
+ * Callers own the surrounding transaction.
7
+ */
8
+ export declare class ExecutionsDao {
9
+ private db;
10
+ constructor(db: SqliteDriver);
11
+ setupDb(): void;
12
+ getState(executionId: string): ExecutionState | undefined;
13
+ /**
14
+ * Up to `limit` claimable execution IDs, earliest due first. `now` is a
15
+ * millisecond Unix timestamp from the runtime clock.
16
+ */
17
+ getClaimableIds(now: number, limit: number): string[];
18
+ /** Returns false when the execution ID is already in use. */
19
+ insertState(state: ExecutionState): boolean;
20
+ /** Leaves the parent link as inserted: it is immutable. */
21
+ updateState(state: ExecutionState): void;
22
+ }
23
+ //# sourceMappingURL=executions-dao.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executions-dao.d.ts","sourceRoot":"","sources":["../../src/dao/executions-dao.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AA0BrD;;;;GAIG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,EAAE,CAAe;gBAEb,EAAE,EAAE,YAAY;IAK5B,OAAO;IA0BP,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IASzD;;;OAGG;IACH,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAY1C,6DAA6D;IAC7D,WAAW,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO;IAwB3C,2DAA2D;IAC3D,WAAW,CAAC,KAAK,EAAE,cAAc;CAsBlC"}
@@ -0,0 +1,15 @@
1
+ import type { StartRequestState } from "@yieldstar/core";
2
+ import type { SqliteDriver } from "../sqlite-driver";
3
+ /**
4
+ * Start requests recorded by `ExecutionClient.start`, keyed by the caller's
5
+ * execution ID and step key. Callers own the surrounding transaction, which
6
+ * must also insert the target execution.
7
+ */
8
+ export declare class StartRequestsDao {
9
+ private db;
10
+ constructor(db: SqliteDriver);
11
+ setupDb(): void;
12
+ get(callerExecutionId: string, stepKey: string): StartRequestState | undefined;
13
+ insert(request: StartRequestState): void;
14
+ }
15
+ //# sourceMappingURL=start-requests-dao.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"start-requests-dao.d.ts","sourceRoot":"","sources":["../../src/dao/start-requests-dao.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAUrD;;;;GAIG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,EAAE,CAAe;gBAEb,EAAE,EAAE,YAAY;IAK5B,OAAO;IAaP,GAAG,CAAC,iBAAiB,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS;IAkB9E,MAAM,CAAC,OAAO,EAAE,iBAAiB;CAgBlC"}
@@ -13,6 +13,7 @@ export declare class StepResponsesDao {
13
13
  getAllSteps(): unknown[];
14
14
  deleteAll(): void;
15
15
  getLatestStepResponse(executionId: string, stepKey: string): StepReponseRow | undefined;
16
+ getStepResponse(executionId: string, stepKey: string, stepAttempt: number): StepReponseRow | undefined;
16
17
  insertStepResponse(executionId: string, stepKey: string, stepAttempt: number, stepDone: boolean, stepResponseJson: string): void;
17
18
  }
18
19
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"step-response-dao.d.ts","sourceRoot":"","sources":["../../src/dao/step-response-dao.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD,cAAM,cAAc;IAClB,YAAY,EAAG,MAAM,CAAC;IACtB,QAAQ,EAAG,MAAM,CAAC;IAClB,YAAY,EAAG,MAAM,CAAC;IACtB,SAAS,EAAG,CAAC,GAAG,CAAC,CAAC;IAClB,aAAa,EAAG,MAAM,CAAC;CACxB;AAED,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,EAAE,CAAe;gBAEb,EAAE,EAAE,YAAY;IAK5B,OAAO;IAeP,WAAW;IAKX,SAAS;IAKT,qBAAqB,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IAgB1D,kBAAkB,CAChB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,OAAO,EACjB,gBAAgB,EAAE,MAAM;CAe3B"}
1
+ {"version":3,"file":"step-response-dao.d.ts","sourceRoot":"","sources":["../../src/dao/step-response-dao.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD,cAAM,cAAc;IAClB,YAAY,EAAG,MAAM,CAAC;IACtB,QAAQ,EAAG,MAAM,CAAC;IAClB,YAAY,EAAG,MAAM,CAAC;IACtB,SAAS,EAAG,CAAC,GAAG,CAAC,CAAC;IAClB,aAAa,EAAG,MAAM,CAAC;CACxB;AAED,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,EAAE,CAAe;gBAEb,EAAE,EAAE,YAAY;IAK5B,OAAO;IAeP,WAAW;IAKX,SAAS;IAKT,qBAAqB,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IAgB1D,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM;IAezE,kBAAkB,CAChB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,OAAO,EACjB,gBAAgB,EAAE,MAAM;CAe3B"}
@@ -0,0 +1,26 @@
1
+ import type { StoreWaiter } from "@yieldstar/core";
2
+ import type { SqliteDriver } from "../sqlite-driver";
3
+ export declare class StoreWaiterRow {
4
+ workflow_id: string;
5
+ execution_id: string;
6
+ step_key: string;
7
+ store_name: string;
8
+ store_id: string;
9
+ since_version: number;
10
+ read_paths: string;
11
+ }
12
+ /**
13
+ * Store waiters live in the same database as step records, so the heap can
14
+ * delete a waiter in the same transaction that records its step's result.
15
+ * Callers own the surrounding transaction.
16
+ */
17
+ export declare class StoreWaitersDao {
18
+ private db;
19
+ constructor(db: SqliteDriver);
20
+ setupDb(): void;
21
+ upsertWaiter(waiter: StoreWaiter): void;
22
+ getStoreWaiters(storeName: string, storeId: string): StoreWaiterRow[];
23
+ deleteStoreWaiters(storeName: string, storeId: string): void;
24
+ deleteStepWaiters(executionId: string, stepKey: string): void;
25
+ }
26
+ //# sourceMappingURL=store-waiters-dao.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store-waiters-dao.d.ts","sourceRoot":"","sources":["../../src/dao/store-waiters-dao.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD,qBAAa,cAAc;IACzB,WAAW,EAAG,MAAM,CAAC;IACrB,YAAY,EAAG,MAAM,CAAC;IACtB,QAAQ,EAAG,MAAM,CAAC;IAClB,UAAU,EAAG,MAAM,CAAC;IACpB,QAAQ,EAAG,MAAM,CAAC;IAClB,aAAa,EAAG,MAAM,CAAC;IACvB,UAAU,EAAG,MAAM,CAAC;CACrB;AAED;;;;GAIG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,EAAE,CAAe;gBAEb,EAAE,EAAE,YAAY;IAK5B,OAAO;IAiBP,YAAY,CAAC,MAAM,EAAE,WAAW;IAwBhC,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IASlD,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IAQrD,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAOvD"}