@dudousxd/nestjs-durable-store-drizzle 0.28.0 → 0.29.1

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/index.d.cts CHANGED
@@ -8,9 +8,16 @@ type DrizzleSqlite = BaseSQLiteDatabase<'sync' | 'async', unknown>;
8
8
  * epoch-ms integers (SQLite's 64-bit integers hold them fine). For Postgres or MySQL, use the
9
9
  * MikroORM, TypeORM or Prisma adapter.
10
10
  */
11
+ interface DrizzleStateStoreOptions {
12
+ /**
13
+ * Not supported: SQLite has no schemas. Setting it throws at construction, so a config meant for
14
+ * Postgres never runs against SQLite with its tables somewhere else.
15
+ */
16
+ schema?: string | undefined;
17
+ }
11
18
  declare class DrizzleStateStore implements StateStore {
12
19
  private readonly db;
13
- constructor(db: DrizzleSqlite);
20
+ constructor(db: DrizzleSqlite, options?: DrizzleStateStoreOptions);
14
21
  tryAdmitSingleton(runId: string, tag: string, workflow: string, limit: number, retryWakeAt?: number): Promise<boolean>;
15
22
  createRun(run: WorkflowRun): Promise<void>;
16
23
  updateRun(runId: string, inputPatch: Partial<WorkflowRun>): Promise<void>;
@@ -2741,4 +2748,4 @@ declare const durableSchema: {
2741
2748
  */
2742
2749
  declare function durableManagedTables(): string[];
2743
2750
 
2744
- export { DEFAULT_NAMESPACE, DrizzleStateStore, bufferedEvents, bufferedSignals, durableManagedTables, durableSchedules, durableSchema, runAttributes, signalIds, signalWaiters, stepCheckpoints, workflowRuns };
2751
+ export { DEFAULT_NAMESPACE, DrizzleStateStore, type DrizzleStateStoreOptions, bufferedEvents, bufferedSignals, durableManagedTables, durableSchedules, durableSchema, runAttributes, signalIds, signalWaiters, stepCheckpoints, workflowRuns };
package/dist/index.d.ts CHANGED
@@ -8,9 +8,16 @@ type DrizzleSqlite = BaseSQLiteDatabase<'sync' | 'async', unknown>;
8
8
  * epoch-ms integers (SQLite's 64-bit integers hold them fine). For Postgres or MySQL, use the
9
9
  * MikroORM, TypeORM or Prisma adapter.
10
10
  */
11
+ interface DrizzleStateStoreOptions {
12
+ /**
13
+ * Not supported: SQLite has no schemas. Setting it throws at construction, so a config meant for
14
+ * Postgres never runs against SQLite with its tables somewhere else.
15
+ */
16
+ schema?: string | undefined;
17
+ }
11
18
  declare class DrizzleStateStore implements StateStore {
12
19
  private readonly db;
13
- constructor(db: DrizzleSqlite);
20
+ constructor(db: DrizzleSqlite, options?: DrizzleStateStoreOptions);
14
21
  tryAdmitSingleton(runId: string, tag: string, workflow: string, limit: number, retryWakeAt?: number): Promise<boolean>;
15
22
  createRun(run: WorkflowRun): Promise<void>;
16
23
  updateRun(runId: string, inputPatch: Partial<WorkflowRun>): Promise<void>;
@@ -2741,4 +2748,4 @@ declare const durableSchema: {
2741
2748
  */
2742
2749
  declare function durableManagedTables(): string[];
2743
2750
 
2744
- export { DEFAULT_NAMESPACE, DrizzleStateStore, bufferedEvents, bufferedSignals, durableManagedTables, durableSchedules, durableSchema, runAttributes, signalIds, signalWaiters, stepCheckpoints, workflowRuns };
2751
+ export { DEFAULT_NAMESPACE, DrizzleStateStore, type DrizzleStateStoreOptions, bufferedEvents, bufferedSignals, durableManagedTables, durableSchedules, durableSchema, runAttributes, signalIds, signalWaiters, stepCheckpoints, workflowRuns };
package/dist/index.js CHANGED
@@ -347,8 +347,11 @@ var DrizzleStateStore = class {
347
347
  __name(this, "DrizzleStateStore");
348
348
  }
349
349
  db;
350
- constructor(db) {
350
+ constructor(db, options = {}) {
351
351
  this.db = db;
352
+ if (options.schema !== void 0) {
353
+ throw new Error(`[nestjs-durable] store-drizzle: the schema option (${JSON.stringify(options.schema)}) is not supported on SQLite, which has no schemas. Remove it, or use DrizzlePgStateStore from '@dudousxd/nestjs-durable-store-drizzle/pg'.`);
354
+ }
352
355
  }
353
356
  async tryAdmitSingleton(runId, tag, workflow, limit, retryWakeAt) {
354
357
  return this.db.transaction((tx) => {
@@ -609,7 +612,9 @@ var DrizzleStateStore = class {
609
612
  error: s.error ?? null,
610
613
  events: s.events ?? null,
611
614
  startedAt: s.startedAt.getTime(),
612
- finishedAt: s.finishedAt.getTime()
615
+ finishedAt: s.finishedAt.getTime(),
616
+ // A settled step has no dispatch lease left.
617
+ wakeAt: null
613
618
  });
614
619
  }
615
620
  const writes = [];
@@ -1331,7 +1336,8 @@ var SETTLED_FIELDS = [
1331
1336
  "error",
1332
1337
  "events",
1333
1338
  "startedAt",
1334
- "finishedAt"
1339
+ "finishedAt",
1340
+ "wakeAt"
1335
1341
  ];
1336
1342
  function inSequence(steps, from = 0) {
1337
1343
  for (let i = from; i < steps.length; i += 1) {