@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 +1 @@
1
- {"version":3,"file":"module.utility.d.ts","sourceRoot":"","sources":["../../../src/utilities/module.utility.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAO9C,4LAA4L;AAC5L,qBAAa,aAAa;IACxB,0RAA0R;IAC1R,OAAO,CAA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84
84
  }
85
85
  try {
86
86
  const file = this.resolveEsmFile({ module });
87
- return (await import(file === undefined ? module : pathToFileURL(file).href));
87
+ const result = await import(file === undefined ? module : pathToFileURL(file).href);
88
+ return result;
88
89
  }
89
90
  catch (error) {
90
91
  throw this.fail({ method: 'load', module, error });
@@ -100,7 +101,8 @@ export class ModuleUtility {
100
101
  const loaded = {};
101
102
  for (const module of opts.modules) {
102
103
  // `load` answers from the registry first, so a module the application handed over comes back as itself.
103
- loaded[module] = await this.load({ module });
104
+ const result = await this.load({ module });
105
+ loaded[module] = result;
104
106
  }
105
107
  this.register({ modules: loaded });
106
108
  }
@@ -1 +1 @@
1
- {"version":3,"file":"module.utility.js","sourceRoot":"","sources":["../../../src/utilities/module.utility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE7D,MAAM,MAAM,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC;AAE1D,4LAA4L;AAC5L,MAAM,OAAO,aAAa;IACxB,0RAA0R;aAClQ,eAAU,GAAyB,aAAa,CAAC,cAAc,EAAE,CAAC;IAElF,MAAM,CAAC,cAAc;QAC3B,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;QACjD,MAAM,MAAM,GAAqC,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QAC/E,IAAI,MAAM,EAAE,CAAC;YACX,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,GAAG,EA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AC;gBACnD,SAAS;YACX,CAAC;YAED,IAAI,CAAC;gBACH,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YAC7B,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;YACvE,CAAC;QACH,CAAC;IACH,CAAC","sourcesContent":["import { createRequire } from 'node:module';\nimport path from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport type { AnyType } from '@/common/types';\nimport { LoggerFactory } from '@/modules/logger';\nimport { getError } from '@/modules/error';\nimport { ProjectRootRegistry } from './project-root.utility';\n\nconst logger = LoggerFactory.getLogger(['ModuleUtility']);\n\n/** Loads an optional peer without letting `Bun.build` see it: every specifier stays a parameter, so there is no literal (nor a `minify.syntax`-folded const) for the bundler to resolve. */\nexport class ModuleUtility {\n /** Peers handed over by the application, keyed by specifier. Checked before any filesystem lookup. The map lives in a globalThis slot because a process (or a compiled bundle) can carry two copies of this module, and a peer registered through one copy must be found by the other. */\n private static readonly registered: Map<string, AnyType> = ModuleUtility.sharedRegistry();\n\n private static sharedRegistry(): Map<string, AnyType> {\n const slot = Symbol.for('ignis:module-registry');\n const shared: Map<string, AnyType> | undefined = Reflect.get(globalThis, slot);\n if (shared) {\n return shared;\n }\n\n const created = new Map<string, AnyType>();\n Reflect.set(globalThis, slot, created);\n\n return created;\n }\n\n /** Called by the application once it knows its root (`configs.projectRoot` or the cwd); every peer lookup below follows it. Delegates to `ProjectRootRegistry`, which a browser Worker host reaches too through `/core` - the two must share ONE slot. */\n static setProjectRoot(opts: { projectRoot: string }): void {\n ProjectRootRegistry.set(opts);\n }\n\n static getProjectRoot(): string {\n return ProjectRootRegistry.getShared() ?? process.cwd();\n }\n\n /** Resolves peers against the APP's node_modules (under the project root), not this package's own `dist/` location. */\n private static appRequire() {\n return createRequire(path.join(this.getProjectRoot(), 'node_modules'));\n }\n\n private static fail(opts: { method: string; module: string; error: unknown; scope?: string }) {\n const { method, module, error, scope } = opts;\n const reason = error instanceof Error ? error.message : String(error);\n\n logger.for(method).error(\"Failed to load '%s' | Error: %s\", module, reason);\n\n return getError({\n message: `[ModuleUtility.${method}] ${module} is required, resolved from ${this.getProjectRoot()}${\n scope ? ` for ${scope}` : ''\n }. Please install '${module}' | Error: ${reason}`,\n });\n }\n\n /**\n * Hands the framework a peer the application already holds, so no filesystem lookup is needed.\n * A `bun build --compile` binary ships without `node_modules`, which leaves runtime resolution\n * nothing to resolve against: the application imports such a peer statically - that import is\n * what gets it into the binary - and registers it here before the consuming component boots.\n *\n * Deliberately does not log. It runs at the entrypoint of exactly the deployment that has no\n * logger provider yet, where `LoggerFactory` throws - and a throw mid-loop would drop every\n * module after the first.\n */\n static register(opts: { modules: Record<string, AnyType> }): void {\n const modulesEntries = Object.entries(opts.modules);\n for (const [module, value] of modulesEntries) {\n this.registered.set(module, value);\n }\n }\n\n /**\n * The file `module` resolves to from the project root under the ES module conditions (`import`), so\n * the peer is the very instance an application's own `import` of it gets. `undefined` when it does not\n * resolve there or the runtime has no resolver: the caller falls back to a plain `import()`.\n */\n private static resolveEsmFile(opts: { module: string }): string | undefined {\n if (typeof Bun === 'undefined') {\n return undefined;\n }\n\n try {\n const file = Bun.resolveSync(opts.module, this.getProjectRoot());\n return path.isAbsolute(file) ? file : undefined;\n } catch {\n return undefined;\n }\n }\n\n /**\n * Loads the module as an ES module, resolved from the project root: a peer that ships both builds\n * (`bullmq`, `socket.io-client`) is loaded as the copy the application's own `import` gets, not a second\n * one. A module handed over with {@link register} wins; one that does not resolve from the project root is\n * imported by name as before. Use this everywhere except a constructor, which cannot await - see {@link preload}.\n */\n static async load<T = AnyType>(opts: { module: string }): Promise<T> {\n const { module } = opts;\n\n if (this.registered.has(module)) {\n return this.registered.get(module) as T;\n }\n\n try {\n const file = this.resolveEsmFile({ module });\n return (await import(file === undefined ? module : pathToFileURL(file).href)) as T;\n } catch (error) {\n throw this.fail({ method: 'load', module, error });\n }\n }\n\n /**\n * The explicit register path for what a constructor needs: loads each module with {@link load} and\n * registers it, so the synchronous {@link loadSync} returns that ES module copy afterwards. Call it once\n * at the entrypoint, before the helpers are constructed. A module already registered is kept; every module\n * is loaded before any is registered, so one that is missing registers nothing.\n */\n static async preload(opts: { modules: Array<string> }): Promise<void> {\n const loaded: Record<string, AnyType> = {};\n\n for (const module of opts.modules) {\n // `load` answers from the registry first, so a module the application handed over comes back as itself.\n loaded[module] = await this.load({ module });\n }\n\n this.register({ modules: loaded });\n }\n\n /**\n * Sync twin of {@link load}, for a constructor or any path that cannot await. It resolves with\n * `require`, so a peer that ships both builds comes back as its CommonJS copy - a second instance next to\n * the one an application's `import` holds, and `instanceof` across the two fails. `await preload(...)` at the\n * entrypoint registers the ES module copy first, and this returns that.\n */\n static loadSync<T = AnyType>(opts: { module: string }): T {\n const { module } = opts;\n\n if (this.registered.has(module)) {\n return this.registered.get(module) as T;\n }\n\n try {\n return this.appRequire()(module) as T;\n } catch (error) {\n throw this.fail({ method: 'loadSync', module, error });\n }\n }\n\n /**\n * Presence check only - throws naming what to install, without executing the module.\n *\n * `allowRegistered` must be set only where {@link load} or {@link loadSync} is what finally loads\n * the module. Where the consumer resolves the specifier itself - `pino.transport()` inside a\n * worker thread, or any caller with its own `createRequire` - the registry cannot reach it, and\n * counting a registration as installed would replace this precise error with an opaque one.\n */\n static assertInstalled(opts: {\n modules: Array<string>;\n scope?: string;\n allowRegistered?: boolean;\n }): void {\n const { modules, scope, allowRegistered = false } = opts;\n const appRequire = this.appRequire();\n\n for (const module of modules) {\n if (allowRegistered && this.registered.has(module)) {\n continue;\n }\n\n try {\n appRequire.resolve(module);\n } catch (error) {\n throw this.fail({ method: 'assertInstalled', module, error, scope });\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"module.utility.js","sourceRoot":"","sources":["../../../src/utilities/module.utility.ts"],"names":[],"mappings":"AAAA,OAAO,E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KG;IACH,MAAM,CAAC,QAAQ,CAAc,IAAwB;QACnD,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QAExB,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;YAChC,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAM,CAAC;QAC1C,CAAC;QAED,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC,MAAM,CAAM,CAAC;QACxC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;QACzD,CAAC;IACH,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,eAAe,CAAC,IAItB;QACC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,eAAe,GAAG,KAAK,EAAE,GAAG,IAAI,CAAC;QACzD,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QAErC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,IAAI,eAAe,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;gBACnD,SAAS;YACX,CAAC;YAED,IAAI,CAAC;gBACH,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YAC7B,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;YACvE,CAAC;QACH,CAAC;IACH,CAAC","sourcesContent":["import { createRequire } from 'node:module';\nimport path from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport type { AnyType } from '@/common/types';\nimport { LoggerFactory } from '@/modules/logger';\nimport { getError } from '@/modules/error';\nimport { ProjectRootRegistry } from './project-root.utility';\n\nconst logger = LoggerFactory.getLogger(['ModuleUtility']);\n\n/** Loads an optional peer without letting `Bun.build` see it: every specifier stays a parameter, so there is no literal (nor a `minify.syntax`-folded const) for the bundler to resolve. */\nexport class ModuleUtility {\n /** Peers handed over by the application, keyed by specifier. Checked before any filesystem lookup. The map lives in a globalThis slot because a process (or a compiled bundle) can carry two copies of this module, and a peer registered through one copy must be found by the other. */\n private static readonly registered: Map<string, AnyType> = ModuleUtility.sharedRegistry();\n\n private static sharedRegistry(): Map<string, AnyType> {\n const slot = Symbol.for('ignis:module-registry');\n const shared: Map<string, AnyType> | undefined = Reflect.get(globalThis, slot);\n if (shared) {\n return shared;\n }\n\n const created = new Map<string, AnyType>();\n Reflect.set(globalThis, slot, created);\n\n return created;\n }\n\n /** Called by the application once it knows its root (`configs.projectRoot` or the cwd); every peer lookup below follows it. Delegates to `ProjectRootRegistry`, which a browser Worker host reaches too through `/core` - the two must share ONE slot. */\n static setProjectRoot(opts: { projectRoot: string }): void {\n ProjectRootRegistry.set(opts);\n }\n\n static getProjectRoot(): string {\n return ProjectRootRegistry.getShared() ?? process.cwd();\n }\n\n /** Resolves peers against the APP's node_modules (under the project root), not this package's own `dist/` location. */\n private static appRequire() {\n return createRequire(path.join(this.getProjectRoot(), 'node_modules'));\n }\n\n private static fail(opts: { method: string; module: string; error: unknown; scope?: string }) {\n const { method, module, error, scope } = opts;\n const reason = error instanceof Error ? error.message : String(error);\n\n logger.for(method).error(\"Failed to load '%s' | Error: %s\", module, reason);\n\n return getError({\n message: `[ModuleUtility.${method}] ${module} is required, resolved from ${this.getProjectRoot()}${\n scope ? ` for ${scope}` : ''\n }. Please install '${module}' | Error: ${reason}`,\n });\n }\n\n /**\n * Hands the framework a peer the application already holds, so no filesystem lookup is needed.\n * A `bun build --compile` binary ships without `node_modules`, which leaves runtime resolution\n * nothing to resolve against: the application imports such a peer statically - that import is\n * what gets it into the binary - and registers it here before the consuming component boots.\n *\n * Deliberately does not log. It runs at the entrypoint of exactly the deployment that has no\n * logger provider yet, where `LoggerFactory` throws - and a throw mid-loop would drop every\n * module after the first.\n */\n static register(opts: { modules: Record<string, AnyType> }): void {\n const modulesEntries = Object.entries(opts.modules);\n for (const [module, value] of modulesEntries) {\n this.registered.set(module, value);\n }\n }\n\n /**\n * The file `module` resolves to from the project root under the ES module conditions (`import`), so\n * the peer is the very instance an application's own `import` of it gets. `undefined` when it does not\n * resolve there or the runtime has no resolver: the caller falls back to a plain `import()`.\n */\n private static resolveEsmFile(opts: { module: string }): string | undefined {\n if (typeof Bun === 'undefined') {\n return undefined;\n }\n\n try {\n const file = Bun.resolveSync(opts.module, this.getProjectRoot());\n return path.isAbsolute(file) ? file : undefined;\n } catch {\n return undefined;\n }\n }\n\n /**\n * Loads the module as an ES module, resolved from the project root: a peer that ships both builds\n * (`bullmq`, `socket.io-client`) is loaded as the copy the application's own `import` gets, not a second\n * one. A module handed over with {@link register} wins; one that does not resolve from the project root is\n * imported by name as before. Use this everywhere except a constructor, which cannot await - see {@link preload}.\n */\n static async load<T = AnyType>(opts: { module: string }): Promise<T> {\n const { module } = opts;\n\n if (this.registered.has(module)) {\n return this.registered.get(module) as T;\n }\n\n try {\n const file = this.resolveEsmFile({ module });\n const result = await import(file === undefined ? module : pathToFileURL(file).href);\n return result as T;\n } catch (error) {\n throw this.fail({ method: 'load', module, error });\n }\n }\n\n /**\n * The explicit register path for what a constructor needs: loads each module with {@link load} and\n * registers it, so the synchronous {@link loadSync} returns that ES module copy afterwards. Call it once\n * at the entrypoint, before the helpers are constructed. A module already registered is kept; every module\n * is loaded before any is registered, so one that is missing registers nothing.\n */\n static async preload(opts: { modules: Array<string> }): Promise<void> {\n const loaded: Record<string, AnyType> = {};\n\n for (const module of opts.modules) {\n // `load` answers from the registry first, so a module the application handed over comes back as itself.\n const result = await this.load({ module });\n loaded[module] = result;\n }\n\n this.register({ modules: loaded });\n }\n\n /**\n * Sync twin of {@link load}, for a constructor or any path that cannot await. It resolves with\n * `require`, so a peer that ships both builds comes back as its CommonJS copy - a second instance next to\n * the one an application's `import` holds, and `instanceof` across the two fails. `await preload(...)` at the\n * entrypoint registers the ES module copy first, and this returns that.\n */\n static loadSync<T = AnyType>(opts: { module: string }): T {\n const { module } = opts;\n\n if (this.registered.has(module)) {\n return this.registered.get(module) as T;\n }\n\n try {\n return this.appRequire()(module) as T;\n } catch (error) {\n throw this.fail({ method: 'loadSync', module, error });\n }\n }\n\n /**\n * Presence check only - throws naming what to install, without executing the module.\n *\n * `allowRegistered` must be set only where {@link load} or {@link loadSync} is what finally loads\n * the module. Where the consumer resolves the specifier itself - `pino.transport()` inside a\n * worker thread, or any caller with its own `createRequire` - the registry cannot reach it, and\n * counting a registration as installed would replace this precise error with an opaque one.\n */\n static assertInstalled(opts: {\n modules: Array<string>;\n scope?: string;\n allowRegistered?: boolean;\n }): void {\n const { modules, scope, allowRegistered = false } = opts;\n const appRequire = this.appRequire();\n\n for (const module of modules) {\n if (allowRegistered && this.registered.has(module)) {\n continue;\n }\n\n try {\n appRequire.resolve(module);\n } catch (error) {\n throw this.fail({ method: 'assertInstalled', module, error, scope });\n }\n }\n }\n}\n"]}
@@ -1,44 +1,90 @@
1
- export declare const getUID: () => string;
2
- export declare const toCamel: (s: string) => string;
3
- export declare const keysToCamel: (object: object) => any;
4
- export declare const isInt: (n: any) => boolean;
5
- export declare const isFloat: (input: any) => boolean;
6
- /**
7
- * Parses an integer, TOTAL by design: it always answers a number, and answers `0` for anything it
8
- * cannot parse - `undefined`, `''`, `'abc'`.
9
- *
10
- * That makes `int(value) ?? fallback` dead code, because the left side is never nullish. The
11
- * fallback belongs INSIDE the call, and for an environment read it belongs in the read itself:
12
- *
13
- * ```ts
14
- * int(applicationEnvironment.get(KEY, { defaultValue: '6379' })) // correct
15
- * int(applicationEnvironment.get(KEY)) ?? 6379 // always 0 when KEY is unset
16
- * ```
17
- *
18
- * The second form is silent: a missing port reads `0` and a missing retry budget reads `0`, which
19
- * through `AbstractRedisHelper.buildRetryStrategy` means "give up after the first failure".
20
- */
21
- export declare const int: (input: any) => number;
22
- export declare const float: (input: any, digit?: number) => number;
23
- export declare const toBoolean: (input: any) => boolean;
24
- /** Converts an array to a Map keyed by `keyMap`. Last element wins on duplicate keys. */
25
- export declare const parseArrayToMapWithKey: <T extends Record<K, PropertyKey>, K extends keyof T>(arr: T[], keyMap: K) => Map<T[K], T>;
26
- /** Splits a delimited string into trimmed, non-empty entries - the transform for list-shaped env values (e.g. `applicationEnvironment.get(KEY, { transform: toDelimitedArray })`). */
27
- export declare const toDelimitedArray: (input: unknown, separator?: string) => string[];
28
- /**
29
- * A trimmed value, or `undefined` when the input is absent or carries nothing but whitespace.
30
- *
31
- * Written for environment reads. `KEY=` in a deployment file is a pipeline that forgot to export the
32
- * value, but `process.env.KEY` answers `''` for it, and `''` walks straight past `??`:
33
- *
34
- * ```ts
35
- * process.env.APP_ENV_LOGGER_FORMAT ?? 'text' // '' when the line is blank
36
- * blankToUndefined(process.env.APP_ENV_LOGGER_FORMAT) ?? 'text' // 'text'
37
- * ```
38
- *
39
- * Reach for this rather than `||`, which reads `'0'` as blank as well.
40
- */
41
- export declare const blankToUndefined: (input: string | undefined) => string | undefined;
42
- /** Trims a possibly-undefined env value to a clean string ('' when absent). */
43
- export declare const toTrimmed: (input: unknown) => string;
1
+ /** Number, string and key conversions that tolerate bad input; no node import, so it ships on `/core`. */
2
+ export declare class ParseUtility {
3
+ /**
4
+ * Rounds at a decimal precision, shifting the exponent rather than multiplying: `1.005` at 2 is
5
+ * `1.01` here, where `Math.round(1.005 * 100) / 100` gives `1`.
6
+ *
7
+ * Hand-written to keep lodash out of a browser bundle. One deliberate difference from `lodash/round`:
8
+ * a result of negative zero is normalised to `0`. They compare equal, stringify the same and
9
+ * serialise the same, so nothing downstream can tell - checked across 114 value/precision pairs, and
10
+ * the sign of zero was the only disagreement.
11
+ */
12
+ private static round;
13
+ /** Arrays stay arrays - mapping one through the object branch would turn it into an index-keyed object - but their object elements still need their keys camelized. Dates are opaque values. */
14
+ private static camelizeValue;
15
+ static getUID(): string;
16
+ static toCamel(opts: {
17
+ input: string;
18
+ }): string;
19
+ static keysToCamel(opts: {
20
+ source: object;
21
+ }): any;
22
+ static isInt(opts: {
23
+ input: any;
24
+ }): boolean;
25
+ static isFloat(opts: {
26
+ input: any;
27
+ }): boolean;
28
+ /**
29
+ * Parses an integer, TOTAL by design: it always answers a number, and answers `0` for anything it
30
+ * cannot parse - `undefined`, `''`, `'abc'`.
31
+ *
32
+ * That makes `ParseUtility.toInt({ input }) ?? fallback` dead code, because the left side is never
33
+ * nullish. The fallback belongs INSIDE the call, and for an environment read it belongs in the read
34
+ * itself:
35
+ *
36
+ * ```ts
37
+ * ParseUtility.toInt({ input: applicationEnvironment.get(KEY, { defaultValue: '6379' }) }) // correct
38
+ * ParseUtility.toInt({ input: applicationEnvironment.get(KEY) }) ?? 6379 // always 0 when KEY is unset
39
+ * ```
40
+ *
41
+ * The second form is silent: a missing port reads `0` and a missing retry budget reads `0`, which
42
+ * through `AbstractRedisHelper.buildRetryStrategy` means "give up after the first failure".
43
+ */
44
+ static toInt(opts: {
45
+ input: any;
46
+ }): number;
47
+ static toFloat(opts: {
48
+ input: any;
49
+ digit?: number;
50
+ }): number;
51
+ static toBoolean(opts: {
52
+ input: any;
53
+ }): boolean;
54
+ /** Converts an array to a Map keyed by `key`. Last element wins on duplicate keys. */
55
+ static parseArrayToMapWithKey<T extends Record<K, PropertyKey>, K extends keyof T>(opts: {
56
+ items: T[];
57
+ key: K;
58
+ }): Map<T[K], T>;
59
+ /** Splits a delimited string into trimmed, non-empty entries - the transform for list-shaped env values (e.g. `applicationEnvironment.get(KEY, { transform: (input) => ParseUtility.toDelimitedArray({ input }) })`). */
60
+ static toDelimitedArray(opts: {
61
+ input: unknown;
62
+ separator?: string;
63
+ }): string[];
64
+ /**
65
+ * A trimmed value, or `undefined` when the input is absent or carries nothing but whitespace.
66
+ *
67
+ * Written for environment reads. `KEY=` in a deployment file is a pipeline that forgot to export the
68
+ * value, but `process.env.KEY` answers `''` for it, and `''` walks straight past `??`:
69
+ *
70
+ * ```ts
71
+ * process.env.APP_ENV_LOGGER_FORMAT ?? 'text' // '' when the line is blank
72
+ * ParseUtility.blankToUndefined({ input: process.env.APP_ENV_LOGGER_FORMAT }) ?? 'text' // 'text'
73
+ * ```
74
+ *
75
+ * Reach for this rather than `||`, which reads `'0'` as blank as well.
76
+ */
77
+ static blankToUndefined(opts: {
78
+ input: string | undefined;
79
+ }): string | undefined;
80
+ /** Trims a possibly-undefined env value to a clean string ('' when absent). */
81
+ static toTrimmed(opts: {
82
+ input: unknown;
83
+ }): string;
84
+ /** Traverse a dotted property path on an object. */
85
+ static getDeepProperty<T, V>(opts: {
86
+ source: T;
87
+ path: string;
88
+ }): V;
89
+ }
44
90
  //# sourceMappingURL=parse.utility.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parse.utility.d.ts","sourceRoot":"","sources":["../../../src/utilities/parse.utility.ts"],"names":[],"mappings":"AAyBA,eAAO,MAAM,MAAM,cAA0D,CAAC;AAE9E,eAAO,MAAM,OAAO,GAAI,GAAG,MAAM,WAIhC,CAAC;AAqBF,eAAO,MAAM,WAAW,GAAI,QAAQ,MAAM,QASzC,CAAC;AAEF,eAAO,MAAM,KAAK,GAAI,GAAG,GAAG,YAM3B,CAAC;AAEF,eAAO,MAAM,OAAO,GAAI,OAAO,GAAG,YAMjC,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,GAAG,GAAI,OAAO,GAAG,WAY7B,CAAC;AAEF,eAAO,MAAM,KAAK,GAAI,OAAO,GAAG,EAAE,cAAS,WAY1C,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,OAAO,GAAG,KAAG,OAUtC,CAAC;AAEF,yFAAyF;AACzF,eAAO,MAAM,sBAAsB,GAAI,CAAC,SAAS,MAAM,CAAC,CAAC,EAAE,WAAW,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC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KAAK,EAAE,GAAG,CAAA;KAAE,GAAG,OAAO;IAa/C,sFAAsF;IACtF,MAAM,CAAC,sBAAsB,CAAC,CAAC,SAAS,MAAM,CAAC,CAAC,EAAE,WAAW,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,EAAE,IAAI,EAAE;QACvF,KAAK,EAAE,CAAC,EAAE,CAAC;QACX,GAAG,EAAE,CAAC,CAAC;KACR,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAoBhB,yNAAyN;IACzN,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,OAAO,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,EAAE;IAY/E;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,GAAG,MAAM,GAAG,SAAS;IAKhF,+EAA+E;IAC/E,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,OAAO,CAAA;KAAE,GAAG,MAAM;IASlD,oDAAoD;IACpD,MAAM,CAAC,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE;QAAE,MAAM,EAAE,CAAC,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,CAAC;CAanE"}
@@ -1,158 +1,190 @@
1
1
  import { getError } from '../modules/error/index.js';
2
- /**
3
- * Rounds at a decimal precision, shifting the exponent rather than multiplying: `1.005` at 2 is
4
- * `1.01` here, where `Math.round(1.005 * 100) / 100` gives `1`.
5
- *
6
- * Hand-written to keep lodash out of a browser bundle. One deliberate difference from `lodash/round`:
7
- * a result of negative zero is normalised to `0`. They compare equal, stringify the same and
8
- * serialise the same, so nothing downstream can tell - checked across 114 value/precision pairs, and
9
- * the sign of zero was the only disagreement.
10
- */
11
- const round = (opts) => {
12
- const { value, precision = 0 } = opts;
13
- if (!Number.isFinite(value) || precision === 0) {
14
- return Math.round(value) + 0;
15
- }
16
- const [mantissa, exponent] = `${value}e`.split('e');
17
- const shifted = Math.round(Number(`${mantissa}e${Number(exponent) + precision}`));
18
- const [shiftedMantissa, shiftedExponent] = `${shifted}e`.split('e');
19
- return Number(`${shiftedMantissa}e${Number(shiftedExponent) - precision}`) + 0;
20
- };
21
- export const getUID = () => Math.random().toString(36).slice(2).toUpperCase();
22
- export const toCamel = (s) => {
23
- return s.replace(/([-_][a-z])/gi, (sub) => {
24
- return sub.toUpperCase().replace('-', '').replace('_', '');
25
- });
26
- };
27
- /** Arrays stay arrays - mapping one through the object branch would turn it into an index-keyed object - but their object elements still need their keys camelized. Dates are opaque values. */
28
- const camelizeValue = (value) => {
29
- if (Array.isArray(value)) {
30
- return value.map((element) => camelizeValue(element));
2
+ /** Number, string and key conversions that tolerate bad input; no node import, so it ships on `/core`. */
3
+ export class ParseUtility {
4
+ /**
5
+ * Rounds at a decimal precision, shifting the exponent rather than multiplying: `1.005` at 2 is
6
+ * `1.01` here, where `Math.round(1.005 * 100) / 100` gives `1`.
7
+ *
8
+ * Hand-written to keep lodash out of a browser bundle. One deliberate difference from `lodash/round`:
9
+ * a result of negative zero is normalised to `0`. They compare equal, stringify the same and
10
+ * serialise the same, so nothing downstream can tell - checked across 114 value/precision pairs, and
11
+ * the sign of zero was the only disagreement.
12
+ */
13
+ static round(opts) {
14
+ const { value, precision = 0 } = opts;
15
+ if (!Number.isFinite(value) || precision === 0) {
16
+ return Math.round(value) + 0;
17
+ }
18
+ const [mantissa, exponent] = `${value}e`.split('e');
19
+ const shifted = Math.round(Number(`${mantissa}e${Number(exponent) + precision}`));
20
+ const [shiftedMantissa, shiftedExponent] = `${shifted}e`.split('e');
21
+ return Number(`${shiftedMantissa}e${Number(shiftedExponent) - precision}`) + 0;
31
22
  }
32
- if (!value || typeof value !== 'object' || value instanceof Date) {
33
- return value;
23
+ /** Arrays stay arrays - mapping one through the object branch would turn it into an index-keyed object - but their object elements still need their keys camelized. Dates are opaque values. */
24
+ static camelizeValue(opts) {
25
+ const { value } = opts;
26
+ if (Array.isArray(value)) {
27
+ return value.map((element) => ParseUtility.camelizeValue({ value: element }));
28
+ }
29
+ if (!value || typeof value !== 'object' || value instanceof Date) {
30
+ return value;
31
+ }
32
+ const camelized = {};
33
+ const valueKeys = Object.keys(value);
34
+ for (const key of valueKeys) {
35
+ camelized[ParseUtility.toCamel({ input: key })] = ParseUtility.camelizeValue({
36
+ value: value[key],
37
+ });
38
+ }
39
+ return camelized;
34
40
  }
35
- const camelized = {};
36
- const valueKeys = Object.keys(value);
37
- for (const key of valueKeys) {
38
- camelized[toCamel(key)] = camelizeValue(value[key]);
41
+ static getUID() {
42
+ return Math.random().toString(36).slice(2).toUpperCase();
39
43
  }
40
- return camelized;
41
- };
42
- export const keysToCamel = (object) => {
43
- const n = {};
44
- const keys = Object.keys(object);
45
- for (const key of keys) {
46
- n[toCamel(key)] = camelizeValue(object[key]);
44
+ static toCamel(opts) {
45
+ return opts.input.replace(/([-_][a-z])/gi, (sub) => {
46
+ return sub.toUpperCase().replace('-', '').replace('_', '');
47
+ });
47
48
  }
48
- return n;
49
- };
50
- export const isInt = (n) => {
51
- if (isNaN(n)) {
52
- return false;
49
+ static keysToCamel(opts) {
50
+ const { source } = opts;
51
+ const n = {};
52
+ const keys = Object.keys(source);
53
+ for (const key of keys) {
54
+ n[ParseUtility.toCamel({ input: key })] = ParseUtility.camelizeValue({
55
+ value: source[key],
56
+ });
57
+ }
58
+ return n;
53
59
  }
54
- return Number.isInteger(n) || Math.floor(Number(n)) === n || Number(n) % 1 === 0;
55
- };
56
- export const isFloat = (input) => {
57
- if (isNaN(input)) {
58
- return false;
60
+ static isInt(opts) {
61
+ const { input } = opts;
62
+ if (isNaN(input)) {
63
+ return false;
64
+ }
65
+ return (Number.isInteger(input) || Math.floor(Number(input)) === input || Number(input) % 1 === 0);
59
66
  }
60
- return Number(input) === input || Number(input) % 1 !== 0;
61
- };
62
- /**
63
- * Parses an integer, TOTAL by design: it always answers a number, and answers `0` for anything it
64
- * cannot parse - `undefined`, `''`, `'abc'`.
65
- *
66
- * That makes `int(value) ?? fallback` dead code, because the left side is never nullish. The
67
- * fallback belongs INSIDE the call, and for an environment read it belongs in the read itself:
68
- *
69
- * ```ts
70
- * int(applicationEnvironment.get(KEY, { defaultValue: '6379' })) // correct
71
- * int(applicationEnvironment.get(KEY)) ?? 6379 // always 0 when KEY is unset
72
- * ```
73
- *
74
- * The second form is silent: a missing port reads `0` and a missing retry budget reads `0`, which
75
- * through `AbstractRedisHelper.buildRetryStrategy` means "give up after the first failure".
76
- */
77
- export const int = (input) => {
78
- if (!input) {
79
- return 0;
67
+ static isFloat(opts) {
68
+ const { input } = opts;
69
+ if (isNaN(input)) {
70
+ return false;
71
+ }
72
+ return Number(input) === input || Number(input) % 1 !== 0;
80
73
  }
81
- const normalized = input?.toString()?.replace(/,/g, '');
82
- if (isNaN(normalized)) {
83
- return 0;
74
+ /**
75
+ * Parses an integer, TOTAL by design: it always answers a number, and answers `0` for anything it
76
+ * cannot parse - `undefined`, `''`, `'abc'`.
77
+ *
78
+ * That makes `ParseUtility.toInt({ input }) ?? fallback` dead code, because the left side is never
79
+ * nullish. The fallback belongs INSIDE the call, and for an environment read it belongs in the read
80
+ * itself:
81
+ *
82
+ * ```ts
83
+ * ParseUtility.toInt({ input: applicationEnvironment.get(KEY, { defaultValue: '6379' }) }) // correct
84
+ * ParseUtility.toInt({ input: applicationEnvironment.get(KEY) }) ?? 6379 // always 0 when KEY is unset
85
+ * ```
86
+ *
87
+ * The second form is silent: a missing port reads `0` and a missing retry budget reads `0`, which
88
+ * through `AbstractRedisHelper.buildRetryStrategy` means "give up after the first failure".
89
+ */
90
+ static toInt(opts) {
91
+ const { input } = opts;
92
+ if (!input) {
93
+ return 0;
94
+ }
95
+ const normalized = input?.toString()?.replace(/,/g, '');
96
+ if (isNaN(normalized)) {
97
+ return 0;
98
+ }
99
+ const parsed = Number.parseInt(normalized, 10);
100
+ return Number.isNaN(parsed) ? 0 : parsed;
84
101
  }
85
- const parsed = Number.parseInt(normalized, 10);
86
- return Number.isNaN(parsed) ? 0 : parsed;
87
- };
88
- export const float = (input, digit = 2) => {
89
- if (!input) {
90
- return 0;
102
+ static toFloat(opts) {
103
+ const { input, digit = 2 } = opts;
104
+ if (!input) {
105
+ return 0;
106
+ }
107
+ const normalized = input?.toString()?.replace(/,/g, '');
108
+ if (isNaN(normalized)) {
109
+ return 0;
110
+ }
111
+ const parsed = ParseUtility.round({ value: Number.parseFloat(normalized), precision: digit });
112
+ return Number.isNaN(parsed) ? 0 : parsed;
91
113
  }
92
- const normalized = input?.toString()?.replace(/,/g, '');
93
- if (isNaN(normalized)) {
94
- return 0;
114
+ static toBoolean(opts) {
115
+ const { input } = opts;
116
+ return (input !== '' &&
117
+ input !== 'false' &&
118
+ input !== '0' &&
119
+ input !== false &&
120
+ input !== 0 &&
121
+ input !== null &&
122
+ input !== undefined);
95
123
  }
96
- const parsed = round({ value: Number.parseFloat(normalized), precision: digit });
97
- return Number.isNaN(parsed) ? 0 : parsed;
98
- };
99
- export const toBoolean = (input) => {
100
- return (input !== '' &&
101
- input !== 'false' &&
102
- input !== '0' &&
103
- input !== false &&
104
- input !== 0 &&
105
- input !== null &&
106
- input !== undefined);
107
- };
108
- /** Converts an array to a Map keyed by `keyMap`. Last element wins on duplicate keys. */
109
- export const parseArrayToMapWithKey = (arr, keyMap) => {
110
- const resultMap = new Map();
111
- if (!arr.length) {
124
+ /** Converts an array to a Map keyed by `key`. Last element wins on duplicate keys. */
125
+ static parseArrayToMapWithKey(opts) {
126
+ const { items, key } = opts;
127
+ const resultMap = new Map();
128
+ if (!items.length) {
129
+ return resultMap;
130
+ }
131
+ items.forEach((element) => {
132
+ if (!(key in element)) {
133
+ throw getError({
134
+ message: 'Invalid keyMap',
135
+ });
136
+ }
137
+ resultMap.set(element[key], element);
138
+ });
112
139
  return resultMap;
113
140
  }
114
- arr.forEach((element) => {
115
- if (!(keyMap in element)) {
116
- throw getError({
117
- message: 'Invalid keyMap',
118
- });
141
+ /** Splits a delimited string into trimmed, non-empty entries - the transform for list-shaped env values (e.g. `applicationEnvironment.get(KEY, { transform: (input) => ParseUtility.toDelimitedArray({ input }) })`). */
142
+ static toDelimitedArray(opts) {
143
+ const { input, separator = ',' } = opts;
144
+ if (input == null) {
145
+ return [];
119
146
  }
120
- resultMap.set(element[keyMap], element);
121
- });
122
- return resultMap;
123
- };
124
- /** Splits a delimited string into trimmed, non-empty entries - the transform for list-shaped env values (e.g. `applicationEnvironment.get(KEY, { transform: toDelimitedArray })`). */
125
- export const toDelimitedArray = (input, separator = ',') => {
126
- if (input == null) {
127
- return [];
147
+ return String(input)
148
+ .split(separator)
149
+ .map((entry) => entry.trim())
150
+ .filter((entry) => entry.length > 0);
151
+ }
152
+ /**
153
+ * A trimmed value, or `undefined` when the input is absent or carries nothing but whitespace.
154
+ *
155
+ * Written for environment reads. `KEY=` in a deployment file is a pipeline that forgot to export the
156
+ * value, but `process.env.KEY` answers `''` for it, and `''` walks straight past `??`:
157
+ *
158
+ * ```ts
159
+ * process.env.APP_ENV_LOGGER_FORMAT ?? 'text' // '' when the line is blank
160
+ * ParseUtility.blankToUndefined({ input: process.env.APP_ENV_LOGGER_FORMAT }) ?? 'text' // 'text'
161
+ * ```
162
+ *
163
+ * Reach for this rather than `||`, which reads `'0'` as blank as well.
164
+ */
165
+ static blankToUndefined(opts) {
166
+ const trimmed = opts.input?.trim();
167
+ return trimmed === undefined || trimmed.length === 0 ? undefined : trimmed;
128
168
  }
129
- return String(input)
130
- .split(separator)
131
- .map((entry) => entry.trim())
132
- .filter((entry) => entry.length > 0);
133
- };
134
- /**
135
- * A trimmed value, or `undefined` when the input is absent or carries nothing but whitespace.
136
- *
137
- * Written for environment reads. `KEY=` in a deployment file is a pipeline that forgot to export the
138
- * value, but `process.env.KEY` answers `''` for it, and `''` walks straight past `??`:
139
- *
140
- * ```ts
141
- * process.env.APP_ENV_LOGGER_FORMAT ?? 'text' // '' when the line is blank
142
- * blankToUndefined(process.env.APP_ENV_LOGGER_FORMAT) ?? 'text' // 'text'
143
- * ```
144
- *
145
- * Reach for this rather than `||`, which reads `'0'` as blank as well.
146
- */
147
- export const blankToUndefined = (input) => {
148
- const trimmed = input?.trim();
149
- return trimmed === undefined || trimmed.length === 0 ? undefined : trimmed;
150
- };
151
- /** Trims a possibly-undefined env value to a clean string ('' when absent). */
152
- export const toTrimmed = (input) => {
153
- if (input == null) {
154
- return '';
169
+ /** Trims a possibly-undefined env value to a clean string ('' when absent). */
170
+ static toTrimmed(opts) {
171
+ const { input } = opts;
172
+ if (input == null) {
173
+ return '';
174
+ }
175
+ return String(input).trim();
176
+ }
177
+ /** Traverse a dotted property path on an object. */
178
+ static getDeepProperty(opts) {
179
+ const keys = opts.path.split('.');
180
+ let result = opts.source;
181
+ for (const key of keys) {
182
+ if (result == null) {
183
+ throw getError({ message: `Cannot read property '${key}' of ${result}` });
184
+ }
185
+ result = result[key];
186
+ }
187
+ return result;
155
188
  }
156
- return String(input).trim();
157
- };
189
+ }
158
190
  //# sourceMappingURL=parse.utility.js.map