@schorts/shared-kernel 4.2.1 → 4.2.2
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.
- package/dist/cjs/value-objects/array-value.js +2 -0
- package/dist/cjs/value-objects/array-value.js.map +1 -1
- package/dist/cjs/value-objects/index.js +3 -1
- package/dist/cjs/value-objects/index.js.map +1 -1
- package/dist/cjs/value-objects/object-value.js +2 -0
- package/dist/cjs/value-objects/object-value.js.map +1 -1
- package/dist/cjs/value-objects/url-value.js +23 -0
- package/dist/cjs/value-objects/url-value.js.map +1 -0
- package/dist/esm/value-objects/array-value.js +2 -0
- package/dist/esm/value-objects/array-value.js.map +1 -1
- package/dist/esm/value-objects/index.js +3 -1
- package/dist/esm/value-objects/index.js.map +1 -1
- package/dist/esm/value-objects/object-value.js +2 -0
- package/dist/esm/value-objects/object-value.js.map +1 -1
- package/dist/esm/value-objects/url-value.js +23 -0
- package/dist/esm/value-objects/url-value.js.map +1 -0
- package/dist/types/value-objects/array-value.d.ts +2 -0
- package/dist/types/value-objects/array-value.d.ts.map +1 -1
- package/dist/types/value-objects/index.d.ts +1 -0
- package/dist/types/value-objects/index.d.ts.map +1 -1
- package/dist/types/value-objects/object-value.d.ts +2 -0
- package/dist/types/value-objects/object-value.d.ts.map +1 -1
- package/dist/types/value-objects/url-value.d.ts +11 -0
- package/dist/types/value-objects/url-value.d.ts.map +1 -0
- package/package.json +11 -3
- package/.idx/airules.md +0 -186
- package/.idx/dev.nix +0 -54
- package/.vscode/settings.json +0 -7
- package/CHANGELOG +0 -363
- package/__tests__/auth/auth-provider.test.ts +0 -50
- package/__tests__/auth/require-auth.decorator.test.ts +0 -88
- package/__tests__/criteria/criteria.test.ts +0 -159
- package/__tests__/criteria/direction.test.ts +0 -11
- package/__tests__/criteria/filter-criterion.test.ts +0 -15
- package/__tests__/criteria/operator.test.ts +0 -22
- package/__tests__/criteria/order.test.ts +0 -14
- package/__tests__/dao/dao.test.ts +0 -126
- package/__tests__/domain-events/domain-event-primitives.test.ts +0 -34
- package/__tests__/domain-events/domain-event.test.ts +0 -50
- package/__tests__/entities/entity-registry.test.ts +0 -71
- package/__tests__/entities/entity.test.ts +0 -114
- package/__tests__/entities/register-entity.decorator.test.ts +0 -54
- package/__tests__/formatters/pascal-camel-to-snake.test.ts +0 -19
- package/__tests__/http/fetch-http-provider.test.ts +0 -155
- package/__tests__/http/http-provider.test.ts +0 -55
- package/__tests__/json-api/json-api-connector.test.ts +0 -78
- package/__tests__/json-api/json-api-list.test.ts +0 -24
- package/__tests__/json-api/json-api-single.test.ts +0 -24
- package/__tests__/json-api/url-criteria-builder.test.ts +0 -74
- package/__tests__/messages/message.test.ts +0 -16
- package/__tests__/models/base-model.test.ts +0 -10
- package/__tests__/state-manager/state-manager.test.ts +0 -101
- package/__tests__/unit-of-work/unit-of-work.test.ts +0 -47
- package/__tests__/utils/url/url-with-params-builder.test.ts +0 -39
- package/__tests__/value-objects/coordinates-value.test.ts +0 -68
- package/__tests__/value-objects/email-value.test.ts +0 -43
- package/__tests__/value-objects/enum-value.test.ts +0 -51
- package/__tests__/value-objects/integer-value.test.ts +0 -115
- package/__tests__/value-objects/phone-value.test.ts +0 -82
- package/__tests__/value-objects/slug-value.test.ts +0 -43
- package/__tests__/value-objects/string-value.test.ts +0 -121
- package/__tests__/value-objects/uuid-value.test.ts +0 -67
- package/__tests__/value-objects/value-object.test.ts +0 -25
- package/jest.config.js +0 -25
- package/src/abac/index.ts +0 -1
- package/src/abac/predicate.ts +0 -3
- package/src/auth/auth-provider.ts +0 -11
- package/src/auth/exceptions/index.ts +0 -2
- package/src/auth/exceptions/not-authenticated.ts +0 -11
- package/src/auth/exceptions/require-auth-not-implemented-correctly.ts +0 -11
- package/src/auth/index.ts +0 -3
- package/src/auth/require-auth.decorator.ts +0 -42
- package/src/converters/index.ts +0 -1
- package/src/converters/remote-file-to-base64.ts +0 -19
- package/src/criteria/criteria.ts +0 -46
- package/src/criteria/direction.ts +0 -1
- package/src/criteria/exceptions/index.ts +0 -2
- package/src/criteria/exceptions/limit-not-valid.ts +0 -11
- package/src/criteria/exceptions/offset-not-valid.ts +0 -11
- package/src/criteria/index.ts +0 -5
- package/src/criteria/operator.ts +0 -12
- package/src/criteria/order.ts +0 -4
- package/src/dao/dao.ts +0 -16
- package/src/dao/index.ts +0 -1
- package/src/domain-events/domain-event-primitives.ts +0 -10
- package/src/domain-events/domain-event-registry.ts +0 -40
- package/src/domain-events/domain-event.ts +0 -29
- package/src/domain-events/exceptions/domain-event-not-registered.ts +0 -11
- package/src/domain-events/exceptions/index.ts +0 -1
- package/src/domain-events/index.ts +0 -4
- package/src/entities/entity-registry.ts +0 -30
- package/src/entities/entity.ts +0 -25
- package/src/entities/exceptions/entity-not-registered.ts +0 -11
- package/src/entities/exceptions/index.ts +0 -1
- package/src/entities/index.ts +0 -4
- package/src/entities/register-entity.decorator.ts +0 -16
- package/src/event-bus/event-store.ts +0 -9
- package/src/event-bus/event-subscriber.ts +0 -5
- package/src/event-bus/in-memory/async-in-memory-event-bus.ts +0 -67
- package/src/event-bus/in-memory/in-memory-event-store.ts +0 -28
- package/src/event-bus/in-memory/index.ts +0 -2
- package/src/event-bus/index.ts +0 -3
- package/src/formatters/index.ts +0 -1
- package/src/formatters/pascal-camel-to-snake.ts +0 -8
- package/src/http/exceptions/http-exception.ts +0 -8
- package/src/http/exceptions/index.ts +0 -1
- package/src/http/fetch-http-provider.ts +0 -151
- package/src/http/http-interceptor.ts +0 -3
- package/src/http/http-provider.ts +0 -7
- package/src/http/index.ts +0 -5
- package/src/i18n/index.ts +0 -2
- package/src/i18n/shared-kernel-translation-keys.ts +0 -19
- package/src/i18n/translation-resolver.ts +0 -3
- package/src/index.ts +0 -21
- package/src/json-api/exceptions/index.ts +0 -1
- package/src/json-api/exceptions/json-api-errors.ts +0 -17
- package/src/json-api/index.ts +0 -5
- package/src/json-api/json-api-connector.ts +0 -97
- package/src/json-api/json-api-list.ts +0 -13
- package/src/json-api/json-api-single.ts +0 -13
- package/src/json-api/url-criteria-builder.ts +0 -49
- package/src/messages/index.ts +0 -1
- package/src/messages/message.ts +0 -3
- package/src/models/base-model.ts +0 -3
- package/src/models/index.ts +0 -1
- package/src/pub-sub/index.ts +0 -2
- package/src/pub-sub/publisher.ts +0 -3
- package/src/pub-sub/subscription.ts +0 -6
- package/src/rbac/base-resource.ts +0 -3
- package/src/rbac/exceptions/index.ts +0 -1
- package/src/rbac/exceptions/not-authorized.ts +0 -1
- package/src/rbac/index.ts +0 -5
- package/src/rbac/permission.ts +0 -4
- package/src/rbac/rbac-policy.ts +0 -41
- package/src/result/index.ts +0 -1
- package/src/result/result.ts +0 -35
- package/src/state-manager/in-memory-state-manager.ts +0 -22
- package/src/state-manager/index.ts +0 -3
- package/src/state-manager/session-storage-state-manager.ts +0 -47
- package/src/state-manager/state-manager.ts +0 -28
- package/src/telemetry/console-telemetry.ts +0 -27
- package/src/telemetry/index.ts +0 -2
- package/src/telemetry/telemetry.ts +0 -5
- package/src/unit-of-work/index.ts +0 -1
- package/src/unit-of-work/unit-of-work.ts +0 -5
- package/src/utils/index.ts +0 -2
- package/src/utils/url/index.ts +0 -1
- package/src/utils/url/url-with-params-builder.ts +0 -19
- package/src/utils/value-objects/index.ts +0 -1
- package/src/utils/value-objects/rule.ts +0 -3
- package/src/value-objects/array-value.ts +0 -92
- package/src/value-objects/boolean-value.ts +0 -23
- package/src/value-objects/coordinates-value.ts +0 -50
- package/src/value-objects/date-value.ts +0 -36
- package/src/value-objects/email-value.ts +0 -25
- package/src/value-objects/enum-value.ts +0 -27
- package/src/value-objects/exceptions/index.ts +0 -2
- package/src/value-objects/exceptions/value-not-valid.ts +0 -3
- package/src/value-objects/exceptions/values-not-valid.ts +0 -11
- package/src/value-objects/float-valuet.ts +0 -39
- package/src/value-objects/index.ts +0 -17
- package/src/value-objects/integer-value.ts +0 -29
- package/src/value-objects/object-value.ts +0 -84
- package/src/value-objects/phone-value.ts +0 -53
- package/src/value-objects/slug-value.ts +0 -25
- package/src/value-objects/string-value.ts +0 -27
- package/src/value-objects/uuid-value.ts +0 -34
- package/src/value-objects/value-object.ts +0 -7
- package/tsconfig.cjs.json +0 -13
- package/tsconfig.esm.json +0 -12
- package/tsconfig.json +0 -47
package/CHANGELOG
DELETED
|
@@ -1,363 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
|
|
5
|
-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
-
|
|
8
|
-
## [4.2.1] - 2025-10-21
|
|
9
|
-
|
|
10
|
-
### Removed
|
|
11
|
-
|
|
12
|
-
- After tests on several `Telemetry` implementations and `Subscription` I found that the init method is useless due to errors in many cases where the error was triggered by the import and not the initialization so it's being removed.
|
|
13
|
-
|
|
14
|
-
## [4.2.0] - 2025-10-21
|
|
15
|
-
|
|
16
|
-
### Added
|
|
17
|
-
|
|
18
|
-
- Added `ConsoleTelemetry` for dev or test environments.
|
|
19
|
-
|
|
20
|
-
## [4.1.2] - 2025-10-21
|
|
21
|
-
|
|
22
|
-
### Changed
|
|
23
|
-
|
|
24
|
-
- Allow any params in the `init` method of the `Telemetry` and `Subscription`.
|
|
25
|
-
|
|
26
|
-
## [4.1.1] - 2025-10-21
|
|
27
|
-
|
|
28
|
-
### Added
|
|
29
|
-
|
|
30
|
-
- Added telemetry module to the main entry point.
|
|
31
|
-
|
|
32
|
-
## [4.1.0] - 2025-10-21
|
|
33
|
-
|
|
34
|
-
### Added
|
|
35
|
-
|
|
36
|
-
- Added `Telemetry`.
|
|
37
|
-
|
|
38
|
-
## [4.0.0] - 2025-10-21
|
|
39
|
-
|
|
40
|
-
### Added
|
|
41
|
-
|
|
42
|
-
- Added `ABAC` support to `RBACPolicy`.
|
|
43
|
-
|
|
44
|
-
## [3.1.5] - 2025-10-18
|
|
45
|
-
|
|
46
|
-
### Fixed
|
|
47
|
-
|
|
48
|
-
- Fixed `greater_than_or_equal` validation in the `FloatValue`.
|
|
49
|
-
|
|
50
|
-
## [3.1.4] - 2025-10-18
|
|
51
|
-
|
|
52
|
-
### Added
|
|
53
|
-
|
|
54
|
-
- Added `converters` module.
|
|
55
|
-
|
|
56
|
-
## [3.1.3] - 2025-10-18
|
|
57
|
-
|
|
58
|
-
### Added
|
|
59
|
-
|
|
60
|
-
- Added support for `meta` field on the body for the `create` method of the `JSONAPIConnector`.
|
|
61
|
-
|
|
62
|
-
## [3.1.2] - 2025-10-18
|
|
63
|
-
|
|
64
|
-
### Added
|
|
65
|
-
|
|
66
|
-
- Added support for arrays in the `create` method of the `JSONAPIConnector`.
|
|
67
|
-
|
|
68
|
-
## [3.1.1] - 2025-10-16
|
|
69
|
-
|
|
70
|
-
### Added
|
|
71
|
-
|
|
72
|
-
- Added `in-memory` implementation to the `state-manager` module.
|
|
73
|
-
|
|
74
|
-
## [3.1.0] - 2025-10-16
|
|
75
|
-
|
|
76
|
-
### Added
|
|
77
|
-
|
|
78
|
-
- Added `pub-sub` module.
|
|
79
|
-
|
|
80
|
-
## [3.0.0] - 2025-10-15
|
|
81
|
-
|
|
82
|
-
### Changed
|
|
83
|
-
|
|
84
|
-
- Update how filters are stored in the `Criteria` to allow multiple filters over one field.
|
|
85
|
-
|
|
86
|
-
## [2.6.0] - 2025-10-14
|
|
87
|
-
|
|
88
|
-
### Added
|
|
89
|
-
|
|
90
|
-
- Added `countBy` to `DAO`.
|
|
91
|
-
|
|
92
|
-
## [2.5.9] - 2025-10-14
|
|
93
|
-
|
|
94
|
-
### Fixed
|
|
95
|
-
|
|
96
|
-
- `JSONAPIErrors` was never thrown in the `JSONAPIConnector` due to a missing `await`.
|
|
97
|
-
|
|
98
|
-
## [2.5.8] - 2025-10-14
|
|
99
|
-
|
|
100
|
-
### Fixed
|
|
101
|
-
|
|
102
|
-
- Remove `Object.freeze` from `IntegerValue` and `FloatValue` to prevent errors when assigning the `attributeName` on subclasses.
|
|
103
|
-
|
|
104
|
-
## [2.5.7] - 2025-10-13
|
|
105
|
-
|
|
106
|
-
### Added
|
|
107
|
-
|
|
108
|
-
- Added `ObjectValue`.
|
|
109
|
-
|
|
110
|
-
## [2.5.6] - 2025-10-13
|
|
111
|
-
|
|
112
|
-
### Added
|
|
113
|
-
|
|
114
|
-
- Added `min` and `max` to `FloatValue`.
|
|
115
|
-
|
|
116
|
-
## [2.5.5] - 2025-10-13
|
|
117
|
-
|
|
118
|
-
### Added
|
|
119
|
-
|
|
120
|
-
- Added `greater_than_or_equal` and `less_than_or_equal` to `rule`.
|
|
121
|
-
|
|
122
|
-
## [2.5.4] - 2025-10-13
|
|
123
|
-
|
|
124
|
-
### Added
|
|
125
|
-
|
|
126
|
-
- Added `rule` function to avoid the use of `const` when defining the schema on the `ArrayValue`.
|
|
127
|
-
|
|
128
|
-
## [2.5.3] - 2025-10-13
|
|
129
|
-
|
|
130
|
-
### Added
|
|
131
|
-
|
|
132
|
-
- Added `ArrayValue` to value-objects.
|
|
133
|
-
|
|
134
|
-
## [2.5.2] - 2025-10-13
|
|
135
|
-
|
|
136
|
-
### Changed
|
|
137
|
-
|
|
138
|
-
- Allow `DateValue` to be optional.
|
|
139
|
-
|
|
140
|
-
## [2.5.1] - 2025-10-13
|
|
141
|
-
|
|
142
|
-
### Changed
|
|
143
|
-
|
|
144
|
-
- `toPrimitives` method from `DomainEvent` now is defined in the abstract class. In future versions the `DomainEventRegistry` will be updated to handle the transformation of values like date/string and preserve it between conversions.
|
|
145
|
-
|
|
146
|
-
## [2.5.0] - 2025-10-12
|
|
147
|
-
|
|
148
|
-
### Added
|
|
149
|
-
|
|
150
|
-
_ Added `event-bus` with `in-memory` implementations.
|
|
151
|
-
|
|
152
|
-
## [2.4.2] - 2025-10-12
|
|
153
|
-
|
|
154
|
-
### Fixed
|
|
155
|
-
|
|
156
|
-
- Add `id` param to `create` method in the `JSONAPIConnector`.
|
|
157
|
-
|
|
158
|
-
## [2.4.1] - 2025-10-12
|
|
159
|
-
|
|
160
|
-
### Fixed
|
|
161
|
-
|
|
162
|
-
- Added missed export for `JSONAPIErrors`.
|
|
163
|
-
|
|
164
|
-
## [2.4.0] - 2025-10-11
|
|
165
|
-
|
|
166
|
-
### Changed
|
|
167
|
-
|
|
168
|
-
- Now the `JSONAPIConnector` throws a `JSONAPIErrors` exception instead of a generic `HTTPException`.
|
|
169
|
-
|
|
170
|
-
## [2.3.4] - 2025-10-11
|
|
171
|
-
|
|
172
|
-
### Changed
|
|
173
|
-
|
|
174
|
-
- Allow partial attributes in the `create` and `update` methods of the `JSONAPIConnector`.
|
|
175
|
-
|
|
176
|
-
## [2.3.3] - 2025-10-11
|
|
177
|
-
|
|
178
|
-
### Added
|
|
179
|
-
|
|
180
|
-
- Added `ValueNotValid` exception.
|
|
181
|
-
|
|
182
|
-
## [2.3.2] - 2025-10-11
|
|
183
|
-
|
|
184
|
-
### Added
|
|
185
|
-
|
|
186
|
-
- Added `NotAuthorized` exception.
|
|
187
|
-
|
|
188
|
-
## [2.3.1] - 2025-10-11
|
|
189
|
-
|
|
190
|
-
### Changed
|
|
191
|
-
|
|
192
|
-
- `userID` now is protected in the `RBACPolicy`.
|
|
193
|
-
|
|
194
|
-
## [2.3.0] - 2025-10-10
|
|
195
|
-
|
|
196
|
-
### Added
|
|
197
|
-
|
|
198
|
-
- Added `RBAC` module.
|
|
199
|
-
|
|
200
|
-
## [2.2.4] - 2025-10-10
|
|
201
|
-
|
|
202
|
-
### Changed
|
|
203
|
-
|
|
204
|
-
- Remove `Optional` param in the `EnumValue`. Instead allow null values in the `allowedTypes` array.
|
|
205
|
-
|
|
206
|
-
## [2.2.3] - 2025-10-10
|
|
207
|
-
|
|
208
|
-
### Changed
|
|
209
|
-
|
|
210
|
-
- Allow `optional` param in the `EnumValue`.
|
|
211
|
-
|
|
212
|
-
## [2.2.2] - 2025-10-10
|
|
213
|
-
|
|
214
|
-
### Added
|
|
215
|
-
|
|
216
|
-
- Added `FloatValue` to value-objects.
|
|
217
|
-
|
|
218
|
-
## [2.2.1] - 2025-10-10
|
|
219
|
-
|
|
220
|
-
### Added
|
|
221
|
-
|
|
222
|
-
- Added `DateValue` to value-objects.
|
|
223
|
-
|
|
224
|
-
## [2.2.0] - 2025-10-09
|
|
225
|
-
|
|
226
|
-
### Changed
|
|
227
|
-
|
|
228
|
-
- Now the `FetchHTTPProvider` returns the body of the request even on errors to handle JSON/API errors better.
|
|
229
|
-
|
|
230
|
-
## [2.0.1]
|
|
231
|
-
|
|
232
|
-
### Added
|
|
233
|
-
|
|
234
|
-
- Added `BooleanValue`.
|
|
235
|
-
|
|
236
|
-
## [2.0.0]
|
|
237
|
-
|
|
238
|
-
### Changed
|
|
239
|
-
|
|
240
|
-
- Rename method `currentUser` to `getCurrentUser` on the `AuthProvider` interface.
|
|
241
|
-
|
|
242
|
-
## [1.3.2]
|
|
243
|
-
|
|
244
|
-
### Changed
|
|
245
|
-
|
|
246
|
-
- Now the `.authenticate` method from `AuthProvider` should return the token to remove responsabilities from it. A `AuthManager` should be implemented instead in case of future needs.
|
|
247
|
-
|
|
248
|
-
## [1.3.1] - 2025-10-04
|
|
249
|
-
|
|
250
|
-
### Added
|
|
251
|
-
|
|
252
|
-
- Added `ValuesNotValid` exception to have a central error for value objects.
|
|
253
|
-
|
|
254
|
-
## [1.3.0] - 2025-10-04
|
|
255
|
-
|
|
256
|
-
### Added
|
|
257
|
-
|
|
258
|
-
- Added `Result` to have more controlled results in application services.
|
|
259
|
-
|
|
260
|
-
### Fixed
|
|
261
|
-
|
|
262
|
-
- Added missed exports for `i18n` module.
|
|
263
|
-
|
|
264
|
-
## [1.2.3] - 2025-10-03
|
|
265
|
-
|
|
266
|
-
### Changed
|
|
267
|
-
|
|
268
|
-
- Added to constructor of the `FetchHTTPProvider` the possibility to receive a function to fetch the `Authorization`.
|
|
269
|
-
|
|
270
|
-
## [1.2.2] - 2025-10-03
|
|
271
|
-
|
|
272
|
-
### Added
|
|
273
|
-
|
|
274
|
-
- Added implementation of the state manager from the session storage.
|
|
275
|
-
|
|
276
|
-
### Changed
|
|
277
|
-
|
|
278
|
-
- `FetchHTTPProvider` now supports the `headers` options.
|
|
279
|
-
|
|
280
|
-
## [1.2.1] - 2025-10-03
|
|
281
|
-
|
|
282
|
-
### Changed
|
|
283
|
-
|
|
284
|
-
- `FetchHTTPProvider` now supports the `credentials` options.
|
|
285
|
-
|
|
286
|
-
## [1.2.0] - 2025-10-02
|
|
287
|
-
|
|
288
|
-
### Added
|
|
289
|
-
|
|
290
|
-
- Added `i18n` support via `TranslationResolver`.
|
|
291
|
-
|
|
292
|
-
## [1.1.5] - 2025-10-01
|
|
293
|
-
|
|
294
|
-
### Changed
|
|
295
|
-
|
|
296
|
-
- Now the `BaseModel` is more flexible to avoid typing issues in the `fromPrimitives` method.
|
|
297
|
-
|
|
298
|
-
## [1.1.4] - 2025-10-01
|
|
299
|
-
|
|
300
|
-
### Added
|
|
301
|
-
|
|
302
|
-
- Added support for `CommonJS`.
|
|
303
|
-
|
|
304
|
-
## [1.1.3] - 2025-10-01
|
|
305
|
-
|
|
306
|
-
### Added
|
|
307
|
-
|
|
308
|
-
- Added root entry point. Now you can import everything from `@schorts/shared-kernel` instead of having to choose an specific module. Example: `@schorts/shared-kernel/auth`.
|
|
309
|
-
|
|
310
|
-
## [1.1.2] - 2025-09-30
|
|
311
|
-
|
|
312
|
-
### Changed
|
|
313
|
-
|
|
314
|
-
- Now the `DAO` actions like `create`, `update` and `delete` can receive a `UnitOfWork`.
|
|
315
|
-
|
|
316
|
-
## [1.1.1] - 2025-09-30
|
|
317
|
-
|
|
318
|
-
### Added
|
|
319
|
-
|
|
320
|
-
- Added `RegisterEntity` decorator to only decorate the entity to add it to the `EntityRegistry`.
|
|
321
|
-
|
|
322
|
-
## [1.1.0] - 2025-09-30
|
|
323
|
-
|
|
324
|
-
### Changed
|
|
325
|
-
|
|
326
|
-
- Now the `ValueObject` for ID property on `Entity` is required.
|
|
327
|
-
|
|
328
|
-
### Added
|
|
329
|
-
|
|
330
|
-
- Added `EntityRegistry` to dynamically instantiate entities in the DAO implementation.
|
|
331
|
-
|
|
332
|
-
## [1.0.5] - 2025-09-30
|
|
333
|
-
|
|
334
|
-
### Added
|
|
335
|
-
|
|
336
|
-
- Introduce `DAO` concept for a related package with a `Firestore` implementation.
|
|
337
|
-
- Introduce `UnitOfWOrk` concept for a related package with a `Firestore` implementation.
|
|
338
|
-
|
|
339
|
-
## [1.0.4] - 2025-09-30
|
|
340
|
-
|
|
341
|
-
### Fixed
|
|
342
|
-
|
|
343
|
-
- Add `dist` folder to the repo and NPM package.
|
|
344
|
-
|
|
345
|
-
## [1.0.3] - 2025-09-30
|
|
346
|
-
|
|
347
|
-
### Added
|
|
348
|
-
|
|
349
|
-
- This CHANGELOG file to keep track of the relevant changes.
|
|
350
|
-
|
|
351
|
-
### Changed
|
|
352
|
-
|
|
353
|
-
- Removed indirect dependencies from the `package.json`.
|
|
354
|
-
|
|
355
|
-
[1.2.0]: https://github.com/schorts99/shared-kernel/compare/v1.2.4...v1.2.0
|
|
356
|
-
[1.1.4]: https://github.com/schorts99/shared-kernel/compare/v1.1.3...v1.1.4
|
|
357
|
-
[1.1.3]: https://github.com/schorts99/shared-kernel/compare/v1.1.2...v1.1.3
|
|
358
|
-
[1.1.2]: https://github.com/schorts99/shared-kernel/compare/v1.1.1...v1.1.2
|
|
359
|
-
[1.1.1]: https://github.com/schorts99/shared-kernel/compare/v1.1.0...v1.1.1
|
|
360
|
-
[1.1.0]: https://github.com/schorts99/shared-kernel/compare/v1.0.5...v1.1.0
|
|
361
|
-
[1.0.5]: https://github.com/schorts99/shared-kernel/compare/v1.0.4...v0.0.5
|
|
362
|
-
[1.0.4]: https://github.com/schorts99/shared-kernel/compare/v1.0.3...v0.0.4
|
|
363
|
-
[1.0.3]: https://github.com/schorts99/shared-kernel/releases/tag/v1.0.3
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { expectTypeOf } from "expect-type";
|
|
2
|
-
|
|
3
|
-
import { AuthProvider } from "../../src/auth";
|
|
4
|
-
import { Entity } from "../../src/entities";
|
|
5
|
-
import { UUIDValue } from "../../src/value-objects";
|
|
6
|
-
|
|
7
|
-
type Model = {
|
|
8
|
-
id: string;
|
|
9
|
-
name: string;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
class IDValue extends UUIDValue {
|
|
13
|
-
attributeName = "ID";
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
class TestUser extends Entity<IDValue, Model> {
|
|
17
|
-
toPrimitives(): Model {
|
|
18
|
-
return {
|
|
19
|
-
id: this.id.toString(),
|
|
20
|
-
name: "test",
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
describe('AuthProvider', () => {
|
|
26
|
-
it('should declare an "authenticate" method', () => {
|
|
27
|
-
expectTypeOf<AuthProvider<TestUser>['authenticate']>().toBeFunction();
|
|
28
|
-
expectTypeOf<AuthProvider<TestUser>['authenticate']>().returns.toEqualTypeOf<Promise<void>>();
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('should declare a "logout" method', () => {
|
|
32
|
-
expectTypeOf<AuthProvider<TestUser>['logout']>().toBeFunction();
|
|
33
|
-
expectTypeOf<AuthProvider<TestUser >['logout']>().returns.toEqualTypeOf<Promise<void>>();
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('should declare a "isAuthenticated" method', () => {
|
|
37
|
-
expectTypeOf<AuthProvider<TestUser>['isAuthenticated']>().toBeFunction();
|
|
38
|
-
expectTypeOf<AuthProvider<TestUser>['isAuthenticated']>().returns.toEqualTypeOf<Promise<boolean>>();
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('should declare a "currentUser" method', () => {
|
|
42
|
-
expectTypeOf<AuthProvider<TestUser>['currentUser']>().toBeFunction();
|
|
43
|
-
expectTypeOf<AuthProvider<TestUser>['currentUser']>().returns.toEqualTypeOf<Promise<TestUser | null>>();
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('should declare a "onAuthChange" method', () => {
|
|
47
|
-
expectTypeOf<AuthProvider<TestUser>['onAuthChange']>().toBeFunction();
|
|
48
|
-
expectTypeOf<AuthProvider<TestUser>['onAuthChange']>().returns.toEqualTypeOf<() => void>();
|
|
49
|
-
});
|
|
50
|
-
});
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { RequireAuth, NotAuthenticated } from '../../src/auth';
|
|
2
|
-
|
|
3
|
-
class FakeAuthProvider {
|
|
4
|
-
constructor(private authenticated: boolean) {}
|
|
5
|
-
async isAuthenticated() {
|
|
6
|
-
return this.authenticated;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
class TestService {
|
|
11
|
-
authProvider: FakeAuthProvider;
|
|
12
|
-
|
|
13
|
-
constructor(authenticated: boolean) {
|
|
14
|
-
this.authProvider = new FakeAuthProvider(authenticated);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
async securedMethod(): Promise<string> {
|
|
18
|
-
return 'should not reach';
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
describe('RequireAuth decorator (manual application)', () => {
|
|
23
|
-
it('should throw NotAuthenticated when not authenticated and no onFail', async () => {
|
|
24
|
-
const service = new TestService(false);
|
|
25
|
-
const originalMethod = service.securedMethod;
|
|
26
|
-
const decorated = RequireAuth()(originalMethod, {
|
|
27
|
-
kind: 'method',
|
|
28
|
-
name: 'securedMethod',
|
|
29
|
-
access: { has: () => true, get: () => originalMethod },
|
|
30
|
-
static: false,
|
|
31
|
-
private: false,
|
|
32
|
-
addInitializer: () => {},
|
|
33
|
-
metadata: {
|
|
34
|
-
get: () => undefined,
|
|
35
|
-
set: () => {},
|
|
36
|
-
},
|
|
37
|
-
});
|
|
38
|
-
const wrappedMethod = typeof decorated === 'function' ? decorated : decorated?.value;
|
|
39
|
-
service.securedMethod = wrappedMethod.bind(service);
|
|
40
|
-
|
|
41
|
-
await expect(service.securedMethod()).rejects.toThrow(NotAuthenticated);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('should return fallback value when not authenticated and onFail is provided', async () => {
|
|
45
|
-
const service = new TestService(false);
|
|
46
|
-
const fallback = () => 'fallback';
|
|
47
|
-
const originalMethod = service.securedMethod;
|
|
48
|
-
const decorated = RequireAuth(fallback)(originalMethod, {
|
|
49
|
-
kind: 'method',
|
|
50
|
-
name: 'securedMethod',
|
|
51
|
-
access: { has: () => true, get: () => originalMethod },
|
|
52
|
-
static: false,
|
|
53
|
-
private: false,
|
|
54
|
-
addInitializer: () => {},
|
|
55
|
-
metadata: {
|
|
56
|
-
get: () => undefined,
|
|
57
|
-
set: () => {},
|
|
58
|
-
},
|
|
59
|
-
});
|
|
60
|
-
const wrappedMethod = typeof decorated === 'function' ? decorated : decorated?.value;
|
|
61
|
-
service.securedMethod = wrappedMethod.bind(service);
|
|
62
|
-
const result = await service.securedMethod();
|
|
63
|
-
|
|
64
|
-
expect(result).toBe('fallback');
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('should call original method when authenticated', async () => {
|
|
68
|
-
const service = new TestService(true);
|
|
69
|
-
const originalMethod = service.securedMethod;
|
|
70
|
-
const decorated = RequireAuth()(originalMethod, {
|
|
71
|
-
kind: 'method',
|
|
72
|
-
name: 'securedMethod',
|
|
73
|
-
access: { has: () => true, get: () => originalMethod },
|
|
74
|
-
static: false,
|
|
75
|
-
private: false,
|
|
76
|
-
addInitializer: () => {},
|
|
77
|
-
metadata: {
|
|
78
|
-
get: () => undefined,
|
|
79
|
-
set: () => {},
|
|
80
|
-
},
|
|
81
|
-
});
|
|
82
|
-
const wrappedMethod = typeof decorated === 'function' ? decorated : decorated?.value;
|
|
83
|
-
service.securedMethod = wrappedMethod.bind(service);
|
|
84
|
-
const result = await service.securedMethod();
|
|
85
|
-
|
|
86
|
-
expect(result).toBe('should not reach');
|
|
87
|
-
});
|
|
88
|
-
});
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import { expectTypeOf } from "expect-type";
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
Criteria,
|
|
5
|
-
FilterCriterion,
|
|
6
|
-
Order,
|
|
7
|
-
Operator,
|
|
8
|
-
Direction,
|
|
9
|
-
PaginationNotValid,
|
|
10
|
-
OffsetNotValid,
|
|
11
|
-
LimitNotValid,
|
|
12
|
-
} from "../../src/criteria";
|
|
13
|
-
|
|
14
|
-
describe('Criteria', () => {
|
|
15
|
-
describe('filters', () => {
|
|
16
|
-
it('should be defined', () => {
|
|
17
|
-
expectTypeOf<Criteria>().toHaveProperty("filters");
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('should be of type Record<string, FilterCriterion>', () => {
|
|
21
|
-
expectTypeOf<Criteria["filters"]>().toEqualTypeOf<Record<string, FilterCriterion>>();
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('should be empty', () => {
|
|
25
|
-
const criteria = new Criteria();
|
|
26
|
-
const filters = criteria.filters;
|
|
27
|
-
const filterKeys = Object.keys(filters);
|
|
28
|
-
|
|
29
|
-
expect(filterKeys).toHaveLength(0);
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
describe('orders', () => {
|
|
34
|
-
it('should be defined', () => {
|
|
35
|
-
expectTypeOf<Criteria>().toHaveProperty("orders");
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('should be of type Array<Order>', () => {
|
|
39
|
-
expectTypeOf<Criteria["orders"]>().toEqualTypeOf<Array<Order>>();
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('should be empty', () => {
|
|
43
|
-
const criteria = new Criteria();
|
|
44
|
-
const orders = criteria.orders;
|
|
45
|
-
|
|
46
|
-
expect(orders).toHaveLength(0);
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it('should have a "limit" property of type number or undefined', () => {
|
|
51
|
-
expectTypeOf<Criteria>().toHaveProperty("limit");
|
|
52
|
-
expectTypeOf<Criteria["limit"]>().toEqualTypeOf<number | undefined>();
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('should have a "offset" property of type number or undefined', () => {
|
|
56
|
-
expectTypeOf<Criteria>().toHaveProperty("offset");
|
|
57
|
-
expectTypeOf<Criteria["offset"]>().toEqualTypeOf<number | undefined>();
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
describe('#where', () => {
|
|
61
|
-
it('should receive field, operator and value', () => {
|
|
62
|
-
expectTypeOf<Criteria["where"]>().parameters.toEqualTypeOf<[string, Operator, any]>();
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('should return the same instance', () => {
|
|
66
|
-
const criteria = new Criteria();
|
|
67
|
-
const result = criteria.where('field', 'EQUAL', 'value');
|
|
68
|
-
|
|
69
|
-
expect(result).toEqual(criteria);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it('should add the filter to the "filters" property', () => {
|
|
73
|
-
const criteria = new Criteria();
|
|
74
|
-
const result = criteria.where('field', 'EQUAL', 'value');
|
|
75
|
-
const filters = result.filters;
|
|
76
|
-
const expectedFilters = { field: { value: "value", operator: "EQUAL" } };
|
|
77
|
-
|
|
78
|
-
expect(filters["field"]).toBeDefined();
|
|
79
|
-
expect(filters).toEqual(expectedFilters);
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
describe('#orderBy', () => {
|
|
84
|
-
it('should receive field and direction', () => {
|
|
85
|
-
expectTypeOf<Criteria["orderBy"]>().parameters.toEqualTypeOf<[string, Direction?]>();
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
it('should return the same instance', () => {
|
|
89
|
-
const criteria = new Criteria();
|
|
90
|
-
const result = criteria.orderBy('field', 'DESC');
|
|
91
|
-
|
|
92
|
-
expect(result).toEqual(criteria);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it('should add the order to the "orders" property', () => {
|
|
96
|
-
const criteria = new Criteria();
|
|
97
|
-
const result = criteria.orderBy("field", "DESC");
|
|
98
|
-
const orders = result.orders;
|
|
99
|
-
const expectedOrders = [{ field: "field", direction: "DESC" }];
|
|
100
|
-
|
|
101
|
-
expect(orders).toHaveLength(1);
|
|
102
|
-
expect(orders).toEqual(expectedOrders);
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
describe('#limitResults', () => {
|
|
107
|
-
it('should receive a number', () => {
|
|
108
|
-
expectTypeOf<Criteria["limitResults"]>().parameters.toEqualTypeOf<[number]>();
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it('should return the same instance', () => {
|
|
112
|
-
const criteria = new Criteria();
|
|
113
|
-
const result = criteria.limitResults(1);
|
|
114
|
-
|
|
115
|
-
expect(result).toEqual(criteria);
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
it('should assign the value to the "limit" property', () => {
|
|
119
|
-
const criteria = new Criteria();
|
|
120
|
-
const limit = 1;
|
|
121
|
-
const result = criteria.limitResults(limit);
|
|
122
|
-
|
|
123
|
-
expect(result.limit).toEqual(limit);
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
it('should throw an LimitNotValid exception if value is less than 1', () => {
|
|
127
|
-
const criteria = new Criteria();
|
|
128
|
-
|
|
129
|
-
expect(() => criteria.limitResults(0)).toThrow(LimitNotValid);
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
describe('#offsetResults', () => {
|
|
134
|
-
it('should receive a number', () => {
|
|
135
|
-
expectTypeOf<Criteria["offsetResults"]>().parameters.toEqualTypeOf<[number]>();
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
it('should return the same instance', () => {
|
|
139
|
-
const criteria = new Criteria();
|
|
140
|
-
const result = criteria.offsetResults(1);
|
|
141
|
-
|
|
142
|
-
expect(result).toEqual(criteria);
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
it('should assign the value to the "offset" property', () => {
|
|
146
|
-
const criteria = new Criteria();
|
|
147
|
-
const offset = 1;
|
|
148
|
-
const result = criteria.offsetResults(offset);
|
|
149
|
-
|
|
150
|
-
expect(result.offset).toEqual(offset);
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
it('should throw an OffsetNotValid exception if value is less than 1', () => {
|
|
154
|
-
const criteria = new Criteria();
|
|
155
|
-
|
|
156
|
-
expect(() => criteria.offsetResults(0)).toThrow(OffsetNotValid);
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
});
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { expectTypeOf } from "expect-type";
|
|
2
|
-
|
|
3
|
-
import { Direction } from "../../src/criteria";
|
|
4
|
-
|
|
5
|
-
type ExpectedDirection = "ASC" | "DESC";
|
|
6
|
-
|
|
7
|
-
describe('Direction', () => {
|
|
8
|
-
it('should match the expected type', () => {
|
|
9
|
-
expectTypeOf<Direction>().toEqualTypeOf<ExpectedDirection>();
|
|
10
|
-
});
|
|
11
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { expectTypeOf } from "expect-type";
|
|
2
|
-
|
|
3
|
-
import { FilterCriterion, Operator } from "../../src/criteria";
|
|
4
|
-
|
|
5
|
-
type ExpectedFilterCriterion = {
|
|
6
|
-
value: any;
|
|
7
|
-
operator: Operator;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
describe('FilterCriterion', () => {
|
|
11
|
-
it('should match the expected type', () => {
|
|
12
|
-
expectTypeOf<FilterCriterion>().toEqualTypeOf<ExpectedFilterCriterion>();
|
|
13
|
-
});
|
|
14
|
-
});
|
|
15
|
-
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { expectTypeOf } from "expect-type";
|
|
2
|
-
|
|
3
|
-
import { Operator } from "../../src/criteria";
|
|
4
|
-
|
|
5
|
-
type ExpectedOperator =
|
|
6
|
-
| "EQUAL"
|
|
7
|
-
| "GREATER_THAN"
|
|
8
|
-
| "LESS_THAN"
|
|
9
|
-
| "GREATER_THAN_OR_EQUAL"
|
|
10
|
-
| "LESS_THAN_OR_EQUAL"
|
|
11
|
-
| "NOT_EQUAL"
|
|
12
|
-
| "IN"
|
|
13
|
-
| "NOT_IN"
|
|
14
|
-
| "LIKE"
|
|
15
|
-
| "BETWEEN"
|
|
16
|
-
| "GEO_RADIUS";
|
|
17
|
-
|
|
18
|
-
describe('Operator', () => {
|
|
19
|
-
it('should match the expected type', () => {
|
|
20
|
-
expectTypeOf<Operator>().toEqualTypeOf<ExpectedOperator>();
|
|
21
|
-
});
|
|
22
|
-
});
|