@thymian/core 0.0.1

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 (314) hide show
  1. package/README.md +7 -0
  2. package/dist/actions/action.d.ts +5 -0
  3. package/dist/actions/action.d.ts.map +1 -0
  4. package/dist/actions/action.js +2 -0
  5. package/dist/actions/action.js.map +1 -0
  6. package/dist/actions/close.action.d.ts +3 -0
  7. package/dist/actions/close.action.d.ts.map +1 -0
  8. package/dist/actions/close.action.js +2 -0
  9. package/dist/actions/close.action.js.map +1 -0
  10. package/dist/actions/index.d.ts +16 -0
  11. package/dist/actions/index.d.ts.map +1 -0
  12. package/dist/actions/index.js +5 -0
  13. package/dist/actions/index.js.map +1 -0
  14. package/dist/actions/load-format.action.d.ts +6 -0
  15. package/dist/actions/load-format.action.d.ts.map +1 -0
  16. package/dist/actions/load-format.action.js +62 -0
  17. package/dist/actions/load-format.action.js.map +1 -0
  18. package/dist/actions/ready.action.d.ts +3 -0
  19. package/dist/actions/ready.action.d.ts.map +1 -0
  20. package/dist/actions/ready.action.js +2 -0
  21. package/dist/actions/ready.action.js.map +1 -0
  22. package/dist/actions/run.action.d.ts +11 -0
  23. package/dist/actions/run.action.d.ts.map +1 -0
  24. package/dist/actions/run.action.js +16 -0
  25. package/dist/actions/run.action.js.map +1 -0
  26. package/dist/ajv.d.ts +5 -0
  27. package/dist/ajv.d.ts.map +1 -0
  28. package/dist/ajv.js +7 -0
  29. package/dist/ajv.js.map +1 -0
  30. package/dist/chalk.d.ts +2 -0
  31. package/dist/chalk.d.ts.map +1 -0
  32. package/dist/chalk.js +2 -0
  33. package/dist/chalk.js.map +1 -0
  34. package/dist/constants.d.ts +5 -0
  35. package/dist/constants.d.ts.map +1 -0
  36. package/dist/constants.js +6 -0
  37. package/dist/constants.js.map +1 -0
  38. package/dist/core-plugin.d.ts +5 -0
  39. package/dist/core-plugin.d.ts.map +1 -0
  40. package/dist/core-plugin.js +38 -0
  41. package/dist/core-plugin.js.map +1 -0
  42. package/dist/emitter/action-event.d.ts +19 -0
  43. package/dist/emitter/action-event.d.ts.map +1 -0
  44. package/dist/emitter/action-event.js +2 -0
  45. package/dist/emitter/action-event.js.map +1 -0
  46. package/dist/emitter/error-event.d.ts +13 -0
  47. package/dist/emitter/error-event.d.ts.map +1 -0
  48. package/dist/emitter/error-event.js +2 -0
  49. package/dist/emitter/error-event.js.map +1 -0
  50. package/dist/emitter/events.d.ts +10 -0
  51. package/dist/emitter/events.d.ts.map +1 -0
  52. package/dist/emitter/events.js +2 -0
  53. package/dist/emitter/events.js.map +1 -0
  54. package/dist/emitter/index.d.ts +6 -0
  55. package/dist/emitter/index.d.ts.map +1 -0
  56. package/dist/emitter/index.js +6 -0
  57. package/dist/emitter/index.js.map +1 -0
  58. package/dist/emitter/thymian-emitter.d.ts +51 -0
  59. package/dist/emitter/thymian-emitter.d.ts.map +1 -0
  60. package/dist/emitter/thymian-emitter.js +306 -0
  61. package/dist/emitter/thymian-emitter.js.map +1 -0
  62. package/dist/emitter/utils.d.ts +8 -0
  63. package/dist/emitter/utils.d.ts.map +1 -0
  64. package/dist/emitter/utils.js +16 -0
  65. package/dist/emitter/utils.js.map +1 -0
  66. package/dist/events/error.event.d.ts +5 -0
  67. package/dist/events/error.event.d.ts.map +1 -0
  68. package/dist/events/error.event.js +49 -0
  69. package/dist/events/error.event.js.map +1 -0
  70. package/dist/events/exit.event.d.ts +14 -0
  71. package/dist/events/exit.event.d.ts.map +1 -0
  72. package/dist/events/exit.event.js +9 -0
  73. package/dist/events/exit.event.js.map +1 -0
  74. package/dist/events/index.d.ts +15 -0
  75. package/dist/events/index.d.ts.map +1 -0
  76. package/dist/events/index.js +4 -0
  77. package/dist/events/index.js.map +1 -0
  78. package/dist/events/register-plugin.event.d.ts +51 -0
  79. package/dist/events/register-plugin.event.d.ts.map +1 -0
  80. package/dist/events/register-plugin.event.js +29 -0
  81. package/dist/events/register-plugin.event.js.map +1 -0
  82. package/dist/events/report.event.d.ts +28 -0
  83. package/dist/events/report.event.d.ts.map +1 -0
  84. package/dist/events/report.event.js +128 -0
  85. package/dist/events/report.event.js.map +1 -0
  86. package/dist/format/edges/edge.d.ts +8 -0
  87. package/dist/format/edges/edge.d.ts.map +1 -0
  88. package/dist/format/edges/edge.js +2 -0
  89. package/dist/format/edges/edge.js.map +1 -0
  90. package/dist/format/edges/has-sample.edge.d.ts +5 -0
  91. package/dist/format/edges/has-sample.edge.d.ts.map +1 -0
  92. package/dist/format/edges/has-sample.edge.js +2 -0
  93. package/dist/format/edges/has-sample.edge.js.map +1 -0
  94. package/dist/format/edges/http-link.edge.d.ts +10 -0
  95. package/dist/format/edges/http-link.edge.d.ts.map +1 -0
  96. package/dist/format/edges/http-link.edge.js +2 -0
  97. package/dist/format/edges/http-link.edge.js.map +1 -0
  98. package/dist/format/edges/http-transaction.edge.d.ts +5 -0
  99. package/dist/format/edges/http-transaction.edge.d.ts.map +1 -0
  100. package/dist/format/edges/http-transaction.edge.js +2 -0
  101. package/dist/format/edges/http-transaction.edge.js.map +1 -0
  102. package/dist/format/edges/is-secured-with.edge.d.ts +5 -0
  103. package/dist/format/edges/is-secured-with.edge.d.ts.map +1 -0
  104. package/dist/format/edges/is-secured-with.edge.js +2 -0
  105. package/dist/format/edges/is-secured-with.edge.js.map +1 -0
  106. package/dist/format/edges/sample-http-transaction.edge.d.ts +5 -0
  107. package/dist/format/edges/sample-http-transaction.edge.d.ts.map +1 -0
  108. package/dist/format/edges/sample-http-transaction.edge.js +2 -0
  109. package/dist/format/edges/sample-http-transaction.edge.js.map +1 -0
  110. package/dist/format/format-location.d.ts +13 -0
  111. package/dist/format/format-location.d.ts.map +1 -0
  112. package/dist/format/format-location.js +2 -0
  113. package/dist/format/format-location.js.map +1 -0
  114. package/dist/format/index.d.ts +14 -0
  115. package/dist/format/index.d.ts.map +1 -0
  116. package/dist/format/index.js +14 -0
  117. package/dist/format/index.js.map +1 -0
  118. package/dist/format/nodes/http-request.node.d.ts +29 -0
  119. package/dist/format/nodes/http-request.node.d.ts.map +1 -0
  120. package/dist/format/nodes/http-request.node.js +2 -0
  121. package/dist/format/nodes/http-request.node.js.map +1 -0
  122. package/dist/format/nodes/http-response.node.d.ts +12 -0
  123. package/dist/format/nodes/http-response.node.d.ts.map +1 -0
  124. package/dist/format/nodes/http-response.node.js +2 -0
  125. package/dist/format/nodes/http-response.node.js.map +1 -0
  126. package/dist/format/nodes/node.d.ts +8 -0
  127. package/dist/format/nodes/node.d.ts.map +1 -0
  128. package/dist/format/nodes/node.js +2 -0
  129. package/dist/format/nodes/node.js.map +1 -0
  130. package/dist/format/nodes/sample-http-request.node.d.ts +7 -0
  131. package/dist/format/nodes/sample-http-request.node.d.ts.map +1 -0
  132. package/dist/format/nodes/sample-http-request.node.js +2 -0
  133. package/dist/format/nodes/sample-http-request.node.js.map +1 -0
  134. package/dist/format/nodes/sample-http-response.node.d.ts +7 -0
  135. package/dist/format/nodes/sample-http-response.node.d.ts.map +1 -0
  136. package/dist/format/nodes/sample-http-response.node.js +2 -0
  137. package/dist/format/nodes/sample-http-response.node.js.map +1 -0
  138. package/dist/format/nodes/security-scheme.node.d.ts +17 -0
  139. package/dist/format/nodes/security-scheme.node.d.ts.map +1 -0
  140. package/dist/format/nodes/security-scheme.node.js +2 -0
  141. package/dist/format/nodes/security-scheme.node.js.map +1 -0
  142. package/dist/format/parameter.d.ts +10 -0
  143. package/dist/format/parameter.d.ts.map +1 -0
  144. package/dist/format/parameter.js +2 -0
  145. package/dist/format/parameter.js.map +1 -0
  146. package/dist/format/serialization-style/cookie.serialization-style.d.ts +5 -0
  147. package/dist/format/serialization-style/cookie.serialization-style.d.ts.map +1 -0
  148. package/dist/format/serialization-style/cookie.serialization-style.js +7 -0
  149. package/dist/format/serialization-style/cookie.serialization-style.js.map +1 -0
  150. package/dist/format/serialization-style/header.serialization-style.d.ts +5 -0
  151. package/dist/format/serialization-style/header.serialization-style.d.ts.map +1 -0
  152. package/dist/format/serialization-style/header.serialization-style.js +7 -0
  153. package/dist/format/serialization-style/header.serialization-style.js.map +1 -0
  154. package/dist/format/serialization-style/index.d.ts +6 -0
  155. package/dist/format/serialization-style/index.d.ts.map +1 -0
  156. package/dist/format/serialization-style/index.js +6 -0
  157. package/dist/format/serialization-style/index.js.map +1 -0
  158. package/dist/format/serialization-style/path.serialization-style.d.ts +5 -0
  159. package/dist/format/serialization-style/path.serialization-style.d.ts.map +1 -0
  160. package/dist/format/serialization-style/path.serialization-style.js +7 -0
  161. package/dist/format/serialization-style/path.serialization-style.js.map +1 -0
  162. package/dist/format/serialization-style/query.serialization-style.d.ts +5 -0
  163. package/dist/format/serialization-style/query.serialization-style.d.ts.map +1 -0
  164. package/dist/format/serialization-style/query.serialization-style.js +7 -0
  165. package/dist/format/serialization-style/query.serialization-style.js.map +1 -0
  166. package/dist/format/serialization-style/serialization-style.d.ts +13 -0
  167. package/dist/format/serialization-style/serialization-style.d.ts.map +1 -0
  168. package/dist/format/serialization-style/serialization-style.js +25 -0
  169. package/dist/format/serialization-style/serialization-style.js.map +1 -0
  170. package/dist/format/thymian-format.d.ts +85 -0
  171. package/dist/format/thymian-format.d.ts.map +1 -0
  172. package/dist/format/thymian-format.js +297 -0
  173. package/dist/format/thymian-format.js.map +1 -0
  174. package/dist/format/thymian-schema.d.ts +55 -0
  175. package/dist/format/thymian-schema.d.ts.map +1 -0
  176. package/dist/format/thymian-schema.js +2 -0
  177. package/dist/format/thymian-schema.js.map +1 -0
  178. package/dist/format/utils.d.ts +12 -0
  179. package/dist/format/utils.d.ts.map +1 -0
  180. package/dist/format/utils.js +81 -0
  181. package/dist/format/utils.js.map +1 -0
  182. package/dist/http-filter-visitor.d.ts +73 -0
  183. package/dist/http-filter-visitor.d.ts.map +1 -0
  184. package/dist/http-filter-visitor.js +163 -0
  185. package/dist/http-filter-visitor.js.map +1 -0
  186. package/dist/http-filter.d.ts +135 -0
  187. package/dist/http-filter.d.ts.map +1 -0
  188. package/dist/http-filter.js +132 -0
  189. package/dist/http-filter.js.map +1 -0
  190. package/dist/http-status-codes/1xx/index.d.ts +15 -0
  191. package/dist/http-status-codes/1xx/index.d.ts.map +1 -0
  192. package/dist/http-status-codes/1xx/index.js +15 -0
  193. package/dist/http-status-codes/1xx/index.js.map +1 -0
  194. package/dist/http-status-codes/1xx/informational.phrases.d.ts +4 -0
  195. package/dist/http-status-codes/1xx/informational.phrases.d.ts.map +1 -0
  196. package/dist/http-status-codes/1xx/informational.phrases.js +10 -0
  197. package/dist/http-status-codes/1xx/informational.phrases.js.map +1 -0
  198. package/dist/http-status-codes/1xx/informational.status-codes.d.ts +4 -0
  199. package/dist/http-status-codes/1xx/informational.status-codes.d.ts.map +1 -0
  200. package/dist/http-status-codes/1xx/informational.status-codes.js +5 -0
  201. package/dist/http-status-codes/1xx/informational.status-codes.js.map +1 -0
  202. package/dist/http-status-codes/2xx/index.d.ts +25 -0
  203. package/dist/http-status-codes/2xx/index.d.ts.map +1 -0
  204. package/dist/http-status-codes/2xx/index.js +25 -0
  205. package/dist/http-status-codes/2xx/index.js.map +1 -0
  206. package/dist/http-status-codes/2xx/successful.phrases.d.ts +4 -0
  207. package/dist/http-status-codes/2xx/successful.phrases.d.ts.map +1 -0
  208. package/dist/http-status-codes/2xx/successful.phrases.js +15 -0
  209. package/dist/http-status-codes/2xx/successful.phrases.js.map +1 -0
  210. package/dist/http-status-codes/2xx/successful.status-codes.d.ts +4 -0
  211. package/dist/http-status-codes/2xx/successful.status-codes.d.ts.map +1 -0
  212. package/dist/http-status-codes/2xx/successful.status-codes.js +7 -0
  213. package/dist/http-status-codes/2xx/successful.status-codes.js.map +1 -0
  214. package/dist/http-status-codes/3xx/index.d.ts +21 -0
  215. package/dist/http-status-codes/3xx/index.d.ts.map +1 -0
  216. package/dist/http-status-codes/3xx/index.js +21 -0
  217. package/dist/http-status-codes/3xx/index.js.map +1 -0
  218. package/dist/http-status-codes/3xx/redirection.phrases.d.ts +4 -0
  219. package/dist/http-status-codes/3xx/redirection.phrases.d.ts.map +1 -0
  220. package/dist/http-status-codes/3xx/redirection.phrases.js +13 -0
  221. package/dist/http-status-codes/3xx/redirection.phrases.js.map +1 -0
  222. package/dist/http-status-codes/3xx/redirection.status-codes.d.ts +4 -0
  223. package/dist/http-status-codes/3xx/redirection.status-codes.d.ts.map +1 -0
  224. package/dist/http-status-codes/3xx/redirection.status-codes.js +7 -0
  225. package/dist/http-status-codes/3xx/redirection.status-codes.js.map +1 -0
  226. package/dist/http-status-codes/4xx/client-error.phrases.d.ts +4 -0
  227. package/dist/http-status-codes/4xx/client-error.phrases.d.ts.map +1 -0
  228. package/dist/http-status-codes/4xx/client-error.phrases.js +34 -0
  229. package/dist/http-status-codes/4xx/client-error.phrases.js.map +1 -0
  230. package/dist/http-status-codes/4xx/client-error.status-codes.d.ts +4 -0
  231. package/dist/http-status-codes/4xx/client-error.status-codes.d.ts.map +1 -0
  232. package/dist/http-status-codes/4xx/client-error.status-codes.js +8 -0
  233. package/dist/http-status-codes/4xx/client-error.status-codes.js.map +1 -0
  234. package/dist/http-status-codes/4xx/index.d.ts +63 -0
  235. package/dist/http-status-codes/4xx/index.d.ts.map +1 -0
  236. package/dist/http-status-codes/4xx/index.js +63 -0
  237. package/dist/http-status-codes/4xx/index.js.map +1 -0
  238. package/dist/http-status-codes/5xx/index.d.ts +29 -0
  239. package/dist/http-status-codes/5xx/index.d.ts.map +1 -0
  240. package/dist/http-status-codes/5xx/index.js +29 -0
  241. package/dist/http-status-codes/5xx/index.js.map +1 -0
  242. package/dist/http-status-codes/5xx/server-error.phrases.d.ts +4 -0
  243. package/dist/http-status-codes/5xx/server-error.phrases.d.ts.map +1 -0
  244. package/dist/http-status-codes/5xx/server-error.phrases.js +17 -0
  245. package/dist/http-status-codes/5xx/server-error.phrases.js.map +1 -0
  246. package/dist/http-status-codes/5xx/server-error.status-codes.d.ts +4 -0
  247. package/dist/http-status-codes/5xx/server-error.status-codes.d.ts.map +1 -0
  248. package/dist/http-status-codes/5xx/server-error.status-codes.js +7 -0
  249. package/dist/http-status-codes/5xx/server-error.status-codes.js.map +1 -0
  250. package/dist/http-status-codes/http-status-code-ranges.d.ts +11 -0
  251. package/dist/http-status-codes/http-status-code-ranges.d.ts.map +1 -0
  252. package/dist/http-status-codes/http-status-code-ranges.js +19 -0
  253. package/dist/http-status-codes/http-status-code-ranges.js.map +1 -0
  254. package/dist/http-status-codes/http-status-code.d.ts +8 -0
  255. package/dist/http-status-codes/http-status-code.d.ts.map +1 -0
  256. package/dist/http-status-codes/http-status-code.js +13 -0
  257. package/dist/http-status-codes/http-status-code.js.map +1 -0
  258. package/dist/http-status-codes/http-status-phrase.d.ts +8 -0
  259. package/dist/http-status-codes/http-status-phrase.d.ts.map +1 -0
  260. package/dist/http-status-codes/http-status-phrase.js +13 -0
  261. package/dist/http-status-codes/http-status-phrase.js.map +1 -0
  262. package/dist/http-status-codes/index.d.ts +10 -0
  263. package/dist/http-status-codes/index.d.ts.map +1 -0
  264. package/dist/http-status-codes/index.js +10 -0
  265. package/dist/http-status-codes/index.js.map +1 -0
  266. package/dist/http-status-codes/phrase-to-status-code.d.ts +62 -0
  267. package/dist/http-status-codes/phrase-to-status-code.d.ts.map +1 -0
  268. package/dist/http-status-codes/phrase-to-status-code.js +13 -0
  269. package/dist/http-status-codes/phrase-to-status-code.js.map +1 -0
  270. package/dist/http-status-codes/status-code-to-phrase.d.ts +62 -0
  271. package/dist/http-status-codes/status-code-to-phrase.d.ts.map +1 -0
  272. package/dist/http-status-codes/status-code-to-phrase.js +13 -0
  273. package/dist/http-status-codes/status-code-to-phrase.js.map +1 -0
  274. package/dist/http-status-codes/validate.d.ts +5 -0
  275. package/dist/http-status-codes/validate.d.ts.map +1 -0
  276. package/dist/http-status-codes/validate.js +28 -0
  277. package/dist/http-status-codes/validate.js.map +1 -0
  278. package/dist/http.d.ts +29 -0
  279. package/dist/http.d.ts.map +1 -0
  280. package/dist/http.js +2 -0
  281. package/dist/http.js.map +1 -0
  282. package/dist/index.d.ts +22 -0
  283. package/dist/index.d.ts.map +1 -0
  284. package/dist/index.js +22 -0
  285. package/dist/index.js.map +1 -0
  286. package/dist/logger/logger.d.ts +12 -0
  287. package/dist/logger/logger.d.ts.map +1 -0
  288. package/dist/logger/logger.js +2 -0
  289. package/dist/logger/logger.js.map +1 -0
  290. package/dist/logger/noop.logger.d.ts +14 -0
  291. package/dist/logger/noop.logger.d.ts.map +1 -0
  292. package/dist/logger/noop.logger.js +18 -0
  293. package/dist/logger/noop.logger.js.map +1 -0
  294. package/dist/logger/text.logger.d.ts +15 -0
  295. package/dist/logger/text.logger.d.ts.map +1 -0
  296. package/dist/logger/text.logger.js +41 -0
  297. package/dist/logger/text.logger.js.map +1 -0
  298. package/dist/thymian-plugin.d.ts +38 -0
  299. package/dist/thymian-plugin.d.ts.map +1 -0
  300. package/dist/thymian-plugin.js +22 -0
  301. package/dist/thymian-plugin.js.map +1 -0
  302. package/dist/thymian.d.ts +33 -0
  303. package/dist/thymian.d.ts.map +1 -0
  304. package/dist/thymian.error.d.ts +26 -0
  305. package/dist/thymian.error.d.ts.map +1 -0
  306. package/dist/thymian.error.js +34 -0
  307. package/dist/thymian.error.js.map +1 -0
  308. package/dist/thymian.js +148 -0
  309. package/dist/thymian.js.map +1 -0
  310. package/dist/utils.d.ts +34 -0
  311. package/dist/utils.d.ts.map +1 -0
  312. package/dist/utils.js +115 -0
  313. package/dist/utils.js.map +1 -0
  314. package/package.json +39 -0
@@ -0,0 +1,306 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import deepmerge from '@fastify/deepmerge';
3
+ import chalk from 'chalk';
4
+ import { filter, firstValueFrom, merge, Subject, take, takeUntil, timer, toArray, } from 'rxjs';
5
+ import { isThymianError, ThymianBaseError, } from '../thymian.error.js';
6
+ import { isActionEventWithName, isEventWithName, isResponseOf, } from './utils.js';
7
+ const dm = deepmerge({ all: true });
8
+ export class ThymianEmitter {
9
+ logger;
10
+ static #hasBeenInitialized = false;
11
+ options;
12
+ source;
13
+ #events = new Subject();
14
+ #responses;
15
+ #errors;
16
+ #listeners;
17
+ // TODO: this is a problem
18
+ #completed;
19
+ constructor(logger, state, options = {}) {
20
+ this.logger = logger;
21
+ this.options = {
22
+ timeout: 1000,
23
+ traceEvents: false,
24
+ ...options,
25
+ };
26
+ this.source = state.source;
27
+ this.#responses = state.responses;
28
+ this.#events = state.events;
29
+ this.#errors = state.errors;
30
+ this.#listeners = state.listeners;
31
+ this.#completed = state.completed;
32
+ if (!ThymianEmitter.#hasBeenInitialized) {
33
+ this.#events.subscribe(this.logEvent('event'));
34
+ this.#responses.subscribe(this.logEvent('response event'));
35
+ ThymianEmitter.#hasBeenInitialized = true;
36
+ }
37
+ }
38
+ static newEmitterState(source = '') {
39
+ return {
40
+ source,
41
+ events: new Subject(),
42
+ responses: new Subject(),
43
+ errors: new Subject(),
44
+ listeners: new Map(),
45
+ completed: new Set(),
46
+ };
47
+ }
48
+ on(name, handler) {
49
+ this.#events
50
+ .pipe(filter(isEventWithName(name)))
51
+ .subscribe(async (event) => {
52
+ try {
53
+ await handler(event.payload);
54
+ }
55
+ catch (e) {
56
+ if (e instanceof ThymianBaseError) {
57
+ this.#errors.next({
58
+ id: randomUUID(),
59
+ error: e,
60
+ name,
61
+ timestamp: Date.now(),
62
+ source: this.source,
63
+ correlationId: event.id,
64
+ });
65
+ }
66
+ else if (isThymianError(e)) {
67
+ const error = new ThymianBaseError(e.message, {
68
+ ...e.options,
69
+ name: e.name,
70
+ });
71
+ this.#errors.next({
72
+ error,
73
+ name,
74
+ timestamp: Date.now(),
75
+ source: this.source,
76
+ correlationId: event.id,
77
+ id: randomUUID(),
78
+ });
79
+ }
80
+ else {
81
+ this.#errors.next({
82
+ error: new ThymianBaseError(`Error while calling event handler for event "${event.name}" from "${event.source}".`, { cause: e }),
83
+ name,
84
+ timestamp: Date.now(),
85
+ source: this.source,
86
+ correlationId: event.id,
87
+ id: randomUUID(),
88
+ });
89
+ }
90
+ }
91
+ });
92
+ }
93
+ emit(name, payload) {
94
+ this.#events.next({
95
+ id: randomUUID(),
96
+ name,
97
+ payload,
98
+ timestamp: Date.now(),
99
+ source: this.source,
100
+ });
101
+ }
102
+ emitError(err, name = '') {
103
+ let error;
104
+ if (err instanceof ThymianBaseError) {
105
+ error = err;
106
+ }
107
+ else if (isThymianError(err)) {
108
+ error = new ThymianBaseError(err.message, {
109
+ ...err.options,
110
+ name: err.name,
111
+ });
112
+ }
113
+ else {
114
+ error = new ThymianBaseError(`Error while emitting error event from "${this.source}".`, { cause: err });
115
+ }
116
+ this.#errors.next({
117
+ error,
118
+ id: randomUUID(),
119
+ name: name,
120
+ source: this.source,
121
+ timestamp: Date.now(),
122
+ });
123
+ }
124
+ onAction(name, handler) {
125
+ this.#listeners.set(name, (this.#listeners.get(name) ?? 0) + 1);
126
+ this.#events
127
+ .pipe(filter(isActionEventWithName(name)))
128
+ .subscribe(async (event) => {
129
+ const ctx = this.createActionContext(name, event.id);
130
+ try {
131
+ await handler(event.payload, ctx);
132
+ }
133
+ catch (e) {
134
+ if (e instanceof ThymianBaseError) {
135
+ this.#errors.next({
136
+ correlationId: event.id,
137
+ id: randomUUID(),
138
+ error: e,
139
+ name,
140
+ timestamp: Date.now(),
141
+ source: this.source,
142
+ });
143
+ }
144
+ else if (isThymianError(e)) {
145
+ const error = new ThymianBaseError(e.message, {
146
+ ...e.options,
147
+ name: e.name,
148
+ });
149
+ this.#errors.next({
150
+ error,
151
+ name,
152
+ correlationId: event.id,
153
+ timestamp: Date.now(),
154
+ source: this.source,
155
+ id: randomUUID(),
156
+ });
157
+ }
158
+ else {
159
+ this.#errors.next({
160
+ error: new ThymianBaseError(`Error while calling action handler for action "${event.name}" from "${event.source}".`, { cause: e }),
161
+ name,
162
+ correlationId: event.id,
163
+ id: randomUUID(),
164
+ timestamp: Date.now(),
165
+ source: this.source,
166
+ });
167
+ }
168
+ }
169
+ });
170
+ }
171
+ async emitAction(...args) {
172
+ const [name, payload, options] = args;
173
+ const opts = {
174
+ timeout: this.options.timeout,
175
+ strategy: 'collect',
176
+ ...(options ?? {}),
177
+ };
178
+ const event = {
179
+ id: randomUUID(),
180
+ name,
181
+ payload,
182
+ timestamp: Date.now(),
183
+ source: this.source,
184
+ };
185
+ const numOfListeners = this.#listeners.get(name) ?? 0;
186
+ const takeNum = opts.strategy === 'first' ? 1 : numOfListeners;
187
+ const responsesAndErrors = merge(this.#responses.pipe(filter(isResponseOf(name, event.id))),
188
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
189
+ // @ts-expect-error
190
+ this.#errors.pipe(filter(isResponseOf(name, event.id)))).pipe(takeUntil(timer(opts.timeout)), take(takeNum), toArray());
191
+ queueMicrotask(() => {
192
+ this.#events.next(event);
193
+ });
194
+ const results = (await firstValueFrom(responsesAndErrors));
195
+ const errors = results.filter((r) => Object.hasOwn(r, 'error'));
196
+ if (errors.length > 0 && typeof errors[0] !== 'undefined') {
197
+ this.logger.error(`Received ${errors.length} error event${errors.length > 1 ? 's' : ''} from ${errors
198
+ .map((err) => `"${err.source}"`)
199
+ .join(', ')} while waiting for response event(s) for event "${name}".`);
200
+ const { error } = errors[0];
201
+ if (error instanceof ThymianBaseError) {
202
+ throw error;
203
+ }
204
+ else {
205
+ throw new ThymianBaseError(error.message, error.options);
206
+ }
207
+ }
208
+ if (opts.strategy !== 'first' && results.length !== numOfListeners) {
209
+ this.logger.debug(`Expected ${numOfListeners} response events for event "${name}" but got ${results.length}.`);
210
+ }
211
+ const payloads = results
212
+ .map((msg) => msg.payload)
213
+ .filter(Boolean);
214
+ this.#completed.add(event.id);
215
+ switch (opts.strategy) {
216
+ case 'first':
217
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
218
+ // @ts-expect-error
219
+ return payloads[0];
220
+ case 'collect':
221
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
222
+ // @ts-expect-error
223
+ return payloads;
224
+ case 'deep-merge':
225
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
226
+ // @ts-expect-error
227
+ return dm(...payloads);
228
+ }
229
+ }
230
+ child(source) {
231
+ return new ThymianEmitter(this.logger.child(source), {
232
+ completed: this.#completed,
233
+ errors: this.#errors,
234
+ events: this.#events,
235
+ listeners: this.#listeners,
236
+ responses: this.#responses,
237
+ source,
238
+ }, {
239
+ ...this.options,
240
+ // we only have to listen to all events once
241
+ traceEvents: false,
242
+ });
243
+ }
244
+ createActionContext(name, correlationId) {
245
+ return {
246
+ error: (error) => {
247
+ if (error instanceof ThymianBaseError) {
248
+ this.#errors.next({
249
+ correlationId,
250
+ id: randomUUID(),
251
+ error: error,
252
+ name,
253
+ timestamp: Date.now(),
254
+ source: this.source,
255
+ });
256
+ }
257
+ else if (isThymianError(error)) {
258
+ const thymianError = new ThymianBaseError(error.message, {
259
+ ...error.options,
260
+ name: error.name,
261
+ });
262
+ this.#errors.next({
263
+ error: thymianError,
264
+ name,
265
+ correlationId,
266
+ id: randomUUID(),
267
+ timestamp: Date.now(),
268
+ source: this.source,
269
+ });
270
+ }
271
+ else {
272
+ this.#errors.next({
273
+ error: new ThymianBaseError(`Error while calling action handler for action "${name}".`, { cause: error }),
274
+ name,
275
+ correlationId,
276
+ id: randomUUID(),
277
+ timestamp: Date.now(),
278
+ source: this.source,
279
+ });
280
+ }
281
+ },
282
+ reply: (payload) => {
283
+ this.#responses.next({
284
+ correlationId,
285
+ name,
286
+ payload,
287
+ timestamp: Date.now(),
288
+ source: this.source,
289
+ id: randomUUID(),
290
+ });
291
+ },
292
+ };
293
+ }
294
+ onError(fn) {
295
+ this.#errors.subscribe(fn);
296
+ }
297
+ logEvent(type) {
298
+ return (event) => {
299
+ this.logger.trace(`${chalk.bold(event.source)} with ${type} ${chalk.bold(event.name)} at ${new Date(event.timestamp)
300
+ .toISOString()
301
+ .replace('T', ' ')
302
+ .replace('Z', '')}`);
303
+ };
304
+ }
305
+ }
306
+ //# sourceMappingURL=thymian-emitter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"thymian-emitter.js","sourceRoot":"","sources":["../../src/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C,SAAS,CAAC;iBAC9B,WAAW,EAAE;iBACb,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC;iBACjB,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,CACtB,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { ThymianActionName } from '../actions/index.js';
2
+ import type { ThymianEventName } from '../events/index.js';
3
+ import type { ThymianActionEvent, ThymianResponseEvent } from './action-event.js';
4
+ import type { ThymianEvent } from './events.js';
5
+ export declare function isEventWithName<Name extends ThymianEventName>(name: Name): (event: ThymianEvent<ThymianEventName> | ThymianActionEvent<ThymianActionName>) => event is ThymianEvent<Name>;
6
+ export declare function isActionEventWithName<Name extends ThymianActionName>(name: Name): (event: ThymianEvent<ThymianEventName> | ThymianActionEvent<ThymianActionName>) => event is ThymianActionEvent<Name>;
7
+ export declare function isResponseOf<Name extends ThymianActionName>(name: Name, cid: string): (event: ThymianResponseEvent<ThymianActionName>) => event is ThymianResponseEvent<Name>;
8
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/emitter/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EACV,kBAAkB,EAClB,oBAAoB,EACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,wBAAgB,eAAe,CAAC,IAAI,SAAS,gBAAgB,EAC3D,IAAI,EAAE,IAAI,GACT,CACD,KAAK,EAAE,YAAY,CAAC,gBAAgB,CAAC,GAAG,kBAAkB,CAAC,iBAAiB,CAAC,KAC1E,KAAK,IAAI,YAAY,CAAC,IAAI,CAAC,CAQ/B;AAED,wBAAgB,qBAAqB,CAAC,IAAI,SAAS,iBAAiB,EAClE,IAAI,EAAE,IAAI,GACT,CACD,KAAK,EAAE,YAAY,CAAC,gBAAgB,CAAC,GAAG,kBAAkB,CAAC,iBAAiB,CAAC,KAC1E,KAAK,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAQrC;AAED,wBAAgB,YAAY,CAAC,IAAI,SAAS,iBAAiB,EACzD,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,MAAM,GACV,CACD,KAAK,EAAE,oBAAoB,CAAC,iBAAiB,CAAC,KAC3C,KAAK,IAAI,oBAAoB,CAAC,IAAI,CAAC,CAMvC"}
@@ -0,0 +1,16 @@
1
+ export function isEventWithName(name) {
2
+ return function (event) {
3
+ return event.name === name; // && !Object.hasOwn(event, 'correlationId'); TODO: is the correlationId needed?
4
+ };
5
+ }
6
+ export function isActionEventWithName(name) {
7
+ return function (event) {
8
+ return event.name === name;
9
+ };
10
+ }
11
+ export function isResponseOf(name, cid) {
12
+ return function (event) {
13
+ return event.name === name && event.correlationId === cid;
14
+ };
15
+ }
16
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/emitter/utils.ts"],"names":[],"mappings":"AAQA,MAAM,UAAU,eAAe,CAC7B,IAAU;IAIV,OAAO,UACL,KAEyC;QAEzC,OAAO,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,gFAAgF;IAC9G,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,IAAU;IAIV,OAAO,UACL,KAEyC;QAEzC,OAAO,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC;IAC7B,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,YAAY,CAC1B,IAAU,EACV,GAAW;IAIX,OAAO,UACL,KAA8C;QAE9C,OAAO,KAAK,CAAC,IAAI,KAAK,IAAI,IAAI,KAAK,CAAC,aAAa,KAAK,GAAG,CAAC;IAC5D,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { JSONSchemaType } from 'ajv/dist/2020.js';
2
+ import type { ThymianBaseError } from '../thymian.error.js';
3
+ export type ErrorEvent = ThymianBaseError;
4
+ export declare const errorEventSchema: JSONSchemaType<ThymianBaseError>;
5
+ //# sourceMappingURL=error.event.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.event.d.ts","sourceRoot":"","sources":["../../src/events/error.event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,MAAM,MAAM,UAAU,GAAG,gBAAgB,CAAC;AAE1C,eAAO,MAAM,gBAAgB,EAAE,cAAc,CAAC,gBAAgB,CA+C7D,CAAC"}
@@ -0,0 +1,49 @@
1
+ export const errorEventSchema = {
2
+ // TODO
3
+ anyOf: [],
4
+ oneOf: [],
5
+ type: 'object',
6
+ required: ['name', 'message', 'exitCode', 'options'],
7
+ properties: {
8
+ exitCode: { type: 'number' },
9
+ message: { type: 'string', nullable: false },
10
+ causingError: { type: 'object', required: [], nullable: true },
11
+ stack: { type: 'string', nullable: true },
12
+ name: { type: 'string', nullable: false },
13
+ cause: { type: 'object', nullable: true },
14
+ options: {
15
+ nullable: false,
16
+ type: 'object',
17
+ properties: {
18
+ exitCode: {
19
+ type: 'number',
20
+ nullable: true,
21
+ },
22
+ suggestions: {
23
+ type: 'array',
24
+ items: { type: 'string' },
25
+ nullable: true,
26
+ },
27
+ ref: {
28
+ type: 'string',
29
+ nullable: true,
30
+ },
31
+ code: {
32
+ type: 'string',
33
+ nullable: true,
34
+ },
35
+ name: {
36
+ type: 'string',
37
+ nullable: true,
38
+ },
39
+ severity: {
40
+ type: 'string',
41
+ enum: ['info', 'warn', 'error'],
42
+ nullable: false,
43
+ },
44
+ },
45
+ required: ['severity'],
46
+ },
47
+ },
48
+ };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ACJ,IAAI,EAAE,QAAQ;oBACd,QAAQ,EAAE,IAAI;iBACf;gBACD,QAAQ,EAAE;oBACR,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC;oBAC/B,QAAQ,EAAE,KAAK;iBAChB;aACF;YACD,QAAQ,EAAE,CAAC,UAAU,CAAC;SACvB;KACF;CACF,CAAC"}
@@ -0,0 +1,14 @@
1
+ export type ExitEvent = {
2
+ code?: number;
3
+ };
4
+ export declare const ExitEventSchema: {
5
+ readonly type: "object";
6
+ readonly required: readonly ["code"];
7
+ readonly properties: {
8
+ readonly code: {
9
+ readonly type: "integer";
10
+ };
11
+ };
12
+ readonly additionalProperties: false;
13
+ };
14
+ //# sourceMappingURL=exit.event.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exit.event.d.ts","sourceRoot":"","sources":["../../src/events/exit.event.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,eAAe;;;;;;;;;CAOlB,CAAC"}
@@ -0,0 +1,9 @@
1
+ export const ExitEventSchema = {
2
+ type: 'object',
3
+ required: ['code'],
4
+ properties: {
5
+ code: { type: 'integer' },
6
+ },
7
+ additionalProperties: false,
8
+ };
9
+ //# sourceMappingURL=exit.event.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exit.event.js","sourceRoot":"","sources":["../../src/events/exit.event.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,CAAC,MAAM,CAAC;IAClB,UAAU,EAAE;QACV,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;KAC1B;IACD,oBAAoB,EAAE,KAAK;CACnB,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { ThymianError } from '../thymian.error.js';
2
+ import type { ExitEvent } from './exit.event.js';
3
+ import type { RegisterPluginEvent } from './register-plugin.event.js';
4
+ import type { ReportEvent } from './report.event.js';
5
+ export interface ThymianEvents {
6
+ 'core.error': ThymianError;
7
+ 'core.register': RegisterPluginEvent;
8
+ 'core.report': ReportEvent;
9
+ 'core.exit': ExitEvent;
10
+ }
11
+ export type ThymianEventName = keyof ThymianEvents;
12
+ export * from './error.event.js';
13
+ export * from './register-plugin.event.js';
14
+ export * from './report.event.js';
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/events/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,MAAM,WAAW,aAAa;IAC5B,YAAY,EAAE,YAAY,CAAC;IAC3B,eAAe,EAAE,mBAAmB,CAAC;IACrC,aAAa,EAAE,WAAW,CAAC;IAC3B,WAAW,EAAE,SAAS,CAAC;CACxB;AAED,MAAM,MAAM,gBAAgB,GAAG,MAAM,aAAa,CAAC;AAEnD,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './error.event.js';
2
+ export * from './register-plugin.event.js';
3
+ export * from './report.event.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/events/index.ts"],"names":[],"mappings":"AAcA,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC"}
@@ -0,0 +1,51 @@
1
+ import type { ThymianPluginEvents } from '../thymian-plugin.js';
2
+ export type RegisterPluginEvent = {
3
+ name: string;
4
+ options: unknown;
5
+ events: ThymianPluginEvents;
6
+ };
7
+ export declare const RegisterPluginEventSchema: {
8
+ readonly type: "object";
9
+ readonly required: readonly ["name", "options", "events", "hooks"];
10
+ readonly properties: {
11
+ readonly name: {
12
+ readonly type: "string";
13
+ };
14
+ readonly options: {};
15
+ readonly events: {
16
+ readonly type: "object";
17
+ readonly properties: {
18
+ readonly emits: {
19
+ readonly type: "object";
20
+ readonly additionalProperties: true;
21
+ };
22
+ readonly listens: {
23
+ readonly type: "array";
24
+ readonly items: {
25
+ readonly type: "string";
26
+ };
27
+ };
28
+ };
29
+ readonly additionalProperties: false;
30
+ };
31
+ readonly hooks: {
32
+ readonly type: "object";
33
+ readonly additionalProperties: {
34
+ readonly type: "object";
35
+ readonly properties: {
36
+ readonly input: {
37
+ readonly type: "object";
38
+ readonly additionalProperties: true;
39
+ };
40
+ readonly output: {
41
+ readonly type: "object";
42
+ readonly additionalProperties: true;
43
+ };
44
+ };
45
+ readonly additionalProperties: false;
46
+ };
47
+ };
48
+ };
49
+ readonly additionalProperties: false;
50
+ };
51
+ //# sourceMappingURL=register-plugin.event.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register-plugin.event.d.ts","sourceRoot":"","sources":["../../src/events/register-plugin.event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,mBAAmB,CAAC;CAC7B,CAAC;AAEF,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2B5B,CAAC"}
@@ -0,0 +1,29 @@
1
+ export const RegisterPluginEventSchema = {
2
+ type: 'object',
3
+ required: ['name', 'options', 'events', 'hooks'],
4
+ properties: {
5
+ name: { type: 'string' },
6
+ options: {},
7
+ events: {
8
+ type: 'object',
9
+ properties: {
10
+ emits: { type: 'object', additionalProperties: true },
11
+ listens: { type: 'array', items: { type: 'string' } },
12
+ },
13
+ additionalProperties: false,
14
+ },
15
+ hooks: {
16
+ type: 'object',
17
+ additionalProperties: {
18
+ type: 'object',
19
+ properties: {
20
+ input: { type: 'object', additionalProperties: true },
21
+ output: { type: 'object', additionalProperties: true },
22
+ },
23
+ additionalProperties: false,
24
+ },
25
+ },
26
+ },
27
+ additionalProperties: false,
28
+ };
29
+ //# sourceMappingURL=register-plugin.event.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register-plugin.event.js","sourceRoot":"","sources":["../../src/events/register-plugin.event.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,CAAC;IAChD,UAAU,EAAE;QACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACxB,OAAO,EAAE,EAAE;QACX,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,oBAAoB,EAAE,IAAI,EAAE;gBACrD,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;aACtD;YACD,oBAAoB,EAAE,KAAK;SAC5B;QACD,KAAK,EAAE;YACL,IAAI,EAAE,QAAQ;YACd,oBAAoB,EAAE;gBACpB,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,oBAAoB,EAAE,IAAI,EAAE;oBACrD,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,oBAAoB,EAAE,IAAI,EAAE;iBACvD;gBACD,oBAAoB,EAAE,KAAK;aAC5B;SACF;KACF;IACD,oBAAoB,EAAE,KAAK;CACnB,CAAC"}
@@ -0,0 +1,28 @@
1
+ import type { JSONSchemaType } from 'ajv/dist/2020.js';
2
+ import type { ThymianFormatLocation } from '../format/index.js';
3
+ export type ThymianReportSeverity = 'info' | 'hint' | 'warn' | 'error';
4
+ export interface ThymianReport {
5
+ producer: string;
6
+ source?: string;
7
+ severity: ThymianReportSeverity;
8
+ summary: string;
9
+ title: string;
10
+ links?: {
11
+ title?: string;
12
+ url: string;
13
+ }[];
14
+ timestamp?: number;
15
+ details?: string;
16
+ category?: string | 'No Category';
17
+ location?: {
18
+ reference?: ThymianFormatLocation;
19
+ format?: {
20
+ elementType: 'node' | 'edge';
21
+ id: string;
22
+ };
23
+ };
24
+ }
25
+ export type ReportFn = (report: ThymianReport) => void;
26
+ export type ReportEvent = ThymianReport;
27
+ export declare const thymianReportSchema: JSONSchemaType<ReportEvent>;
28
+ //# sourceMappingURL=report.event.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"report.event.d.ts","sourceRoot":"","sources":["../../src/events/report.event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAEhE,MAAM,MAAM,qBAAqB,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAEvE,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,qBAAqB,CAAC;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,GAAG,aAAa,CAAC;IAClC,QAAQ,CAAC,EAAE;QACT,SAAS,CAAC,EAAE,qBAAqB,CAAC;QAClC,MAAM,CAAC,EAAE;YACP,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC;YAC7B,EAAE,EAAE,MAAM,CAAC;SACZ,CAAC;KACH,CAAC;CACH;AAED,MAAM,MAAM,QAAQ,GAAG,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;AAEvD,MAAM,MAAM,WAAW,GAAG,aAAa,CAAC;AAExC,eAAO,MAAM,mBAAmB,EAAE,cAAc,CAAC,WAAW,CA8H3D,CAAC"}