@nestjs-pipeline/job-context 0.3.0 → 0.4.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.
Files changed (54) hide show
  1. package/README.md +3 -0
  2. package/dist/constants/job-context.constants.js +3 -6
  3. package/dist/constants/job-context.constants.js.map +1 -1
  4. package/dist/decorators/as-system.decorator.d.ts +1 -1
  5. package/dist/decorators/as-system.decorator.d.ts.map +1 -1
  6. package/dist/decorators/as-system.decorator.js +5 -8
  7. package/dist/decorators/as-system.decorator.js.map +1 -1
  8. package/dist/decorators/in-job-context.decorator.js +5 -8
  9. package/dist/decorators/in-job-context.decorator.js.map +1 -1
  10. package/dist/errors/invalid-job-context.error.js +1 -5
  11. package/dist/errors/invalid-job-context.error.js.map +1 -1
  12. package/dist/errors/missing-job-context.error.js +1 -5
  13. package/dist/errors/missing-job-context.error.js.map +1 -1
  14. package/dist/helpers/parse-job-context.d.ts +1 -1
  15. package/dist/helpers/parse-job-context.d.ts.map +1 -1
  16. package/dist/helpers/parse-job-context.js +12 -15
  17. package/dist/helpers/parse-job-context.js.map +1 -1
  18. package/dist/helpers/principal-reference.d.ts +1 -1
  19. package/dist/helpers/principal-reference.d.ts.map +1 -1
  20. package/dist/helpers/principal-reference.js +1 -4
  21. package/dist/helpers/principal-reference.js.map +1 -1
  22. package/dist/helpers/registration.d.ts +2 -2
  23. package/dist/helpers/registration.d.ts.map +1 -1
  24. package/dist/helpers/registration.js +5 -10
  25. package/dist/helpers/registration.js.map +1 -1
  26. package/dist/helpers/with-job-context.d.ts +1 -1
  27. package/dist/helpers/with-job-context.d.ts.map +1 -1
  28. package/dist/helpers/with-job-context.js +8 -11
  29. package/dist/helpers/with-job-context.js.map +1 -1
  30. package/dist/index.d.ts +11 -11
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +6 -15
  33. package/dist/index.js.map +1 -1
  34. package/dist/interfaces/context-source.interface.js +1 -2
  35. package/dist/interfaces/context-source.interface.js.map +1 -1
  36. package/dist/interfaces/job-context-options.interface.d.ts +2 -2
  37. package/dist/interfaces/job-context-options.interface.d.ts.map +1 -1
  38. package/dist/interfaces/job-context-options.interface.js +1 -2
  39. package/dist/interfaces/job-context-options.interface.js.map +1 -1
  40. package/dist/interfaces/job-context.interface.d.ts +1 -1
  41. package/dist/interfaces/job-context.interface.d.ts.map +1 -1
  42. package/dist/interfaces/job-context.interface.js +1 -2
  43. package/dist/interfaces/job-context.interface.js.map +1 -1
  44. package/dist/interfaces/job-principal.interface.d.ts +1 -1
  45. package/dist/interfaces/job-principal.interface.d.ts.map +1 -1
  46. package/dist/interfaces/job-principal.interface.js +1 -2
  47. package/dist/interfaces/job-principal.interface.js.map +1 -1
  48. package/dist/interfaces/principal-reference.interface.js +1 -2
  49. package/dist/interfaces/principal-reference.interface.js.map +1 -1
  50. package/dist/job-context.module.d.ts +1 -1
  51. package/dist/job-context.module.d.ts.map +1 -1
  52. package/dist/job-context.module.js +16 -19
  53. package/dist/job-context.module.js.map +1 -1
  54. package/package.json +9 -1
package/README.md CHANGED
@@ -23,6 +23,9 @@ pnpm add @nestjs-pipeline/job-context @nestjs/common
23
23
 
24
24
  Requires Node.js 22.12 or later and `@nestjs/common` `^12.1.0`.
25
25
 
26
+ Published as an ES module; a CommonJS application loads it with `require()`. Coming from
27
+ 0.3.x, see [Upgrading from 0.3.x](https://github.com/aristoteliss/nestjs-pipeline#upgrading-from-03x).
28
+
26
29
  ## Setup
27
30
 
28
31
  Implement `IJobPrincipal` over the application's authentication state, and register it
@@ -1,11 +1,8 @@
1
- "use strict";
2
1
  /* Copyright (C) 2026-present Aristotelis — see repository license. */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.JOB_SOURCES = exports.JOB_TENANTS = exports.JOB_PRINCIPAL = void 0;
5
2
  /** Injection token of the application's `IJobPrincipal`. */
6
- exports.JOB_PRINCIPAL = Symbol('JOB_PRINCIPAL');
3
+ export const JOB_PRINCIPAL = Symbol('JOB_PRINCIPAL');
7
4
  /** Injection token of the configured tenant list. */
8
- exports.JOB_TENANTS = Symbol('JOB_TENANTS');
5
+ export const JOB_TENANTS = Symbol('JOB_TENANTS');
9
6
  /** Injection token of the tenant and correlation id sources. */
10
- exports.JOB_SOURCES = Symbol('JOB_SOURCES');
7
+ export const JOB_SOURCES = Symbol('JOB_SOURCES');
11
8
  //# sourceMappingURL=job-context.constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"job-context.constants.js","sourceRoot":"","sources":["../../src/constants/job-context.constants.ts"],"names":[],"mappings":";AAAA,sEAAsE;;;AAEtE,4DAA4D;AAC/C,QAAA,aAAa,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC;AAErD,qDAAqD;AACxC,QAAA,WAAW,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;AAEjD,gEAAgE;AACnD,QAAA,WAAW,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC"}
1
+ {"version":3,"file":"job-context.constants.js","sourceRoot":"","sources":["../../src/constants/job-context.constants.ts"],"names":[],"mappings":"AAAA,sEAAsE;AAEtE,4DAA4D;AAC5D,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC;AAErD,qDAAqD;AACrD,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;AAEjD,gEAAgE;AAChE,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { PrincipalReference } from '../interfaces/principal-reference.interface';
1
+ import type { PrincipalReference } from '../interfaces/principal-reference.interface.js';
2
2
  /** Options of {@link AsSystem}. */
3
3
  export interface AsSystemOptions<TGrant = unknown> {
4
4
  /** The service principal the work acts as. */
@@ -1 +1 @@
1
- {"version":3,"file":"as-system.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/as-system.decorator.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AAEtF,mCAAmC;AACnC,MAAM,WAAW,eAAe,CAAC,MAAM,GAAG,OAAO;IAC/C,8CAA8C;IAC9C,SAAS,EAAE,kBAAkB,CAAC;IAC9B,+EAA+E;IAC/E,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAC7B,OAAO,EAAE,eAAe,CAAC,MAAM,CAAC,GAC/B,eAAe,CA2CjB"}
1
+ {"version":3,"file":"as-system.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/as-system.decorator.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gDAAgD,CAAC;AAEzF,mCAAmC;AACnC,MAAM,WAAW,eAAe,CAAC,MAAM,GAAG,OAAO;IAC/C,8CAA8C;IAC9C,SAAS,EAAE,kBAAkB,CAAC;IAC9B,+EAA+E;IAC/E,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAC7B,OAAO,EAAE,eAAe,CAAC,MAAM,CAAC,GAC/B,eAAe,CA2CjB"}
@@ -1,9 +1,6 @@
1
- "use strict";
2
1
  /* Copyright (C) 2026-present Aristotelis — see repository license. */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.AsSystem = AsSystem;
5
- const principal_reference_1 = require("../helpers/principal-reference");
6
- const registration_1 = require("../helpers/registration");
2
+ import { toReference } from '../helpers/principal-reference.js';
3
+ import { activeRegistration } from '../helpers/registration.js';
7
4
  /**
8
5
  * Runs system-started work, such as a cron job, once per configured tenant.
9
6
  * Each run has its own tenant, a new correlation id, and the declared service
@@ -26,13 +23,13 @@ const registration_1 = require("../helpers/registration");
26
23
  * }
27
24
  * ```
28
25
  */
29
- function AsSystem(options) {
30
- const reference = (0, principal_reference_1.toReference)(options.principal);
26
+ export function AsSystem(options) {
27
+ const reference = toReference(options.principal);
31
28
  const grants = [...options.grants];
32
29
  return (_target, _propertyKey, descriptor) => {
33
30
  const original = descriptor.value;
34
31
  descriptor.value = async function (...args) {
35
- const { principal, tenants, sources } = (0, registration_1.activeRegistration)();
32
+ const { principal, tenants, sources } = activeRegistration();
36
33
  const failures = [];
37
34
  const failed = [];
38
35
  for (const tenant of tenants) {
@@ -1 +1 @@
1
- {"version":3,"file":"as-system.decorator.js","sourceRoot":"","sources":["../../src/decorators/as-system.decorator.ts"],"names":[],"mappings":";AAAA,sEAAsE;;;AAEtE,wEAA6D;AAC7D,0DAA6D;AAW7D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,kBACE,OAAgC;IAEhC,MAAM,SAAS,GAAG,IAAA,iCAAW,EAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACjD,MAAM,MAAM,GAAG,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEnC,OAAO,CAAC,OAAO,EAAE,YAAY,EAAE,UAA8B,EAAE,EAAE;QAC/D,MAAM,QAAQ,GAAG,UAAU,CAAC,KAAwC,CAAC;QAErE,UAAU,CAAC,KAAK,GAAG,KAAK,WAEtB,GAAG,IAAe;YAElB,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,IAAA,iCAAkB,GAAE,CAAC;YAC7D,MAAM,QAAQ,GAAc,EAAE,CAAC;YAC/B,MAAM,MAAM,GAAa,EAAE,CAAC;YAC5B,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;gBAC7B,IAAI,CAAC;oBACH,MAAM,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,CACtC,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,EAAE,EAAE,GAAG,EAAE,CAC7D,SAAS,CAAC,OAAO,CACf,SAAS,EACT,KAAK,IAAI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YAElB,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,kBAAkB,EAAE,CAAC;YAC7D,MAAM,QAAQ,GAAc,EAAE,CAAC;YAC/B,MAAM,MAAM,GAAa,EAAE,CAAC;YAC5B,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;gBAC7B,IAAI,CAAC;oBACH,MAAM,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,CACtC,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,EAAE,EAAE,GAAG,EAAE,CAC7D,SAAS,CAAC,OAAO,CACf,SAAS,EACT,KAAK,IAAI,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,EACtC,MAAM,CACP,CACF,CACF,CAAC;gBACJ,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;oBACrB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBACtB,CAAC;YACH,CAAC;YACD,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACxB,MAAM,IAAI,cAAc,CACtB,QAAQ,EACR,kCAAkC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACtD,CAAC;YACJ,CAAC;QACH,CAAC,CAAC;QACF,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE;YAC9C,KAAK,EAAE,QAAQ,CAAC,IAAI;YACpB,YAAY,EAAE,IAAI;SACnB,CAAC,CAAC;QACH,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC"}
@@ -1,9 +1,6 @@
1
- "use strict";
2
1
  /* Copyright (C) 2026-present Aristotelis — see repository license. */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.InJobContext = InJobContext;
5
- const parse_job_context_1 = require("../helpers/parse-job-context");
6
- const registration_1 = require("../helpers/registration");
2
+ import { parseJobContext } from '../helpers/parse-job-context.js';
3
+ import { activeRegistration } from '../helpers/registration.js';
7
4
  function readPath(value, segments) {
8
5
  let current = value;
9
6
  for (const segment of segments) {
@@ -34,13 +31,13 @@ function readPath(value, segments) {
34
31
  * }
35
32
  * ```
36
33
  */
37
- function InJobContext(options = {}) {
34
+ export function InJobContext(options = {}) {
38
35
  const segments = (options.path ?? 'data.jobContext').split('.');
39
36
  return (_target, _propertyKey, descriptor) => {
40
37
  const original = descriptor.value;
41
38
  descriptor.value = async function (...args) {
42
- const { principal, tenants, sources } = (0, registration_1.activeRegistration)();
43
- const context = (0, parse_job_context_1.parseJobContext)(readPath(args[0], segments), tenants, sources.correlationId.accepts);
39
+ const { principal, tenants, sources } = activeRegistration();
40
+ const context = parseJobContext(readPath(args[0], segments), tenants, sources.correlationId.accepts);
44
41
  return sources.tenantId.run(context.tenantId, () => sources.correlationId.run(context.correlationId, () => principal.restore(context.principal, async () => original.apply(this, args))));
45
42
  };
46
43
  Object.defineProperty(descriptor.value, 'name', {
@@ -1 +1 @@
1
- {"version":3,"file":"in-job-context.decorator.js","sourceRoot":"","sources":["../../src/decorators/in-job-context.decorator.ts"],"names":[],"mappings":";AAAA,sEAAsE;;;AAEtE,oEAA+D;AAC/D,0DAA6D;AAY7D,SAAS,QAAQ,CAAC,KAAc,EAAE,QAA2B;IAC3D,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI;YAAE,OAAO,SAAS,CAAC;QACtE,OAAO,GAAI,OAAmC,CAAC,OAAO,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,sBACE,OAAO,GAAwB,EAAE;IAEj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AAC,CAC3B,CACF,CACF,CAAC;QACJ,CAAC,CAAC;QACF,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE;YAC9C,KAAK,EAAE,QAAQ,CAAC,IAAI;YACpB,YAAY,EAAE,IAAI;SACnB,CAAC,CAAC;QACH,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC"}
@@ -1,7 +1,4 @@
1
- "use strict";
2
1
  /* Copyright (C) 2026-present Aristotelis — see repository license. */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.InvalidJobContextError = void 0;
5
2
  /**
6
3
  * Raised when a job payload's context is malformed, names an unconfigured
7
4
  * tenant, or carries fields a principal reference must not have, such as
@@ -12,7 +9,7 @@ exports.InvalidJobContextError = void 0;
12
9
  * throw new InvalidJobContextError('tenantId is not a configured tenant');
13
10
  * ```
14
11
  */
15
- class InvalidJobContextError extends Error {
12
+ export class InvalidJobContextError extends Error {
16
13
  reason;
17
14
  constructor(reason) {
18
15
  super(`Invalid job context: ${reason}.`);
@@ -20,5 +17,4 @@ class InvalidJobContextError extends Error {
20
17
  this.name = InvalidJobContextError.name;
21
18
  }
22
19
  }
23
- exports.InvalidJobContextError = InvalidJobContextError;
24
20
  //# sourceMappingURL=invalid-job-context.error.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"invalid-job-context.error.js","sourceRoot":"","sources":["../../src/errors/invalid-job-context.error.ts"],"names":[],"mappings":";AAAA,sEAAsE;;;AAEtE;;;;;;;;;GASG;AACH,4BAAoC,SAAQ,KAAK;IAC1B,MAAM;IAA3B,YAAqB,MAAc;QACjC,KAAK,CAAC,wBAAwB,MAAM,GAAG,CAAC,CAAC;sBADtB,MAAM;QAEzB,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC,IAAI,CAAC;IAC1C,CAAC;CACF"}
1
+ {"version":3,"file":"invalid-job-context.error.js","sourceRoot":"","sources":["../../src/errors/invalid-job-context.error.ts"],"names":[],"mappings":"AAAA,sEAAsE;AAEtE;;;;;;;;;GASG;AACH,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAC1B,MAAM;IAA3B,YAAqB,MAAc;QACjC,KAAK,CAAC,wBAAwB,MAAM,GAAG,CAAC,CAAC;sBADtB,MAAM;QAEzB,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC,IAAI,CAAC;IAC1C,CAAC;CACF"}
@@ -1,7 +1,4 @@
1
- "use strict";
2
1
  /* Copyright (C) 2026-present Aristotelis — see repository license. */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.MissingJobContextError = void 0;
5
2
  /**
6
3
  * Raised when a job would run, or be enqueued, without part of its execution
7
4
  * context. A job never falls back to a default tenant or an anonymous principal.
@@ -11,7 +8,7 @@ exports.MissingJobContextError = void 0;
11
8
  * throw new MissingJobContextError('principal');
12
9
  * ```
13
10
  */
14
- class MissingJobContextError extends Error {
11
+ export class MissingJobContextError extends Error {
15
12
  missing;
16
13
  constructor(missing) {
17
14
  super(`Missing job context: ${missing}. A job never runs without it and never falls back to a default.`);
@@ -19,5 +16,4 @@ class MissingJobContextError extends Error {
19
16
  this.name = MissingJobContextError.name;
20
17
  }
21
18
  }
22
- exports.MissingJobContextError = MissingJobContextError;
23
19
  //# sourceMappingURL=missing-job-context.error.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"missing-job-context.error.js","sourceRoot":"","sources":["../../src/errors/missing-job-context.error.ts"],"names":[],"mappings":";AAAA,sEAAsE;;;AAEtE;;;;;;;;GAQG;AACH,4BAAoC,SAAQ,KAAK;IAC1B,OAAO;IAA5B,YAAqB,OAAe;QAClC,KAAK,CACH,wBAAwB,OAAO,kEAAkE,CAClG,CAAC;uBAHiB,OAAO;QAI1B,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC,IAAI,CAAC;IAC1C,CAAC;CACF"}
1
+ {"version":3,"file":"missing-job-context.error.js","sourceRoot":"","sources":["../../src/errors/missing-job-context.error.ts"],"names":[],"mappings":"AAAA,sEAAsE;AAEtE;;;;;;;;GAQG;AACH,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAC1B,OAAO;IAA5B,YAAqB,OAAe;QAClC,KAAK,CACH,wBAAwB,OAAO,kEAAkE,CAClG,CAAC;uBAHiB,OAAO;QAI1B,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC,IAAI,CAAC;IAC1C,CAAC;CACF"}
@@ -1,4 +1,4 @@
1
- import type { JobContext } from '../interfaces/job-context.interface';
1
+ import type { JobContext } from '../interfaces/job-context.interface.js';
2
2
  /**
3
3
  * Validates a job payload's context before anything runs with it. Every field
4
4
  * is checked, unknown fields are refused, the tenant must be configured, and
@@ -1 +1 @@
1
- {"version":3,"file":"parse-job-context.d.ts","sourceRoot":"","sources":["../../src/helpers/parse-job-context.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AAyBtE;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,oBAAoB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,GAC5C,UAAU,CAmCZ"}
1
+ {"version":3,"file":"parse-job-context.d.ts","sourceRoot":"","sources":["../../src/helpers/parse-job-context.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AAyBzE;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,oBAAoB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,GAC5C,UAAU,CAmCZ"}
@@ -1,10 +1,7 @@
1
- "use strict";
2
1
  /* Copyright (C) 2026-present Aristotelis — see repository license. */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.parseJobContext = parseJobContext;
5
- const invalid_job_context_error_1 = require("../errors/invalid-job-context.error");
6
- const missing_job_context_error_1 = require("../errors/missing-job-context.error");
7
- const principal_reference_1 = require("./principal-reference");
2
+ import { InvalidJobContextError } from '../errors/invalid-job-context.error.js';
3
+ import { MissingJobContextError } from '../errors/missing-job-context.error.js';
4
+ import { toReference } from './principal-reference.js';
8
5
  const CONTEXT_FIELDS = new Set(['tenantId', 'correlationId', 'principal']);
9
6
  const PRINCIPAL_FIELDS = new Set(['id', 'type', 'sessionId']);
10
7
  function isRecord(value) {
@@ -16,7 +13,7 @@ function isText(value) {
16
13
  function assertFields(value, allowed, name) {
17
14
  const extra = Object.keys(value).find((key) => !allowed.has(key));
18
15
  if (extra !== undefined) {
19
- throw new invalid_job_context_error_1.InvalidJobContextError(`${name} carries the field "${extra}"`);
16
+ throw new InvalidJobContextError(`${name} carries the field "${extra}"`);
20
17
  }
21
18
  }
22
19
  /**
@@ -36,36 +33,36 @@ function assertFields(value, allowed, name) {
36
33
  * const context = parseJobContext(job.data.jobContext, ['tenant_a'], sources.correlationId.accepts);
37
34
  * ```
38
35
  */
39
- function parseJobContext(value, tenants, acceptsCorrelationId) {
36
+ export function parseJobContext(value, tenants, acceptsCorrelationId) {
40
37
  if (value === undefined) {
41
- throw new missing_job_context_error_1.MissingJobContextError('the payload has no jobContext');
38
+ throw new MissingJobContextError('the payload has no jobContext');
42
39
  }
43
40
  if (!isRecord(value)) {
44
- throw new invalid_job_context_error_1.InvalidJobContextError('jobContext is not an object');
41
+ throw new InvalidJobContextError('jobContext is not an object');
45
42
  }
46
43
  assertFields(value, CONTEXT_FIELDS, 'jobContext');
47
44
  const { tenantId, correlationId, principal } = value;
48
45
  if (typeof tenantId !== 'string' || !tenants.includes(tenantId)) {
49
- throw new invalid_job_context_error_1.InvalidJobContextError('tenantId is not a configured tenant');
46
+ throw new InvalidJobContextError('tenantId is not a configured tenant');
50
47
  }
51
48
  if (typeof correlationId !== 'string' ||
52
49
  !acceptsCorrelationId(correlationId)) {
53
- throw new invalid_job_context_error_1.InvalidJobContextError('correlationId is malformed');
50
+ throw new InvalidJobContextError('correlationId is malformed');
54
51
  }
55
52
  if (!isRecord(principal)) {
56
- throw new invalid_job_context_error_1.InvalidJobContextError('principal is not an object');
53
+ throw new InvalidJobContextError('principal is not an object');
57
54
  }
58
55
  assertFields(principal, PRINCIPAL_FIELDS, 'principal');
59
56
  const { id, type, sessionId } = principal;
60
57
  if (!isText(id) ||
61
58
  !isText(type) ||
62
59
  (sessionId !== undefined && !isText(sessionId))) {
63
- throw new invalid_job_context_error_1.InvalidJobContextError('principal is malformed');
60
+ throw new InvalidJobContextError('principal is malformed');
64
61
  }
65
62
  return {
66
63
  tenantId,
67
64
  correlationId,
68
- principal: (0, principal_reference_1.toReference)({ id, type, sessionId }),
65
+ principal: toReference({ id, type, sessionId }),
69
66
  };
70
67
  }
71
68
  //# sourceMappingURL=parse-job-context.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"parse-job-context.js","sourceRoot":"","sources":["../../src/helpers/parse-job-context.ts"],"names":[],"mappings":";AAAA,sEAAsE;;;AAEtE,mFAA6E;AAC7E,mFAA6E;AAE7E,+DAAoD;AAEpD,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,UAAU,EAAE,eAAe,EAAE,WAAW,CAAC,CAAC,CAAC;AAC3E,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC;AAE9D,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,MAAM,CAAC,KAAc;IAC5B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;AAC1D,CAAC;AAED,SAAS,YAAY,CACnB,KAA8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jE,CAAC;IACD,YAAY,CAAC,SAAS,EAAE,gBAAgB,EAAE,WAAW,CAAC,CAAC;IACvD,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,SAAS,CAAC;IAC1C,IACE,CAAC,MAAM,CAAC,EAAE,CAAC;QACX,CAAC,MAAM,CAAC,IAAI,CAAC;QACb,CAAC,SAAS,KAAK,SAAS,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,EAC/C,CAAC;QACD,MAAM,IAAI,sBAAsB,CAAC,wBAAwB,CAAC,CAAC;IAC7D,CAAC;IACD,OAAO;QACL,QAAQ;QACR,aAAa;QACb,SAAS,EAAE,WAAW,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;KAChD,CAAC;AACJ,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { PrincipalReference } from '../interfaces/principal-reference.interface';
1
+ import type { PrincipalReference } from '../interfaces/principal-reference.interface.js';
2
2
  /**
3
3
  * Copies only the identity fields of `principal`, so grants or session data an
4
4
  * application object also holds never reach a payload or a restore call.
@@ -1 +1 @@
1
- {"version":3,"file":"principal-reference.d.ts","sourceRoot":"","sources":["../../src/helpers/principal-reference.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AAEtF;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE,kBAAkB,GAAG,kBAAkB,CAG7E"}
1
+ {"version":3,"file":"principal-reference.d.ts","sourceRoot":"","sources":["../../src/helpers/principal-reference.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gDAAgD,CAAC;AAEzF;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE,kBAAkB,GAAG,kBAAkB,CAG7E"}
@@ -1,7 +1,4 @@
1
- "use strict";
2
1
  /* Copyright (C) 2026-present Aristotelis — see repository license. */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.toReference = toReference;
5
2
  /**
6
3
  * Copies only the identity fields of `principal`, so grants or session data an
7
4
  * application object also holds never reach a payload or a restore call.
@@ -11,7 +8,7 @@ exports.toReference = toReference;
11
8
  * toReference({ id: 'u-1', type: 'user', sid: 's-1', grants: [] }); // { id: 'u-1', type: 'user' }
12
9
  * ```
13
10
  */
14
- function toReference(principal) {
11
+ export function toReference(principal) {
15
12
  const { id, type, sessionId } = principal;
16
13
  return sessionId === undefined ? { id, type } : { id, type, sessionId };
17
14
  }
@@ -1 +1 @@
1
- {"version":3,"file":"principal-reference.js","sourceRoot":"","sources":["../../src/helpers/principal-reference.ts"],"names":[],"mappings":";AAAA,sEAAsE;;;AAItE;;;;;;;;GAQG;AACH,qBAA4B,SAA6B;IACvD,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,SAAS,CAAC;IAC1C,OAAO,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;AAC1E,CAAC"}
1
+ {"version":3,"file":"principal-reference.js","sourceRoot":"","sources":["../../src/helpers/principal-reference.ts"],"names":[],"mappings":"AAAA,sEAAsE;AAItE;;;;;;;;GAQG;AACH,MAAM,UAAU,WAAW,CAAC,SAA6B;IACvD,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,SAAS,CAAC;IAC1C,OAAO,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;AAC1E,CAAC"}
@@ -1,5 +1,5 @@
1
- import type { JobContextSources } from '../interfaces/context-source.interface';
2
- import type { IJobPrincipal } from '../interfaces/job-principal.interface';
1
+ import type { JobContextSources } from '../interfaces/context-source.interface.js';
2
+ import type { IJobPrincipal } from '../interfaces/job-principal.interface.js';
3
3
  /** What `JobContextModule` registers for the decorators, which run outside DI. */
4
4
  export interface Registration {
5
5
  readonly principal: IJobPrincipal;
@@ -1 +1 @@
1
- {"version":3,"file":"registration.d.ts","sourceRoot":"","sources":["../../src/helpers/registration.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAChF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAE3E,kFAAkF;AAClF,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAC;CACrC;AAID;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI,CAEzD;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI,CAE3D;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,IAAI,YAAY,CAKjD"}
1
+ {"version":3,"file":"registration.d.ts","sourceRoot":"","sources":["../../src/helpers/registration.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AACnF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;AAE9E,kFAAkF;AAClF,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAC;CACrC;AAID;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI,CAEzD;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI,CAE3D;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,IAAI,YAAY,CAKjD"}
@@ -1,10 +1,5 @@
1
- "use strict";
2
1
  /* Copyright (C) 2026-present Aristotelis — see repository license. */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.register = register;
5
- exports.unregister = unregister;
6
- exports.activeRegistration = activeRegistration;
7
- const missing_job_context_error_1 = require("../errors/missing-job-context.error");
2
+ import { MissingJobContextError } from '../errors/missing-job-context.error.js';
8
3
  let active;
9
4
  /**
10
5
  * Makes `registration` the one the decorators and `withJobContext` use.
@@ -14,7 +9,7 @@ let active;
14
9
  * register({ principal, tenants: ['tenant_a'], sources });
15
10
  * ```
16
11
  */
17
- function register(registration) {
12
+ export function register(registration) {
18
13
  active = registration;
19
14
  }
20
15
  /**
@@ -26,7 +21,7 @@ function register(registration) {
26
21
  * unregister(registration);
27
22
  * ```
28
23
  */
29
- function unregister(registration) {
24
+ export function unregister(registration) {
30
25
  if (active === registration)
31
26
  active = undefined;
32
27
  }
@@ -40,9 +35,9 @@ function unregister(registration) {
40
35
  * const { principal, tenants, sources } = activeRegistration();
41
36
  * ```
42
37
  */
43
- function activeRegistration() {
38
+ export function activeRegistration() {
44
39
  if (active === undefined) {
45
- throw new missing_job_context_error_1.MissingJobContextError('a running JobContextModule');
40
+ throw new MissingJobContextError('a running JobContextModule');
46
41
  }
47
42
  return active;
48
43
  }
@@ -1 +1 @@
1
- {"version":3,"file":"registration.js","sourceRoot":"","sources":["../../src/helpers/registration.ts"],"names":[],"mappings":";AAAA,sEAAsE;;;;;AAEtE,mFAA6E;AAW7E,IAAI,MAAgC,CAAC;AAErC;;;;;;;GAOG;AACH,kBAAyB,YAA0B;IACjD,MAAM,GAAG,YAAY,CAAC;AACxB,CAAC;AAED;;;;;;;;GAQG;AACH,oBAA2B,YAA0B;IACnD,IAAI,MAAM,KAAK,YAAY;QAAE,MAAM,GAAG,SAAS,CAAC;AAClD,CAAC;AAED;;;;;;;;;GASG;AACH;IACE,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,MAAM,IAAI,kDAAsB,CAAC,4BAA4B,CAAC,CAAC;IACjE,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
1
+ {"version":3,"file":"registration.js","sourceRoot":"","sources":["../../src/helpers/registration.ts"],"names":[],"mappings":"AAAA,sEAAsE;AAEtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAWhF,IAAI,MAAgC,CAAC;AAErC;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CAAC,YAA0B;IACjD,MAAM,GAAG,YAAY,CAAC;AACxB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,UAAU,CAAC,YAA0B;IACnD,IAAI,MAAM,KAAK,YAAY;QAAE,MAAM,GAAG,SAAS,CAAC;AAClD,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,kBAAkB;IAChC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,MAAM,IAAI,sBAAsB,CAAC,4BAA4B,CAAC,CAAC;IACjE,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { WithJobContext } from '../interfaces/job-context.interface';
1
+ import type { WithJobContext } from '../interfaces/job-context.interface.js';
2
2
  /**
3
3
  * Stamps the current execution context onto a job payload: the tenant and
4
4
  * correlation id of the registered sources (a new one from the correlation
@@ -1 +1 @@
1
- {"version":3,"file":"with-job-context.d.ts","sourceRoot":"","sources":["../../src/helpers/with-job-context.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAI1E;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9D,IAAI,EAAE,CAAC,GACN,cAAc,CAAC,CAAC,CAAC,CAwBnB"}
1
+ {"version":3,"file":"with-job-context.d.ts","sourceRoot":"","sources":["../../src/helpers/with-job-context.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAI7E;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9D,IAAI,EAAE,CAAC,GACN,cAAc,CAAC,CAAC,CAAC,CAwBnB"}
@@ -1,10 +1,7 @@
1
- "use strict";
2
1
  /* Copyright (C) 2026-present Aristotelis — see repository license. */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.withJobContext = withJobContext;
5
- const missing_job_context_error_1 = require("../errors/missing-job-context.error");
6
- const principal_reference_1 = require("./principal-reference");
7
- const registration_1 = require("./registration");
2
+ import { MissingJobContextError } from '../errors/missing-job-context.error.js';
3
+ import { toReference } from './principal-reference.js';
4
+ import { activeRegistration } from './registration.js';
8
5
  /**
9
6
  * Stamps the current execution context onto a job payload: the tenant and
10
7
  * correlation id of the registered sources (a new one from the correlation
@@ -23,26 +20,26 @@ const registration_1 = require("./registration");
23
20
  * await queue.add('send', withJobContext({ userId, email }));
24
21
  * ```
25
22
  */
26
- function withJobContext(data) {
23
+ export function withJobContext(data) {
27
24
  const prototype = data !== null && typeof data === 'object'
28
25
  ? Object.getPrototypeOf(data)
29
26
  : undefined;
30
27
  if (prototype !== Object.prototype && prototype !== null) {
31
28
  throw new TypeError('withJobContext(data) requires a plain object payload. Wrap arrays and class instances in a plain object first.');
32
29
  }
33
- const { principal, sources } = (0, registration_1.activeRegistration)();
30
+ const { principal, sources } = activeRegistration();
34
31
  const tenantId = sources.tenantId.current();
35
32
  if (tenantId === undefined)
36
- throw new missing_job_context_error_1.MissingJobContextError('tenant');
33
+ throw new MissingJobContextError('tenant');
37
34
  const captured = principal.capture();
38
35
  if (captured === undefined)
39
- throw new missing_job_context_error_1.MissingJobContextError('principal');
36
+ throw new MissingJobContextError('principal');
40
37
  return {
41
38
  ...data,
42
39
  jobContext: {
43
40
  tenantId,
44
41
  correlationId: sources.correlationId.current() ?? sources.correlationId.create(),
45
- principal: (0, principal_reference_1.toReference)(captured),
42
+ principal: toReference(captured),
46
43
  },
47
44
  };
48
45
  }
@@ -1 +1 @@
1
- {"version":3,"file":"with-job-context.js","sourceRoot":"","sources":["../../src/helpers/with-job-context.ts"],"names":[],"mappings":";AAAA,sEAAsE;;;AAEtE,mFAA6E;AAE7E,+DAAoD;AACpD,iDAAoD;AAEpD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBACE,IAAO;IAEP,MAAM,SAAS,GACb,IAAI,KAAK,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;QACvC,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC;QAC7B,CAAC,CAAC,SAAS,CAAC;IAChB,IAAI,SAAS,KAAK,MAAM,CAAC,SAAS,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;QACzD,MAAM,IAAI,SAAS,CACjB,gHAAgH,CACjH,CAAC;IACJ,CAAC;IACD,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,IAAA,iCAAkB,GAAE,CAAC;IACpD,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;IAC5C,IAAI,QAAQ,KAAK,SAAS;QAAE,MAAM,IAAI,kDAAsB,CAAC,QAAQ,CAAC,CAAC;IACvE,MAAM,QAAQ,GAAG,SAAS,CAAC,OAAO,EAAE,CAAC;IACrC,IAAI,QAAQ,KAAK,SAAS;QAAE,MAAM,IAAI,kDAAsB,CAAC,WAAW,CAAC,CAAC;IAC1E,OAAO;QACL,GAAG,IAAI;QACP,UAAU,EAAE;YACV,QAAQ;YACR,aAAa,EACX,OAAO,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,OAAO,CAAC,aAAa,CAAC,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S,EAAE,WAAW,CAAC,QAAQ,CAAC;SACjC;KACF,CAAC;AACJ,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- export { AsSystem, type AsSystemOptions, } from './decorators/as-system.decorator';
2
- export { InJobContext, type InJobContextOptions, } from './decorators/in-job-context.decorator';
3
- export { InvalidJobContextError } from './errors/invalid-job-context.error';
4
- export { MissingJobContextError } from './errors/missing-job-context.error';
5
- export { withJobContext } from './helpers/with-job-context';
6
- export type { ContextSource, CorrelationSource, JobContextSources, } from './interfaces/context-source.interface';
7
- export type { JobContext, WithJobContext, } from './interfaces/job-context.interface';
8
- export type { JobContextOptions } from './interfaces/job-context-options.interface';
9
- export type { IJobPrincipal } from './interfaces/job-principal.interface';
10
- export type { PrincipalReference } from './interfaces/principal-reference.interface';
11
- export { JobContextModule } from './job-context.module';
1
+ export { AsSystem, type AsSystemOptions, } from './decorators/as-system.decorator.js';
2
+ export { InJobContext, type InJobContextOptions, } from './decorators/in-job-context.decorator.js';
3
+ export { InvalidJobContextError } from './errors/invalid-job-context.error.js';
4
+ export { MissingJobContextError } from './errors/missing-job-context.error.js';
5
+ export { withJobContext } from './helpers/with-job-context.js';
6
+ export type { ContextSource, CorrelationSource, JobContextSources, } from './interfaces/context-source.interface.js';
7
+ export type { JobContext, WithJobContext, } from './interfaces/job-context.interface.js';
8
+ export type { JobContextOptions } from './interfaces/job-context-options.interface.js';
9
+ export type { IJobPrincipal } from './interfaces/job-principal.interface.js';
10
+ export type { PrincipalReference } from './interfaces/principal-reference.interface.js';
11
+ export { JobContextModule } from './job-context.module.js';
12
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,QAAQ,EACR,KAAK,eAAe,GACrB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,YAAY,EACZ,KAAK,mBAAmB,GACzB,MAAM,uCAAuC,CA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dist/index.js CHANGED
@@ -1,17 +1,8 @@
1
- "use strict";
2
1
  /* Copyright (C) 2026-present Aristotelis — see repository license. */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.JobContextModule = exports.withJobContext = exports.MissingJobContextError = exports.InvalidJobContextError = exports.InJobContext = exports.AsSystem = void 0;
5
- var as_system_decorator_1 = require("./decorators/as-system.decorator");
6
- Object.defineProperty(exports, "AsSystem", { enumerable: true, get: function () { return as_system_decorator_1.AsSystem; } });
7
- var in_job_context_decorator_1 = require("./decorators/in-job-context.decorator");
8
- Object.defineProperty(exports, "InJobContext", { enumerable: true, get: function () { return in_job_context_decorator_1.InJobContext; } });
9
- var invalid_job_context_error_1 = require("./errors/invalid-job-context.error");
10
- Object.defineProperty(exports, "InvalidJobContextError", { enumerable: true, get: function () { return invalid_job_context_error_1.InvalidJobContextError; } });
11
- var missing_job_context_error_1 = require("./errors/missing-job-context.error");
12
- Object.defineProperty(exports, "MissingJobContextError", { enumerable: true, get: function () { return missing_job_context_error_1.MissingJobContextError; } });
13
- var with_job_context_1 = require("./helpers/with-job-context");
14
- Object.defineProperty(exports, "withJobContext", { enumerable: true, get: function () { return with_job_context_1.withJobContext; } });
15
- var job_context_module_1 = require("./job-context.module");
16
- Object.defineProperty(exports, "JobContextModule", { enumerable: true, get: function () { return job_context_module_1.JobContextModule; } });
2
+ export { AsSystem, } from './decorators/as-system.decorator.js';
3
+ export { InJobContext, } from './decorators/in-job-context.decorator.js';
4
+ export { InvalidJobContextError } from './errors/invalid-job-context.error.js';
5
+ export { MissingJobContextError } from './errors/missing-job-context.error.js';
6
+ export { withJobContext } from './helpers/with-job-context.js';
7
+ export { JobContextModule } from './job-context.module.js';
17
8
  //# 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,sEAAsE;;;AAEtE,wEAG0C;AAFxC,+GAAA,QAAQ,OAAA;AAGV,kFAG+C;AAF7C,wHAAA,YAAY,OAAA;AAGd,gFAA4E;AAAnE,mIAAA,sBAAsB,OAAA;AAC/B,gFAA4E;AAAnE,mIAAA,sBAAsB,OAAA;AAC/B,+DAA4D;AAAnD,kHAAA,cAAc,OAAA;AAavB,2DAAwD;AAA/C,sHAAA,gBAAgB,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,sEAAsE;AAEtE,OAAO,EACL,QAAQ,GAET,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,YAAY,GAEb,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAa/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC"}
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /* Copyright (C) 2026-present Aristotelis — see repository license. */
3
- Object.defineProperty(exports, "__esModule", { value: true });
2
+ export {};
4
3
  //# sourceMappingURL=context-source.interface.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"context-source.interface.js","sourceRoot":"","sources":["../../src/interfaces/context-source.interface.ts"],"names":[],"mappings":";AAAA,sEAAsE"}
1
+ {"version":3,"file":"context-source.interface.js","sourceRoot":"","sources":["../../src/interfaces/context-source.interface.ts"],"names":[],"mappings":"AAAA,sEAAsE"}
@@ -1,6 +1,6 @@
1
1
  import type { ModuleMetadata, Type } from '@nestjs/common';
2
- import type { JobContextSources } from './context-source.interface';
3
- import type { IJobPrincipal } from './job-principal.interface';
2
+ import type { JobContextSources } from './context-source.interface.js';
3
+ import type { IJobPrincipal } from './job-principal.interface.js';
4
4
  /** Options of `JobContextModule.forRoot`. */
5
5
  export interface JobContextOptions {
6
6
  /** The application's principal port, instantiated through dependency injection. */
@@ -1 +1 @@
1
- {"version":3,"file":"job-context-options.interface.d.ts","sourceRoot":"","sources":["../../src/interfaces/job-context-options.interface.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,6CAA6C;AAC7C,MAAM,WAAW,iBAAiB;IAChC,mFAAmF;IACnF,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IAC/B;;;;;;;OAOG;IACH,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,CAAC,MAAM,SAAS,MAAM,EAAE,CAAC,CAAC;IACvD;;;;OAIG;IACH,OAAO,EAAE,iBAAiB,CAAC;IAC3B,2DAA2D;IAC3D,OAAO,CAAC,EAAE,cAAc,CAAC,SAAS,CAAC,CAAC;CACrC"}
1
+ {"version":3,"file":"job-context-options.interface.d.ts","sourceRoot":"","sources":["../../src/interfaces/job-context-options.interface.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE,6CAA6C;AAC7C,MAAM,WAAW,iBAAiB;IAChC,mFAAmF;IACnF,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IAC/B;;;;;;;OAOG;IACH,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,CAAC,MAAM,SAAS,MAAM,EAAE,CAAC,CAAC;IACvD;;;;OAIG;IACH,OAAO,EAAE,iBAAiB,CAAC;IAC3B,2DAA2D;IAC3D,OAAO,CAAC,EAAE,cAAc,CAAC,SAAS,CAAC,CAAC;CACrC"}
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /* Copyright (C) 2026-present Aristotelis — see repository license. */
3
- Object.defineProperty(exports, "__esModule", { value: true });
2
+ export {};
4
3
  //# sourceMappingURL=job-context-options.interface.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"job-context-options.interface.js","sourceRoot":"","sources":["../../src/interfaces/job-context-options.interface.ts"],"names":[],"mappings":";AAAA,sEAAsE"}
1
+ {"version":3,"file":"job-context-options.interface.js","sourceRoot":"","sources":["../../src/interfaces/job-context-options.interface.ts"],"names":[],"mappings":"AAAA,sEAAsE"}
@@ -1,4 +1,4 @@
1
- import type { PrincipalReference } from './principal-reference.interface';
1
+ import type { PrincipalReference } from './principal-reference.interface.js';
2
2
  /** Execution context a job payload carries from the request that enqueued it. */
3
3
  export interface JobContext {
4
4
  readonly tenantId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"job-context.interface.d.ts","sourceRoot":"","sources":["../../src/interfaces/job-context.interface.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAE1E,iFAAiF;AACjF,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,SAAS,EAAE,kBAAkB,CAAC;CACxC;AAED,iDAAiD;AACjD,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG;IAClE,UAAU,EAAE,UAAU,CAAC;CACxB,CAAC"}
1
+ {"version":3,"file":"job-context.interface.d.ts","sourceRoot":"","sources":["../../src/interfaces/job-context.interface.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAE7E,iFAAiF;AACjF,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,SAAS,EAAE,kBAAkB,CAAC;CACxC;AAED,iDAAiD;AACjD,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG;IAClE,UAAU,EAAE,UAAU,CAAC;CACxB,CAAC"}
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /* Copyright (C) 2026-present Aristotelis — see repository license. */
3
- Object.defineProperty(exports, "__esModule", { value: true });
2
+ export {};
4
3
  //# sourceMappingURL=job-context.interface.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"job-context.interface.js","sourceRoot":"","sources":["../../src/interfaces/job-context.interface.ts"],"names":[],"mappings":";AAAA,sEAAsE"}
1
+ {"version":3,"file":"job-context.interface.js","sourceRoot":"","sources":["../../src/interfaces/job-context.interface.ts"],"names":[],"mappings":"AAAA,sEAAsE"}
@@ -1,4 +1,4 @@
1
- import type { PrincipalReference } from './principal-reference.interface';
1
+ import type { PrincipalReference } from './principal-reference.interface.js';
2
2
  /**
3
3
  * Application port that reads the current principal when a job is enqueued and
4
4
  * binds it again when the job runs. The application implements it over its own
@@ -1 +1 @@
1
- {"version":3,"file":"job-principal.interface.d.ts","sourceRoot":"","sources":["../../src/interfaces/job-principal.interface.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAE1E;;;;;;;GAOG;AACH,MAAM,WAAW,aAAa,CAAC,MAAM,GAAG,OAAO;IAC7C;;;OAGG;IACH,OAAO,IAAI,kBAAkB,GAAG,SAAS,CAAC;IAE1C;;;;;;;;;OASG;IACH,OAAO,CAAC,CAAC,EACP,SAAS,EAAE,kBAAkB,EAC7B,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACtB,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,GACzB,OAAO,CAAC,CAAC,CAAC,CAAC;CACf"}
1
+ {"version":3,"file":"job-principal.interface.d.ts","sourceRoot":"","sources":["../../src/interfaces/job-principal.interface.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAE7E;;;;;;;GAOG;AACH,MAAM,WAAW,aAAa,CAAC,MAAM,GAAG,OAAO;IAC7C;;;OAGG;IACH,OAAO,IAAI,kBAAkB,GAAG,SAAS,CAAC;IAE1C;;;;;;;;;OASG;IACH,OAAO,CAAC,CAAC,EACP,SAAS,EAAE,kBAAkB,EAC7B,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACtB,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,GACzB,OAAO,CAAC,CAAC,CAAC,CAAC;CACf"}
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /* Copyright (C) 2026-present Aristotelis — see repository license. */
3
- Object.defineProperty(exports, "__esModule", { value: true });
2
+ export {};
4
3
  //# sourceMappingURL=job-principal.interface.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"job-principal.interface.js","sourceRoot":"","sources":["../../src/interfaces/job-principal.interface.ts"],"names":[],"mappings":";AAAA,sEAAsE"}
1
+ {"version":3,"file":"job-principal.interface.js","sourceRoot":"","sources":["../../src/interfaces/job-principal.interface.ts"],"names":[],"mappings":"AAAA,sEAAsE"}
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /* Copyright (C) 2026-present Aristotelis — see repository license. */
3
- Object.defineProperty(exports, "__esModule", { value: true });
2
+ export {};
4
3
  //# sourceMappingURL=principal-reference.interface.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"principal-reference.interface.js","sourceRoot":"","sources":["../../src/interfaces/principal-reference.interface.ts"],"names":[],"mappings":";AAAA,sEAAsE"}
1
+ {"version":3,"file":"principal-reference.interface.js","sourceRoot":"","sources":["../../src/interfaces/principal-reference.interface.ts"],"names":[],"mappings":"AAAA,sEAAsE"}
@@ -1,5 +1,5 @@
1
1
  import { type DynamicModule } from '@nestjs/common';
2
- import type { JobContextOptions } from './interfaces/job-context-options.interface';
2
+ import type { JobContextOptions } from './interfaces/job-context-options.interface.js';
3
3
  /**
4
4
  * Connects `withJobContext`, `@InJobContext` and `@AsSystem` to the
5
5
  * application's principal port, tenant list, and tenant and correlation id
@@ -1 +1 @@
1
- {"version":3,"file":"job-context.module.d.ts","sourceRoot":"","sources":["../src/job-context.module.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,aAAa,EAKnB,MAAM,gBAAgB,CAAC;AAYxB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4CAA4C,CAAC;AAyBpF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBACa,gBAAgB;IAC3B;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,iBAAiB,GAAG,aAAa,CAcxD;CACF"}
1
+ {"version":3,"file":"job-context.module.d.ts","sourceRoot":"","sources":["../src/job-context.module.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,aAAa,EAKnB,MAAM,gBAAgB,CAAC;AAYxB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAyBvF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBACa,gBAAgB;IAC3B;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,iBAAiB,GAAG,aAAa,CAcxD;CACF"}
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /* Copyright (C) 2026-present Aristotelis — see repository license. */
3
2
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
4
3
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -13,11 +12,9 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
13
12
  return function (target, key) { decorator(target, key, paramIndex); }
14
13
  };
15
14
  var JobContextModule_1;
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.JobContextModule = void 0;
18
- const common_1 = require("@nestjs/common");
19
- const job_context_constants_1 = require("./constants/job-context.constants");
20
- const registration_1 = require("./helpers/registration");
15
+ import { Inject, Injectable, Module, } from '@nestjs/common';
16
+ import { JOB_PRINCIPAL, JOB_SOURCES, JOB_TENANTS, } from './constants/job-context.constants.js';
17
+ import { register, unregister, } from './helpers/registration.js';
21
18
  /**
22
19
  * Registers the principal port, tenants and sources when it is constructed, before any
23
20
  * lifecycle hook can start a worker, and removes them at shutdown.
@@ -26,17 +23,17 @@ let JobContextRegistration = class JobContextRegistration {
26
23
  registration;
27
24
  constructor(principal, tenants, sources) {
28
25
  this.registration = { principal, tenants, sources };
29
- (0, registration_1.register)(this.registration);
26
+ register(this.registration);
30
27
  }
31
28
  onApplicationShutdown() {
32
- (0, registration_1.unregister)(this.registration);
29
+ unregister(this.registration);
33
30
  }
34
31
  };
35
32
  JobContextRegistration = __decorate([
36
- (0, common_1.Injectable)(),
37
- __param(0, (0, common_1.Inject)(job_context_constants_1.JOB_PRINCIPAL)),
38
- __param(1, (0, common_1.Inject)(job_context_constants_1.JOB_TENANTS)),
39
- __param(2, (0, common_1.Inject)(job_context_constants_1.JOB_SOURCES)),
33
+ Injectable(),
34
+ __param(0, Inject(JOB_PRINCIPAL)),
35
+ __param(1, Inject(JOB_TENANTS)),
36
+ __param(2, Inject(JOB_SOURCES)),
40
37
  __metadata("design:paramtypes", [Object, Array, Object])
41
38
  ], JobContextRegistration);
42
39
  /**
@@ -83,20 +80,20 @@ let JobContextModule = JobContextModule_1 = class JobContextModule {
83
80
  module: JobContextModule_1,
84
81
  imports: options.imports ?? [],
85
82
  providers: [
86
- { provide: job_context_constants_1.JOB_PRINCIPAL, useClass: options.principal },
83
+ { provide: JOB_PRINCIPAL, useClass: options.principal },
87
84
  typeof tenants === 'function'
88
- ? { provide: job_context_constants_1.JOB_TENANTS, useFactory: () => toTenantList(tenants()) }
89
- : { provide: job_context_constants_1.JOB_TENANTS, useValue: toTenantList(tenants) },
90
- { provide: job_context_constants_1.JOB_SOURCES, useValue: options.sources },
85
+ ? { provide: JOB_TENANTS, useFactory: () => toTenantList(tenants()) }
86
+ : { provide: JOB_TENANTS, useValue: toTenantList(tenants) },
87
+ { provide: JOB_SOURCES, useValue: options.sources },
91
88
  JobContextRegistration,
92
89
  ],
93
90
  };
94
91
  }
95
92
  };
96
- exports.JobContextModule = JobContextModule;
97
- exports.JobContextModule = JobContextModule = JobContextModule_1 = __decorate([
98
- (0, common_1.Module)({})
93
+ JobContextModule = JobContextModule_1 = __decorate([
94
+ Module({})
99
95
  ], JobContextModule);
96
+ export { JobContextModule };
100
97
  function toTenantList(tenants) {
101
98
  if (tenants.length === 0) {
102
99
  throw new TypeError('JobContextModule needs at least one tenant.');
@@ -1 +1 @@
1
- {"version":3,"file":"job-context.module.js","sourceRoot":"","sources":["../src/job-context.module.ts"],"names":[],"mappings":";AAAA,sEAAsE;;;;;;;;;;;;;;;;AAEtE,2CAMwB;AACxB,6EAI2C;AAC3C,yDAIgC;AAKhC;;;GAGG;AACH,IACM,sBAAsB,GAD5B,MACM,sBAAsB;IACT,YAAY,CAAe;IAE5C,YACyB,SAAwB,EAC1B,OAA0B,EAC1B,OAA0B;QAE/C,IAAI,CAAC,YAAY,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;QACpD,IAAA,uBAAQ,EAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC9B,CAAC;IAED,qBAAqB;QACnB,IAAA,yBAAU,EAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAChC,CAAC;CACF,CAAA;AAfK,sBAAsB;IAD3B,IAAA,mBAAU,GAAE;IAKR,WAAA,IAAA,eAAM,EAAC,qCAAa,CAAC,CAAA;IACrB,WAAA,IAAA,eAAM,EAAC,mCAAW,CAAC,CAAA;IACnB,WAAA,IAAA,eAAM,EAAC,mCAAW,CAAC,CAAA;;GANlB,sBA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Y,CAAC,OAAO,CAAC,EAAE;gBAC7D,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,CAAC,OAAO,EAAE;gBACnD,sBAAsB;aACvB;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AA/BY,gBAAgB;IAD5B,MAAM,CAAC,EAAE,CAAC;GACE,gBAAgB,CA+B5B;;AAED,SAAS,YAAY,CAAC,OAA0B;IAC9C,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,SAAS,CAAC,6CAA6C,CAAC,CAAC;IACrE,CAAC;IACD,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC;AACtB,CAAC"}
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@nestjs-pipeline/job-context",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Carries the tenant, correlation id and principal of a request into the queue jobs it enqueues, and gives system-started work an explicit context",
5
5
  "author": "Aristotelis",
6
6
  "license": "SEE LICENSE IN LICENSE",
7
+ "type": "module",
7
8
  "engines": {
8
9
  "node": ">=22.12.0"
9
10
  },
@@ -26,6 +27,13 @@
26
27
  "authorization",
27
28
  "correlation-id"
28
29
  ],
30
+ "exports": {
31
+ ".": {
32
+ "types": "./dist/index.d.ts",
33
+ "default": "./dist/index.js"
34
+ },
35
+ "./package.json": "./package.json"
36
+ },
29
37
  "main": "dist/index.js",
30
38
  "types": "dist/index.d.ts",
31
39
  "files": [