@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
package/dist/notes/index.d.ts
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
*
|
|
4
|
+
* Notes domain for markdown-based content creation.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Provides complete domain implementation for note management including:
|
|
8
|
+
*
|
|
9
|
+
* - **Entities** - Note 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
|
+
* Notes support markdown content with titles for organizing personal knowledge.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* import {
|
|
20
|
+
* noteEntity,
|
|
21
|
+
* makeNoteTitle,
|
|
22
|
+
* makeMarkdown,
|
|
23
|
+
* NoteCreatedEvent,
|
|
24
|
+
* } from "@repo/core/notes";
|
|
25
|
+
*
|
|
26
|
+
* const note = noteEntity.create({
|
|
27
|
+
* userId: makeUserId("user-123"),
|
|
28
|
+
* title: makeNoteTitle("Meeting Notes"),
|
|
29
|
+
* content: makeMarkdown("# Agenda\n- Item 1\n- Item 2"),
|
|
30
|
+
* });
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
1
33
|
export * from "./entities/note-entity";
|
|
2
34
|
export * from "./events/note-created-event";
|
|
3
35
|
export * from "./events/note-deleted-event";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../notes/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../notes/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAGH,cAAc,wBAAwB,CAAC;AAGvC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAG5C,cAAc,mDAAmD,CAAC;AAClE,cAAc,iDAAiD,CAAC;AAGhE,cAAc,iCAAiC,CAAC;AAGhD,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC"}
|
package/dist/notes/index.js
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
*
|
|
4
|
+
* Notes domain for markdown-based content creation.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Provides complete domain implementation for note management including:
|
|
8
|
+
*
|
|
9
|
+
* - **Entities** - Note 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
|
+
* Notes support markdown content with titles for organizing personal knowledge.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* import {
|
|
20
|
+
* noteEntity,
|
|
21
|
+
* makeNoteTitle,
|
|
22
|
+
* makeMarkdown,
|
|
23
|
+
* NoteCreatedEvent,
|
|
24
|
+
* } from "@repo/core/notes";
|
|
25
|
+
*
|
|
26
|
+
* const note = noteEntity.create({
|
|
27
|
+
* userId: makeUserId("user-123"),
|
|
28
|
+
* title: makeNoteTitle("Meeting Notes"),
|
|
29
|
+
* content: makeMarkdown("# Agenda\n- Item 1\n- Item 2"),
|
|
30
|
+
* });
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
1
33
|
// Entities
|
|
2
34
|
export * from "./entities/note-entity";
|
|
3
35
|
// Events
|
package/dist/notes/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../notes/index.ts"],"names":[],"mappings":"AAAA,WAAW;AACX,cAAc,wBAAwB,CAAC;AAEvC,SAAS;AACT,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAE5C,eAAe;AACf,cAAc,mDAAmD,CAAC;AAClE,cAAc,iDAAiD,CAAC;AAEhE,WAAW;AACX,cAAc,iCAAiC,CAAC;AAEhD,QAAQ;AACR,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../notes/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,WAAW;AACX,cAAc,wBAAwB,CAAC;AAEvC,SAAS;AACT,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAE5C,eAAe;AACf,cAAc,mDAAmD,CAAC;AAClE,cAAc,iDAAiD,CAAC;AAEhE,WAAW;AACX,cAAc,iCAAiC,CAAC;AAEhD,QAAQ;AACR,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC"}
|
|
@@ -1,7 +1,44 @@
|
|
|
1
1
|
import type { Id, Status, UserId } from "../../common/entities/common-entity";
|
|
2
2
|
import type { UnexportedNote } from "../entities/note-entity";
|
|
3
|
+
/**
|
|
4
|
+
* Command repository interface for the Note domain.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Follows the CQRS pattern - this interface handles write operations only.
|
|
8
|
+
* Implementations should be provided by the infrastructure layer (e.g., Prisma).
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* // Infrastructure implementation
|
|
13
|
+
* class PrismaNotesCommandRepository implements INotesCommandRepository {
|
|
14
|
+
* async create(data: UnexportedNote) {
|
|
15
|
+
* await prisma.note.create({ data });
|
|
16
|
+
* }
|
|
17
|
+
*
|
|
18
|
+
* async deleteById(id: Id, userId: UserId, status: Status) {
|
|
19
|
+
* await prisma.note.delete({
|
|
20
|
+
* where: { id, userId, status }
|
|
21
|
+
* });
|
|
22
|
+
* }
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @see {@link INotesQueryRepository} for read operations
|
|
27
|
+
*/
|
|
3
28
|
export type INotesCommandRepository = {
|
|
29
|
+
/**
|
|
30
|
+
* Creates a new note in the repository.
|
|
31
|
+
*
|
|
32
|
+
* @param data - The unexported note entity to persist
|
|
33
|
+
*/
|
|
4
34
|
create(data: UnexportedNote): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Deletes a note by its ID.
|
|
37
|
+
*
|
|
38
|
+
* @param id - The note ID to delete
|
|
39
|
+
* @param userId - The user ID for tenant isolation
|
|
40
|
+
* @param status - The expected status of the note
|
|
41
|
+
*/
|
|
5
42
|
deleteById(id: Id, userId: UserId, status: Status): Promise<void>;
|
|
6
43
|
};
|
|
7
44
|
//# sourceMappingURL=notes-command-repository.interface.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notes-command-repository.interface.d.ts","sourceRoot":"","sources":["../../../notes/repositories/notes-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,yBAAyB,CAAC;AAE9D,MAAM,MAAM,uBAAuB,GAAG;IACrC,MAAM,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"notes-command-repository.interface.d.ts","sourceRoot":"","sources":["../../../notes/repositories/notes-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,yBAAyB,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;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;CAClE,CAAC"}
|
|
@@ -1,18 +1,71 @@
|
|
|
1
1
|
import type { Status, UserId } from "../../common/entities/common-entity";
|
|
2
2
|
import type { NoteTitle } from "../entities/note-entity";
|
|
3
3
|
import type { NotesFindManyParams } from "../types/query-params";
|
|
4
|
+
/**
|
|
5
|
+
* Query repository interface for the Note 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 PrismaNotesQueryRepository implements INotesQueryRepository {
|
|
15
|
+
* async findByTitle(title: NoteTitle, userId: UserId) {
|
|
16
|
+
* return await prisma.note.findUnique({
|
|
17
|
+
* where: { title, userId }
|
|
18
|
+
* });
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @see {@link INotesCommandRepository} for write operations
|
|
24
|
+
*/
|
|
4
25
|
export type INotesQueryRepository = {
|
|
26
|
+
/**
|
|
27
|
+
* Finds a note by its title for a specific user.
|
|
28
|
+
*
|
|
29
|
+
* @param title - The validated title to search for
|
|
30
|
+
* @param userId - The user ID for tenant isolation
|
|
31
|
+
* @returns The note data if found, null otherwise
|
|
32
|
+
*/
|
|
5
33
|
findByTitle(title: NoteTitle, userId: UserId): Promise<{
|
|
6
34
|
id: string;
|
|
7
35
|
title: string;
|
|
8
36
|
markdown: string;
|
|
9
37
|
status: string;
|
|
10
38
|
} | null>;
|
|
39
|
+
/**
|
|
40
|
+
* Retrieves multiple notes with pagination and filtering.
|
|
41
|
+
*
|
|
42
|
+
* @param userId - The user ID for tenant isolation
|
|
43
|
+
* @param status - Filter by UNEXPORTED or EXPORTED status
|
|
44
|
+
* @param params - Pagination, sorting, and caching parameters
|
|
45
|
+
* @returns Array of note data objects
|
|
46
|
+
*
|
|
47
|
+
* @see {@link NotesFindManyParams} for parameter options
|
|
48
|
+
*/
|
|
11
49
|
findMany(userId: UserId, status: Status, params: NotesFindManyParams): Promise<Array<{
|
|
12
50
|
id: string;
|
|
13
51
|
title: string;
|
|
14
52
|
}>>;
|
|
53
|
+
/**
|
|
54
|
+
* Counts notes matching the given criteria.
|
|
55
|
+
*
|
|
56
|
+
* @param userId - The user ID for tenant isolation
|
|
57
|
+
* @param status - Filter by status
|
|
58
|
+
* @returns The count of matching notes
|
|
59
|
+
*/
|
|
15
60
|
count(userId: UserId, status: Status): Promise<number>;
|
|
61
|
+
/**
|
|
62
|
+
* Searches notes by text query.
|
|
63
|
+
*
|
|
64
|
+
* @param query - The search query string
|
|
65
|
+
* @param userId - The user ID for tenant isolation
|
|
66
|
+
* @param limit - Optional maximum number of results
|
|
67
|
+
* @returns Array of matching note data objects
|
|
68
|
+
*/
|
|
16
69
|
search(query: string, userId: UserId, limit?: number): Promise<{
|
|
17
70
|
id: string;
|
|
18
71
|
title: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notes-query-repository.interface.d.ts","sourceRoot":"","sources":["../../../notes/repositories/notes-query-repository.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEjE,MAAM,MAAM,qBAAqB,GAAG;IACnC,WAAW,CACV,KAAK,EAAE,SAAS,EAChB,MAAM,EAAE,MAAM,GACZ,OAAO,CAAC;QACV,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;KACf,GAAG,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"notes-query-repository.interface.d.ts","sourceRoot":"","sources":["../../../notes/repositories/notes-query-repository.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEjE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,qBAAqB,GAAG;IACnC;;;;;;OAMG;IACH,WAAW,CACV,KAAK,EAAE,SAAS,EAChB,MAAM,EAAE,MAAM,GACZ,OAAO,CAAC;QACV,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;KACf,GAAG,IAAI,CAAC,CAAC;IAEV;;;;;;;;;OASG;IACH,QAAQ,CACP,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,mBAAmB,GACzB,OAAO,CAAC,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;IAEjD;;;;;;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,QAAQ,EAAE,MAAM,CAAC;KACjB,EAAE,CACH,CAAC;CACF,CAAC"}
|
|
@@ -1,9 +1,49 @@
|
|
|
1
1
|
import type { UserId } from "../../common/entities/common-entity";
|
|
2
2
|
import type { NoteTitle } from "../entities/note-entity";
|
|
3
3
|
import type { INotesQueryRepository } from "../repositories/notes-query-repository.interface";
|
|
4
|
+
/**
|
|
5
|
+
* Domain service for Note 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: INotesQueryRepository = new PrismaNotesQueryRepository();
|
|
14
|
+
* const domainService = new NotesDomainService(queryRepo);
|
|
15
|
+
*
|
|
16
|
+
* try {
|
|
17
|
+
* await domainService.ensureNoDuplicate(title, userId);
|
|
18
|
+
* // Safe to create the note
|
|
19
|
+
* } catch (error) {
|
|
20
|
+
* if (error instanceof DuplicateError) {
|
|
21
|
+
* // Handle duplicate title
|
|
22
|
+
* }
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @see {@link INotesQueryRepository} for repository interface
|
|
27
|
+
* @see {@link DuplicateError} for duplicate handling
|
|
28
|
+
*/
|
|
4
29
|
export declare class NotesDomainService {
|
|
5
30
|
private readonly notesQueryRepository;
|
|
31
|
+
/**
|
|
32
|
+
* Creates a new NotesDomainService instance.
|
|
33
|
+
*
|
|
34
|
+
* @param notesQueryRepository - The query repository for checking duplicates
|
|
35
|
+
*/
|
|
6
36
|
constructor(notesQueryRepository: INotesQueryRepository);
|
|
37
|
+
/**
|
|
38
|
+
* Validates that no note with the same title exists for the user.
|
|
39
|
+
*
|
|
40
|
+
* @param title - The title to check for duplicates
|
|
41
|
+
* @param userId - The user ID for tenant isolation
|
|
42
|
+
* @throws {DuplicateError} When a note with this title already exists
|
|
43
|
+
*
|
|
44
|
+
* @remarks
|
|
45
|
+
* This is a domain invariant check that should be called before creating notes.
|
|
46
|
+
*/
|
|
7
47
|
ensureNoDuplicate(title: NoteTitle, userId: UserId): Promise<void>;
|
|
8
48
|
}
|
|
9
49
|
//# sourceMappingURL=notes-domain-service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notes-domain-service.d.ts","sourceRoot":"","sources":["../../../notes/services/notes-domain-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAElE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kDAAkD,CAAC;
|
|
1
|
+
{"version":3,"file":"notes-domain-service.d.ts","sourceRoot":"","sources":["../../../notes/services/notes-domain-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAElE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kDAAkD,CAAC;AAuB9F;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,qBAAa,kBAAkB;IAMlB,OAAO,CAAC,QAAQ,CAAC,oBAAoB;IALjD;;;;OAIG;gBAC0B,oBAAoB,EAAE,qBAAqB;IAExE;;;;;;;;;OASG;IACU,iBAAiB,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM;CAG/D"}
|
|
@@ -1,15 +1,65 @@
|
|
|
1
1
|
import { DuplicateError } from "../../errors/error-classes";
|
|
2
|
+
/**
|
|
3
|
+
* Checks if a note with the given title already exists.
|
|
4
|
+
*
|
|
5
|
+
* @param notesQueryRepository - The query repository to check against
|
|
6
|
+
* @param title - The title to check for duplicates
|
|
7
|
+
* @param userId - The user ID for tenant isolation
|
|
8
|
+
* @throws {DuplicateError} When a note with this title already exists
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
2
12
|
async function ensureNoDuplicateNote(notesQueryRepository, title, userId) {
|
|
3
13
|
const exists = await notesQueryRepository.findByTitle(title, userId);
|
|
4
14
|
if (exists) {
|
|
5
15
|
throw new DuplicateError();
|
|
6
16
|
}
|
|
7
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Domain service for Note business logic.
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* Encapsulates complex business rules that don't belong to a single entity.
|
|
23
|
+
* Uses dependency injection for repository access.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* const queryRepo: INotesQueryRepository = new PrismaNotesQueryRepository();
|
|
28
|
+
* const domainService = new NotesDomainService(queryRepo);
|
|
29
|
+
*
|
|
30
|
+
* try {
|
|
31
|
+
* await domainService.ensureNoDuplicate(title, userId);
|
|
32
|
+
* // Safe to create the note
|
|
33
|
+
* } catch (error) {
|
|
34
|
+
* if (error instanceof DuplicateError) {
|
|
35
|
+
* // Handle duplicate title
|
|
36
|
+
* }
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @see {@link INotesQueryRepository} for repository interface
|
|
41
|
+
* @see {@link DuplicateError} for duplicate handling
|
|
42
|
+
*/
|
|
8
43
|
export class NotesDomainService {
|
|
9
44
|
notesQueryRepository;
|
|
45
|
+
/**
|
|
46
|
+
* Creates a new NotesDomainService instance.
|
|
47
|
+
*
|
|
48
|
+
* @param notesQueryRepository - The query repository for checking duplicates
|
|
49
|
+
*/
|
|
10
50
|
constructor(notesQueryRepository) {
|
|
11
51
|
this.notesQueryRepository = notesQueryRepository;
|
|
12
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Validates that no note with the same title exists for the user.
|
|
55
|
+
*
|
|
56
|
+
* @param title - The title to check for duplicates
|
|
57
|
+
* @param userId - The user ID for tenant isolation
|
|
58
|
+
* @throws {DuplicateError} When a note with this title already exists
|
|
59
|
+
*
|
|
60
|
+
* @remarks
|
|
61
|
+
* This is a domain invariant check that should be called before creating notes.
|
|
62
|
+
*/
|
|
13
63
|
async ensureNoDuplicate(title, userId) {
|
|
14
64
|
return ensureNoDuplicateNote(this.notesQueryRepository, title, userId);
|
|
15
65
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notes-domain-service.js","sourceRoot":"","sources":["../../../notes/services/notes-domain-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAI5D,KAAK,UAAU,qBAAqB,CACnC,oBAA2C,EAC3C,KAAgB,EAChB,MAAc;IAEd,MAAM,MAAM,GAAG,MAAM,oBAAoB,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACrE,IAAI,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,cAAc,EAAE,CAAC;IAC5B,CAAC;AACF,CAAC;AAED,MAAM,OAAO,kBAAkB;
|
|
1
|
+
{"version":3,"file":"notes-domain-service.js","sourceRoot":"","sources":["../../../notes/services/notes-domain-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAI5D;;;;;;;;;GASG;AACH,KAAK,UAAU,qBAAqB,CACnC,oBAA2C,EAC3C,KAAgB,EAChB,MAAc;IAEd,MAAM,MAAM,GAAG,MAAM,oBAAoB,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACrE,IAAI,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,cAAc,EAAE,CAAC;IAC5B,CAAC;AACF,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,KAAgB,EAAE,MAAc;QAC9D,OAAO,qBAAqB,CAAC,IAAI,CAAC,oBAAoB,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IACxE,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: ["notes"] // 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":["../../../notes/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":["../../../notes/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 note queries.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* All fields correspond to Note entity properties.
|
|
8
|
+
* Used with {@link NotesOrderBy} to specify sort criteria.
|
|
9
|
+
*/
|
|
10
|
+
export type NotesOrderByField = "id" | "title" | "markdown" | "status" | "createdAt" | "updatedAt" | "exportedAt";
|
|
11
|
+
/**
|
|
12
|
+
* Sort configuration for note 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: NotesOrderBy = { createdAt: "desc" };
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @see {@link NotesOrderByField} for available fields
|
|
24
|
+
* @see {@link SortOrder} for sort directions
|
|
25
|
+
*/
|
|
26
|
+
export type NotesOrderBy = {
|
|
5
27
|
[K in NotesOrderByField]?: SortOrder;
|
|
6
28
|
};
|
|
29
|
+
/**
|
|
30
|
+
* Parameters for paginated note queries.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* const params: NotesFindManyParams = {
|
|
35
|
+
* orderBy: { createdAt: "desc" },
|
|
36
|
+
* take: 20,
|
|
37
|
+
* skip: 0,
|
|
38
|
+
* cacheStrategy: { ttl: 60, tags: ["notes"] },
|
|
39
|
+
* };
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @see {@link NotesOrderBy} for sorting options
|
|
43
|
+
* @see {@link CacheStrategy} for caching configuration
|
|
44
|
+
*/
|
|
7
45
|
export type NotesFindManyParams = {
|
|
46
|
+
/** Sort configuration */
|
|
8
47
|
orderBy?: NotesOrderBy;
|
|
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":["../../../notes/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":["../../../notes/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,OAAO,GACP,UAAU,GACV,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":["../../../notes/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":["../../../notes/types/sort-order.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,MAAM,CAAC"}
|