@dudousxd/nestjs-durable-store-drizzle 0.24.1 → 0.24.2

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.
@@ -1,6 +1,6 @@
1
1
  import * as drizzle_orm_pg_core from 'drizzle-orm/pg-core';
2
2
  import { PgDatabase } from 'drizzle-orm/pg-core';
3
- import { StateStore, WorkflowRun, RunStatus, RetentionPolicy, StepCheckpoint, StoreTransaction, OwnedLeaseReclaim, RunQuery, RunFacetQuery, RunFacetRow, RunValueAxis, RunValueFacetOptions, RunValueFacetRow, ScheduleRecord, ScheduleQuery, CheckpointStat, CheckpointQuery, SignalWaiter, ChildWait } from '@dudousxd/nestjs-durable-core';
3
+ import { StateStore, WorkflowRun, RunStatus, RetentionPolicy, StepCheckpoint, StoreTransaction, OwnedLeaseReclaim, RunQuery, RunFacetQuery, RunFacetRow, RunValueAxis, RunValueFacetOptions, RunValueFacetRow, ScheduleRecord, ScheduleQuery, CheckpointStat, CheckpointQuery, SignalWaiter, ChildWait, BufferedSignalRow } from '@dudousxd/nestjs-durable-core';
4
4
  import { SQL } from 'drizzle-orm';
5
5
 
6
6
  /**
@@ -176,6 +176,8 @@ declare class DrizzlePgStateStore implements StateStore {
176
176
  takeBufferedSignal(token: string): Promise<{
177
177
  payload: unknown;
178
178
  } | null>;
179
+ listBufferedSignals(tokenPrefix: string, afterId: string | undefined, limit: number): Promise<BufferedSignalRow[]>;
180
+ deleteBufferedSignals(ids: string[]): Promise<void>;
179
181
  bufferEvent(input: {
180
182
  name: string;
181
183
  payload: unknown;
@@ -1,6 +1,6 @@
1
1
  import * as drizzle_orm_pg_core from 'drizzle-orm/pg-core';
2
2
  import { PgDatabase } from 'drizzle-orm/pg-core';
3
- import { StateStore, WorkflowRun, RunStatus, RetentionPolicy, StepCheckpoint, StoreTransaction, OwnedLeaseReclaim, RunQuery, RunFacetQuery, RunFacetRow, RunValueAxis, RunValueFacetOptions, RunValueFacetRow, ScheduleRecord, ScheduleQuery, CheckpointStat, CheckpointQuery, SignalWaiter, ChildWait } from '@dudousxd/nestjs-durable-core';
3
+ import { StateStore, WorkflowRun, RunStatus, RetentionPolicy, StepCheckpoint, StoreTransaction, OwnedLeaseReclaim, RunQuery, RunFacetQuery, RunFacetRow, RunValueAxis, RunValueFacetOptions, RunValueFacetRow, ScheduleRecord, ScheduleQuery, CheckpointStat, CheckpointQuery, SignalWaiter, ChildWait, BufferedSignalRow } from '@dudousxd/nestjs-durable-core';
4
4
  import { SQL } from 'drizzle-orm';
5
5
 
6
6
  /**
@@ -176,6 +176,8 @@ declare class DrizzlePgStateStore implements StateStore {
176
176
  takeBufferedSignal(token: string): Promise<{
177
177
  payload: unknown;
178
178
  } | null>;
179
+ listBufferedSignals(tokenPrefix: string, afterId: string | undefined, limit: number): Promise<BufferedSignalRow[]>;
180
+ deleteBufferedSignals(ids: string[]): Promise<void>;
179
181
  bufferEvent(input: {
180
182
  name: string;
181
183
  payload: unknown;
package/dist/pg/index.js CHANGED
@@ -199,7 +199,7 @@ __name(ensureDrizzlePgDurableSchema, "ensureDrizzlePgDurableSchema");
199
199
 
200
200
  // src/pg/drizzle-pg-state-store.ts
201
201
  import { RUN_VALUE_FACET_SCAN, SINGLETON_ACTIVE_STATUSES, TERMINAL_RUN_STATUSES, attributePredicateOperands, axisIsRunColumn, clearTerminalSingletonAdmission, mergeRunFacetRows, mergeRunValueFacetRows, normalizeAttributeRows, parseDuration, runValueFacetsFromRuns, singletonAdmissionDenialPatch, singletonAdmissionTags } from "@dudousxd/nestjs-durable-core";
202
- import { and, asc, desc, eq, exists, getTableColumns, gte, inArray, isNotNull, isNull, like, lt, lte, notInArray, or, sql as sql3 } from "drizzle-orm";
202
+ import { and, asc, desc, eq, exists, getTableColumns, gt, gte, inArray, isNotNull, isNull, like, lt, lte, notInArray, or, sql as sql3 } from "drizzle-orm";
203
203
 
204
204
  // src/pg/schema.ts
205
205
  import { getTableName } from "drizzle-orm";
@@ -903,6 +903,18 @@ var DrizzlePgStateStore = class _DrizzlePgStateStore {
903
903
  payload: row.payload ?? void 0
904
904
  } : null;
905
905
  }
906
+ async listBufferedSignals(tokenPrefix, afterId, limit) {
907
+ const rows = await this.db.select().from(durableBufferedSignals).where(and(like(durableBufferedSignals.token, `${escapeLike(tokenPrefix)}%`), afterId !== void 0 ? gt(durableBufferedSignals.id, Number(afterId)) : void 0)).orderBy(asc(durableBufferedSignals.id)).limit(limit);
908
+ return rows.filter((r) => r.token.startsWith(tokenPrefix)).map((r) => ({
909
+ id: String(r.id),
910
+ token: r.token,
911
+ payload: r.payload ?? void 0
912
+ }));
913
+ }
914
+ async deleteBufferedSignals(ids) {
915
+ if (ids.length === 0) return;
916
+ await this.db.delete(durableBufferedSignals).where(inArray(durableBufferedSignals.id, ids.map(Number)));
917
+ }
906
918
  async bufferEvent(input) {
907
919
  await this.db.insert(durableBufferedEvents).values({
908
920
  id: input.id,