@s-hirano-ist/s-core 1.1.6 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/articles/entities/article-entity.d.ts +342 -11
- package/dist/articles/entities/article-entity.d.ts.map +1 -1
- package/dist/articles/entities/article-entity.js +295 -9
- package/dist/articles/entities/article-entity.js.map +1 -1
- package/dist/articles/events/article-created-event.d.ts +36 -0
- package/dist/articles/events/article-created-event.d.ts.map +1 -1
- package/dist/articles/events/article-created-event.js +36 -0
- package/dist/articles/events/article-created-event.js.map +1 -1
- package/dist/articles/events/article-deleted-event.d.ts +30 -0
- package/dist/articles/events/article-deleted-event.d.ts.map +1 -1
- package/dist/articles/events/article-deleted-event.js +30 -0
- package/dist/articles/events/article-deleted-event.js.map +1 -1
- package/dist/articles/index.d.ts +33 -0
- package/dist/articles/index.d.ts.map +1 -1
- package/dist/articles/index.js +33 -0
- package/dist/articles/index.js.map +1 -1
- package/dist/articles/repositories/articles-command-repository.interface.d.ts +37 -0
- package/dist/articles/repositories/articles-command-repository.interface.d.ts.map +1 -1
- package/dist/articles/repositories/articles-query-repository.interface.d.ts +53 -0
- package/dist/articles/repositories/articles-query-repository.interface.d.ts.map +1 -1
- package/dist/articles/repositories/category-query-repository.interface.d.ts +29 -0
- package/dist/articles/repositories/category-query-repository.interface.d.ts.map +1 -1
- package/dist/articles/services/articles-domain-service.d.ts +40 -0
- package/dist/articles/services/articles-domain-service.d.ts.map +1 -1
- package/dist/articles/services/articles-domain-service.js +50 -0
- package/dist/articles/services/articles-domain-service.js.map +1 -1
- package/dist/articles/types/cache-strategy.d.ts +19 -0
- package/dist/articles/types/cache-strategy.d.ts.map +1 -1
- package/dist/articles/types/query-params.d.ts +83 -5
- package/dist/articles/types/query-params.d.ts.map +1 -1
- package/dist/articles/types/sort-order.d.ts +12 -0
- package/dist/articles/types/sort-order.d.ts.map +1 -1
- package/dist/books/entities/books-entity.d.ts +348 -13
- package/dist/books/entities/books-entity.d.ts.map +1 -1
- package/dist/books/entities/books-entity.js +296 -11
- package/dist/books/entities/books-entity.js.map +1 -1
- package/dist/books/events/book-created-event.d.ts +32 -0
- package/dist/books/events/book-created-event.d.ts.map +1 -1
- package/dist/books/events/book-created-event.js +32 -0
- package/dist/books/events/book-created-event.js.map +1 -1
- package/dist/books/events/book-deleted-event.d.ts +30 -0
- package/dist/books/events/book-deleted-event.d.ts.map +1 -1
- package/dist/books/events/book-deleted-event.js +30 -0
- package/dist/books/events/book-deleted-event.js.map +1 -1
- package/dist/books/index.d.ts +33 -0
- package/dist/books/index.d.ts.map +1 -1
- package/dist/books/index.js +33 -0
- package/dist/books/index.js.map +1 -1
- package/dist/books/repositories/books-command-repository.interface.d.ts +45 -0
- package/dist/books/repositories/books-command-repository.interface.d.ts.map +1 -1
- package/dist/books/repositories/books-query-repository.interface.d.ts +53 -0
- package/dist/books/repositories/books-query-repository.interface.d.ts.map +1 -1
- package/dist/books/services/books-domain-service.d.ts +40 -0
- package/dist/books/services/books-domain-service.d.ts.map +1 -1
- package/dist/books/services/books-domain-service.js +50 -0
- package/dist/books/services/books-domain-service.js.map +1 -1
- package/dist/books/types/cache-strategy.d.ts +19 -0
- package/dist/books/types/cache-strategy.d.ts.map +1 -1
- package/dist/books/types/query-params.d.ts +44 -3
- package/dist/books/types/query-params.d.ts.map +1 -1
- package/dist/books/types/sort-order.d.ts +12 -0
- package/dist/books/types/sort-order.d.ts.map +1 -1
- package/dist/common/entities/common-entity.d.ts +282 -2
- package/dist/common/entities/common-entity.d.ts.map +1 -1
- package/dist/common/entities/common-entity.js +235 -2
- package/dist/common/entities/common-entity.js.map +1 -1
- package/dist/common/events/base-domain-event.d.ts +32 -0
- package/dist/common/events/base-domain-event.d.ts.map +1 -1
- package/dist/common/events/base-domain-event.js +32 -0
- package/dist/common/events/base-domain-event.js.map +1 -1
- package/dist/common/events/domain-event.interface.d.ts +54 -0
- package/dist/common/events/domain-event.interface.d.ts.map +1 -1
- package/dist/common/events/system-error-event.d.ts +36 -0
- package/dist/common/events/system-error-event.d.ts.map +1 -1
- package/dist/common/events/system-error-event.js +36 -0
- package/dist/common/events/system-error-event.js.map +1 -1
- package/dist/common/events/system-warning-event.d.ts +35 -0
- package/dist/common/events/system-warning-event.d.ts.map +1 -1
- package/dist/common/events/system-warning-event.js +35 -0
- package/dist/common/events/system-warning-event.js.map +1 -1
- package/dist/common/index.d.ts +23 -0
- package/dist/common/index.d.ts.map +1 -1
- package/dist/common/index.js +23 -0
- package/dist/common/index.js.map +1 -1
- package/dist/common/services/entity-factory.d.ts +27 -0
- package/dist/common/services/entity-factory.d.ts.map +1 -1
- package/dist/common/services/entity-factory.js +27 -0
- package/dist/common/services/entity-factory.js.map +1 -1
- package/dist/common/services/id-generator.d.ts +32 -0
- package/dist/common/services/id-generator.d.ts.map +1 -1
- package/dist/common/services/id-generator.js +32 -0
- package/dist/common/services/id-generator.js.map +1 -1
- package/dist/errors/error-classes.d.ts +83 -3
- package/dist/errors/error-classes.d.ts.map +1 -1
- package/dist/errors/error-classes.js +83 -6
- package/dist/errors/error-classes.js.map +1 -1
- package/dist/errors/index.d.ts +29 -0
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +29 -0
- package/dist/errors/index.js.map +1 -1
- package/dist/images/entities/image-entity.d.ts +373 -4
- package/dist/images/entities/image-entity.d.ts.map +1 -1
- package/dist/images/entities/image-entity.js +320 -3
- package/dist/images/entities/image-entity.js.map +1 -1
- package/dist/images/events/image-created-event.d.ts +30 -0
- package/dist/images/events/image-created-event.d.ts.map +1 -1
- package/dist/images/events/image-created-event.js +30 -0
- package/dist/images/events/image-created-event.js.map +1 -1
- package/dist/images/events/image-deleted-event.d.ts +30 -0
- package/dist/images/events/image-deleted-event.d.ts.map +1 -1
- package/dist/images/events/image-deleted-event.js +30 -0
- package/dist/images/events/image-deleted-event.js.map +1 -1
- package/dist/images/index.d.ts +35 -0
- package/dist/images/index.d.ts.map +1 -1
- package/dist/images/index.js +35 -0
- package/dist/images/index.js.map +1 -1
- package/dist/images/repositories/images-command-repository.interface.d.ts +43 -0
- package/dist/images/repositories/images-command-repository.interface.d.ts.map +1 -1
- package/dist/images/repositories/images-query-repository.interface.d.ts +59 -0
- package/dist/images/repositories/images-query-repository.interface.d.ts.map +1 -1
- package/dist/images/services/images-domain-service.d.ts +40 -0
- package/dist/images/services/images-domain-service.d.ts.map +1 -1
- package/dist/images/services/images-domain-service.js +50 -0
- package/dist/images/services/images-domain-service.js.map +1 -1
- package/dist/images/types/cache-strategy.d.ts +19 -0
- package/dist/images/types/cache-strategy.d.ts.map +1 -1
- package/dist/images/types/query-params.d.ts +44 -3
- package/dist/images/types/query-params.d.ts.map +1 -1
- package/dist/images/types/sort-order.d.ts +12 -0
- package/dist/images/types/sort-order.d.ts.map +1 -1
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -1
- package/dist/notes/entities/note-entity.d.ts +212 -6
- package/dist/notes/entities/note-entity.d.ts.map +1 -1
- package/dist/notes/entities/note-entity.js +182 -4
- package/dist/notes/entities/note-entity.js.map +1 -1
- package/dist/notes/events/note-created-event.d.ts +32 -0
- package/dist/notes/events/note-created-event.d.ts.map +1 -1
- package/dist/notes/events/note-created-event.js +32 -0
- package/dist/notes/events/note-created-event.js.map +1 -1
- package/dist/notes/events/note-deleted-event.d.ts +30 -0
- package/dist/notes/events/note-deleted-event.d.ts.map +1 -1
- package/dist/notes/events/note-deleted-event.js +30 -0
- package/dist/notes/events/note-deleted-event.js.map +1 -1
- package/dist/notes/index.d.ts +32 -0
- package/dist/notes/index.d.ts.map +1 -1
- package/dist/notes/index.js +32 -0
- package/dist/notes/index.js.map +1 -1
- package/dist/notes/repositories/notes-command-repository.interface.d.ts +37 -0
- package/dist/notes/repositories/notes-command-repository.interface.d.ts.map +1 -1
- package/dist/notes/repositories/notes-query-repository.interface.d.ts +53 -0
- package/dist/notes/repositories/notes-query-repository.interface.d.ts.map +1 -1
- package/dist/notes/services/notes-domain-service.d.ts +40 -0
- package/dist/notes/services/notes-domain-service.d.ts.map +1 -1
- package/dist/notes/services/notes-domain-service.js +50 -0
- package/dist/notes/services/notes-domain-service.js.map +1 -1
- package/dist/notes/types/cache-strategy.d.ts +19 -0
- package/dist/notes/types/cache-strategy.d.ts.map +1 -1
- package/dist/notes/types/query-params.d.ts +44 -3
- package/dist/notes/types/query-params.d.ts.map +1 -1
- package/dist/notes/types/sort-order.d.ts +12 -0
- package/dist/notes/types/sort-order.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../common/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../common/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,cAAc,0BAA0B,CAAC;AAGzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,iCAAiC,CAAC;AAChD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAG9C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AAGxC,cAAc,sBAAsB,CAAC"}
|
package/dist/common/index.js
CHANGED
|
@@ -1,3 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
*
|
|
4
|
+
* Common utilities shared across all domains.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Provides foundational building blocks including:
|
|
8
|
+
*
|
|
9
|
+
* - **Entities** - Common value objects (Id, UserId, CreatedAt, Status)
|
|
10
|
+
* - **Events** - Domain event infrastructure (BaseDomainEvent, SystemEvents)
|
|
11
|
+
* - **Services** - Shared services (ID generation, entity factory)
|
|
12
|
+
* - **Types** - Common type definitions
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* import { makeId, makeUserId, makeCreatedAt, UnexportedStatus } from "@repo/core/common";
|
|
17
|
+
*
|
|
18
|
+
* const id = makeId();
|
|
19
|
+
* const userId = makeUserId("user-123");
|
|
20
|
+
* const createdAt = makeCreatedAt();
|
|
21
|
+
* const status = UnexportedStatus;
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
1
24
|
// Entities
|
|
2
25
|
export * from "./entities/common-entity";
|
|
3
26
|
// Events
|
package/dist/common/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../common/index.ts"],"names":[],"mappings":"AAAA,WAAW;AACX,cAAc,0BAA0B,CAAC;AAEzC,SAAS;AACT,cAAc,4BAA4B,CAAC;AAC3C,cAAc,iCAAiC,CAAC;AAChD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAE9C,WAAW;AACX,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AAExC,QAAQ;AACR,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../common/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,WAAW;AACX,cAAc,0BAA0B,CAAC;AAEzC,SAAS;AACT,cAAc,4BAA4B,CAAC;AAC3C,cAAc,iCAAiC,CAAC;AAChD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAE9C,WAAW;AACX,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AAExC,QAAQ;AACR,cAAc,sBAAsB,CAAC"}
|
|
@@ -1,2 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wraps entity creation with standardized error handling.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* This utility function provides consistent error handling across all entity factories.
|
|
6
|
+
* It catches Zod validation errors and converts them to domain-specific error types.
|
|
7
|
+
*
|
|
8
|
+
* @typeParam T - The type of entity being created
|
|
9
|
+
* @param factory - A function that creates the entity
|
|
10
|
+
* @returns The created entity
|
|
11
|
+
* @throws {InvalidFormatError} When Zod validation fails
|
|
12
|
+
* @throws {UnexpectedError} For any other unexpected errors
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const article = createEntityWithErrorHandling(() =>
|
|
17
|
+
* Object.freeze({
|
|
18
|
+
* id: makeId(),
|
|
19
|
+
* title: makeArticleTitle(rawTitle),
|
|
20
|
+
* // ... other fields
|
|
21
|
+
* })
|
|
22
|
+
* );
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @see {@link InvalidFormatError} for validation error handling
|
|
26
|
+
* @see {@link UnexpectedError} for unexpected error handling
|
|
27
|
+
*/
|
|
1
28
|
export declare const createEntityWithErrorHandling: <T>(factory: () => T) => T;
|
|
2
29
|
//# sourceMappingURL=entity-factory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-factory.d.ts","sourceRoot":"","sources":["../../../common/services/entity-factory.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,6BAA6B,GAAI,CAAC,EAAE,SAAS,MAAM,CAAC,KAAG,CAOnE,CAAC"}
|
|
1
|
+
{"version":3,"file":"entity-factory.d.ts","sourceRoot":"","sources":["../../../common/services/entity-factory.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,6BAA6B,GAAI,CAAC,EAAE,SAAS,MAAM,CAAC,KAAG,CAOnE,CAAC"}
|
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
import { ZodError } from "zod";
|
|
2
2
|
import { InvalidFormatError, UnexpectedError, } from "../../errors/error-classes";
|
|
3
|
+
/**
|
|
4
|
+
* Wraps entity creation with standardized error handling.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* This utility function provides consistent error handling across all entity factories.
|
|
8
|
+
* It catches Zod validation errors and converts them to domain-specific error types.
|
|
9
|
+
*
|
|
10
|
+
* @typeParam T - The type of entity being created
|
|
11
|
+
* @param factory - A function that creates the entity
|
|
12
|
+
* @returns The created entity
|
|
13
|
+
* @throws {InvalidFormatError} When Zod validation fails
|
|
14
|
+
* @throws {UnexpectedError} For any other unexpected errors
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const article = createEntityWithErrorHandling(() =>
|
|
19
|
+
* Object.freeze({
|
|
20
|
+
* id: makeId(),
|
|
21
|
+
* title: makeArticleTitle(rawTitle),
|
|
22
|
+
* // ... other fields
|
|
23
|
+
* })
|
|
24
|
+
* );
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @see {@link InvalidFormatError} for validation error handling
|
|
28
|
+
* @see {@link UnexpectedError} for unexpected error handling
|
|
29
|
+
*/
|
|
3
30
|
export const createEntityWithErrorHandling = (factory) => {
|
|
4
31
|
try {
|
|
5
32
|
return factory();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-factory.js","sourceRoot":"","sources":["../../../common/services/entity-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAC/B,OAAO,EACN,kBAAkB,EAClB,eAAe,GACf,MAAM,4BAA4B,CAAC;AAEpC,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAI,OAAgB,EAAK,EAAE;IACvE,IAAI,CAAC;QACJ,OAAO,OAAO,EAAE,CAAC;IAClB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,IAAI,KAAK,YAAY,QAAQ;YAAE,MAAM,IAAI,kBAAkB,EAAE,CAAC;QAC9D,MAAM,IAAI,eAAe,EAAE,CAAC;IAC7B,CAAC;AACF,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"entity-factory.js","sourceRoot":"","sources":["../../../common/services/entity-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAC/B,OAAO,EACN,kBAAkB,EAClB,eAAe,GACf,MAAM,4BAA4B,CAAC;AAEpC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAI,OAAgB,EAAK,EAAE;IACvE,IAAI,CAAC;QACJ,OAAO,OAAO,EAAE,CAAC;IAClB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,IAAI,KAAK,YAAY,QAAQ;YAAE,MAAM,IAAI,kBAAkB,EAAE,CAAC;QAC9D,MAAM,IAAI,eAAe,EAAE,CAAC;IAC7B,CAAC;AACF,CAAC,CAAC"}
|
|
@@ -1,4 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates a new UUIDv7 identifier.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* UUIDv7 is a time-ordered UUID that provides both uniqueness and sortability.
|
|
6
|
+
* The timestamp is embedded in the first 48 bits, making it suitable for
|
|
7
|
+
* database primary keys where insertion order matters.
|
|
8
|
+
*
|
|
9
|
+
* @returns A new UUIDv7 string
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const id = uuidv7();
|
|
14
|
+
* // "01912c9a-5e8a-7b5c-8a1b-2c3d4e5f6a7b"
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @see {@link https://www.rfc-editor.org/rfc/rfc9562#section-5.7 | RFC 9562 - UUIDv7}
|
|
18
|
+
*/
|
|
1
19
|
export declare const uuidv7: () => string;
|
|
20
|
+
/**
|
|
21
|
+
* ID generator service for creating unique identifiers.
|
|
22
|
+
*
|
|
23
|
+
* @remarks
|
|
24
|
+
* Provides a centralized service for generating identifiers.
|
|
25
|
+
* Currently only supports UUIDv7.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* import { idGenerator } from "@s-hirano-ist/s-core";
|
|
30
|
+
*
|
|
31
|
+
* const id = idGenerator.uuidv7();
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
2
34
|
export declare const idGenerator: {
|
|
3
35
|
uuidv7: () => string;
|
|
4
36
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"id-generator.d.ts","sourceRoot":"","sources":["../../../common/services/id-generator.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,QAAO,MAAc,CAAC;AAEzC,eAAO,MAAM,WAAW;
|
|
1
|
+
{"version":3,"file":"id-generator.d.ts","sourceRoot":"","sources":["../../../common/services/id-generator.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,MAAM,QAAO,MAAc,CAAC;AAEzC;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,WAAW;kBAhBE,MAAM;CAgBK,CAAC"}
|
|
@@ -1,4 +1,36 @@
|
|
|
1
1
|
import { v7 } from "uuid";
|
|
2
|
+
/**
|
|
3
|
+
* Generates a new UUIDv7 identifier.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* UUIDv7 is a time-ordered UUID that provides both uniqueness and sortability.
|
|
7
|
+
* The timestamp is embedded in the first 48 bits, making it suitable for
|
|
8
|
+
* database primary keys where insertion order matters.
|
|
9
|
+
*
|
|
10
|
+
* @returns A new UUIDv7 string
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const id = uuidv7();
|
|
15
|
+
* // "01912c9a-5e8a-7b5c-8a1b-2c3d4e5f6a7b"
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @see {@link https://www.rfc-editor.org/rfc/rfc9562#section-5.7 | RFC 9562 - UUIDv7}
|
|
19
|
+
*/
|
|
2
20
|
export const uuidv7 = () => v7();
|
|
21
|
+
/**
|
|
22
|
+
* ID generator service for creating unique identifiers.
|
|
23
|
+
*
|
|
24
|
+
* @remarks
|
|
25
|
+
* Provides a centralized service for generating identifiers.
|
|
26
|
+
* Currently only supports UUIDv7.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* import { idGenerator } from "@s-hirano-ist/s-core";
|
|
31
|
+
*
|
|
32
|
+
* const id = idGenerator.uuidv7();
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
3
35
|
export const idGenerator = { uuidv7 };
|
|
4
36
|
//# sourceMappingURL=id-generator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"id-generator.js","sourceRoot":"","sources":["../../../common/services/id-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAW,EAAE,CAAC,EAAE,EAAE,CAAC;AAEzC,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,MAAM,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"id-generator.js","sourceRoot":"","sources":["../../../common/services/id-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAE1B;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAW,EAAE,CAAC,EAAE,EAAE,CAAC;AAEzC;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,MAAM,EAAE,CAAC"}
|
|
@@ -1,15 +1,95 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Error thrown when an unexpected error occurs.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Used as a catch-all for errors that shouldn't happen under normal conditions.
|
|
6
|
+
* The message "unexpected" can be used for i18n lookups.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* try {
|
|
11
|
+
* // Some operation that should never fail
|
|
12
|
+
* } catch (error) {
|
|
13
|
+
* throw new UnexpectedError();
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @see {@link InvalidFormatError} for validation errors
|
|
18
|
+
* @see {@link DuplicateError} for uniqueness constraint violations
|
|
19
|
+
*/
|
|
4
20
|
export declare class UnexpectedError extends Error {
|
|
5
21
|
constructor();
|
|
6
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Error thrown when input validation fails.
|
|
25
|
+
*
|
|
26
|
+
* @remarks
|
|
27
|
+
* Used by domain entities when Zod validation fails.
|
|
28
|
+
* The message "invalidFormat" can be used for i18n lookups.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* // In entity factory
|
|
33
|
+
* try {
|
|
34
|
+
* return ArticleTitle.parse(value);
|
|
35
|
+
* } catch (zodError) {
|
|
36
|
+
* throw new InvalidFormatError();
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @see {@link UnexpectedError} for unexpected errors
|
|
41
|
+
* @see {@link DuplicateError} for uniqueness constraint violations
|
|
42
|
+
*/
|
|
7
43
|
export declare class InvalidFormatError extends Error {
|
|
8
44
|
constructor();
|
|
9
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Error thrown when a duplicate entity is detected.
|
|
48
|
+
*
|
|
49
|
+
* @remarks
|
|
50
|
+
* Used by domain services to enforce uniqueness constraints.
|
|
51
|
+
* The message "duplicate" can be used for i18n lookups.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* // In domain service
|
|
56
|
+
* if (await repository.exists(key)) {
|
|
57
|
+
* throw new DuplicateError();
|
|
58
|
+
* }
|
|
59
|
+
*
|
|
60
|
+
* // In application service
|
|
61
|
+
* try {
|
|
62
|
+
* await domainService.ensureNoDuplicate(key, userId);
|
|
63
|
+
* } catch (error) {
|
|
64
|
+
* if (error instanceof DuplicateError) {
|
|
65
|
+
* return { success: false, message: t("errors.duplicate") };
|
|
66
|
+
* }
|
|
67
|
+
* }
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* @see {@link InvalidFormatError} for validation errors
|
|
71
|
+
* @see {@link UnexpectedError} for unexpected errors
|
|
72
|
+
*/
|
|
10
73
|
export declare class DuplicateError extends Error {
|
|
11
74
|
constructor();
|
|
12
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Error thrown when a file type is not allowed.
|
|
78
|
+
*
|
|
79
|
+
* @remarks
|
|
80
|
+
* Used by the images domain when an unsupported file format is uploaded.
|
|
81
|
+
* The message "invalidFileFormat" can be used for i18n lookups.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* const allowedTypes = ["image/jpeg", "image/png", "image/webp"];
|
|
86
|
+
* if (!allowedTypes.includes(file.type)) {
|
|
87
|
+
* throw new FileNotAllowedError();
|
|
88
|
+
* }
|
|
89
|
+
* ```
|
|
90
|
+
*
|
|
91
|
+
* @see {@link InvalidFormatError} for general validation errors
|
|
92
|
+
*/
|
|
13
93
|
export declare class FileNotAllowedError extends Error {
|
|
14
94
|
constructor();
|
|
15
95
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-classes.d.ts","sourceRoot":"","sources":["../../errors/error-classes.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"error-classes.d.ts","sourceRoot":"","sources":["../../errors/error-classes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,eAAgB,SAAQ,KAAK;;CAKzC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;;CAK5C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,cAAe,SAAQ,KAAK;;CAKxC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;;CAK7C"}
|
|
@@ -1,27 +1,104 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Error thrown when an unexpected error occurs.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Used as a catch-all for errors that shouldn't happen under normal conditions.
|
|
6
|
+
* The message "unexpected" can be used for i18n lookups.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* try {
|
|
11
|
+
* // Some operation that should never fail
|
|
12
|
+
* } catch (error) {
|
|
13
|
+
* throw new UnexpectedError();
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @see {@link InvalidFormatError} for validation errors
|
|
18
|
+
* @see {@link DuplicateError} for uniqueness constraint violations
|
|
19
|
+
*/
|
|
7
20
|
export class UnexpectedError extends Error {
|
|
8
21
|
constructor() {
|
|
9
22
|
super("unexpected");
|
|
10
23
|
this.name = "UnexpectedError";
|
|
11
24
|
}
|
|
12
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Error thrown when input validation fails.
|
|
28
|
+
*
|
|
29
|
+
* @remarks
|
|
30
|
+
* Used by domain entities when Zod validation fails.
|
|
31
|
+
* The message "invalidFormat" can be used for i18n lookups.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* // In entity factory
|
|
36
|
+
* try {
|
|
37
|
+
* return ArticleTitle.parse(value);
|
|
38
|
+
* } catch (zodError) {
|
|
39
|
+
* throw new InvalidFormatError();
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @see {@link UnexpectedError} for unexpected errors
|
|
44
|
+
* @see {@link DuplicateError} for uniqueness constraint violations
|
|
45
|
+
*/
|
|
13
46
|
export class InvalidFormatError extends Error {
|
|
14
47
|
constructor() {
|
|
15
48
|
super("invalidFormat");
|
|
16
49
|
this.name = "InvalidFormatError";
|
|
17
50
|
}
|
|
18
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Error thrown when a duplicate entity is detected.
|
|
54
|
+
*
|
|
55
|
+
* @remarks
|
|
56
|
+
* Used by domain services to enforce uniqueness constraints.
|
|
57
|
+
* The message "duplicate" can be used for i18n lookups.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* // In domain service
|
|
62
|
+
* if (await repository.exists(key)) {
|
|
63
|
+
* throw new DuplicateError();
|
|
64
|
+
* }
|
|
65
|
+
*
|
|
66
|
+
* // In application service
|
|
67
|
+
* try {
|
|
68
|
+
* await domainService.ensureNoDuplicate(key, userId);
|
|
69
|
+
* } catch (error) {
|
|
70
|
+
* if (error instanceof DuplicateError) {
|
|
71
|
+
* return { success: false, message: t("errors.duplicate") };
|
|
72
|
+
* }
|
|
73
|
+
* }
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* @see {@link InvalidFormatError} for validation errors
|
|
77
|
+
* @see {@link UnexpectedError} for unexpected errors
|
|
78
|
+
*/
|
|
19
79
|
export class DuplicateError extends Error {
|
|
20
80
|
constructor() {
|
|
21
81
|
super("duplicate");
|
|
22
82
|
this.name = "DuplicateError";
|
|
23
83
|
}
|
|
24
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Error thrown when a file type is not allowed.
|
|
87
|
+
*
|
|
88
|
+
* @remarks
|
|
89
|
+
* Used by the images domain when an unsupported file format is uploaded.
|
|
90
|
+
* The message "invalidFileFormat" can be used for i18n lookups.
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* const allowedTypes = ["image/jpeg", "image/png", "image/webp"];
|
|
95
|
+
* if (!allowedTypes.includes(file.type)) {
|
|
96
|
+
* throw new FileNotAllowedError();
|
|
97
|
+
* }
|
|
98
|
+
* ```
|
|
99
|
+
*
|
|
100
|
+
* @see {@link InvalidFormatError} for general validation errors
|
|
101
|
+
*/
|
|
25
102
|
export class FileNotAllowedError extends Error {
|
|
26
103
|
constructor() {
|
|
27
104
|
super("invalidFileFormat");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-classes.js","sourceRoot":"","sources":["../../errors/error-classes.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"error-classes.js","sourceRoot":"","sources":["../../errors/error-classes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACzC;QACC,KAAK,CAAC,YAAY,CAAC,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAC/B,CAAC;CACD;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC5C;QACC,KAAK,CAAC,eAAe,CAAC,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IAClC,CAAC;CACD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,OAAO,cAAe,SAAQ,KAAK;IACxC;QACC,KAAK,CAAC,WAAW,CAAC,CAAC;QACnB,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC9B,CAAC;CACD;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAC7C;QACC,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACnC,CAAC;CACD"}
|
package/dist/errors/index.d.ts
CHANGED
|
@@ -1,2 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
*
|
|
4
|
+
* Domain-specific error classes for error handling.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Provides typed error classes for common domain scenarios:
|
|
8
|
+
*
|
|
9
|
+
* - **UnexpectedError** - For unexpected runtime errors
|
|
10
|
+
* - **InvalidFormatError** - For validation failures
|
|
11
|
+
* - **DuplicateError** - For uniqueness constraint violations
|
|
12
|
+
* - **FileNotAllowedError** - For forbidden file types
|
|
13
|
+
*
|
|
14
|
+
* All error classes extend the base Error class and include
|
|
15
|
+
* descriptive messages for logging and user feedback.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* import { DuplicateError, InvalidFormatError } from "@repo/core/errors";
|
|
20
|
+
*
|
|
21
|
+
* if (exists) {
|
|
22
|
+
* throw new DuplicateError("Article already exists");
|
|
23
|
+
* }
|
|
24
|
+
*
|
|
25
|
+
* if (!isValid) {
|
|
26
|
+
* throw new InvalidFormatError("Invalid ISBN format");
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
1
30
|
export * from "./error-classes";
|
|
2
31
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../errors/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../errors/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAGH,cAAc,iBAAiB,CAAC"}
|
package/dist/errors/index.js
CHANGED
|
@@ -1,3 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
*
|
|
4
|
+
* Domain-specific error classes for error handling.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Provides typed error classes for common domain scenarios:
|
|
8
|
+
*
|
|
9
|
+
* - **UnexpectedError** - For unexpected runtime errors
|
|
10
|
+
* - **InvalidFormatError** - For validation failures
|
|
11
|
+
* - **DuplicateError** - For uniqueness constraint violations
|
|
12
|
+
* - **FileNotAllowedError** - For forbidden file types
|
|
13
|
+
*
|
|
14
|
+
* All error classes extend the base Error class and include
|
|
15
|
+
* descriptive messages for logging and user feedback.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* import { DuplicateError, InvalidFormatError } from "@repo/core/errors";
|
|
20
|
+
*
|
|
21
|
+
* if (exists) {
|
|
22
|
+
* throw new DuplicateError("Article already exists");
|
|
23
|
+
* }
|
|
24
|
+
*
|
|
25
|
+
* if (!isValid) {
|
|
26
|
+
* throw new InvalidFormatError("Invalid ISBN format");
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
1
30
|
// Error classes
|
|
2
31
|
export * from "./error-classes";
|
|
3
32
|
//# sourceMappingURL=index.js.map
|
package/dist/errors/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../errors/index.ts"],"names":[],"mappings":"AAAA,gBAAgB;AAChB,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../errors/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,gBAAgB;AAChB,cAAc,iBAAiB,CAAC"}
|