@s-hirano-ist/s-core 1.2.0 → 1.3.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 (168) hide show
  1. package/dist/articles/entities/article-entity.d.ts +342 -11
  2. package/dist/articles/entities/article-entity.d.ts.map +1 -1
  3. package/dist/articles/entities/article-entity.js +295 -9
  4. package/dist/articles/entities/article-entity.js.map +1 -1
  5. package/dist/articles/events/article-created-event.d.ts +36 -0
  6. package/dist/articles/events/article-created-event.d.ts.map +1 -1
  7. package/dist/articles/events/article-created-event.js +36 -0
  8. package/dist/articles/events/article-created-event.js.map +1 -1
  9. package/dist/articles/events/article-deleted-event.d.ts +30 -0
  10. package/dist/articles/events/article-deleted-event.d.ts.map +1 -1
  11. package/dist/articles/events/article-deleted-event.js +30 -0
  12. package/dist/articles/events/article-deleted-event.js.map +1 -1
  13. package/dist/articles/index.d.ts +33 -0
  14. package/dist/articles/index.d.ts.map +1 -1
  15. package/dist/articles/index.js +33 -0
  16. package/dist/articles/index.js.map +1 -1
  17. package/dist/articles/repositories/articles-command-repository.interface.d.ts +37 -0
  18. package/dist/articles/repositories/articles-command-repository.interface.d.ts.map +1 -1
  19. package/dist/articles/repositories/articles-query-repository.interface.d.ts +53 -0
  20. package/dist/articles/repositories/articles-query-repository.interface.d.ts.map +1 -1
  21. package/dist/articles/repositories/category-query-repository.interface.d.ts +29 -0
  22. package/dist/articles/repositories/category-query-repository.interface.d.ts.map +1 -1
  23. package/dist/articles/services/articles-domain-service.d.ts +40 -0
  24. package/dist/articles/services/articles-domain-service.d.ts.map +1 -1
  25. package/dist/articles/services/articles-domain-service.js +50 -0
  26. package/dist/articles/services/articles-domain-service.js.map +1 -1
  27. package/dist/articles/types/cache-strategy.d.ts +19 -0
  28. package/dist/articles/types/cache-strategy.d.ts.map +1 -1
  29. package/dist/articles/types/query-params.d.ts +83 -5
  30. package/dist/articles/types/query-params.d.ts.map +1 -1
  31. package/dist/articles/types/sort-order.d.ts +12 -0
  32. package/dist/articles/types/sort-order.d.ts.map +1 -1
  33. package/dist/books/entities/books-entity.d.ts +348 -13
  34. package/dist/books/entities/books-entity.d.ts.map +1 -1
  35. package/dist/books/entities/books-entity.js +296 -11
  36. package/dist/books/entities/books-entity.js.map +1 -1
  37. package/dist/books/events/book-created-event.d.ts +32 -0
  38. package/dist/books/events/book-created-event.d.ts.map +1 -1
  39. package/dist/books/events/book-created-event.js +32 -0
  40. package/dist/books/events/book-created-event.js.map +1 -1
  41. package/dist/books/events/book-deleted-event.d.ts +30 -0
  42. package/dist/books/events/book-deleted-event.d.ts.map +1 -1
  43. package/dist/books/events/book-deleted-event.js +30 -0
  44. package/dist/books/events/book-deleted-event.js.map +1 -1
  45. package/dist/books/index.d.ts +33 -0
  46. package/dist/books/index.d.ts.map +1 -1
  47. package/dist/books/index.js +33 -0
  48. package/dist/books/index.js.map +1 -1
  49. package/dist/books/repositories/books-command-repository.interface.d.ts +45 -0
  50. package/dist/books/repositories/books-command-repository.interface.d.ts.map +1 -1
  51. package/dist/books/repositories/books-query-repository.interface.d.ts +53 -0
  52. package/dist/books/repositories/books-query-repository.interface.d.ts.map +1 -1
  53. package/dist/books/services/books-domain-service.d.ts +40 -0
  54. package/dist/books/services/books-domain-service.d.ts.map +1 -1
  55. package/dist/books/services/books-domain-service.js +50 -0
  56. package/dist/books/services/books-domain-service.js.map +1 -1
  57. package/dist/books/types/cache-strategy.d.ts +19 -0
  58. package/dist/books/types/cache-strategy.d.ts.map +1 -1
  59. package/dist/books/types/query-params.d.ts +44 -3
  60. package/dist/books/types/query-params.d.ts.map +1 -1
  61. package/dist/books/types/sort-order.d.ts +12 -0
  62. package/dist/books/types/sort-order.d.ts.map +1 -1
  63. package/dist/common/entities/common-entity.d.ts +282 -2
  64. package/dist/common/entities/common-entity.d.ts.map +1 -1
  65. package/dist/common/entities/common-entity.js +235 -2
  66. package/dist/common/entities/common-entity.js.map +1 -1
  67. package/dist/common/events/base-domain-event.d.ts +32 -0
  68. package/dist/common/events/base-domain-event.d.ts.map +1 -1
  69. package/dist/common/events/base-domain-event.js +32 -0
  70. package/dist/common/events/base-domain-event.js.map +1 -1
  71. package/dist/common/events/domain-event.interface.d.ts +54 -0
  72. package/dist/common/events/domain-event.interface.d.ts.map +1 -1
  73. package/dist/common/events/system-error-event.d.ts +36 -0
  74. package/dist/common/events/system-error-event.d.ts.map +1 -1
  75. package/dist/common/events/system-error-event.js +36 -0
  76. package/dist/common/events/system-error-event.js.map +1 -1
  77. package/dist/common/events/system-warning-event.d.ts +35 -0
  78. package/dist/common/events/system-warning-event.d.ts.map +1 -1
  79. package/dist/common/events/system-warning-event.js +35 -0
  80. package/dist/common/events/system-warning-event.js.map +1 -1
  81. package/dist/common/index.d.ts +23 -0
  82. package/dist/common/index.d.ts.map +1 -1
  83. package/dist/common/index.js +23 -0
  84. package/dist/common/index.js.map +1 -1
  85. package/dist/common/services/entity-factory.d.ts +27 -0
  86. package/dist/common/services/entity-factory.d.ts.map +1 -1
  87. package/dist/common/services/entity-factory.js +27 -0
  88. package/dist/common/services/entity-factory.js.map +1 -1
  89. package/dist/common/services/id-generator.d.ts +32 -0
  90. package/dist/common/services/id-generator.d.ts.map +1 -1
  91. package/dist/common/services/id-generator.js +32 -0
  92. package/dist/common/services/id-generator.js.map +1 -1
  93. package/dist/common/types/search-types.d.ts +96 -0
  94. package/dist/common/types/search-types.d.ts.map +1 -1
  95. package/dist/errors/error-classes.d.ts +83 -0
  96. package/dist/errors/error-classes.d.ts.map +1 -1
  97. package/dist/errors/error-classes.js +83 -0
  98. package/dist/errors/error-classes.js.map +1 -1
  99. package/dist/errors/index.d.ts +29 -0
  100. package/dist/errors/index.d.ts.map +1 -1
  101. package/dist/errors/index.js +29 -0
  102. package/dist/errors/index.js.map +1 -1
  103. package/dist/images/entities/image-entity.d.ts +373 -4
  104. package/dist/images/entities/image-entity.d.ts.map +1 -1
  105. package/dist/images/entities/image-entity.js +320 -3
  106. package/dist/images/entities/image-entity.js.map +1 -1
  107. package/dist/images/events/image-created-event.d.ts +30 -0
  108. package/dist/images/events/image-created-event.d.ts.map +1 -1
  109. package/dist/images/events/image-created-event.js +30 -0
  110. package/dist/images/events/image-created-event.js.map +1 -1
  111. package/dist/images/events/image-deleted-event.d.ts +30 -0
  112. package/dist/images/events/image-deleted-event.d.ts.map +1 -1
  113. package/dist/images/events/image-deleted-event.js +30 -0
  114. package/dist/images/events/image-deleted-event.js.map +1 -1
  115. package/dist/images/index.d.ts +35 -0
  116. package/dist/images/index.d.ts.map +1 -1
  117. package/dist/images/index.js +35 -0
  118. package/dist/images/index.js.map +1 -1
  119. package/dist/images/repositories/images-command-repository.interface.d.ts +43 -0
  120. package/dist/images/repositories/images-command-repository.interface.d.ts.map +1 -1
  121. package/dist/images/repositories/images-query-repository.interface.d.ts +59 -0
  122. package/dist/images/repositories/images-query-repository.interface.d.ts.map +1 -1
  123. package/dist/images/services/images-domain-service.d.ts +40 -0
  124. package/dist/images/services/images-domain-service.d.ts.map +1 -1
  125. package/dist/images/services/images-domain-service.js +50 -0
  126. package/dist/images/services/images-domain-service.js.map +1 -1
  127. package/dist/images/types/cache-strategy.d.ts +19 -0
  128. package/dist/images/types/cache-strategy.d.ts.map +1 -1
  129. package/dist/images/types/query-params.d.ts +44 -3
  130. package/dist/images/types/query-params.d.ts.map +1 -1
  131. package/dist/images/types/sort-order.d.ts +12 -0
  132. package/dist/images/types/sort-order.d.ts.map +1 -1
  133. package/dist/index.d.ts +30 -0
  134. package/dist/index.d.ts.map +1 -1
  135. package/dist/index.js +30 -0
  136. package/dist/index.js.map +1 -1
  137. package/dist/notes/entities/note-entity.d.ts +212 -6
  138. package/dist/notes/entities/note-entity.d.ts.map +1 -1
  139. package/dist/notes/entities/note-entity.js +182 -4
  140. package/dist/notes/entities/note-entity.js.map +1 -1
  141. package/dist/notes/events/note-created-event.d.ts +32 -0
  142. package/dist/notes/events/note-created-event.d.ts.map +1 -1
  143. package/dist/notes/events/note-created-event.js +32 -0
  144. package/dist/notes/events/note-created-event.js.map +1 -1
  145. package/dist/notes/events/note-deleted-event.d.ts +30 -0
  146. package/dist/notes/events/note-deleted-event.d.ts.map +1 -1
  147. package/dist/notes/events/note-deleted-event.js +30 -0
  148. package/dist/notes/events/note-deleted-event.js.map +1 -1
  149. package/dist/notes/index.d.ts +32 -0
  150. package/dist/notes/index.d.ts.map +1 -1
  151. package/dist/notes/index.js +32 -0
  152. package/dist/notes/index.js.map +1 -1
  153. package/dist/notes/repositories/notes-command-repository.interface.d.ts +37 -0
  154. package/dist/notes/repositories/notes-command-repository.interface.d.ts.map +1 -1
  155. package/dist/notes/repositories/notes-query-repository.interface.d.ts +53 -0
  156. package/dist/notes/repositories/notes-query-repository.interface.d.ts.map +1 -1
  157. package/dist/notes/services/notes-domain-service.d.ts +40 -0
  158. package/dist/notes/services/notes-domain-service.d.ts.map +1 -1
  159. package/dist/notes/services/notes-domain-service.js +50 -0
  160. package/dist/notes/services/notes-domain-service.js.map +1 -1
  161. package/dist/notes/types/cache-strategy.d.ts +19 -0
  162. package/dist/notes/types/cache-strategy.d.ts.map +1 -1
  163. package/dist/notes/types/query-params.d.ts +44 -3
  164. package/dist/notes/types/query-params.d.ts.map +1 -1
  165. package/dist/notes/types/sort-order.d.ts +12 -0
  166. package/dist/notes/types/sort-order.d.ts.map +1 -1
  167. package/dist/tsconfig.tsbuildinfo +1 -1
  168. package/package.json +1 -1
@@ -1,35 +1,198 @@
1
1
  import { z } from "zod";
2
- import { CreatedAt, ExportedStatus, Id, makeCreatedAt, makeExportedStatus, makeId, UnexportedStatus, UserId, } from "../../common/entities/common-entity";
2
+ import { CreatedAt, ExportedStatus, Id, LastUpdatedStatus, makeCreatedAt, makeExportedStatus, makeId, UnexportedStatus, UserId, } from "../../common/entities/common-entity";
3
3
  import { createEntityWithErrorHandling } from "../../common/services/entity-factory";
4
4
  // Value objects
5
- const ISBN = z
5
+ /**
6
+ * Zod schema for validating ISBN identifiers.
7
+ *
8
+ * @remarks
9
+ * Validates that the ISBN is a string of 1-17 characters containing only
10
+ * digits and hyphens. Supports both ISBN-10 and ISBN-13 formats.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * const isbn = ISBN.parse("978-4-06-521234-5");
15
+ * const isbn10 = ISBN.parse("4-06-521234-X");
16
+ * ```
17
+ *
18
+ * @see {@link makeISBN} for factory function
19
+ */
20
+ export const ISBN = z
6
21
  .string({ message: "required" })
7
22
  .min(1, { message: "required" })
8
23
  .max(17, { message: "tooLong" })
9
24
  .regex(/^[\d-]+$/, { message: "invalidFormat" })
10
25
  .brand();
26
+ /**
27
+ * Creates a validated ISBN from a string.
28
+ *
29
+ * @param v - The raw ISBN string
30
+ * @returns A branded ISBN value
31
+ * @throws {ZodError} When validation fails
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * const isbn = makeISBN("978-4-06-521234-5");
36
+ * ```
37
+ */
11
38
  export const makeISBN = (v) => ISBN.parse(v);
12
- const BookTitle = z
39
+ /**
40
+ * Zod schema for validating book titles.
41
+ *
42
+ * @remarks
43
+ * Validates that the title is a non-empty string between 1 and 256 characters.
44
+ *
45
+ * @example
46
+ * ```typescript
47
+ * const title = BookTitle.parse("The Pragmatic Programmer");
48
+ * ```
49
+ *
50
+ * @see {@link makeBookTitle} for factory function
51
+ */
52
+ export const BookTitle = z
13
53
  .string({ message: "required" })
14
54
  .min(1, { message: "required" })
15
55
  .max(256, { message: "tooLong" })
16
56
  .brand();
57
+ /**
58
+ * Creates a validated BookTitle from a string.
59
+ *
60
+ * @param v - The raw title string
61
+ * @returns A branded BookTitle value
62
+ * @throws {ZodError} When validation fails (empty or exceeds 256 chars)
63
+ *
64
+ * @example
65
+ * ```typescript
66
+ * const title = makeBookTitle("The Pragmatic Programmer");
67
+ * ```
68
+ */
17
69
  export const makeBookTitle = (v) => BookTitle.parse(v);
18
- const GoogleTitle = z.string().nullable().brand();
70
+ /**
71
+ * Zod schema for Google Books API title.
72
+ *
73
+ * @remarks
74
+ * Optional string for the title fetched from Google Books API.
75
+ * Null values are allowed when no Google Books data is available.
76
+ *
77
+ * @see {@link makeGoogleTitle} for factory function
78
+ */
79
+ export const GoogleTitle = z.string().nullable().brand();
80
+ /**
81
+ * Creates a validated GoogleTitle from a string or null.
82
+ *
83
+ * @param v - The Google Books title, null, or undefined
84
+ * @returns A branded GoogleTitle value
85
+ */
19
86
  export const makeGoogleTitle = (v) => GoogleTitle.parse(v);
20
- const GoogleSubtitle = z.string().nullable().brand();
87
+ /**
88
+ * Zod schema for Google Books API subtitle.
89
+ *
90
+ * @remarks
91
+ * Optional string for the subtitle fetched from Google Books API.
92
+ *
93
+ * @see {@link makeGoogleSubTitle} for factory function
94
+ */
95
+ export const GoogleSubtitle = z.string().nullable().brand();
96
+ /**
97
+ * Creates a validated GoogleSubtitle from a string or null.
98
+ *
99
+ * @param v - The Google Books subtitle, null, or undefined
100
+ * @returns A branded GoogleSubtitle value
101
+ */
21
102
  export const makeGoogleSubTitle = (v) => GoogleSubtitle.parse(v);
22
- const GoogleAuthors = z.array(z.string()).nullable().brand();
103
+ /**
104
+ * Zod schema for Google Books API authors list.
105
+ *
106
+ * @remarks
107
+ * Array of author names fetched from Google Books API.
108
+ * Null when no author information is available.
109
+ *
110
+ * @see {@link makeGoogleAuthors} for factory function
111
+ */
112
+ export const GoogleAuthors = z
113
+ .array(z.string())
114
+ .nullable()
115
+ .brand();
116
+ /**
117
+ * Creates a validated GoogleAuthors from an array or null.
118
+ *
119
+ * @param v - The authors array, null, or undefined
120
+ * @returns A branded GoogleAuthors value
121
+ */
23
122
  export const makeGoogleAuthors = (v) => GoogleAuthors.parse(v);
24
- const GoogleDescription = z.string().nullable().brand();
123
+ /**
124
+ * Zod schema for Google Books API description.
125
+ *
126
+ * @remarks
127
+ * Book description/synopsis fetched from Google Books API.
128
+ *
129
+ * @see {@link makeGoogleDescription} for factory function
130
+ */
131
+ export const GoogleDescription = z
132
+ .string()
133
+ .nullable()
134
+ .brand();
135
+ /**
136
+ * Creates a validated GoogleDescription from a string or null.
137
+ *
138
+ * @param v - The description, null, or undefined
139
+ * @returns A branded GoogleDescription value
140
+ */
25
141
  export const makeGoogleDescription = (v) => GoogleDescription.parse(v);
26
- const GoogleImgSrc = z.string().nullable().brand();
142
+ /**
143
+ * Zod schema for Google Books API cover image URL.
144
+ *
145
+ * @remarks
146
+ * URL to the book cover image from Google Books API.
147
+ *
148
+ * @see {@link makeGoogleImgSrc} for factory function
149
+ */
150
+ export const GoogleImgSrc = z.string().nullable().brand();
151
+ /**
152
+ * Creates a validated GoogleImgSrc from a string or null.
153
+ *
154
+ * @param v - The image URL, null, or undefined
155
+ * @returns A branded GoogleImgSrc value
156
+ */
27
157
  export const makeGoogleImgSrc = (v) => GoogleImgSrc.parse(v);
28
- const GoogleHref = z.string().nullable().brand();
158
+ /**
159
+ * Zod schema for Google Books API link URL.
160
+ *
161
+ * @remarks
162
+ * URL to the book's page on Google Books.
163
+ *
164
+ * @see {@link makeGoogleHref} for factory function
165
+ */
166
+ export const GoogleHref = z.string().nullable().brand();
167
+ /**
168
+ * Creates a validated GoogleHref from a string or null.
169
+ *
170
+ * @param v - The link URL, null, or undefined
171
+ * @returns A branded GoogleHref value
172
+ */
29
173
  export const makeGoogleHref = (v) => GoogleHref.parse(v);
30
- const BookMarkdown = z.string().nullable().brand();
174
+ /**
175
+ * Zod schema for book markdown content.
176
+ *
177
+ * @remarks
178
+ * Markdown-formatted notes or review content for the book.
179
+ *
180
+ * @see {@link makeBookMarkdown} for factory function
181
+ */
182
+ export const BookMarkdown = z.string().nullable().brand();
183
+ /**
184
+ * Creates a validated BookMarkdown from a string or null.
185
+ *
186
+ * @param v - The markdown content or null
187
+ * @returns A branded BookMarkdown value
188
+ */
31
189
  export const makeBookMarkdown = (v) => BookMarkdown.parse(v);
32
190
  // Entities
191
+ /**
192
+ * Base schema containing common book fields.
193
+ *
194
+ * @internal
195
+ */
33
196
  const Base = z.object({
34
197
  id: Id,
35
198
  userId: UserId,
@@ -44,9 +207,68 @@ const Base = z.object({
44
207
  markdown: BookMarkdown.optional(),
45
208
  createdAt: CreatedAt,
46
209
  });
210
+ /**
211
+ * Zod schema for an unexported book.
212
+ *
213
+ * @remarks
214
+ * Represents a book that has not yet been published.
215
+ * This is the initial state of all newly created books.
216
+ *
217
+ * @see {@link ExportedBook} for the published state
218
+ */
47
219
  export const UnexportedBook = Base.extend({ status: UnexportedStatus });
48
- const ExportedBook = Base.extend(ExportedStatus.shape);
220
+ /**
221
+ * Zod schema for an exported book.
222
+ *
223
+ * @remarks
224
+ * Represents a book that has been published.
225
+ * Includes the exportedAt timestamp.
226
+ *
227
+ * @see {@link UnexportedBook} for the initial state
228
+ */
229
+ export const ExportedBook = Base.extend(ExportedStatus.shape);
230
+ /**
231
+ * Zod schema for a book marked for export in the current batch.
232
+ *
233
+ * @remarks
234
+ * Represents a book that has been marked for export but not yet finalized.
235
+ * This intermediate state allows for batch processing with revert capability.
236
+ *
237
+ * @see {@link UnexportedBook} for the initial state
238
+ * @see {@link ExportedBook} for the final state
239
+ */
240
+ export const LastUpdatedBook = Base.extend({ status: LastUpdatedStatus });
241
+ /**
242
+ * Factory object for Book domain entity operations.
243
+ *
244
+ * @remarks
245
+ * Provides immutable entity creation following DDD patterns.
246
+ * All returned entities are frozen using Object.freeze().
247
+ *
248
+ * @example
249
+ * ```typescript
250
+ * // Create a new unexported book
251
+ * const book = bookEntity.create({
252
+ * userId: makeUserId("user-123"),
253
+ * ISBN: makeISBN("978-4-06-521234-5"),
254
+ * title: makeBookTitle("The Pragmatic Programmer"),
255
+ * });
256
+ *
257
+ * // Export the book (changes status to EXPORTED)
258
+ * const exported = bookEntity.export(book);
259
+ * ```
260
+ *
261
+ * @see {@link CreateBookArgs} for creation parameters
262
+ */
49
263
  export const bookEntity = {
264
+ /**
265
+ * Creates a new unexported book entity.
266
+ *
267
+ * @param args - The creation arguments containing required fields
268
+ * @returns A frozen UnexportedBook instance with generated id and timestamps
269
+ * @throws {InvalidFormatError} When validation of any field fails
270
+ * @throws {UnexpectedError} For unexpected errors during creation
271
+ */
50
272
  create: (args) => {
51
273
  return createEntityWithErrorHandling(() => Object.freeze({
52
274
  id: makeId(),
@@ -55,6 +277,14 @@ export const bookEntity = {
55
277
  ...args,
56
278
  }));
57
279
  },
280
+ /**
281
+ * Transitions a book from UNEXPORTED to EXPORTED status.
282
+ *
283
+ * @param book - The unexported book to export
284
+ * @returns A frozen ExportedBook with exportedAt timestamp
285
+ * @throws {InvalidFormatError} When the book state is invalid
286
+ * @throws {UnexpectedError} For unexpected errors during export
287
+ */
58
288
  export: (book) => {
59
289
  return createEntityWithErrorHandling(() => {
60
290
  const exportedStatus = makeExportedStatus();
@@ -64,5 +294,60 @@ export const bookEntity = {
64
294
  });
65
295
  });
66
296
  },
297
+ /**
298
+ * Marks a book for export in the current batch.
299
+ *
300
+ * @remarks
301
+ * Transitions from UNEXPORTED to LAST_UPDATED status.
302
+ * This allows for batch processing with revert capability.
303
+ *
304
+ * @param book - The unexported book to mark
305
+ * @returns A frozen LastUpdatedBook
306
+ * @throws {InvalidFormatError} When the book state is invalid
307
+ * @throws {UnexpectedError} For unexpected errors
308
+ */
309
+ markAsLastUpdated: (book) => {
310
+ return createEntityWithErrorHandling(() => Object.freeze({
311
+ ...book,
312
+ status: "LAST_UPDATED",
313
+ }));
314
+ },
315
+ /**
316
+ * Reverts a book from LAST_UPDATED back to UNEXPORTED.
317
+ *
318
+ * @remarks
319
+ * Use this when batch processing fails and needs to be rolled back.
320
+ *
321
+ * @param book - The last updated book to revert
322
+ * @returns A frozen UnexportedBook
323
+ * @throws {InvalidFormatError} When the book state is invalid
324
+ * @throws {UnexpectedError} For unexpected errors
325
+ */
326
+ revert: (book) => {
327
+ return createEntityWithErrorHandling(() => Object.freeze({
328
+ ...book,
329
+ status: "UNEXPORTED",
330
+ }));
331
+ },
332
+ /**
333
+ * Finalizes a book from LAST_UPDATED to EXPORTED.
334
+ *
335
+ * @remarks
336
+ * Use this after batch processing succeeds to confirm the export.
337
+ *
338
+ * @param book - The last updated book to finalize
339
+ * @returns A frozen ExportedBook with exportedAt timestamp
340
+ * @throws {InvalidFormatError} When the book state is invalid
341
+ * @throws {UnexpectedError} For unexpected errors
342
+ */
343
+ finalize: (book) => {
344
+ return createEntityWithErrorHandling(() => {
345
+ const exportedStatus = makeExportedStatus();
346
+ return Object.freeze({
347
+ ...book,
348
+ ...exportedStatus,
349
+ });
350
+ });
351
+ },
67
352
  };
68
353
  //# sourceMappingURL=books-entity.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"books-entity.js","sourceRoot":"","sources":["../../../books/entities/books-entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACN,SAAS,EACT,cAAc,EACd,EAAE,EACF,aAAa,EACb,kBAAkB,EAClB,MAAM,EACN,gBAAgB,EAChB,MAAM,GACN,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,6BAA6B,EAAE,MAAM,sCAAsC,CAAC;AAErF,gBAAgB;AAEhB,MAAM,IAAI,GAAG,CAAC;KACZ,MAAM,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;KAC/B,GAAG,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;KAC/B,GAAG,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;KAC/B,KAAK,CAAC,UAAU,EAAE,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC;KAC/C,KAAK,EAAU,CAAC;AAElB,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAS,EAAQ,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAE3D,MAAM,SAAS,GAAG,CAAC;KACjB,MAAM,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;KAC/B,GAAG,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;KAC/B,GAAG,CA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CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;OAWG;IACH,iBAAiB,EAAE,CAAC,IAAoB,EAAmB,EAAE;QAC5D,OAAO,6BAA6B,CAAC,GAAG,EAAE,CACzC,MAAM,CAAC,MAAM,CAAC;YACb,GAAG,IAAI;YACP,MAAM,EAAE,cAAuB;SAC/B,CAAC,CACF,CAAC;IACH,CAAC;IAED;;;;;;;;;;OAUG;IACH,MAAM,EAAE,CAAC,IAAqB,EAAkB,EAAE;QACjD,OAAO,6BAA6B,CAAC,GAAG,EAAE,CACzC,MAAM,CAAC,MAAM,CAAC;YACb,GAAG,IAAI;YACP,MAAM,EAAE,YAAqB;SAC7B,CAAC,CACF,CAAC;IACH,CAAC;IAED;;;;;;;;;;OAUG;IACH,QAAQ,EAAE,CAAC,IAAqB,EAAgB,EAAE;QACjD,OAAO,6BAA6B,CAAC,GAAG,EAAE;YACzC,MAAM,cAAc,GAAG,kBAAkB,EAAE,CAAC;YAC5C,OAAO,MAAM,CAAC,MAAM,CAAC;gBACpB,GAAG,IAAI;gBACP,GAAG,cAAc;aACjB,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACJ,CAAC;CACD,CAAC"}
@@ -1,5 +1,37 @@
1
1
  import { BaseDomainEvent } from "../../common/events/base-domain-event";
2
+ /**
3
+ * Domain event emitted when a book is created.
4
+ *
5
+ * @remarks
6
+ * Part of the event-driven architecture for cross-cutting concerns
7
+ * like notifications, logging, and analytics.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * const event = new BookCreatedEvent({
12
+ * ISBN: "978-4-06-521234-5",
13
+ * title: "The Pragmatic Programmer",
14
+ * userId: "user-123",
15
+ * caller: "addBook",
16
+ * });
17
+ *
18
+ * // event.eventType === "book.created"
19
+ * await eventHandler.handle(event);
20
+ * ```
21
+ *
22
+ * @see {@link BaseDomainEvent} for base class
23
+ * @see {@link BookDeletedEvent} for deletion event
24
+ */
2
25
  export declare class BookCreatedEvent extends BaseDomainEvent {
26
+ /**
27
+ * Creates a new BookCreatedEvent.
28
+ *
29
+ * @param data - Event data containing book details and metadata
30
+ * @param data.ISBN - The book's ISBN identifier
31
+ * @param data.title - The book title
32
+ * @param data.userId - The user who created the book
33
+ * @param data.caller - The function/method that triggered the event
34
+ */
3
35
  constructor(data: {
4
36
  ISBN: string;
5
37
  title: string;
@@ -1 +1 @@
1
- {"version":3,"file":"book-created-event.d.ts","sourceRoot":"","sources":["../../../books/events/book-created-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAExE,qBAAa,gBAAiB,SAAQ,eAAe;gBACxC,IAAI,EAAE;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;KACf;CAaD"}
1
+ {"version":3,"file":"book-created-event.d.ts","sourceRoot":"","sources":["../../../books/events/book-created-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAExE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,gBAAiB,SAAQ,eAAe;IACpD;;;;;;;;OAQG;gBACS,IAAI,EAAE;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;KACf;CAaD"}
@@ -1,5 +1,37 @@
1
1
  import { BaseDomainEvent } from "../../common/events/base-domain-event";
2
+ /**
3
+ * Domain event emitted when a book is created.
4
+ *
5
+ * @remarks
6
+ * Part of the event-driven architecture for cross-cutting concerns
7
+ * like notifications, logging, and analytics.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * const event = new BookCreatedEvent({
12
+ * ISBN: "978-4-06-521234-5",
13
+ * title: "The Pragmatic Programmer",
14
+ * userId: "user-123",
15
+ * caller: "addBook",
16
+ * });
17
+ *
18
+ * // event.eventType === "book.created"
19
+ * await eventHandler.handle(event);
20
+ * ```
21
+ *
22
+ * @see {@link BaseDomainEvent} for base class
23
+ * @see {@link BookDeletedEvent} for deletion event
24
+ */
2
25
  export class BookCreatedEvent extends BaseDomainEvent {
26
+ /**
27
+ * Creates a new BookCreatedEvent.
28
+ *
29
+ * @param data - Event data containing book details and metadata
30
+ * @param data.ISBN - The book's ISBN identifier
31
+ * @param data.title - The book title
32
+ * @param data.userId - The user who created the book
33
+ * @param data.caller - The function/method that triggered the event
34
+ */
3
35
  constructor(data) {
4
36
  super("book.created", {
5
37
  ISBN: data.ISBN,
@@ -1 +1 @@
1
- {"version":3,"file":"book-created-event.js","sourceRoot":"","sources":["../../../books/events/book-created-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAExE,MAAM,OAAO,gBAAiB,SAAQ,eAAe;IACpD,YAAY,IAKX;QACA,KAAK,CACJ,cAAc,EACd;YACC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,KAAK,EAAE,IAAI,CAAC,KAAK;SACjB,EACD;YACC,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,MAAM,EAAE,IAAI,CAAC,MAAM;SACnB,CACD,CAAC;IACH,CAAC;CACD"}
1
+ {"version":3,"file":"book-created-event.js","sourceRoot":"","sources":["../../../books/events/book-created-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAExE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,OAAO,gBAAiB,SAAQ,eAAe;IACpD;;;;;;;;OAQG;IACH,YAAY,IAKX;QACA,KAAK,CACJ,cAAc,EACd;YACC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,KAAK,EAAE,IAAI,CAAC,KAAK;SACjB,EACD;YACC,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,MAAM,EAAE,IAAI,CAAC,MAAM;SACnB,CACD,CAAC;IACH,CAAC;CACD"}
@@ -1,5 +1,35 @@
1
1
  import { BaseDomainEvent } from "../../common/events/base-domain-event";
2
+ /**
3
+ * Domain event emitted when a book is deleted.
4
+ *
5
+ * @remarks
6
+ * Part of the event-driven architecture for cross-cutting concerns
7
+ * like notifications, logging, and analytics.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * const event = new BookDeletedEvent({
12
+ * title: "Deleted Book",
13
+ * userId: "user-123",
14
+ * caller: "deleteBook",
15
+ * });
16
+ *
17
+ * // event.eventType === "book.deleted"
18
+ * await eventHandler.handle(event);
19
+ * ```
20
+ *
21
+ * @see {@link BaseDomainEvent} for base class
22
+ * @see {@link BookCreatedEvent} for creation event
23
+ */
2
24
  export declare class BookDeletedEvent extends BaseDomainEvent {
25
+ /**
26
+ * Creates a new BookDeletedEvent.
27
+ *
28
+ * @param data - Event data containing deletion details
29
+ * @param data.title - The title of the deleted book
30
+ * @param data.userId - The user who deleted the book
31
+ * @param data.caller - The function/method that triggered the event
32
+ */
3
33
  constructor(data: {
4
34
  title: string;
5
35
  userId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"book-deleted-event.d.ts","sourceRoot":"","sources":["../../../books/events/book-deleted-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAExE,qBAAa,gBAAiB,SAAQ,eAAe;gBACxC,IAAI,EAAE;QACjB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;KACf;CAYD"}
1
+ {"version":3,"file":"book-deleted-event.d.ts","sourceRoot":"","sources":["../../../books/events/book-deleted-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAExE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,gBAAiB,SAAQ,eAAe;IACpD;;;;;;;OAOG;gBACS,IAAI,EAAE;QACjB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;KACf;CAYD"}
@@ -1,5 +1,35 @@
1
1
  import { BaseDomainEvent } from "../../common/events/base-domain-event";
2
+ /**
3
+ * Domain event emitted when a book is deleted.
4
+ *
5
+ * @remarks
6
+ * Part of the event-driven architecture for cross-cutting concerns
7
+ * like notifications, logging, and analytics.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * const event = new BookDeletedEvent({
12
+ * title: "Deleted Book",
13
+ * userId: "user-123",
14
+ * caller: "deleteBook",
15
+ * });
16
+ *
17
+ * // event.eventType === "book.deleted"
18
+ * await eventHandler.handle(event);
19
+ * ```
20
+ *
21
+ * @see {@link BaseDomainEvent} for base class
22
+ * @see {@link BookCreatedEvent} for creation event
23
+ */
2
24
  export class BookDeletedEvent extends BaseDomainEvent {
25
+ /**
26
+ * Creates a new BookDeletedEvent.
27
+ *
28
+ * @param data - Event data containing deletion details
29
+ * @param data.title - The title of the deleted book
30
+ * @param data.userId - The user who deleted the book
31
+ * @param data.caller - The function/method that triggered the event
32
+ */
3
33
  constructor(data) {
4
34
  super("book.deleted", {
5
35
  title: data.title,
@@ -1 +1 @@
1
- {"version":3,"file":"book-deleted-event.js","sourceRoot":"","sources":["../../../books/events/book-deleted-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAExE,MAAM,OAAO,gBAAiB,SAAQ,eAAe;IACpD,YAAY,IAIX;QACA,KAAK,CACJ,cAAc,EACd;YACC,KAAK,EAAE,IAAI,CAAC,KAAK;SACjB,EACD;YACC,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,MAAM,EAAE,IAAI,CAAC,MAAM;SACnB,CACD,CAAC;IACH,CAAC;CACD"}
1
+ {"version":3,"file":"book-deleted-event.js","sourceRoot":"","sources":["../../../books/events/book-deleted-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAExE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,gBAAiB,SAAQ,eAAe;IACpD;;;;;;;OAOG;IACH,YAAY,IAIX;QACA,KAAK,CACJ,cAAc,EACd;YACC,KAAK,EAAE,IAAI,CAAC,KAAK;SACjB,EACD;YACC,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,MAAM,EAAE,IAAI,CAAC,MAAM;SACnB,CACD,CAAC;IACH,CAAC;CACD"}
@@ -1,3 +1,36 @@
1
+ /**
2
+ * @packageDocumentation
3
+ *
4
+ * Books domain for ISBN-based book tracking.
5
+ *
6
+ * @remarks
7
+ * Provides complete domain implementation for book management including:
8
+ *
9
+ * - **Entities** - Book value objects and entity factory
10
+ * - **Repositories** - Query and command repository interfaces (CQRS)
11
+ * - **Services** - Domain service for business logic
12
+ * - **Events** - Domain events for cross-cutting concerns
13
+ * - **Types** - Query parameters and cache strategies
14
+ *
15
+ * Books integrate with Google Books API for metadata enrichment
16
+ * (title, authors, thumbnail, page count, published date).
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * import {
21
+ * bookEntity,
22
+ * makeISBN,
23
+ * makeRating,
24
+ * BookCreatedEvent,
25
+ * } from "@repo/core/books";
26
+ *
27
+ * const book = bookEntity.create({
28
+ * userId: makeUserId("user-123"),
29
+ * isbn: makeISBN("978-4-12-345678-9"),
30
+ * rating: makeRating(4),
31
+ * });
32
+ * ```
33
+ */
1
34
  export * from "./entities/books-entity";
2
35
  export * from "./events/book-created-event";
3
36
  export * from "./events/book-deleted-event";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../books/index.ts"],"names":[],"mappings":"AACA,cAAc,yBAAyB,CAAC;AAGxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAG5C,cAAc,mDAAmD,CAAC;AAClE,cAAc,iDAAiD,CAAC;AAGhE,cAAc,iCAAiC,CAAC;AAGhD,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../books/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAGH,cAAc,yBAAyB,CAAC;AAGxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAG5C,cAAc,mDAAmD,CAAC;AAClE,cAAc,iDAAiD,CAAC;AAGhE,cAAc,iCAAiC,CAAC;AAGhD,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC"}
@@ -1,3 +1,36 @@
1
+ /**
2
+ * @packageDocumentation
3
+ *
4
+ * Books domain for ISBN-based book tracking.
5
+ *
6
+ * @remarks
7
+ * Provides complete domain implementation for book management including:
8
+ *
9
+ * - **Entities** - Book value objects and entity factory
10
+ * - **Repositories** - Query and command repository interfaces (CQRS)
11
+ * - **Services** - Domain service for business logic
12
+ * - **Events** - Domain events for cross-cutting concerns
13
+ * - **Types** - Query parameters and cache strategies
14
+ *
15
+ * Books integrate with Google Books API for metadata enrichment
16
+ * (title, authors, thumbnail, page count, published date).
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * import {
21
+ * bookEntity,
22
+ * makeISBN,
23
+ * makeRating,
24
+ * BookCreatedEvent,
25
+ * } from "@repo/core/books";
26
+ *
27
+ * const book = bookEntity.create({
28
+ * userId: makeUserId("user-123"),
29
+ * isbn: makeISBN("978-4-12-345678-9"),
30
+ * rating: makeRating(4),
31
+ * });
32
+ * ```
33
+ */
1
34
  // Entities
2
35
  export * from "./entities/books-entity";
3
36
  // Events
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../books/index.ts"],"names":[],"mappings":"AAAA,WAAW;AACX,cAAc,yBAAyB,CAAC;AAExC,SAAS;AACT,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAE5C,eAAe;AACf,cAAc,mDAAmD,CAAC;AAClE,cAAc,iDAAiD,CAAC;AAEhE,WAAW;AACX,cAAc,iCAAiC,CAAC;AAEhD,QAAQ;AACR,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../books/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,WAAW;AACX,cAAc,yBAAyB,CAAC;AAExC,SAAS;AACT,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAE5C,eAAe;AACf,cAAc,mDAAmD,CAAC;AAClE,cAAc,iDAAiD,CAAC;AAEhE,WAAW;AACX,cAAc,iCAAiC,CAAC;AAEhD,QAAQ;AACR,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC"}
@@ -1,8 +1,53 @@
1
1
  import type { Id, Status, UserId } from "../../common/entities/common-entity";
2
2
  import type { UnexportedBook } from "../entities/books-entity";
3
+ /**
4
+ * Command repository interface for the Book domain.
5
+ *
6
+ * @remarks
7
+ * Follows the CQRS pattern - this interface handles write operations only.
8
+ * Implementations should be provided by the infrastructure layer (e.g., Prisma).
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * // Infrastructure implementation
13
+ * class PrismaBooksCommandRepository implements IBooksCommandRepository {
14
+ * async create(data: UnexportedBook) {
15
+ * await prisma.book.create({ data });
16
+ * }
17
+ *
18
+ * async deleteById(id: Id, userId: UserId, status: Status) {
19
+ * await prisma.book.delete({
20
+ * where: { id, userId, status }
21
+ * });
22
+ * }
23
+ * }
24
+ * ```
25
+ *
26
+ * @see {@link IBooksQueryRepository} for read operations
27
+ */
3
28
  export type IBooksCommandRepository = {
29
+ /**
30
+ * Creates a new book in the repository.
31
+ *
32
+ * @param data - The unexported book entity to persist
33
+ */
4
34
  create(data: UnexportedBook): Promise<void>;
35
+ /**
36
+ * Deletes a book by its ID.
37
+ *
38
+ * @param id - The book ID to delete
39
+ * @param userId - The user ID for tenant isolation
40
+ * @param status - The expected status of the book
41
+ */
5
42
  deleteById(id: Id, userId: UserId, status: Status): Promise<void>;
43
+ /**
44
+ * Fetches books from an external GitHub repository.
45
+ *
46
+ * @remarks
47
+ * Used for importing book data from external sources.
48
+ *
49
+ * @returns Array of unexported book entities
50
+ */
6
51
  fetchBookFromGitHub(): Promise<UnexportedBook[]>;
7
52
  };
8
53
  //# sourceMappingURL=books-command-repository.interface.d.ts.map