@hexafy/core 1.0.0-rc.0 → 1.0.0-rc.2

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/domain.mjs DELETED
@@ -1,350 +0,0 @@
1
- // src/domain/errors/application.error.ts
2
- /**
3
- * Base error class for application/domain boundaries.
4
- *
5
- * Provides standardized error handling with error codes and context. Consumers
6
- * may use this class or provide their own errors with a compatible shape.
7
- *
8
- * @example
9
- * ```typescript
10
- * // With custom code
11
- * throw new ApplicationError('Invalid operation', { code: 'INVALID_OP' });
12
- *
13
- * // With context
14
- * throw new ApplicationError('Payment failed', {
15
- * code: 'PAYMENT_ERROR',
16
- * context: { amount: 100, currency: 'USD' }
17
- * });
18
- *
19
- * // With cause (error chaining)
20
- * try {
21
- * await someOperation();
22
- * } catch (e) {
23
- * throw new ApplicationError('Operation failed', { cause: e });
24
- * }
25
- * ```;
26
- *
27
- * @param message - The error message
28
- * @param options - Optional error configuration
29
- */
30
- var ApplicationError = class extends Error {
31
- code;
32
- context;
33
- /**
34
- * Constructs a new ApplicationError.
35
- *
36
- * @param message - The error message
37
- * @param options - Optional error configuration (code, context, cause)
38
- */
39
- constructor(message, options = {}) {
40
- super(message, { cause: options.cause });
41
- Object.setPrototypeOf(this, new.target.prototype);
42
- this.name = new.target.name;
43
- this.code = options.code ?? "APPLICATION_ERROR";
44
- this.context = options.context;
45
- }
46
- };
47
- /**
48
- * Validation error for input validation failures.
49
- *
50
- * @example
51
- * ```typescript
52
- * // Simple validation error
53
- * throw new ValidationError('Email is required');
54
- *
55
- * // With validation details
56
- * throw new ValidationError('Validation failed', {
57
- * context: {
58
- * field: 'email',
59
- * reason: 'Invalid email format'
60
- * }
61
- * });
62
- * ```;
63
- *
64
- * @param message - Optional error message (default: 'Validation failed')
65
- * @param details - Optional validation details or raw value
66
- */
67
- var ValidationError = class extends ApplicationError {
68
- constructor(message = "Validation failed", details) {
69
- const options = normalizeApplicationErrorDetails(details);
70
- super(message, {
71
- ...options,
72
- code: "VALIDATION_ERROR"
73
- });
74
- }
75
- };
76
- /**
77
- * Not found error for missing resources.
78
- *
79
- * @example
80
- * ```typescript
81
- * // Standard message
82
- * throw new NotFoundError('User');
83
- * // → "User not found"
84
- *
85
- * // Custom message
86
- * throw new NotFoundError('The specified order was not found');
87
- * ```;
88
- *
89
- * @param resourceOrMessage - Resource name or custom error message
90
- * @param details - Optional error details
91
- */
92
- var NotFoundError = class extends ApplicationError {
93
- constructor(resourceOrMessage = "Resource", details) {
94
- const options = normalizeApplicationErrorDetails(details);
95
- const message = toNotFoundMessage(resourceOrMessage);
96
- super(message, {
97
- ...options,
98
- code: "NOT_FOUND_ERROR"
99
- });
100
- }
101
- };
102
- /**
103
- * Conflict error for resource conflicts (e.g., duplicate entries).
104
- *
105
- * @example
106
- * ```typescript
107
- * throw new ConflictError('Email already registered');
108
- * ```;
109
- *
110
- * @param message - Optional error message (default: 'Conflict detected')
111
- * @param details - Optional error details
112
- */
113
- var ConflictError = class extends ApplicationError {
114
- constructor(message = "Conflict detected", details) {
115
- const options = normalizeApplicationErrorDetails(details);
116
- super(message, {
117
- ...options,
118
- code: "CONFLICT_ERROR"
119
- });
120
- }
121
- };
122
- /**
123
- * Unauthorized error for authentication failures.
124
- *
125
- * @example
126
- * ```typescript
127
- * throw new UnauthorizedError('Invalid authentication token');
128
- * ```;
129
- *
130
- * @param message - Optional error message (default: 'Unauthorized')
131
- * @param details - Optional error details
132
- */
133
- var UnauthorizedError = class extends ApplicationError {
134
- constructor(message = "Unauthorized", details) {
135
- const options = normalizeApplicationErrorDetails(details);
136
- super(message, {
137
- ...options,
138
- code: "UNAUTHORIZED_ERROR"
139
- });
140
- }
141
- };
142
- /**
143
- * Forbidden error for authorization failures.
144
- *
145
- * @example
146
- * ```typescript
147
- * throw new ForbiddenError('Insufficient permissions');
148
- * ```;
149
- *
150
- * @param message - Optional error message (default: 'Forbidden')
151
- * @param details - Optional error details
152
- */
153
- var ForbiddenError = class extends ApplicationError {
154
- constructor(message = "Forbidden", details) {
155
- const options = normalizeApplicationErrorDetails(details);
156
- super(message, {
157
- ...options,
158
- code: "FORBIDDEN_ERROR"
159
- });
160
- }
161
- };
162
- /**
163
- * Invariant error for violated business invariants.
164
- *
165
- * @example
166
- * ```typescript
167
- * throw new InvariantError('Order cannot be modified after shipment');
168
- * ```;
169
- *
170
- * @param message - Optional error message (default: 'Invariant violated')
171
- * @param details - Optional error details
172
- */
173
- var InvariantError = class extends ApplicationError {
174
- constructor(message = "Invariant violated", details) {
175
- const options = normalizeApplicationErrorDetails(details);
176
- super(message, {
177
- ...options,
178
- code: "INVARIANT_ERROR"
179
- });
180
- }
181
- };
182
- /**
183
- * Infrastructure error for external service failures.
184
- *
185
- * @example
186
- * ```typescript
187
- * throw new InfrastructureError('Database connection failed', e);
188
- * ```;
189
- *
190
- * @param message - Optional error message (default: 'Infrastructure failure')
191
- * @param details - Optional error details or underlying error
192
- */
193
- var InfrastructureError = class extends ApplicationError {
194
- constructor(message = "Infrastructure failure", details) {
195
- const options = normalizeApplicationErrorDetails(details);
196
- super(message, {
197
- ...options,
198
- code: "INFRASTRUCTURE_ERROR"
199
- });
200
- }
201
- };
202
- function normalizeApplicationErrorDetails(details) {
203
- if (details === void 0) return {};
204
- if (details !== null && typeof details === "object" && ("context" in details || "cause" in details)) return details;
205
- return { cause: details };
206
- }
207
- function toNotFoundMessage(resourceOrMessage) {
208
- if (resourceOrMessage.trim().length === 0) return "Resource not found";
209
- if (/not found/i.test(resourceOrMessage)) return resourceOrMessage;
210
- return `${resourceOrMessage} not found`;
211
- }
212
- // src/domain/errors/domain-error.guard.ts
213
- const KNOWN_DOMAIN_ERROR_NAMES = /* @__PURE__ */ new Set([
214
- "ApplicationError",
215
- "ValidationError",
216
- "NotFoundError",
217
- "ConflictError",
218
- "UnauthorizedError",
219
- "ForbiddenError",
220
- "InvariantError"
221
- ]);
222
- const DOMAIN_ERROR_CODE_ALIASES = {
223
- UNAUTHORIZED: "UNAUTHORIZED_ERROR",
224
- FORBIDDEN: "FORBIDDEN_ERROR",
225
- NOT_FOUND: "NOT_FOUND_ERROR",
226
- VALIDATION: "VALIDATION_ERROR",
227
- CONFLICT: "CONFLICT_ERROR"
228
- };
229
- function isDomainError(value) {
230
- if (!(value instanceof Error)) return false;
231
- if (value instanceof ApplicationError) return true;
232
- if (KNOWN_DOMAIN_ERROR_NAMES.has(value.name)) return true;
233
- return readCode(value) !== void 0;
234
- }
235
- function getDomainErrorCode(error) {
236
- const explicitCode = readCode(error);
237
- if (explicitCode) return DOMAIN_ERROR_CODE_ALIASES[explicitCode] ?? explicitCode;
238
- return toCodeFromName(error.name) ?? void 0;
239
- }
240
- function readCode(error) {
241
- const code = error.code;
242
- if (typeof code !== "string" || code.trim().length === 0) return;
243
- return code.trim().toUpperCase();
244
- }
245
- function toCodeFromName(name) {
246
- if (!KNOWN_DOMAIN_ERROR_NAMES.has(name)) return null;
247
- if (name === "ApplicationError") return "APPLICATION_ERROR";
248
- return name.replace(/Error$/, "").replace(/([a-z0-9])([A-Z])/g, "$1_$2").toUpperCase().concat("_ERROR");
249
- }
250
- // src/domain/repository/repository.base.ts
251
- /**
252
- * Base repository class providing common CRUD operations.
253
- *
254
- * This class implements the Repository interface and can be extended to provide
255
- * domain-specific implementations while maintaining the core repository
256
- * contract. It provides default implementations for common operations like
257
- * `exists`, `update`, and others.
258
- *
259
- * @example
260
- * ```typescript
261
- * class UserRepository extends RepositoryBase<User, UserId> {
262
- * async findById(id: UserId): Promise<User | null> {
263
- * const data = await db.users.findOne({ id: id.value });
264
- * return data ? new User(id, data.email, data.name) : null;
265
- * }
266
- *
267
- * async findAll(): Promise<User[]> {
268
- * const users = await db.users.find({});
269
- * return users.map((u) => new User(new UserId(u.id), u.email, u.name));
270
- * }
271
- *
272
- * async save(entity: User): Promise<User> {
273
- * const data = {
274
- * id: entity.id.value,
275
- * email: entity.email,
276
- * name: entity.name
277
- * };
278
- * await db.users.upsert(data);
279
- * return entity;
280
- * }
281
- *
282
- * async delete(id: Id): Promise<void> {
283
- * await db.users.delete({ id: id.value });
284
- * }
285
- * }
286
- * ```;
287
- *
288
- * @template Entity - The entity type managed by this repository
289
- * @template Id - The unique identifier type for the entity
290
- */
291
- var RepositoryBase = class {
292
- /** Check if an entity exists by its identifier */
293
- async exists(id) {
294
- return await this.findById(id) !== null;
295
- }
296
- /** Update an entity (alias for save with type safety) */
297
- async update(entity) {
298
- return this.save(entity);
299
- }
300
- };
301
- // src/domain/unit-of-work/unit-of-work.base.ts
302
- /**
303
- * Base unit of work class providing default transaction implementations.
304
- *
305
- * This class provides the UnitOfWork interface implementation with a default
306
- * transaction pattern that commits on success and rolls back on failure.
307
- *
308
- * Extending this class ensures consistent transactional behavior across all
309
- * operations while allowing custom commit/rollback logic per implementation.
310
- *
311
- * @example
312
- * ```typescript
313
- * class SqlUnitOfWork extends UnitOfWorkBase {
314
- * constructor(private readonly connection: SqlConnection) {}
315
- *
316
- * async commit(): Promise<void> {
317
- * await this.connection.commit();
318
- * }
319
- *
320
- * async rollback(): Promise<void> {
321
- * await this.connection.rollback();
322
- * }
323
- * }
324
- *
325
- * // Usage
326
- * const uw = new SqlUnitOfWork(connection);
327
- * const result = await uw.transaction(async (txn) => {
328
- * const user = new User(generateId());
329
- * await repository.save(user);
330
- * return user;
331
- * });
332
- * // Returns user and commits transaction
333
- * ```
334
- */
335
- var UnitOfWorkBase = class {
336
- /** Execute a function within a transaction */
337
- async transaction(fn) {
338
- try {
339
- const result = await fn(this);
340
- await this.commit();
341
- return result;
342
- } catch (error) {
343
- await this.rollback();
344
- throw error;
345
- }
346
- }
347
- };
348
- export { ApplicationError, ConflictError, ForbiddenError, InfrastructureError, InvariantError, NotFoundError, RepositoryBase, UnauthorizedError, UnitOfWorkBase, ValidationError, getDomainErrorCode, isDomainError };
349
-
350
- //# sourceMappingURL=domain.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"domain.mjs","names":[],"sources":["../src/domain/errors/application.error.ts","../src/domain/errors/domain-error.guard.ts","../src/domain/repository/repository.base.ts","../src/domain/unit-of-work/unit-of-work.base.ts"],"sourcesContent":["/**\n * Options for configuring application errors.\n *\n * @param code - An optional error code for programmatic handling\n * @param context - Optional structured context data for debugging\n * @param cause - Optional underlying cause for error chaining\n */\nexport interface ApplicationErrorOptions {\n code?: string;\n context?: Record<string, unknown>;\n cause?: unknown;\n}\n\n/**\n * Details extracted from error configuration.\n *\n * Represents either structured error options (context, cause) or a raw error\n * value.\n */\nexport type ApplicationErrorDetails =\n Omit<ApplicationErrorOptions, 'code'> | unknown;\n\n/**\n * Base error class for application/domain boundaries.\n *\n * Provides standardized error handling with error codes and context. Consumers\n * may use this class or provide their own errors with a compatible shape.\n *\n * @example\n * ```typescript\n * // With custom code\n * throw new ApplicationError('Invalid operation', { code: 'INVALID_OP' });\n *\n * // With context\n * throw new ApplicationError('Payment failed', {\n * code: 'PAYMENT_ERROR',\n * context: { amount: 100, currency: 'USD' }\n * });\n *\n * // With cause (error chaining)\n * try {\n * await someOperation();\n * } catch (e) {\n * throw new ApplicationError('Operation failed', { cause: e });\n * }\n * ```;\n *\n * @param message - The error message\n * @param options - Optional error configuration\n */\nexport class ApplicationError extends Error {\n readonly code: string;\n readonly context: Record<string, unknown> | undefined;\n\n /**\n * Constructs a new ApplicationError.\n *\n * @param message - The error message\n * @param options - Optional error configuration (code, context, cause)\n */\n constructor(message: string, options: ApplicationErrorOptions = {}) {\n super(message, { cause: options.cause });\n Object.setPrototypeOf(this, new.target.prototype);\n\n this.name = new.target.name;\n this.code = options.code ?? 'APPLICATION_ERROR';\n this.context = options.context;\n }\n}\n\n/**\n * Validation error for input validation failures.\n *\n * @example\n * ```typescript\n * // Simple validation error\n * throw new ValidationError('Email is required');\n *\n * // With validation details\n * throw new ValidationError('Validation failed', {\n * context: {\n * field: 'email',\n * reason: 'Invalid email format'\n * }\n * });\n * ```;\n *\n * @param message - Optional error message (default: 'Validation failed')\n * @param details - Optional validation details or raw value\n */\nexport class ValidationError extends ApplicationError {\n constructor(\n message = 'Validation failed',\n details?: ApplicationErrorDetails\n ) {\n const options = normalizeApplicationErrorDetails(details);\n super(message, { ...options, code: 'VALIDATION_ERROR' });\n }\n}\n\n/**\n * Not found error for missing resources.\n *\n * @example\n * ```typescript\n * // Standard message\n * throw new NotFoundError('User');\n * // → \"User not found\"\n *\n * // Custom message\n * throw new NotFoundError('The specified order was not found');\n * ```;\n *\n * @param resourceOrMessage - Resource name or custom error message\n * @param details - Optional error details\n */\nexport class NotFoundError extends ApplicationError {\n constructor(\n resourceOrMessage = 'Resource',\n details?: ApplicationErrorDetails\n ) {\n const options = normalizeApplicationErrorDetails(details);\n const message = toNotFoundMessage(resourceOrMessage);\n super(message, { ...options, code: 'NOT_FOUND_ERROR' });\n }\n}\n\n/**\n * Conflict error for resource conflicts (e.g., duplicate entries).\n *\n * @example\n * ```typescript\n * throw new ConflictError('Email already registered');\n * ```;\n *\n * @param message - Optional error message (default: 'Conflict detected')\n * @param details - Optional error details\n */\nexport class ConflictError extends ApplicationError {\n constructor(\n message = 'Conflict detected',\n details?: ApplicationErrorDetails\n ) {\n const options = normalizeApplicationErrorDetails(details);\n super(message, { ...options, code: 'CONFLICT_ERROR' });\n }\n}\n\n/**\n * Unauthorized error for authentication failures.\n *\n * @example\n * ```typescript\n * throw new UnauthorizedError('Invalid authentication token');\n * ```;\n *\n * @param message - Optional error message (default: 'Unauthorized')\n * @param details - Optional error details\n */\nexport class UnauthorizedError extends ApplicationError {\n constructor(message = 'Unauthorized', details?: ApplicationErrorDetails) {\n const options = normalizeApplicationErrorDetails(details);\n super(message, { ...options, code: 'UNAUTHORIZED_ERROR' });\n }\n}\n\n/**\n * Forbidden error for authorization failures.\n *\n * @example\n * ```typescript\n * throw new ForbiddenError('Insufficient permissions');\n * ```;\n *\n * @param message - Optional error message (default: 'Forbidden')\n * @param details - Optional error details\n */\nexport class ForbiddenError extends ApplicationError {\n constructor(message = 'Forbidden', details?: ApplicationErrorDetails) {\n const options = normalizeApplicationErrorDetails(details);\n super(message, { ...options, code: 'FORBIDDEN_ERROR' });\n }\n}\n\n/**\n * Invariant error for violated business invariants.\n *\n * @example\n * ```typescript\n * throw new InvariantError('Order cannot be modified after shipment');\n * ```;\n *\n * @param message - Optional error message (default: 'Invariant violated')\n * @param details - Optional error details\n */\nexport class InvariantError extends ApplicationError {\n constructor(\n message = 'Invariant violated',\n details?: ApplicationErrorDetails\n ) {\n const options = normalizeApplicationErrorDetails(details);\n super(message, { ...options, code: 'INVARIANT_ERROR' });\n }\n}\n\n/**\n * Infrastructure error for external service failures.\n *\n * @example\n * ```typescript\n * throw new InfrastructureError('Database connection failed', e);\n * ```;\n *\n * @param message - Optional error message (default: 'Infrastructure failure')\n * @param details - Optional error details or underlying error\n */\nexport class InfrastructureError extends ApplicationError {\n constructor(\n message = 'Infrastructure failure',\n details?: ApplicationErrorDetails\n ) {\n const options = normalizeApplicationErrorDetails(details);\n super(message, { ...options, code: 'INFRASTRUCTURE_ERROR' });\n }\n}\n\nfunction normalizeApplicationErrorDetails(\n details: ApplicationErrorDetails | undefined\n): Omit<ApplicationErrorOptions, 'code'> {\n if (details === undefined) {\n return {};\n }\n\n if (\n details !== null &&\n typeof details === 'object' &&\n ('context' in details || 'cause' in details)\n ) {\n return details as Omit<ApplicationErrorOptions, 'code'>;\n }\n\n return { cause: details };\n}\n\nfunction toNotFoundMessage(resourceOrMessage: string): string {\n if (resourceOrMessage.trim().length === 0) {\n return 'Resource not found';\n }\n\n if (/not found/i.test(resourceOrMessage)) {\n return resourceOrMessage;\n }\n\n return `${resourceOrMessage} not found`;\n}\n","import { ApplicationError } from './application.error';\n\nexport interface DomainErrorLike extends Error {\n code?: string;\n context?: Record<string, unknown>;\n}\n\nconst KNOWN_DOMAIN_ERROR_NAMES = new Set<string>([\n 'ApplicationError',\n 'ValidationError',\n 'NotFoundError',\n 'ConflictError',\n 'UnauthorizedError',\n 'ForbiddenError',\n 'InvariantError'\n]);\n\nconst DOMAIN_ERROR_CODE_ALIASES: Record<string, string> = {\n UNAUTHORIZED: 'UNAUTHORIZED_ERROR',\n FORBIDDEN: 'FORBIDDEN_ERROR',\n NOT_FOUND: 'NOT_FOUND_ERROR',\n VALIDATION: 'VALIDATION_ERROR',\n CONFLICT: 'CONFLICT_ERROR'\n};\n\nexport function isDomainError(value: unknown): value is DomainErrorLike {\n if (!(value instanceof Error)) {\n return false;\n }\n\n if (value instanceof ApplicationError) {\n return true;\n }\n\n if (KNOWN_DOMAIN_ERROR_NAMES.has(value.name)) {\n return true;\n }\n\n const code = readCode(value);\n return code !== undefined;\n}\n\nexport function getDomainErrorCode(error: Error): string | undefined {\n const explicitCode = readCode(error);\n if (explicitCode) {\n return DOMAIN_ERROR_CODE_ALIASES[explicitCode] ?? explicitCode;\n }\n\n const nameAsCode = toCodeFromName(error.name);\n return nameAsCode ?? undefined;\n}\n\nfunction readCode(error: Error): string | undefined {\n const code = (error as DomainErrorLike).code;\n if (typeof code !== 'string' || code.trim().length === 0) {\n return undefined;\n }\n return code.trim().toUpperCase();\n}\n\nfunction toCodeFromName(name: string): string | null {\n if (!KNOWN_DOMAIN_ERROR_NAMES.has(name)) {\n return null;\n }\n\n if (name === 'ApplicationError') {\n return 'APPLICATION_ERROR';\n }\n\n const nameWithoutSuffix = name.replace(/Error$/, '');\n return nameWithoutSuffix\n .replace(/([a-z0-9])([A-Z])/g, '$1_$2')\n .toUpperCase()\n .concat('_ERROR');\n}\n","import { Entity as EntityType, type UniqueIdentifier } from '../primitives';\n\n/**\n * Base repository class providing common CRUD operations.\n *\n * This class implements the Repository interface and can be extended to provide\n * domain-specific implementations while maintaining the core repository\n * contract. It provides default implementations for common operations like\n * `exists`, `update`, and others.\n *\n * @example\n * ```typescript\n * class UserRepository extends RepositoryBase<User, UserId> {\n * async findById(id: UserId): Promise<User | null> {\n * const data = await db.users.findOne({ id: id.value });\n * return data ? new User(id, data.email, data.name) : null;\n * }\n *\n * async findAll(): Promise<User[]> {\n * const users = await db.users.find({});\n * return users.map((u) => new User(new UserId(u.id), u.email, u.name));\n * }\n *\n * async save(entity: User): Promise<User> {\n * const data = {\n * id: entity.id.value,\n * email: entity.email,\n * name: entity.name\n * };\n * await db.users.upsert(data);\n * return entity;\n * }\n *\n * async delete(id: Id): Promise<void> {\n * await db.users.delete({ id: id.value });\n * }\n * }\n * ```;\n *\n * @template Entity - The entity type managed by this repository\n * @template Id - The unique identifier type for the entity\n */\nexport abstract class RepositoryBase<\n Entity extends EntityType<UniqueIdentifier>,\n Id extends UniqueIdentifier = UniqueIdentifier\n> {\n /**\n * Find an entity by its unique identifier\n *\n * @abstract\n */\n abstract findById(id: Id): Promise<Entity | null>;\n\n /**\n * Find all entities\n *\n * @abstract\n */\n abstract findAll(): Promise<Entity[]>;\n\n /**\n * Save an entity (create or update)\n *\n * @abstract\n */\n abstract save(entity: Entity): Promise<Entity>;\n\n /**\n * Delete an entity by its unique identifier\n *\n * @abstract\n */\n abstract delete(id: Id): Promise<void>;\n\n /** Check if an entity exists by its identifier */\n async exists(id: Id): Promise<boolean> {\n const entity = await this.findById(id);\n return entity !== null;\n }\n\n /** Update an entity (alias for save with type safety) */\n async update(entity: Entity): Promise<Entity> {\n return this.save(entity);\n }\n}\n","/**\n * Base unit of work class providing default transaction implementations.\n *\n * This class provides the UnitOfWork interface implementation with a default\n * transaction pattern that commits on success and rolls back on failure.\n *\n * Extending this class ensures consistent transactional behavior across all\n * operations while allowing custom commit/rollback logic per implementation.\n *\n * @example\n * ```typescript\n * class SqlUnitOfWork extends UnitOfWorkBase {\n * constructor(private readonly connection: SqlConnection) {}\n *\n * async commit(): Promise<void> {\n * await this.connection.commit();\n * }\n *\n * async rollback(): Promise<void> {\n * await this.connection.rollback();\n * }\n * }\n *\n * // Usage\n * const uw = new SqlUnitOfWork(connection);\n * const result = await uw.transaction(async (txn) => {\n * const user = new User(generateId());\n * await repository.save(user);\n * return user;\n * });\n * // Returns user and commits transaction\n * ```\n */\n\nexport abstract class UnitOfWorkBase {\n /**\n * Commit all pending changes\n *\n * @abstract\n */\n abstract commit(): Promise<void>;\n\n /**\n * Rollback all pending changes\n *\n * @abstract\n */\n abstract rollback(): Promise<void>;\n\n /** Execute a function within a transaction */\n async transaction<T>(fn: (uw: UnitOfWorkBase) => Promise<T>): Promise<T> {\n try {\n const result = await fn(this);\n await this.commit();\n return result;\n } catch (error) {\n await this.rollback();\n throw error;\n }\n }\n}\n"],"mappings":"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"}
@@ -1,38 +0,0 @@
1
- import { a as ClockPort, n as LoggingPort, r as IdentifierPort, t as MetricsPort } from "./metrics.port-CfI8yKMA.mjs";
2
- export declare const SystemClockAdapter: ClockPort;
3
- export declare const SystemIdentifierAdapter: IdentifierPort;
4
- /**
5
- * Console-based logging adapter for development and debugging.
6
- *
7
- * Outputs structured log messages to the console with appropriate colors based
8
- * on log level (info, debug, warn, error).
9
- *
10
- * @see {@link LoggingPort}
11
- */
12
- export declare const ConsoleLoggingAdapter: LoggingPort;
13
- export declare const createConsoleLogger: (component?: string) => LoggingPort;
14
- /**
15
- * No-op logging adapter implementing LoggingPort.
16
- *
17
- * Discards all log messages. Useful for:
18
- *
19
- * - Production environments with external logging
20
- * - Testing where logging output is undesirable
21
- * - Performance-critical paths without logging
22
- *
23
- * @see {@link LoggingPort}
24
- */
25
- export declare const NoOpLoggingAdapter: LoggingPort;
26
- /**
27
- * No-op metrics adapter implementing MetricsPort.
28
- *
29
- * Discards all metric data. Useful for:
30
- *
31
- * - Production environments with external metrics collection
32
- * - Testing where metrics should not be recorded
33
- * - Development without metrics instrumentation
34
- *
35
- * @see {@link MetricsPort}
36
- */
37
- export declare const NoOpMetricsAdapter: MetricsPort;
38
- //# sourceMappingURL=infrastructure.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"infrastructure.d.mts","names":[],"sources":["../src/infrastructure/adapters/clock/system.clock.adapter.ts","../src/infrastructure/adapters/identifier/system.identifier.adapter.ts","../src/infrastructure/adapters/logging/console.logging.adapter.ts","../src/infrastructure/adapters/logging/json-console.logging.adapter.ts","../src/infrastructure/adapters/logging/noop.logging.adapter.ts","../src/infrastructure/adapters/metrics/noop.metrics.adapter.ts"],"mappings":";qBAEa,oBAAoB;qBCApB,yBAAyB;;;;;;;;;qBCQzB,uBAAuB;qBC2GvB,sBAAmB,uBAAyB;;;;;;;;;;;;qBCxG5C,oBAAoB;;;;;;;;;;;;qBCApB,oBAAoB"}
@@ -1,98 +0,0 @@
1
- import { i as SystemClockAdapter, n as ConsoleLoggingAdapter, r as SystemIdentifierAdapter, t as NoOpMetricsAdapter } from "./noop.metrics.adapter-MgMrk-sq.mjs";
2
- // src/infrastructure/adapters/logging/json-console.logging.adapter.ts
3
- function createLogEntry(level, message, component, context) {
4
- const entry = {
5
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
6
- level,
7
- message,
8
- ...component && { component }
9
- };
10
- if (context) {
11
- const seen = /* @__PURE__ */ new WeakSet();
12
- for (const [key, value] of Object.entries(context)) {
13
- if (key in entry) continue;
14
- entry[key] = normalizeLogValue(value, seen);
15
- }
16
- }
17
- try {
18
- return JSON.stringify(entry);
19
- } catch {
20
- return JSON.stringify({
21
- timestamp: entry["timestamp"],
22
- level: entry["level"],
23
- message: entry["message"],
24
- component: entry["component"],
25
- _serializationError: "Failed to serialize full log entry"
26
- });
27
- }
28
- }
29
- const RESERVED_ERROR_KEYS = /* @__PURE__ */ new Set([
30
- "name",
31
- "message",
32
- "stack",
33
- "cause",
34
- "logLevel"
35
- ]);
36
- function normalizeErrorForLog(error, seen = /* @__PURE__ */ new WeakSet()) {
37
- if (seen.has(error)) return {
38
- name: error.name,
39
- message: error.message,
40
- stack: error.stack,
41
- _circular: true
42
- };
43
- seen.add(error);
44
- const normalized = {
45
- name: error.name,
46
- message: error.message,
47
- stack: error.stack
48
- };
49
- for (const [key, value] of Object.entries(error)) {
50
- if (RESERVED_ERROR_KEYS.has(key)) continue;
51
- normalized[key] = normalizeLogValue(value, seen);
52
- }
53
- const cause = error.cause;
54
- if (cause instanceof Error) normalized["cause"] = normalizeErrorForLog(cause, seen);
55
- return normalized;
56
- }
57
- function normalizeLogValue(value, seen) {
58
- if (value instanceof Error) return normalizeErrorForLog(value, seen);
59
- if (value === null || typeof value !== "object") return value;
60
- if (seen.has(value)) return "[Circular]";
61
- seen.add(value);
62
- if (Array.isArray(value)) return value.map((item) => normalizeLogValue(item, seen));
63
- if (!isPlainObject(value)) return value;
64
- const normalized = {};
65
- for (const [key, nestedValue] of Object.entries(value)) normalized[key] = normalizeLogValue(nestedValue, seen);
66
- return normalized;
67
- }
68
- function isPlainObject(value) {
69
- const prototype = Object.getPrototypeOf(value);
70
- return prototype === Object.prototype || prototype === null;
71
- }
72
- const createConsoleLogger = (component) => ({
73
- info: (message, context) => console.info(createLogEntry("info", message, component, context)),
74
- debug: (message, context) => console.debug(createLogEntry("debug", message, component, context)),
75
- warn: (message, context) => console.warn(createLogEntry("warn", message, component, context)),
76
- error: (message, context) => console.error(createLogEntry("error", message, component, context))
77
- });
78
- // src/infrastructure/adapters/logging/noop.logging.adapter.ts
79
- /**
80
- * No-op logging adapter implementing LoggingPort.
81
- *
82
- * Discards all log messages. Useful for:
83
- *
84
- * - Production environments with external logging
85
- * - Testing where logging output is undesirable
86
- * - Performance-critical paths without logging
87
- *
88
- * @see {@link LoggingPort}
89
- */
90
- const NoOpLoggingAdapter = {
91
- info: () => {},
92
- warn: () => {},
93
- error: () => {},
94
- debug: () => {}
95
- };
96
- export { ConsoleLoggingAdapter, NoOpLoggingAdapter, NoOpMetricsAdapter, SystemClockAdapter, SystemIdentifierAdapter, createConsoleLogger };
97
-
98
- //# sourceMappingURL=infrastructure.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"infrastructure.mjs","names":[],"sources":["../src/infrastructure/adapters/logging/json-console.logging.adapter.ts","../src/infrastructure/adapters/logging/noop.logging.adapter.ts"],"sourcesContent":["import type { LoggingPort } from '../../../domain/ports';\n\nfunction createLogEntry(\n level: 'info' | 'debug' | 'warn' | 'error',\n message: string,\n component?: string,\n context?: unknown\n): string {\n const entry: Record<string, unknown> = {\n timestamp: new Date().toISOString(),\n level,\n message,\n ...(component && { component })\n };\n\n if (context) {\n const seen = new WeakSet<object>();\n for (const [key, value] of Object.entries(context)) {\n if (key in entry) continue;\n entry[key] = normalizeLogValue(value, seen);\n }\n }\n\n try {\n return JSON.stringify(entry);\n } catch {\n return JSON.stringify({\n timestamp: entry['timestamp'],\n level: entry['level'],\n message: entry['message'],\n component: entry['component'],\n _serializationError: 'Failed to serialize full log entry'\n });\n }\n}\n\nconst RESERVED_ERROR_KEYS = new Set([\n 'name',\n 'message',\n 'stack',\n 'cause',\n 'logLevel'\n]);\n\nfunction normalizeErrorForLog(\n error: Error,\n seen = new WeakSet<object>()\n): Record<string, unknown> {\n if (seen.has(error)) {\n return {\n name: error.name,\n message: error.message,\n stack: error.stack,\n _circular: true\n };\n }\n\n seen.add(error);\n\n const normalized: Record<string, unknown> = {\n name: error.name,\n message: error.message,\n stack: error.stack\n };\n\n for (const [key, value] of Object.entries(error)) {\n if (RESERVED_ERROR_KEYS.has(key)) {\n continue;\n }\n\n normalized[key] = normalizeLogValue(value, seen);\n }\n\n const cause = (error as Error & { cause?: unknown }).cause;\n if (cause instanceof Error) {\n normalized['cause'] = normalizeErrorForLog(cause, seen);\n }\n\n return normalized;\n}\n\nfunction normalizeLogValue(value: unknown, seen: WeakSet<object>): unknown {\n if (value instanceof Error) {\n return normalizeErrorForLog(value, seen);\n }\n\n if (value === null || typeof value !== 'object') {\n return value;\n }\n\n if (seen.has(value)) {\n return '[Circular]';\n }\n\n seen.add(value);\n\n if (Array.isArray(value)) {\n return value.map((item) => normalizeLogValue(item, seen));\n }\n\n if (!isPlainObject(value)) {\n return value;\n }\n\n const normalized: Record<string, unknown> = {};\n for (const [key, nestedValue] of Object.entries(value)) {\n normalized[key] = normalizeLogValue(nestedValue, seen);\n }\n\n return normalized;\n}\n\nfunction isPlainObject(value: object): value is Record<string, unknown> {\n const prototype = Object.getPrototypeOf(value);\n return prototype === Object.prototype || prototype === null;\n}\n\nexport const createConsoleLogger = (component?: string): LoggingPort => ({\n info: (message, context) =>\n console.info(createLogEntry('info', message, component, context)),\n debug: (message, context) =>\n console.debug(createLogEntry('debug', message, component, context)),\n warn: (message, context) =>\n console.warn(createLogEntry('warn', message, component, context)),\n error: (message, context) =>\n console.error(createLogEntry('error', message, component, context))\n});\n","import type { LoggingPort } from '../../../domain/ports';\n\n/**\n * No-op logging adapter implementing LoggingPort.\n *\n * Discards all log messages. Useful for:\n *\n * - Production environments with external logging\n * - Testing where logging output is undesirable\n * - Performance-critical paths without logging\n *\n * @see {@link LoggingPort}\n */\nexport const NoOpLoggingAdapter: LoggingPort = {\n info: () => {},\n warn: () => {},\n error: () => {},\n debug: () => {}\n};\n"],"mappings":";;AAEA,SAAS,eACP,OACA,SACA,WACA,SACQ;CACR,MAAM,QAAiC;EACrC,4BAAW,IAAI,KAAK,EAAA,CAAE,YAAY;EAClC;EACA;EACA,GAAI,aAAa,EAAE,UAAU;CAC/B;CAEA,IAAI,SAAS;EACX,MAAM,uBAAO,IAAI,QAAgB;EACjC,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,GAAG;GAClD,IAAI,OAAO,OAAO;GAClB,MAAM,OAAO,kBAAkB,OAAO,IAAI;EAC5C;CACF;CAEA,IAAI;EACF,OAAO,KAAK,UAAU,KAAK;CAC7B,QAAQ;EACN,OAAO,KAAK,UAAU;GACpB,WAAW,MAAM;GACjB,OAAO,MAAM;GACb,SAAS,MAAM;GACf,WAAW,MAAM;GACjB,qBAAqB;EACvB,CAAC;CACH;AACF;AAEA,MAAM,sCAAsB,IAAI,IAAI;CAClC;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,qBACP,OACA,uBAAO,IAAI,QAAgB,GACF;CACzB,IAAI,KAAK,IAAI,KAAK,GAChB,OAAO;EACL,MAAM,MAAM;EACZ,SAAS,MAAM;EACf,OAAO,MAAM;EACb,WAAW;CACb;CAGF,KAAK,IAAI,KAAK;CAEd,MAAM,aAAsC;EAC1C,MAAM,MAAM;EACZ,SAAS,MAAM;EACf,OAAO,MAAM;CACf;CAEA,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,KAAK,GAAG;EAChD,IAAI,oBAAoB,IAAI,GAAG,GAC7B;EAGF,WAAW,OAAO,kBAAkB,OAAO,IAAI;CACjD;CAEA,MAAM,QAAS,MAAsC;CACrD,IAAI,iBAAiB,OACnB,WAAW,WAAW,qBAAqB,OAAO,IAAI;CAGxD,OAAO;AACT;AAEA,SAAS,kBAAkB,OAAgB,MAAgC;CACzE,IAAI,iBAAiB,OACnB,OAAO,qBAAqB,OAAO,IAAI;CAGzC,IAAI,UAAU,QAAQ,OAAO,UAAU,UACrC,OAAO;CAGT,IAAI,KAAK,IAAI,KAAK,GAChB,OAAO;CAGT,KAAK,IAAI,KAAK;CAEd,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,KAAK,SAAS,kBAAkB,MAAM,IAAI,CAAC;CAG1D,IAAI,CAAC,cAAc,KAAK,GACtB,OAAO;CAGT,MAAM,aAAsC,CAAC;CAC7C,KAAK,MAAM,CAAC,KAAK,gBAAgB,OAAO,QAAQ,KAAK,GACnD,WAAW,OAAO,kBAAkB,aAAa,IAAI;CAGvD,OAAO;AACT;AAEA,SAAS,cAAc,OAAiD;CACtE,MAAM,YAAY,OAAO,eAAe,KAAK;CAC7C,OAAO,cAAc,OAAO,aAAa,cAAc;AACzD;AAEA,MAAa,uBAAuB,eAAqC;CACvE,OAAO,SAAS,YACd,QAAQ,KAAK,eAAe,QAAQ,SAAS,WAAW,OAAO,CAAC;CAClE,QAAQ,SAAS,YACf,QAAQ,MAAM,eAAe,SAAS,SAAS,WAAW,OAAO,CAAC;CACpE,OAAO,SAAS,YACd,QAAQ,KAAK,eAAe,QAAQ,SAAS,WAAW,OAAO,CAAC;CAClE,QAAQ,SAAS,YACf,QAAQ,MAAM,eAAe,SAAS,SAAS,WAAW,OAAO,CAAC;AACtE;;;;;;;;;;;;;ACjHA,MAAa,qBAAkC;CAC7C,YAAY,CAAC;CACb,YAAY,CAAC;CACb,aAAa,CAAC;CACd,aAAa,CAAC;AAChB"}
@@ -1,114 +0,0 @@
1
- /**
2
- * Port for clock/time operations.
3
- *
4
- * Provides an abstraction for time-related operations, enabling testing through
5
- * mock implementations and flexibility for different time sources.
6
- *
7
- * @example
8
- * ```typescript
9
- * // Get current timestamp
10
- * const timestamp = clock.now(); // milliseconds since epoch
11
- * ```
12
- *
13
- * @returns Current time as milliseconds since Unix epoch
14
- */
15
- interface ClockPort {
16
- now(): number;
17
- }
18
- /**
19
- * Unique identifier type for domain objects.
20
- *
21
- * Represents an identifier that uniquely identifies an entity, value object, or
22
- * aggregate. Can be either a string (e.g., UUID) or number (e.g.,
23
- * auto-increment ID).
24
- *
25
- * @example
26
- * ```typescript
27
- * // Using branded types for stronger typing
28
- * type UserId = Brand<UniqueIdentifier, 'UserId'>;
29
- * type OrderId = Brand<UniqueIdentifier, 'OrderId'>;
30
- *
31
- * // Type-safe function
32
- * function getUser(id: UserId): User | null {
33
- * return db.users.find(id);
34
- * }
35
- * ```
36
- */
37
- type UniqueIdentifier = string | number;
38
- /**
39
- * Port for generating unique identifiers.
40
- *
41
- * Provides an abstraction for identifier generation, enabling testing through
42
- * mock implementations and flexibility for different ID strategies (UUIDs,
43
- * ULIDs, timestamps, etc.).
44
- *
45
- * @example
46
- * ```typescript
47
- * // Generate a unique identifier
48
- * const id = identifier.generate(clock);
49
- * // 'a1b2c3d4e5f6g7h8'
50
- * ```;
51
- *
52
- * @param clock - Optional clock port for time-based generation
53
- * @returns A unique identifier string
54
- */
55
- interface IdentifierPort {
56
- generate(clock?: ClockPort): UniqueIdentifier;
57
- }
58
- /**
59
- * Port for structured logging operations.
60
- *
61
- * Provides a unified interface for logging across different layers.
62
- * Implementations can be console-based, file-based, or distributed (e.g.,
63
- * logging to a service).
64
- *
65
- * @example
66
- * ```typescript
67
- * logger.info('User created', { userId: '123', email: 'user@example.com' });
68
- * logger.debug('Processing payment', { amount: 100 });
69
- * logger.warn('Rate limit approaching', { remaining: 10 });
70
- * logger.error('Payment failed', { error: 'timeout', attempt: 3 });
71
- * ```
72
- *
73
- * @param message - The log message
74
- * @param data - Optional structured data to include in the log
75
- */
76
- interface LoggingPort {
77
- info(message: string, data?: unknown): void;
78
- debug(message: string, data?: unknown): void;
79
- warn(message: string, data?: unknown): void;
80
- error(message: string, data?: unknown): void;
81
- }
82
- /**
83
- * MetricPort - Interface for metrics collection
84
- *
85
- * Consumers implement this interface to integrate with their metrics system
86
- * (Prometheus, Datadog, New Relic, etc.)
87
- */
88
- interface MetricsPort {
89
- /**
90
- * Increment a counter metric
91
- *
92
- * @param metric - The metric name
93
- * @param labels - Optional labels/key-value pairs
94
- */
95
- increment(metric: string, labels?: Record<string, string>): void;
96
- /**
97
- * Record a histogram value
98
- *
99
- * @param metric - The metric name
100
- * @param value - The value to record
101
- * @param labels - Optional labels/key-value pairs
102
- */
103
- histogram(metric: string, value: number, labels?: Record<string, string>): void;
104
- /**
105
- * Record a gauge value
106
- *
107
- * @param metric - The metric name
108
- * @param value - The value to record
109
- * @param labels - Optional labels/key-value pairs
110
- */
111
- gauge(metric: string, value: number, labels?: Record<string, string>): void;
112
- }
113
- export { ClockPort as a, UniqueIdentifier as i, LoggingPort as n, IdentifierPort as r, MetricsPort as t };
114
- //# sourceMappingURL=metrics.port-CfI8yKMA.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"metrics.port-CfI8yKMA.d.mts","names":[],"sources":["../src/domain/ports/clock.port.ts","../src/domain/primitives/unique-identifier.type.ts","../src/domain/ports/identifier.port.ts","../src/domain/ports/logging.port.ts","../src/domain/ports/metrics.port.ts"],"mappings":";;;;;;;;;;;;;;UAciB;EACf;;;;;;;;;;;;;;;;;;;;;KCIU;;;;;;;;;;;;;;;;;;UCCK;EACf,SAAS,QAAQ,YAAY;;;;;;;;;;;;;;;;;;;;UCHd;EACf,KAAK,iBAAiB;EACtB,MAAM,iBAAiB;EACvB,KAAK,iBAAiB;EACtB,MAAM,iBAAiB;;;;;;;;UChBR;;;;;;;EAOf,UAAU,gBAAgB,SAAS;;;;;;;;EASnC,UACE,gBACA,eACA,SAAS;;;;;;;;EAUX,MAAM,gBAAgB,eAAe,SAAS"}