@dudousxd/nestjs-durable-store-drizzle 0.24.0 → 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.
- package/dist/index.cjs +19 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +20 -1
- package/dist/index.js.map +1 -1
- package/dist/pg/index.cjs +19 -0
- package/dist/pg/index.cjs.map +1 -1
- package/dist/pg/index.d.cts +4 -1
- package/dist/pg/index.d.ts +4 -1
- package/dist/pg/index.js +20 -1
- package/dist/pg/index.js.map +1 -1
- package/package.json +4 -4
package/dist/pg/index.d.cts
CHANGED
|
@@ -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
|
/**
|
|
@@ -115,6 +115,7 @@ declare class DrizzlePgStateStore implements StateStore {
|
|
|
115
115
|
updateRun(runId: string, inputPatch: Partial<WorkflowRun>): Promise<void>;
|
|
116
116
|
updateRunIf(runId: string, expectedStatuses: RunStatus[], inputPatch: Partial<WorkflowRun>): Promise<boolean>;
|
|
117
117
|
getRun(runId: string): Promise<WorkflowRun | null>;
|
|
118
|
+
getRuns(runIds: string[]): Promise<WorkflowRun[]>;
|
|
118
119
|
deleteRun(runId: string): Promise<void>;
|
|
119
120
|
deleteRuns(runIds: string[]): Promise<void>;
|
|
120
121
|
pruneTerminalRuns(policy: RetentionPolicy, nowMs: number, limit: number): Promise<number>;
|
|
@@ -175,6 +176,8 @@ declare class DrizzlePgStateStore implements StateStore {
|
|
|
175
176
|
takeBufferedSignal(token: string): Promise<{
|
|
176
177
|
payload: unknown;
|
|
177
178
|
} | null>;
|
|
179
|
+
listBufferedSignals(tokenPrefix: string, afterId: string | undefined, limit: number): Promise<BufferedSignalRow[]>;
|
|
180
|
+
deleteBufferedSignals(ids: string[]): Promise<void>;
|
|
178
181
|
bufferEvent(input: {
|
|
179
182
|
name: string;
|
|
180
183
|
payload: unknown;
|
package/dist/pg/index.d.ts
CHANGED
|
@@ -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
|
/**
|
|
@@ -115,6 +115,7 @@ declare class DrizzlePgStateStore implements StateStore {
|
|
|
115
115
|
updateRun(runId: string, inputPatch: Partial<WorkflowRun>): Promise<void>;
|
|
116
116
|
updateRunIf(runId: string, expectedStatuses: RunStatus[], inputPatch: Partial<WorkflowRun>): Promise<boolean>;
|
|
117
117
|
getRun(runId: string): Promise<WorkflowRun | null>;
|
|
118
|
+
getRuns(runIds: string[]): Promise<WorkflowRun[]>;
|
|
118
119
|
deleteRun(runId: string): Promise<void>;
|
|
119
120
|
deleteRuns(runIds: string[]): Promise<void>;
|
|
120
121
|
pruneTerminalRuns(policy: RetentionPolicy, nowMs: number, limit: number): Promise<number>;
|
|
@@ -175,6 +176,8 @@ declare class DrizzlePgStateStore implements StateStore {
|
|
|
175
176
|
takeBufferedSignal(token: string): Promise<{
|
|
176
177
|
payload: unknown;
|
|
177
178
|
} | null>;
|
|
179
|
+
listBufferedSignals(tokenPrefix: string, afterId: string | undefined, limit: number): Promise<BufferedSignalRow[]>;
|
|
180
|
+
deleteBufferedSignals(ids: string[]): Promise<void>;
|
|
178
181
|
bufferEvent(input: {
|
|
179
182
|
name: string;
|
|
180
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";
|
|
@@ -477,6 +477,13 @@ var DrizzlePgStateStore = class _DrizzlePgStateStore {
|
|
|
477
477
|
const rows = await this.db.select().from(durableWorkflowRuns).where(and(eq(durableWorkflowRuns.id, runId), this.scope())).limit(1);
|
|
478
478
|
return rows[0] ? fromRunRow(rows[0]) : null;
|
|
479
479
|
}
|
|
480
|
+
async getRuns(runIds) {
|
|
481
|
+
if (runIds.length === 0) return [];
|
|
482
|
+
const rows = await this.db.select().from(durableWorkflowRuns).where(and(inArray(durableWorkflowRuns.id, [
|
|
483
|
+
...new Set(runIds)
|
|
484
|
+
]), this.scope()));
|
|
485
|
+
return rows.map(fromRunRow);
|
|
486
|
+
}
|
|
480
487
|
async deleteRun(runId) {
|
|
481
488
|
await this.db.transaction(async (tx) => {
|
|
482
489
|
await deleteRunsCascade(tx, [
|
|
@@ -896,6 +903,18 @@ var DrizzlePgStateStore = class _DrizzlePgStateStore {
|
|
|
896
903
|
payload: row.payload ?? void 0
|
|
897
904
|
} : null;
|
|
898
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
|
+
}
|
|
899
918
|
async bufferEvent(input) {
|
|
900
919
|
await this.db.insert(durableBufferedEvents).values({
|
|
901
920
|
id: input.id,
|