@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.
- 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/common/types/search-types.d.ts +96 -0
- package/dist/common/types/search-types.d.ts.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,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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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,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AAE;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;
|
|
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;
|
|
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"}
|
package/dist/books/index.d.ts
CHANGED
|
@@ -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":"
|
|
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"}
|
package/dist/books/index.js
CHANGED
|
@@ -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
|
package/dist/books/index.js.map
CHANGED
|
@@ -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
|