@venizia/ignis 0.4.7 → 0.4.8-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 (265) hide show
  1. package/dist/esm/base/applications/base.js +3 -1
  2. package/dist/esm/base/applications/base.js.map +1 -1
  3. package/dist/esm/base/applications/server.js.map +1 -1
  4. package/dist/esm/base/controllers/grpc/abstract.js.map +1 -1
  5. package/dist/esm/base/controllers/grpc/adapter.js.map +1 -1
  6. package/dist/esm/base/controllers/grpc/base.js.map +1 -1
  7. package/dist/esm/base/middlewares/request-spy/request-spy.middleware.js.map +1 -1
  8. package/dist/esm/components/api-reference/component.js.map +1 -1
  9. package/dist/esm/components/api-reference/ui/factory.js.map +1 -1
  10. package/dist/esm/components/api-reference/ui/scalar.js.map +1 -1
  11. package/dist/esm/components/api-reference/ui/swagger.js.map +1 -1
  12. package/dist/esm/components/auth/authenticate/component.js.map +1 -1
  13. package/dist/esm/components/auth/authenticate/controllers/factory.js.map +1 -1
  14. package/dist/esm/components/auth/authenticate/controllers/jwks/controller.js.map +1 -1
  15. package/dist/esm/components/auth/authenticate/controllers/service-certs/controller.js.map +1 -1
  16. package/dist/esm/components/auth/authenticate/services/basic/service.js.map +1 -1
  17. package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.js.map +1 -1
  18. package/dist/esm/components/auth/authenticate/services/bearer/jwks/issuer.service.js.map +1 -1
  19. package/dist/esm/components/auth/authenticate/services/bearer/jwks/verifier.service.js.map +1 -1
  20. package/dist/esm/components/auth/authenticate/services/bearer/jws.service.js.map +1 -1
  21. package/dist/esm/components/auth/authenticate/services/jose-loader.js.map +1 -1
  22. package/dist/esm/components/auth/authenticate/services/service/signer.service.js.map +1 -1
  23. package/dist/esm/components/auth/authenticate/services/service/verifier.service.js.map +1 -1
  24. package/dist/esm/components/auth/authenticate/strategies/basic.strategy.js.map +1 -1
  25. package/dist/esm/components/auth/authenticate/strategies/jwks/issuer.js.map +1 -1
  26. package/dist/esm/components/auth/authenticate/strategies/jwks/verifier.js.map +1 -1
  27. package/dist/esm/components/auth/authenticate/strategies/jws.strategy.js.map +1 -1
  28. package/dist/esm/components/auth/authenticate/strategies/service.strategy.js.map +1 -1
  29. package/dist/esm/components/auth/authorize/adapters/base-filtered.js.map +1 -1
  30. package/dist/esm/components/auth/authorize/adapters/custom-grant-expander.js.map +1 -1
  31. package/dist/esm/components/auth/authorize/adapters/scoped-casbin/adapter.js.map +1 -1
  32. package/dist/esm/components/auth/authorize/enforcers/casbin-module.js.map +1 -1
  33. package/dist/esm/components/auth/authorize/enforcers/casbin.enforcer.js.map +1 -1
  34. package/dist/esm/components/auth/authorize/enforcers/policy-line-codec.js.map +1 -1
  35. package/dist/esm/components/auth/authorize/enforcers/user-policy-line-cache.js.map +1 -1
  36. package/dist/esm/components/auth/authorize/role-managers/base.js.map +1 -1
  37. package/dist/esm/components/auth/authorize/role-managers/domain-hierarchy.js.map +1 -1
  38. package/dist/esm/components/auth/authorize/role-managers/membership.js.map +1 -1
  39. package/dist/esm/components/auth/authorize/role-managers/resource.js.map +1 -1
  40. package/dist/esm/components/controller/grpc/grpc.component.js.map +1 -1
  41. package/dist/esm/components/health-check/controller.js.map +1 -1
  42. package/dist/esm/components/health-check/reporter.js.map +1 -1
  43. package/dist/esm/components/mail/common/constants.js.map +1 -1
  44. package/dist/esm/components/mail/common/keys.js.map +1 -1
  45. package/dist/esm/components/mail/component.js.map +1 -1
  46. package/dist/esm/components/mail/helpers/executors/bull-mq-executor.helper.js.map +1 -1
  47. package/dist/esm/components/mail/helpers/executors/internal-queue-executor.helper.js.map +1 -1
  48. package/dist/esm/components/mail/helpers/transporters/mailgun-transporter.helper.js.map +1 -1
  49. package/dist/esm/components/mail/helpers/transporters/nodemail-transporter.helper.js.map +1 -1
  50. package/dist/esm/components/mail/providers/mail-queue-executor.provider.js.map +1 -1
  51. package/dist/esm/components/mail/providers/mail-transporter.provider.js.map +1 -1
  52. package/dist/esm/components/mail/services/generators/numeric-code.js.map +1 -1
  53. package/dist/esm/components/mail/services/mail.service.js.map +1 -1
  54. package/dist/esm/components/mail/services/template.service.js.map +1 -1
  55. package/dist/esm/components/mail/utilities/address.utility.js.map +1 -1
  56. package/dist/esm/components/mail/utilities/attachment.utility.js.map +1 -1
  57. package/dist/esm/components/mail/utilities/mime.utility.js.map +1 -1
  58. package/dist/esm/components/socket-io/component.js.map +1 -1
  59. package/dist/esm/components/static-asset/common/commit-token.js.map +1 -1
  60. package/dist/esm/components/static-asset/component.js.map +1 -1
  61. package/dist/esm/components/static-asset/controller/factory.js.map +1 -1
  62. package/dist/esm/components/static-asset/controller/meta-link.js.map +1 -1
  63. package/dist/esm/components/static-asset/controller/route-options.js.map +1 -1
  64. package/dist/esm/components/websocket/component.js.map +1 -1
  65. package/dist/esm/testing/assert-application-boots.js.map +1 -1
  66. package/dist/presets/app/files/.configs/builders/compile.ts +3 -1
  67. package/dist/presets/app/files/_env.example +1 -1
  68. package/dist/presets/app/files/src/smoke.test.ts +14 -8
  69. package/dist/presets/app/preset.json +4 -4
  70. package/dist/presets/lib/preset.json +3 -3
  71. package/dist/presets/shared/preset.json +1 -1
  72. package/package.json +10 -10
  73. package/dist/esm/base/applications/base.d.ts.map +0 -1
  74. package/dist/esm/base/applications/boot-steps.d.ts.map +0 -1
  75. package/dist/esm/base/applications/common/index.d.ts.map +0 -1
  76. package/dist/esm/base/applications/common/logger-startup.d.ts.map +0 -1
  77. package/dist/esm/base/applications/common/types.d.ts.map +0 -1
  78. package/dist/esm/base/applications/index.d.ts.map +0 -1
  79. package/dist/esm/base/applications/server.d.ts.map +0 -1
  80. package/dist/esm/base/controllers/grpc/abstract.d.ts.map +0 -1
  81. package/dist/esm/base/controllers/grpc/adapter.d.ts.map +0 -1
  82. package/dist/esm/base/controllers/grpc/base.d.ts.map +0 -1
  83. package/dist/esm/base/controllers/grpc/common/index.d.ts.map +0 -1
  84. package/dist/esm/base/controllers/grpc/common/types.d.ts.map +0 -1
  85. package/dist/esm/base/controllers/grpc/index.d.ts.map +0 -1
  86. package/dist/esm/base/controllers/index.d.ts.map +0 -1
  87. package/dist/esm/base/index.d.ts.map +0 -1
  88. package/dist/esm/base/metadata/index.d.ts.map +0 -1
  89. package/dist/esm/base/metadata/request-context.d.ts.map +0 -1
  90. package/dist/esm/base/middlewares/app-error/app-error.middleware.d.ts.map +0 -1
  91. package/dist/esm/base/middlewares/app-error/index.d.ts.map +0 -1
  92. package/dist/esm/base/middlewares/index.d.ts.map +0 -1
  93. package/dist/esm/base/middlewares/request-spy/index.d.ts.map +0 -1
  94. package/dist/esm/base/middlewares/request-spy/request-spy.middleware.d.ts.map +0 -1
  95. package/dist/esm/common/environments.d.ts.map +0 -1
  96. package/dist/esm/common/index.d.ts.map +0 -1
  97. package/dist/esm/components/api-reference/common/constants.d.ts.map +0 -1
  98. package/dist/esm/components/api-reference/common/index.d.ts.map +0 -1
  99. package/dist/esm/components/api-reference/common/keys.d.ts.map +0 -1
  100. package/dist/esm/components/api-reference/common/types.d.ts.map +0 -1
  101. package/dist/esm/components/api-reference/component.d.ts.map +0 -1
  102. package/dist/esm/components/api-reference/index.d.ts.map +0 -1
  103. package/dist/esm/components/api-reference/ui/factory.d.ts.map +0 -1
  104. package/dist/esm/components/api-reference/ui/index.d.ts.map +0 -1
  105. package/dist/esm/components/api-reference/ui/scalar.d.ts.map +0 -1
  106. package/dist/esm/components/api-reference/ui/swagger.d.ts.map +0 -1
  107. package/dist/esm/components/auth/authenticate/component.d.ts.map +0 -1
  108. package/dist/esm/components/auth/authenticate/controllers/factory.d.ts.map +0 -1
  109. package/dist/esm/components/auth/authenticate/controllers/index.d.ts.map +0 -1
  110. package/dist/esm/components/auth/authenticate/controllers/jwks/controller.d.ts.map +0 -1
  111. package/dist/esm/components/auth/authenticate/controllers/jwks/definitions.d.ts.map +0 -1
  112. package/dist/esm/components/auth/authenticate/controllers/jwks/index.d.ts.map +0 -1
  113. package/dist/esm/components/auth/authenticate/controllers/service-certs/controller.d.ts.map +0 -1
  114. package/dist/esm/components/auth/authenticate/controllers/service-certs/definitions.d.ts.map +0 -1
  115. package/dist/esm/components/auth/authenticate/controllers/service-certs/index.d.ts.map +0 -1
  116. package/dist/esm/components/auth/authenticate/index.d.ts.map +0 -1
  117. package/dist/esm/components/auth/authenticate/services/basic/index.d.ts.map +0 -1
  118. package/dist/esm/components/auth/authenticate/services/basic/service.d.ts.map +0 -1
  119. package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.d.ts.map +0 -1
  120. package/dist/esm/components/auth/authenticate/services/bearer/index.d.ts.map +0 -1
  121. package/dist/esm/components/auth/authenticate/services/bearer/jwks/abstract.service.d.ts.map +0 -1
  122. package/dist/esm/components/auth/authenticate/services/bearer/jwks/index.d.ts.map +0 -1
  123. package/dist/esm/components/auth/authenticate/services/bearer/jwks/issuer.service.d.ts.map +0 -1
  124. package/dist/esm/components/auth/authenticate/services/bearer/jwks/verifier.service.d.ts.map +0 -1
  125. package/dist/esm/components/auth/authenticate/services/bearer/jws.service.d.ts.map +0 -1
  126. package/dist/esm/components/auth/authenticate/services/index.d.ts.map +0 -1
  127. package/dist/esm/components/auth/authenticate/services/jose-loader.d.ts.map +0 -1
  128. package/dist/esm/components/auth/authenticate/services/service/index.d.ts.map +0 -1
  129. package/dist/esm/components/auth/authenticate/services/service/signer.service.d.ts.map +0 -1
  130. package/dist/esm/components/auth/authenticate/services/service/verifier.service.d.ts.map +0 -1
  131. package/dist/esm/components/auth/authenticate/strategies/basic.strategy.d.ts.map +0 -1
  132. package/dist/esm/components/auth/authenticate/strategies/index.d.ts.map +0 -1
  133. package/dist/esm/components/auth/authenticate/strategies/jwks/index.d.ts.map +0 -1
  134. package/dist/esm/components/auth/authenticate/strategies/jwks/issuer.d.ts.map +0 -1
  135. package/dist/esm/components/auth/authenticate/strategies/jwks/verifier.d.ts.map +0 -1
  136. package/dist/esm/components/auth/authenticate/strategies/jws.strategy.d.ts.map +0 -1
  137. package/dist/esm/components/auth/authenticate/strategies/service.strategy.d.ts.map +0 -1
  138. package/dist/esm/components/auth/authorize/adapters/base-filtered.d.ts.map +0 -1
  139. package/dist/esm/components/auth/authorize/adapters/common/index.d.ts.map +0 -1
  140. package/dist/esm/components/auth/authorize/adapters/common/types.d.ts.map +0 -1
  141. package/dist/esm/components/auth/authorize/adapters/connector.d.ts.map +0 -1
  142. package/dist/esm/components/auth/authorize/adapters/custom-grant-expander.d.ts.map +0 -1
  143. package/dist/esm/components/auth/authorize/adapters/index.d.ts.map +0 -1
  144. package/dist/esm/components/auth/authorize/adapters/scoped-casbin/adapter.d.ts.map +0 -1
  145. package/dist/esm/components/auth/authorize/adapters/scoped-casbin/common/constants.d.ts.map +0 -1
  146. package/dist/esm/components/auth/authorize/adapters/scoped-casbin/common/index.d.ts.map +0 -1
  147. package/dist/esm/components/auth/authorize/adapters/scoped-casbin/common/types.d.ts.map +0 -1
  148. package/dist/esm/components/auth/authorize/adapters/scoped-casbin/index.d.ts.map +0 -1
  149. package/dist/esm/components/auth/authorize/adapters/scoped-casbin/policy-edges.d.ts.map +0 -1
  150. package/dist/esm/components/auth/authorize/component.d.ts.map +0 -1
  151. package/dist/esm/components/auth/authorize/enforcers/casbin-module.d.ts.map +0 -1
  152. package/dist/esm/components/auth/authorize/enforcers/casbin.enforcer.d.ts.map +0 -1
  153. package/dist/esm/components/auth/authorize/enforcers/index.d.ts.map +0 -1
  154. package/dist/esm/components/auth/authorize/enforcers/models/index.d.ts.map +0 -1
  155. package/dist/esm/components/auth/authorize/enforcers/models/rbac-domain.model.d.ts.map +0 -1
  156. package/dist/esm/components/auth/authorize/enforcers/policy-line-codec.d.ts.map +0 -1
  157. package/dist/esm/components/auth/authorize/enforcers/user-policy-line-cache.d.ts.map +0 -1
  158. package/dist/esm/components/auth/authorize/index.d.ts.map +0 -1
  159. package/dist/esm/components/auth/authorize/role-managers/base.d.ts.map +0 -1
  160. package/dist/esm/components/auth/authorize/role-managers/domain-hierarchy.d.ts.map +0 -1
  161. package/dist/esm/components/auth/authorize/role-managers/index.d.ts.map +0 -1
  162. package/dist/esm/components/auth/authorize/role-managers/membership.d.ts.map +0 -1
  163. package/dist/esm/components/auth/authorize/role-managers/resource.d.ts.map +0 -1
  164. package/dist/esm/components/auth/index.d.ts.map +0 -1
  165. package/dist/esm/components/auth/models/entities/columns.d.ts.map +0 -1
  166. package/dist/esm/components/auth/models/entities/index.d.ts.map +0 -1
  167. package/dist/esm/components/auth/models/entities/permission.model.d.ts.map +0 -1
  168. package/dist/esm/components/auth/models/entities/policy-definition.model.d.ts.map +0 -1
  169. package/dist/esm/components/auth/models/index.d.ts.map +0 -1
  170. package/dist/esm/components/controller/grpc/common/index.d.ts.map +0 -1
  171. package/dist/esm/components/controller/grpc/common/types.d.ts.map +0 -1
  172. package/dist/esm/components/controller/grpc/grpc.component.d.ts.map +0 -1
  173. package/dist/esm/components/controller/grpc/index.d.ts.map +0 -1
  174. package/dist/esm/components/health-check/common/constants.d.ts.map +0 -1
  175. package/dist/esm/components/health-check/common/index.d.ts.map +0 -1
  176. package/dist/esm/components/health-check/common/keys.d.ts.map +0 -1
  177. package/dist/esm/components/health-check/common/rest-paths.d.ts.map +0 -1
  178. package/dist/esm/components/health-check/common/types.d.ts.map +0 -1
  179. package/dist/esm/components/health-check/component.d.ts.map +0 -1
  180. package/dist/esm/components/health-check/controller.d.ts.map +0 -1
  181. package/dist/esm/components/health-check/index.d.ts.map +0 -1
  182. package/dist/esm/components/health-check/reporter.d.ts.map +0 -1
  183. package/dist/esm/components/index.d.ts.map +0 -1
  184. package/dist/esm/components/mail/common/constants.d.ts.map +0 -1
  185. package/dist/esm/components/mail/common/errors.d.ts.map +0 -1
  186. package/dist/esm/components/mail/common/index.d.ts.map +0 -1
  187. package/dist/esm/components/mail/common/keys.d.ts.map +0 -1
  188. package/dist/esm/components/mail/common/types/index.d.ts.map +0 -1
  189. package/dist/esm/components/mail/common/types/message.d.ts.map +0 -1
  190. package/dist/esm/components/mail/common/types/options.d.ts.map +0 -1
  191. package/dist/esm/components/mail/common/types/queue.d.ts.map +0 -1
  192. package/dist/esm/components/mail/common/types/template.d.ts.map +0 -1
  193. package/dist/esm/components/mail/common/types/verification.d.ts.map +0 -1
  194. package/dist/esm/components/mail/component.d.ts.map +0 -1
  195. package/dist/esm/components/mail/helpers/executors/bull-mq-executor.helper.d.ts.map +0 -1
  196. package/dist/esm/components/mail/helpers/executors/direct-executor.helper.d.ts.map +0 -1
  197. package/dist/esm/components/mail/helpers/executors/index.d.ts.map +0 -1
  198. package/dist/esm/components/mail/helpers/executors/internal-queue-executor.helper.d.ts.map +0 -1
  199. package/dist/esm/components/mail/helpers/index.d.ts.map +0 -1
  200. package/dist/esm/components/mail/helpers/transporters/amazon-ses-transporter.helper.d.ts.map +0 -1
  201. package/dist/esm/components/mail/helpers/transporters/index.d.ts.map +0 -1
  202. package/dist/esm/components/mail/helpers/transporters/mailgun-transporter.helper.d.ts.map +0 -1
  203. package/dist/esm/components/mail/helpers/transporters/nodemail-transporter.helper.d.ts.map +0 -1
  204. package/dist/esm/components/mail/index.d.ts.map +0 -1
  205. package/dist/esm/components/mail/providers/index.d.ts.map +0 -1
  206. package/dist/esm/components/mail/providers/mail-queue-executor.provider.d.ts.map +0 -1
  207. package/dist/esm/components/mail/providers/mail-transporter.provider.d.ts.map +0 -1
  208. package/dist/esm/components/mail/services/generators/index.d.ts.map +0 -1
  209. package/dist/esm/components/mail/services/generators/numeric-code.d.ts.map +0 -1
  210. package/dist/esm/components/mail/services/generators/random-token.d.ts.map +0 -1
  211. package/dist/esm/components/mail/services/generators/verification-data.d.ts.map +0 -1
  212. package/dist/esm/components/mail/services/index.d.ts.map +0 -1
  213. package/dist/esm/components/mail/services/mail.service.d.ts.map +0 -1
  214. package/dist/esm/components/mail/services/template.service.d.ts.map +0 -1
  215. package/dist/esm/components/mail/utilities/address.utility.d.ts.map +0 -1
  216. package/dist/esm/components/mail/utilities/attachment.utility.d.ts.map +0 -1
  217. package/dist/esm/components/mail/utilities/body.utility.d.ts.map +0 -1
  218. package/dist/esm/components/mail/utilities/index.d.ts.map +0 -1
  219. package/dist/esm/components/mail/utilities/mime.utility.d.ts.map +0 -1
  220. package/dist/esm/components/mail/utilities/type.utility.d.ts.map +0 -1
  221. package/dist/esm/components/mail/utilities/verification.utility.d.ts.map +0 -1
  222. package/dist/esm/components/request-tracker/component.d.ts.map +0 -1
  223. package/dist/esm/components/request-tracker/index.d.ts.map +0 -1
  224. package/dist/esm/components/socket-io/common/index.d.ts.map +0 -1
  225. package/dist/esm/components/socket-io/common/keys.d.ts.map +0 -1
  226. package/dist/esm/components/socket-io/common/types.d.ts.map +0 -1
  227. package/dist/esm/components/socket-io/component.d.ts.map +0 -1
  228. package/dist/esm/components/socket-io/handlers/bun.handler.d.ts.map +0 -1
  229. package/dist/esm/components/socket-io/handlers/index.d.ts.map +0 -1
  230. package/dist/esm/components/socket-io/index.d.ts.map +0 -1
  231. package/dist/esm/components/static-asset/common/commit-token.d.ts.map +0 -1
  232. package/dist/esm/components/static-asset/common/constants.d.ts.map +0 -1
  233. package/dist/esm/components/static-asset/common/errors.d.ts.map +0 -1
  234. package/dist/esm/components/static-asset/common/index.d.ts.map +0 -1
  235. package/dist/esm/components/static-asset/common/keys.d.ts.map +0 -1
  236. package/dist/esm/components/static-asset/common/types.d.ts.map +0 -1
  237. package/dist/esm/components/static-asset/component.d.ts.map +0 -1
  238. package/dist/esm/components/static-asset/controller/base.definition.d.ts.map +0 -1
  239. package/dist/esm/components/static-asset/controller/factory.d.ts.map +0 -1
  240. package/dist/esm/components/static-asset/controller/index.d.ts.map +0 -1
  241. package/dist/esm/components/static-asset/controller/key-scope.d.ts.map +0 -1
  242. package/dist/esm/components/static-asset/controller/meta-link.d.ts.map +0 -1
  243. package/dist/esm/components/static-asset/controller/route-options.d.ts.map +0 -1
  244. package/dist/esm/components/static-asset/index.d.ts.map +0 -1
  245. package/dist/esm/components/static-asset/ingest.d.ts.map +0 -1
  246. package/dist/esm/components/static-asset/models/base.model.d.ts.map +0 -1
  247. package/dist/esm/components/static-asset/models/index.d.ts.map +0 -1
  248. package/dist/esm/components/static-asset/repositories/base.repository.d.ts.map +0 -1
  249. package/dist/esm/components/static-asset/repositories/index.d.ts.map +0 -1
  250. package/dist/esm/components/websocket/common/index.d.ts.map +0 -1
  251. package/dist/esm/components/websocket/common/keys.d.ts.map +0 -1
  252. package/dist/esm/components/websocket/common/types.d.ts.map +0 -1
  253. package/dist/esm/components/websocket/component.d.ts.map +0 -1
  254. package/dist/esm/components/websocket/handlers/bun.handler.d.ts.map +0 -1
  255. package/dist/esm/components/websocket/handlers/index.d.ts.map +0 -1
  256. package/dist/esm/components/websocket/index.d.ts.map +0 -1
  257. package/dist/esm/connectors/index.d.ts.map +0 -1
  258. package/dist/esm/helpers/base-helper.d.ts.map +0 -1
  259. package/dist/esm/helpers/index.d.ts.map +0 -1
  260. package/dist/esm/index.d.ts.map +0 -1
  261. package/dist/esm/testing/assert-application-boots.d.ts.map +0 -1
  262. package/dist/esm/testing/index.d.ts.map +0 -1
  263. package/dist/esm/utilities/drizzle-result.utility.d.ts.map +0 -1
  264. package/dist/esm/utilities/index.d.ts.map +0 -1
  265. package/dist/esm/utilities/network.utility.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"user-policy-line-cache.js","sourceRoot":"","sources":["../../../../../../src/components/auth/authorize/enforcers/user-policy-line-cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEnE,OAAO,EACL,mBAAmB,GAGpB,MAAM,uBAAuB,CAAC;AAK/B;;;GAGG;AACH,MAAM,OAAO,mBAAoB,SAAQ,UAAU;IAOjD,YAAY,IAGX;QACC,KAAK,CAAC,EAAE,KAAK,EAAE,mBAAmB,CAAC,IAAI,EAAE,CAAC,CAAC;QAP7C,4IAA4I;QAC3H,uBAAkB,GAAG,IAAI,GAAG,EAA6B,CAAC;QAOzE,IAAI,CAAC,MAAM,GAAG,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,EAAE,mBAAmB,CAAC,iBAAiB;gBAC5C,OAAO,EAAE,0DAA0D;aACpE,CAAC,CAAC;QACL,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,0FAA0F;IAClF,KAAK,CAAC,UAAU,CAAC,IAA2C;QAClE,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC;YACvC,GAAG,EAAE,IAAI,CAAC,QAAQ;YAClB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE;SACtD,CAAC,CAAC;IACL,CAAC;IAED,kGAAkG;IAC1F,UAAU,CAAC,IAAuC;QACxD,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAEpC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,EAAE,CAAC;gBAC9E,MAAM,QAAQ,CAAC;oBACb,OAAO,EAAE,uEAAuE;iBACjF,CAAC,CAAC;YACL,CAAC;YAED,OAAO,MAAkB,CAAC;QAC5B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM;iBACR,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;iBACzB,IAAI,CAAC,8DAA8D,EAAE,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;YAC9F,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;CACF","sourcesContent":["import { BaseHelper, getError } from '@venizia/ignis-helpers/core';\nimport type { TNullable } from '@venizia/ignis-helpers/common';\nimport {\n AuthorizationErrors,\n type IAuthorizationUser,\n type ICasbinEnforcerCachedRedis,\n} from '@venizia/ignis-kernel';\n\n/** Computes a user's policy lines on a cache miss - CasbinAuthorizationEnforcer wires this to its isolated-enforcer extraction (PolicyLineCodec.extractUserLines). */\nexport type TPolicyLineLoader = (opts: { user: IAuthorizationUser }) => Promise<string[]>;\n\n/**\n * Per-user redis cache of casbin policy lines. Owns the cache key, the TTL, and concurrent-miss\n * de-duplication so N simultaneous misses for the same user collapse onto one extraction.\n */\nexport class UserPolicyLineCache extends BaseHelper {\n private readonly cached: ICasbinEnforcerCachedRedis & { use: true };\n private readonly loadLines: TPolicyLineLoader;\n\n // cacheKey -> in-progress line-fetch; concurrent misses for the same user share one extraction instead of all hitting the DB (see fetch()).\n private readonly pendingLineFetches = new Map<string, Promise<string[]>>();\n\n constructor(opts: {\n cached: ICasbinEnforcerCachedRedis & { use: true };\n loadLines: TPolicyLineLoader;\n }) {\n super({ scope: UserPolicyLineCache.name });\n this.cached = opts.cached;\n this.loadLines = opts.loadLines;\n }\n\n /** Fetch the user's lines, collapsing concurrent misses per key onto one extraction. Best-effort: two misses may race past the cache read and both extract (benign - per-user lines are identical). */\n async fetch(opts: { user: IAuthorizationUser }): Promise<string[]> {\n const cacheKey = await this.resolveCacheKey({ user: opts.user });\n\n // Cache hit - Redis owns expiry (PX on write), so a present key is fresh; an entry that does not decode (corrupted, or not an array of policy lines) must NOT 500 the request, so it is discarded and refetched.\n const raw = await this.cached.options.connection.get({ key: cacheKey });\n if (raw) {\n const lines = this.parseLines({ raw, cacheKey });\n\n if (lines) {\n return lines;\n }\n }\n\n const existing = this.pendingLineFetches.get(cacheKey);\n if (existing) {\n return existing;\n }\n\n // Cache miss (or discarded corrupt entry) - extract from an ISOLATED enforcer so a concurrent load cannot contaminate the cache, persist it, then return the lines for THIS request.\n const task = async () => {\n const lines = await this.loadLines({ user: opts.user });\n await this.writeLines({ cacheKey, lines });\n return lines;\n };\n\n const promise = task().finally(() => {\n this.pendingLineFetches.delete(cacheKey);\n });\n\n this.pendingLineFetches.set(cacheKey, promise);\n return promise;\n }\n\n /** Drop the user's cached entry. */\n async invalidate(opts: {\n user: IAuthorizationUser;\n }): Promise<{ cacheKey: string; invalidatedKeys: number }> {\n const cacheKey = await this.resolveCacheKey({ user: opts.user });\n const invalidatedKeys = await this.cached.options.connection.del({ keys: [cacheKey] });\n\n return { cacheKey, invalidatedKeys };\n }\n\n /** Drop then recompute the user's cached entry via `loadLines` - an isolated extraction (never a pooled serving enforcer), so a concurrent request cannot make the cache hold another user's lines. */\n async rebuild(opts: {\n user: IAuthorizationUser;\n }): Promise<{ cacheKey: string; lines: string[] }> {\n const cacheKey = await this.resolveCacheKey({ user: opts.user });\n await this.cached.options.connection.del({ keys: [cacheKey] });\n\n const lines = await this.loadLines({ user: opts.user });\n await this.writeLines({ cacheKey, lines });\n\n return { cacheKey, lines };\n }\n\n /** Compute the user's cache key and reject an empty result - consistent with the read path. */\n private async resolveCacheKey(opts: { user: IAuthorizationUser }): Promise<string> {\n const cacheKey = await this.cached.options.keyFn({ user: opts.user });\n if (!cacheKey) {\n throw getError({\n error: AuthorizationErrors.CACHE_KEY_INVALID,\n message: '[UserPolicyLineCache] keyFn returned an empty cache key.',\n });\n }\n\n return cacheKey;\n }\n\n /** Single source of truth for the cache encoding. Used by the miss path and rebuild(). */\n private async writeLines(opts: { cacheKey: string; lines: string[] }): Promise<void> {\n await this.cached.options.connection.set({\n key: opts.cacheKey,\n value: opts.lines,\n options: { expiresIn: this.cached.options.expiresIn },\n });\n }\n\n /** Decode cached policy lines; on any corruption, log and return null so the caller refetches. */\n private parseLines(opts: { raw: string; cacheKey: string }): TNullable<string[]> {\n try {\n const parsed = JSON.parse(opts.raw);\n\n if (!Array.isArray(parsed) || parsed.some((line) => typeof line !== 'string')) {\n throw getError({\n message: '[UserPolicyLineCache] Cached payload is not an array of policy lines.',\n });\n }\n\n return parsed as string[];\n } catch (error) {\n this.logger\n .for(this.parseLines.name)\n .warn('Discarding corrupted authz cache entry | key: %s | error: %s', opts.cacheKey, error);\n return null;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"user-policy-line-cache.js","sourceRoot":"","sources":["../../../../../../src/components/auth/authorize/enforcers/user-policy-line-cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEnE,OAAO,EACL,mBAAmB,GAGpB,MAAM,uBAAuB,CAAC;AAK/B;;;GAGG;AACH,MAAM,OAAO,mBAAoB,SAAQ,UAAU;IAOjD,YAAY,IAGX;QACC,KAAK,CAAC,EAAE,KAAK,EAAE,mBAAmB,CAAC,IAAI,EAAE,CAAC,CAAC;QAP7C,4IAA4I;QAC3H,uBAAkB,GAAG,IAAI,GAAG,EAA6B,CAAC;QAOzE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;IAClC,CAAC;IAED,uMAAuM;IACvM,KAAK,CAAC,KAAK,CAAC,IAAkC;QAC5C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QAEjE,iNAAiN;QACjN,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC;QAExE,IAAI,GAAG,EAAE,CAAC;YACR,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC;YAEjD,IAAI,KAAK,EAAE,CAAC;gBACV,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAEvD,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,qLAAqL;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OAAO,EAAE,uEAAuE;iBACjF,CAAC,CAAC;YACL,CAAC;YAED,OAAO,MAAkB,CAAC;QAC5B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM;iBACR,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;iBACzB,IAAI,CAAC,8DAA8D,EAAE,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;YAE9F,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;CACF","sourcesContent":["import { BaseHelper, getError } from '@venizia/ignis-helpers/core';\nimport type { TNullable } from '@venizia/ignis-helpers/common';\nimport {\n AuthorizationErrors,\n type IAuthorizationUser,\n type ICasbinEnforcerCachedRedis,\n} from '@venizia/ignis-kernel';\n\n/** Computes a user's policy lines on a cache miss - CasbinAuthorizationEnforcer wires this to its isolated-enforcer extraction (PolicyLineCodec.extractUserLines). */\nexport type TPolicyLineLoader = (opts: { user: IAuthorizationUser }) => Promise<string[]>;\n\n/**\n * Per-user redis cache of casbin policy lines. Owns the cache key, the TTL, and concurrent-miss\n * de-duplication so N simultaneous misses for the same user collapse onto one extraction.\n */\nexport class UserPolicyLineCache extends BaseHelper {\n private readonly cached: ICasbinEnforcerCachedRedis & { use: true };\n private readonly loadLines: TPolicyLineLoader;\n\n // cacheKey -> in-progress line-fetch; concurrent misses for the same user share one extraction instead of all hitting the DB (see fetch()).\n private readonly pendingLineFetches = new Map<string, Promise<string[]>>();\n\n constructor(opts: {\n cached: ICasbinEnforcerCachedRedis & { use: true };\n loadLines: TPolicyLineLoader;\n }) {\n super({ scope: UserPolicyLineCache.name });\n this.cached = opts.cached;\n this.loadLines = opts.loadLines;\n }\n\n /** Fetch the user's lines, collapsing concurrent misses per key onto one extraction. Best-effort: two misses may race past the cache read and both extract (benign - per-user lines are identical). */\n async fetch(opts: { user: IAuthorizationUser }): Promise<string[]> {\n const cacheKey = await this.resolveCacheKey({ user: opts.user });\n\n // Cache hit - Redis owns expiry (PX on write), so a present key is fresh; an entry that does not decode (corrupted, or not an array of policy lines) must NOT 500 the request, so it is discarded and refetched.\n const raw = await this.cached.options.connection.get({ key: cacheKey });\n\n if (raw) {\n const lines = this.parseLines({ raw, cacheKey });\n\n if (lines) {\n return lines;\n }\n }\n\n const existing = this.pendingLineFetches.get(cacheKey);\n\n if (existing) {\n return existing;\n }\n\n // Cache miss (or discarded corrupt entry) - extract from an ISOLATED enforcer so a concurrent load cannot contaminate the cache, persist it, then return the lines for THIS request.\n const task = async () => {\n const lines = await this.loadLines({ user: opts.user });\n await this.writeLines({ cacheKey, lines });\n\n return lines;\n };\n\n const promise = task().finally(() => {\n this.pendingLineFetches.delete(cacheKey);\n });\n\n this.pendingLineFetches.set(cacheKey, promise);\n\n return promise;\n }\n\n /** Drop the user's cached entry. */\n async invalidate(opts: {\n user: IAuthorizationUser;\n }): Promise<{ cacheKey: string; invalidatedKeys: number }> {\n const cacheKey = await this.resolveCacheKey({ user: opts.user });\n const invalidatedKeys = await this.cached.options.connection.del({ keys: [cacheKey] });\n\n return { cacheKey, invalidatedKeys };\n }\n\n /** Drop then recompute the user's cached entry via `loadLines` - an isolated extraction (never a pooled serving enforcer), so a concurrent request cannot make the cache hold another user's lines. */\n async rebuild(opts: {\n user: IAuthorizationUser;\n }): Promise<{ cacheKey: string; lines: string[] }> {\n const cacheKey = await this.resolveCacheKey({ user: opts.user });\n await this.cached.options.connection.del({ keys: [cacheKey] });\n\n const lines = await this.loadLines({ user: opts.user });\n await this.writeLines({ cacheKey, lines });\n\n return { cacheKey, lines };\n }\n\n /** Compute the user's cache key and reject an empty result - consistent with the read path. */\n private async resolveCacheKey(opts: { user: IAuthorizationUser }): Promise<string> {\n const cacheKey = await this.cached.options.keyFn({ user: opts.user });\n\n if (!cacheKey) {\n throw getError({\n error: AuthorizationErrors.CACHE_KEY_INVALID,\n message: '[UserPolicyLineCache] keyFn returned an empty cache key.',\n });\n }\n\n return cacheKey;\n }\n\n /** Single source of truth for the cache encoding. Used by the miss path and rebuild(). */\n private async writeLines(opts: { cacheKey: string; lines: string[] }): Promise<void> {\n await this.cached.options.connection.set({\n key: opts.cacheKey,\n value: opts.lines,\n options: { expiresIn: this.cached.options.expiresIn },\n });\n }\n\n /** Decode cached policy lines; on any corruption, log and return null so the caller refetches. */\n private parseLines(opts: { raw: string; cacheKey: string }): TNullable<string[]> {\n try {\n const parsed = JSON.parse(opts.raw);\n\n if (!Array.isArray(parsed) || parsed.some((line) => typeof line !== 'string')) {\n throw getError({\n message: '[UserPolicyLineCache] Cached payload is not an array of policy lines.',\n });\n }\n\n return parsed as string[];\n } catch (error) {\n this.logger\n .for(this.parseLines.name)\n .warn('Discarding corrupted authz cache entry | key: %s | error: %s', opts.cacheKey, error);\n\n return null;\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../../../src/components/auth/authorize/role-managers/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAEzD;;;;;GAKG;AACH,MAAM,OAAgB,eAAgB,SAAQ,UAAU;IAAxD;;QACY,kBAAa,GAAG,KAAK,CAAC;IAkFlC,CAAC;IA9EC,KAAK,CAAC,OAAO,CAAC,KAAa,EAAE,KAAa;QACxC,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAC1C,CAAC;IAED,8GAA8G;IAC9G,KAAK,CAAC,UAAU,KAAmB,CAAC;IAEpC,KAAK,CAAC,UAAU;QACd,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,KAAK,CAAC,aAAa;QACjB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,8HAA8H;IACpH,eAAe,CAAC,KAAiD;QACzE,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACvB,OAAO;QACT,CAAC;QACD,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAE1B,MAAM,EAAE,OAAO,EAAE,IAAI,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AI,OAAO,EAAE,CAAC;gBAC7B,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;oBACxB,SAAS;gBACX,CAAC;gBACD,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;gBACpB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBACpB,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACrB,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import { BaseHelper } from '@venizia/ignis-helpers/core';\n\n/**\n * Shared casbin `RoleManager` scaffolding for the resource, domain-hierarchy, and membership\n * role managers: the debug-only interface members (`printRoles`, `getDomains`, `getAllDomains`),\n * the `hasLink` wrapper around the synchronous `syncedHasLink`, the once-per-`clear()`\n * overlay-initialized log line, and the shared ancestor walk both hierarchy-aware managers use.\n */\nexport abstract class BaseRoleManager extends BaseHelper {\n protected graphReported = false;\n\n abstract syncedHasLink(name1: string, name2: string): boolean;\n\n async hasLink(name1: string, name2: string): Promise<boolean> {\n return this.syncedHasLink(name1, name2);\n }\n\n /** casbin calls this after buildRoleLinks purely as a debug hook; none of the role managers log from here. */\n async printRoles(): Promise<void> {}\n\n async getDomains(): Promise<string[]> {\n return [];\n }\n\n async getAllDomains(): Promise<string[]> {\n return [];\n }\n\n /** Logs the initialized-overlay line once per `clear()` cycle; `build` is only invoked the first time so counts stay lazy. */\n protected reportGraphOnce(build: () => { message: string; args: unknown[] }): void {\n if (this.graphReported) {\n return;\n }\n this.graphReported = true;\n\n const { message, args } = build();\n this.logger.for(this.syncedHasLink.name).debug(message, ...args);\n }\n\n /** Node and edge counts of a domain-hierarchy overlay, for the once-per-`clear()` debug log. */\n protected static overlayStats(overlay?: Map<string, Set<string>>): {\n nodeCount: number;\n edgeCount: number;\n } {\n if (!overlay) {\n return { nodeCount: 0, edgeCount: 0 };\n }\n\n let edgeCount = 0;\n const overlayValues = overlay.values();\n for (const parents of overlayValues) {\n edgeCount += parents.size;\n }\n\n return { nodeCount: overlay.size, edgeCount };\n }\n\n /** `node` itself plus every ancestor reachable by walking the overlay's child->parent edges,\n * node first. Cycle-safe: visited Set + index cursor, never shift(). Static - `ResourceRoleManager`\n * extends this base with no overlay of this shape, so this must not force instance state onto it. */\n protected static collectAncestors(opts: {\n overlay?: Map<string, Set<string>>;\n node: string;\n }): string[] {\n const { overlay, node } = opts;\n const result: string[] = [node];\n const visited = new Set<string>([node]);\n const queue: string[] = [node];\n\n let head = 0;\n while (head < queue.length) {\n const current = queue[head];\n head += 1;\n\n const parents = overlay?.get(current);\n if (!parents) {\n continue;\n }\n\n for (const parent of parents) {\n if (visited.has(parent)) {\n continue;\n }\n visited.add(parent);\n result.push(parent);\n queue.push(parent);\n }\n }\n\n return result;\n }\n}\n"]}
1
+ {"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../../../src/components/auth/authorize/role-managers/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAEzD;;;;;GAKG;AACH,MAAM,OAAgB,eAAgB,SAAQ,UAAU;IAAxD;;QACY,kBAAa,GAAG,KAAK,CAAC;IAuFlC,CAAC;IAnFC,KAAK,CAAC,OAAO,CAAC,KAAa,EAAE,KAAa;QACxC,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAC1C,CAAC;IAED,8GAA8G;IAC9G,KAAK,CAAC,UAAU,KAAmB,CAAC;IAEpC,KAAK,CAAC,UAAU;QACd,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,KAAK,CAAC,aAAa;QACjB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,8HAA8H;IACpH,eAAe,CAAC,KAAiD;QACzE,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACvB,OAAO;QACT,CAAC;QAED,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAE1B,MAAM,EAAE,OAAO,EAAE,IAA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AM,IAAI,OAAO,EAAE,CAAC;gBAC7B,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;oBACxB,SAAS;gBACX,CAAC;gBAED,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;gBACpB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBACpB,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACrB,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import { BaseHelper } from '@venizia/ignis-helpers/core';\n\n/**\n * Shared casbin `RoleManager` scaffolding for the resource, domain-hierarchy, and membership\n * role managers: the debug-only interface members (`printRoles`, `getDomains`, `getAllDomains`),\n * the `hasLink` wrapper around the synchronous `syncedHasLink`, the once-per-`clear()`\n * overlay-initialized log line, and the shared ancestor walk both hierarchy-aware managers use.\n */\nexport abstract class BaseRoleManager extends BaseHelper {\n protected graphReported = false;\n\n abstract syncedHasLink(name1: string, name2: string): boolean;\n\n async hasLink(name1: string, name2: string): Promise<boolean> {\n return this.syncedHasLink(name1, name2);\n }\n\n /** casbin calls this after buildRoleLinks purely as a debug hook; none of the role managers log from here. */\n async printRoles(): Promise<void> {}\n\n async getDomains(): Promise<string[]> {\n return [];\n }\n\n async getAllDomains(): Promise<string[]> {\n return [];\n }\n\n /** Logs the initialized-overlay line once per `clear()` cycle; `build` is only invoked the first time so counts stay lazy. */\n protected reportGraphOnce(build: () => { message: string; args: unknown[] }): void {\n if (this.graphReported) {\n return;\n }\n\n this.graphReported = true;\n\n const { message, args } = build();\n this.logger.for(this.syncedHasLink.name).debug(message, ...args);\n }\n\n /** Node and edge counts of a domain-hierarchy overlay, for the once-per-`clear()` debug log. */\n protected static overlayStats(overlay?: Map<string, Set<string>>): {\n nodeCount: number;\n edgeCount: number;\n } {\n if (!overlay) {\n return { nodeCount: 0, edgeCount: 0 };\n }\n\n let edgeCount = 0;\n const overlayValues = overlay.values();\n\n for (const parents of overlayValues) {\n edgeCount += parents.size;\n }\n\n return { nodeCount: overlay.size, edgeCount };\n }\n\n /** `node` itself plus every ancestor reachable by walking the overlay's child->parent edges,\n * node first. Cycle-safe: visited Set + index cursor, never shift(). Static - `ResourceRoleManager`\n * extends this base with no overlay of this shape, so this must not force instance state onto it. */\n protected static collectAncestors(opts: {\n overlay?: Map<string, Set<string>>;\n node: string;\n }): string[] {\n const { overlay, node } = opts;\n const result: string[] = [node];\n const visited = new Set<string>([node]);\n const queue: string[] = [node];\n\n let head = 0;\n\n while (head < queue.length) {\n const current = queue[head];\n head += 1;\n\n const parents = overlay?.get(current);\n\n if (!parents) {\n continue;\n }\n\n for (const parent of parents) {\n if (visited.has(parent)) {\n continue;\n }\n\n visited.add(parent);\n result.push(parent);\n queue.push(parent);\n }\n }\n\n return result;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"domain-hierarchy.js","sourceRoot":"","sources":["../../../../../../src/components/auth/authorize/role-managers/domain-hierarchy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAEzC;;;;;;GAMG;AACH,MAAM,OAAO,0BAA2B,SAAQ,eAAe;IAO7D,YAAY,IAAgE;QAC1E,KAAK,CAAC,EAAE,KAAK,EAAE,0BAA0B,CAAC,IAAI,EAAE,CAAC,CAAC;QAClD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,KAAK,CAAC;QACvC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,IAAI,GAAG,EAAuB,CAAC;IAChE,CAAC;IAED,8JAA8J;IAC9J,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACrB,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,KAAa,EAAE,MAAc;QACzC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAA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;IAC9G,KAAK,CAAC,QAAQ,CAAC,IAAY;QACzB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAC7C,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,IAAY;QACzB,MAAM,KAAK,GAAa,EAAE,CAAC;QAE3B,KAAK,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAC5C,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;gBACtB,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACpB,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED,wEAAwE;IAChE,OAAO,CAAC,IAAuC;QACrD,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QAE/B,IAAI,KAAK,KAAK,MAAM,EAAE,CAAC;YACrB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,SAAS,GAAG,0BAA0B,CAAC,gBAAgB,CAAC;YAC5D,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,IAAI,EAAE,KAAK;SACZ,CAAC,CAAC;QACH,OAAO,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;CACF","sourcesContent":["import type { RoleManager } from 'casbin';\nimport { BaseRoleManager } from './base';\n\n/**\n * Serves the `g3` axis (`g3(r.dom, p.dom)`) and, with `reversed`, casbin's\n * `DefaultRoleManager.addDomainHierarchy()` on `g`, which asks in the opposite argument order.\n * `clear()` wipes only the overlay, never shared across requests: `buildRoleLinksInternal` clears\n * every registered role manager each request. Pass both instances one `overlay` so per-request `g3`\n * edges reach the `g` axis, which casbin never puts in `rmMap` and so never feeds `addLink`.\n */\nexport class DomainHierarchyRoleManager extends BaseRoleManager implements RoleManager {\n private readonly reversed: boolean;\n private readonly overlay: Map<\n string, // child domain\n Set<string> // set of parent domains\n >;\n\n constructor(opts: { reversed?: boolean; overlay?: Map<string, Set<string>> }) {\n super({ scope: DomainHierarchyRoleManager.name });\n this.reversed = opts.reversed ?? false;\n this.overlay = opts.overlay ?? new Map<string, Set<string>>();\n }\n\n /** Mutates the map in place - never reassigns `this.overlay` - so a caller sharing this map with another instance (see `opts.overlay`) sees the clear too. */\n async clear(): Promise<void> {\n this.overlay.clear();\n this.graphReported = false;\n }\n\n async addLink(child: string, parent: string): Promise<void> {\n const existing = this.overlay.get(child);\n if (existing) {\n existing.add(parent);\n } else {\n this.overlay.set(child, new Set<string>([parent]));\n }\n\n if (!this.overlay.has(parent)) {\n this.overlay.set(parent, new Set<string>());\n }\n }\n\n async deleteLink(child: string, parent: string): Promise<void> {\n this.overlay.get(child)?.delete(parent);\n }\n\n syncedHasLink(name1: string, name2: string): boolean {\n this.reportGraphOnce(() => {\n const { nodeCount, edgeCount } = DomainHierarchyRoleManager.overlayStats(this.overlay);\n return {\n message: 'domain-hierarchy role manager initialized | nodes: %d | edges: %d | reversed: %s',\n args: [nodeCount, edgeCount, this.reversed],\n };\n });\n\n const start = this.reversed ? name2 : name1;\n const target = this.reversed ? name1 : name2;\n\n return this.reaches({ start, target });\n }\n\n /** Local overlay only, not the shared graph - correct for hasLink, incomplete for casbin's management API. */\n async getRoles(name: string): Promise<string[]> {\n return [...(this.overlay.get(name) ?? [])];\n }\n\n async getUsers(name: string): Promise<string[]> {\n const users: string[] = [];\n\n for (const [child, parents] of this.overlay) {\n if (parents.has(name)) {\n users.push(child);\n }\n }\n\n return users;\n }\n\n /** True when `start` is `target`, or reaches it through the overlay. */\n private reaches(opts: { start: string; target: string }): boolean {\n const { start, target } = opts;\n\n if (start === target) {\n return true;\n }\n\n const ancestors = DomainHierarchyRoleManager.collectAncestors({\n overlay: this.overlay,\n node: start,\n });\n return ancestors.includes(target);\n }\n}\n"]}
1
+ {"version":3,"file":"domain-hierarchy.js","sourceRoot":"","s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AAC;QAE/B,IAAI,KAAK,KAAK,MAAM,EAAE,CAAC;YACrB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,SAAS,GAAG,0BAA0B,CAAC,gBAAgB,CAAC;YAC5D,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,IAAI,EAAE,KAAK;SACZ,CAAC,CAAC;QAEH,OAAO,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;CACF","sourcesContent":["import type { RoleManager } from 'casbin';\nimport { BaseRoleManager } from './base';\n\n/**\n * Serves the `g3` axis (`g3(r.dom, p.dom)`) and, with `reversed`, casbin's\n * `DefaultRoleManager.addDomainHierarchy()` on `g`, which asks in the opposite argument order.\n * `clear()` wipes only the overlay, never shared across requests: `buildRoleLinksInternal` clears\n * every registered role manager each request. Pass both instances one `overlay` so per-request `g3`\n * edges reach the `g` axis, which casbin never puts in `rmMap` and so never feeds `addLink`.\n */\nexport class DomainHierarchyRoleManager extends BaseRoleManager implements RoleManager {\n private readonly reversed: boolean;\n private readonly overlay: Map<\n string, // child domain\n Set<string> // set of parent domains\n >;\n\n constructor(opts: { reversed?: boolean; overlay?: Map<string, Set<string>> }) {\n super({ scope: DomainHierarchyRoleManager.name });\n this.reversed = opts.reversed ?? false;\n this.overlay = opts.overlay ?? new Map<string, Set<string>>();\n }\n\n /** Mutates the map in place - never reassigns `this.overlay` - so a caller sharing this map with another instance (see `opts.overlay`) sees the clear too. */\n async clear(): Promise<void> {\n this.overlay.clear();\n this.graphReported = false;\n }\n\n async addLink(child: string, parent: string): Promise<void> {\n const existing = this.overlay.get(child);\n\n if (existing) {\n existing.add(parent);\n } else {\n this.overlay.set(child, new Set<string>([parent]));\n }\n\n if (!this.overlay.has(parent)) {\n this.overlay.set(parent, new Set<string>());\n }\n }\n\n async deleteLink(child: string, parent: string): Promise<void> {\n this.overlay.get(child)?.delete(parent);\n }\n\n syncedHasLink(name1: string, name2: string): boolean {\n this.reportGraphOnce(() => {\n const { nodeCount, edgeCount } = DomainHierarchyRoleManager.overlayStats(this.overlay);\n\n return {\n message: 'domain-hierarchy role manager initialized | nodes: %d | edges: %d | reversed: %s',\n args: [nodeCount, edgeCount, this.reversed],\n };\n });\n\n const start = this.reversed ? name2 : name1;\n const target = this.reversed ? name1 : name2;\n\n return this.reaches({ start, target });\n }\n\n /** Local overlay only, not the shared graph - correct for hasLink, incomplete for casbin's management API. */\n async getRoles(name: string): Promise<string[]> {\n return [...(this.overlay.get(name) ?? [])];\n }\n\n async getUsers(name: string): Promise<string[]> {\n const users: string[] = [];\n\n for (const [child, parents] of this.overlay) {\n if (parents.has(name)) {\n users.push(child);\n }\n }\n\n return users;\n }\n\n /** True when `start` is `target`, or reaches it through the overlay. */\n private reaches(opts: { start: string; target: string }): boolean {\n const { start, target } = opts;\n\n if (start === target) {\n return true;\n }\n\n const ancestors = DomainHierarchyRoleManager.collectAncestors({\n overlay: this.overlay,\n node: start,\n });\n\n return ancestors.includes(target);\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"membership.js","sourceRoot":"","sources":["../../../../../../src/components/auth/authorize/role-managers/membership.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAEzC;;sEAEsE;AACtE,MAAM,OAAO,qBAAsB,SAAQ,eAAe;IAUxD,YAAY,IAA4C;QACtD,KAAK,CAAC,EAAE,KAAK,EAAE,qBAAqB,CAAC,IAAI,EAAE,CAAC,CAAC;QANvC,gBAAW,GAAG,IAAI,GAAG,EAG1B,CAAC;QAIF,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,WAAW,GAAG,IAAI,GAAG,EAAuB,CAAC;QAClD,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,IAAY,EAAE,MAAc;QACxC,MAAM,QAAQ,GAA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AAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED,uHAAuH;IACvH,KAAK,CAAC,QAAQ,CAAC,IAAY;QACzB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IACjD,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,IAAY;QACzB,MAAM,KAAK,GAAa,EAAE,CAAC;QAE3B,KAAK,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YAC/C,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;gBACtB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACnB,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF","sourcesContent":["import type { RoleManager } from 'casbin';\nimport { BaseRoleManager } from './base';\n\n/** `g2` axis (`g2(r.sub, r.dom)`): membership holds when the user joined the request domain or any\n * ancestor of it, walking the shared per-request domain-hierarchy overlay. Memberships are\n * per-principal and rebuilt every request, so `clear()` wipes all. */\nexport class MembershipRoleManager extends BaseRoleManager implements RoleManager {\n private readonly overlay?: Map<\n string, // child domain\n Set<string> // set of parent domains\n >;\n private memberships = new Map<\n string, // user\n Set<string> // set of joined domains\n >();\n\n constructor(opts: { overlay?: Map<string, Set<string>> }) {\n super({ scope: MembershipRoleManager.name });\n this.overlay = opts.overlay;\n }\n\n async clear(): Promise<void> {\n this.memberships = new Map<string, Set<string>>();\n this.graphReported = false;\n }\n\n async addLink(user: string, domain: string): Promise<void> {\n const existing = this.memberships.get(user);\n if (existing) {\n existing.add(domain);\n } else {\n this.memberships.set(user, new Set<string>([domain]));\n }\n }\n\n async deleteLink(user: string, domain: string): Promise<void> {\n this.memberships.get(user)?.delete(domain);\n }\n\n /** True when `name1` (user) joined `name2` (request domain) itself, or any ancestor of it. Walks UP from the request domain only - walking down from every joined domain would fan out over the whole subtree. */\n syncedHasLink(name1: string, name2: string): boolean {\n this.reportGraphOnce(() => {\n const { nodeCount, edgeCount } = MembershipRoleManager.overlayStats(this.overlay);\n return {\n message: 'membership role manager initialized | nodes: %d | edges: %d',\n args: [nodeCount, edgeCount],\n };\n });\n\n const joined = this.memberships.get(name1);\n if (!joined || joined.size === 0) {\n return false;\n }\n\n const ancestors = MembershipRoleManager.collectAncestors({\n overlay: this.overlay,\n node: name2,\n });\n for (const ancestor of ancestors) {\n if (joined.has(ancestor)) {\n return true;\n }\n }\n\n return false;\n }\n\n /** Local membership state only, not the shared graph - correct for hasLink, incomplete for casbin's management API. */\n async getRoles(name: string): Promise<string[]> {\n return [...(this.memberships.get(name) ?? [])];\n }\n\n async getUsers(name: string): Promise<string[]> {\n const users: string[] = [];\n\n for (const [user, domains] of this.memberships) {\n if (domains.has(name)) {\n users.push(user);\n }\n }\n\n return users;\n }\n}\n"]}
1
+ {"version":3,"file":"membership.js","sourceRoot":"","sources":["../../../../../../src/components/auth/authorize/role-managers/membership.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAEzC;;sEAEsE;AACtE,MAAM,OAAO,qBAAsB,SAAQ,eAAe;IAWxD,YAAY,IAA4C;QACtD,KAAK,CAAC,EAAE,KAAK,EAAE,qBAAqB,CAAC,IAAI,EAAE,CAAC,CAAC;QANvC,gBAAW,GAAG,IAAI,GAAG,EAG1B,CAAC;QAIF,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,WAAW,GAAG,IAAI,GAAG,EAAuB,CAAC;QAClD,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,IAAY,EAAE,MAAc;QACxC,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,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H;IACvH,KAAK,CAAC,QAAQ,CAAC,IAAY;QACzB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IACjD,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,IAAY;QACzB,MAAM,KAAK,GAAa,EAAE,CAAC;QAE3B,KAAK,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YAC/C,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;gBACtB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACnB,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF","sourcesContent":["import type { RoleManager } from 'casbin';\nimport { BaseRoleManager } from './base';\n\n/** `g2` axis (`g2(r.sub, r.dom)`): membership holds when the user joined the request domain or any\n * ancestor of it, walking the shared per-request domain-hierarchy overlay. Memberships are\n * per-principal and rebuilt every request, so `clear()` wipes all. */\nexport class MembershipRoleManager extends BaseRoleManager implements RoleManager {\n private readonly overlay?: Map<\n string, // child domain\n Set<string> // set of parent domains\n >;\n\n private memberships = new Map<\n string, // user\n Set<string> // set of joined domains\n >();\n\n constructor(opts: { overlay?: Map<string, Set<string>> }) {\n super({ scope: MembershipRoleManager.name });\n this.overlay = opts.overlay;\n }\n\n async clear(): Promise<void> {\n this.memberships = new Map<string, Set<string>>();\n this.graphReported = false;\n }\n\n async addLink(user: string, domain: string): Promise<void> {\n const existing = this.memberships.get(user);\n\n if (existing) {\n existing.add(domain);\n } else {\n this.memberships.set(user, new Set<string>([domain]));\n }\n }\n\n async deleteLink(user: string, domain: string): Promise<void> {\n this.memberships.get(user)?.delete(domain);\n }\n\n /** True when `name1` (user) joined `name2` (request domain) itself, or any ancestor of it. Walks UP from the request domain only - walking down from every joined domain would fan out over the whole subtree. */\n syncedHasLink(name1: string, name2: string): boolean {\n this.reportGraphOnce(() => {\n const { nodeCount, edgeCount } = MembershipRoleManager.overlayStats(this.overlay);\n\n return {\n message: 'membership role manager initialized | nodes: %d | edges: %d',\n args: [nodeCount, edgeCount],\n };\n });\n\n const joined = this.memberships.get(name1);\n\n if (!joined || joined.size === 0) {\n return false;\n }\n\n const ancestors = MembershipRoleManager.collectAncestors({\n overlay: this.overlay,\n node: name2,\n });\n\n for (const ancestor of ancestors) {\n if (joined.has(ancestor)) {\n return true;\n }\n }\n\n return false;\n }\n\n /** Local membership state only, not the shared graph - correct for hasLink, incomplete for casbin's management API. */\n async getRoles(name: string): Promise<string[]> {\n return [...(this.memberships.get(name) ?? [])];\n }\n\n async getUsers(name: string): Promise<string[]> {\n const users: string[] = [];\n\n for (const [user, domains] of this.memberships) {\n if (domains.has(name)) {\n users.push(user);\n }\n }\n\n return users;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"resource.js","sourceRoot":"","sources":["../../../../../../src/components/auth/authorize/role-managers/resource.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAEzC,yQAAyQ;AACzQ,MAAM,OAAO,mBAAoB,SAAQ,eAAe;IAMtD;QACE,KAAK,CAAC,EAAE,KAAK,EAAE,mBAAmB,CAAC,IAAI,EAAE,CAAC,CAAC;QANrC,YAAO,GAAG,IAAI,GAAG,EAGtB,CAAC;IAIJ,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,EAAuB,CAAC;QAC9C,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,KAAa,EAAE,MAAc;QACzC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAEzC,IAAI,QAAQ,EAAE,CAAC;YACb,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACvB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SAAS,GAAa,EAAE,CAAC;QAE/B,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAChC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC5B,CAAC;QAED,IAAI,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC;QACxB,SAAS,CAAC;YACR,MAAM,KAAK,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;YACvC,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;gBACjB,MAAM;YACR,CAAC;YAED,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;YAClC,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC9B,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC;QAED,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACtD,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACtB,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF","sourcesContent":["import type { RoleManager } from 'casbin';\nimport { BaseRoleManager } from './base';\n\n/** Resource-axis (`g4`) role manager: `addMatchingFunc` would set `hasPattern` and disable DefaultRoleManager's O(1) fast path, so prefix ancestors are walked manually; `addLink` must stay idempotent because `buildRoleLinks` re-adds every edge once per request. */\nexport class ResourceRoleManager extends BaseRoleManager implements RoleManager {\n private parents = new Map<\n string, // Child module\n Set<string> // Set of Parent modules\n >();\n\n constructor() {\n super({ scope: ResourceRoleManager.name });\n }\n\n async clear(): Promise<void> {\n this.parents = new Map<string, Set<string>>();\n this.graphReported = false;\n }\n\n async addLink(child: string, parent: string): Promise<void> {\n const existing = this.parents.get(child);\n\n if (existing) {\n existing.add(parent);\n } else {\n this.parents.set(child, new Set<string>([parent]));\n }\n\n if (!this.parents.has(parent)) {\n this.parents.set(parent, new Set<string>());\n }\n }\n\n async deleteLink(child: string, parent: string): Promise<void> {\n this.parents.get(child)?.delete(parent);\n }\n\n syncedHasLink(name1: string, name2: string): boolean {\n this.reportGraphOnce(() => {\n const nodeCount = this.parents.size;\n const edgeCount = Array.from(this.parents.values()).reduce((sum, set) => sum + set.size, 0);\n return {\n message: 'resource-role initialized | nodes: %d | edges: %d',\n args: [nodeCount, edgeCount],\n };\n });\n\n if (name1 === name2) {\n return true;\n }\n\n const seeds = this.collectStoredAncestors({ name: name1 });\n if (seeds.length === 0) {\n return false;\n }\n\n const visited = new Set<string>();\n const queue: string[] = [...seeds];\n\n // Index cursor rather than shift(): shift() is O(n) and would make the walk quadratic.\n let head = 0;\n while (head < queue.length) {\n const current = queue[head];\n head += 1;\n\n if (current === name2) {\n return true;\n }\n\n if (visited.has(current)) {\n continue;\n }\n visited.add(current);\n\n const parents = this.parents.get(current);\n if (parents) {\n queue.push(...parents);\n }\n }\n\n return false;\n }\n\n async getRoles(name: string): Promise<string[]> {\n return [...(this.parents.get(name) ?? [])];\n }\n\n async getUsers(name: string): Promise<string[]> {\n const users: string[] = [];\n\n for (const [child, parents] of this.parents) {\n if (parents.has(name)) {\n users.push(child);\n }\n }\n\n return users;\n }\n\n /** All stored prefix ancestors of a dotted code (`a.b.c` -> `a.b` -> `a`), not only the deepest, plus a literal stored `'*'` node - `objectMatch(anything, '*')` is always true, so a `g4` edge whose child is `'*'` must stay reachable from every request object. */\n private collectStoredAncestors(opts: { name: string }): string[] {\n const ancestors: string[] = [];\n\n if (this.parents.has(opts.name)) {\n ancestors.push(opts.name);\n }\n\n let current = opts.name;\n for (;;) {\n const index = current.lastIndexOf('.');\n if (index === -1) {\n break;\n }\n\n current = current.slice(0, index);\n if (this.parents.has(current)) {\n ancestors.push(current);\n }\n }\n\n if (this.parents.has('*') && !ancestors.includes('*')) {\n ancestors.push('*');\n }\n\n return ancestors;\n }\n}\n"]}
1
+ {"version":3,"file":"resource.js","sourceRoot":"","sources":["../../../../../../src/components/auth/authorize/role-managers/resource.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAEzC,yQAAyQ;AACzQ,MAAM,OAAO,mBAAoB,SAAQ,eAAe;IAMtD;QACE,KAAK,CAAC,EAAE,KAAK,EAAE,mBAAmB,CAAC,IAAI,EAAE,CAAC,CAAC;QANrC,YAAO,GAAG,IAAI,GAAG,EAGtB,CAAC;IAIJ,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,EAAuB,CAAC;QAC9C,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,KAAa,EAAE,MAAc;QACzC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAEzC,IAAI,QAAQ,EAAE,CAAC;YACb,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACvB,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,GAAG,CAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACrD,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;YAC9B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,GAAG,EAAU,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,KAAa,EAAE,MAAc;QAC5C,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC1C,CAAC;IAED,aAAa,CAAC,KAA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AG,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC9B,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC;QAED,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACtD,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACtB,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF","sourcesContent":["import type { RoleManager } from 'casbin';\nimport { BaseRoleManager } from './base';\n\n/** Resource-axis (`g4`) role manager: `addMatchingFunc` would set `hasPattern` and disable DefaultRoleManager's O(1) fast path, so prefix ancestors are walked manually; `addLink` must stay idempotent because `buildRoleLinks` re-adds every edge once per request. */\nexport class ResourceRoleManager extends BaseRoleManager implements RoleManager {\n private parents = new Map<\n string, // Child module\n Set<string> // Set of Parent modules\n >();\n\n constructor() {\n super({ scope: ResourceRoleManager.name });\n }\n\n async clear(): Promise<void> {\n this.parents = new Map<string, Set<string>>();\n this.graphReported = false;\n }\n\n async addLink(child: string, parent: string): Promise<void> {\n const existing = this.parents.get(child);\n\n if (existing) {\n existing.add(parent);\n } else {\n this.parents.set(child, new Set<string>([parent]));\n }\n\n if (!this.parents.has(parent)) {\n this.parents.set(parent, new Set<string>());\n }\n }\n\n async deleteLink(child: string, parent: string): Promise<void> {\n this.parents.get(child)?.delete(parent);\n }\n\n syncedHasLink(name1: string, name2: string): boolean {\n this.reportGraphOnce(() => {\n const nodeCount = this.parents.size;\n const edgeCount = Array.from(this.parents.values()).reduce((sum, set) => sum + set.size, 0);\n\n return {\n message: 'resource-role initialized | nodes: %d | edges: %d',\n args: [nodeCount, edgeCount],\n };\n });\n\n if (name1 === name2) {\n return true;\n }\n\n const seeds = this.collectStoredAncestors({ name: name1 });\n\n if (seeds.length === 0) {\n return false;\n }\n\n const visited = new Set<string>();\n const queue: string[] = [...seeds];\n\n // Index cursor rather than shift(): shift() is O(n) and would make the walk quadratic.\n let head = 0;\n\n while (head < queue.length) {\n const current = queue[head];\n head += 1;\n\n if (current === name2) {\n return true;\n }\n\n if (visited.has(current)) {\n continue;\n }\n\n visited.add(current);\n\n const parents = this.parents.get(current);\n\n if (parents) {\n queue.push(...parents);\n }\n }\n\n return false;\n }\n\n async getRoles(name: string): Promise<string[]> {\n return [...(this.parents.get(name) ?? [])];\n }\n\n async getUsers(name: string): Promise<string[]> {\n const users: string[] = [];\n\n for (const [child, parents] of this.parents) {\n if (parents.has(name)) {\n users.push(child);\n }\n }\n\n return users;\n }\n\n /** All stored prefix ancestors of a dotted code (`a.b.c` -> `a.b` -> `a`), not only the deepest, plus a literal stored `'*'` node - `objectMatch(anything, '*')` is always true, so a `g4` edge whose child is `'*'` must stay reachable from every request object. */\n private collectStoredAncestors(opts: { name: string }): string[] {\n const ancestors: string[] = [];\n\n if (this.parents.has(opts.name)) {\n ancestors.push(opts.name);\n }\n\n let current = opts.name;\n\n for (;;) {\n const index = current.lastIndexOf('.');\n\n if (index === -1) {\n break;\n }\n\n current = current.slice(0, index);\n\n if (this.parents.has(current)) {\n ancestors.push(current);\n }\n }\n\n if (this.parents.has('*') && !ancestors.includes('*')) {\n ancestors.push('*');\n }\n\n return ancestors;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"grpc.component.js","sourceRoot":"","sources":["../../../../../src/components/controller/grpc/grpc.component.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACrF,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,IAAI,EA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gBAED,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;oBACtB,MAAM,CAAC,IAAI,CAAC,+DAA+D,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;oBAC1F,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;oBAC5B,SAAS;gBACX,CAAC;gBAED,QAAQ,CAAC,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,iBAAiB,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;gBACnE,QAAQ,CAAC,gBAAgB,GAAG,OAAO,EAAE,MAAM,CAAC;gBAC5C,QAAQ,CAAC,YAAY,GAAG,OAAO,EAAE,YAAY,CAAC;gBAC9C,MAAM,QAAQ,CAAC,SAAS,EAAE,CAAC;gBAE3B,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC;gBAClD,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;gBAE5B,MAAM,CAAC,IAAI,CAAC,iDAAiD,EAAE,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;YAC7F,CAAC;YAED,iFAAiF;YACjF,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC;gBACpC,GAAG,EAAE,iBAAiB,CAAC,UAAU;gBACjC,OAAO,EAAE,UAAU;aACpB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF","sourcesContent":["import type { BaseApplication } from '@/base/applications';\nimport { BaseComponent } from '@venizia/ignis-kernel';\nimport { ControllerTransports } from '@venizia/ignis-kernel';\nimport type { AbstractGrpcController } from '@/base/controllers/grpc';\nimport { BindingNamespaces } from '@venizia/ignis-kernel';\nimport { Binding, BindingValueTypes, MetadataRegistry } from '@venizia/ignis-kernel';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { HTTP, ObjectUtility } from '@venizia/ignis-helpers/common';\nimport type { IGrpcComponentConfig } from './common/types';\nimport { GrpcBindingKeys } from './common/types';\n\nconst DEFAULT_OPTIONS: IGrpcComponentConfig = {};\n\nexport class GrpcComponent extends BaseComponent {\n constructor(private application: BaseApplication) {\n super({\n scope: GrpcComponent.name,\n initDefault: { enable: true, container: application },\n bindings: {\n [GrpcBindingKeys.GRPC_COMPONENT_OPTIONS]: Binding.bind<IGrpcComponentConfig>({\n key: GrpcBindingKeys.GRPC_COMPONENT_OPTIONS,\n }).toValue(DEFAULT_OPTIONS),\n },\n });\n }\n\n override async binding(): Promise<void> {\n const logger = this.logger.for(this.binding.name);\n const router = this.application.getRootRouter();\n\n const options = this.application.get<IGrpcComponentConfig>({\n key: GrpcBindingKeys.GRPC_COMPONENT_OPTIONS,\n isOptional: true,\n });\n\n // Batch drained before re-scanning - see `RestApplication.registerDynamicBindings` for why.\n const configured = new Set<string>();\n\n let bindings = this.application.findByTag({\n tag: BindingNamespaces.CONTROLLER,\n exclude: configured,\n });\n\n while (bindings.length > 0) {\n for (const binding of bindings) {\n if (configured.has(binding.key)) {\n continue;\n }\n\n const target = binding.getBindingMeta({ type: BindingValueTypes.CLASS });\n if (!target) {\n configured.add(binding.key);\n continue;\n }\n\n const metadata = MetadataRegistry.getInstance().getControllerMetadata({ target });\n\n // Skip non-gRPC controllers — they are configured by RestComponent\n if (metadata?.transport !== ControllerTransports.GRPC) {\n configured.add(binding.key);\n continue;\n }\n\n if (!metadata?.path || ObjectUtility.isEmpty({ value: metadata.path })) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: `[registerControllers] key: '${binding.key}' | Invalid controller metadata, 'path' is required for gRPC controller metadata`,\n });\n }\n\n const instance = this.application.get<AbstractGrpcController>({\n key: binding.key,\n isOptional: false,\n });\n\n if (!instance) {\n logger.debug('No binding instance | key: %s', binding.key);\n configured.add(binding.key);\n continue;\n }\n\n if (!instance.service) {\n logger.warn('gRPC controller has no service definition, skipping | key: %s', binding.key);\n configured.add(binding.key);\n continue;\n }\n\n instance.basePath = this.application.getProjectConfigs().path.base;\n instance.connectRpcModule = options?.module;\n instance.interceptors = options?.interceptors;\n await instance.configure();\n\n router.route(metadata.path, instance.getRouter());\n configured.add(binding.key);\n\n logger.info('Configured gRPC controller | key: %s | path: %s', binding.key, metadata.path);\n }\n\n // Re-fetch excluding already configured — picks up dynamically added controllers\n bindings = this.application.findByTag({\n tag: BindingNamespaces.CONTROLLER,\n exclude: configured,\n });\n }\n }\n}\n"]}
1
+ {"version":3,"file":"grpc.component.js","sourceRoot":"","sources":["../../../../../src/components/controller/grpc/grpc.component.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACrF,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEpE,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,MAAM,eAAe,GAAyB,EAAE,CAAC;AAEjD,MAAM,OAAO,aAAc,SAAQ,aAAa;IAC9C,YAAoB,WAA4B;QAC9C,KAAK,CAAC;YACJ,KAAK,EAAE,aAAa,CAAC,IAAI;YACzB,WAAW,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE;YACrD,QAAQ,EAAE;gBACR,CAAC,eAAe,CAAC,sBAAsB,CAAC,EAAE,OAAO,CAAC,IAAI,CAAuB;oBAC3E,GAAG,EAAE,eAAe,CAAC,sBAAsB;iBAC5C,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC;aAC5B;SACF,CAAC,CAAC;QATe,gBAAW,GAAX,WA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AE,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC;gBAClD,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;gBAE5B,MAAM,CAAC,IAAI,CAAC,iDAAiD,EAAE,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;YAC7F,CAAC;YAED,iFAAiF;YACjF,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC;gBACpC,GAAG,EAAE,iBAAiB,CAAC,UAAU;gBACjC,OAAO,EAAE,UAAU;aACpB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF","sourcesContent":["import type { BaseApplication } from '@/base/applications';\nimport { BaseComponent } from '@venizia/ignis-kernel';\nimport { ControllerTransports } from '@venizia/ignis-kernel';\nimport type { AbstractGrpcController } from '@/base/controllers/grpc';\nimport { BindingNamespaces } from '@venizia/ignis-kernel';\nimport { Binding, BindingValueTypes, MetadataRegistry } from '@venizia/ignis-kernel';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { HTTP, ObjectUtility } from '@venizia/ignis-helpers/common';\nimport type { IGrpcComponentConfig } from './common/types';\nimport { GrpcBindingKeys } from './common/types';\n\nconst DEFAULT_OPTIONS: IGrpcComponentConfig = {};\n\nexport class GrpcComponent extends BaseComponent {\n constructor(private application: BaseApplication) {\n super({\n scope: GrpcComponent.name,\n initDefault: { enable: true, container: application },\n bindings: {\n [GrpcBindingKeys.GRPC_COMPONENT_OPTIONS]: Binding.bind<IGrpcComponentConfig>({\n key: GrpcBindingKeys.GRPC_COMPONENT_OPTIONS,\n }).toValue(DEFAULT_OPTIONS),\n },\n });\n }\n\n override async binding(): Promise<void> {\n const logger = this.logger.for(this.binding.name);\n const router = this.application.getRootRouter();\n\n const options = this.application.get<IGrpcComponentConfig>({\n key: GrpcBindingKeys.GRPC_COMPONENT_OPTIONS,\n isOptional: true,\n });\n\n // Batch drained before re-scanning - see `RestApplication.registerDynamicBindings` for why.\n const configured = new Set<string>();\n\n let bindings = this.application.findByTag({\n tag: BindingNamespaces.CONTROLLER,\n exclude: configured,\n });\n\n while (bindings.length > 0) {\n for (const binding of bindings) {\n if (configured.has(binding.key)) {\n continue;\n }\n\n const target = binding.getBindingMeta({ type: BindingValueTypes.CLASS });\n\n if (!target) {\n configured.add(binding.key);\n continue;\n }\n\n const metadata = MetadataRegistry.getInstance().getControllerMetadata({ target });\n\n // Skip non-gRPC controllers — they are configured by RestComponent\n if (metadata?.transport !== ControllerTransports.GRPC) {\n configured.add(binding.key);\n continue;\n }\n\n if (!metadata?.path || ObjectUtility.isEmpty({ value: metadata.path })) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: `[registerControllers] key: '${binding.key}' | Invalid controller metadata, 'path' is required for gRPC controller metadata`,\n });\n }\n\n const instance = this.application.get<AbstractGrpcController>({\n key: binding.key,\n isOptional: false,\n });\n\n if (!instance) {\n logger.debug('No binding instance | key: %s', binding.key);\n configured.add(binding.key);\n continue;\n }\n\n if (!instance.service) {\n logger.warn('gRPC controller has no service definition, skipping | key: %s', binding.key);\n configured.add(binding.key);\n continue;\n }\n\n instance.basePath = this.application.getProjectConfigs().path.base;\n instance.connectRpcModule = options?.module;\n instance.interceptors = options?.interceptors;\n await instance.configure();\n\n router.route(metadata.path, instance.getRouter());\n configured.add(binding.key);\n\n logger.info('Configured gRPC controller | key: %s | path: %s', binding.key, metadata.path);\n }\n\n // Re-fetch excluding already configured — picks up dynamically added controllers\n bindings = this.application.findByTag({\n tag: BindingNamespaces.CONTROLLER,\n exclude: configured,\n });\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../../src/components/health-check/controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,kBAAkB,EAAsB,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO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,CACjB,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,OAAO,EAAE,EACzD,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CACzB,CAAC;IACJ,CAAC;CACF,CAAA;AATC;IADC,GAAG,CAAC,EAAE,OAAO,EAAE,YAAY,CAAC,IAAI,EAAE,CAAC;;;;qDASnC;AAhEU,qBAAqB;IAM7B,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,sBAAsB,CAAC,oBAAoB,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAA;IAE9E,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,sBAAsB,CAAC,gBAAgB,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAA;;GARlE,qBAAqB,CAiEjC","sourcesContent":["import { BaseRestController, type TRouteContext } from '@/base/controllers';\nimport { api, inject } from '@/base/metadata';\nimport { OpenApiResponses } from '@venizia/ignis-kernel';\nimport type { IApplicationInfo } from '@venizia/ignis-kernel';\nimport { z } from '@hono/zod-openapi';\nimport { HTTP, type ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport {\n HealthCheckBindingKeys,\n HealthCheckHeaders,\n HealthCheckRestPaths,\n type IHealthCheckOptions,\n} from './common';\nimport { HealthCheckReporter } from './reporter';\n\nconst RouteConfigs = {\n ROOT: {\n method: HTTP.Methods.GET,\n path: HealthCheckRestPaths.ROOT,\n responses: OpenApiResponses.jsonResponse({\n schema: z.object({ status: z.string(), timestamp: z.iso.datetime() }).openapi({\n description: 'HealthCheck Schema',\n examples: [{ status: 'ok', timestamp: new Date().toISOString() }],\n }),\n description: 'Health check status',\n }),\n },\n STATS: {\n method: HTTP.Methods.GET,\n path: HealthCheckRestPaths.STATS,\n request: {\n headers: z.object({\n [HealthCheckHeaders.SECRET_KEY]: z.string().optional().openapi({\n description: 'The stats key',\n }),\n }),\n },\n responses: OpenApiResponses.jsonResponse({\n schema: z\n .object({\n status: z.string(),\n timestamp: z.iso.datetime(),\n build: z.object({\n service: z.string(),\n version: z.string(),\n commit: z.string(),\n branch: z.string(),\n builtAt: z.string(),\n }),\n process: z.object({\n pid: z.number(),\n uptime: z.number(),\n uptimeHuman: z.string(),\n runtime: z.string(),\n environment: z.string(),\n }),\n memory: z.object({ rss: z.string(), heapUsed: z.string(), heapTotal: z.string() }),\n })\n .openapi({ description: 'HealthCheck Stats Schema' }),\n description:\n 'Build stamp, process and memory - closed outside the development environments unless enabled',\n }),\n },\n PING: {\n method: HTTP.Methods.POST,\n path: HealthCheckRestPaths.PING,\n request: {\n body: OpenApiResponses.jsonContent({\n description: 'PING | Request body',\n schema: z.object({\n type: z.string().optional().default('PING'),\n message: z.string().min(1).max(255),\n }),\n }),\n },\n responses: OpenApiResponses.jsonResponse({\n schema: z\n .object({\n type: z.string().optional().default('PONG'),\n date: z.iso.datetime(),\n message: z.string(),\n })\n .openapi({\n description: 'HealthCheck PingPong Schema',\n examples: [{ date: new Date().toISOString(), message: 'ok' }],\n }),\n description: 'HealthCheck PingPong Message',\n }),\n },\n} as const;\n\nexport class HealthCheckController extends BaseRestController {\n /**\n * Both dependencies arrive through the container, so two applications in one process each get\n * their own gate - a static field would let the last one to boot decide for every other.\n */\n constructor(\n @inject({ key: HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS, isOptional: true })\n private readonly healthOptions: IHealthCheckOptions = {},\n @inject({ key: HealthCheckBindingKeys.APPLICATION_INFO, isOptional: true })\n private readonly appInfo?: IApplicationInfo,\n ) {\n super({ scope: HealthCheckController.name });\n\n // Note: This is optional declare internal controller route definitions\n this.definitions = RouteConfigs;\n }\n\n override binding(): ValueOrPromise<void> {\n // Public liveness probe: status and clock only. Nothing here names a runtime or a version.\n this.bindRoute({ configs: RouteConfigs.ROOT }).to({\n handler: (context) => {\n return context.json(HealthCheckReporter.buildSummary(), HTTP.ResultCodes.RS_2.Ok);\n },\n });\n\n if (!HealthCheckReporter.isStatsEnabled({ options: this.healthOptions })) {\n this.logger\n .for(this.binding.name)\n .debug('Stats route disabled | path: %s', HealthCheckRestPaths.STATS);\n return;\n }\n\n this.bindRoute({ configs: RouteConfigs.STATS }).to({\n handler: (context) => {\n // `context.notFound()`, not a thrown 404: it runs the application's own notFound handler,\n // so the refusal is byte-identical to the answer for a route that was never mounted. A\n // thrown `ApplicationError` serializes a different body and would confirm the route exists.\n if (\n !HealthCheckReporter.isStatsAuthorized({\n options: this.healthOptions,\n header: context.req.header(HealthCheckHeaders.SECRET_KEY),\n })\n ) {\n return context.notFound();\n }\n\n return context.json(\n HealthCheckReporter.buildStats({ options: this.healthOptions, appInfo: this.appInfo }),\n HTTP.ResultCodes.RS_2.Ok,\n );\n },\n });\n }\n\n // Method 3: Using 'decorators' to create a controller route, with an explicit type assertion for the validated request data\n @api({ configs: RouteConfigs.PING })\n pingPong(context: TRouteContext) {\n const { message } = context.req.valid<{ type?: string; message: string }>('json');\n\n // Return type is automatically validated against the response schema\n return context.json(\n { type: 'PONG', date: new Date().toISOString(), message },\n HTTP.ResultCodes.RS_2.Ok,\n );\n }\n}\n"]}
1
+ {"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../../src/components/health-check/controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,kBAAkB,EAAsB,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AACtC,OAAO,EAAE,IAAI,EAAuB,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,oBAAoB,GAErB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,MAAM,YAAY,GAAG;IACnB,IAAI,EAAE;QACJ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AE,sBAAsB,CAAC,oBAAoB,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAA;IAE9E,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,sBAAsB,CAAC,gBAAgB,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAA;;GARlE,qBAAqB,CAkEjC","sourcesContent":["import { BaseRestController, type TRouteContext } from '@/base/controllers';\nimport { api, inject } from '@/base/metadata';\nimport { OpenApiResponses } from '@venizia/ignis-kernel';\nimport type { IApplicationInfo } from '@venizia/ignis-kernel';\nimport { z } from '@hono/zod-openapi';\nimport { HTTP, type ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport {\n HealthCheckBindingKeys,\n HealthCheckHeaders,\n HealthCheckRestPaths,\n type IHealthCheckOptions,\n} from './common';\nimport { HealthCheckReporter } from './reporter';\n\nconst RouteConfigs = {\n ROOT: {\n method: HTTP.Methods.GET,\n path: HealthCheckRestPaths.ROOT,\n responses: OpenApiResponses.jsonResponse({\n schema: z.object({ status: z.string(), timestamp: z.iso.datetime() }).openapi({\n description: 'HealthCheck Schema',\n examples: [{ status: 'ok', timestamp: new Date().toISOString() }],\n }),\n description: 'Health check status',\n }),\n },\n STATS: {\n method: HTTP.Methods.GET,\n path: HealthCheckRestPaths.STATS,\n request: {\n headers: z.object({\n [HealthCheckHeaders.SECRET_KEY]: z.string().optional().openapi({\n description: 'The stats key',\n }),\n }),\n },\n responses: OpenApiResponses.jsonResponse({\n schema: z\n .object({\n status: z.string(),\n timestamp: z.iso.datetime(),\n build: z.object({\n service: z.string(),\n version: z.string(),\n commit: z.string(),\n branch: z.string(),\n builtAt: z.string(),\n }),\n process: z.object({\n pid: z.number(),\n uptime: z.number(),\n uptimeHuman: z.string(),\n runtime: z.string(),\n environment: z.string(),\n }),\n memory: z.object({ rss: z.string(), heapUsed: z.string(), heapTotal: z.string() }),\n })\n .openapi({ description: 'HealthCheck Stats Schema' }),\n description:\n 'Build stamp, process and memory - closed outside the development environments unless enabled',\n }),\n },\n PING: {\n method: HTTP.Methods.POST,\n path: HealthCheckRestPaths.PING,\n request: {\n body: OpenApiResponses.jsonContent({\n description: 'PING | Request body',\n schema: z.object({\n type: z.string().optional().default('PING'),\n message: z.string().min(1).max(255),\n }),\n }),\n },\n responses: OpenApiResponses.jsonResponse({\n schema: z\n .object({\n type: z.string().optional().default('PONG'),\n date: z.iso.datetime(),\n message: z.string(),\n })\n .openapi({\n description: 'HealthCheck PingPong Schema',\n examples: [{ date: new Date().toISOString(), message: 'ok' }],\n }),\n description: 'HealthCheck PingPong Message',\n }),\n },\n} as const;\n\nexport class HealthCheckController extends BaseRestController {\n /**\n * Both dependencies arrive through the container, so two applications in one process each get\n * their own gate - a static field would let the last one to boot decide for every other.\n */\n constructor(\n @inject({ key: HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS, isOptional: true })\n private readonly healthOptions: IHealthCheckOptions = {},\n @inject({ key: HealthCheckBindingKeys.APPLICATION_INFO, isOptional: true })\n private readonly appInfo?: IApplicationInfo,\n ) {\n super({ scope: HealthCheckController.name });\n\n // Note: This is optional declare internal controller route definitions\n this.definitions = RouteConfigs;\n }\n\n override binding(): ValueOrPromise<void> {\n // Public liveness probe: status and clock only. Nothing here names a runtime or a version.\n this.bindRoute({ configs: RouteConfigs.ROOT }).to({\n handler: (context) => {\n return context.json(HealthCheckReporter.buildSummary(), HTTP.ResultCodes.RS_2.Ok);\n },\n });\n\n if (!HealthCheckReporter.isStatsEnabled({ options: this.healthOptions })) {\n this.logger\n .for(this.binding.name)\n .debug('Stats route disabled | path: %s', HealthCheckRestPaths.STATS);\n\n return;\n }\n\n this.bindRoute({ configs: RouteConfigs.STATS }).to({\n handler: (context) => {\n // `context.notFound()`, not a thrown 404: it runs the application's own notFound handler,\n // so the refusal is byte-identical to the answer for a route that was never mounted. A\n // thrown `ApplicationError` serializes a different body and would confirm the route exists.\n if (\n !HealthCheckReporter.isStatsAuthorized({\n options: this.healthOptions,\n header: context.req.header(HealthCheckHeaders.SECRET_KEY),\n })\n ) {\n return context.notFound();\n }\n\n return context.json(\n HealthCheckReporter.buildStats({ options: this.healthOptions, appInfo: this.appInfo }),\n HTTP.ResultCodes.RS_2.Ok,\n );\n },\n });\n }\n\n // Method 3: Using 'decorators' to create a controller route, with an explicit type assertion for the validated request data\n @api({ configs: RouteConfigs.PING })\n pingPong(context: TRouteContext) {\n const { message } = context.req.valid<{ type?: string; message: string }>('json');\n\n // Return type is automatically validated against the response schema\n return context.json(\n { type: 'PONG', date: new Date().toISOString(), message },\n HTTP.ResultCodes.RS_2.Ok,\n );\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"reporter.js","sourceRoot":"","sources":["../../../../src/components/health-check/reporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAyB,MAAM,6BAA6B,CAAC;AAIvF;;;;;;;GAOG;AACH,MAAM,OAAO,mBAAmB;aACN,iBAAY,GAAG,IAAI,GAAG,IAAI,CAAC;IAEnD,iGAAiG;IACjG,MAAM,CAAC,YAAY;QACjB,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC;IAC/D,CAAC;IAED;;;;;;;;;;OAUG;IACH,MAAM,CAAC,cAAc,CAAC,IAIrB;QACC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC;QAC5C,IAAI,OAAO,MAAM,KAAK,SAAS,EAAE,CAAC;YAChC,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC;QAC5E,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,OAAO,KAAK,CAAC;QACf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uildInfoRecord } from '@venizia/ignis-helpers/core';\nimport type { IApplicationInfo } from '@venizia/ignis-kernel';\nimport type { IHealthCheckOptions } from './common';\n\n/**\n * Assembles what `GET /health` and `GET /health/stats` answer.\n *\n * Never reads the filesystem and never spawns `git`: the build stamp is PUSHED in at the\n * entrypoint through {@link BuildInfoRegistry} (or the component's own options), so a\n * `bun build --compile` binary and a Distroless image - neither of which has `node_modules`,\n * `.git` or a readable `package.json` - report exactly what a dev machine does.\n */\nexport class HealthCheckReporter {\n private static readonly BYTES_PER_MB = 1024 * 1024;\n\n /** Public liveness answer: liveness and the server clock, nothing a probe cannot already see. */\n static buildSummary(): { status: string; timestamp: string } {\n return { status: 'ok', timestamp: new Date().toISOString() };\n }\n\n /**\n * Fail-closed, copying `AppErrorMiddleware.isProduction`: the default is MEMBERSHIP in\n * `DEVELOPMENT_ENVS`, never inequality against `production`. `staging`, `uat`, `alpha` and a\n * typo all keep this route shut, because the runtime and release it names are what picks an\n * exploit. `ambient`, not `current`: an unset `NODE_ENV` is a host that cannot prove it is a dev\n * machine, and `current` would mask it as `development`.\n *\n * `enable` is compared to `true`/`false` rather than read through `??`: this binding is\n * env/config driven, and a JSON-derived `\"false\"` is truthy - an operator who wrote false would\n * otherwise get the route mounted.\n */\n static isStatsEnabled(opts: {\n options: IHealthCheckOptions;\n /** Reads the ambient environment; injected by tests so nothing has to write `process.env`. */\n environment?: () => string | undefined;\n }): boolean {\n const { enable } = opts.options.stats ?? {};\n if (typeof enable === 'boolean') {\n return enable;\n }\n\n const ambient = opts.environment ? opts.environment() : Environment.ambient;\n if (ambient === undefined) {\n return false;\n }\n\n return Environment.DEVELOPMENT_ENVS.has(ambient.toLowerCase());\n }\n\n /**\n * No `secretKey` configured leaves the route open to whatever can reach the port - stated, not\n * implied. Anything that is not a non-blank string fails CLOSED: a blank or config-derived\n * non-string key is a pipeline that lost the variable, and reading it as \"no key\" would publish\n * the route the operator meant to lock.\n *\n * The comparison is a plain `===`: a remote timing attack on a header compare is not practical\n * through an HTTP stack, and a constant-time digest compare would buy nothing here.\n */\n /**\n * Whether the stats route is mounted, unauthenticated, and on a host that cannot be shown to be a\n * development one. That combination stays LEGAL - on a cluster-internal port it is often the right\n * call - so this reports rather than refuses, and the component turns it into one warning at boot.\n *\n * It exists because `enable: true` bypasses the environment gate entirely: an operator who sets it\n * for a local run and ships the same code publishes the runtime version, the release and the\n * memory profile to whatever can reach the port. A blank `secretKey` is NOT unguarded - that fails\n * closed in {@link isStatsAuthorized}.\n */\n static isStatsUnguarded(opts: {\n options: IHealthCheckOptions;\n environment?: () => string | undefined;\n }): boolean {\n if (!HealthCheckReporter.isStatsEnabled(opts)) {\n return false;\n }\n\n if (opts.options.stats?.secretKey !== undefined) {\n return false;\n }\n\n const ambient = opts.environment ? opts.environment() : Environment.ambient;\n if (ambient === undefined) {\n return true;\n }\n\n return !Environment.DEVELOPMENT_ENVS.has(ambient.toLowerCase());\n }\n\n static isStatsAuthorized(opts: { options: IHealthCheckOptions; header?: string }): boolean {\n const secretKey = opts.options.stats?.secretKey;\n if (secretKey === undefined) {\n return true;\n }\n\n if (typeof secretKey !== 'string' || secretKey.trim().length === 0) {\n return false;\n }\n\n return opts.header === secretKey;\n }\n\n /** The slot is a process-wide `globalThis` entry any dependency can write, and `IBuildInfo` types it without checking - so a non-string never reaches the response schema, which declares `z.string()`. */\n private static extractText(opts: { value: unknown }): string | undefined {\n return typeof opts.value === 'string' && opts.value.length > 0 ? opts.value : undefined;\n }\n\n /**\n * Explicit options win over the registry, and the application's own `getAppInfo()` fills what\n * neither carries - so a host that ran no generator still reports its real name and version.\n */\n static resolveBuildInfo(opts: {\n options: IHealthCheckOptions;\n appInfo?: IApplicationInfo;\n }): TBuildInfoRecord {\n const stamp = opts.options.stats?.buildInfo ?? BuildInfoRegistry.get() ?? {};\n const extract = HealthCheckReporter.extractText;\n\n return {\n service:\n extract({ value: stamp.service }) ?? opts.appInfo?.name ?? BuildInfoRegistry.UNSPECIFIED,\n version:\n extract({ value: stamp.version }) ?? opts.appInfo?.version ?? BuildInfoRegistry.UNSPECIFIED,\n commit: extract({ value: stamp.commit }) ?? BuildInfoRegistry.UNSPECIFIED,\n branch: extract({ value: stamp.branch }) ?? BuildInfoRegistry.UNSPECIFIED,\n builtAt: extract({ value: stamp.builtAt }) ?? BuildInfoRegistry.UNSPECIFIED,\n };\n }\n\n /** `3661` -> `1h 1m 1s`: an operator reads a restart out of this faster than out of a float. */\n static toHumanUptime(opts: { seconds: number }): string {\n const total = Math.floor(opts.seconds);\n const hours = Math.floor(total / 3600);\n const minutes = Math.floor((total % 3600) / 60);\n const seconds = total % 60;\n\n return `${hours}h ${minutes}m ${seconds}s`;\n }\n\n private static toMegabytes(opts: { bytes: number }): string {\n return `${(opts.bytes / HealthCheckReporter.BYTES_PER_MB).toFixed(1)} MB`;\n }\n\n static buildStats(opts: { options: IHealthCheckOptions; appInfo?: IApplicationInfo }) {\n const memory = process.memoryUsage();\n const uptime = process.uptime();\n\n return {\n ...HealthCheckReporter.buildSummary(),\n build: HealthCheckReporter.resolveBuildInfo(opts),\n process: {\n pid: process.pid,\n uptime,\n uptimeHuman: HealthCheckReporter.toHumanUptime({ seconds: uptime }),\n runtime: `bun ${Bun.version}`,\n // `ambient`, not `current`: an unset `NODE_ENV` is reported as such, never dressed up as `development`.\n environment: Environment.ambient ?? BuildInfoRegistry.UNSPECIFIED,\n },\n memory: {\n rss: HealthCheckReporter.toMegabytes({ bytes: memory.rss }),\n heapUsed: HealthCheckReporter.toMegabytes({ bytes: memory.heapUsed }),\n heapTotal: HealthCheckReporter.toMegabytes({ bytes: memory.heapTotal }),\n },\n };\n }\n}\n"]}
1
+ {"version":3,"file":"reporter.js","sourceRoot":"","sources":["../../../../src/components/health-check/reporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAyB,MAAM,6BAA6B,CAAC;AAIvF;;;;;;;GAOG;AACH,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,EAAE,OAAO,CAAC,GAAG;gBAChB,MAAM;gBACN,WAAW,EAAE,mBAAmB,CAAC,aAAa,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;gBACnE,OAAO,EAAE,OAAO,GAAG,CAAC,OAAO,EAAE;gBAC7B,wGAAwG;gBACxG,WAAW,EAAE,WAAW,CAAC,OAAO,IAAI,iBAAiB,CAAC,WAAW;aAClE;YACD,MAAM,EAAE;gBACN,GAAG,EAAE,mBAAmB,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,EAAE,CAAC;gBAC3D,QAAQ,EAAE,mBAAmB,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC;gBACrE,SAAS,EAAE,mBAAmB,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,SAAS,EAAE,CAAC;aACxE;SACF,CAAC;IACJ,CAAC","sourcesContent":["import { Environment } from '@venizia/ignis-helpers';\nimport { BuildInfoRegistry, type TBuildInfoRecord } from '@venizia/ignis-helpers/core';\nimport type { IApplicationInfo } from '@venizia/ignis-kernel';\nimport type { IHealthCheckOptions } from './common';\n\n/**\n * Assembles what `GET /health` and `GET /health/stats` answer.\n *\n * Never reads the filesystem and never spawns `git`: the build stamp is PUSHED in at the\n * entrypoint through {@link BuildInfoRegistry} (or the component's own options), so a\n * `bun build --compile` binary and a Distroless image - neither of which has `node_modules`,\n * `.git` or a readable `package.json` - report exactly what a dev machine does.\n */\nexport class HealthCheckReporter {\n private static readonly BYTES_PER_MB = 1024 * 1024;\n\n /** Public liveness answer: liveness and the server clock, nothing a probe cannot already see. */\n static buildSummary(): { status: string; timestamp: string } {\n return { status: 'ok', timestamp: new Date().toISOString() };\n }\n\n /**\n * Fail-closed, copying `AppErrorMiddleware.isProduction`: the default is MEMBERSHIP in\n * `DEVELOPMENT_ENVS`, never inequality against `production`. `staging`, `uat`, `alpha` and a\n * typo all keep this route shut, because the runtime and release it names are what picks an\n * exploit. `ambient`, not `current`: an unset `NODE_ENV` is a host that cannot prove it is a dev\n * machine, and `current` would mask it as `development`.\n *\n * `enable` is compared to `true`/`false` rather than read through `??`: this binding is\n * env/config driven, and a JSON-derived `\"false\"` is truthy - an operator who wrote false would\n * otherwise get the route mounted.\n */\n static isStatsEnabled(opts: {\n options: IHealthCheckOptions;\n /** Reads the ambient environment; injected by tests so nothing has to write `process.env`. */\n environment?: () => string | undefined;\n }): boolean {\n const { enable } = opts.options.stats ?? {};\n\n if (typeof enable === 'boolean') {\n return enable;\n }\n\n const ambient = opts.environment ? opts.environment() : Environment.ambient;\n\n if (ambient === undefined) {\n return false;\n }\n\n return Environment.DEVELOPMENT_ENVS.has(ambient.toLowerCase());\n }\n\n /**\n * No `secretKey` configured leaves the route open to whatever can reach the port - stated, not\n * implied. Anything that is not a non-blank string fails CLOSED: a blank or config-derived\n * non-string key is a pipeline that lost the variable, and reading it as \"no key\" would publish\n * the route the operator meant to lock.\n *\n * The comparison is a plain `===`: a remote timing attack on a header compare is not practical\n * through an HTTP stack, and a constant-time digest compare would buy nothing here.\n */\n /**\n * Whether the stats route is mounted, unauthenticated, and on a host that cannot be shown to be a\n * development one. That combination stays LEGAL - on a cluster-internal port it is often the right\n * call - so this reports rather than refuses, and the component turns it into one warning at boot.\n *\n * It exists because `enable: true` bypasses the environment gate entirely: an operator who sets it\n * for a local run and ships the same code publishes the runtime version, the release and the\n * memory profile to whatever can reach the port. A blank `secretKey` is NOT unguarded - that fails\n * closed in {@link isStatsAuthorized}.\n */\n static isStatsUnguarded(opts: {\n options: IHealthCheckOptions;\n environment?: () => string | undefined;\n }): boolean {\n if (!HealthCheckReporter.isStatsEnabled(opts)) {\n return false;\n }\n\n if (opts.options.stats?.secretKey !== undefined) {\n return false;\n }\n\n const ambient = opts.environment ? opts.environment() : Environment.ambient;\n\n if (ambient === undefined) {\n return true;\n }\n\n return !Environment.DEVELOPMENT_ENVS.has(ambient.toLowerCase());\n }\n\n static isStatsAuthorized(opts: { options: IHealthCheckOptions; header?: string }): boolean {\n const secretKey = opts.options.stats?.secretKey;\n\n if (secretKey === undefined) {\n return true;\n }\n\n if (typeof secretKey !== 'string' || secretKey.trim().length === 0) {\n return false;\n }\n\n return opts.header === secretKey;\n }\n\n /** The slot is a process-wide `globalThis` entry any dependency can write, and `IBuildInfo` types it without checking - so a non-string never reaches the response schema, which declares `z.string()`. */\n private static extractText(opts: { value: unknown }): string | undefined {\n return typeof opts.value === 'string' && opts.value.length > 0 ? opts.value : undefined;\n }\n\n /**\n * Explicit options win over the registry, and the application's own `getAppInfo()` fills what\n * neither carries - so a host that ran no generator still reports its real name and version.\n */\n static resolveBuildInfo(opts: {\n options: IHealthCheckOptions;\n appInfo?: IApplicationInfo;\n }): TBuildInfoRecord {\n const stamp = opts.options.stats?.buildInfo ?? BuildInfoRegistry.get() ?? {};\n const extract = HealthCheckReporter.extractText;\n\n return {\n service:\n extract({ value: stamp.service }) ?? opts.appInfo?.name ?? BuildInfoRegistry.UNSPECIFIED,\n version:\n extract({ value: stamp.version }) ?? opts.appInfo?.version ?? BuildInfoRegistry.UNSPECIFIED,\n commit: extract({ value: stamp.commit }) ?? BuildInfoRegistry.UNSPECIFIED,\n branch: extract({ value: stamp.branch }) ?? BuildInfoRegistry.UNSPECIFIED,\n builtAt: extract({ value: stamp.builtAt }) ?? BuildInfoRegistry.UNSPECIFIED,\n };\n }\n\n /** `3661` -> `1h 1m 1s`: an operator reads a restart out of this faster than out of a float. */\n static toHumanUptime(opts: { seconds: number }): string {\n const total = Math.floor(opts.seconds);\n const hours = Math.floor(total / 3600);\n const minutes = Math.floor((total % 3600) / 60);\n const seconds = total % 60;\n\n return `${hours}h ${minutes}m ${seconds}s`;\n }\n\n private static toMegabytes(opts: { bytes: number }): string {\n return `${(opts.bytes / HealthCheckReporter.BYTES_PER_MB).toFixed(1)} MB`;\n }\n\n static buildStats(opts: { options: IHealthCheckOptions; appInfo?: IApplicationInfo }) {\n const memory = process.memoryUsage();\n const uptime = process.uptime();\n\n return {\n ...HealthCheckReporter.buildSummary(),\n build: HealthCheckReporter.resolveBuildInfo(opts),\n process: {\n pid: process.pid,\n uptime,\n uptimeHuman: HealthCheckReporter.toHumanUptime({ seconds: uptime }),\n runtime: `bun ${Bun.version}`,\n // `ambient`, not `current`: an unset `NODE_ENV` is reported as such, never dressed up as `development`.\n environment: Environment.ambient ?? BuildInfoRegistry.UNSPECIFIED,\n },\n memory: {\n rss: HealthCheckReporter.toMegabytes({ bytes: memory.rss }),\n heapUsed: HealthCheckReporter.toMegabytes({ bytes: memory.heapUsed }),\n heapTotal: HealthCheckReporter.toMegabytes({ bytes: memory.heapTotal }),\n },\n };\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/components/mail/common/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE1D,MAAM,OAAO,YAAY;aACP,sBAAiB,GAAG,CAAC,CAAC;aACtB,kBAAa,GAAG,qBAAqB,CAAC;IACtD,mFAAmF;aACnE,yBAAoB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;;AAG1D,yKAAyK;AACzK,MAAM,OAAO,cAAc;aACT,0BAAqB,GAAG,WAAW,CAAC,KAAK,CAAC;QACxD,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,uBAAuB,CAAC;KACjD,CAAC,CAAC;aACa,gBAAW,GAAG,WAAW,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,CAAC,CAAC;aAC5E,wBAAmB,GAAG,WAAW,CAAC,KAAK,CAAC;QACtD,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,qBAAqB,CAAC;KAC/C,CAAC,CAAC;aACa,sBAAiB,GAAG,WAAW,CAAC,KAAK,CAAC;QACpD,KAAK,EAAE,CAAC,MAAM,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aAAQ,GAAG,IAAI,GAAG,CAAS,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3F,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;;AAGH,MAAM,OAAO,aAAa;aACR,eAAU,GAAG,YAAY,CAAC;aAC1B,YAAO,GAAG,SAAS,CAAC;aACpB,WAAM,GAAG,QAAQ,CAAC;IAClC,uHAAuH;aACvG,eAAU,GAAG,YAAY,CAAC;;AAK5C,iHAAiH;AACjH,MAAM,OAAO,gBAAgB;aACX,UAAK,GAAG,OAAO,CAAC;aAChB,gBAAW,GAAG,aAAa,CAAC;aAE5B,eAAU,GAAG,IAAI,GAAG,CAAS,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IAE7E,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC","sourcesContent":["import type { TConstValue } from '@venizia/ignis-helpers/common';\nimport { MessageCode } from '@venizia/ignis-helpers/core';\n\nexport class MailDefaults {\n static readonly BATCH_CONCURRENCY = 5;\n static readonly FALLBACK_FROM = 'noreply@example.com';\n /** Bytes of attachment content one message may carry, all attachments together. */\n static readonly MAX_ATTACHMENT_BYTES = 25 * 1024 * 1024;\n}\n\n/** Built via {@link MessageCode.build}: `ApplicationError` lower-cases codes, so a SCREAMING_CASE literal would reach the client in a spelling no const here matches. */\nexport class MailErrorCodes {\n static readonly INVALID_CONFIGURATION = MessageCode.build({\n parts: ['core', 'mail', 'invalid_configuration'],\n });\n static readonly SEND_FAILED = MessageCode.build({ parts: ['core', 'mail', 'send_failed'] });\n static readonly VERIFICATION_FAILED = MessageCode.build({\n parts: ['core', 'mail', 'verification_failed'],\n });\n static readonly INVALID_RECIPIENT = MessageCode.build({\n parts: ['core', 'mail', 'invalid_recipient'],\n });\n static readonly BATCH_SEND_FAILED = MessageCode.build({\n parts: ['core', 'mail', 'batch_send_failed'],\n });\n static readonly TEMPLATE_NOT_FOUND = MessageCode.build({\n parts: ['core', 'mail', 'template_not_found'],\n });\n static readonly ATTACHMENT_PATH_REFUSED = MessageCode.build({\n parts: ['core', 'mail', 'attachment_path_refused'],\n });\n static readonly ATTACHMENT_TOO_LARGE = MessageCode.build({\n parts: ['core', 'mail', 'attachment_too_large'],\n });\n static readonly BODY_SOURCE_REFUSED = MessageCode.build({\n parts: ['core', 'mail', 'body_source_refused'],\n });\n}\n\nexport class MailExecutorErrors {\n static readonly PROCESSOR_NOT_SET = 'Processor not set. Call setProcessor() first.';\n}\n\nexport class MailQueueExecutorTypes {\n static readonly DIRECT = 'direct';\n static readonly INTERNAL_QUEUE = 'internal-queue';\n static readonly BULLMQ = 'bullmq';\n\n static readonly SCHEME_SET = new Set<string>([this.DIRECT, this.INTERNAL_QUEUE, this.BULLMQ]);\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\nexport class BullMQExecutorModes {\n static readonly QUEUE_ONLY = 'queue-only';\n static readonly WORKER_ONLY = 'worker-only';\n static readonly BOTH = 'both';\n\n static readonly MODE_SET = new Set<string>([this.QUEUE_ONLY, this.WORKER_ONLY, this.BOTH]);\n static isValid(value: string): boolean {\n return this.MODE_SET.has(value);\n }\n}\n\nexport class MailProviders {\n static readonly NODEMAILER = 'nodemailer';\n static readonly MAILGUN = 'mailgun';\n static readonly CUSTOM = 'custom';\n // Amazon SES supports both SMTP and HTTPS - this provider is the HTTPS API path; SMTP goes through NODEMAILER instead.\n static readonly AMAZON_SES = 'amazon-ses';\n}\n\nexport type TMailProvider = TConstValue<typeof MailProviders>;\n\n/** How the delay between two attempts to send a queued mail grows: FIXED stays the same, EXPONENTIAL doubles. */\nexport class MailBackoffTypes {\n static readonly FIXED = 'fixed';\n static readonly EXPONENTIAL = 'exponential';\n\n static readonly SCHEME_SET = new Set<string>([this.FIXED, this.EXPONENTIAL]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** Valid mail backoff type values. */\nexport type TMailBackoffType = TConstValue<typeof MailBackoffTypes>;\n"]}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/components/mail/common/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE1D,MAAM,OAAO,YAAY;aACP,sBAAiB,GAAG,CAAC,CAAC;aACtB,kBAAa,GAAG,qBAAqB,CAAC;IACtD,mFAAmF;aACnE,yBAAoB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;;AAG1D,yKAAyK;AACzK,MAAM,OAAO,cAAc;aACT,0BAAqB,GAAG,WAAW,CAAC,KAAK,CAAC;QACxD,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,uBAAuB,CAAC;KACjD,CAAC,CAAC;aAEa,gBAAW,GAAG,WAAW,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,CAAC,CAAC;aAC5E,wBAAmB,GAAG,WAAW,CAAC,KAAK,CAAC;QACtD,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,qBAAqB,CAAC;KAC/C,CAAC,CAAC;aAEa,sBAAiB,GAAG,WAAW,CAAC,KAAK,CAAC;QACpD,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,mBAAmB,CAAC;KAC7C,CAAC,CAAC;aAEa,sBAAiB,GAAG,WAAW,CAAC,KAAK,CAAC;QACpD,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,mBAAmB,CAAC;KAC7C,CAAC,CAAC;aAEa,uBAAkB,GAAG,WAAW,CAAC,KAAK,CAAC;QACrD,KAAK,EAAE,CAAC,MA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GH,MAAM,OAAO,aAAa;aACR,eAAU,GAAG,YAAY,CAAC;aAC1B,YAAO,GAAG,SAAS,CAAC;aACpB,WAAM,GAAG,QAAQ,CAAC;IAClC,uHAAuH;aACvG,eAAU,GAAG,YAAY,CAAC;;AAK5C,iHAAiH;AACjH,MAAM,OAAO,gBAAgB;aACX,UAAK,GAAG,OAAO,CAAC;aAChB,gBAAW,GAAG,aAAa,CAAC;aAE5B,eAAU,GAAG,IAAI,GAAG,CAAS,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IAE7E,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC","sourcesContent":["import type { TConstValue } from '@venizia/ignis-helpers/common';\nimport { MessageCode } from '@venizia/ignis-helpers/core';\n\nexport class MailDefaults {\n static readonly BATCH_CONCURRENCY = 5;\n static readonly FALLBACK_FROM = 'noreply@example.com';\n /** Bytes of attachment content one message may carry, all attachments together. */\n static readonly MAX_ATTACHMENT_BYTES = 25 * 1024 * 1024;\n}\n\n/** Built via {@link MessageCode.build}: `ApplicationError` lower-cases codes, so a SCREAMING_CASE literal would reach the client in a spelling no const here matches. */\nexport class MailErrorCodes {\n static readonly INVALID_CONFIGURATION = MessageCode.build({\n parts: ['core', 'mail', 'invalid_configuration'],\n });\n\n static readonly SEND_FAILED = MessageCode.build({ parts: ['core', 'mail', 'send_failed'] });\n static readonly VERIFICATION_FAILED = MessageCode.build({\n parts: ['core', 'mail', 'verification_failed'],\n });\n\n static readonly INVALID_RECIPIENT = MessageCode.build({\n parts: ['core', 'mail', 'invalid_recipient'],\n });\n\n static readonly BATCH_SEND_FAILED = MessageCode.build({\n parts: ['core', 'mail', 'batch_send_failed'],\n });\n\n static readonly TEMPLATE_NOT_FOUND = MessageCode.build({\n parts: ['core', 'mail', 'template_not_found'],\n });\n\n static readonly ATTACHMENT_PATH_REFUSED = MessageCode.build({\n parts: ['core', 'mail', 'attachment_path_refused'],\n });\n\n static readonly ATTACHMENT_TOO_LARGE = MessageCode.build({\n parts: ['core', 'mail', 'attachment_too_large'],\n });\n\n static readonly BODY_SOURCE_REFUSED = MessageCode.build({\n parts: ['core', 'mail', 'body_source_refused'],\n });\n}\n\nexport class MailExecutorErrors {\n static readonly PROCESSOR_NOT_SET = 'Processor not set. Call setProcessor() first.';\n}\n\nexport class MailQueueExecutorTypes {\n static readonly DIRECT = 'direct';\n static readonly INTERNAL_QUEUE = 'internal-queue';\n static readonly BULLMQ = 'bullmq';\n\n static readonly SCHEME_SET = new Set<string>([this.DIRECT, this.INTERNAL_QUEUE, this.BULLMQ]);\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\nexport class BullMQExecutorModes {\n static readonly QUEUE_ONLY = 'queue-only';\n static readonly WORKER_ONLY = 'worker-only';\n static readonly BOTH = 'both';\n\n static readonly MODE_SET = new Set<string>([this.QUEUE_ONLY, this.WORKER_ONLY, this.BOTH]);\n static isValid(value: string): boolean {\n return this.MODE_SET.has(value);\n }\n}\n\nexport class MailProviders {\n static readonly NODEMAILER = 'nodemailer';\n static readonly MAILGUN = 'mailgun';\n static readonly CUSTOM = 'custom';\n // Amazon SES supports both SMTP and HTTPS - this provider is the HTTPS API path; SMTP goes through NODEMAILER instead.\n static readonly AMAZON_SES = 'amazon-ses';\n}\n\nexport type TMailProvider = TConstValue<typeof MailProviders>;\n\n/** How the delay between two attempts to send a queued mail grows: FIXED stays the same, EXPONENTIAL doubles. */\nexport class MailBackoffTypes {\n static readonly FIXED = 'fixed';\n static readonly EXPONENTIAL = 'exponential';\n\n static readonly SCHEME_SET = new Set<string>([this.FIXED, this.EXPONENTIAL]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** Valid mail backoff type values. */\nexport type TMailBackoffType = TConstValue<typeof MailBackoffTypes>;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../../../src/components/mail/common/keys.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,QAAQ;IACnB,oBAAoB;aACJ,iBAAY,GAAG,8BAA8B,CAAC;aAC9C,+BAA0B,GAAG,4CAA4C,CAAC;IAE1F,cAAc;aACE,4BAAuB,GAAG,yCAAyC,CAAC;aACpE,4BAAuB,GAAG,yCAAyC,CAAC;IAEpF,WAAW;aACK,yBAAoB,GAAG,+CAA+C,CAAC;aACvE,iBAAY,GAAG,8BAA8B,CAAC;IAE9D,aAAa;aACG,qCAAgC,GAC9C,kDAAkD,CAAC;aACrC,sCAAiC,GAC/C,mDAAmD,CAAC;aACtC,qCAAgC,GAC9C,kDAAkD,CAAC;IAErD,QAAQ;aACQ,iCAA4B,GAAG,8CAA8C,CAAC;aAC9E,iCAA4B,GAAG,8CAA8C,CAAC","sourcesContent":["export class MailKeys {\n // Options & Configs\n static readonly MAIL_OPTIONS = '@app/components/mail/options';\n static readonly MAIL_QUEUE_EXECUTOR_CONFIG = '@app/components/mail/queue/executor-config';\n\n // Transporter\n static readonly MAIL_TRANSPORT_PROVIDER = '@app/components/mail/transport-provider';\n static readonly MAIL_TRANSPORT_INSTANCE = '@app/components/mail/transport-instance';\n\n // Services\n static readonly MAIL_TEMPLATE_ENGINE = '@app/components/mail/services/template-engine';\n static readonly MAIL_SERVICE = '@app/components/mail/service';\n\n // Generators\n static readonly MAIL_VERIFICATION_CODE_GENERATOR =\n '@app/components/mail/verification/code-generator';\n static readonly MAIL_VERIFICATION_TOKEN_GENERATOR =\n '@app/components/mail/verification/token-generator';\n static readonly MAIL_VERIFICATION_DATA_GENERATOR =\n '@app/components/mail/verification/data-generator';\n\n // Queue\n static readonly MAIL_QUEUE_EXECUTOR_PROVIDER = '@app/components/mail/queue-executor-provider';\n static readonly MAIL_QUEUE_EXECUTOR_INSTANCE = '@app/components/mail/queue-executor-instance';\n}\n"]}
1
+ {"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../../../src/components/mail/common/keys.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,QAAQ;IACnB,oBAAoB;aACJ,iBAAY,GAAG,8BAA8B,CAAC;aAC9C,+BAA0B,GAAG,4CAA4C,CAAC;IAE1F,cAAc;aACE,4BAAuB,GAAG,yCAAyC,CAAC;aACpE,4BAAuB,GAAG,yCAAyC,CAAC;IAEpF,WAAW;aACK,yBAAoB,GAAG,+CAA+C,CAAC;aACvE,iBAAY,GAAG,8BAA8B,CAAC;IAE9D,aAAa;aACG,qCAAgC,GAC9C,kDAAkD,CAAC;aAErC,sCAAiC,GAC/C,mDAAmD,CAAC;aAEtC,qCAAgC,GAC9C,kDAAkD,CAAC;IAErD,QAAQ;aACQ,iCAA4B,GAAG,8CAA8C,CAAC;aAC9E,iCAA4B,GAAG,8CAA8C,CAAC","sourcesContent":["export class MailKeys {\n // Options & Configs\n static readonly MAIL_OPTIONS = '@app/components/mail/options';\n static readonly MAIL_QUEUE_EXECUTOR_CONFIG = '@app/components/mail/queue/executor-config';\n\n // Transporter\n static readonly MAIL_TRANSPORT_PROVIDER = '@app/components/mail/transport-provider';\n static readonly MAIL_TRANSPORT_INSTANCE = '@app/components/mail/transport-instance';\n\n // Services\n static readonly MAIL_TEMPLATE_ENGINE = '@app/components/mail/services/template-engine';\n static readonly MAIL_SERVICE = '@app/components/mail/service';\n\n // Generators\n static readonly MAIL_VERIFICATION_CODE_GENERATOR =\n '@app/components/mail/verification/code-generator';\n\n static readonly MAIL_VERIFICATION_TOKEN_GENERATOR =\n '@app/components/mail/verification/token-generator';\n\n static readonly MAIL_VERIFICATION_DATA_GENERATOR =\n '@app/components/mail/verification/data-generator';\n\n // Queue\n static readonly MAIL_QUEUE_EXECUTOR_PROVIDER = '@app/components/mail/queue-executor-provider';\n static readonly MAIL_QUEUE_EXECUTOR_INSTANCE = '@app/components/mail/queue-executor-instance';\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"component.js","sourceRoot":"","sources":["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AAC,EAAE,GAAG,EAAE,QAAQ,CAAC,uBAAuB,EAAE,CAAC,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;QAEhG,QAAQ;QACR,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAA0B;YAChE,GAAG,EAAE,QAAQ,CAAC,4BAA4B;SAC3C,CAAC,CAAC;QAEH,oJAAoJ;QACpJ,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAA2B;YACjE,GAAG,EAAE,QAAQ,CAAC,0BAA0B;YACxC,UAAU,EAAE,IAAI;SACjB,CAAC,IAAI,EAAE,IAAI,EAAE,sBAAsB,CAAC,MAAM,EAAE,CAAC;QAE9C,oEAAoE;QACpE,IAAI,CAAC,MAAM;aACR,GAAG,CAAC,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC;aACrC,IAAI,CAAC,8BAA8B,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC;QAE1D,MAAM,qBAAqB,GAAG,WAAW,CAAC,WAAW,CAAC,CAAC;QACvD,IAAI,CAAC,WAAW;aACb,IAAI,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,4BAA4B,EAAE,CAAC;aACpD,OAAO,CAAC,qBAAqB,CAAC,CAAC;IACpC,CAAC;CACF,CAAA;AAnKY,aAAa;IAErB,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,oBAAoB,EAAE,CAAC,CAAA;;GAF1C,aAAa,CAmKzB","sourcesContent":["import { type BaseApplication } from '@/base/applications';\nimport { BaseComponent } from '@venizia/ignis-kernel';\nimport { inject } from '@/base/metadata';\nimport { CoreBindings } from '@/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { HTTP } from '@venizia/ignis-helpers/common';\nimport { statSync } from 'node:fs';\nimport { isAbsolute } from 'node:path';\nimport type { IMailQueueExecutorConfig, TMailOptions } from './common';\nimport { MailErrorCodes, MailKeys, MailQueueExecutorTypes } from './common';\nimport type { TGetMailQueueExecutorFn, TGetMailTransportFn } from './providers';\nimport { MailQueueExecutorProvider, MailTransportProvider } from './providers';\nimport {\n DefaultVerificationDataGenerator,\n MailService,\n NumericCodeGenerator,\n RandomTokenGenerator,\n TemplateEngineService,\n} from './services';\n\nexport class MailComponent extends BaseComponent<TMailOptions> {\n constructor(\n @inject({ key: CoreBindings.APPLICATION_INSTANCE }) private application: BaseApplication,\n ) {\n super({\n scope: MailComponent.name,\n initDefault: { enable: true, container: application },\n bindings: {},\n });\n }\n\n /** `application.component(MailComponent, { options })` lands here; the call site outranks a key bound earlier. */\n override async configure(opts?: TMailOptions): Promise<void> {\n // The base short-circuits a second call; binding before that check would swap the options\n // under a transport that was already built from the first ones.\n if (this.isConfigured) {\n return;\n }\n\n if (opts !== undefined) {\n this.application.bind<TMailOptions>({ key: MailKeys.MAIL_OPTIONS }).toValue(opts);\n }\n\n await super.configure(opts);\n }\n\n override binding(): void | Promise<void> {\n if (!this.application.isBound({ key: MailKeys.MAIL_OPTIONS })) {\n this.logger\n .for(this.binding.name)\n .error(\n 'Mail options not configured. Please bind MailKeys.MAIL_OPTIONS before adding MailComponent.',\n );\n\n throw getError({\n message: 'Mail options not configured',\n });\n }\n\n this.initGenerators();\n this.initProviders();\n this.initServices();\n\n this.createAndBindInstances();\n\n this.logger.for(this.binding.name).info('Mail component initialized successfully');\n }\n\n initGenerators() {\n this.application\n .bind({ key: MailKeys.MAIL_VERIFICATION_CODE_GENERATOR })\n .toClass(NumericCodeGenerator);\n this.application\n .bind({ key: MailKeys.MAIL_VERIFICATION_TOKEN_GENERATOR })\n .toClass(RandomTokenGenerator);\n this.application\n .bind({ key: MailKeys.MAIL_VERIFICATION_DATA_GENERATOR })\n .toClass(DefaultVerificationDataGenerator);\n }\n\n initProviders() {\n this.application\n .bind({ key: MailKeys.MAIL_TRANSPORT_PROVIDER })\n .toProvider(MailTransportProvider)\n .setScope('singleton');\n this.application\n .bind({ key: MailKeys.MAIL_QUEUE_EXECUTOR_PROVIDER })\n .toProvider(MailQueueExecutorProvider)\n .setScope('singleton');\n }\n\n initServices() {\n this.application\n .bind({ key: MailKeys.MAIL_SERVICE })\n .toClass(MailService)\n .setScope('singleton');\n this.application\n .bind({ key: MailKeys.MAIL_TEMPLATE_ENGINE })\n .toClass(TemplateEngineService)\n .setScope('singleton');\n }\n\n /** A bad limit or root would otherwise surface on every send, as a 400 that blames the caller. */\n private validateAttachmentOptions(opts: { options: TMailOptions }): void {\n const { attachmentRoot, maxAttachmentBytes } = opts.options;\n const buildOptionError = (details: { message: string; cause?: unknown }) => {\n return getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n messageCode: MailErrorCodes.INVALID_CONFIGURATION,\n message: `Invalid mail options | ${details.message}`,\n cause: details.cause,\n });\n };\n\n const isValidLimit =\n maxAttachmentBytes === undefined ||\n (Number.isSafeInteger(maxAttachmentBytes) && maxAttachmentBytes > 0);\n\n if (!isValidLimit) {\n throw buildOptionError({ message: 'maxAttachmentBytes must be a positive integer' });\n }\n\n if (attachmentRoot === undefined) {\n return;\n }\n\n if (typeof attachmentRoot !== 'string' || !isAbsolute(attachmentRoot)) {\n throw buildOptionError({ message: 'attachmentRoot must be an absolute path' });\n }\n\n let isDirectory: boolean;\n\n try {\n isDirectory = statSync(attachmentRoot).isDirectory();\n } catch (error) {\n throw buildOptionError({\n message: 'attachmentRoot must be an existing directory',\n cause: error,\n });\n }\n\n if (!isDirectory) {\n throw buildOptionError({ message: 'attachmentRoot must be an existing directory' });\n }\n }\n\n createAndBindInstances(): void {\n // Transport\n const transportGetter = this.application.get<TGetMailTransportFn>({\n key: MailKeys.MAIL_TRANSPORT_PROVIDER,\n });\n const mailOptions = this.application.get<TMailOptions>({ key: MailKeys.MAIL_OPTIONS });\n this.validateAttachmentOptions({ options: mailOptions });\n\n // Only the provider is logged: the options carry SMTP / API credentials, which must never reach a log sink.\n this.logger\n .for(this.createAndBindInstances.name)\n .info('Mail provider: %s', mailOptions.provider);\n\n const mailTransportInstance = transportGetter(mailOptions);\n this.application.bind({ key: MailKeys.MAIL_TRANSPORT_INSTANCE }).toValue(mailTransportInstance);\n\n // Queue\n const queueGetter = this.application.get<TGetMailQueueExecutorFn>({\n key: MailKeys.MAIL_QUEUE_EXECUTOR_PROVIDER,\n });\n\n // Queueing is opt-in: with no executor config bound, fall back to the direct (inline) executor instead of a \"binding is not bounded\" crash at boot.\n const queueConfig = this.application.get<IMailQueueExecutorConfig>({\n key: MailKeys.MAIL_QUEUE_EXECUTOR_CONFIG,\n isOptional: true,\n }) ?? { type: MailQueueExecutorTypes.DIRECT };\n\n // Same reason as above: a bullmq config carries the Redis password.\n this.logger\n .for(this.createAndBindInstances.name)\n .info('Mail queue executor type: %s', queueConfig.type);\n\n const queueExecutorInstance = queueGetter(queueConfig);\n this.application\n .bind({ key: MailKeys.MAIL_QUEUE_EXECUTOR_INSTANCE })\n .toValue(queueExecutorInstance);\n }\n}\n"]}
1
+ {"version":3,"file":"component.js","sourceRoot":"","sources":["../../../../src/components/mail/component.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAE5E,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAC/E,OAAO,EACL,gCAAgC,EAChC,WAAW,EACX,oBAAoB,EACpB,oBAAoB,EACpB,qBAAq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,GAAG,WAAW,CAAC,WAAW,CAAC,CAAC;QACvD,IAAI,CAAC,WAAW;aACb,IAAI,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,4BAA4B,EAAE,CAAC;aACpD,OAAO,CAAC,qBAAqB,CAAC,CAAC;IACpC,CAAC;CACF,CAAA;AApKY,aAAa;IAErB,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,oBAAoB,EAAE,CAAC,CAAA;;GAF1C,aAAa,CAoKzB","sourcesContent":["import { type BaseApplication } from '@/base/applications';\nimport { BaseComponent } from '@venizia/ignis-kernel';\nimport { inject } from '@/base/metadata';\nimport { CoreBindings } from '@/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { HTTP } from '@venizia/ignis-helpers/common';\nimport { statSync } from 'node:fs';\nimport { isAbsolute } from 'node:path';\nimport type { IMailQueueExecutorConfig, TMailOptions } from './common';\nimport { MailErrorCodes, MailKeys, MailQueueExecutorTypes } from './common';\nimport type { TGetMailQueueExecutorFn, TGetMailTransportFn } from './providers';\nimport { MailQueueExecutorProvider, MailTransportProvider } from './providers';\nimport {\n DefaultVerificationDataGenerator,\n MailService,\n NumericCodeGenerator,\n RandomTokenGenerator,\n TemplateEngineService,\n} from './services';\n\nexport class MailComponent extends BaseComponent<TMailOptions> {\n constructor(\n @inject({ key: CoreBindings.APPLICATION_INSTANCE }) private application: BaseApplication,\n ) {\n super({\n scope: MailComponent.name,\n initDefault: { enable: true, container: application },\n bindings: {},\n });\n }\n\n /** `application.component(MailComponent, { options })` lands here; the call site outranks a key bound earlier. */\n override async configure(opts?: TMailOptions): Promise<void> {\n // The base short-circuits a second call; binding before that check would swap the options\n // under a transport that was already built from the first ones.\n if (this.isConfigured) {\n return;\n }\n\n if (opts !== undefined) {\n this.application.bind<TMailOptions>({ key: MailKeys.MAIL_OPTIONS }).toValue(opts);\n }\n\n await super.configure(opts);\n }\n\n override binding(): void | Promise<void> {\n if (!this.application.isBound({ key: MailKeys.MAIL_OPTIONS })) {\n this.logger\n .for(this.binding.name)\n .error(\n 'Mail options not configured. Please bind MailKeys.MAIL_OPTIONS before adding MailComponent.',\n );\n\n throw getError({\n message: 'Mail options not configured',\n });\n }\n\n this.initGenerators();\n this.initProviders();\n this.initServices();\n\n this.createAndBindInstances();\n\n this.logger.for(this.binding.name).info('Mail component initialized successfully');\n }\n\n initGenerators() {\n this.application\n .bind({ key: MailKeys.MAIL_VERIFICATION_CODE_GENERATOR })\n .toClass(NumericCodeGenerator);\n this.application\n .bind({ key: MailKeys.MAIL_VERIFICATION_TOKEN_GENERATOR })\n .toClass(RandomTokenGenerator);\n this.application\n .bind({ key: MailKeys.MAIL_VERIFICATION_DATA_GENERATOR })\n .toClass(DefaultVerificationDataGenerator);\n }\n\n initProviders() {\n this.application\n .bind({ key: MailKeys.MAIL_TRANSPORT_PROVIDER })\n .toProvider(MailTransportProvider)\n .setScope('singleton');\n this.application\n .bind({ key: MailKeys.MAIL_QUEUE_EXECUTOR_PROVIDER })\n .toProvider(MailQueueExecutorProvider)\n .setScope('singleton');\n }\n\n initServices() {\n this.application\n .bind({ key: MailKeys.MAIL_SERVICE })\n .toClass(MailService)\n .setScope('singleton');\n this.application\n .bind({ key: MailKeys.MAIL_TEMPLATE_ENGINE })\n .toClass(TemplateEngineService)\n .setScope('singleton');\n }\n\n /** A bad limit or root would otherwise surface on every send, as a 400 that blames the caller. */\n private validateAttachmentOptions(opts: { options: TMailOptions }): void {\n const { attachmentRoot, maxAttachmentBytes } = opts.options;\n\n const buildOptionError = (details: { message: string; cause?: unknown }) => {\n return getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n messageCode: MailErrorCodes.INVALID_CONFIGURATION,\n message: `Invalid mail options | ${details.message}`,\n cause: details.cause,\n });\n };\n\n const isValidLimit =\n maxAttachmentBytes === undefined ||\n (Number.isSafeInteger(maxAttachmentBytes) && maxAttachmentBytes > 0);\n\n if (!isValidLimit) {\n throw buildOptionError({ message: 'maxAttachmentBytes must be a positive integer' });\n }\n\n if (attachmentRoot === undefined) {\n return;\n }\n\n if (typeof attachmentRoot !== 'string' || !isAbsolute(attachmentRoot)) {\n throw buildOptionError({ message: 'attachmentRoot must be an absolute path' });\n }\n\n let isDirectory: boolean;\n\n try {\n isDirectory = statSync(attachmentRoot).isDirectory();\n } catch (error) {\n throw buildOptionError({\n message: 'attachmentRoot must be an existing directory',\n cause: error,\n });\n }\n\n if (!isDirectory) {\n throw buildOptionError({ message: 'attachmentRoot must be an existing directory' });\n }\n }\n\n createAndBindInstances(): void {\n // Transport\n const transportGetter = this.application.get<TGetMailTransportFn>({\n key: MailKeys.MAIL_TRANSPORT_PROVIDER,\n });\n const mailOptions = this.application.get<TMailOptions>({ key: MailKeys.MAIL_OPTIONS });\n this.validateAttachmentOptions({ options: mailOptions });\n\n // Only the provider is logged: the options carry SMTP / API credentials, which must never reach a log sink.\n this.logger\n .for(this.createAndBindInstances.name)\n .info('Mail provider: %s', mailOptions.provider);\n\n const mailTransportInstance = transportGetter(mailOptions);\n this.application.bind({ key: MailKeys.MAIL_TRANSPORT_INSTANCE }).toValue(mailTransportInstance);\n\n // Queue\n const queueGetter = this.application.get<TGetMailQueueExecutorFn>({\n key: MailKeys.MAIL_QUEUE_EXECUTOR_PROVIDER,\n });\n\n // Queueing is opt-in: with no executor config bound, fall back to the direct (inline) executor instead of a \"binding is not bounded\" crash at boot.\n const queueConfig = this.application.get<IMailQueueExecutorConfig>({\n key: MailKeys.MAIL_QUEUE_EXECUTOR_CONFIG,\n isOptional: true,\n }) ?? { type: MailQueueExecutorTypes.DIRECT };\n\n // Same reason as above: a bullmq config carries the Redis password.\n this.logger\n .for(this.createAndBindInstances.name)\n .info('Mail queue executor type: %s', queueConfig.type);\n\n const queueExecutorInstance = queueGetter(queueConfig);\n this.application\n .bind({ key: MailKeys.MAIL_QUEUE_EXECUTOR_INSTANCE })\n .toValue(queueExecutorInstance);\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"bull-mq-execut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IAAI,CAAC;aACvC,IAAI,CACH,kEAAkE,EAClE,KAAK,EACL,KAAK,EACL,IAAI,CAAC,IAAI,CACV,CAAC;QAEJ,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,yBAAyB,EAAE,GAAG,EAAE;YAC/E,QAAQ,EAAE,OAAO,EAAE,QAAQ;YAC3B,KAAK,EAAE,OAAO,EAAE,KAAK;YACrB,QAAQ,EAAE,OAAO,EAAE,QAAQ,IAAI,CAAC;YAChC,OAAO,EAAE;gBACP,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,IAAI,gBAAgB,CAAC,WAAW;gBAC5D,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,IAAI,IAAI;aACvC;YACD,gBAAgB,EAAE,IAAI;YACtB,YAAY,EAAE,KAAK;SACpB,CAAC,CAAC;QAEH,OAAO;YACL,KAAK,EAAE,OAAO,CAAC,EAAE,IAAI,KAAK;YAC1B,MAAM,EAAE,IAAI;YACZ,OAAO,EAAE,0CAA0C;SACpD,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { BaseHelper, getError } from '@venizia/ignis-helpers/core';\nimport { RedisSingleHelper } from '@venizia/ignis-helpers';\nimport type { TConstValue } from '@/helpers';\nimport { BullMQHelper } from '@venizia/ignis-helpers/bullmq';\nimport type {\n IBullMQMailExecutorOpts,\n IMailProcessorResult,\n IMailQueueExecutor,\n IMailQueueOptions,\n IMailQueueResult,\n IQueueJobPayload,\n} from '../../common';\nimport {\n BullMQExecutorModes,\n MailBackoffTypes,\n MailErrorCodes,\n MailExecutorErrors,\n} from '../../common';\nimport type { Job } from 'bullmq';\n\nexport class BullMQMailExecutorHelper extends BaseHelper implements IMailQueueExecutor {\n private queueIdentifier: string;\n private queueName: string;\n private mode: TConstValue<typeof BullMQExecutorModes>;\n\n private queueHelper?: BullMQHelper<IQueueJobPayload, IMailQueueResult>;\n private workerHelpers: BullMQHelper<IQueueJobPayload, IMailProcessorResult>[] = [];\n private redisConnection: RedisSingleHelper;\n private readonly bullmqModule?: typeof import('bullmq');\n private jobIdCounter = 0;\n\n private processor?: (email: string) => Promise<IMailProcessorResult>;\n\n constructor(opts: IBullMQMailExecutorOpts) {\n super({ scope: BullMQMailExecutorHelper.name });\n\n this.mode = opts.mode;\n\n this.redisConnection = new RedisSingleHelper({\n ...opts.redis,\n maxRetry: undefined,\n });\n\n this.bullmqModule = opts.module;\n this.queueIdentifier = opts.queue.identifier;\n this.queueName = opts.queue.name;\n\n this.initQueue(opts.queue);\n }\n\n initQueue(queue: { identifier: string; name: string }) {\n switch (this.mode) {\n case BullMQExecutorModes.QUEUE_ONLY:\n case BullMQExecutorModes.BOTH: {\n this.queueHelper = new BullMQHelper<IQueueJobPayload, IMailQueueResult>({\n identifier: queue.identifier,\n queueName: queue.name,\n redisConnection: this.redisConnection,\n role: 'queue',\n module: this.bullmqModule,\n });\n\n this.logger\n .for(this.constructor.name)\n .info(\n 'BullMQ queue executor initialized (queue enabled) | Identifier: %s | Mode: %s',\n this.queueIdentifier,\n this.mode,\n );\n break;\n }\n default: {\n this.logger\n .for(this.constructor.name)\n .info(\n 'BullMQ queue executor initialized (worker-only mode) | Identifier: %s | Mode: %s',\n this.queueIdentifier,\n this.mode,\n );\n\n break;\n }\n }\n }\n\n async setProcessor(\n processor: (email: string) => Promise<IMailProcessorResult>,\n opts?: {\n numberOfWorkers?: number;\n concurrencyPerWorker?: number;\n lockDuration?: number;\n },\n ): Promise<void> {\n this.processor = processor;\n\n if (this.mode === BullMQExecutorModes.QUEUE_ONLY) {\n this.logger\n .for(this.setProcessor.name)\n .warn('Skipping worker creation in queue-only mode. Workers will not be started.');\n return;\n }\n\n const numberOfWorkers = opts?.numberOfWorkers ?? 1;\n const concurrencyPerWorker = opts?.concurrencyPerWorker ?? 5;\n const lockDuration = opts?.lockDuration ?? 30000;\n\n await this.clearWorkers();\n\n for (let i = 0; i < numberOfWorkers; i++) {\n this.addWorker({\n workerIdentifier: `${this.queueIdentifier}-worker-${i}`,\n concurrency: concurrencyPerWorker,\n lockDuration,\n });\n }\n\n this.logger\n .for(this.setProcessor.name)\n .info(\n 'Processor registered | Mode: %s | Workers: %d | Concurrency per worker: %d',\n this.mode,\n numberOfWorkers,\n concurrencyPerWorker,\n );\n }\n\n addWorker(opts: { workerIdentifier: string; concurrency?: number; lockDuration?: number }): void {\n if (!this.processor) {\n throw getError({ message: MailExecutorErrors.PROCESSOR_NOT_SET });\n }\n\n const workerIdentifier = opts.workerIdentifier;\n const concurrency = opts?.concurrency ?? 5;\n const lockDuration = opts?.lockDuration ?? 30000;\n\n const workerHelper = new BullMQHelper<IQueueJobPayload, IMailProcessorResult>({\n identifier: workerIdentifier,\n queueName: this.queueName,\n redisConnection: this.redisConnection,\n role: 'worker',\n module: this.bullmqModule,\n numberOfWorker: concurrency,\n lockDuration,\n onWorkerData: async (job: Job<IQueueJobPayload, IMailProcessorResult>) => {\n const maxAttempts = job.data.options?.attempts ?? 3;\n\n this.logger\n .for('onWorkerData')\n .info(\n 'Processing job | Worker: %s | jobId: %s | email: %s | attempt: %d/%d',\n workerIdentifier,\n job.data.id,\n job.data.email,\n job.attemptsMade + 1,\n maxAttempts,\n );\n\n if (!this.processor) {\n // Returning undefined would let BullMQ mark the job COMPLETED and (with removeOnComplete) delete it - mail silently dropped.\n throw getError({\n messageCode: MailErrorCodes.SEND_FAILED,\n message: `[onWorkerData] ${MailExecutorErrors.PROCESSOR_NOT_SET} | jobId: ${job.data.id}`,\n });\n }\n\n const result = await this.processor(job.data.email);\n\n // A processor reports SMTP rejection by RETURNING `{ success: false }`; BullMQ only treats a REJECTION as failure, so resolving completes the job - no retry, no DLQ.\n if (result?.success === false) {\n throw getError({\n messageCode: MailErrorCodes.SEND_FAILED,\n message: `[onWorkerData] Processor reported failure | jobId: ${job.data.id} | reason: ${result.message}`,\n });\n }\n\n return result;\n },\n onWorkerDataCompleted: async (job: Job<IQueueJobPayload, IMailProcessorResult>) => {\n this.logger\n .for('onWorkerDataCompleted')\n .info(\n 'Job completed | Worker: %s | jobId: %s | email: %s',\n workerIdentifier,\n job.data.id,\n job.data.email,\n );\n },\n onWorkerDataFail: async (\n job: Job<IQueueJobPayload, IMailProcessorResult> | undefined,\n error: Error,\n ) => {\n if (job) {\n const maxAttempts = job.data.options?.attempts ?? 3;\n this.logger\n .for('onWorkerDataFail')\n .error(\n 'Job failed | Worker: %s | jobId: %s | email: %s | attempt: %d/%d | error: %s',\n workerIdentifier,\n job.data.id,\n job.data.email,\n job.attemptsMade,\n maxAttempts,\n error.message,\n );\n } else {\n this.logger\n .for('onWorkerDataFail')\n .error(\n 'Worker error (no job) | Worker: %s | error: %s',\n workerIdentifier,\n error.message,\n );\n }\n },\n });\n\n this.workerHelpers.push(workerHelper);\n\n this.logger\n .for(this.addWorker.name)\n .info(\n 'Worker added | Identifier: %s | Concurrency: %d | Total workers: %d',\n workerIdentifier,\n concurrency,\n this.workerHelpers.length,\n );\n }\n\n async removeWorker(index: number): Promise<boolean> {\n if (index < 0 || index >= this.workerHelpers.length) {\n this.logger.for(this.removeWorker.name).warn('Invalid worker index: %d', index);\n return false;\n }\n\n // Dropped from the list BEFORE the close is awaited: a rejecting close must not leave a half-closed worker still counted and still handed jobs.\n const [workerHelper] = this.workerHelpers.splice(index, 1);\n await workerHelper.worker.close();\n\n this.logger\n .for(this.removeWorker.name)\n .info('Worker removed | Index: %d | Remaining workers: %d', index, this.workerHelpers.length);\n\n return true;\n }\n\n /** Closes every worker without stopping at the first failure, always empties the list, and returns failures instead of throwing so teardown can continue. */\n private async closeWorkers(): Promise<Error[]> {\n const workerHelpers = this.workerHelpers;\n this.workerHelpers = [];\n\n const results = await Promise.allSettled(\n workerHelpers.map((workerHelper) => workerHelper.worker.close()),\n );\n\n const failures: Error[] = [];\n\n for (const result of results) {\n if (result.status !== 'rejected') {\n continue;\n }\n\n const error =\n result.reason instanceof Error\n ? result.reason\n : getError({ message: `Worker close failed | reason: ${String(result.reason)}` });\n\n failures.push(error);\n this.logger.for('closeWorkers').error('Failed to close worker | error: %s', error.message);\n }\n\n return failures;\n }\n\n async clearWorkers(): Promise<void> {\n const count = this.workerHelpers.length;\n await this.closeWorkers();\n\n this.logger.for(this.clearWorkers.name).info('All workers cleared | Count: %d', count);\n }\n\n /** Full teardown: workers -> queue -> Redis. Every step runs even if an earlier one failed (skipping leaks a queue client + Redis socket); failures are reported once, at the end. */\n async close(): Promise<void> {\n const result = await this.closeWorkers();\n const failures: Error[] = [...result];\n\n if (this.queueHelper) {\n try {\n await this.queueHelper.queue.close();\n } catch (error) {\n const closeError = error instanceof Error ? error : getError({ message: String(error) });\n failures.push(closeError);\n this.logger.for(this.close.name).error('Failed to close queue | error: %s', closeError);\n }\n }\n\n try {\n await this.redisConnection.disconnect();\n } catch (error) {\n const disconnectError = error instanceof Error ? error : getError({ message: String(error) });\n failures.push(disconnectError);\n this.logger\n .for(this.close.name)\n .error('Failed to disconnect redis | error: %s', disconnectError);\n }\n\n if (failures.length > 0) {\n throw getError({\n message: `[close] Incomplete BullMQ mail executor teardown | failures: ${failures\n .map((failure) => failure.message)\n .join(' | ')}`,\n });\n }\n\n this.logger.for(this.close.name).info('BullMQ mail executor closed | Mode: %s', this.mode);\n }\n\n getWorkerCount(): number {\n return this.workerHelpers.length;\n }\n\n getMode(): TConstValue<typeof BullMQExecutorModes> {\n return this.mode;\n }\n\n async enqueueVerificationEmail(\n email: string,\n options?: IMailQueueOptions,\n ): Promise<IMailQueueResult> {\n if (this.mode === BullMQExecutorModes.WORKER_ONLY) {\n throw getError({\n message: 'Cannot enqueue jobs in worker-only mode. Set mode to \"queue-only\" or \"both\".',\n });\n }\n\n if (!this.queueHelper) {\n throw getError({\n message: 'Queue helper not initialized. This should not happen in queue-enabled mode.',\n });\n }\n\n if (!this.processor && this.mode !== BullMQExecutorModes.QUEUE_ONLY) {\n throw getError({ message: MailExecutorErrors.PROCESSOR_NOT_SET });\n }\n\n const jobId = `job_${++this.jobIdCounter}_${Date.now()}`;\n const job: IQueueJobPayload = {\n id: jobId,\n email,\n options,\n attempts: 0,\n scheduledAt: Date.now() + (options?.delay ?? 0),\n };\n\n this.logger\n .for(this.enqueueVerificationEmail.name)\n .info(\n 'Queuing email to BullMQ/Redis | jobId: %s | email: %s | mode: %s',\n jobId,\n email,\n this.mode,\n );\n\n const bullJob = await this.queueHelper.queue.add('send-verification-email', job, {\n priority: options?.priority,\n delay: options?.delay,\n attempts: options?.attempts ?? 3,\n backoff: {\n type: options?.backoff?.type ?? MailBackoffTypes.EXPONENTIAL,\n delay: options?.backoff?.delay ?? 1000,\n },\n removeOnComplete: true,\n removeOnFail: false,\n });\n\n return {\n jobId: bullJob.id ?? jobId,\n queued: true,\n message: 'Email queued successfully (BullMQ/Redis)',\n };\n }\n}\n"]}
1
+ {"version":3,"file":"bull-mq-executor.helper.js","sourceRoot":"","sources":["../../../../../../src/components/mail/helpers/executors/bull-mq-executor.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAS7D,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,kBAAkB,GACnB,MAAM,cAAc,CAAC;AAGtB,MAAM,OAAO,wBAAyB,SAAQ,UAAU;IAatD,YAAY,IAA6B;QACvC,KAAK,CAAC,EAAE,KAAK,EAAE,wBAAwB,CAAC,IAAI,EAAE,CAAC,CAAC;QAR1C,kBAAa,GAA2D,EAAE,CAAC;QAG3E,iBAAY,GAAG,CAAC,CAAC;QAOvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QAEtB,IAAI,CAAC,eAAe,GAAG,IAAI,iBAAiB,CAAC;YAC3C,GAAG,IAAI,CAAC,KAAK;YACb,QAAQ,EAAE,SAAS;SACp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import { BaseHelper, getError } from '@venizia/ignis-helpers/core';\nimport { RedisSingleHelper } from '@venizia/ignis-helpers';\nimport type { TConstValue } from '@/helpers';\nimport { BullMQHelper } from '@venizia/ignis-helpers/bullmq';\nimport type {\n IBullMQMailExecutorOpts,\n IMailProcessorResult,\n IMailQueueExecutor,\n IMailQueueOptions,\n IMailQueueResult,\n IQueueJobPayload,\n} from '../../common';\nimport {\n BullMQExecutorModes,\n MailBackoffTypes,\n MailErrorCodes,\n MailExecutorErrors,\n} from '../../common';\nimport type { Job } from 'bullmq';\n\nexport class BullMQMailExecutorHelper extends BaseHelper implements IMailQueueExecutor {\n private queueIdentifier: string;\n private queueName: string;\n private mode: TConstValue<typeof BullMQExecutorModes>;\n\n private queueHelper?: BullMQHelper<IQueueJobPayload, IMailQueueResult>;\n private workerHelpers: BullMQHelper<IQueueJobPayload, IMailProcessorResult>[] = [];\n private redisConnection: RedisSingleHelper;\n private readonly bullmqModule?: typeof import('bullmq');\n private jobIdCounter = 0;\n\n private processor?: (email: string) => Promise<IMailProcessorResult>;\n\n constructor(opts: IBullMQMailExecutorOpts) {\n super({ scope: BullMQMailExecutorHelper.name });\n\n this.mode = opts.mode;\n\n this.redisConnection = new RedisSingleHelper({\n ...opts.redis,\n maxRetry: undefined,\n });\n\n this.bullmqModule = opts.module;\n this.queueIdentifier = opts.queue.identifier;\n this.queueName = opts.queue.name;\n\n this.initQueue(opts.queue);\n }\n\n initQueue(queue: { identifier: string; name: string }) {\n switch (this.mode) {\n case BullMQExecutorModes.QUEUE_ONLY:\n case BullMQExecutorModes.BOTH: {\n this.queueHelper = new BullMQHelper<IQueueJobPayload, IMailQueueResult>({\n identifier: queue.identifier,\n queueName: queue.name,\n redisConnection: this.redisConnection,\n role: 'queue',\n module: this.bullmqModule,\n });\n\n this.logger\n .for(this.constructor.name)\n .info(\n 'BullMQ queue executor initialized (queue enabled) | Identifier: %s | Mode: %s',\n this.queueIdentifier,\n this.mode,\n );\n break;\n }\n default: {\n this.logger\n .for(this.constructor.name)\n .info(\n 'BullMQ queue executor initialized (worker-only mode) | Identifier: %s | Mode: %s',\n this.queueIdentifier,\n this.mode,\n );\n\n break;\n }\n }\n }\n\n async setProcessor(\n processor: (email: string) => Promise<IMailProcessorResult>,\n opts?: {\n numberOfWorkers?: number;\n concurrencyPerWorker?: number;\n lockDuration?: number;\n },\n ): Promise<void> {\n this.processor = processor;\n\n if (this.mode === BullMQExecutorModes.QUEUE_ONLY) {\n this.logger\n .for(this.setProcessor.name)\n .warn('Skipping worker creation in queue-only mode. Workers will not be started.');\n\n return;\n }\n\n const numberOfWorkers = opts?.numberOfWorkers ?? 1;\n const concurrencyPerWorker = opts?.concurrencyPerWorker ?? 5;\n const lockDuration = opts?.lockDuration ?? 30000;\n\n await this.clearWorkers();\n\n for (let i = 0; i < numberOfWorkers; i++) {\n this.addWorker({\n workerIdentifier: `${this.queueIdentifier}-worker-${i}`,\n concurrency: concurrencyPerWorker,\n lockDuration,\n });\n }\n\n this.logger\n .for(this.setProcessor.name)\n .info(\n 'Processor registered | Mode: %s | Workers: %d | Concurrency per worker: %d',\n this.mode,\n numberOfWorkers,\n concurrencyPerWorker,\n );\n }\n\n addWorker(opts: { workerIdentifier: string; concurrency?: number; lockDuration?: number }): void {\n if (!this.processor) {\n throw getError({ message: MailExecutorErrors.PROCESSOR_NOT_SET });\n }\n\n const workerIdentifier = opts.workerIdentifier;\n const concurrency = opts?.concurrency ?? 5;\n const lockDuration = opts?.lockDuration ?? 30000;\n\n const workerHelper = new BullMQHelper<IQueueJobPayload, IMailProcessorResult>({\n identifier: workerIdentifier,\n queueName: this.queueName,\n redisConnection: this.redisConnection,\n role: 'worker',\n module: this.bullmqModule,\n numberOfWorker: concurrency,\n lockDuration,\n onWorkerData: async (job: Job<IQueueJobPayload, IMailProcessorResult>) => {\n const maxAttempts = job.data.options?.attempts ?? 3;\n\n this.logger\n .for('onWorkerData')\n .info(\n 'Processing job | Worker: %s | jobId: %s | email: %s | attempt: %d/%d',\n workerIdentifier,\n job.data.id,\n job.data.email,\n job.attemptsMade + 1,\n maxAttempts,\n );\n\n if (!this.processor) {\n // Returning undefined would let BullMQ mark the job COMPLETED and (with removeOnComplete) delete it - mail silently dropped.\n throw getError({\n messageCode: MailErrorCodes.SEND_FAILED,\n message: `[onWorkerData] ${MailExecutorErrors.PROCESSOR_NOT_SET} | jobId: ${job.data.id}`,\n });\n }\n\n const result = await this.processor(job.data.email);\n\n // A processor reports SMTP rejection by RETURNING `{ success: false }`; BullMQ only treats a REJECTION as failure, so resolving completes the job - no retry, no DLQ.\n if (result?.success === false) {\n throw getError({\n messageCode: MailErrorCodes.SEND_FAILED,\n message: `[onWorkerData] Processor reported failure | jobId: ${job.data.id} | reason: ${result.message}`,\n });\n }\n\n return result;\n },\n onWorkerDataCompleted: async (job: Job<IQueueJobPayload, IMailProcessorResult>) => {\n this.logger\n .for('onWorkerDataCompleted')\n .info(\n 'Job completed | Worker: %s | jobId: %s | email: %s',\n workerIdentifier,\n job.data.id,\n job.data.email,\n );\n },\n onWorkerDataFail: async (\n job: Job<IQueueJobPayload, IMailProcessorResult> | undefined,\n error: Error,\n ) => {\n if (job) {\n const maxAttempts = job.data.options?.attempts ?? 3;\n this.logger\n .for('onWorkerDataFail')\n .error(\n 'Job failed | Worker: %s | jobId: %s | email: %s | attempt: %d/%d | error: %s',\n workerIdentifier,\n job.data.id,\n job.data.email,\n job.attemptsMade,\n maxAttempts,\n error.message,\n );\n } else {\n this.logger\n .for('onWorkerDataFail')\n .error(\n 'Worker error (no job) | Worker: %s | error: %s',\n workerIdentifier,\n error.message,\n );\n }\n },\n });\n\n this.workerHelpers.push(workerHelper);\n\n this.logger\n .for(this.addWorker.name)\n .info(\n 'Worker added | Identifier: %s | Concurrency: %d | Total workers: %d',\n workerIdentifier,\n concurrency,\n this.workerHelpers.length,\n );\n }\n\n async removeWorker(index: number): Promise<boolean> {\n if (index < 0 || index >= this.workerHelpers.length) {\n this.logger.for(this.removeWorker.name).warn('Invalid worker index: %d', index);\n\n return false;\n }\n\n // Dropped from the list BEFORE the close is awaited: a rejecting close must not leave a half-closed worker still counted and still handed jobs.\n const [workerHelper] = this.workerHelpers.splice(index, 1);\n await workerHelper.worker.close();\n\n this.logger\n .for(this.removeWorker.name)\n .info('Worker removed | Index: %d | Remaining workers: %d', index, this.workerHelpers.length);\n\n return true;\n }\n\n /** Closes every worker without stopping at the first failure, always empties the list, and returns failures instead of throwing so teardown can continue. */\n private async closeWorkers(): Promise<Error[]> {\n const workerHelpers = this.workerHelpers;\n this.workerHelpers = [];\n\n const results = await Promise.allSettled(\n workerHelpers.map((workerHelper) => workerHelper.worker.close()),\n );\n\n const failures: Error[] = [];\n\n for (const result of results) {\n if (result.status !== 'rejected') {\n continue;\n }\n\n const error =\n result.reason instanceof Error\n ? result.reason\n : getError({ message: `Worker close failed | reason: ${String(result.reason)}` });\n\n failures.push(error);\n this.logger.for('closeWorkers').error('Failed to close worker | error: %s', error.message);\n }\n\n return failures;\n }\n\n async clearWorkers(): Promise<void> {\n const count = this.workerHelpers.length;\n await this.closeWorkers();\n\n this.logger.for(this.clearWorkers.name).info('All workers cleared | Count: %d', count);\n }\n\n /** Full teardown: workers -> queue -> Redis. Every step runs even if an earlier one failed (skipping leaks a queue client + Redis socket); failures are reported once, at the end. */\n async close(): Promise<void> {\n const result = await this.closeWorkers();\n const failures: Error[] = [...result];\n\n if (this.queueHelper) {\n try {\n await this.queueHelper.queue.close();\n } catch (error) {\n const closeError = error instanceof Error ? error : getError({ message: String(error) });\n failures.push(closeError);\n this.logger.for(this.close.name).error('Failed to close queue | error: %s', closeError);\n }\n }\n\n try {\n await this.redisConnection.disconnect();\n } catch (error) {\n const disconnectError = error instanceof Error ? error : getError({ message: String(error) });\n failures.push(disconnectError);\n this.logger\n .for(this.close.name)\n .error('Failed to disconnect redis | error: %s', disconnectError);\n }\n\n if (failures.length > 0) {\n throw getError({\n message: `[close] Incomplete BullMQ mail executor teardown | failures: ${failures\n .map((failure) => failure.message)\n .join(' | ')}`,\n });\n }\n\n this.logger.for(this.close.name).info('BullMQ mail executor closed | Mode: %s', this.mode);\n }\n\n getWorkerCount(): number {\n return this.workerHelpers.length;\n }\n\n getMode(): TConstValue<typeof BullMQExecutorModes> {\n return this.mode;\n }\n\n async enqueueVerificationEmail(\n email: string,\n options?: IMailQueueOptions,\n ): Promise<IMailQueueResult> {\n if (this.mode === BullMQExecutorModes.WORKER_ONLY) {\n throw getError({\n message: 'Cannot enqueue jobs in worker-only mode. Set mode to \"queue-only\" or \"both\".',\n });\n }\n\n if (!this.queueHelper) {\n throw getError({\n message: 'Queue helper not initialized. This should not happen in queue-enabled mode.',\n });\n }\n\n if (!this.processor && this.mode !== BullMQExecutorModes.QUEUE_ONLY) {\n throw getError({ message: MailExecutorErrors.PROCESSOR_NOT_SET });\n }\n\n const jobId = `job_${++this.jobIdCounter}_${Date.now()}`;\n const job: IQueueJobPayload = {\n id: jobId,\n email,\n options,\n attempts: 0,\n scheduledAt: Date.now() + (options?.delay ?? 0),\n };\n\n this.logger\n .for(this.enqueueVerificationEmail.name)\n .info(\n 'Queuing email to BullMQ/Redis | jobId: %s | email: %s | mode: %s',\n jobId,\n email,\n this.mode,\n );\n\n const bullJob = await this.queueHelper.queue.add('send-verification-email', job, {\n priority: options?.priority,\n delay: options?.delay,\n attempts: options?.attempts ?? 3,\n backoff: {\n type: options?.backoff?.type ?? MailBackoffTypes.EXPONENTIAL,\n delay: options?.backoff?.delay ?? 1000,\n },\n removeOnComplete: true,\n removeOnFail: false,\n });\n\n return {\n jobId: bullJob.id ?? jobId,\n queued: true,\n message: 'Email queued successfully (BullMQ/Redis)',\n };\n }\n}\n"]}