@venizia/ignis-helpers 0.4.6 → 0.4.7-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 (300) hide show
  1. package/LICENSE.md +1 -3
  2. package/README.md +4 -5
  3. package/dist/esm/common/redact.d.ts +25 -17
  4. package/dist/esm/common/redact.d.ts.map +1 -1
  5. package/dist/esm/common/redact.js +50 -46
  6. package/dist/esm/common/redact.js.map +1 -1
  7. package/dist/esm/common/resolvers.d.ts +7 -5
  8. package/dist/esm/common/resolvers.d.ts.map +1 -1
  9. package/dist/esm/common/resolvers.js +11 -9
  10. package/dist/esm/common/resolvers.js.map +1 -1
  11. package/dist/esm/core.d.ts +6 -3
  12. package/dist/esm/core.d.ts.map +1 -1
  13. package/dist/esm/core.js +6 -3
  14. package/dist/esm/core.js.map +1 -1
  15. package/dist/esm/modules/base.js +4 -4
  16. package/dist/esm/modules/base.js.map +1 -1
  17. package/dist/esm/modules/cron/helper.js +4 -4
  18. package/dist/esm/modules/cron/helper.js.map +1 -1
  19. package/dist/esm/modules/crypto/algorithms/aes-legacy.algorithm.js +3 -3
  20. package/dist/esm/modules/crypto/algorithms/aes-legacy.algorithm.js.map +1 -1
  21. package/dist/esm/modules/crypto/algorithms/aes.algorithm.js +5 -5
  22. package/dist/esm/modules/crypto/algorithms/aes.algorithm.js.map +1 -1
  23. package/dist/esm/modules/crypto/algorithms/base.algorithm.js +3 -3
  24. package/dist/esm/modules/crypto/algorithms/base.algorithm.js.map +1 -1
  25. package/dist/esm/modules/env/app-env.d.ts.map +1 -1
  26. package/dist/esm/modules/env/app-env.js +2 -2
  27. package/dist/esm/modules/env/app-env.js.map +1 -1
  28. package/dist/esm/modules/logger/common/constants.d.ts +23 -21
  29. package/dist/esm/modules/logger/common/constants.d.ts.map +1 -1
  30. package/dist/esm/modules/logger/common/constants.js +45 -42
  31. package/dist/esm/modules/logger/common/constants.js.map +1 -1
  32. package/dist/esm/modules/logger/factory.d.ts +5 -3
  33. package/dist/esm/modules/logger/factory.d.ts.map +1 -1
  34. package/dist/esm/modules/logger/factory.js +5 -3
  35. package/dist/esm/modules/logger/factory.js.map +1 -1
  36. package/dist/esm/modules/logger/formatting/deep-splat.d.ts +10 -6
  37. package/dist/esm/modules/logger/formatting/deep-splat.d.ts.map +1 -1
  38. package/dist/esm/modules/logger/formatting/deep-splat.js +73 -62
  39. package/dist/esm/modules/logger/formatting/deep-splat.js.map +1 -1
  40. package/dist/esm/modules/logger/formatting/error-prettier.d.ts.map +1 -1
  41. package/dist/esm/modules/logger/formatting/error-prettier.js +8 -6
  42. package/dist/esm/modules/logger/formatting/error-prettier.js.map +1 -1
  43. package/dist/esm/modules/logger/hf/logger.d.ts.map +1 -1
  44. package/dist/esm/modules/logger/hf/logger.js +2 -2
  45. package/dist/esm/modules/logger/hf/logger.js.map +1 -1
  46. package/dist/esm/modules/logger/pino/backing.d.ts +0 -9
  47. package/dist/esm/modules/logger/pino/backing.d.ts.map +1 -1
  48. package/dist/esm/modules/logger/pino/backing.js +3 -8
  49. package/dist/esm/modules/logger/pino/backing.js.map +1 -1
  50. package/dist/esm/modules/logger/pino/destination.d.ts +6 -9
  51. package/dist/esm/modules/logger/pino/destination.d.ts.map +1 -1
  52. package/dist/esm/modules/logger/pino/destination.js +12 -13
  53. package/dist/esm/modules/logger/pino/destination.js.map +1 -1
  54. package/dist/esm/modules/logger/pino/logger.js +2 -2
  55. package/dist/esm/modules/logger/pino/logger.js.map +1 -1
  56. package/dist/esm/modules/logger/resolver.js +2 -2
  57. package/dist/esm/modules/logger/resolver.js.map +1 -1
  58. package/dist/esm/modules/logger/slot.d.ts +39 -18
  59. package/dist/esm/modules/logger/slot.d.ts.map +1 -1
  60. package/dist/esm/modules/logger/slot.js +117 -110
  61. package/dist/esm/modules/logger/slot.js.map +1 -1
  62. package/dist/esm/modules/logger/winston/common/constants.d.ts.map +1 -1
  63. package/dist/esm/modules/logger/winston/common/constants.js +7 -6
  64. package/dist/esm/modules/logger/winston/common/constants.js.map +1 -1
  65. package/dist/esm/modules/logger/winston/define.d.ts +0 -7
  66. package/dist/esm/modules/logger/winston/define.d.ts.map +1 -1
  67. package/dist/esm/modules/logger/winston/define.js +0 -5
  68. package/dist/esm/modules/logger/winston/define.js.map +1 -1
  69. package/dist/esm/modules/logger/winston/formats.d.ts +2 -0
  70. package/dist/esm/modules/logger/winston/formats.d.ts.map +1 -1
  71. package/dist/esm/modules/logger/winston/formats.js +17 -4
  72. package/dist/esm/modules/logger/winston/formats.js.map +1 -1
  73. package/dist/esm/modules/logger/winston/index.d.ts +3 -2
  74. package/dist/esm/modules/logger/winston/index.d.ts.map +1 -1
  75. package/dist/esm/modules/logger/winston/index.js +3 -2
  76. package/dist/esm/modules/logger/winston/index.js.map +1 -1
  77. package/dist/esm/modules/logger/winston/logger-factory.js +4 -4
  78. package/dist/esm/modules/logger/winston/logger-factory.js.map +1 -1
  79. package/dist/esm/modules/network/http-request/base-network-request.helper.js +2 -2
  80. package/dist/esm/modules/network/http-request/base-network-request.helper.js.map +1 -1
  81. package/dist/esm/modules/network/http-request/common/index.d.ts +0 -1
  82. package/dist/esm/modules/network/http-request/common/index.d.ts.map +1 -1
  83. package/dist/esm/modules/network/http-request/common/index.js +0 -1
  84. package/dist/esm/modules/network/http-request/common/index.js.map +1 -1
  85. package/dist/esm/modules/network/http-request/fetcher/axios-fetcher.d.ts.map +1 -1
  86. package/dist/esm/modules/network/http-request/fetcher/axios-fetcher.js +4 -2
  87. package/dist/esm/modules/network/http-request/fetcher/axios-fetcher.js.map +1 -1
  88. package/dist/esm/modules/network/http-request/fetcher/node-fetcher.d.ts.map +1 -1
  89. package/dist/esm/modules/network/http-request/fetcher/node-fetcher.js +6 -4
  90. package/dist/esm/modules/network/http-request/fetcher/node-fetcher.js.map +1 -1
  91. package/dist/esm/modules/network/tcp-socket/base-tcp-client.helper.js +4 -4
  92. package/dist/esm/modules/network/tcp-socket/base-tcp-client.helper.js.map +1 -1
  93. package/dist/esm/modules/network/tcp-socket/base-tcp-server.helper.js +4 -4
  94. package/dist/esm/modules/network/tcp-socket/base-tcp-server.helper.js.map +1 -1
  95. package/dist/esm/modules/network/udp-socket/network-udp-client.helper.js +2 -2
  96. package/dist/esm/modules/network/udp-socket/network-udp-client.helper.js.map +1 -1
  97. package/dist/esm/modules/network/utilities/query-string.d.ts +22 -20
  98. package/dist/esm/modules/network/utilities/query-string.d.ts.map +1 -1
  99. package/dist/esm/modules/network/utilities/query-string.js +48 -46
  100. package/dist/esm/modules/network/utilities/query-string.js.map +1 -1
  101. package/dist/esm/modules/network/utilities/url-safety/common/errors.d.ts +0 -10
  102. package/dist/esm/modules/network/utilities/url-safety/common/errors.d.ts.map +1 -1
  103. package/dist/esm/modules/network/utilities/url-safety/common/errors.js +0 -11
  104. package/dist/esm/modules/network/utilities/url-safety/common/errors.js.map +1 -1
  105. package/dist/esm/modules/network/utilities/url-safety/ingest.d.ts.map +1 -1
  106. package/dist/esm/modules/network/utilities/url-safety/ingest.js +2 -1
  107. package/dist/esm/modules/network/utilities/url-safety/ingest.js.map +1 -1
  108. package/dist/esm/modules/network/utilities/url-safety/policy.d.ts +10 -0
  109. package/dist/esm/modules/network/utilities/url-safety/policy.d.ts.map +1 -1
  110. package/dist/esm/modules/network/utilities/url-safety/policy.js +11 -0
  111. package/dist/esm/modules/network/utilities/url-safety/policy.js.map +1 -1
  112. package/dist/esm/modules/pool/abstract.d.ts.map +1 -1
  113. package/dist/esm/modules/pool/abstract.js +4 -2
  114. package/dist/esm/modules/pool/abstract.js.map +1 -1
  115. package/dist/esm/modules/queue/bullmq/helper.d.ts.map +1 -1
  116. package/dist/esm/modules/queue/bullmq/helper.js +6 -6
  117. package/dist/esm/modules/queue/bullmq/helper.js.map +1 -1
  118. package/dist/esm/modules/queue/common/hook.d.ts +14 -12
  119. package/dist/esm/modules/queue/common/hook.d.ts.map +1 -1
  120. package/dist/esm/modules/queue/common/hook.js +21 -19
  121. package/dist/esm/modules/queue/common/hook.js.map +1 -1
  122. package/dist/esm/modules/queue/common/index.d.ts +0 -1
  123. package/dist/esm/modules/queue/common/index.d.ts.map +1 -1
  124. package/dist/esm/modules/queue/common/index.js +0 -1
  125. package/dist/esm/modules/queue/common/index.js.map +1 -1
  126. package/dist/esm/modules/queue/internal/sequential/helper.js +8 -8
  127. package/dist/esm/modules/queue/internal/sequential/helper.js.map +1 -1
  128. package/dist/esm/modules/queue/kafka/base.js +3 -3
  129. package/dist/esm/modules/queue/kafka/base.js.map +1 -1
  130. package/dist/esm/modules/queue/kafka/bundler/index.d.ts +0 -2
  131. package/dist/esm/modules/queue/kafka/bundler/index.d.ts.map +1 -1
  132. package/dist/esm/modules/queue/kafka/bundler/index.js +0 -2
  133. package/dist/esm/modules/queue/kafka/bundler/index.js.map +1 -1
  134. package/dist/esm/modules/queue/kafka/bundler/plugins.d.ts +8 -2
  135. package/dist/esm/modules/queue/kafka/bundler/plugins.d.ts.map +1 -1
  136. package/dist/esm/modules/queue/kafka/bundler/plugins.js +64 -7
  137. package/dist/esm/modules/queue/kafka/bundler/plugins.js.map +1 -1
  138. package/dist/esm/modules/queue/kafka/consumer.d.ts.map +1 -1
  139. package/dist/esm/modules/queue/kafka/consumer.js +26 -24
  140. package/dist/esm/modules/queue/kafka/consumer.js.map +1 -1
  141. package/dist/esm/modules/queue/mqtt/helper.js +10 -10
  142. package/dist/esm/modules/queue/mqtt/helper.js.map +1 -1
  143. package/dist/esm/modules/redis/base/abstract.helper.js +8 -8
  144. package/dist/esm/modules/redis/base/abstract.helper.js.map +1 -1
  145. package/dist/esm/modules/redis/cluster/cluster.helper.js +2 -2
  146. package/dist/esm/modules/redis/cluster/cluster.helper.js.map +1 -1
  147. package/dist/esm/modules/redis/factory.d.ts +13 -9
  148. package/dist/esm/modules/redis/factory.d.ts.map +1 -1
  149. package/dist/esm/modules/redis/factory.js +15 -13
  150. package/dist/esm/modules/redis/factory.js.map +1 -1
  151. package/dist/esm/modules/redis/sentinel/sentinel.helper.js +2 -2
  152. package/dist/esm/modules/redis/sentinel/sentinel.helper.js.map +1 -1
  153. package/dist/esm/modules/redis/single/single.helper.js +2 -2
  154. package/dist/esm/modules/redis/single/single.helper.js.map +1 -1
  155. package/dist/esm/modules/redis/utility.d.ts +13 -11
  156. package/dist/esm/modules/redis/utility.d.ts.map +1 -1
  157. package/dist/esm/modules/redis/utility.js +46 -44
  158. package/dist/esm/modules/redis/utility.js.map +1 -1
  159. package/dist/esm/modules/retry/helper.d.ts.map +1 -1
  160. package/dist/esm/modules/retry/helper.js +6 -4
  161. package/dist/esm/modules/retry/helper.js.map +1 -1
  162. package/dist/esm/modules/secrets/factory.d.ts +5 -3
  163. package/dist/esm/modules/secrets/factory.d.ts.map +1 -1
  164. package/dist/esm/modules/secrets/factory.js +36 -34
  165. package/dist/esm/modules/secrets/factory.js.map +1 -1
  166. package/dist/esm/modules/secrets/hashicorp/hashicorp.helper.d.ts.map +1 -1
  167. package/dist/esm/modules/secrets/hashicorp/hashicorp.helper.js +4 -2
  168. package/dist/esm/modules/secrets/hashicorp/hashicorp.helper.js.map +1 -1
  169. package/dist/esm/modules/socket/socket-io/server/helper.d.ts.map +1 -1
  170. package/dist/esm/modules/socket/socket-io/server/helper.js +11 -11
  171. package/dist/esm/modules/socket/socket-io/server/helper.js.map +1 -1
  172. package/dist/esm/modules/socket/websocket/emitter/helper.d.ts.map +1 -1
  173. package/dist/esm/modules/socket/websocket/emitter/helper.js +3 -3
  174. package/dist/esm/modules/socket/websocket/emitter/helper.js.map +1 -1
  175. package/dist/esm/modules/socket/websocket/server/delivery.d.ts.map +1 -1
  176. package/dist/esm/modules/socket/websocket/server/delivery.js +5 -6
  177. package/dist/esm/modules/socket/websocket/server/delivery.js.map +1 -1
  178. package/dist/esm/modules/socket/websocket/server/helper.d.ts.map +1 -1
  179. package/dist/esm/modules/socket/websocket/server/helper.js +7 -7
  180. package/dist/esm/modules/socket/websocket/server/helper.js.map +1 -1
  181. package/dist/esm/modules/storage/base.d.ts.map +1 -1
  182. package/dist/esm/modules/storage/base.js +9 -8
  183. package/dist/esm/modules/storage/base.js.map +1 -1
  184. package/dist/esm/modules/storage/bun-s3/helper.d.ts.map +1 -1
  185. package/dist/esm/modules/storage/bun-s3/helper.js +25 -18
  186. package/dist/esm/modules/storage/bun-s3/helper.js.map +1 -1
  187. package/dist/esm/modules/storage/bun-s3/utility.d.ts +95 -77
  188. package/dist/esm/modules/storage/bun-s3/utility.d.ts.map +1 -1
  189. package/dist/esm/modules/storage/bun-s3/utility.js +261 -244
  190. package/dist/esm/modules/storage/bun-s3/utility.js.map +1 -1
  191. package/dist/esm/modules/storage/common/errors.d.ts +0 -4
  192. package/dist/esm/modules/storage/common/errors.d.ts.map +1 -1
  193. package/dist/esm/modules/storage/common/errors.js +0 -10
  194. package/dist/esm/modules/storage/common/errors.js.map +1 -1
  195. package/dist/esm/modules/storage/common/utility.d.ts +11 -5
  196. package/dist/esm/modules/storage/common/utility.d.ts.map +1 -1
  197. package/dist/esm/modules/storage/common/utility.js +30 -17
  198. package/dist/esm/modules/storage/common/utility.js.map +1 -1
  199. package/dist/esm/modules/storage/disk/helper.d.ts.map +1 -1
  200. package/dist/esm/modules/storage/disk/helper.js +18 -9
  201. package/dist/esm/modules/storage/disk/helper.js.map +1 -1
  202. package/dist/esm/modules/tree/builder.d.ts.map +1 -1
  203. package/dist/esm/modules/tree/builder.js +2 -1
  204. package/dist/esm/modules/tree/builder.js.map +1 -1
  205. package/dist/esm/modules/uid/opaque.d.ts.map +1 -1
  206. package/dist/esm/modules/uid/opaque.js +4 -2
  207. package/dist/esm/modules/uid/opaque.js.map +1 -1
  208. package/dist/esm/modules/uid/uuid/helper.d.ts +1 -1
  209. package/dist/esm/modules/uid/uuid/helper.d.ts.map +1 -1
  210. package/dist/esm/modules/uid/uuid/helper.js +7 -7
  211. package/dist/esm/modules/uid/uuid/helper.js.map +1 -1
  212. package/dist/esm/modules/uid/uuid/v4.d.ts +11 -8
  213. package/dist/esm/modules/uid/uuid/v4.d.ts.map +1 -1
  214. package/dist/esm/modules/uid/uuid/v4.js +51 -46
  215. package/dist/esm/modules/uid/uuid/v4.js.map +1 -1
  216. package/dist/esm/modules/uid/uuid/v5.d.ts +17 -14
  217. package/dist/esm/modules/uid/uuid/v5.d.ts.map +1 -1
  218. package/dist/esm/modules/uid/uuid/v5.js +83 -78
  219. package/dist/esm/modules/uid/uuid/v5.js.map +1 -1
  220. package/dist/esm/modules/uid/uuid/v7.d.ts +15 -10
  221. package/dist/esm/modules/uid/uuid/v7.d.ts.map +1 -1
  222. package/dist/esm/modules/uid/uuid/v7.js +88 -79
  223. package/dist/esm/modules/uid/uuid/v7.js.map +1 -1
  224. package/dist/esm/modules/worker-thread/bus/base.js +2 -2
  225. package/dist/esm/modules/worker-thread/bus/base.js.map +1 -1
  226. package/dist/esm/modules/worker-thread/worker/base.d.ts.map +1 -1
  227. package/dist/esm/modules/worker-thread/worker/base.js +4 -3
  228. package/dist/esm/modules/worker-thread/worker/base.js.map +1 -1
  229. package/dist/esm/utilities/error.utility.d.ts +7 -0
  230. package/dist/esm/utilities/error.utility.d.ts.map +1 -0
  231. package/dist/esm/utilities/error.utility.js +9 -0
  232. package/dist/esm/utilities/error.utility.js.map +1 -0
  233. package/dist/esm/utilities/form-body.utility.d.ts +12 -10
  234. package/dist/esm/utilities/form-body.utility.d.ts.map +1 -1
  235. package/dist/esm/utilities/form-body.utility.js +19 -16
  236. package/dist/esm/utilities/form-body.utility.js.map +1 -1
  237. package/dist/esm/utilities/hr-time.utility.d.ts +7 -5
  238. package/dist/esm/utilities/hr-time.utility.d.ts.map +1 -1
  239. package/dist/esm/utilities/hr-time.utility.js +11 -9
  240. package/dist/esm/utilities/hr-time.utility.js.map +1 -1
  241. package/dist/esm/utilities/index.d.ts +2 -2
  242. package/dist/esm/utilities/index.d.ts.map +1 -1
  243. package/dist/esm/utilities/index.js +2 -2
  244. package/dist/esm/utilities/index.js.map +1 -1
  245. package/dist/esm/utilities/module.utility.d.ts.map +1 -1
  246. package/dist/esm/utilities/module.utility.js +4 -2
  247. package/dist/esm/utilities/module.utility.js.map +1 -1
  248. package/dist/esm/utilities/parse.utility.d.ts +89 -43
  249. package/dist/esm/utilities/parse.utility.d.ts.map +1 -1
  250. package/dist/esm/utilities/parse.utility.js +173 -141
  251. package/dist/esm/utilities/parse.utility.js.map +1 -1
  252. package/dist/esm/utilities/performance.utility.d.ts +15 -13
  253. package/dist/esm/utilities/performance.utility.d.ts.map +1 -1
  254. package/dist/esm/utilities/performance.utility.js +34 -29
  255. package/dist/esm/utilities/performance.utility.js.map +1 -1
  256. package/dist/esm/utilities/promise.utility.d.ts +20 -18
  257. package/dist/esm/utilities/promise.utility.d.ts.map +1 -1
  258. package/dist/esm/utilities/promise.utility.js +41 -51
  259. package/dist/esm/utilities/promise.utility.js.map +1 -1
  260. package/dist/esm/utilities/request.utility.d.ts +35 -29
  261. package/dist/esm/utilities/request.utility.d.ts.map +1 -1
  262. package/dist/esm/utilities/request.utility.js +117 -115
  263. package/dist/esm/utilities/request.utility.js.map +1 -1
  264. package/package.json +4 -15
  265. package/dist/esm/modules/logger/winston/formatters/deep-splat.d.ts +0 -4
  266. package/dist/esm/modules/logger/winston/formatters/deep-splat.d.ts.map +0 -1
  267. package/dist/esm/modules/logger/winston/formatters/deep-splat.js +0 -14
  268. package/dist/esm/modules/logger/winston/formatters/deep-splat.js.map +0 -1
  269. package/dist/esm/modules/logger/winston/formatters/index.d.ts +0 -2
  270. package/dist/esm/modules/logger/winston/formatters/index.d.ts.map +0 -1
  271. package/dist/esm/modules/logger/winston/formatters/index.js +0 -2
  272. package/dist/esm/modules/logger/winston/formatters/index.js.map +0 -1
  273. package/dist/esm/modules/network/http-request/common/types.d.ts +0 -2
  274. package/dist/esm/modules/network/http-request/common/types.d.ts.map +0 -1
  275. package/dist/esm/modules/network/http-request/common/types.js +0 -2
  276. package/dist/esm/modules/network/http-request/common/types.js.map +0 -1
  277. package/dist/esm/modules/queue/common/types.d.ts +0 -2
  278. package/dist/esm/modules/queue/common/types.d.ts.map +0 -1
  279. package/dist/esm/modules/queue/common/types.js +0 -2
  280. package/dist/esm/modules/queue/common/types.js.map +0 -1
  281. package/dist/esm/modules/queue/kafka/bundler/platformatic-require.plugin.d.ts +0 -4
  282. package/dist/esm/modules/queue/kafka/bundler/platformatic-require.plugin.d.ts.map +0 -1
  283. package/dist/esm/modules/queue/kafka/bundler/platformatic-require.plugin.js +0 -28
  284. package/dist/esm/modules/queue/kafka/bundler/platformatic-require.plugin.js.map +0 -1
  285. package/dist/esm/modules/queue/kafka/bundler/platformatic-wasm.plugin.d.ts +0 -4
  286. package/dist/esm/modules/queue/kafka/bundler/platformatic-wasm.plugin.d.ts.map +0 -1
  287. package/dist/esm/modules/queue/kafka/bundler/platformatic-wasm.plugin.js +0 -26
  288. package/dist/esm/modules/queue/kafka/bundler/platformatic-wasm.plugin.js.map +0 -1
  289. package/dist/esm/modules/storage/minio/helper.d.ts +0 -55
  290. package/dist/esm/modules/storage/minio/helper.d.ts.map +0 -1
  291. package/dist/esm/modules/storage/minio/helper.js +0 -176
  292. package/dist/esm/modules/storage/minio/helper.js.map +0 -1
  293. package/dist/esm/modules/storage/minio/index.d.ts +0 -2
  294. package/dist/esm/modules/storage/minio/index.d.ts.map +0 -1
  295. package/dist/esm/modules/storage/minio/index.js +0 -2
  296. package/dist/esm/modules/storage/minio/index.js.map +0 -1
  297. package/dist/esm/utilities/sleep.utility.d.ts +0 -2
  298. package/dist/esm/utilities/sleep.utility.d.ts.map +0 -1
  299. package/dist/esm/utilities/sleep.utility.js +0 -4
  300. package/dist/esm/utilities/sleep.utility.js.map +0 -1
@@ -1,11 +1,16 @@
1
- /**
2
- * Builds a v7 generator with its own clock state and counter. Never `Bun.randomUUIDv7`: it is
3
- * slower, and it reads `(encoding, timestamp)` from whatever it is called with.
4
- */
5
- export declare const createUuidV7: () => (() => string);
6
- /**
7
- * Mints a time-ordered UUID v7 - the default for a string primary key. Forwards no argument: the
8
- * shared slot may hold another helpers version's generator.
9
- */
10
- export declare const uuidV7: () => string;
1
+ export declare class UuidV7Generator {
2
+ /**
3
+ * Builds a v7 generator with its own clock state and counter. Never `Bun.randomUUIDv7`: it is
4
+ * slower, and it reads `(encoding, timestamp)` from whatever it is called with.
5
+ */
6
+ static create(): () => string;
7
+ /** The realm's one generator: the one in the shared slot when another copy of this module put it there, else a new one that fills the slot. */
8
+ private static resolveShared;
9
+ private static readonly shared;
10
+ /**
11
+ * Mints a time-ordered UUID v7 - the default for a string primary key. Forwards no argument: the
12
+ * shared slot may hold another helpers version's generator.
13
+ */
14
+ static generate(): string;
15
+ }
11
16
  //# sourceMappingURL=v7.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"v7.d.ts","sourceRoot":"","sources":["../../../../../src/modules/uid/uuid/v7.ts"],"names":[],"mappings":"AAWA;;;GAGG;AACH,eAAO,MAAM,YAAY,QAAO,CAAC,MAAM,MAAM,CA+E5C,CAAC;AAQF;;;GAGG;AACH,eAAO,MAAM,MAAM,QAAO,MAAsB,CAAC"}
1
+ {"version":3,"file":"v7.d.ts","sourceRoot":"","sources":["../../../../../src/modules/uid/uuid/v7.ts"],"names":[],"mappings":"AAWA,qBAAa,eAAe;IAC1B;;;OAGG;IACH,MAAM,CAAC,MAAM,IAAI,MAAM,MAAM;IAiF7B,+IAA+I;IAC/I,OAAO,CAAC,MAAM,CAAC,aAAa;IAU5B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAiD;IAE/E;;;OAGG;IACH,MAAM,CAAC,QAAQ,IAAI,MAAM;CAG1B"}
@@ -6,85 +6,94 @@ import { UUID_HEX_OCTETS } from './common/constants.js';
6
6
  const SHARED_SLOT = Symbol.for('@venizia/ignis-helpers:uuid-v7');
7
7
  const POOL_SIZE = 8 * 256;
8
8
  const MAX_COUNTER = 0xfff;
9
- /**
10
- * Builds a v7 generator with its own clock state and counter. Never `Bun.randomUUIDv7`: it is
11
- * slower, and it reads `(encoding, timestamp)` from whatever it is called with.
12
- */
13
- export const createUuidV7 = () => {
14
- const pool = new Uint8Array(POOL_SIZE);
15
- let offset = POOL_SIZE;
16
- let lastMs = -1;
17
- let counter = 0;
18
- let prefix = '';
19
- /** Draws a counter seed below 0x800, leaving room to climb inside the millisecond. */
20
- const drawCounterSeed = () => {
21
- if (offset > POOL_SIZE - 2) {
22
- globalThis.crypto.getRandomValues(pool);
23
- offset = 0;
24
- }
25
- const seed = ((pool[offset] << 8) | pool[offset + 1]) & 0x7ff;
26
- offset += 2;
27
- return seed;
28
- };
29
- /** Renders the 48-bit timestamp half of the id. */
30
- const renderPrefix = (opts) => {
31
- const { ms } = opts;
32
- const hex = UUID_HEX_OCTETS;
33
- // 48 bits exceed the 32-bit bitwise range: split at 24 bits with arithmetic first.
34
- const high = Math.floor(ms / 0x1000000);
35
- const low = ms % 0x1000000;
36
- return (hex[(high >>> 16) & 0xff] +
37
- hex[(high >>> 8) & 0xff] +
38
- hex[high & 0xff] +
39
- hex[(low >>> 16) & 0xff] +
40
- '-' +
41
- hex[(low >>> 8) & 0xff] +
42
- hex[low & 0xff] +
43
- '-');
44
- };
45
- return () => {
46
- const now = Date.now();
47
- if (now > lastMs) {
48
- lastMs = now;
49
- counter = drawCounterSeed();
50
- prefix = renderPrefix({ ms: now });
51
- }
52
- else if (++counter > MAX_COUNTER) {
53
- // Counter spent, or the clock stepped back: borrow the next millisecond rather than repeat.
54
- lastMs += 1;
55
- counter = drawCounterSeed();
56
- prefix = renderPrefix({ ms: lastMs });
9
+ export class UuidV7Generator {
10
+ /**
11
+ * Builds a v7 generator with its own clock state and counter. Never `Bun.randomUUIDv7`: it is
12
+ * slower, and it reads `(encoding, timestamp)` from whatever it is called with.
13
+ */
14
+ static create() {
15
+ const pool = new Uint8Array(POOL_SIZE);
16
+ let offset = POOL_SIZE;
17
+ let lastMs = -1;
18
+ let counter = 0;
19
+ let prefix = '';
20
+ /** Draws a counter seed below 0x800, leaving room to climb inside the millisecond. */
21
+ const drawCounterSeed = () => {
22
+ if (offset > POOL_SIZE - 2) {
23
+ globalThis.crypto.getRandomValues(pool);
24
+ offset = 0;
25
+ }
26
+ const seed = ((pool[offset] << 8) | pool[offset + 1]) & 0x7ff;
27
+ offset += 2;
28
+ return seed;
29
+ };
30
+ /** Renders the 48-bit timestamp half of the id. */
31
+ const renderPrefix = (opts) => {
32
+ const { ms } = opts;
33
+ const hex = UUID_HEX_OCTETS;
34
+ // 48 bits exceed the 32-bit bitwise range: split at 24 bits with arithmetic first.
35
+ const high = Math.floor(ms / 0x1000000);
36
+ const low = ms % 0x1000000;
37
+ return (hex[(high >>> 16) & 0xff] +
38
+ hex[(high >>> 8) & 0xff] +
39
+ hex[high & 0xff] +
40
+ hex[(low >>> 16) & 0xff] +
41
+ '-' +
42
+ hex[(low >>> 8) & 0xff] +
43
+ hex[low & 0xff] +
44
+ '-');
45
+ };
46
+ return () => {
47
+ const now = Date.now();
48
+ if (now > lastMs) {
49
+ lastMs = now;
50
+ counter = drawCounterSeed();
51
+ prefix = renderPrefix({ ms: now });
52
+ }
53
+ else if (++counter > MAX_COUNTER) {
54
+ // Counter spent, or the clock stepped back: borrow the next millisecond rather than repeat.
55
+ lastMs += 1;
56
+ counter = drawCounterSeed();
57
+ prefix = renderPrefix({ ms: lastMs });
58
+ }
59
+ if (offset > POOL_SIZE - 8) {
60
+ globalThis.crypto.getRandomValues(pool);
61
+ offset = 0;
62
+ }
63
+ const at = offset;
64
+ offset = at + 8;
65
+ const hex = UUID_HEX_OCTETS;
66
+ return (prefix +
67
+ hex[0x70 | (counter >>> 8)] +
68
+ hex[counter & 0xff] +
69
+ '-' +
70
+ hex[(pool[at] & 0x3f) | 0x80] +
71
+ hex[pool[at + 1]] +
72
+ '-' +
73
+ hex[pool[at + 2]] +
74
+ hex[pool[at + 3]] +
75
+ hex[pool[at + 4]] +
76
+ hex[pool[at + 5]] +
77
+ hex[pool[at + 6]] +
78
+ hex[pool[at + 7]]);
79
+ };
80
+ }
81
+ /** The realm's one generator: the one in the shared slot when another copy of this module put it there, else a new one that fills the slot. */
82
+ static resolveShared() {
83
+ const shared = Reflect.get(globalThis, SHARED_SLOT);
84
+ const resolved = shared ?? UuidV7Generator.create();
85
+ if (!shared) {
86
+ Reflect.set(globalThis, SHARED_SLOT, resolved);
57
87
  }
58
- if (offset > POOL_SIZE - 8) {
59
- globalThis.crypto.getRandomValues(pool);
60
- offset = 0;
61
- }
62
- const at = offset;
63
- offset = at + 8;
64
- const hex = UUID_HEX_OCTETS;
65
- return (prefix +
66
- hex[0x70 | (counter >>> 8)] +
67
- hex[counter & 0xff] +
68
- '-' +
69
- hex[(pool[at] & 0x3f) | 0x80] +
70
- hex[pool[at + 1]] +
71
- '-' +
72
- hex[pool[at + 2]] +
73
- hex[pool[at + 3]] +
74
- hex[pool[at + 4]] +
75
- hex[pool[at + 5]] +
76
- hex[pool[at + 6]] +
77
- hex[pool[at + 7]]);
78
- };
79
- };
80
- const sharedV7 = Reflect.get(globalThis, SHARED_SLOT);
81
- const resolvedV7 = sharedV7 ?? createUuidV7();
82
- if (!sharedV7) {
83
- Reflect.set(globalThis, SHARED_SLOT, resolvedV7);
88
+ return resolved;
89
+ }
90
+ static { this.shared = UuidV7Generator.resolveShared(); }
91
+ /**
92
+ * Mints a time-ordered UUID v7 - the default for a string primary key. Forwards no argument: the
93
+ * shared slot may hold another helpers version's generator.
94
+ */
95
+ static generate() {
96
+ return UuidV7Generator.shared();
97
+ }
84
98
  }
85
- /**
86
- * Mints a time-ordered UUID v7 - the default for a string primary key. Forwards no argument: the
87
- * shared slot may hold another helpers version's generator.
88
- */
89
- export const uuidV7 = () => resolvedV7();
90
99
  //# sourceMappingURL=v7.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"v7.js","sourceRoot":"","sources":["../../../../../src/modules/uid/uuid/v7.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD;;;GAGG;AACH,MAAM,WAAW,GAAG,MAAM,CAA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CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;YAC7B,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;YACjB,GAAG;YACH,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;YACjB,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;YACjB,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;YACjB,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;YACjB,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;YACjB,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAClB,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,QAAQ,GAA+B,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;AAClF,MAAM,UAAU,GAAG,QAAQ,IAAI,YAAY,EAAE,CAAC;AAC9C,IAAI,CAAC,QAAQ,EAAE,CAAC;IACd,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;AACnD,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAW,EAAE,CAAC,UAAU,EAAE,CAAC","sourcesContent":["import { UUID_HEX_OCTETS } from './common/constants';\n\n/**\n * One sequence per realm, so the CJS and ESM copies - and two helpers versions - never interleave two\n * counters. The slot holds a `() => string`; that key and shape are a contract across versions.\n */\nconst SHARED_SLOT = Symbol.for('@venizia/ignis-helpers:uuid-v7');\n\nconst POOL_SIZE = 8 * 256;\nconst MAX_COUNTER = 0xfff;\n\n/**\n * Builds a v7 generator with its own clock state and counter. Never `Bun.randomUUIDv7`: it is\n * slower, and it reads `(encoding, timestamp)` from whatever it is called with.\n */\nexport const createUuidV7 = (): (() => string) => {\n const pool = new Uint8Array(POOL_SIZE);\n let offset = POOL_SIZE;\n let lastMs = -1;\n let counter = 0;\n let prefix = '';\n\n /** Draws a counter seed below 0x800, leaving room to climb inside the millisecond. */\n const drawCounterSeed = (): number => {\n if (offset > POOL_SIZE - 2) {\n globalThis.crypto.getRandomValues(pool);\n offset = 0;\n }\n\n const seed = ((pool[offset] << 8) | pool[offset + 1]) & 0x7ff;\n offset += 2;\n return seed;\n };\n\n /** Renders the 48-bit timestamp half of the id. */\n const renderPrefix = (opts: { ms: number }): string => {\n const { ms } = opts;\n const hex = UUID_HEX_OCTETS;\n // 48 bits exceed the 32-bit bitwise range: split at 24 bits with arithmetic first.\n const high = Math.floor(ms / 0x1000000);\n const low = ms % 0x1000000;\n\n return (\n hex[(high >>> 16) & 0xff] +\n hex[(high >>> 8) & 0xff] +\n hex[high & 0xff] +\n hex[(low >>> 16) & 0xff] +\n '-' +\n hex[(low >>> 8) & 0xff] +\n hex[low & 0xff] +\n '-'\n );\n };\n\n return () => {\n const now = Date.now();\n\n if (now > lastMs) {\n lastMs = now;\n counter = drawCounterSeed();\n prefix = renderPrefix({ ms: now });\n } else if (++counter > MAX_COUNTER) {\n // Counter spent, or the clock stepped back: borrow the next millisecond rather than repeat.\n lastMs += 1;\n counter = drawCounterSeed();\n prefix = renderPrefix({ ms: lastMs });\n }\n\n if (offset > POOL_SIZE - 8) {\n globalThis.crypto.getRandomValues(pool);\n offset = 0;\n }\n\n const at = offset;\n offset = at + 8;\n\n const hex = UUID_HEX_OCTETS;\n\n return (\n prefix +\n hex[0x70 | (counter >>> 8)] +\n hex[counter & 0xff] +\n '-' +\n hex[(pool[at] & 0x3f) | 0x80] +\n hex[pool[at + 1]] +\n '-' +\n hex[pool[at + 2]] +\n hex[pool[at + 3]] +\n hex[pool[at + 4]] +\n hex[pool[at + 5]] +\n hex[pool[at + 6]] +\n hex[pool[at + 7]]\n );\n };\n};\n\nconst sharedV7: (() => string) | undefined = Reflect.get(globalThis, SHARED_SLOT);\nconst resolvedV7 = sharedV7 ?? createUuidV7();\nif (!sharedV7) {\n Reflect.set(globalThis, SHARED_SLOT, resolvedV7);\n}\n\n/**\n * Mints a time-ordered UUID v7 - the default for a string primary key. Forwards no argument: the\n * shared slot may hold another helpers version's generator.\n */\nexport const uuidV7 = (): string => resolvedV7();\n"]}
1
+ {"version":3,"file":"v7.js","sourceRoot":"","sources":["../../../../../src/modules/uid/uuid/v7.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD;;;GAGG;AACH,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;AAEjE,MAAM,SAAS,GAAG,CAAC,GAAG,GAAG,CAAC;AAC1B,MAAM,WAAW,GAAG,KAAK,CAAC;AAE1B,MAAM,OAAO,eAAe;IAC1B;;;OAGG;IACH,MAAM,CAAC,MAAM;QACX,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,SAAS,CAAC,CAAC;QACvC,IAAI,MAAM,GAAG,SAAS,CAAC;QACvB,IAAI,MAAM,GAAG,CAAC,CAAC,CAAC;QAChB,IAAI,OAAO,GAAG,CAAC,CAAC;QAChB,IAAI,MAAM,GAAG,EAAE,CAAC;QAEhB,sFAAsF;QACtF,MAAM,eAAe,GAAG,GAAW,EAAE;YACnC,IAAI,MAAM,GAAG,SAAS,GAAG,CAAC,EAAE,CAAC;gBAC3B,UAAU,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;gBACxC,MAAM,GAAG,CAAC,CAAC;YACb,CAAC;YAED,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;YAC9D,MAAM,IAAI,CAAC,CAAC;YACZ,OAAO,IAAI,CAAC;QACd,CAAC,CAAC;QAEF,mDAAmD;QACnD,MAAM,YAAY,GAAG,CAAC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OAAO,QAAQ,CAAC;IAClB,CAAC;aAEuB,WAAM,GAAiB,eAAe,CAAC,aAAa,EAAE,CAAC;IAE/E;;;OAGG;IACH,MAAM,CAAC,QAAQ;QACb,OAAO,eAAe,CAAC,MAAM,EAAE,CAAC;IAClC,CAAC","sourcesContent":["import { UUID_HEX_OCTETS } from './common/constants';\n\n/**\n * One sequence per realm, so the CJS and ESM copies - and two helpers versions - never interleave two\n * counters. The slot holds a `() => string`; that key and shape are a contract across versions.\n */\nconst SHARED_SLOT = Symbol.for('@venizia/ignis-helpers:uuid-v7');\n\nconst POOL_SIZE = 8 * 256;\nconst MAX_COUNTER = 0xfff;\n\nexport class UuidV7Generator {\n /**\n * Builds a v7 generator with its own clock state and counter. Never `Bun.randomUUIDv7`: it is\n * slower, and it reads `(encoding, timestamp)` from whatever it is called with.\n */\n static create(): () => string {\n const pool = new Uint8Array(POOL_SIZE);\n let offset = POOL_SIZE;\n let lastMs = -1;\n let counter = 0;\n let prefix = '';\n\n /** Draws a counter seed below 0x800, leaving room to climb inside the millisecond. */\n const drawCounterSeed = (): number => {\n if (offset > POOL_SIZE - 2) {\n globalThis.crypto.getRandomValues(pool);\n offset = 0;\n }\n\n const seed = ((pool[offset] << 8) | pool[offset + 1]) & 0x7ff;\n offset += 2;\n return seed;\n };\n\n /** Renders the 48-bit timestamp half of the id. */\n const renderPrefix = (opts: { ms: number }): string => {\n const { ms } = opts;\n const hex = UUID_HEX_OCTETS;\n // 48 bits exceed the 32-bit bitwise range: split at 24 bits with arithmetic first.\n const high = Math.floor(ms / 0x1000000);\n const low = ms % 0x1000000;\n\n return (\n hex[(high >>> 16) & 0xff] +\n hex[(high >>> 8) & 0xff] +\n hex[high & 0xff] +\n hex[(low >>> 16) & 0xff] +\n '-' +\n hex[(low >>> 8) & 0xff] +\n hex[low & 0xff] +\n '-'\n );\n };\n\n return () => {\n const now = Date.now();\n\n if (now > lastMs) {\n lastMs = now;\n counter = drawCounterSeed();\n prefix = renderPrefix({ ms: now });\n } else if (++counter > MAX_COUNTER) {\n // Counter spent, or the clock stepped back: borrow the next millisecond rather than repeat.\n lastMs += 1;\n counter = drawCounterSeed();\n prefix = renderPrefix({ ms: lastMs });\n }\n\n if (offset > POOL_SIZE - 8) {\n globalThis.crypto.getRandomValues(pool);\n offset = 0;\n }\n\n const at = offset;\n offset = at + 8;\n\n const hex = UUID_HEX_OCTETS;\n\n return (\n prefix +\n hex[0x70 | (counter >>> 8)] +\n hex[counter & 0xff] +\n '-' +\n hex[(pool[at] & 0x3f) | 0x80] +\n hex[pool[at + 1]] +\n '-' +\n hex[pool[at + 2]] +\n hex[pool[at + 3]] +\n hex[pool[at + 4]] +\n hex[pool[at + 5]] +\n hex[pool[at + 6]] +\n hex[pool[at + 7]]\n );\n };\n }\n\n /** The realm's one generator: the one in the shared slot when another copy of this module put it there, else a new one that fills the slot. */\n private static resolveShared(): () => string {\n const shared: (() => string) | undefined = Reflect.get(globalThis, SHARED_SLOT);\n const resolved = shared ?? UuidV7Generator.create();\n if (!shared) {\n Reflect.set(globalThis, SHARED_SLOT, resolved);\n }\n\n return resolved;\n }\n\n private static readonly shared: () => string = UuidV7Generator.resolveShared();\n\n /**\n * Mints a time-ordered UUID v7 - the default for a string primary key. Forwards no argument: the\n * shared slot may hold another helpers version's generator.\n */\n static generate(): string {\n return UuidV7Generator.shared();\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { voidExecution } from '../../../utilities/promise.utility.js';
1
+ import { PromiseUtility } from '../../../utilities/promise.utility.js';
2
2
  import { AbstractWorkerBusHelper } from './abstract.js';
3
3
  export class BaseWorkerBusHelper extends AbstractWorkerBusHelper {
4
4
  constructor(opts) {
@@ -25,7 +25,7 @@ export class BaseWorkerBusHelper extends AbstractWorkerBusHelper {
25
25
  invokeHook(opts) {
26
26
  const { scope, execution } = opts;
27
27
  try {
28
- voidExecution({ logger: this.logger, scope, execution: execution() });
28
+ PromiseUtility.voidExecution({ logger: this.logger, scope, execution: execution() });
29
29
  }
30
30
  catch (error) {
31
31
  this.logger.for(scope).error('Hook execution FAILED | Error: %s', error);
@@ -1 +1 @@
1
- {"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../../src/modules/worker-thread/bus/base.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAG5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAErD,MAAM,OAAO,mBAAsD,SAAQ,uBAG1E;IACC,YAAY,IAIX;QACC,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QAErD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC;QAE/B,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,EAAE;YAClC,IAAI,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;QAChG,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YAC9B,IAAI,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;QAC1F,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,cAAc,EAAE,CAAC,KAAK,EAAE,EAAE;YACrC,IAAI,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE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;QACT,CAAC;QAED,IAAI,CAAC,UAAU,CAAC;YACd,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI;YAC5B,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,mBAAmB,EAAE,CAAC,IAAI,CAAC;SAClD,CAAC,CAAC;QAEH,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;QAC9D,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACtC,CAAC;QAED,IAAI,CAAC,UAAU,CAAC;YACd,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI;YAC5B,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,kBAAkB,EAAE,CAAC,IAAI,CAAC;SACjD,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { type ValueOrPromise } from '@/common/types';\nimport { voidExecution } from '@/utilities/promise.utility';\nimport { type MessagePort, type Transferable } from 'node:worker_threads';\nimport { type IWorkerMessageBusHandler } from '../common';\nimport { AbstractWorkerBusHelper } from './abstract';\n\nexport class BaseWorkerBusHelper<IConsumePayload, IPublishPayload> extends AbstractWorkerBusHelper<\n IConsumePayload,\n IPublishPayload\n> {\n constructor(opts: {\n scope: string;\n port: MessagePort;\n busHandler: IWorkerMessageBusHandler<IConsumePayload>;\n }) {\n super({ scope: opts.scope, identifier: opts.scope });\n\n this.port = opts.port;\n this.handler = opts.busHandler;\n\n this.port.on('message', (message) => {\n this.invokeHook({ scope: 'onMessage', execution: () => this.handler.onMessage({ message }) });\n });\n\n this.port.on('error', (error) => {\n this.invokeHook({ scope: 'onError', execution: () => this.handler.onError({ error }) });\n });\n\n this.port.on('messageerror', (error) => {\n this.invokeHook({ scope: 'onError', execution: () => this.handler.onError({ error }) });\n });\n\n this.port.on('exit', (exitCode) => {\n this.invokeHook({ scope: 'onExit', execution: () => this.handler.onExit({ exitCode }) });\n });\n\n this.port.on('close', () => {\n this.invokeHook({ scope: 'onClose', execution: () => this.handler.onClose() });\n });\n }\n\n /** Bus handlers run inside MessagePort listeners; a sync throw there is uncaught and kills the worker thread, so wrap it - voidExecution alone can't catch a throw evaluated before it's called. */\n protected invokeHook(opts: { scope: string; execution: () => ValueOrPromise<void> }) {\n const { scope, execution } = opts;\n\n try {\n voidExecution({ logger: this.logger, scope, execution: execution() });\n } catch (error) {\n this.logger.for(scope).error('Hook execution FAILED | Error: %s', error);\n }\n }\n\n onBeforePostMessage?(opts: { message: IPublishPayload }): ValueOrPromise<void>;\n onAfterPostMessage?(opts: { message: IPublishPayload }): ValueOrPromise<void>;\n\n postMessage(opts: {\n message: IPublishPayload;\n transferList: readonly Transferable[] | undefined;\n }): ValueOrPromise<void> {\n if (!this.port) {\n this.logger\n .for(this.postMessage.name)\n .error('Failed to post message to main | Invalid parentPort!');\n return;\n }\n\n this.invokeHook({\n scope: this.postMessage.name,\n execution: () => this.onBeforePostMessage?.(opts),\n });\n\n if (opts.transferList) {\n this.port.postMessage(opts.message, [...opts.transferList]);\n } else {\n this.port.postMessage(opts.message);\n }\n\n this.invokeHook({\n scope: this.postMessage.name,\n execution: () => this.onAfterPostMessage?.(opts),\n });\n }\n}\n"]}
1
+ {"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../../src/modules/worker-thread/bus/base.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAG7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAErD,MAAM,OAAO,mBAAsD,SAAQ,uBAG1E;IACC,YAAY,IAIX;QACC,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QAErD,IAAI,C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AC,OAAO,CAAC,CAAC;QACtC,CAAC;QAED,IAAI,CAAC,UAAU,CAAC;YACd,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI;YAC5B,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,kBAAkB,EAAE,CAAC,IAAI,CAAC;SACjD,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { type ValueOrPromise } from '@/common/types';\nimport { PromiseUtility } from '@/utilities/promise.utility';\nimport { type MessagePort, type Transferable } from 'node:worker_threads';\nimport { type IWorkerMessageBusHandler } from '../common';\nimport { AbstractWorkerBusHelper } from './abstract';\n\nexport class BaseWorkerBusHelper<IConsumePayload, IPublishPayload> extends AbstractWorkerBusHelper<\n IConsumePayload,\n IPublishPayload\n> {\n constructor(opts: {\n scope: string;\n port: MessagePort;\n busHandler: IWorkerMessageBusHandler<IConsumePayload>;\n }) {\n super({ scope: opts.scope, identifier: opts.scope });\n\n this.port = opts.port;\n this.handler = opts.busHandler;\n\n this.port.on('message', (message) => {\n this.invokeHook({ scope: 'onMessage', execution: () => this.handler.onMessage({ message }) });\n });\n\n this.port.on('error', (error) => {\n this.invokeHook({ scope: 'onError', execution: () => this.handler.onError({ error }) });\n });\n\n this.port.on('messageerror', (error) => {\n this.invokeHook({ scope: 'onError', execution: () => this.handler.onError({ error }) });\n });\n\n this.port.on('exit', (exitCode) => {\n this.invokeHook({ scope: 'onExit', execution: () => this.handler.onExit({ exitCode }) });\n });\n\n this.port.on('close', () => {\n this.invokeHook({ scope: 'onClose', execution: () => this.handler.onClose() });\n });\n }\n\n /** Bus handlers run inside MessagePort listeners; a sync throw there is uncaught and kills the worker thread, so wrap it - voidExecution alone can't catch a throw evaluated before it's called. */\n protected invokeHook(opts: { scope: string; execution: () => ValueOrPromise<void> }) {\n const { scope, execution } = opts;\n\n try {\n PromiseUtility.voidExecution({ logger: this.logger, scope, execution: execution() });\n } catch (error) {\n this.logger.for(scope).error('Hook execution FAILED | Error: %s', error);\n }\n }\n\n onBeforePostMessage?(opts: { message: IPublishPayload }): ValueOrPromise<void>;\n onAfterPostMessage?(opts: { message: IPublishPayload }): ValueOrPromise<void>;\n\n postMessage(opts: {\n message: IPublishPayload;\n transferList: readonly Transferable[] | undefined;\n }): ValueOrPromise<void> {\n if (!this.port) {\n this.logger\n .for(this.postMessage.name)\n .error('Failed to post message to main | Invalid parentPort!');\n return;\n }\n\n this.invokeHook({\n scope: this.postMessage.name,\n execution: () => this.onBeforePostMessage?.(opts),\n });\n\n if (opts.transferList) {\n this.port.postMessage(opts.message, [...opts.transferList]);\n } else {\n this.port.postMessage(opts.message);\n }\n\n this.invokeHook({\n scope: this.postMessage.name,\n execution: () => this.onAfterPostMessage?.(opts),\n });\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../../src/modules/worker-thread/worker/base.ts"],"names":[],"mappings":"AACA,OAAO,EAAU,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEjE,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAElD,qBAAa,gBAAgB,CAAC,WAAW,CAAE,SAAQ,oBAAoB,CAAC,WAAW,CAAC;IAClF,SAAS,CAAC,aAAa,CAAC,EAAE,OAAO,CAC/B,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,WAAW,GAAG,gBAAgB,CAAC,CAC/F,CAAC;gBAEU,IAAI,EAAE;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,MAAM,CAAC;QACnB,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC;QACnB,OAAO,EAAE,aAAa,CAAC;QACvB,aAAa,CAAC,EAAE,OAAO,CACrB,IAAI,CAAC,OAAO,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W,GAAG,gBAAgB,CAAC,CAC/F,CAAC;gBAEU,IAAI,EAAE;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,MAAM,CAAC;QACnB,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC;QACnB,OAAO,EAAE,aAAa,CAAC;QACvB,aAAa,CAAC,EAAE,OAAO,CACrB,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,WAAW,GAAG,gBAAgB,CAAC,CAC/F,CAAC;KACH;IAQD,0LAA0L;IAC1L,SAAS,CAAC,UAAU,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,cAAc,CAAC,IAAI,CAAC,CAAA;KAAE;IAU1E,QAAQ,IAAI,cAAc,CAAC,IAAI,CAAC;IAYhC,MAAM,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,GAAG,cAAc,CAAC,IAAI,CAAC;IAY7D,OAAO,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,KAAK,CAAA;KAAE,GAAG,cAAc,CAAC,IAAI,CAAC;IAYrD,SAAS,CAAC,IAAI,EAAE;QAAE,OAAO,EAAE,WAAW,CAAA;KAAE,GAAG,cAAc,CAAC,IAAI,CAAC;IAY/D,cAAc,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,KAAK,CAAA;KAAE,GAAG,cAAc,CAAC,IAAI,CAAC;IAYrE,OAAO;CA+BR"}
@@ -1,4 +1,5 @@
1
- import { toError, voidExecution } from '../../../utilities/promise.utility.js';
1
+ import { ErrorUtility } from '../../../utilities/error.utility.js';
2
+ import { PromiseUtility } from '../../../utilities/promise.utility.js';
2
3
  import { Worker } from 'node:worker_threads';
3
4
  import { getError } from '../../error/index.js';
4
5
  import { AbstractWorkerHelper } from './abstract.js';
@@ -13,7 +14,7 @@ export class BaseWorkerHelper extends AbstractWorkerHelper {
13
14
  invokeHook(opts) {
14
15
  const { scope, execution } = opts;
15
16
  try {
16
- voidExecution({ logger: this.logger, scope, execution: execution() });
17
+ PromiseUtility.voidExecution({ logger: this.logger, scope, execution: execution() });
17
18
  }
18
19
  catch (error) {
19
20
  this.logger.for(scope).error('Hook execution FAILED | Error: %s', error);
@@ -82,7 +83,7 @@ export class BaseWorkerHelper extends AbstractWorkerHelper {
82
83
  this.worker.on('error', (error) => {
83
84
  this.invokeHook({
84
85
  scope: this.binding.name,
85
- execution: () => this.onError({ error: toError(error) }),
86
+ execution: () => this.onError({ error: ErrorUtility.toError({ error }) }),
86
87
  });
87
88
  });
88
89
  this.worker.on('message', (message) => {
@@ -1 +1 @@
1
- {"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../../src/modules/worker-thread/worker/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,MAAM,EAAsB,MAAM,qBAAqB,CAAC;AAGjE,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAElD,MAAM,OAAO,gBAA8B,SAAQ,oBAAiC;IAKlF,YAAY,IAQX;QACC,KAAK,CAAC,EAAE,KAAK,EAAE,gBAAgB,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;QACrE,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAClD,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;QAExC,IAAI,CAAC,OAAO,EAAE,CAAC;IACjB,CAAC;IAED,0LAA0L;IAChL,UAAU,CAAC,IAA8D;QACjF,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;QAElC,IAAI,CA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AC,EAAE,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;QAC9F,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,cAAc,EAAE,CAAC,KAAK,EAAE,EAAE;YACvC,IAAI,CAAC,UAAU,CAAC;gBACd,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI;gBACxB,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE,KAAK,EAAE,CAAC;aAChD,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { toError, voidExecution } from '@/utilities/promise.utility';\nimport { Worker, type WorkerOptions } from 'node:worker_threads';\n\nimport { type ValueOrPromise } from '@/common/types';\nimport { getError } from '@/modules/error';\nimport { type IWorker } from '../common';\nimport { AbstractWorkerHelper } from './abstract';\n\nexport class BaseWorkerHelper<MessageType> extends AbstractWorkerHelper<MessageType> {\n protected eventHandlers?: Partial<\n Pick<IWorker<MessageType>, 'onOnline' | 'onExit' | 'onError' | 'onMessage' | 'onMessageError'>\n >;\n\n constructor(opts: {\n scope?: string;\n identifier: string;\n path: string | URL;\n options: WorkerOptions;\n eventHandlers?: Partial<\n Pick<IWorker<MessageType>, 'onOnline' | 'onExit' | 'onError' | 'onMessage' | 'onMessageError'>\n >;\n }) {\n super({ scope: BaseWorkerHelper.name, identifier: opts.identifier });\n this.worker = new Worker(opts.path, opts.options);\n this.eventHandlers = opts.eventHandlers;\n\n this.binding();\n }\n\n /** User handlers run inside worker listeners; a sync throw there is uncaught and kills the process, so wrap it - voidExecution alone can't catch a throw evaluated before it's called. */\n protected invokeHook(opts: { scope: string; execution: () => ValueOrPromise<void> }) {\n const { scope, execution } = opts;\n\n try {\n voidExecution({ logger: this.logger, scope, execution: execution() });\n } catch (error) {\n this.logger.for(scope).error('Hook execution FAILED | Error: %s', error);\n }\n }\n\n override onOnline(): ValueOrPromise<void> {\n if (this.eventHandlers?.onOnline) {\n this.invokeHook({\n scope: this.onOnline.name,\n execution: () => this.eventHandlers?.onOnline?.(),\n });\n return;\n }\n\n this.logger.for(this.onOnline.name).info('Worker ONLINE');\n }\n\n override onExit(opts: { code: string | number }): ValueOrPromise<void> {\n if (this.eventHandlers?.onExit) {\n this.invokeHook({\n scope: this.onExit.name,\n execution: () => this.eventHandlers?.onExit?.({ code: opts.code }),\n });\n return;\n }\n\n this.logger.for(this.onExit.name).warn('Worker EXIT | Code: %s', opts.code);\n }\n\n override onError(opts: { error: Error }): ValueOrPromise<void> {\n if (this.eventHandlers?.onError) {\n this.invokeHook({\n scope: this.onError.name,\n execution: () => this.eventHandlers?.onError?.({ error: opts.error }),\n });\n return;\n }\n\n this.logger.for(this.onError.name).error('Worker ERROR | Error: %s', opts.error);\n }\n\n override onMessage(opts: { message: MessageType }): ValueOrPromise<void> {\n if (this.eventHandlers?.onMessage) {\n this.invokeHook({\n scope: this.onMessage.name,\n execution: () => this.eventHandlers?.onMessage?.({ message: opts.message }),\n });\n return;\n }\n\n this.logger.for(this.onMessage.name).error('Worker MESSAGE | message: %j', opts.message);\n }\n\n override onMessageError(opts: { error: Error }): ValueOrPromise<void> {\n if (this.eventHandlers?.onMessageError) {\n this.invokeHook({\n scope: this.onMessageError.name,\n execution: () => this.eventHandlers?.onMessageError?.({ error: opts.error }),\n });\n return;\n }\n\n this.logger.for(this.onMessageError.name).error('Worker MESSAGE_ERROR | Error: %s', opts.error);\n }\n\n binding() {\n if (!this.worker) {\n throw getError({ message: '[binding] Invalid worker instance to bind event handlers' });\n }\n\n this.worker.on('online', () => {\n this.invokeHook({ scope: this.binding.name, execution: () => this.onOnline() });\n });\n\n this.worker.on('exit', (code) => {\n this.invokeHook({ scope: this.binding.name, execution: () => this.onExit({ code }) });\n });\n\n this.worker.on('error', (error) => {\n this.invokeHook({\n scope: this.binding.name,\n execution: () => this.onError({ error: toError(error) }),\n });\n });\n\n this.worker.on('message', (message) => {\n this.invokeHook({ scope: this.binding.name, execution: () => this.onMessage({ message }) });\n });\n\n this.worker.on('messageerror', (error) => {\n this.invokeHook({\n scope: this.binding.name,\n execution: () => this.onMessageError({ error }),\n });\n });\n }\n}\n"]}
1
+ {"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../../src/modules/worker-thread/worker/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAsB,MAAM,qBAAqB,CAAC;AAGjE,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAElD,MAAM,OAAO,gBAA8B,SAAQ,oBAAiC;IAKlF,YAAY,IAQX;QACC,KAAK,CAAC,EAAE,KAAK,EAAE,gBAAgB,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;QACrE,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAClD,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;QAExC,IAAI,CAAC,OAAO,EAAE,CAAC;IACjB,CAAC;IAED,0LAA0L;IAChL,UAAU,CAAC,IAA8D;QACjF,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;QAElC,IAAI,CAAC;YACH,cAAc,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;QACvF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,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AC,CAAC;QAC9F,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,cAAc,EAAE,CAAC,KAAK,EAAE,EAAE;YACvC,IAAI,CAAC,UAAU,CAAC;gBACd,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI;gBACxB,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE,KAAK,EAAE,CAAC;aAChD,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { ErrorUtility } from '@/utilities/error.utility';\nimport { PromiseUtility } from '@/utilities/promise.utility';\nimport { Worker, type WorkerOptions } from 'node:worker_threads';\n\nimport { type ValueOrPromise } from '@/common/types';\nimport { getError } from '@/modules/error';\nimport { type IWorker } from '../common';\nimport { AbstractWorkerHelper } from './abstract';\n\nexport class BaseWorkerHelper<MessageType> extends AbstractWorkerHelper<MessageType> {\n protected eventHandlers?: Partial<\n Pick<IWorker<MessageType>, 'onOnline' | 'onExit' | 'onError' | 'onMessage' | 'onMessageError'>\n >;\n\n constructor(opts: {\n scope?: string;\n identifier: string;\n path: string | URL;\n options: WorkerOptions;\n eventHandlers?: Partial<\n Pick<IWorker<MessageType>, 'onOnline' | 'onExit' | 'onError' | 'onMessage' | 'onMessageError'>\n >;\n }) {\n super({ scope: BaseWorkerHelper.name, identifier: opts.identifier });\n this.worker = new Worker(opts.path, opts.options);\n this.eventHandlers = opts.eventHandlers;\n\n this.binding();\n }\n\n /** User handlers run inside worker listeners; a sync throw there is uncaught and kills the process, so wrap it - voidExecution alone can't catch a throw evaluated before it's called. */\n protected invokeHook(opts: { scope: string; execution: () => ValueOrPromise<void> }) {\n const { scope, execution } = opts;\n\n try {\n PromiseUtility.voidExecution({ logger: this.logger, scope, execution: execution() });\n } catch (error) {\n this.logger.for(scope).error('Hook execution FAILED | Error: %s', error);\n }\n }\n\n override onOnline(): ValueOrPromise<void> {\n if (this.eventHandlers?.onOnline) {\n this.invokeHook({\n scope: this.onOnline.name,\n execution: () => this.eventHandlers?.onOnline?.(),\n });\n return;\n }\n\n this.logger.for(this.onOnline.name).info('Worker ONLINE');\n }\n\n override onExit(opts: { code: string | number }): ValueOrPromise<void> {\n if (this.eventHandlers?.onExit) {\n this.invokeHook({\n scope: this.onExit.name,\n execution: () => this.eventHandlers?.onExit?.({ code: opts.code }),\n });\n return;\n }\n\n this.logger.for(this.onExit.name).warn('Worker EXIT | Code: %s', opts.code);\n }\n\n override onError(opts: { error: Error }): ValueOrPromise<void> {\n if (this.eventHandlers?.onError) {\n this.invokeHook({\n scope: this.onError.name,\n execution: () => this.eventHandlers?.onError?.({ error: opts.error }),\n });\n return;\n }\n\n this.logger.for(this.onError.name).error('Worker ERROR | Error: %s', opts.error);\n }\n\n override onMessage(opts: { message: MessageType }): ValueOrPromise<void> {\n if (this.eventHandlers?.onMessage) {\n this.invokeHook({\n scope: this.onMessage.name,\n execution: () => this.eventHandlers?.onMessage?.({ message: opts.message }),\n });\n return;\n }\n\n this.logger.for(this.onMessage.name).error('Worker MESSAGE | message: %j', opts.message);\n }\n\n override onMessageError(opts: { error: Error }): ValueOrPromise<void> {\n if (this.eventHandlers?.onMessageError) {\n this.invokeHook({\n scope: this.onMessageError.name,\n execution: () => this.eventHandlers?.onMessageError?.({ error: opts.error }),\n });\n return;\n }\n\n this.logger.for(this.onMessageError.name).error('Worker MESSAGE_ERROR | Error: %s', opts.error);\n }\n\n binding() {\n if (!this.worker) {\n throw getError({ message: '[binding] Invalid worker instance to bind event handlers' });\n }\n\n this.worker.on('online', () => {\n this.invokeHook({ scope: this.binding.name, execution: () => this.onOnline() });\n });\n\n this.worker.on('exit', (code) => {\n this.invokeHook({ scope: this.binding.name, execution: () => this.onExit({ code }) });\n });\n\n this.worker.on('error', (error) => {\n this.invokeHook({\n scope: this.binding.name,\n execution: () => this.onError({ error: ErrorUtility.toError({ error }) }),\n });\n });\n\n this.worker.on('message', (message) => {\n this.invokeHook({ scope: this.binding.name, execution: () => this.onMessage({ message }) });\n });\n\n this.worker.on('messageerror', (error) => {\n this.invokeHook({\n scope: this.binding.name,\n execution: () => this.onMessageError({ error }),\n });\n });\n }\n}\n"]}
@@ -0,0 +1,7 @@
1
+ export declare class ErrorUtility {
2
+ /** Normalize an unknown thrown value into an Error instance - an ApplicationError when it was not one. */
3
+ static toError(opts: {
4
+ error: unknown;
5
+ }): Error;
6
+ }
7
+ //# sourceMappingURL=error.utility.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.utility.d.ts","sourceRoot":"","sources":["../../../src/utilities/error.utility.ts"],"names":[],"mappings":"AAEA,qBAAa,YAAY;IACvB,0GAA0G;IAC1G,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,OAAO,CAAA;KAAE,GAAG,KAAK;CAIhD"}
@@ -0,0 +1,9 @@
1
+ import { getError } from '../modules/error/index.js';
2
+ export class ErrorUtility {
3
+ /** Normalize an unknown thrown value into an Error instance - an ApplicationError when it was not one. */
4
+ static toError(opts) {
5
+ const { error } = opts;
6
+ return error instanceof Error ? error : getError({ message: String(error) });
7
+ }
8
+ }
9
+ //# sourceMappingURL=error.utility.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.utility.js","sourceRoot":"","sources":["../../../src/utilities/error.utility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,MAAM,OAAO,YAAY;IACvB,0GAA0G;IAC1G,MAAM,CAAC,OAAO,CAAC,IAAwB;QACrC,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;QACvB,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAC/E,CAAC;CACF","sourcesContent":["import { getError } from '@/modules/error';\n\nexport class ErrorUtility {\n /** Normalize an unknown thrown value into an Error instance - an ApplicationError when it was not one. */\n static toError(opts: { error: unknown }): Error {\n const { error } = opts;\n return error instanceof Error ? error : getError({ message: String(error) });\n }\n}\n"]}
@@ -9,14 +9,16 @@ export declare const RequestBodyErrors: {
9
9
  readonly category: "validation";
10
10
  };
11
11
  };
12
- /**
13
- * Reads a form body through the request's own cache, so every later reader gets the same
14
- * `FormData`. A body the runtime cannot parse is the caller's fault: it becomes a 400 here, where
15
- * the runtime's own error would be a 500 - Bun's carries only a code, Node's carries nothing.
16
- */
17
- export declare const readFormBody: (opts: {
18
- req: {
19
- formData: () => Promise<FormData>;
20
- };
21
- }) => Promise<FormData>;
12
+ export declare class FormBodyUtility {
13
+ /**
14
+ * Reads a form body through the request's own cache, so every later reader gets the same
15
+ * `FormData`. A body the runtime cannot parse is the caller's fault: it becomes a 400 here, where
16
+ * the runtime's own error would be a 500 - Bun's carries only a code, Node's carries nothing.
17
+ */
18
+ static readFormBody(opts: {
19
+ req: {
20
+ formData: () => Promise<FormData>;
21
+ };
22
+ }): Promise<FormData>;
23
+ }
22
24
  //# sourceMappingURL=form-body.utility.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"form-body.utility.d.ts","sourceRoot":"","sources":["../../../src/utilities/form-body.utility.ts"],"names":[],"mappings":"AAGA,yHAAyH;AACzH,eAAO,MAAM,iBAAiB;;;;;;;;;CAMuB,CAAC;AAEtD;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAU,MAAM;IACvC,GAAG,EAAE;QAAE,QAAQ,EAAE,MAAM,OAAO,CAAC,QAAQ,CAAC,CAAA;KAAE,CAAC;CAC5C,KAAG,OAAO,CAAC,QAAQ,CAUnB,CAAC"}
1
+ {"version":3,"file":"form-body.utility.d.ts","sourceRoot":"","sources":["../../../src/utilities/form-body.utility.ts"],"names":[],"mappings":"AAGA,yHAAyH;AACzH,eAAO,MAAM,iBAAiB;;;;;;;;;CAMuB,CAAC;AAEtD,qBAAa,eAAe;IAC1B;;;;OAIG;WACU,YAAY,CAAC,IAAI,EAAE;QAC9B,GAAG,EAAE;YAAE,QAAQ,EAAE,MAAM,OAAO,CAAC,QAAQ,CAAC,CAAA;SAAE,CAAC;KAC5C,GAAG,OAAO,CAAC,QAAQ,CAAC;CAYtB"}
@@ -8,21 +8,24 @@ export const RequestBodyErrors = {
8
8
  category: ErrorScopes.VALIDATION,
9
9
  },
10
10
  };
11
- /**
12
- * Reads a form body through the request's own cache, so every later reader gets the same
13
- * `FormData`. A body the runtime cannot parse is the caller's fault: it becomes a 400 here, where
14
- * the runtime's own error would be a 500 - Bun's carries only a code, Node's carries nothing.
15
- */
16
- export const readFormBody = async (opts) => {
17
- try {
18
- return await opts.req.formData();
11
+ export class FormBodyUtility {
12
+ /**
13
+ * Reads a form body through the request's own cache, so every later reader gets the same
14
+ * `FormData`. A body the runtime cannot parse is the caller's fault: it becomes a 400 here, where
15
+ * the runtime's own error would be a 500 - Bun's carries only a code, Node's carries nothing.
16
+ */
17
+ static async readFormBody(opts) {
18
+ try {
19
+ const result = await opts.req.formData();
20
+ return result;
21
+ }
22
+ catch (error) {
23
+ throw getError({
24
+ error: RequestBodyErrors.BODY_MALFORMED,
25
+ message: 'Malformed Body Payload',
26
+ cause: error,
27
+ });
28
+ }
19
29
  }
20
- catch (error) {
21
- throw getError({
22
- error: RequestBodyErrors.BODY_MALFORMED,
23
- message: 'Malformed Body Payload',
24
- cause: error,
25
- });
26
- }
27
- };
30
+ }
28
31
  //# sourceMappingURL=form-body.utility.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"form-body.utility.js","sourceRoot":"","sources":["../../../src/utilities/form-body.utility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAyB,MAAM,iBAAiB,CAAC;AAE/E,yHAAyH;AACzH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,cAAc,EAAE;QACd,OAAO,EAAE,EAAE,IAAI,EAAE,wBAAwB,EAAE,IAAI,EAAE,6BAA6B,EAAE;QAChF,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU;QAC5C,QAAQ,EAAE,WAAW,CAAC,UAAU;KACjC;CACkD,CAAC;AAEtD;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAAE,IAElC,EAAqB,EAAE;IACtB,IAAI,CAAC;QACH,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;IACnC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,QAAQ,CAAC;YACb,KAAK,EAAE,iBAAiB,CAAC,cAAc;YACvC,OAAO,EAAE,wBAAwB;YACjC,KAAK,EAAE,KAAK;SACb,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC","sourcesContent":["import { HTTP } from '@/common/constants';\nimport { ErrorScopes, getError, type TErrorDefinition } from '@/modules/error';\n\n/** The one definition of a body the runtime cannot parse; the kernel's `RequestErrors.BODY_MALFORMED` is this object. */\nexport const RequestBodyErrors = {\n BODY_MALFORMED: {\n message: { text: 'Malformed body payload', code: 'core.request.body_malformed' },\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n category: ErrorScopes.VALIDATION,\n },\n} as const satisfies Record<string, TErrorDefinition>;\n\n/**\n * Reads a form body through the request's own cache, so every later reader gets the same\n * `FormData`. A body the runtime cannot parse is the caller's fault: it becomes a 400 here, where\n * the runtime's own error would be a 500 - Bun's carries only a code, Node's carries nothing.\n */\nexport const readFormBody = async (opts: {\n req: { formData: () => Promise<FormData> };\n}): Promise<FormData> => {\n try {\n return await opts.req.formData();\n } catch (error) {\n throw getError({\n error: RequestBodyErrors.BODY_MALFORMED,\n message: 'Malformed Body Payload',\n cause: error,\n });\n }\n};\n"]}
1
+ {"version":3,"file":"form-body.utility.js","sourceRoot":"","sources":["../../../src/utilities/form-body.utility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAyB,MAAM,iBAAiB,CAAC;AAE/E,yHAAyH;AACzH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,cAAc,EAAE;QACd,OAAO,EAAE,EAAE,IAAI,EAAE,wBAAwB,EAAE,IAAI,EAAE,6BAA6B,EAAE;QAChF,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU;QAC5C,QAAQ,EAAE,WAAW,CAAC,UAAU;KACjC;CACkD,CAAC;AAEtD,MAAM,OAAO,eAAe;IAC1B;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,IAEzB;QACC,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;YACzC,OAAO,MAAM,CAAC;QAChB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,QAAQ,CAAC;gBACb,KAAK,EAAE,iBAAiB,CAAC,cAAc;gBACvC,OAAO,EAAE,wBAAwB;gBACjC,KAAK,EAAE,KAAK;aACb,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF","sourcesContent":["import { HTTP } from '@/common/constants';\nimport { ErrorScopes, getError, type TErrorDefinition } from '@/modules/error';\n\n/** The one definition of a body the runtime cannot parse; the kernel's `RequestErrors.BODY_MALFORMED` is this object. */\nexport const RequestBodyErrors = {\n BODY_MALFORMED: {\n message: { text: 'Malformed body payload', code: 'core.request.body_malformed' },\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n category: ErrorScopes.VALIDATION,\n },\n} as const satisfies Record<string, TErrorDefinition>;\n\nexport class FormBodyUtility {\n /**\n * Reads a form body through the request's own cache, so every later reader gets the same\n * `FormData`. A body the runtime cannot parse is the caller's fault: it becomes a 400 here, where\n * the runtime's own error would be a 500 - Bun's carries only a code, Node's carries nothing.\n */\n static async readFormBody(opts: {\n req: { formData: () => Promise<FormData> };\n }): Promise<FormData> {\n try {\n const result = await opts.req.formData();\n return result;\n } catch (error) {\n throw getError({\n error: RequestBodyErrors.BODY_MALFORMED,\n message: 'Malformed Body Payload',\n cause: error,\n });\n }\n }\n}\n"]}
@@ -1,6 +1,8 @@
1
- /**
2
- * Seconds from the process's high-resolution clock, to nine decimals - for measuring, not for dates.
3
- * A file of its own: `process.hrtime` is Node-only, and `performance.utility` ships on `/core`.
4
- */
5
- export declare const hrTime: () => number;
1
+ export declare class HrTimeUtility {
2
+ /**
3
+ * Seconds from the process's high-resolution clock, to nine decimals - for measuring, not for dates.
4
+ * A file of its own: `process.hrtime` is Node-only, and `performance.utility` ships on `/core`.
5
+ */
6
+ static getSeconds(): number;
7
+ }
6
8
  //# sourceMappingURL=hr-time.utility.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hr-time.utility.d.ts","sourceRoot":"","sources":["../../../src/utilities/hr-time.utility.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,MAAM,cAGlB,CAAC"}
1
+ {"version":3,"file":"hr-time.utility.d.ts","sourceRoot":"","sources":["../../../src/utilities/hr-time.utility.ts"],"names":[],"mappings":"AAEA,qBAAa,aAAa;IACxB;;;OAGG;IACH,MAAM,CAAC,UAAU;CAIlB"}
@@ -1,10 +1,12 @@
1
- import { float } from './parse.utility.js';
2
- /**
3
- * Seconds from the process's high-resolution clock, to nine decimals - for measuring, not for dates.
4
- * A file of its own: `process.hrtime` is Node-only, and `performance.utility` ships on `/core`.
5
- */
6
- export const hrTime = () => {
7
- const current = process.hrtime();
8
- return float(current[0] + current[1] / 10 ** 9, 9);
9
- };
1
+ import { ParseUtility } from './parse.utility.js';
2
+ export class HrTimeUtility {
3
+ /**
4
+ * Seconds from the process's high-resolution clock, to nine decimals - for measuring, not for dates.
5
+ * A file of its own: `process.hrtime` is Node-only, and `performance.utility` ships on `/core`.
6
+ */
7
+ static getSeconds() {
8
+ const current = process.hrtime();
9
+ return ParseUtility.toFloat({ input: current[0] + current[1] / 10 ** 9, digit: 9 });
10
+ }
11
+ }
10
12
  //# sourceMappingURL=hr-time.utility.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"hr-time.utility.js","sourceRoot":"","sources":["../../../src/utilities/hr-time.utility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAExC;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,EAAE;IACzB,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IACjC,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;AACrD,CAAC,CAAC","sourcesContent":["import { float } from './parse.utility';\n\n/**\n * Seconds from the process's high-resolution clock, to nine decimals - for measuring, not for dates.\n * A file of its own: `process.hrtime` is Node-only, and `performance.utility` ships on `/core`.\n */\nexport const hrTime = () => {\n const current = process.hrtime();\n return float(current[0] + current[1] / 10 ** 9, 9);\n};\n"]}
1
+ {"version":3,"file":"hr-time.utility.js","sourceRoot":"","sources":["../../../src/utilities/hr-time.utility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,OAAO,aAAa;IACxB;;;OAGG;IACH,MAAM,CAAC,UAAU;QACf,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;QACjC,OAAO,YAAY,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;IACtF,CAAC;CACF","sourcesContent":["import { ParseUtility } from './parse.utility';\n\nexport class HrTimeUtility {\n /**\n * Seconds from the process's high-resolution clock, to nine decimals - for measuring, not for dates.\n * A file of its own: `process.hrtime` is Node-only, and `performance.utility` ships on `/core`.\n */\n static getSeconds() {\n const current = process.hrtime();\n return ParseUtility.toFloat({ input: current[0] + current[1] / 10 ** 9, digit: 9 });\n }\n}\n"]}
@@ -1,10 +1,10 @@
1
1
  export * from './build-info.utility.js';
2
- export { readFormBody } from './form-body.utility.js';
2
+ export { FormBodyUtility } from './form-body.utility.js';
3
+ export * from './error.utility.js';
3
4
  export * from './hr-time.utility.js';
4
5
  export * from './module.utility.js';
5
6
  export * from './parse.utility.js';
6
7
  export * from './performance.utility.js';
7
8
  export * from './promise.utility.js';
8
9
  export * from './request.utility.js';
9
- export * from './sleep.utility.js';
10
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utilities/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AAErC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utilities/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AAErC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC"}
@@ -1,11 +1,11 @@
1
1
  export * from './build-info.utility.js';
2
2
  // `RequestBodyErrors` stays on `/core`: consumers name it through the kernel's `RequestErrors`.
3
- export { readFormBody } from './form-body.utility.js';
3
+ export { FormBodyUtility } from './form-body.utility.js';
4
+ export * from './error.utility.js';
4
5
  export * from './hr-time.utility.js';
5
6
  export * from './module.utility.js';
6
7
  export * from './parse.utility.js';
7
8
  export * from './performance.utility.js';
8
9
  export * from './promise.utility.js';
9
10
  export * from './request.utility.js';
10
- export * from './sleep.utility.js';
11
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utilities/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,gGAAgG;AAChG,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC","sourcesContent":["export * from './build-info.utility';\n// `RequestBodyErrors` stays on `/core`: consumers name it through the kernel's `RequestErrors`.\nexport { readFormBody } from './form-body.utility';\nexport * from './hr-time.utility';\nexport * from './module.utility';\nexport * from './parse.utility';\nexport * from './performance.utility';\nexport * from './promise.utility';\nexport * from './request.utility';\nexport * from './sleep.utility';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utilities/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,gGAAgG;AAChG,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC","sourcesContent":["export * from './build-info.utility';\n// `RequestBodyErrors` stays on `/core`: consumers name it through the kernel's `RequestErrors`.\nexport { FormBodyUtility } from './form-body.utility';\nexport * from './error.utility';\nexport * from './hr-time.utility';\nexport * from './module.utility';\nexport * from './parse.utility';\nexport * from './performance.utility';\nexport * from './promise.utility';\nexport * from './request.utility';\n"]}