@dudousxd/nestjs-durable-core 0.36.0 → 0.38.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 +30 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -4
- package/dist/index.d.ts +14 -4
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1434,9 +1434,28 @@ function createWorkflowCtx(host, runId, compensations, workflow = "") {
|
|
|
1434
1434
|
const now = /* @__PURE__ */ __name(() => step("now", async () => host.clock()), "now");
|
|
1435
1435
|
const random = /* @__PURE__ */ __name(() => step("random", async () => Math.random()), "random");
|
|
1436
1436
|
const uuid = /* @__PURE__ */ __name(() => step("uuid", async () => globalThis.crypto.randomUUID()), "uuid");
|
|
1437
|
+
const upsertSearchAttributes = /* @__PURE__ */ __name(async (attrs) => {
|
|
1438
|
+
const current = pos.next();
|
|
1439
|
+
const existing = await readCheckpoint(current);
|
|
1440
|
+
if (existing) {
|
|
1441
|
+
if (existing.name !== "searchAttributes") {
|
|
1442
|
+
throw new NonDeterminismError(runId, current, "searchAttributes", existing.name);
|
|
1443
|
+
}
|
|
1444
|
+
return;
|
|
1445
|
+
}
|
|
1446
|
+
await host.upsertSearchAttributes(runId, attrs);
|
|
1447
|
+
await writeCheckpoint(instantCheckpoint({
|
|
1448
|
+
runId,
|
|
1449
|
+
seq: current,
|
|
1450
|
+
name: "searchAttributes",
|
|
1451
|
+
kind: "local",
|
|
1452
|
+
output: attrs
|
|
1453
|
+
}));
|
|
1454
|
+
}, "upsertSearchAttributes");
|
|
1437
1455
|
return {
|
|
1438
1456
|
runId,
|
|
1439
1457
|
step,
|
|
1458
|
+
upsertSearchAttributes,
|
|
1440
1459
|
transaction,
|
|
1441
1460
|
callEntity,
|
|
1442
1461
|
signalEntity,
|
|
@@ -3165,6 +3184,17 @@ var WorkflowEngine = class {
|
|
|
3165
3184
|
priority
|
|
3166
3185
|
}).catch(() => void 0));
|
|
3167
3186
|
}, "startChild"),
|
|
3187
|
+
// Shallow-merge into the run's searchAttributes (the ctx primitive makes this exactly-once).
|
|
3188
|
+
upsertSearchAttributes: /* @__PURE__ */ __name(async (runId, attrs) => {
|
|
3189
|
+
const run = await this.store.getRun(runId);
|
|
3190
|
+
await this.store.updateRun(runId, {
|
|
3191
|
+
searchAttributes: {
|
|
3192
|
+
...run?.searchAttributes ?? {},
|
|
3193
|
+
...attrs
|
|
3194
|
+
},
|
|
3195
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
3196
|
+
});
|
|
3197
|
+
}, "upsertSearchAttributes"),
|
|
3168
3198
|
signalEntity: /* @__PURE__ */ __name((name, key, op, arg, reply) => {
|
|
3169
3199
|
queueMicrotask(() => void this.entities.dispatch(name, key, op, arg, reply).catch(() => void 0));
|
|
3170
3200
|
}, "signalEntity"),
|