@dudousxd/nestjs-durable 0.34.2 → 0.35.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.d.cts CHANGED
@@ -623,6 +623,18 @@ interface DurableModuleOptions {
623
623
  topology?: {
624
624
  role: 'control-plane';
625
625
  tenant?: string;
626
+ /**
627
+ * `'bridge'` — this operator's tenant workers follow the OPERATOR convention (bare
628
+ * transport prefix + `@<tenant>`-suffixed groups: the Python SDK, the TS `role: 'tenant'`
629
+ * worker). When `tenant` is set, the preset pairs the configured `transport` with a
630
+ * bare-prefix sibling (`transport.withNamespace('default')`) in a pool, so those workers
631
+ * are discoverable and dispatchable from this otherwise-namespaced keyspace. INERT when
632
+ * `tenant` is unset (a global operator is already on the bare prefix) — safe to leave on a
633
+ * static config that reads `tenant` from an env var. CAUTION: the bare sibling consumes
634
+ * the shared bare control queues — only sound when this stack owns its broker (a private
635
+ * Redis); on a shared broker, point the tenant workers at a scoped prefix instead.
636
+ */
637
+ tenantWorkers?: 'bridge';
626
638
  } | {
627
639
  role: 'tenant';
628
640
  tenant: string;
package/dist/index.d.ts CHANGED
@@ -623,6 +623,18 @@ interface DurableModuleOptions {
623
623
  topology?: {
624
624
  role: 'control-plane';
625
625
  tenant?: string;
626
+ /**
627
+ * `'bridge'` — this operator's tenant workers follow the OPERATOR convention (bare
628
+ * transport prefix + `@<tenant>`-suffixed groups: the Python SDK, the TS `role: 'tenant'`
629
+ * worker). When `tenant` is set, the preset pairs the configured `transport` with a
630
+ * bare-prefix sibling (`transport.withNamespace('default')`) in a pool, so those workers
631
+ * are discoverable and dispatchable from this otherwise-namespaced keyspace. INERT when
632
+ * `tenant` is unset (a global operator is already on the bare prefix) — safe to leave on a
633
+ * static config that reads `tenant` from an env var. CAUTION: the bare sibling consumes
634
+ * the shared bare control queues — only sound when this stack owns its broker (a private
635
+ * Redis); on a shared broker, point the tenant workers at a scoped prefix instead.
636
+ */
637
+ tenantWorkers?: 'bridge';
626
638
  } | {
627
639
  role: 'tenant';
628
640
  tenant: string;
package/dist/index.js CHANGED
@@ -1828,10 +1828,10 @@ function resolveTopology(options) {
1828
1828
  if (topology === void 0) return options;
1829
1829
  if (topology.role === "control-plane") {
1830
1830
  if (topology.tenant === void 0 || options.namespace !== void 0) return options;
1831
- return {
1831
+ return resolveTenantWorkersBridge({
1832
1832
  ...options,
1833
1833
  namespace: topology.tenant
1834
- };
1834
+ });
1835
1835
  }
1836
1836
  if (options.partition !== void 0) return options;
1837
1837
  return {
@@ -1840,6 +1840,30 @@ function resolveTopology(options) {
1840
1840
  };
1841
1841
  }
1842
1842
  __name(resolveTopology, "resolveTopology");
1843
+ function resolveTenantWorkersBridge(options) {
1844
+ const topology = options.topology;
1845
+ if (topology?.role !== "control-plane" || topology.tenantWorkers !== "bridge") return options;
1846
+ if (options.transports !== void 0) return options;
1847
+ const primary = options.transport;
1848
+ if (primary === void 0) return options;
1849
+ if (primary.withNamespace === void 0) {
1850
+ throw new Error("topology: { tenantWorkers: 'bridge' } needs a transport implementing `withNamespace` (e.g. BullMQTransport) \u2014 the bridge derives a bare-prefix sibling from the configured transport to reach operator-convention tenant workers.");
1851
+ }
1852
+ return {
1853
+ ...options,
1854
+ transports: [
1855
+ {
1856
+ id: "default",
1857
+ transport: primary
1858
+ },
1859
+ {
1860
+ id: "tenant-workers",
1861
+ transport: primary.withNamespace("default")
1862
+ }
1863
+ ]
1864
+ };
1865
+ }
1866
+ __name(resolveTenantWorkersBridge, "resolveTenantWorkersBridge");
1843
1867
  var RunGatewayBootstrap = class RunGatewayBootstrap2 {
1844
1868
  static {
1845
1869
  __name(this, "RunGatewayBootstrap");
@@ -1949,7 +1973,11 @@ var DurableModule = class _DurableModule {
1949
1973
  },
1950
1974
  {
1951
1975
  provide: TRANSPORT_CANONICAL3,
1952
- useFactory: /* @__PURE__ */ __name((options) => options.transport ?? null, "useFactory"),
1976
+ // With a POOL (`transports`) and no singular `transport`, the canonical transport is the
1977
+ // pool's PRIMARY — the same one the engine dispatches on first. Leaving it null starved
1978
+ // the step registrar / in-app worker of a transport, so a pool-configured operator
1979
+ // registered NO step handlers and its own steps parked in `wait` with no consumer.
1980
+ useFactory: /* @__PURE__ */ __name((options) => options.transport ?? options.transports?.[0]?.transport ?? null, "useFactory"),
1953
1981
  inject: [
1954
1982
  DURABLE_OPTIONS_CANONICAL7
1955
1983
  ]