@cosmneo/onion-lasagna 0.1.3 → 0.1.4

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 (218) hide show
  1. package/dist/backend/core/global.cjs +0 -31
  2. package/dist/backend/core/global.cjs.map +1 -1
  3. package/dist/backend/core/global.d.cts +0 -2
  4. package/dist/backend/core/global.d.ts +0 -2
  5. package/dist/backend/core/global.js +5 -32
  6. package/dist/backend/core/global.js.map +1 -1
  7. package/dist/backend/core/onion-layers.cjs +36 -749
  8. package/dist/backend/core/onion-layers.cjs.map +1 -1
  9. package/dist/backend/core/onion-layers.d.cts +56 -525
  10. package/dist/backend/core/onion-layers.d.ts +56 -525
  11. package/dist/backend/core/onion-layers.js +18 -467
  12. package/dist/backend/core/onion-layers.js.map +1 -1
  13. package/dist/backend/core/presentation.cjs +15 -331
  14. package/dist/backend/core/presentation.cjs.map +1 -1
  15. package/dist/backend/core/presentation.d.cts +176 -6
  16. package/dist/backend/core/presentation.d.ts +176 -6
  17. package/dist/backend/core/presentation.js +6 -18
  18. package/dist/chunk-2OCBNJAL.js +51 -0
  19. package/dist/chunk-2OCBNJAL.js.map +1 -0
  20. package/dist/{chunk-74IKUOSE.js → chunk-4UEIG5JG.js} +3 -35
  21. package/dist/chunk-4UEIG5JG.js.map +1 -0
  22. package/dist/chunk-55ROG54O.js +1 -0
  23. package/dist/chunk-55ROG54O.js.map +1 -0
  24. package/dist/chunk-BX5N64GX.js +214 -0
  25. package/dist/chunk-BX5N64GX.js.map +1 -0
  26. package/dist/chunk-DEN7ID75.js +44 -0
  27. package/dist/chunk-DEN7ID75.js.map +1 -0
  28. package/dist/chunk-FFWSSDHW.js +216 -0
  29. package/dist/chunk-FFWSSDHW.js.map +1 -0
  30. package/dist/chunk-FU7TNJGI.js +40 -0
  31. package/dist/chunk-FU7TNJGI.js.map +1 -0
  32. package/dist/{chunk-5ITWMATY.js → chunk-JIPE44L4.js} +2 -2
  33. package/dist/chunk-LNSTWJMP.js +40 -0
  34. package/dist/chunk-LNSTWJMP.js.map +1 -0
  35. package/dist/chunk-MO5ZITSK.js +62 -0
  36. package/dist/chunk-MO5ZITSK.js.map +1 -0
  37. package/dist/chunk-ORO6XCUL.js +192 -0
  38. package/dist/chunk-ORO6XCUL.js.map +1 -0
  39. package/dist/{chunk-MQD5GXMT.js → chunk-PLANCJ3H.js} +2 -46
  40. package/dist/chunk-PLANCJ3H.js.map +1 -0
  41. package/dist/chunk-QBTE773Z.js +62 -0
  42. package/dist/chunk-QBTE773Z.js.map +1 -0
  43. package/dist/chunk-U4OVBR4C.js +52 -0
  44. package/dist/chunk-U4OVBR4C.js.map +1 -0
  45. package/dist/chunk-VECRK4QT.js +51 -0
  46. package/dist/chunk-VECRK4QT.js.map +1 -0
  47. package/dist/chunk-WOVMB3GY.js +324 -0
  48. package/dist/chunk-WOVMB3GY.js.map +1 -0
  49. package/dist/client/index.cjs +471 -0
  50. package/dist/client/index.cjs.map +1 -0
  51. package/dist/client/index.d.cts +210 -0
  52. package/dist/client/index.d.ts +210 -0
  53. package/dist/client/index.js +410 -0
  54. package/dist/client/index.js.map +1 -0
  55. package/dist/client/react-query/index.cjs +124 -0
  56. package/dist/client/react-query/index.cjs.map +1 -0
  57. package/dist/client/react-query/index.d.cts +86 -0
  58. package/dist/client/react-query/index.d.ts +86 -0
  59. package/dist/client/react-query/index.js +95 -0
  60. package/dist/client/react-query/index.js.map +1 -0
  61. package/dist/client/vue-query/index.cjs +124 -0
  62. package/dist/client/vue-query/index.cjs.map +1 -0
  63. package/dist/client/vue-query/index.d.cts +87 -0
  64. package/dist/client/vue-query/index.d.ts +87 -0
  65. package/dist/client/vue-query/index.js +95 -0
  66. package/dist/client/vue-query/index.js.map +1 -0
  67. package/dist/create-server-routes-1QP_sRcu.d.cts +84 -0
  68. package/dist/create-server-routes-DmCcLpcb.d.ts +84 -0
  69. package/dist/http/client/index.cjs +257 -0
  70. package/dist/http/client/index.cjs.map +1 -0
  71. package/dist/http/client/index.d.cts +222 -0
  72. package/dist/http/client/index.d.ts +222 -0
  73. package/dist/http/client/index.js +11 -0
  74. package/dist/http/client/index.js.map +1 -0
  75. package/dist/{backend → http}/frameworks/elysia.cjs +144 -143
  76. package/dist/http/frameworks/elysia.cjs.map +1 -0
  77. package/dist/http/frameworks/elysia.d.cts +182 -0
  78. package/dist/http/frameworks/elysia.d.ts +182 -0
  79. package/dist/http/frameworks/elysia.js +141 -0
  80. package/dist/http/frameworks/elysia.js.map +1 -0
  81. package/dist/{backend → http}/frameworks/fastify.cjs +127 -151
  82. package/dist/http/frameworks/fastify.cjs.map +1 -0
  83. package/dist/http/frameworks/fastify.d.cts +159 -0
  84. package/dist/http/frameworks/fastify.d.ts +159 -0
  85. package/dist/http/frameworks/fastify.js +77 -0
  86. package/dist/http/frameworks/fastify.js.map +1 -0
  87. package/dist/{backend → http}/frameworks/hono.cjs +267 -252
  88. package/dist/http/frameworks/hono.cjs.map +1 -0
  89. package/dist/http/frameworks/hono.d.cts +146 -0
  90. package/dist/http/frameworks/hono.d.ts +146 -0
  91. package/dist/http/frameworks/hono.js +154 -0
  92. package/dist/http/frameworks/hono.js.map +1 -0
  93. package/dist/{backend → http}/frameworks/nestjs.cjs +143 -161
  94. package/dist/http/frameworks/nestjs.cjs.map +1 -0
  95. package/dist/http/frameworks/nestjs.d.cts +201 -0
  96. package/dist/http/frameworks/nestjs.d.ts +201 -0
  97. package/dist/http/frameworks/nestjs.js +89 -0
  98. package/dist/http/frameworks/nestjs.js.map +1 -0
  99. package/dist/http/index.cjs +1116 -0
  100. package/dist/http/index.cjs.map +1 -0
  101. package/dist/http/index.d.cts +7 -0
  102. package/dist/http/index.d.ts +7 -0
  103. package/dist/http/index.js +58 -0
  104. package/dist/http/index.js.map +1 -0
  105. package/dist/http/openapi/index.cjs +263 -0
  106. package/dist/http/openapi/index.cjs.map +1 -0
  107. package/dist/http/openapi/index.d.cts +332 -0
  108. package/dist/http/openapi/index.d.ts +332 -0
  109. package/dist/http/openapi/index.js +9 -0
  110. package/dist/http/openapi/index.js.map +1 -0
  111. package/dist/http/route/index.cjs +158 -0
  112. package/dist/http/route/index.cjs.map +1 -0
  113. package/dist/http/route/index.d.cts +310 -0
  114. package/dist/http/route/index.d.ts +310 -0
  115. package/dist/http/route/index.js +32 -0
  116. package/dist/http/route/index.js.map +1 -0
  117. package/dist/http/schema/index.cjs +163 -0
  118. package/dist/http/schema/index.cjs.map +1 -0
  119. package/dist/http/schema/index.d.cts +5 -0
  120. package/dist/http/schema/index.d.ts +5 -0
  121. package/dist/http/schema/index.js +28 -0
  122. package/dist/http/schema/index.js.map +1 -0
  123. package/dist/http/schema/typebox.cjs +76 -0
  124. package/dist/http/schema/typebox.cjs.map +1 -0
  125. package/dist/http/schema/typebox.d.cts +73 -0
  126. package/dist/http/schema/typebox.d.ts +73 -0
  127. package/dist/http/schema/typebox.js +10 -0
  128. package/dist/http/schema/typebox.js.map +1 -0
  129. package/dist/http/schema/zod.cjs +69 -0
  130. package/dist/http/schema/zod.cjs.map +1 -0
  131. package/dist/http/schema/zod.d.cts +77 -0
  132. package/dist/http/schema/zod.d.ts +77 -0
  133. package/dist/http/schema/zod.js +10 -0
  134. package/dist/http/schema/zod.js.map +1 -0
  135. package/dist/http/server/index.cjs +610 -0
  136. package/dist/http/server/index.cjs.map +1 -0
  137. package/dist/http/server/index.d.cts +270 -0
  138. package/dist/http/server/index.d.ts +270 -0
  139. package/dist/http/server/index.js +57 -0
  140. package/dist/http/server/index.js.map +1 -0
  141. package/dist/infer-client.type-C5OBBOGG.d.ts +39 -0
  142. package/dist/infer-client.type-CSju5Mn8.d.cts +39 -0
  143. package/dist/router-contract.type-ChG1qA8g.d.cts +180 -0
  144. package/dist/router-contract.type-ChG1qA8g.d.ts +180 -0
  145. package/dist/router-definition.type-DO-g7vF1.d.cts +566 -0
  146. package/dist/router-definition.type-DXZTEJc2.d.ts +566 -0
  147. package/dist/schema-adapter.type-D5VqTjlp.d.cts +370 -0
  148. package/dist/schema-adapter.type-D5VqTjlp.d.ts +370 -0
  149. package/dist/shared/contracts.cjs +81 -0
  150. package/dist/shared/contracts.cjs.map +1 -0
  151. package/dist/shared/contracts.d.cts +110 -0
  152. package/dist/shared/contracts.d.ts +110 -0
  153. package/dist/shared/contracts.js +16 -0
  154. package/dist/shared/contracts.js.map +1 -0
  155. package/dist/types-BMoXXd8J.d.ts +250 -0
  156. package/dist/types-BkQePGPW.d.cts +250 -0
  157. package/dist/types-Dw-b8WZ7.d.cts +50 -0
  158. package/dist/types-Dw-b8WZ7.d.ts +50 -0
  159. package/package.json +108 -50
  160. package/dist/backend/core/validators/arktype.cjs +0 -241
  161. package/dist/backend/core/validators/arktype.cjs.map +0 -1
  162. package/dist/backend/core/validators/arktype.d.cts +0 -114
  163. package/dist/backend/core/validators/arktype.d.ts +0 -114
  164. package/dist/backend/core/validators/arktype.js +0 -50
  165. package/dist/backend/core/validators/arktype.js.map +0 -1
  166. package/dist/backend/core/validators/typebox.cjs +0 -238
  167. package/dist/backend/core/validators/typebox.cjs.map +0 -1
  168. package/dist/backend/core/validators/typebox.d.cts +0 -115
  169. package/dist/backend/core/validators/typebox.d.ts +0 -115
  170. package/dist/backend/core/validators/typebox.js +0 -47
  171. package/dist/backend/core/validators/typebox.js.map +0 -1
  172. package/dist/backend/core/validators/valibot.cjs +0 -239
  173. package/dist/backend/core/validators/valibot.cjs.map +0 -1
  174. package/dist/backend/core/validators/valibot.d.cts +0 -86
  175. package/dist/backend/core/validators/valibot.d.ts +0 -86
  176. package/dist/backend/core/validators/valibot.js +0 -48
  177. package/dist/backend/core/validators/valibot.js.map +0 -1
  178. package/dist/backend/core/validators/zod.cjs +0 -235
  179. package/dist/backend/core/validators/zod.cjs.map +0 -1
  180. package/dist/backend/core/validators/zod.d.cts +0 -114
  181. package/dist/backend/core/validators/zod.d.ts +0 -114
  182. package/dist/backend/core/validators/zod.js +0 -46
  183. package/dist/backend/core/validators/zod.js.map +0 -1
  184. package/dist/backend/frameworks/elysia.cjs.map +0 -1
  185. package/dist/backend/frameworks/elysia.d.cts +0 -239
  186. package/dist/backend/frameworks/elysia.d.ts +0 -239
  187. package/dist/backend/frameworks/elysia.js +0 -252
  188. package/dist/backend/frameworks/elysia.js.map +0 -1
  189. package/dist/backend/frameworks/fastify.cjs.map +0 -1
  190. package/dist/backend/frameworks/fastify.d.cts +0 -222
  191. package/dist/backend/frameworks/fastify.d.ts +0 -222
  192. package/dist/backend/frameworks/fastify.js +0 -213
  193. package/dist/backend/frameworks/fastify.js.map +0 -1
  194. package/dist/backend/frameworks/hono.cjs.map +0 -1
  195. package/dist/backend/frameworks/hono.d.cts +0 -225
  196. package/dist/backend/frameworks/hono.d.ts +0 -225
  197. package/dist/backend/frameworks/hono.js +0 -249
  198. package/dist/backend/frameworks/hono.js.map +0 -1
  199. package/dist/backend/frameworks/nestjs.cjs.map +0 -1
  200. package/dist/backend/frameworks/nestjs.d.cts +0 -227
  201. package/dist/backend/frameworks/nestjs.d.ts +0 -227
  202. package/dist/backend/frameworks/nestjs.js +0 -206
  203. package/dist/backend/frameworks/nestjs.js.map +0 -1
  204. package/dist/base-dto.class-BfpIFfH4.d.ts +0 -85
  205. package/dist/base-dto.class-CMIbpN23.d.cts +0 -85
  206. package/dist/chunk-2SM3DIEP.js +0 -262
  207. package/dist/chunk-2SM3DIEP.js.map +0 -1
  208. package/dist/chunk-74IKUOSE.js.map +0 -1
  209. package/dist/chunk-MQD5GXMT.js.map +0 -1
  210. package/dist/http-response-B-Z9Bb5Y.d.cts +0 -185
  211. package/dist/http-response-B-Z9Bb5Y.d.ts +0 -185
  212. package/dist/index-B--doH3s.d.cts +0 -1207
  213. package/dist/index-CxqJAWiF.d.ts +0 -1207
  214. package/dist/object-validator.port-B2eqdkJh.d.cts +0 -84
  215. package/dist/object-validator.port-B2eqdkJh.d.ts +0 -84
  216. package/dist/routing.type-CeLtIrIo.d.cts +0 -183
  217. package/dist/routing.type-DwLVRLya.d.ts +0 -183
  218. /package/dist/{chunk-5ITWMATY.js.map → chunk-JIPE44L4.js.map} +0 -0
@@ -24,7 +24,6 @@ __export(onion_layers_exports, {
24
24
  BaseAggregateRoot: () => BaseAggregateRoot,
25
25
  BaseAuditByVo: () => BaseAuditByVo,
26
26
  BaseAuditOnVo: () => BaseAuditOnVo,
27
- BaseController: () => BaseController,
28
27
  BaseDomainEvent: () => BaseDomainEvent,
29
28
  BaseEmailVo: () => BaseEmailVo,
30
29
  BaseEntity: () => BaseEntity,
@@ -43,32 +42,15 @@ __export(onion_layers_exports, {
43
42
  DbError: () => DbError,
44
43
  DomainError: () => DomainError,
45
44
  ExternalServiceError: () => ExternalServiceError,
46
- GuardedController: () => GuardedController,
47
45
  InfraError: () => InfraError,
48
46
  InvalidRequestError: () => InvalidRequestError,
49
47
  InvariantViolationError: () => InvariantViolationError,
50
- Money: () => Money,
51
48
  NetworkError: () => NetworkError,
52
49
  NotFoundError: () => NotFoundError,
53
- Order: () => Order,
54
- OrderAlreadyShippedError: () => OrderAlreadyShippedError,
55
- OrderCancelledEvent: () => OrderCancelledEvent,
56
- OrderId: () => OrderId,
57
- OrderItem: () => OrderItem,
58
- OrderItemId: () => OrderItemId,
59
- OrderPlacedEvent: () => OrderPlacedEvent,
60
- OrderStatus: () => OrderStatus,
61
50
  PartialLoadError: () => PartialLoadError,
62
51
  TimeoutError: () => TimeoutError,
63
52
  UnprocessableError: () => UnprocessableError,
64
- UseCaseError: () => UseCaseError,
65
- assertHttpResponse: () => assertHttpResponse,
66
- canAddOrderItem: () => canAddOrderItem,
67
- canCancelOrder: () => canCancelOrder,
68
- computeRoutePath: () => computeRoutePath,
69
- defaultOrderStatus: () => defaultOrderStatus,
70
- defineSystemMetadata: () => defineSystemMetadata,
71
- isHttpResponse: () => isHttpResponse
53
+ UseCaseError: () => UseCaseError
72
54
  });
73
55
  module.exports = __toCommonJS(onion_layers_exports);
74
56
 
@@ -238,16 +220,6 @@ var ObjectValidationError = class _ObjectValidationError extends CodedError {
238
220
  };
239
221
 
240
222
  // src/backend/core/global/utils/wrap-error.util.ts
241
- function wrapErrorUnless(fn, errorFactory, passthroughTypes) {
242
- try {
243
- return fn();
244
- } catch (error) {
245
- if (passthroughTypes.some((Type) => error instanceof Type)) {
246
- throw error;
247
- }
248
- throw errorFactory(error);
249
- }
250
- }
251
223
  async function wrapErrorUnlessAsync(fn, errorFactory, passthroughTypes) {
252
224
  try {
253
225
  return await fn();
@@ -360,8 +332,8 @@ var BaseInboundAdapter = class {
360
332
  * Known error types are re-thrown as-is to preserve error semantics.
361
333
  * Unknown errors are wrapped in a UseCaseError to maintain error hierarchy.
362
334
  *
363
- * @param input - Validated input DTO
364
- * @returns Promise resolving to the output DTO
335
+ * @param input - Input data
336
+ * @returns Promise resolving to the output
365
337
  * @throws {ObjectValidationError} For validation failures (propagated to controller)
366
338
  * @throws {UseCaseError} For use case failures or wrapped unknown errors
367
339
  * @throws {DomainError} For domain invariant violations
@@ -530,7 +502,7 @@ var BaseEntity = class {
530
502
  * @example
531
503
  * ```typescript
532
504
  * const user1 = User.create(PersonName.create('John'), Email.create('john@example.com'));
533
- * const user2 = User.fromPersistence(user1.id, { name: PersonName.create('John Updated'), ... }, 1);
505
+ * const user2 = User.reconstitute(user1.id, { name: PersonName.create('John Updated'), ... }, 1);
534
506
  * user1.equals(user2); // true - same ID, different state
535
507
  * ```
536
508
  */
@@ -1209,434 +1181,6 @@ var BaseUuidV7Vo = class _BaseUuidV7Vo extends BaseValueObject {
1209
1181
  }
1210
1182
  };
1211
1183
 
1212
- // src/backend/core/onion-layers/domain/example-domain/value-objects/money.vo.ts
1213
- var Money = class _Money extends BaseValueObject {
1214
- /**
1215
- * Creates a Money instance with USD currency.
1216
- *
1217
- * @param amount - The monetary amount
1218
- */
1219
- static usd(amount) {
1220
- return new _Money({ amount, currency: "USD" });
1221
- }
1222
- /**
1223
- * Creates a Money instance with EUR currency.
1224
- *
1225
- * @param amount - The monetary amount
1226
- */
1227
- static eur(amount) {
1228
- return new _Money({ amount, currency: "EUR" });
1229
- }
1230
- /**
1231
- * Creates a zero amount in the specified currency.
1232
- *
1233
- * @param currency - The currency code (default: 'USD')
1234
- */
1235
- static zero(currency = "USD") {
1236
- return new _Money({ amount: 0, currency });
1237
- }
1238
- /**
1239
- * Reconstitutes a Money from a persisted value.
1240
- *
1241
- * @param value - The money value from persistence
1242
- */
1243
- static fromPersistence(value) {
1244
- return new _Money(value);
1245
- }
1246
- /**
1247
- * The monetary amount.
1248
- */
1249
- get amount() {
1250
- return this.value.amount;
1251
- }
1252
- /**
1253
- * The currency code.
1254
- */
1255
- get currency() {
1256
- return this.value.currency;
1257
- }
1258
- /**
1259
- * Adds another Money value to this one.
1260
- *
1261
- * @param other - The Money to add
1262
- * @throws {InvariantViolationError} If currencies don't match
1263
- */
1264
- add(other) {
1265
- this.assertSameCurrency(other);
1266
- return new _Money({ amount: this.amount + other.amount, currency: this.currency });
1267
- }
1268
- /**
1269
- * Subtracts another Money value from this one.
1270
- *
1271
- * @param other - The Money to subtract
1272
- * @throws {InvariantViolationError} If currencies don't match
1273
- */
1274
- subtract(other) {
1275
- this.assertSameCurrency(other);
1276
- return new _Money({ amount: this.amount - other.amount, currency: this.currency });
1277
- }
1278
- /**
1279
- * Multiplies this Money by a factor.
1280
- *
1281
- * @param factor - The multiplication factor
1282
- */
1283
- multiply(factor) {
1284
- return new _Money({ amount: this.amount * factor, currency: this.currency });
1285
- }
1286
- /**
1287
- * Checks if this Money is greater than another.
1288
- *
1289
- * @param other - The Money to compare with
1290
- * @throws {InvariantViolationError} If currencies don't match
1291
- */
1292
- isGreaterThan(other) {
1293
- this.assertSameCurrency(other);
1294
- return this.amount > other.amount;
1295
- }
1296
- /**
1297
- * Checks if this Money is less than another.
1298
- *
1299
- * @param other - The Money to compare with
1300
- * @throws {InvariantViolationError} If currencies don't match
1301
- */
1302
- isLessThan(other) {
1303
- this.assertSameCurrency(other);
1304
- return this.amount < other.amount;
1305
- }
1306
- /**
1307
- * Checks if this Money represents zero.
1308
- */
1309
- isZero() {
1310
- return this.amount === 0;
1311
- }
1312
- /**
1313
- * Asserts that two Money values have the same currency.
1314
- * @internal
1315
- */
1316
- assertSameCurrency(other) {
1317
- if (this.currency !== other.currency) {
1318
- throw new InvariantViolationError({
1319
- message: `Cannot operate on different currencies: ${this.currency} vs ${other.currency}`,
1320
- code: "CURRENCY_MISMATCH"
1321
- });
1322
- }
1323
- }
1324
- };
1325
-
1326
- // src/backend/core/onion-layers/domain/example-domain/value-objects/order-id.vo.ts
1327
- var import_uuid3 = require("uuid");
1328
- var OrderId = class _OrderId extends BaseUuidV7Vo {
1329
- static generate() {
1330
- return new _OrderId((0, import_uuid3.v7)());
1331
- }
1332
- };
1333
-
1334
- // src/backend/core/onion-layers/domain/example-domain/value-objects/order-status.vo.ts
1335
- var OrderStatus = class _OrderStatus extends BaseValueObject {
1336
- /**
1337
- * Creates a new OrderStatus with 'pending' value.
1338
- * Use when creating new orders.
1339
- */
1340
- static pending() {
1341
- return new _OrderStatus("pending");
1342
- }
1343
- /**
1344
- * Creates a new OrderStatus with 'confirmed' value.
1345
- * Use when payment is received.
1346
- */
1347
- static confirmed() {
1348
- return new _OrderStatus("confirmed");
1349
- }
1350
- /**
1351
- * Creates a new OrderStatus with 'shipped' value.
1352
- * Use when order is dispatched.
1353
- */
1354
- static shipped() {
1355
- return new _OrderStatus("shipped");
1356
- }
1357
- /**
1358
- * Creates a new OrderStatus with 'cancelled' value.
1359
- * Use when order is cancelled by customer or system.
1360
- */
1361
- static cancelled() {
1362
- return new _OrderStatus("cancelled");
1363
- }
1364
- /**
1365
- * Reconstitutes an OrderStatus from a persisted value.
1366
- *
1367
- * @param value - The status value from persistence
1368
- */
1369
- static fromPersistence(value) {
1370
- return new _OrderStatus(value);
1371
- }
1372
- /**
1373
- * Checks if the order is in pending status.
1374
- */
1375
- isPending() {
1376
- return this.value === "pending";
1377
- }
1378
- /**
1379
- * Checks if the order is confirmed.
1380
- */
1381
- isConfirmed() {
1382
- return this.value === "confirmed";
1383
- }
1384
- /**
1385
- * Checks if the order has been shipped.
1386
- */
1387
- isShipped() {
1388
- return this.value === "shipped";
1389
- }
1390
- /**
1391
- * Checks if the order has been cancelled.
1392
- */
1393
- isCancelled() {
1394
- return this.value === "cancelled";
1395
- }
1396
- /**
1397
- * Checks if the order can still be modified (pending or confirmed).
1398
- */
1399
- isModifiable() {
1400
- return this.isPending() || this.isConfirmed();
1401
- }
1402
- };
1403
-
1404
- // src/backend/core/onion-layers/domain/example-domain/events/order-cancelled.event.ts
1405
- var OrderCancelledEvent = class extends BaseDomainEvent {
1406
- constructor(payload) {
1407
- super("OrderCancelled", payload.orderId, payload);
1408
- }
1409
- };
1410
-
1411
- // src/backend/core/onion-layers/domain/example-domain/events/order-placed.event.ts
1412
- var OrderPlacedEvent = class extends BaseDomainEvent {
1413
- constructor(payload) {
1414
- super("OrderPlaced", payload.orderId, payload);
1415
- }
1416
- };
1417
-
1418
- // src/backend/core/onion-layers/domain/example-domain/aggregates/order/policies/value/default-order-status.policy.ts
1419
- var defaultOrderStatus = () => {
1420
- return OrderStatus.pending();
1421
- };
1422
-
1423
- // src/backend/core/onion-layers/domain/example-domain/aggregates/order/policies/business/can-add-order-item.policy.ts
1424
- var canAddOrderItem = (order) => {
1425
- return order.status.isPending();
1426
- };
1427
-
1428
- // src/backend/core/onion-layers/domain/example-domain/aggregates/order/policies/business/can-cancel-order.policy.ts
1429
- var canCancelOrder = (order) => {
1430
- return order.status.isPending() || order.status.isConfirmed();
1431
- };
1432
-
1433
- // src/backend/core/onion-layers/domain/example-domain/aggregates/order/order.aggregate.ts
1434
- var Order = class _Order extends BaseAggregateRoot {
1435
- constructor(id, props, version) {
1436
- super(id, props, version);
1437
- }
1438
- /**
1439
- * Creates a new Order.
1440
- *
1441
- * @param customerId - The customer placing the order
1442
- * @param items - Initial order items
1443
- * @returns A new Order instance with OrderPlacedEvent raised
1444
- */
1445
- static create(customerId, items) {
1446
- const id = OrderId.generate();
1447
- const totalAmount = items.reduce((sum, item) => sum.add(item.totalPrice), Money.zero());
1448
- const order = new _Order(id, {
1449
- customerId,
1450
- items,
1451
- status: defaultOrderStatus(),
1452
- totalAmount,
1453
- placedAt: /* @__PURE__ */ new Date()
1454
- });
1455
- order.addDomainEvent(
1456
- new OrderPlacedEvent({
1457
- orderId: id.value,
1458
- customerId,
1459
- itemCount: items.length,
1460
- totalAmount: totalAmount.amount,
1461
- currency: totalAmount.currency,
1462
- placedAt: order.placedAt.toISOString()
1463
- })
1464
- );
1465
- return order;
1466
- }
1467
- /**
1468
- * Reconstitutes an Order from persistence.
1469
- *
1470
- * @param id - The order ID
1471
- * @param props - The order properties
1472
- * @param version - The version for optimistic locking
1473
- */
1474
- static fromPersistence(id, props, version) {
1475
- return new _Order(id, props, version);
1476
- }
1477
- get customerId() {
1478
- return this.props.customerId;
1479
- }
1480
- get items() {
1481
- return this.props.items;
1482
- }
1483
- get status() {
1484
- return this.props.status;
1485
- }
1486
- get totalAmount() {
1487
- return this.props.totalAmount;
1488
- }
1489
- get placedAt() {
1490
- return this.props.placedAt;
1491
- }
1492
- /**
1493
- * Adds an item to the order.
1494
- *
1495
- * Uses the `canAddOrderItem` business policy to check if the operation is allowed.
1496
- *
1497
- * @param item - The item to add
1498
- * @throws {InvariantViolationError} If the order is not in pending status
1499
- */
1500
- addItem(item) {
1501
- if (!canAddOrderItem(this)) {
1502
- throw new InvariantViolationError({
1503
- message: "Cannot add items to non-pending order",
1504
- code: "ORDER_NOT_PENDING"
1505
- });
1506
- }
1507
- this._props.items.push(item);
1508
- this._props.totalAmount = this._props.totalAmount.add(item.totalPrice);
1509
- }
1510
- /**
1511
- * Confirms the order (e.g., after payment received).
1512
- *
1513
- * @throws {InvariantViolationError} If the order is not in pending status
1514
- */
1515
- confirm() {
1516
- if (!this.status.isPending()) {
1517
- throw new InvariantViolationError({
1518
- message: "Only pending orders can be confirmed",
1519
- code: "ORDER_NOT_PENDING"
1520
- });
1521
- }
1522
- this._props.status = OrderStatus.confirmed();
1523
- }
1524
- /**
1525
- * Marks the order as shipped.
1526
- *
1527
- * @throws {InvariantViolationError} If the order is not confirmed
1528
- */
1529
- ship() {
1530
- if (!this.status.isConfirmed()) {
1531
- throw new InvariantViolationError({
1532
- message: "Only confirmed orders can be shipped",
1533
- code: "ORDER_NOT_CONFIRMED"
1534
- });
1535
- }
1536
- this._props.status = OrderStatus.shipped();
1537
- }
1538
- /**
1539
- * Cancels the order.
1540
- *
1541
- * Uses the `canCancelOrder` business policy to check if the operation is allowed.
1542
- *
1543
- * @param reason - The reason for cancellation
1544
- * @throws {InvariantViolationError} If the order cannot be cancelled
1545
- */
1546
- cancel(reason) {
1547
- if (!canCancelOrder(this)) {
1548
- throw new InvariantViolationError({
1549
- message: "Order cannot be cancelled - already shipped or cancelled",
1550
- code: "ORDER_CANNOT_CANCEL"
1551
- });
1552
- }
1553
- this._props.status = OrderStatus.cancelled();
1554
- this.addDomainEvent(
1555
- new OrderCancelledEvent({
1556
- orderId: this.id.value,
1557
- reason,
1558
- cancelledAt: (/* @__PURE__ */ new Date()).toISOString()
1559
- })
1560
- );
1561
- }
1562
- };
1563
-
1564
- // src/backend/core/onion-layers/domain/example-domain/entities/order-item-id.vo.ts
1565
- var import_uuid4 = require("uuid");
1566
- var OrderItemId = class _OrderItemId extends BaseUuidV7Vo {
1567
- static generate() {
1568
- return new _OrderItemId((0, import_uuid4.v7)());
1569
- }
1570
- };
1571
-
1572
- // src/backend/core/onion-layers/domain/example-domain/entities/order-item.entity.ts
1573
- var OrderItem = class _OrderItem extends BaseEntity {
1574
- constructor(id, props) {
1575
- super(id, props);
1576
- }
1577
- /**
1578
- * Creates a new OrderItem.
1579
- */
1580
- static create(props) {
1581
- return new _OrderItem(OrderItemId.generate(), props);
1582
- }
1583
- /**
1584
- * Reconstitutes an OrderItem from persistence.
1585
- */
1586
- static fromPersistence(id, props) {
1587
- return new _OrderItem(id, props);
1588
- }
1589
- get productId() {
1590
- return this.props.productId;
1591
- }
1592
- get productName() {
1593
- return this.props.productName;
1594
- }
1595
- get quantity() {
1596
- return this.props.quantity;
1597
- }
1598
- get unitPrice() {
1599
- return this.props.unitPrice;
1600
- }
1601
- /**
1602
- * Calculates the total price for this line item.
1603
- */
1604
- get totalPrice() {
1605
- return this.props.unitPrice.multiply(this.props.quantity);
1606
- }
1607
- /**
1608
- * Updates the quantity of this item.
1609
- */
1610
- updateQuantity(newQuantity) {
1611
- this._props.quantity = newQuantity;
1612
- }
1613
- /**
1614
- * Converts to a plain object for events or persistence.
1615
- */
1616
- toPlain() {
1617
- return {
1618
- id: this.id.value,
1619
- productId: this.props.productId,
1620
- productName: this.props.productName,
1621
- quantity: this.props.quantity,
1622
- unitPrice: {
1623
- amount: this.props.unitPrice.amount,
1624
- currency: this.props.unitPrice.currency
1625
- }
1626
- };
1627
- }
1628
- };
1629
-
1630
- // src/backend/core/onion-layers/domain/example-domain/exceptions/order-already-shipped.error.ts
1631
- var OrderAlreadyShippedError = class extends InvariantViolationError {
1632
- constructor(orderId) {
1633
- super({
1634
- message: `Order ${orderId} has already been shipped and cannot be modified`,
1635
- code: "ORDER_ALREADY_SHIPPED"
1636
- });
1637
- }
1638
- };
1639
-
1640
1184
  // src/backend/core/onion-layers/infra/classes/base-outbound-adapter.class.ts
1641
1185
  var WRAPPED_METHODS_SYMBOL = /* @__PURE__ */ Symbol.for("onion-lasagna:wrapped-methods");
1642
1186
  function getWrappedMethods(proto) {
@@ -1847,6 +1391,37 @@ var ExternalServiceError = class _ExternalServiceError extends InfraError {
1847
1391
  }
1848
1392
  };
1849
1393
 
1394
+ // src/backend/core/onion-layers/presentation/exceptions/access-denied.error.ts
1395
+ var AccessDeniedError = class _AccessDeniedError extends CodedError {
1396
+ /**
1397
+ * Creates a new AccessDeniedError instance.
1398
+ *
1399
+ * @param options - Error configuration
1400
+ * @param options.message - Description of why access was denied
1401
+ * @param options.code - Machine-readable error code (default: 'ACCESS_DENIED')
1402
+ * @param options.cause - Optional underlying error
1403
+ */
1404
+ constructor({
1405
+ message,
1406
+ code = ErrorCodes.Presentation.ACCESS_DENIED,
1407
+ cause
1408
+ }) {
1409
+ super({ message, code, cause });
1410
+ }
1411
+ /**
1412
+ * Creates an AccessDeniedError from a caught error.
1413
+ *
1414
+ * @param cause - The original caught error
1415
+ * @returns A new AccessDeniedError instance with the cause attached
1416
+ */
1417
+ static fromError(cause) {
1418
+ return new _AccessDeniedError({
1419
+ message: cause instanceof Error ? cause.message : "Access denied",
1420
+ cause
1421
+ });
1422
+ }
1423
+ };
1424
+
1850
1425
  // src/backend/core/onion-layers/presentation/exceptions/controller.error.ts
1851
1426
  var ControllerError = class _ControllerError extends CodedError {
1852
1427
  /**
@@ -1920,283 +1495,12 @@ var InvalidRequestError = class _InvalidRequestError extends CodedError {
1920
1495
  });
1921
1496
  }
1922
1497
  };
1923
-
1924
- // src/backend/core/onion-layers/presentation/classes/base-controller.class.ts
1925
- var BaseController = class _BaseController {
1926
- /* eslint-enable @typescript-eslint/no-invalid-void-type */
1927
- /**
1928
- * Creates a new BaseController instance.
1929
- *
1930
- * @param requestMapper - Function to map request DTO to use case input DTO
1931
- * @param useCase - The use case port to execute
1932
- * @param responseMapper - Function to map use case output DTO to response DTO
1933
- */
1934
- constructor(requestMapper, useCase, responseMapper) {
1935
- this.requestMapper = requestMapper;
1936
- this.useCase = useCase;
1937
- this.responseMapper = responseMapper;
1938
- }
1939
- /**
1940
- * Factory method to create a controller from a configuration object.
1941
- *
1942
- * @param config - Controller configuration
1943
- * @returns A new BaseController instance
1944
- */
1945
- /* eslint-disable @typescript-eslint/no-invalid-void-type */
1946
- static create(config) {
1947
- return new _BaseController(config.requestMapper, config.useCase, config.responseMapper);
1948
- }
1949
- /**
1950
- * Executes the controller pipeline with error wrapping.
1951
- *
1952
- * This is the public entry point that ensures consistent error handling.
1953
- * All errors are wrapped in {@link ControllerError} unless they extend {@link CodedError}.
1954
- *
1955
- * **Do not override this method.** Override {@link pipeline} instead for custom pipeline logic.
1956
- *
1957
- * @param input - The validated request DTO
1958
- * @returns Promise resolving to the validated response DTO
1959
- * @throws {InvalidRequestError} When request mapping/validation fails
1960
- * @throws {ControllerError} When an unexpected error occurs
1961
- * @throws {CodedError} When use case throws a known error type
1962
- */
1963
- async execute(input) {
1964
- return wrapErrorUnlessAsync(
1965
- () => this.pipeline(input),
1966
- (cause) => new ControllerError({
1967
- message: cause instanceof Error ? cause.message : "Controller execution failed",
1968
- cause
1969
- }),
1970
- [CodedError]
1971
- );
1972
- }
1973
- /**
1974
- * Runs the controller pipeline.
1975
- *
1976
- * Orchestrates: `mapRequest → executeUseCase → mapResponse`
1977
- *
1978
- * Override this method to customize the entire pipeline flow, or override
1979
- * individual protected methods ({@link mapRequest}, {@link executeUseCase},
1980
- * {@link mapResponse}) for more granular control.
1981
- *
1982
- * @param input - The validated request DTO
1983
- * @returns Promise resolving to the validated response DTO
1984
- */
1985
- async pipeline(input) {
1986
- const mappedInput = this.mapRequest(input);
1987
- const result = await this.executeUseCase(mappedInput);
1988
- return this.mapResponse(result);
1989
- }
1990
- /**
1991
- * Maps the request DTO to a use case input DTO.
1992
- *
1993
- * Override to add custom pre-processing, logging, or transformation logic.
1994
- * The default implementation uses the configured `requestMapper` and converts
1995
- * {@link ObjectValidationError} to {@link InvalidRequestError}.
1996
- *
1997
- * @param input - The validated request DTO
1998
- * @returns The use case input DTO
1999
- * @throws {InvalidRequestError} When validation fails
2000
- * @throws {ControllerError} When mapping fails unexpectedly
2001
- */
2002
- mapRequest(input) {
2003
- return wrapErrorUnless(
2004
- () => this.requestMapper(input),
2005
- (cause) => {
2006
- if (cause instanceof ObjectValidationError) {
2007
- return new InvalidRequestError({
2008
- message: cause.message,
2009
- cause,
2010
- validationErrors: cause.validationErrors
2011
- });
2012
- }
2013
- return new ControllerError({
2014
- message: cause instanceof Error ? cause.message : "Request mapping failed",
2015
- cause
2016
- });
2017
- },
2018
- [CodedError]
2019
- );
2020
- }
2021
- /**
2022
- * Executes the use case with the mapped input.
2023
- *
2024
- * Override to add custom logic around use case execution, such as:
2025
- * - Logging/tracing
2026
- * - Caching
2027
- * - Retry logic
2028
- * - Multi-use-case orchestration
2029
- *
2030
- * @param input - The use case input DTO
2031
- * @returns Promise resolving to the use case output DTO
2032
- */
2033
- async executeUseCase(input) {
2034
- return this.useCase.execute(input);
2035
- }
2036
- /**
2037
- * Maps the use case output DTO to a response DTO.
2038
- *
2039
- * Override to add custom post-processing, logging, or transformation logic.
2040
- * The default implementation uses the configured `responseMapper`.
2041
- *
2042
- * @param output - The use case output DTO
2043
- * @returns The response DTO
2044
- * @throws {ControllerError} When mapping or validation fails
2045
- */
2046
- mapResponse(output) {
2047
- return wrapErrorUnless(
2048
- () => this.responseMapper(output),
2049
- (cause) => new ControllerError({
2050
- message: cause instanceof ObjectValidationError ? "Response validation failed" : cause instanceof Error ? cause.message : "Response mapping failed",
2051
- cause
2052
- }),
2053
- [CodedError]
2054
- );
2055
- }
2056
- };
2057
-
2058
- // src/backend/core/onion-layers/presentation/exceptions/access-denied.error.ts
2059
- var AccessDeniedError = class _AccessDeniedError extends CodedError {
2060
- /**
2061
- * Creates a new AccessDeniedError instance.
2062
- *
2063
- * @param options - Error configuration
2064
- * @param options.message - Description of why access was denied
2065
- * @param options.code - Machine-readable error code (default: 'ACCESS_DENIED')
2066
- * @param options.cause - Optional underlying error
2067
- */
2068
- constructor({
2069
- message,
2070
- code = ErrorCodes.Presentation.ACCESS_DENIED,
2071
- cause
2072
- }) {
2073
- super({ message, code, cause });
2074
- }
2075
- /**
2076
- * Creates an AccessDeniedError from a caught error.
2077
- *
2078
- * @param cause - The original caught error
2079
- * @returns A new AccessDeniedError instance with the cause attached
2080
- */
2081
- static fromError(cause) {
2082
- return new _AccessDeniedError({
2083
- message: cause instanceof Error ? cause.message : "Access denied",
2084
- cause
2085
- });
2086
- }
2087
- };
2088
-
2089
- // src/backend/core/onion-layers/presentation/classes/guarded-controller.class.ts
2090
- function createAllowAllGuard() {
2091
- return async () => ({
2092
- isAllowed: true
2093
- });
2094
- }
2095
- var GuardedController = class _GuardedController extends BaseController {
2096
- /* eslint-enable @typescript-eslint/no-invalid-void-type */
2097
- /** The access guard function for this controller. */
2098
- accessGuard;
2099
- /**
2100
- * Creates a new GuardedController instance.
2101
- *
2102
- * @param requestMapper - Function to map request DTO to use case input DTO
2103
- * @param useCase - The use case port to execute
2104
- * @param responseMapper - Function to map use case output DTO to response DTO
2105
- * @param accessGuard - Optional access guard; defaults to allowing all
2106
- */
2107
- constructor(requestMapper, useCase, responseMapper, accessGuard) {
2108
- super(requestMapper, useCase, responseMapper);
2109
- this.accessGuard = accessGuard ?? createAllowAllGuard();
2110
- }
2111
- /**
2112
- * Factory method to create a guarded controller from a configuration object.
2113
- *
2114
- * @param config - Controller configuration including optional access guard
2115
- * @returns A new GuardedController instance
2116
- */
2117
- /* eslint-disable @typescript-eslint/no-invalid-void-type */
2118
- static create(config) {
2119
- return new _GuardedController(
2120
- config.requestMapper,
2121
- config.useCase,
2122
- config.responseMapper,
2123
- config.accessGuard
2124
- );
2125
- }
2126
- /**
2127
- * Runs the controller pipeline with access control.
2128
- *
2129
- * Checks the access guard before executing the pipeline.
2130
- * If denied, throws {@link AccessDeniedError}.
2131
- *
2132
- * @param input - The validated request DTO
2133
- * @returns Promise resolving to the validated response DTO
2134
- * @throws {AccessDeniedError} When access guard denies the request
2135
- */
2136
- async pipeline(input) {
2137
- await this.checkAccess(input);
2138
- return super.pipeline(input);
2139
- }
2140
- /**
2141
- * Checks access using the configured guard.
2142
- *
2143
- * Override to customize access control logic.
2144
- *
2145
- * @param input - The validated request DTO
2146
- * @throws {AccessDeniedError} When access is denied
2147
- */
2148
- async checkAccess(input) {
2149
- const result = await this.accessGuard(input);
2150
- if (!result.isAllowed) {
2151
- throw new AccessDeniedError({
2152
- message: result.reason ?? "Access denied"
2153
- });
2154
- }
2155
- }
2156
- };
2157
-
2158
- // src/backend/core/onion-layers/presentation/interfaces/types/metadata/system-metadata.type.ts
2159
- function defineSystemMetadata(metadata) {
2160
- return metadata;
2161
- }
2162
-
2163
- // src/backend/core/onion-layers/presentation/routing/compute-route-path.util.ts
2164
- function trimSlashes(segment) {
2165
- return segment.replace(/^\/+|\/+$/g, "");
2166
- }
2167
- function computeRoutePath(service, resource, endpoint) {
2168
- const segments = [service.basePath, resource.path, endpoint.path].map(trimSlashes).filter((s) => s.length > 0);
2169
- if (segments.length === 0) {
2170
- return "/";
2171
- }
2172
- return "/" + segments.join("/");
2173
- }
2174
-
2175
- // src/backend/core/onion-layers/presentation/utils/http-response.util.ts
2176
- function isHttpResponse(value) {
2177
- return typeof value === "object" && value !== null && "statusCode" in value && typeof value.statusCode === "number";
2178
- }
2179
- function assertHttpResponse(value, context = "value") {
2180
- if (!isHttpResponse(value)) {
2181
- const actualType = value === null ? "null" : value === void 0 ? "undefined" : typeof value;
2182
- const hasStatusCode = typeof value === "object" && value !== null && "statusCode" in value;
2183
- let message = `Expected ${context} to be an HttpResponse with a numeric statusCode, `;
2184
- if (hasStatusCode) {
2185
- const statusCodeType = typeof value["statusCode"];
2186
- message += `but statusCode was ${statusCodeType}`;
2187
- } else {
2188
- message += `but got ${actualType}`;
2189
- }
2190
- throw new Error(message);
2191
- }
2192
- }
2193
1498
  // Annotate the CommonJS export names for ESM import in node:
2194
1499
  0 && (module.exports = {
2195
1500
  AccessDeniedError,
2196
1501
  BaseAggregateRoot,
2197
1502
  BaseAuditByVo,
2198
1503
  BaseAuditOnVo,
2199
- BaseController,
2200
1504
  BaseDomainEvent,
2201
1505
  BaseEmailVo,
2202
1506
  BaseEntity,
@@ -2215,31 +1519,14 @@ function assertHttpResponse(value, context = "value") {
2215
1519
  DbError,
2216
1520
  DomainError,
2217
1521
  ExternalServiceError,
2218
- GuardedController,
2219
1522
  InfraError,
2220
1523
  InvalidRequestError,
2221
1524
  InvariantViolationError,
2222
- Money,
2223
1525
  NetworkError,
2224
1526
  NotFoundError,
2225
- Order,
2226
- OrderAlreadyShippedError,
2227
- OrderCancelledEvent,
2228
- OrderId,
2229
- OrderItem,
2230
- OrderItemId,
2231
- OrderPlacedEvent,
2232
- OrderStatus,
2233
1527
  PartialLoadError,
2234
1528
  TimeoutError,
2235
1529
  UnprocessableError,
2236
- UseCaseError,
2237
- assertHttpResponse,
2238
- canAddOrderItem,
2239
- canCancelOrder,
2240
- computeRoutePath,
2241
- defaultOrderStatus,
2242
- defineSystemMetadata,
2243
- isHttpResponse
1530
+ UseCaseError
2244
1531
  });
2245
1532
  //# sourceMappingURL=onion-layers.cjs.map