@carbonbox/domain 0.7.34 → 0.8.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 (94) hide show
  1. package/build/carbonbox/emission-calculation-process/calculation-jobs/domain/events/CalculationJobCompletedDomainEvent.js +38 -0
  2. package/build/carbonbox/emission-calculation-process/calculation-jobs/domain/events/CalculationJobFailedDomainEvent.js +38 -0
  3. package/build/carbonbox/emission-calculation-process/calculation-jobs/domain/events/CalculationJobStartedDomainEvent.js +38 -0
  4. package/build/carbonbox/emission-calculation-process/calculation-jobs/domain/types/CalculationJobCompletedPayload.js +2 -0
  5. package/build/carbonbox/emission-calculation-process/calculation-jobs/domain/types/CalculationJobFailedPayload.js +2 -0
  6. package/build/carbonbox/emission-calculation-process/calculation-jobs/domain/types/CalculationJobStartedPayload.js +2 -0
  7. package/build/carbonbox/emission-calculation-process/calculation-processes/domain/entity/CalculationProcess.js +11 -2
  8. package/build/carbonbox/emission-calculation-process/calculation-processes/domain/events/CalculationProcessCompletedDomainEvent.js +38 -0
  9. package/build/carbonbox/emission-calculation-process/calculation-processes/domain/events/CalculationProcessFailedDomainEvent.js +38 -0
  10. package/build/carbonbox/emission-calculation-process/calculation-processes/domain/types/CalculationProcessCompletedPayload.js +2 -0
  11. package/build/carbonbox/emission-calculation-process/calculation-processes/domain/types/CalculationProcessFailedPayload.js +2 -0
  12. package/build/carbonbox/emission-calculation-process/calculation-processes/domain/value-objects/CalculationProcessParentWorkflow.js +34 -0
  13. package/build/carbonbox/emission-calculation-process/calculation-workflows/domain/events/WorkflowActivatedDomainEvent.js +38 -0
  14. package/build/carbonbox/emission-calculation-process/calculation-workflows/domain/events/WorkflowPausedDomainEvent.js +38 -0
  15. package/build/carbonbox/emission-calculation-process/calculation-workflows/domain/types/WorkflowActivatedPayload.js +2 -0
  16. package/build/carbonbox/emission-calculation-process/calculation-workflows/domain/types/WorkflowPausedPayload.js +2 -0
  17. package/build/carbonbox/shared/domain/events/DomainEvent.js +33 -0
  18. package/build/carbonbox/shared/domain/events/DomainEventEnvelopePrimitives.js +2 -0
  19. package/build/carbonbox/shared/domain/events/DomainEventName.js +113 -0
  20. package/build/carbonbox/shared/domain/events/IDomainEvent.js +2 -0
  21. package/build/carbonbox/shared/domain/exceptions/InvalidDomainEventNameError.js +17 -0
  22. package/build/carbonbox/shared/domain/types/CalculationWorkflowReference.js +2 -0
  23. package/build/carbonbox/shared/domain/types/CalculationWorkflowReferencePrimitives.js +2 -0
  24. package/build/carbonbox/shared/domain/types/DomainEventEnvelopePrimitives.js +2 -0
  25. package/build/carbonbox/shared/domain/types/DomainEventFromPrimitivesInput.js +2 -0
  26. package/build/carbonbox/shared/domain/value-objects/CalculationWorkflowReference.js +89 -0
  27. package/build/main/index.js +46 -11
  28. package/build/types/carbonbox/emission-calculation-formulas/domain/repository/IEmissionCalculationFormulaRepository.d.ts +11 -0
  29. package/build/types/carbonbox/emission-calculation-formulas/domain/repository/IEmissionCalculationFormulaRepository.d.ts.map +1 -1
  30. package/build/types/carbonbox/emission-calculation-process/calculation-jobs/domain/events/CalculationJobCompletedDomainEvent.d.ts +15 -0
  31. package/build/types/carbonbox/emission-calculation-process/calculation-jobs/domain/events/CalculationJobCompletedDomainEvent.d.ts.map +1 -0
  32. package/build/types/carbonbox/emission-calculation-process/calculation-jobs/domain/events/CalculationJobFailedDomainEvent.d.ts +15 -0
  33. package/build/types/carbonbox/emission-calculation-process/calculation-jobs/domain/events/CalculationJobFailedDomainEvent.d.ts.map +1 -0
  34. package/build/types/carbonbox/emission-calculation-process/calculation-jobs/domain/events/CalculationJobStartedDomainEvent.d.ts +15 -0
  35. package/build/types/carbonbox/emission-calculation-process/calculation-jobs/domain/events/CalculationJobStartedDomainEvent.d.ts.map +1 -0
  36. package/build/types/carbonbox/emission-calculation-process/calculation-jobs/domain/repository/ICalculationJobRepository.d.ts +10 -0
  37. package/build/types/carbonbox/emission-calculation-process/calculation-jobs/domain/repository/ICalculationJobRepository.d.ts.map +1 -1
  38. package/build/types/carbonbox/emission-calculation-process/calculation-jobs/domain/types/CalculationJobCompletedPayload.d.ts +26 -0
  39. package/build/types/carbonbox/emission-calculation-process/calculation-jobs/domain/types/CalculationJobCompletedPayload.d.ts.map +1 -0
  40. package/build/types/carbonbox/emission-calculation-process/calculation-jobs/domain/types/CalculationJobFailedPayload.d.ts +28 -0
  41. package/build/types/carbonbox/emission-calculation-process/calculation-jobs/domain/types/CalculationJobFailedPayload.d.ts.map +1 -0
  42. package/build/types/carbonbox/emission-calculation-process/calculation-jobs/domain/types/CalculationJobStartedPayload.d.ts +17 -0
  43. package/build/types/carbonbox/emission-calculation-process/calculation-jobs/domain/types/CalculationJobStartedPayload.d.ts.map +1 -0
  44. package/build/types/carbonbox/emission-calculation-process/calculation-processes/domain/entity/CalculationProcess.d.ts +2 -0
  45. package/build/types/carbonbox/emission-calculation-process/calculation-processes/domain/entity/CalculationProcess.d.ts.map +1 -1
  46. package/build/types/carbonbox/emission-calculation-process/calculation-processes/domain/entity/ICalculationProcess.d.ts +2 -0
  47. package/build/types/carbonbox/emission-calculation-process/calculation-processes/domain/entity/ICalculationProcess.d.ts.map +1 -1
  48. package/build/types/carbonbox/emission-calculation-process/calculation-processes/domain/events/CalculationProcessCompletedDomainEvent.d.ts +15 -0
  49. package/build/types/carbonbox/emission-calculation-process/calculation-processes/domain/events/CalculationProcessCompletedDomainEvent.d.ts.map +1 -0
  50. package/build/types/carbonbox/emission-calculation-process/calculation-processes/domain/events/CalculationProcessFailedDomainEvent.d.ts +15 -0
  51. package/build/types/carbonbox/emission-calculation-process/calculation-processes/domain/events/CalculationProcessFailedDomainEvent.d.ts.map +1 -0
  52. package/build/types/carbonbox/emission-calculation-process/calculation-processes/domain/repository/ICalculationProcessRepository.d.ts +13 -0
  53. package/build/types/carbonbox/emission-calculation-process/calculation-processes/domain/repository/ICalculationProcessRepository.d.ts.map +1 -1
  54. package/build/types/carbonbox/emission-calculation-process/calculation-processes/domain/types/CalculationProcessCompletedPayload.d.ts +21 -0
  55. package/build/types/carbonbox/emission-calculation-process/calculation-processes/domain/types/CalculationProcessCompletedPayload.d.ts.map +1 -0
  56. package/build/types/carbonbox/emission-calculation-process/calculation-processes/domain/types/CalculationProcessFailedPayload.d.ts +24 -0
  57. package/build/types/carbonbox/emission-calculation-process/calculation-processes/domain/types/CalculationProcessFailedPayload.d.ts.map +1 -0
  58. package/build/types/carbonbox/emission-calculation-process/calculation-processes/domain/types/CalculationProcessPrimitives.d.ts +2 -0
  59. package/build/types/carbonbox/emission-calculation-process/calculation-processes/domain/types/CalculationProcessPrimitives.d.ts.map +1 -1
  60. package/build/types/carbonbox/emission-calculation-process/calculation-processes/domain/types/CalculationProcessProps.d.ts +2 -0
  61. package/build/types/carbonbox/emission-calculation-process/calculation-processes/domain/types/CalculationProcessProps.d.ts.map +1 -1
  62. package/build/types/carbonbox/emission-calculation-process/calculation-processes/domain/value-objects/CalculationProcessParentWorkflow.d.ts +20 -0
  63. package/build/types/carbonbox/emission-calculation-process/calculation-processes/domain/value-objects/CalculationProcessParentWorkflow.d.ts.map +1 -0
  64. package/build/types/carbonbox/emission-calculation-process/calculation-workflows/domain/events/WorkflowActivatedDomainEvent.d.ts +15 -0
  65. package/build/types/carbonbox/emission-calculation-process/calculation-workflows/domain/events/WorkflowActivatedDomainEvent.d.ts.map +1 -0
  66. package/build/types/carbonbox/emission-calculation-process/calculation-workflows/domain/events/WorkflowPausedDomainEvent.d.ts +15 -0
  67. package/build/types/carbonbox/emission-calculation-process/calculation-workflows/domain/events/WorkflowPausedDomainEvent.d.ts.map +1 -0
  68. package/build/types/carbonbox/emission-calculation-process/calculation-workflows/domain/types/WorkflowActivatedPayload.d.ts +18 -0
  69. package/build/types/carbonbox/emission-calculation-process/calculation-workflows/domain/types/WorkflowActivatedPayload.d.ts.map +1 -0
  70. package/build/types/carbonbox/emission-calculation-process/calculation-workflows/domain/types/WorkflowPausedPayload.d.ts +16 -0
  71. package/build/types/carbonbox/emission-calculation-process/calculation-workflows/domain/types/WorkflowPausedPayload.d.ts.map +1 -0
  72. package/build/types/carbonbox/shared/domain/events/DomainEvent.d.ts +28 -0
  73. package/build/types/carbonbox/shared/domain/events/DomainEvent.d.ts.map +1 -0
  74. package/build/types/carbonbox/shared/domain/events/DomainEventEnvelopePrimitives.d.ts +26 -0
  75. package/build/types/carbonbox/shared/domain/events/DomainEventEnvelopePrimitives.d.ts.map +1 -0
  76. package/build/types/carbonbox/shared/domain/events/DomainEventName.d.ts +40 -0
  77. package/build/types/carbonbox/shared/domain/events/DomainEventName.d.ts.map +1 -0
  78. package/build/types/carbonbox/shared/domain/events/IDomainEvent.d.ts +36 -0
  79. package/build/types/carbonbox/shared/domain/events/IDomainEvent.d.ts.map +1 -0
  80. package/build/types/carbonbox/shared/domain/exceptions/InvalidDomainEventNameError.d.ts +7 -0
  81. package/build/types/carbonbox/shared/domain/exceptions/InvalidDomainEventNameError.d.ts.map +1 -0
  82. package/build/types/carbonbox/shared/domain/types/CalculationWorkflowReference.d.ts +13 -0
  83. package/build/types/carbonbox/shared/domain/types/CalculationWorkflowReference.d.ts.map +1 -0
  84. package/build/types/carbonbox/shared/domain/types/CalculationWorkflowReferencePrimitives.d.ts +9 -0
  85. package/build/types/carbonbox/shared/domain/types/CalculationWorkflowReferencePrimitives.d.ts.map +1 -0
  86. package/build/types/carbonbox/shared/domain/types/DomainEventEnvelopePrimitives.d.ts +26 -0
  87. package/build/types/carbonbox/shared/domain/types/DomainEventEnvelopePrimitives.d.ts.map +1 -0
  88. package/build/types/carbonbox/shared/domain/types/DomainEventFromPrimitivesInput.d.ts +15 -0
  89. package/build/types/carbonbox/shared/domain/types/DomainEventFromPrimitivesInput.d.ts.map +1 -0
  90. package/build/types/carbonbox/shared/domain/value-objects/CalculationWorkflowReference.d.ts +32 -0
  91. package/build/types/carbonbox/shared/domain/value-objects/CalculationWorkflowReference.d.ts.map +1 -0
  92. package/build/types/main/index.d.ts +24 -0
  93. package/build/types/main/index.d.ts.map +1 -1
  94. package/package.json +1 -1
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _CalculationJobCompletedDomainEvent_payload;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.CalculationJobCompletedDomainEvent = void 0;
16
+ const DomainEvent_1 = require("../../../../shared/domain/events/DomainEvent");
17
+ const DomainEventName_1 = require("../../../../shared/domain/events/DomainEventName");
18
+ class CalculationJobCompletedDomainEvent extends DomainEvent_1.DomainEvent {
19
+ constructor(payload, occurredAt) {
20
+ super(occurredAt);
21
+ this.name = CalculationJobCompletedDomainEvent.NAME;
22
+ _CalculationJobCompletedDomainEvent_payload.set(this, void 0);
23
+ this.aggregateId = payload.jobId;
24
+ __classPrivateFieldSet(this, _CalculationJobCompletedDomainEvent_payload, payload, "f");
25
+ }
26
+ static create(payload) {
27
+ return new CalculationJobCompletedDomainEvent(payload);
28
+ }
29
+ static fromPrimitives(primitives) {
30
+ return new CalculationJobCompletedDomainEvent(primitives.payload, primitives.occurredAt);
31
+ }
32
+ get payload() {
33
+ return __classPrivateFieldGet(this, _CalculationJobCompletedDomainEvent_payload, "f");
34
+ }
35
+ }
36
+ exports.CalculationJobCompletedDomainEvent = CalculationJobCompletedDomainEvent;
37
+ _CalculationJobCompletedDomainEvent_payload = new WeakMap();
38
+ CalculationJobCompletedDomainEvent.NAME = DomainEventName_1.DomainEventName.create('CalculationJobCompleted');
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _CalculationJobFailedDomainEvent_payload;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.CalculationJobFailedDomainEvent = void 0;
16
+ const DomainEvent_1 = require("../../../../shared/domain/events/DomainEvent");
17
+ const DomainEventName_1 = require("../../../../shared/domain/events/DomainEventName");
18
+ class CalculationJobFailedDomainEvent extends DomainEvent_1.DomainEvent {
19
+ constructor(payload, occurredAt) {
20
+ super(occurredAt);
21
+ this.name = CalculationJobFailedDomainEvent.NAME;
22
+ _CalculationJobFailedDomainEvent_payload.set(this, void 0);
23
+ this.aggregateId = payload.jobId;
24
+ __classPrivateFieldSet(this, _CalculationJobFailedDomainEvent_payload, payload, "f");
25
+ }
26
+ static create(payload) {
27
+ return new CalculationJobFailedDomainEvent(payload);
28
+ }
29
+ static fromPrimitives(primitives) {
30
+ return new CalculationJobFailedDomainEvent(primitives.payload, primitives.occurredAt);
31
+ }
32
+ get payload() {
33
+ return __classPrivateFieldGet(this, _CalculationJobFailedDomainEvent_payload, "f");
34
+ }
35
+ }
36
+ exports.CalculationJobFailedDomainEvent = CalculationJobFailedDomainEvent;
37
+ _CalculationJobFailedDomainEvent_payload = new WeakMap();
38
+ CalculationJobFailedDomainEvent.NAME = DomainEventName_1.DomainEventName.create('CalculationJobFailed');
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _CalculationJobStartedDomainEvent_payload;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.CalculationJobStartedDomainEvent = void 0;
16
+ const DomainEvent_1 = require("../../../../shared/domain/events/DomainEvent");
17
+ const DomainEventName_1 = require("../../../../shared/domain/events/DomainEventName");
18
+ class CalculationJobStartedDomainEvent extends DomainEvent_1.DomainEvent {
19
+ constructor(payload, occurredAt) {
20
+ super(occurredAt);
21
+ this.name = CalculationJobStartedDomainEvent.NAME;
22
+ _CalculationJobStartedDomainEvent_payload.set(this, void 0);
23
+ this.aggregateId = payload.jobId;
24
+ __classPrivateFieldSet(this, _CalculationJobStartedDomainEvent_payload, payload, "f");
25
+ }
26
+ static create(payload) {
27
+ return new CalculationJobStartedDomainEvent(payload);
28
+ }
29
+ static fromPrimitives(primitives) {
30
+ return new CalculationJobStartedDomainEvent(primitives.payload, primitives.occurredAt);
31
+ }
32
+ get payload() {
33
+ return __classPrivateFieldGet(this, _CalculationJobStartedDomainEvent_payload, "f");
34
+ }
35
+ }
36
+ exports.CalculationJobStartedDomainEvent = CalculationJobStartedDomainEvent;
37
+ _CalculationJobStartedDomainEvent_payload = new WeakMap();
38
+ CalculationJobStartedDomainEvent.NAME = DomainEventName_1.DomainEventName.create('CalculationJobStarted');
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -10,13 +10,14 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
10
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
11
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
12
  };
13
- var _CalculationProcess_carbonClient, _CalculationProcess_footprintConfiguration, _CalculationProcess_scheduledAt, _CalculationProcess_estimatedDuration, _CalculationProcess_priority, _CalculationProcess_dependencies, _CalculationProcess_executedByStakeholder, _CalculationProcess_startedAt, _CalculationProcess_completedAt, _CalculationProcess_actualDuration, _CalculationProcess_status, _CalculationProcess_errorMessage, _CalculationProcess_progressPercentage, _CalculationProcess_submissionsToProcess, _CalculationProcess_calculationsGenerated, _CalculationProcess_totalEmissionsCalculated, _CalculationProcess_processNotes, _CalculationProcess_retryCount, _CalculationProcess_maxRetries;
13
+ var _CalculationProcess_parentWorkflow, _CalculationProcess_carbonClient, _CalculationProcess_footprintConfiguration, _CalculationProcess_scheduledAt, _CalculationProcess_estimatedDuration, _CalculationProcess_priority, _CalculationProcess_dependencies, _CalculationProcess_executedByStakeholder, _CalculationProcess_startedAt, _CalculationProcess_completedAt, _CalculationProcess_actualDuration, _CalculationProcess_status, _CalculationProcess_errorMessage, _CalculationProcess_progressPercentage, _CalculationProcess_submissionsToProcess, _CalculationProcess_calculationsGenerated, _CalculationProcess_totalEmissionsCalculated, _CalculationProcess_processNotes, _CalculationProcess_retryCount, _CalculationProcess_maxRetries;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.CalculationProcess = void 0;
16
16
  const AggregateRoot_1 = require("../../../../shared/domain/entities/AggregateRoot");
17
17
  const CalculationProcessActualDuration_1 = require("../value-objects/CalculationProcessActualDuration");
18
18
  const CalculationProcessCalculationsGenerated_1 = require("../value-objects/CalculationProcessCalculationsGenerated");
19
19
  const CalculationProcessCarbonClient_1 = require("../value-objects/CalculationProcessCarbonClient");
20
+ const CalculationProcessParentWorkflow_1 = require("../value-objects/CalculationProcessParentWorkflow");
20
21
  const CalculationProcessCompletedAt_1 = require("../value-objects/CalculationProcessCompletedAt");
21
22
  const CalculationProcessDependencies_1 = require("../value-objects/CalculationProcessDependencies");
22
23
  const CalculationProcessErrorMessage_1 = require("../value-objects/CalculationProcessErrorMessage");
@@ -40,6 +41,7 @@ class CalculationProcess extends AggregateRoot_1.AggregateRoot {
40
41
  ? CalculationProcessId_1.CalculationProcessId.fromPrimitives(props.id).toPrimitives()
41
42
  : CalculationProcessId_1.CalculationProcessId.create(props.id).toPrimitives();
42
43
  super({ id }, skipDomainValidation);
44
+ _CalculationProcess_parentWorkflow.set(this, void 0);
43
45
  _CalculationProcess_carbonClient.set(this, void 0);
44
46
  _CalculationProcess_footprintConfiguration.set(this, void 0);
45
47
  _CalculationProcess_scheduledAt.set(this, void 0);
@@ -61,6 +63,7 @@ class CalculationProcess extends AggregateRoot_1.AggregateRoot {
61
63
  _CalculationProcess_maxRetries.set(this, void 0);
62
64
  if (skipDomainValidation === false) {
63
65
  // Initialize with domain validation
66
+ __classPrivateFieldSet(this, _CalculationProcess_parentWorkflow, CalculationProcessParentWorkflow_1.CalculationProcessParentWorkflow.create(props.parentWorkflow), "f");
64
67
  __classPrivateFieldSet(this, _CalculationProcess_carbonClient, CalculationProcessCarbonClient_1.CalculationProcessCarbonClient.create(props.carbonClient), "f");
65
68
  __classPrivateFieldSet(this, _CalculationProcess_footprintConfiguration, CalculationProcessFootprintConfiguration_1.CalculationProcessFootprintConfiguration.create(props.footprintConfiguration), "f");
66
69
  __classPrivateFieldSet(this, _CalculationProcess_scheduledAt, CalculationProcessScheduledAt_1.CalculationProcessScheduledAt.create(props.scheduledAt), "f");
@@ -83,6 +86,7 @@ class CalculationProcess extends AggregateRoot_1.AggregateRoot {
83
86
  }
84
87
  else {
85
88
  // Initialize from primitives (no domain validation)
89
+ __classPrivateFieldSet(this, _CalculationProcess_parentWorkflow, CalculationProcessParentWorkflow_1.CalculationProcessParentWorkflow.fromPrimitives(props.parentWorkflow), "f");
86
90
  __classPrivateFieldSet(this, _CalculationProcess_carbonClient, CalculationProcessCarbonClient_1.CalculationProcessCarbonClient.fromPrimitives(props.carbonClient), "f");
87
91
  __classPrivateFieldSet(this, _CalculationProcess_footprintConfiguration, CalculationProcessFootprintConfiguration_1.CalculationProcessFootprintConfiguration.fromPrimitives(props.footprintConfiguration), "f");
88
92
  __classPrivateFieldSet(this, _CalculationProcess_scheduledAt, CalculationProcessScheduledAt_1.CalculationProcessScheduledAt.fromPrimitives(props.scheduledAt), "f");
@@ -110,6 +114,7 @@ class CalculationProcess extends AggregateRoot_1.AggregateRoot {
110
114
  static fromPrimitives(primitives) {
111
115
  const props = {
112
116
  id: primitives.id,
117
+ parentWorkflow: primitives.parentWorkflow,
113
118
  carbonClient: primitives.carbonClient,
114
119
  footprintConfiguration: primitives.footprintConfiguration,
115
120
  scheduledAt: primitives.scheduledAt,
@@ -135,6 +140,7 @@ class CalculationProcess extends AggregateRoot_1.AggregateRoot {
135
140
  get toPrimitives() {
136
141
  return {
137
142
  id: this.id.toPrimitives(),
143
+ parentWorkflow: __classPrivateFieldGet(this, _CalculationProcess_parentWorkflow, "f").toPrimitives(),
138
144
  carbonClient: __classPrivateFieldGet(this, _CalculationProcess_carbonClient, "f").toPrimitives(),
139
145
  footprintConfiguration: __classPrivateFieldGet(this, _CalculationProcess_footprintConfiguration, "f").toPrimitives(),
140
146
  scheduledAt: __classPrivateFieldGet(this, _CalculationProcess_scheduledAt, "f").toPrimitives(),
@@ -156,6 +162,9 @@ class CalculationProcess extends AggregateRoot_1.AggregateRoot {
156
162
  maxRetries: __classPrivateFieldGet(this, _CalculationProcess_maxRetries, "f").toPrimitives(),
157
163
  };
158
164
  }
165
+ get parentWorkflow() {
166
+ return __classPrivateFieldGet(this, _CalculationProcess_parentWorkflow, "f");
167
+ }
159
168
  get carbonClient() {
160
169
  return __classPrivateFieldGet(this, _CalculationProcess_carbonClient, "f");
161
170
  }
@@ -215,7 +224,7 @@ class CalculationProcess extends AggregateRoot_1.AggregateRoot {
215
224
  }
216
225
  }
217
226
  exports.CalculationProcess = CalculationProcess;
218
- _CalculationProcess_carbonClient = new WeakMap(), _CalculationProcess_footprintConfiguration = new WeakMap(), _CalculationProcess_scheduledAt = new WeakMap(), _CalculationProcess_estimatedDuration = new WeakMap(), _CalculationProcess_priority = new WeakMap(), _CalculationProcess_dependencies = new WeakMap(), _CalculationProcess_executedByStakeholder = new WeakMap(), _CalculationProcess_startedAt = new WeakMap(), _CalculationProcess_completedAt = new WeakMap(), _CalculationProcess_actualDuration = new WeakMap(), _CalculationProcess_status = new WeakMap(), _CalculationProcess_errorMessage = new WeakMap(), _CalculationProcess_progressPercentage = new WeakMap(), _CalculationProcess_submissionsToProcess = new WeakMap(), _CalculationProcess_calculationsGenerated = new WeakMap(), _CalculationProcess_totalEmissionsCalculated = new WeakMap(), _CalculationProcess_processNotes = new WeakMap(), _CalculationProcess_retryCount = new WeakMap(), _CalculationProcess_maxRetries = new WeakMap();
227
+ _CalculationProcess_parentWorkflow = new WeakMap(), _CalculationProcess_carbonClient = new WeakMap(), _CalculationProcess_footprintConfiguration = new WeakMap(), _CalculationProcess_scheduledAt = new WeakMap(), _CalculationProcess_estimatedDuration = new WeakMap(), _CalculationProcess_priority = new WeakMap(), _CalculationProcess_dependencies = new WeakMap(), _CalculationProcess_executedByStakeholder = new WeakMap(), _CalculationProcess_startedAt = new WeakMap(), _CalculationProcess_completedAt = new WeakMap(), _CalculationProcess_actualDuration = new WeakMap(), _CalculationProcess_status = new WeakMap(), _CalculationProcess_errorMessage = new WeakMap(), _CalculationProcess_progressPercentage = new WeakMap(), _CalculationProcess_submissionsToProcess = new WeakMap(), _CalculationProcess_calculationsGenerated = new WeakMap(), _CalculationProcess_totalEmissionsCalculated = new WeakMap(), _CalculationProcess_processNotes = new WeakMap(), _CalculationProcess_retryCount = new WeakMap(), _CalculationProcess_maxRetries = new WeakMap();
219
228
  // TODO: Pasar todo el módulo de service-catalog a ServiceCatalog
220
229
  // TODO: Validar que todo lo que herede de String, Boolean, Numeric, PositiveInteger, DateTimeString
221
230
  // AggregateId, AggregateIdList, Code, CodeList, tenga guardas en el create
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _CalculationProcessCompletedDomainEvent_payload;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.CalculationProcessCompletedDomainEvent = void 0;
16
+ const DomainEvent_1 = require("../../../../shared/domain/events/DomainEvent");
17
+ const DomainEventName_1 = require("../../../../shared/domain/events/DomainEventName");
18
+ class CalculationProcessCompletedDomainEvent extends DomainEvent_1.DomainEvent {
19
+ constructor(payload, occurredAt) {
20
+ super(occurredAt);
21
+ this.name = CalculationProcessCompletedDomainEvent.NAME;
22
+ _CalculationProcessCompletedDomainEvent_payload.set(this, void 0);
23
+ this.aggregateId = payload.processId;
24
+ __classPrivateFieldSet(this, _CalculationProcessCompletedDomainEvent_payload, payload, "f");
25
+ }
26
+ static create(payload) {
27
+ return new CalculationProcessCompletedDomainEvent(payload);
28
+ }
29
+ static fromPrimitives(primitives) {
30
+ return new CalculationProcessCompletedDomainEvent(primitives.payload, primitives.occurredAt);
31
+ }
32
+ get payload() {
33
+ return __classPrivateFieldGet(this, _CalculationProcessCompletedDomainEvent_payload, "f");
34
+ }
35
+ }
36
+ exports.CalculationProcessCompletedDomainEvent = CalculationProcessCompletedDomainEvent;
37
+ _CalculationProcessCompletedDomainEvent_payload = new WeakMap();
38
+ CalculationProcessCompletedDomainEvent.NAME = DomainEventName_1.DomainEventName.create('CalculationProcessCompleted');
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _CalculationProcessFailedDomainEvent_payload;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.CalculationProcessFailedDomainEvent = void 0;
16
+ const DomainEvent_1 = require("../../../../shared/domain/events/DomainEvent");
17
+ const DomainEventName_1 = require("../../../../shared/domain/events/DomainEventName");
18
+ class CalculationProcessFailedDomainEvent extends DomainEvent_1.DomainEvent {
19
+ constructor(payload, occurredAt) {
20
+ super(occurredAt);
21
+ this.name = CalculationProcessFailedDomainEvent.NAME;
22
+ _CalculationProcessFailedDomainEvent_payload.set(this, void 0);
23
+ this.aggregateId = payload.processId;
24
+ __classPrivateFieldSet(this, _CalculationProcessFailedDomainEvent_payload, payload, "f");
25
+ }
26
+ static create(payload) {
27
+ return new CalculationProcessFailedDomainEvent(payload);
28
+ }
29
+ static fromPrimitives(primitives) {
30
+ return new CalculationProcessFailedDomainEvent(primitives.payload, primitives.occurredAt);
31
+ }
32
+ get payload() {
33
+ return __classPrivateFieldGet(this, _CalculationProcessFailedDomainEvent_payload, "f");
34
+ }
35
+ }
36
+ exports.CalculationProcessFailedDomainEvent = CalculationProcessFailedDomainEvent;
37
+ _CalculationProcessFailedDomainEvent_payload = new WeakMap();
38
+ CalculationProcessFailedDomainEvent.NAME = DomainEventName_1.DomainEventName.create('CalculationProcessFailed');
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CalculationProcessParentWorkflow = void 0;
4
+ const CalculationWorkflowReference_1 = require("../../../../shared/domain/value-objects/CalculationWorkflowReference");
5
+ /**
6
+ * Reference from a CalculationProcess to the CalculationWorkflow that
7
+ * triggered it.
8
+ *
9
+ * Modelling this relation explicitly is what makes invariants like
10
+ * `maxConcurrentProcesses per workflow` enforceable: the process
11
+ * repository can now answer `countRunningByWorkflowId(...)` without
12
+ * leaking workflow internals across the aggregate boundary.
13
+ */
14
+ class CalculationProcessParentWorkflow extends CalculationWorkflowReference_1.CalculationWorkflowReference {
15
+ constructor(value, skipDomainValidation) {
16
+ super(value, skipDomainValidation, CalculationProcessParentWorkflow.PROPERTY_NAME);
17
+ }
18
+ static create(value) {
19
+ return new CalculationProcessParentWorkflow(value, false);
20
+ }
21
+ static fromPrimitives(primitives) {
22
+ const value = {
23
+ id: primitives.id,
24
+ };
25
+ return new CalculationProcessParentWorkflow(value, true);
26
+ }
27
+ toPrimitives() {
28
+ return {
29
+ id: this.value.id,
30
+ };
31
+ }
32
+ }
33
+ exports.CalculationProcessParentWorkflow = CalculationProcessParentWorkflow;
34
+ CalculationProcessParentWorkflow.PROPERTY_NAME = 'parentWorkflow';
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _WorkflowActivatedDomainEvent_payload;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.WorkflowActivatedDomainEvent = void 0;
16
+ const DomainEvent_1 = require("../../../../shared/domain/events/DomainEvent");
17
+ const DomainEventName_1 = require("../../../../shared/domain/events/DomainEventName");
18
+ class WorkflowActivatedDomainEvent extends DomainEvent_1.DomainEvent {
19
+ constructor(payload, occurredAt) {
20
+ super(occurredAt);
21
+ this.name = WorkflowActivatedDomainEvent.NAME;
22
+ _WorkflowActivatedDomainEvent_payload.set(this, void 0);
23
+ this.aggregateId = payload.workflowId;
24
+ __classPrivateFieldSet(this, _WorkflowActivatedDomainEvent_payload, payload, "f");
25
+ }
26
+ static create(payload) {
27
+ return new WorkflowActivatedDomainEvent(payload);
28
+ }
29
+ static fromPrimitives(primitives) {
30
+ return new WorkflowActivatedDomainEvent(primitives.payload, primitives.occurredAt);
31
+ }
32
+ get payload() {
33
+ return __classPrivateFieldGet(this, _WorkflowActivatedDomainEvent_payload, "f");
34
+ }
35
+ }
36
+ exports.WorkflowActivatedDomainEvent = WorkflowActivatedDomainEvent;
37
+ _WorkflowActivatedDomainEvent_payload = new WeakMap();
38
+ WorkflowActivatedDomainEvent.NAME = DomainEventName_1.DomainEventName.create('WorkflowActivated');
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _WorkflowPausedDomainEvent_payload;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.WorkflowPausedDomainEvent = void 0;
16
+ const DomainEvent_1 = require("../../../../shared/domain/events/DomainEvent");
17
+ const DomainEventName_1 = require("../../../../shared/domain/events/DomainEventName");
18
+ class WorkflowPausedDomainEvent extends DomainEvent_1.DomainEvent {
19
+ constructor(payload, occurredAt) {
20
+ super(occurredAt);
21
+ this.name = WorkflowPausedDomainEvent.NAME;
22
+ _WorkflowPausedDomainEvent_payload.set(this, void 0);
23
+ this.aggregateId = payload.workflowId;
24
+ __classPrivateFieldSet(this, _WorkflowPausedDomainEvent_payload, payload, "f");
25
+ }
26
+ static create(payload) {
27
+ return new WorkflowPausedDomainEvent(payload);
28
+ }
29
+ static fromPrimitives(primitives) {
30
+ return new WorkflowPausedDomainEvent(primitives.payload, primitives.occurredAt);
31
+ }
32
+ get payload() {
33
+ return __classPrivateFieldGet(this, _WorkflowPausedDomainEvent_payload, "f");
34
+ }
35
+ }
36
+ exports.WorkflowPausedDomainEvent = WorkflowPausedDomainEvent;
37
+ _WorkflowPausedDomainEvent_payload = new WeakMap();
38
+ WorkflowPausedDomainEvent.NAME = DomainEventName_1.DomainEventName.create('WorkflowPaused');
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DomainEvent = void 0;
4
+ /**
5
+ * Abstract base class every concrete domain event extends.
6
+ *
7
+ * Concrete subclasses MUST:
8
+ * - Declare a `public static readonly NAME: DomainEventName` so callers
9
+ * can reference it statically (e.g. when building EventBridge rule
10
+ * `detail-type` filters) without instantiating the event.
11
+ * - Implement `name`, `aggregateId` and `payload` as readonly members so
12
+ * the event is immutable from the outside.
13
+ * - Provide a `static create(payload)` factory and a
14
+ * `static fromPrimitives({ aggregateId, occurredAt, payload })`
15
+ * factory for the reconstruction path used by consumers.
16
+ *
17
+ * Subclasses MUST NOT add behaviour that mutates state or talks to
18
+ * infrastructure — events are facts, not orchestrators.
19
+ */
20
+ class DomainEvent {
21
+ constructor(occurredAt) {
22
+ this.occurredAt = occurredAt ?? new Date();
23
+ }
24
+ toEnvelope() {
25
+ return {
26
+ name: this.name.value,
27
+ aggregateId: this.aggregateId,
28
+ occurredAt: this.occurredAt,
29
+ payload: this.payload,
30
+ };
31
+ }
32
+ }
33
+ exports.DomainEvent = DomainEvent;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _a, _DomainEventName_value, _DomainEventName_validate, _DomainEventName_endsInRecognisedPastTense;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.DomainEventName = void 0;
16
+ const InvalidDomainEventNameError_1 = require("../exceptions/InvalidDomainEventNameError");
17
+ /**
18
+ * Value object that enforces the naming convention for domain events.
19
+ *
20
+ * Conventions enforced:
21
+ * - Non-empty string with no leading/trailing whitespace.
22
+ * - PascalCase (each word starts uppercase, no separators).
23
+ * - Past-tense semantics (last word ends in `ed`, `en` or known irregular
24
+ * past participles). Past tense communicates that the event describes a
25
+ * fact that already occurred — never an intent.
26
+ * - Length between 3 and 80 characters to keep EventBridge `DetailType`
27
+ * well-bounded (EventBridge accepts up to 128 characters).
28
+ *
29
+ * The string value is what the infrastructure layer maps to EventBridge
30
+ * `DetailType`, so consumers can build static rules like
31
+ * `detail-type: [CalculationJobCompletedDomainEvent.NAME.value]`.
32
+ */
33
+ class DomainEventName {
34
+ constructor(value) {
35
+ _DomainEventName_value.set(this, void 0);
36
+ __classPrivateFieldSet(this, _DomainEventName_value, value, "f");
37
+ }
38
+ static create(value) {
39
+ __classPrivateFieldGet(_a, _a, "m", _DomainEventName_validate).call(_a, value);
40
+ return new _a(value);
41
+ }
42
+ /**
43
+ * Reconstruction path used when re-hydrating an event from its
44
+ * persisted/serialised form. Same validation as `create()`; we keep the
45
+ * separate factory only for symmetry with the rest of the domain.
46
+ */
47
+ static fromPrimitives(value) {
48
+ return _a.create(value);
49
+ }
50
+ get value() {
51
+ return __classPrivateFieldGet(this, _DomainEventName_value, "f");
52
+ }
53
+ toPrimitives() {
54
+ return __classPrivateFieldGet(this, _DomainEventName_value, "f");
55
+ }
56
+ equals(other) {
57
+ return __classPrivateFieldGet(this, _DomainEventName_value, "f") === __classPrivateFieldGet(other, _DomainEventName_value, "f");
58
+ }
59
+ toString() {
60
+ return __classPrivateFieldGet(this, _DomainEventName_value, "f");
61
+ }
62
+ }
63
+ exports.DomainEventName = DomainEventName;
64
+ _a = DomainEventName, _DomainEventName_value = new WeakMap(), _DomainEventName_validate = function _DomainEventName_validate(value) {
65
+ if (typeof value !== 'string') {
66
+ throw InvalidDomainEventNameError_1.InvalidDomainEventNameError.create(value, 'must be a string');
67
+ }
68
+ if (value.trim() !== value) {
69
+ throw InvalidDomainEventNameError_1.InvalidDomainEventNameError.create(value, 'must not have leading or trailing whitespace');
70
+ }
71
+ if (value.length < _a.MIN_LENGTH || value.length > _a.MAX_LENGTH) {
72
+ throw InvalidDomainEventNameError_1.InvalidDomainEventNameError.create(value, `length must be between ${_a.MIN_LENGTH} and ${_a.MAX_LENGTH} characters`);
73
+ }
74
+ if (!_a.PASCAL_CASE_REGEX.test(value)) {
75
+ throw InvalidDomainEventNameError_1.InvalidDomainEventNameError.create(value, 'must be PascalCase (e.g. CalculationJobCompleted)');
76
+ }
77
+ if (!__classPrivateFieldGet(_a, _a, "m", _DomainEventName_endsInRecognisedPastTense).call(_a, value)) {
78
+ throw InvalidDomainEventNameError_1.InvalidDomainEventNameError.create(value, 'must be in past tense (e.g. ends in "ed", "en"); domain events describe facts that already occurred');
79
+ }
80
+ }, _DomainEventName_endsInRecognisedPastTense = function _DomainEventName_endsInRecognisedPastTense(value) {
81
+ const lower = value.toLowerCase();
82
+ return _a.PAST_TENSE_SUFFIXES.some((suffix) => lower.endsWith(suffix));
83
+ };
84
+ DomainEventName.MIN_LENGTH = 3;
85
+ DomainEventName.MAX_LENGTH = 80;
86
+ DomainEventName.PASCAL_CASE_REGEX = /^([A-Z][a-z0-9]*)+$/u;
87
+ /**
88
+ * Recognised past-tense suffixes (regular `-ed`/`-en` plus a curated list
89
+ * of irregular forms that may appear in domain events).
90
+ */
91
+ DomainEventName.PAST_TENSE_SUFFIXES = [
92
+ 'ed',
93
+ 'en',
94
+ 'ne',
95
+ 'lt',
96
+ 'nt',
97
+ 'pt',
98
+ 'st',
99
+ 'ought',
100
+ 'aught',
101
+ 'oken',
102
+ 'iven',
103
+ 'aid',
104
+ 'old',
105
+ 'ound',
106
+ 'ung',
107
+ 'ade',
108
+ 'ent',
109
+ 'eft',
110
+ 'ode',
111
+ 'ept',
112
+ 'orn',
113
+ ];
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InvalidDomainEventNameError = void 0;
4
+ const RootError_1 = require("./RootError");
5
+ class InvalidDomainEventNameError extends RootError_1.RootError {
6
+ constructor(message) {
7
+ super(message);
8
+ Object.setPrototypeOf(this, InvalidDomainEventNameError.prototype);
9
+ }
10
+ static create(value, reason) {
11
+ return new InvalidDomainEventNameError(`Invalid DomainEventName '${String(value)}': ${reason}`);
12
+ }
13
+ logError() {
14
+ return `[${this.name}] ${this.message}`;
15
+ }
16
+ }
17
+ exports.InvalidDomainEventNameError = InvalidDomainEventNameError;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });