@dudousxd/nestjs-durable 0.52.0 → 0.52.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 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 UnsupportedRunRequestError = class UnsupportedRunRequestError2 extends Error {
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
- const { message, code } = reply.result.error;
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
- const source = this.tenantToken;
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
- })) : this.transport.dispatchRunRequest?.({
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);
@@ -3127,6 +3135,7 @@ var import_nestjs_durable_core19 = require("@dudousxd/nestjs-durable-core");
3127
3135
  RUN_GATEWAY,
3128
3136
  RUN_REDIS_WORKER,
3129
3137
  RunGateway,
3138
+ RunGatewayError,
3130
3139
  RunRequestResponder,
3131
3140
  STEP_INTERCEPTOR_METADATA,
3132
3141
  Step,