@dudousxd/nestjs-durable-store-prisma 0.25.0 → 0.27.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.
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { StateStore, WorkflowRun, RunStatus, RetentionPolicy, StepCheckpoint, StepSettlement, OwnedLeaseReclaim, RunQuery, RunFacetQuery, RunFacetRow, RunValueAxis, RunValueFacetOptions, RunValueFacetRow, ScheduleRecord, ScheduleQuery, CheckpointStat, CheckpointQuery, SignalWaiter, ChildWait, BufferedSignalRow as BufferedSignalRow$1 } from '@dudousxd/nestjs-durable-core';
1
+ import { StateStore, StepResultSettlement, StepCheckpoint, WorkflowRun, RunStatus, RetentionPolicy, StepSettlement, OwnedLeaseReclaim, RunQuery, RunFacetQuery, RunFacetRow, RunValueAxis, RunValueFacetOptions, RunValueFacetRow, ScheduleRecord, ScheduleQuery, CheckpointStat, CheckpointQuery, SignalWaiter, ChildWait, BufferedSignalRow as BufferedSignalRow$1 } from '@dudousxd/nestjs-durable-core';
2
2
 
3
3
  interface RunRow {
4
4
  id: string;
@@ -19,6 +19,9 @@ interface RunRow {
19
19
  /** NOT NULL in the schema (defaulted to `'default'`), so every row carries a real namespace. */
20
20
  namespace: string;
21
21
  origin: string | null;
22
+ /** The customer (tenancy); NULL = none. */
23
+ tenantId: string | null;
24
+ tenantKind: string | null;
22
25
  createdAt: Date;
23
26
  updatedAt: Date;
24
27
  }
@@ -87,6 +90,11 @@ interface Delegate<Row> {
87
90
  * not model rows, so the result type is stated at the call site rather than derived from `Row`. */
88
91
  groupBy(args: Args): Promise<Record<string, unknown>[]>;
89
92
  }
93
+ interface SignalIdRow {
94
+ token: string;
95
+ signalId: string;
96
+ expiresAt: bigint;
97
+ }
90
98
  interface ScheduleRow {
91
99
  id: string;
92
100
  namespace: string;
@@ -96,6 +104,8 @@ interface ScheduleRow {
96
104
  tags: unknown;
97
105
  spec: unknown;
98
106
  state: unknown;
107
+ tenantId: string | null;
108
+ tenantKind: string | null;
99
109
  createdAt: Date;
100
110
  updatedAt: Date;
101
111
  }
@@ -108,6 +118,8 @@ interface DurablePrismaTx {
108
118
  durableBufferedEvent: Delegate<BufferedEventRow>;
109
119
  /** Only needed for persisted schedules (`engine.schedules`) — add the `DurableSchedule` model. */
110
120
  durableSchedule?: Delegate<ScheduleRow>;
121
+ /** Only needed for signal dedupe (`signal(..., { id })`) — add the `DurableSignalId` model. */
122
+ durableSignalId?: Delegate<SignalIdRow>;
111
123
  }
112
124
  interface DurablePrismaClient extends DurablePrismaTx {
113
125
  /** Prisma's interactive-transaction form: runs `fn` with a tx-scoped client and commits on resolve. */
@@ -125,6 +137,12 @@ interface DurablePrismaClient extends DurablePrismaTx {
125
137
  */
126
138
  declare class PrismaStateStore implements StateStore {
127
139
  private readonly db;
140
+ readonly settleResultsIfPending?: (results: StepResultSettlement[]) => Promise<(StepCheckpoint | null)[]>;
141
+ readonly insertCheckpointIfAbsent?: (checkpoint: StepCheckpoint) => Promise<boolean>;
142
+ readonly tryLockRunAndGet?: (runId: string, owner: string, leaseUntilMs: number, nowMs: number) => Promise<WorkflowRun | null>;
143
+ readonly claimPendingRuns?: (limit: number, owner: string, leaseUntilMs: number, nowMs: number, namespace?: string) => Promise<WorkflowRun[]>;
144
+ /** Raw single-statement writes on Postgres/MySQL (Prisma wraps `updateMany` in a transaction). */
145
+ private readonly fast?;
128
146
  constructor(db: DurablePrismaClient);
129
147
  tryAdmitSingleton(runId: string, tag: string, workflow: string, limit: number, retryWakeAt?: number): Promise<boolean>;
130
148
  createRun(run: WorkflowRun): Promise<void>;
@@ -214,6 +232,14 @@ declare class PrismaStateStore implements StateStore {
214
232
  takeBufferedSignal(token: string): Promise<{
215
233
  payload: unknown;
216
234
  } | null>;
235
+ takeOldestBufferedSignal(tokens: string[]): Promise<{
236
+ token: string;
237
+ payload: unknown;
238
+ } | null>;
239
+ private signalIds;
240
+ claimSignalId(token: string, id: string, expiresAt: number, nowMs: number): Promise<boolean>;
241
+ releaseSignalId(token: string, id: string): Promise<void>;
242
+ deleteExpiredSignalIds(nowMs: number, limit: number): Promise<number>;
217
243
  listBufferedSignals(tokenPrefix: string, afterId: string | undefined, limit: number): Promise<BufferedSignalRow$1[]>;
218
244
  deleteBufferedSignals(ids: string[]): Promise<void>;
219
245
  bufferEvent(input: {
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { StateStore, WorkflowRun, RunStatus, RetentionPolicy, StepCheckpoint, StepSettlement, OwnedLeaseReclaim, RunQuery, RunFacetQuery, RunFacetRow, RunValueAxis, RunValueFacetOptions, RunValueFacetRow, ScheduleRecord, ScheduleQuery, CheckpointStat, CheckpointQuery, SignalWaiter, ChildWait, BufferedSignalRow as BufferedSignalRow$1 } from '@dudousxd/nestjs-durable-core';
1
+ import { StateStore, StepResultSettlement, StepCheckpoint, WorkflowRun, RunStatus, RetentionPolicy, StepSettlement, OwnedLeaseReclaim, RunQuery, RunFacetQuery, RunFacetRow, RunValueAxis, RunValueFacetOptions, RunValueFacetRow, ScheduleRecord, ScheduleQuery, CheckpointStat, CheckpointQuery, SignalWaiter, ChildWait, BufferedSignalRow as BufferedSignalRow$1 } from '@dudousxd/nestjs-durable-core';
2
2
 
3
3
  interface RunRow {
4
4
  id: string;
@@ -19,6 +19,9 @@ interface RunRow {
19
19
  /** NOT NULL in the schema (defaulted to `'default'`), so every row carries a real namespace. */
20
20
  namespace: string;
21
21
  origin: string | null;
22
+ /** The customer (tenancy); NULL = none. */
23
+ tenantId: string | null;
24
+ tenantKind: string | null;
22
25
  createdAt: Date;
23
26
  updatedAt: Date;
24
27
  }
@@ -87,6 +90,11 @@ interface Delegate<Row> {
87
90
  * not model rows, so the result type is stated at the call site rather than derived from `Row`. */
88
91
  groupBy(args: Args): Promise<Record<string, unknown>[]>;
89
92
  }
93
+ interface SignalIdRow {
94
+ token: string;
95
+ signalId: string;
96
+ expiresAt: bigint;
97
+ }
90
98
  interface ScheduleRow {
91
99
  id: string;
92
100
  namespace: string;
@@ -96,6 +104,8 @@ interface ScheduleRow {
96
104
  tags: unknown;
97
105
  spec: unknown;
98
106
  state: unknown;
107
+ tenantId: string | null;
108
+ tenantKind: string | null;
99
109
  createdAt: Date;
100
110
  updatedAt: Date;
101
111
  }
@@ -108,6 +118,8 @@ interface DurablePrismaTx {
108
118
  durableBufferedEvent: Delegate<BufferedEventRow>;
109
119
  /** Only needed for persisted schedules (`engine.schedules`) — add the `DurableSchedule` model. */
110
120
  durableSchedule?: Delegate<ScheduleRow>;
121
+ /** Only needed for signal dedupe (`signal(..., { id })`) — add the `DurableSignalId` model. */
122
+ durableSignalId?: Delegate<SignalIdRow>;
111
123
  }
112
124
  interface DurablePrismaClient extends DurablePrismaTx {
113
125
  /** Prisma's interactive-transaction form: runs `fn` with a tx-scoped client and commits on resolve. */
@@ -125,6 +137,12 @@ interface DurablePrismaClient extends DurablePrismaTx {
125
137
  */
126
138
  declare class PrismaStateStore implements StateStore {
127
139
  private readonly db;
140
+ readonly settleResultsIfPending?: (results: StepResultSettlement[]) => Promise<(StepCheckpoint | null)[]>;
141
+ readonly insertCheckpointIfAbsent?: (checkpoint: StepCheckpoint) => Promise<boolean>;
142
+ readonly tryLockRunAndGet?: (runId: string, owner: string, leaseUntilMs: number, nowMs: number) => Promise<WorkflowRun | null>;
143
+ readonly claimPendingRuns?: (limit: number, owner: string, leaseUntilMs: number, nowMs: number, namespace?: string) => Promise<WorkflowRun[]>;
144
+ /** Raw single-statement writes on Postgres/MySQL (Prisma wraps `updateMany` in a transaction). */
145
+ private readonly fast?;
128
146
  constructor(db: DurablePrismaClient);
129
147
  tryAdmitSingleton(runId: string, tag: string, workflow: string, limit: number, retryWakeAt?: number): Promise<boolean>;
130
148
  createRun(run: WorkflowRun): Promise<void>;
@@ -214,6 +232,14 @@ declare class PrismaStateStore implements StateStore {
214
232
  takeBufferedSignal(token: string): Promise<{
215
233
  payload: unknown;
216
234
  } | null>;
235
+ takeOldestBufferedSignal(tokens: string[]): Promise<{
236
+ token: string;
237
+ payload: unknown;
238
+ } | null>;
239
+ private signalIds;
240
+ claimSignalId(token: string, id: string, expiresAt: number, nowMs: number): Promise<boolean>;
241
+ releaseSignalId(token: string, id: string): Promise<void>;
242
+ deleteExpiredSignalIds(nowMs: number, limit: number): Promise<number>;
217
243
  listBufferedSignals(tokenPrefix: string, afterId: string | undefined, limit: number): Promise<BufferedSignalRow$1[]>;
218
244
  deleteBufferedSignals(ids: string[]): Promise<void>;
219
245
  bufferEvent(input: {