@s-hirano-ist/s-core 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/articles/entities/article-entity.d.ts +342 -11
- package/dist/articles/entities/article-entity.d.ts.map +1 -1
- package/dist/articles/entities/article-entity.js +295 -9
- package/dist/articles/entities/article-entity.js.map +1 -1
- package/dist/articles/events/article-created-event.d.ts +36 -0
- package/dist/articles/events/article-created-event.d.ts.map +1 -1
- package/dist/articles/events/article-created-event.js +36 -0
- package/dist/articles/events/article-created-event.js.map +1 -1
- package/dist/articles/events/article-deleted-event.d.ts +30 -0
- package/dist/articles/events/article-deleted-event.d.ts.map +1 -1
- package/dist/articles/events/article-deleted-event.js +30 -0
- package/dist/articles/events/article-deleted-event.js.map +1 -1
- package/dist/articles/index.d.ts +33 -0
- package/dist/articles/index.d.ts.map +1 -1
- package/dist/articles/index.js +33 -0
- package/dist/articles/index.js.map +1 -1
- package/dist/articles/repositories/articles-command-repository.interface.d.ts +37 -0
- package/dist/articles/repositories/articles-command-repository.interface.d.ts.map +1 -1
- package/dist/articles/repositories/articles-query-repository.interface.d.ts +53 -0
- package/dist/articles/repositories/articles-query-repository.interface.d.ts.map +1 -1
- package/dist/articles/repositories/category-query-repository.interface.d.ts +29 -0
- package/dist/articles/repositories/category-query-repository.interface.d.ts.map +1 -1
- package/dist/articles/services/articles-domain-service.d.ts +40 -0
- package/dist/articles/services/articles-domain-service.d.ts.map +1 -1
- package/dist/articles/services/articles-domain-service.js +50 -0
- package/dist/articles/services/articles-domain-service.js.map +1 -1
- package/dist/articles/types/cache-strategy.d.ts +19 -0
- package/dist/articles/types/cache-strategy.d.ts.map +1 -1
- package/dist/articles/types/query-params.d.ts +83 -5
- package/dist/articles/types/query-params.d.ts.map +1 -1
- package/dist/articles/types/sort-order.d.ts +12 -0
- package/dist/articles/types/sort-order.d.ts.map +1 -1
- package/dist/books/entities/books-entity.d.ts +348 -13
- package/dist/books/entities/books-entity.d.ts.map +1 -1
- package/dist/books/entities/books-entity.js +296 -11
- package/dist/books/entities/books-entity.js.map +1 -1
- package/dist/books/events/book-created-event.d.ts +32 -0
- package/dist/books/events/book-created-event.d.ts.map +1 -1
- package/dist/books/events/book-created-event.js +32 -0
- package/dist/books/events/book-created-event.js.map +1 -1
- package/dist/books/events/book-deleted-event.d.ts +30 -0
- package/dist/books/events/book-deleted-event.d.ts.map +1 -1
- package/dist/books/events/book-deleted-event.js +30 -0
- package/dist/books/events/book-deleted-event.js.map +1 -1
- package/dist/books/index.d.ts +33 -0
- package/dist/books/index.d.ts.map +1 -1
- package/dist/books/index.js +33 -0
- package/dist/books/index.js.map +1 -1
- package/dist/books/repositories/books-command-repository.interface.d.ts +45 -0
- package/dist/books/repositories/books-command-repository.interface.d.ts.map +1 -1
- package/dist/books/repositories/books-query-repository.interface.d.ts +53 -0
- package/dist/books/repositories/books-query-repository.interface.d.ts.map +1 -1
- package/dist/books/services/books-domain-service.d.ts +40 -0
- package/dist/books/services/books-domain-service.d.ts.map +1 -1
- package/dist/books/services/books-domain-service.js +50 -0
- package/dist/books/services/books-domain-service.js.map +1 -1
- package/dist/books/types/cache-strategy.d.ts +19 -0
- package/dist/books/types/cache-strategy.d.ts.map +1 -1
- package/dist/books/types/query-params.d.ts +44 -3
- package/dist/books/types/query-params.d.ts.map +1 -1
- package/dist/books/types/sort-order.d.ts +12 -0
- package/dist/books/types/sort-order.d.ts.map +1 -1
- package/dist/common/entities/common-entity.d.ts +282 -2
- package/dist/common/entities/common-entity.d.ts.map +1 -1
- package/dist/common/entities/common-entity.js +235 -2
- package/dist/common/entities/common-entity.js.map +1 -1
- package/dist/common/events/base-domain-event.d.ts +32 -0
- package/dist/common/events/base-domain-event.d.ts.map +1 -1
- package/dist/common/events/base-domain-event.js +32 -0
- package/dist/common/events/base-domain-event.js.map +1 -1
- package/dist/common/events/domain-event.interface.d.ts +54 -0
- package/dist/common/events/domain-event.interface.d.ts.map +1 -1
- package/dist/common/events/system-error-event.d.ts +36 -0
- package/dist/common/events/system-error-event.d.ts.map +1 -1
- package/dist/common/events/system-error-event.js +36 -0
- package/dist/common/events/system-error-event.js.map +1 -1
- package/dist/common/events/system-warning-event.d.ts +35 -0
- package/dist/common/events/system-warning-event.d.ts.map +1 -1
- package/dist/common/events/system-warning-event.js +35 -0
- package/dist/common/events/system-warning-event.js.map +1 -1
- package/dist/common/index.d.ts +23 -0
- package/dist/common/index.d.ts.map +1 -1
- package/dist/common/index.js +23 -0
- package/dist/common/index.js.map +1 -1
- package/dist/common/services/entity-factory.d.ts +27 -0
- package/dist/common/services/entity-factory.d.ts.map +1 -1
- package/dist/common/services/entity-factory.js +27 -0
- package/dist/common/services/entity-factory.js.map +1 -1
- package/dist/common/services/id-generator.d.ts +32 -0
- package/dist/common/services/id-generator.d.ts.map +1 -1
- package/dist/common/services/id-generator.js +32 -0
- package/dist/common/services/id-generator.js.map +1 -1
- package/dist/errors/error-classes.d.ts +83 -0
- package/dist/errors/error-classes.d.ts.map +1 -1
- package/dist/errors/error-classes.js +83 -0
- package/dist/errors/error-classes.js.map +1 -1
- package/dist/errors/index.d.ts +29 -0
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +29 -0
- package/dist/errors/index.js.map +1 -1
- package/dist/images/entities/image-entity.d.ts +373 -4
- package/dist/images/entities/image-entity.d.ts.map +1 -1
- package/dist/images/entities/image-entity.js +320 -3
- package/dist/images/entities/image-entity.js.map +1 -1
- package/dist/images/events/image-created-event.d.ts +30 -0
- package/dist/images/events/image-created-event.d.ts.map +1 -1
- package/dist/images/events/image-created-event.js +30 -0
- package/dist/images/events/image-created-event.js.map +1 -1
- package/dist/images/events/image-deleted-event.d.ts +30 -0
- package/dist/images/events/image-deleted-event.d.ts.map +1 -1
- package/dist/images/events/image-deleted-event.js +30 -0
- package/dist/images/events/image-deleted-event.js.map +1 -1
- package/dist/images/index.d.ts +35 -0
- package/dist/images/index.d.ts.map +1 -1
- package/dist/images/index.js +35 -0
- package/dist/images/index.js.map +1 -1
- package/dist/images/repositories/images-command-repository.interface.d.ts +43 -0
- package/dist/images/repositories/images-command-repository.interface.d.ts.map +1 -1
- package/dist/images/repositories/images-query-repository.interface.d.ts +59 -0
- package/dist/images/repositories/images-query-repository.interface.d.ts.map +1 -1
- package/dist/images/services/images-domain-service.d.ts +40 -0
- package/dist/images/services/images-domain-service.d.ts.map +1 -1
- package/dist/images/services/images-domain-service.js +50 -0
- package/dist/images/services/images-domain-service.js.map +1 -1
- package/dist/images/types/cache-strategy.d.ts +19 -0
- package/dist/images/types/cache-strategy.d.ts.map +1 -1
- package/dist/images/types/query-params.d.ts +44 -3
- package/dist/images/types/query-params.d.ts.map +1 -1
- package/dist/images/types/sort-order.d.ts +12 -0
- package/dist/images/types/sort-order.d.ts.map +1 -1
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -1
- package/dist/notes/entities/note-entity.d.ts +212 -6
- package/dist/notes/entities/note-entity.d.ts.map +1 -1
- package/dist/notes/entities/note-entity.js +182 -4
- package/dist/notes/entities/note-entity.js.map +1 -1
- package/dist/notes/events/note-created-event.d.ts +32 -0
- package/dist/notes/events/note-created-event.d.ts.map +1 -1
- package/dist/notes/events/note-created-event.js +32 -0
- package/dist/notes/events/note-created-event.js.map +1 -1
- package/dist/notes/events/note-deleted-event.d.ts +30 -0
- package/dist/notes/events/note-deleted-event.d.ts.map +1 -1
- package/dist/notes/events/note-deleted-event.js +30 -0
- package/dist/notes/events/note-deleted-event.js.map +1 -1
- package/dist/notes/index.d.ts +32 -0
- package/dist/notes/index.d.ts.map +1 -1
- package/dist/notes/index.js +32 -0
- package/dist/notes/index.js.map +1 -1
- package/dist/notes/repositories/notes-command-repository.interface.d.ts +37 -0
- package/dist/notes/repositories/notes-command-repository.interface.d.ts.map +1 -1
- package/dist/notes/repositories/notes-query-repository.interface.d.ts +53 -0
- package/dist/notes/repositories/notes-query-repository.interface.d.ts.map +1 -1
- package/dist/notes/services/notes-domain-service.d.ts +40 -0
- package/dist/notes/services/notes-domain-service.d.ts.map +1 -1
- package/dist/notes/services/notes-domain-service.js +50 -0
- package/dist/notes/services/notes-domain-service.js.map +1 -1
- package/dist/notes/types/cache-strategy.d.ts +19 -0
- package/dist/notes/types/cache-strategy.d.ts.map +1 -1
- package/dist/notes/types/query-params.d.ts +44 -3
- package/dist/notes/types/query-params.d.ts.map +1 -1
- package/dist/notes/types/sort-order.d.ts +12 -0
- package/dist/notes/types/sort-order.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -1,13 +1,52 @@
|
|
|
1
1
|
import sharp from "sharp";
|
|
2
2
|
import z from "zod";
|
|
3
|
-
import { CreatedAt, ExportedStatus, Id, makeCreatedAt, makeExportedStatus, makeId, UnexportedStatus, UserId, } from "../../common/entities/common-entity";
|
|
3
|
+
import { CreatedAt, ExportedStatus, Id, LastUpdatedStatus, makeCreatedAt, makeExportedStatus, makeId, UnexportedStatus, UserId, } from "../../common/entities/common-entity";
|
|
4
4
|
import { createEntityWithErrorHandling } from "../../common/services/entity-factory";
|
|
5
5
|
import { idGenerator } from "../../common/services/id-generator";
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Width of generated thumbnails in pixels.
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
7
10
|
const THUMBNAIL_WIDTH = 192;
|
|
11
|
+
/**
|
|
12
|
+
* Height of generated thumbnails in pixels.
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
8
15
|
const THUMBNAIL_HEIGHT = 192;
|
|
9
16
|
// Value objects
|
|
17
|
+
/**
|
|
18
|
+
* Zod schema for validating image paths.
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* Validates that the path is a non-empty string.
|
|
22
|
+
* Paths are stored in MinIO object storage.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* const path = Path.parse("01912c9a-image.jpg");
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @see {@link makePath} for factory function
|
|
30
|
+
*/
|
|
10
31
|
export const Path = z.string().min(1).brand();
|
|
32
|
+
/**
|
|
33
|
+
* Creates a validated Path from a string.
|
|
34
|
+
*
|
|
35
|
+
* @param v - The raw path or filename string
|
|
36
|
+
* @param sanitizeAndUnique - If true, sanitizes the filename and prepends a UUIDv7
|
|
37
|
+
* @returns A branded Path value
|
|
38
|
+
* @throws {ZodError} When the path is empty
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* // Create unique path from user-uploaded filename
|
|
43
|
+
* const path = makePath("my image.jpg", true);
|
|
44
|
+
* // Result: "01912c9a-5e8a-7b5c-8a1b-2c3d4e5f6a7b-myimage.jpg"
|
|
45
|
+
*
|
|
46
|
+
* // Use existing path as-is
|
|
47
|
+
* const existingPath = makePath("existing-path.jpg", false);
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
11
50
|
export const makePath = (v, sanitizeAndUnique) => {
|
|
12
51
|
if (sanitizeAndUnique) {
|
|
13
52
|
const sanitizedFileName = v.replaceAll(/[^a-zA-Z0-9._-]/g, "");
|
|
@@ -16,41 +55,196 @@ export const makePath = (v, sanitizeAndUnique) => {
|
|
|
16
55
|
}
|
|
17
56
|
return Path.parse(v);
|
|
18
57
|
};
|
|
58
|
+
/**
|
|
59
|
+
* Zod schema for validating image content types.
|
|
60
|
+
*
|
|
61
|
+
* @remarks
|
|
62
|
+
* Only allows JPEG, PNG, and GIF formats.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* const type = ContentType.parse("image/jpeg");
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* @see {@link makeContentType} for factory function
|
|
70
|
+
*/
|
|
19
71
|
export const ContentType = z
|
|
20
72
|
.enum(["image/jpeg", "image/png", "image/gif", "jpeg", "png"])
|
|
21
73
|
.brand();
|
|
74
|
+
/**
|
|
75
|
+
* Creates a validated ContentType from a string.
|
|
76
|
+
*
|
|
77
|
+
* @param v - The MIME type or format string
|
|
78
|
+
* @returns A branded ContentType value
|
|
79
|
+
* @throws {ZodError} When the content type is not supported
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```typescript
|
|
83
|
+
* const type = makeContentType("image/jpeg");
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
22
86
|
export const makeContentType = (v) => ContentType.parse(v);
|
|
87
|
+
/**
|
|
88
|
+
* Zod schema for validating file sizes.
|
|
89
|
+
*
|
|
90
|
+
* @remarks
|
|
91
|
+
* Validates that the size is a non-negative integer up to 100MB.
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```typescript
|
|
95
|
+
* const size = FileSize.parse(1024 * 1024); // 1MB
|
|
96
|
+
* ```
|
|
97
|
+
*
|
|
98
|
+
* @see {@link makeFileSize} for factory function
|
|
99
|
+
*/
|
|
23
100
|
export const FileSize = z
|
|
24
101
|
.number()
|
|
25
102
|
.int()
|
|
26
103
|
.nonnegative()
|
|
27
104
|
.max(100 * 1024 * 1024) // 100MB
|
|
28
105
|
.brand();
|
|
106
|
+
/**
|
|
107
|
+
* Creates a validated FileSize from a number.
|
|
108
|
+
*
|
|
109
|
+
* @param v - The file size in bytes
|
|
110
|
+
* @returns A branded FileSize value
|
|
111
|
+
* @throws {ZodError} When the size exceeds 100MB or is negative
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```typescript
|
|
115
|
+
* const size = makeFileSize(1024 * 1024); // 1MB
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
29
118
|
export const makeFileSize = (v) => FileSize.parse(v);
|
|
119
|
+
/**
|
|
120
|
+
* Zod schema for validating pixel dimensions.
|
|
121
|
+
*
|
|
122
|
+
* @remarks
|
|
123
|
+
* Validates that the value is a positive integer.
|
|
124
|
+
* Optional to handle cases where dimensions cannot be determined.
|
|
125
|
+
*
|
|
126
|
+
* @see {@link makePixel} for factory function
|
|
127
|
+
*/
|
|
30
128
|
export const Pixel = z.number().int().positive().optional().brand();
|
|
129
|
+
/**
|
|
130
|
+
* Creates a validated Pixel from a number.
|
|
131
|
+
*
|
|
132
|
+
* @param v - The pixel dimension value
|
|
133
|
+
* @returns A branded Pixel value
|
|
134
|
+
* @throws {ZodError} When the value is not a positive integer
|
|
135
|
+
*/
|
|
31
136
|
export const makePixel = (v) => Pixel.parse(v);
|
|
137
|
+
/**
|
|
138
|
+
* Zod schema for validating image tags.
|
|
139
|
+
*
|
|
140
|
+
* @remarks
|
|
141
|
+
* Tags are non-empty strings used for organizing images.
|
|
142
|
+
*
|
|
143
|
+
* @see {@link makeTag} for factory function
|
|
144
|
+
*/
|
|
32
145
|
export const Tag = z.string().min(1).brand();
|
|
146
|
+
/**
|
|
147
|
+
* Creates a validated Tag from a string.
|
|
148
|
+
*
|
|
149
|
+
* @param v - The tag string
|
|
150
|
+
* @returns A branded Tag value
|
|
151
|
+
* @throws {ZodError} When the tag is empty
|
|
152
|
+
*/
|
|
33
153
|
export const makeTag = (v) => Tag.parse(v);
|
|
154
|
+
/**
|
|
155
|
+
* Zod schema for validating image descriptions.
|
|
156
|
+
*
|
|
157
|
+
* @remarks
|
|
158
|
+
* Optional non-empty string for describing the image content.
|
|
159
|
+
*
|
|
160
|
+
* @see {@link makeDescription} for factory function
|
|
161
|
+
*/
|
|
34
162
|
export const Description = z.string().min(1).optional().brand();
|
|
163
|
+
/**
|
|
164
|
+
* Creates a validated Description from a string.
|
|
165
|
+
*
|
|
166
|
+
* @param v - The description string
|
|
167
|
+
* @returns A branded Description value
|
|
168
|
+
* @throws {ZodError} When the description is empty
|
|
169
|
+
*/
|
|
35
170
|
export const makeDescription = (v) => Description.parse(v);
|
|
171
|
+
/**
|
|
172
|
+
* Converts a File object to a Buffer.
|
|
173
|
+
*
|
|
174
|
+
* @param file - The File object to convert
|
|
175
|
+
* @returns A Buffer containing the file data
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* ```typescript
|
|
179
|
+
* const buffer = await makeOriginalBuffer(uploadedFile);
|
|
180
|
+
* ```
|
|
181
|
+
*/
|
|
36
182
|
export const makeOriginalBuffer = async (file) => {
|
|
37
183
|
return Buffer.from(await file.arrayBuffer());
|
|
38
184
|
};
|
|
185
|
+
/**
|
|
186
|
+
* Creates a thumbnail buffer from a File object.
|
|
187
|
+
*
|
|
188
|
+
* @remarks
|
|
189
|
+
* Resizes the image to 192x192 pixels using sharp.
|
|
190
|
+
*
|
|
191
|
+
* @param file - The File object to create a thumbnail from
|
|
192
|
+
* @returns A Buffer containing the thumbnail image data
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* ```typescript
|
|
196
|
+
* const thumbnail = await makeThumbnailBufferFromFile(uploadedFile);
|
|
197
|
+
* ```
|
|
198
|
+
*/
|
|
39
199
|
export const makeThumbnailBufferFromFile = async (file) => {
|
|
40
200
|
const originalBuffer = Buffer.from(await file.arrayBuffer());
|
|
41
201
|
return await sharp(originalBuffer)
|
|
42
202
|
.resize(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT)
|
|
43
203
|
.toBuffer();
|
|
44
204
|
};
|
|
205
|
+
/**
|
|
206
|
+
* Creates a thumbnail buffer from an existing Buffer.
|
|
207
|
+
*
|
|
208
|
+
* @remarks
|
|
209
|
+
* Resizes the image to 192x192 pixels using sharp.
|
|
210
|
+
*
|
|
211
|
+
* @param buffer - The Buffer to create a thumbnail from
|
|
212
|
+
* @returns A Buffer containing the thumbnail image data
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* ```typescript
|
|
216
|
+
* const thumbnail = await makeThumbnailBufferFromBuffer(imageBuffer);
|
|
217
|
+
* ```
|
|
218
|
+
*/
|
|
45
219
|
export const makeThumbnailBufferFromBuffer = async (buffer) => {
|
|
46
220
|
return await sharp(buffer)
|
|
47
221
|
.resize(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT)
|
|
48
222
|
.toBuffer();
|
|
49
223
|
};
|
|
224
|
+
/**
|
|
225
|
+
* Extracts metadata from an image buffer.
|
|
226
|
+
*
|
|
227
|
+
* @remarks
|
|
228
|
+
* Uses sharp to extract image metadata including dimensions, format, etc.
|
|
229
|
+
*
|
|
230
|
+
* @param buffer - The image buffer to analyze
|
|
231
|
+
* @returns The image metadata from sharp
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* ```typescript
|
|
235
|
+
* const metadata = await makeMetadata(imageBuffer);
|
|
236
|
+
* console.log(metadata.width, metadata.height);
|
|
237
|
+
* ```
|
|
238
|
+
*/
|
|
50
239
|
export const makeMetadata = async (buffer) => {
|
|
51
240
|
return sharp(buffer).metadata();
|
|
52
241
|
};
|
|
53
242
|
// Entities
|
|
243
|
+
/**
|
|
244
|
+
* Base schema containing common image fields.
|
|
245
|
+
*
|
|
246
|
+
* @internal
|
|
247
|
+
*/
|
|
54
248
|
const Base = z.object({
|
|
55
249
|
id: Id,
|
|
56
250
|
userId: UserId,
|
|
@@ -63,9 +257,69 @@ const Base = z.object({
|
|
|
63
257
|
description: Description,
|
|
64
258
|
createdAt: CreatedAt,
|
|
65
259
|
});
|
|
260
|
+
/**
|
|
261
|
+
* Zod schema for an unexported image.
|
|
262
|
+
*
|
|
263
|
+
* @remarks
|
|
264
|
+
* Represents an image that has not yet been published.
|
|
265
|
+
* This is the initial state of all newly created images.
|
|
266
|
+
*
|
|
267
|
+
* @see {@link ExportedImage} for the published state
|
|
268
|
+
*/
|
|
66
269
|
export const UnexportedImage = Base.extend({ status: UnexportedStatus });
|
|
67
|
-
|
|
270
|
+
/**
|
|
271
|
+
* Zod schema for an exported image.
|
|
272
|
+
*
|
|
273
|
+
* @remarks
|
|
274
|
+
* Represents an image that has been published.
|
|
275
|
+
* Includes the exportedAt timestamp.
|
|
276
|
+
*
|
|
277
|
+
* @see {@link UnexportedImage} for the initial state
|
|
278
|
+
*/
|
|
279
|
+
export const ExportedImage = Base.extend(ExportedStatus.shape);
|
|
280
|
+
/**
|
|
281
|
+
* Zod schema for an image marked for export in the current batch.
|
|
282
|
+
*
|
|
283
|
+
* @remarks
|
|
284
|
+
* Represents an image that has been marked for export but not yet finalized.
|
|
285
|
+
* This intermediate state allows for batch processing with revert capability.
|
|
286
|
+
*
|
|
287
|
+
* @see {@link UnexportedImage} for the initial state
|
|
288
|
+
* @see {@link ExportedImage} for the final state
|
|
289
|
+
*/
|
|
290
|
+
export const LastUpdatedImage = Base.extend({ status: LastUpdatedStatus });
|
|
291
|
+
/**
|
|
292
|
+
* Factory object for Image domain entity operations.
|
|
293
|
+
*
|
|
294
|
+
* @remarks
|
|
295
|
+
* Provides immutable entity creation following DDD patterns.
|
|
296
|
+
* All returned entities are frozen using Object.freeze().
|
|
297
|
+
*
|
|
298
|
+
* @example
|
|
299
|
+
* ```typescript
|
|
300
|
+
* // Create a new unexported image
|
|
301
|
+
* const image = imageEntity.create({
|
|
302
|
+
* userId: makeUserId("user-123"),
|
|
303
|
+
* path: makePath("image.jpg", true),
|
|
304
|
+
* contentType: makeContentType("image/jpeg"),
|
|
305
|
+
* fileSize: makeFileSize(1024),
|
|
306
|
+
* });
|
|
307
|
+
*
|
|
308
|
+
* // Export the image (changes status to EXPORTED)
|
|
309
|
+
* const exported = imageEntity.export(image);
|
|
310
|
+
* ```
|
|
311
|
+
*
|
|
312
|
+
* @see {@link CreateImageArgs} for creation parameters
|
|
313
|
+
*/
|
|
68
314
|
export const imageEntity = {
|
|
315
|
+
/**
|
|
316
|
+
* Creates a new unexported image entity.
|
|
317
|
+
*
|
|
318
|
+
* @param args - The creation arguments containing required fields
|
|
319
|
+
* @returns A frozen UnexportedImage instance with generated id and timestamps
|
|
320
|
+
* @throws {InvalidFormatError} When validation of any field fails
|
|
321
|
+
* @throws {UnexpectedError} For unexpected errors during creation
|
|
322
|
+
*/
|
|
69
323
|
create: (args) => {
|
|
70
324
|
return createEntityWithErrorHandling(() => Object.freeze({
|
|
71
325
|
id: makeId(),
|
|
@@ -74,6 +328,14 @@ export const imageEntity = {
|
|
|
74
328
|
...args,
|
|
75
329
|
}));
|
|
76
330
|
},
|
|
331
|
+
/**
|
|
332
|
+
* Transitions an image from UNEXPORTED to EXPORTED status.
|
|
333
|
+
*
|
|
334
|
+
* @param image - The unexported image to export
|
|
335
|
+
* @returns A frozen ExportedImage with exportedAt timestamp
|
|
336
|
+
* @throws {InvalidFormatError} When the image state is invalid
|
|
337
|
+
* @throws {UnexpectedError} For unexpected errors during export
|
|
338
|
+
*/
|
|
77
339
|
export: (image) => {
|
|
78
340
|
return createEntityWithErrorHandling(() => {
|
|
79
341
|
const exportedStatus = makeExportedStatus();
|
|
@@ -83,5 +345,60 @@ export const imageEntity = {
|
|
|
83
345
|
});
|
|
84
346
|
});
|
|
85
347
|
},
|
|
348
|
+
/**
|
|
349
|
+
* Marks an image for export in the current batch.
|
|
350
|
+
*
|
|
351
|
+
* @remarks
|
|
352
|
+
* Transitions from UNEXPORTED to LAST_UPDATED status.
|
|
353
|
+
* This allows for batch processing with revert capability.
|
|
354
|
+
*
|
|
355
|
+
* @param image - The unexported image to mark
|
|
356
|
+
* @returns A frozen LastUpdatedImage
|
|
357
|
+
* @throws {InvalidFormatError} When the image state is invalid
|
|
358
|
+
* @throws {UnexpectedError} For unexpected errors
|
|
359
|
+
*/
|
|
360
|
+
markAsLastUpdated: (image) => {
|
|
361
|
+
return createEntityWithErrorHandling(() => Object.freeze({
|
|
362
|
+
...image,
|
|
363
|
+
status: "LAST_UPDATED",
|
|
364
|
+
}));
|
|
365
|
+
},
|
|
366
|
+
/**
|
|
367
|
+
* Reverts an image from LAST_UPDATED back to UNEXPORTED.
|
|
368
|
+
*
|
|
369
|
+
* @remarks
|
|
370
|
+
* Use this when batch processing fails and needs to be rolled back.
|
|
371
|
+
*
|
|
372
|
+
* @param image - The last updated image to revert
|
|
373
|
+
* @returns A frozen UnexportedImage
|
|
374
|
+
* @throws {InvalidFormatError} When the image state is invalid
|
|
375
|
+
* @throws {UnexpectedError} For unexpected errors
|
|
376
|
+
*/
|
|
377
|
+
revert: (image) => {
|
|
378
|
+
return createEntityWithErrorHandling(() => Object.freeze({
|
|
379
|
+
...image,
|
|
380
|
+
status: "UNEXPORTED",
|
|
381
|
+
}));
|
|
382
|
+
},
|
|
383
|
+
/**
|
|
384
|
+
* Finalizes an image from LAST_UPDATED to EXPORTED.
|
|
385
|
+
*
|
|
386
|
+
* @remarks
|
|
387
|
+
* Use this after batch processing succeeds to confirm the export.
|
|
388
|
+
*
|
|
389
|
+
* @param image - The last updated image to finalize
|
|
390
|
+
* @returns A frozen ExportedImage with exportedAt timestamp
|
|
391
|
+
* @throws {InvalidFormatError} When the image state is invalid
|
|
392
|
+
* @throws {UnexpectedError} For unexpected errors
|
|
393
|
+
*/
|
|
394
|
+
finalize: (image) => {
|
|
395
|
+
return createEntityWithErrorHandling(() => {
|
|
396
|
+
const exportedStatus = makeExportedStatus();
|
|
397
|
+
return Object.freeze({
|
|
398
|
+
...image,
|
|
399
|
+
...exportedStatus,
|
|
400
|
+
});
|
|
401
|
+
});
|
|
402
|
+
},
|
|
86
403
|
};
|
|
87
404
|
//# sourceMappingURL=image-entity.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-entity.js","sourceRoot":"","sources":["../../../images/entities/image-entity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,CAAC,MAAM,KAAK,CAAC;AACpB,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;AACrF,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAEjE
|
|
1
|
+
{"version":3,"file":"image-entity.js","sourceRoot":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C,MAAM,CAAC,MAAM,CAAC;YACb,GAAG,KAAK;YACR,MAAM,EAAE,cAAuB;SAC/B,CAAC,CACF,CAAC;IACH,CAAC;IAED;;;;;;;;;;OAUG;IACH,MAAM,EAAE,CAAC,KAAuB,EAAmB,EAAE;QACpD,OAAO,6BAA6B,CAAC,GAAG,EAAE,CACzC,MAAM,CAAC,MAAM,CAAC;YACb,GAAG,KAAK;YACR,MAAM,EAAE,YAAqB;SAC7B,CAAC,CACF,CAAC;IACH,CAAC;IAED;;;;;;;;;;OAUG;IACH,QAAQ,EAAE,CAAC,KAAuB,EAAiB,EAAE;QACpD,OAAO,6BAA6B,CAAC,GAAG,EAAE;YACzC,MAAM,cAAc,GAAG,kBAAkB,EAAE,CAAC;YAC5C,OAAO,MAAM,CAAC,MAAM,CAAC;gBACpB,GAAG,KAAK;gBACR,GAAG,cAAc;aACjB,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACJ,CAAC;CACD,CAAC"}
|
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
import { BaseDomainEvent } from "../../common/events/base-domain-event";
|
|
2
|
+
/**
|
|
3
|
+
* Domain event emitted when an image 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 ImageCreatedEvent({
|
|
12
|
+
* id: "01912c9a-5e8a-7b5c-8a1b-2c3d4e5f6a7b-image.jpg",
|
|
13
|
+
* userId: "user-123",
|
|
14
|
+
* caller: "addImage",
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
* // event.eventType === "image.created"
|
|
18
|
+
* await eventHandler.handle(event);
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @see {@link BaseDomainEvent} for base class
|
|
22
|
+
* @see {@link ImageDeletedEvent} for deletion event
|
|
23
|
+
*/
|
|
2
24
|
export declare class ImageCreatedEvent extends BaseDomainEvent {
|
|
25
|
+
/**
|
|
26
|
+
* Creates a new ImageCreatedEvent.
|
|
27
|
+
*
|
|
28
|
+
* @param data - Event data containing image details and metadata
|
|
29
|
+
* @param data.id - The image ID (used as filename in payload)
|
|
30
|
+
* @param data.userId - The user who created the image
|
|
31
|
+
* @param data.caller - The function/method that triggered the event
|
|
32
|
+
*/
|
|
3
33
|
constructor(data: {
|
|
4
34
|
id: string;
|
|
5
35
|
userId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-created-event.d.ts","sourceRoot":"","sources":["../../../images/events/image-created-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAExE,qBAAa,iBAAkB,SAAQ,eAAe;
|
|
1
|
+
{"version":3,"file":"image-created-event.d.ts","sourceRoot":"","sources":["../../../images/events/image-created-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAExE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,iBAAkB,SAAQ,eAAe;IACrD;;;;;;;OAOG;gBACS,IAAI,EAAE;QACjB,EAAE,EAAE,MAAM,CAAC;QACX,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 image 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 ImageCreatedEvent({
|
|
12
|
+
* id: "01912c9a-5e8a-7b5c-8a1b-2c3d4e5f6a7b-image.jpg",
|
|
13
|
+
* userId: "user-123",
|
|
14
|
+
* caller: "addImage",
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
* // event.eventType === "image.created"
|
|
18
|
+
* await eventHandler.handle(event);
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @see {@link BaseDomainEvent} for base class
|
|
22
|
+
* @see {@link ImageDeletedEvent} for deletion event
|
|
23
|
+
*/
|
|
2
24
|
export class ImageCreatedEvent extends BaseDomainEvent {
|
|
25
|
+
/**
|
|
26
|
+
* Creates a new ImageCreatedEvent.
|
|
27
|
+
*
|
|
28
|
+
* @param data - Event data containing image details and metadata
|
|
29
|
+
* @param data.id - The image ID (used as filename in payload)
|
|
30
|
+
* @param data.userId - The user who created the image
|
|
31
|
+
* @param data.caller - The function/method that triggered the event
|
|
32
|
+
*/
|
|
3
33
|
constructor(data) {
|
|
4
34
|
super("image.created", {
|
|
5
35
|
fileName: data.id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-created-event.js","sourceRoot":"","sources":["../../../images/events/image-created-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAExE,MAAM,OAAO,iBAAkB,SAAQ,eAAe;IACrD,YAAY,IAIX;QACA,KAAK,CACJ,eAAe,EACf;YACC,QAAQ,EAAE,IAAI,CAAC,EAAE;SACjB,EACD;YACC,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,MAAM,EAAE,IAAI,CAAC,MAAM;SACnB,CACD,CAAC;IACH,CAAC;CACD"}
|
|
1
|
+
{"version":3,"file":"image-created-event.js","sourceRoot":"","sources":["../../../images/events/image-created-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAExE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,iBAAkB,SAAQ,eAAe;IACrD;;;;;;;OAOG;IACH,YAAY,IAIX;QACA,KAAK,CACJ,eAAe,EACf;YACC,QAAQ,EAAE,IAAI,CAAC,EAAE;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 an image 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 ImageDeletedEvent({
|
|
12
|
+
* path: "01912c9a-5e8a-7b5c-8a1b-2c3d4e5f6a7b-image.jpg",
|
|
13
|
+
* userId: "user-123",
|
|
14
|
+
* caller: "deleteImage",
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
* // event.eventType === "image.deleted"
|
|
18
|
+
* await eventHandler.handle(event);
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @see {@link BaseDomainEvent} for base class
|
|
22
|
+
* @see {@link ImageCreatedEvent} for creation event
|
|
23
|
+
*/
|
|
2
24
|
export declare class ImageDeletedEvent extends BaseDomainEvent {
|
|
25
|
+
/**
|
|
26
|
+
* Creates a new ImageDeletedEvent.
|
|
27
|
+
*
|
|
28
|
+
* @param data - Event data containing deletion details
|
|
29
|
+
* @param data.path - The storage path of the deleted image
|
|
30
|
+
* @param data.userId - The user who deleted the image
|
|
31
|
+
* @param data.caller - The function/method that triggered the event
|
|
32
|
+
*/
|
|
3
33
|
constructor(data: {
|
|
4
34
|
path: string;
|
|
5
35
|
userId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-deleted-event.d.ts","sourceRoot":"","sources":["../../../images/events/image-deleted-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAExE,qBAAa,iBAAkB,SAAQ,eAAe;
|
|
1
|
+
{"version":3,"file":"image-deleted-event.d.ts","sourceRoot":"","sources":["../../../images/events/image-deleted-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAExE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,iBAAkB,SAAQ,eAAe;IACrD;;;;;;;OAOG;gBACS,IAAI,EAAE;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,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 image 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 ImageDeletedEvent({
|
|
12
|
+
* path: "01912c9a-5e8a-7b5c-8a1b-2c3d4e5f6a7b-image.jpg",
|
|
13
|
+
* userId: "user-123",
|
|
14
|
+
* caller: "deleteImage",
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
* // event.eventType === "image.deleted"
|
|
18
|
+
* await eventHandler.handle(event);
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @see {@link BaseDomainEvent} for base class
|
|
22
|
+
* @see {@link ImageCreatedEvent} for creation event
|
|
23
|
+
*/
|
|
2
24
|
export class ImageDeletedEvent extends BaseDomainEvent {
|
|
25
|
+
/**
|
|
26
|
+
* Creates a new ImageDeletedEvent.
|
|
27
|
+
*
|
|
28
|
+
* @param data - Event data containing deletion details
|
|
29
|
+
* @param data.path - The storage path of the deleted image
|
|
30
|
+
* @param data.userId - The user who deleted the image
|
|
31
|
+
* @param data.caller - The function/method that triggered the event
|
|
32
|
+
*/
|
|
3
33
|
constructor(data) {
|
|
4
34
|
super("image.deleted", {
|
|
5
35
|
path: data.path,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-deleted-event.js","sourceRoot":"","sources":["../../../images/events/image-deleted-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAExE,MAAM,OAAO,iBAAkB,SAAQ,eAAe;IACrD,YAAY,IAIX;QACA,KAAK,CACJ,eAAe,EACf;YACC,IAAI,EAAE,IAAI,CAAC,IAAI;SACf,EACD;YACC,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,MAAM,EAAE,IAAI,CAAC,MAAM;SACnB,CACD,CAAC;IACH,CAAC;CACD"}
|
|
1
|
+
{"version":3,"file":"image-deleted-event.js","sourceRoot":"","sources":["../../../images/events/image-deleted-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAExE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,iBAAkB,SAAQ,eAAe;IACrD;;;;;;;OAOG;IACH,YAAY,IAIX;QACA,KAAK,CACJ,eAAe,EACf;YACC,IAAI,EAAE,IAAI,CAAC,IAAI;SACf,EACD;YACC,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,MAAM,EAAE,IAAI,CAAC,MAAM;SACnB,CACD,CAAC;IACH,CAAC;CACD"}
|
package/dist/images/index.d.ts
CHANGED
|
@@ -1,3 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
*
|
|
4
|
+
* Images domain for file metadata and image processing.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Provides complete domain implementation for image management including:
|
|
8
|
+
*
|
|
9
|
+
* - **Entities** - Image 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
|
+
* Images support metadata extraction (dimensions, file size, content type),
|
|
16
|
+
* thumbnail generation, and tag-based organization.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* import {
|
|
21
|
+
* imageEntity,
|
|
22
|
+
* makePath,
|
|
23
|
+
* makeTag,
|
|
24
|
+
* makeThumbnailBufferFromFile,
|
|
25
|
+
* ImageCreatedEvent,
|
|
26
|
+
* } from "@repo/core/images";
|
|
27
|
+
*
|
|
28
|
+
* const thumbnail = await makeThumbnailBufferFromFile(file);
|
|
29
|
+
* const image = imageEntity.create({
|
|
30
|
+
* userId: makeUserId("user-123"),
|
|
31
|
+
* path: makePath("uuid-image.jpg"),
|
|
32
|
+
* tags: [makeTag("nature"), makeTag("landscape")],
|
|
33
|
+
* });
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
1
36
|
export * from "./entities/image-entity";
|
|
2
37
|
export * from "./events/image-created-event";
|
|
3
38
|
export * from "./events/image-deleted-event";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../images/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../images/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAGH,cAAc,yBAAyB,CAAC;AAGxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAG7C,cAAc,oDAAoD,CAAC;AACnE,cAAc,kDAAkD,CAAC;AAGjE,cAAc,kCAAkC,CAAC;AAGjD,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC"}
|
package/dist/images/index.js
CHANGED
|
@@ -1,3 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
*
|
|
4
|
+
* Images domain for file metadata and image processing.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Provides complete domain implementation for image management including:
|
|
8
|
+
*
|
|
9
|
+
* - **Entities** - Image 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
|
+
* Images support metadata extraction (dimensions, file size, content type),
|
|
16
|
+
* thumbnail generation, and tag-based organization.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* import {
|
|
21
|
+
* imageEntity,
|
|
22
|
+
* makePath,
|
|
23
|
+
* makeTag,
|
|
24
|
+
* makeThumbnailBufferFromFile,
|
|
25
|
+
* ImageCreatedEvent,
|
|
26
|
+
* } from "@repo/core/images";
|
|
27
|
+
*
|
|
28
|
+
* const thumbnail = await makeThumbnailBufferFromFile(file);
|
|
29
|
+
* const image = imageEntity.create({
|
|
30
|
+
* userId: makeUserId("user-123"),
|
|
31
|
+
* path: makePath("uuid-image.jpg"),
|
|
32
|
+
* tags: [makeTag("nature"), makeTag("landscape")],
|
|
33
|
+
* });
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
1
36
|
// Entities
|
|
2
37
|
export * from "./entities/image-entity";
|
|
3
38
|
// Events
|
package/dist/images/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../images/index.ts"],"names":[],"mappings":"AAAA,WAAW;AACX,cAAc,yBAAyB,CAAC;AAExC,SAAS;AACT,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAE7C,eAAe;AACf,cAAc,oDAAoD,CAAC;AACnE,cAAc,kDAAkD,CAAC;AAEjE,WAAW;AACX,cAAc,kCAAkC,CAAC;AAEjD,QAAQ;AACR,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../images/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,WAAW;AACX,cAAc,yBAAyB,CAAC;AAExC,SAAS;AACT,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAE7C,eAAe;AACf,cAAc,oDAAoD,CAAC;AACnE,cAAc,kDAAkD,CAAC;AAEjE,WAAW;AACX,cAAc,kCAAkC,CAAC;AAEjD,QAAQ;AACR,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC"}
|