@dudousxd/nestjs-durable 0.52.0 → 0.52.2
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 +28 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +74 -58
- package/dist/index.d.ts +74 -58
- package/dist/index.js +27 -14
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -59,6 +59,7 @@ __export(index_exports, {
|
|
|
59
59
|
RUN_GATEWAY: () => RUN_GATEWAY,
|
|
60
60
|
RUN_REDIS_WORKER: () => RUN_REDIS_WORKER,
|
|
61
61
|
RunGateway: () => import_nestjs_durable_core19.RunGateway,
|
|
62
|
+
RunGatewayError: () => RunGatewayError,
|
|
62
63
|
RunRequestResponder: () => RunRequestResponder,
|
|
63
64
|
STEP_INTERCEPTOR_METADATA: () => STEP_INTERCEPTOR_METADATA,
|
|
64
65
|
Step: () => Step,
|
|
@@ -1506,7 +1507,18 @@ function _ts_metadata6(metadataKey, metadataValue) {
|
|
|
1506
1507
|
}
|
|
1507
1508
|
}
|
|
1508
1509
|
__name(_ts_metadata6, "_ts_metadata");
|
|
1509
|
-
var
|
|
1510
|
+
var RunGatewayError = class extends Error {
|
|
1511
|
+
static {
|
|
1512
|
+
__name(this, "RunGatewayError");
|
|
1513
|
+
}
|
|
1514
|
+
code;
|
|
1515
|
+
constructor(message, code) {
|
|
1516
|
+
super(message);
|
|
1517
|
+
this.name = "RunGatewayError";
|
|
1518
|
+
this.code = code;
|
|
1519
|
+
}
|
|
1520
|
+
};
|
|
1521
|
+
var UnsupportedRunRequestError = class UnsupportedRunRequestError2 extends RunGatewayError {
|
|
1510
1522
|
static {
|
|
1511
1523
|
__name(this, "UnsupportedRunRequestError");
|
|
1512
1524
|
}
|
|
@@ -1546,15 +1558,17 @@ var ProxyRunGateway = class {
|
|
|
1546
1558
|
if (reply.result.ok) {
|
|
1547
1559
|
pending.resolve(reply.result.data);
|
|
1548
1560
|
} else if (reply.result.error.code === UNSUPPORTED_RUN_REQUEST) {
|
|
1549
|
-
pending.reject(new UnsupportedRunRequestError(reply.result.error.message));
|
|
1561
|
+
pending.reject(new UnsupportedRunRequestError(reply.result.error.message, UNSUPPORTED_RUN_REQUEST));
|
|
1550
1562
|
} else {
|
|
1551
|
-
|
|
1552
|
-
pending.reject(code !== void 0 ? Object.assign(new Error(message), {
|
|
1553
|
-
code
|
|
1554
|
-
}) : new Error(message));
|
|
1563
|
+
pending.reject(new RunGatewayError(reply.result.error.message, reply.result.error.code));
|
|
1555
1564
|
}
|
|
1556
1565
|
}
|
|
1557
1566
|
request(body) {
|
|
1567
|
+
const source = this.tenantToken;
|
|
1568
|
+
if (typeof source !== "function") return this.send(source ?? this.tenant, body);
|
|
1569
|
+
return (0, import_nestjs_durable_core11.resolveTenantToken)(source).then((tenant) => this.send(tenant, body));
|
|
1570
|
+
}
|
|
1571
|
+
send(tenant, body) {
|
|
1558
1572
|
return new Promise((resolve, reject) => {
|
|
1559
1573
|
const requestId = globalThis.crypto.randomUUID();
|
|
1560
1574
|
const timer = setTimeout(() => {
|
|
@@ -1566,17 +1580,11 @@ var ProxyRunGateway = class {
|
|
|
1566
1580
|
reject,
|
|
1567
1581
|
timer
|
|
1568
1582
|
});
|
|
1569
|
-
|
|
1570
|
-
const dispatched = typeof source === "function" ? (0, import_nestjs_durable_core11.resolveTenantToken)(source).then((tenant) => this.transport.dispatchRunRequest?.({
|
|
1583
|
+
this.transport.dispatchRunRequest?.({
|
|
1571
1584
|
requestId,
|
|
1572
1585
|
tenant,
|
|
1573
1586
|
body
|
|
1574
|
-
}))
|
|
1575
|
-
requestId,
|
|
1576
|
-
tenant: source ?? this.tenant,
|
|
1577
|
-
body
|
|
1578
|
-
});
|
|
1579
|
-
dispatched?.catch((error) => {
|
|
1587
|
+
})?.catch((error) => {
|
|
1580
1588
|
const stillPending = this.pending.get(requestId);
|
|
1581
1589
|
if (!stillPending) return;
|
|
1582
1590
|
clearTimeout(stillPending.timer);
|
|
@@ -2236,7 +2244,12 @@ var TimerPoller = class {
|
|
|
2236
2244
|
async onApplicationBootstrap() {
|
|
2237
2245
|
for (const s of this.options.schedules ?? []) (0, import_nestjs_durable_core14.workflowName)(s.workflow);
|
|
2238
2246
|
if (!isDrivingOperator(this.options)) return;
|
|
2247
|
+
this.engine.consumeRuns?.();
|
|
2239
2248
|
this.unsubscribeEnqueued = this.engine.onEnqueued((runId) => {
|
|
2249
|
+
if (typeof this.engine.runEnqueued === "function") {
|
|
2250
|
+
this.engine.runEnqueued(runId);
|
|
2251
|
+
return;
|
|
2252
|
+
}
|
|
2240
2253
|
void this.engine.runOne(runId).catch((error) => {
|
|
2241
2254
|
console.error(`[nestjs-durable] could not run enqueued run ${runId}:`, error);
|
|
2242
2255
|
});
|
|
@@ -3127,6 +3140,7 @@ var import_nestjs_durable_core19 = require("@dudousxd/nestjs-durable-core");
|
|
|
3127
3140
|
RUN_GATEWAY,
|
|
3128
3141
|
RUN_REDIS_WORKER,
|
|
3129
3142
|
RunGateway,
|
|
3143
|
+
RunGatewayError,
|
|
3130
3144
|
RunRequestResponder,
|
|
3131
3145
|
STEP_INTERCEPTOR_METADATA,
|
|
3132
3146
|
Step,
|