@cqrs-ddd/core 0.2.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 (212) hide show
  1. package/COMMERCIAL_LICENSE.txt +34 -0
  2. package/LICENSE +661 -0
  3. package/README.md +707 -0
  4. package/dist/application/base.command.d.ts +44 -0
  5. package/dist/application/base.command.d.ts.map +1 -0
  6. package/dist/application/base.command.js +58 -0
  7. package/dist/application/base.command.js.map +1 -0
  8. package/dist/application/base.query.d.ts +42 -0
  9. package/dist/application/base.query.d.ts.map +1 -0
  10. package/dist/application/base.query.js +52 -0
  11. package/dist/application/base.query.js.map +1 -0
  12. package/dist/application/command-base.handler.d.ts +106 -0
  13. package/dist/application/command-base.handler.d.ts.map +1 -0
  14. package/dist/application/command-base.handler.js +119 -0
  15. package/dist/application/command-base.handler.js.map +1 -0
  16. package/dist/application/index.d.ts +16 -0
  17. package/dist/application/index.d.ts.map +1 -0
  18. package/dist/application/index.js +33 -0
  19. package/dist/application/index.js.map +1 -0
  20. package/dist/application/ports/cache.port.d.ts +104 -0
  21. package/dist/application/ports/cache.port.d.ts.map +1 -0
  22. package/dist/application/ports/cache.port.js +17 -0
  23. package/dist/application/ports/cache.port.js.map +1 -0
  24. package/dist/application/ports/command-repository.port.d.ts +28 -0
  25. package/dist/application/ports/command-repository.port.d.ts.map +1 -0
  26. package/dist/application/ports/command-repository.port.js +4 -0
  27. package/dist/application/ports/command-repository.port.js.map +1 -0
  28. package/dist/application/ports/domain-event-publisher.port.d.ts +18 -0
  29. package/dist/application/ports/domain-event-publisher.port.d.ts.map +1 -0
  30. package/dist/application/ports/domain-event-publisher.port.js +4 -0
  31. package/dist/application/ports/domain-event-publisher.port.js.map +1 -0
  32. package/dist/application/ports/query-repository.port.d.ts +26 -0
  33. package/dist/application/ports/query-repository.port.d.ts.map +1 -0
  34. package/dist/application/ports/query-repository.port.js +4 -0
  35. package/dist/application/ports/query-repository.port.js.map +1 -0
  36. package/dist/application/ports/write-side-aggregate-repository.port.d.ts +33 -0
  37. package/dist/application/ports/write-side-aggregate-repository.port.d.ts.map +1 -0
  38. package/dist/application/ports/write-side-aggregate-repository.port.js +4 -0
  39. package/dist/application/ports/write-side-aggregate-repository.port.js.map +1 -0
  40. package/dist/application/query.options.d.ts +22 -0
  41. package/dist/application/query.options.d.ts.map +1 -0
  42. package/dist/application/query.options.js +4 -0
  43. package/dist/application/query.options.js.map +1 -0
  44. package/dist/application/request-fields.helper.d.ts +5 -0
  45. package/dist/application/request-fields.helper.d.ts.map +1 -0
  46. package/dist/application/request-fields.helper.js +20 -0
  47. package/dist/application/request-fields.helper.js.map +1 -0
  48. package/dist/application/tenant-resolver.d.ts +56 -0
  49. package/dist/application/tenant-resolver.d.ts.map +1 -0
  50. package/dist/application/tenant-resolver.js +60 -0
  51. package/dist/application/tenant-resolver.js.map +1 -0
  52. package/dist/domain/decorators/apply-mutation.decorator.d.ts +64 -0
  53. package/dist/domain/decorators/apply-mutation.decorator.d.ts.map +1 -0
  54. package/dist/domain/decorators/apply-mutation.decorator.js +86 -0
  55. package/dist/domain/decorators/apply-mutation.decorator.js.map +1 -0
  56. package/dist/domain/decorators/mutable.decorator.d.ts +54 -0
  57. package/dist/domain/decorators/mutable.decorator.d.ts.map +1 -0
  58. package/dist/domain/decorators/mutable.decorator.js +76 -0
  59. package/dist/domain/decorators/mutable.decorator.js.map +1 -0
  60. package/dist/domain/events/domain.event.d.ts +13 -0
  61. package/dist/domain/events/domain.event.d.ts.map +1 -0
  62. package/dist/domain/events/domain.event.js +20 -0
  63. package/dist/domain/events/domain.event.js.map +1 -0
  64. package/dist/domain/events/event.interface.d.ts +9 -0
  65. package/dist/domain/events/event.interface.d.ts.map +1 -0
  66. package/dist/domain/events/event.interface.js +4 -0
  67. package/dist/domain/events/event.interface.js.map +1 -0
  68. package/dist/domain/events/root-domain.event.d.ts +50 -0
  69. package/dist/domain/events/root-domain.event.d.ts.map +1 -0
  70. package/dist/domain/events/root-domain.event.js +156 -0
  71. package/dist/domain/events/root-domain.event.js.map +1 -0
  72. package/dist/domain/exceptions/concurrency-conflict.error.d.ts +20 -0
  73. package/dist/domain/exceptions/concurrency-conflict.error.d.ts.map +1 -0
  74. package/dist/domain/exceptions/concurrency-conflict.error.js +32 -0
  75. package/dist/domain/exceptions/concurrency-conflict.error.js.map +1 -0
  76. package/dist/domain/exceptions/domain.exception.d.ts +30 -0
  77. package/dist/domain/exceptions/domain.exception.d.ts.map +1 -0
  78. package/dist/domain/exceptions/domain.exception.js +39 -0
  79. package/dist/domain/exceptions/domain.exception.js.map +1 -0
  80. package/dist/domain/exceptions/entity-not-found.exception.d.ts +14 -0
  81. package/dist/domain/exceptions/entity-not-found.exception.d.ts.map +1 -0
  82. package/dist/domain/exceptions/entity-not-found.exception.js +23 -0
  83. package/dist/domain/exceptions/entity-not-found.exception.js.map +1 -0
  84. package/dist/domain/exceptions/invalid-value.exception.d.ts +35 -0
  85. package/dist/domain/exceptions/invalid-value.exception.d.ts.map +1 -0
  86. package/dist/domain/exceptions/invalid-value.exception.js +67 -0
  87. package/dist/domain/exceptions/invalid-value.exception.js.map +1 -0
  88. package/dist/domain/exceptions/missing-tenant-context.exception.d.ts +24 -0
  89. package/dist/domain/exceptions/missing-tenant-context.exception.d.ts.map +1 -0
  90. package/dist/domain/exceptions/missing-tenant-context.exception.js +33 -0
  91. package/dist/domain/exceptions/missing-tenant-context.exception.js.map +1 -0
  92. package/dist/domain/exceptions/transient-operation.error.d.ts +17 -0
  93. package/dist/domain/exceptions/transient-operation.error.d.ts.map +1 -0
  94. package/dist/domain/exceptions/transient-operation.error.js +27 -0
  95. package/dist/domain/exceptions/transient-operation.error.js.map +1 -0
  96. package/dist/domain/exceptions/unknown-mutable-field.error.d.ts +14 -0
  97. package/dist/domain/exceptions/unknown-mutable-field.error.d.ts.map +1 -0
  98. package/dist/domain/exceptions/unknown-mutable-field.error.js +24 -0
  99. package/dist/domain/exceptions/unknown-mutable-field.error.js.map +1 -0
  100. package/dist/domain/index.d.ts +26 -0
  101. package/dist/domain/index.d.ts.map +1 -0
  102. package/dist/domain/index.js +43 -0
  103. package/dist/domain/index.js.map +1 -0
  104. package/dist/domain/interfaces/root-entity-snapshot.interface.d.ts +7 -0
  105. package/dist/domain/interfaces/root-entity-snapshot.interface.d.ts.map +1 -0
  106. package/dist/domain/interfaces/root-entity-snapshot.interface.js +4 -0
  107. package/dist/domain/interfaces/root-entity-snapshot.interface.js.map +1 -0
  108. package/dist/domain/models/aggregate-root.d.ts +87 -0
  109. package/dist/domain/models/aggregate-root.d.ts.map +1 -0
  110. package/dist/domain/models/aggregate-root.js +122 -0
  111. package/dist/domain/models/aggregate-root.js.map +1 -0
  112. package/dist/domain/models/root.entity.d.ts +208 -0
  113. package/dist/domain/models/root.entity.d.ts.map +1 -0
  114. package/dist/domain/models/root.entity.js +350 -0
  115. package/dist/domain/models/root.entity.js.map +1 -0
  116. package/dist/domain/rules/number.rule.d.ts +81 -0
  117. package/dist/domain/rules/number.rule.d.ts.map +1 -0
  118. package/dist/domain/rules/number.rule.js +81 -0
  119. package/dist/domain/rules/number.rule.js.map +1 -0
  120. package/dist/domain/rules/rule-support.d.ts +6 -0
  121. package/dist/domain/rules/rule-support.d.ts.map +1 -0
  122. package/dist/domain/rules/rule-support.js +19 -0
  123. package/dist/domain/rules/rule-support.js.map +1 -0
  124. package/dist/domain/rules/text.rule.d.ts +98 -0
  125. package/dist/domain/rules/text.rule.d.ts.map +1 -0
  126. package/dist/domain/rules/text.rule.js +103 -0
  127. package/dist/domain/rules/text.rule.js.map +1 -0
  128. package/dist/domain/rules/value-violation.d.ts +44 -0
  129. package/dist/domain/rules/value-violation.d.ts.map +1 -0
  130. package/dist/domain/rules/value-violation.js +4 -0
  131. package/dist/domain/rules/value-violation.js.map +1 -0
  132. package/dist/http/domain-error-http-status.d.ts +43 -0
  133. package/dist/http/domain-error-http-status.d.ts.map +1 -0
  134. package/dist/http/domain-error-http-status.js +27 -0
  135. package/dist/http/domain-error-http-status.js.map +1 -0
  136. package/dist/http/index.d.ts +9 -0
  137. package/dist/http/index.d.ts.map +1 -0
  138. package/dist/http/index.js +26 -0
  139. package/dist/http/index.js.map +1 -0
  140. package/dist/index.d.ts +13 -0
  141. package/dist/index.d.ts.map +1 -0
  142. package/dist/index.js +30 -0
  143. package/dist/index.js.map +1 -0
  144. package/dist/persistence/cache/cache-logger.d.ts +29 -0
  145. package/dist/persistence/cache/cache-logger.d.ts.map +1 -0
  146. package/dist/persistence/cache/cache-logger.js +23 -0
  147. package/dist/persistence/cache/cache-logger.js.map +1 -0
  148. package/dist/persistence/cache/memory.cache.d.ts +72 -0
  149. package/dist/persistence/cache/memory.cache.d.ts.map +1 -0
  150. package/dist/persistence/cache/memory.cache.js +183 -0
  151. package/dist/persistence/cache/memory.cache.js.map +1 -0
  152. package/dist/persistence/command-repository.abstract.d.ts +39 -0
  153. package/dist/persistence/command-repository.abstract.d.ts.map +1 -0
  154. package/dist/persistence/command-repository.abstract.js +43 -0
  155. package/dist/persistence/command-repository.abstract.js.map +1 -0
  156. package/dist/persistence/decorators/acknowledge-persisted.decorator.d.ts +82 -0
  157. package/dist/persistence/decorators/acknowledge-persisted.decorator.d.ts.map +1 -0
  158. package/dist/persistence/decorators/acknowledge-persisted.decorator.js +82 -0
  159. package/dist/persistence/decorators/acknowledge-persisted.decorator.js.map +1 -0
  160. package/dist/persistence/decorators/cache.decorator.d.ts +93 -0
  161. package/dist/persistence/decorators/cache.decorator.d.ts.map +1 -0
  162. package/dist/persistence/decorators/cache.decorator.js +200 -0
  163. package/dist/persistence/decorators/cache.decorator.js.map +1 -0
  164. package/dist/persistence/decorators/from-cache.decorator.d.ts +65 -0
  165. package/dist/persistence/decorators/from-cache.decorator.d.ts.map +1 -0
  166. package/dist/persistence/decorators/from-cache.decorator.js +165 -0
  167. package/dist/persistence/decorators/from-cache.decorator.js.map +1 -0
  168. package/dist/persistence/decorators/map-persistence-errors.decorator.d.ts +88 -0
  169. package/dist/persistence/decorators/map-persistence-errors.decorator.d.ts.map +1 -0
  170. package/dist/persistence/decorators/map-persistence-errors.decorator.js +89 -0
  171. package/dist/persistence/decorators/map-persistence-errors.decorator.js.map +1 -0
  172. package/dist/persistence/decorators/persisted-write.decorator.d.ts +61 -0
  173. package/dist/persistence/decorators/persisted-write.decorator.d.ts.map +1 -0
  174. package/dist/persistence/decorators/persisted-write.decorator.js +57 -0
  175. package/dist/persistence/decorators/persisted-write.decorator.js.map +1 -0
  176. package/dist/persistence/helpers/cache-barrier.helper.d.ts +70 -0
  177. package/dist/persistence/helpers/cache-barrier.helper.d.ts.map +1 -0
  178. package/dist/persistence/helpers/cache-barrier.helper.js +57 -0
  179. package/dist/persistence/helpers/cache-barrier.helper.js.map +1 -0
  180. package/dist/persistence/helpers/cache-key.helper.d.ts +73 -0
  181. package/dist/persistence/helpers/cache-key.helper.d.ts.map +1 -0
  182. package/dist/persistence/helpers/cache-key.helper.js +132 -0
  183. package/dist/persistence/helpers/cache-key.helper.js.map +1 -0
  184. package/dist/persistence/helpers/cache-owner.helper.d.ts +9 -0
  185. package/dist/persistence/helpers/cache-owner.helper.d.ts.map +1 -0
  186. package/dist/persistence/helpers/cache-owner.helper.js +22 -0
  187. package/dist/persistence/helpers/cache-owner.helper.js.map +1 -0
  188. package/dist/persistence/helpers/cache-snapshot.helper.d.ts +28 -0
  189. package/dist/persistence/helpers/cache-snapshot.helper.d.ts.map +1 -0
  190. package/dist/persistence/helpers/cache-snapshot.helper.js +42 -0
  191. package/dist/persistence/helpers/cache-snapshot.helper.js.map +1 -0
  192. package/dist/persistence/helpers/cache-version.helper.d.ts +29 -0
  193. package/dist/persistence/helpers/cache-version.helper.d.ts.map +1 -0
  194. package/dist/persistence/helpers/cache-version.helper.js +71 -0
  195. package/dist/persistence/helpers/cache-version.helper.js.map +1 -0
  196. package/dist/persistence/index.d.ts +23 -0
  197. package/dist/persistence/index.d.ts.map +1 -0
  198. package/dist/persistence/index.js +40 -0
  199. package/dist/persistence/index.js.map +1 -0
  200. package/dist/persistence/persistence-dialect.d.ts +35 -0
  201. package/dist/persistence/persistence-dialect.d.ts.map +1 -0
  202. package/dist/persistence/persistence-dialect.js +31 -0
  203. package/dist/persistence/persistence-dialect.js.map +1 -0
  204. package/dist/persistence/query-repository.abstract.d.ts +76 -0
  205. package/dist/persistence/query-repository.abstract.d.ts.map +1 -0
  206. package/dist/persistence/query-repository.abstract.js +67 -0
  207. package/dist/persistence/query-repository.abstract.js.map +1 -0
  208. package/dist/types/Method.type.d.ts +2 -0
  209. package/dist/types/Method.type.d.ts.map +1 -0
  210. package/dist/types/Method.type.js +4 -0
  211. package/dist/types/Method.type.js.map +1 -0
  212. package/package.json +80 -0
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ /* Copyright (C) 2026-present Aristotelis — see repository license. */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.Mutable = Mutable;
5
+ exports.getMutableFields = getMutableFields;
6
+ const MUTABLE_FIELDS = Symbol('MUTABLE_FIELDS');
7
+ /**
8
+ * Declares an aggregate property as mutable through domain methods.
9
+ *
10
+ * `RootEntity.applyPatch()` writes only to fields registered here, so the set of properties a
11
+ * mutation may touch is declared once on the field itself instead of being
12
+ * restated in every method that changes it.
13
+ *
14
+ * @param options - Patch key override and the field's normalizer.
15
+ * @returns A property decorator registering the field on the owning class.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * export class User extends RootEntity<UserSnapshot> {
20
+ * @Mutable<string>({ normalize: (value) => User.normalizeUsername(value) })
21
+ * private _username: string;
22
+ * }
23
+ * ```
24
+ */
25
+ function Mutable(options = {}) {
26
+ return (target, propertyKey) => {
27
+ if (typeof propertyKey !== 'string') {
28
+ throw new TypeError('@Mutable() supports string properties only.');
29
+ }
30
+ // A static property decorates the class itself, whose constructor is `Function`.
31
+ const owner = target.constructor;
32
+ if (!owner || typeof target === 'function') {
33
+ throw new TypeError('@Mutable() supports instance properties only.');
34
+ }
35
+ const own = Object.hasOwn(owner, MUTABLE_FIELDS)
36
+ ? owner[MUTABLE_FIELDS]
37
+ : new Map();
38
+ owner[MUTABLE_FIELDS] = own;
39
+ const patchKey = options.as ?? propertyKey.replace(/^_/, '');
40
+ own.set(patchKey, {
41
+ propertyKey,
42
+ patchKey,
43
+ normalize: options.normalize,
44
+ });
45
+ };
46
+ }
47
+ /**
48
+ * Resolves every mutable field visible on an instance, including fields
49
+ * declared by base classes.
50
+ *
51
+ * @param instance - The aggregate to inspect.
52
+ * @returns Patch key to field definition, nearest declaration winning.
53
+ */
54
+ function getMutableFields(instance) {
55
+ const resolved = new Map();
56
+ const chain = [];
57
+ let current = instance.constructor;
58
+ while (typeof current === 'function') {
59
+ chain.push(current);
60
+ current = Object.getPrototypeOf(current);
61
+ }
62
+ for (const owner of chain.reverse()) {
63
+ if (!Object.hasOwn(owner, MUTABLE_FIELDS)) {
64
+ continue;
65
+ }
66
+ const fields = owner[MUTABLE_FIELDS];
67
+ if (!fields) {
68
+ continue;
69
+ }
70
+ for (const [patchKey, definition] of fields) {
71
+ resolved.set(patchKey, definition);
72
+ }
73
+ }
74
+ return resolved;
75
+ }
76
+ //# sourceMappingURL=mutable.decorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mutable.decorator.js","sourceRoot":"","sources":["../../../domain/decorators/mutable.decorator.ts"],"names":[],"mappings":";AAAA,sEAAsE;;AAuDtE,0BA6BC;AASD,4CA0BC;AAxFD,MAAM,cAAc,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAMhD;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,OAAO,CACrB,UAAkC,EAAE;IAEpC,OAAO,CAAC,MAAc,EAAE,WAA4B,EAAE,EAAE;QACtD,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE,CAAC;YACpC,MAAM,IAAI,SAAS,CAAC,6CAA6C,CAAC,CAAC;QACrE,CAAC;QAED,iFAAiF;QACjF,MAAM,KAAK,GAAI,MAAmC,CAAC,WAEtC,CAAC;QAE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AC;QACD,KAAK,MAAM,CAAC,QAAQ,EAAE,UAAU,CAAC,IAAI,MAAM,EAAE,CAAC;YAC5C,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { IEvent } from './event.interface';
2
+ /**
3
+ * Base class for all domain events.
4
+ *
5
+ * Carries a unique `id` (a time-sortable `uuidv7`) generated on construction
6
+ * unless one is supplied. Concrete events extend this to describe something that
7
+ * has happened in the domain.
8
+ */
9
+ export declare abstract class DomainEvent implements IEvent {
10
+ readonly id: string;
11
+ protected constructor(id?: string);
12
+ }
13
+ //# sourceMappingURL=domain.event.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"domain.event.d.ts","sourceRoot":"","sources":["../../../domain/events/domain.event.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD;;;;;;GAMG;AACH,8BAAsB,WAAY,YAAW,MAAM;IACjD,SAAgB,EAAE,EAAE,MAAM,CAAC;IAE3B,SAAS,aAAa,EAAE,CAAC,EAAE,MAAM;CAGlC"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ /* Copyright (C) 2026-present Aristotelis — see repository license. */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.DomainEvent = void 0;
5
+ const uuidv7_1 = require("@cqrs-ddd/uuidv7");
6
+ /**
7
+ * Base class for all domain events.
8
+ *
9
+ * Carries a unique `id` (a time-sortable `uuidv7`) generated on construction
10
+ * unless one is supplied. Concrete events extend this to describe something that
11
+ * has happened in the domain.
12
+ */
13
+ class DomainEvent {
14
+ id;
15
+ constructor(id) {
16
+ this.id = id ?? (0, uuidv7_1.uuidv7)();
17
+ }
18
+ }
19
+ exports.DomainEvent = DomainEvent;
20
+ //# sourceMappingURL=domain.event.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"domain.event.js","sourceRoot":"","sources":["../../../domain/events/domain.event.ts"],"names":[],"mappings":";AAAA,sEAAsE;;;AAEtE,6CAA0C;AAG1C;;;;;;GAMG;AACH,MAAsB,WAAW;IACf,EAAE,CAAS;IAE3B,YAAsB,EAAW;QAC/B,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,IAAA,eAAM,GAAE,CAAC;IAC3B,CAAC;CACF;AAND,kCAMC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Marker interface for domain events.
3
+ *
4
+ * Framework-neutral base contract for all domain events buffered by
5
+ * {@link AggregateRoot} and published through {@link IDomainEventPublisher}.
6
+ */
7
+ export interface IEvent {
8
+ }
9
+ //# sourceMappingURL=event.interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event.interface.d.ts","sourceRoot":"","sources":["../../../domain/events/event.interface.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,MAAM,WAAW,MAAM;CAAG"}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ /* Copyright (C) 2026-present Aristotelis — see repository license. */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ //# sourceMappingURL=event.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event.interface.js","sourceRoot":"","sources":["../../../domain/events/event.interface.ts"],"names":[],"mappings":";AAAA,sEAAsE"}
@@ -0,0 +1,50 @@
1
+ import { RootEntitySnapshot } from '../interfaces/root-entity-snapshot.interface';
2
+ import { RootEntity } from '../models/root.entity';
3
+ import { DomainEvent } from './domain.event';
4
+ /** Payload type of an event raised from `T`: its `toJSON()` result, or `T` itself. */
5
+ export type InferPayload<T> = T extends {
6
+ toJSON(): infer J;
7
+ } ? J : T extends object ? T : unknown;
8
+ /**
9
+ * Deep clones and recursively freezes any value, object, array, Date, Set, Map, or RegExp.
10
+ * Safely handles circular references via a WeakMap tracking visited objects.
11
+ * Guarantees that mutations on original nested objects do not leak into the clone.
12
+ *
13
+ * `Object.freeze` covers own properties only. The internal state of a cloned
14
+ * Date, Map or Set is guarded by overriding its mutating methods, which stops
15
+ * ordinary calls such as `date.setTime(...)` but not
16
+ * `Date.prototype.setTime.call(date, ...)`. Treat the result as detached and
17
+ * ordinarily read-only, not as a security boundary.
18
+ */
19
+ export declare function deepCloneAndFreeze<T>(value: T, seen?: WeakMap<object, unknown>): T;
20
+ /**
21
+ * A {@link DomainEvent} carrying aggregate identity/version and a detached,
22
+ * frozen state payload snapshot captured at event creation time.
23
+ *
24
+ * The snapshot is deep-cloned from the aggregate, so later aggregate mutations
25
+ * never reach it. Every consumer shares the same `payload` instance: its own
26
+ * properties are frozen, but Date/Map/Set internals can still be changed
27
+ * through their prototype methods (see {@link deepCloneAndFreeze}). A consumer
28
+ * that must not observe changes made by another consumer reads
29
+ * {@link RootDomainEvent.clonePayload} instead. Transports should serialize an
30
+ * explicit message rather than the payload object itself.
31
+ *
32
+ * @typeParam T - The aggregate input type used to infer the snapshot payload.
33
+ * @typeParam TPayload - The snapshot payload type.
34
+ */
35
+ export declare class RootDomainEvent<T = RootEntity<Partial<RootEntitySnapshot>>, TPayload = InferPayload<T>> extends DomainEvent {
36
+ /** Detached, frozen state captured when the event was raised; shared by all consumers. */
37
+ readonly payload: Readonly<TPayload>;
38
+ /** Identity of the aggregate that raised the event. */
39
+ readonly aggregateId?: string;
40
+ /** Aggregate version at the moment the event was raised. */
41
+ readonly aggregateVersion?: number;
42
+ protected constructor(entity: T, payload?: TPayload);
43
+ /**
44
+ * Returns a new detached, frozen copy of {@link payload} on every call, so
45
+ * a change one consumer forces through a Date/Map/Set prototype method stays
46
+ * out of the shared payload and out of other copies.
47
+ */
48
+ clonePayload(): Readonly<TPayload>;
49
+ }
50
+ //# sourceMappingURL=root-domain.event.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"root-domain.event.d.ts","sourceRoot":"","sources":["../../../domain/events/root-domain.event.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,8CAA8C,CAAC;AAClF,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,sFAAsF;AACtF,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,SAAS;IAAE,MAAM,IAAI,MAAM,CAAC,CAAA;CAAE,GACzD,CAAC,GACD,CAAC,SAAS,MAAM,GACd,CAAC,GACD,OAAO,CAAC;AAwCd;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,KAAK,EAAE,CAAC,EACR,IAAI,2BAAiC,GACpC,CAAC,CA+DH;AAED;;;;;;;;;;;;;;GAcG;AACH,qBAAa,eAAe,CAC1B,CAAC,GAAG,UAAU,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,EAC3C,QAAQ,GAAG,YAAY,CAAC,CAAC,CAAC,CAC1B,SAAQ,WAAW;IACnB,0FAA0F;IAC1F,SAAgB,OAAO,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAE5C,uDAAuD;IACvD,SAAgB,WAAW,CAAC,EAAE,MAAM,CAAC;IAErC,4DAA4D;IAC5D,SAAgB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1C,SAAS,aAAa,MAAM,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,QAAQ;IAuBnD;;;;OAIG;IACH,YAAY,IAAI,QAAQ,CAAC,QAAQ,CAAC;CAGnC"}
@@ -0,0 +1,156 @@
1
+ "use strict";
2
+ /* Copyright (C) 2026-present Aristotelis — see repository license. */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.RootDomainEvent = void 0;
5
+ exports.deepCloneAndFreeze = deepCloneAndFreeze;
6
+ const domain_event_1 = require("./domain.event");
7
+ const MUTATING_DATE_METHODS = [
8
+ 'setTime',
9
+ 'setMilliseconds',
10
+ 'setUTCMilliseconds',
11
+ 'setSeconds',
12
+ 'setUTCSeconds',
13
+ 'setMinutes',
14
+ 'setUTCMinutes',
15
+ 'setHours',
16
+ 'setUTCHours',
17
+ 'setDate',
18
+ 'setUTCDate',
19
+ 'setMonth',
20
+ 'setUTCMonth',
21
+ 'setFullYear',
22
+ 'setUTCFullYear',
23
+ ];
24
+ const MUTATING_MAP_METHODS = ['set', 'delete', 'clear'];
25
+ const MUTATING_SET_METHODS = ['add', 'delete', 'clear'];
26
+ function freezeBuiltIn(copy, mutators, name) {
27
+ for (const method of mutators) {
28
+ Object.defineProperty(copy, method, {
29
+ value: () => {
30
+ throw new TypeError(`Cannot mutate frozen ${name}`);
31
+ },
32
+ configurable: false,
33
+ writable: false,
34
+ });
35
+ }
36
+ return Object.freeze(copy);
37
+ }
38
+ /**
39
+ * Deep clones and recursively freezes any value, object, array, Date, Set, Map, or RegExp.
40
+ * Safely handles circular references via a WeakMap tracking visited objects.
41
+ * Guarantees that mutations on original nested objects do not leak into the clone.
42
+ *
43
+ * `Object.freeze` covers own properties only. The internal state of a cloned
44
+ * Date, Map or Set is guarded by overriding its mutating methods, which stops
45
+ * ordinary calls such as `date.setTime(...)` but not
46
+ * `Date.prototype.setTime.call(date, ...)`. Treat the result as detached and
47
+ * ordinarily read-only, not as a security boundary.
48
+ */
49
+ function deepCloneAndFreeze(value, seen = new WeakMap()) {
50
+ if (value === null || typeof value !== 'object') {
51
+ return value;
52
+ }
53
+ if (seen.has(value)) {
54
+ return seen.get(value);
55
+ }
56
+ if (value instanceof Date) {
57
+ const copy = new Date(value.getTime());
58
+ return freezeBuiltIn(copy, MUTATING_DATE_METHODS, 'Date');
59
+ }
60
+ if (value instanceof RegExp) {
61
+ const copy = new RegExp(value.source, value.flags);
62
+ return Object.freeze(copy);
63
+ }
64
+ if (Array.isArray(value)) {
65
+ const copy = [];
66
+ seen.set(value, copy);
67
+ for (let i = 0; i < value.length; i++) {
68
+ copy[i] = deepCloneAndFreeze(value[i], seen);
69
+ }
70
+ return Object.freeze(copy);
71
+ }
72
+ if (value instanceof Map) {
73
+ const copy = new Map();
74
+ seen.set(value, copy);
75
+ for (const [k, v] of value.entries()) {
76
+ copy.set(deepCloneAndFreeze(k, seen), deepCloneAndFreeze(v, seen));
77
+ }
78
+ return freezeBuiltIn(copy, MUTATING_MAP_METHODS, 'Map');
79
+ }
80
+ if (value instanceof Set) {
81
+ const copy = new Set();
82
+ seen.set(value, copy);
83
+ for (const v of value.values()) {
84
+ copy.add(deepCloneAndFreeze(v, seen));
85
+ }
86
+ return freezeBuiltIn(copy, MUTATING_SET_METHODS, 'Set');
87
+ }
88
+ const proto = Object.getPrototypeOf(value);
89
+ const copy = Object.create(proto === Object.prototype || proto === null ? proto : Object.prototype);
90
+ seen.set(value, copy);
91
+ for (const key of Reflect.ownKeys(value)) {
92
+ const desc = Object.getOwnPropertyDescriptor(value, key);
93
+ if (desc) {
94
+ if ('value' in desc) {
95
+ desc.value = deepCloneAndFreeze(desc.value, seen);
96
+ }
97
+ Object.defineProperty(copy, key, desc);
98
+ }
99
+ }
100
+ return Object.freeze(copy);
101
+ }
102
+ /**
103
+ * A {@link DomainEvent} carrying aggregate identity/version and a detached,
104
+ * frozen state payload snapshot captured at event creation time.
105
+ *
106
+ * The snapshot is deep-cloned from the aggregate, so later aggregate mutations
107
+ * never reach it. Every consumer shares the same `payload` instance: its own
108
+ * properties are frozen, but Date/Map/Set internals can still be changed
109
+ * through their prototype methods (see {@link deepCloneAndFreeze}). A consumer
110
+ * that must not observe changes made by another consumer reads
111
+ * {@link RootDomainEvent.clonePayload} instead. Transports should serialize an
112
+ * explicit message rather than the payload object itself.
113
+ *
114
+ * @typeParam T - The aggregate input type used to infer the snapshot payload.
115
+ * @typeParam TPayload - The snapshot payload type.
116
+ */
117
+ class RootDomainEvent extends domain_event_1.DomainEvent {
118
+ /** Detached, frozen state captured when the event was raised; shared by all consumers. */
119
+ payload;
120
+ /** Identity of the aggregate that raised the event. */
121
+ aggregateId;
122
+ /** Aggregate version at the moment the event was raised. */
123
+ aggregateVersion;
124
+ constructor(entity, payload) {
125
+ super();
126
+ const source = entity;
127
+ this.aggregateId = typeof source?.id === 'string' ? source.id : undefined;
128
+ this.aggregateVersion =
129
+ typeof source?.version === 'number' ? source.version : undefined;
130
+ let rawPayload;
131
+ if (payload !== undefined) {
132
+ rawPayload = payload;
133
+ }
134
+ else if (entity &&
135
+ typeof entity.toJSON === 'function') {
136
+ rawPayload = entity.toJSON();
137
+ }
138
+ else if (entity && typeof entity === 'object') {
139
+ rawPayload = { ...entity };
140
+ }
141
+ else {
142
+ rawPayload = {};
143
+ }
144
+ this.payload = deepCloneAndFreeze(rawPayload);
145
+ }
146
+ /**
147
+ * Returns a new detached, frozen copy of {@link payload} on every call, so
148
+ * a change one consumer forces through a Date/Map/Set prototype method stays
149
+ * out of the shared payload and out of other copies.
150
+ */
151
+ clonePayload() {
152
+ return deepCloneAndFreeze(this.payload);
153
+ }
154
+ }
155
+ exports.RootDomainEvent = RootDomainEvent;
156
+ //# sourceMappingURL=root-domain.event.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"root-domain.event.js","sourceRoot":"","sources":["../../../domain/events/root-domain.event.ts"],"names":[],"mappings":";AAAA,sEAAsE;;;AA8DtE,gDAkEC;AA5HD,iDAA6C;AAS7C,MAAM,qBAAqB,GAAG;IAC5B,SAAS;IACT,iBAAiB;IACjB,oBAAoB;IACpB,YAAY;IACZ,eAAe;IACf,YAAY;IACZ,eAAe;IACf,UAAU;IACV,aAAa;IACb,SAAS;IACT,YAAY;IACZ,UAAU;IACV,aAAa;IACb,aAAa;IACb,gBAAgB;CACR,CAAC;AAEX,MAAM,oBAAoB,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAU,CAAC;AACjE,MAAM,oBAAoB,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAU,CAAC;AAEjE,SAAS,aAAa,CACpB,IAAO,EACP,QAA2B,EAC3B,IAAY;IAEZ,KAAK,MAAM,MAAM,IAAI,QAAQ,EAAE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AS,EAAE,CAAC;YAC1B,UAAU,GAAG,OAAO,CAAC;QACvB,CAAC;aAAM,IACL,MAAM;YACN,OAAQ,MAAqC,CAAC,MAAM,KAAK,UAAU,EACnE,CAAC;YACD,UAAU,GAAI,MAA+C,CAAC,MAAM,EAAE,CAAC;QACzE,CAAC;aAAM,IAAI,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAChD,UAAU,GAAG,EAAE,GAAG,MAAM,EAAE,CAAC;QAC7B,CAAC;aAAM,CAAC;YACN,UAAU,GAAG,EAAE,CAAC;QAClB,CAAC;QACD,IAAI,CAAC,OAAO,GAAG,kBAAkB,CAAC,UAAU,CAAuB,CAAC;IACtE,CAAC;IAED;;;;OAIG;IACH,YAAY;QACV,OAAO,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;CACF;AA5CD,0CA4CC"}
@@ -0,0 +1,20 @@
1
+ import { DomainException } from './domain.exception';
2
+ /**
3
+ * Framework-neutral signal that a version-conditioned write lost a race.
4
+ *
5
+ * Persistence adapters translate their own concurrency failures into this error,
6
+ * exactly as they translate transient driver faults into
7
+ * {@link TransientOperationError}, so no ORM exception class reaches the
8
+ * application layer or the presentation boundary.
9
+ *
10
+ * Transport adapters map it to their own conflict representation, such as
11
+ * HTTP 409 through `domainErrorHttpStatus`.
12
+ */
13
+ export declare class ConcurrencyConflictError extends DomainException {
14
+ readonly entityName: string;
15
+ readonly entityId: string;
16
+ readonly expectedVersion: number;
17
+ readonly actualVersion?: number | undefined;
18
+ constructor(entityName: string, entityId: string, expectedVersion: number, actualVersion?: number | undefined);
19
+ }
20
+ //# sourceMappingURL=concurrency-conflict.error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"concurrency-conflict.error.d.ts","sourceRoot":"","sources":["../../../domain/exceptions/concurrency-conflict.error.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD;;;;;;;;;;GAUG;AACH,qBAAa,wBAAyB,SAAQ,eAAe;IAEzD,QAAQ,CAAC,UAAU,EAAE,MAAM;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM;IACzB,QAAQ,CAAC,eAAe,EAAE,MAAM;IAChC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM;gBAHtB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,eAAe,EAAE,MAAM,EACvB,aAAa,CAAC,EAAE,MAAM,YAAA;CAOlC"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ /* Copyright (C) 2026-present Aristotelis — see repository license. */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.ConcurrencyConflictError = void 0;
5
+ const domain_exception_1 = require("./domain.exception");
6
+ /**
7
+ * Framework-neutral signal that a version-conditioned write lost a race.
8
+ *
9
+ * Persistence adapters translate their own concurrency failures into this error,
10
+ * exactly as they translate transient driver faults into
11
+ * {@link TransientOperationError}, so no ORM exception class reaches the
12
+ * application layer or the presentation boundary.
13
+ *
14
+ * Transport adapters map it to their own conflict representation, such as
15
+ * HTTP 409 through `domainErrorHttpStatus`.
16
+ */
17
+ class ConcurrencyConflictError extends domain_exception_1.DomainException {
18
+ entityName;
19
+ entityId;
20
+ expectedVersion;
21
+ actualVersion;
22
+ constructor(entityName, entityId, expectedVersion, actualVersion) {
23
+ super(`${entityName} ${entityId} was modified concurrently: expected version ${expectedVersion}` +
24
+ (actualVersion === undefined ? '.' : `, found ${actualVersion}.`));
25
+ this.entityName = entityName;
26
+ this.entityId = entityId;
27
+ this.expectedVersion = expectedVersion;
28
+ this.actualVersion = actualVersion;
29
+ }
30
+ }
31
+ exports.ConcurrencyConflictError = ConcurrencyConflictError;
32
+ //# sourceMappingURL=concurrency-conflict.error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"concurrency-conflict.error.js","sourceRoot":"","sources":["../../../domain/exceptions/concurrency-conflict.error.ts"],"names":[],"mappings":";AAAA,sEAAsE;;;AAEtE,yDAAqD;AAErD;;;;;;;;;;GAUG;AACH,MAAa,wBAAyB,SAAQ,kCAAe;IAEhD;IACA;IACA;IACA;IAJX,YACW,UAAkB,EAClB,QAAgB,EAChB,eAAuB,EACvB,aAAsB;QAE/B,KAAK,CACH,GAAG,UAAU,IAAI,QAAQ,gDAAgD,eAAe,EAAE;YACxF,CAAC,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,WAAW,aAAa,GAAG,CAAC,CACpE,CAAC;QARO,eAAU,GAAV,UAAU,CAAQ;QAClB,aAAQ,GAAR,QAAQ,CAAQ;QAChB,oBAAe,GAAf,eAAe,CAAQ;QACvB,kBAAa,GAAb,aAAa,CAAS;IAMjC,CAAC;CACF;AAZD,4DAYC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Base class for all domain-layer exceptions.
3
+ *
4
+ * Decouples business invariant failures from web frameworks, HTTP status codes,
5
+ * and transport boundaries, ensuring domain logic remains pure and executable
6
+ * across HTTP APIs, background jobs, CLIs, and microservices.
7
+ *
8
+ * Domain exceptions carry domain-specific contextual properties (e.g. invalid
9
+ * field values, threshold limits) rather than HTTP status codes. Presentation
10
+ * boundaries (such as NestJS exception filters) translate them into appropriate
11
+ * transport responses (e.g., HTTP 400, 409, 422).
12
+ *
13
+ * @example Defining a concrete domain exception
14
+ * ```typescript
15
+ * export class InvalidUsernameException extends DomainException {
16
+ * readonly minLength: number;
17
+ * readonly actualValue: string;
18
+ *
19
+ * constructor(actualValue: string, minLength = 3) {
20
+ * super(`Username must be at least ${minLength} characters, received: "${actualValue}".`);
21
+ * this.minLength = minLength;
22
+ * this.actualValue = actualValue;
23
+ * }
24
+ * }
25
+ * ```
26
+ */
27
+ export declare abstract class DomainException extends Error {
28
+ constructor(message: string);
29
+ }
30
+ //# sourceMappingURL=domain.exception.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"domain.exception.d.ts","sourceRoot":"","sources":["../../../domain/exceptions/domain.exception.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,8BAAsB,eAAgB,SAAQ,KAAK;gBACrC,OAAO,EAAE,MAAM;CAK5B"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ /* Copyright (C) 2026-present Aristotelis — see repository license. */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.DomainException = void 0;
5
+ /**
6
+ * Base class for all domain-layer exceptions.
7
+ *
8
+ * Decouples business invariant failures from web frameworks, HTTP status codes,
9
+ * and transport boundaries, ensuring domain logic remains pure and executable
10
+ * across HTTP APIs, background jobs, CLIs, and microservices.
11
+ *
12
+ * Domain exceptions carry domain-specific contextual properties (e.g. invalid
13
+ * field values, threshold limits) rather than HTTP status codes. Presentation
14
+ * boundaries (such as NestJS exception filters) translate them into appropriate
15
+ * transport responses (e.g., HTTP 400, 409, 422).
16
+ *
17
+ * @example Defining a concrete domain exception
18
+ * ```typescript
19
+ * export class InvalidUsernameException extends DomainException {
20
+ * readonly minLength: number;
21
+ * readonly actualValue: string;
22
+ *
23
+ * constructor(actualValue: string, minLength = 3) {
24
+ * super(`Username must be at least ${minLength} characters, received: "${actualValue}".`);
25
+ * this.minLength = minLength;
26
+ * this.actualValue = actualValue;
27
+ * }
28
+ * }
29
+ * ```
30
+ */
31
+ class DomainException extends Error {
32
+ constructor(message) {
33
+ super(message);
34
+ this.name = new.target.name;
35
+ Object.setPrototypeOf(this, new.target.prototype);
36
+ }
37
+ }
38
+ exports.DomainException = DomainException;
39
+ //# sourceMappingURL=domain.exception.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"domain.exception.js","sourceRoot":"","sources":["../../../domain/exceptions/domain.exception.ts"],"names":[],"mappings":";AAAA,sEAAsE;;;AAEtE;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAsB,eAAgB,SAAQ,KAAK;IACjD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;QAC5B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;CACF;AAND,0CAMC"}
@@ -0,0 +1,14 @@
1
+ import { DomainException } from './domain.exception';
2
+ /**
3
+ * Framework-neutral lookup failure for an aggregate or entity required by a use case.
4
+ *
5
+ * Application and persistence layers may throw this exception without importing
6
+ * HTTP/Nest presentation semantics. Transport adapters are responsible for mapping
7
+ * it to their own not-found representation (such as HTTP 404).
8
+ */
9
+ export declare class EntityNotFoundException extends DomainException {
10
+ readonly entityName: string;
11
+ readonly entityId?: string | undefined;
12
+ constructor(entityName: string, entityId?: string | undefined);
13
+ }
14
+ //# sourceMappingURL=entity-not-found.exception.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity-not-found.exception.d.ts","sourceRoot":"","sources":["../../../domain/exceptions/entity-not-found.exception.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD;;;;;;GAMG;AACH,qBAAa,uBAAwB,SAAQ,eAAe;IAExD,QAAQ,CAAC,UAAU,EAAE,MAAM;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM;gBADjB,UAAU,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE,MAAM,YAAA;CAI7B"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ /* Copyright (C) 2026-present Aristotelis — see repository license. */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.EntityNotFoundException = void 0;
5
+ const domain_exception_1 = require("./domain.exception");
6
+ /**
7
+ * Framework-neutral lookup failure for an aggregate or entity required by a use case.
8
+ *
9
+ * Application and persistence layers may throw this exception without importing
10
+ * HTTP/Nest presentation semantics. Transport adapters are responsible for mapping
11
+ * it to their own not-found representation (such as HTTP 404).
12
+ */
13
+ class EntityNotFoundException extends domain_exception_1.DomainException {
14
+ entityName;
15
+ entityId;
16
+ constructor(entityName, entityId) {
17
+ super(`${entityName} not found`);
18
+ this.entityName = entityName;
19
+ this.entityId = entityId;
20
+ }
21
+ }
22
+ exports.EntityNotFoundException = EntityNotFoundException;
23
+ //# sourceMappingURL=entity-not-found.exception.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity-not-found.exception.js","sourceRoot":"","sources":["../../../domain/exceptions/entity-not-found.exception.ts"],"names":[],"mappings":";AAAA,sEAAsE;;;AAEtE,yDAAqD;AAErD;;;;;;GAMG;AACH,MAAa,uBAAwB,SAAQ,kCAAe;IAE/C;IACA;IAFX,YACW,UAAkB,EAClB,QAAiB;QAE1B,KAAK,CAAC,GAAG,UAAU,YAAY,CAAC,CAAC;QAHxB,eAAU,GAAV,UAAU,CAAQ;QAClB,aAAQ,GAAR,QAAQ,CAAS;IAG5B,CAAC;CACF;AAPD,0DAOC"}
@@ -0,0 +1,35 @@
1
+ import type { ValueViolation } from '../rules/value-violation';
2
+ import { DomainException } from './domain.exception';
3
+ /**
4
+ * A value broke a rule of a {@link textRule} or {@link numberRule}.
5
+ *
6
+ * It is the error both rules throw by default, and the base class for an
7
+ * application's own exceptions, which then share its message format and its
8
+ * `violation`. `domainErrorHttpStatus()` answers 400 for it, like any other
9
+ * `DomainException`.
10
+ *
11
+ * The rejected value is not kept, so logging the exception cannot leak it.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * export class InvalidUsernameException extends InvalidValueException {}
16
+ *
17
+ * const username = textRule({
18
+ * field: 'username',
19
+ * minLength: 3,
20
+ * error: (violation) => new InvalidUsernameException(violation),
21
+ * });
22
+ *
23
+ * username.normalize('ab');
24
+ * // throws InvalidUsernameException: "username must be at least 3 characters."
25
+ * ```
26
+ */
27
+ export declare class InvalidValueException extends DomainException {
28
+ readonly violation: ValueViolation;
29
+ /**
30
+ * @param violation - The broken rule.
31
+ * @param message - Replaces the default message built from `violation`.
32
+ */
33
+ constructor(violation: ValueViolation, message?: string);
34
+ }
35
+ //# sourceMappingURL=invalid-value.exception.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invalid-value.exception.d.ts","sourceRoot":"","sources":["../../../domain/exceptions/invalid-value.exception.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AA4BrD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,qBAAsB,SAAQ,eAAe;IACxD,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC;IAEnC;;;OAGG;gBACS,SAAS,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE,MAAM;CAIxD"}