@s-hirano-ist/s-core 1.1.6 → 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 -3
- package/dist/errors/error-classes.d.ts.map +1 -1
- package/dist/errors/error-classes.js +83 -6
- 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 +7 -5
|
@@ -1,28 +1,121 @@
|
|
|
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 category names.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* Validates that the category name is a trimmed string between 1 and 16 characters.
|
|
10
|
+
* Used for organizing articles into logical groups.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const name = CategoryName.parse("Technology");
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @see {@link makeCategoryName} for factory function
|
|
18
|
+
*/
|
|
19
|
+
export const CategoryName = z
|
|
6
20
|
.string({ message: "required" })
|
|
7
21
|
.trim()
|
|
8
22
|
.min(1, { message: "required" })
|
|
9
23
|
.max(16, { message: "tooLong" })
|
|
10
24
|
.brand();
|
|
25
|
+
/**
|
|
26
|
+
* Creates a validated CategoryName from a string.
|
|
27
|
+
*
|
|
28
|
+
* @param v - The raw string value to validate
|
|
29
|
+
* @returns A branded CategoryName value
|
|
30
|
+
* @throws {ZodError} When validation fails (empty or exceeds 16 chars)
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* const name = makeCategoryName("Technology");
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
11
37
|
export const makeCategoryName = (v) => CategoryName.parse(v);
|
|
12
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Zod schema for validating article titles.
|
|
40
|
+
*
|
|
41
|
+
* @remarks
|
|
42
|
+
* Validates that the title is a non-empty string between 1 and 128 characters.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const title = ArticleTitle.parse("Introduction to TypeScript");
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @see {@link makeArticleTitle} for factory function
|
|
50
|
+
*/
|
|
51
|
+
export const ArticleTitle = z
|
|
13
52
|
.string({ message: "required" })
|
|
14
53
|
.min(1, { message: "required" })
|
|
15
54
|
.max(128, { message: "tooLong" })
|
|
16
55
|
.brand();
|
|
56
|
+
/**
|
|
57
|
+
* Creates a validated ArticleTitle from a string.
|
|
58
|
+
*
|
|
59
|
+
* @param v - The raw string value to validate
|
|
60
|
+
* @returns A branded ArticleTitle value
|
|
61
|
+
* @throws {ZodError} When validation fails (empty or exceeds 128 chars)
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* const title = makeArticleTitle("Introduction to TypeScript");
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
17
68
|
export const makeArticleTitle = (v) => ArticleTitle.parse(v);
|
|
18
|
-
|
|
69
|
+
/**
|
|
70
|
+
* Zod schema for validating article quotes.
|
|
71
|
+
*
|
|
72
|
+
* @remarks
|
|
73
|
+
* Validates an optional quote with maximum 512 characters.
|
|
74
|
+
* Null and undefined values are allowed.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* const quote = Quote.parse("This is a notable excerpt from the article.");
|
|
79
|
+
* const empty = Quote.parse(null);
|
|
80
|
+
* ```
|
|
81
|
+
*
|
|
82
|
+
* @see {@link makeQuote} for factory function
|
|
83
|
+
*/
|
|
84
|
+
export const Quote = z
|
|
19
85
|
.string()
|
|
20
86
|
.max(512, { message: "tooLong" })
|
|
21
87
|
.nullable()
|
|
22
88
|
.optional()
|
|
23
89
|
.brand();
|
|
90
|
+
/**
|
|
91
|
+
* Creates a validated Quote from a string or null/undefined.
|
|
92
|
+
*
|
|
93
|
+
* @param v - The raw string value, null, or undefined
|
|
94
|
+
* @returns A branded Quote value
|
|
95
|
+
* @throws {ZodError} When string exceeds 512 characters
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```typescript
|
|
99
|
+
* const quote = makeQuote("Notable excerpt");
|
|
100
|
+
* const noQuote = makeQuote(null);
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
24
103
|
export const makeQuote = (v) => Quote.parse(v);
|
|
25
|
-
|
|
104
|
+
/**
|
|
105
|
+
* Zod schema for validating article URLs.
|
|
106
|
+
*
|
|
107
|
+
* @remarks
|
|
108
|
+
* Validates that the URL is a valid HTTP or HTTPS URL.
|
|
109
|
+
* Other protocols are not allowed.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```typescript
|
|
113
|
+
* const url = Url.parse("https://example.com/article");
|
|
114
|
+
* ```
|
|
115
|
+
*
|
|
116
|
+
* @see {@link makeUrl} for factory function
|
|
117
|
+
*/
|
|
118
|
+
export const Url = z
|
|
26
119
|
.url({ message: "invalidFormat" })
|
|
27
120
|
.min(1, { message: "required" })
|
|
28
121
|
.refine((url) => {
|
|
@@ -35,14 +128,84 @@ const Url = z
|
|
|
35
128
|
}
|
|
36
129
|
}, { message: "invalidFormat" })
|
|
37
130
|
.brand();
|
|
131
|
+
/**
|
|
132
|
+
* Creates a validated Url from a string.
|
|
133
|
+
*
|
|
134
|
+
* @param v - The raw URL string
|
|
135
|
+
* @returns A branded Url value
|
|
136
|
+
* @throws {ZodError} When URL is invalid or not HTTP/HTTPS
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```typescript
|
|
140
|
+
* const url = makeUrl("https://example.com/article");
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
38
143
|
export const makeUrl = (v) => Url.parse(v);
|
|
39
|
-
|
|
144
|
+
/**
|
|
145
|
+
* Zod schema for validating Open Graph titles.
|
|
146
|
+
*
|
|
147
|
+
* @remarks
|
|
148
|
+
* Optional string for the OG title fetched from the article URL.
|
|
149
|
+
* Null and undefined values are allowed.
|
|
150
|
+
*
|
|
151
|
+
* @see {@link makeOgTitle} for factory function
|
|
152
|
+
*/
|
|
153
|
+
export const OgTitle = z.string().nullable().optional().brand();
|
|
154
|
+
/**
|
|
155
|
+
* Creates a validated OgTitle from a string or null/undefined.
|
|
156
|
+
*
|
|
157
|
+
* @param v - The raw OG title string, null, or undefined
|
|
158
|
+
* @returns A branded OgTitle value
|
|
159
|
+
*/
|
|
40
160
|
export const makeOgTitle = (v) => OgTitle.parse(v);
|
|
41
|
-
|
|
161
|
+
/**
|
|
162
|
+
* Zod schema for validating Open Graph descriptions.
|
|
163
|
+
*
|
|
164
|
+
* @remarks
|
|
165
|
+
* Optional string for the OG description fetched from the article URL.
|
|
166
|
+
* Null and undefined values are allowed.
|
|
167
|
+
*
|
|
168
|
+
* @see {@link makeOgDescription} for factory function
|
|
169
|
+
*/
|
|
170
|
+
export const OgDescription = z
|
|
171
|
+
.string()
|
|
172
|
+
.nullable()
|
|
173
|
+
.optional()
|
|
174
|
+
.brand();
|
|
175
|
+
/**
|
|
176
|
+
* Creates a validated OgDescription from a string or null/undefined.
|
|
177
|
+
*
|
|
178
|
+
* @param v - The raw OG description string, null, or undefined
|
|
179
|
+
* @returns A branded OgDescription value
|
|
180
|
+
*/
|
|
42
181
|
export const makeOgDescription = (v) => OgDescription.parse(v);
|
|
43
|
-
|
|
182
|
+
/**
|
|
183
|
+
* Zod schema for validating Open Graph image URLs.
|
|
184
|
+
*
|
|
185
|
+
* @remarks
|
|
186
|
+
* Optional string for the OG image URL fetched from the article URL.
|
|
187
|
+
* Null and undefined values are allowed.
|
|
188
|
+
*
|
|
189
|
+
* @see {@link makeOgImageUrl} for factory function
|
|
190
|
+
*/
|
|
191
|
+
export const OgImageUrl = z
|
|
192
|
+
.string()
|
|
193
|
+
.nullable()
|
|
194
|
+
.optional()
|
|
195
|
+
.brand();
|
|
196
|
+
/**
|
|
197
|
+
* Creates a validated OgImageUrl from a string or null/undefined.
|
|
198
|
+
*
|
|
199
|
+
* @param v - The raw OG image URL string, null, or undefined
|
|
200
|
+
* @returns A branded OgImageUrl value
|
|
201
|
+
*/
|
|
44
202
|
export const makeOgImageUrl = (v) => OgImageUrl.parse(v);
|
|
45
203
|
// Entities
|
|
204
|
+
/**
|
|
205
|
+
* Base schema containing common article fields.
|
|
206
|
+
*
|
|
207
|
+
* @internal
|
|
208
|
+
*/
|
|
46
209
|
const Base = z.object({
|
|
47
210
|
id: Id,
|
|
48
211
|
userId: UserId,
|
|
@@ -56,9 +219,69 @@ const Base = z.object({
|
|
|
56
219
|
ogDescription: OgDescription,
|
|
57
220
|
ogImageUrl: OgImageUrl,
|
|
58
221
|
});
|
|
222
|
+
/**
|
|
223
|
+
* Zod schema for an unexported article.
|
|
224
|
+
*
|
|
225
|
+
* @remarks
|
|
226
|
+
* Represents an article that has not yet been published.
|
|
227
|
+
* This is the initial state of all newly created articles.
|
|
228
|
+
*
|
|
229
|
+
* @see {@link ExportedArticle} for the published state
|
|
230
|
+
*/
|
|
59
231
|
export const UnexportedArticle = Base.extend({ status: UnexportedStatus });
|
|
60
|
-
|
|
232
|
+
/**
|
|
233
|
+
* Zod schema for an exported article.
|
|
234
|
+
*
|
|
235
|
+
* @remarks
|
|
236
|
+
* Represents an article that has been published.
|
|
237
|
+
* Includes the exportedAt timestamp.
|
|
238
|
+
*
|
|
239
|
+
* @see {@link UnexportedArticle} for the initial state
|
|
240
|
+
*/
|
|
241
|
+
export const ExportedArticle = Base.extend(ExportedStatus.shape);
|
|
242
|
+
/**
|
|
243
|
+
* Zod schema for an article marked for export in the current batch.
|
|
244
|
+
*
|
|
245
|
+
* @remarks
|
|
246
|
+
* Represents an article that has been marked for export but not yet finalized.
|
|
247
|
+
* This intermediate state allows for batch processing with revert capability.
|
|
248
|
+
*
|
|
249
|
+
* @see {@link UnexportedArticle} for the initial state
|
|
250
|
+
* @see {@link ExportedArticle} for the final state
|
|
251
|
+
*/
|
|
252
|
+
export const LastUpdatedArticle = Base.extend({ status: LastUpdatedStatus });
|
|
253
|
+
/**
|
|
254
|
+
* Factory object for Article domain entity operations.
|
|
255
|
+
*
|
|
256
|
+
* @remarks
|
|
257
|
+
* Provides immutable entity creation following DDD patterns.
|
|
258
|
+
* All returned entities are frozen using Object.freeze().
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* ```typescript
|
|
262
|
+
* // Create a new unexported article
|
|
263
|
+
* const article = articleEntity.create({
|
|
264
|
+
* userId: makeUserId("user-123"),
|
|
265
|
+
* categoryName: makeCategoryName("Tech"),
|
|
266
|
+
* title: makeArticleTitle("Article Title"),
|
|
267
|
+
* url: makeUrl("https://example.com"),
|
|
268
|
+
* });
|
|
269
|
+
*
|
|
270
|
+
* // Export the article (changes status to EXPORTED)
|
|
271
|
+
* const exported = articleEntity.export(article);
|
|
272
|
+
* ```
|
|
273
|
+
*
|
|
274
|
+
* @see {@link CreateArticleArgs} for creation parameters
|
|
275
|
+
*/
|
|
61
276
|
export const articleEntity = {
|
|
277
|
+
/**
|
|
278
|
+
* Creates a new unexported article entity.
|
|
279
|
+
*
|
|
280
|
+
* @param args - The creation arguments containing required fields
|
|
281
|
+
* @returns A frozen UnexportedArticle instance with generated id and timestamps
|
|
282
|
+
* @throws {InvalidFormatError} When validation of any field fails
|
|
283
|
+
* @throws {UnexpectedError} For unexpected errors during creation
|
|
284
|
+
*/
|
|
62
285
|
create: (args) => {
|
|
63
286
|
return createEntityWithErrorHandling(() => Object.freeze({
|
|
64
287
|
id: makeId(),
|
|
@@ -68,6 +291,14 @@ export const articleEntity = {
|
|
|
68
291
|
...args,
|
|
69
292
|
}));
|
|
70
293
|
},
|
|
294
|
+
/**
|
|
295
|
+
* Transitions an article from UNEXPORTED to EXPORTED status.
|
|
296
|
+
*
|
|
297
|
+
* @param article - The unexported article to export
|
|
298
|
+
* @returns A frozen ExportedArticle with exportedAt timestamp
|
|
299
|
+
* @throws {InvalidFormatError} When the article state is invalid
|
|
300
|
+
* @throws {UnexpectedError} For unexpected errors during export
|
|
301
|
+
*/
|
|
71
302
|
export: (article) => {
|
|
72
303
|
return createEntityWithErrorHandling(() => {
|
|
73
304
|
const exportedStatus = makeExportedStatus();
|
|
@@ -77,5 +308,60 @@ export const articleEntity = {
|
|
|
77
308
|
});
|
|
78
309
|
});
|
|
79
310
|
},
|
|
311
|
+
/**
|
|
312
|
+
* Marks an article for export in the current batch.
|
|
313
|
+
*
|
|
314
|
+
* @remarks
|
|
315
|
+
* Transitions from UNEXPORTED to LAST_UPDATED status.
|
|
316
|
+
* This allows for batch processing with revert capability.
|
|
317
|
+
*
|
|
318
|
+
* @param article - The unexported article to mark
|
|
319
|
+
* @returns A frozen LastUpdatedArticle
|
|
320
|
+
* @throws {InvalidFormatError} When the article state is invalid
|
|
321
|
+
* @throws {UnexpectedError} For unexpected errors
|
|
322
|
+
*/
|
|
323
|
+
markAsLastUpdated: (article) => {
|
|
324
|
+
return createEntityWithErrorHandling(() => Object.freeze({
|
|
325
|
+
...article,
|
|
326
|
+
status: "LAST_UPDATED",
|
|
327
|
+
}));
|
|
328
|
+
},
|
|
329
|
+
/**
|
|
330
|
+
* Reverts an article from LAST_UPDATED back to UNEXPORTED.
|
|
331
|
+
*
|
|
332
|
+
* @remarks
|
|
333
|
+
* Use this when batch processing fails and needs to be rolled back.
|
|
334
|
+
*
|
|
335
|
+
* @param article - The last updated article to revert
|
|
336
|
+
* @returns A frozen UnexportedArticle
|
|
337
|
+
* @throws {InvalidFormatError} When the article state is invalid
|
|
338
|
+
* @throws {UnexpectedError} For unexpected errors
|
|
339
|
+
*/
|
|
340
|
+
revert: (article) => {
|
|
341
|
+
return createEntityWithErrorHandling(() => Object.freeze({
|
|
342
|
+
...article,
|
|
343
|
+
status: "UNEXPORTED",
|
|
344
|
+
}));
|
|
345
|
+
},
|
|
346
|
+
/**
|
|
347
|
+
* Finalizes an article from LAST_UPDATED to EXPORTED.
|
|
348
|
+
*
|
|
349
|
+
* @remarks
|
|
350
|
+
* Use this after batch processing succeeds to confirm the export.
|
|
351
|
+
*
|
|
352
|
+
* @param article - The last updated article to finalize
|
|
353
|
+
* @returns A frozen ExportedArticle with exportedAt timestamp
|
|
354
|
+
* @throws {InvalidFormatError} When the article state is invalid
|
|
355
|
+
* @throws {UnexpectedError} For unexpected errors
|
|
356
|
+
*/
|
|
357
|
+
finalize: (article) => {
|
|
358
|
+
return createEntityWithErrorHandling(() => {
|
|
359
|
+
const exportedStatus = makeExportedStatus();
|
|
360
|
+
return Object.freeze({
|
|
361
|
+
...article,
|
|
362
|
+
...exportedStatus,
|
|
363
|
+
});
|
|
364
|
+
});
|
|
365
|
+
},
|
|
80
366
|
};
|
|
81
367
|
//# sourceMappingURL=article-entity.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"article-entity.js","sourceRoot":"","sources":["../../../articles/entities/article-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;AA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B,EAAE;QAC1D,OAAO,6BAA6B,CAAC,GAAG,EAAE;YACzC,MAAM,cAAc,GAAG,kBAAkB,EAAE,CAAC;YAC5C,OAAO,MAAM,CAAC,MAAM,CAAC;gBACpB,GAAG,OAAO;gBACV,GAAG,cAAc;aACjB,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACJ,CAAC;CACD,CAAC"}
|
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
import { BaseDomainEvent } from "../../common/events/base-domain-event";
|
|
2
|
+
/**
|
|
3
|
+
* Domain event emitted when an article 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 ArticleCreatedEvent({
|
|
12
|
+
* title: "New Article",
|
|
13
|
+
* url: "https://example.com",
|
|
14
|
+
* quote: "Important quote",
|
|
15
|
+
* categoryName: "Technology",
|
|
16
|
+
* userId: "user-123",
|
|
17
|
+
* caller: "addArticle",
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* // event.eventType === "article.created"
|
|
21
|
+
* await eventHandler.handle(event);
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @see {@link BaseDomainEvent} for base class
|
|
25
|
+
* @see {@link ArticleDeletedEvent} for deletion event
|
|
26
|
+
*/
|
|
2
27
|
export declare class ArticleCreatedEvent extends BaseDomainEvent {
|
|
28
|
+
/**
|
|
29
|
+
* Creates a new ArticleCreatedEvent.
|
|
30
|
+
*
|
|
31
|
+
* @param data - Event data containing article details and metadata
|
|
32
|
+
* @param data.title - The article title
|
|
33
|
+
* @param data.url - The article URL
|
|
34
|
+
* @param data.quote - Quote/excerpt from the article
|
|
35
|
+
* @param data.categoryName - The category name
|
|
36
|
+
* @param data.userId - The user who created the article
|
|
37
|
+
* @param data.caller - The function/method that triggered the event
|
|
38
|
+
*/
|
|
3
39
|
constructor(data: {
|
|
4
40
|
title: string;
|
|
5
41
|
url: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"article-created-event.d.ts","sourceRoot":"","sources":["../../../articles/events/article-created-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAExE,qBAAa,mBAAoB,SAAQ,eAAe;
|
|
1
|
+
{"version":3,"file":"article-created-event.d.ts","sourceRoot":"","sources":["../../../articles/events/article-created-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAExE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,qBAAa,mBAAoB,SAAQ,eAAe;IACvD;;;;;;;;;;OAUG;gBACS,IAAI,EAAE;QACjB,KAAK,EAAE,MAAM,CAAC;QACd,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE,MAAM,CAAC;QACd,YAAY,EAAE,MAAM,CAAC;QACrB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;KACf;CAeD"}
|
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
import { BaseDomainEvent } from "../../common/events/base-domain-event";
|
|
2
|
+
/**
|
|
3
|
+
* Domain event emitted when an article 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 ArticleCreatedEvent({
|
|
12
|
+
* title: "New Article",
|
|
13
|
+
* url: "https://example.com",
|
|
14
|
+
* quote: "Important quote",
|
|
15
|
+
* categoryName: "Technology",
|
|
16
|
+
* userId: "user-123",
|
|
17
|
+
* caller: "addArticle",
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* // event.eventType === "article.created"
|
|
21
|
+
* await eventHandler.handle(event);
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @see {@link BaseDomainEvent} for base class
|
|
25
|
+
* @see {@link ArticleDeletedEvent} for deletion event
|
|
26
|
+
*/
|
|
2
27
|
export class ArticleCreatedEvent extends BaseDomainEvent {
|
|
28
|
+
/**
|
|
29
|
+
* Creates a new ArticleCreatedEvent.
|
|
30
|
+
*
|
|
31
|
+
* @param data - Event data containing article details and metadata
|
|
32
|
+
* @param data.title - The article title
|
|
33
|
+
* @param data.url - The article URL
|
|
34
|
+
* @param data.quote - Quote/excerpt from the article
|
|
35
|
+
* @param data.categoryName - The category name
|
|
36
|
+
* @param data.userId - The user who created the article
|
|
37
|
+
* @param data.caller - The function/method that triggered the event
|
|
38
|
+
*/
|
|
3
39
|
constructor(data) {
|
|
4
40
|
super("article.created", {
|
|
5
41
|
title: data.title,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"article-created-event.js","sourceRoot":"","sources":["../../../articles/events/article-created-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAExE,MAAM,OAAO,mBAAoB,SAAQ,eAAe;IACvD,YAAY,IAOX;QACA,KAAK,CACJ,iBAAiB,EACjB;YACC,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,YAAY,EAAE,IAAI,CAAC,YAAY;SAC/B,EACD;YACC,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,MAAM,EAAE,IAAI,CAAC,MAAM;SACnB,CACD,CAAC;IACH,CAAC;CACD"}
|
|
1
|
+
{"version":3,"file":"article-created-event.js","sourceRoot":"","sources":["../../../articles/events/article-created-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAExE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,OAAO,mBAAoB,SAAQ,eAAe;IACvD;;;;;;;;;;OAUG;IACH,YAAY,IAOX;QACA,KAAK,CACJ,iBAAiB,EACjB;YACC,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,YAAY,EAAE,IAAI,CAAC,YAAY;SAC/B,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 an article 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 ArticleDeletedEvent({
|
|
12
|
+
* title: "Deleted Article",
|
|
13
|
+
* userId: "user-123",
|
|
14
|
+
* caller: "deleteArticle",
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
* // event.eventType === "article.deleted"
|
|
18
|
+
* await eventHandler.handle(event);
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @see {@link BaseDomainEvent} for base class
|
|
22
|
+
* @see {@link ArticleCreatedEvent} for creation event
|
|
23
|
+
*/
|
|
2
24
|
export declare class ArticleDeletedEvent extends BaseDomainEvent {
|
|
25
|
+
/**
|
|
26
|
+
* Creates a new ArticleDeletedEvent.
|
|
27
|
+
*
|
|
28
|
+
* @param data - Event data containing deletion details
|
|
29
|
+
* @param data.title - The title of the deleted article
|
|
30
|
+
* @param data.userId - The user who deleted the article
|
|
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":"article-deleted-event.d.ts","sourceRoot":"","sources":["../../../articles/events/article-deleted-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAExE,qBAAa,mBAAoB,SAAQ,eAAe;
|
|
1
|
+
{"version":3,"file":"article-deleted-event.d.ts","sourceRoot":"","sources":["../../../articles/events/article-deleted-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAExE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,mBAAoB,SAAQ,eAAe;IACvD;;;;;;;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 an article 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 ArticleDeletedEvent({
|
|
12
|
+
* title: "Deleted Article",
|
|
13
|
+
* userId: "user-123",
|
|
14
|
+
* caller: "deleteArticle",
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
* // event.eventType === "article.deleted"
|
|
18
|
+
* await eventHandler.handle(event);
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @see {@link BaseDomainEvent} for base class
|
|
22
|
+
* @see {@link ArticleCreatedEvent} for creation event
|
|
23
|
+
*/
|
|
2
24
|
export class ArticleDeletedEvent extends BaseDomainEvent {
|
|
25
|
+
/**
|
|
26
|
+
* Creates a new ArticleDeletedEvent.
|
|
27
|
+
*
|
|
28
|
+
* @param data - Event data containing deletion details
|
|
29
|
+
* @param data.title - The title of the deleted article
|
|
30
|
+
* @param data.userId - The user who deleted the article
|
|
31
|
+
* @param data.caller - The function/method that triggered the event
|
|
32
|
+
*/
|
|
3
33
|
constructor(data) {
|
|
4
34
|
super("article.deleted", {
|
|
5
35
|
title: data.title,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"article-deleted-event.js","sourceRoot":"","sources":["../../../articles/events/article-deleted-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAExE,MAAM,OAAO,mBAAoB,SAAQ,eAAe;IACvD,YAAY,IAIX;QACA,KAAK,CACJ,iBAAiB,EACjB;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":"article-deleted-event.js","sourceRoot":"","sources":["../../../articles/events/article-deleted-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAExE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,mBAAoB,SAAQ,eAAe;IACvD;;;;;;;OAOG;IACH,YAAY,IAIX;QACA,KAAK,CACJ,iBAAiB,EACjB;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/articles/index.d.ts
CHANGED
|
@@ -1,3 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
*
|
|
4
|
+
* Articles domain for news and link management.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Provides complete domain implementation for article management including:
|
|
8
|
+
*
|
|
9
|
+
* - **Entities** - Article 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
|
+
* Articles support Open Graph metadata extraction (title, description, image URL)
|
|
16
|
+
* and can be organized into categories.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* import {
|
|
21
|
+
* articleEntity,
|
|
22
|
+
* makeArticleTitle,
|
|
23
|
+
* makeUrl,
|
|
24
|
+
* ArticleCreatedEvent,
|
|
25
|
+
* } from "@repo/core/articles";
|
|
26
|
+
*
|
|
27
|
+
* const article = articleEntity.create({
|
|
28
|
+
* userId: makeUserId("user-123"),
|
|
29
|
+
* title: makeArticleTitle("Breaking News"),
|
|
30
|
+
* url: makeUrl("https://example.com/news"),
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
1
34
|
export * from "./entities/article-entity";
|
|
2
35
|
export * from "./events/article-created-event";
|
|
3
36
|
export * from "./events/article-deleted-event";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../articles/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../articles/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAGH,cAAc,2BAA2B,CAAC;AAG1C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC;AAG/C,cAAc,sDAAsD,CAAC;AACrE,cAAc,oDAAoD,CAAC;AACnE,cAAc,oDAAoD,CAAC;AAGnE,cAAc,oCAAoC,CAAC;AAGnD,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC"}
|
package/dist/articles/index.js
CHANGED
|
@@ -1,3 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
*
|
|
4
|
+
* Articles domain for news and link management.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Provides complete domain implementation for article management including:
|
|
8
|
+
*
|
|
9
|
+
* - **Entities** - Article 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
|
+
* Articles support Open Graph metadata extraction (title, description, image URL)
|
|
16
|
+
* and can be organized into categories.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* import {
|
|
21
|
+
* articleEntity,
|
|
22
|
+
* makeArticleTitle,
|
|
23
|
+
* makeUrl,
|
|
24
|
+
* ArticleCreatedEvent,
|
|
25
|
+
* } from "@repo/core/articles";
|
|
26
|
+
*
|
|
27
|
+
* const article = articleEntity.create({
|
|
28
|
+
* userId: makeUserId("user-123"),
|
|
29
|
+
* title: makeArticleTitle("Breaking News"),
|
|
30
|
+
* url: makeUrl("https://example.com/news"),
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
1
34
|
// Entities
|
|
2
35
|
export * from "./entities/article-entity";
|
|
3
36
|
// Events
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../articles/index.ts"],"names":[],"mappings":"AAAA,WAAW;AACX,cAAc,2BAA2B,CAAC;AAE1C,SAAS;AACT,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC;AAE/C,eAAe;AACf,cAAc,sDAAsD,CAAC;AACrE,cAAc,oDAAoD,CAAC;AACnE,cAAc,oDAAoD,CAAC;AAEnE,WAAW;AACX,cAAc,oCAAoC,CAAC;AAEnD,QAAQ;AACR,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../articles/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,WAAW;AACX,cAAc,2BAA2B,CAAC;AAE1C,SAAS;AACT,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC;AAE/C,eAAe;AACf,cAAc,sDAAsD,CAAC;AACrE,cAAc,oDAAoD,CAAC;AACnE,cAAc,oDAAoD,CAAC;AAEnE,WAAW;AACX,cAAc,oCAAoC,CAAC;AAEnD,QAAQ;AACR,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC"}
|