@woltz/rich-domain 0.2.1

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 (178) hide show
  1. package/.github/workflows/ci.yml +40 -0
  2. package/.husky/commit-msg +1 -0
  3. package/.husky/pre-commit +1 -0
  4. package/.versionrc.json +21 -0
  5. package/.vscode/settings.json +3 -0
  6. package/CHANGELOG.md +81 -0
  7. package/LICENSE +21 -0
  8. package/README.md +712 -0
  9. package/commitlint.config.js +23 -0
  10. package/dist/base-entity.d.ts +67 -0
  11. package/dist/base-entity.d.ts.map +1 -0
  12. package/dist/base-entity.js +309 -0
  13. package/dist/base-entity.js.map +1 -0
  14. package/dist/constants.d.ts +3 -0
  15. package/dist/constants.d.ts.map +1 -0
  16. package/dist/constants.js +6 -0
  17. package/dist/constants.js.map +1 -0
  18. package/dist/criteria.d.ts +60 -0
  19. package/dist/criteria.d.ts.map +1 -0
  20. package/dist/criteria.js +214 -0
  21. package/dist/criteria.js.map +1 -0
  22. package/dist/deep-proxy.d.ts +34 -0
  23. package/dist/deep-proxy.d.ts.map +1 -0
  24. package/dist/deep-proxy.js +297 -0
  25. package/dist/deep-proxy.js.map +1 -0
  26. package/dist/domain-event-bus.d.ts +57 -0
  27. package/dist/domain-event-bus.d.ts.map +1 -0
  28. package/dist/domain-event-bus.js +112 -0
  29. package/dist/domain-event-bus.js.map +1 -0
  30. package/dist/domain-event.d.ts +55 -0
  31. package/dist/domain-event.d.ts.map +1 -0
  32. package/dist/domain-event.js +42 -0
  33. package/dist/domain-event.js.map +1 -0
  34. package/dist/entity.d.ts +13 -0
  35. package/dist/entity.d.ts.map +1 -0
  36. package/dist/entity.js +15 -0
  37. package/dist/entity.js.map +1 -0
  38. package/dist/filtering.d.ts +107 -0
  39. package/dist/filtering.d.ts.map +1 -0
  40. package/dist/filtering.js +202 -0
  41. package/dist/filtering.js.map +1 -0
  42. package/dist/id.d.ts +51 -0
  43. package/dist/id.d.ts.map +1 -0
  44. package/dist/id.js +84 -0
  45. package/dist/id.js.map +1 -0
  46. package/dist/index.d.ts +15 -0
  47. package/dist/index.d.ts.map +1 -0
  48. package/dist/index.js +25 -0
  49. package/dist/index.js.map +1 -0
  50. package/dist/ordering.d.ts +93 -0
  51. package/dist/ordering.d.ts.map +1 -0
  52. package/dist/ordering.js +154 -0
  53. package/dist/ordering.js.map +1 -0
  54. package/dist/paginated-result.d.ts +62 -0
  55. package/dist/paginated-result.d.ts.map +1 -0
  56. package/dist/paginated-result.js +201 -0
  57. package/dist/paginated-result.js.map +1 -0
  58. package/dist/pagination.d.ts +218 -0
  59. package/dist/pagination.d.ts.map +1 -0
  60. package/dist/pagination.js +281 -0
  61. package/dist/pagination.js.map +1 -0
  62. package/dist/repository/base-repository.d.ts +77 -0
  63. package/dist/repository/base-repository.d.ts.map +1 -0
  64. package/dist/repository/base-repository.js +80 -0
  65. package/dist/repository/base-repository.js.map +1 -0
  66. package/dist/repository/in-memory-repository.d.ts +46 -0
  67. package/dist/repository/in-memory-repository.d.ts.map +1 -0
  68. package/dist/repository/in-memory-repository.js +85 -0
  69. package/dist/repository/in-memory-repository.js.map +1 -0
  70. package/dist/repository/index.d.ts +42 -0
  71. package/dist/repository/index.d.ts.map +1 -0
  72. package/dist/repository/index.js +47 -0
  73. package/dist/repository/index.js.map +1 -0
  74. package/dist/repository/mapper.d.ts +56 -0
  75. package/dist/repository/mapper.d.ts.map +1 -0
  76. package/dist/repository/mapper.js +15 -0
  77. package/dist/repository/mapper.js.map +1 -0
  78. package/dist/repository/types.d.ts +87 -0
  79. package/dist/repository/types.d.ts.map +1 -0
  80. package/dist/repository/types.js +6 -0
  81. package/dist/repository/types.js.map +1 -0
  82. package/dist/repository/unit-of-work.d.ts +70 -0
  83. package/dist/repository/unit-of-work.d.ts.map +1 -0
  84. package/dist/repository/unit-of-work.js +122 -0
  85. package/dist/repository/unit-of-work.js.map +1 -0
  86. package/dist/repository.d.ts +2 -0
  87. package/dist/repository.d.ts.map +1 -0
  88. package/dist/repository.js +21 -0
  89. package/dist/repository.js.map +1 -0
  90. package/dist/specification.d.ts +102 -0
  91. package/dist/specification.d.ts.map +1 -0
  92. package/dist/specification.js +187 -0
  93. package/dist/specification.js.map +1 -0
  94. package/dist/types/criteria.d.ts +35 -0
  95. package/dist/types/criteria.d.ts.map +1 -0
  96. package/dist/types/criteria.js +17 -0
  97. package/dist/types/criteria.js.map +1 -0
  98. package/dist/types/domain.d.ts +30 -0
  99. package/dist/types/domain.d.ts.map +1 -0
  100. package/dist/types/domain.js +2 -0
  101. package/dist/types/domain.js.map +1 -0
  102. package/dist/types/history-tracker.d.ts +36 -0
  103. package/dist/types/history-tracker.d.ts.map +1 -0
  104. package/dist/types/history-tracker.js +2 -0
  105. package/dist/types/history-tracker.js.map +1 -0
  106. package/dist/types/index.d.ts +8 -0
  107. package/dist/types/index.d.ts.map +1 -0
  108. package/dist/types/index.js +8 -0
  109. package/dist/types/index.js.map +1 -0
  110. package/dist/types/repository.d.ts +43 -0
  111. package/dist/types/repository.d.ts.map +1 -0
  112. package/dist/types/repository.js +2 -0
  113. package/dist/types/repository.js.map +1 -0
  114. package/dist/types/standard-schema.d.ts +15 -0
  115. package/dist/types/standard-schema.d.ts.map +1 -0
  116. package/dist/types/standard-schema.js +2 -0
  117. package/dist/types/standard-schema.js.map +1 -0
  118. package/dist/types/unit-of-work.d.ts +39 -0
  119. package/dist/types/unit-of-work.d.ts.map +1 -0
  120. package/dist/types/unit-of-work.js +2 -0
  121. package/dist/types/unit-of-work.js.map +1 -0
  122. package/dist/types/utils.d.ts +14 -0
  123. package/dist/types/utils.d.ts.map +1 -0
  124. package/dist/types/utils.js +2 -0
  125. package/dist/types/utils.js.map +1 -0
  126. package/dist/types.d.ts +88 -0
  127. package/dist/types.d.ts.map +1 -0
  128. package/dist/types.js +12 -0
  129. package/dist/types.js.map +1 -0
  130. package/dist/validation-error.d.ts +42 -0
  131. package/dist/validation-error.d.ts.map +1 -0
  132. package/dist/validation-error.js +73 -0
  133. package/dist/validation-error.js.map +1 -0
  134. package/dist/value-object.d.ts +47 -0
  135. package/dist/value-object.d.ts.map +1 -0
  136. package/dist/value-object.js +136 -0
  137. package/dist/value-object.js.map +1 -0
  138. package/eslint.config.js +51 -0
  139. package/jest.config.js +21 -0
  140. package/package.json +58 -0
  141. package/src/base-entity.ts +401 -0
  142. package/src/constants.ts +7 -0
  143. package/src/criteria.ts +291 -0
  144. package/src/deep-proxy.ts +339 -0
  145. package/src/domain-event-bus.ts +166 -0
  146. package/src/domain-event.ts +90 -0
  147. package/src/entity.ts +16 -0
  148. package/src/id.ts +94 -0
  149. package/src/index.ts +33 -0
  150. package/src/paginated-result.ts +274 -0
  151. package/src/repository/base-repository.ts +152 -0
  152. package/src/repository/in-memory-repository.ts +104 -0
  153. package/src/repository/index.ts +55 -0
  154. package/src/repository/mapper.ts +74 -0
  155. package/src/repository/unit-of-work.ts +148 -0
  156. package/src/types/criteria.ts +79 -0
  157. package/src/types/domain.ts +37 -0
  158. package/src/types/history-tracker.ts +45 -0
  159. package/src/types/index.ts +7 -0
  160. package/src/types/repository.ts +51 -0
  161. package/src/types/standard-schema.ts +19 -0
  162. package/src/types/unit-of-work.ts +46 -0
  163. package/src/types/utils.ts +29 -0
  164. package/src/validation-error.ts +97 -0
  165. package/src/value-object.ts +187 -0
  166. package/tests/criteria.test.ts +432 -0
  167. package/tests/domain-events.test.ts +445 -0
  168. package/tests/entity-equality.test.ts +487 -0
  169. package/tests/entity-validation.test.ts +339 -0
  170. package/tests/entity.test.ts +33 -0
  171. package/tests/history-tracker.spec.ts +667 -0
  172. package/tests/id.test.ts +341 -0
  173. package/tests/repository.test.ts +641 -0
  174. package/tests/to-json.test.ts +91 -0
  175. package/tests/utils.ts +151 -0
  176. package/tests/value-object-validation.test.ts +228 -0
  177. package/tests/value-objects.test.ts +52 -0
  178. package/tsconfig.json +31 -0
@@ -0,0 +1,40 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+ branches: [ main ]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+
13
+ strategy:
14
+ matrix:
15
+ node-version: [20.x]
16
+
17
+ steps:
18
+ - name: Checkout code
19
+ uses: actions/checkout@v4
20
+
21
+ - name: Setup Node.js ${{ matrix.node-version }}
22
+ uses: actions/setup-node@v4
23
+ with:
24
+ node-version: ${{ matrix.node-version }}
25
+ cache: 'npm'
26
+
27
+ - name: Install dependencies
28
+ run: npm ci
29
+
30
+ - name: Run linter
31
+ run: npm run lint
32
+
33
+ - name: Run type checking
34
+ run: npx tsc --noEmit
35
+
36
+ - name: Run tests
37
+ run: npm test
38
+
39
+ - name: Build
40
+ run: npm run build
@@ -0,0 +1 @@
1
+ npx --no -- commitlint --edit $1
@@ -0,0 +1 @@
1
+ npm test
@@ -0,0 +1,21 @@
1
+ {
2
+ "types": [
3
+ { "type": "feat", "section": "Features" },
4
+ { "type": "fix", "section": "Bug Fixes" },
5
+ { "type": "chore", "hidden": false, "section": "Chores" },
6
+ { "type": "docs", "hidden": false, "section": "Documentation" },
7
+ { "type": "style", "hidden": true },
8
+ { "type": "refactor", "section": "Refactoring" },
9
+ { "type": "perf", "section": "Performance Improvements" },
10
+ { "type": "test", "hidden": false, "section": "Tests" }
11
+ ],
12
+ "commitUrlFormat": "{{host}}/{{owner}}/{{repository}}/commit/{{hash}}",
13
+ "compareUrlFormat": "{{host}}/{{owner}}/{{repository}}/compare/{{previousTag}}...{{currentTag}}",
14
+ "issueUrlFormat": "{{host}}/{{owner}}/{{repository}}/issues/{{id}}",
15
+ "userUrlFormat": "{{host}}/{{user}}",
16
+ "releaseCommitMessageFormat": "chore(release): {{currentTag}}",
17
+ "issuePrefixes": ["#"],
18
+ "skip": {
19
+ "changelog": false
20
+ }
21
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "typescript.tsdk": "node_modules\\typescript\\lib"
3
+ }
package/CHANGELOG.md ADDED
@@ -0,0 +1,81 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
+
5
+ ### [0.2.1](https://github.com/tarcisioandrade/rich-domain/compare/v0.2.0...v0.2.1) (2025-11-19)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * update TypeScript configuration for module resolution and add check script ([4c0951f](https://github.com/tarcisioandrade/rich-domain/commit/4c0951fa3ce7551fc9182a7e584578053d0137a7))
11
+
12
+
13
+ ### Chores
14
+
15
+ * add ignoreDeprecations option to TypeScript configuration ([a66e528](https://github.com/tarcisioandrade/rich-domain/commit/a66e5289c33972f0449f9eb6d9e6fb85054888c4))
16
+
17
+ ## [0.2.0](https://github.com/tarcisioandrade/rich-domain/compare/v0.1.0...v0.2.0) (2025-11-19)
18
+
19
+
20
+ ### Features
21
+
22
+ * add repository and unit of work modules with transaction management and clean exports ([83b652c](https://github.com/tarcisioandrade/rich-domain/commit/83b652cf751c2824799cfc961b282413ac7667f7))
23
+ * add search functionality to Criteria class with related methods ([1445e09](https://github.com/tarcisioandrade/rich-domain/commit/1445e092141c538766af39ec7de13421bf318393))
24
+ * implement abstract base repository and mapper for domain persistence ([f6b06ca](https://github.com/tarcisioandrade/rich-domain/commit/f6b06ca59292d9290e438717acaf2eaf361f63a7))
25
+ * implement criteria with filtering, ordering, and pagination ([bb42425](https://github.com/tarcisioandrade/rich-domain/commit/bb42425cc9e763ced350c3e6ee86954a5239cfb6))
26
+ * implement InMemoryRepository for testing with CRUD operations and criteria support ([a9d0cf6](https://github.com/tarcisioandrade/rich-domain/commit/a9d0cf63e68ab40d2944b6f26792ebfc456db176))
27
+
28
+
29
+ ### Bug Fixes
30
+
31
+ * disable no-unsafe-function-type rule in ESLint configuration ([f185ed9](https://github.com/tarcisioandrade/rich-domain/commit/f185ed920eda8e1f1c205aed8d7f1091cd03fbee))
32
+
33
+
34
+ ### Chores
35
+
36
+ * add coverage directory to .gitignore ([7a895f0](https://github.com/tarcisioandrade/rich-domain/commit/7a895f0ca777c27056f5bfd5adeed0b44049c60e))
37
+ * enhance Jest configuration and add coverage script to package.json ([d3b08d9](https://github.com/tarcisioandrade/rich-domain/commit/d3b08d97a4ecb650825e0b99d307203a5449ee96))
38
+ * update .gitignore to exclude example directories ([26c2d41](https://github.com/tarcisioandrade/rich-domain/commit/26c2d4140403877dabbd8a8b2b86250fa459f9b5))
39
+ * update version to 0.1.0 and add release scripts ([bb0aafa](https://github.com/tarcisioandrade/rich-domain/commit/bb0aafa85b5527d8ac3a582fcb75c489e7a4aa7a))
40
+
41
+
42
+ ### Refactoring
43
+
44
+ * drop default values ([a7e130a](https://github.com/tarcisioandrade/rich-domain/commit/a7e130af3a7ece31bb7bdf38afd7e05ed724bf3c))
45
+ * move pagination logic to a new PaginatedResult class and update criteria tests ([96639e1](https://github.com/tarcisioandrade/rich-domain/commit/96639e15c9e7aa2794f7439741150d1a8b087d39))
46
+ * reorganize types and constants, introduce new criteria types ([170e93a](https://github.com/tarcisioandrade/rich-domain/commit/170e93a2b9f68c21e02818f87171df242018a130))
47
+ * update access modifiers and default values in BaseEntity and Criteria classes ([75cde9d](https://github.com/tarcisioandrade/rich-domain/commit/75cde9d162adc1ad8d142140186592c155415c2e))
48
+
49
+
50
+ ### Documentation
51
+
52
+ * enhance README with new features ([0a49e63](https://github.com/tarcisioandrade/rich-domain/commit/0a49e6339bd36ae0c3193f8a3389906b139e56b3))
53
+
54
+ ## 0.1.0 (2025-11-16)
55
+
56
+
57
+ ### Features
58
+
59
+ * domain-events implementation ([92384cc](https://github.com/tarcisioandrade/rich-domain/commit/92384cc4cc645ccb2a92ea9348491b05c7e34247))
60
+ * entity equality ([eb19399](https://github.com/tarcisioandrade/rich-domain/commit/eb19399375daaafb8aad850ba9cee590e6ddf11f))
61
+ * id class ([086d6b6](https://github.com/tarcisioandrade/rich-domain/commit/086d6b622041f03c70519e667c3d7b009c241c60))
62
+
63
+
64
+ ### Refactoring
65
+
66
+ * Change property access in BaseEntity and related classes ([ceacca1](https://github.com/tarcisioandrade/rich-domain/commit/ceacca18b33d70a0d87119436c7b6180ddf61648))
67
+ * Remove Result class and related tests ([02fa29f](https://github.com/tarcisioandrade/rich-domain/commit/02fa29ff6bdad377c5c0737e9cec2dd2f36940af))
68
+ * Standardize quotes and remove obsolete test files ([2a38df7](https://github.com/tarcisioandrade/rich-domain/commit/2a38df7a88f418b63797dd32241284a52bdae3cf))
69
+
70
+
71
+ ### Tests
72
+
73
+ * validation tests ([eb620a4](https://github.com/tarcisioandrade/rich-domain/commit/eb620a4aec22d2335a466f002f8659bf402ced74))
74
+
75
+
76
+ ### Chores
77
+
78
+ * config ci and eslint ([88fba8f](https://github.com/tarcisioandrade/rich-domain/commit/88fba8fe51b0929cc55a649cfbf1e76d9bfb99b2))
79
+ * update CI node version matrix to only include 20.x ([9aecd60](https://github.com/tarcisioandrade/rich-domain/commit/9aecd6043dd391a2795e1209631b57d542c748da))
80
+ * update node engine requirement to >=20.0.0 ([213629c](https://github.com/tarcisioandrade/rich-domain/commit/213629cb64b3b85452f0364f802bb58bd4a757f8))
81
+ * update node engine requirement to >=22.0.0 ([1bad966](https://github.com/tarcisioandrade/rich-domain/commit/1bad966de395ff2b02dd0d7a4627aa725039b862))
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 tarcisioandrade
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.