@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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"books-command-repository.interface.d.ts","sourceRoot":"","sources":["../../../books/repositories/books-command-repository.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE/D,MAAM,MAAM,uBAAuB,GAAG;IACrC,MAAM,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"books-command-repository.interface.d.ts","sourceRoot":"","sources":["../../../books/repositories/books-command-repository.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACrC;;;;OAIG;IACH,MAAM,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5C;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAElE;;;;;;;OAOG;IACH,mBAAmB,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;CACjD,CAAC"}
|
|
@@ -1,7 +1,35 @@
|
|
|
1
1
|
import type { Status, UserId } from "../../common/entities/common-entity";
|
|
2
2
|
import type { ISBN } from "../entities/books-entity";
|
|
3
3
|
import type { BooksFindManyParams } from "../types/query-params";
|
|
4
|
+
/**
|
|
5
|
+
* Query repository interface for the Book domain.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* Follows the CQRS pattern - this interface handles read operations only.
|
|
9
|
+
* Implementations should be provided by the infrastructure layer (e.g., Prisma).
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* // Infrastructure implementation
|
|
14
|
+
* class PrismaBooksQueryRepository implements IBooksQueryRepository {
|
|
15
|
+
* async findByISBN(ISBN: ISBN, userId: UserId) {
|
|
16
|
+
* return await prisma.book.findUnique({
|
|
17
|
+
* where: { ISBN, userId }
|
|
18
|
+
* });
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @see {@link IBooksCommandRepository} for write operations
|
|
24
|
+
*/
|
|
4
25
|
export type IBooksQueryRepository = {
|
|
26
|
+
/**
|
|
27
|
+
* Finds a book by its ISBN for a specific user.
|
|
28
|
+
*
|
|
29
|
+
* @param ISBN - The validated ISBN to search for
|
|
30
|
+
* @param userId - The user ID for tenant isolation
|
|
31
|
+
* @returns The book data if found, null otherwise
|
|
32
|
+
*/
|
|
5
33
|
findByISBN(ISBN: ISBN, userId: UserId): Promise<{
|
|
6
34
|
ISBN: string;
|
|
7
35
|
id: string;
|
|
@@ -20,6 +48,16 @@ export type IBooksQueryRepository = {
|
|
|
20
48
|
updatedAt: Date;
|
|
21
49
|
exportedAt: Date | null;
|
|
22
50
|
} | null>;
|
|
51
|
+
/**
|
|
52
|
+
* Retrieves multiple books with pagination and filtering.
|
|
53
|
+
*
|
|
54
|
+
* @param userId - The user ID for tenant isolation
|
|
55
|
+
* @param status - Filter by UNEXPORTED or EXPORTED status
|
|
56
|
+
* @param params - Optional pagination, sorting, and caching parameters
|
|
57
|
+
* @returns Array of book data objects
|
|
58
|
+
*
|
|
59
|
+
* @see {@link BooksFindManyParams} for parameter options
|
|
60
|
+
*/
|
|
23
61
|
findMany(userId: UserId, status: Status, params?: BooksFindManyParams): Promise<{
|
|
24
62
|
ISBN: string;
|
|
25
63
|
id: string;
|
|
@@ -37,7 +75,22 @@ export type IBooksQueryRepository = {
|
|
|
37
75
|
updatedAt: Date;
|
|
38
76
|
exportedAt: Date | null;
|
|
39
77
|
}[]>;
|
|
78
|
+
/**
|
|
79
|
+
* Counts books matching the given criteria.
|
|
80
|
+
*
|
|
81
|
+
* @param userId - The user ID for tenant isolation
|
|
82
|
+
* @param status - Filter by status
|
|
83
|
+
* @returns The count of matching books
|
|
84
|
+
*/
|
|
40
85
|
count(userId: UserId, status: Status): Promise<number>;
|
|
86
|
+
/**
|
|
87
|
+
* Searches books by text query.
|
|
88
|
+
*
|
|
89
|
+
* @param query - The search query string
|
|
90
|
+
* @param userId - The user ID for tenant isolation
|
|
91
|
+
* @param limit - Optional maximum number of results
|
|
92
|
+
* @returns Array of matching book data objects
|
|
93
|
+
*/
|
|
41
94
|
search(query: string, userId: UserId, limit?: number): Promise<{
|
|
42
95
|
id: string;
|
|
43
96
|
title: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"books-query-repository.interface.d.ts","sourceRoot":"","sources":["../../../books/repositories/books-query-repository.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEjE,MAAM,MAAM,qBAAqB,GAAG;IACnC,UAAU,CACT,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM,GACZ,OAAO,CAAC;QACV,IAAI,EAAE,MAAM,CAAC;QACb,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;QAC3B,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;QAC9B,aAAa,EAAE,MAAM,EAAE,CAAC;QACxB,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;QACjC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;QAC5B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;QAC1B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;QACxB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;QACtB,IAAI,EAAE,MAAM,EAAE,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,IAAI,CAAC;QAChB,SAAS,EAAE,IAAI,CAAC;QAChB,UAAU,EAAE,IAAI,GAAG,IAAI,CAAC;KACxB,GAAG,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"books-query-repository.interface.d.ts","sourceRoot":"","sources":["../../../books/repositories/books-query-repository.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEjE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,qBAAqB,GAAG;IACnC;;;;;;OAMG;IACH,UAAU,CACT,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM,GACZ,OAAO,CAAC;QACV,IAAI,EAAE,MAAM,CAAC;QACb,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;QAC3B,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;QAC9B,aAAa,EAAE,MAAM,EAAE,CAAC;QACxB,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;QACjC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;QAC5B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;QAC1B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;QACxB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;QACtB,IAAI,EAAE,MAAM,EAAE,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,IAAI,CAAC;QAChB,SAAS,EAAE,IAAI,CAAC;QAChB,UAAU,EAAE,IAAI,GAAG,IAAI,CAAC;KACxB,GAAG,IAAI,CAAC,CAAC;IAEV;;;;;;;;;OASG;IACH,QAAQ,CACP,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,mBAAmB,GAC1B,OAAO,CACT;QACC,IAAI,EAAE,MAAM,CAAC;QACb,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;QAC3B,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;QAC9B,aAAa,EAAE,MAAM,EAAE,CAAC;QACxB,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;QACjC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;QAC5B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;QAC1B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;QACxB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;QACtB,IAAI,EAAE,MAAM,EAAE,CAAC;QACf,SAAS,EAAE,IAAI,CAAC;QAChB,SAAS,EAAE,IAAI,CAAC;QAChB,UAAU,EAAE,IAAI,GAAG,IAAI,CAAC;KACxB,EAAE,CACH,CAAC;IAEF;;;;;;OAMG;IACH,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEvD;;;;;;;OAOG;IACH,MAAM,CACL,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,KAAK,CAAC,EAAE,MAAM,GACZ,OAAO,CACT;QACC,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;QAC3B,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;QAC9B,aAAa,EAAE,MAAM,EAAE,CAAC;QACxB,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;QACjC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;QACxB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;QACtB,IAAI,EAAE,MAAM,EAAE,CAAC;KACf,EAAE,CACH,CAAC;CACF,CAAC"}
|
|
@@ -1,9 +1,49 @@
|
|
|
1
1
|
import type { UserId } from "../../common/entities/common-entity";
|
|
2
2
|
import type { ISBN } from "../entities/books-entity";
|
|
3
3
|
import type { IBooksQueryRepository } from "../repositories/books-query-repository.interface";
|
|
4
|
+
/**
|
|
5
|
+
* Domain service for Book business logic.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* Encapsulates complex business rules that don't belong to a single entity.
|
|
9
|
+
* Uses dependency injection for repository access.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const queryRepo: IBooksQueryRepository = new PrismaBooksQueryRepository();
|
|
14
|
+
* const domainService = new BooksDomainService(queryRepo);
|
|
15
|
+
*
|
|
16
|
+
* try {
|
|
17
|
+
* await domainService.ensureNoDuplicate(isbn, userId);
|
|
18
|
+
* // Safe to create the book
|
|
19
|
+
* } catch (error) {
|
|
20
|
+
* if (error instanceof DuplicateError) {
|
|
21
|
+
* // Handle duplicate ISBN
|
|
22
|
+
* }
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @see {@link IBooksQueryRepository} for repository interface
|
|
27
|
+
* @see {@link DuplicateError} for duplicate handling
|
|
28
|
+
*/
|
|
4
29
|
export declare class BooksDomainService {
|
|
5
30
|
private readonly booksQueryRepository;
|
|
31
|
+
/**
|
|
32
|
+
* Creates a new BooksDomainService instance.
|
|
33
|
+
*
|
|
34
|
+
* @param booksQueryRepository - The query repository for checking duplicates
|
|
35
|
+
*/
|
|
6
36
|
constructor(booksQueryRepository: IBooksQueryRepository);
|
|
37
|
+
/**
|
|
38
|
+
* Validates that no book with the same ISBN exists for the user.
|
|
39
|
+
*
|
|
40
|
+
* @param ISBN - The ISBN to check for duplicates
|
|
41
|
+
* @param userId - The user ID for tenant isolation
|
|
42
|
+
* @throws {DuplicateError} When a book with this ISBN already exists
|
|
43
|
+
*
|
|
44
|
+
* @remarks
|
|
45
|
+
* This is a domain invariant check that should be called before creating books.
|
|
46
|
+
*/
|
|
7
47
|
ensureNoDuplicate(ISBN: ISBN, userId: UserId): Promise<void>;
|
|
8
48
|
}
|
|
9
49
|
//# sourceMappingURL=books-domain-service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"books-domain-service.d.ts","sourceRoot":"","sources":["../../../books/services/books-domain-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAElE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kDAAkD,CAAC;
|
|
1
|
+
{"version":3,"file":"books-domain-service.d.ts","sourceRoot":"","sources":["../../../books/services/books-domain-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAElE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kDAAkD,CAAC;AAqB9F;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,qBAAa,kBAAkB;IAMlB,OAAO,CAAC,QAAQ,CAAC,oBAAoB;IALjD;;;;OAIG;gBAC0B,oBAAoB,EAAE,qBAAqB;IAExE;;;;;;;;;OASG;IACU,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM;CAGzD"}
|
|
@@ -1,14 +1,64 @@
|
|
|
1
1
|
import { DuplicateError } from "../../errors/error-classes";
|
|
2
|
+
/**
|
|
3
|
+
* Checks if a book with the given ISBN already exists.
|
|
4
|
+
*
|
|
5
|
+
* @param booksQueryRepository - The query repository to check against
|
|
6
|
+
* @param ISBN - The ISBN to check for duplicates
|
|
7
|
+
* @param userId - The user ID for tenant isolation
|
|
8
|
+
* @throws {DuplicateError} When a book with this ISBN already exists
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
2
12
|
async function ensureNoDuplicateBook(booksQueryRepository, ISBN, userId) {
|
|
3
13
|
const exists = await booksQueryRepository.findByISBN(ISBN, userId);
|
|
4
14
|
if (exists !== null)
|
|
5
15
|
throw new DuplicateError();
|
|
6
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Domain service for Book business logic.
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* Encapsulates complex business rules that don't belong to a single entity.
|
|
22
|
+
* Uses dependency injection for repository access.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* const queryRepo: IBooksQueryRepository = new PrismaBooksQueryRepository();
|
|
27
|
+
* const domainService = new BooksDomainService(queryRepo);
|
|
28
|
+
*
|
|
29
|
+
* try {
|
|
30
|
+
* await domainService.ensureNoDuplicate(isbn, userId);
|
|
31
|
+
* // Safe to create the book
|
|
32
|
+
* } catch (error) {
|
|
33
|
+
* if (error instanceof DuplicateError) {
|
|
34
|
+
* // Handle duplicate ISBN
|
|
35
|
+
* }
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @see {@link IBooksQueryRepository} for repository interface
|
|
40
|
+
* @see {@link DuplicateError} for duplicate handling
|
|
41
|
+
*/
|
|
7
42
|
export class BooksDomainService {
|
|
8
43
|
booksQueryRepository;
|
|
44
|
+
/**
|
|
45
|
+
* Creates a new BooksDomainService instance.
|
|
46
|
+
*
|
|
47
|
+
* @param booksQueryRepository - The query repository for checking duplicates
|
|
48
|
+
*/
|
|
9
49
|
constructor(booksQueryRepository) {
|
|
10
50
|
this.booksQueryRepository = booksQueryRepository;
|
|
11
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Validates that no book with the same ISBN exists for the user.
|
|
54
|
+
*
|
|
55
|
+
* @param ISBN - The ISBN to check for duplicates
|
|
56
|
+
* @param userId - The user ID for tenant isolation
|
|
57
|
+
* @throws {DuplicateError} When a book with this ISBN already exists
|
|
58
|
+
*
|
|
59
|
+
* @remarks
|
|
60
|
+
* This is a domain invariant check that should be called before creating books.
|
|
61
|
+
*/
|
|
12
62
|
async ensureNoDuplicate(ISBN, userId) {
|
|
13
63
|
return ensureNoDuplicateBook(this.booksQueryRepository, ISBN, userId);
|
|
14
64
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"books-domain-service.js","sourceRoot":"","sources":["../../../books/services/books-domain-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAI5D,KAAK,UAAU,qBAAqB,CACnC,oBAA2C,EAC3C,IAAU,EACV,MAAc;IAEd,MAAM,MAAM,GAAG,MAAM,oBAAoB,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACnE,IAAI,MAAM,KAAK,IAAI;QAAE,MAAM,IAAI,cAAc,EAAE,CAAC;AACjD,CAAC;AAED,MAAM,OAAO,kBAAkB;
|
|
1
|
+
{"version":3,"file":"books-domain-service.js","sourceRoot":"","sources":["../../../books/services/books-domain-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAI5D;;;;;;;;;GASG;AACH,KAAK,UAAU,qBAAqB,CACnC,oBAA2C,EAC3C,IAAU,EACV,MAAc;IAEd,MAAM,MAAM,GAAG,MAAM,oBAAoB,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACnE,IAAI,MAAM,KAAK,IAAI;QAAE,MAAM,IAAI,cAAc,EAAE,CAAC;AACjD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,OAAO,kBAAkB;IAMD;IAL7B;;;;OAIG;IACH,YAA6B,oBAA2C;QAA3C,yBAAoB,GAApB,oBAAoB,CAAuB;IAAG,CAAC;IAE5E;;;;;;;;;OASG;IACI,KAAK,CAAC,iBAAiB,CAAC,IAAU,EAAE,MAAc;QACxD,OAAO,qBAAqB,CAAC,IAAI,CAAC,oBAAoB,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IACvE,CAAC;CACD"}
|
|
@@ -1,6 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cache configuration for repository queries.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Provides fine-grained control over caching behavior.
|
|
6
|
+
* Uses stale-while-revalidate (SWR) pattern for optimal performance.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const strategy: CacheStrategy = {
|
|
11
|
+
* ttl: 60, // Cache for 60 seconds
|
|
12
|
+
* swr: 300, // Serve stale for 5 minutes while revalidating
|
|
13
|
+
* tags: ["books"] // Cache tags for invalidation
|
|
14
|
+
* };
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
1
17
|
export type CacheStrategy = {
|
|
18
|
+
/** Time-to-live in seconds */
|
|
2
19
|
ttl?: number;
|
|
20
|
+
/** Stale-while-revalidate duration in seconds */
|
|
3
21
|
swr?: number;
|
|
22
|
+
/** Cache tags for targeted invalidation */
|
|
4
23
|
tags?: string[];
|
|
5
24
|
};
|
|
6
25
|
//# sourceMappingURL=cache-strategy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache-strategy.d.ts","sourceRoot":"","sources":["../../../books/types/cache-strategy.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CAChB,CAAC"}
|
|
1
|
+
{"version":3,"file":"cache-strategy.d.ts","sourceRoot":"","sources":["../../../books/types/cache-strategy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,aAAa,GAAG;IAC3B,8BAA8B;IAC9B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,iDAAiD;IACjD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,2CAA2C;IAC3C,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CAChB,CAAC"}
|
|
@@ -1,14 +1,55 @@
|
|
|
1
1
|
import type { CacheStrategy } from "./cache-strategy";
|
|
2
2
|
import type { SortOrder } from "./sort-order";
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Available fields for sorting book queries.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* All fields correspond to Book entity properties.
|
|
8
|
+
* Used with {@link BooksOrderBy} to specify sort criteria.
|
|
9
|
+
*/
|
|
10
|
+
export type BooksOrderByField = "id" | "ISBN" | "title" | "googleTitle" | "googleSubTitle" | "googleAuthors" | "googleDescription" | "googleImgSrc" | "googleHref" | "markdown" | "rating" | "tags" | "status" | "createdAt" | "updatedAt" | "exportedAt";
|
|
11
|
+
/**
|
|
12
|
+
* Sort configuration for book queries.
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
* Maps field names to sort directions.
|
|
16
|
+
* Typically only one field should be specified at a time.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const orderBy: BooksOrderBy = { createdAt: "desc" };
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @see {@link BooksOrderByField} for available fields
|
|
24
|
+
* @see {@link SortOrder} for sort directions
|
|
25
|
+
*/
|
|
26
|
+
export type BooksOrderBy = {
|
|
5
27
|
[K in BooksOrderByField]?: SortOrder;
|
|
6
28
|
};
|
|
29
|
+
/**
|
|
30
|
+
* Parameters for paginated book queries.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* const params: BooksFindManyParams = {
|
|
35
|
+
* orderBy: { createdAt: "desc" },
|
|
36
|
+
* take: 20,
|
|
37
|
+
* skip: 0,
|
|
38
|
+
* cacheStrategy: { ttl: 60, tags: ["books"] },
|
|
39
|
+
* };
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @see {@link BooksOrderBy} for sorting options
|
|
43
|
+
* @see {@link CacheStrategy} for caching configuration
|
|
44
|
+
*/
|
|
7
45
|
export type BooksFindManyParams = {
|
|
46
|
+
/** Sort configuration */
|
|
8
47
|
orderBy?: BooksOrderBy;
|
|
48
|
+
/** Maximum number of results to return */
|
|
9
49
|
take?: number;
|
|
50
|
+
/** Number of results to skip (for pagination) */
|
|
10
51
|
skip?: number;
|
|
52
|
+
/** Caching configuration for the query */
|
|
11
53
|
cacheStrategy?: CacheStrategy;
|
|
12
54
|
};
|
|
13
|
-
export {};
|
|
14
55
|
//# sourceMappingURL=query-params.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-params.d.ts","sourceRoot":"","sources":["../../../books/types/query-params.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,
|
|
1
|
+
{"version":3,"file":"query-params.d.ts","sourceRoot":"","sources":["../../../books/types/query-params.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,GAC1B,IAAI,GACJ,MAAM,GACN,OAAO,GACP,aAAa,GACb,gBAAgB,GAChB,eAAe,GACf,mBAAmB,GACnB,cAAc,GACd,YAAY,GACZ,UAAU,GACV,QAAQ,GACR,MAAM,GACN,QAAQ,GACR,WAAW,GACX,WAAW,GACX,YAAY,CAAC;AAEhB;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,YAAY,GAAG;KACzB,CAAC,IAAI,iBAAiB,CAAC,CAAC,EAAE,SAAS;CACpC,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,mBAAmB,GAAG;IACjC,yBAAyB;IACzB,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,0CAA0C;IAC1C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iDAAiD;IACjD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,0CAA0C;IAC1C,aAAa,CAAC,EAAE,aAAa,CAAC;CAC9B,CAAC"}
|
|
@@ -1,2 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sort direction for query ordering.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Standard SQL-style sort order used across all domain queries.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const ascending: SortOrder = "asc";
|
|
10
|
+
* const descending: SortOrder = "desc";
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
1
13
|
export type SortOrder = "asc" | "desc";
|
|
2
14
|
//# sourceMappingURL=sort-order.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sort-order.d.ts","sourceRoot":"","sources":["../../../books/types/sort-order.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,MAAM,CAAC"}
|
|
1
|
+
{"version":3,"file":"sort-order.d.ts","sourceRoot":"","sources":["../../../books/types/sort-order.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,MAAM,CAAC"}
|
|
@@ -1,25 +1,305 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Zod schema for validating UUIDv7 identifiers.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* UUIDv7 is time-ordered, making it suitable for database primary keys.
|
|
7
|
+
* Auto-generates a new UUIDv7 if no value is provided.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const id = Id.parse(undefined); // Auto-generates UUIDv7
|
|
12
|
+
* const id2 = Id.parse("01912c9a-5e8a-7b5c-8a1b-2c3d4e5f6a7b");
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @see {@link makeId} for factory function
|
|
16
|
+
*/
|
|
2
17
|
export declare const Id: z.core.$ZodBranded<z.ZodDefault<z.ZodUUID>, "Id">;
|
|
18
|
+
/**
|
|
19
|
+
* Branded type for validated UUIDv7 identifiers.
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* This type is branded to prevent accidental assignment of raw strings.
|
|
23
|
+
* Always use {@link makeId} to create instances.
|
|
24
|
+
*/
|
|
3
25
|
export type Id = z.infer<typeof Id>;
|
|
26
|
+
/**
|
|
27
|
+
* Creates a validated Id from an optional string.
|
|
28
|
+
*
|
|
29
|
+
* @param id - Optional UUIDv7 string. If not provided, generates a new one.
|
|
30
|
+
* @returns A branded Id value
|
|
31
|
+
* @throws {ZodError} When the provided string is not a valid UUIDv7
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const newId = makeId(); // Auto-generate
|
|
36
|
+
* const existingId = makeId("01912c9a-5e8a-7b5c-8a1b-2c3d4e5f6a7b");
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
4
39
|
export declare const makeId: (id?: string) => Id;
|
|
40
|
+
/**
|
|
41
|
+
* Zod schema for validating user identifiers.
|
|
42
|
+
*
|
|
43
|
+
* @remarks
|
|
44
|
+
* Validates that the user ID is a non-empty string.
|
|
45
|
+
* Used for multi-tenant data isolation across all domains.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* const userId = UserId.parse("auth0|123456789");
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @see {@link makeUserId} for factory function
|
|
53
|
+
*/
|
|
5
54
|
export declare const UserId: z.core.$ZodBranded<z.ZodString, "UserId">;
|
|
55
|
+
/**
|
|
56
|
+
* Branded type for validated user identifiers.
|
|
57
|
+
*
|
|
58
|
+
* @remarks
|
|
59
|
+
* This type is branded to prevent accidental assignment of raw strings.
|
|
60
|
+
* All domain entities include userId for tenant isolation.
|
|
61
|
+
*/
|
|
6
62
|
export type UserId = z.infer<typeof UserId>;
|
|
63
|
+
/**
|
|
64
|
+
* Creates a validated UserId from a string.
|
|
65
|
+
*
|
|
66
|
+
* @param v - The user ID string (typically from Auth0)
|
|
67
|
+
* @returns A branded UserId value
|
|
68
|
+
* @throws {ZodError} When the string is empty
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* const userId = makeUserId("auth0|123456789");
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
7
75
|
export declare const makeUserId: (v: string) => UserId;
|
|
76
|
+
/**
|
|
77
|
+
* Zod schema for validating creation timestamps.
|
|
78
|
+
*
|
|
79
|
+
* @remarks
|
|
80
|
+
* Validates that the value is a valid Date object.
|
|
81
|
+
* Used to track when entities are created.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* const timestamp = CreatedAt.parse(new Date());
|
|
86
|
+
* ```
|
|
87
|
+
*
|
|
88
|
+
* @see {@link makeCreatedAt} for factory function
|
|
89
|
+
*/
|
|
8
90
|
export declare const CreatedAt: z.core.$ZodBranded<z.ZodDate, "CreatedAt">;
|
|
91
|
+
/**
|
|
92
|
+
* Branded type for validated creation timestamps.
|
|
93
|
+
*/
|
|
9
94
|
export type CreatedAt = z.infer<typeof CreatedAt>;
|
|
95
|
+
/**
|
|
96
|
+
* Creates a validated CreatedAt timestamp.
|
|
97
|
+
*
|
|
98
|
+
* @param createdAt - Optional Date. If not provided, uses current time.
|
|
99
|
+
* @returns A branded CreatedAt value
|
|
100
|
+
* @throws {ZodError} When the value is not a valid Date
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```typescript
|
|
104
|
+
* const now = makeCreatedAt(); // Current time
|
|
105
|
+
* const specific = makeCreatedAt(new Date("2024-01-01"));
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
10
108
|
export declare const makeCreatedAt: (createdAt?: Date) => CreatedAt;
|
|
109
|
+
/**
|
|
110
|
+
* Zod schema for validating update timestamps.
|
|
111
|
+
*
|
|
112
|
+
* @remarks
|
|
113
|
+
* Validates that the value is a valid Date object.
|
|
114
|
+
* Used to track when entities are last modified.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```typescript
|
|
118
|
+
* const timestamp = UpdatedAt.parse(new Date());
|
|
119
|
+
* ```
|
|
120
|
+
*
|
|
121
|
+
* @see {@link makeUpdatedAt} for factory function
|
|
122
|
+
*/
|
|
123
|
+
export declare const UpdatedAt: z.core.$ZodBranded<z.ZodDate, "UpdatedAt">;
|
|
124
|
+
/**
|
|
125
|
+
* Branded type for validated update timestamps.
|
|
126
|
+
*/
|
|
127
|
+
export type UpdatedAt = z.infer<typeof UpdatedAt>;
|
|
128
|
+
/**
|
|
129
|
+
* Creates a validated UpdatedAt timestamp.
|
|
130
|
+
*
|
|
131
|
+
* @param updatedAt - Optional Date. If not provided, uses current time.
|
|
132
|
+
* @returns A branded UpdatedAt value
|
|
133
|
+
* @throws {ZodError} When the value is not a valid Date
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```typescript
|
|
137
|
+
* const now = makeUpdatedAt(); // Current time
|
|
138
|
+
* const specific = makeUpdatedAt(new Date("2024-01-01"));
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
export declare const makeUpdatedAt: (updatedAt?: Date) => UpdatedAt;
|
|
142
|
+
/**
|
|
143
|
+
* Zod schema for the UNEXPORTED status literal.
|
|
144
|
+
*
|
|
145
|
+
* @remarks
|
|
146
|
+
* Represents the initial state of all content entities.
|
|
147
|
+
* Content transitions from UNEXPORTED to EXPORTED when published.
|
|
148
|
+
*
|
|
149
|
+
* @see {@link ExportedStatus} for the exported state
|
|
150
|
+
* @see {@link Status} for the union type
|
|
151
|
+
*/
|
|
11
152
|
export declare const UnexportedStatus: z.ZodLiteral<"UNEXPORTED">;
|
|
153
|
+
/**
|
|
154
|
+
* Literal type for the UNEXPORTED status.
|
|
155
|
+
*/
|
|
12
156
|
export type UnexportedStatus = z.infer<typeof UnexportedStatus>;
|
|
157
|
+
/**
|
|
158
|
+
* Creates an UnexportedStatus value.
|
|
159
|
+
*
|
|
160
|
+
* @returns The literal "UNEXPORTED" status
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* ```typescript
|
|
164
|
+
* const status = makeUnexportedStatus(); // "UNEXPORTED"
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
13
167
|
export declare const makeUnexportedStatus: () => UnexportedStatus;
|
|
168
|
+
/**
|
|
169
|
+
* Zod schema for the LAST_UPDATED status literal.
|
|
170
|
+
*
|
|
171
|
+
* @remarks
|
|
172
|
+
* Represents the intermediate state of content entities during batch processing.
|
|
173
|
+
* Content transitions from UNEXPORTED to LAST_UPDATED when marked for export,
|
|
174
|
+
* then from LAST_UPDATED to EXPORTED when finalized.
|
|
175
|
+
* Can be reverted back to UNEXPORTED if something goes wrong.
|
|
176
|
+
*
|
|
177
|
+
* @see {@link UnexportedStatus} for the initial state
|
|
178
|
+
* @see {@link ExportedStatus} for the final state
|
|
179
|
+
* @see {@link Status} for the union type
|
|
180
|
+
*/
|
|
181
|
+
export declare const LastUpdatedStatus: z.ZodLiteral<"LAST_UPDATED">;
|
|
182
|
+
/**
|
|
183
|
+
* Literal type for the LAST_UPDATED status.
|
|
184
|
+
*/
|
|
185
|
+
export type LastUpdatedStatus = z.infer<typeof LastUpdatedStatus>;
|
|
186
|
+
/**
|
|
187
|
+
* Creates a LastUpdatedStatus value.
|
|
188
|
+
*
|
|
189
|
+
* @returns The literal "LAST_UPDATED" status
|
|
190
|
+
*
|
|
191
|
+
* @example
|
|
192
|
+
* ```typescript
|
|
193
|
+
* const status = makeLastUpdatedStatus(); // "LAST_UPDATED"
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
export declare const makeLastUpdatedStatus: () => LastUpdatedStatus;
|
|
197
|
+
/**
|
|
198
|
+
* Zod schema for validating export timestamps.
|
|
199
|
+
*
|
|
200
|
+
* @remarks
|
|
201
|
+
* Validates that the value is a valid Date object.
|
|
202
|
+
* Used to track when entities are exported/published.
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* ```typescript
|
|
206
|
+
* const timestamp = ExportedAt.parse(new Date());
|
|
207
|
+
* ```
|
|
208
|
+
*
|
|
209
|
+
* @see {@link makeExportedAt} for factory function
|
|
210
|
+
*/
|
|
14
211
|
export declare const ExportedAt: z.core.$ZodBranded<z.ZodDate, "ExportedAt">;
|
|
212
|
+
/**
|
|
213
|
+
* Branded type for validated export timestamps.
|
|
214
|
+
*/
|
|
15
215
|
export type ExportedAt = z.infer<typeof ExportedAt>;
|
|
216
|
+
/**
|
|
217
|
+
* Creates a validated ExportedAt timestamp.
|
|
218
|
+
*
|
|
219
|
+
* @param exportedAt - Optional Date. If not provided, uses current time.
|
|
220
|
+
* @returns A branded ExportedAt value
|
|
221
|
+
* @throws {ZodError} When the value is not a valid Date
|
|
222
|
+
*
|
|
223
|
+
* @example
|
|
224
|
+
* ```typescript
|
|
225
|
+
* const now = makeExportedAt(); // Current time
|
|
226
|
+
* const specific = makeExportedAt(new Date("2024-01-01"));
|
|
227
|
+
* ```
|
|
228
|
+
*/
|
|
16
229
|
export declare const makeExportedAt: (exportedAt?: Date) => ExportedAt;
|
|
230
|
+
/**
|
|
231
|
+
* Zod schema for the EXPORTED status with timestamp.
|
|
232
|
+
*
|
|
233
|
+
* @remarks
|
|
234
|
+
* Represents the published state of content entities.
|
|
235
|
+
* Includes both the status literal and the export timestamp.
|
|
236
|
+
*
|
|
237
|
+
* @example
|
|
238
|
+
* ```typescript
|
|
239
|
+
* const exported = ExportedStatus.parse({
|
|
240
|
+
* status: "EXPORTED",
|
|
241
|
+
* exportedAt: new Date()
|
|
242
|
+
* });
|
|
243
|
+
* ```
|
|
244
|
+
*
|
|
245
|
+
* @see {@link UnexportedStatus} for the initial state
|
|
246
|
+
* @see {@link makeExportedStatus} for factory function
|
|
247
|
+
*/
|
|
17
248
|
export declare const ExportedStatus: z.ZodObject<{
|
|
18
249
|
status: z.ZodLiteral<"EXPORTED">;
|
|
19
250
|
exportedAt: z.core.$ZodBranded<z.ZodDate, "ExportedAt">;
|
|
20
251
|
}, z.core.$strip>;
|
|
252
|
+
/**
|
|
253
|
+
* Type for the EXPORTED status with timestamp.
|
|
254
|
+
*/
|
|
21
255
|
export type ExportedStatus = z.infer<typeof ExportedStatus>;
|
|
256
|
+
/**
|
|
257
|
+
* Creates an ExportedStatus with current timestamp.
|
|
258
|
+
*
|
|
259
|
+
* @returns An ExportedStatus object with status "EXPORTED" and current time
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
* ```typescript
|
|
263
|
+
* const status = makeExportedStatus();
|
|
264
|
+
* // { status: "EXPORTED", exportedAt: Date }
|
|
265
|
+
* ```
|
|
266
|
+
*/
|
|
22
267
|
export declare const makeExportedStatus: () => ExportedStatus;
|
|
23
|
-
|
|
24
|
-
|
|
268
|
+
/**
|
|
269
|
+
* Union type for entity status.
|
|
270
|
+
*
|
|
271
|
+
* @remarks
|
|
272
|
+
* Represents the lifecycle state of content entities.
|
|
273
|
+
* State transitions: UNEXPORTED → LAST_UPDATED → EXPORTED
|
|
274
|
+
* LAST_UPDATED can be reverted back to UNEXPORTED.
|
|
275
|
+
*
|
|
276
|
+
* @example
|
|
277
|
+
* ```typescript
|
|
278
|
+
* function filterByStatus(items: Entity[], status: Status) {
|
|
279
|
+
* return items.filter(item => item.status === status);
|
|
280
|
+
* }
|
|
281
|
+
* ```
|
|
282
|
+
*/
|
|
283
|
+
export type Status = UnexportedStatus | LastUpdatedStatus | ExportedStatus["status"];
|
|
284
|
+
/**
|
|
285
|
+
* Creates a Status value from a string.
|
|
286
|
+
*
|
|
287
|
+
* @param status - The status string ("UNEXPORTED", "LAST_UPDATED", or "EXPORTED")
|
|
288
|
+
* @returns The status value
|
|
289
|
+
*
|
|
290
|
+
* @deprecated This is for legacy compatibility. Use {@link makeUnexportedStatus},
|
|
291
|
+
* {@link makeLastUpdatedStatus}, or {@link makeExportedStatus} instead.
|
|
292
|
+
*
|
|
293
|
+
* @example
|
|
294
|
+
* ```typescript
|
|
295
|
+
* // Prefer these:
|
|
296
|
+
* const unexported = makeUnexportedStatus();
|
|
297
|
+
* const lastUpdated = makeLastUpdatedStatus();
|
|
298
|
+
* const exported = makeExportedStatus();
|
|
299
|
+
*
|
|
300
|
+
* // Instead of:
|
|
301
|
+
* const status = makeStatus("UNEXPORTED");
|
|
302
|
+
* ```
|
|
303
|
+
*/
|
|
304
|
+
export declare const makeStatus: (status: "UNEXPORTED" | "LAST_UPDATED" | "EXPORTED") => Status;
|
|
25
305
|
//# sourceMappingURL=common-entity.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common-entity.d.ts","sourceRoot":"","sources":["../../../common/entities/common-entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"common-entity.d.ts","sourceRoot":"","sources":["../../../common/entities/common-entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,EAAE,mDAGA,CAAC;AAChB;;;;;;GAMG;AACH,MAAM,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;AAEpC;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,MAAM,GAAI,KAAK,MAAM,KAAG,EAGpC,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,MAAM,2CAAkD,CAAC;AAEtE;;;;;;GAMG;AACH,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,MAAM,CAAC,CAAC;AAE5C;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,UAAU,GAAI,GAAG,MAAM,KAAG,MAAyB,CAAC;AAEjE;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,SAAS,4CAAgC,CAAC;AAEvD;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAC;AAElD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,aAAa,GAAI,YAAY,IAAI,KAAG,SAGhD,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,SAAS,4CAAgC,CAAC;AAEvD;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAC;AAElD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,aAAa,GAAI,YAAY,IAAI,KAAG,SAGhD,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,4BAA0B,CAAC;AAExD;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEhE;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB,QAAO,gBACH,CAAC;AAEtC;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,iBAAiB,8BAA4B,CAAC;AAE3D;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAElE;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,QAAO,iBACD,CAAC;AAEzC;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,UAAU,6CAAiC,CAAC;AAEzD;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAEpD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,cAAc,GAAI,aAAa,IAAI,KAAG,UAGlD,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,cAAc;;;iBAGzB,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAE5D;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kBAAkB,QAAO,cAC+B,CAAC;AAEtE;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,MAAM,GACf,gBAAgB,GAChB,iBAAiB,GACjB,cAAc,CAAC,QAAQ,CAAC,CAAC;AAE5B;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,UAAU,GACtB,QAAQ,YAAY,GAAG,cAAc,GAAG,UAAU,KAChD,MAEF,CAAC"}
|