plutin 1.3.0 → 1.3.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.
Files changed (240) hide show
  1. package/dist/index.d.cts +286 -28
  2. package/dist/index.d.ts +286 -28
  3. package/dist/{index.js → index.mjs} +1 -1
  4. package/package.json +4 -3
  5. package/dist/base-controller-68008870.d.ts +0 -46
  6. package/dist/core/decorators/controller-http-decorator.cjs +0 -310
  7. package/dist/core/decorators/controller-http-decorator.cjs.map +0 -1
  8. package/dist/core/decorators/controller-http-decorator.d.cts +0 -13
  9. package/dist/core/decorators/controller-http-decorator.d.ts +0 -13
  10. package/dist/core/decorators/controller-http-decorator.js +0 -285
  11. package/dist/core/decorators/controller-http-decorator.js.map +0 -1
  12. package/dist/core/decorators/dependency-container.cjs +0 -95
  13. package/dist/core/decorators/dependency-container.cjs.map +0 -1
  14. package/dist/core/decorators/dependency-container.d.cts +0 -22
  15. package/dist/core/decorators/dependency-container.d.ts +0 -22
  16. package/dist/core/decorators/dependency-container.js +0 -71
  17. package/dist/core/decorators/dependency-container.js.map +0 -1
  18. package/dist/core/entities/aggregate-root.cjs +0 -99
  19. package/dist/core/entities/aggregate-root.cjs.map +0 -1
  20. package/dist/core/entities/aggregate-root.d.cts +0 -8
  21. package/dist/core/entities/aggregate-root.d.ts +0 -8
  22. package/dist/core/entities/aggregate-root.js +0 -74
  23. package/dist/core/entities/aggregate-root.js.map +0 -1
  24. package/dist/core/entities/common-dto.cjs +0 -19
  25. package/dist/core/entities/common-dto.cjs.map +0 -1
  26. package/dist/core/entities/common-dto.d.cts +0 -10
  27. package/dist/core/entities/common-dto.d.ts +0 -10
  28. package/dist/core/entities/common-dto.js +0 -1
  29. package/dist/core/entities/common-dto.js.map +0 -1
  30. package/dist/core/entities/domain-event.cjs +0 -19
  31. package/dist/core/entities/domain-event.cjs.map +0 -1
  32. package/dist/core/entities/domain-event.d.cts +0 -6
  33. package/dist/core/entities/domain-event.d.ts +0 -6
  34. package/dist/core/entities/domain-event.js +0 -1
  35. package/dist/core/entities/domain-event.js.map +0 -1
  36. package/dist/core/entities/entity.cjs +0 -92
  37. package/dist/core/entities/entity.cjs.map +0 -1
  38. package/dist/core/entities/entity.d.cts +0 -18
  39. package/dist/core/entities/entity.d.ts +0 -18
  40. package/dist/core/entities/entity.js +0 -67
  41. package/dist/core/entities/entity.js.map +0 -1
  42. package/dist/core/entities/optional.cjs +0 -19
  43. package/dist/core/entities/optional.cjs.map +0 -1
  44. package/dist/core/entities/optional.d.cts +0 -3
  45. package/dist/core/entities/optional.d.ts +0 -3
  46. package/dist/core/entities/optional.js +0 -1
  47. package/dist/core/entities/optional.js.map +0 -1
  48. package/dist/core/entities/replace.cjs +0 -19
  49. package/dist/core/entities/replace.cjs.map +0 -1
  50. package/dist/core/entities/replace.d.cts +0 -5
  51. package/dist/core/entities/replace.d.ts +0 -5
  52. package/dist/core/entities/replace.js +0 -1
  53. package/dist/core/entities/replace.js.map +0 -1
  54. package/dist/core/entities/unique-entity-id.cjs +0 -50
  55. package/dist/core/entities/unique-entity-id.cjs.map +0 -1
  56. package/dist/core/entities/unique-entity-id.d.cts +0 -9
  57. package/dist/core/entities/unique-entity-id.d.ts +0 -9
  58. package/dist/core/entities/unique-entity-id.js +0 -27
  59. package/dist/core/entities/unique-entity-id.js.map +0 -1
  60. package/dist/core/entities/value-object.cjs +0 -40
  61. package/dist/core/entities/value-object.cjs.map +0 -1
  62. package/dist/core/entities/value-object.d.cts +0 -6
  63. package/dist/core/entities/value-object.d.ts +0 -6
  64. package/dist/core/entities/value-object.js +0 -17
  65. package/dist/core/entities/value-object.js.map +0 -1
  66. package/dist/core/entities/watched-list.cjs +0 -121
  67. package/dist/core/entities/watched-list.cjs.map +0 -1
  68. package/dist/core/entities/watched-list.d.cts +0 -27
  69. package/dist/core/entities/watched-list.d.ts +0 -27
  70. package/dist/core/entities/watched-list.js +0 -98
  71. package/dist/core/entities/watched-list.js.map +0 -1
  72. package/dist/core/entities/watched-list.test.cjs +0 -186
  73. package/dist/core/entities/watched-list.test.cjs.map +0 -1
  74. package/dist/core/entities/watched-list.test.d.cts +0 -2
  75. package/dist/core/entities/watched-list.test.d.ts +0 -2
  76. package/dist/core/entities/watched-list.test.js +0 -185
  77. package/dist/core/entities/watched-list.test.js.map +0 -1
  78. package/dist/core/errors/api-common-error.cjs +0 -38
  79. package/dist/core/errors/api-common-error.cjs.map +0 -1
  80. package/dist/core/errors/api-common-error.d.cts +0 -28
  81. package/dist/core/errors/api-common-error.d.ts +0 -28
  82. package/dist/core/errors/api-common-error.js +0 -13
  83. package/dist/core/errors/api-common-error.js.map +0 -1
  84. package/dist/core/errors/application-error.cjs +0 -54
  85. package/dist/core/errors/application-error.cjs.map +0 -1
  86. package/dist/core/errors/application-error.d.cts +0 -8
  87. package/dist/core/errors/application-error.d.ts +0 -8
  88. package/dist/core/errors/application-error.js +0 -33
  89. package/dist/core/errors/application-error.js.map +0 -1
  90. package/dist/core/errors/conflict-error.cjs +0 -56
  91. package/dist/core/errors/conflict-error.cjs.map +0 -1
  92. package/dist/core/errors/conflict-error.d.cts +0 -13
  93. package/dist/core/errors/conflict-error.d.ts +0 -13
  94. package/dist/core/errors/conflict-error.js +0 -35
  95. package/dist/core/errors/conflict-error.js.map +0 -1
  96. package/dist/core/errors/domain-error.cjs +0 -54
  97. package/dist/core/errors/domain-error.cjs.map +0 -1
  98. package/dist/core/errors/domain-error.d.cts +0 -8
  99. package/dist/core/errors/domain-error.d.ts +0 -8
  100. package/dist/core/errors/domain-error.js +0 -33
  101. package/dist/core/errors/domain-error.js.map +0 -1
  102. package/dist/core/errors/http-client-error.cjs +0 -54
  103. package/dist/core/errors/http-client-error.cjs.map +0 -1
  104. package/dist/core/errors/http-client-error.d.cts +0 -8
  105. package/dist/core/errors/http-client-error.d.ts +0 -8
  106. package/dist/core/errors/http-client-error.js +0 -33
  107. package/dist/core/errors/http-client-error.js.map +0 -1
  108. package/dist/core/errors/infra-error.cjs +0 -54
  109. package/dist/core/errors/infra-error.cjs.map +0 -1
  110. package/dist/core/errors/infra-error.d.cts +0 -8
  111. package/dist/core/errors/infra-error.d.ts +0 -8
  112. package/dist/core/errors/infra-error.js +0 -33
  113. package/dist/core/errors/infra-error.js.map +0 -1
  114. package/dist/core/errors/validation-error.cjs +0 -55
  115. package/dist/core/errors/validation-error.cjs.map +0 -1
  116. package/dist/core/errors/validation-error.d.cts +0 -8
  117. package/dist/core/errors/validation-error.d.ts +0 -8
  118. package/dist/core/errors/validation-error.js +0 -34
  119. package/dist/core/errors/validation-error.js.map +0 -1
  120. package/dist/core/http/base-controller.cjs +0 -295
  121. package/dist/core/http/base-controller.cjs.map +0 -1
  122. package/dist/core/http/base-controller.d.cts +0 -1
  123. package/dist/core/http/base-controller.d.ts +0 -1
  124. package/dist/core/http/base-controller.js +0 -270
  125. package/dist/core/http/base-controller.js.map +0 -1
  126. package/dist/core/http/dto-response.cjs +0 -19
  127. package/dist/core/http/dto-response.cjs.map +0 -1
  128. package/dist/core/http/dto-response.d.cts +0 -10
  129. package/dist/core/http/dto-response.d.ts +0 -10
  130. package/dist/core/http/dto-response.js +0 -1
  131. package/dist/core/http/dto-response.js.map +0 -1
  132. package/dist/core/http/error-notifier.cjs +0 -19
  133. package/dist/core/http/error-notifier.cjs.map +0 -1
  134. package/dist/core/http/error-notifier.d.cts +0 -1
  135. package/dist/core/http/error-notifier.d.ts +0 -1
  136. package/dist/core/http/error-notifier.js +0 -1
  137. package/dist/core/http/error-notifier.js.map +0 -1
  138. package/dist/core/http/get-take-and-skip.cjs +0 -40
  139. package/dist/core/http/get-take-and-skip.cjs.map +0 -1
  140. package/dist/core/http/get-take-and-skip.d.cts +0 -6
  141. package/dist/core/http/get-take-and-skip.d.ts +0 -6
  142. package/dist/core/http/get-take-and-skip.js +0 -17
  143. package/dist/core/http/get-take-and-skip.js.map +0 -1
  144. package/dist/core/http/health-connections.cjs +0 -42
  145. package/dist/core/http/health-connections.cjs.map +0 -1
  146. package/dist/core/http/health-connections.d.cts +0 -16
  147. package/dist/core/http/health-connections.d.ts +0 -16
  148. package/dist/core/http/health-connections.js +0 -23
  149. package/dist/core/http/health-connections.js.map +0 -1
  150. package/dist/core/http/http.cjs +0 -19
  151. package/dist/core/http/http.cjs.map +0 -1
  152. package/dist/core/http/http.d.cts +0 -10
  153. package/dist/core/http/http.d.ts +0 -10
  154. package/dist/core/http/http.js +0 -1
  155. package/dist/core/http/http.js.map +0 -1
  156. package/dist/core/http/pagination.cjs +0 -19
  157. package/dist/core/http/pagination.cjs.map +0 -1
  158. package/dist/core/http/pagination.d.cts +0 -9
  159. package/dist/core/http/pagination.d.ts +0 -9
  160. package/dist/core/http/pagination.js +0 -1
  161. package/dist/core/http/pagination.js.map +0 -1
  162. package/dist/core/http/validator.cjs +0 -19
  163. package/dist/core/http/validator.cjs.map +0 -1
  164. package/dist/core/http/validator.d.cts +0 -11
  165. package/dist/core/http/validator.d.ts +0 -11
  166. package/dist/core/http/validator.js +0 -1
  167. package/dist/core/http/validator.js.map +0 -1
  168. package/dist/infra/adapters/http/express-adapter.cjs +0 -139
  169. package/dist/infra/adapters/http/express-adapter.cjs.map +0 -1
  170. package/dist/infra/adapters/http/express-adapter.d.cts +0 -15
  171. package/dist/infra/adapters/http/express-adapter.d.ts +0 -15
  172. package/dist/infra/adapters/http/express-adapter.js +0 -106
  173. package/dist/infra/adapters/http/express-adapter.js.map +0 -1
  174. package/dist/infra/adapters/http/fastify-adapter.cjs +0 -124
  175. package/dist/infra/adapters/http/fastify-adapter.cjs.map +0 -1
  176. package/dist/infra/adapters/http/fastify-adapter.d.cts +0 -14
  177. package/dist/infra/adapters/http/fastify-adapter.d.ts +0 -14
  178. package/dist/infra/adapters/http/fastify-adapter.js +0 -91
  179. package/dist/infra/adapters/http/fastify-adapter.js.map +0 -1
  180. package/dist/infra/adapters/http/response-error-code.cjs +0 -35
  181. package/dist/infra/adapters/http/response-error-code.cjs.map +0 -1
  182. package/dist/infra/adapters/http/response-error-code.d.cts +0 -6
  183. package/dist/infra/adapters/http/response-error-code.d.ts +0 -6
  184. package/dist/infra/adapters/http/response-error-code.js +0 -10
  185. package/dist/infra/adapters/http/response-error-code.js.map +0 -1
  186. package/dist/infra/adapters/http/validate-controller-metadata.cjs +0 -42
  187. package/dist/infra/adapters/http/validate-controller-metadata.cjs.map +0 -1
  188. package/dist/infra/adapters/http/validate-controller-metadata.d.cts +0 -11
  189. package/dist/infra/adapters/http/validate-controller-metadata.d.ts +0 -11
  190. package/dist/infra/adapters/http/validate-controller-metadata.js +0 -19
  191. package/dist/infra/adapters/http/validate-controller-metadata.js.map +0 -1
  192. package/dist/infra/adapters/notifications/discord.cjs +0 -90
  193. package/dist/infra/adapters/notifications/discord.cjs.map +0 -1
  194. package/dist/infra/adapters/notifications/discord.d.cts +0 -14
  195. package/dist/infra/adapters/notifications/discord.d.ts +0 -14
  196. package/dist/infra/adapters/notifications/discord.js +0 -65
  197. package/dist/infra/adapters/notifications/discord.js.map +0 -1
  198. package/dist/infra/adapters/notifications/in-memory.cjs +0 -44
  199. package/dist/infra/adapters/notifications/in-memory.cjs.map +0 -1
  200. package/dist/infra/adapters/notifications/in-memory.d.cts +0 -8
  201. package/dist/infra/adapters/notifications/in-memory.d.ts +0 -8
  202. package/dist/infra/adapters/notifications/in-memory.js +0 -21
  203. package/dist/infra/adapters/notifications/in-memory.js.map +0 -1
  204. package/dist/infra/adapters/notifications/notification-factory.cjs +0 -219
  205. package/dist/infra/adapters/notifications/notification-factory.cjs.map +0 -1
  206. package/dist/infra/adapters/notifications/notification-factory.d.cts +0 -18
  207. package/dist/infra/adapters/notifications/notification-factory.d.ts +0 -18
  208. package/dist/infra/adapters/notifications/notification-factory.js +0 -184
  209. package/dist/infra/adapters/notifications/notification-factory.js.map +0 -1
  210. package/dist/infra/adapters/notifications/sentry.cjs +0 -129
  211. package/dist/infra/adapters/notifications/sentry.cjs.map +0 -1
  212. package/dist/infra/adapters/notifications/sentry.d.cts +0 -13
  213. package/dist/infra/adapters/notifications/sentry.d.ts +0 -13
  214. package/dist/infra/adapters/notifications/sentry.js +0 -96
  215. package/dist/infra/adapters/notifications/sentry.js.map +0 -1
  216. package/dist/infra/adapters/validators/zod/index.cjs +0 -179
  217. package/dist/infra/adapters/validators/zod/index.cjs.map +0 -1
  218. package/dist/infra/adapters/validators/zod/index.d.cts +0 -19
  219. package/dist/infra/adapters/validators/zod/index.d.ts +0 -19
  220. package/dist/infra/adapters/validators/zod/index.js +0 -154
  221. package/dist/infra/adapters/validators/zod/index.js.map +0 -1
  222. package/dist/infra/adapters/validators/zod/zod-map-error.cjs +0 -79
  223. package/dist/infra/adapters/validators/zod/zod-map-error.cjs.map +0 -1
  224. package/dist/infra/adapters/validators/zod/zod-map-error.d.cts +0 -15
  225. package/dist/infra/adapters/validators/zod/zod-map-error.d.ts +0 -15
  226. package/dist/infra/adapters/validators/zod/zod-map-error.js +0 -60
  227. package/dist/infra/adapters/validators/zod/zod-map-error.js.map +0 -1
  228. package/dist/infra/adapters/validators/zod/zod-validator.cjs +0 -178
  229. package/dist/infra/adapters/validators/zod/zod-validator.cjs.map +0 -1
  230. package/dist/infra/adapters/validators/zod/zod-validator.d.cts +0 -13
  231. package/dist/infra/adapters/validators/zod/zod-validator.d.ts +0 -13
  232. package/dist/infra/adapters/validators/zod/zod-validator.js +0 -153
  233. package/dist/infra/adapters/validators/zod/zod-validator.js.map +0 -1
  234. package/dist/infra/env/index.cjs +0 -467
  235. package/dist/infra/env/index.cjs.map +0 -1
  236. package/dist/infra/env/index.d.cts +0 -26
  237. package/dist/infra/env/index.d.ts +0 -26
  238. package/dist/infra/env/index.js +0 -452
  239. package/dist/infra/env/index.js.map +0 -1
  240. /package/dist/{index.js.map → index.mjs.map} +0 -0
@@ -1,184 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
-
4
- // src/core/decorators/dependency-container.ts
5
- import "reflect-metadata";
6
- function Inject(token) {
7
- return (target, _propertyKey, parameterIndex) => {
8
- const constructor = typeof target === "function" ? target : target.constructor;
9
- const existingInjectedParams = Reflect.getOwnMetadata("inject:params", constructor) || {};
10
- existingInjectedParams[parameterIndex] = token;
11
- Reflect.defineMetadata("inject:params", existingInjectedParams, constructor);
12
- };
13
- }
14
- __name(Inject, "Inject");
15
-
16
- // src/infra/adapters/notifications/discord.ts
17
- import { MessageBuilder, Webhook } from "discord-webhook-node";
18
- function _ts_decorate(decorators, target, key, desc) {
19
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
21
- r = Reflect.decorate(decorators, target, key, desc);
22
- else
23
- for (var i = decorators.length - 1; i >= 0; i--)
24
- if (d = decorators[i])
25
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
26
- return c > 3 && r && Object.defineProperty(target, key, r), r;
27
- }
28
- __name(_ts_decorate, "_ts_decorate");
29
- function _ts_metadata(k, v) {
30
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
31
- return Reflect.metadata(k, v);
32
- }
33
- __name(_ts_metadata, "_ts_metadata");
34
- function _ts_param(paramIndex, decorator) {
35
- return function(target, key) {
36
- decorator(target, key, paramIndex);
37
- };
38
- }
39
- __name(_ts_param, "_ts_param");
40
- var DiscordNotifier = class {
41
- static {
42
- __name(this, "DiscordNotifier");
43
- }
44
- options;
45
- webhook;
46
- constructor(options) {
47
- this.options = options;
48
- this.webhook = new Webhook(this.options.url);
49
- }
50
- async notify(error, context) {
51
- const embed = new MessageBuilder().setTitle("\u{1F6A8} Error").addField("Message", `\`\`\`${error.message.slice(0, 300)}\`\`\``).addField("Route:", `\`[${context?.request?.method}] ${context?.request?.url}\``, true).addField("Params:", "```json\n" + JSON.stringify(context?.request?.params, null, 2) + "\n```", true).addField("Query:", "```json\n" + JSON.stringify(context?.request?.query, null, 2) + "\n```", true).addField("Headers:", "```json\n" + JSON.stringify(context?.request?.headers, null, 2) + "\n```", true).addField("Body:", "```json\n" + JSON.stringify(context?.request?.body, null, 2) + "\n```").addField("Stack Trace:", "```" + (error.stack || "No stack provided").slice(0, 900) + "```").setFooter(`Env: ${this.options.env || "development"}`).setTimestamp();
52
- await this.webhook.send(embed);
53
- }
54
- };
55
- DiscordNotifier = _ts_decorate([
56
- _ts_param(0, Inject("DiscordConfig")),
57
- _ts_metadata("design:type", Function),
58
- _ts_metadata("design:paramtypes", [
59
- typeof DiscordOptions === "undefined" ? Object : DiscordOptions
60
- ])
61
- ], DiscordNotifier);
62
-
63
- // src/infra/adapters/notifications/in-memory.ts
64
- var NotificationErrorInMemory = class {
65
- static {
66
- __name(this, "NotificationErrorInMemory");
67
- }
68
- errors = [];
69
- async notify(error, context) {
70
- console.log("NOTIFICATION ERROR: ", error);
71
- this.errors.push({
72
- error: error.message,
73
- context
74
- });
75
- }
76
- };
77
-
78
- // src/infra/adapters/notifications/sentry.ts
79
- import * as Sentry from "@sentry/node";
80
- function _ts_decorate2(decorators, target, key, desc) {
81
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
82
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
83
- r = Reflect.decorate(decorators, target, key, desc);
84
- else
85
- for (var i = decorators.length - 1; i >= 0; i--)
86
- if (d = decorators[i])
87
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
88
- return c > 3 && r && Object.defineProperty(target, key, r), r;
89
- }
90
- __name(_ts_decorate2, "_ts_decorate");
91
- function _ts_metadata2(k, v) {
92
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
93
- return Reflect.metadata(k, v);
94
- }
95
- __name(_ts_metadata2, "_ts_metadata");
96
- function _ts_param2(paramIndex, decorator) {
97
- return function(target, key) {
98
- decorator(target, key, paramIndex);
99
- };
100
- }
101
- __name(_ts_param2, "_ts_param");
102
- var SentryNotifier = class {
103
- static {
104
- __name(this, "SentryNotifier");
105
- }
106
- options;
107
- constructor(options) {
108
- this.options = options;
109
- Sentry.init({
110
- dsn: this.options.dsn,
111
- environment: this.options.environment,
112
- attachStacktrace: true,
113
- tracesSampleRate: this.options.environment === "production" ? 0.1 : 1,
114
- maxBreadcrumbs: 100,
115
- debug: this.options.environment !== "production"
116
- });
117
- }
118
- async notify(error, context) {
119
- Sentry.withScope((scope) => {
120
- scope.setLevel("error");
121
- if (context?.env)
122
- scope.setTag("env", context.env);
123
- if (context?.user) {
124
- scope.setUser({
125
- id: context.user.id,
126
- username: context.user.name,
127
- email: context.user.email
128
- });
129
- }
130
- if (context?.request) {
131
- const { body, query, params, headers, method, url, requestId } = context.request;
132
- scope.setContext("http", {
133
- method,
134
- requestId,
135
- url,
136
- headers,
137
- query,
138
- body,
139
- params
140
- });
141
- }
142
- Sentry.captureException(error);
143
- });
144
- }
145
- };
146
- SentryNotifier = _ts_decorate2([
147
- _ts_param2(0, Inject("SentryConfig")),
148
- _ts_metadata2("design:type", Function),
149
- _ts_metadata2("design:paramtypes", [
150
- typeof SentryOptions === "undefined" ? Object : SentryOptions
151
- ])
152
- ], SentryNotifier);
153
-
154
- // src/infra/adapters/notifications/notification-factory.ts
155
- var NotificationFactory = class {
156
- static {
157
- __name(this, "NotificationFactory");
158
- }
159
- static define(env, definitions) {
160
- const defaultDefinition = {
161
- test: this.defineProvider(definitions?.local ?? "console"),
162
- development: this.defineProvider(definitions?.local ?? "console"),
163
- staging: this.defineProvider(definitions?.local ?? "discord"),
164
- production: this.defineProvider(definitions?.local ?? "sentry")
165
- };
166
- return defaultDefinition[env];
167
- }
168
- static defineProvider(provider) {
169
- switch (provider) {
170
- case "console":
171
- return NotificationErrorInMemory;
172
- case "discord":
173
- return DiscordNotifier;
174
- case "sentry":
175
- return SentryNotifier;
176
- default:
177
- return NotificationErrorInMemory;
178
- }
179
- }
180
- };
181
- export {
182
- NotificationFactory
183
- };
184
- //# sourceMappingURL=notification-factory.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/core/decorators/dependency-container.ts","../../../../src/infra/adapters/notifications/discord.ts","../../../../src/infra/adapters/notifications/in-memory.ts","../../../../src/infra/adapters/notifications/sentry.ts","../../../../src/infra/adapters/notifications/notification-factory.ts"],"sourcesContent":["import 'reflect-metadata'\n\ntype Class<T = any> = new (...args: any[]) => T\n\ntype Registration =\n | { type: 'class'; myClass: Class; singleton: boolean }\n | { type: 'value'; value: any }\n\nexport class DependencyContainer {\n static registry = new Map<string, Registration>()\n static singletons = new Map<string, any>()\n\n static register<T>(\n token: string,\n myClass: Class<T>,\n options: { singleton: boolean }\n ) {\n this.registry.set(token, {\n type: 'class',\n myClass,\n singleton: options.singleton,\n })\n }\n\n static registerValue<T>(token: string, value: T) {\n this.registry.set(token, { type: 'value', value })\n }\n\n static resolve<T>(target: Class<T>): T {\n const injectMetadata: Record<number, string> =\n Reflect.getOwnMetadata('inject:params', target) || {}\n\n const paramCount = Object.keys(injectMetadata).length\n\n const params = Array.from({ length: paramCount }, (_, index) => {\n const token = injectMetadata[index]\n if (!token) {\n throw new Error(\n `Missing @Inject token for parameter index ${index} in ${target.name}`\n )\n }\n return this.resolveToken(token)\n })\n\n return new target(...params)\n }\n\n static resolveToken(token: string): any {\n const registration = this.registry.get(token)\n\n if (!registration) {\n throw new Error(\n `\"${token}\" not registered. Please register it in the container.`\n )\n }\n\n if (registration.type === 'value') {\n return registration.value\n }\n\n const { myClass, singleton } = registration\n\n if (singleton) {\n if (!this.singletons.has(token)) {\n const instance = this.resolve(myClass)\n this.singletons.set(token, instance)\n }\n return this.singletons.get(token)\n }\n\n return this.resolve(myClass)\n }\n}\n\nexport function Inject(token: string): ParameterDecorator {\n return (\n target: object,\n _propertyKey: string | symbol | undefined,\n parameterIndex: number\n ): void => {\n const constructor =\n typeof target === 'function' ? target : target.constructor\n\n const existingInjectedParams: Record<number, string> =\n Reflect.getOwnMetadata('inject:params', constructor) || {}\n\n existingInjectedParams[parameterIndex] = token\n\n Reflect.defineMetadata('inject:params', existingInjectedParams, constructor)\n }\n}\n","import { Inject } from 'core/decorators/dependency-container'\nimport { MessageBuilder, Webhook } from 'discord-webhook-node'\n\nimport type { ContextError } from '../../../core/http/base-controller'\nimport type { IErrorNotifier } from '../../../core/http/error-notifier'\n\ntype DiscordOptions = {\n url: string\n env: string\n}\n\nexport class DiscordNotifier implements IErrorNotifier {\n private webhook: Webhook\n\n constructor(\n @Inject('DiscordConfig') private readonly options: DiscordOptions\n ) {\n this.webhook = new Webhook(this.options.url)\n }\n\n async notify(error: Error, context: ContextError): Promise<void> {\n const embed = new MessageBuilder()\n .setTitle('🚨 Error')\n .addField('Message', `\\`\\`\\`${error.message.slice(0, 300)}\\`\\`\\``)\n .addField(\n 'Route:',\n `\\`[${context?.request?.method}] ${context?.request?.url}\\``,\n true\n )\n .addField(\n 'Params:',\n '```json\\n' +\n JSON.stringify(context?.request?.params, null, 2) +\n '\\n```',\n true\n )\n .addField(\n 'Query:',\n '```json\\n' +\n JSON.stringify(context?.request?.query, null, 2) +\n '\\n```',\n true\n )\n .addField(\n 'Headers:',\n '```json\\n' +\n JSON.stringify(context?.request?.headers, null, 2) +\n '\\n```',\n true\n )\n .addField(\n 'Body:',\n '```json\\n' + JSON.stringify(context?.request?.body, null, 2) + '\\n```'\n )\n .addField(\n 'Stack Trace:',\n '```' + (error.stack || 'No stack provided').slice(0, 900) + '```'\n )\n .setFooter(`Env: ${this.options.env || 'development'}`)\n .setTimestamp()\n\n await this.webhook.send(embed)\n }\n}\n","import type { ContextError } from '../../../core/http/base-controller'\nimport type { IErrorNotifier } from '../../../core/http/error-notifier'\n\nexport class NotificationErrorInMemory implements IErrorNotifier {\n public errors: any[] = []\n\n async notify(error: Error, context?: ContextError): Promise<void> {\n console.log('NOTIFICATION ERROR: ', error)\n\n this.errors.push({\n error: error.message,\n context,\n })\n }\n}\n","import * as Sentry from '@sentry/node'\nimport type { ContextError } from 'core/http/base-controller'\n\nimport { Inject } from '../../../core/decorators/dependency-container'\nimport { IErrorNotifier } from '../../../core/http/error-notifier'\n\ntype SentryOptions = {\n dsn: string\n environment: string\n}\n\nexport class SentryNotifier implements IErrorNotifier {\n constructor(@Inject('SentryConfig') private readonly options: SentryOptions) {\n Sentry.init({\n dsn: this.options.dsn,\n environment: this.options.environment,\n attachStacktrace: true,\n tracesSampleRate: this.options.environment === 'production' ? 0.1 : 1.0,\n maxBreadcrumbs: 100,\n debug: this.options.environment !== 'production',\n })\n }\n\n async notify(error: Error, context: ContextError): Promise<void> {\n Sentry.withScope((scope) => {\n scope.setLevel('error')\n\n if (context?.env) scope.setTag('env', context.env)\n\n if (context?.user) {\n scope.setUser({\n id: context.user.id,\n username: context.user.name,\n email: context.user.email,\n })\n }\n\n if (context?.request) {\n const { body, query, params, headers, method, url, requestId } =\n context.request\n\n scope.setContext('http', {\n method,\n requestId,\n url,\n headers,\n query,\n body,\n params,\n })\n }\n\n Sentry.captureException(error)\n })\n }\n}\n","import type { z } from 'zod'\n\nimport type { baseEnvSchema } from '../../env'\n\nimport { DiscordNotifier } from './discord'\nimport { NotificationErrorInMemory } from './in-memory'\nimport { SentryNotifier } from './sentry'\n\ntype OptionsNotifications = 'console' | 'discord' | 'sentry'\ntype EnvironmentEnum = z.infer<typeof baseEnvSchema>['ENVIRONMENT']\n\ntype Props = {\n local?: OptionsNotifications\n test?: OptionsNotifications\n development?: OptionsNotifications\n staging?: OptionsNotifications\n production?: OptionsNotifications\n}\n\nexport class NotificationFactory {\n static define(env: EnvironmentEnum, definitions?: Props): any {\n const defaultDefinition = {\n test: this.defineProvider(definitions?.local ?? 'console'),\n development: this.defineProvider(definitions?.local ?? 'console'),\n staging: this.defineProvider(definitions?.local ?? 'discord'),\n production: this.defineProvider(definitions?.local ?? 'sentry'),\n }\n\n return defaultDefinition[env]\n }\n\n private static defineProvider(provider: OptionsNotifications) {\n switch (provider) {\n case 'console':\n return NotificationErrorInMemory\n case 'discord':\n return DiscordNotifier\n case 'sentry':\n return SentryNotifier\n default:\n return NotificationErrorInMemory\n }\n }\n}\n"],"mappings":"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","names":["Inject","token","target","_propertyKey","parameterIndex","constructor","existingInjectedParams","Reflect","getOwnMetadata","defineMetadata","MessageBuilder","Webhook","DiscordNotifier","webhook","constructor","options","Webhook","url","notify","error","context","embed","MessageBuilder","setTitle","addField","message","slice","request","method","JSON","stringify","params","query","headers","body","stack","setFooter","env","setTimestamp","send","NotificationErrorInMemory","errors","notify","error","context","console","log","push","message","Sentry","SentryNotifier","constructor","options","Sentry","init","dsn","environment","attachStacktrace","tracesSampleRate","maxBreadcrumbs","debug","notify","error","context","withScope","scope","setLevel","env","setTag","user","setUser","id","username","name","email","request","body","query","params","headers","method","url","requestId","setContext","captureException","NotificationFactory","define","env","definitions","defaultDefinition","test","defineProvider","local","development","staging","production","provider","NotificationErrorInMemory","DiscordNotifier","SentryNotifier"]}
@@ -1,129 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
- var __export = (target, all) => {
10
- for (var name in all)
11
- __defProp(target, name, { get: all[name], enumerable: true });
12
- };
13
- var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(to, key) && key !== except)
17
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
- }
19
- return to;
20
- };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
-
31
- // src/infra/adapters/notifications/sentry.ts
32
- var sentry_exports = {};
33
- __export(sentry_exports, {
34
- SentryNotifier: () => SentryNotifier
35
- });
36
- module.exports = __toCommonJS(sentry_exports);
37
- var Sentry = __toESM(require("@sentry/node"), 1);
38
-
39
- // src/core/decorators/dependency-container.ts
40
- var import_reflect_metadata = require("reflect-metadata");
41
- function Inject(token) {
42
- return (target, _propertyKey, parameterIndex) => {
43
- const constructor = typeof target === "function" ? target : target.constructor;
44
- const existingInjectedParams = Reflect.getOwnMetadata("inject:params", constructor) || {};
45
- existingInjectedParams[parameterIndex] = token;
46
- Reflect.defineMetadata("inject:params", existingInjectedParams, constructor);
47
- };
48
- }
49
- __name(Inject, "Inject");
50
-
51
- // src/infra/adapters/notifications/sentry.ts
52
- function _ts_decorate(decorators, target, key, desc) {
53
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
54
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
55
- r = Reflect.decorate(decorators, target, key, desc);
56
- else
57
- for (var i = decorators.length - 1; i >= 0; i--)
58
- if (d = decorators[i])
59
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
60
- return c > 3 && r && Object.defineProperty(target, key, r), r;
61
- }
62
- __name(_ts_decorate, "_ts_decorate");
63
- function _ts_metadata(k, v) {
64
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
65
- return Reflect.metadata(k, v);
66
- }
67
- __name(_ts_metadata, "_ts_metadata");
68
- function _ts_param(paramIndex, decorator) {
69
- return function(target, key) {
70
- decorator(target, key, paramIndex);
71
- };
72
- }
73
- __name(_ts_param, "_ts_param");
74
- var SentryNotifier = class {
75
- static {
76
- __name(this, "SentryNotifier");
77
- }
78
- options;
79
- constructor(options) {
80
- this.options = options;
81
- Sentry.init({
82
- dsn: this.options.dsn,
83
- environment: this.options.environment,
84
- attachStacktrace: true,
85
- tracesSampleRate: this.options.environment === "production" ? 0.1 : 1,
86
- maxBreadcrumbs: 100,
87
- debug: this.options.environment !== "production"
88
- });
89
- }
90
- async notify(error, context) {
91
- Sentry.withScope((scope) => {
92
- scope.setLevel("error");
93
- if (context?.env)
94
- scope.setTag("env", context.env);
95
- if (context?.user) {
96
- scope.setUser({
97
- id: context.user.id,
98
- username: context.user.name,
99
- email: context.user.email
100
- });
101
- }
102
- if (context?.request) {
103
- const { body, query, params, headers, method, url, requestId } = context.request;
104
- scope.setContext("http", {
105
- method,
106
- requestId,
107
- url,
108
- headers,
109
- query,
110
- body,
111
- params
112
- });
113
- }
114
- Sentry.captureException(error);
115
- });
116
- }
117
- };
118
- SentryNotifier = _ts_decorate([
119
- _ts_param(0, Inject("SentryConfig")),
120
- _ts_metadata("design:type", Function),
121
- _ts_metadata("design:paramtypes", [
122
- typeof SentryOptions === "undefined" ? Object : SentryOptions
123
- ])
124
- ], SentryNotifier);
125
- // Annotate the CommonJS export names for ESM import in node:
126
- 0 && (module.exports = {
127
- SentryNotifier
128
- });
129
- //# sourceMappingURL=sentry.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/infra/adapters/notifications/sentry.ts","../../../../src/core/decorators/dependency-container.ts"],"sourcesContent":["import * as Sentry from '@sentry/node'\nimport type { ContextError } from 'core/http/base-controller'\n\nimport { Inject } from '../../../core/decorators/dependency-container'\nimport { IErrorNotifier } from '../../../core/http/error-notifier'\n\ntype SentryOptions = {\n dsn: string\n environment: string\n}\n\nexport class SentryNotifier implements IErrorNotifier {\n constructor(@Inject('SentryConfig') private readonly options: SentryOptions) {\n Sentry.init({\n dsn: this.options.dsn,\n environment: this.options.environment,\n attachStacktrace: true,\n tracesSampleRate: this.options.environment === 'production' ? 0.1 : 1.0,\n maxBreadcrumbs: 100,\n debug: this.options.environment !== 'production',\n })\n }\n\n async notify(error: Error, context: ContextError): Promise<void> {\n Sentry.withScope((scope) => {\n scope.setLevel('error')\n\n if (context?.env) scope.setTag('env', context.env)\n\n if (context?.user) {\n scope.setUser({\n id: context.user.id,\n username: context.user.name,\n email: context.user.email,\n })\n }\n\n if (context?.request) {\n const { body, query, params, headers, method, url, requestId } =\n context.request\n\n scope.setContext('http', {\n method,\n requestId,\n url,\n headers,\n query,\n body,\n params,\n })\n }\n\n Sentry.captureException(error)\n })\n }\n}\n","import 'reflect-metadata'\n\ntype Class<T = any> = new (...args: any[]) => T\n\ntype Registration =\n | { type: 'class'; myClass: Class; singleton: boolean }\n | { type: 'value'; value: any }\n\nexport class DependencyContainer {\n static registry = new Map<string, Registration>()\n static singletons = new Map<string, any>()\n\n static register<T>(\n token: string,\n myClass: Class<T>,\n options: { singleton: boolean }\n ) {\n this.registry.set(token, {\n type: 'class',\n myClass,\n singleton: options.singleton,\n })\n }\n\n static registerValue<T>(token: string, value: T) {\n this.registry.set(token, { type: 'value', value })\n }\n\n static resolve<T>(target: Class<T>): T {\n const injectMetadata: Record<number, string> =\n Reflect.getOwnMetadata('inject:params', target) || {}\n\n const paramCount = Object.keys(injectMetadata).length\n\n const params = Array.from({ length: paramCount }, (_, index) => {\n const token = injectMetadata[index]\n if (!token) {\n throw new Error(\n `Missing @Inject token for parameter index ${index} in ${target.name}`\n )\n }\n return this.resolveToken(token)\n })\n\n return new target(...params)\n }\n\n static resolveToken(token: string): any {\n const registration = this.registry.get(token)\n\n if (!registration) {\n throw new Error(\n `\"${token}\" not registered. Please register it in the container.`\n )\n }\n\n if (registration.type === 'value') {\n return registration.value\n }\n\n const { myClass, singleton } = registration\n\n if (singleton) {\n if (!this.singletons.has(token)) {\n const instance = this.resolve(myClass)\n this.singletons.set(token, instance)\n }\n return this.singletons.get(token)\n }\n\n return this.resolve(myClass)\n }\n}\n\nexport function Inject(token: string): ParameterDecorator {\n return (\n target: object,\n _propertyKey: string | symbol | undefined,\n parameterIndex: number\n ): void => {\n const constructor =\n typeof target === 'function' ? target : target.constructor\n\n const existingInjectedParams: Record<number, string> =\n Reflect.getOwnMetadata('inject:params', constructor) || {}\n\n existingInjectedParams[parameterIndex] = token\n\n Reflect.defineMetadata('inject:params', existingInjectedParams, constructor)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,aAAwB;;;ACAxB,8BAAO;AA0EA,SAASA,OAAOC,OAAa;AAClC,SAAO,CACLC,QACAC,cACAC,mBAAAA;AAEA,UAAMC,cACJ,OAAOH,WAAW,aAAaA,SAASA,OAAOG;AAEjD,UAAMC,yBACJC,QAAQC,eAAe,iBAAiBH,WAAAA,KAAgB,CAAC;AAE3DC,2BAAuBF,cAAAA,IAAkBH;AAEzCM,YAAQE,eAAe,iBAAiBH,wBAAwBD,WAAAA;EAClE;AACF;AAhBgBL;;;;;;;;;;;;;;;;;;;;;;;;;AD/DT,IAAMU,iBAAN,MAAMA;SAAAA;;;;EACXC,YAAqDC,SAAwB;SAAxBA,UAAAA;AACnDC,IAAOC,YAAK;MACVC,KAAK,KAAKH,QAAQG;MAClBC,aAAa,KAAKJ,QAAQI;MAC1BC,kBAAkB;MAClBC,kBAAkB,KAAKN,QAAQI,gBAAgB,eAAe,MAAM;MACpEG,gBAAgB;MAChBC,OAAO,KAAKR,QAAQI,gBAAgB;IACtC,CAAA;EACF;EAEA,MAAMK,OAAOC,OAAcC,SAAsC;AAC/DV,IAAOW,iBAAU,CAACC,UAAAA;AAChBA,YAAMC,SAAS,OAAA;AAEf,UAAIH,SAASI;AAAKF,cAAMG,OAAO,OAAOL,QAAQI,GAAG;AAEjD,UAAIJ,SAASM,MAAM;AACjBJ,cAAMK,QAAQ;UACZC,IAAIR,QAAQM,KAAKE;UACjBC,UAAUT,QAAQM,KAAKI;UACvBC,OAAOX,QAAQM,KAAKK;QACtB,CAAA;MACF;AAEA,UAAIX,SAASY,SAAS;AACpB,cAAM,EAAEC,MAAMC,OAAOC,QAAQC,SAASC,QAAQC,KAAKC,UAAS,IAC1DnB,QAAQY;AAEVV,cAAMkB,WAAW,QAAQ;UACvBH;UACAE;UACAD;UACAF;UACAF;UACAD;UACAE;QACF,CAAA;MACF;AAEAzB,MAAO+B,wBAAiBtB,KAAAA;IAC1B,CAAA;EACF;AACF;;;;;;;;","names":["Inject","token","target","_propertyKey","parameterIndex","constructor","existingInjectedParams","Reflect","getOwnMetadata","defineMetadata","SentryNotifier","constructor","options","Sentry","init","dsn","environment","attachStacktrace","tracesSampleRate","maxBreadcrumbs","debug","notify","error","context","withScope","scope","setLevel","env","setTag","user","setUser","id","username","name","email","request","body","query","params","headers","method","url","requestId","setContext","captureException"]}
@@ -1,13 +0,0 @@
1
- import { I as IErrorNotifier, C as ContextError } from '../../../base-controller-68008870.js';
2
-
3
- type SentryOptions = {
4
- dsn: string;
5
- environment: string;
6
- };
7
- declare class SentryNotifier implements IErrorNotifier {
8
- private readonly options;
9
- constructor(options: SentryOptions);
10
- notify(error: Error, context: ContextError): Promise<void>;
11
- }
12
-
13
- export { SentryNotifier };
@@ -1,13 +0,0 @@
1
- import { I as IErrorNotifier, C as ContextError } from '../../../base-controller-68008870.js';
2
-
3
- type SentryOptions = {
4
- dsn: string;
5
- environment: string;
6
- };
7
- declare class SentryNotifier implements IErrorNotifier {
8
- private readonly options;
9
- constructor(options: SentryOptions);
10
- notify(error: Error, context: ContextError): Promise<void>;
11
- }
12
-
13
- export { SentryNotifier };
@@ -1,96 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
-
4
- // src/infra/adapters/notifications/sentry.ts
5
- import * as Sentry from "@sentry/node";
6
-
7
- // src/core/decorators/dependency-container.ts
8
- import "reflect-metadata";
9
- function Inject(token) {
10
- return (target, _propertyKey, parameterIndex) => {
11
- const constructor = typeof target === "function" ? target : target.constructor;
12
- const existingInjectedParams = Reflect.getOwnMetadata("inject:params", constructor) || {};
13
- existingInjectedParams[parameterIndex] = token;
14
- Reflect.defineMetadata("inject:params", existingInjectedParams, constructor);
15
- };
16
- }
17
- __name(Inject, "Inject");
18
-
19
- // src/infra/adapters/notifications/sentry.ts
20
- function _ts_decorate(decorators, target, key, desc) {
21
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
22
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
23
- r = Reflect.decorate(decorators, target, key, desc);
24
- else
25
- for (var i = decorators.length - 1; i >= 0; i--)
26
- if (d = decorators[i])
27
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
28
- return c > 3 && r && Object.defineProperty(target, key, r), r;
29
- }
30
- __name(_ts_decorate, "_ts_decorate");
31
- function _ts_metadata(k, v) {
32
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
33
- return Reflect.metadata(k, v);
34
- }
35
- __name(_ts_metadata, "_ts_metadata");
36
- function _ts_param(paramIndex, decorator) {
37
- return function(target, key) {
38
- decorator(target, key, paramIndex);
39
- };
40
- }
41
- __name(_ts_param, "_ts_param");
42
- var SentryNotifier = class {
43
- static {
44
- __name(this, "SentryNotifier");
45
- }
46
- options;
47
- constructor(options) {
48
- this.options = options;
49
- Sentry.init({
50
- dsn: this.options.dsn,
51
- environment: this.options.environment,
52
- attachStacktrace: true,
53
- tracesSampleRate: this.options.environment === "production" ? 0.1 : 1,
54
- maxBreadcrumbs: 100,
55
- debug: this.options.environment !== "production"
56
- });
57
- }
58
- async notify(error, context) {
59
- Sentry.withScope((scope) => {
60
- scope.setLevel("error");
61
- if (context?.env)
62
- scope.setTag("env", context.env);
63
- if (context?.user) {
64
- scope.setUser({
65
- id: context.user.id,
66
- username: context.user.name,
67
- email: context.user.email
68
- });
69
- }
70
- if (context?.request) {
71
- const { body, query, params, headers, method, url, requestId } = context.request;
72
- scope.setContext("http", {
73
- method,
74
- requestId,
75
- url,
76
- headers,
77
- query,
78
- body,
79
- params
80
- });
81
- }
82
- Sentry.captureException(error);
83
- });
84
- }
85
- };
86
- SentryNotifier = _ts_decorate([
87
- _ts_param(0, Inject("SentryConfig")),
88
- _ts_metadata("design:type", Function),
89
- _ts_metadata("design:paramtypes", [
90
- typeof SentryOptions === "undefined" ? Object : SentryOptions
91
- ])
92
- ], SentryNotifier);
93
- export {
94
- SentryNotifier
95
- };
96
- //# sourceMappingURL=sentry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/infra/adapters/notifications/sentry.ts","../../../../src/core/decorators/dependency-container.ts"],"sourcesContent":["import * as Sentry from '@sentry/node'\nimport type { ContextError } from 'core/http/base-controller'\n\nimport { Inject } from '../../../core/decorators/dependency-container'\nimport { IErrorNotifier } from '../../../core/http/error-notifier'\n\ntype SentryOptions = {\n dsn: string\n environment: string\n}\n\nexport class SentryNotifier implements IErrorNotifier {\n constructor(@Inject('SentryConfig') private readonly options: SentryOptions) {\n Sentry.init({\n dsn: this.options.dsn,\n environment: this.options.environment,\n attachStacktrace: true,\n tracesSampleRate: this.options.environment === 'production' ? 0.1 : 1.0,\n maxBreadcrumbs: 100,\n debug: this.options.environment !== 'production',\n })\n }\n\n async notify(error: Error, context: ContextError): Promise<void> {\n Sentry.withScope((scope) => {\n scope.setLevel('error')\n\n if (context?.env) scope.setTag('env', context.env)\n\n if (context?.user) {\n scope.setUser({\n id: context.user.id,\n username: context.user.name,\n email: context.user.email,\n })\n }\n\n if (context?.request) {\n const { body, query, params, headers, method, url, requestId } =\n context.request\n\n scope.setContext('http', {\n method,\n requestId,\n url,\n headers,\n query,\n body,\n params,\n })\n }\n\n Sentry.captureException(error)\n })\n }\n}\n","import 'reflect-metadata'\n\ntype Class<T = any> = new (...args: any[]) => T\n\ntype Registration =\n | { type: 'class'; myClass: Class; singleton: boolean }\n | { type: 'value'; value: any }\n\nexport class DependencyContainer {\n static registry = new Map<string, Registration>()\n static singletons = new Map<string, any>()\n\n static register<T>(\n token: string,\n myClass: Class<T>,\n options: { singleton: boolean }\n ) {\n this.registry.set(token, {\n type: 'class',\n myClass,\n singleton: options.singleton,\n })\n }\n\n static registerValue<T>(token: string, value: T) {\n this.registry.set(token, { type: 'value', value })\n }\n\n static resolve<T>(target: Class<T>): T {\n const injectMetadata: Record<number, string> =\n Reflect.getOwnMetadata('inject:params', target) || {}\n\n const paramCount = Object.keys(injectMetadata).length\n\n const params = Array.from({ length: paramCount }, (_, index) => {\n const token = injectMetadata[index]\n if (!token) {\n throw new Error(\n `Missing @Inject token for parameter index ${index} in ${target.name}`\n )\n }\n return this.resolveToken(token)\n })\n\n return new target(...params)\n }\n\n static resolveToken(token: string): any {\n const registration = this.registry.get(token)\n\n if (!registration) {\n throw new Error(\n `\"${token}\" not registered. Please register it in the container.`\n )\n }\n\n if (registration.type === 'value') {\n return registration.value\n }\n\n const { myClass, singleton } = registration\n\n if (singleton) {\n if (!this.singletons.has(token)) {\n const instance = this.resolve(myClass)\n this.singletons.set(token, instance)\n }\n return this.singletons.get(token)\n }\n\n return this.resolve(myClass)\n }\n}\n\nexport function Inject(token: string): ParameterDecorator {\n return (\n target: object,\n _propertyKey: string | symbol | undefined,\n parameterIndex: number\n ): void => {\n const constructor =\n typeof target === 'function' ? target : target.constructor\n\n const existingInjectedParams: Record<number, string> =\n Reflect.getOwnMetadata('inject:params', constructor) || {}\n\n existingInjectedParams[parameterIndex] = token\n\n Reflect.defineMetadata('inject:params', existingInjectedParams, constructor)\n }\n}\n"],"mappings":";;;;AAAA,YAAYA,YAAY;;;ACAxB,OAAO;AA0EA,SAASC,OAAOC,OAAa;AAClC,SAAO,CACLC,QACAC,cACAC,mBAAAA;AAEA,UAAMC,cACJ,OAAOH,WAAW,aAAaA,SAASA,OAAOG;AAEjD,UAAMC,yBACJC,QAAQC,eAAe,iBAAiBH,WAAAA,KAAgB,CAAC;AAE3DC,2BAAuBF,cAAAA,IAAkBH;AAEzCM,YAAQE,eAAe,iBAAiBH,wBAAwBD,WAAAA;EAClE;AACF;AAhBgBL;;;;;;;;;;;;;;;;;;;;;;;;;AD/DT,IAAMU,iBAAN,MAAMA;SAAAA;;;;EACXC,YAAqDC,SAAwB;SAAxBA,UAAAA;AACnDC,IAAOC,YAAK;MACVC,KAAK,KAAKH,QAAQG;MAClBC,aAAa,KAAKJ,QAAQI;MAC1BC,kBAAkB;MAClBC,kBAAkB,KAAKN,QAAQI,gBAAgB,eAAe,MAAM;MACpEG,gBAAgB;MAChBC,OAAO,KAAKR,QAAQI,gBAAgB;IACtC,CAAA;EACF;EAEA,MAAMK,OAAOC,OAAcC,SAAsC;AAC/DV,IAAOW,iBAAU,CAACC,UAAAA;AAChBA,YAAMC,SAAS,OAAA;AAEf,UAAIH,SAASI;AAAKF,cAAMG,OAAO,OAAOL,QAAQI,GAAG;AAEjD,UAAIJ,SAASM,MAAM;AACjBJ,cAAMK,QAAQ;UACZC,IAAIR,QAAQM,KAAKE;UACjBC,UAAUT,QAAQM,KAAKI;UACvBC,OAAOX,QAAQM,KAAKK;QACtB,CAAA;MACF;AAEA,UAAIX,SAASY,SAAS;AACpB,cAAM,EAAEC,MAAMC,OAAOC,QAAQC,SAASC,QAAQC,KAAKC,UAAS,IAC1DnB,QAAQY;AAEVV,cAAMkB,WAAW,QAAQ;UACvBH;UACAE;UACAD;UACAF;UACAF;UACAD;UACAE;QACF,CAAA;MACF;AAEAzB,MAAO+B,wBAAiBtB,KAAAA;IAC1B,CAAA;EACF;AACF;;;;;;;;","names":["Sentry","Inject","token","target","_propertyKey","parameterIndex","constructor","existingInjectedParams","Reflect","getOwnMetadata","defineMetadata","SentryNotifier","constructor","options","Sentry","init","dsn","environment","attachStacktrace","tracesSampleRate","maxBreadcrumbs","debug","notify","error","context","withScope","scope","setLevel","env","setTag","user","setUser","id","username","name","email","request","body","query","params","headers","method","url","requestId","setContext","captureException"]}