@dudousxd/nestjs-durable 0.14.0 → 0.15.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.
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Local, structural mirror of `@dudousxd/nestjs-context`'s public accessor
3
+ * (`packages/core/src/accessor.ts`).
4
+ *
5
+ * We deliberately do NOT import nestjs-context (it is an OPTIONAL peer). Instead
6
+ * we declare the same shape here and inject it via the shared
7
+ * {@link CONTEXT_ACCESSOR} token with `@Optional()`. Any object that structurally
8
+ * satisfies this interface — including nestjs-context's real accessor — works.
9
+ *
10
+ * Kept byte-aligned with nestjs-context's `ContextAccessor` (and the identical
11
+ * mirror in `@dudousxd/nestjs-authz`): `traceId()` / `tenantId()` are REQUIRED
12
+ * (the real accessor always provides them) and `get()` is included, so the
13
+ * structural match stays exact when DurableModule auto-feeds the carrier.
14
+ */
15
+ export interface UserRef {
16
+ type: string;
17
+ id: string | number;
18
+ }
19
+ /** Opaque shape of the context store. durable never reads it; mirrors the upstream surface. */
20
+ export type ContextStore = Record<string, unknown>;
21
+ export interface ContextAccessor {
22
+ /** Trace id for the current request, or `undefined` when unavailable. */
23
+ traceId(): string | undefined;
24
+ /** Current tenant id, or `undefined` when no multi-tenant context is populated. */
25
+ tenantId(): string | undefined;
26
+ /** Reference to the current user, or `undefined` when unauthenticated. */
27
+ userRef(): UserRef | undefined;
28
+ /** The raw context store for the current request, or `undefined`. */
29
+ get(): ContextStore | undefined;
30
+ }
31
+ //# sourceMappingURL=context-accessor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-accessor.d.ts","sourceRoot":"","sources":["../src/context-accessor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;CACrB;AAED,+FAA+F;AAC/F,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEnD,MAAM,WAAW,eAAe;IAC9B,yEAAyE;IACzE,OAAO,IAAI,MAAM,GAAG,SAAS,CAAC;IAC9B,mFAAmF;IACnF,QAAQ,IAAI,MAAM,GAAG,SAAS,CAAC;IAC/B,0EAA0E;IAC1E,OAAO,IAAI,OAAO,GAAG,SAAS,CAAC;IAC/B,qEAAqE;IACrE,GAAG,IAAI,YAAY,GAAG,SAAS,CAAC;CACjC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=context-accessor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-accessor.js","sourceRoot":"","sources":["../src/context-accessor.ts"],"names":[],"mappings":""}
@@ -6,6 +6,18 @@ import type { DurableModuleOptions } from './durable.module';
6
6
  * Discovers `@DurableStep` methods and registers them as step handlers on the configured
7
7
  * transport, when that transport runs handlers in-process. With a queue/remote transport the
8
8
  * handlers live in the worker process instead, so there is nothing to wire here.
9
+ *
10
+ * **Context re-hydration (consume side) is the consumer's responsibility.** DurableModule's
11
+ * produce side auto-feeds an opaque carrier (`{ traceId, tenantId, userRef }`) from
12
+ * `@dudousxd/nestjs-context` onto each dispatched `RemoteTask.context` (see DurableModule). A worker
13
+ * that wants its `@DurableStep` reads to SEE the originating context must re-establish it from
14
+ * `task.context`. We do NOT do this here because: (a) re-hydration needs nestjs-context's module-level
15
+ * `Context.deserialize(carrier, fn)` at runtime, and it is an OPTIONAL peer we must not hard-import;
16
+ * and (b) the in-process `StepHandler` contract is `(input, log)` — the engine never surfaces
17
+ * `task.context` to the handler closure, so wrapping it here would require widening the core
18
+ * transport/handler signature (a non-additive cross-cutting change). Instead, a worker that consumes
19
+ * the carrier should wrap its handler with `Context.deserialize(task.context, () => handler(...))`
20
+ * from its own transport/worker bootstrap, where `task` is in scope.
9
21
  */
10
22
  export declare class DurableStepRegistrar implements OnModuleInit {
11
23
  private readonly discovery;
@@ -1 +1 @@
1
- {"version":3,"file":"durable-step.registrar.d.ts","sourceRoot":"","sources":["../src/durable-step.registrar.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,SAAS,EACf,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEjE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAW7D;;;;GAIG;AACH,qBACa,oBAAqB,YAAW,YAAY;IAErD,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,eAAe;IACb,OAAO,CAAC,QAAQ,CAAC,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAHhC,SAAS,EAAE,gBAAgB,EAC3B,eAAe,EAAE,eAAe,EACb,SAAS,EAAE,SAAS,GAAG,IAAI,EACrB,OAAO,EAAE,oBAAoB;IAGzE,YAAY,IAAI,IAAI;CAqBrB"}
1
+ {"version":3,"file":"durable-step.registrar.d.ts","sourceRoot":"","sources":["../src/durable-step.registrar.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,SAAS,EACf,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEjE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAW7D;;;;;;;;;;;;;;;;GAgBG;AACH,qBACa,oBAAqB,YAAW,YAAY;IAErD,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,eAAe;IACb,OAAO,CAAC,QAAQ,CAAC,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAHhC,SAAS,EAAE,gBAAgB,EAC3B,eAAe,EAAE,eAAe,EACb,SAAS,EAAE,SAAS,GAAG,IAAI,EACrB,OAAO,EAAE,oBAAoB;IAGzE,YAAY,IAAI,IAAI;CAqBrB"}
@@ -24,6 +24,18 @@ function supportsHandle(transport) {
24
24
  * Discovers `@DurableStep` methods and registers them as step handlers on the configured
25
25
  * transport, when that transport runs handlers in-process. With a queue/remote transport the
26
26
  * handlers live in the worker process instead, so there is nothing to wire here.
27
+ *
28
+ * **Context re-hydration (consume side) is the consumer's responsibility.** DurableModule's
29
+ * produce side auto-feeds an opaque carrier (`{ traceId, tenantId, userRef }`) from
30
+ * `@dudousxd/nestjs-context` onto each dispatched `RemoteTask.context` (see DurableModule). A worker
31
+ * that wants its `@DurableStep` reads to SEE the originating context must re-establish it from
32
+ * `task.context`. We do NOT do this here because: (a) re-hydration needs nestjs-context's module-level
33
+ * `Context.deserialize(carrier, fn)` at runtime, and it is an OPTIONAL peer we must not hard-import;
34
+ * and (b) the in-process `StepHandler` contract is `(input, log)` — the engine never surfaces
35
+ * `task.context` to the handler closure, so wrapping it here would require widening the core
36
+ * transport/handler signature (a non-additive cross-cutting change). Instead, a worker that consumes
37
+ * the carrier should wrap its handler with `Context.deserialize(task.context, () => handler(...))`
38
+ * from its own transport/worker bootstrap, where `task` is in scope.
27
39
  */
28
40
  let DurableStepRegistrar = class DurableStepRegistrar {
29
41
  discovery;
@@ -1 +1 @@
1
- {"version":3,"file":"durable-step.registrar.js","sourceRoot":"","sources":["../src/durable-step.registrar.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uEAKuC;AACvC,2CAAuE;AACvE,uCAAiE;AACjE,6CAAkD;AAQlD,SAAS,cAAc,CAAC,SAAkB;IACxC,OAAO,OAAQ,SAAsC,EAAE,MAAM,KAAK,UAAU,CAAC;AAC/E,CAAC;AAED;;;;GAIG;AAEI,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAEZ;IACA;IACmB;IACM;IAJ5C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AC,CAAC;YAClD,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,eAAe,CAAC,iBAAiB,CAAC,SAAS,CAAC,EAAE,CAAC;gBAC3E,MAAM,MAAM,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC;gBACpC,IAAI,OAAO,MAAM,KAAK,UAAU;oBAAE,SAAS;gBAC3C,MAAM,IAAI,GAAG,IAAA,+BAAkB,EAAC,MAAM,CAAC,CAAC;gBACxC,IAAI,CAAC,IAAI;oBAAE,SAAS;gBACpB,0FAA0F;gBAC1F,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;YAChF,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAA;AA7BY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,mBAAU,GAAE;IAKR,WAAA,IAAA,eAAM,EAAC,+BAAS,CAAC,CAAA;IACjB,WAAA,IAAA,eAAM,EAAC,qCAAe,CAAC,CAAA;qCAHI,uBAAgB;QACV,sBAAe;GAHxC,oBAAoB,CA6BhC"}
@@ -78,8 +78,14 @@ export interface DurableModuleOptions {
78
78
  traceparent?: () => string | undefined;
79
79
  /**
80
80
  * Provide an opaque context carrier (tenant / user / correlation ids) to stamp on dispatched remote
81
- * tasks, so workers re-expose it to the step handler alongside the `traceparent`. Pass a reader from
82
- * `@dudousxd/nestjs-context` or your own request-scoped source. The engine never inspects its shape.
81
+ * tasks, so workers re-expose it to the step handler alongside the `traceparent`. The engine never
82
+ * inspects its shape.
83
+ *
84
+ * **Auto-feed**: if you omit this AND `@dudousxd/nestjs-context` is installed (its accessor is bound
85
+ * to the shared `CONTEXT_ACCESSOR` token), DurableModule defaults this to a reader that builds
86
+ * `{ traceId, tenantId, userRef }` from the accessor — so a workflow dispatched within a request
87
+ * automatically carries the originating context across process boundaries. Pass your own reader to
88
+ * override the auto-feed; with neither, the carrier is omitted (unchanged behavior).
83
89
  *
84
90
  * Re-evaluated at each (re)dispatch — including a retry or a crash/scale-down resume that the engine
85
91
  * drives OUTSIDE the originating request scope, where this reader may return empty or stale values.
@@ -1 +1 @@
1
- {"version":3,"file":"durable.module.d.ts","sourceRoot":"","sources":["../src/durable.module.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EAEjB,KAAK,cAAc,EACnB,KAAK,WAAW,EAEhB,KAAK,iBAAiB,EACtB,KAAK,UAAU,EAEf,KAAK,SAAS,EAEd,KAAK,WAAW,EACjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,cAAc,EAAyB,MAAM,gBAAgB,CAAC;AAiBhG,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,UAAU,CAAC;IAClB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB;;;;OAIG;IACH,UAAU,CAAC,EAAE,cAAc,EAAE,CAAC;IAC9B;;;OAGG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,qFAAqF;IACrF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yEAAyE;IACzE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;;;;;;OAQG;IACH,kBAAkB,CAAC,EAAE,WAAW,CAAC;IACjC;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,uFAAuF;IACvF,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;;OAKG;IACH,SAAS,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAChC;;;;;OAKG;IACH,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,C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Binding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
2
18
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
19
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
20
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
21
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
22
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
23
  };
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
8
41
  var DurableModule_1;
9
42
  Object.defineProperty(exports, "__esModule", { value: true });
10
43
  exports.DurableModule = void 0;
@@ -14,8 +47,64 @@ const core_1 = require("@nestjs/core");
14
47
  const durable_step_registrar_1 = require("./durable-step.registrar");
15
48
  const entity_1 = require("./entity");
16
49
  const timer_poller_1 = require("./timer-poller");
50
+ const tokens_1 = require("./tokens");
17
51
  const workflow_registrar_1 = require("./workflow.registrar");
18
52
  const workflow_service_1 = require("./workflow.service");
53
+ /**
54
+ * Locate the context accessor non-strictly: an accessor provided by ANY module (a global
55
+ * `ContextModule` from `@dudousxd/nestjs-context`, or the app root) is found via {@link ModuleRef},
56
+ * because DurableModule is `global` and its engine factory can't see another module's local
57
+ * providers directly. Returns undefined when the optional peer isn't installed/bound.
58
+ */
59
+ function resolveAccessor(moduleRef) {
60
+ try {
61
+ return moduleRef.get(tokens_1.CONTEXT_ACCESSOR, { strict: false });
62
+ }
63
+ catch {
64
+ return undefined;
65
+ }
66
+ }
67
+ /**
68
+ * Build an opaque context carrier from a {@link ContextAccessor} — the auto-feed default for the
69
+ * engine's `context` option when `@dudousxd/nestjs-context` is present and the app passed no own
70
+ * reader. Drops fields the accessor doesn't populate, so an empty/anonymous request yields `{}`.
71
+ */
72
+ function carrierFromAccessor(accessor) {
73
+ const carrier = {};
74
+ const traceId = accessor.traceId();
75
+ if (traceId !== undefined)
76
+ carrier.traceId = traceId;
77
+ const tenantId = accessor.tenantId();
78
+ if (tenantId !== undefined)
79
+ carrier.tenantId = tenantId;
80
+ const userRef = accessor.userRef();
81
+ if (userRef !== undefined)
82
+ carrier.userRef = userRef;
83
+ return carrier;
84
+ }
85
+ function isContextRuntime(x) {
86
+ return !!x && typeof x.deserialize === 'function';
87
+ }
88
+ /**
89
+ * Resolve `@dudousxd/nestjs-context`'s runtime `Context` singleton via a GUARDED dynamic import — used
90
+ * to build the engine's `rehydrate` bridge. The runtime `Context` (its `deserialize`/ALS `run`) is a
91
+ * module-level singleton, NOT a DI provider behind {@link CONTEXT_ACCESSOR}, so it can't be resolved
92
+ * through ModuleRef — we import it directly. We do NOT add a hard/static import (the peer is optional):
93
+ * a failure (peer not installed) returns undefined and the engine falls back to passthrough re-hydration.
94
+ */
95
+ async function resolveContextRuntime() {
96
+ try {
97
+ // Indirect the specifier through a variable so the compiler does not try to STATICALLY resolve
98
+ // the optional peer (it may be uninstalled). This stays a runtime guarded import — a missing
99
+ // module rejects and is caught below.
100
+ const specifier = '@dudousxd/nestjs-context';
101
+ const mod = (await Promise.resolve(`${specifier}`).then(s => __importStar(require(s))));
102
+ return isContextRuntime(mod.Context) ? mod.Context : undefined;
103
+ }
104
+ catch {
105
+ return undefined;
106
+ }
107
+ }
19
108
  /** True when `x` can act as a control plane (broadcast pub/sub) — e.g. a broadcast-capable transport. */
20
109
  function isControlPlane(x) {
21
110
  return (!!x &&
@@ -52,10 +141,29 @@ let DurableModule = DurableModule_1 = class DurableModule {
52
141
  },
53
142
  {
54
143
  provide: nestjs_durable_core_1.WorkflowEngine,
55
- useFactory: (store, transport, opts) => {
144
+ useFactory: async (store, transport, opts,
145
+ // The accessor from `@dudousxd/nestjs-context` is resolved at construction via ModuleRef
146
+ // (shared CONTEXT_ACCESSOR symbol — no hard import). Absent → unchanged behavior.
147
+ moduleRef) => {
56
148
  // The control-plane default is the primary task transport (single, or the pool's first)
57
149
  // when it can broadcast.
58
150
  const primary = transport ?? opts.transports?.[0]?.transport;
151
+ // Auto-feed the carrier from nestjs-context when an accessor is present AND the app didn't
152
+ // pass its own `context` reader. The app's own reader always wins; with no accessor the
153
+ // carrier stays `undefined` (unchanged behavior — `traceparent` etc. still work).
154
+ const accessor = resolveAccessor(moduleRef);
155
+ const context = opts.context ?? (accessor ? () => carrierFromAccessor(accessor) : undefined);
156
+ // Consume side: when nestjs-context is present (an accessor is bound), re-hydrate the
157
+ // originating context AROUND each local step body, so a `@DurableStep` reader sees the
158
+ // tenant/user/trace ids ambiently via nestjs-context's ALS — no consumer wrapping needed.
159
+ // The runtime `Context` is a module-level singleton (not the accessor token), resolved
160
+ // ONCE here via a guarded dynamic import (optional peer — failure leaves the default
161
+ // passthrough). Best-effort: an empty/undefined carrier just runs the handler normally.
162
+ const runtime = accessor ? await resolveContextRuntime() : undefined;
163
+ const rehydrate = runtime &&
164
+ ((carrier, fn) => carrier && Object.keys(carrier).length > 0
165
+ ? runtime.deserialize(carrier, fn)
166
+ : fn());
59
167
  const engine = new nestjs_durable_core_1.WorkflowEngine({
60
168
  store,
61
169
  transport: transport ?? undefined,
@@ -66,7 +174,8 @@ let DurableModule = DurableModule_1 = class DurableModule {
66
174
  instanceId: opts.instanceId,
67
175
  webhookUrl: opts.webhookUrl,
68
176
  traceparent: opts.traceparent,
69
- context: opts.context,
177
+ context,
178
+ rehydrate: rehydrate || undefined,
70
179
  compensationRetries: opts.compensationRetries,
71
180
  // A non-worker (API/dashboard) instance must not run workflows: enqueue-only, leaving
72
181
  // each `pending` run in the store for a worker's `runPending` poll. Workers use the
@@ -79,7 +188,7 @@ let DurableModule = DurableModule_1 = class DurableModule {
79
188
  // default) is wired by the WorkflowRegistrar, which owns the `@Workflow` metadata.
80
189
  return engine;
81
190
  },
82
- inject: [nestjs_durable_core_1.STATE_STORE, nestjs_durable_core_1.TRANSPORT, nestjs_durable_core_1.DURABLE_OPTIONS],
191
+ inject: [nestjs_durable_core_1.STATE_STORE, nestjs_durable_core_1.TRANSPORT, nestjs_durable_core_1.DURABLE_OPTIONS, core_1.ModuleRef],
83
192
  },
84
193
  workflow_service_1.WorkflowService,
85
194
  entity_1.EntityService,
@@ -1 +1 @@
1
- {"version":3,"file":"durable.module.js","sourceRoot":"","sources":["../src/durable.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,uEAYuC;AACvC,2CAAgG;AAChG,uCAA+C;AAC/C,qEAAgE;AAChE,qCAAyC;AACzC,iDAA6C;AAC7C,6DAAyD;AACzD,yDAAqD;AAErD,yGAAyG;AACzG,SAAS,cAAc,CAAC,CAAU;IAChC,OAAO,CACL,CAAC,CAAC,CAAC;QACH,OAAQ,CAAkB,CAAC,cAAc,KAAK,UAAU;QACxD,OAAQ,CAAkB,CAAC,SAA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@
1
+ export * from './context-accessor';
1
2
  export * from './decorators';
2
3
  export * from './durable.module';
3
4
  export * from './entity';
4
5
  export * from './step-interceptor';
6
+ export * from './tokens';
5
7
  export * from './workflow.service';
6
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC"}
package/dist/index.js CHANGED
@@ -14,9 +14,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./context-accessor"), exports);
17
18
  __exportStar(require("./decorators"), exports);
18
19
  __exportStar(require("./durable.module"), exports);
19
20
  __exportStar(require("./entity"), exports);
20
21
  __exportStar(require("./step-interceptor"), exports);
22
+ __exportStar(require("./tokens"), exports);
21
23
  __exportStar(require("./workflow.service"), exports);
22
24
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,mDAAiC;AACjC,2CAAyB;AACzB,qDAAmC;AACnC,qDAAmC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,+CAA6B;AAC7B,mDAAiC;AACjC,2CAAyB;AACzB,qDAAmC;AACnC,2CAAyB;AACzB,qDAAmC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Cross-lib injection token for the current-request context accessor, owned by
3
+ * `@dudousxd/nestjs-context`. We do NOT import nestjs-context (it is an OPTIONAL
4
+ * peer dependency) — instead we share its well-known token by value so DI
5
+ * resolves the same provider when nestjs-context is installed and present.
6
+ *
7
+ * `Symbol.for(key)` uses the global symbol registry, so this resolves to the
8
+ * SAME symbol instance as nestjs-context's `tokens.ts` (and the identical token
9
+ * declared by `@dudousxd/nestjs-authz`) without any import. The key MUST stay
10
+ * byte-identical with nestjs-context's export.
11
+ */
12
+ export declare const CONTEXT_ACCESSOR: unique symbol;
13
+ //# sourceMappingURL=tokens.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB,eAAkD,CAAC"}
package/dist/tokens.js ADDED
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CONTEXT_ACCESSOR = void 0;
4
+ /**
5
+ * Cross-lib injection token for the current-request context accessor, owned by
6
+ * `@dudousxd/nestjs-context`. We do NOT import nestjs-context (it is an OPTIONAL
7
+ * peer dependency) — instead we share its well-known token by value so DI
8
+ * resolves the same provider when nestjs-context is installed and present.
9
+ *
10
+ * `Symbol.for(key)` uses the global symbol registry, so this resolves to the
11
+ * SAME symbol instance as nestjs-context's `tokens.ts` (and the identical token
12
+ * declared by `@dudousxd/nestjs-authz`) without any import. The key MUST stay
13
+ * byte-identical with nestjs-context's export.
14
+ */
15
+ exports.CONTEXT_ACCESSOR = Symbol.for('@dudousxd/nestjs-context:accessor');
16
+ //# sourceMappingURL=tokens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;GAUG;AACU,QAAA,gBAAgB,GAAG,MAAM,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dudousxd/nestjs-durable",
3
- "version": "0.14.0",
3
+ "version": "0.15.0",
4
4
  "description": "Durable workflows for NestJS — module, decorators, discovery and boot recovery",
5
5
  "license": "MIT",
6
6
  "author": "Davide Carvalho",
@@ -16,6 +16,7 @@
16
16
  "dist"
17
17
  ],
18
18
  "peerDependencies": {
19
+ "@dudousxd/nestjs-context": ">=0.1.0 <1.0.0",
19
20
  "@dudousxd/nestjs-durable-core": ">=0.1.0 <1.0.0",
20
21
  "@nestjs/common": "^10.0.0 || ^11.0.0",
21
22
  "@nestjs/core": "^10.0.0 || ^11.0.0",
@@ -24,6 +25,9 @@
24
25
  "reflect-metadata": "^0.2.0"
25
26
  },
26
27
  "peerDependenciesMeta": {
28
+ "@dudousxd/nestjs-context": {
29
+ "optional": true
30
+ },
27
31
  "class-transformer": {
28
32
  "optional": true
29
33
  },
@@ -43,7 +47,7 @@
43
47
  "rxjs": "7.8.2",
44
48
  "typescript": "5.9.3",
45
49
  "zod": "3.25.76",
46
- "@dudousxd/nestjs-durable-core": "^0.26.0",
50
+ "@dudousxd/nestjs-durable-core": "^0.27.0",
47
51
  "@dudousxd/nestjs-durable-transport-event-emitter": "^0.4.0"
48
52
  },
49
53
  "scripts": {