@dudousxd/nestjs-durable-store-drizzle 0.24.4 → 0.24.6
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 +7 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/pg/index.cjs +16 -0
- package/dist/pg/index.cjs.map +1 -1
- package/dist/pg/index.d.cts +1 -0
- package/dist/pg/index.d.ts +1 -0
- package/dist/pg/index.js +16 -0
- package/dist/pg/index.js.map +1 -1
- package/package.json +3 -3
package/dist/pg/index.d.cts
CHANGED
|
@@ -159,6 +159,7 @@ declare class DrizzlePgStateStore implements StateStore {
|
|
|
159
159
|
listCheckpoints(runId: string): Promise<StepCheckpoint[]>;
|
|
160
160
|
listCheckpointsForReplay(runId: string): Promise<StepCheckpoint[]>;
|
|
161
161
|
getLatestCheckpointByName(runId: string, name: string): Promise<StepCheckpoint | undefined>;
|
|
162
|
+
hasCheckpoints(runId: string, fromSeq: number, toSeq: number, statuses: StepCheckpoint['status'][]): Promise<boolean>;
|
|
162
163
|
countCheckpoints(runId: string, fromSeq: number, toSeq: number, statuses: StepCheckpoint['status'][]): Promise<number>;
|
|
163
164
|
listCheckpointsByNamePrefix(runId: string, prefixes: string[]): Promise<StepCheckpoint[]>;
|
|
164
165
|
/** {@link StateStore.checkpointStats}: one `GROUP BY parallel_group, status, name_kind` over the
|
package/dist/pg/index.d.ts
CHANGED
|
@@ -159,6 +159,7 @@ declare class DrizzlePgStateStore implements StateStore {
|
|
|
159
159
|
listCheckpoints(runId: string): Promise<StepCheckpoint[]>;
|
|
160
160
|
listCheckpointsForReplay(runId: string): Promise<StepCheckpoint[]>;
|
|
161
161
|
getLatestCheckpointByName(runId: string, name: string): Promise<StepCheckpoint | undefined>;
|
|
162
|
+
hasCheckpoints(runId: string, fromSeq: number, toSeq: number, statuses: StepCheckpoint['status'][]): Promise<boolean>;
|
|
162
163
|
countCheckpoints(runId: string, fromSeq: number, toSeq: number, statuses: StepCheckpoint['status'][]): Promise<number>;
|
|
163
164
|
listCheckpointsByNamePrefix(runId: string, prefixes: string[]): Promise<StepCheckpoint[]>;
|
|
164
165
|
/** {@link StateStore.checkpointStats}: one `GROUP BY parallel_group, status, name_kind` over the
|
package/dist/pg/index.js
CHANGED
|
@@ -442,6 +442,11 @@ var DrizzlePgStateStore = class _DrizzlePgStateStore {
|
|
|
442
442
|
});
|
|
443
443
|
}
|
|
444
444
|
async createRun(run) {
|
|
445
|
+
if (normalizeAttributeRows(run.id, run.searchAttributes).length === 0) {
|
|
446
|
+
await this.db.insert(durableWorkflowRuns).values(toRunRow(run));
|
|
447
|
+
await this.db.delete(durableRunAttributes).where(eq(durableRunAttributes.runId, run.id));
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
445
450
|
await this.db.transaction(async (tx) => {
|
|
446
451
|
await tx.insert(durableWorkflowRuns).values(toRunRow(run));
|
|
447
452
|
await reindexAttributes(tx, run.id, run.searchAttributes);
|
|
@@ -452,6 +457,10 @@ var DrizzlePgStateStore = class _DrizzlePgStateStore {
|
|
|
452
457
|
const row = toRunPatch(patch);
|
|
453
458
|
const reindex = "searchAttributes" in patch;
|
|
454
459
|
if (!Object.keys(row).length && !reindex) return;
|
|
460
|
+
if (!reindex) {
|
|
461
|
+
await this.db.update(durableWorkflowRuns).set(row).where(eq(durableWorkflowRuns.id, runId));
|
|
462
|
+
return;
|
|
463
|
+
}
|
|
455
464
|
await this.db.transaction(async (tx) => {
|
|
456
465
|
if (Object.keys(row).length) await tx.update(durableWorkflowRuns).set(row).where(eq(durableWorkflowRuns.id, runId));
|
|
457
466
|
if (reindex) await reindexAttributes(tx, runId, patch.searchAttributes);
|
|
@@ -835,6 +844,13 @@ var DrizzlePgStateStore = class _DrizzlePgStateStore {
|
|
|
835
844
|
const rows = await this.db.select().from(durableStepCheckpoints).where(and(eq(durableStepCheckpoints.runId, runId), eq(durableStepCheckpoints.name, name))).orderBy(desc(durableStepCheckpoints.seq)).limit(1);
|
|
836
845
|
return rows[0] ? fromCheckpointRow(rows[0]) : void 0;
|
|
837
846
|
}
|
|
847
|
+
async hasCheckpoints(runId, fromSeq, toSeq, statuses) {
|
|
848
|
+
if (statuses.length === 0) return false;
|
|
849
|
+
const rows = await this.db.select({
|
|
850
|
+
seq: durableStepCheckpoints.seq
|
|
851
|
+
}).from(durableStepCheckpoints).where(and(eq(durableStepCheckpoints.runId, runId), gte(durableStepCheckpoints.seq, fromSeq), lte(durableStepCheckpoints.seq, toSeq), inArray(durableStepCheckpoints.status, statuses))).orderBy(desc(durableStepCheckpoints.seq)).limit(1);
|
|
852
|
+
return rows.length > 0;
|
|
853
|
+
}
|
|
838
854
|
async countCheckpoints(runId, fromSeq, toSeq, statuses) {
|
|
839
855
|
if (statuses.length === 0) return 0;
|
|
840
856
|
const rows = await this.db.select({
|