@dudousxd/nestjs-durable-store-drizzle 0.24.2 → 0.24.3
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 +108 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +108 -22
- package/dist/index.js.map +1 -1
- package/dist/pg/index.cjs +24 -0
- package/dist/pg/index.cjs.map +1 -1
- package/dist/pg/index.d.cts +2 -0
- package/dist/pg/index.d.ts +2 -0
- package/dist/pg/index.js +24 -0
- package/dist/pg/index.js.map +1 -1
- package/package.json +4 -4
package/dist/pg/index.d.cts
CHANGED
|
@@ -120,7 +120,9 @@ declare class DrizzlePgStateStore implements StateStore {
|
|
|
120
120
|
deleteRuns(runIds: string[]): Promise<void>;
|
|
121
121
|
pruneTerminalRuns(policy: RetentionPolicy, nowMs: number, limit: number): Promise<number>;
|
|
122
122
|
getCheckpoint(runId: string, seq: number): Promise<StepCheckpoint | null>;
|
|
123
|
+
getCheckpoints(runId: string, seqs: number[]): Promise<StepCheckpoint[]>;
|
|
123
124
|
saveCheckpoint(checkpoint: StepCheckpoint): Promise<void>;
|
|
125
|
+
saveCheckpoints(checkpoints: StepCheckpoint[]): Promise<void>;
|
|
124
126
|
saveCheckpointIfPending(checkpoint: StepCheckpoint): Promise<boolean>;
|
|
125
127
|
saveCheckpointsIfPending(checkpoints: StepCheckpoint[]): Promise<boolean[]>;
|
|
126
128
|
transaction<T>(work: (tx: StoreTransaction) => Promise<T>): Promise<T>;
|
package/dist/pg/index.d.ts
CHANGED
|
@@ -120,7 +120,9 @@ declare class DrizzlePgStateStore implements StateStore {
|
|
|
120
120
|
deleteRuns(runIds: string[]): Promise<void>;
|
|
121
121
|
pruneTerminalRuns(policy: RetentionPolicy, nowMs: number, limit: number): Promise<number>;
|
|
122
122
|
getCheckpoint(runId: string, seq: number): Promise<StepCheckpoint | null>;
|
|
123
|
+
getCheckpoints(runId: string, seqs: number[]): Promise<StepCheckpoint[]>;
|
|
123
124
|
saveCheckpoint(checkpoint: StepCheckpoint): Promise<void>;
|
|
125
|
+
saveCheckpoints(checkpoints: StepCheckpoint[]): Promise<void>;
|
|
124
126
|
saveCheckpointIfPending(checkpoint: StepCheckpoint): Promise<boolean>;
|
|
125
127
|
saveCheckpointsIfPending(checkpoints: StepCheckpoint[]): Promise<boolean[]>;
|
|
126
128
|
transaction<T>(work: (tx: StoreTransaction) => Promise<T>): Promise<T>;
|
package/dist/pg/index.js
CHANGED
|
@@ -539,9 +539,33 @@ var DrizzlePgStateStore = class _DrizzlePgStateStore {
|
|
|
539
539
|
const rows = await this.db.select().from(durableStepCheckpoints).where(and(eq(durableStepCheckpoints.runId, runId), eq(durableStepCheckpoints.seq, seq))).limit(1);
|
|
540
540
|
return rows[0] ? fromCheckpointRow(rows[0]) : null;
|
|
541
541
|
}
|
|
542
|
+
async getCheckpoints(runId, seqs) {
|
|
543
|
+
const unique = [
|
|
544
|
+
...new Set(seqs)
|
|
545
|
+
];
|
|
546
|
+
const rows = [];
|
|
547
|
+
for (let at = 0; at < unique.length; at += 500) {
|
|
548
|
+
rows.push(...await this.db.select().from(durableStepCheckpoints).where(and(eq(durableStepCheckpoints.runId, runId), inArray(durableStepCheckpoints.seq, unique.slice(at, at + 500)))));
|
|
549
|
+
}
|
|
550
|
+
return rows.sort((a, b) => a.seq - b.seq).map(fromCheckpointRow);
|
|
551
|
+
}
|
|
542
552
|
async saveCheckpoint(checkpoint) {
|
|
543
553
|
await upsertCheckpoint(this.db, checkpoint);
|
|
544
554
|
}
|
|
555
|
+
async saveCheckpoints(checkpoints) {
|
|
556
|
+
if (checkpoints.length === 0) return;
|
|
557
|
+
await this.db.transaction(async (tx) => {
|
|
558
|
+
for (let at = 0; at < checkpoints.length; at += CHECKPOINT_BATCH_ROWS) {
|
|
559
|
+
await tx.insert(durableStepCheckpoints).values(checkpoints.slice(at, at + CHECKPOINT_BATCH_ROWS).map(toCheckpointRow)).onConflictDoUpdate({
|
|
560
|
+
target: [
|
|
561
|
+
durableStepCheckpoints.runId,
|
|
562
|
+
durableStepCheckpoints.seq
|
|
563
|
+
],
|
|
564
|
+
set: excludedSet(durableStepCheckpoints)
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
});
|
|
568
|
+
}
|
|
545
569
|
async saveCheckpointIfPending(checkpoint) {
|
|
546
570
|
const { runId, seq, ...set } = toCheckpointRow(checkpoint);
|
|
547
571
|
const rows = await this.db.update(durableStepCheckpoints).set(set).where(and(eq(durableStepCheckpoints.runId, runId), eq(durableStepCheckpoints.seq, seq), eq(durableStepCheckpoints.status, "pending"))).returning({
|