@venizia/ignis-helpers 0.4.1 → 0.4.3

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 (213) hide show
  1. package/dist/cjs/common/constants/duration.d.ts +4 -1
  2. package/dist/cjs/common/constants/duration.d.ts.map +1 -1
  3. package/dist/cjs/common/constants/duration.js +13 -8
  4. package/dist/cjs/common/constants/duration.js.map +1 -1
  5. package/dist/cjs/common/types/field-mapping.d.ts +13 -1
  6. package/dist/cjs/common/types/field-mapping.d.ts.map +1 -1
  7. package/dist/cjs/common/types/field-mapping.js +20 -0
  8. package/dist/cjs/common/types/field-mapping.js.map +1 -1
  9. package/dist/cjs/core.d.ts +2 -1
  10. package/dist/cjs/core.d.ts.map +1 -1
  11. package/dist/cjs/core.js +6 -1
  12. package/dist/cjs/core.js.map +1 -1
  13. package/dist/cjs/modules/crypto/algorithms/aes.algorithm.d.ts +2 -2
  14. package/dist/cjs/modules/crypto/algorithms/aes.algorithm.d.ts.map +1 -1
  15. package/dist/cjs/modules/crypto/algorithms/aes.algorithm.js +3 -1
  16. package/dist/cjs/modules/crypto/algorithms/aes.algorithm.js.map +1 -1
  17. package/dist/cjs/modules/crypto/algorithms/aes.constants.d.ts +11 -0
  18. package/dist/cjs/modules/crypto/algorithms/aes.constants.d.ts.map +1 -0
  19. package/dist/cjs/modules/crypto/algorithms/aes.constants.js +14 -0
  20. package/dist/cjs/modules/crypto/algorithms/aes.constants.js.map +1 -0
  21. package/dist/cjs/modules/env/app-env.d.ts.map +1 -1
  22. package/dist/cjs/modules/env/app-env.js +1 -1
  23. package/dist/cjs/modules/env/app-env.js.map +1 -1
  24. package/dist/cjs/modules/error/index.d.ts +1 -1
  25. package/dist/cjs/modules/error/index.d.ts.map +1 -1
  26. package/dist/cjs/modules/error/index.js +2 -1
  27. package/dist/cjs/modules/error/index.js.map +1 -1
  28. package/dist/cjs/modules/logger/hf/common/types.d.ts +3 -1
  29. package/dist/cjs/modules/logger/hf/common/types.d.ts.map +1 -1
  30. package/dist/cjs/modules/logger/hf/common/types.js.map +1 -1
  31. package/dist/cjs/modules/logger/hf/logger.d.ts.map +1 -1
  32. package/dist/cjs/modules/logger/hf/logger.js +3 -1
  33. package/dist/cjs/modules/logger/hf/logger.js.map +1 -1
  34. package/dist/cjs/modules/logger/pino/common/constants.d.ts +10 -1
  35. package/dist/cjs/modules/logger/pino/common/constants.d.ts.map +1 -1
  36. package/dist/cjs/modules/logger/pino/common/constants.js +11 -1
  37. package/dist/cjs/modules/logger/pino/common/constants.js.map +1 -1
  38. package/dist/cjs/modules/logger/pino/destination.d.ts.map +1 -1
  39. package/dist/cjs/modules/logger/pino/destination.js +4 -3
  40. package/dist/cjs/modules/logger/pino/destination.js.map +1 -1
  41. package/dist/cjs/modules/network/http-request/common/constants.d.ts +11 -0
  42. package/dist/cjs/modules/network/http-request/common/constants.d.ts.map +1 -0
  43. package/dist/cjs/modules/network/http-request/common/constants.js +14 -0
  44. package/dist/cjs/modules/network/http-request/common/constants.js.map +1 -0
  45. package/dist/cjs/modules/network/http-request/common/index.d.ts +1 -0
  46. package/dist/cjs/modules/network/http-request/common/index.d.ts.map +1 -1
  47. package/dist/cjs/modules/network/http-request/common/index.js +1 -0
  48. package/dist/cjs/modules/network/http-request/common/index.js.map +1 -1
  49. package/dist/cjs/modules/network/http-request/common/types.d.ts +1 -1
  50. package/dist/cjs/modules/network/http-request/common/types.d.ts.map +1 -1
  51. package/dist/cjs/modules/network/http-request/common/types.js.map +1 -1
  52. package/dist/cjs/modules/network/tcp-socket/base-tcp-server.helper.d.ts +13 -2
  53. package/dist/cjs/modules/network/tcp-socket/base-tcp-server.helper.d.ts.map +1 -1
  54. package/dist/cjs/modules/network/tcp-socket/base-tcp-server.helper.js +26 -8
  55. package/dist/cjs/modules/network/tcp-socket/base-tcp-server.helper.js.map +1 -1
  56. package/dist/cjs/modules/queue/common/constants.d.ts +11 -0
  57. package/dist/cjs/modules/queue/common/constants.d.ts.map +1 -0
  58. package/dist/cjs/modules/queue/common/constants.js +14 -0
  59. package/dist/cjs/modules/queue/common/constants.js.map +1 -0
  60. package/dist/cjs/modules/queue/common/index.d.ts +1 -0
  61. package/dist/cjs/modules/queue/common/index.d.ts.map +1 -1
  62. package/dist/cjs/modules/queue/common/index.js +1 -0
  63. package/dist/cjs/modules/queue/common/index.js.map +1 -1
  64. package/dist/cjs/modules/queue/common/types.d.ts +1 -1
  65. package/dist/cjs/modules/queue/common/types.d.ts.map +1 -1
  66. package/dist/cjs/modules/queue/common/types.js.map +1 -1
  67. package/dist/cjs/modules/queue/kafka/common/constants.d.ts +9 -0
  68. package/dist/cjs/modules/queue/kafka/common/constants.d.ts.map +1 -1
  69. package/dist/cjs/modules/queue/kafka/common/constants.js +11 -1
  70. package/dist/cjs/modules/queue/kafka/common/constants.js.map +1 -1
  71. package/dist/cjs/modules/queue/kafka/consumer.d.ts +2 -1
  72. package/dist/cjs/modules/queue/kafka/consumer.d.ts.map +1 -1
  73. package/dist/cjs/modules/queue/kafka/consumer.js +2 -2
  74. package/dist/cjs/modules/queue/kafka/consumer.js.map +1 -1
  75. package/dist/cjs/modules/secrets/base/abstract.helper.d.ts.map +1 -1
  76. package/dist/cjs/modules/secrets/base/abstract.helper.js +5 -1
  77. package/dist/cjs/modules/secrets/base/abstract.helper.js.map +1 -1
  78. package/dist/cjs/modules/temporal/common/constants.d.ts +21 -0
  79. package/dist/cjs/modules/temporal/common/constants.d.ts.map +1 -1
  80. package/dist/cjs/modules/temporal/common/constants.js +22 -1
  81. package/dist/cjs/modules/temporal/common/constants.js.map +1 -1
  82. package/dist/cjs/modules/temporal/locale/locale.d.ts +4 -3
  83. package/dist/cjs/modules/temporal/locale/locale.d.ts.map +1 -1
  84. package/dist/cjs/modules/temporal/locale/locale.js +2 -1
  85. package/dist/cjs/modules/temporal/locale/locale.js.map +1 -1
  86. package/dist/cjs/modules/temporal/pattern/common/constants.d.ts +43 -0
  87. package/dist/cjs/modules/temporal/pattern/common/constants.d.ts.map +1 -0
  88. package/dist/cjs/modules/temporal/pattern/common/constants.js +74 -0
  89. package/dist/cjs/modules/temporal/pattern/common/constants.js.map +1 -0
  90. package/dist/cjs/modules/temporal/pattern/common/index.d.ts +1 -0
  91. package/dist/cjs/modules/temporal/pattern/common/index.d.ts.map +1 -1
  92. package/dist/cjs/modules/temporal/pattern/common/index.js +1 -0
  93. package/dist/cjs/modules/temporal/pattern/common/index.js.map +1 -1
  94. package/dist/cjs/modules/temporal/pattern/common/types.d.ts +2 -11
  95. package/dist/cjs/modules/temporal/pattern/common/types.d.ts.map +1 -1
  96. package/dist/cjs/modules/temporal/pattern/common/types.js.map +1 -1
  97. package/dist/cjs/modules/temporal/pattern/tokens.d.ts +2 -1
  98. package/dist/cjs/modules/temporal/pattern/tokens.d.ts.map +1 -1
  99. package/dist/cjs/modules/temporal/pattern/tokens.js +2 -14
  100. package/dist/cjs/modules/temporal/pattern/tokens.js.map +1 -1
  101. package/dist/cjs/modules/worker-thread/thread/base.js +2 -2
  102. package/dist/cjs/modules/worker-thread/thread/base.js.map +1 -1
  103. package/dist/cjs/utilities/request.utility.d.ts +21 -2
  104. package/dist/cjs/utilities/request.utility.d.ts.map +1 -1
  105. package/dist/cjs/utilities/request.utility.js +25 -5
  106. package/dist/cjs/utilities/request.utility.js.map +1 -1
  107. package/dist/esm/common/constants/duration.d.ts +4 -1
  108. package/dist/esm/common/constants/duration.d.ts.map +1 -1
  109. package/dist/esm/common/constants/duration.js +13 -8
  110. package/dist/esm/common/constants/duration.js.map +1 -1
  111. package/dist/esm/common/types/field-mapping.d.ts +13 -1
  112. package/dist/esm/common/types/field-mapping.d.ts.map +1 -1
  113. package/dist/esm/common/types/field-mapping.js +18 -1
  114. package/dist/esm/common/types/field-mapping.js.map +1 -1
  115. package/dist/esm/core.d.ts +2 -1
  116. package/dist/esm/core.d.ts.map +1 -1
  117. package/dist/esm/core.js +4 -0
  118. package/dist/esm/core.js.map +1 -1
  119. package/dist/esm/modules/crypto/algorithms/aes.algorithm.d.ts +2 -2
  120. package/dist/esm/modules/crypto/algorithms/aes.algorithm.d.ts.map +1 -1
  121. package/dist/esm/modules/crypto/algorithms/aes.algorithm.js +2 -0
  122. package/dist/esm/modules/crypto/algorithms/aes.algorithm.js.map +1 -1
  123. package/dist/esm/modules/crypto/algorithms/aes.constants.d.ts +11 -0
  124. package/dist/esm/modules/crypto/algorithms/aes.constants.d.ts.map +1 -0
  125. package/dist/esm/modules/crypto/algorithms/aes.constants.js +10 -0
  126. package/dist/esm/modules/crypto/algorithms/aes.constants.js.map +1 -0
  127. package/dist/esm/modules/env/app-env.d.ts.map +1 -1
  128. package/dist/esm/modules/env/app-env.js +1 -1
  129. package/dist/esm/modules/env/app-env.js.map +1 -1
  130. package/dist/esm/modules/error/index.d.ts +1 -1
  131. package/dist/esm/modules/error/index.d.ts.map +1 -1
  132. package/dist/esm/modules/error/index.js +1 -1
  133. package/dist/esm/modules/error/index.js.map +1 -1
  134. package/dist/esm/modules/logger/hf/common/types.d.ts +3 -1
  135. package/dist/esm/modules/logger/hf/common/types.d.ts.map +1 -1
  136. package/dist/esm/modules/logger/hf/common/types.js.map +1 -1
  137. package/dist/esm/modules/logger/hf/logger.d.ts.map +1 -1
  138. package/dist/esm/modules/logger/hf/logger.js +3 -1
  139. package/dist/esm/modules/logger/hf/logger.js.map +1 -1
  140. package/dist/esm/modules/logger/pino/common/constants.d.ts +10 -1
  141. package/dist/esm/modules/logger/pino/common/constants.d.ts.map +1 -1
  142. package/dist/esm/modules/logger/pino/common/constants.js +9 -0
  143. package/dist/esm/modules/logger/pino/common/constants.js.map +1 -1
  144. package/dist/esm/modules/logger/pino/destination.d.ts.map +1 -1
  145. package/dist/esm/modules/logger/pino/destination.js +4 -3
  146. package/dist/esm/modules/logger/pino/destination.js.map +1 -1
  147. package/dist/esm/modules/network/http-request/common/constants.d.ts +11 -0
  148. package/dist/esm/modules/network/http-request/common/constants.d.ts.map +1 -0
  149. package/dist/esm/modules/network/http-request/common/constants.js +10 -0
  150. package/dist/esm/modules/network/http-request/common/constants.js.map +1 -0
  151. package/dist/esm/modules/network/http-request/common/index.d.ts +1 -0
  152. package/dist/esm/modules/network/http-request/common/index.d.ts.map +1 -1
  153. package/dist/esm/modules/network/http-request/common/index.js +1 -0
  154. package/dist/esm/modules/network/http-request/common/index.js.map +1 -1
  155. package/dist/esm/modules/network/http-request/common/types.d.ts +1 -1
  156. package/dist/esm/modules/network/http-request/common/types.d.ts.map +1 -1
  157. package/dist/esm/modules/network/http-request/common/types.js.map +1 -1
  158. package/dist/esm/modules/network/tcp-socket/base-tcp-server.helper.d.ts +13 -2
  159. package/dist/esm/modules/network/tcp-socket/base-tcp-server.helper.d.ts.map +1 -1
  160. package/dist/esm/modules/network/tcp-socket/base-tcp-server.helper.js +24 -7
  161. package/dist/esm/modules/network/tcp-socket/base-tcp-server.helper.js.map +1 -1
  162. package/dist/esm/modules/queue/common/constants.d.ts +11 -0
  163. package/dist/esm/modules/queue/common/constants.d.ts.map +1 -0
  164. package/dist/esm/modules/queue/common/constants.js +10 -0
  165. package/dist/esm/modules/queue/common/constants.js.map +1 -0
  166. package/dist/esm/modules/queue/common/index.d.ts +1 -0
  167. package/dist/esm/modules/queue/common/index.d.ts.map +1 -1
  168. package/dist/esm/modules/queue/common/index.js +1 -0
  169. package/dist/esm/modules/queue/common/index.js.map +1 -1
  170. package/dist/esm/modules/queue/common/types.d.ts +1 -1
  171. package/dist/esm/modules/queue/common/types.d.ts.map +1 -1
  172. package/dist/esm/modules/queue/common/types.js.map +1 -1
  173. package/dist/esm/modules/queue/kafka/common/constants.d.ts +9 -0
  174. package/dist/esm/modules/queue/kafka/common/constants.d.ts.map +1 -1
  175. package/dist/esm/modules/queue/kafka/common/constants.js +9 -0
  176. package/dist/esm/modules/queue/kafka/common/constants.js.map +1 -1
  177. package/dist/esm/modules/queue/kafka/consumer.d.ts +2 -1
  178. package/dist/esm/modules/queue/kafka/consumer.d.ts.map +1 -1
  179. package/dist/esm/modules/queue/kafka/consumer.js +3 -3
  180. package/dist/esm/modules/queue/kafka/consumer.js.map +1 -1
  181. package/dist/esm/modules/secrets/base/abstract.helper.d.ts.map +1 -1
  182. package/dist/esm/modules/secrets/base/abstract.helper.js +5 -1
  183. package/dist/esm/modules/secrets/base/abstract.helper.js.map +1 -1
  184. package/dist/esm/modules/temporal/common/constants.d.ts +21 -0
  185. package/dist/esm/modules/temporal/common/constants.d.ts.map +1 -1
  186. package/dist/esm/modules/temporal/common/constants.js +19 -0
  187. package/dist/esm/modules/temporal/common/constants.js.map +1 -1
  188. package/dist/esm/modules/temporal/locale/locale.d.ts +4 -3
  189. package/dist/esm/modules/temporal/locale/locale.d.ts.map +1 -1
  190. package/dist/esm/modules/temporal/locale/locale.js +2 -1
  191. package/dist/esm/modules/temporal/locale/locale.js.map +1 -1
  192. package/dist/esm/modules/temporal/pattern/common/constants.d.ts +43 -0
  193. package/dist/esm/modules/temporal/pattern/common/constants.d.ts.map +1 -0
  194. package/dist/esm/modules/temporal/pattern/common/constants.js +70 -0
  195. package/dist/esm/modules/temporal/pattern/common/constants.js.map +1 -0
  196. package/dist/esm/modules/temporal/pattern/common/index.d.ts +1 -0
  197. package/dist/esm/modules/temporal/pattern/common/index.d.ts.map +1 -1
  198. package/dist/esm/modules/temporal/pattern/common/index.js +1 -0
  199. package/dist/esm/modules/temporal/pattern/common/index.js.map +1 -1
  200. package/dist/esm/modules/temporal/pattern/common/types.d.ts +2 -11
  201. package/dist/esm/modules/temporal/pattern/common/types.d.ts.map +1 -1
  202. package/dist/esm/modules/temporal/pattern/common/types.js.map +1 -1
  203. package/dist/esm/modules/temporal/pattern/tokens.d.ts +2 -1
  204. package/dist/esm/modules/temporal/pattern/tokens.d.ts.map +1 -1
  205. package/dist/esm/modules/temporal/pattern/tokens.js +2 -14
  206. package/dist/esm/modules/temporal/pattern/tokens.js.map +1 -1
  207. package/dist/esm/modules/worker-thread/thread/base.js +2 -2
  208. package/dist/esm/modules/worker-thread/thread/base.js.map +1 -1
  209. package/dist/esm/utilities/request.utility.d.ts +21 -2
  210. package/dist/esm/utilities/request.utility.d.ts.map +1 -1
  211. package/dist/esm/utilities/request.utility.js +22 -4
  212. package/dist/esm/utilities/request.utility.js.map +1 -1
  213. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/modules/queue/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC","sourcesContent":["export * from './hook';\nexport * from './types';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/modules/queue/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC","sourcesContent":["export * from './constants';\nexport * from './hook';\nexport * from './types';\n"]}
@@ -1,2 +1,2 @@
1
- export type TBullQueueRole = 'queue' | 'worker';
1
+ export {};
2
2
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/modules/queue/common/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,QAAQ,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/modules/queue/common/types.ts"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/modules/queue/common/types.ts"],"names":[],"mappings":"","sourcesContent":["export type TBullQueueRole = 'queue' | 'worker';\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/modules/queue/common/types.ts"],"names":[],"mappings":"","sourcesContent":[""]}
@@ -56,4 +56,13 @@ export declare class KafkaDefaults {
56
56
  static readonly SHUTDOWN_TIMEOUT = 30000;
57
57
  static readonly LAG_MONITOR_INTERVAL = 30000;
58
58
  }
59
+ /** Why every broker of a consumer is gone: DISCONNECTED (the connections closed) or FAILED (they errored). */
60
+ export declare class KafkaBrokersDownReasons {
61
+ static readonly DISCONNECTED = "disconnected";
62
+ static readonly FAILED = "failed";
63
+ static readonly SCHEME_SET: Set<string>;
64
+ static isValid(value: string): boolean;
65
+ }
66
+ /** Valid Kafka brokers-down reason values. */
67
+ export type TKafkaBrokersDownReason = TConstValue<typeof KafkaBrokersDownReasons>;
59
68
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../../src/modules/queue/kafka/common/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,qBAAa,kBAAkB;IAC7B,MAAM,CAAC,QAAQ,CAAC,OAAO,aAAa;IACpC,MAAM,CAAC,QAAQ,CAAC,QAAQ,cAAc;IAEtC,MAAM,CAAC,QAAQ,CAAC,UAAU,cAA0C;IAEpE,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;CAGtC;AAED,MAAM,MAAM,mBAAmB,GAAG,WAAW,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAEzE,qBAAa,SAAS;IACpB,MAAM,CAAC,QAAQ,CAAC,IAAI,KAAK;IACzB,MAAM,CAAC,QAAQ,CAAC,MAAM,KAAK;IAC3B,MAAM,CAAC,QAAQ,CAAC,GAAG,MAAM;IAEzB,MAAM,CAAC,QAAQ,CAAC,UAAU,cAA+C;IAEzE,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;CAGrC;AAED,MAAM,MAAM,UAAU,GAAG,WAAW,CAAC,OAAO,SAAS,CAAC,CAAC;AAEvD,qBAAa,mBAAmB;IAC9B,MAAM,CAAC,QAAQ,CAAC,SAAS,eAAe;IACxC,MAAM,CAAC,QAAQ,CAAC,YAAY,kBAAkB;IAC9C,MAAM,CAAC,QAAQ,CAAC,OAAO,aAAa;IAEpC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AC9B,MAAM,CAAC,QAAQ,CAAC,SAAS,SAAkB;IAC3C,MAAM,CAAC,QAAQ,CAAC,aAAa,QAAS;IACtC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,UAAW;IAC3C,MAAM,CAAC,QAAQ,CAAC,cAAc,aAA8B;IAE5D,MAAM,CAAC,QAAQ,CAAC,YAAY,eAAe;IAC3C,MAAM,CAAC,QAAQ,CAAC,qBAAqB,YAAY;IAEjD,MAAM,CAAC,QAAQ,CAAC,eAAe,QAAS;IACxC,MAAM,CAAC,QAAQ,CAAC,sBAAsB,KAAK;IAC3C,MAAM,CAAC,QAAQ,CAAC,gBAAgB,SAAU;IAC1C,MAAM,CAAC,QAAQ,CAAC,oBAAoB,SAAU;CAC/C;AAED,8GAA8G;AAC9G,qBAAa,uBAAuB;IAClC,MAAM,CAAC,QAAQ,CAAC,YAAY,kBAAkB;IAC9C,MAAM,CAAC,QAAQ,CAAC,MAAM,YAAY;IAElC,MAAM,CAAC,QAAQ,CAAC,UAAU,cAAqD;IAE/E,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;CAGvC;AAED,8CAA8C;AAC9C,MAAM,MAAM,uBAAuB,GAAG,WAAW,CAAC,OAAO,uBAAuB,CAAC,CAAC"}
@@ -61,4 +61,13 @@ export class KafkaDefaults {
61
61
  static { this.SHUTDOWN_TIMEOUT = 30_000; }
62
62
  static { this.LAG_MONITOR_INTERVAL = 30_000; }
63
63
  }
64
+ /** Why every broker of a consumer is gone: DISCONNECTED (the connections closed) or FAILED (they errored). */
65
+ export class KafkaBrokersDownReasons {
66
+ static { this.DISCONNECTED = 'disconnected'; }
67
+ static { this.FAILED = 'failed'; }
68
+ static { this.SCHEME_SET = new Set([this.DISCONNECTED, this.FAILED]); }
69
+ static isValid(value) {
70
+ return this.SCHEME_SET.has(value);
71
+ }
72
+ }
64
73
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","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BAAa,GAAG,sBAAsB,CAAC;aAEvC,wBAAmB,GAAG,qBAAqB,CAAC;aAC5C,yBAAoB,GAAG,sBAAsB,CAAC;aAC9C,6BAAwB,GAAG,0BAA0B,CAAC;aACtD,6BAAwB,GAAG,0BAA0B,CAAC;aACtD,iBAAY,GAAG,cAAc,CAAC;aAC9B,uBAAkB,GAAG,oBAAoB,CAAC;aAE1C,gBAAW,GAAG,MAAM,CAAC;aACrB,iBAAY,GAAG,OAAO,CAAC;;AAGzC,MAAM,OAAO,aAAa;IACxB,SAAS;aACO,YAAO,GAAG,CAAC,CAAC;aACZ,gBAAW,GAAG,KAAK,CAAC;IAEpC,WAAW;aACK,WAAM,GAAG,IAAI,CAAC;aACd,sBAAiB,GAAG,KAAK,CAAC;IAE1C,WAAW;aACK,eAAU,GAAG,KAAK,CAAC;aACnB,oBAAe,GAAG,MAAM,CAAC;aACzB,uBAAkB,GAAG,MAAM,CAAC;aAC5B,oBAAe,GAAG,IAAI,CAAC;aACvB,cAAS,GAAG,CAAC,CAAC;aACd,cAAS,GAAG,SAAS,GAAG,EAAE,CAAC,GAAC,QAAQ;aACpC,kBAAa,GAAG,KAAK,CAAC;aACtB,qBAAgB,GAAG,OAAO,CAAC;aAC3B,mBAAc,GAAG,kBAAkB,CAAC,OAAO,CAAC;aAE5C,iBAAY,GAAG,WAAW,CAAC;aAC3B,0BAAqB,GAAG,QAAQ,CAAC;aAEjC,oBAAe,GAAG,KAAK,CAAC;aACxB,2BAAsB,GAAG,CAAC,CAAC;aAC3B,qBAAgB,GAAG,MAAM,CAAC;aAC1B,yBAAoB,GAAG,MAAM,CAAC","sourcesContent":["import { type TConstValue } from '@/common';\n\nexport class KafkaGroupProtocol {\n static readonly CLASSIC = 'classic';\n static readonly CONSUMER = 'consumer';\n\n static readonly SCHEME_SET = new Set([this.CLASSIC, this.CONSUMER]);\n\n static isValid(mode: string): boolean {\n return this.SCHEME_SET.has(mode);\n }\n}\n\nexport type TKafkaGroupProtocol = TConstValue<typeof KafkaGroupProtocol>;\n\nexport class KafkaAcks {\n static readonly NONE = 0; // No acknowledgment — fire-and-forget\n static readonly LEADER = 1; // Leader acknowledgment only\n static readonly ALL = -1; // Full ISR acknowledgment\n\n static readonly SCHEME_SET = new Set([this.NONE, this.LEADER, this.ALL]);\n\n static isValid(ack: number): boolean {\n return this.SCHEME_SET.has(ack);\n }\n}\n\nexport type TKafkaAcks = TConstValue<typeof KafkaAcks>;\n\nexport class KafkaHealthStatuses {\n static readonly CONNECTED = 'connected';\n static readonly DISCONNECTED = 'disconnected';\n static readonly UNKNOWN = 'unknown';\n\n static readonly SCHEME_SET = new Set([this.CONNECTED, this.DISCONNECTED, this.UNKNOWN]);\n\n static isValid(status: string): boolean {\n return this.SCHEME_SET.has(status);\n }\n}\n\nexport type TKafkaHealthStatus = TConstValue<typeof KafkaHealthStatuses>;\n\nexport class KafkaClientEvents {\n static readonly BROKER_CONNECT = 'client:broker:connect';\n static readonly BROKER_DISCONNECT = 'client:broker:disconnect';\n static readonly BROKER_FAILED = 'client:broker:failed';\n\n static readonly CONSUMER_GROUP_JOIN = 'consumer:group:join';\n static readonly CONSUMER_GROUP_LEAVE = 'consumer:group:leave';\n static readonly CONSUMER_GROUP_REBALANCE = 'consumer:group:rebalance';\n static readonly CONSUMER_HEARTBEAT_ERROR = 'consumer:heartbeat:error';\n static readonly CONSUMER_LAG = 'consumer:lag';\n static readonly CONSUMER_LAG_ERROR = 'consumer:lag:error';\n\n static readonly STREAM_DATA = 'data';\n static readonly STREAM_ERROR = 'error';\n}\n\nexport class KafkaDefaults {\n // Shared\n static readonly RETRIES = 3;\n static readonly RETRY_DELAY = 1_000;\n\n // Producer\n static readonly STRICT = true;\n static readonly AUTOCREATE_TOPICS = false;\n\n // Consumer\n static readonly AUTOCOMMIT = false;\n static readonly SESSION_TIMEOUT = 60_000;\n static readonly HEARTBEAT_INTERVAL = 10_000;\n static readonly HIGH_WATER_MARK = 1024;\n static readonly MIN_BYTES = 1;\n static readonly MAX_BYTES = 1_048_576 * 10; // 10 MB\n static readonly MAX_WAIT_TIME = 5_000;\n static readonly METADATA_MAX_AGE = 300_000;\n static readonly GROUP_PROTOCOL = KafkaGroupProtocol.CLASSIC;\n\n static readonly CONSUME_MODE = 'committed';\n static readonly CONSUME_FALLBACK_MODE = 'latest';\n\n static readonly RECONNECT_DELAY = 2_000;\n static readonly MAX_RECONNECT_ATTEMPTS = 5;\n static readonly SHUTDOWN_TIMEOUT = 30_000;\n static readonly LAG_MONITOR_INTERVAL = 30_000;\n}\n"]}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../src/modules/queue/kafka/common/constants.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,kBAAkB;aACb,YAAO,GAAG,SAAS,CAAC;aACpB,aAAQ,GAAG,UAAU,CAAC;aAEtB,eAAU,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEpE,MAAM,CAAC,OAAO,CAAC,IAAY;QACzB,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;;AAKH,MAAM,OAAO,SAAS;aACJ,SAAI,GAAG,CAAC,CAAC,GAAC,sCAAsC;aAChD,WAAM,GAAG,CAAC,CAAC,GAAC,6BAA6B;aACzC,QAAG,GAAG,CAAC,CAAC,CAAC,GAAC,0BAA0B;aAEpC,eAAU,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAEzE,MAAM,CAAC,OAAO,CAAC,GAAW;QACxB,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAClC,CAAC;;AAKH,MAAM,OAAO,mBAAmB;aACd,cAAS,GAAG,WAAW,CAAC;aACxB,iBAAY,GAAG,cAAc,CAAC;aAC9B,Y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AAQ,CAAC;aAEjC,oBAAe,GAAG,KAAK,CAAC;aACxB,2BAAsB,GAAG,CAAC,CAAC;aAC3B,qBAAgB,GAAG,MAAM,CAAC;aAC1B,yBAAoB,GAAG,MAAM,CAAC;;AAGhD,8GAA8G;AAC9G,MAAM,OAAO,uBAAuB;aAClB,iBAAY,GAAG,cAAc,CAAC;aAC9B,WAAM,GAAG,QAAQ,CAAC;aAElB,eAAU,GAAG,IAAI,GAAG,CAAS,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAE/E,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC","sourcesContent":["import { type TConstValue } from '@/common';\n\nexport class KafkaGroupProtocol {\n static readonly CLASSIC = 'classic';\n static readonly CONSUMER = 'consumer';\n\n static readonly SCHEME_SET = new Set([this.CLASSIC, this.CONSUMER]);\n\n static isValid(mode: string): boolean {\n return this.SCHEME_SET.has(mode);\n }\n}\n\nexport type TKafkaGroupProtocol = TConstValue<typeof KafkaGroupProtocol>;\n\nexport class KafkaAcks {\n static readonly NONE = 0; // No acknowledgment — fire-and-forget\n static readonly LEADER = 1; // Leader acknowledgment only\n static readonly ALL = -1; // Full ISR acknowledgment\n\n static readonly SCHEME_SET = new Set([this.NONE, this.LEADER, this.ALL]);\n\n static isValid(ack: number): boolean {\n return this.SCHEME_SET.has(ack);\n }\n}\n\nexport type TKafkaAcks = TConstValue<typeof KafkaAcks>;\n\nexport class KafkaHealthStatuses {\n static readonly CONNECTED = 'connected';\n static readonly DISCONNECTED = 'disconnected';\n static readonly UNKNOWN = 'unknown';\n\n static readonly SCHEME_SET = new Set([this.CONNECTED, this.DISCONNECTED, this.UNKNOWN]);\n\n static isValid(status: string): boolean {\n return this.SCHEME_SET.has(status);\n }\n}\n\nexport type TKafkaHealthStatus = TConstValue<typeof KafkaHealthStatuses>;\n\nexport class KafkaClientEvents {\n static readonly BROKER_CONNECT = 'client:broker:connect';\n static readonly BROKER_DISCONNECT = 'client:broker:disconnect';\n static readonly BROKER_FAILED = 'client:broker:failed';\n\n static readonly CONSUMER_GROUP_JOIN = 'consumer:group:join';\n static readonly CONSUMER_GROUP_LEAVE = 'consumer:group:leave';\n static readonly CONSUMER_GROUP_REBALANCE = 'consumer:group:rebalance';\n static readonly CONSUMER_HEARTBEAT_ERROR = 'consumer:heartbeat:error';\n static readonly CONSUMER_LAG = 'consumer:lag';\n static readonly CONSUMER_LAG_ERROR = 'consumer:lag:error';\n\n static readonly STREAM_DATA = 'data';\n static readonly STREAM_ERROR = 'error';\n}\n\nexport class KafkaDefaults {\n // Shared\n static readonly RETRIES = 3;\n static readonly RETRY_DELAY = 1_000;\n\n // Producer\n static readonly STRICT = true;\n static readonly AUTOCREATE_TOPICS = false;\n\n // Consumer\n static readonly AUTOCOMMIT = false;\n static readonly SESSION_TIMEOUT = 60_000;\n static readonly HEARTBEAT_INTERVAL = 10_000;\n static readonly HIGH_WATER_MARK = 1024;\n static readonly MIN_BYTES = 1;\n static readonly MAX_BYTES = 1_048_576 * 10; // 10 MB\n static readonly MAX_WAIT_TIME = 5_000;\n static readonly METADATA_MAX_AGE = 300_000;\n static readonly GROUP_PROTOCOL = KafkaGroupProtocol.CLASSIC;\n\n static readonly CONSUME_MODE = 'committed';\n static readonly CONSUME_FALLBACK_MODE = 'latest';\n\n static readonly RECONNECT_DELAY = 2_000;\n static readonly MAX_RECONNECT_ATTEMPTS = 5;\n static readonly SHUTDOWN_TIMEOUT = 30_000;\n static readonly LAG_MONITOR_INTERVAL = 30_000;\n}\n\n/** Why every broker of a consumer is gone: DISCONNECTED (the connections closed) or FAILED (they errored). */\nexport class KafkaBrokersDownReasons {\n static readonly DISCONNECTED = 'disconnected';\n static readonly FAILED = 'failed';\n\n static readonly SCHEME_SET = new Set<string>([this.DISCONNECTED, this.FAILED]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** Valid Kafka brokers-down reason values. */\nexport type TKafkaBrokersDownReason = TConstValue<typeof KafkaBrokersDownReasons>;\n"]}
@@ -1,6 +1,7 @@
1
1
  import type { MessagesStream } from '@platformatic/kafka';
2
2
  import { Consumer } from '@platformatic/kafka';
3
3
  import { BaseKafkaHelper } from './base.js';
4
+ import { type TKafkaBrokersDownReason } from './common/constants.js';
4
5
  import type { IKafkaConsumeStartOptions, IKafkaConsumerOptions, TKafkaGroupJoinCallback, TKafkaGroupLeaveCallback, TKafkaGroupRebalanceCallback, TKafkaHeartbeatErrorCallback, TKafkaLagCallback, TKafkaLagErrorCallback, TKafkaMessageCallback, TKafkaMessageDoneCallback, TKafkaMessageErrorCallback, TKafkaReconnectErrorCallback, TKafkaStreamErrorCallback } from './common/types/index.js';
5
6
  /**
6
7
  * Wrapper around `@platformatic/kafka` Consumer with lifecycle management, health tracking, graceful shutdown, message callbacks, and lag monitoring.
@@ -78,7 +79,7 @@ export declare class KafkaConsumerHelper<KeyType = string, ValueType = string, H
78
79
  }): Promise<void>;
79
80
  protected rebuildClient(): Promise<void>;
80
81
  protected closeOldClient(oldClient: Consumer<KeyType, ValueType, HeaderKeyType, HeaderValueType>): Promise<void>;
81
- protected handleAllBrokersDown(reason: 'disconnected' | 'failed'): void;
82
+ protected handleAllBrokersDown(reason: TKafkaBrokersDownReason): void;
82
83
  protected destroyDeadStream(): void;
83
84
  protected closeStream(): Promise<void>;
84
85
  protected unconfigureBrokerEvents(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"consumer.d.ts","sourceRoot":"","sources":["../../../../../src/modules/queue/kafka/consumer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAKV,cAAc,EAEf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAEzC,OAAO,KAAK,EACV,yBAAyB,E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}
@@ -4,7 +4,7 @@ import { toError } from '../../../utilities/promise.utility.js';
4
4
  import { Consumer } from '@platformatic/kafka';
5
5
  import { invokeHook } from '../common/index.js';
6
6
  import { BaseKafkaHelper } from './base.js';
7
- import { KafkaClientEvents, KafkaDefaults, KafkaHealthStatuses } from './common/constants.js';
7
+ import { KafkaBrokersDownReasons, KafkaClientEvents, KafkaDefaults, KafkaHealthStatuses, } from './common/constants.js';
8
8
  /**
9
9
  * Wrapper around `@platformatic/kafka` Consumer with lifecycle management, health tracking, graceful shutdown, message callbacks, and lag monitoring.
10
10
  *
@@ -394,10 +394,10 @@ export class KafkaConsumerHelper extends BaseKafkaHelper {
394
394
  configureBrokerEvents() {
395
395
  super.configureBrokerEvents();
396
396
  this.client.on(KafkaClientEvents.BROKER_DISCONNECT, () => {
397
- this.handleAllBrokersDown('disconnected');
397
+ this.handleAllBrokersDown(KafkaBrokersDownReasons.DISCONNECTED);
398
398
  });
399
399
  this.client.on(KafkaClientEvents.BROKER_FAILED, () => {
400
- this.handleAllBrokersDown('failed');
400
+ this.handleAllBrokersDown(KafkaBrokersDownReasons.FAILED);
401
401
  });
402
402
  this.client.on(KafkaClientEvents.CONSUMER_GROUP_JOIN, (payload) => {
403
403
  this.logger.info('[configureConsumerEvents] Group JOINED | GroupId: %s | MemberId: %s | GenerationId: %d', payload.groupId, payload.memberId, payload.generationId);
@@ -1 +1 @@
1
- {"version":3,"file":"consumer.js","sourceRoot":"","sources":["../../../../../src/modules/queue/kafka/consumer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAStD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,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E,CAAC,GAAY,EAAE,EAAE;YAC9D,UAAU,CAAC;gBACT,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,KAAK,EAAE,uBAAuB;gBAC9B,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC;aACvC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,iBAAiB,CAAC,kBAAkB,EAAE,CAAC,KAAY,EAAE,EAAE;YACpE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,oDAAoD,EAAE,KAAK,CAAC,CAAC;YAC/E,UAAU,CAAC;gBACT,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,KAAK,EAAE,uBAAuB;gBAC9B,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC;aAC9C,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { getError } from '@/modules/error';\nimport { sleep } from '@/utilities/sleep.utility';\nimport { toError } from '@/utilities/promise.utility';\nimport type {\n ConsumerGroupJoinPayload,\n ConsumerGroupLeavePayload,\n ConsumerGroupRebalancePayload,\n ConsumerHeartbeatErrorPayload,\n MessagesStream,\n Offsets,\n} from '@platformatic/kafka';\nimport { Consumer } from '@platformatic/kafka';\nimport { invokeHook } from '../common';\nimport { BaseKafkaHelper } from './base';\nimport { KafkaClientEvents, KafkaDefaults, KafkaHealthStatuses } from './common/constants';\nimport type {\n IKafkaConsumeStartOptions,\n IKafkaConsumerOptions,\n TKafkaGroupJoinCallback,\n TKafkaGroupLeaveCallback,\n TKafkaGroupRebalanceCallback,\n TKafkaHeartbeatErrorCallback,\n TKafkaLagCallback,\n TKafkaLagErrorCallback,\n TKafkaMessageCallback,\n TKafkaMessageDoneCallback,\n TKafkaMessageErrorCallback,\n TKafkaReconnectErrorCallback,\n TKafkaStreamErrorCallback,\n} from './common/types';\n\n/**\n * Wrapper around `@platformatic/kafka` Consumer with lifecycle management, health tracking, graceful shutdown, message callbacks, and lag monitoring.\n *\n * Every member below is `protected`, not `private`, so a consumer extends this class instead of forking it. That visibility is not a stable contract between minor versions.\n */\nexport class KafkaConsumerHelper<\n KeyType = string,\n ValueType = string,\n HeaderKeyType = string,\n HeaderValueType = string,\n> extends BaseKafkaHelper<Consumer<KeyType, ValueType, HeaderKeyType, HeaderValueType>> {\n protected stream: MessagesStream<KeyType, ValueType, HeaderKeyType, HeaderValueType> | null =\n null;\n protected consumeLoop: Promise<void> | null = null;\n protected consumeStartOptions: IKafkaConsumeStartOptions | null = null;\n protected lagMonitoringActive = false;\n protected lagMonitoringOptions: { topics: string[]; interval?: number } | null = null;\n protected sessionLikelyStale = false;\n\n protected readonly onMessage?: TKafkaMessageCallback<\n KeyType,\n ValueType,\n HeaderKeyType,\n HeaderValueType\n >;\n protected readonly onMessageDone?: TKafkaMessageDoneCallback<\n KeyType,\n ValueType,\n HeaderKeyType,\n HeaderValueType\n >;\n protected readonly onMessageError?: TKafkaMessageErrorCallback<\n KeyType,\n ValueType,\n HeaderKeyType,\n HeaderValueType\n >;\n protected readonly onStreamError?: TKafkaStreamErrorCallback;\n protected readonly onReconnectError?: TKafkaReconnectErrorCallback;\n\n protected readonly onGroupJoin?: TKafkaGroupJoinCallback;\n protected readonly onGroupLeave?: TKafkaGroupLeaveCallback;\n protected readonly onGroupRebalance?: TKafkaGroupRebalanceCallback;\n protected readonly onHeartbeatError?: TKafkaHeartbeatErrorCallback;\n\n protected readonly onLag?: TKafkaLagCallback;\n protected readonly onLagError?: TKafkaLagErrorCallback;\n\n protected readonly initialOptions: IKafkaConsumerOptions<\n KeyType,\n ValueType,\n HeaderKeyType,\n HeaderValueType\n >;\n\n constructor(opts: IKafkaConsumerOptions<KeyType, ValueType, HeaderKeyType, HeaderValueType>) {\n super({\n scope: KafkaConsumerHelper.name,\n identifier: opts.identifier ?? 'kafka-consumer',\n shutdownTimeout: opts.shutdownTimeout,\n client: KafkaConsumerHelper.buildConsumerClient(opts),\n onBrokerConnect: opts.onBrokerConnect,\n onBrokerDisconnect: opts.onBrokerDisconnect,\n });\n\n this.initialOptions = opts;\n this.onMessage = opts.onMessage;\n this.onMessageDone = opts.onMessageDone;\n this.onMessageError = opts.onMessageError;\n this.onStreamError = opts.onStreamError;\n this.onReconnectError = opts.onReconnectError;\n this.onGroupJoin = opts.onGroupJoin;\n this.onGroupLeave = opts.onGroupLeave;\n this.onGroupRebalance = opts.onGroupRebalance;\n this.onHeartbeatError = opts.onHeartbeatError;\n this.onLag = opts.onLag;\n this.onLagError = opts.onLagError;\n\n this.configureBrokerEvents();\n\n this.logger.info(\n '[constructor] Kafka Consumer CREATED | ClientId: %s | GroupId: %s | Brokers: %j',\n opts.clientId,\n opts.groupId,\n opts.bootstrapBrokers,\n );\n }\n\n static newInstance<\n KeyType = string,\n ValueType = string,\n HeaderKeyType = string,\n HeaderValueType = string,\n >(opts: IKafkaConsumerOptions<KeyType, ValueType, HeaderKeyType, HeaderValueType>) {\n return new KafkaConsumerHelper<KeyType, ValueType, HeaderKeyType, HeaderValueType>(opts);\n }\n\n /** The instance seam every rebuild goes through; the constructor alone uses the static factory because no instance exists yet. Override this to hand a rebuilt consumer different options or a test double. */\n protected buildClient(opts: {\n options: IKafkaConsumerOptions<KeyType, ValueType, HeaderKeyType, HeaderValueType>;\n }): Consumer<KeyType, ValueType, HeaderKeyType, HeaderValueType> {\n return KafkaConsumerHelper.buildConsumerClient(opts.options);\n }\n\n protected static buildConsumerClient<\n KeyType = string,\n ValueType = string,\n HeaderKeyType = string,\n HeaderValueType = string,\n >(\n opts: IKafkaConsumerOptions<KeyType, ValueType, HeaderKeyType, HeaderValueType>,\n ): Consumer<KeyType, ValueType, HeaderKeyType, HeaderValueType> {\n return new Consumer<KeyType, ValueType, HeaderKeyType, HeaderValueType>({\n clientId: opts.clientId,\n bootstrapBrokers: opts.bootstrapBrokers,\n sasl: opts.sasl,\n tls: opts.tls,\n ssl: opts.ssl,\n connectTimeout: opts.connectTimeout,\n requestTimeout: opts.requestTimeout,\n groupId: opts.groupId,\n groupInstanceId: opts.groupInstanceId,\n groupProtocol: opts.groupProtocol ?? KafkaDefaults.GROUP_PROTOCOL,\n deserializers: opts.deserializers,\n autocommit: opts.autocommit ?? KafkaDefaults.AUTOCOMMIT,\n sessionTimeout: opts.sessionTimeout ?? KafkaDefaults.SESSION_TIMEOUT,\n heartbeatInterval: opts.heartbeatInterval ?? KafkaDefaults.HEARTBEAT_INTERVAL,\n rebalanceTimeout:\n opts.rebalanceTimeout ?? opts.sessionTimeout ?? KafkaDefaults.SESSION_TIMEOUT,\n highWaterMark: opts.highWaterMark ?? KafkaDefaults.HIGH_WATER_MARK,\n minBytes: opts.minBytes ?? KafkaDefaults.MIN_BYTES,\n maxBytes: opts.maxBytes ?? KafkaDefaults.MAX_BYTES,\n maxWaitTime: opts.maxWaitTime ?? KafkaDefaults.MAX_WAIT_TIME,\n metadataMaxAge: opts.metadataMaxAge ?? KafkaDefaults.METADATA_MAX_AGE,\n retries: opts.retries ?? KafkaDefaults.RETRIES,\n retryDelay: opts.retryDelay ?? KafkaDefaults.RETRY_DELAY,\n registry: opts.registry,\n });\n }\n\n getConsumer(): Consumer<KeyType, ValueType, HeaderKeyType, HeaderValueType> {\n return this.client;\n }\n\n getStream(): MessagesStream<KeyType, ValueType, HeaderKeyType, HeaderValueType> | null {\n return this.stream;\n }\n\n override isReady(): boolean {\n return this.healthStatus === KafkaHealthStatuses.CONNECTED && this.client.isActive();\n }\n\n async start(opts: IKafkaConsumeStartOptions): Promise<void> {\n if (this.stream) {\n this.logger.warn('[start] Consumer already started, ignoring duplicate start call');\n return;\n }\n\n this.logger.info('[start] Starting consumer | Topics: %j', opts.topics);\n\n this.consumeStartOptions = opts;\n this.stream = await this.client.consume({\n topics: opts.topics,\n mode: opts.mode ?? KafkaDefaults.CONSUME_MODE,\n fallbackMode: opts.fallbackMode ?? KafkaDefaults.CONSUME_FALLBACK_MODE,\n });\n\n // Successful consume() means we're freshly joined to the group; clear any stale-session flag set during initial broker negotiation (e.g. a transient BROKER_DISCONNECT during bootstrap).\n this.sessionLikelyStale = false;\n\n // Always attached, hook or not: a stream 'error' with ZERO listeners is rethrown by EventEmitter as an uncaught exception, so a pull-style consumer (start() + getStream(), no onMessage/onMessageError) would take the whole process down on the first broker drop.\n const startedStream = this.stream;\n startedStream.on(KafkaClientEvents.STREAM_ERROR, (streamError: Error) => {\n this.logger.for('start').error('Kafka stream ERROR | Error: %s', streamError);\n this.reportStreamError({ error: streamError, scope: 'start', stream: startedStream });\n });\n\n if (this.onMessage) {\n const loop = this.startConsumeLoop({\n messageHandler: this.onMessage,\n doneHandler: this.onMessageDone,\n errorHandler: this.onMessageError,\n reconnectDelayMs: opts.reconnectDelayMs ?? KafkaDefaults.RECONNECT_DELAY,\n maxReconnectAttempts: opts.maxReconnectAttempts ?? KafkaDefaults.MAX_RECONNECT_ATTEMPTS,\n }).finally(() => {\n // A finished loop (exhausted reconnects or shutdown) no longer reports stream errors; the listeners take over.\n if (this.consumeLoop === loop) {\n this.consumeLoop = null;\n }\n });\n this.consumeLoop = loop;\n }\n\n this.logger.info('[start] Consumer started | Topics: %j', opts.topics);\n }\n\n startLagMonitoring(opts: { topics: string[]; interval?: number }): void {\n if (this.lagMonitoringActive) {\n this.logger.warn(\n '[startLagMonitoring] Lag monitoring already active, ignoring duplicate call',\n );\n return;\n }\n\n const interval = opts.interval ?? KafkaDefaults.LAG_MONITOR_INTERVAL;\n this.client.startLagMonitoring({ topics: opts.topics }, interval);\n this.lagMonitoringActive = true;\n this.lagMonitoringOptions = { topics: opts.topics, interval };\n\n this.logger.info(\n '[startLagMonitoring] Lag monitoring STARTED | Topics: %j | Interval: %dms',\n opts.topics,\n interval,\n );\n }\n\n stopLagMonitoring(): void {\n if (!this.lagMonitoringActive) {\n return;\n }\n\n this.client.stopLagMonitoring();\n this.lagMonitoringActive = false;\n this.lagMonitoringOptions = null;\n\n this.logger.info('[stopLagMonitoring] Lag monitoring STOPPED');\n }\n\n protected override closeClient(): Promise<void> {\n return this.closeClientWithCallback();\n }\n\n async close(opts?: { isForce?: boolean }): Promise<void> {\n const force = opts?.isForce ?? false;\n\n this.stopLagMonitoring();\n await this.closeStream();\n\n if (force) {\n await this.closeClient();\n } else {\n try {\n await this.gracefulCloseClient();\n } catch (error) {\n this.logger.warn('[close] Graceful shutdown timed out, forcing close | Error: %s', error);\n await this.closeClient();\n }\n }\n\n this.resetHealthState();\n this.logger.info('[close] Consumer closed | Force: %s', force);\n }\n\n protected async startConsumeLoop(opts: {\n messageHandler: TKafkaMessageCallback<KeyType, ValueType, HeaderKeyType, HeaderValueType>;\n doneHandler?: TKafkaMessageDoneCallback<KeyType, ValueType, HeaderKeyType, HeaderValueType>;\n errorHandler?: TKafkaMessageErrorCallback<KeyType, ValueType, HeaderKeyType, HeaderValueType>;\n reconnectDelayMs: number;\n maxReconnectAttempts: number;\n }): Promise<void> {\n const { messageHandler, doneHandler, errorHandler, reconnectDelayMs, maxReconnectAttempts } =\n opts;\n\n const messages = this.consumeMessages({\n reconnectDelayMs,\n maxReconnectAttempts,\n errorHandler,\n });\n for await (const message of messages) {\n try {\n await messageHandler({ message });\n await doneHandler?.({ message });\n } catch (error) {\n const normalizedError = toError(error);\n this.logger.error(\n '[startConsumeLoop] Message processing error: %s',\n normalizedError.message,\n );\n invokeHook({\n logger: this.logger,\n scope: 'startConsumeLoop',\n execution: () => errorHandler?.({ error: normalizedError, message }),\n });\n }\n }\n }\n\n protected async *consumeMessages(opts: {\n reconnectDelayMs: number;\n maxReconnectAttempts: number;\n errorHandler?: TKafkaMessageErrorCallback<KeyType, ValueType, HeaderKeyType, HeaderValueType>;\n }) {\n const { reconnectDelayMs, maxReconnectAttempts, errorHandler } = opts;\n let consecutiveErrors = 0;\n\n while (true) {\n if (this.stream) {\n yield* this.drainStream({ errorHandler });\n }\n\n if (!this.consumeStartOptions) {\n this.logger.info('[consumeMessages] Shutdown requested, exiting consume loop');\n return;\n }\n\n consecutiveErrors++;\n if (consecutiveErrors > maxReconnectAttempts) {\n this.logger.error(\n '[consumeMessages] All %d reconnect attempts exhausted | Topics: %j',\n maxReconnectAttempts,\n this.consumeStartOptions?.topics,\n );\n return;\n }\n\n await this.attemptReconnect({\n attempt: consecutiveErrors,\n maxAttempts: maxReconnectAttempts,\n delayMs: reconnectDelayMs,\n errorHandler,\n });\n\n if (!this.consumeStartOptions) {\n this.logger.info(\n '[consumeMessages] Shutdown requested during reconnect, exiting consume loop',\n );\n return;\n }\n\n if (this.stream) {\n consecutiveErrors = 0;\n }\n }\n }\n\n /** Silent only while the consume loop is alive AND the erroring stream is the one it drains - the iterator then reports the same error once. A dead or replaced stream, or pull mode, reports here. */\n protected reportStreamError(opts: { error: Error; scope: string; stream: unknown }): void {\n if (this.consumeLoop && this.stream === opts.stream) {\n return;\n }\n\n invokeHook({\n logger: this.logger,\n scope: opts.scope,\n execution: () =>\n this.onStreamError\n ? this.onStreamError({ error: opts.error })\n : this.onMessageError?.({ error: opts.error }),\n });\n }\n\n protected async *drainStream(opts: {\n errorHandler?: TKafkaMessageErrorCallback<KeyType, ValueType, HeaderKeyType, HeaderValueType>;\n }) {\n this.logger.debug('[drainStream] Consuming | Topics: %j', this.consumeStartOptions?.topics);\n\n try {\n yield* this.stream!;\n this.logger.warn(\n '[drainStream] Stream ended normally | Topics: %j',\n this.consumeStartOptions?.topics,\n );\n } catch (error) {\n const normalizedError = toError(error);\n this.logger.error(\n '[drainStream] Stream error: %s | Topics: %j',\n normalizedError.message,\n this.consumeStartOptions?.topics,\n );\n invokeHook({\n logger: this.logger,\n scope: 'drainStream',\n execution: () =>\n this.onStreamError\n ? this.onStreamError({ error: normalizedError })\n : opts.errorHandler?.({ error: normalizedError }),\n });\n }\n\n this.destroyDeadStream();\n }\n\n protected async attemptReconnect(opts: {\n attempt: number;\n maxAttempts: number;\n delayMs: number;\n errorHandler?: TKafkaMessageErrorCallback<KeyType, ValueType, HeaderKeyType, HeaderValueType>;\n }): Promise<void> {\n const { attempt, maxAttempts, delayMs, errorHandler } = opts;\n\n this.logger.info(\n '[attemptReconnect] Reconnecting %d/%d in %dms | Topics: %j | ConnectedBrokers: %d',\n attempt,\n maxAttempts,\n delayMs,\n this.consumeStartOptions?.topics,\n this.getConnectedBrokerCount(),\n );\n await sleep(delayMs);\n\n if (!this.consumeStartOptions) {\n return;\n }\n\n const shouldRebuildClient = this.sessionLikelyStale;\n\n if (shouldRebuildClient) {\n this.logger.warn(\n '[attemptReconnect] Session stale flag is set, will rebuild client | Attempt: %d',\n attempt,\n );\n }\n\n if (shouldRebuildClient) {\n try {\n await this.rebuildClient();\n this.sessionLikelyStale = false;\n } catch (error) {\n const normalizedError = toError(error);\n this.logger.error(\n '[attemptReconnect] Client rebuild failed (%d/%d): %s | Topics: %j',\n attempt,\n maxAttempts,\n normalizedError.message,\n this.consumeStartOptions?.topics,\n );\n invokeHook({\n logger: this.logger,\n scope: 'attemptReconnect',\n execution: () =>\n this.onReconnectError\n ? this.onReconnectError({ error: normalizedError, attempt, maxAttempts })\n : errorHandler?.({ error: normalizedError }),\n });\n return;\n }\n }\n\n try {\n this.stream = await this.client.consume({\n topics: this.consumeStartOptions.topics,\n mode: this.consumeStartOptions.mode ?? KafkaDefaults.CONSUME_MODE,\n fallbackMode: this.consumeStartOptions.fallbackMode ?? KafkaDefaults.CONSUME_FALLBACK_MODE,\n });\n\n // Always attached, hook or not, like the listener in start(): a stream 'error' with ZERO listeners is rethrown by EventEmitter and takes the process down.\n const reconnectedStream = this.stream;\n reconnectedStream.on(KafkaClientEvents.STREAM_ERROR, (streamError: Error) => {\n this.logger.for('attemptReconnect').error('Kafka stream ERROR | Error: %s', streamError);\n this.reportStreamError({\n error: streamError,\n scope: 'attemptReconnect',\n stream: reconnectedStream,\n });\n });\n\n this.sessionLikelyStale = false;\n\n this.logger.info(\n '[attemptReconnect] Reconnected successfully | Topics: %j | Attempt: %d | Rebuilt: %s',\n this.consumeStartOptions.topics,\n attempt,\n shouldRebuildClient,\n );\n } catch (error) {\n const normalizedError = toError(error);\n this.logger.error(\n '[attemptReconnect] Failed (%d/%d): %s | Topics: %j | ConnectedBrokers: %d',\n attempt,\n maxAttempts,\n normalizedError.message,\n this.consumeStartOptions?.topics,\n this.getConnectedBrokerCount(),\n );\n invokeHook({\n logger: this.logger,\n scope: 'attemptReconnect',\n execution: () =>\n this.onReconnectError\n ? this.onReconnectError({ error: normalizedError, attempt, maxAttempts })\n : errorHandler?.({ error: normalizedError }),\n });\n }\n }\n\n protected async rebuildClient(): Promise<void> {\n this.logger.warn(\n '[rebuildClient] All brokers were disconnected; rebuilding @platformatic/kafka ' +\n 'Consumer to force a clean group rejoin (cached session state is stale)',\n );\n\n const oldClient = this.client;\n const newClient = this.buildClient({ options: this.initialOptions });\n\n this.swapClient(newClient);\n\n if (this.lagMonitoringOptions) {\n const opts = this.lagMonitoringOptions;\n this.lagMonitoringActive = false; // reset so startLagMonitoring won't refuse\n try {\n this.startLagMonitoring(opts);\n this.logger.info(\n '[rebuildClient] Lag monitoring re-armed on new client | Topics: %j',\n opts.topics,\n );\n } catch (error) {\n this.logger.warn(\n '[rebuildClient] Failed to restart lag monitoring on new client | Error: %s',\n toError(error).message,\n );\n }\n }\n\n this.closeOldClient(oldClient).catch((error) => {\n this.logger.warn(\n '[rebuildClient] background close of old client failed (ignored) | Error: %s',\n toError(error).message,\n );\n });\n }\n\n protected async closeOldClient(\n oldClient: Consumer<KeyType, ValueType, HeaderKeyType, HeaderValueType>,\n ): Promise<void> {\n let timeoutHandle: NodeJS.Timeout | null = null;\n try {\n await Promise.race([\n new Promise<void>((resolve, reject) => {\n oldClient.close(true, (normalizedError?: Error | null) => {\n if (normalizedError) {\n reject(normalizedError);\n } else {\n resolve();\n }\n });\n }),\n new Promise<void>((resolve) => {\n timeoutHandle = setTimeout(resolve, this.shutdownTimeout);\n }),\n ]);\n } finally {\n if (timeoutHandle !== null) {\n clearTimeout(timeoutHandle);\n }\n }\n }\n\n protected handleAllBrokersDown(reason: 'disconnected' | 'failed'): void {\n if (this.getConnectedBrokerCount() !== 0) {\n return;\n }\n this.sessionLikelyStale = true;\n if (this.stream) {\n this.logger.warn(\n '[configureBrokerEvents] All brokers %s, destroying stream to trigger reconnect',\n reason,\n );\n this.destroyDeadStream();\n }\n }\n\n protected destroyDeadStream(): void {\n this.stream?.destroy(getError({ message: '[destroyDeadStream] All brokers disconnected' }));\n this.stream = null;\n }\n\n protected async closeStream(): Promise<void> {\n const stream = this.stream;\n this.stream = null;\n this.consumeStartOptions = null;\n\n try {\n await stream?.close();\n } catch (error) {\n this.logger.warn('[closeStream] Error closing stream: %s', toError(error).message);\n }\n\n await this.consumeLoop;\n this.consumeLoop = null;\n }\n\n protected override unconfigureBrokerEvents(): void {\n super.unconfigureBrokerEvents();\n this.client.removeAllListeners(KafkaClientEvents.CONSUMER_GROUP_JOIN);\n this.client.removeAllListeners(KafkaClientEvents.CONSUMER_GROUP_LEAVE);\n this.client.removeAllListeners(KafkaClientEvents.CONSUMER_GROUP_REBALANCE);\n this.client.removeAllListeners(KafkaClientEvents.CONSUMER_HEARTBEAT_ERROR);\n this.client.removeAllListeners(KafkaClientEvents.CONSUMER_LAG);\n this.client.removeAllListeners(KafkaClientEvents.CONSUMER_LAG_ERROR);\n }\n\n protected override configureBrokerEvents(): void {\n super.configureBrokerEvents();\n\n this.client.on(KafkaClientEvents.BROKER_DISCONNECT, () => {\n this.handleAllBrokersDown('disconnected');\n });\n this.client.on(KafkaClientEvents.BROKER_FAILED, () => {\n this.handleAllBrokersDown('failed');\n });\n\n this.client.on(KafkaClientEvents.CONSUMER_GROUP_JOIN, (payload: ConsumerGroupJoinPayload) => {\n this.logger.info(\n '[configureConsumerEvents] Group JOINED | GroupId: %s | MemberId: %s | GenerationId: %d',\n payload.groupId,\n payload.memberId,\n payload.generationId,\n );\n invokeHook({\n logger: this.logger,\n scope: 'configureBrokerEvents',\n execution: () =>\n this.onGroupJoin?.({\n groupId: payload.groupId,\n memberId: payload.memberId,\n generationId: payload.generationId,\n }),\n });\n });\n\n this.client.on(KafkaClientEvents.CONSUMER_GROUP_LEAVE, (payload: ConsumerGroupLeavePayload) => {\n this.logger.info(\n '[configureConsumerEvents] Group LEFT | GroupId: %s | MemberId: %s',\n payload.groupId,\n payload.memberId,\n );\n invokeHook({\n logger: this.logger,\n scope: 'configureBrokerEvents',\n execution: () =>\n this.onGroupLeave?.({\n groupId: payload.groupId,\n memberId: payload.memberId,\n }),\n });\n });\n\n this.client.on(\n KafkaClientEvents.CONSUMER_GROUP_REBALANCE,\n (payload: ConsumerGroupRebalancePayload) => {\n this.logger.info(\n '[configureConsumerEvents] Group REBALANCE | GroupId: %s',\n payload.groupId,\n );\n invokeHook({\n logger: this.logger,\n scope: 'configureBrokerEvents',\n execution: () => this.onGroupRebalance?.({ groupId: payload.groupId }),\n });\n },\n );\n\n this.client.on(\n KafkaClientEvents.CONSUMER_HEARTBEAT_ERROR,\n (payload: ConsumerHeartbeatErrorPayload) => {\n this.logger.error(\n '[configureConsumerEvents] Heartbeat ERROR | GroupId: %s | MemberId: %s | Error: %s',\n payload.groupId,\n payload.memberId,\n payload.error,\n );\n invokeHook({\n logger: this.logger,\n scope: 'configureBrokerEvents',\n execution: () =>\n this.onHeartbeatError?.({\n error: payload.error,\n groupId: payload.groupId,\n memberId: payload.memberId,\n }),\n });\n },\n );\n\n this.client.on(KafkaClientEvents.CONSUMER_LAG, (lag: Offsets) => {\n invokeHook({\n logger: this.logger,\n scope: 'configureBrokerEvents',\n execution: () => this.onLag?.({ lag }),\n });\n });\n\n this.client.on(KafkaClientEvents.CONSUMER_LAG_ERROR, (error: Error) => {\n this.logger.error('[configureConsumerEvents] Lag monitoring ERROR: %s', error);\n invokeHook({\n logger: this.logger,\n scope: 'configureBrokerEvents',\n execution: () => this.onLagError?.({ error }),\n });\n });\n }\n}\n"]}
1
+ {"version":3,"file":"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d,CAAC;YACF,UAAU,CAAC;gBACT,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,KAAK,EAAE,uBAAuB;gBAC9B,SAAS,EAAE,GAAG,EAAE,CACd,IAAI,CAAC,gBAAgB,EAAE,CAAC;oBACtB,KAAK,EAAE,OAAO,CAAC,KAAK;oBACpB,OAAO,EAAE,OAAO,CAAC,OAAO;oBACxB,QAAQ,EAAE,OAAO,CAAC,QAAQ;iBAC3B,CAAC;aACL,CAAC,CAAC;QACL,CAAC,CACF,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,iBAAiB,CAAC,YAAY,EAAE,CAAC,GAAY,EAAE,EAAE;YAC9D,UAAU,CAAC;gBACT,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,KAAK,EAAE,uBAAuB;gBAC9B,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC;aACvC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,iBAAiB,CAAC,kBAAkB,EAAE,CAAC,KAAY,EAAE,EAAE;YACpE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,oDAAoD,EAAE,KAAK,CAAC,CAAC;YAC/E,UAAU,CAAC;gBACT,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,KAAK,EAAE,uBAAuB;gBAC9B,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC;aAC9C,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { getError } from '@/modules/error';\nimport { sleep } from '@/utilities/sleep.utility';\nimport { toError } from '@/utilities/promise.utility';\nimport type {\n ConsumerGroupJoinPayload,\n ConsumerGroupLeavePayload,\n ConsumerGroupRebalancePayload,\n ConsumerHeartbeatErrorPayload,\n MessagesStream,\n Offsets,\n} from '@platformatic/kafka';\nimport { Consumer } from '@platformatic/kafka';\nimport { invokeHook } from '../common';\nimport { BaseKafkaHelper } from './base';\nimport {\n KafkaBrokersDownReasons,\n KafkaClientEvents,\n KafkaDefaults,\n KafkaHealthStatuses,\n type TKafkaBrokersDownReason,\n} from './common/constants';\nimport type {\n IKafkaConsumeStartOptions,\n IKafkaConsumerOptions,\n TKafkaGroupJoinCallback,\n TKafkaGroupLeaveCallback,\n TKafkaGroupRebalanceCallback,\n TKafkaHeartbeatErrorCallback,\n TKafkaLagCallback,\n TKafkaLagErrorCallback,\n TKafkaMessageCallback,\n TKafkaMessageDoneCallback,\n TKafkaMessageErrorCallback,\n TKafkaReconnectErrorCallback,\n TKafkaStreamErrorCallback,\n} from './common/types';\n\n/**\n * Wrapper around `@platformatic/kafka` Consumer with lifecycle management, health tracking, graceful shutdown, message callbacks, and lag monitoring.\n *\n * Every member below is `protected`, not `private`, so a consumer extends this class instead of forking it. That visibility is not a stable contract between minor versions.\n */\nexport class KafkaConsumerHelper<\n KeyType = string,\n ValueType = string,\n HeaderKeyType = string,\n HeaderValueType = string,\n> extends BaseKafkaHelper<Consumer<KeyType, ValueType, HeaderKeyType, HeaderValueType>> {\n protected stream: MessagesStream<KeyType, ValueType, HeaderKeyType, HeaderValueType> | null =\n null;\n protected consumeLoop: Promise<void> | null = null;\n protected consumeStartOptions: IKafkaConsumeStartOptions | null = null;\n protected lagMonitoringActive = false;\n protected lagMonitoringOptions: { topics: string[]; interval?: number } | null = null;\n protected sessionLikelyStale = false;\n\n protected readonly onMessage?: TKafkaMessageCallback<\n KeyType,\n ValueType,\n HeaderKeyType,\n HeaderValueType\n >;\n protected readonly onMessageDone?: TKafkaMessageDoneCallback<\n KeyType,\n ValueType,\n HeaderKeyType,\n HeaderValueType\n >;\n protected readonly onMessageError?: TKafkaMessageErrorCallback<\n KeyType,\n ValueType,\n HeaderKeyType,\n HeaderValueType\n >;\n protected readonly onStreamError?: TKafkaStreamErrorCallback;\n protected readonly onReconnectError?: TKafkaReconnectErrorCallback;\n\n protected readonly onGroupJoin?: TKafkaGroupJoinCallback;\n protected readonly onGroupLeave?: TKafkaGroupLeaveCallback;\n protected readonly onGroupRebalance?: TKafkaGroupRebalanceCallback;\n protected readonly onHeartbeatError?: TKafkaHeartbeatErrorCallback;\n\n protected readonly onLag?: TKafkaLagCallback;\n protected readonly onLagError?: TKafkaLagErrorCallback;\n\n protected readonly initialOptions: IKafkaConsumerOptions<\n KeyType,\n ValueType,\n HeaderKeyType,\n HeaderValueType\n >;\n\n constructor(opts: IKafkaConsumerOptions<KeyType, ValueType, HeaderKeyType, HeaderValueType>) {\n super({\n scope: KafkaConsumerHelper.name,\n identifier: opts.identifier ?? 'kafka-consumer',\n shutdownTimeout: opts.shutdownTimeout,\n client: KafkaConsumerHelper.buildConsumerClient(opts),\n onBrokerConnect: opts.onBrokerConnect,\n onBrokerDisconnect: opts.onBrokerDisconnect,\n });\n\n this.initialOptions = opts;\n this.onMessage = opts.onMessage;\n this.onMessageDone = opts.onMessageDone;\n this.onMessageError = opts.onMessageError;\n this.onStreamError = opts.onStreamError;\n this.onReconnectError = opts.onReconnectError;\n this.onGroupJoin = opts.onGroupJoin;\n this.onGroupLeave = opts.onGroupLeave;\n this.onGroupRebalance = opts.onGroupRebalance;\n this.onHeartbeatError = opts.onHeartbeatError;\n this.onLag = opts.onLag;\n this.onLagError = opts.onLagError;\n\n this.configureBrokerEvents();\n\n this.logger.info(\n '[constructor] Kafka Consumer CREATED | ClientId: %s | GroupId: %s | Brokers: %j',\n opts.clientId,\n opts.groupId,\n opts.bootstrapBrokers,\n );\n }\n\n static newInstance<\n KeyType = string,\n ValueType = string,\n HeaderKeyType = string,\n HeaderValueType = string,\n >(opts: IKafkaConsumerOptions<KeyType, ValueType, HeaderKeyType, HeaderValueType>) {\n return new KafkaConsumerHelper<KeyType, ValueType, HeaderKeyType, HeaderValueType>(opts);\n }\n\n /** The instance seam every rebuild goes through; the constructor alone uses the static factory because no instance exists yet. Override this to hand a rebuilt consumer different options or a test double. */\n protected buildClient(opts: {\n options: IKafkaConsumerOptions<KeyType, ValueType, HeaderKeyType, HeaderValueType>;\n }): Consumer<KeyType, ValueType, HeaderKeyType, HeaderValueType> {\n return KafkaConsumerHelper.buildConsumerClient(opts.options);\n }\n\n protected static buildConsumerClient<\n KeyType = string,\n ValueType = string,\n HeaderKeyType = string,\n HeaderValueType = string,\n >(\n opts: IKafkaConsumerOptions<KeyType, ValueType, HeaderKeyType, HeaderValueType>,\n ): Consumer<KeyType, ValueType, HeaderKeyType, HeaderValueType> {\n return new Consumer<KeyType, ValueType, HeaderKeyType, HeaderValueType>({\n clientId: opts.clientId,\n bootstrapBrokers: opts.bootstrapBrokers,\n sasl: opts.sasl,\n tls: opts.tls,\n ssl: opts.ssl,\n connectTimeout: opts.connectTimeout,\n requestTimeout: opts.requestTimeout,\n groupId: opts.groupId,\n groupInstanceId: opts.groupInstanceId,\n groupProtocol: opts.groupProtocol ?? KafkaDefaults.GROUP_PROTOCOL,\n deserializers: opts.deserializers,\n autocommit: opts.autocommit ?? KafkaDefaults.AUTOCOMMIT,\n sessionTimeout: opts.sessionTimeout ?? KafkaDefaults.SESSION_TIMEOUT,\n heartbeatInterval: opts.heartbeatInterval ?? KafkaDefaults.HEARTBEAT_INTERVAL,\n rebalanceTimeout:\n opts.rebalanceTimeout ?? opts.sessionTimeout ?? KafkaDefaults.SESSION_TIMEOUT,\n highWaterMark: opts.highWaterMark ?? KafkaDefaults.HIGH_WATER_MARK,\n minBytes: opts.minBytes ?? KafkaDefaults.MIN_BYTES,\n maxBytes: opts.maxBytes ?? KafkaDefaults.MAX_BYTES,\n maxWaitTime: opts.maxWaitTime ?? KafkaDefaults.MAX_WAIT_TIME,\n metadataMaxAge: opts.metadataMaxAge ?? KafkaDefaults.METADATA_MAX_AGE,\n retries: opts.retries ?? KafkaDefaults.RETRIES,\n retryDelay: opts.retryDelay ?? KafkaDefaults.RETRY_DELAY,\n registry: opts.registry,\n });\n }\n\n getConsumer(): Consumer<KeyType, ValueType, HeaderKeyType, HeaderValueType> {\n return this.client;\n }\n\n getStream(): MessagesStream<KeyType, ValueType, HeaderKeyType, HeaderValueType> | null {\n return this.stream;\n }\n\n override isReady(): boolean {\n return this.healthStatus === KafkaHealthStatuses.CONNECTED && this.client.isActive();\n }\n\n async start(opts: IKafkaConsumeStartOptions): Promise<void> {\n if (this.stream) {\n this.logger.warn('[start] Consumer already started, ignoring duplicate start call');\n return;\n }\n\n this.logger.info('[start] Starting consumer | Topics: %j', opts.topics);\n\n this.consumeStartOptions = opts;\n this.stream = await this.client.consume({\n topics: opts.topics,\n mode: opts.mode ?? KafkaDefaults.CONSUME_MODE,\n fallbackMode: opts.fallbackMode ?? KafkaDefaults.CONSUME_FALLBACK_MODE,\n });\n\n // Successful consume() means we're freshly joined to the group; clear any stale-session flag set during initial broker negotiation (e.g. a transient BROKER_DISCONNECT during bootstrap).\n this.sessionLikelyStale = false;\n\n // Always attached, hook or not: a stream 'error' with ZERO listeners is rethrown by EventEmitter as an uncaught exception, so a pull-style consumer (start() + getStream(), no onMessage/onMessageError) would take the whole process down on the first broker drop.\n const startedStream = this.stream;\n startedStream.on(KafkaClientEvents.STREAM_ERROR, (streamError: Error) => {\n this.logger.for('start').error('Kafka stream ERROR | Error: %s', streamError);\n this.reportStreamError({ error: streamError, scope: 'start', stream: startedStream });\n });\n\n if (this.onMessage) {\n const loop = this.startConsumeLoop({\n messageHandler: this.onMessage,\n doneHandler: this.onMessageDone,\n errorHandler: this.onMessageError,\n reconnectDelayMs: opts.reconnectDelayMs ?? KafkaDefaults.RECONNECT_DELAY,\n maxReconnectAttempts: opts.maxReconnectAttempts ?? KafkaDefaults.MAX_RECONNECT_ATTEMPTS,\n }).finally(() => {\n // A finished loop (exhausted reconnects or shutdown) no longer reports stream errors; the listeners take over.\n if (this.consumeLoop === loop) {\n this.consumeLoop = null;\n }\n });\n this.consumeLoop = loop;\n }\n\n this.logger.info('[start] Consumer started | Topics: %j', opts.topics);\n }\n\n startLagMonitoring(opts: { topics: string[]; interval?: number }): void {\n if (this.lagMonitoringActive) {\n this.logger.warn(\n '[startLagMonitoring] Lag monitoring already active, ignoring duplicate call',\n );\n return;\n }\n\n const interval = opts.interval ?? KafkaDefaults.LAG_MONITOR_INTERVAL;\n this.client.startLagMonitoring({ topics: opts.topics }, interval);\n this.lagMonitoringActive = true;\n this.lagMonitoringOptions = { topics: opts.topics, interval };\n\n this.logger.info(\n '[startLagMonitoring] Lag monitoring STARTED | Topics: %j | Interval: %dms',\n opts.topics,\n interval,\n );\n }\n\n stopLagMonitoring(): void {\n if (!this.lagMonitoringActive) {\n return;\n }\n\n this.client.stopLagMonitoring();\n this.lagMonitoringActive = false;\n this.lagMonitoringOptions = null;\n\n this.logger.info('[stopLagMonitoring] Lag monitoring STOPPED');\n }\n\n protected override closeClient(): Promise<void> {\n return this.closeClientWithCallback();\n }\n\n async close(opts?: { isForce?: boolean }): Promise<void> {\n const force = opts?.isForce ?? false;\n\n this.stopLagMonitoring();\n await this.closeStream();\n\n if (force) {\n await this.closeClient();\n } else {\n try {\n await this.gracefulCloseClient();\n } catch (error) {\n this.logger.warn('[close] Graceful shutdown timed out, forcing close | Error: %s', error);\n await this.closeClient();\n }\n }\n\n this.resetHealthState();\n this.logger.info('[close] Consumer closed | Force: %s', force);\n }\n\n protected async startConsumeLoop(opts: {\n messageHandler: TKafkaMessageCallback<KeyType, ValueType, HeaderKeyType, HeaderValueType>;\n doneHandler?: TKafkaMessageDoneCallback<KeyType, ValueType, HeaderKeyType, HeaderValueType>;\n errorHandler?: TKafkaMessageErrorCallback<KeyType, ValueType, HeaderKeyType, HeaderValueType>;\n reconnectDelayMs: number;\n maxReconnectAttempts: number;\n }): Promise<void> {\n const { messageHandler, doneHandler, errorHandler, reconnectDelayMs, maxReconnectAttempts } =\n opts;\n\n const messages = this.consumeMessages({\n reconnectDelayMs,\n maxReconnectAttempts,\n errorHandler,\n });\n for await (const message of messages) {\n try {\n await messageHandler({ message });\n await doneHandler?.({ message });\n } catch (error) {\n const normalizedError = toError(error);\n this.logger.error(\n '[startConsumeLoop] Message processing error: %s',\n normalizedError.message,\n );\n invokeHook({\n logger: this.logger,\n scope: 'startConsumeLoop',\n execution: () => errorHandler?.({ error: normalizedError, message }),\n });\n }\n }\n }\n\n protected async *consumeMessages(opts: {\n reconnectDelayMs: number;\n maxReconnectAttempts: number;\n errorHandler?: TKafkaMessageErrorCallback<KeyType, ValueType, HeaderKeyType, HeaderValueType>;\n }) {\n const { reconnectDelayMs, maxReconnectAttempts, errorHandler } = opts;\n let consecutiveErrors = 0;\n\n while (true) {\n if (this.stream) {\n yield* this.drainStream({ errorHandler });\n }\n\n if (!this.consumeStartOptions) {\n this.logger.info('[consumeMessages] Shutdown requested, exiting consume loop');\n return;\n }\n\n consecutiveErrors++;\n if (consecutiveErrors > maxReconnectAttempts) {\n this.logger.error(\n '[consumeMessages] All %d reconnect attempts exhausted | Topics: %j',\n maxReconnectAttempts,\n this.consumeStartOptions?.topics,\n );\n return;\n }\n\n await this.attemptReconnect({\n attempt: consecutiveErrors,\n maxAttempts: maxReconnectAttempts,\n delayMs: reconnectDelayMs,\n errorHandler,\n });\n\n if (!this.consumeStartOptions) {\n this.logger.info(\n '[consumeMessages] Shutdown requested during reconnect, exiting consume loop',\n );\n return;\n }\n\n if (this.stream) {\n consecutiveErrors = 0;\n }\n }\n }\n\n /** Silent only while the consume loop is alive AND the erroring stream is the one it drains - the iterator then reports the same error once. A dead or replaced stream, or pull mode, reports here. */\n protected reportStreamError(opts: { error: Error; scope: string; stream: unknown }): void {\n if (this.consumeLoop && this.stream === opts.stream) {\n return;\n }\n\n invokeHook({\n logger: this.logger,\n scope: opts.scope,\n execution: () =>\n this.onStreamError\n ? this.onStreamError({ error: opts.error })\n : this.onMessageError?.({ error: opts.error }),\n });\n }\n\n protected async *drainStream(opts: {\n errorHandler?: TKafkaMessageErrorCallback<KeyType, ValueType, HeaderKeyType, HeaderValueType>;\n }) {\n this.logger.debug('[drainStream] Consuming | Topics: %j', this.consumeStartOptions?.topics);\n\n try {\n yield* this.stream!;\n this.logger.warn(\n '[drainStream] Stream ended normally | Topics: %j',\n this.consumeStartOptions?.topics,\n );\n } catch (error) {\n const normalizedError = toError(error);\n this.logger.error(\n '[drainStream] Stream error: %s | Topics: %j',\n normalizedError.message,\n this.consumeStartOptions?.topics,\n );\n invokeHook({\n logger: this.logger,\n scope: 'drainStream',\n execution: () =>\n this.onStreamError\n ? this.onStreamError({ error: normalizedError })\n : opts.errorHandler?.({ error: normalizedError }),\n });\n }\n\n this.destroyDeadStream();\n }\n\n protected async attemptReconnect(opts: {\n attempt: number;\n maxAttempts: number;\n delayMs: number;\n errorHandler?: TKafkaMessageErrorCallback<KeyType, ValueType, HeaderKeyType, HeaderValueType>;\n }): Promise<void> {\n const { attempt, maxAttempts, delayMs, errorHandler } = opts;\n\n this.logger.info(\n '[attemptReconnect] Reconnecting %d/%d in %dms | Topics: %j | ConnectedBrokers: %d',\n attempt,\n maxAttempts,\n delayMs,\n this.consumeStartOptions?.topics,\n this.getConnectedBrokerCount(),\n );\n await sleep(delayMs);\n\n if (!this.consumeStartOptions) {\n return;\n }\n\n const shouldRebuildClient = this.sessionLikelyStale;\n\n if (shouldRebuildClient) {\n this.logger.warn(\n '[attemptReconnect] Session stale flag is set, will rebuild client | Attempt: %d',\n attempt,\n );\n }\n\n if (shouldRebuildClient) {\n try {\n await this.rebuildClient();\n this.sessionLikelyStale = false;\n } catch (error) {\n const normalizedError = toError(error);\n this.logger.error(\n '[attemptReconnect] Client rebuild failed (%d/%d): %s | Topics: %j',\n attempt,\n maxAttempts,\n normalizedError.message,\n this.consumeStartOptions?.topics,\n );\n invokeHook({\n logger: this.logger,\n scope: 'attemptReconnect',\n execution: () =>\n this.onReconnectError\n ? this.onReconnectError({ error: normalizedError, attempt, maxAttempts })\n : errorHandler?.({ error: normalizedError }),\n });\n return;\n }\n }\n\n try {\n this.stream = await this.client.consume({\n topics: this.consumeStartOptions.topics,\n mode: this.consumeStartOptions.mode ?? KafkaDefaults.CONSUME_MODE,\n fallbackMode: this.consumeStartOptions.fallbackMode ?? KafkaDefaults.CONSUME_FALLBACK_MODE,\n });\n\n // Always attached, hook or not, like the listener in start(): a stream 'error' with ZERO listeners is rethrown by EventEmitter and takes the process down.\n const reconnectedStream = this.stream;\n reconnectedStream.on(KafkaClientEvents.STREAM_ERROR, (streamError: Error) => {\n this.logger.for('attemptReconnect').error('Kafka stream ERROR | Error: %s', streamError);\n this.reportStreamError({\n error: streamError,\n scope: 'attemptReconnect',\n stream: reconnectedStream,\n });\n });\n\n this.sessionLikelyStale = false;\n\n this.logger.info(\n '[attemptReconnect] Reconnected successfully | Topics: %j | Attempt: %d | Rebuilt: %s',\n this.consumeStartOptions.topics,\n attempt,\n shouldRebuildClient,\n );\n } catch (error) {\n const normalizedError = toError(error);\n this.logger.error(\n '[attemptReconnect] Failed (%d/%d): %s | Topics: %j | ConnectedBrokers: %d',\n attempt,\n maxAttempts,\n normalizedError.message,\n this.consumeStartOptions?.topics,\n this.getConnectedBrokerCount(),\n );\n invokeHook({\n logger: this.logger,\n scope: 'attemptReconnect',\n execution: () =>\n this.onReconnectError\n ? this.onReconnectError({ error: normalizedError, attempt, maxAttempts })\n : errorHandler?.({ error: normalizedError }),\n });\n }\n }\n\n protected async rebuildClient(): Promise<void> {\n this.logger.warn(\n '[rebuildClient] All brokers were disconnected; rebuilding @platformatic/kafka ' +\n 'Consumer to force a clean group rejoin (cached session state is stale)',\n );\n\n const oldClient = this.client;\n const newClient = this.buildClient({ options: this.initialOptions });\n\n this.swapClient(newClient);\n\n if (this.lagMonitoringOptions) {\n const opts = this.lagMonitoringOptions;\n this.lagMonitoringActive = false; // reset so startLagMonitoring won't refuse\n try {\n this.startLagMonitoring(opts);\n this.logger.info(\n '[rebuildClient] Lag monitoring re-armed on new client | Topics: %j',\n opts.topics,\n );\n } catch (error) {\n this.logger.warn(\n '[rebuildClient] Failed to restart lag monitoring on new client | Error: %s',\n toError(error).message,\n );\n }\n }\n\n this.closeOldClient(oldClient).catch((error) => {\n this.logger.warn(\n '[rebuildClient] background close of old client failed (ignored) | Error: %s',\n toError(error).message,\n );\n });\n }\n\n protected async closeOldClient(\n oldClient: Consumer<KeyType, ValueType, HeaderKeyType, HeaderValueType>,\n ): Promise<void> {\n let timeoutHandle: NodeJS.Timeout | null = null;\n try {\n await Promise.race([\n new Promise<void>((resolve, reject) => {\n oldClient.close(true, (normalizedError?: Error | null) => {\n if (normalizedError) {\n reject(normalizedError);\n } else {\n resolve();\n }\n });\n }),\n new Promise<void>((resolve) => {\n timeoutHandle = setTimeout(resolve, this.shutdownTimeout);\n }),\n ]);\n } finally {\n if (timeoutHandle !== null) {\n clearTimeout(timeoutHandle);\n }\n }\n }\n\n protected handleAllBrokersDown(reason: TKafkaBrokersDownReason): void {\n if (this.getConnectedBrokerCount() !== 0) {\n return;\n }\n this.sessionLikelyStale = true;\n if (this.stream) {\n this.logger.warn(\n '[configureBrokerEvents] All brokers %s, destroying stream to trigger reconnect',\n reason,\n );\n this.destroyDeadStream();\n }\n }\n\n protected destroyDeadStream(): void {\n this.stream?.destroy(getError({ message: '[destroyDeadStream] All brokers disconnected' }));\n this.stream = null;\n }\n\n protected async closeStream(): Promise<void> {\n const stream = this.stream;\n this.stream = null;\n this.consumeStartOptions = null;\n\n try {\n await stream?.close();\n } catch (error) {\n this.logger.warn('[closeStream] Error closing stream: %s', toError(error).message);\n }\n\n await this.consumeLoop;\n this.consumeLoop = null;\n }\n\n protected override unconfigureBrokerEvents(): void {\n super.unconfigureBrokerEvents();\n this.client.removeAllListeners(KafkaClientEvents.CONSUMER_GROUP_JOIN);\n this.client.removeAllListeners(KafkaClientEvents.CONSUMER_GROUP_LEAVE);\n this.client.removeAllListeners(KafkaClientEvents.CONSUMER_GROUP_REBALANCE);\n this.client.removeAllListeners(KafkaClientEvents.CONSUMER_HEARTBEAT_ERROR);\n this.client.removeAllListeners(KafkaClientEvents.CONSUMER_LAG);\n this.client.removeAllListeners(KafkaClientEvents.CONSUMER_LAG_ERROR);\n }\n\n protected override configureBrokerEvents(): void {\n super.configureBrokerEvents();\n\n this.client.on(KafkaClientEvents.BROKER_DISCONNECT, () => {\n this.handleAllBrokersDown(KafkaBrokersDownReasons.DISCONNECTED);\n });\n this.client.on(KafkaClientEvents.BROKER_FAILED, () => {\n this.handleAllBrokersDown(KafkaBrokersDownReasons.FAILED);\n });\n\n this.client.on(KafkaClientEvents.CONSUMER_GROUP_JOIN, (payload: ConsumerGroupJoinPayload) => {\n this.logger.info(\n '[configureConsumerEvents] Group JOINED | GroupId: %s | MemberId: %s | GenerationId: %d',\n payload.groupId,\n payload.memberId,\n payload.generationId,\n );\n invokeHook({\n logger: this.logger,\n scope: 'configureBrokerEvents',\n execution: () =>\n this.onGroupJoin?.({\n groupId: payload.groupId,\n memberId: payload.memberId,\n generationId: payload.generationId,\n }),\n });\n });\n\n this.client.on(KafkaClientEvents.CONSUMER_GROUP_LEAVE, (payload: ConsumerGroupLeavePayload) => {\n this.logger.info(\n '[configureConsumerEvents] Group LEFT | GroupId: %s | MemberId: %s',\n payload.groupId,\n payload.memberId,\n );\n invokeHook({\n logger: this.logger,\n scope: 'configureBrokerEvents',\n execution: () =>\n this.onGroupLeave?.({\n groupId: payload.groupId,\n memberId: payload.memberId,\n }),\n });\n });\n\n this.client.on(\n KafkaClientEvents.CONSUMER_GROUP_REBALANCE,\n (payload: ConsumerGroupRebalancePayload) => {\n this.logger.info(\n '[configureConsumerEvents] Group REBALANCE | GroupId: %s',\n payload.groupId,\n );\n invokeHook({\n logger: this.logger,\n scope: 'configureBrokerEvents',\n execution: () => this.onGroupRebalance?.({ groupId: payload.groupId }),\n });\n },\n );\n\n this.client.on(\n KafkaClientEvents.CONSUMER_HEARTBEAT_ERROR,\n (payload: ConsumerHeartbeatErrorPayload) => {\n this.logger.error(\n '[configureConsumerEvents] Heartbeat ERROR | GroupId: %s | MemberId: %s | Error: %s',\n payload.groupId,\n payload.memberId,\n payload.error,\n );\n invokeHook({\n logger: this.logger,\n scope: 'configureBrokerEvents',\n execution: () =>\n this.onHeartbeatError?.({\n error: payload.error,\n groupId: payload.groupId,\n memberId: payload.memberId,\n }),\n });\n },\n );\n\n this.client.on(KafkaClientEvents.CONSUMER_LAG, (lag: Offsets) => {\n invokeHook({\n logger: this.logger,\n scope: 'configureBrokerEvents',\n execution: () => this.onLag?.({ lag }),\n });\n });\n\n this.client.on(KafkaClientEvents.CONSUMER_LAG_ERROR, (error: Error) => {\n this.logger.error('[configureConsumerEvents] Lag monitoring ERROR: %s', error);\n invokeHook({\n logger: this.logger,\n scope: 'configureBrokerEvents',\n execution: () => this.onLagError?.({ error }),\n });\n });\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"abstract.helper.d.ts","sourceRoot":"","sources":["../../../../../src/modules/secrets/base/abstract.helper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,KAAK,EACV,MAAM,EACN,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAEhB,cAAc,EACd,qBAAqB,EACrB,aAAa,EACb,sBAAsB,EAEvB,MAAM,WAAW,CAAC;AAOnB,UAAU,eAAe;IACvB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,KAAK,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,OAAO,CAAA;KAAE,CAAC;CACrE;AAoBD,8BAAsB,qBAAsB,SAAQ,UAAW,YAAW,cAAc;IACtF,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACjC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IACzC,SAAS,CAAC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IAC3C,SAAS,CAAC,QAAQ,CAAC,gB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W7D,KAAK,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,YAAY,CAAC;IAoBvE,QAAQ,CAAC,OAAO,EAAE,sBAAsB,GAAG,IAAI;IAI/C,iBAAiB,CAAC,IAAI,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,gBAAgB,CAAA;KAAE,GAAG,IAAI;IAMlE,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IA4B/B,OAAO,CAAC,UAAU;IAOlB,OAAO,CAAC,iBAAiB;IASzB,OAAO,CAAC,YAAY;IAOpB,OAAO,CAAC,QAAQ;IAehB,OAAO,CAAC,eAAe;IAYvB,OAAO,CAAC,oBAAoB;YAWd,aAAa;YA6Cb,MAAM;YAoBN,gBAAgB;CAkB/B"}
@@ -57,7 +57,11 @@ export class AbstractSecretsHelper extends BaseHelper {
57
57
  }
58
58
  async get(opts) {
59
59
  const bundle = await this.getBundle({ path: opts.path });
60
- const raw = opts.key ? bundle[opts.key] : bundle;
60
+ const raw = opts.key
61
+ ? Object.hasOwn(bundle, opts.key)
62
+ ? bundle[opts.key]
63
+ : undefined
64
+ : bundle;
61
65
  return (raw ?? opts.defaultValue);
62
66
  }
63
67
  async lease(opts) {
@@ -1 +1 @@
1
- {"version":3,"file":"abstract.helper.js","sourceRoot":"","sources":["../../../../../src/modules/secrets/base/abstract.helper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAwB3C,MAAM,aAAa,GAAW,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;AACxD,MAAM,cAAc,GAAkB;IACpC,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,E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/modules/error';\nimport type {\n IClock,\n IGetSecretOptions,\n ISecretLease,\n ISecretRotatable,\n ISecretRotationEvent,\n ISecretsHelper,\n ISecretsHelperOptions,\n ITimerAdapter,\n TSecretRotationHandler,\n TTimerHandle,\n} from '../common';\n\ninterface ICacheEntry {\n value: Record<string, string>;\n expiresAt: number;\n}\n\ninterface IRawFetchResult {\n value: Record<string, string>;\n lease?: { leaseId: string; ttlSeconds: number; renewable: boolean };\n}\n\nconst DEFAULT_CLOCK: IClock = { now: () => Date.now() };\nconst DEFAULT_TIMERS: ITimerAdapter = {\n set: (handler, ms) => setTimeout(handler, ms),\n clear: (handle) => clearTimeout(handle as AnyType),\n};\n\nconst DEFAULT_CACHE_TTL_SECONDS = 300;\nconst DEFAULT_RENEW_BEFORE_RATIO = 0.66;\n\n// setTimeout coerces any delay above this to 1ms, triggering an immediate renewal storm.\nconst TIMEOUT_MAX_MS = 2_147_483_647;\n// Floor so an invalid/tiny ttl never becomes a 0ms busy-loop.\nconst MIN_RENEW_DELAY_MS = 1_000;\n// Bounded exponential backoff for the renewal retry loop when Vault is unreachable.\nconst BACKOFF_BASE_MS = 1_000;\n// Capped at 31 to keep 2 ** (attempt - 1) inside double range: past ~1024 it overflows to Infinity and clampDelayMs's non-finite branch returns the FLOOR, collapsing a long backoff into a 1/sec retry storm.\nconst MAX_BACKOFF_ATTEMPT_EXPONENT = 31;\n\nexport abstract class AbstractSecretsHelper extends BaseHelper implements ISecretsHelper {\n protected readonly clock: IClock;\n protected readonly timers: ITimerAdapter;\n protected readonly cacheTtlSeconds: number;\n protected readonly renewBeforeRatio: number;\n\n private readonly cache = new Map<string, ICacheEntry>();\n private readonly leases = new Map<string, ISecretLease>();\n private readonly leasePaths = new Map<string, string>();\n private readonly timerHandles = new Map<string, TTimerHandle>();\n private readonly rotatables = new Map<string, ISecretRotatable[]>();\n private readonly rotateHandlers: TSecretRotationHandler[] = [];\n private readonly backoffAttempts = new Map<string, number>();\n private closed = false;\n\n constructor(opts: ISecretsHelperOptions) {\n super({ scope: opts.scope, identifier: opts.identifier });\n this.clock = opts.clock ?? DEFAULT_CLOCK;\n this.timers = opts.timers ?? DEFAULT_TIMERS;\n this.cacheTtlSeconds = opts.cacheTtlSeconds ?? DEFAULT_CACHE_TTL_SECONDS;\n\n const ratio = opts.renewBeforeRatio ?? DEFAULT_RENEW_BEFORE_RATIO;\n if (!Number.isFinite(ratio) || ratio <= 0 || ratio > 1) {\n throw getError({\n message: `[constructor] renewBeforeRatio must be within (0, 1] | received: ${ratio}`,\n });\n }\n this.renewBeforeRatio = ratio;\n }\n\n protected abstract fetchRaw(opts: { path: string }): Promise<IRawFetchResult>;\n protected abstract renewRaw(opts: {\n leaseId: string;\n ttlSeconds: number;\n }): Promise<{ ttlSeconds: number } | null>;\n protected abstract revokeRaw(opts: { leaseId: string }): Promise<void>;\n\n // Concrete providers override to authenticate; default is a no-op.\n async configure(): Promise<void> {\n return;\n }\n\n async getBundle(opts: { path: string }): Promise<Record<string, string>> {\n this.evictExpiredCache();\n const cached = this.cache.get(opts.path);\n if (cached && cached.expiresAt > this.clock.now()) {\n return cached.value;\n }\n const fresh = await this.fetchRaw({ path: opts.path });\n // A shutdown that ran while fetchRaw was in flight already cleared `cache` - honor that and hand back the fetched value uncached rather than resurrecting a map shutdown just emptied.\n if (this.closed) {\n return fresh.value;\n }\n this.writeCache({ path: opts.path, value: fresh.value });\n return fresh.value;\n }\n\n async get(opts: IGetSecretOptions<string>): Promise<string>;\n async get<TValue>(opts: IGetSecretOptions<TValue>): Promise<TValue>;\n async get<TValue = string>(opts: IGetSecretOptions<TValue>): Promise<TValue> {\n const bundle = await this.getBundle({ path: opts.path });\n const raw = opts.key ? bundle[opts.key] : (bundle as AnyType);\n return (raw ?? opts.defaultValue) as TValue;\n }\n\n async lease(opts: { path: string; key: string }): Promise<ISecretLease> {\n const fresh = await this.fetchRaw({ path: opts.path });\n // A shutdown that ran while fetchRaw was in flight already revoked/cleared every lease - committing this one now would resurrect leases/leasePaths with a lease no live provider will ever renew or revoke, so surface the shutdown instead of silently leaking it back in.\n if (this.closed) {\n throw getError({\n message: `[lease] Provider is shut down | path: ${opts.path} | key: ${opts.key}`,\n });\n }\n if (!fresh.lease) {\n throw getError({\n message: `[lease] Path returned no lease | path: ${opts.path} | key: ${opts.key}`,\n });\n }\n const lease: ISecretLease = { value: fresh.value, ...fresh.lease };\n this.leases.set(opts.key, lease);\n this.leasePaths.set(opts.key, opts.path);\n this.scheduleRenewal({ key: opts.key, lease });\n return lease;\n }\n\n onRotate(handler: TSecretRotationHandler): void {\n this.rotateHandlers.push(handler);\n }\n\n registerRotatable(opts: { key: string; target: ISecretRotatable }): void {\n const list = this.rotatables.get(opts.key) ?? [];\n list.push(opts.target);\n this.rotatables.set(opts.key, list);\n }\n\n async shutdown(): Promise<void> {\n const logger = this.logger.for(this.shutdown.name);\n this.closed = true;\n\n const timerHandlesValues = this.timerHandles.values();\n for (const handle of timerHandlesValues) {\n this.timers.clear(handle);\n }\n this.timerHandles.clear();\n this.backoffAttempts.clear();\n\n for (const [key, lease] of this.leases) {\n try {\n await this.revokeRaw({ leaseId: lease.leaseId });\n } catch (error) {\n logger.error(\n 'Revoke failed | key: %s | leaseId: %s | error: %s',\n key,\n lease.leaseId,\n error,\n );\n }\n }\n this.leases.clear();\n this.leasePaths.clear();\n this.cache.clear();\n }\n\n private writeCache(opts: { path: string; value: Record<string, string> }): void {\n this.cache.set(opts.path, {\n value: opts.value,\n expiresAt: this.clock.now() + this.cacheTtlSeconds * 1000,\n });\n }\n\n private evictExpiredCache(): void {\n const now = this.clock.now();\n for (const [path, entry] of this.cache) {\n if (entry.expiresAt <= now) {\n this.cache.delete(path);\n }\n }\n }\n\n private clampDelayMs(opts: { delayMs: number }): number {\n if (!Number.isFinite(opts.delayMs) || opts.delayMs <= 0) {\n return MIN_RENEW_DELAY_MS;\n }\n return Math.min(Math.max(opts.delayMs, MIN_RENEW_DELAY_MS), TIMEOUT_MAX_MS);\n }\n\n private armTimer(opts: { key: string; delayMs: number }): void {\n const existing = this.timerHandles.get(opts.key);\n if (existing) {\n this.timers.clear(existing);\n }\n const handle = this.timers.set(() => {\n this.handleRenewal({ key: opts.key }).catch((error) => {\n this.logger\n .for(this.armTimer.name)\n .error('Renewal handler crashed | key: %s | error: %s', opts.key, error);\n });\n }, opts.delayMs);\n this.timerHandles.set(opts.key, handle);\n }\n\n private scheduleRenewal(opts: { key: string; lease: ISecretLease }): void {\n if (this.closed) {\n return;\n }\n this.backoffAttempts.delete(opts.key);\n const delayMs = this.clampDelayMs({\n delayMs: opts.lease.ttlSeconds * this.renewBeforeRatio * 1000,\n });\n this.armTimer({ key: opts.key, delayMs });\n }\n\n // A transient Vault failure must not kill the loop; retry with bounded exponential backoff.\n private scheduleBackoffRetry(opts: { key: string }): void {\n if (this.closed) {\n return;\n }\n const attempt = (this.backoffAttempts.get(opts.key) ?? 0) + 1;\n this.backoffAttempts.set(opts.key, attempt);\n const cappedAttempt = Math.min(attempt, MAX_BACKOFF_ATTEMPT_EXPONENT);\n const delayMs = this.clampDelayMs({ delayMs: BACKOFF_BASE_MS * 2 ** (cappedAttempt - 1) });\n this.armTimer({ key: opts.key, delayMs });\n }\n\n private async handleRenewal(opts: { key: string }): Promise<void> {\n if (this.closed) {\n return;\n }\n const logger = this.logger.for(this.handleRenewal.name);\n const lease = this.leases.get(opts.key);\n if (!lease) {\n logger.debug('No lease to renew | key: %s', opts.key);\n return;\n }\n try {\n if (!lease.renewable) {\n await this.rotate({ key: opts.key });\n return;\n }\n\n const renewed = await this.renewRaw({\n leaseId: lease.leaseId,\n ttlSeconds: lease.ttlSeconds,\n });\n if (this.closed) {\n return;\n }\n\n if (!renewed) {\n await this.rotate({ key: opts.key });\n return;\n }\n\n const next: ISecretLease = { ...lease, ttlSeconds: renewed.ttlSeconds };\n this.leases.set(opts.key, next);\n this.scheduleRenewal({ key: opts.key, lease: next });\n } catch (error) {\n if (this.closed) {\n return;\n }\n logger.error(\n 'Renewal cycle failed; scheduling backoff retry | key: %s | error: %s',\n opts.key,\n error,\n );\n this.scheduleBackoffRetry({ key: opts.key });\n }\n }\n\n private async rotate(opts: { key: string }): Promise<void> {\n const path = this.leasePaths.get(opts.key);\n if (!path) {\n throw getError({ message: `[rotate] No lease path registered | key: ${opts.key}` });\n }\n const fresh = await this.fetchRaw({ path });\n if (this.closed) {\n return;\n }\n if (!fresh.lease) {\n throw getError({ message: `[rotate] Path returned no lease on rotation | key: ${opts.key}` });\n }\n const lease: ISecretLease = { value: fresh.value, ...fresh.lease };\n this.leases.set(opts.key, lease);\n this.writeCache({ path, value: fresh.value });\n // Arm the next renewal BEFORE dispatching: a wedged consumer must not stall the loop.\n this.scheduleRenewal({ key: opts.key, lease });\n await this.dispatchRotation({ key: opts.key, lease });\n }\n\n private async dispatchRotation(event: ISecretRotationEvent): Promise<void> {\n const logger = this.logger.for(this.dispatchRotation.name);\n for (const handler of this.rotateHandlers) {\n try {\n await handler(event);\n } catch (error) {\n logger.error('onRotate handler failed | key: %s | error: %s', event.key, error);\n }\n }\n const targets = this.rotatables.get(event.key) ?? [];\n for (const target of targets) {\n try {\n await target.onSecretRotated({ key: event.key, secret: event.lease.value });\n } catch (error) {\n logger.error('Rotatable failed | key: %s | error: %s', event.key, error);\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"abstract.helper.js","sourceRoot":"","sources":["../../../../../src/modules/secrets/base/abstract.helper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAwB3C,MAAM,aAAa,GAAW,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;AACxD,MAAM,cAAc,GAAkB;IACpC,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC;IAC7C,KAAK,EAAE,CAA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esContent":["import type { AnyType } from '@/common/types';\nimport { BaseHelper } from '@/modules/base';\nimport { getError } from '@/modules/error';\nimport type {\n IClock,\n IGetSecretOptions,\n ISecretLease,\n ISecretRotatable,\n ISecretRotationEvent,\n ISecretsHelper,\n ISecretsHelperOptions,\n ITimerAdapter,\n TSecretRotationHandler,\n TTimerHandle,\n} from '../common';\n\ninterface ICacheEntry {\n value: Record<string, string>;\n expiresAt: number;\n}\n\ninterface IRawFetchResult {\n value: Record<string, string>;\n lease?: { leaseId: string; ttlSeconds: number; renewable: boolean };\n}\n\nconst DEFAULT_CLOCK: IClock = { now: () => Date.now() };\nconst DEFAULT_TIMERS: ITimerAdapter = {\n set: (handler, ms) => setTimeout(handler, ms),\n clear: (handle) => clearTimeout(handle as AnyType),\n};\n\nconst DEFAULT_CACHE_TTL_SECONDS = 300;\nconst DEFAULT_RENEW_BEFORE_RATIO = 0.66;\n\n// setTimeout coerces any delay above this to 1ms, triggering an immediate renewal storm.\nconst TIMEOUT_MAX_MS = 2_147_483_647;\n// Floor so an invalid/tiny ttl never becomes a 0ms busy-loop.\nconst MIN_RENEW_DELAY_MS = 1_000;\n// Bounded exponential backoff for the renewal retry loop when Vault is unreachable.\nconst BACKOFF_BASE_MS = 1_000;\n// Capped at 31 to keep 2 ** (attempt - 1) inside double range: past ~1024 it overflows to Infinity and clampDelayMs's non-finite branch returns the FLOOR, collapsing a long backoff into a 1/sec retry storm.\nconst MAX_BACKOFF_ATTEMPT_EXPONENT = 31;\n\nexport abstract class AbstractSecretsHelper extends BaseHelper implements ISecretsHelper {\n protected readonly clock: IClock;\n protected readonly timers: ITimerAdapter;\n protected readonly cacheTtlSeconds: number;\n protected readonly renewBeforeRatio: number;\n\n private readonly cache = new Map<string, ICacheEntry>();\n private readonly leases = new Map<string, ISecretLease>();\n private readonly leasePaths = new Map<string, string>();\n private readonly timerHandles = new Map<string, TTimerHandle>();\n private readonly rotatables = new Map<string, ISecretRotatable[]>();\n private readonly rotateHandlers: TSecretRotationHandler[] = [];\n private readonly backoffAttempts = new Map<string, number>();\n private closed = false;\n\n constructor(opts: ISecretsHelperOptions) {\n super({ scope: opts.scope, identifier: opts.identifier });\n this.clock = opts.clock ?? DEFAULT_CLOCK;\n this.timers = opts.timers ?? DEFAULT_TIMERS;\n this.cacheTtlSeconds = opts.cacheTtlSeconds ?? DEFAULT_CACHE_TTL_SECONDS;\n\n const ratio = opts.renewBeforeRatio ?? DEFAULT_RENEW_BEFORE_RATIO;\n if (!Number.isFinite(ratio) || ratio <= 0 || ratio > 1) {\n throw getError({\n message: `[constructor] renewBeforeRatio must be within (0, 1] | received: ${ratio}`,\n });\n }\n this.renewBeforeRatio = ratio;\n }\n\n protected abstract fetchRaw(opts: { path: string }): Promise<IRawFetchResult>;\n protected abstract renewRaw(opts: {\n leaseId: string;\n ttlSeconds: number;\n }): Promise<{ ttlSeconds: number } | null>;\n protected abstract revokeRaw(opts: { leaseId: string }): Promise<void>;\n\n // Concrete providers override to authenticate; default is a no-op.\n async configure(): Promise<void> {\n return;\n }\n\n async getBundle(opts: { path: string }): Promise<Record<string, string>> {\n this.evictExpiredCache();\n const cached = this.cache.get(opts.path);\n if (cached && cached.expiresAt > this.clock.now()) {\n return cached.value;\n }\n const fresh = await this.fetchRaw({ path: opts.path });\n // A shutdown that ran while fetchRaw was in flight already cleared `cache` - honor that and hand back the fetched value uncached rather than resurrecting a map shutdown just emptied.\n if (this.closed) {\n return fresh.value;\n }\n this.writeCache({ path: opts.path, value: fresh.value });\n return fresh.value;\n }\n\n async get(opts: IGetSecretOptions<string>): Promise<string>;\n async get<TValue>(opts: IGetSecretOptions<TValue>): Promise<TValue>;\n async get<TValue = string>(opts: IGetSecretOptions<TValue>): Promise<TValue> {\n const bundle = await this.getBundle({ path: opts.path });\n const raw = opts.key\n ? Object.hasOwn(bundle, opts.key)\n ? bundle[opts.key]\n : undefined\n : (bundle as AnyType);\n return (raw ?? opts.defaultValue) as TValue;\n }\n\n async lease(opts: { path: string; key: string }): Promise<ISecretLease> {\n const fresh = await this.fetchRaw({ path: opts.path });\n // A shutdown that ran while fetchRaw was in flight already revoked/cleared every lease - committing this one now would resurrect leases/leasePaths with a lease no live provider will ever renew or revoke, so surface the shutdown instead of silently leaking it back in.\n if (this.closed) {\n throw getError({\n message: `[lease] Provider is shut down | path: ${opts.path} | key: ${opts.key}`,\n });\n }\n if (!fresh.lease) {\n throw getError({\n message: `[lease] Path returned no lease | path: ${opts.path} | key: ${opts.key}`,\n });\n }\n const lease: ISecretLease = { value: fresh.value, ...fresh.lease };\n this.leases.set(opts.key, lease);\n this.leasePaths.set(opts.key, opts.path);\n this.scheduleRenewal({ key: opts.key, lease });\n return lease;\n }\n\n onRotate(handler: TSecretRotationHandler): void {\n this.rotateHandlers.push(handler);\n }\n\n registerRotatable(opts: { key: string; target: ISecretRotatable }): void {\n const list = this.rotatables.get(opts.key) ?? [];\n list.push(opts.target);\n this.rotatables.set(opts.key, list);\n }\n\n async shutdown(): Promise<void> {\n const logger = this.logger.for(this.shutdown.name);\n this.closed = true;\n\n const timerHandlesValues = this.timerHandles.values();\n for (const handle of timerHandlesValues) {\n this.timers.clear(handle);\n }\n this.timerHandles.clear();\n this.backoffAttempts.clear();\n\n for (const [key, lease] of this.leases) {\n try {\n await this.revokeRaw({ leaseId: lease.leaseId });\n } catch (error) {\n logger.error(\n 'Revoke failed | key: %s | leaseId: %s | error: %s',\n key,\n lease.leaseId,\n error,\n );\n }\n }\n this.leases.clear();\n this.leasePaths.clear();\n this.cache.clear();\n }\n\n private writeCache(opts: { path: string; value: Record<string, string> }): void {\n this.cache.set(opts.path, {\n value: opts.value,\n expiresAt: this.clock.now() + this.cacheTtlSeconds * 1000,\n });\n }\n\n private evictExpiredCache(): void {\n const now = this.clock.now();\n for (const [path, entry] of this.cache) {\n if (entry.expiresAt <= now) {\n this.cache.delete(path);\n }\n }\n }\n\n private clampDelayMs(opts: { delayMs: number }): number {\n if (!Number.isFinite(opts.delayMs) || opts.delayMs <= 0) {\n return MIN_RENEW_DELAY_MS;\n }\n return Math.min(Math.max(opts.delayMs, MIN_RENEW_DELAY_MS), TIMEOUT_MAX_MS);\n }\n\n private armTimer(opts: { key: string; delayMs: number }): void {\n const existing = this.timerHandles.get(opts.key);\n if (existing) {\n this.timers.clear(existing);\n }\n const handle = this.timers.set(() => {\n this.handleRenewal({ key: opts.key }).catch((error) => {\n this.logger\n .for(this.armTimer.name)\n .error('Renewal handler crashed | key: %s | error: %s', opts.key, error);\n });\n }, opts.delayMs);\n this.timerHandles.set(opts.key, handle);\n }\n\n private scheduleRenewal(opts: { key: string; lease: ISecretLease }): void {\n if (this.closed) {\n return;\n }\n this.backoffAttempts.delete(opts.key);\n const delayMs = this.clampDelayMs({\n delayMs: opts.lease.ttlSeconds * this.renewBeforeRatio * 1000,\n });\n this.armTimer({ key: opts.key, delayMs });\n }\n\n // A transient Vault failure must not kill the loop; retry with bounded exponential backoff.\n private scheduleBackoffRetry(opts: { key: string }): void {\n if (this.closed) {\n return;\n }\n const attempt = (this.backoffAttempts.get(opts.key) ?? 0) + 1;\n this.backoffAttempts.set(opts.key, attempt);\n const cappedAttempt = Math.min(attempt, MAX_BACKOFF_ATTEMPT_EXPONENT);\n const delayMs = this.clampDelayMs({ delayMs: BACKOFF_BASE_MS * 2 ** (cappedAttempt - 1) });\n this.armTimer({ key: opts.key, delayMs });\n }\n\n private async handleRenewal(opts: { key: string }): Promise<void> {\n if (this.closed) {\n return;\n }\n const logger = this.logger.for(this.handleRenewal.name);\n const lease = this.leases.get(opts.key);\n if (!lease) {\n logger.debug('No lease to renew | key: %s', opts.key);\n return;\n }\n try {\n if (!lease.renewable) {\n await this.rotate({ key: opts.key });\n return;\n }\n\n const renewed = await this.renewRaw({\n leaseId: lease.leaseId,\n ttlSeconds: lease.ttlSeconds,\n });\n if (this.closed) {\n return;\n }\n\n if (!renewed) {\n await this.rotate({ key: opts.key });\n return;\n }\n\n const next: ISecretLease = { ...lease, ttlSeconds: renewed.ttlSeconds };\n this.leases.set(opts.key, next);\n this.scheduleRenewal({ key: opts.key, lease: next });\n } catch (error) {\n if (this.closed) {\n return;\n }\n logger.error(\n 'Renewal cycle failed; scheduling backoff retry | key: %s | error: %s',\n opts.key,\n error,\n );\n this.scheduleBackoffRetry({ key: opts.key });\n }\n }\n\n private async rotate(opts: { key: string }): Promise<void> {\n const path = this.leasePaths.get(opts.key);\n if (!path) {\n throw getError({ message: `[rotate] No lease path registered | key: ${opts.key}` });\n }\n const fresh = await this.fetchRaw({ path });\n if (this.closed) {\n return;\n }\n if (!fresh.lease) {\n throw getError({ message: `[rotate] Path returned no lease on rotation | key: ${opts.key}` });\n }\n const lease: ISecretLease = { value: fresh.value, ...fresh.lease };\n this.leases.set(opts.key, lease);\n this.writeCache({ path, value: fresh.value });\n // Arm the next renewal BEFORE dispatching: a wedged consumer must not stall the loop.\n this.scheduleRenewal({ key: opts.key, lease });\n await this.dispatchRotation({ key: opts.key, lease });\n }\n\n private async dispatchRotation(event: ISecretRotationEvent): Promise<void> {\n const logger = this.logger.for(this.dispatchRotation.name);\n for (const handler of this.rotateHandlers) {\n try {\n await handler(event);\n } catch (error) {\n logger.error('onRotate handler failed | key: %s | error: %s', event.key, error);\n }\n }\n const targets = this.rotatables.get(event.key) ?? [];\n for (const target of targets) {\n try {\n await target.onSecretRotated({ key: event.key, secret: event.lease.value });\n } catch (error) {\n logger.error('Rotatable failed | key: %s | error: %s', event.key, error);\n }\n }\n }\n}\n"]}
@@ -40,4 +40,25 @@ export declare class TemporalInclusivities {
40
40
  static isValid(input: string): input is TTemporalInclusivity;
41
41
  }
42
42
  export type TTemporalInclusivity = TConstValue<typeof TemporalInclusivities>;
43
+ /** How long a month or weekday name is written: NARROW (`M`), SHORT (`Mon`) or LONG (`Monday`). */
44
+ export declare class TemporalNameWidths {
45
+ static readonly NARROW = "narrow";
46
+ static readonly SHORT = "short";
47
+ static readonly LONG = "long";
48
+ static readonly SCHEME_SET: Set<string>;
49
+ static isValid(value: string): boolean;
50
+ }
51
+ /** Valid name width values. */
52
+ export type TTemporalNameWidth = TConstValue<typeof TemporalNameWidths>;
53
+ /** A month name has no narrow form here: SHORT or LONG. */
54
+ export type TTemporalMonthNameWidth = Exclude<TTemporalNameWidth, typeof TemporalNameWidths.NARROW>;
55
+ /** How `writtenDate` writes a date: NUMERIC is `10/14/2026`, LONG is `October 14, 2026`. */
56
+ export declare class TemporalWrittenDateStyles {
57
+ static readonly NUMERIC = "numeric";
58
+ static readonly LONG = "long";
59
+ static readonly SCHEME_SET: Set<string>;
60
+ static isValid(value: string): boolean;
61
+ }
62
+ /** Valid written date style values. */
63
+ export type TTemporalWrittenDateStyle = TConstValue<typeof TemporalWrittenDateStyles>;
43
64
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/modules/temporal/common/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,kLAAkL;AAClL,qBAAa,aAAa;IACxB,MAAM,CAAC,QAAQ,CAAC,WAAW,iBAAiB;IAC5C,MAAM,CAAC,QAAQ,CAAC,MAAM,YAAY;IAClC,MAAM,CAAC,QAAQ,CAAC,MAAM,YAAY;IAClC,MAAM,CAAC,QAAQ,CAAC,IAAI,UAAU;IAC9B,MAAM,CAAC,QAAQ,CAAC,GAAG,SAAS;IAC5B,MAAM,CAAC,QAAQ,CAAC,IAAI,UAAU;IAC9B,MAAM,CAAC,QAAQ,CAAC,KAAK,WAAW;IAChC,MAAM,CAAC,QAAQ,CAAC,OAAO,aAAa;IACpC,MAAM,CAAC,QAAQ,CAAC,IAAI,UAAU;IAE9B,MAAM,CAAC,QAAQ,CAAC,UAAU,cAUvB;IAEH,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,aAAa;CAGtD;AAED,MAAM,MAAM,aAAa,GAAG,WAAW,CAAC,OAAO,aAAa,CAAC,CAA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ACjC,MAAM,CAAC,QAAQ,CAAC,UAAU,QAAQ;IAClC,MAAM,CAAC,QAAQ,CAAC,QAAQ,QAAQ;IAEhC,MAAM,CAAC,QAAQ,CAAC,UAAU,cAKvB;IAEH,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,oBAAoB;CAG7D;AAED,MAAM,MAAM,oBAAoB,GAAG,WAAW,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAE7E,mGAAmG;AACnG,qBAAa,kBAAkB;IAC7B,MAAM,CAAC,QAAQ,CAAC,MAAM,YAAY;IAClC,MAAM,CAAC,QAAQ,CAAC,KAAK,WAAW;IAChC,MAAM,CAAC,QAAQ,CAAC,IAAI,UAAU;IAE9B,MAAM,CAAC,QAAQ,CAAC,UAAU,cAAyD;IAEnF,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;CAGvC;AAED,+BAA+B;AAC/B,MAAM,MAAM,kBAAkB,GAAG,WAAW,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAExE,2DAA2D;AAC3D,MAAM,MAAM,uBAAuB,GAAG,OAAO,CAAC,kBAAkB,EAAE,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAC;AAEpG,4FAA4F;AAC5F,qBAAa,yBAAyB;IACpC,MAAM,CAAC,QAAQ,CAAC,OAAO,aAAa;IACpC,MAAM,CAAC,QAAQ,CAAC,IAAI,UAAU;IAE9B,MAAM,CAAC,QAAQ,CAAC,UAAU,cAA8C;IAExE,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;CAGvC;AAED,uCAAuC;AACvC,MAAM,MAAM,yBAAyB,GAAG,WAAW,CAAC,OAAO,yBAAyB,CAAC,CAAC"}
@@ -57,4 +57,23 @@ export class TemporalInclusivities {
57
57
  return this.SCHEME_SET.has(input);
58
58
  }
59
59
  }
60
+ /** How long a month or weekday name is written: NARROW (`M`), SHORT (`Mon`) or LONG (`Monday`). */
61
+ export class TemporalNameWidths {
62
+ static { this.NARROW = 'narrow'; }
63
+ static { this.SHORT = 'short'; }
64
+ static { this.LONG = 'long'; }
65
+ static { this.SCHEME_SET = new Set([this.NARROW, this.SHORT, this.LONG]); }
66
+ static isValid(value) {
67
+ return this.SCHEME_SET.has(value);
68
+ }
69
+ }
70
+ /** How `writtenDate` writes a date: NUMERIC is `10/14/2026`, LONG is `October 14, 2026`. */
71
+ export class TemporalWrittenDateStyles {
72
+ static { this.NUMERIC = 'numeric'; }
73
+ static { this.LONG = 'long'; }
74
+ static { this.SCHEME_SET = new Set([this.NUMERIC, this.LONG]); }
75
+ static isValid(value) {
76
+ return this.SCHEME_SET.has(value);
77
+ }
78
+ }
60
79
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/modules/temporal/common/constants.ts"],"names":[],"mappings":"AAEA,kLAAkL;AAClL,MAAM,OAAO,aAAa;aACR,gBAAW,GAAG,aAAa,CAAC;aAC5B,WAAM,GAAG,QAAQ,CAAC;aAClB,WAAM,GAAG,QAAQ,CAAC;aAClB,SAAI,GAAG,MAAM,CAAC;aACd,QAAG,GAAG,KAAK,CAAC;aACZ,SAAI,GAAG,MAAM,CAAC;aACd,UAAK,GAAG,OAAO,CAAC;aAChB,YAAO,GAAG,SAAS,CAAC;aACpB,SAAI,GAAG,MAAM,CAAC;aAEd,eAAU,GAAG,IAAI,GAAG,CAAC;QACnC,IAAI,CAAC,WAAW;QAChB,IAAI,CAAC,MAAM;QACX,IAAI,CAAC,MAAM;QACX,IAAI,CAAC,IAAI;QACT,IAAI,CAAC,GAAG;QACR,IAAI,CAAC,IAAI;QACT,IAAI,CAAC,KAAK;QACV,IAAI,CAAC,OAAO;QACZ,IAAI,CAAC,IAAI;KACV,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;AAKH,2GAA2G;AAC3G,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAC;AAEzC,wGAAwG;AACxG,MAAM,CAAC,MAAM,wBAAwB,GAAG,0BAA0B,CAAC;AAEnE,2FAA2F;AAC3F,MAAM,CAAC,MAAM,uBAAuB,GAAG,OAAO,CAAC;AAE/C,uGAAuG;AACvG,MAAM,OAAO,sBAAsB;aACjB,YAAO,GAAG,SAAS,CAAC;aACpB,WAAM,GAAG,QAAQ,CAAC;aAClB,UAAK,GAAG,OAAO,CAAC;aAChB,SAAI,GAAG,MAAM,CAAC;aAEd,eAAU,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAEzF,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;AAKH,0FAA0F;AAC1F,MAAM,OAAO,qBAAqB;aAChB,cAAS,GAAG,IAAI,CAAC;aACjB,cAAS,GAAG,IAAI,CAAC;aACjB,eAAU,GAAG,IAAI,CAAC;aAClB,aAAQ,GAAG,IAAI,CAAC;aAEhB,eAAU,GAAG,IAAI,GAAG,CAAC;QACnC,IAAI,CAAC,SAAS;QACd,IAAI,CAAC,SAAS;QACd,IAAI,CAAC,UAAU;QACf,IAAI,CAAC,QAAQ;KACd,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC","sourcesContent":["import type { TConstValue } from '@/common/types';\n\n/** Units `add`, `subtract`, `startOf` and `endOf` accept. Weeks are ISO weeks - they start on Monday; a quarter is three calendar months from January, April, July or October. */\nexport class TemporalUnits {\n static readonly MILLISECOND = 'millisecond';\n static readonly SECOND = 'second';\n static readonly MINUTE = 'minute';\n static readonly HOUR = 'hour';\n static readonly DAY = 'day';\n static readonly WEEK = 'week';\n static readonly MONTH = 'month';\n static readonly QUARTER = 'quarter';\n static readonly YEAR = 'year';\n\n static readonly SCHEME_SET = new Set([\n this.MILLISECOND,\n this.SECOND,\n this.MINUTE,\n this.HOUR,\n this.DAY,\n this.WEEK,\n this.MONTH,\n this.QUARTER,\n this.YEAR,\n ]);\n\n static isValid(input: string): input is TTemporalUnit {\n return this.SCHEME_SET.has(input);\n }\n}\n\nexport type TTemporalUnit = TConstValue<typeof TemporalUnits>;\n\n/** A helper built without a `tz` computes in UTC - never in the host's zone, which differs per machine. */\nexport const DEFAULT_TEMPORAL_TZ = 'UTC';\n\n/** `format` with no pattern writes ISO 8601 with the zone's offset: `2026-09-19T12:00:00.000+07:00`. */\nexport const DEFAULT_TEMPORAL_PATTERN = 'YYYY-MM-DDTHH:mm:ss.SSSZ';\n\n/** The locale name tokens and `formatIntl` write in when a helper is built without one. */\nexport const DEFAULT_TEMPORAL_LOCALE = 'en-US';\n\n/** How `formatDuration` writes: `compact` is `1d1h30m`; the others are the locale's own unit words. */\nexport class TemporalDurationStyles {\n static readonly COMPACT = 'compact';\n static readonly NARROW = 'narrow';\n static readonly SHORT = 'short';\n static readonly LONG = 'long';\n\n static readonly SCHEME_SET = new Set([this.COMPACT, this.NARROW, this.SHORT, this.LONG]);\n\n static isValid(input: string): input is TTemporalDurationStyle {\n return this.SCHEME_SET.has(input);\n }\n}\n\nexport type TTemporalDurationStyle = TConstValue<typeof TemporalDurationStyles>;\n\n/** Which ends of the range `isBetween` counts: `[` includes an end, `(` leaves it out. */\nexport class TemporalInclusivities {\n static readonly EXCLUSIVE = '()';\n static readonly INCLUSIVE = '[]';\n static readonly START_ONLY = '[)';\n static readonly END_ONLY = '(]';\n\n static readonly SCHEME_SET = new Set([\n this.EXCLUSIVE,\n this.INCLUSIVE,\n this.START_ONLY,\n this.END_ONLY,\n ]);\n\n static isValid(input: string): input is TTemporalInclusivity {\n return this.SCHEME_SET.has(input);\n }\n}\n\nexport type TTemporalInclusivity = TConstValue<typeof TemporalInclusivities>;\n"]}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/modules/temporal/common/constants.ts"],"names":[],"mappings":"AAEA,kLAAkL;AAClL,MAAM,OAAO,aAAa;aACR,gBAAW,GAAG,aAAa,CAAC;aAC5B,WAAM,GAAG,QAAQ,CAAC;aAClB,WAAM,GAAG,QAAQ,CAAC;aAClB,SAAI,GAAG,MAAM,CAAC;aACd,QAAG,GAAG,KAAK,CAAC;aACZ,SAAI,GAAG,MAAM,CAAC;aACd,UAAK,GAAG,OAAO,CAAC;aAChB,YAAO,GAAG,SAAS,CAAC;aACpB,SAAI,GAAG,MAAM,CAAC;aAEd,eAAU,GAAG,IAAI,GAAG,CAAC;QACnC,IAAI,CAAC,WAAW;QAChB,IAAI,CAAC,MAAM;QACX,IAAI,CAAC,MAAM;QACX,IAAI,CAAC,IAAI;QACT,IAAI,CAAC,GAAG;QACR,IAAI,CAAC,IAAI;QACT,IAAI,CAAC,KAAK;QACV,IAAI,CAAC,OAAO;QACZ,IAAI,CAAC,IAAI;KACV,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;AAKH,2GAA2G;AAC3G,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAC;AAEzC,wGAAwG;AACxG,MAAM,CAAC,MAAM,wBAAwB,GAAG,0BAA0B,CAAC;AAEnE,2FAA2F;AAC3F,MAAM,CAAC,MAAM,uBAAuB,GAAG,OAAO,CAAC;AAE/C,uGAAuG;AACvG,MAAM,OAAO,sBAAsB;aACjB,YAAO,GAAG,SAAS,CAAC;aACpB,WAAM,GAAG,QAAQ,CAAC;aAClB,UAAK,GAAG,OAAO,CAAC;aAChB,S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CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAExE,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC","sourcesContent":["import type { TConstValue } from '@/common/types';\n\n/** Units `add`, `subtract`, `startOf` and `endOf` accept. Weeks are ISO weeks - they start on Monday; a quarter is three calendar months from January, April, July or October. */\nexport class TemporalUnits {\n static readonly MILLISECOND = 'millisecond';\n static readonly SECOND = 'second';\n static readonly MINUTE = 'minute';\n static readonly HOUR = 'hour';\n static readonly DAY = 'day';\n static readonly WEEK = 'week';\n static readonly MONTH = 'month';\n static readonly QUARTER = 'quarter';\n static readonly YEAR = 'year';\n\n static readonly SCHEME_SET = new Set([\n this.MILLISECOND,\n this.SECOND,\n this.MINUTE,\n this.HOUR,\n this.DAY,\n this.WEEK,\n this.MONTH,\n this.QUARTER,\n this.YEAR,\n ]);\n\n static isValid(input: string): input is TTemporalUnit {\n return this.SCHEME_SET.has(input);\n }\n}\n\nexport type TTemporalUnit = TConstValue<typeof TemporalUnits>;\n\n/** A helper built without a `tz` computes in UTC - never in the host's zone, which differs per machine. */\nexport const DEFAULT_TEMPORAL_TZ = 'UTC';\n\n/** `format` with no pattern writes ISO 8601 with the zone's offset: `2026-09-19T12:00:00.000+07:00`. */\nexport const DEFAULT_TEMPORAL_PATTERN = 'YYYY-MM-DDTHH:mm:ss.SSSZ';\n\n/** The locale name tokens and `formatIntl` write in when a helper is built without one. */\nexport const DEFAULT_TEMPORAL_LOCALE = 'en-US';\n\n/** How `formatDuration` writes: `compact` is `1d1h30m`; the others are the locale's own unit words. */\nexport class TemporalDurationStyles {\n static readonly COMPACT = 'compact';\n static readonly NARROW = 'narrow';\n static readonly SHORT = 'short';\n static readonly LONG = 'long';\n\n static readonly SCHEME_SET = new Set([this.COMPACT, this.NARROW, this.SHORT, this.LONG]);\n\n static isValid(input: string): input is TTemporalDurationStyle {\n return this.SCHEME_SET.has(input);\n }\n}\n\nexport type TTemporalDurationStyle = TConstValue<typeof TemporalDurationStyles>;\n\n/** Which ends of the range `isBetween` counts: `[` includes an end, `(` leaves it out. */\nexport class TemporalInclusivities {\n static readonly EXCLUSIVE = '()';\n static readonly INCLUSIVE = '[]';\n static readonly START_ONLY = '[)';\n static readonly END_ONLY = '(]';\n\n static readonly SCHEME_SET = new Set([\n this.EXCLUSIVE,\n this.INCLUSIVE,\n this.START_ONLY,\n this.END_ONLY,\n ]);\n\n static isValid(input: string): input is TTemporalInclusivity {\n return this.SCHEME_SET.has(input);\n }\n}\n\nexport type TTemporalInclusivity = TConstValue<typeof TemporalInclusivities>;\n\n/** How long a month or weekday name is written: NARROW (`M`), SHORT (`Mon`) or LONG (`Monday`). */\nexport class TemporalNameWidths {\n static readonly NARROW = 'narrow';\n static readonly SHORT = 'short';\n static readonly LONG = 'long';\n\n static readonly SCHEME_SET = new Set<string>([this.NARROW, this.SHORT, this.LONG]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** Valid name width values. */\nexport type TTemporalNameWidth = TConstValue<typeof TemporalNameWidths>;\n\n/** A month name has no narrow form here: SHORT or LONG. */\nexport type TTemporalMonthNameWidth = Exclude<TTemporalNameWidth, typeof TemporalNameWidths.NARROW>;\n\n/** How `writtenDate` writes a date: NUMERIC is `10/14/2026`, LONG is `October 14, 2026`. */\nexport class TemporalWrittenDateStyles {\n static readonly NUMERIC = 'numeric';\n static readonly LONG = 'long';\n\n static readonly SCHEME_SET = new Set<string>([this.NUMERIC, this.LONG]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** Valid written date style values. */\nexport type TTemporalWrittenDateStyle = TConstValue<typeof TemporalWrittenDateStyles>;\n"]}