@woltz/rich-domain 1.9.2 → 1.9.3

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 (122) hide show
  1. package/dist/cjs/constants.d.ts +1 -1
  2. package/dist/cjs/constants.d.ts.map +1 -1
  3. package/dist/cjs/core/base-entity.d.ts +2 -1
  4. package/dist/cjs/core/base-entity.d.ts.map +1 -1
  5. package/dist/cjs/core/base-entity.js +9 -7
  6. package/dist/cjs/core/base-entity.js.map +1 -1
  7. package/dist/cjs/core/change-tracker.d.ts +1 -0
  8. package/dist/cjs/core/change-tracker.d.ts.map +1 -1
  9. package/dist/cjs/core/change-tracker.js +24 -15
  10. package/dist/cjs/core/change-tracker.js.map +1 -1
  11. package/dist/cjs/core/domain-event.d.ts +1 -1
  12. package/dist/cjs/core/domain-event.d.ts.map +1 -1
  13. package/dist/cjs/core/domain-event.js +2 -2
  14. package/dist/cjs/core/domain-event.js.map +1 -1
  15. package/dist/cjs/core/entities.d.ts +8 -0
  16. package/dist/cjs/core/entities.d.ts.map +1 -0
  17. package/dist/cjs/core/entities.js +12 -0
  18. package/dist/cjs/core/entities.js.map +1 -0
  19. package/dist/cjs/core/index.d.ts +9 -9
  20. package/dist/cjs/core/index.d.ts.map +1 -1
  21. package/dist/cjs/core/index.js +9 -9
  22. package/dist/cjs/core/index.js.map +1 -1
  23. package/dist/cjs/repository/base-repository.d.ts +1 -1
  24. package/dist/cjs/repository/base-repository.d.ts.map +1 -1
  25. package/dist/cjs/repository/entity-schema-registry.d.ts +1 -1
  26. package/dist/cjs/repository/entity-schema-registry.d.ts.map +1 -1
  27. package/dist/cjs/repository/entity-schema-registry.js +5 -5
  28. package/dist/cjs/repository/entity-schema-registry.js.map +1 -1
  29. package/dist/cjs/types/change-tracker.d.ts +1 -1
  30. package/dist/cjs/types/change-tracker.d.ts.map +1 -1
  31. package/dist/cjs/types/domain.d.ts +1 -1
  32. package/dist/cjs/types/domain.d.ts.map +1 -1
  33. package/dist/cjs/types/event-bus.d.ts +1 -1
  34. package/dist/cjs/types/event-bus.d.ts.map +1 -1
  35. package/dist/cjs/types/unit-of-work.d.ts +2 -2
  36. package/dist/cjs/types/unit-of-work.d.ts.map +1 -1
  37. package/dist/cjs/types/utils.d.ts +1 -1
  38. package/dist/cjs/types/utils.d.ts.map +1 -1
  39. package/dist/esm/constants.d.ts +1 -1
  40. package/dist/esm/constants.d.ts.map +1 -1
  41. package/dist/esm/core/base-entity.d.ts +2 -1
  42. package/dist/esm/core/base-entity.d.ts.map +1 -1
  43. package/dist/esm/core/base-entity.js +3 -1
  44. package/dist/esm/core/base-entity.js.map +1 -1
  45. package/dist/esm/core/change-tracker.d.ts +1 -0
  46. package/dist/esm/core/change-tracker.d.ts.map +1 -1
  47. package/dist/esm/core/change-tracker.js +24 -15
  48. package/dist/esm/core/change-tracker.js.map +1 -1
  49. package/dist/esm/core/domain-event.d.ts +1 -1
  50. package/dist/esm/core/domain-event.d.ts.map +1 -1
  51. package/dist/esm/core/domain-event.js +1 -1
  52. package/dist/esm/core/domain-event.js.map +1 -1
  53. package/dist/esm/core/entities.d.ts +8 -0
  54. package/dist/esm/core/entities.d.ts.map +1 -0
  55. package/dist/esm/core/entities.js +7 -0
  56. package/dist/esm/core/entities.js.map +1 -0
  57. package/dist/esm/core/index.d.ts +9 -9
  58. package/dist/esm/core/index.d.ts.map +1 -1
  59. package/dist/esm/core/index.js +9 -9
  60. package/dist/esm/core/index.js.map +1 -1
  61. package/dist/esm/repository/base-repository.d.ts +1 -1
  62. package/dist/esm/repository/base-repository.d.ts.map +1 -1
  63. package/dist/esm/repository/entity-schema-registry.d.ts +1 -1
  64. package/dist/esm/repository/entity-schema-registry.d.ts.map +1 -1
  65. package/dist/esm/repository/entity-schema-registry.js +1 -1
  66. package/dist/esm/repository/entity-schema-registry.js.map +1 -1
  67. package/dist/esm/types/change-tracker.d.ts +1 -1
  68. package/dist/esm/types/change-tracker.d.ts.map +1 -1
  69. package/dist/esm/types/domain.d.ts +1 -1
  70. package/dist/esm/types/domain.d.ts.map +1 -1
  71. package/dist/esm/types/event-bus.d.ts +1 -1
  72. package/dist/esm/types/event-bus.d.ts.map +1 -1
  73. package/dist/esm/types/unit-of-work.d.ts +2 -2
  74. package/dist/esm/types/unit-of-work.d.ts.map +1 -1
  75. package/dist/esm/types/utils.d.ts +1 -1
  76. package/dist/esm/types/utils.d.ts.map +1 -1
  77. package/dist/tsconfig.cjs.tsbuildinfo +1 -1
  78. package/dist/tsconfig.esm.tsbuildinfo +1 -1
  79. package/dist/tsconfig.types.tsbuildinfo +1 -1
  80. package/dist/types/constants.d.ts +1 -1
  81. package/dist/types/constants.d.ts.map +1 -1
  82. package/dist/types/core/base-entity.d.ts +2 -1
  83. package/dist/types/core/base-entity.d.ts.map +1 -1
  84. package/dist/types/core/change-tracker.d.ts +1 -0
  85. package/dist/types/core/change-tracker.d.ts.map +1 -1
  86. package/dist/types/core/domain-event.d.ts +1 -1
  87. package/dist/types/core/domain-event.d.ts.map +1 -1
  88. package/dist/types/core/entities.d.ts +8 -0
  89. package/dist/types/core/entities.d.ts.map +1 -0
  90. package/dist/types/core/index.d.ts +9 -9
  91. package/dist/types/core/index.d.ts.map +1 -1
  92. package/dist/types/repository/base-repository.d.ts +1 -1
  93. package/dist/types/repository/base-repository.d.ts.map +1 -1
  94. package/dist/types/repository/entity-schema-registry.d.ts +1 -1
  95. package/dist/types/repository/entity-schema-registry.d.ts.map +1 -1
  96. package/dist/types/types/change-tracker.d.ts +1 -1
  97. package/dist/types/types/change-tracker.d.ts.map +1 -1
  98. package/dist/types/types/domain.d.ts +1 -1
  99. package/dist/types/types/domain.d.ts.map +1 -1
  100. package/dist/types/types/event-bus.d.ts +1 -1
  101. package/dist/types/types/event-bus.d.ts.map +1 -1
  102. package/dist/types/types/unit-of-work.d.ts +2 -2
  103. package/dist/types/types/unit-of-work.d.ts.map +1 -1
  104. package/dist/types/types/utils.d.ts +1 -1
  105. package/dist/types/types/utils.d.ts.map +1 -1
  106. package/package.json +68 -68
  107. package/src/constants.ts +82 -82
  108. package/src/core/aggregate-changes.ts +466 -466
  109. package/src/core/base-entity.ts +4 -1
  110. package/src/core/change-tracker.ts +30 -16
  111. package/src/core/domain-event.ts +41 -41
  112. package/src/core/{entity.ts → entities.ts} +13 -13
  113. package/src/core/index.ts +9 -9
  114. package/src/core/value-object.ts +179 -179
  115. package/src/repository/base-repository.ts +81 -81
  116. package/src/repository/entity-schema-registry.ts +1 -1
  117. package/src/types/change-tracker.ts +268 -268
  118. package/src/types/domain.ts +41 -41
  119. package/src/types/event-bus.ts +17 -17
  120. package/src/types/unit-of-work.ts +46 -46
  121. package/src/types/utils.ts +24 -24
  122. package/src/utils/helpers.ts +50 -50
@@ -1,81 +1,81 @@
1
- import type { Aggregate } from "../core/entity.js";
2
- import type { Criteria } from "../criteria.js";
3
- import { PaginatedResult } from "./paginated-result.js";
4
- import { Mapper } from "./mapper.js";
5
-
6
- export abstract class ReadRepository<Agg extends Aggregate<any>> {
7
- /**
8
- * Find entities based on criteria.
9
- * @param criteria - The criteria to use for the search. If not provided, all entities will be returned. (optional)
10
- * @returns A promise that resolves to a paginated result of entities.
11
- */
12
- abstract find(criteria?: Criteria<Agg>): Promise<PaginatedResult<Agg>>;
13
- abstract findById(id: string): Promise<Agg | null>;
14
- abstract findManyByIds(ids: string[]): Promise<Agg[]>;
15
- /**
16
- * Count the number of entities based on criteria.
17
- * @param criteria - The criteria to use for the count. If not provided, all entities will be counted. (optional)
18
- * @returns A promise that resolves to the number of entities.
19
- */
20
- abstract count(criteria?: Criteria<Agg>): Promise<number>;
21
- /**
22
- * Check if an entity exists based on its identifier.
23
- * @param id - The identifier of the entity to check.
24
- * @returns A promise that resolves to a boolean.
25
- */
26
- abstract exists(id: string): Promise<boolean>;
27
- }
28
-
29
- export abstract class WriteRepository<Agg extends Aggregate<any>> {
30
- /**
31
- *
32
- * Save or update an entity.
33
- * @param entity - The entity to save.
34
- * @returns void
35
- */
36
- abstract save(entity: Agg): Promise<void>;
37
- abstract delete(entity: Agg): Promise<void>;
38
- }
39
-
40
- export abstract class WriteAndRead<Agg extends Aggregate<any>> {
41
- /**
42
- * Find entities based on criteria.
43
- * @param criteria - The criteria to use for the search. If not provided, all entities will be returned. (optional)
44
- * @returns A promise that resolves to a paginated result of entities.
45
- */
46
- abstract find(criteria?: Criteria<Agg>): Promise<PaginatedResult<Agg>>;
47
- abstract findById(id: string): Promise<Agg | null>;
48
- abstract findManyByIds(ids: string[]): Promise<Agg[]>;
49
- /**
50
- *
51
- * Save or update an entity.
52
- * @param entity - The entity to save.
53
- * @returns void
54
- */
55
- abstract save(entity: Agg): Promise<void>;
56
- abstract delete(entity: Agg): Promise<void>;
57
- /**
58
- * Count the number of entities based on criteria.
59
- * @param criteria - The criteria to use for the count. If not provided, all entities will be counted. (optional)
60
- * @returns A promise that resolves to the number of entities.
61
- */
62
- abstract count(criteria?: Criteria<Agg>): Promise<number>;
63
- /**
64
- * Check if an entity exists based on its identifier.
65
- * @param id - The identifier of the entity to check.
66
- * @returns A promise that resolves to a boolean.
67
- */
68
- abstract exists(id: string): Promise<boolean>;
69
- }
70
-
71
- export abstract class Repository<
72
- TDomain extends Aggregate<any>,
73
- > extends WriteAndRead<TDomain> {
74
- protected abstract readonly toDomainMapper: Mapper<unknown, TDomain>;
75
- protected abstract readonly toPersistenceMapper: Mapper<TDomain, unknown>;
76
- /**
77
- * Provide the model name of the repository. Usually the table name in the database.
78
- * @returns The model name of the repository.
79
- */
80
- protected abstract get model(): any;
81
- }
1
+ import type { Aggregate } from "../core/entities.js";
2
+ import type { Criteria } from "../criteria.js";
3
+ import { PaginatedResult } from "./paginated-result.js";
4
+ import { Mapper } from "./mapper.js";
5
+
6
+ export abstract class ReadRepository<Agg extends Aggregate<any>> {
7
+ /**
8
+ * Find entities based on criteria.
9
+ * @param criteria - The criteria to use for the search. If not provided, all entities will be returned. (optional)
10
+ * @returns A promise that resolves to a paginated result of entities.
11
+ */
12
+ abstract find(criteria?: Criteria<Agg>): Promise<PaginatedResult<Agg>>;
13
+ abstract findById(id: string): Promise<Agg | null>;
14
+ abstract findManyByIds(ids: string[]): Promise<Agg[]>;
15
+ /**
16
+ * Count the number of entities based on criteria.
17
+ * @param criteria - The criteria to use for the count. If not provided, all entities will be counted. (optional)
18
+ * @returns A promise that resolves to the number of entities.
19
+ */
20
+ abstract count(criteria?: Criteria<Agg>): Promise<number>;
21
+ /**
22
+ * Check if an entity exists based on its identifier.
23
+ * @param id - The identifier of the entity to check.
24
+ * @returns A promise that resolves to a boolean.
25
+ */
26
+ abstract exists(id: string): Promise<boolean>;
27
+ }
28
+
29
+ export abstract class WriteRepository<Agg extends Aggregate<any>> {
30
+ /**
31
+ *
32
+ * Save or update an entity.
33
+ * @param entity - The entity to save.
34
+ * @returns void
35
+ */
36
+ abstract save(entity: Agg): Promise<void>;
37
+ abstract delete(entity: Agg): Promise<void>;
38
+ }
39
+
40
+ export abstract class WriteAndRead<Agg extends Aggregate<any>> {
41
+ /**
42
+ * Find entities based on criteria.
43
+ * @param criteria - The criteria to use for the search. If not provided, all entities will be returned. (optional)
44
+ * @returns A promise that resolves to a paginated result of entities.
45
+ */
46
+ abstract find(criteria?: Criteria<Agg>): Promise<PaginatedResult<Agg>>;
47
+ abstract findById(id: string): Promise<Agg | null>;
48
+ abstract findManyByIds(ids: string[]): Promise<Agg[]>;
49
+ /**
50
+ *
51
+ * Save or update an entity.
52
+ * @param entity - The entity to save.
53
+ * @returns void
54
+ */
55
+ abstract save(entity: Agg): Promise<void>;
56
+ abstract delete(entity: Agg): Promise<void>;
57
+ /**
58
+ * Count the number of entities based on criteria.
59
+ * @param criteria - The criteria to use for the count. If not provided, all entities will be counted. (optional)
60
+ * @returns A promise that resolves to the number of entities.
61
+ */
62
+ abstract count(criteria?: Criteria<Agg>): Promise<number>;
63
+ /**
64
+ * Check if an entity exists based on its identifier.
65
+ * @param id - The identifier of the entity to check.
66
+ * @returns A promise that resolves to a boolean.
67
+ */
68
+ abstract exists(id: string): Promise<boolean>;
69
+ }
70
+
71
+ export abstract class Repository<
72
+ TDomain extends Aggregate<any>,
73
+ > extends WriteAndRead<TDomain> {
74
+ protected abstract readonly toDomainMapper: Mapper<unknown, TDomain>;
75
+ protected abstract readonly toPersistenceMapper: Mapper<TDomain, unknown>;
76
+ /**
77
+ * Provide the model name of the repository. Usually the table name in the database.
78
+ * @returns The model name of the repository.
79
+ */
80
+ protected abstract get model(): any;
81
+ }
@@ -1,4 +1,4 @@
1
- import { Entity, ValueObject, Id } from "../core/index";
1
+ import { Entity, ValueObject, Id } from "../core/index.js";
2
2
  import { ConfigurationError } from "../exceptions.js";
3
3
  import { levenshteinDistance } from "../utils/helpers.js";
4
4