@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.cjs
CHANGED
|
@@ -482,6 +482,11 @@ var DrizzlePgStateStore = class _DrizzlePgStateStore {
|
|
|
482
482
|
});
|
|
483
483
|
}
|
|
484
484
|
async createRun(run) {
|
|
485
|
+
if ((0, import_nestjs_durable_core.normalizeAttributeRows)(run.id, run.searchAttributes).length === 0) {
|
|
486
|
+
await this.db.insert(durableWorkflowRuns).values(toRunRow(run));
|
|
487
|
+
await this.db.delete(durableRunAttributes).where((0, import_drizzle_orm4.eq)(durableRunAttributes.runId, run.id));
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
485
490
|
await this.db.transaction(async (tx) => {
|
|
486
491
|
await tx.insert(durableWorkflowRuns).values(toRunRow(run));
|
|
487
492
|
await reindexAttributes(tx, run.id, run.searchAttributes);
|
|
@@ -492,6 +497,10 @@ var DrizzlePgStateStore = class _DrizzlePgStateStore {
|
|
|
492
497
|
const row = toRunPatch(patch);
|
|
493
498
|
const reindex = "searchAttributes" in patch;
|
|
494
499
|
if (!Object.keys(row).length && !reindex) return;
|
|
500
|
+
if (!reindex) {
|
|
501
|
+
await this.db.update(durableWorkflowRuns).set(row).where((0, import_drizzle_orm4.eq)(durableWorkflowRuns.id, runId));
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
495
504
|
await this.db.transaction(async (tx) => {
|
|
496
505
|
if (Object.keys(row).length) await tx.update(durableWorkflowRuns).set(row).where((0, import_drizzle_orm4.eq)(durableWorkflowRuns.id, runId));
|
|
497
506
|
if (reindex) await reindexAttributes(tx, runId, patch.searchAttributes);
|
|
@@ -875,6 +884,13 @@ var DrizzlePgStateStore = class _DrizzlePgStateStore {
|
|
|
875
884
|
const rows = await this.db.select().from(durableStepCheckpoints).where((0, import_drizzle_orm4.and)((0, import_drizzle_orm4.eq)(durableStepCheckpoints.runId, runId), (0, import_drizzle_orm4.eq)(durableStepCheckpoints.name, name))).orderBy((0, import_drizzle_orm4.desc)(durableStepCheckpoints.seq)).limit(1);
|
|
876
885
|
return rows[0] ? fromCheckpointRow(rows[0]) : void 0;
|
|
877
886
|
}
|
|
887
|
+
async hasCheckpoints(runId, fromSeq, toSeq, statuses) {
|
|
888
|
+
if (statuses.length === 0) return false;
|
|
889
|
+
const rows = await this.db.select({
|
|
890
|
+
seq: durableStepCheckpoints.seq
|
|
891
|
+
}).from(durableStepCheckpoints).where((0, import_drizzle_orm4.and)((0, import_drizzle_orm4.eq)(durableStepCheckpoints.runId, runId), (0, import_drizzle_orm4.gte)(durableStepCheckpoints.seq, fromSeq), (0, import_drizzle_orm4.lte)(durableStepCheckpoints.seq, toSeq), (0, import_drizzle_orm4.inArray)(durableStepCheckpoints.status, statuses))).orderBy((0, import_drizzle_orm4.desc)(durableStepCheckpoints.seq)).limit(1);
|
|
892
|
+
return rows.length > 0;
|
|
893
|
+
}
|
|
878
894
|
async countCheckpoints(runId, fromSeq, toSeq, statuses) {
|
|
879
895
|
if (statuses.length === 0) return 0;
|
|
880
896
|
const rows = await this.db.select({
|