@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,124 @@
1
+ /**
2
+ * Base controller interface for the presentation layer.
3
+ *
4
+ * All controllers must implement this interface. The {@link BaseController} class
5
+ * provides a standard request/response pipeline implementation.
6
+ *
7
+ * @typeParam TInput - The input type the controller accepts
8
+ * @typeParam TOutput - The output type the controller returns
9
+ *
10
+ * @example Using BaseController (recommended)
11
+ * ```typescript
12
+ * const controller = BaseController.create({
13
+ * requestMapper: (req) => CreateUserInputDto.create(req.body),
14
+ * useCase: createUserUseCase,
15
+ * responseMapper: (output) => ({ statusCode: 201, body: output.value }),
16
+ * });
17
+ * ```
18
+ *
19
+ * @example Custom implementation
20
+ * ```typescript
21
+ * class MyController implements Controller<MyInput, MyOutput> {
22
+ * async execute(input: MyInput): Promise<MyOutput> {
23
+ * // custom logic
24
+ * }
25
+ * }
26
+ * ```
27
+ */
28
+ interface Controller<TInput = unknown, TOutput = unknown> {
29
+ /**
30
+ * Executes the controller with the given input.
31
+ *
32
+ * @param input - The input to process
33
+ * @returns Promise resolving to the output
34
+ */
35
+ execute(input: TInput): Promise<TOutput>;
36
+ }
37
+
38
+ /**
39
+ * Basic HTTP request structure for any HTTP-based framework.
40
+ *
41
+ * This is the foundation type representing the data extracted from an HTTP request.
42
+ * Frameworks (AWS API Gateway, Cloudflare Workers, Express, etc.) map their native
43
+ * request types to this common interface.
44
+ *
45
+ * @example Complete request
46
+ * ```typescript
47
+ * const request: HttpRequest = {
48
+ * body: { name: 'John', email: 'john@example.com' },
49
+ * headers: { 'content-type': 'application/json', 'authorization': 'Bearer ...' },
50
+ * pathParams: { id: '123' },
51
+ * queryParams: { include: 'profile' },
52
+ * };
53
+ * ```
54
+ */
55
+ interface HttpRequest {
56
+ /**
57
+ * Parsed request body.
58
+ * For JSON requests, this is the deserialized object.
59
+ * For form data, this contains the parsed form fields.
60
+ */
61
+ body?: unknown;
62
+ /**
63
+ * HTTP request headers (normalized to lowercase keys).
64
+ * Common headers include authorization, content-type, accept, etc.
65
+ */
66
+ headers?: Record<string, string>;
67
+ /**
68
+ * Query string parameters from the URL.
69
+ * For `/users?page=1&limit=10`, this would be `{ page: '1', limit: '10' }`.
70
+ * When a key appears multiple times (e.g., `?tag=a&tag=b`), the value is an array.
71
+ */
72
+ queryParams?: Record<string, string | string[]>;
73
+ /**
74
+ * Path parameters extracted from the URL pattern.
75
+ * For route `/users/:id` and URL `/users/123`, this would be `{ id: '123' }`.
76
+ */
77
+ pathParams?: Record<string, string>;
78
+ }
79
+
80
+ /**
81
+ * Basic HTTP response structure for any HTTP-based framework.
82
+ *
83
+ * This is the foundation type representing the data to send as an HTTP response.
84
+ * Frameworks (AWS API Gateway, Cloudflare Workers, Express, etc.) map this common
85
+ * interface to their native response types.
86
+ *
87
+ * @example Success response
88
+ * ```typescript
89
+ * const response: HttpResponse = {
90
+ * statusCode: 200,
91
+ * body: { id: '123', name: 'John' },
92
+ * };
93
+ * ```
94
+ *
95
+ * @example Response with headers
96
+ * ```typescript
97
+ * const response: HttpResponse = {
98
+ * statusCode: 201,
99
+ * headers: {
100
+ * 'Location': '/users/123',
101
+ * 'X-Request-Id': 'req-abc',
102
+ * },
103
+ * body: { id: '123' },
104
+ * };
105
+ * ```
106
+ */
107
+ interface HttpResponse {
108
+ /**
109
+ * HTTP status code (e.g., 200, 201, 400, 404, 500).
110
+ */
111
+ statusCode: number;
112
+ /**
113
+ * Optional response headers.
114
+ * Common headers include Content-Type, Location, Cache-Control, etc.
115
+ */
116
+ headers?: Record<string, unknown>;
117
+ /**
118
+ * Optional response body.
119
+ * Will be serialized to JSON by framework adapters if it's an object.
120
+ */
121
+ body?: unknown;
122
+ }
123
+
124
+ export type { Controller as C, HttpRequest as H, HttpResponse as a };