@zudojs/errors 0.1.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (508) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +29 -8
  3. package/dist/base/core/baseError.core.d.ts +25 -2
  4. package/dist/base/core/baseError.core.js +95 -23
  5. package/dist/base/core/errorMetadata.core.d.ts +62 -5
  6. package/dist/base/core/errorMetadata.core.js +280 -23
  7. package/dist/base/types/errorCategory.helpers.js +3 -2
  8. package/dist/base/types/errorCode.type.d.ts +70 -1
  9. package/dist/base/types/errorCode.type.js +78 -2
  10. package/dist/base/types/errorSeverity.type.js +3 -2
  11. package/dist/base/utils/baseError.utils.d.ts +18 -2
  12. package/dist/base/utils/baseError.utils.js +68 -17
  13. package/dist/domain/access/rateLimit.error.d.ts +6 -1
  14. package/dist/domain/access/rateLimit.error.js +7 -9
  15. package/dist/domain/api/apiError.base.d.ts +3 -0
  16. package/dist/domain/api/apiError.base.js +5 -2
  17. package/dist/domain/api/apiError.lifecycle.d.ts +15 -1
  18. package/dist/domain/api/apiError.lifecycle.js +27 -7
  19. package/dist/domain/api/apiError.routing.d.ts +11 -3
  20. package/dist/domain/api/apiError.routing.js +12 -7
  21. package/dist/domain/app/domain.error.d.ts +2 -0
  22. package/dist/domain/app/domain.error.js +3 -1
  23. package/dist/domain/app/lifecycleError.types.js +2 -8
  24. package/dist/domain/app/moduleError.types.d.ts +3 -0
  25. package/dist/domain/app/moduleError.types.js +6 -2
  26. package/dist/domain/body/bodyParser.error.d.ts +9 -2
  27. package/dist/domain/body/bodyParser.error.js +20 -12
  28. package/dist/domain/body/httpBodyError.base.js +1 -2
  29. package/dist/domain/body/httpBodyError.types.js +1 -3
  30. package/dist/domain/body/httpFormData.error.js +2 -4
  31. package/dist/domain/body/multipart.error.js +2 -4
  32. package/dist/domain/documentation/documentationError.base.js +4 -2
  33. package/dist/domain/documentation/documentationError.types.js +1 -11
  34. package/dist/domain/documentation/index.d.ts +1 -1
  35. package/dist/domain/documentation/index.js +1 -1
  36. package/dist/domain/event/event.error.d.ts +1 -1
  37. package/dist/domain/event/event.error.js +1 -1
  38. package/dist/domain/event/eventError.base.d.ts +4 -1
  39. package/dist/domain/event/eventError.base.js +7 -9
  40. package/dist/domain/event/eventError.handler.d.ts +12 -3
  41. package/dist/domain/event/eventError.handler.js +21 -11
  42. package/dist/domain/event/eventError.lifecycle.d.ts +20 -3
  43. package/dist/domain/event/eventError.lifecycle.js +48 -18
  44. package/dist/domain/event/eventError.serialization.d.ts +10 -2
  45. package/dist/domain/event/eventError.serialization.js +16 -4
  46. package/dist/domain/message/message.error.d.ts +1 -0
  47. package/dist/domain/message/message.error.js +1 -0
  48. package/dist/domain/message/messageError.base.d.ts +4 -1
  49. package/dist/domain/message/messageError.base.js +7 -9
  50. package/dist/domain/message/messageError.handler.d.ts +12 -3
  51. package/dist/domain/message/messageError.handler.js +22 -12
  52. package/dist/domain/message/messageError.lifecycle.d.ts +5 -1
  53. package/dist/domain/message/messageError.lifecycle.js +15 -8
  54. package/dist/domain/message/messageError.serialization.d.ts +26 -0
  55. package/dist/domain/message/messageError.serialization.js +35 -0
  56. package/dist/domain/plugin/pluginError.lifecycle.js +23 -21
  57. package/dist/domain/plugin/pluginError.runtime.d.ts +5 -1
  58. package/dist/domain/plugin/pluginError.runtime.js +12 -7
  59. package/dist/domain/queue/queueError.base.d.ts +19 -0
  60. package/dist/domain/queue/queueError.base.js +24 -4
  61. package/dist/domain/queue/queueError.job.js +2 -0
  62. package/dist/domain/queue/queueError.worker.d.ts +9 -3
  63. package/dist/domain/queue/queueError.worker.js +14 -6
  64. package/dist/domain/rpc/rpcError.base.js +0 -2
  65. package/dist/domain/rpc/rpcError.protocol.js +0 -7
  66. package/dist/domain/rpc/rpcError.transport.d.ts +10 -1
  67. package/dist/domain/rpc/rpcError.transport.js +19 -9
  68. package/dist/domain/scheduler/schedulerError.base.d.ts +17 -3
  69. package/dist/domain/scheduler/schedulerError.base.js +26 -15
  70. package/dist/domain/scheduler/schedulerError.execution.d.ts +7 -6
  71. package/dist/domain/scheduler/schedulerError.execution.js +22 -18
  72. package/dist/domain/scheduler/schedulerError.schedule.d.ts +15 -5
  73. package/dist/domain/scheduler/schedulerError.schedule.js +32 -14
  74. package/dist/domain/schema/index.d.ts +2 -1
  75. package/dist/domain/schema/index.js +1 -1
  76. package/dist/domain/schema/schemaError.base.d.ts +31 -5
  77. package/dist/domain/schema/schemaError.base.js +34 -6
  78. package/dist/domain/schema/schemaError.types.js +12 -5
  79. package/dist/domain/serialization/serializationError.base.d.ts +8 -2
  80. package/dist/domain/serialization/serializationError.base.js +38 -8
  81. package/dist/domain/serialization/serializationError.types.d.ts +22 -3
  82. package/dist/domain/serialization/serializationError.types.js +30 -5
  83. package/dist/domain/shared/domainError.helpers.d.ts +60 -0
  84. package/dist/domain/shared/domainError.helpers.js +191 -0
  85. package/dist/domain/state/conflict.error.d.ts +1 -1
  86. package/dist/domain/state/conflict.error.js +2 -2
  87. package/dist/domain/state/validationError.base.d.ts +8 -1
  88. package/dist/domain/state/validationError.base.js +11 -2
  89. package/dist/infrastructure/adapter/adapterError.base.js +6 -6
  90. package/dist/infrastructure/adapter/adapterError.lifecycle.js +0 -3
  91. package/dist/infrastructure/adapter/adapterError.operation.js +0 -5
  92. package/dist/infrastructure/cache/cacheError.base.js +1 -1
  93. package/dist/infrastructure/container/containerError.registration.js +6 -4
  94. package/dist/infrastructure/network/httpAdapter.error.js +4 -2
  95. package/dist/infrastructure/network/httpClientError.advanced.js +10 -18
  96. package/dist/infrastructure/network/httpClientError.base.d.ts +11 -0
  97. package/dist/infrastructure/network/httpClientError.base.js +47 -7
  98. package/dist/infrastructure/network/httpClientError.common.d.ts +14 -0
  99. package/dist/infrastructure/network/httpClientError.common.js +21 -31
  100. package/dist/infrastructure/network/httpClientError.specialized.js +5 -8
  101. package/dist/infrastructure/network/httpClientError.types.d.ts +23 -2
  102. package/dist/infrastructure/network/httpClientError.types.js +55 -42
  103. package/dist/infrastructure/network/httpResponse.error.js +0 -3
  104. package/dist/infrastructure/network/httpRouterError.base.js +0 -1
  105. package/dist/infrastructure/network/httpRouterError.types.d.ts +5 -3
  106. package/dist/infrastructure/network/httpRouterError.types.js +6 -7
  107. package/dist/infrastructure/network/httpServerError.error.js +6 -10
  108. package/dist/infrastructure/network/httpServerLifecycleError.base.js +0 -1
  109. package/dist/infrastructure/network/httpServerLifecycleError.types.js +0 -3
  110. package/dist/infrastructure/network/httpStream.error.js +0 -1
  111. package/dist/infrastructure/network/network.error.d.ts +1 -1
  112. package/dist/infrastructure/network/network.error.js +1 -1
  113. package/dist/infrastructure/network/networkError.factory.d.ts +9 -2
  114. package/dist/infrastructure/network/networkError.factory.js +9 -2
  115. package/dist/infrastructure/network/routePattern.error.d.ts +7 -6
  116. package/dist/infrastructure/network/routePattern.error.js +16 -8
  117. package/dist/infrastructure/network/timeoutError.base.d.ts +7 -0
  118. package/dist/infrastructure/network/timeoutError.base.js +12 -1
  119. package/dist/infrastructure/network/timeoutError.factory.d.ts +14 -0
  120. package/dist/infrastructure/network/timeoutError.factory.js +25 -17
  121. package/dist/infrastructure/service/externalService.error.d.ts +1 -1
  122. package/dist/infrastructure/service/externalService.error.js +1 -1
  123. package/dist/infrastructure/service/externalServiceError.base.d.ts +8 -0
  124. package/dist/infrastructure/service/externalServiceError.base.js +8 -11
  125. package/dist/infrastructure/service/externalServiceError.factory.d.ts +3 -1
  126. package/dist/infrastructure/service/externalServiceError.factory.js +3 -1
  127. package/dist/infrastructure/storage/databaseError.factory.js +1 -1
  128. package/dist/infrastructure/storage/storageError.factory.js +2 -2
  129. package/dist/system/cryptoError.factory.js +5 -2
  130. package/dist/system/runtimeError.base.js +1 -1
  131. package/dist/utils/errorHandler.core.d.ts +42 -8
  132. package/dist/utils/errorHandler.core.js +116 -63
  133. package/dist/utils/errorHandler.factory.d.ts +1 -1
  134. package/dist/utils/errorHandler.factory.js +2 -2
  135. package/dist/utils/errorHandler.types.d.ts +37 -1
  136. package/dist/utils/errorMapper.core.d.ts +1 -1
  137. package/dist/utils/errorMapper.core.js +1 -1
  138. package/dist/utils/errorMapper.mappers.d.ts +27 -6
  139. package/dist/utils/errorMapper.mappers.js +57 -49
  140. package/dist/utils/errorSerializer.core.d.ts +22 -3
  141. package/dist/utils/errorSerializer.core.js +88 -40
  142. package/dist/utils/errorSerializer.factory.d.ts +1 -1
  143. package/dist/utils/errorSerializer.factory.js +2 -26
  144. package/dist/utils/errorSerializer.types.d.ts +14 -4
  145. package/dist/utils/errorUtils.extraction.js +3 -2
  146. package/dist/utils/errorUtils.transform.d.ts +1 -1
  147. package/dist/utils/errorUtils.transform.js +2 -26
  148. package/dist/utils/errorUtils.typeCheck.js +7 -7
  149. package/package.json +21 -10
  150. package/dist/.tsbuildinfo +0 -1
  151. package/dist/base/core/baseError.core.d.ts.map +0 -1
  152. package/dist/base/core/baseError.core.js.map +0 -1
  153. package/dist/base/core/errorMetadata.core.d.ts.map +0 -1
  154. package/dist/base/core/errorMetadata.core.js.map +0 -1
  155. package/dist/base/core/errorMetadata.type.d.ts.map +0 -1
  156. package/dist/base/core/errorMetadata.type.js.map +0 -1
  157. package/dist/base/core/index.d.ts.map +0 -1
  158. package/dist/base/core/index.js.map +0 -1
  159. package/dist/base/index.d.ts.map +0 -1
  160. package/dist/base/index.js.map +0 -1
  161. package/dist/base/types/baseError.type.d.ts.map +0 -1
  162. package/dist/base/types/baseError.type.js.map +0 -1
  163. package/dist/base/types/errorCategory.enum.d.ts.map +0 -1
  164. package/dist/base/types/errorCategory.enum.js.map +0 -1
  165. package/dist/base/types/errorCategory.helpers.d.ts.map +0 -1
  166. package/dist/base/types/errorCategory.helpers.js.map +0 -1
  167. package/dist/base/types/errorCategory.type.d.ts.map +0 -1
  168. package/dist/base/types/errorCategory.type.js.map +0 -1
  169. package/dist/base/types/errorCode.type.d.ts.map +0 -1
  170. package/dist/base/types/errorCode.type.js.map +0 -1
  171. package/dist/base/types/errorSeverity.type.d.ts.map +0 -1
  172. package/dist/base/types/errorSeverity.type.js.map +0 -1
  173. package/dist/base/types/index.d.ts.map +0 -1
  174. package/dist/base/types/index.js.map +0 -1
  175. package/dist/base/utils/baseError.utils.d.ts.map +0 -1
  176. package/dist/base/utils/baseError.utils.js.map +0 -1
  177. package/dist/base/utils/index.d.ts.map +0 -1
  178. package/dist/base/utils/index.js.map +0 -1
  179. package/dist/domain/access/authentication.error.d.ts.map +0 -1
  180. package/dist/domain/access/authentication.error.js.map +0 -1
  181. package/dist/domain/access/authorization.error.d.ts.map +0 -1
  182. package/dist/domain/access/authorization.error.js.map +0 -1
  183. package/dist/domain/access/index.d.ts.map +0 -1
  184. package/dist/domain/access/index.js.map +0 -1
  185. package/dist/domain/access/rateLimit.error.d.ts.map +0 -1
  186. package/dist/domain/access/rateLimit.error.js.map +0 -1
  187. package/dist/domain/api/api.error.d.ts.map +0 -1
  188. package/dist/domain/api/api.error.js.map +0 -1
  189. package/dist/domain/api/apiError.base.d.ts.map +0 -1
  190. package/dist/domain/api/apiError.base.js.map +0 -1
  191. package/dist/domain/api/apiError.lifecycle.d.ts.map +0 -1
  192. package/dist/domain/api/apiError.lifecycle.js.map +0 -1
  193. package/dist/domain/api/apiError.routing.d.ts.map +0 -1
  194. package/dist/domain/api/apiError.routing.js.map +0 -1
  195. package/dist/domain/api/index.d.ts.map +0 -1
  196. package/dist/domain/api/index.js.map +0 -1
  197. package/dist/domain/app/application.error.d.ts.map +0 -1
  198. package/dist/domain/app/application.error.js.map +0 -1
  199. package/dist/domain/app/configuration.error.d.ts.map +0 -1
  200. package/dist/domain/app/configuration.error.js.map +0 -1
  201. package/dist/domain/app/domain.error.d.ts.map +0 -1
  202. package/dist/domain/app/domain.error.js.map +0 -1
  203. package/dist/domain/app/index.d.ts.map +0 -1
  204. package/dist/domain/app/index.js.map +0 -1
  205. package/dist/domain/app/lifecycle.error.d.ts.map +0 -1
  206. package/dist/domain/app/lifecycle.error.js.map +0 -1
  207. package/dist/domain/app/lifecycleError.base.d.ts.map +0 -1
  208. package/dist/domain/app/lifecycleError.base.js.map +0 -1
  209. package/dist/domain/app/lifecycleError.types.d.ts.map +0 -1
  210. package/dist/domain/app/lifecycleError.types.js.map +0 -1
  211. package/dist/domain/app/module.error.d.ts.map +0 -1
  212. package/dist/domain/app/module.error.js.map +0 -1
  213. package/dist/domain/app/moduleError.base.d.ts.map +0 -1
  214. package/dist/domain/app/moduleError.base.js.map +0 -1
  215. package/dist/domain/app/moduleError.types.d.ts.map +0 -1
  216. package/dist/domain/app/moduleError.types.js.map +0 -1
  217. package/dist/domain/body/bodyParser.error.d.ts.map +0 -1
  218. package/dist/domain/body/bodyParser.error.js.map +0 -1
  219. package/dist/domain/body/httpBody.error.d.ts.map +0 -1
  220. package/dist/domain/body/httpBody.error.js.map +0 -1
  221. package/dist/domain/body/httpBodyError.base.d.ts.map +0 -1
  222. package/dist/domain/body/httpBodyError.base.js.map +0 -1
  223. package/dist/domain/body/httpBodyError.types.d.ts.map +0 -1
  224. package/dist/domain/body/httpBodyError.types.js.map +0 -1
  225. package/dist/domain/body/httpFormData.error.d.ts.map +0 -1
  226. package/dist/domain/body/httpFormData.error.js.map +0 -1
  227. package/dist/domain/body/index.d.ts.map +0 -1
  228. package/dist/domain/body/index.js.map +0 -1
  229. package/dist/domain/body/multipart.error.d.ts.map +0 -1
  230. package/dist/domain/body/multipart.error.js.map +0 -1
  231. package/dist/domain/documentation/documentation.error.d.ts.map +0 -1
  232. package/dist/domain/documentation/documentation.error.js.map +0 -1
  233. package/dist/domain/documentation/documentationError.base.d.ts.map +0 -1
  234. package/dist/domain/documentation/documentationError.base.js.map +0 -1
  235. package/dist/domain/documentation/documentationError.types.d.ts.map +0 -1
  236. package/dist/domain/documentation/documentationError.types.js.map +0 -1
  237. package/dist/domain/documentation/index.d.ts.map +0 -1
  238. package/dist/domain/documentation/index.js.map +0 -1
  239. package/dist/domain/event/event.error.d.ts.map +0 -1
  240. package/dist/domain/event/event.error.js.map +0 -1
  241. package/dist/domain/event/eventError.base.d.ts.map +0 -1
  242. package/dist/domain/event/eventError.base.js.map +0 -1
  243. package/dist/domain/event/eventError.handler.d.ts.map +0 -1
  244. package/dist/domain/event/eventError.handler.js.map +0 -1
  245. package/dist/domain/event/eventError.lifecycle.d.ts.map +0 -1
  246. package/dist/domain/event/eventError.lifecycle.js.map +0 -1
  247. package/dist/domain/event/eventError.serialization.d.ts.map +0 -1
  248. package/dist/domain/event/eventError.serialization.js.map +0 -1
  249. package/dist/domain/event/index.d.ts.map +0 -1
  250. package/dist/domain/event/index.js.map +0 -1
  251. package/dist/domain/index.d.ts.map +0 -1
  252. package/dist/domain/index.js.map +0 -1
  253. package/dist/domain/message/index.d.ts.map +0 -1
  254. package/dist/domain/message/index.js.map +0 -1
  255. package/dist/domain/message/message.error.d.ts.map +0 -1
  256. package/dist/domain/message/message.error.js.map +0 -1
  257. package/dist/domain/message/messageError.base.d.ts.map +0 -1
  258. package/dist/domain/message/messageError.base.js.map +0 -1
  259. package/dist/domain/message/messageError.handler.d.ts.map +0 -1
  260. package/dist/domain/message/messageError.handler.js.map +0 -1
  261. package/dist/domain/message/messageError.lifecycle.d.ts.map +0 -1
  262. package/dist/domain/message/messageError.lifecycle.js.map +0 -1
  263. package/dist/domain/message/messageError.validation.d.ts.map +0 -1
  264. package/dist/domain/message/messageError.validation.js.map +0 -1
  265. package/dist/domain/plugin/index.d.ts.map +0 -1
  266. package/dist/domain/plugin/index.js.map +0 -1
  267. package/dist/domain/plugin/plugin.error.d.ts.map +0 -1
  268. package/dist/domain/plugin/plugin.error.js.map +0 -1
  269. package/dist/domain/plugin/pluginError.base.d.ts.map +0 -1
  270. package/dist/domain/plugin/pluginError.base.js.map +0 -1
  271. package/dist/domain/plugin/pluginError.lifecycle.d.ts.map +0 -1
  272. package/dist/domain/plugin/pluginError.lifecycle.js.map +0 -1
  273. package/dist/domain/plugin/pluginError.runtime.d.ts.map +0 -1
  274. package/dist/domain/plugin/pluginError.runtime.js.map +0 -1
  275. package/dist/domain/queue/index.d.ts.map +0 -1
  276. package/dist/domain/queue/index.js.map +0 -1
  277. package/dist/domain/queue/queue.error.d.ts.map +0 -1
  278. package/dist/domain/queue/queue.error.js.map +0 -1
  279. package/dist/domain/queue/queueError.base.d.ts.map +0 -1
  280. package/dist/domain/queue/queueError.base.js.map +0 -1
  281. package/dist/domain/queue/queueError.job.d.ts.map +0 -1
  282. package/dist/domain/queue/queueError.job.js.map +0 -1
  283. package/dist/domain/queue/queueError.queue.d.ts.map +0 -1
  284. package/dist/domain/queue/queueError.queue.js.map +0 -1
  285. package/dist/domain/queue/queueError.worker.d.ts.map +0 -1
  286. package/dist/domain/queue/queueError.worker.js.map +0 -1
  287. package/dist/domain/rpc/index.d.ts.map +0 -1
  288. package/dist/domain/rpc/index.js.map +0 -1
  289. package/dist/domain/rpc/rpc.error.d.ts.map +0 -1
  290. package/dist/domain/rpc/rpc.error.js.map +0 -1
  291. package/dist/domain/rpc/rpcError.base.d.ts.map +0 -1
  292. package/dist/domain/rpc/rpcError.base.js.map +0 -1
  293. package/dist/domain/rpc/rpcError.protocol.d.ts.map +0 -1
  294. package/dist/domain/rpc/rpcError.protocol.js.map +0 -1
  295. package/dist/domain/rpc/rpcError.transport.d.ts.map +0 -1
  296. package/dist/domain/rpc/rpcError.transport.js.map +0 -1
  297. package/dist/domain/scheduler/index.d.ts.map +0 -1
  298. package/dist/domain/scheduler/index.js.map +0 -1
  299. package/dist/domain/scheduler/scheduler.error.d.ts.map +0 -1
  300. package/dist/domain/scheduler/scheduler.error.js.map +0 -1
  301. package/dist/domain/scheduler/schedulerError.base.d.ts.map +0 -1
  302. package/dist/domain/scheduler/schedulerError.base.js.map +0 -1
  303. package/dist/domain/scheduler/schedulerError.execution.d.ts.map +0 -1
  304. package/dist/domain/scheduler/schedulerError.execution.js.map +0 -1
  305. package/dist/domain/scheduler/schedulerError.schedule.d.ts.map +0 -1
  306. package/dist/domain/scheduler/schedulerError.schedule.js.map +0 -1
  307. package/dist/domain/schema/index.d.ts.map +0 -1
  308. package/dist/domain/schema/index.js.map +0 -1
  309. package/dist/domain/schema/schema.error.d.ts.map +0 -1
  310. package/dist/domain/schema/schema.error.js.map +0 -1
  311. package/dist/domain/schema/schemaError.base.d.ts.map +0 -1
  312. package/dist/domain/schema/schemaError.base.js.map +0 -1
  313. package/dist/domain/schema/schemaError.types.d.ts.map +0 -1
  314. package/dist/domain/schema/schemaError.types.js.map +0 -1
  315. package/dist/domain/serialization/index.d.ts.map +0 -1
  316. package/dist/domain/serialization/index.js.map +0 -1
  317. package/dist/domain/serialization/serialization.error.d.ts.map +0 -1
  318. package/dist/domain/serialization/serialization.error.js.map +0 -1
  319. package/dist/domain/serialization/serializationError.base.d.ts.map +0 -1
  320. package/dist/domain/serialization/serializationError.base.js.map +0 -1
  321. package/dist/domain/serialization/serializationError.types.d.ts.map +0 -1
  322. package/dist/domain/serialization/serializationError.types.js.map +0 -1
  323. package/dist/domain/state/conflict.error.d.ts.map +0 -1
  324. package/dist/domain/state/conflict.error.js.map +0 -1
  325. package/dist/domain/state/index.d.ts.map +0 -1
  326. package/dist/domain/state/index.js.map +0 -1
  327. package/dist/domain/state/notFound.error.d.ts.map +0 -1
  328. package/dist/domain/state/notFound.error.js.map +0 -1
  329. package/dist/domain/state/validation.error.d.ts.map +0 -1
  330. package/dist/domain/state/validation.error.js.map +0 -1
  331. package/dist/domain/state/validationError.base.d.ts.map +0 -1
  332. package/dist/domain/state/validationError.base.js.map +0 -1
  333. package/dist/domain/state/validationError.helpers.d.ts.map +0 -1
  334. package/dist/domain/state/validationError.helpers.js.map +0 -1
  335. package/dist/index.d.ts.map +0 -1
  336. package/dist/index.js.map +0 -1
  337. package/dist/infrastructure/adapter/adapter.error.d.ts.map +0 -1
  338. package/dist/infrastructure/adapter/adapter.error.js.map +0 -1
  339. package/dist/infrastructure/adapter/adapterError.base.d.ts.map +0 -1
  340. package/dist/infrastructure/adapter/adapterError.base.js.map +0 -1
  341. package/dist/infrastructure/adapter/adapterError.lifecycle.d.ts.map +0 -1
  342. package/dist/infrastructure/adapter/adapterError.lifecycle.js.map +0 -1
  343. package/dist/infrastructure/adapter/adapterError.operation.d.ts.map +0 -1
  344. package/dist/infrastructure/adapter/adapterError.operation.js.map +0 -1
  345. package/dist/infrastructure/adapter/index.d.ts.map +0 -1
  346. package/dist/infrastructure/adapter/index.js.map +0 -1
  347. package/dist/infrastructure/cache/cache.error.d.ts.map +0 -1
  348. package/dist/infrastructure/cache/cache.error.js.map +0 -1
  349. package/dist/infrastructure/cache/cacheError.base.d.ts.map +0 -1
  350. package/dist/infrastructure/cache/cacheError.base.js.map +0 -1
  351. package/dist/infrastructure/cache/cacheError.factory.d.ts.map +0 -1
  352. package/dist/infrastructure/cache/cacheError.factory.js.map +0 -1
  353. package/dist/infrastructure/cache/index.d.ts.map +0 -1
  354. package/dist/infrastructure/cache/index.js.map +0 -1
  355. package/dist/infrastructure/container/container.error.d.ts.map +0 -1
  356. package/dist/infrastructure/container/container.error.js.map +0 -1
  357. package/dist/infrastructure/container/containerError.base.d.ts.map +0 -1
  358. package/dist/infrastructure/container/containerError.base.js.map +0 -1
  359. package/dist/infrastructure/container/containerError.registration.d.ts.map +0 -1
  360. package/dist/infrastructure/container/containerError.registration.js.map +0 -1
  361. package/dist/infrastructure/container/index.d.ts.map +0 -1
  362. package/dist/infrastructure/container/index.js.map +0 -1
  363. package/dist/infrastructure/index.d.ts.map +0 -1
  364. package/dist/infrastructure/index.js.map +0 -1
  365. package/dist/infrastructure/middleware/index.d.ts.map +0 -1
  366. package/dist/infrastructure/middleware/index.js.map +0 -1
  367. package/dist/infrastructure/middleware/middleware.error.d.ts.map +0 -1
  368. package/dist/infrastructure/middleware/middleware.error.js.map +0 -1
  369. package/dist/infrastructure/network/http.error.d.ts.map +0 -1
  370. package/dist/infrastructure/network/http.error.js.map +0 -1
  371. package/dist/infrastructure/network/httpAdapter.error.d.ts.map +0 -1
  372. package/dist/infrastructure/network/httpAdapter.error.js.map +0 -1
  373. package/dist/infrastructure/network/httpClient.errors.d.ts.map +0 -1
  374. package/dist/infrastructure/network/httpClient.errors.js.map +0 -1
  375. package/dist/infrastructure/network/httpClientError.advanced.d.ts.map +0 -1
  376. package/dist/infrastructure/network/httpClientError.advanced.js.map +0 -1
  377. package/dist/infrastructure/network/httpClientError.base.d.ts.map +0 -1
  378. package/dist/infrastructure/network/httpClientError.base.js.map +0 -1
  379. package/dist/infrastructure/network/httpClientError.common.d.ts.map +0 -1
  380. package/dist/infrastructure/network/httpClientError.common.js.map +0 -1
  381. package/dist/infrastructure/network/httpClientError.error.d.ts.map +0 -1
  382. package/dist/infrastructure/network/httpClientError.error.js.map +0 -1
  383. package/dist/infrastructure/network/httpClientError.options.d.ts.map +0 -1
  384. package/dist/infrastructure/network/httpClientError.options.js.map +0 -1
  385. package/dist/infrastructure/network/httpClientError.specialized.d.ts.map +0 -1
  386. package/dist/infrastructure/network/httpClientError.specialized.js.map +0 -1
  387. package/dist/infrastructure/network/httpClientError.types.d.ts.map +0 -1
  388. package/dist/infrastructure/network/httpClientError.types.js.map +0 -1
  389. package/dist/infrastructure/network/httpError.base.d.ts.map +0 -1
  390. package/dist/infrastructure/network/httpError.base.js.map +0 -1
  391. package/dist/infrastructure/network/httpError.helpers.d.ts.map +0 -1
  392. package/dist/infrastructure/network/httpError.helpers.js.map +0 -1
  393. package/dist/infrastructure/network/httpResponse.error.d.ts.map +0 -1
  394. package/dist/infrastructure/network/httpResponse.error.js.map +0 -1
  395. package/dist/infrastructure/network/httpRouter.error.d.ts.map +0 -1
  396. package/dist/infrastructure/network/httpRouter.error.js.map +0 -1
  397. package/dist/infrastructure/network/httpRouterError.base.d.ts.map +0 -1
  398. package/dist/infrastructure/network/httpRouterError.base.js.map +0 -1
  399. package/dist/infrastructure/network/httpRouterError.types.d.ts.map +0 -1
  400. package/dist/infrastructure/network/httpRouterError.types.js.map +0 -1
  401. package/dist/infrastructure/network/httpServerError.error.d.ts.map +0 -1
  402. package/dist/infrastructure/network/httpServerError.error.js.map +0 -1
  403. package/dist/infrastructure/network/httpServerLifecycle.error.d.ts.map +0 -1
  404. package/dist/infrastructure/network/httpServerLifecycle.error.js.map +0 -1
  405. package/dist/infrastructure/network/httpServerLifecycleError.base.d.ts.map +0 -1
  406. package/dist/infrastructure/network/httpServerLifecycleError.base.js.map +0 -1
  407. package/dist/infrastructure/network/httpServerLifecycleError.types.d.ts.map +0 -1
  408. package/dist/infrastructure/network/httpServerLifecycleError.types.js.map +0 -1
  409. package/dist/infrastructure/network/httpStream.error.d.ts.map +0 -1
  410. package/dist/infrastructure/network/httpStream.error.js.map +0 -1
  411. package/dist/infrastructure/network/index.d.ts.map +0 -1
  412. package/dist/infrastructure/network/index.js.map +0 -1
  413. package/dist/infrastructure/network/network.error.d.ts.map +0 -1
  414. package/dist/infrastructure/network/network.error.js.map +0 -1
  415. package/dist/infrastructure/network/networkError.base.d.ts.map +0 -1
  416. package/dist/infrastructure/network/networkError.base.js.map +0 -1
  417. package/dist/infrastructure/network/networkError.factory.d.ts.map +0 -1
  418. package/dist/infrastructure/network/networkError.factory.js.map +0 -1
  419. package/dist/infrastructure/network/routePattern.error.d.ts.map +0 -1
  420. package/dist/infrastructure/network/routePattern.error.js.map +0 -1
  421. package/dist/infrastructure/network/timeout.error.d.ts.map +0 -1
  422. package/dist/infrastructure/network/timeout.error.js.map +0 -1
  423. package/dist/infrastructure/network/timeoutError.base.d.ts.map +0 -1
  424. package/dist/infrastructure/network/timeoutError.base.js.map +0 -1
  425. package/dist/infrastructure/network/timeoutError.factory.d.ts.map +0 -1
  426. package/dist/infrastructure/network/timeoutError.factory.js.map +0 -1
  427. package/dist/infrastructure/service/externalService.error.d.ts.map +0 -1
  428. package/dist/infrastructure/service/externalService.error.js.map +0 -1
  429. package/dist/infrastructure/service/externalServiceError.base.d.ts.map +0 -1
  430. package/dist/infrastructure/service/externalServiceError.base.js.map +0 -1
  431. package/dist/infrastructure/service/externalServiceError.factory.d.ts.map +0 -1
  432. package/dist/infrastructure/service/externalServiceError.factory.js.map +0 -1
  433. package/dist/infrastructure/service/index.d.ts.map +0 -1
  434. package/dist/infrastructure/service/index.js.map +0 -1
  435. package/dist/infrastructure/service/service.error.d.ts.map +0 -1
  436. package/dist/infrastructure/service/service.error.js.map +0 -1
  437. package/dist/infrastructure/service/serviceError.base.d.ts.map +0 -1
  438. package/dist/infrastructure/service/serviceError.base.js.map +0 -1
  439. package/dist/infrastructure/service/serviceError.factory.d.ts.map +0 -1
  440. package/dist/infrastructure/service/serviceError.factory.js.map +0 -1
  441. package/dist/infrastructure/storage/database.error.d.ts.map +0 -1
  442. package/dist/infrastructure/storage/database.error.js.map +0 -1
  443. package/dist/infrastructure/storage/databaseError.base.d.ts.map +0 -1
  444. package/dist/infrastructure/storage/databaseError.base.js.map +0 -1
  445. package/dist/infrastructure/storage/databaseError.factory.d.ts.map +0 -1
  446. package/dist/infrastructure/storage/databaseError.factory.js.map +0 -1
  447. package/dist/infrastructure/storage/index.d.ts.map +0 -1
  448. package/dist/infrastructure/storage/index.js.map +0 -1
  449. package/dist/infrastructure/storage/storage.error.d.ts.map +0 -1
  450. package/dist/infrastructure/storage/storage.error.js.map +0 -1
  451. package/dist/infrastructure/storage/storageError.base.d.ts.map +0 -1
  452. package/dist/infrastructure/storage/storageError.base.js.map +0 -1
  453. package/dist/infrastructure/storage/storageError.factory.d.ts.map +0 -1
  454. package/dist/infrastructure/storage/storageError.factory.js.map +0 -1
  455. package/dist/system/crypto.error.d.ts.map +0 -1
  456. package/dist/system/crypto.error.js.map +0 -1
  457. package/dist/system/cryptoError.base.d.ts.map +0 -1
  458. package/dist/system/cryptoError.base.js.map +0 -1
  459. package/dist/system/cryptoError.factory.d.ts.map +0 -1
  460. package/dist/system/cryptoError.factory.js.map +0 -1
  461. package/dist/system/index.d.ts.map +0 -1
  462. package/dist/system/index.js.map +0 -1
  463. package/dist/system/logging/index.d.ts.map +0 -1
  464. package/dist/system/logging/index.js.map +0 -1
  465. package/dist/system/logging/logging.error.d.ts.map +0 -1
  466. package/dist/system/logging/logging.error.js.map +0 -1
  467. package/dist/system/runtime.error.d.ts.map +0 -1
  468. package/dist/system/runtime.error.js.map +0 -1
  469. package/dist/system/runtimeError.base.d.ts.map +0 -1
  470. package/dist/system/runtimeError.base.js.map +0 -1
  471. package/dist/system/runtimeError.types.d.ts.map +0 -1
  472. package/dist/system/runtimeError.types.js.map +0 -1
  473. package/dist/system/system.error.d.ts.map +0 -1
  474. package/dist/system/system.error.js.map +0 -1
  475. package/dist/system/systemError.base.d.ts.map +0 -1
  476. package/dist/system/systemError.base.js.map +0 -1
  477. package/dist/system/systemError.factory.d.ts.map +0 -1
  478. package/dist/system/systemError.factory.js.map +0 -1
  479. package/dist/utils/errorHandler.core.d.ts.map +0 -1
  480. package/dist/utils/errorHandler.core.js.map +0 -1
  481. package/dist/utils/errorHandler.factory.d.ts.map +0 -1
  482. package/dist/utils/errorHandler.factory.js.map +0 -1
  483. package/dist/utils/errorHandler.types.d.ts.map +0 -1
  484. package/dist/utils/errorHandler.types.js.map +0 -1
  485. package/dist/utils/errorMapper.core.d.ts.map +0 -1
  486. package/dist/utils/errorMapper.core.js.map +0 -1
  487. package/dist/utils/errorMapper.mappers.d.ts.map +0 -1
  488. package/dist/utils/errorMapper.mappers.js.map +0 -1
  489. package/dist/utils/errorMapper.registry.d.ts.map +0 -1
  490. package/dist/utils/errorMapper.registry.js.map +0 -1
  491. package/dist/utils/errorMapper.types.d.ts.map +0 -1
  492. package/dist/utils/errorMapper.types.js.map +0 -1
  493. package/dist/utils/errorSerializer.core.d.ts.map +0 -1
  494. package/dist/utils/errorSerializer.core.js.map +0 -1
  495. package/dist/utils/errorSerializer.factory.d.ts.map +0 -1
  496. package/dist/utils/errorSerializer.factory.js.map +0 -1
  497. package/dist/utils/errorSerializer.types.d.ts.map +0 -1
  498. package/dist/utils/errorSerializer.types.js.map +0 -1
  499. package/dist/utils/errorUtils.extraction.d.ts.map +0 -1
  500. package/dist/utils/errorUtils.extraction.js.map +0 -1
  501. package/dist/utils/errorUtils.helper.d.ts.map +0 -1
  502. package/dist/utils/errorUtils.helper.js.map +0 -1
  503. package/dist/utils/errorUtils.transform.d.ts.map +0 -1
  504. package/dist/utils/errorUtils.transform.js.map +0 -1
  505. package/dist/utils/errorUtils.typeCheck.d.ts.map +0 -1
  506. package/dist/utils/errorUtils.typeCheck.js.map +0 -1
  507. package/dist/utils/index.d.ts.map +0 -1
  508. package/dist/utils/index.js.map +0 -1
@@ -2,6 +2,7 @@
2
2
  * Converts errors into safe, predictable serialized structures.
3
3
  */
4
4
  import { BaseError } from "../base/core/baseError.core.js";
5
+ import { pickErrorMetadata, redactErrorMetadata, } from "../base/core/errorMetadata.core.js";
5
6
  import { normalizeUnknownError } from "./errorSerializer.factory.js";
6
7
  export { createErrorSerializer, serializeError, serializePublicError, normalizeUnknownError, } from "./errorSerializer.factory.js";
7
8
  /** Converts errors into safe, predictable serialized structures. */
@@ -11,41 +12,41 @@ export class ErrorSerializer {
11
12
  includeMetadata;
12
13
  safeMessage;
13
14
  redactSensitiveData;
15
+ sensitiveKeyPattern;
16
+ publicMetadataKeys;
14
17
  constructor(options = {}) {
15
18
  this.includeStack = options.includeStack ?? false;
16
19
  this.includeCause = options.includeCause ?? false;
17
20
  this.includeMetadata = options.includeMetadata ?? true;
18
21
  this.safeMessage = options.safeMessage ?? "An unexpected error occurred.";
19
22
  this.redactSensitiveData = options.redactSensitiveData ?? true;
23
+ this.sensitiveKeyPattern = options.sensitiveKeyPattern;
24
+ this.publicMetadataKeys = options.publicMetadataKeys;
20
25
  }
21
- /** Serializes an error for internal logging or monitoring. */
26
+ /**
27
+ * Serializes an error for internal logging or monitoring.
28
+ *
29
+ * `includeStack`, `includeCause` and `redactSensitiveData` are applied at
30
+ * every level of the cause chain.
31
+ */
22
32
  serialize(error) {
23
- const serialized = error.toJSON();
24
- const result = {
25
- ...serialized,
26
- ...(this.includeStack ? {} : { stack: undefined }),
27
- ...(this.includeCause ? {} : { cause: undefined }),
28
- ...(this.includeMetadata ? {} : { metadata: {} }),
29
- };
30
- if (this.redactSensitiveData && result.metadata) {
31
- return {
32
- ...result,
33
- metadata: this.redactMetadata(result.metadata),
34
- };
35
- }
36
- return result;
33
+ return this.serializeLevel(error.toJSON());
37
34
  }
38
- /** Serializes an error for an untrusted API client. */
35
+ /**
36
+ * Serializes an error for an untrusted API client.
37
+ *
38
+ * Never includes a stack or cause. Metadata is only included when the error
39
+ * is exposable (or when `publicMetadataKeys` allow-lists specific keys) and
40
+ * is always redacted.
41
+ */
39
42
  serializePublic(error) {
40
- const metadata = this.includeMetadata
41
- ? this.redactMetadata(error.metadata)
42
- : undefined;
43
+ const metadata = this.publicMetadata(error);
43
44
  return {
44
45
  code: error.code,
45
46
  message: error.expose ? error.message : this.safeMessage,
46
47
  category: error.category,
47
48
  statusCode: error.statusCode,
48
- ...(metadata && Object.keys(metadata).length > 0 ? { metadata } : {}),
49
+ ...(metadata !== undefined ? { metadata } : {}),
49
50
  };
50
51
  }
51
52
  /** Serializes an unknown thrown value. */
@@ -56,27 +57,74 @@ export class ErrorSerializer {
56
57
  serializeUnknownPublic(value) {
57
58
  return this.serializePublic(normalizeUnknownError(value));
58
59
  }
59
- /** Removes commonly sensitive metadata fields. */
60
- redactMetadata(metadata) {
61
- const sensitiveKeys = new Set([
62
- "password",
63
- "passcode",
64
- "token",
65
- "accessToken",
66
- "refreshToken",
67
- "authorization",
68
- "cookie",
69
- "secret",
70
- "privateKey",
71
- "apiKey",
72
- "credential",
73
- "clientSecret",
74
- ]);
75
- const result = {};
76
- for (const [key, value] of Object.entries(metadata)) {
77
- result[key] = sensitiveKeys.has(key) ? "[REDACTED]" : value;
78
- }
60
+ /** Applies the serializer options to one level of a serialized error. */
61
+ serializeLevel(serialized) {
62
+ const { stack, cause, metadata, ...rest } = serialized;
63
+ const result = {
64
+ ...rest,
65
+ metadata: this.includeMetadata
66
+ ? this.redactSensitiveData
67
+ ? this.redactMetadata(metadata)
68
+ : metadata
69
+ : {},
70
+ ...(this.includeStack && stack !== undefined ? { stack } : {}),
71
+ ...(this.includeCause && cause !== undefined
72
+ ? { cause: this.serializeCause(cause) }
73
+ : {}),
74
+ };
79
75
  return result;
80
76
  }
77
+ /** Applies the serializer options recursively to a serialized cause. */
78
+ serializeCause(cause) {
79
+ if (cause === null || typeof cause !== "object")
80
+ return cause;
81
+ if (Array.isArray(cause))
82
+ return cause;
83
+ const record = cause;
84
+ if (isSerializedBaseError(record)) {
85
+ return this.serializeLevel(record);
86
+ }
87
+ // Native error shape: { name, message, stack?, cause? }
88
+ const { stack, cause: nested, ...rest } = record;
89
+ return {
90
+ ...rest,
91
+ ...(this.includeStack && stack !== undefined ? { stack } : {}),
92
+ ...(nested !== undefined ? { cause: this.serializeCause(nested) } : {}),
93
+ };
94
+ }
95
+ /** Computes the metadata allowed in a public response. */
96
+ publicMetadata(error) {
97
+ if (!this.includeMetadata)
98
+ return undefined;
99
+ let metadata;
100
+ if (this.publicMetadataKeys !== undefined) {
101
+ metadata = pickErrorMetadata(error.metadata, this.publicMetadataKeys);
102
+ }
103
+ else if (error.expose) {
104
+ metadata = error.metadata;
105
+ }
106
+ else {
107
+ return undefined;
108
+ }
109
+ const redacted = this.redactSensitiveData
110
+ ? this.redactMetadata(metadata)
111
+ : metadata;
112
+ return Object.keys(redacted).length > 0 ? redacted : undefined;
113
+ }
114
+ /** Removes commonly sensitive metadata fields (recursively). */
115
+ redactMetadata(metadata) {
116
+ return redactErrorMetadata(metadata, {
117
+ sensitiveKeyPattern: this.sensitiveKeyPattern,
118
+ });
119
+ }
120
+ }
121
+ /** Structural check for a serialized BaseError (used on nested causes). */
122
+ function isSerializedBaseError(value) {
123
+ return (typeof value.code === "string" &&
124
+ typeof value.category === "string" &&
125
+ typeof value.severity === "string" &&
126
+ typeof value.statusCode === "number" &&
127
+ typeof value.metadata === "object" &&
128
+ value.metadata !== null);
81
129
  }
82
130
  //# sourceMappingURL=errorSerializer.core.js.map
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Error serializer factory and utility functions.
3
3
  */
4
- import { BaseError } from "../base/core/baseError.core.js";
4
+ import type { BaseError } from "../base/core/baseError.core.js";
5
5
  import { ErrorSerializer } from "./errorSerializer.core.js";
6
6
  import type { ErrorSerializerOptions, PublicErrorResponse, InternalErrorResponse } from "./errorSerializer.types.js";
7
7
  export type { ErrorSerializerOptions, PublicErrorResponse, InternalErrorResponse, } from "./errorSerializer.types.js";
@@ -1,9 +1,7 @@
1
1
  /**
2
2
  * Error serializer factory and utility functions.
3
3
  */
4
- import { BaseError } from "../base/core/baseError.core.js";
5
- import { ErrorCategory } from "../base/types/errorCategory.type.js";
6
- import { ErrorSeverity } from "../base/types/errorSeverity.type.js";
4
+ import { normalizeUnknownToBaseError } from "../base/utils/baseError.utils.js";
7
5
  import { ErrorSerializer } from "./errorSerializer.core.js";
8
6
  /** Creates an ErrorSerializer instance. */
9
7
  export function createErrorSerializer(options = {}) {
@@ -19,28 +17,6 @@ export function serializePublicError(error, options = {}) {
19
17
  }
20
18
  /** Converts an unknown thrown value into a BaseError. */
21
19
  export function normalizeUnknownError(value) {
22
- if (value instanceof BaseError) {
23
- return value;
24
- }
25
- if (value instanceof Error) {
26
- return new BaseError(value.message || "An unexpected error occurred.", {
27
- code: "INTERNAL_ERROR",
28
- category: ErrorCategory.SYSTEM,
29
- severity: ErrorSeverity.ERROR,
30
- statusCode: 500,
31
- expose: false,
32
- isOperational: false,
33
- cause: value,
34
- });
35
- }
36
- return new BaseError("An unexpected error occurred.", {
37
- code: "INTERNAL_ERROR",
38
- category: ErrorCategory.SYSTEM,
39
- severity: ErrorSeverity.ERROR,
40
- statusCode: 500,
41
- expose: false,
42
- isOperational: false,
43
- metadata: { originalType: typeof value },
44
- });
20
+ return normalizeUnknownToBaseError(value);
45
21
  }
46
22
  //# sourceMappingURL=errorSerializer.factory.js.map
@@ -5,16 +5,26 @@ import type { SerializedBaseError } from "../base/types/baseError.type.js";
5
5
  import { ErrorCategory } from "../base/types/errorCategory.type.js";
6
6
  /** Options controlling error serialization. */
7
7
  export interface ErrorSerializerOptions {
8
- /** Include the stack trace in the serialized result. Defaults to false. */
8
+ /** Include the stack trace (at every level of the cause chain). Defaults to false. */
9
9
  readonly includeStack?: boolean;
10
- /** Include the error cause. Defaults to false. */
10
+ /** Include the error cause chain. Defaults to false. */
11
11
  readonly includeCause?: boolean;
12
- /** Include internal metadata. Defaults to true for internal serialization. */
12
+ /** Include metadata in internal serialization. Defaults to true. */
13
13
  readonly includeMetadata?: boolean;
14
14
  /** Replace non-exposable error messages with a safe message. */
15
15
  readonly safeMessage?: string;
16
- /** Remove sensitive metadata values. */
16
+ /** Redact sensitive metadata values (recursively, at every level). Defaults to true. */
17
17
  readonly redactSensitiveData?: boolean;
18
+ /** Pattern used to detect sensitive metadata keys. Defaults to the package pattern. */
19
+ readonly sensitiveKeyPattern?: RegExp;
20
+ /**
21
+ * Metadata keys allowed in public output.
22
+ *
23
+ * When provided, only these keys are copied into `PublicErrorResponse.metadata`
24
+ * (for exposed and non-exposed errors alike). When omitted, metadata is only
25
+ * included for errors with `expose: true`, and never for non-exposed errors.
26
+ */
27
+ readonly publicMetadataKeys?: readonly string[];
18
28
  }
19
29
  /** Public error representation suitable for an API response. */
20
30
  export interface PublicErrorResponse {
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Error extraction utilities — message, name, stack, root cause.
3
3
  */
4
+ import { isBaseError } from "../base/utils/baseError.utils.js";
4
5
  import { BaseError } from "../base/core/baseError.core.js";
5
6
  import { isErrorLike } from "./errorUtils.typeCheck.js";
6
7
  /** Returns the message from an unknown thrown value. */
@@ -56,7 +57,7 @@ export function getRootBaseError(value) {
56
57
  const visited = new Set();
57
58
  while (current !== undefined && current !== null && !visited.has(current)) {
58
59
  visited.add(current);
59
- if (current instanceof BaseError) {
60
+ if (isBaseError(current)) {
60
61
  result = current;
61
62
  }
62
63
  if (current instanceof Error && "cause" in current) {
@@ -77,7 +78,7 @@ export function getErrorDiagnostics(value) {
77
78
  if (stack !== undefined) {
78
79
  diagnostics.stack = stack;
79
80
  }
80
- if (value instanceof BaseError) {
81
+ if (isBaseError(value)) {
81
82
  diagnostics.code = value.code;
82
83
  diagnostics.category = value.category;
83
84
  diagnostics.severity = value.severity;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Error transformation utilities — toError, withErrorContext, tryCatch, normalize.
3
3
  */
4
- import { BaseError } from "../base/core/baseError.core.js";
4
+ import type { BaseError } from "../base/core/baseError.core.js";
5
5
  /** Safely converts an unknown thrown value into an Error instance. */
6
6
  export declare function toError(value: unknown, fallback?: string): Error;
7
7
  /** Adds context to an Error while preserving the original error as its cause. */
@@ -1,9 +1,7 @@
1
1
  /**
2
2
  * Error transformation utilities — toError, withErrorContext, tryCatch, normalize.
3
3
  */
4
- import { BaseError } from "../base/core/baseError.core.js";
5
- import { ErrorCategory } from "../base/types/errorCategory.type.js";
6
- import { ErrorSeverity } from "../base/types/errorSeverity.type.js";
4
+ import { normalizeUnknownToBaseError } from "../base/utils/baseError.utils.js";
7
5
  import { getErrorMessage } from "./errorUtils.extraction.js";
8
6
  /** Safely converts an unknown thrown value into an Error instance. */
9
7
  export function toError(value, fallback = "An unexpected error occurred.") {
@@ -37,28 +35,6 @@ export async function tryCatchAsync(operation) {
37
35
  }
38
36
  /** Converts an unknown thrown value into a BaseError. */
39
37
  export function normalizeToBaseError(value) {
40
- if (value instanceof BaseError) {
41
- return value;
42
- }
43
- if (value instanceof Error) {
44
- return new BaseError(value.message || "An unexpected error occurred.", {
45
- code: "INTERNAL_ERROR",
46
- category: ErrorCategory.SYSTEM,
47
- severity: ErrorSeverity.ERROR,
48
- statusCode: 500,
49
- expose: false,
50
- isOperational: false,
51
- cause: value,
52
- });
53
- }
54
- return new BaseError(getErrorMessage(value), {
55
- code: "INTERNAL_ERROR",
56
- category: ErrorCategory.SYSTEM,
57
- severity: ErrorSeverity.ERROR,
58
- statusCode: 500,
59
- expose: false,
60
- isOperational: false,
61
- metadata: { originalType: typeof value },
62
- });
38
+ return normalizeUnknownToBaseError(value);
63
39
  }
64
40
  //# sourceMappingURL=errorUtils.transform.js.map
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Error type-checking utilities.
3
3
  */
4
- import { BaseError } from "../base/core/baseError.core.js";
4
+ import { isBaseError } from "../base/utils/baseError.utils.js";
5
5
  import { ErrorCategory } from "../base/types/errorCategory.type.js";
6
6
  import { ErrorSeverity } from "../base/types/errorSeverity.type.js";
7
7
  /** Type guard for unknown error-like values. */
@@ -13,31 +13,31 @@ export function isErrorLike(value) {
13
13
  }
14
14
  /** Returns whether an error is operational. */
15
15
  export function isOperationalError(value) {
16
- return value instanceof BaseError && value.isOperational;
16
+ return isBaseError(value) && value.isOperational;
17
17
  }
18
18
  /** Returns whether an error is safe to expose to clients. */
19
19
  export function isExposableError(value) {
20
- return value instanceof BaseError && value.expose;
20
+ return isBaseError(value) && value.expose;
21
21
  }
22
22
  /** Returns whether an error represents a server-side failure. */
23
23
  export function isServerError(value) {
24
- if (value instanceof BaseError) {
24
+ if (isBaseError(value)) {
25
25
  return value.statusCode >= 500;
26
26
  }
27
27
  return true;
28
28
  }
29
29
  /** Returns whether an error represents a client-side failure. */
30
30
  export function isClientError(value) {
31
- return (value instanceof BaseError &&
31
+ return (isBaseError(value) &&
32
32
  value.statusCode >= 400 &&
33
33
  value.statusCode < 500);
34
34
  }
35
35
  /** Returns whether an error belongs to a category. */
36
36
  export function hasErrorCategory(value, category) {
37
- return value instanceof BaseError && value.category === category;
37
+ return isBaseError(value) && value.category === category;
38
38
  }
39
39
  /** Returns whether an error has a specific severity. */
40
40
  export function hasErrorSeverity(value, severity) {
41
- return value instanceof BaseError && value.severity === severity;
41
+ return isBaseError(value) && value.severity === severity;
42
42
  }
43
43
  //# sourceMappingURL=errorUtils.typeCheck.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zudojs/errors",
3
- "version": "0.1.0",
3
+ "version": "1.0.0",
4
4
  "description": "Shared error base class, error codes, and error handling utilities for the Zudojs framework.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -13,16 +13,16 @@
13
13
  }
14
14
  },
15
15
  "files": [
16
- "dist"
16
+ "dist",
17
+ "!dist/**/*.map",
18
+ "!dist/**/*.tsbuildinfo",
19
+ "!dist/.tsbuildinfo"
17
20
  ],
18
- "scripts": {
19
- "build": "tsc -p tsconfig.json",
20
- "clean": "rm -rf dist",
21
- "typecheck": "tsc -p tsconfig.json --noEmit"
22
- },
21
+ "sideEffects": false,
23
22
  "dependencies": {},
24
23
  "devDependencies": {
25
- "typescript": "^7.0.2"
24
+ "typescript": "7.0.2",
25
+ "vitest": "^4.1.11"
26
26
  },
27
27
  "engines": {
28
28
  "node": ">=24.0.0"
@@ -37,8 +37,19 @@
37
37
  "error-handling"
38
38
  ],
39
39
  "homepage": "https://github.com/oyinlola-tech/zudo#readme",
40
+ "bugs": {
41
+ "url": "https://github.com/oyinlola-tech/zudo/issues"
42
+ },
40
43
  "repository": {
41
44
  "type": "git",
42
- "url": "https://github.com/oyinlola-tech/zudo"
45
+ "url": "https://github.com/oyinlola-tech/zudo",
46
+ "directory": "packages/errors"
47
+ },
48
+ "scripts": {
49
+ "build": "tsc -p tsconfig.json",
50
+ "clean": "rm -rf dist",
51
+ "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.test.json --noEmit",
52
+ "test": "vitest run",
53
+ "test:watch": "vitest"
43
54
  }
44
- }
55
+ }