@dudousxd/nestjs-durable-store-mikro-orm 0.27.0 → 0.27.1
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 +38 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +39 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -934,13 +934,50 @@ var MikroOrmStateStore = class _MikroOrmStateStore {
|
|
|
934
934
|
async ensureSchema() {
|
|
935
935
|
await ensureMikroOrmDurableSchema(this.orm);
|
|
936
936
|
}
|
|
937
|
+
async tryAdmitSingleton(runId, tag, workflow, limit, retryWakeAt) {
|
|
938
|
+
return this.fork().transactional(async (em) => {
|
|
939
|
+
const where = {
|
|
940
|
+
workflow,
|
|
941
|
+
status: {
|
|
942
|
+
$in: import_nestjs_durable_core.SINGLETON_ACTIVE_STATUSES
|
|
943
|
+
},
|
|
944
|
+
...this.scopeNamespace !== void 0 ? {
|
|
945
|
+
namespace: this.scopeNamespace
|
|
946
|
+
} : {}
|
|
947
|
+
};
|
|
948
|
+
await em.nativeUpdate(WorkflowRunEntity, where, {
|
|
949
|
+
workflow
|
|
950
|
+
});
|
|
951
|
+
const rows = await em.find(WorkflowRunEntity, where);
|
|
952
|
+
const runs = rows.map(fromRunEntity);
|
|
953
|
+
const tags = (0, import_nestjs_durable_core.singletonAdmissionTags)(runs, runId, tag, workflow, limit);
|
|
954
|
+
if (!tags) {
|
|
955
|
+
const patch = (0, import_nestjs_durable_core.singletonAdmissionDenialPatch)(runs, runId, tag, workflow, retryWakeAt);
|
|
956
|
+
if (patch) await em.nativeUpdate(WorkflowRunEntity, {
|
|
957
|
+
id: runId
|
|
958
|
+
}, {
|
|
959
|
+
status: "suspended",
|
|
960
|
+
wakeAt: new Date(patch.wakeAt),
|
|
961
|
+
updatedAt: patch.updatedAt
|
|
962
|
+
});
|
|
963
|
+
return false;
|
|
964
|
+
}
|
|
965
|
+
await em.nativeUpdate(WorkflowRunEntity, {
|
|
966
|
+
id: runId
|
|
967
|
+
}, {
|
|
968
|
+
tags
|
|
969
|
+
});
|
|
970
|
+
return true;
|
|
971
|
+
});
|
|
972
|
+
}
|
|
937
973
|
async createRun(run) {
|
|
938
974
|
const em = this.fork();
|
|
939
975
|
em.create(WorkflowRunEntity, toRunEntity(run));
|
|
940
976
|
await em.flush();
|
|
941
977
|
await this.reindexAttributes(run.id, run.searchAttributes);
|
|
942
978
|
}
|
|
943
|
-
async updateRun(runId,
|
|
979
|
+
async updateRun(runId, inputPatch) {
|
|
980
|
+
const patch = inputPatch.status && import_nestjs_durable_core.TERMINAL_RUN_STATUSES.includes(inputPatch.status) ? await (0, import_nestjs_durable_core.clearTerminalSingletonAdmission)(runId, inputPatch, (id) => this.withScope({}).getRun(id)) : inputPatch;
|
|
944
981
|
const em = this.fork();
|
|
945
982
|
const entity = await em.findOneOrFail(WorkflowRunEntity, {
|
|
946
983
|
id: runId
|