@dudousxd/nestjs-durable-store-mikro-orm 0.31.0 → 0.32.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.cjs +15 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +15 -5
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _mikro_orm_core from '@mikro-orm/core';
|
|
2
2
|
import { EntityRepository, EntityRepositoryType, EntitySchema, MikroORM } from '@mikro-orm/core';
|
|
3
|
-
import { StepKind, RunStatus, StateStore, WorkflowRun, RetentionPolicy, StepCheckpoint, RunQuery, RunFacetQuery, RunFacetRow, RunValueAxis, RunValueFacetOptions, RunValueFacetRow, ScheduleRecord, ScheduleQuery, CheckpointStat, CheckpointQuery, SignalWaiter, ChildWait } from '@dudousxd/nestjs-durable-core';
|
|
3
|
+
import { StepKind, RunStatus, StateStore, WorkflowRun, RetentionPolicy, StepCheckpoint, OwnedLeaseReclaim, RunQuery, RunFacetQuery, RunFacetRow, RunValueAxis, RunValueFacetOptions, RunValueFacetRow, ScheduleRecord, ScheduleQuery, CheckpointStat, CheckpointQuery, SignalWaiter, ChildWait } from '@dudousxd/nestjs-durable-core';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Custom repositories for the durable entities, so a host app can `@InjectRepository`/inject a
|
|
@@ -205,7 +205,7 @@ declare class MikroOrmStateStore implements StateStore {
|
|
|
205
205
|
saveCheckpoint: (cp: StepCheckpoint) => Promise<void>;
|
|
206
206
|
}) => Promise<T>): Promise<T>;
|
|
207
207
|
listIncompleteRuns(namespace?: string): Promise<WorkflowRun[]>;
|
|
208
|
-
listOrphanedRuns(nowMs: number, limit: number, namespace?: string): Promise<WorkflowRun[]>;
|
|
208
|
+
listOrphanedRuns(nowMs: number, limit: number, namespace?: string, ownedBy?: OwnedLeaseReclaim): Promise<WorkflowRun[]>;
|
|
209
209
|
listPendingRuns(limit: number, namespace?: string): Promise<WorkflowRun[]>;
|
|
210
210
|
listDueTimers(nowMs: number, namespace?: string, limit?: number): Promise<WorkflowRun[]>;
|
|
211
211
|
tryLockRun(runId: string, owner: string, leaseUntilMs: number, nowMs: number): Promise<boolean>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _mikro_orm_core from '@mikro-orm/core';
|
|
2
2
|
import { EntityRepository, EntityRepositoryType, EntitySchema, MikroORM } from '@mikro-orm/core';
|
|
3
|
-
import { StepKind, RunStatus, StateStore, WorkflowRun, RetentionPolicy, StepCheckpoint, RunQuery, RunFacetQuery, RunFacetRow, RunValueAxis, RunValueFacetOptions, RunValueFacetRow, ScheduleRecord, ScheduleQuery, CheckpointStat, CheckpointQuery, SignalWaiter, ChildWait } from '@dudousxd/nestjs-durable-core';
|
|
3
|
+
import { StepKind, RunStatus, StateStore, WorkflowRun, RetentionPolicy, StepCheckpoint, OwnedLeaseReclaim, RunQuery, RunFacetQuery, RunFacetRow, RunValueAxis, RunValueFacetOptions, RunValueFacetRow, ScheduleRecord, ScheduleQuery, CheckpointStat, CheckpointQuery, SignalWaiter, ChildWait } from '@dudousxd/nestjs-durable-core';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Custom repositories for the durable entities, so a host app can `@InjectRepository`/inject a
|
|
@@ -205,7 +205,7 @@ declare class MikroOrmStateStore implements StateStore {
|
|
|
205
205
|
saveCheckpoint: (cp: StepCheckpoint) => Promise<void>;
|
|
206
206
|
}) => Promise<T>): Promise<T>;
|
|
207
207
|
listIncompleteRuns(namespace?: string): Promise<WorkflowRun[]>;
|
|
208
|
-
listOrphanedRuns(nowMs: number, limit: number, namespace?: string): Promise<WorkflowRun[]>;
|
|
208
|
+
listOrphanedRuns(nowMs: number, limit: number, namespace?: string, ownedBy?: OwnedLeaseReclaim): Promise<WorkflowRun[]>;
|
|
209
209
|
listPendingRuns(limit: number, namespace?: string): Promise<WorkflowRun[]>;
|
|
210
210
|
listDueTimers(nowMs: number, namespace?: string, limit?: number): Promise<WorkflowRun[]>;
|
|
211
211
|
tryLockRun(runId: string, owner: string, leaseUntilMs: number, nowMs: number): Promise<boolean>;
|
package/dist/index.js
CHANGED
|
@@ -938,6 +938,7 @@ var MikroOrmStateStore = class _MikroOrmStateStore {
|
|
|
938
938
|
}, {
|
|
939
939
|
status: "suspended",
|
|
940
940
|
wakeAt: new Date(patch.wakeAt),
|
|
941
|
+
tags: patch.tags,
|
|
941
942
|
updatedAt: patch.updatedAt
|
|
942
943
|
});
|
|
943
944
|
return false;
|
|
@@ -1157,7 +1158,7 @@ var MikroOrmStateStore = class _MikroOrmStateStore {
|
|
|
1157
1158
|
});
|
|
1158
1159
|
return rows.map(fromRunEntity);
|
|
1159
1160
|
}
|
|
1160
|
-
async listOrphanedRuns(nowMs, limit, namespace) {
|
|
1161
|
+
async listOrphanedRuns(nowMs, limit, namespace, ownedBy) {
|
|
1161
1162
|
if (limit <= 0) return [];
|
|
1162
1163
|
const em = this.fork();
|
|
1163
1164
|
const rows = await em.find(WorkflowRunEntity, {
|
|
@@ -1175,7 +1176,16 @@ var MikroOrmStateStore = class _MikroOrmStateStore {
|
|
|
1175
1176
|
lockedUntil: {
|
|
1176
1177
|
$lte: new Date(nowMs)
|
|
1177
1178
|
}
|
|
1178
|
-
}
|
|
1179
|
+
},
|
|
1180
|
+
// A live lease left by a previous process with the caller's own instance id.
|
|
1181
|
+
...ownedBy ? [
|
|
1182
|
+
{
|
|
1183
|
+
lockedBy: ownedBy.owner,
|
|
1184
|
+
lockedUntil: {
|
|
1185
|
+
$lt: new Date(ownedBy.lockedBefore)
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
] : []
|
|
1179
1189
|
],
|
|
1180
1190
|
...namespace !== void 0 ? {
|
|
1181
1191
|
namespace
|
|
@@ -1579,7 +1589,7 @@ var MikroOrmStateStore = class _MikroOrmStateStore {
|
|
|
1579
1589
|
* single statement. */
|
|
1580
1590
|
async updateSchedule(id, patch, expectedNextFireAt) {
|
|
1581
1591
|
const data = {};
|
|
1582
|
-
if (patch.namespace !== void 0) data.namespace = patch.namespace;
|
|
1592
|
+
if (patch.namespace !== void 0) data.namespace = patch.namespace || "default";
|
|
1583
1593
|
if (patch.workflow !== void 0) data.workflow = patch.workflow;
|
|
1584
1594
|
if (patch.paused !== void 0) data.paused = patch.paused;
|
|
1585
1595
|
if ("nextFireAt" in patch) data.nextFireAt = patch.nextFireAt ?? null;
|
|
@@ -1965,7 +1975,7 @@ function runUpdateData(patch) {
|
|
|
1965
1975
|
if ("tags" in patch) data.tags = patch.tags ?? null;
|
|
1966
1976
|
if ("searchAttributes" in patch) data.searchAttributes = patch.searchAttributes ?? null;
|
|
1967
1977
|
if ("priority" in patch) data.priority = patch.priority ?? null;
|
|
1968
|
-
if ("namespace" in patch) data.namespace = patch.namespace
|
|
1978
|
+
if ("namespace" in patch) data.namespace = patch.namespace || "default";
|
|
1969
1979
|
if ("origin" in patch) data.origin = patch.origin ?? null;
|
|
1970
1980
|
if (patch.createdAt != null) data.createdAt = patch.createdAt;
|
|
1971
1981
|
if (patch.updatedAt != null) data.updatedAt = patch.updatedAt;
|
|
@@ -1989,7 +1999,7 @@ function toRunEntity(run) {
|
|
|
1989
1999
|
e.tags = run.tags ?? null;
|
|
1990
2000
|
e.searchAttributes = run.searchAttributes ?? null;
|
|
1991
2001
|
e.priority = run.priority ?? null;
|
|
1992
|
-
e.namespace = run.namespace
|
|
2002
|
+
e.namespace = run.namespace || "default";
|
|
1993
2003
|
e.origin = run.origin ?? null;
|
|
1994
2004
|
e.createdAt = run.createdAt;
|
|
1995
2005
|
e.updatedAt = run.updatedAt;
|