@cosmneo/onion-lasagna 0.1.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.
Files changed (97) hide show
  1. package/dist/backend/core/global.cjs +283 -0
  2. package/dist/backend/core/global.cjs.map +1 -0
  3. package/dist/backend/core/global.d.cts +294 -0
  4. package/dist/backend/core/global.d.ts +294 -0
  5. package/dist/backend/core/global.js +39 -0
  6. package/dist/backend/core/global.js.map +1 -0
  7. package/dist/backend/core/onion-layers.cjs +2302 -0
  8. package/dist/backend/core/onion-layers.cjs.map +1 -0
  9. package/dist/backend/core/onion-layers.d.cts +1675 -0
  10. package/dist/backend/core/onion-layers.d.ts +1675 -0
  11. package/dist/backend/core/onion-layers.js +1158 -0
  12. package/dist/backend/core/onion-layers.js.map +1 -0
  13. package/dist/backend/core/presentation.cjs +573 -0
  14. package/dist/backend/core/presentation.cjs.map +1 -0
  15. package/dist/backend/core/presentation.d.cts +5 -0
  16. package/dist/backend/core/presentation.d.ts +5 -0
  17. package/dist/backend/core/presentation.js +28 -0
  18. package/dist/backend/core/presentation.js.map +1 -0
  19. package/dist/backend/core/validators/arktype.cjs +947 -0
  20. package/dist/backend/core/validators/arktype.cjs.map +1 -0
  21. package/dist/backend/core/validators/arktype.d.cts +188 -0
  22. package/dist/backend/core/validators/arktype.d.ts +188 -0
  23. package/dist/backend/core/validators/arktype.js +287 -0
  24. package/dist/backend/core/validators/arktype.js.map +1 -0
  25. package/dist/backend/core/validators/typebox.cjs +939 -0
  26. package/dist/backend/core/validators/typebox.cjs.map +1 -0
  27. package/dist/backend/core/validators/typebox.d.cts +189 -0
  28. package/dist/backend/core/validators/typebox.d.ts +189 -0
  29. package/dist/backend/core/validators/typebox.js +281 -0
  30. package/dist/backend/core/validators/typebox.js.map +1 -0
  31. package/dist/backend/core/validators/valibot.cjs +942 -0
  32. package/dist/backend/core/validators/valibot.cjs.map +1 -0
  33. package/dist/backend/core/validators/valibot.d.cts +160 -0
  34. package/dist/backend/core/validators/valibot.d.ts +160 -0
  35. package/dist/backend/core/validators/valibot.js +294 -0
  36. package/dist/backend/core/validators/valibot.js.map +1 -0
  37. package/dist/backend/core/validators/zod.cjs +934 -0
  38. package/dist/backend/core/validators/zod.cjs.map +1 -0
  39. package/dist/backend/core/validators/zod.d.cts +188 -0
  40. package/dist/backend/core/validators/zod.d.ts +188 -0
  41. package/dist/backend/core/validators/zod.js +278 -0
  42. package/dist/backend/core/validators/zod.js.map +1 -0
  43. package/dist/backend/frameworks/elysia.cjs +715 -0
  44. package/dist/backend/frameworks/elysia.cjs.map +1 -0
  45. package/dist/backend/frameworks/elysia.d.cts +208 -0
  46. package/dist/backend/frameworks/elysia.d.ts +208 -0
  47. package/dist/backend/frameworks/elysia.js +251 -0
  48. package/dist/backend/frameworks/elysia.js.map +1 -0
  49. package/dist/backend/frameworks/fastify.cjs +677 -0
  50. package/dist/backend/frameworks/fastify.cjs.map +1 -0
  51. package/dist/backend/frameworks/fastify.d.cts +201 -0
  52. package/dist/backend/frameworks/fastify.d.ts +201 -0
  53. package/dist/backend/frameworks/fastify.js +213 -0
  54. package/dist/backend/frameworks/fastify.js.map +1 -0
  55. package/dist/backend/frameworks/hono.cjs +715 -0
  56. package/dist/backend/frameworks/hono.cjs.map +1 -0
  57. package/dist/backend/frameworks/hono.d.cts +163 -0
  58. package/dist/backend/frameworks/hono.d.ts +163 -0
  59. package/dist/backend/frameworks/hono.js +249 -0
  60. package/dist/backend/frameworks/hono.js.map +1 -0
  61. package/dist/backend/frameworks/nestjs.cjs +260 -0
  62. package/dist/backend/frameworks/nestjs.cjs.map +1 -0
  63. package/dist/backend/frameworks/nestjs.d.cts +168 -0
  64. package/dist/backend/frameworks/nestjs.d.ts +168 -0
  65. package/dist/backend/frameworks/nestjs.js +193 -0
  66. package/dist/backend/frameworks/nestjs.js.map +1 -0
  67. package/dist/base-dto.class-D7W9iqoU.d.cts +146 -0
  68. package/dist/base-dto.class-D7W9iqoU.d.ts +146 -0
  69. package/dist/base-uuid-v7.vo-BPGEIWLM.d.ts +799 -0
  70. package/dist/base-uuid-v7.vo-BjqKX44G.d.cts +799 -0
  71. package/dist/chunk-74IKUOSE.js +116 -0
  72. package/dist/chunk-74IKUOSE.js.map +1 -0
  73. package/dist/chunk-BKZOLGQW.js +29 -0
  74. package/dist/chunk-BKZOLGQW.js.map +1 -0
  75. package/dist/chunk-CGZBV6BD.js +54 -0
  76. package/dist/chunk-CGZBV6BD.js.map +1 -0
  77. package/dist/chunk-DDAHJZVK.js +258 -0
  78. package/dist/chunk-DDAHJZVK.js.map +1 -0
  79. package/dist/chunk-MQD5GXMT.js +171 -0
  80. package/dist/chunk-MQD5GXMT.js.map +1 -0
  81. package/dist/chunk-OKFXZHBC.js +43 -0
  82. package/dist/chunk-OKFXZHBC.js.map +1 -0
  83. package/dist/chunk-RLLWYFPI.js +168 -0
  84. package/dist/chunk-RLLWYFPI.js.map +1 -0
  85. package/dist/chunk-VCHFXT5W.js +425 -0
  86. package/dist/chunk-VCHFXT5W.js.map +1 -0
  87. package/dist/chunk-ZWLYNGO3.js +40 -0
  88. package/dist/chunk-ZWLYNGO3.js.map +1 -0
  89. package/dist/http-response-BAhi8lF4.d.cts +124 -0
  90. package/dist/http-response-BAhi8lF4.d.ts +124 -0
  91. package/dist/index-DingXh7B.d.cts +1187 -0
  92. package/dist/index-tOH7XBa3.d.ts +1187 -0
  93. package/dist/routing.type-DB4pt-d9.d.ts +184 -0
  94. package/dist/routing.type-DF2BIL7x.d.cts +184 -0
  95. package/dist/validation-error.type-kD4_qNZ9.d.cts +199 -0
  96. package/dist/validation-error.type-kD4_qNZ9.d.ts +199 -0
  97. package/package.json +191 -0
@@ -0,0 +1,939 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/backend/core/validators/typebox/index.ts
21
+ var typebox_exports = {};
22
+ __export(typebox_exports, {
23
+ AuditByVo: () => AuditByVo,
24
+ AuditInfoVo: () => AuditInfoVo,
25
+ AuditOnVo: () => AuditOnVo,
26
+ Dto: () => Dto,
27
+ EmailVo: () => EmailVo,
28
+ LongTextVo: () => LongTextVo,
29
+ MediumTextVo: () => MediumTextVo,
30
+ PaginationVo: () => PaginationVo,
31
+ ShortTextVo: () => ShortTextVo,
32
+ TypeBoxObjectValidator: () => TypeBoxObjectValidator,
33
+ UuidV4Vo: () => UuidV4Vo,
34
+ UuidV7Vo: () => UuidV7Vo,
35
+ createTypeBoxValidator: () => createTypeBoxValidator,
36
+ typeBoxObjectValidator: () => typeBoxObjectValidator
37
+ });
38
+ module.exports = __toCommonJS(typebox_exports);
39
+
40
+ // src/backend/core/validators/typebox/object-validator.typebox.ts
41
+ var import_value = require("@sinclair/typebox/value");
42
+
43
+ // src/backend/core/global/exceptions/coded-error.error.ts
44
+ var CodedError = class extends Error {
45
+ /** Machine-readable error code for programmatic handling. */
46
+ code;
47
+ /**
48
+ * Creates a new CodedError instance.
49
+ *
50
+ * @param options - Error configuration
51
+ * @param options.message - Human-readable error message
52
+ * @param options.code - Machine-readable error code from ErrorCodes registry or custom string
53
+ * @param options.cause - Optional underlying error that caused this error
54
+ */
55
+ constructor({
56
+ message,
57
+ code,
58
+ cause
59
+ }) {
60
+ super(message);
61
+ this.name = this.constructor.name;
62
+ this.code = code;
63
+ if (cause !== void 0) {
64
+ Object.defineProperty(this, "cause", {
65
+ value: cause,
66
+ writable: false,
67
+ enumerable: false,
68
+ configurable: true
69
+ });
70
+ }
71
+ }
72
+ /**
73
+ * Factory method to create a typed error from a caught error.
74
+ *
75
+ * Subclasses should override this to provide proper error transformation.
76
+ * Designed for use with {@link wrapErrorAsync} and {@link wrapError}.
77
+ *
78
+ * @param _cause - The original caught error
79
+ * @returns A new CodedError instance
80
+ * @throws {Error} If not overridden by subclass
81
+ *
82
+ * @example
83
+ * ```typescript
84
+ * class NotFoundError extends UseCaseError {
85
+ * static override fromError(cause: unknown): NotFoundError {
86
+ * return new NotFoundError({
87
+ * message: 'Resource not found',
88
+ * cause,
89
+ * });
90
+ * }
91
+ * }
92
+ * ```
93
+ */
94
+ static fromError(_cause) {
95
+ throw new Error(`${this.name}.fromError() must be implemented by subclass`);
96
+ }
97
+ };
98
+
99
+ // src/backend/core/global/exceptions/error-codes.const.ts
100
+ var ErrorCodes = {
101
+ /**
102
+ * Domain layer error codes.
103
+ * Used for business rule violations and invariant failures.
104
+ */
105
+ Domain: {
106
+ /** Generic domain error */
107
+ DOMAIN_ERROR: "DOMAIN_ERROR",
108
+ /** Business invariant was violated */
109
+ INVARIANT_VIOLATION: "INVARIANT_VIOLATION",
110
+ /** Aggregate was partially loaded (missing required relations) */
111
+ PARTIAL_LOAD: "PARTIAL_LOAD"
112
+ },
113
+ /**
114
+ * Application layer (use case) error codes.
115
+ * Used for orchestration failures and business operation errors.
116
+ */
117
+ App: {
118
+ /** Generic use case error */
119
+ USE_CASE_ERROR: "USE_CASE_ERROR",
120
+ /** Requested resource was not found */
121
+ NOT_FOUND: "NOT_FOUND",
122
+ /** Resource state conflict (e.g., duplicate, already exists) */
123
+ CONFLICT: "CONFLICT",
124
+ /** Request is valid but cannot be processed due to business rules */
125
+ UNPROCESSABLE: "UNPROCESSABLE"
126
+ },
127
+ /**
128
+ * Infrastructure layer error codes.
129
+ * Used for data access, external services, and I/O failures.
130
+ */
131
+ Infra: {
132
+ /** Generic infrastructure error */
133
+ INFRA_ERROR: "INFRA_ERROR",
134
+ /** Database operation failed */
135
+ DB_ERROR: "DB_ERROR",
136
+ /** Network connectivity or communication error */
137
+ NETWORK_ERROR: "NETWORK_ERROR",
138
+ /** Operation timed out */
139
+ TIMEOUT_ERROR: "TIMEOUT_ERROR",
140
+ /** External/third-party service error */
141
+ EXTERNAL_SERVICE_ERROR: "EXTERNAL_SERVICE_ERROR"
142
+ },
143
+ /**
144
+ * Presentation layer error codes.
145
+ * Used for controller, request handling, and authorization errors.
146
+ */
147
+ Presentation: {
148
+ /** Generic controller error */
149
+ CONTROLLER_ERROR: "CONTROLLER_ERROR",
150
+ /** Request denied due to authorization failure */
151
+ ACCESS_DENIED: "ACCESS_DENIED",
152
+ /** Request validation failed (malformed input) */
153
+ INVALID_REQUEST: "INVALID_REQUEST"
154
+ },
155
+ /**
156
+ * Global/cross-cutting error codes.
157
+ * Used for validation and other cross-layer concerns.
158
+ */
159
+ Global: {
160
+ /** Object/schema validation failed */
161
+ OBJECT_VALIDATION_ERROR: "OBJECT_VALIDATION_ERROR"
162
+ }
163
+ };
164
+
165
+ // src/backend/core/global/exceptions/object-validation.error.ts
166
+ var ObjectValidationError = class _ObjectValidationError extends CodedError {
167
+ /**
168
+ * Array of field-level validation errors.
169
+ *
170
+ * Each entry contains:
171
+ * - `field`: Dot-notation path to the invalid field (e.g., 'user.email')
172
+ * - `message`: Human-readable validation failure message
173
+ */
174
+ validationErrors;
175
+ /**
176
+ * Creates a new ObjectValidationError instance.
177
+ *
178
+ * @param options - Error configuration
179
+ * @param options.message - Human-readable summary message
180
+ * @param options.code - Machine-readable error code (default: 'OBJECT_VALIDATION_ERROR')
181
+ * @param options.cause - Optional underlying error from validation library
182
+ * @param options.validationErrors - Array of field-level validation errors
183
+ */
184
+ constructor({
185
+ message,
186
+ code = ErrorCodes.Global.OBJECT_VALIDATION_ERROR,
187
+ cause,
188
+ validationErrors
189
+ }) {
190
+ super({ message, code, cause });
191
+ this.validationErrors = validationErrors;
192
+ }
193
+ /**
194
+ * Creates an ObjectValidationError from a caught error.
195
+ *
196
+ * @param cause - The original caught error
197
+ * @returns A new ObjectValidationError instance with the cause attached
198
+ */
199
+ static fromError(cause) {
200
+ return new _ObjectValidationError({
201
+ message: cause instanceof Error ? cause.message : "Validation failed",
202
+ cause,
203
+ validationErrors: []
204
+ });
205
+ }
206
+ };
207
+
208
+ // src/backend/core/validators/typebox/object-validator.typebox.ts
209
+ var formatPath = (path) => {
210
+ if (!path || path === "/") return "root";
211
+ return path.slice(1).split("/").map((segment, index) => {
212
+ const num = Number(segment);
213
+ if (!isNaN(num)) return `[${num}]`;
214
+ return index === 0 ? segment : `.${segment}`;
215
+ }).join("");
216
+ };
217
+ var toValidationErrors = (errors) => [...errors].map((error) => ({
218
+ field: formatPath(error?.path ?? "/"),
219
+ message: error?.message ?? "Validation failed"
220
+ }));
221
+ var TypeBoxObjectValidator = class {
222
+ validateObject(schema11, value) {
223
+ const errors = [...import_value.Value.Errors(schema11, value)];
224
+ if (errors.length === 0) {
225
+ return import_value.Value.Decode(schema11, value);
226
+ }
227
+ throw new ObjectValidationError({
228
+ message: "Object validation failed",
229
+ cause: errors,
230
+ validationErrors: toValidationErrors(errors)
231
+ });
232
+ }
233
+ withSchema(schema11) {
234
+ return {
235
+ validate: (value) => this.validateObject(schema11, value)
236
+ };
237
+ }
238
+ };
239
+
240
+ // src/backend/core/validators/typebox/bootstrap.ts
241
+ var typeBoxObjectValidator = new TypeBoxObjectValidator();
242
+ var createTypeBoxValidator = (schema11) => typeBoxObjectValidator.withSchema(schema11);
243
+
244
+ // src/backend/core/global/classes/base-dto.class.ts
245
+ var SKIP_DTO_VALIDATION = "skip dto validation";
246
+ var BaseDto = class {
247
+ _data;
248
+ /**
249
+ * Creates a new DTO instance.
250
+ *
251
+ * @param data - The raw data to validate and wrap
252
+ * @param validator - A bound validator or SKIP_DTO_VALIDATION to bypass
253
+ * @throws {ObjectValidationError} When validation fails
254
+ */
255
+ constructor(data, validator) {
256
+ this._data = validator === SKIP_DTO_VALIDATION ? data : validator.validate(data);
257
+ }
258
+ /**
259
+ * The validated data payload.
260
+ *
261
+ * @returns The validated data of type T
262
+ */
263
+ get data() {
264
+ return this._data;
265
+ }
266
+ };
267
+
268
+ // src/backend/core/validators/typebox/wrappers/dto.ts
269
+ var Dto = class extends BaseDto {
270
+ constructor(schema11, value) {
271
+ super(value, createTypeBoxValidator(schema11));
272
+ }
273
+ };
274
+
275
+ // src/backend/core/validators/typebox/wrappers/value-objects/audit-by.vo.ts
276
+ var import_typebox2 = require("@sinclair/typebox");
277
+
278
+ // src/backend/core/onion-layers/domain/classes/base-value-object.class.ts
279
+ var SKIP_VALUE_OBJECT_VALIDATION = "skip value object validation";
280
+ function deepEquals(a, b) {
281
+ if (a === b) return true;
282
+ if (a === null || a === void 0 || b === null || b === void 0) {
283
+ return a === b;
284
+ }
285
+ if (a instanceof Date && b instanceof Date) {
286
+ return a.getTime() === b.getTime();
287
+ }
288
+ if (Array.isArray(a) && Array.isArray(b)) {
289
+ if (a.length !== b.length) return false;
290
+ return a.every((item, index) => deepEquals(item, b[index]));
291
+ }
292
+ if (typeof a === "object" && typeof b === "object") {
293
+ const aObj = a;
294
+ const bObj = b;
295
+ const aKeys = Object.keys(aObj);
296
+ const bKeys = Object.keys(bObj);
297
+ if (aKeys.length !== bKeys.length) return false;
298
+ return aKeys.every((key) => deepEquals(aObj[key], bObj[key]));
299
+ }
300
+ return false;
301
+ }
302
+ var BaseValueObject = class {
303
+ _value;
304
+ /**
305
+ * Creates a new Value Object instance.
306
+ *
307
+ * @param value - The raw value to wrap
308
+ * @param validator - A bound validator or SKIP_VALUE_OBJECT_VALIDATION to bypass
309
+ * @throws {ObjectValidationError} When validation fails
310
+ */
311
+ constructor(value, validator) {
312
+ this._value = validator === SKIP_VALUE_OBJECT_VALIDATION ? value : validator.validate(value);
313
+ }
314
+ /**
315
+ * Compares this Value Object with another for equality.
316
+ *
317
+ * Uses deep equality comparison to handle nested objects, arrays, and dates.
318
+ * Two Value Objects are equal if their underlying values are deeply equal.
319
+ *
320
+ * @param other - The Value Object to compare with
321
+ * @returns `true` if the values are deeply equal, `false` otherwise
322
+ */
323
+ equals(other) {
324
+ if (this === other) return true;
325
+ return deepEquals(this.value, other.value);
326
+ }
327
+ /**
328
+ * The underlying immutable value.
329
+ *
330
+ * @returns The wrapped value of type T
331
+ */
332
+ get value() {
333
+ return this._value;
334
+ }
335
+ };
336
+
337
+ // src/backend/core/onion-layers/domain/value-objects/base-audit-by.vo.ts
338
+ var BaseAuditByVo = class extends BaseValueObject {
339
+ /**
340
+ * Creates a new BaseAuditByVo instance.
341
+ *
342
+ * @param value - The user tracking values
343
+ * @param value.createdBy - User who created the entity (optional for system ops)
344
+ * @param value.updatedBy - User who last updated the entity (optional)
345
+ * @param validator - Bound validator or skip validation symbol
346
+ */
347
+ constructor(value, validator) {
348
+ super(value, validator);
349
+ }
350
+ /**
351
+ * The user ID who created the entity.
352
+ * Returns `undefined` for system-created entities.
353
+ */
354
+ get createdBy() {
355
+ return this.value.createdBy;
356
+ }
357
+ /**
358
+ * The user ID who last updated the entity.
359
+ * Returns `undefined` for system-updated entities.
360
+ */
361
+ get updatedBy() {
362
+ return this.value.updatedBy;
363
+ }
364
+ };
365
+
366
+ // src/backend/core/validators/typebox/wrappers/value-objects/uuid-v4.vo.ts
367
+ var import_typebox = require("@sinclair/typebox");
368
+
369
+ // src/backend/core/onion-layers/domain/value-objects/base-uuid-v4.vo.ts
370
+ var import_uuid = require("uuid");
371
+ var BaseUuidV4Vo = class extends BaseValueObject {
372
+ /**
373
+ * Creates a new BaseUuidV4Vo instance.
374
+ *
375
+ * @param value - The UUID v4 string value
376
+ * @param validator - Bound validator or skip validation symbol
377
+ */
378
+ constructor(value, validator) {
379
+ super(value, validator);
380
+ }
381
+ /**
382
+ * Generates a new UUID v4 value object.
383
+ *
384
+ * Creates a random UUID, skipping validation since the
385
+ * `uuid` library guarantees format.
386
+ *
387
+ * @returns A new BaseUuidV4Vo with a freshly generated UUID
388
+ */
389
+ static generate() {
390
+ return new this((0, import_uuid.v4)(), SKIP_VALUE_OBJECT_VALIDATION);
391
+ }
392
+ /**
393
+ * Creates a UUID v4 value object from an existing string.
394
+ *
395
+ * **Important:** This base implementation skips validation and accepts
396
+ * any string value. Subclasses should override this method with a
397
+ * validator to ensure UUID format correctness.
398
+ *
399
+ * @param value - The UUID v4 string value (not validated at base level)
400
+ * @returns A new BaseUuidV4Vo with the provided value
401
+ *
402
+ * @example Subclass with validation (recommended)
403
+ * ```typescript
404
+ * class UserId extends BaseUuidV4Vo {
405
+ * static override create(value: string): UserId {
406
+ * return new UserId(value, uuidV4Validator);
407
+ * }
408
+ * }
409
+ * ```
410
+ *
411
+ * @see generate - For creating new UUIDs (always valid)
412
+ */
413
+ static create(value) {
414
+ return new this(value, SKIP_VALUE_OBJECT_VALIDATION);
415
+ }
416
+ };
417
+
418
+ // src/backend/core/validators/typebox/wrappers/value-objects/uuid-v4.vo.ts
419
+ var schema = import_typebox.Type.String({ format: "uuid" });
420
+ var UuidV4Vo = class _UuidV4Vo extends BaseUuidV4Vo {
421
+ constructor(value) {
422
+ super(value, createTypeBoxValidator(schema));
423
+ }
424
+ static create(value) {
425
+ return new _UuidV4Vo(value);
426
+ }
427
+ };
428
+
429
+ // src/backend/core/validators/typebox/wrappers/value-objects/audit-by.vo.ts
430
+ var schema2 = import_typebox2.Type.Object({
431
+ createdBy: import_typebox2.Type.Optional(import_typebox2.Type.String({ format: "uuid" })),
432
+ updatedBy: import_typebox2.Type.Optional(import_typebox2.Type.String({ format: "uuid" }))
433
+ });
434
+ var AuditByVo = class _AuditByVo extends BaseAuditByVo {
435
+ constructor(value) {
436
+ super(value, SKIP_VALUE_OBJECT_VALIDATION);
437
+ }
438
+ static create({ createdBy, updatedBy }) {
439
+ const validated = createTypeBoxValidator(schema2).validate({
440
+ createdBy,
441
+ updatedBy
442
+ });
443
+ return new _AuditByVo({
444
+ createdBy: validated.createdBy ? UuidV4Vo.create(validated.createdBy) : void 0,
445
+ updatedBy: validated.updatedBy ? UuidV4Vo.create(validated.updatedBy) : void 0
446
+ });
447
+ }
448
+ update(updatedBy) {
449
+ return new _AuditByVo({ createdBy: this.createdBy, updatedBy });
450
+ }
451
+ };
452
+
453
+ // src/backend/core/validators/typebox/wrappers/value-objects/audit-info.vo.ts
454
+ var import_typebox4 = require("@sinclair/typebox");
455
+
456
+ // src/backend/core/onion-layers/domain/value-objects/base-audit-info.vo.ts
457
+ var BaseAuditInfoVo = class extends BaseValueObject {
458
+ /**
459
+ * Creates a new BaseAuditInfoVo instance.
460
+ *
461
+ * @param value - Composite value containing audit by and on VOs
462
+ * @param value.by - User tracking value object
463
+ * @param value.on - Timestamp tracking value object
464
+ * @param validator - Bound validator or skip validation symbol
465
+ */
466
+ constructor(value, validator) {
467
+ super(value, validator);
468
+ }
469
+ /**
470
+ * The user ID who created the entity.
471
+ * Returns `undefined` for system-created entities.
472
+ */
473
+ get createdBy() {
474
+ return this.value.by.createdBy;
475
+ }
476
+ /**
477
+ * The timestamp when the entity was created.
478
+ * Returns a cloned Date to prevent mutation.
479
+ */
480
+ get createdAt() {
481
+ return new Date(this.value.on.createdAt.getTime());
482
+ }
483
+ /**
484
+ * The user ID who last updated the entity.
485
+ * Returns `undefined` for system-updated entities.
486
+ */
487
+ get updatedBy() {
488
+ return this.value.by.updatedBy;
489
+ }
490
+ /**
491
+ * The timestamp when the entity was last updated.
492
+ * Returns a cloned Date to prevent mutation.
493
+ */
494
+ get updatedAt() {
495
+ return new Date(this.value.on.updatedAt.getTime());
496
+ }
497
+ /**
498
+ * Whether the entity has been modified since creation.
499
+ *
500
+ * Compares both timestamps and user IDs. Returns `true` if either:
501
+ * - The updatedAt timestamp differs from createdAt
502
+ * - The updatedBy user differs from createdBy
503
+ *
504
+ * Note: When both createdBy and updatedBy are undefined (system-created
505
+ * entities), this correctly returns false for the user comparison.
506
+ */
507
+ get isModified() {
508
+ const timestampChanged = this.updatedAt.getTime() !== this.createdAt.getTime();
509
+ const userChanged = this.updatedBy?.value !== this.createdBy?.value;
510
+ return timestampChanged || userChanged;
511
+ }
512
+ /**
513
+ * Alias for `updatedBy` for semantic clarity.
514
+ */
515
+ get lastModifiedBy() {
516
+ return this.updatedBy;
517
+ }
518
+ /**
519
+ * Alias for `updatedAt` for semantic clarity.
520
+ */
521
+ get lastModifiedAt() {
522
+ return this.updatedAt;
523
+ }
524
+ };
525
+
526
+ // src/backend/core/validators/typebox/wrappers/value-objects/audit-on.vo.ts
527
+ var import_typebox3 = require("@sinclair/typebox");
528
+
529
+ // src/backend/core/onion-layers/domain/exceptions/domain.error.ts
530
+ var DomainError = class _DomainError extends CodedError {
531
+ /**
532
+ * Creates a new DomainError instance.
533
+ *
534
+ * @param options - Error configuration
535
+ * @param options.message - Human-readable error description
536
+ * @param options.code - Machine-readable error code (default: 'DOMAIN_ERROR')
537
+ * @param options.cause - Optional underlying error
538
+ */
539
+ constructor({
540
+ message,
541
+ code = ErrorCodes.Domain.DOMAIN_ERROR,
542
+ cause
543
+ }) {
544
+ super({ message, code, cause });
545
+ }
546
+ /**
547
+ * Creates a DomainError from a caught error.
548
+ *
549
+ * @param cause - The original caught error
550
+ * @returns A new DomainError instance with the cause attached
551
+ */
552
+ static fromError(cause) {
553
+ return new _DomainError({
554
+ message: cause instanceof Error ? cause.message : "Domain error",
555
+ cause
556
+ });
557
+ }
558
+ };
559
+
560
+ // src/backend/core/onion-layers/domain/exceptions/invariant-violation.error.ts
561
+ var InvariantViolationError = class _InvariantViolationError extends DomainError {
562
+ /**
563
+ * Creates a new InvariantViolationError instance.
564
+ *
565
+ * @param options - Error configuration
566
+ * @param options.message - Description of the violated invariant
567
+ * @param options.code - Machine-readable error code (default: 'INVARIANT_VIOLATION')
568
+ * @param options.cause - Optional underlying error
569
+ */
570
+ constructor({
571
+ message,
572
+ code = ErrorCodes.Domain.INVARIANT_VIOLATION,
573
+ cause
574
+ }) {
575
+ super({ message, code, cause });
576
+ }
577
+ /**
578
+ * Creates an InvariantViolationError from a caught error.
579
+ *
580
+ * @param cause - The original caught error
581
+ * @returns A new InvariantViolationError instance with the cause attached
582
+ */
583
+ static fromError(cause) {
584
+ return new _InvariantViolationError({
585
+ message: cause instanceof Error ? cause.message : "Invariant violation",
586
+ cause
587
+ });
588
+ }
589
+ };
590
+
591
+ // src/backend/core/onion-layers/domain/value-objects/base-audit-on.vo.ts
592
+ var BaseAuditOnVo = class extends BaseValueObject {
593
+ /**
594
+ * Creates a new BaseAuditOnVo instance.
595
+ *
596
+ * @param value - The timestamp values
597
+ * @param value.createdAt - When the entity was created
598
+ * @param value.updatedAt - When the entity was last updated
599
+ * @param validator - Bound validator or skip validation symbol
600
+ * @throws {InvariantViolationError} When `updatedAt < createdAt`
601
+ */
602
+ constructor(value, validator) {
603
+ if (value.updatedAt < value.createdAt) {
604
+ throw new InvariantViolationError({
605
+ message: "UpdatedAt cannot be earlier than createdAt",
606
+ code: "INVALID_AUDIT_TIMESTAMPS"
607
+ });
608
+ }
609
+ super(value, validator);
610
+ }
611
+ /**
612
+ * When the entity was created.
613
+ * Returns a cloned Date to prevent mutation.
614
+ */
615
+ get createdAt() {
616
+ return new Date(this.value.createdAt);
617
+ }
618
+ /**
619
+ * When the entity was last updated.
620
+ * Returns a cloned Date to prevent mutation.
621
+ */
622
+ get updatedAt() {
623
+ return new Date(this.value.updatedAt);
624
+ }
625
+ };
626
+
627
+ // src/backend/core/validators/typebox/wrappers/value-objects/audit-on.vo.ts
628
+ var schema3 = import_typebox3.Type.Object({
629
+ createdAt: import_typebox3.Type.Optional(import_typebox3.Type.Date()),
630
+ updatedAt: import_typebox3.Type.Optional(import_typebox3.Type.Date())
631
+ });
632
+ var AuditOnVo = class _AuditOnVo extends BaseAuditOnVo {
633
+ constructor(value) {
634
+ super(value, SKIP_VALUE_OBJECT_VALIDATION);
635
+ }
636
+ static create({ createdAt, updatedAt }) {
637
+ const validated = createTypeBoxValidator(schema3).validate({
638
+ createdAt,
639
+ updatedAt
640
+ });
641
+ const finalCreatedAt = validated.createdAt ?? /* @__PURE__ */ new Date();
642
+ const finalUpdatedAt = validated.updatedAt ?? finalCreatedAt;
643
+ return new _AuditOnVo({
644
+ createdAt: new Date(finalCreatedAt),
645
+ updatedAt: new Date(finalUpdatedAt)
646
+ });
647
+ }
648
+ update() {
649
+ return new _AuditOnVo({ createdAt: this.createdAt, updatedAt: /* @__PURE__ */ new Date() });
650
+ }
651
+ };
652
+
653
+ // src/backend/core/validators/typebox/wrappers/value-objects/audit-info.vo.ts
654
+ var schema4 = import_typebox4.Type.Object({
655
+ createdBy: import_typebox4.Type.Optional(import_typebox4.Type.String({ format: "uuid" })),
656
+ createdAt: import_typebox4.Type.Optional(import_typebox4.Type.Date()),
657
+ updatedBy: import_typebox4.Type.Optional(import_typebox4.Type.String({ format: "uuid" })),
658
+ updatedAt: import_typebox4.Type.Optional(import_typebox4.Type.Date())
659
+ });
660
+ var AuditInfoVo = class _AuditInfoVo extends BaseAuditInfoVo {
661
+ constructor(value) {
662
+ super(value, SKIP_VALUE_OBJECT_VALIDATION);
663
+ }
664
+ static create({
665
+ createdBy,
666
+ createdAt,
667
+ updatedBy,
668
+ updatedAt
669
+ }) {
670
+ const validated = createTypeBoxValidator(schema4).validate({
671
+ createdBy,
672
+ createdAt,
673
+ updatedBy,
674
+ updatedAt
675
+ });
676
+ const by = AuditByVo.create({
677
+ createdBy: validated.createdBy,
678
+ updatedBy: validated.updatedBy
679
+ });
680
+ const on = AuditOnVo.create({
681
+ createdAt: validated.createdAt,
682
+ updatedAt: validated.updatedAt
683
+ });
684
+ return new _AuditInfoVo({ by, on });
685
+ }
686
+ static createNew(createdBy) {
687
+ const by = AuditByVo.create({ createdBy });
688
+ const on = AuditOnVo.create({});
689
+ return new _AuditInfoVo({ by, on });
690
+ }
691
+ update(updatedBy) {
692
+ const by = this.value.by.update(updatedBy);
693
+ const on = this.value.on.update();
694
+ return new _AuditInfoVo({ by, on });
695
+ }
696
+ };
697
+
698
+ // src/backend/core/validators/typebox/wrappers/value-objects/email.vo.ts
699
+ var import_typebox5 = require("@sinclair/typebox");
700
+
701
+ // src/backend/core/onion-layers/domain/value-objects/base-email.vo.ts
702
+ var BaseEmailVo = class extends BaseValueObject {
703
+ /**
704
+ * Creates a new BaseEmailVo instance.
705
+ *
706
+ * @param value - The email address string
707
+ * @param validator - Bound validator or skip validation symbol
708
+ */
709
+ constructor(value, validator) {
710
+ super(value, validator);
711
+ }
712
+ };
713
+
714
+ // src/backend/core/validators/typebox/wrappers/value-objects/email.vo.ts
715
+ var schema5 = import_typebox5.Type.String({ format: "email" });
716
+ var EmailVo = class _EmailVo extends BaseEmailVo {
717
+ constructor(value) {
718
+ super(value, createTypeBoxValidator(schema5));
719
+ }
720
+ static create(value) {
721
+ return new _EmailVo(value);
722
+ }
723
+ };
724
+
725
+ // src/backend/core/validators/typebox/wrappers/value-objects/long-text.vo.ts
726
+ var import_typebox6 = require("@sinclair/typebox");
727
+
728
+ // src/backend/core/onion-layers/domain/value-objects/base-long-text.vo.ts
729
+ var BaseLongTextVo = class extends BaseValueObject {
730
+ /**
731
+ * Creates a new BaseLongTextVo instance.
732
+ *
733
+ * @param value - The long text string
734
+ * @param validator - Bound validator or skip validation symbol
735
+ */
736
+ constructor(value, validator) {
737
+ super(value, validator);
738
+ }
739
+ };
740
+
741
+ // src/backend/core/validators/typebox/wrappers/value-objects/long-text.vo.ts
742
+ var schema6 = (maxLen) => import_typebox6.Type.String({ minLength: 1, maxLength: maxLen });
743
+ var LongTextVo = class _LongTextVo extends BaseLongTextVo {
744
+ constructor(value, maxLen = 2e3) {
745
+ super(value, createTypeBoxValidator(schema6(maxLen)));
746
+ }
747
+ static create(value, maxLen = 2e3) {
748
+ return new _LongTextVo(value, maxLen);
749
+ }
750
+ };
751
+
752
+ // src/backend/core/validators/typebox/wrappers/value-objects/medium-text.vo.ts
753
+ var import_typebox7 = require("@sinclair/typebox");
754
+
755
+ // src/backend/core/onion-layers/domain/value-objects/base-medium-text.vo.ts
756
+ var BaseMediumTextVo = class extends BaseValueObject {
757
+ /**
758
+ * Creates a new BaseMediumTextVo instance.
759
+ *
760
+ * @param value - The medium text string
761
+ * @param validator - Bound validator or skip validation symbol
762
+ */
763
+ constructor(value, validator) {
764
+ super(value, validator);
765
+ }
766
+ };
767
+
768
+ // src/backend/core/validators/typebox/wrappers/value-objects/medium-text.vo.ts
769
+ var schema7 = (maxLen) => import_typebox7.Type.String({ minLength: 1, maxLength: maxLen });
770
+ var MediumTextVo = class _MediumTextVo extends BaseMediumTextVo {
771
+ constructor(value, maxLen = 500) {
772
+ super(value, createTypeBoxValidator(schema7(maxLen)));
773
+ }
774
+ static create(value, maxLen = 500) {
775
+ return new _MediumTextVo(value, maxLen);
776
+ }
777
+ };
778
+
779
+ // src/backend/core/validators/typebox/wrappers/value-objects/pagination.vo.ts
780
+ var import_typebox8 = require("@sinclair/typebox");
781
+
782
+ // src/backend/core/onion-layers/domain/value-objects/base-pagination.vo.ts
783
+ var BasePaginationVo = class extends BaseValueObject {
784
+ /**
785
+ * Creates a new BasePaginationVo instance.
786
+ *
787
+ * @param value - The pagination parameters
788
+ * @param value.page - The page number (typically 1-indexed)
789
+ * @param value.pageSize - The number of items per page
790
+ * @param validator - Bound validator or skip validation symbol
791
+ */
792
+ constructor(value, validator) {
793
+ super(value, validator);
794
+ }
795
+ /**
796
+ * The current page number.
797
+ */
798
+ get page() {
799
+ return this.value.page;
800
+ }
801
+ /**
802
+ * The number of items per page.
803
+ */
804
+ get pageSize() {
805
+ return this.value.pageSize;
806
+ }
807
+ };
808
+
809
+ // src/backend/core/validators/typebox/wrappers/value-objects/pagination.vo.ts
810
+ var schema8 = (maxPageSize) => import_typebox8.Type.Object({
811
+ page: import_typebox8.Type.Integer({ minimum: 1 }),
812
+ pageSize: import_typebox8.Type.Integer({ minimum: 1, maximum: maxPageSize })
813
+ });
814
+ var PaginationVo = class _PaginationVo extends BasePaginationVo {
815
+ constructor(value) {
816
+ super(value, SKIP_VALUE_OBJECT_VALIDATION);
817
+ }
818
+ static create({
819
+ page,
820
+ pageSize,
821
+ maxPageSize = 100
822
+ }) {
823
+ const validated = createTypeBoxValidator(
824
+ schema8(maxPageSize)
825
+ ).validate({
826
+ page,
827
+ pageSize
828
+ });
829
+ return new _PaginationVo(validated);
830
+ }
831
+ };
832
+
833
+ // src/backend/core/validators/typebox/wrappers/value-objects/short-text.vo.ts
834
+ var import_typebox9 = require("@sinclair/typebox");
835
+
836
+ // src/backend/core/onion-layers/domain/value-objects/base-short-text.vo.ts
837
+ var BaseShortTextVo = class extends BaseValueObject {
838
+ /**
839
+ * Creates a new BaseShortTextVo instance.
840
+ *
841
+ * @param value - The short text string
842
+ * @param validator - Bound validator or skip validation symbol
843
+ */
844
+ constructor(value, validator) {
845
+ super(value, validator);
846
+ }
847
+ };
848
+
849
+ // src/backend/core/validators/typebox/wrappers/value-objects/short-text.vo.ts
850
+ var schema9 = (maxLen) => import_typebox9.Type.String({ minLength: 1, maxLength: maxLen });
851
+ var ShortTextVo = class _ShortTextVo extends BaseShortTextVo {
852
+ constructor(value, maxLen = 100) {
853
+ super(value, createTypeBoxValidator(schema9(maxLen)));
854
+ }
855
+ static create(value, maxLen = 100) {
856
+ return new _ShortTextVo(value, maxLen);
857
+ }
858
+ };
859
+
860
+ // src/backend/core/validators/typebox/wrappers/value-objects/uuid-v7.vo.ts
861
+ var import_typebox10 = require("@sinclair/typebox");
862
+
863
+ // src/backend/core/onion-layers/domain/value-objects/base-uuid-v7.vo.ts
864
+ var import_uuid2 = require("uuid");
865
+ var BaseUuidV7Vo = class extends BaseValueObject {
866
+ /**
867
+ * Creates a new BaseUuidV7Vo instance.
868
+ *
869
+ * @param value - The UUID v7 string value
870
+ * @param validator - Bound validator or skip validation symbol
871
+ */
872
+ constructor(value, validator) {
873
+ super(value, validator);
874
+ }
875
+ /**
876
+ * Generates a new UUID v7 value object.
877
+ *
878
+ * Creates a time-ordered UUID using the current timestamp,
879
+ * skipping validation since the `uuid` library guarantees format.
880
+ *
881
+ * @returns A new BaseUuidV7Vo with a freshly generated UUID
882
+ */
883
+ static generate() {
884
+ return new this((0, import_uuid2.v7)(), SKIP_VALUE_OBJECT_VALIDATION);
885
+ }
886
+ /**
887
+ * Creates a UUID v7 value object from an existing string.
888
+ *
889
+ * **Important:** This base implementation skips validation and accepts
890
+ * any string value. Subclasses should override this method with a
891
+ * validator to ensure UUID format correctness.
892
+ *
893
+ * @param value - The UUID v7 string value (not validated at base level)
894
+ * @returns A new BaseUuidV7Vo with the provided value
895
+ *
896
+ * @example Subclass with validation (recommended)
897
+ * ```typescript
898
+ * class OrderId extends BaseUuidV7Vo {
899
+ * static override create(value: string): OrderId {
900
+ * return new OrderId(value, uuidV7Validator);
901
+ * }
902
+ * }
903
+ * ```
904
+ *
905
+ * @see generate - For creating new UUIDs (always valid)
906
+ */
907
+ static create(value) {
908
+ return new this(value, SKIP_VALUE_OBJECT_VALIDATION);
909
+ }
910
+ };
911
+
912
+ // src/backend/core/validators/typebox/wrappers/value-objects/uuid-v7.vo.ts
913
+ var schema10 = import_typebox10.Type.String({ format: "uuid" });
914
+ var UuidV7Vo = class _UuidV7Vo extends BaseUuidV7Vo {
915
+ constructor(value) {
916
+ super(value, createTypeBoxValidator(schema10));
917
+ }
918
+ static create(value) {
919
+ return new _UuidV7Vo(value);
920
+ }
921
+ };
922
+ // Annotate the CommonJS export names for ESM import in node:
923
+ 0 && (module.exports = {
924
+ AuditByVo,
925
+ AuditInfoVo,
926
+ AuditOnVo,
927
+ Dto,
928
+ EmailVo,
929
+ LongTextVo,
930
+ MediumTextVo,
931
+ PaginationVo,
932
+ ShortTextVo,
933
+ TypeBoxObjectValidator,
934
+ UuidV4Vo,
935
+ UuidV7Vo,
936
+ createTypeBoxValidator,
937
+ typeBoxObjectValidator
938
+ });
939
+ //# sourceMappingURL=typebox.cjs.map