@gravito/enterprise 1.0.2 → 1.0.3

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/index.d.mts CHANGED
@@ -28,11 +28,32 @@ interface QueryHandler<TQuery extends Query, TResult> {
28
28
  handle(query: TQuery): Promise<TResult>;
29
29
  }
30
30
 
31
+ /**
32
+ * Abstract base class for Application Use Cases.
33
+ *
34
+ * Use cases encapsulate specific business operations and orchestrate the flow
35
+ * of data between the domain and infrastructure layers.
36
+ *
37
+ * @template TInput - The type of input data required by the use case.
38
+ * @template TOutput - The type of data returned by the use case.
39
+ *
40
+ * @public
41
+ * @since 3.0.0
42
+ */
31
43
  declare abstract class UseCase<TInput, TOutput> {
32
44
  constructor();
33
45
  abstract execute(input: TInput): Promise<TOutput> | TOutput;
34
46
  }
35
47
 
48
+ /**
49
+ * Base class for all Domain Events.
50
+ *
51
+ * Domain events represent something that happened in the domain that is
52
+ * relevant to other parts of the system or external services.
53
+ *
54
+ * @public
55
+ * @since 3.0.0
56
+ */
36
57
  declare abstract class DomainEvent {
37
58
  readonly occurredOn: Date;
38
59
  readonly eventId: string;
@@ -40,6 +61,17 @@ declare abstract class DomainEvent {
40
61
  get eventName(): string;
41
62
  }
42
63
 
64
+ /**
65
+ * Abstract base class for Domain Entities.
66
+ *
67
+ * Entities are objects that have a unique identity that persists over time,
68
+ * even if their attributes change.
69
+ *
70
+ * @template TId - The type of the entity's unique identifier.
71
+ *
72
+ * @public
73
+ * @since 3.0.0
74
+ */
43
75
  declare abstract class Entity<TId> {
44
76
  protected readonly _id: TId;
45
77
  constructor(id: TId);
@@ -59,14 +91,75 @@ declare abstract class AggregateRoot<TId> extends Entity<TId> {
59
91
  clearDomainEvents(): void;
60
92
  }
61
93
 
94
+ /**
95
+ * Generic Repository interface following Domain-Driven Design (DDD) principles.
96
+ *
97
+ * Repositories provide a collection-like interface for accessing and persisting
98
+ * domain entities. They abstract the underlying data storage mechanism.
99
+ *
100
+ * @template TEntity - The type of the Entity managed by the repository.
101
+ * @template TId - The type of the Entity's unique identifier.
102
+ *
103
+ * @example
104
+ * ```typescript
105
+ * class UserRepository implements Repository<User, string> {
106
+ * async save(user: User): Promise<void> { ... }
107
+ * async findById(id: string): Promise<User | null> { ... }
108
+ * // ...
109
+ * }
110
+ * ```
111
+ *
112
+ * @public
113
+ * @since 3.0.0
114
+ */
62
115
  interface Repository<TEntity extends Entity<TId>, TId> {
116
+ /**
117
+ * Persist an entity to the underlying storage.
118
+ *
119
+ * @param entity - The entity to save.
120
+ * @returns A promise that resolves when the save operation is complete.
121
+ */
63
122
  save(entity: TEntity): Promise<void>;
123
+ /**
124
+ * Find an entity by its unique identifier.
125
+ *
126
+ * @param id - The unique identifier of the entity.
127
+ * @returns A promise that resolves to the entity if found, or null otherwise.
128
+ */
64
129
  findById(id: TId): Promise<TEntity | null>;
130
+ /**
131
+ * Retrieve all entities of this type.
132
+ *
133
+ * @returns A promise that resolves to an array of all entities.
134
+ */
65
135
  findAll(): Promise<TEntity[]>;
136
+ /**
137
+ * Delete an entity by its unique identifier.
138
+ *
139
+ * @param id - The unique identifier of the entity to delete.
140
+ * @returns A promise that resolves when the deletion is complete.
141
+ */
66
142
  delete(id: TId): Promise<void>;
143
+ /**
144
+ * Determine if an entity with the given identifier exists.
145
+ *
146
+ * @param id - The unique identifier to check.
147
+ * @returns A promise that resolves to true if the entity exists, false otherwise.
148
+ */
67
149
  exists(id: TId): Promise<boolean>;
68
150
  }
69
151
 
152
+ /**
153
+ * Abstract base class for Domain Value Objects.
154
+ *
155
+ * Value objects are objects that have no conceptual identity. They are defined
156
+ * solely by their attributes and are considered immutable.
157
+ *
158
+ * @template T - The type of the properties held by the value object.
159
+ *
160
+ * @public
161
+ * @since 3.0.0
162
+ */
70
163
  declare abstract class ValueObject<T> {
71
164
  protected readonly props: T;
72
165
  constructor(props: T);
package/dist/index.d.ts CHANGED
@@ -28,11 +28,32 @@ interface QueryHandler<TQuery extends Query, TResult> {
28
28
  handle(query: TQuery): Promise<TResult>;
29
29
  }
30
30
 
31
+ /**
32
+ * Abstract base class for Application Use Cases.
33
+ *
34
+ * Use cases encapsulate specific business operations and orchestrate the flow
35
+ * of data between the domain and infrastructure layers.
36
+ *
37
+ * @template TInput - The type of input data required by the use case.
38
+ * @template TOutput - The type of data returned by the use case.
39
+ *
40
+ * @public
41
+ * @since 3.0.0
42
+ */
31
43
  declare abstract class UseCase<TInput, TOutput> {
32
44
  constructor();
33
45
  abstract execute(input: TInput): Promise<TOutput> | TOutput;
34
46
  }
35
47
 
48
+ /**
49
+ * Base class for all Domain Events.
50
+ *
51
+ * Domain events represent something that happened in the domain that is
52
+ * relevant to other parts of the system or external services.
53
+ *
54
+ * @public
55
+ * @since 3.0.0
56
+ */
36
57
  declare abstract class DomainEvent {
37
58
  readonly occurredOn: Date;
38
59
  readonly eventId: string;
@@ -40,6 +61,17 @@ declare abstract class DomainEvent {
40
61
  get eventName(): string;
41
62
  }
42
63
 
64
+ /**
65
+ * Abstract base class for Domain Entities.
66
+ *
67
+ * Entities are objects that have a unique identity that persists over time,
68
+ * even if their attributes change.
69
+ *
70
+ * @template TId - The type of the entity's unique identifier.
71
+ *
72
+ * @public
73
+ * @since 3.0.0
74
+ */
43
75
  declare abstract class Entity<TId> {
44
76
  protected readonly _id: TId;
45
77
  constructor(id: TId);
@@ -59,14 +91,75 @@ declare abstract class AggregateRoot<TId> extends Entity<TId> {
59
91
  clearDomainEvents(): void;
60
92
  }
61
93
 
94
+ /**
95
+ * Generic Repository interface following Domain-Driven Design (DDD) principles.
96
+ *
97
+ * Repositories provide a collection-like interface for accessing and persisting
98
+ * domain entities. They abstract the underlying data storage mechanism.
99
+ *
100
+ * @template TEntity - The type of the Entity managed by the repository.
101
+ * @template TId - The type of the Entity's unique identifier.
102
+ *
103
+ * @example
104
+ * ```typescript
105
+ * class UserRepository implements Repository<User, string> {
106
+ * async save(user: User): Promise<void> { ... }
107
+ * async findById(id: string): Promise<User | null> { ... }
108
+ * // ...
109
+ * }
110
+ * ```
111
+ *
112
+ * @public
113
+ * @since 3.0.0
114
+ */
62
115
  interface Repository<TEntity extends Entity<TId>, TId> {
116
+ /**
117
+ * Persist an entity to the underlying storage.
118
+ *
119
+ * @param entity - The entity to save.
120
+ * @returns A promise that resolves when the save operation is complete.
121
+ */
63
122
  save(entity: TEntity): Promise<void>;
123
+ /**
124
+ * Find an entity by its unique identifier.
125
+ *
126
+ * @param id - The unique identifier of the entity.
127
+ * @returns A promise that resolves to the entity if found, or null otherwise.
128
+ */
64
129
  findById(id: TId): Promise<TEntity | null>;
130
+ /**
131
+ * Retrieve all entities of this type.
132
+ *
133
+ * @returns A promise that resolves to an array of all entities.
134
+ */
65
135
  findAll(): Promise<TEntity[]>;
136
+ /**
137
+ * Delete an entity by its unique identifier.
138
+ *
139
+ * @param id - The unique identifier of the entity to delete.
140
+ * @returns A promise that resolves when the deletion is complete.
141
+ */
66
142
  delete(id: TId): Promise<void>;
143
+ /**
144
+ * Determine if an entity with the given identifier exists.
145
+ *
146
+ * @param id - The unique identifier to check.
147
+ * @returns A promise that resolves to true if the entity exists, false otherwise.
148
+ */
67
149
  exists(id: TId): Promise<boolean>;
68
150
  }
69
151
 
152
+ /**
153
+ * Abstract base class for Domain Value Objects.
154
+ *
155
+ * Value objects are objects that have no conceptual identity. They are defined
156
+ * solely by their attributes and are considered immutable.
157
+ *
158
+ * @template T - The type of the properties held by the value object.
159
+ *
160
+ * @public
161
+ * @since 3.0.0
162
+ */
70
163
  declare abstract class ValueObject<T> {
71
164
  protected readonly props: T;
72
165
  constructor(props: T);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravito/enterprise",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Enterprise architecture primitives for Gravito framework (DDD/Clean Architecture)",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",