@s-hirano-ist/s-core 1.2.0 → 1.3.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.
- package/dist/articles/entities/article-entity.d.ts +342 -11
- package/dist/articles/entities/article-entity.d.ts.map +1 -1
- package/dist/articles/entities/article-entity.js +295 -9
- package/dist/articles/entities/article-entity.js.map +1 -1
- package/dist/articles/events/article-created-event.d.ts +36 -0
- package/dist/articles/events/article-created-event.d.ts.map +1 -1
- package/dist/articles/events/article-created-event.js +36 -0
- package/dist/articles/events/article-created-event.js.map +1 -1
- package/dist/articles/events/article-deleted-event.d.ts +30 -0
- package/dist/articles/events/article-deleted-event.d.ts.map +1 -1
- package/dist/articles/events/article-deleted-event.js +30 -0
- package/dist/articles/events/article-deleted-event.js.map +1 -1
- package/dist/articles/index.d.ts +33 -0
- package/dist/articles/index.d.ts.map +1 -1
- package/dist/articles/index.js +33 -0
- package/dist/articles/index.js.map +1 -1
- package/dist/articles/repositories/articles-command-repository.interface.d.ts +37 -0
- package/dist/articles/repositories/articles-command-repository.interface.d.ts.map +1 -1
- package/dist/articles/repositories/articles-query-repository.interface.d.ts +53 -0
- package/dist/articles/repositories/articles-query-repository.interface.d.ts.map +1 -1
- package/dist/articles/repositories/category-query-repository.interface.d.ts +29 -0
- package/dist/articles/repositories/category-query-repository.interface.d.ts.map +1 -1
- package/dist/articles/services/articles-domain-service.d.ts +40 -0
- package/dist/articles/services/articles-domain-service.d.ts.map +1 -1
- package/dist/articles/services/articles-domain-service.js +50 -0
- package/dist/articles/services/articles-domain-service.js.map +1 -1
- package/dist/articles/types/cache-strategy.d.ts +19 -0
- package/dist/articles/types/cache-strategy.d.ts.map +1 -1
- package/dist/articles/types/query-params.d.ts +83 -5
- package/dist/articles/types/query-params.d.ts.map +1 -1
- package/dist/articles/types/sort-order.d.ts +12 -0
- package/dist/articles/types/sort-order.d.ts.map +1 -1
- package/dist/books/entities/books-entity.d.ts +348 -13
- package/dist/books/entities/books-entity.d.ts.map +1 -1
- package/dist/books/entities/books-entity.js +296 -11
- package/dist/books/entities/books-entity.js.map +1 -1
- package/dist/books/events/book-created-event.d.ts +32 -0
- package/dist/books/events/book-created-event.d.ts.map +1 -1
- package/dist/books/events/book-created-event.js +32 -0
- package/dist/books/events/book-created-event.js.map +1 -1
- package/dist/books/events/book-deleted-event.d.ts +30 -0
- package/dist/books/events/book-deleted-event.d.ts.map +1 -1
- package/dist/books/events/book-deleted-event.js +30 -0
- package/dist/books/events/book-deleted-event.js.map +1 -1
- package/dist/books/index.d.ts +33 -0
- package/dist/books/index.d.ts.map +1 -1
- package/dist/books/index.js +33 -0
- package/dist/books/index.js.map +1 -1
- package/dist/books/repositories/books-command-repository.interface.d.ts +45 -0
- package/dist/books/repositories/books-command-repository.interface.d.ts.map +1 -1
- package/dist/books/repositories/books-query-repository.interface.d.ts +53 -0
- package/dist/books/repositories/books-query-repository.interface.d.ts.map +1 -1
- package/dist/books/services/books-domain-service.d.ts +40 -0
- package/dist/books/services/books-domain-service.d.ts.map +1 -1
- package/dist/books/services/books-domain-service.js +50 -0
- package/dist/books/services/books-domain-service.js.map +1 -1
- package/dist/books/types/cache-strategy.d.ts +19 -0
- package/dist/books/types/cache-strategy.d.ts.map +1 -1
- package/dist/books/types/query-params.d.ts +44 -3
- package/dist/books/types/query-params.d.ts.map +1 -1
- package/dist/books/types/sort-order.d.ts +12 -0
- package/dist/books/types/sort-order.d.ts.map +1 -1
- package/dist/common/entities/common-entity.d.ts +282 -2
- package/dist/common/entities/common-entity.d.ts.map +1 -1
- package/dist/common/entities/common-entity.js +235 -2
- package/dist/common/entities/common-entity.js.map +1 -1
- package/dist/common/events/base-domain-event.d.ts +32 -0
- package/dist/common/events/base-domain-event.d.ts.map +1 -1
- package/dist/common/events/base-domain-event.js +32 -0
- package/dist/common/events/base-domain-event.js.map +1 -1
- package/dist/common/events/domain-event.interface.d.ts +54 -0
- package/dist/common/events/domain-event.interface.d.ts.map +1 -1
- package/dist/common/events/system-error-event.d.ts +36 -0
- package/dist/common/events/system-error-event.d.ts.map +1 -1
- package/dist/common/events/system-error-event.js +36 -0
- package/dist/common/events/system-error-event.js.map +1 -1
- package/dist/common/events/system-warning-event.d.ts +35 -0
- package/dist/common/events/system-warning-event.d.ts.map +1 -1
- package/dist/common/events/system-warning-event.js +35 -0
- package/dist/common/events/system-warning-event.js.map +1 -1
- package/dist/common/index.d.ts +23 -0
- package/dist/common/index.d.ts.map +1 -1
- package/dist/common/index.js +23 -0
- package/dist/common/index.js.map +1 -1
- package/dist/common/services/entity-factory.d.ts +27 -0
- package/dist/common/services/entity-factory.d.ts.map +1 -1
- package/dist/common/services/entity-factory.js +27 -0
- package/dist/common/services/entity-factory.js.map +1 -1
- package/dist/common/services/id-generator.d.ts +32 -0
- package/dist/common/services/id-generator.d.ts.map +1 -1
- package/dist/common/services/id-generator.js +32 -0
- package/dist/common/services/id-generator.js.map +1 -1
- package/dist/errors/error-classes.d.ts +83 -0
- package/dist/errors/error-classes.d.ts.map +1 -1
- package/dist/errors/error-classes.js +83 -0
- package/dist/errors/error-classes.js.map +1 -1
- package/dist/errors/index.d.ts +29 -0
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +29 -0
- package/dist/errors/index.js.map +1 -1
- package/dist/images/entities/image-entity.d.ts +373 -4
- package/dist/images/entities/image-entity.d.ts.map +1 -1
- package/dist/images/entities/image-entity.js +320 -3
- package/dist/images/entities/image-entity.js.map +1 -1
- package/dist/images/events/image-created-event.d.ts +30 -0
- package/dist/images/events/image-created-event.d.ts.map +1 -1
- package/dist/images/events/image-created-event.js +30 -0
- package/dist/images/events/image-created-event.js.map +1 -1
- package/dist/images/events/image-deleted-event.d.ts +30 -0
- package/dist/images/events/image-deleted-event.d.ts.map +1 -1
- package/dist/images/events/image-deleted-event.js +30 -0
- package/dist/images/events/image-deleted-event.js.map +1 -1
- package/dist/images/index.d.ts +35 -0
- package/dist/images/index.d.ts.map +1 -1
- package/dist/images/index.js +35 -0
- package/dist/images/index.js.map +1 -1
- package/dist/images/repositories/images-command-repository.interface.d.ts +43 -0
- package/dist/images/repositories/images-command-repository.interface.d.ts.map +1 -1
- package/dist/images/repositories/images-query-repository.interface.d.ts +59 -0
- package/dist/images/repositories/images-query-repository.interface.d.ts.map +1 -1
- package/dist/images/services/images-domain-service.d.ts +40 -0
- package/dist/images/services/images-domain-service.d.ts.map +1 -1
- package/dist/images/services/images-domain-service.js +50 -0
- package/dist/images/services/images-domain-service.js.map +1 -1
- package/dist/images/types/cache-strategy.d.ts +19 -0
- package/dist/images/types/cache-strategy.d.ts.map +1 -1
- package/dist/images/types/query-params.d.ts +44 -3
- package/dist/images/types/query-params.d.ts.map +1 -1
- package/dist/images/types/sort-order.d.ts +12 -0
- package/dist/images/types/sort-order.d.ts.map +1 -1
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -1
- package/dist/notes/entities/note-entity.d.ts +212 -6
- package/dist/notes/entities/note-entity.d.ts.map +1 -1
- package/dist/notes/entities/note-entity.js +182 -4
- package/dist/notes/entities/note-entity.js.map +1 -1
- package/dist/notes/events/note-created-event.d.ts +32 -0
- package/dist/notes/events/note-created-event.d.ts.map +1 -1
- package/dist/notes/events/note-created-event.js +32 -0
- package/dist/notes/events/note-created-event.js.map +1 -1
- package/dist/notes/events/note-deleted-event.d.ts +30 -0
- package/dist/notes/events/note-deleted-event.d.ts.map +1 -1
- package/dist/notes/events/note-deleted-event.js +30 -0
- package/dist/notes/events/note-deleted-event.js.map +1 -1
- package/dist/notes/index.d.ts +32 -0
- package/dist/notes/index.d.ts.map +1 -1
- package/dist/notes/index.js +32 -0
- package/dist/notes/index.js.map +1 -1
- package/dist/notes/repositories/notes-command-repository.interface.d.ts +37 -0
- package/dist/notes/repositories/notes-command-repository.interface.d.ts.map +1 -1
- package/dist/notes/repositories/notes-query-repository.interface.d.ts +53 -0
- package/dist/notes/repositories/notes-query-repository.interface.d.ts.map +1 -1
- package/dist/notes/services/notes-domain-service.d.ts +40 -0
- package/dist/notes/services/notes-domain-service.d.ts.map +1 -1
- package/dist/notes/services/notes-domain-service.js +50 -0
- package/dist/notes/services/notes-domain-service.js.map +1 -1
- package/dist/notes/types/cache-strategy.d.ts +19 -0
- package/dist/notes/types/cache-strategy.d.ts.map +1 -1
- package/dist/notes/types/query-params.d.ts +44 -3
- package/dist/notes/types/query-params.d.ts.map +1 -1
- package/dist/notes/types/sort-order.d.ts +12 -0
- package/dist/notes/types/sort-order.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -1,37 +1,270 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { idGenerator } from "../services/id-generator";
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Zod schema for validating UUIDv7 identifiers.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* UUIDv7 is time-ordered, making it suitable for database primary keys.
|
|
8
|
+
* Auto-generates a new UUIDv7 if no value is provided.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const id = Id.parse(undefined); // Auto-generates UUIDv7
|
|
13
|
+
* const id2 = Id.parse("01912c9a-5e8a-7b5c-8a1b-2c3d4e5f6a7b");
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @see {@link makeId} for factory function
|
|
17
|
+
*/
|
|
4
18
|
export const Id = z
|
|
5
19
|
.uuid({ version: "v7" })
|
|
6
20
|
.default(() => idGenerator.uuidv7())
|
|
7
21
|
.brand();
|
|
22
|
+
/**
|
|
23
|
+
* Creates a validated Id from an optional string.
|
|
24
|
+
*
|
|
25
|
+
* @param id - Optional UUIDv7 string. If not provided, generates a new one.
|
|
26
|
+
* @returns A branded Id value
|
|
27
|
+
* @throws {ZodError} When the provided string is not a valid UUIDv7
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* const newId = makeId(); // Auto-generate
|
|
32
|
+
* const existingId = makeId("01912c9a-5e8a-7b5c-8a1b-2c3d4e5f6a7b");
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
8
35
|
export const makeId = (id) => {
|
|
9
36
|
if (!id)
|
|
10
37
|
return Id.parse(idGenerator.uuidv7());
|
|
11
38
|
return Id.parse(id);
|
|
12
39
|
};
|
|
40
|
+
/**
|
|
41
|
+
* Zod schema for validating user identifiers.
|
|
42
|
+
*
|
|
43
|
+
* @remarks
|
|
44
|
+
* Validates that the user ID is a non-empty string.
|
|
45
|
+
* Used for multi-tenant data isolation across all domains.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* const userId = UserId.parse("auth0|123456789");
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @see {@link makeUserId} for factory function
|
|
53
|
+
*/
|
|
13
54
|
export const UserId = z.string().min(1, "required").brand();
|
|
55
|
+
/**
|
|
56
|
+
* Creates a validated UserId from a string.
|
|
57
|
+
*
|
|
58
|
+
* @param v - The user ID string (typically from Auth0)
|
|
59
|
+
* @returns A branded UserId value
|
|
60
|
+
* @throws {ZodError} When the string is empty
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* const userId = makeUserId("auth0|123456789");
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
14
67
|
export const makeUserId = (v) => UserId.parse(v);
|
|
68
|
+
/**
|
|
69
|
+
* Zod schema for validating creation timestamps.
|
|
70
|
+
*
|
|
71
|
+
* @remarks
|
|
72
|
+
* Validates that the value is a valid Date object.
|
|
73
|
+
* Used to track when entities are created.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* const timestamp = CreatedAt.parse(new Date());
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* @see {@link makeCreatedAt} for factory function
|
|
81
|
+
*/
|
|
15
82
|
export const CreatedAt = z.date().brand();
|
|
83
|
+
/**
|
|
84
|
+
* Creates a validated CreatedAt timestamp.
|
|
85
|
+
*
|
|
86
|
+
* @param createdAt - Optional Date. If not provided, uses current time.
|
|
87
|
+
* @returns A branded CreatedAt value
|
|
88
|
+
* @throws {ZodError} When the value is not a valid Date
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* const now = makeCreatedAt(); // Current time
|
|
93
|
+
* const specific = makeCreatedAt(new Date("2024-01-01"));
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
16
96
|
export const makeCreatedAt = (createdAt) => {
|
|
17
97
|
if (!createdAt)
|
|
18
98
|
return CreatedAt.parse(new Date());
|
|
19
99
|
return CreatedAt.parse(createdAt);
|
|
20
100
|
};
|
|
101
|
+
/**
|
|
102
|
+
* Zod schema for validating update timestamps.
|
|
103
|
+
*
|
|
104
|
+
* @remarks
|
|
105
|
+
* Validates that the value is a valid Date object.
|
|
106
|
+
* Used to track when entities are last modified.
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```typescript
|
|
110
|
+
* const timestamp = UpdatedAt.parse(new Date());
|
|
111
|
+
* ```
|
|
112
|
+
*
|
|
113
|
+
* @see {@link makeUpdatedAt} for factory function
|
|
114
|
+
*/
|
|
115
|
+
export const UpdatedAt = z.date().brand();
|
|
116
|
+
/**
|
|
117
|
+
* Creates a validated UpdatedAt timestamp.
|
|
118
|
+
*
|
|
119
|
+
* @param updatedAt - Optional Date. If not provided, uses current time.
|
|
120
|
+
* @returns A branded UpdatedAt value
|
|
121
|
+
* @throws {ZodError} When the value is not a valid Date
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```typescript
|
|
125
|
+
* const now = makeUpdatedAt(); // Current time
|
|
126
|
+
* const specific = makeUpdatedAt(new Date("2024-01-01"));
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
export const makeUpdatedAt = (updatedAt) => {
|
|
130
|
+
if (!updatedAt)
|
|
131
|
+
return UpdatedAt.parse(new Date());
|
|
132
|
+
return UpdatedAt.parse(updatedAt);
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Zod schema for the UNEXPORTED status literal.
|
|
136
|
+
*
|
|
137
|
+
* @remarks
|
|
138
|
+
* Represents the initial state of all content entities.
|
|
139
|
+
* Content transitions from UNEXPORTED to EXPORTED when published.
|
|
140
|
+
*
|
|
141
|
+
* @see {@link ExportedStatus} for the exported state
|
|
142
|
+
* @see {@link Status} for the union type
|
|
143
|
+
*/
|
|
21
144
|
export const UnexportedStatus = z.literal("UNEXPORTED");
|
|
145
|
+
/**
|
|
146
|
+
* Creates an UnexportedStatus value.
|
|
147
|
+
*
|
|
148
|
+
* @returns The literal "UNEXPORTED" status
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* ```typescript
|
|
152
|
+
* const status = makeUnexportedStatus(); // "UNEXPORTED"
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
22
155
|
export const makeUnexportedStatus = () => UnexportedStatus.parse("UNEXPORTED");
|
|
156
|
+
/**
|
|
157
|
+
* Zod schema for the LAST_UPDATED status literal.
|
|
158
|
+
*
|
|
159
|
+
* @remarks
|
|
160
|
+
* Represents the intermediate state of content entities during batch processing.
|
|
161
|
+
* Content transitions from UNEXPORTED to LAST_UPDATED when marked for export,
|
|
162
|
+
* then from LAST_UPDATED to EXPORTED when finalized.
|
|
163
|
+
* Can be reverted back to UNEXPORTED if something goes wrong.
|
|
164
|
+
*
|
|
165
|
+
* @see {@link UnexportedStatus} for the initial state
|
|
166
|
+
* @see {@link ExportedStatus} for the final state
|
|
167
|
+
* @see {@link Status} for the union type
|
|
168
|
+
*/
|
|
169
|
+
export const LastUpdatedStatus = z.literal("LAST_UPDATED");
|
|
170
|
+
/**
|
|
171
|
+
* Creates a LastUpdatedStatus value.
|
|
172
|
+
*
|
|
173
|
+
* @returns The literal "LAST_UPDATED" status
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* ```typescript
|
|
177
|
+
* const status = makeLastUpdatedStatus(); // "LAST_UPDATED"
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
180
|
+
export const makeLastUpdatedStatus = () => LastUpdatedStatus.parse("LAST_UPDATED");
|
|
181
|
+
/**
|
|
182
|
+
* Zod schema for validating export timestamps.
|
|
183
|
+
*
|
|
184
|
+
* @remarks
|
|
185
|
+
* Validates that the value is a valid Date object.
|
|
186
|
+
* Used to track when entities are exported/published.
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* ```typescript
|
|
190
|
+
* const timestamp = ExportedAt.parse(new Date());
|
|
191
|
+
* ```
|
|
192
|
+
*
|
|
193
|
+
* @see {@link makeExportedAt} for factory function
|
|
194
|
+
*/
|
|
23
195
|
export const ExportedAt = z.date().brand();
|
|
196
|
+
/**
|
|
197
|
+
* Creates a validated ExportedAt timestamp.
|
|
198
|
+
*
|
|
199
|
+
* @param exportedAt - Optional Date. If not provided, uses current time.
|
|
200
|
+
* @returns A branded ExportedAt value
|
|
201
|
+
* @throws {ZodError} When the value is not a valid Date
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* ```typescript
|
|
205
|
+
* const now = makeExportedAt(); // Current time
|
|
206
|
+
* const specific = makeExportedAt(new Date("2024-01-01"));
|
|
207
|
+
* ```
|
|
208
|
+
*/
|
|
24
209
|
export const makeExportedAt = (exportedAt) => {
|
|
25
210
|
if (!exportedAt)
|
|
26
211
|
return ExportedAt.parse(new Date());
|
|
27
212
|
return ExportedAt.parse(exportedAt);
|
|
28
213
|
};
|
|
214
|
+
/**
|
|
215
|
+
* Zod schema for the EXPORTED status with timestamp.
|
|
216
|
+
*
|
|
217
|
+
* @remarks
|
|
218
|
+
* Represents the published state of content entities.
|
|
219
|
+
* Includes both the status literal and the export timestamp.
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* ```typescript
|
|
223
|
+
* const exported = ExportedStatus.parse({
|
|
224
|
+
* status: "EXPORTED",
|
|
225
|
+
* exportedAt: new Date()
|
|
226
|
+
* });
|
|
227
|
+
* ```
|
|
228
|
+
*
|
|
229
|
+
* @see {@link UnexportedStatus} for the initial state
|
|
230
|
+
* @see {@link makeExportedStatus} for factory function
|
|
231
|
+
*/
|
|
29
232
|
export const ExportedStatus = z.object({
|
|
30
233
|
status: z.literal("EXPORTED"),
|
|
31
234
|
exportedAt: ExportedAt,
|
|
32
235
|
});
|
|
236
|
+
/**
|
|
237
|
+
* Creates an ExportedStatus with current timestamp.
|
|
238
|
+
*
|
|
239
|
+
* @returns An ExportedStatus object with status "EXPORTED" and current time
|
|
240
|
+
*
|
|
241
|
+
* @example
|
|
242
|
+
* ```typescript
|
|
243
|
+
* const status = makeExportedStatus();
|
|
244
|
+
* // { status: "EXPORTED", exportedAt: Date }
|
|
245
|
+
* ```
|
|
246
|
+
*/
|
|
33
247
|
export const makeExportedStatus = () => ExportedStatus.parse({ status: "EXPORTED", exportedAt: new Date() });
|
|
34
|
-
|
|
248
|
+
/**
|
|
249
|
+
* Creates a Status value from a string.
|
|
250
|
+
*
|
|
251
|
+
* @param status - The status string ("UNEXPORTED", "LAST_UPDATED", or "EXPORTED")
|
|
252
|
+
* @returns The status value
|
|
253
|
+
*
|
|
254
|
+
* @deprecated This is for legacy compatibility. Use {@link makeUnexportedStatus},
|
|
255
|
+
* {@link makeLastUpdatedStatus}, or {@link makeExportedStatus} instead.
|
|
256
|
+
*
|
|
257
|
+
* @example
|
|
258
|
+
* ```typescript
|
|
259
|
+
* // Prefer these:
|
|
260
|
+
* const unexported = makeUnexportedStatus();
|
|
261
|
+
* const lastUpdated = makeLastUpdatedStatus();
|
|
262
|
+
* const exported = makeExportedStatus();
|
|
263
|
+
*
|
|
264
|
+
* // Instead of:
|
|
265
|
+
* const status = makeStatus("UNEXPORTED");
|
|
266
|
+
* ```
|
|
267
|
+
*/
|
|
35
268
|
export const makeStatus = (status) => {
|
|
36
269
|
return status;
|
|
37
270
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common-entity.js","sourceRoot":"","sources":["../../../common/entities/common-entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD
|
|
1
|
+
{"version":3,"file":"common-entity.js","sourceRoot":"","sources":["../../../common/entities/common-entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;KACjB,IAAI,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;KACvB,OAAO,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC;KACnC,KAAK,EAAQ,CAAC;AAUhB;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,EAAW,EAAM,EAAE;IACzC,IAAI,CAAC,EAAE;QAAE,OAAO,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC;IAC/C,OAAO,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AACrB,CAAC,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,KAAK,EAAY,CAAC;AAWtE;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAS,EAAU,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAEjE;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,EAAe,CAAC;AAOvD;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,SAAgB,EAAa,EAAE;IAC5D,IAAI,CAAC,SAAS;QAAE,OAAO,SAAS,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;IACnD,OAAO,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AACnC,CAAC,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,EAAe,CAAC;AAOvD;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,SAAgB,EAAa,EAAE;IAC5D,IAAI,CAAC,SAAS;QAAE,OAAO,SAAS,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;IACnD,OAAO,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AACnC,CAAC,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;AAOxD;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAqB,EAAE,CAC1D,gBAAgB,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;AAEtC;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;AAO3D;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAsB,EAAE,CAC5D,iBAAiB,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;AAEzC;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,EAAgB,CAAC;AAOzD;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,UAAiB,EAAc,EAAE;IAC/D,IAAI,CAAC,UAAU;QAAE,OAAO,UAAU,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;IACrD,OAAO,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;AACrC,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC;IAC7B,UAAU,EAAE,UAAU;CACtB,CAAC,CAAC;AAOH;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAmB,EAAE,CACtD,cAAc,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,IAAI,IAAI,EAAE,EAAE,CAAC,CAAC;AAsBtE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CACzB,MAAkD,EACzC,EAAE;IACX,OAAO,MAAgB,CAAC;AACzB,CAAC,CAAC"}
|
|
@@ -1,12 +1,44 @@
|
|
|
1
1
|
import type { DomainEvent } from "./domain-event.interface";
|
|
2
|
+
/**
|
|
3
|
+
* Abstract base class for all domain events.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Provides common functionality for domain events including automatic
|
|
7
|
+
* timestamp generation. Extend this class to create specific event types.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* class ArticleCreatedEvent extends BaseDomainEvent {
|
|
12
|
+
* constructor(data: { title: string; userId: string; caller: string }) {
|
|
13
|
+
* super(
|
|
14
|
+
* "article.created",
|
|
15
|
+
* { title: data.title },
|
|
16
|
+
* { caller: data.caller, userId: data.userId }
|
|
17
|
+
* );
|
|
18
|
+
* }
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @see {@link DomainEvent} for the interface
|
|
23
|
+
*/
|
|
2
24
|
export declare abstract class BaseDomainEvent implements DomainEvent {
|
|
25
|
+
/** The type of event (e.g., "article.created") */
|
|
3
26
|
readonly eventType: string;
|
|
27
|
+
/** Event-specific data */
|
|
4
28
|
readonly payload: Record<string, unknown>;
|
|
29
|
+
/** Contextual information about the event */
|
|
5
30
|
readonly metadata: {
|
|
6
31
|
timestamp: Date;
|
|
7
32
|
caller: string;
|
|
8
33
|
userId: string;
|
|
9
34
|
};
|
|
35
|
+
/**
|
|
36
|
+
* Creates a new domain event.
|
|
37
|
+
*
|
|
38
|
+
* @param eventType - The type identifier for the event
|
|
39
|
+
* @param payload - Event-specific data
|
|
40
|
+
* @param metadata - Contextual information (timestamp is auto-generated)
|
|
41
|
+
*/
|
|
10
42
|
constructor(eventType: string, payload: Record<string, unknown>, metadata: {
|
|
11
43
|
caller: string;
|
|
12
44
|
userId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-domain-event.d.ts","sourceRoot":"","sources":["../../../common/events/base-domain-event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAE5D,8BAAsB,eAAgB,YAAW,WAAW;IAC3D,SAAgB,SAAS,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"base-domain-event.d.ts","sourceRoot":"","sources":["../../../common/events/base-domain-event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,8BAAsB,eAAgB,YAAW,WAAW;IAC3D,kDAAkD;IAClD,SAAgB,SAAS,EAAE,MAAM,CAAC;IAElC,0BAA0B;IAC1B,SAAgB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEjD,6CAA6C;IAC7C,SAAgB,QAAQ,EAAE;QACzB,SAAS,EAAE,IAAI,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;KACf,CAAC;IAEF;;;;;;OAMG;gBAEF,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,QAAQ,EAAE;QACT,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;KACf;CASF"}
|
|
@@ -1,7 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Abstract base class for all domain events.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Provides common functionality for domain events including automatic
|
|
6
|
+
* timestamp generation. Extend this class to create specific event types.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* class ArticleCreatedEvent extends BaseDomainEvent {
|
|
11
|
+
* constructor(data: { title: string; userId: string; caller: string }) {
|
|
12
|
+
* super(
|
|
13
|
+
* "article.created",
|
|
14
|
+
* { title: data.title },
|
|
15
|
+
* { caller: data.caller, userId: data.userId }
|
|
16
|
+
* );
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @see {@link DomainEvent} for the interface
|
|
22
|
+
*/
|
|
1
23
|
export class BaseDomainEvent {
|
|
24
|
+
/** The type of event (e.g., "article.created") */
|
|
2
25
|
eventType;
|
|
26
|
+
/** Event-specific data */
|
|
3
27
|
payload;
|
|
28
|
+
/** Contextual information about the event */
|
|
4
29
|
metadata;
|
|
30
|
+
/**
|
|
31
|
+
* Creates a new domain event.
|
|
32
|
+
*
|
|
33
|
+
* @param eventType - The type identifier for the event
|
|
34
|
+
* @param payload - Event-specific data
|
|
35
|
+
* @param metadata - Contextual information (timestamp is auto-generated)
|
|
36
|
+
*/
|
|
5
37
|
constructor(eventType, payload, metadata) {
|
|
6
38
|
this.eventType = eventType;
|
|
7
39
|
this.payload = payload;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-domain-event.js","sourceRoot":"","sources":["../../../common/events/base-domain-event.ts"],"names":[],"mappings":"AAEA,MAAM,OAAgB,eAAe;
|
|
1
|
+
{"version":3,"file":"base-domain-event.js","sourceRoot":"","sources":["../../../common/events/base-domain-event.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAgB,eAAe;IACpC,kDAAkD;IAClC,SAAS,CAAS;IAElC,0BAA0B;IACV,OAAO,CAA0B;IAEjD,6CAA6C;IAC7B,QAAQ,CAItB;IAEF;;;;;;OAMG;IACH,YACC,SAAiB,EACjB,OAAgC,EAChC,QAGC;QAED,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG;YACf,GAAG,QAAQ;YACX,SAAS,EAAE,IAAI,IAAI,EAAE;SACrB,CAAC;IACH,CAAC;CACD"}
|
|
@@ -1,13 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base interface for all domain events.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Domain events represent significant occurrences within the domain.
|
|
6
|
+
* They are used for cross-cutting concerns like notifications, logging, and analytics.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const event: DomainEvent = {
|
|
11
|
+
* eventType: "article.created",
|
|
12
|
+
* payload: { title: "New Article", url: "https://example.com" },
|
|
13
|
+
* metadata: {
|
|
14
|
+
* timestamp: new Date(),
|
|
15
|
+
* caller: "addArticle",
|
|
16
|
+
* userId: "user-123"
|
|
17
|
+
* }
|
|
18
|
+
* };
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @see {@link BaseDomainEvent} for abstract base class
|
|
22
|
+
* @see {@link DomainEventHandler} for handling events
|
|
23
|
+
*/
|
|
1
24
|
export type DomainEvent = {
|
|
25
|
+
/** The type of event (e.g., "article.created", "book.deleted") */
|
|
2
26
|
eventType: string;
|
|
27
|
+
/** Event-specific data */
|
|
3
28
|
payload: Record<string, unknown>;
|
|
29
|
+
/** Contextual information about the event */
|
|
4
30
|
metadata: {
|
|
31
|
+
/** When the event occurred */
|
|
5
32
|
timestamp: Date;
|
|
33
|
+
/** The function/method that triggered the event */
|
|
6
34
|
caller: string;
|
|
35
|
+
/** The user who triggered the event */
|
|
7
36
|
userId: string;
|
|
8
37
|
};
|
|
9
38
|
};
|
|
39
|
+
/**
|
|
40
|
+
* Interface for handling domain events.
|
|
41
|
+
*
|
|
42
|
+
* @remarks
|
|
43
|
+
* Implement this interface to create event handlers for specific event types.
|
|
44
|
+
* Handlers are typically used for side effects like sending notifications.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* class ArticleCreatedHandler implements DomainEventHandler {
|
|
49
|
+
* async handle(event: DomainEvent): Promise<void> {
|
|
50
|
+
* if (event.eventType === "article.created") {
|
|
51
|
+
* await sendNotification(event.payload);
|
|
52
|
+
* }
|
|
53
|
+
* }
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* @see {@link DomainEvent} for the event structure
|
|
58
|
+
*/
|
|
10
59
|
export type DomainEventHandler = {
|
|
60
|
+
/**
|
|
61
|
+
* Handles a domain event.
|
|
62
|
+
*
|
|
63
|
+
* @param event - The domain event to handle
|
|
64
|
+
*/
|
|
11
65
|
handle(event: DomainEvent): Promise<void>;
|
|
12
66
|
};
|
|
13
67
|
//# sourceMappingURL=domain-event.interface.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domain-event.interface.d.ts","sourceRoot":"","sources":["../../../common/events/domain-event.interface.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,QAAQ,EAAE;QACT,SAAS,EAAE,IAAI,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;KACf,CAAC;CACF,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAChC,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1C,CAAC"}
|
|
1
|
+
{"version":3,"file":"domain-event.interface.d.ts","sourceRoot":"","sources":["../../../common/events/domain-event.interface.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,MAAM,WAAW,GAAG;IACzB,kEAAkE;IAClE,SAAS,EAAE,MAAM,CAAC;IAClB,0BAA0B;IAC1B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,6CAA6C;IAC7C,QAAQ,EAAE;QACT,8BAA8B;QAC9B,SAAS,EAAE,IAAI,CAAC;QAChB,mDAAmD;QACnD,MAAM,EAAE,MAAM,CAAC;QACf,uCAAuC;QACvC,MAAM,EAAE,MAAM,CAAC;KACf,CAAC;CACF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAChC;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1C,CAAC"}
|
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
import { BaseDomainEvent } from "./base-domain-event";
|
|
2
|
+
/**
|
|
3
|
+
* Domain event for system errors.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Used to track and notify about system-level errors.
|
|
7
|
+
* The shouldNotify flag controls whether external notifications (e.g., Pushover) are sent.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const event = new SystemErrorEvent({
|
|
12
|
+
* message: "Database connection failed",
|
|
13
|
+
* status: 500,
|
|
14
|
+
* caller: "connectDatabase",
|
|
15
|
+
* userId: "system",
|
|
16
|
+
* shouldNotify: true,
|
|
17
|
+
* extraData: { host: "localhost", port: 5432 }
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* // event.eventType === "system.error"
|
|
21
|
+
* await eventHandler.handle(event);
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @see {@link SystemWarningEvent} for non-critical issues
|
|
25
|
+
* @see {@link BaseDomainEvent} for base class
|
|
26
|
+
*/
|
|
2
27
|
export declare class SystemErrorEvent extends BaseDomainEvent {
|
|
28
|
+
/**
|
|
29
|
+
* Creates a new system error event.
|
|
30
|
+
*
|
|
31
|
+
* @param data - Error event data
|
|
32
|
+
* @param data.message - Human-readable error message
|
|
33
|
+
* @param data.status - HTTP status code representing the error severity
|
|
34
|
+
* @param data.caller - The function/method where the error occurred
|
|
35
|
+
* @param data.userId - The user affected (defaults to "system")
|
|
36
|
+
* @param data.extraData - Additional context about the error
|
|
37
|
+
* @param data.shouldNotify - Whether to send external notifications (defaults to false)
|
|
38
|
+
*/
|
|
3
39
|
constructor(data: {
|
|
4
40
|
message: string;
|
|
5
41
|
status: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system-error-event.d.ts","sourceRoot":"","sources":["../../../common/events/system-error-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,qBAAa,gBAAiB,SAAQ,eAAe;
|
|
1
|
+
{"version":3,"file":"system-error-event.d.ts","sourceRoot":"","sources":["../../../common/events/system-error-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,qBAAa,gBAAiB,SAAQ,eAAe;IACpD;;;;;;;;;;OAUG;gBACS,IAAI,EAAE;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,YAAY,CAAC,EAAE,OAAO,CAAC;KACvB;CAeD"}
|
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
import { BaseDomainEvent } from "./base-domain-event";
|
|
2
|
+
/**
|
|
3
|
+
* Domain event for system errors.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Used to track and notify about system-level errors.
|
|
7
|
+
* The shouldNotify flag controls whether external notifications (e.g., Pushover) are sent.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const event = new SystemErrorEvent({
|
|
12
|
+
* message: "Database connection failed",
|
|
13
|
+
* status: 500,
|
|
14
|
+
* caller: "connectDatabase",
|
|
15
|
+
* userId: "system",
|
|
16
|
+
* shouldNotify: true,
|
|
17
|
+
* extraData: { host: "localhost", port: 5432 }
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* // event.eventType === "system.error"
|
|
21
|
+
* await eventHandler.handle(event);
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @see {@link SystemWarningEvent} for non-critical issues
|
|
25
|
+
* @see {@link BaseDomainEvent} for base class
|
|
26
|
+
*/
|
|
2
27
|
export class SystemErrorEvent extends BaseDomainEvent {
|
|
28
|
+
/**
|
|
29
|
+
* Creates a new system error event.
|
|
30
|
+
*
|
|
31
|
+
* @param data - Error event data
|
|
32
|
+
* @param data.message - Human-readable error message
|
|
33
|
+
* @param data.status - HTTP status code representing the error severity
|
|
34
|
+
* @param data.caller - The function/method where the error occurred
|
|
35
|
+
* @param data.userId - The user affected (defaults to "system")
|
|
36
|
+
* @param data.extraData - Additional context about the error
|
|
37
|
+
* @param data.shouldNotify - Whether to send external notifications (defaults to false)
|
|
38
|
+
*/
|
|
3
39
|
constructor(data) {
|
|
4
40
|
super("system.error", {
|
|
5
41
|
message: data.message,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system-error-event.js","sourceRoot":"","sources":["../../../common/events/system-error-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,MAAM,OAAO,gBAAiB,SAAQ,eAAe;IACpD,YAAY,IAOX;QACA,KAAK,CACJ,cAAc,EACd;YACC,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,YAAY,EAAE,IAAI,CAAC,YAAY,IAAI,KAAK;SACxC,EACD;YACC,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,QAAQ;SAC/B,CACD,CAAC;IACH,CAAC;CACD"}
|
|
1
|
+
{"version":3,"file":"system-error-event.js","sourceRoot":"","sources":["../../../common/events/system-error-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,OAAO,gBAAiB,SAAQ,eAAe;IACpD;;;;;;;;;;OAUG;IACH,YAAY,IAOX;QACA,KAAK,CACJ,cAAc,EACd;YACC,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,YAAY,EAAE,IAAI,CAAC,YAAY,IAAI,KAAK;SACxC,EACD;YACC,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,QAAQ;SAC/B,CACD,CAAC;IACH,CAAC;CACD"}
|
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
import { BaseDomainEvent } from "./base-domain-event";
|
|
2
|
+
/**
|
|
3
|
+
* Domain event for system warnings.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Used to track non-critical issues that don't require immediate action.
|
|
7
|
+
* The shouldNotify flag controls whether external notifications are sent.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const event = new SystemWarningEvent({
|
|
12
|
+
* message: "Cache miss rate above threshold",
|
|
13
|
+
* status: 200,
|
|
14
|
+
* caller: "cacheService",
|
|
15
|
+
* shouldNotify: false,
|
|
16
|
+
* extraData: { missRate: 0.75 }
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* // event.eventType === "system.warning"
|
|
20
|
+
* await eventHandler.handle(event);
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @see {@link SystemErrorEvent} for critical errors
|
|
24
|
+
* @see {@link BaseDomainEvent} for base class
|
|
25
|
+
*/
|
|
2
26
|
export declare class SystemWarningEvent extends BaseDomainEvent {
|
|
27
|
+
/**
|
|
28
|
+
* Creates a new system warning event.
|
|
29
|
+
*
|
|
30
|
+
* @param data - Warning event data
|
|
31
|
+
* @param data.message - Human-readable warning message
|
|
32
|
+
* @param data.status - HTTP status code (typically 2xx for warnings)
|
|
33
|
+
* @param data.caller - The function/method where the warning occurred
|
|
34
|
+
* @param data.userId - The user affected (defaults to "system")
|
|
35
|
+
* @param data.extraData - Additional context about the warning
|
|
36
|
+
* @param data.shouldNotify - Whether to send external notifications (defaults to false)
|
|
37
|
+
*/
|
|
3
38
|
constructor(data: {
|
|
4
39
|
message: string;
|
|
5
40
|
status: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system-warning-event.d.ts","sourceRoot":"","sources":["../../../common/events/system-warning-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,qBAAa,kBAAmB,SAAQ,eAAe;
|
|
1
|
+
{"version":3,"file":"system-warning-event.d.ts","sourceRoot":"","sources":["../../../common/events/system-warning-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,kBAAmB,SAAQ,eAAe;IACtD;;;;;;;;;;OAUG;gBACS,IAAI,EAAE;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,YAAY,CAAC,EAAE,OAAO,CAAC;KACvB;CAeD"}
|
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
import { BaseDomainEvent } from "./base-domain-event";
|
|
2
|
+
/**
|
|
3
|
+
* Domain event for system warnings.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Used to track non-critical issues that don't require immediate action.
|
|
7
|
+
* The shouldNotify flag controls whether external notifications are sent.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const event = new SystemWarningEvent({
|
|
12
|
+
* message: "Cache miss rate above threshold",
|
|
13
|
+
* status: 200,
|
|
14
|
+
* caller: "cacheService",
|
|
15
|
+
* shouldNotify: false,
|
|
16
|
+
* extraData: { missRate: 0.75 }
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* // event.eventType === "system.warning"
|
|
20
|
+
* await eventHandler.handle(event);
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @see {@link SystemErrorEvent} for critical errors
|
|
24
|
+
* @see {@link BaseDomainEvent} for base class
|
|
25
|
+
*/
|
|
2
26
|
export class SystemWarningEvent extends BaseDomainEvent {
|
|
27
|
+
/**
|
|
28
|
+
* Creates a new system warning event.
|
|
29
|
+
*
|
|
30
|
+
* @param data - Warning event data
|
|
31
|
+
* @param data.message - Human-readable warning message
|
|
32
|
+
* @param data.status - HTTP status code (typically 2xx for warnings)
|
|
33
|
+
* @param data.caller - The function/method where the warning occurred
|
|
34
|
+
* @param data.userId - The user affected (defaults to "system")
|
|
35
|
+
* @param data.extraData - Additional context about the warning
|
|
36
|
+
* @param data.shouldNotify - Whether to send external notifications (defaults to false)
|
|
37
|
+
*/
|
|
3
38
|
constructor(data) {
|
|
4
39
|
super("system.warning", {
|
|
5
40
|
message: data.message,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system-warning-event.js","sourceRoot":"","sources":["../../../common/events/system-warning-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,MAAM,OAAO,kBAAmB,SAAQ,eAAe;IACtD,YAAY,IAOX;QACA,KAAK,CACJ,gBAAgB,EAChB;YACC,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,YAAY,EAAE,IAAI,CAAC,YAAY,IAAI,KAAK;SACxC,EACD;YACC,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,QAAQ;SAC/B,CACD,CAAC;IACH,CAAC;CACD"}
|
|
1
|
+
{"version":3,"file":"system-warning-event.js","sourceRoot":"","sources":["../../../common/events/system-warning-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,OAAO,kBAAmB,SAAQ,eAAe;IACtD;;;;;;;;;;OAUG;IACH,YAAY,IAOX;QACA,KAAK,CACJ,gBAAgB,EAChB;YACC,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,YAAY,EAAE,IAAI,CAAC,YAAY,IAAI,KAAK;SACxC,EACD;YACC,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,QAAQ;SAC/B,CACD,CAAC;IACH,CAAC;CACD"}
|
package/dist/common/index.d.ts
CHANGED
|
@@ -1,3 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
*
|
|
4
|
+
* Common utilities shared across all domains.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Provides foundational building blocks including:
|
|
8
|
+
*
|
|
9
|
+
* - **Entities** - Common value objects (Id, UserId, CreatedAt, Status)
|
|
10
|
+
* - **Events** - Domain event infrastructure (BaseDomainEvent, SystemEvents)
|
|
11
|
+
* - **Services** - Shared services (ID generation, entity factory)
|
|
12
|
+
* - **Types** - Common type definitions
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* import { makeId, makeUserId, makeCreatedAt, UnexportedStatus } from "@repo/core/common";
|
|
17
|
+
*
|
|
18
|
+
* const id = makeId();
|
|
19
|
+
* const userId = makeUserId("user-123");
|
|
20
|
+
* const createdAt = makeCreatedAt();
|
|
21
|
+
* const status = UnexportedStatus;
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
1
24
|
export * from "./entities/common-entity";
|
|
2
25
|
export * from "./events/base-domain-event";
|
|
3
26
|
export * from "./events/domain-event.interface";
|