@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
@@ -74,11 +74,14 @@ export declare class DurationMultipliers {
74
74
  static readonly MONTH: number;
75
75
  static readonly YEAR: number;
76
76
  static readonly BY_UNIT: Record<string, number>;
77
+ /** The multiplier of a known unit, `null` for anything else - inherited property names included. */
78
+ private static multiplierOf;
77
79
  /**
78
80
  * `null` rather than a throw, so a caller that wants an error raises its own with its own context.
79
81
  * Every method here answers the same way.
80
82
  *
81
- * One map read, not a validity check followed by a read: an unknown unit is already `undefined`.
83
+ * The unit is checked against {@link DurationUnits.SCHEME_SET} first: a plain-object read alone
84
+ * would answer `'constructor'` or `'toString'` with a member of `Object.prototype`, not `undefined`.
82
85
  */
83
86
  static toMilliseconds(opts: IDuration | null): number | null;
84
87
  /** The inverse of {@link toMilliseconds}. Fractional on purpose - rounding here would silently lose a 36-hour window asked for in days. */
@@ -1 +1 @@
1
- {"version":3,"file":"duration.d.ts","sourceRoot":"","sources":["../../../../src/common/constants/duration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,qEAAqE;AACrE,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,IAAI,UAAU;IAE9B,MAAM,CAAC,QAAQ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AAA;KAAE,GAAG,MAAM,GAAG,IAAI;IAW9F,2JAA2J;IAC3J,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAqB7C,qGAAqG;IACrG,MAAM,CAAC,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;CAGzD"}
@@ -119,35 +119,40 @@ class DurationMultipliers {
119
119
  [DurationUnits.MONTH]: this.MONTH,
120
120
  [DurationUnits.YEAR]: this.YEAR,
121
121
  }; }
122
+ /** The multiplier of a known unit, `null` for anything else - inherited property names included. */
123
+ static multiplierOf(unit) {
124
+ return typeof unit === 'string' && DurationUnits.isValid(unit) ? this.BY_UNIT[unit] : null;
125
+ }
122
126
  /**
123
127
  * `null` rather than a throw, so a caller that wants an error raises its own with its own context.
124
128
  * Every method here answers the same way.
125
129
  *
126
- * One map read, not a validity check followed by a read: an unknown unit is already `undefined`.
130
+ * The unit is checked against {@link DurationUnits.SCHEME_SET} first: a plain-object read alone
131
+ * would answer `'constructor'` or `'toString'` with a member of `Object.prototype`, not `undefined`.
127
132
  */
128
133
  static toMilliseconds(opts) {
129
134
  if (!opts) {
130
135
  return null;
131
136
  }
132
- const multiplier = this.BY_UNIT[opts.unit];
133
- if (multiplier === undefined || !Number.isFinite(opts.value)) {
137
+ const multiplier = this.multiplierOf(opts.unit);
138
+ if (multiplier === null || !Number.isFinite(opts.value)) {
134
139
  return null;
135
140
  }
136
141
  return Math.round(opts.value * multiplier);
137
142
  }
138
143
  /** The inverse of {@link toMilliseconds}. Fractional on purpose - rounding here would silently lose a 36-hour window asked for in days. */
139
144
  static fromMilliseconds(opts) {
140
- const multiplier = this.BY_UNIT[opts?.unit];
141
- if (multiplier === undefined || !Number.isFinite(opts.milliseconds)) {
145
+ const multiplier = this.multiplierOf(opts?.unit);
146
+ if (multiplier === null || !Number.isFinite(opts.milliseconds)) {
142
147
  return null;
143
148
  }
144
149
  return opts.milliseconds / multiplier;
145
150
  }
146
151
  /** Unit to unit, through milliseconds. Fractional, for the reason {@link fromMilliseconds} gives. */
147
152
  static convert(opts) {
148
- const source = this.BY_UNIT[opts?.from];
149
- const target = this.BY_UNIT[opts?.to];
150
- if (source === undefined || target === undefined || !Number.isFinite(opts.value)) {
153
+ const source = this.multiplierOf(opts?.from);
154
+ const target = this.multiplierOf(opts?.to);
155
+ if (source === null || target === null || !Number.isFinite(opts.value)) {
151
156
  return null;
152
157
  }
153
158
  return (opts.value * source) / target;
@@ -1 +1 @@
1
- {"version":3,"file":"duration.js","sourceRoot":"","sources":["../../../../src/common/constants/duration.ts"],"names":[],"mappings":";;;AAEA,qEAAqE;AACrE,MAAa,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,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,IAAI;KACV,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;AAvBH,sCAwBC;AAID;;;;;;GAMG;AACH,MAAa,eAAe;aACV,OAAE,GAAG,aAAa,CAAC,WAAW,CAAC;aAC/B,SAAI,GAAG,aAAa,CAAC,WAAW,CAAC;aACjC,gBAAW,GAAG,aAAa,CAAC,WAAW,CAAC;aACxC,iBAAY,GAAG,aAAa,CAAC,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AI,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IAChD,CAAC;;AAzFH,kDA0FC","sourcesContent":["import { type TConstValue } from '../types';\n\n/** The time units a duration can be expressed in, smallest first. */\nexport class DurationUnits {\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 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.YEAR,\n ]);\n\n static isValid(input: string): input is TDurationUnit {\n return this.SCHEME_SET.has(input);\n }\n}\n\nexport type TDurationUnit = TConstValue<typeof DurationUnits>;\n\n/**\n * Written spellings that resolve to a unit. Member names are the spelling, upper-cased - so\n * {@link resolve} upper-cases its input and reads one property, with no second table to keep in step.\n *\n * `M` is MINUTE and `MO` is MONTH - the same choice every duration library makes, and the one\n * ambiguity a reader will trip on. There is no single-letter month.\n */\nexport class DurationAliases {\n static readonly MS = DurationUnits.MILLISECOND;\n static readonly MSEC = DurationUnits.MILLISECOND;\n static readonly MILLISECOND = DurationUnits.MILLISECOND;\n static readonly MILLISECONDS = DurationUnits.MILLISECOND;\n\n static readonly S = DurationUnits.SECOND;\n static readonly SEC = DurationUnits.SECOND;\n static readonly SECOND = DurationUnits.SECOND;\n static readonly SECONDS = DurationUnits.SECOND;\n\n static readonly M = DurationUnits.MINUTE;\n static readonly MIN = DurationUnits.MINUTE;\n static readonly MINUTE = DurationUnits.MINUTE;\n static readonly MINUTES = DurationUnits.MINUTE;\n\n static readonly H = DurationUnits.HOUR;\n static readonly HR = DurationUnits.HOUR;\n static readonly HOUR = DurationUnits.HOUR;\n static readonly HOURS = DurationUnits.HOUR;\n\n static readonly D = DurationUnits.DAY;\n static readonly DAY = DurationUnits.DAY;\n static readonly DAYS = DurationUnits.DAY;\n\n static readonly W = DurationUnits.WEEK;\n static readonly WK = DurationUnits.WEEK;\n static readonly WEEK = DurationUnits.WEEK;\n static readonly WEEKS = DurationUnits.WEEK;\n\n static readonly MO = DurationUnits.MONTH;\n static readonly MON = DurationUnits.MONTH;\n static readonly MONTH = DurationUnits.MONTH;\n static readonly MONTHS = DurationUnits.MONTH;\n\n static readonly Y = DurationUnits.YEAR;\n static readonly YR = DurationUnits.YEAR;\n static readonly YEAR = DurationUnits.YEAR;\n static readonly YEARS = DurationUnits.YEAR;\n\n /** Resolves a written unit - `'d'`, `'days'`, `'DAY'` - to its canonical name, or `null`. */\n static resolve(input: string): TDurationUnit | null {\n if (typeof input !== 'string') {\n return null;\n }\n\n // Try the input as given first. `trim().toUpperCase()` allocates two strings and costs ~55ns,\n // where the lookup itself is ~1ns - so the spellings callers actually pass (`'day'`, `'d'`,\n // `'DAYS'`) must not pay for it. Measured, both ways.\n //\n // The table is declared below because it is derived FROM this class; it is read at call time,\n // never at class-evaluation time.\n /* eslint-disable @typescript-eslint/no-use-before-define */\n return ALIAS_LOOKUP.get(input) ?? ALIAS_LOOKUP.get(input.trim().toUpperCase()) ?? null;\n /* eslint-enable @typescript-eslint/no-use-before-define */\n }\n}\n\n/**\n * Derived from the class once, never hand-listed, so the two cannot drift. Reading the class\n * directly is slower and would need `name`/`length`/`constructor` guarded out. Each spelling is\n * stored upper and lower so the common call allocates nothing.\n */\nconst ALIAS_LOOKUP: Map<string, TDurationUnit> = new Map(\n Object.entries(DurationAliases)\n .filter((entry): entry is [string, TDurationUnit] => DurationUnits.isValid(entry[1] as string))\n .flatMap(([spelling, unit]): Array<[string, TDurationUnit]> => [\n [spelling, unit],\n [spelling.toLowerCase(), unit],\n ]),\n);\n\nexport interface IDuration {\n unit: TDurationUnit;\n value: number;\n}\n\n/** `30d`, `1500 ms`, `-2 Hours`. One number, optional space, one unit. */\nconst DURATION_PATTERN = /^([+-]?\\d+(?:\\.\\d+)?)\\s*([a-z]+)$/i;\n\n/**\n * A month is 30 days and a year 365, nominal. These size a WINDOW - a grace period, a cache TTL, a\n * near-expiry horizon - and must never compute a calendar date: adding `MONTH` to 31 January lands\n * on 2 March in a leap year and 3 March otherwise. Use a date library for calendar arithmetic.\n */\nexport class DurationMultipliers {\n static readonly MILLISECOND = 1;\n static readonly SECOND = 1000 * this.MILLISECOND;\n static readonly MINUTE = 60 * this.SECOND;\n static readonly HOUR = 60 * this.MINUTE;\n static readonly DAY = 24 * this.HOUR;\n static readonly WEEK = 7 * this.DAY;\n static readonly MONTH = 30 * this.DAY;\n static readonly YEAR = 365 * this.DAY;\n\n static readonly BY_UNIT: Record<string, number> = {\n [DurationUnits.MILLISECOND]: this.MILLISECOND,\n [DurationUnits.SECOND]: this.SECOND,\n [DurationUnits.MINUTE]: this.MINUTE,\n [DurationUnits.HOUR]: this.HOUR,\n [DurationUnits.DAY]: this.DAY,\n [DurationUnits.WEEK]: this.WEEK,\n [DurationUnits.MONTH]: this.MONTH,\n [DurationUnits.YEAR]: this.YEAR,\n };\n\n /**\n * `null` rather than a throw, so a caller that wants an error raises its own with its own context.\n * Every method here answers the same way.\n *\n * One map read, not a validity check followed by a read: an unknown unit is already `undefined`.\n */\n static toMilliseconds(opts: IDuration | null): number | null {\n if (!opts) {\n return null;\n }\n\n const multiplier = this.BY_UNIT[opts.unit];\n\n if (multiplier === undefined || !Number.isFinite(opts.value)) {\n return null;\n }\n\n return Math.round(opts.value * multiplier);\n }\n\n /** The inverse of {@link toMilliseconds}. Fractional on purpose - rounding here would silently lose a 36-hour window asked for in days. */\n static fromMilliseconds(opts: { milliseconds: number; unit: TDurationUnit }): number | null {\n const multiplier = this.BY_UNIT[opts?.unit];\n\n if (multiplier === undefined || !Number.isFinite(opts.milliseconds)) {\n return null;\n }\n\n return opts.milliseconds / multiplier;\n }\n\n /** Unit to unit, through milliseconds. Fractional, for the reason {@link fromMilliseconds} gives. */\n static convert(opts: { value: number; from: TDurationUnit; to: TDurationUnit }): number | null {\n const source = this.BY_UNIT[opts?.from];\n const target = this.BY_UNIT[opts?.to];\n\n if (source === undefined || target === undefined || !Number.isFinite(opts.value)) {\n return null;\n }\n\n return (opts.value * source) / target;\n }\n\n /** Reads a written duration - `'30d'`, `'1500 ms'`, `'2 hours'` - into {@link IDuration}. Aliases and the `M`/`MO` rule are on {@link DurationAliases}. */\n static parse(input: string): IDuration | null {\n if (typeof input !== 'string') {\n return null;\n }\n\n const matched = DURATION_PATTERN.exec(input.trim());\n\n if (!matched) {\n return null;\n }\n\n const unit = DurationAliases.resolve(matched[2]);\n const value = Number(matched[1]);\n\n if (!unit || !Number.isFinite(value)) {\n return null;\n }\n\n return { unit, value };\n }\n\n /** `'30d'` straight to milliseconds - the shape a TTL or a grace period is usually configured in. */\n static parseToMilliseconds(input: string): number | null {\n return this.toMilliseconds(this.parse(input));\n }\n}\n"]}
1
+ {"version":3,"file":"duration.js","sourceRoot":"","sources":["../../../../src/common/constants/duration.ts"],"names":[],"mappings":";;;AAEA,qEAAqE;AACrE,MAAa,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,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,IAAI;KACV,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,K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D,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,IAAI,GAAG,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;QACjD,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;QAEjC,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YACrC,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;IACzB,CAAC;IAED,qGAAqG;IACrG,MAAM,CAAC,mBAAmB,CAAC,KAAa;QACtC,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IAChD,CAAC;;AA/FH,kDAgGC","sourcesContent":["import { type TConstValue } from '../types';\n\n/** The time units a duration can be expressed in, smallest first. */\nexport class DurationUnits {\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 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.YEAR,\n ]);\n\n static isValid(input: string): input is TDurationUnit {\n return this.SCHEME_SET.has(input);\n }\n}\n\nexport type TDurationUnit = TConstValue<typeof DurationUnits>;\n\n/**\n * Written spellings that resolve to a unit. Member names are the spelling, upper-cased - so\n * {@link resolve} upper-cases its input and reads one property, with no second table to keep in step.\n *\n * `M` is MINUTE and `MO` is MONTH - the same choice every duration library makes, and the one\n * ambiguity a reader will trip on. There is no single-letter month.\n */\nexport class DurationAliases {\n static readonly MS = DurationUnits.MILLISECOND;\n static readonly MSEC = DurationUnits.MILLISECOND;\n static readonly MILLISECOND = DurationUnits.MILLISECOND;\n static readonly MILLISECONDS = DurationUnits.MILLISECOND;\n\n static readonly S = DurationUnits.SECOND;\n static readonly SEC = DurationUnits.SECOND;\n static readonly SECOND = DurationUnits.SECOND;\n static readonly SECONDS = DurationUnits.SECOND;\n\n static readonly M = DurationUnits.MINUTE;\n static readonly MIN = DurationUnits.MINUTE;\n static readonly MINUTE = DurationUnits.MINUTE;\n static readonly MINUTES = DurationUnits.MINUTE;\n\n static readonly H = DurationUnits.HOUR;\n static readonly HR = DurationUnits.HOUR;\n static readonly HOUR = DurationUnits.HOUR;\n static readonly HOURS = DurationUnits.HOUR;\n\n static readonly D = DurationUnits.DAY;\n static readonly DAY = DurationUnits.DAY;\n static readonly DAYS = DurationUnits.DAY;\n\n static readonly W = DurationUnits.WEEK;\n static readonly WK = DurationUnits.WEEK;\n static readonly WEEK = DurationUnits.WEEK;\n static readonly WEEKS = DurationUnits.WEEK;\n\n static readonly MO = DurationUnits.MONTH;\n static readonly MON = DurationUnits.MONTH;\n static readonly MONTH = DurationUnits.MONTH;\n static readonly MONTHS = DurationUnits.MONTH;\n\n static readonly Y = DurationUnits.YEAR;\n static readonly YR = DurationUnits.YEAR;\n static readonly YEAR = DurationUnits.YEAR;\n static readonly YEARS = DurationUnits.YEAR;\n\n /** Resolves a written unit - `'d'`, `'days'`, `'DAY'` - to its canonical name, or `null`. */\n static resolve(input: string): TDurationUnit | null {\n if (typeof input !== 'string') {\n return null;\n }\n\n // Try the input as given first. `trim().toUpperCase()` allocates two strings and costs ~55ns,\n // where the lookup itself is ~1ns - so the spellings callers actually pass (`'day'`, `'d'`,\n // `'DAYS'`) must not pay for it. Measured, both ways.\n //\n // The table is declared below because it is derived FROM this class; it is read at call time,\n // never at class-evaluation time.\n /* eslint-disable @typescript-eslint/no-use-before-define */\n return ALIAS_LOOKUP.get(input) ?? ALIAS_LOOKUP.get(input.trim().toUpperCase()) ?? null;\n /* eslint-enable @typescript-eslint/no-use-before-define */\n }\n}\n\n/**\n * Derived from the class once, never hand-listed, so the two cannot drift. Reading the class\n * directly is slower and would need `name`/`length`/`constructor` guarded out. Each spelling is\n * stored upper and lower so the common call allocates nothing.\n */\nconst ALIAS_LOOKUP: Map<string, TDurationUnit> = new Map(\n Object.entries(DurationAliases)\n .filter((entry): entry is [string, TDurationUnit] => DurationUnits.isValid(entry[1] as string))\n .flatMap(([spelling, unit]): Array<[string, TDurationUnit]> => [\n [spelling, unit],\n [spelling.toLowerCase(), unit],\n ]),\n);\n\nexport interface IDuration {\n unit: TDurationUnit;\n value: number;\n}\n\n/** `30d`, `1500 ms`, `-2 Hours`. One number, optional space, one unit. */\nconst DURATION_PATTERN = /^([+-]?\\d+(?:\\.\\d+)?)\\s*([a-z]+)$/i;\n\n/**\n * A month is 30 days and a year 365, nominal. These size a WINDOW - a grace period, a cache TTL, a\n * near-expiry horizon - and must never compute a calendar date: adding `MONTH` to 31 January lands\n * on 2 March in a leap year and 3 March otherwise. Use a date library for calendar arithmetic.\n */\nexport class DurationMultipliers {\n static readonly MILLISECOND = 1;\n static readonly SECOND = 1000 * this.MILLISECOND;\n static readonly MINUTE = 60 * this.SECOND;\n static readonly HOUR = 60 * this.MINUTE;\n static readonly DAY = 24 * this.HOUR;\n static readonly WEEK = 7 * this.DAY;\n static readonly MONTH = 30 * this.DAY;\n static readonly YEAR = 365 * this.DAY;\n\n static readonly BY_UNIT: Record<string, number> = {\n [DurationUnits.MILLISECOND]: this.MILLISECOND,\n [DurationUnits.SECOND]: this.SECOND,\n [DurationUnits.MINUTE]: this.MINUTE,\n [DurationUnits.HOUR]: this.HOUR,\n [DurationUnits.DAY]: this.DAY,\n [DurationUnits.WEEK]: this.WEEK,\n [DurationUnits.MONTH]: this.MONTH,\n [DurationUnits.YEAR]: this.YEAR,\n };\n\n /** The multiplier of a known unit, `null` for anything else - inherited property names included. */\n private static multiplierOf(unit: unknown): number | null {\n return typeof unit === 'string' && DurationUnits.isValid(unit) ? this.BY_UNIT[unit] : null;\n }\n\n /**\n * `null` rather than a throw, so a caller that wants an error raises its own with its own context.\n * Every method here answers the same way.\n *\n * The unit is checked against {@link DurationUnits.SCHEME_SET} first: a plain-object read alone\n * would answer `'constructor'` or `'toString'` with a member of `Object.prototype`, not `undefined`.\n */\n static toMilliseconds(opts: IDuration | null): number | null {\n if (!opts) {\n return null;\n }\n\n const multiplier = this.multiplierOf(opts.unit);\n\n if (multiplier === null || !Number.isFinite(opts.value)) {\n return null;\n }\n\n return Math.round(opts.value * multiplier);\n }\n\n /** The inverse of {@link toMilliseconds}. Fractional on purpose - rounding here would silently lose a 36-hour window asked for in days. */\n static fromMilliseconds(opts: { milliseconds: number; unit: TDurationUnit }): number | null {\n const multiplier = this.multiplierOf(opts?.unit);\n\n if (multiplier === null || !Number.isFinite(opts.milliseconds)) {\n return null;\n }\n\n return opts.milliseconds / multiplier;\n }\n\n /** Unit to unit, through milliseconds. Fractional, for the reason {@link fromMilliseconds} gives. */\n static convert(opts: { value: number; from: TDurationUnit; to: TDurationUnit }): number | null {\n const source = this.multiplierOf(opts?.from);\n const target = this.multiplierOf(opts?.to);\n\n if (source === null || target === null || !Number.isFinite(opts.value)) {\n return null;\n }\n\n return (opts.value * source) / target;\n }\n\n /** Reads a written duration - `'30d'`, `'1500 ms'`, `'2 hours'` - into {@link IDuration}. Aliases and the `M`/`MO` rule are on {@link DurationAliases}. */\n static parse(input: string): IDuration | null {\n if (typeof input !== 'string') {\n return null;\n }\n\n const matched = DURATION_PATTERN.exec(input.trim());\n\n if (!matched) {\n return null;\n }\n\n const unit = DurationAliases.resolve(matched[2]);\n const value = Number(matched[1]);\n\n if (!unit || !Number.isFinite(value)) {\n return null;\n }\n\n return { unit, value };\n }\n\n /** `'30d'` straight to milliseconds - the shape a TTL or a grace period is usually configured in. */\n static parseToMilliseconds(input: string): number | null {\n return this.toMilliseconds(this.parse(input));\n }\n}\n"]}
@@ -1,4 +1,16 @@
1
- export type TFieldMappingDataType = 'string' | 'number' | 'strings' | 'numbers' | 'boolean';
1
+ import type { TConstValue } from './const-value';
2
+ /** The value kinds a field mapping reads. */
3
+ export declare class FieldMappingDataTypes {
4
+ static readonly STRING = "string";
5
+ static readonly NUMBER = "number";
6
+ static readonly STRINGS = "strings";
7
+ static readonly NUMBERS = "numbers";
8
+ static readonly BOOLEAN = "boolean";
9
+ static readonly SCHEME_SET: Set<string>;
10
+ static isValid(value: string): boolean;
11
+ }
12
+ /** Valid field mapping data type values. */
13
+ export type TFieldMappingDataType = TConstValue<typeof FieldMappingDataTypes>;
2
14
  export interface IFieldMapping {
3
15
  name: string;
4
16
  type: TFieldMappingDataType;
@@ -1 +1 @@
1
- {"version":3,"file":"field-mapping.d.ts","sourceRoot":"","sources":["../../../../src/common/types/field-mapping.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;AAC5F,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,qBAAqB,CAAC;IAC5B,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC;CACrE;AAED,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,KAAK,CAAC,aAAa,CAAC,IAAI,OAAO,CACtE,CAAC,CAAC,MAAM,CAAC,EACT;IAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,CAAA;CAAE,CAChD,CAAC,MAAM,CAAC,CAAC;AAEV,MAAM,MAAM,wBAAwB,CAClC,CAAC,SAAS,SAAS;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,GAAG,CAAC;C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AG,GAAG,CAAA;KAAE,GAClE,MAAM,GACN,CAAC,SAAS;QAAE,IAAI,EAAE,CAAC,CAAC;QAAC,IAAI,EAAE,SAAS,CAAC;QAAC,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,GAAG,CAAA;KAAE,GACnE,OAAO,GACP,CAAC,SAAS;QAAE,IAAI,EAAE,CAAC,CAAC;QAAC,IAAI,EAAE,SAAS,CAAC;QAAC,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,GAAG,CAAA;KAAE,GACnE,MAAM,EAAE,GACR,CAAC,SAAS;QACN,IAAI,EAAE,CAAC,CAAC;QACR,IAAI,EAAE,SAAS,CAAC;QAChB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,GAAG,CAAC;KAC/B,GACD,MAAM,EAAE,GACR,KAAK;CAClB,CAAC"}
@@ -1,3 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FieldMappingDataTypes = void 0;
4
+ /** The value kinds a field mapping reads. */
5
+ class FieldMappingDataTypes {
6
+ static { this.STRING = 'string'; }
7
+ static { this.NUMBER = 'number'; }
8
+ static { this.STRINGS = 'strings'; }
9
+ static { this.NUMBERS = 'numbers'; }
10
+ static { this.BOOLEAN = 'boolean'; }
11
+ static { this.SCHEME_SET = new Set([
12
+ this.STRING,
13
+ this.NUMBER,
14
+ this.STRINGS,
15
+ this.NUMBERS,
16
+ this.BOOLEAN,
17
+ ]); }
18
+ static isValid(value) {
19
+ return this.SCHEME_SET.has(value);
20
+ }
21
+ }
22
+ exports.FieldMappingDataTypes = FieldMappingDataTypes;
3
23
  //# sourceMappingURL=field-mapping.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"field-mapping.js","sourceRoot":"","sources":["../../../../src/common/types/field-mapping.ts"],"names":[],"mappings":"","sourcesContent":["export type TFieldMappingDataType = 'string' | 'number' | 'strings' | 'numbers' | 'boolean';\nexport interface IFieldMapping {\n name: string;\n type: TFieldMappingDataType;\n default?: string | number | Array<string> | Array<number> | boolean;\n}\n\nexport type TFieldMappingNames<T extends Array<IFieldMapping>> = Extract<\n T[number],\n { type: Exclude<T[number]['type'], undefined> }\n>['name'];\n\nexport type TObjectFromFieldMappings<\n T extends readonly {\n name: string;\n type: string;\n [extra: string | symbol]: any;\n }[],\n> = {\n [K in T[number]['name']]: T extends {\n name: K;\n type: 'string';\n [extra: string | symbol]: any;\n }\n ? string\n : T extends { name: K; type: 'number'; [extra: string | symbol]: any }\n ? number\n : T extends { name: K; type: 'boolean'; [extra: string | symbol]: any }\n ? boolean\n : T extends { name: K; type: 'strings'; [extra: string | symbol]: any }\n ? string[]\n : T extends {\n name: K;\n type: 'numbers';\n [extra: string | symbol]: any;\n }\n ? number[]\n : never;\n};\n"]}
1
+ {"version":3,"file":"field-mapping.js","sourceRoot":"","sources":["../../../../src/common/types/field-mapping.ts"],"names":[],"mappings":";;;AAEA,6CAA6C;AAC7C,MAAa,qBAAqB;aAChB,WAAM,GAAG,QAAQ,CAAC;aAClB,WAAM,GAAG,QAAQ,CAAC;aAClB,YAAO,GAAG,SAAS,CAAC;aACpB,YAAO,GAAG,SAAS,CAAC;aACpB,YAAO,GAAG,SAAS,CAAC;aAEpB,eAAU,GAAG,IAAI,GAAG,CAAS;QAC3C,IAAI,CAAC,MAAM;QACX,IAAI,CAAC,MAAM;QACX,IAAI,CAAC,OAAO;QACZ,IAAI,CAAC,OAAO;QACZ,IAAI,CAAC,OAAO;KACb,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;AAjBH,sDAkBC","sourcesContent":["import type { TConstValue } from './const-value';\n\n/** The value kinds a field mapping reads. */\nexport class FieldMappingDataTypes {\n static readonly STRING = 'string';\n static readonly NUMBER = 'number';\n static readonly STRINGS = 'strings';\n static readonly NUMBERS = 'numbers';\n static readonly BOOLEAN = 'boolean';\n\n static readonly SCHEME_SET = new Set<string>([\n this.STRING,\n this.NUMBER,\n this.STRINGS,\n this.NUMBERS,\n this.BOOLEAN,\n ]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** Valid field mapping data type values. */\nexport type TFieldMappingDataType = TConstValue<typeof FieldMappingDataTypes>;\n\nexport interface IFieldMapping {\n name: string;\n type: TFieldMappingDataType;\n default?: string | number | Array<string> | Array<number> | boolean;\n}\n\nexport type TFieldMappingNames<T extends Array<IFieldMapping>> = Extract<\n T[number],\n { type: Exclude<T[number]['type'], undefined> }\n>['name'];\n\nexport type TObjectFromFieldMappings<\n T extends readonly {\n name: string;\n type: string;\n [extra: string | symbol]: any;\n }[],\n> = {\n [K in T[number]['name']]: T extends {\n name: K;\n type: 'string';\n [extra: string | symbol]: any;\n }\n ? string\n : T extends { name: K; type: 'number'; [extra: string | symbol]: any }\n ? number\n : T extends { name: K; type: 'boolean'; [extra: string | symbol]: any }\n ? boolean\n : T extends { name: K; type: 'strings'; [extra: string | symbol]: any }\n ? string[]\n : T extends {\n name: K;\n type: 'numbers';\n [extra: string | symbol]: any;\n }\n ? number[]\n : never;\n};\n"]}
@@ -28,7 +28,8 @@ export { blankToUndefined, int, keysToCamel, toBoolean, toCamel } from './utilit
28
28
  export { executeWithPerformanceMeasure } from './utilities/performance.utility';
29
29
  export { readFormBody, RequestBodyErrors } from './utilities/form-body.utility';
30
30
  export { ProjectRootRegistry } from './utilities/project-root.utility';
31
- export type { AESAlgorithmType } from './modules/crypto/algorithms/aes.algorithm';
31
+ export { AESAlgorithms } from './modules/crypto/algorithms/aes.constants';
32
+ export type { AESAlgorithmType } from './modules/crypto/algorithms/aes.constants';
32
33
  export type { IPayloadCipher } from './modules/crypto/common/types';
33
34
  export type { IRedisHelper } from './modules/redis/common/interfaces';
34
35
  //# sourceMappingURL=core.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"core.d.ts","sourceRoot":"","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BAAqB,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAChG,YAAY,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AACxF,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,YAAY,EACV,aAAa,EACb,mBAAmB,EACnB,cAAc,EACd,aAAa,EACb,aAAa,EACb,SAAS,EACT,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACd,QAAQ,EACR,aAAa,GACd,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAMjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,YAAY,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,GAAG,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACnG,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAKvE,OAAO,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC;AAC1E,YAAY,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAClF,YAAY,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACpE,YAAY,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC"}
package/dist/cjs/core.js CHANGED
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.ProjectRootRegistry = exports.RequestBodyErrors = exports.readFormBody = exports.executeWithPerformanceMeasure = exports.toCamel = exports.toBoolean = exports.keysToCamel = exports.int = exports.blankToUndefined = exports.BuildInfoRegistry = exports.TreeWalker = exports.TreeBuilder = exports.SlugHelper = exports.RetryHelper = exports.RetryJitterModes = exports.RetryBackoffStrategies = exports.LogLevels = exports.EnvironmentNames = exports.BaseHelper = void 0;
17
+ exports.AESAlgorithms = exports.ProjectRootRegistry = exports.RequestBodyErrors = exports.readFormBody = exports.executeWithPerformanceMeasure = exports.toCamel = exports.toBoolean = exports.keysToCamel = exports.int = exports.blankToUndefined = exports.BuildInfoRegistry = exports.TreeWalker = exports.TreeBuilder = exports.SlugHelper = exports.RetryHelper = exports.RetryJitterModes = exports.RetryBackoffStrategies = exports.LogLevels = exports.EnvironmentNames = exports.BaseHelper = void 0;
18
18
  var base_1 = require("./modules/base");
19
19
  Object.defineProperty(exports, "BaseHelper", { enumerable: true, get: function () { return base_1.BaseHelper; } });
20
20
  // By name, never `export *` from `./modules/env`: that barrel also carries `Environment` and
@@ -69,4 +69,9 @@ Object.defineProperty(exports, "readFormBody", { enumerable: true, get: function
69
69
  Object.defineProperty(exports, "RequestBodyErrors", { enumerable: true, get: function () { return form_body_utility_1.RequestBodyErrors; } });
70
70
  var project_root_utility_1 = require("./utilities/project-root.utility");
71
71
  Object.defineProperty(exports, "ProjectRootRegistry", { enumerable: true, get: function () { return project_root_utility_1.ProjectRootRegistry; } });
72
+ // Type-only: erased at compile time, so re-exporting these carries no runtime/bundle cost even
73
+ // though the concrete classes they describe (crypto algorithms, the ioredis-backed helper) are not
74
+ // themselves part of this pure surface.
75
+ var aes_constants_1 = require("./modules/crypto/algorithms/aes.constants");
76
+ Object.defineProperty(exports, "AESAlgorithms", { enumerable: true, get: function () { return aes_constants_1.AESAlgorithms; } });
72
77
  //# sourceMappingURL=core.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/core.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uCAA4C;AAAnC,kGAAA,UAAU,OAAA;AACnB,6FAA6F;AAC7F,8DAA8D;AAC9D,6CAAuD;AAA9C,yGAAA,gBAAgB,OAAA;AACzB,kDAAgC;AAChC,uDAA0D;AAAjD,kGAAA,SAAS,OAAA;AAElB,sFAAoE;AACpE,qGAAqG;AACrG,4FAA4F;AAC5F,oBAAoB;AACpB,sFAAoE;AACpE,6FAA2E;AAC3E,iDAA+B;AAC/B,8DAA4C;AAC5C,qDAAmC;AACnC,gDAA8B;AAC9B,iGAAiG;AACjG,yFAAyF;AACzF,0FAAwE;AAExE,gFAA8D;AAC9D,2EAAyD;AACzD,8DAA4F;AAAnF,mHAAA,sBAAsB,OAAA;AAAE,6GAAA,gBAAgB,OAAA;AAGjD,iDAAqD;AAA5C,qGAAA,WAAW,OAAA;AACpB,gDAAmD;AAA1C,oGAAA,UAAU,OAAA;AACnB,kDAAqD;AAA5C,sGAAA,WAAW,OAAA;AAcpB,4CAAiD;AAAxC,kGAAA,UAAU,OAAA;AAEnB,gGAAgG;AAChG,6FAA6F;AAC7F,iGAAiG;AACjG,0DAA0D;AAC1D,qEAAmE;AAA1D,uHAAA,iBAAiB,OAAA;AAE1B,2DAAmG;AAA1F,iHAAA,gBAAgB,OAAA;AAAE,oGAAA,GAAG,OAAA;AAAE,4GAAA,WAAW,OAAA;AAAE,0GAAA,SAAS,OAAA;AAAE,wGAAA,OAAO,OAAA;AAC/D,uEAAgF;AAAvE,oIAAA,6BAA6B,OAAA;AACtC,mEAAgF;AAAvE,iHAAA,YAAY,OAAA;AAAE,sHAAA,iBAAiB,OAAA;AACxC,yEAAuE;AAA9D,2HAAA,mBAAmB,OAAA","sourcesContent":["export { BaseHelper } from './modules/base';\n// By name, never `export *` from `./modules/env`: that barrel also carries `Environment` and\n// `applicationEnvironment`, both of which read `process.env`.\nexport { EnvironmentNames } from './modules/env/names';\nexport * from './modules/error';\nexport { LogLevels } from './modules/logger/common/types';\nexport type { ILogger, ILoggerProvider, TLogLevel } from './modules/logger/common/types';\nexport * from './modules/network/http-request/fetcher/base-fetcher';\n// The node fetcher carries no node builtin - its one `querystring.stringify` is written out - so the\n// framework HTTP layer is reachable from a browser bundle, and a connector on HTTP need not\n// re-implement one.\nexport * from './modules/network/http-request/fetcher/node-fetcher';\nexport * from './modules/network/http-request/base-network-request.helper';\nexport * from './modules/pool';\nexport * from './modules/queue/internal/hf';\nexport * from './modules/temporal';\nexport * from './modules/uid';\n// The url guard, pure half only: `UrlPolicy` decides a url and a literal address with string and\n// number work. Its sibling `UrlIngest` reaches `node:dns` and stays out of this subpath.\nexport * from './modules/network/utilities/url-safety/common/constants';\nexport type { IUrlSafetyPolicy } from './modules/network/utilities/url-safety/common/types';\nexport * from './modules/network/utilities/url-safety/policy';\nexport * from './modules/network/utilities/query-string';\nexport { RetryBackoffStrategies, RetryJitterModes } from './modules/retry/common/constants';\nexport type { TRetryBackoffStrategy, TRetryJitterMode } from './modules/retry/common/constants';\nexport type { IRetryBackoffOptions, IRetryContext } from './modules/retry/common/types';\nexport { RetryHelper } from './modules/retry/helper';\nexport { SlugHelper } from './modules/slug/helper';\nexport { TreeBuilder } from './modules/tree/builder';\nexport type {\n IBuildOptions,\n IHeightWhereOptions,\n ILeavesOptions,\n INodeWithPath,\n IPrintOptions,\n ITreeNode,\n IWalkAsyncOptions,\n IWalkOptions,\n TNodePredicate,\n TOnVisit,\n TOnVisitAsync,\n} from './modules/tree/common/types';\nexport { TreeWalker } from './modules/tree/walk';\n\n// Pure value/type utilities that already live under the root barrel's `./utilities` re-export -\n// that barrel also carries node-only siblings (module.utility.ts, request.utility.ts), so it\n// cannot itself become a subpath. Named one at a time here instead of widening the barrel: every\n// symbol below is verified free of node builtins/globals.\nexport { BuildInfoRegistry } from './utilities/build-info.utility';\nexport type { IBuildInfo, TBuildInfoRecord } from './utilities/build-info.utility';\nexport { blankToUndefined, int, keysToCamel, toBoolean, toCamel } from './utilities/parse.utility';\nexport { executeWithPerformanceMeasure } from './utilities/performance.utility';\nexport { readFormBody, RequestBodyErrors } from './utilities/form-body.utility';\nexport { ProjectRootRegistry } from './utilities/project-root.utility';\n\n// Type-only: erased at compile time, so re-exporting these carries no runtime/bundle cost even\n// though the concrete classes they describe (crypto algorithms, the ioredis-backed helper) are not\n// themselves part of this pure surface.\nexport type { AESAlgorithmType } from './modules/crypto/algorithms/aes.algorithm';\nexport type { IPayloadCipher } from './modules/crypto/common/types';\nexport type { IRedisHelper } from './modules/redis/common/interfaces';\n"]}
1
+ {"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/core.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uCAA4C;AAAnC,kGAAA,UAAU,OAAA;AACnB,6FAA6F;AAC7F,8DAA8D;AAC9D,6CAAuD;AAA9C,yGAAA,gBAAgB,OAAA;AACzB,kDAAgC;AAChC,uDAA0D;AAAjD,kGAAA,SAAS,OAAA;AAElB,sFAAoE;AACpE,qGAAqG;AACrG,4FAA4F;AAC5F,oBAAoB;AACpB,sFAAoE;AACpE,6FAA2E;AAC3E,iDAA+B;AAC/B,8DAA4C;AAC5C,qDAAmC;AACnC,gDAA8B;AAC9B,iGAAiG;AACjG,yFAAyF;AACzF,0FAAwE;AAExE,gFAA8D;AAC9D,2EAAyD;AACzD,8DAA4F;AAAnF,mHAAA,sBAAsB,OAAA;AAAE,6GAAA,gBAAgB,OAAA;AAGjD,iDAAqD;AAA5C,qGAAA,WAAW,OAAA;AACpB,gDAAmD;AAA1C,oGAAA,UAAU,OAAA;AACnB,kDAAqD;AAA5C,sGAAA,WAAW,OAAA;AAcpB,4CAAiD;AAAxC,kGAAA,UAAU,OAAA;AAEnB,gGAAgG;AAChG,6FAA6F;AAC7F,iGAAiG;AACjG,0DAA0D;AAC1D,qEAAmE;AAA1D,uHAAA,iBAAiB,OAAA;AAE1B,2DAAmG;AAA1F,iHAAA,gBAAgB,OAAA;AAAE,oGAAA,GAAG,OAAA;AAAE,4GAAA,WAAW,OAAA;AAAE,0GAAA,SAAS,OAAA;AAAE,wGAAA,OAAO,OAAA;AAC/D,uEAAgF;AAAvE,oIAAA,6BAA6B,OAAA;AACtC,mEAAgF;AAAvE,iHAAA,YAAY,OAAA;AAAE,sHAAA,iBAAiB,OAAA;AACxC,yEAAuE;AAA9D,2HAAA,mBAAmB,OAAA;AAE5B,+FAA+F;AAC/F,mGAAmG;AACnG,wCAAwC;AACxC,2EAA0E;AAAjE,8GAAA,aAAa,OAAA","sourcesContent":["export { BaseHelper } from './modules/base';\n// By name, never `export *` from `./modules/env`: that barrel also carries `Environment` and\n// `applicationEnvironment`, both of which read `process.env`.\nexport { EnvironmentNames } from './modules/env/names';\nexport * from './modules/error';\nexport { LogLevels } from './modules/logger/common/types';\nexport type { ILogger, ILoggerProvider, TLogLevel } from './modules/logger/common/types';\nexport * from './modules/network/http-request/fetcher/base-fetcher';\n// The node fetcher carries no node builtin - its one `querystring.stringify` is written out - so the\n// framework HTTP layer is reachable from a browser bundle, and a connector on HTTP need not\n// re-implement one.\nexport * from './modules/network/http-request/fetcher/node-fetcher';\nexport * from './modules/network/http-request/base-network-request.helper';\nexport * from './modules/pool';\nexport * from './modules/queue/internal/hf';\nexport * from './modules/temporal';\nexport * from './modules/uid';\n// The url guard, pure half only: `UrlPolicy` decides a url and a literal address with string and\n// number work. Its sibling `UrlIngest` reaches `node:dns` and stays out of this subpath.\nexport * from './modules/network/utilities/url-safety/common/constants';\nexport type { IUrlSafetyPolicy } from './modules/network/utilities/url-safety/common/types';\nexport * from './modules/network/utilities/url-safety/policy';\nexport * from './modules/network/utilities/query-string';\nexport { RetryBackoffStrategies, RetryJitterModes } from './modules/retry/common/constants';\nexport type { TRetryBackoffStrategy, TRetryJitterMode } from './modules/retry/common/constants';\nexport type { IRetryBackoffOptions, IRetryContext } from './modules/retry/common/types';\nexport { RetryHelper } from './modules/retry/helper';\nexport { SlugHelper } from './modules/slug/helper';\nexport { TreeBuilder } from './modules/tree/builder';\nexport type {\n IBuildOptions,\n IHeightWhereOptions,\n ILeavesOptions,\n INodeWithPath,\n IPrintOptions,\n ITreeNode,\n IWalkAsyncOptions,\n IWalkOptions,\n TNodePredicate,\n TOnVisit,\n TOnVisitAsync,\n} from './modules/tree/common/types';\nexport { TreeWalker } from './modules/tree/walk';\n\n// Pure value/type utilities that already live under the root barrel's `./utilities` re-export -\n// that barrel also carries node-only siblings (module.utility.ts, request.utility.ts), so it\n// cannot itself become a subpath. Named one at a time here instead of widening the barrel: every\n// symbol below is verified free of node builtins/globals.\nexport { BuildInfoRegistry } from './utilities/build-info.utility';\nexport type { IBuildInfo, TBuildInfoRecord } from './utilities/build-info.utility';\nexport { blankToUndefined, int, keysToCamel, toBoolean, toCamel } from './utilities/parse.utility';\nexport { executeWithPerformanceMeasure } from './utilities/performance.utility';\nexport { readFormBody, RequestBodyErrors } from './utilities/form-body.utility';\nexport { ProjectRootRegistry } from './utilities/project-root.utility';\n\n// Type-only: erased at compile time, so re-exporting these carries no runtime/bundle cost even\n// though the concrete classes they describe (crypto algorithms, the ioredis-backed helper) are not\n// themselves part of this pure surface.\nexport { AESAlgorithms } from './modules/crypto/algorithms/aes.constants';\nexport type { AESAlgorithmType } from './modules/crypto/algorithms/aes.constants';\nexport type { IPayloadCipher } from './modules/crypto/common/types';\nexport type { IRedisHelper } from './modules/redis/common/interfaces';\n"]}
@@ -1,3 +1,4 @@
1
+ import { AESAlgorithms, type AESAlgorithmType } from './aes.constants';
1
2
  import { BaseCryptoAlgorithm } from './base.algorithm';
2
3
  interface IAESDecryptOptions {
3
4
  inputEncoding?: BufferEncoding;
@@ -17,7 +18,7 @@ export interface IAESKeyringEntry {
17
18
  secret: string;
18
19
  }
19
20
  export type TAESSecret = string | IAESKeyringEntry[];
20
- export type AESAlgorithmType = 'aes-256-cbc' | 'aes-256-gcm';
21
+ export { AESAlgorithms, type AESAlgorithmType };
21
22
  export declare class AES extends BaseCryptoAlgorithm<AESAlgorithmType, string, string, TAESSecret, string, string, IAESExtraOptions> {
22
23
  constructor(opts: {
23
24
  algorithm: AESAlgorithmType;
@@ -56,5 +57,4 @@ export declare class AES extends BaseCryptoAlgorithm<AESAlgorithmType, string, s
56
57
  secret: TAESSecret;
57
58
  }): string;
58
59
  }
59
- export {};
60
60
  //# sourceMappingURL=aes.algorithm.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"aes.algorithm.d.ts","sourceRoot":"","sources":["../../../../../src/modules/crypto/algorithms/aes.algorithm.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAMvD,UAAU,kBAAkB;IAC1B,aAAa,CAAC,EAAE,cAAc,CAAC;IAC/B,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,8HAA8H;IAC9H,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,0HAA0H;IAC1H,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,sIAAsI;AACtI,UAAU,gBAAiB,SAAQ,kBAAkB;IACnD,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,gBAAgB,EAAE,CAAC;AAErD,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG,aAAa,CAAC;AAE7D,qBAAa,GAAI,SAAQ,mBAAmB,CAC1C,gBAAgB,EAChB,MAAM,EACN,MAAM,EACN,UAAU,EACV,MAAM,EACN,MAAM,EACN,gBAAgB,CACjB;gBACa,IAAI,EAAE;QAAE,SAAS,EAAE,gBAAgB,CAAA;KAAE;IAIjD,MAAM,CAAC,aAAa,CAAC,SAAS,EAAE,gBAAgB;IAIhD,SAAS,CAAC,iBAAiB,CAAC,IAA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;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,UAAU,CAAA;KAAE,GAAG,MAAM;IAavE,OAAO,CAAC,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,UAAU,CAAC;QAAC,IAAI,CAAC,EAAE,kBAAkB,CAAA;KAAE;IAuDhF,WAAW,CAAC,IAAI,EAAE;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,UAAU,CAAA;KAAE;CAY/D"}
@@ -3,7 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.AES = void 0;
6
+ exports.AES = exports.AESAlgorithms = void 0;
7
+ const aes_constants_1 = require("./aes.constants");
8
+ Object.defineProperty(exports, "AESAlgorithms", { enumerable: true, get: function () { return aes_constants_1.AESAlgorithms; } });
7
9
  const ignis_inversion_1 = require("@venizia/ignis-inversion");
8
10
  const node_crypto_1 = __importDefault(require("node:crypto"));
9
11
  const node_fs_1 = __importDefault(require("node:fs"));
@@ -1 +1 @@
1
- {"version":3,"file":"aes.algorithm.js","sourceRoot":"","sources":["../../../../../src/modules/crypto/algorithms/aes.algorithm.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAmD;AACnD,8DAA4B;AAC5B,sDAAyB;AACzB,2CAA2C;AAC3C,qDAAuD;AAEvD,MAAM,cAAc,GAAG,EAAE,CAAC;AAC1B,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAChC,MAAM,cAAc,GAAG,GAAG,CAAC;AA0B3B,MAAa,GAAI,SAAQ,oCAQxB;IACC,YAAY,IAAqC;QAC/C,KAAK,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,IAAI,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;IACtC,CAAC;IAED,MAAM,CAAC,aAAa,CAAC,SAA2B;QAC9C,OAAO,IAAI,G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AAC,OAAO,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,CAAC;QACjE,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AArMD,kBAqMC","sourcesContent":["import { isEmpty } from '@venizia/ignis-inversion';\nimport C from 'node:crypto';\nimport fs from 'node:fs';\nimport { getError } from '@/modules/error';\nimport { BaseCryptoAlgorithm } from './base.algorithm';\n\nconst DEFAULT_LENGTH = 16;\nconst CIPHERTEXT_VERSION = 0x01;\nconst DEFAULT_KEY_ID = '0';\n\ninterface IAESDecryptOptions {\n inputEncoding?: BufferEncoding;\n outputEncoding?: BufferEncoding;\n doThrow?: boolean;\n /** Per-deployment PBKDF2 salt override. Must be supplied identically on encrypt and decrypt; omit for the shipped default. */\n kdfSalt?: string;\n /** PBKDF2 iteration count override. Must be supplied identically on encrypt and decrypt; omit for the shipped default. */\n kdfIterations?: number;\n}\n\n/** `iv` is encrypt-only: the envelope carries the IV, so decrypt reads it from there and a supplied one would be silently ignored. */\ninterface IAESExtraOptions extends IAESDecryptOptions {\n iv?: Buffer;\n}\n\nexport interface IAESKeyringEntry {\n id: string;\n secret: string;\n}\n\nexport type TAESSecret = string | IAESKeyringEntry[];\n\nexport type AESAlgorithmType = 'aes-256-cbc' | 'aes-256-gcm';\n\nexport class AES extends BaseCryptoAlgorithm<\n AESAlgorithmType,\n string,\n string,\n TAESSecret,\n string,\n string,\n IAESExtraOptions\n> {\n constructor(opts: { algorithm: AESAlgorithmType }) {\n super({ scope: AES.name, ...opts });\n }\n\n static withAlgorithm(algorithm: AESAlgorithmType) {\n return new AES({ algorithm });\n }\n\n protected resolveEncryptKey(opts: {\n secret: TAESSecret;\n kdfSalt?: string;\n kdfIterations?: number;\n }): { id: string; key: Buffer } {\n const { secret, kdfSalt, kdfIterations } = opts;\n const entry = Array.isArray(secret) ? secret[0] : { id: DEFAULT_KEY_ID, secret };\n\n if (!entry || isEmpty({ value: entry.secret })) {\n throw getError({ message: '[AES][resolveEncryptKey] Missing secret or empty keyring' });\n }\n\n const key = this.normalizeSecretKey({\n secret: entry.secret,\n length: this.getAlgorithmKeySize(),\n kdfSalt,\n kdfIterations,\n });\n return { id: entry.id, key };\n }\n\n protected resolveDecryptKey(opts: {\n secret: TAESSecret;\n id: string;\n kdfSalt?: string;\n kdfIterations?: number;\n }): Buffer {\n const { secret, id, kdfSalt, kdfIterations } = opts;\n const length = this.getAlgorithmKeySize();\n\n if (!Array.isArray(secret)) {\n return this.normalizeSecretKey({ secret, length, kdfSalt, kdfIterations });\n }\n\n const entry = secret.find((e) => e.id === id);\n if (!entry) {\n throw getError({\n message: `[AES][resolveDecryptKey] No key in keyring matches ciphertext key id \"${id}\"`,\n });\n }\n\n // Without this the empty secret derives a key from '' and fails as an opaque OpenSSL error, hiding a plain configuration mistake.\n if (isEmpty({ value: entry.secret })) {\n throw getError({\n message: `[AES][resolveDecryptKey] Keyring entry for key id \"${id}\" has an empty secret`,\n });\n }\n\n return this.normalizeSecretKey({ secret: entry.secret, length, kdfSalt, kdfIterations });\n }\n\n encrypt(opts: { message: string; secret: TAESSecret; opts?: IAESExtraOptions }) {\n const { message, secret } = opts;\n const {\n iv = C.randomBytes(DEFAULT_LENGTH),\n inputEncoding = 'utf-8',\n outputEncoding = 'base64',\n doThrow = true,\n kdfSalt,\n kdfIterations,\n } = opts.opts ?? {};\n\n try {\n const { id, key } = this.resolveEncryptKey({ secret, kdfSalt, kdfIterations });\n const idBuffer = Buffer.from(id, 'utf-8');\n if (idBuffer.length > 0xff) {\n throw getError({ message: '[AES][encrypt] Key id too long (max 255 bytes)' });\n }\n\n const cipher = C.createCipheriv(this.algorithm, key, iv);\n\n // Envelope: [version(1)][idLen(1)][id(idLen)][iv(16)][authTag(16, gcm only)][cipher]\n const header = Buffer.from([CIPHERTEXT_VERSION, idBuffer.length]);\n const parts = [header, idBuffer, iv];\n\n const cipherText = cipher.update(message, inputEncoding);\n const cipherFinal = cipher.final();\n\n switch (this.algorithm) {\n case 'aes-256-cbc': {\n break;\n }\n case 'aes-256-gcm': {\n parts.push((cipher as C.CipherGCM).getAuthTag());\n break;\n }\n }\n parts.push(cipherText);\n parts.push(cipherFinal);\n\n return Buffer.concat(parts).toString(outputEncoding);\n } catch (error) {\n if (doThrow) {\n throw error;\n }\n\n return message;\n }\n }\n\n encryptFile(opts: { absolutePath: string; secret: TAESSecret }): string {\n const { absolutePath, secret } = opts;\n\n if (!absolutePath || isEmpty({ value: absolutePath })) {\n return '';\n }\n\n const buffer = fs.readFileSync(absolutePath);\n const fileContent = buffer?.toString('utf-8');\n const encrypted = this.encrypt({ message: fileContent, secret });\n return encrypted;\n }\n\n decrypt(opts: { message: string; secret: TAESSecret; opts?: IAESDecryptOptions }) {\n const { message, secret } = opts;\n const {\n inputEncoding = 'base64',\n outputEncoding = 'utf-8',\n doThrow = true,\n kdfSalt,\n kdfIterations,\n } = opts.opts ?? {};\n\n try {\n const raw = Buffer.from(message, inputEncoding);\n\n const version = raw[0];\n if (version !== CIPHERTEXT_VERSION) {\n throw getError({ message: `[AES][decrypt] Unsupported ciphertext version: ${version}` });\n }\n\n const idLength = raw[1];\n let cursor = 2;\n\n const id = raw.subarray(cursor, cursor + idLength).toString('utf-8');\n cursor += idLength;\n\n const iv = raw.subarray(cursor, cursor + DEFAULT_LENGTH);\n cursor += DEFAULT_LENGTH;\n\n const key = this.resolveDecryptKey({ secret, id, kdfSalt, kdfIterations });\n const decipher = C.createDecipheriv(this.algorithm, key, iv);\n\n switch (this.algorithm) {\n case 'aes-256-cbc': {\n break;\n }\n case 'aes-256-gcm': {\n const authTag = raw.subarray(cursor, cursor + DEFAULT_LENGTH);\n cursor += DEFAULT_LENGTH;\n (decipher as C.DecipherGCM).setAuthTag(authTag);\n break;\n }\n }\n\n const cipherText = raw.subarray(cursor);\n return Buffer.concat([decipher.update(cipherText), decipher.final()]).toString(\n outputEncoding,\n );\n } catch (error) {\n if (doThrow) {\n throw error;\n }\n\n return message;\n }\n }\n\n decryptFile(opts: { absolutePath: string; secret: TAESSecret }) {\n const { absolutePath, secret } = opts;\n\n if (!absolutePath || isEmpty({ value: absolutePath })) {\n return '';\n }\n\n const buffer = fs.readFileSync(absolutePath);\n const fileContent = buffer?.toString('utf-8');\n const decrypted = this.decrypt({ message: fileContent, secret });\n return decrypted;\n }\n}\n"]}
1
+ {"version":3,"file":"aes.algorithm.js","sourceRoot":"","sources":["../../../../../src/modules/crypto/algorithms/aes.algorithm.ts"],"names":[],"mappings":";;;;;;AAAA,mDAAuE;AAiC9D,8FAjCA,6BAAa,OAiCA;AAhCtB,8DAAmD;AACnD,8DAA4B;AAC5B,sDAAyB;AACzB,2CAA2C;AAC3C,qDAAuD;AAEvD,MAAM,cAAc,GAAG,EAAE,CAAC;AAC1B,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAChC,MAAM,cAAc,GAAG,GAAG,CAAC;AA0B3B,MAAa,GAAI,SAAQ,oCAQxB;IACC,YAAY,IAAqC;QAC/C,KAAK,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,IAAI,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;IACtC,CAAC;IAED,MAAM,CAAC,aAAa,CAAC,SAA2B;QAC9C,OAAO,IAAI,GAAG,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC;IAChC,CAAC;IAES,iBAAiB,CAAC,IAI3B;QACC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC;QAChD,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,cAAc,EAAE,MAAM,EAAE,CAAC;QAEjF,IAAI,CAAC,KAAK,IAAI,IAAA,yBAAO,EAAC,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC;YAC/C,MAAM,IAAA,gBAAQ,EAAC,EAAE,OAAO,EAAE,0DAA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G,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YACxC,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,QAAQ,CAC5E,cAAc,CACf,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,OAAO,EAAE,CAAC;gBACZ,MAAM,KAAK,CAAC;YACd,CAAC;YAED,OAAO,OAAO,CAAC;QACjB,CAAC;IACH,CAAC;IAED,WAAW,CAAC,IAAkD;QAC5D,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QAEtC,IAAI,CAAC,YAAY,IAAI,IAAA,yBAAO,EAAC,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC;YACtD,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,MAAM,GAAG,iBAAE,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;QAC7C,MAAM,WAAW,GAAG,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC9C,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,CAAC;QACjE,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AArMD,kBAqMC","sourcesContent":["import { AESAlgorithms, type AESAlgorithmType } from './aes.constants';\nimport { isEmpty } from '@venizia/ignis-inversion';\nimport C from 'node:crypto';\nimport fs from 'node:fs';\nimport { getError } from '@/modules/error';\nimport { BaseCryptoAlgorithm } from './base.algorithm';\n\nconst DEFAULT_LENGTH = 16;\nconst CIPHERTEXT_VERSION = 0x01;\nconst DEFAULT_KEY_ID = '0';\n\ninterface IAESDecryptOptions {\n inputEncoding?: BufferEncoding;\n outputEncoding?: BufferEncoding;\n doThrow?: boolean;\n /** Per-deployment PBKDF2 salt override. Must be supplied identically on encrypt and decrypt; omit for the shipped default. */\n kdfSalt?: string;\n /** PBKDF2 iteration count override. Must be supplied identically on encrypt and decrypt; omit for the shipped default. */\n kdfIterations?: number;\n}\n\n/** `iv` is encrypt-only: the envelope carries the IV, so decrypt reads it from there and a supplied one would be silently ignored. */\ninterface IAESExtraOptions extends IAESDecryptOptions {\n iv?: Buffer;\n}\n\nexport interface IAESKeyringEntry {\n id: string;\n secret: string;\n}\n\nexport type TAESSecret = string | IAESKeyringEntry[];\n\nexport { AESAlgorithms, type AESAlgorithmType };\n\nexport class AES extends BaseCryptoAlgorithm<\n AESAlgorithmType,\n string,\n string,\n TAESSecret,\n string,\n string,\n IAESExtraOptions\n> {\n constructor(opts: { algorithm: AESAlgorithmType }) {\n super({ scope: AES.name, ...opts });\n }\n\n static withAlgorithm(algorithm: AESAlgorithmType) {\n return new AES({ algorithm });\n }\n\n protected resolveEncryptKey(opts: {\n secret: TAESSecret;\n kdfSalt?: string;\n kdfIterations?: number;\n }): { id: string; key: Buffer } {\n const { secret, kdfSalt, kdfIterations } = opts;\n const entry = Array.isArray(secret) ? secret[0] : { id: DEFAULT_KEY_ID, secret };\n\n if (!entry || isEmpty({ value: entry.secret })) {\n throw getError({ message: '[AES][resolveEncryptKey] Missing secret or empty keyring' });\n }\n\n const key = this.normalizeSecretKey({\n secret: entry.secret,\n length: this.getAlgorithmKeySize(),\n kdfSalt,\n kdfIterations,\n });\n return { id: entry.id, key };\n }\n\n protected resolveDecryptKey(opts: {\n secret: TAESSecret;\n id: string;\n kdfSalt?: string;\n kdfIterations?: number;\n }): Buffer {\n const { secret, id, kdfSalt, kdfIterations } = opts;\n const length = this.getAlgorithmKeySize();\n\n if (!Array.isArray(secret)) {\n return this.normalizeSecretKey({ secret, length, kdfSalt, kdfIterations });\n }\n\n const entry = secret.find((e) => e.id === id);\n if (!entry) {\n throw getError({\n message: `[AES][resolveDecryptKey] No key in keyring matches ciphertext key id \"${id}\"`,\n });\n }\n\n // Without this the empty secret derives a key from '' and fails as an opaque OpenSSL error, hiding a plain configuration mistake.\n if (isEmpty({ value: entry.secret })) {\n throw getError({\n message: `[AES][resolveDecryptKey] Keyring entry for key id \"${id}\" has an empty secret`,\n });\n }\n\n return this.normalizeSecretKey({ secret: entry.secret, length, kdfSalt, kdfIterations });\n }\n\n encrypt(opts: { message: string; secret: TAESSecret; opts?: IAESExtraOptions }) {\n const { message, secret } = opts;\n const {\n iv = C.randomBytes(DEFAULT_LENGTH),\n inputEncoding = 'utf-8',\n outputEncoding = 'base64',\n doThrow = true,\n kdfSalt,\n kdfIterations,\n } = opts.opts ?? {};\n\n try {\n const { id, key } = this.resolveEncryptKey({ secret, kdfSalt, kdfIterations });\n const idBuffer = Buffer.from(id, 'utf-8');\n if (idBuffer.length > 0xff) {\n throw getError({ message: '[AES][encrypt] Key id too long (max 255 bytes)' });\n }\n\n const cipher = C.createCipheriv(this.algorithm, key, iv);\n\n // Envelope: [version(1)][idLen(1)][id(idLen)][iv(16)][authTag(16, gcm only)][cipher]\n const header = Buffer.from([CIPHERTEXT_VERSION, idBuffer.length]);\n const parts = [header, idBuffer, iv];\n\n const cipherText = cipher.update(message, inputEncoding);\n const cipherFinal = cipher.final();\n\n switch (this.algorithm) {\n case 'aes-256-cbc': {\n break;\n }\n case 'aes-256-gcm': {\n parts.push((cipher as C.CipherGCM).getAuthTag());\n break;\n }\n }\n parts.push(cipherText);\n parts.push(cipherFinal);\n\n return Buffer.concat(parts).toString(outputEncoding);\n } catch (error) {\n if (doThrow) {\n throw error;\n }\n\n return message;\n }\n }\n\n encryptFile(opts: { absolutePath: string; secret: TAESSecret }): string {\n const { absolutePath, secret } = opts;\n\n if (!absolutePath || isEmpty({ value: absolutePath })) {\n return '';\n }\n\n const buffer = fs.readFileSync(absolutePath);\n const fileContent = buffer?.toString('utf-8');\n const encrypted = this.encrypt({ message: fileContent, secret });\n return encrypted;\n }\n\n decrypt(opts: { message: string; secret: TAESSecret; opts?: IAESDecryptOptions }) {\n const { message, secret } = opts;\n const {\n inputEncoding = 'base64',\n outputEncoding = 'utf-8',\n doThrow = true,\n kdfSalt,\n kdfIterations,\n } = opts.opts ?? {};\n\n try {\n const raw = Buffer.from(message, inputEncoding);\n\n const version = raw[0];\n if (version !== CIPHERTEXT_VERSION) {\n throw getError({ message: `[AES][decrypt] Unsupported ciphertext version: ${version}` });\n }\n\n const idLength = raw[1];\n let cursor = 2;\n\n const id = raw.subarray(cursor, cursor + idLength).toString('utf-8');\n cursor += idLength;\n\n const iv = raw.subarray(cursor, cursor + DEFAULT_LENGTH);\n cursor += DEFAULT_LENGTH;\n\n const key = this.resolveDecryptKey({ secret, id, kdfSalt, kdfIterations });\n const decipher = C.createDecipheriv(this.algorithm, key, iv);\n\n switch (this.algorithm) {\n case 'aes-256-cbc': {\n break;\n }\n case 'aes-256-gcm': {\n const authTag = raw.subarray(cursor, cursor + DEFAULT_LENGTH);\n cursor += DEFAULT_LENGTH;\n (decipher as C.DecipherGCM).setAuthTag(authTag);\n break;\n }\n }\n\n const cipherText = raw.subarray(cursor);\n return Buffer.concat([decipher.update(cipherText), decipher.final()]).toString(\n outputEncoding,\n );\n } catch (error) {\n if (doThrow) {\n throw error;\n }\n\n return message;\n }\n }\n\n decryptFile(opts: { absolutePath: string; secret: TAESSecret }) {\n const { absolutePath, secret } = opts;\n\n if (!absolutePath || isEmpty({ value: absolutePath })) {\n return '';\n }\n\n const buffer = fs.readFileSync(absolutePath);\n const fileContent = buffer?.toString('utf-8');\n const decrypted = this.decrypt({ message: fileContent, secret });\n return decrypted;\n }\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import type { TConstValue } from '../../../common/types';
2
+ /** The ciphers `AES` supports. */
3
+ export declare class AESAlgorithms {
4
+ static readonly AES_256_CBC = "aes-256-cbc";
5
+ static readonly AES_256_GCM = "aes-256-gcm";
6
+ static readonly SCHEME_SET: Set<string>;
7
+ static isValid(value: string): boolean;
8
+ }
9
+ /** Valid AES algorithm values. */
10
+ export type AESAlgorithmType = TConstValue<typeof AESAlgorithms>;
11
+ //# sourceMappingURL=aes.constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aes.constants.d.ts","sourceRoot":"","sources":["../../../../../src/modules/crypto/algorithms/aes.constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,kCAAkC;AAClC,qBAAa,aAAa;IACxB,MAAM,CAAC,QAAQ,CAAC,WAAW,iBAAiB;IAC5C,MAAM,CAAC,QAAQ,CAAC,WAAW,iBAAiB;IAE5C,MAAM,CAAC,QAAQ,CAAC,UAAU,cAAyD;IAEnF,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;CAGvC;AAED,kCAAkC;AAClC,MAAM,MAAM,gBAAgB,GAAG,WAAW,CAAC,OAAO,aAAa,CAAC,CAAC"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AESAlgorithms = void 0;
4
+ /** The ciphers `AES` supports. */
5
+ class AESAlgorithms {
6
+ static { this.AES_256_CBC = 'aes-256-cbc'; }
7
+ static { this.AES_256_GCM = 'aes-256-gcm'; }
8
+ static { this.SCHEME_SET = new Set([this.AES_256_CBC, this.AES_256_GCM]); }
9
+ static isValid(value) {
10
+ return this.SCHEME_SET.has(value);
11
+ }
12
+ }
13
+ exports.AESAlgorithms = AESAlgorithms;
14
+ //# sourceMappingURL=aes.constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aes.constants.js","sourceRoot":"","sources":["../../../../../src/modules/crypto/algorithms/aes.constants.ts"],"names":[],"mappings":";;;AAEA,kCAAkC;AAClC,MAAa,aAAa;aACR,gBAAW,GAAG,aAAa,CAAC;aAC5B,gBAAW,GAAG,aAAa,CAAC;aAE5B,eAAU,GAAG,IAAI,GAAG,CAAS,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IAEnF,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;AARH,sCASC","sourcesContent":["import type { TConstValue } from '@/common/types';\n\n/** The ciphers `AES` supports. */\nexport class AESAlgorithms {\n static readonly AES_256_CBC = 'aes-256-cbc';\n static readonly AES_256_GCM = 'aes-256-gcm';\n\n static readonly SCHEME_SET = new Set<string>([this.AES_256_CBC, this.AES_256_GCM]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** Valid AES algorithm values. */\nexport type AESAlgorithmType = TConstValue<typeof AESAlgorithms>;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"app-env.d.ts","sourceRoot":"","sources":["../../../../src/modules/env/app-env.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAExD,sPAAsP;AACtP,qBAAa,WAAY,SAAQ,gBAAgB;IAC/C,gNAAgN;IAChN,MAAM,KAAK,OAAO,IAAI,MAAM,GAAG,SAAS,CAGvC;IAED,MAAM,KAAK,OAAO,IAAI,MAAM,CAE3B;IAED,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE;CAGjC;AAED,qBAAa,sBAAuB,SAAQ,UAAW,YAAW,uBAAuB;IACvF,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,SAAS,CAA2B;gBAEhC,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC,CAAA;KAAE;IAcvF;;;;;;;;;;OAUG;IACH,GAAG,CAAC,UAAU,EA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AS,CAAC,CAAA;KAAE;IAcvF;;;;;;;;;;OAUG;IACH,GAAG,CAAC,UAAU,EAAE,mBAAmB,GAAG,OAAO,EAC3C,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE;QACL,YAAY,CAAC,EAAE,UAAU,CAAC;QAC1B,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,UAAU,CAAC;KACxD,GACA,UAAU;IAcb,GAAG,CAAC,SAAS,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS;IAI5C,KAAK,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE;IAO5C,aAAa;IAIb,IAAI;CAGL;AAoBD,eAAO,MAAM,sBAAsB,wBAAkC,CAAC;AAEtE,eAAO,MAAM,OAAO,wBAAyB,CAAC;AAC9C,eAAO,MAAM,IAAI,wBAAyB,CAAC"}
@@ -22,7 +22,7 @@ exports.Environment = Environment;
22
22
  class ApplicationEnvironment extends base_1.BaseHelper {
23
23
  constructor(opts) {
24
24
  super({ scope: ApplicationEnvironment.name });
25
- this.arguments = {};
25
+ this.arguments = Object.create(null);
26
26
  this.prefix = opts.prefix;
27
27
  for (const key in opts.envs) {
28
28
  if (!key.startsWith(this.prefix)) {
@@ -1 +1 @@
1
- {"version":3,"file":"app-env.js","sourceRoot":"","sources":["../../../../src/modules/env/app-env.ts"],"names":[],"mappings":";;;AAAA,6DAA6D;AAC7D,yCAA4C;AAC5C,mCAA2C;AAG3C,sPAAsP;AACtP,MAAa,WAAY,SAAQ,wBAAgB;IAC/C,gNAAgN;IAChN,MAAM,KAAK,OAAO;QAChB,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;QACjC,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,MAAM,KAAK,OAAO;QAChB,OAAO,WAAW,CAAC,OAAO,IAAI,WAAW,CAAC,WAAW,CAAC;IACxD,CA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AG,8BAAsB,CAAC;AACjC,QAAA,IAAI,GAAG,8BAAsB,CAAC","sourcesContent":["import { blankToUndefined } from '@/utilities/parse.utility';\nimport { BaseHelper } from '@/modules/base';\nimport { EnvironmentNames } from './names';\nimport { type IApplicationEnvironment } from './common';\n\n/** Adds the `NODE_ENV` reads to {@link EnvironmentNames}. Every name and set is inherited, so `Environment.PRODUCTION`, `Environment.COMMON_ENVS` and `Environment.DEVELOPMENT_ENVS` keep resolving here; only these two members need a `process`. */\nexport class Environment extends EnvironmentNames {\n /** `NODE_ENV` exactly as the host has it, `undefined` when unset. Destructured on purpose: `bun build` rewrites `process.env.NODE_ENV` to a literal at build time, a destructured read stays a runtime read. */\n static get ambient(): string | undefined {\n const { NODE_ENV } = process.env;\n return NODE_ENV;\n }\n\n static get current(): string {\n return Environment.ambient ?? Environment.DEVELOPMENT;\n }\n\n static is(opts: { name: string }) {\n return this.current === opts.name;\n }\n}\n\nexport class ApplicationEnvironment extends BaseHelper implements IApplicationEnvironment {\n private prefix: string;\n private arguments: Record<string, any> = {};\n\n constructor(opts: { prefix: string; envs: Record<string, string | number | undefined> }) {\n super({ scope: ApplicationEnvironment.name });\n\n this.prefix = opts.prefix;\n\n for (const key in opts.envs) {\n if (!key.startsWith(this.prefix)) {\n continue;\n }\n\n this.arguments[key] = opts.envs[key];\n }\n }\n\n /**\n * Reads one name. A line that is present but empty - `KEY=`, or padded to `KEY= ` by a hand\n * edit - is a pipeline that forgot to export the value, not a value: it is normalised to\n * `undefined` so `defaultValue` applies, and `transform` is handed that `undefined` rather than\n * the empty string.\n *\n * The normalisation runs ONLY when the caller supplied a `defaultValue`, because that call site\n * has already declared what it wants when the name carries nothing. A caller without one still\n * receives `''` unchanged, so no existing read changes shape. `'0'` and `'false'` are values and\n * are never normalised.\n */\n get<ReturnType, BeforeTransformType = unknown>(\n key: string,\n opts?: {\n defaultValue?: ReturnType;\n transform?: (value: BeforeTransformType) => ReturnType;\n },\n ): ReturnType {\n const raw = this.arguments[key];\n\n const isBlank = raw === undefined || raw === null || (typeof raw === 'string' && !raw.trim());\n const rs = opts?.defaultValue !== undefined && isBlank ? undefined : raw;\n\n if (!opts?.transform) {\n return (rs ?? opts?.defaultValue) as ReturnType;\n }\n\n const transformed = opts.transform(rs);\n return (transformed ?? opts?.defaultValue) as ReturnType;\n }\n\n set<ValueType>(key: string, value: ValueType) {\n this.arguments[key] = value;\n }\n\n merge(opts: { envs: Record<string, string> }) {\n const envsEntries = Object.entries(opts.envs);\n for (const [key, value] of envsEntries) {\n this.arguments[key] = value;\n }\n }\n\n isDevelopment() {\n return Environment.ambient === 'development';\n }\n\n keys() {\n return Object.keys(this.arguments);\n }\n}\n\n/** A process can carry two copies of this module - an application's ESM import beside a CommonJS require. The instance lives in this globalThis slot so a `set()` through one copy is read through the other. */\nconst INSTANCE_SLOT = Symbol.for('ignis:application-environment');\n\nconst resolveApplicationEnvironment = (): ApplicationEnvironment => {\n const shared: ApplicationEnvironment | undefined = Reflect.get(globalThis, INSTANCE_SLOT);\n if (shared) {\n return shared;\n }\n\n const created = new ApplicationEnvironment({\n prefix: blankToUndefined(process.env.APPLICATION_ENV_PREFIX) ?? 'APP_ENV',\n envs: process.env,\n });\n Reflect.set(globalThis, INSTANCE_SLOT, created);\n\n return created;\n};\n\nexport const applicationEnvironment = resolveApplicationEnvironment();\n\nexport const AppEnvs = applicationEnvironment;\nexport const Envs = applicationEnvironment;\n"]}
1
+ {"version":3,"file":"app-env.js","sourceRoot":"","sources":["../../../../src/modules/env/app-env.ts"],"names":[],"mappings":";;;AAAA,6DAA6D;AAC7D,yCAA4C;AAC5C,mCAA2C;AAG3C,sPAAsP;AACtP,MAAa,WAAY,SAAQ,wBAAgB;IAC/C,gNAAgN;IAChN,MAAM,KAAK,OAAO;QAChB,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;QACjC,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,MAAM,KAAK,OAAO;QAChB,OAAO,WAA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B,CAAC,CAAC;AAEW,QAAA,sBAAsB,GAAG,6BAA6B,EAAE,CAAC;AAEzD,QAAA,OAAO,GAAG,8BAAsB,CAAC;AACjC,QAAA,IAAI,GAAG,8BAAsB,CAAC","sourcesContent":["import { blankToUndefined } from '@/utilities/parse.utility';\nimport { BaseHelper } from '@/modules/base';\nimport { EnvironmentNames } from './names';\nimport { type IApplicationEnvironment } from './common';\n\n/** Adds the `NODE_ENV` reads to {@link EnvironmentNames}. Every name and set is inherited, so `Environment.PRODUCTION`, `Environment.COMMON_ENVS` and `Environment.DEVELOPMENT_ENVS` keep resolving here; only these two members need a `process`. */\nexport class Environment extends EnvironmentNames {\n /** `NODE_ENV` exactly as the host has it, `undefined` when unset. Destructured on purpose: `bun build` rewrites `process.env.NODE_ENV` to a literal at build time, a destructured read stays a runtime read. */\n static get ambient(): string | undefined {\n const { NODE_ENV } = process.env;\n return NODE_ENV;\n }\n\n static get current(): string {\n return Environment.ambient ?? Environment.DEVELOPMENT;\n }\n\n static is(opts: { name: string }) {\n return this.current === opts.name;\n }\n}\n\nexport class ApplicationEnvironment extends BaseHelper implements IApplicationEnvironment {\n private prefix: string;\n private arguments: Record<string, any> = Object.create(null);\n\n constructor(opts: { prefix: string; envs: Record<string, string | number | undefined> }) {\n super({ scope: ApplicationEnvironment.name });\n\n this.prefix = opts.prefix;\n\n for (const key in opts.envs) {\n if (!key.startsWith(this.prefix)) {\n continue;\n }\n\n this.arguments[key] = opts.envs[key];\n }\n }\n\n /**\n * Reads one name. A line that is present but empty - `KEY=`, or padded to `KEY= ` by a hand\n * edit - is a pipeline that forgot to export the value, not a value: it is normalised to\n * `undefined` so `defaultValue` applies, and `transform` is handed that `undefined` rather than\n * the empty string.\n *\n * The normalisation runs ONLY when the caller supplied a `defaultValue`, because that call site\n * has already declared what it wants when the name carries nothing. A caller without one still\n * receives `''` unchanged, so no existing read changes shape. `'0'` and `'false'` are values and\n * are never normalised.\n */\n get<ReturnType, BeforeTransformType = unknown>(\n key: string,\n opts?: {\n defaultValue?: ReturnType;\n transform?: (value: BeforeTransformType) => ReturnType;\n },\n ): ReturnType {\n const raw = this.arguments[key];\n\n const isBlank = raw === undefined || raw === null || (typeof raw === 'string' && !raw.trim());\n const rs = opts?.defaultValue !== undefined && isBlank ? undefined : raw;\n\n if (!opts?.transform) {\n return (rs ?? opts?.defaultValue) as ReturnType;\n }\n\n const transformed = opts.transform(rs);\n return (transformed ?? opts?.defaultValue) as ReturnType;\n }\n\n set<ValueType>(key: string, value: ValueType) {\n this.arguments[key] = value;\n }\n\n merge(opts: { envs: Record<string, string> }) {\n const envsEntries = Object.entries(opts.envs);\n for (const [key, value] of envsEntries) {\n this.arguments[key] = value;\n }\n }\n\n isDevelopment() {\n return Environment.ambient === 'development';\n }\n\n keys() {\n return Object.keys(this.arguments);\n }\n}\n\n/** A process can carry two copies of this module - an application's ESM import beside a CommonJS require. The instance lives in this globalThis slot so a `set()` through one copy is read through the other. */\nconst INSTANCE_SLOT = Symbol.for('ignis:application-environment');\n\nconst resolveApplicationEnvironment = (): ApplicationEnvironment => {\n const shared: ApplicationEnvironment | undefined = Reflect.get(globalThis, INSTANCE_SLOT);\n if (shared) {\n return shared;\n }\n\n const created = new ApplicationEnvironment({\n prefix: blankToUndefined(process.env.APPLICATION_ENV_PREFIX) ?? 'APP_ENV',\n envs: process.env,\n });\n Reflect.set(globalThis, INSTANCE_SLOT, created);\n\n return created;\n};\n\nexport const applicationEnvironment = resolveApplicationEnvironment();\n\nexport const AppEnvs = applicationEnvironment;\nexport const Envs = applicationEnvironment;\n"]}
@@ -1,5 +1,5 @@
1
1
  /** Error layer lives in `@venizia/ignis-inversion` so browser apps (DI-only, no helpers) share the same class; re-exported by NAME, not `export *`, to keep inversion's DI container off the helpers surface. */
2
2
  /** Augment `IErrorKeyRegistry` via whichever module the file imports - see `registry-augmentation.test.ts`. */
3
- export { ApplicationError, ErrorScopes, fromError, getError, isApplicationError, MessageCode, MessageTemplate, } from '@venizia/ignis-inversion';
3
+ export { ApplicationError, ErrorLogLevels, ErrorScopes, fromError, getError, isApplicationError, MessageCode, MessageTemplate, } from '@venizia/ignis-inversion';
4
4
  export type { IErrorKeyRegistry, TError, TErrorByDefinition, TErrorByField, TErrorDefinition, TErrorDefinitionMessage, TErrorKey, TErrorLogLevel, TErrorMessage, TErrorMessageInput, TErrorMessageOverride, TErrorNormalized, TErrorNormalizeTransformFn, TErrorScope, TRegisterErrors, TResponsedError, } from '@venizia/ignis-inversion';
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modules/error/index.ts"],"names":[],"mappings":"AAAA,iNAAiN;AACjN,+GAA+G;AAC/G,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,SAAS,EACT,QAAQ,EACR,kBAAkB,EAClB,WAAW,EACX,eAAe,GAChB,MAAM,0BAA0B,CAAC;AAElC,YAAY,EACV,iBAAiB,EACjB,MAAM,EACN,kBAAkB,EAClB,aAAa,EACb,gBAAgB,EAChB,uBAAuB,EACvB,SAAS,EACT,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,qBAAqB,EACrB,gBAAgB,EAChB,0BAA0B,EAC1B,WAAW,EACX,eAAe,EACf,eAAe,GAChB,MAAM,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modules/error/index.ts"],"names":[],"mappings":"AAAA,iNAAiN;AACjN,+GAA+G;AAC/G,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,WAAW,EACX,SAAS,EACT,QAAQ,EACR,kBAAkB,EAClB,WAAW,EACX,eAAe,GAChB,MAAM,0BAA0B,CAAC;AAElC,YAAY,EACV,iBAAiB,EACjB,MAAM,EACN,kBAAkB,EAClB,aAAa,EACb,gBAAgB,EAChB,uBAAuB,EACvB,SAAS,EACT,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,qBAAqB,EACrB,gBAAgB,EAChB,0BAA0B,EAC1B,WAAW,EACX,eAAe,EACf,eAAe,GAChB,MAAM,0BAA0B,CAAC"}
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MessageTemplate = exports.MessageCode = exports.isApplicationError = exports.getError = exports.fromError = exports.ErrorScopes = exports.ApplicationError = void 0;
3
+ exports.MessageTemplate = exports.MessageCode = exports.isApplicationError = exports.getError = exports.fromError = exports.ErrorScopes = exports.ErrorLogLevels = exports.ApplicationError = void 0;
4
4
  /** Error layer lives in `@venizia/ignis-inversion` so browser apps (DI-only, no helpers) share the same class; re-exported by NAME, not `export *`, to keep inversion's DI container off the helpers surface. */
5
5
  /** Augment `IErrorKeyRegistry` via whichever module the file imports - see `registry-augmentation.test.ts`. */
6
6
  var ignis_inversion_1 = require("@venizia/ignis-inversion");
7
7
  Object.defineProperty(exports, "ApplicationError", { enumerable: true, get: function () { return ignis_inversion_1.ApplicationError; } });
8
+ Object.defineProperty(exports, "ErrorLogLevels", { enumerable: true, get: function () { return ignis_inversion_1.ErrorLogLevels; } });
8
9
  Object.defineProperty(exports, "ErrorScopes", { enumerable: true, get: function () { return ignis_inversion_1.ErrorScopes; } });
9
10
  Object.defineProperty(exports, "fromError", { enumerable: true, get: function () { return ignis_inversion_1.fromError; } });
10
11
  Object.defineProperty(exports, "getError", { enumerable: true, get: function () { return ignis_inversion_1.getError; } });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/error/index.ts"],"names":[],"mappings":";;;AAAA,iNAAiN;AACjN,+GAA+G;AAC/G,4DAQkC;AAPhC,mHAAA,gBAAgB,OAAA;AAChB,8GAAA,WAAW,OAAA;AACX,4GAAA,SAAS,OAAA;AACT,2GAAA,QAAQ,OAAA;AACR,qHAAA,kBAAkB,OAAA;AAClB,8GAAA,WAAW,OAAA;AACX,kHAAA,eAAe,OAAA","sourcesContent":["/** Error layer lives in `@venizia/ignis-inversion` so browser apps (DI-only, no helpers) share the same class; re-exported by NAME, not `export *`, to keep inversion's DI container off the helpers surface. */\n/** Augment `IErrorKeyRegistry` via whichever module the file imports - see `registry-augmentation.test.ts`. */\nexport {\n ApplicationError,\n ErrorScopes,\n fromError,\n getError,\n isApplicationError,\n MessageCode,\n MessageTemplate,\n} from '@venizia/ignis-inversion';\n\nexport type {\n IErrorKeyRegistry,\n TError,\n TErrorByDefinition,\n TErrorByField,\n TErrorDefinition,\n TErrorDefinitionMessage,\n TErrorKey,\n TErrorLogLevel,\n TErrorMessage,\n TErrorMessageInput,\n TErrorMessageOverride,\n TErrorNormalized,\n TErrorNormalizeTransformFn,\n TErrorScope,\n TRegisterErrors,\n TResponsedError,\n} from '@venizia/ignis-inversion';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/error/index.ts"],"names":[],"mappings":";;;AAAA,iNAAiN;AACjN,+GAA+G;AAC/G,4DASkC;AARhC,mHAAA,gBAAgB,OAAA;AAChB,iHAAA,cAAc,OAAA;AACd,8GAAA,WAAW,OAAA;AACX,4GAAA,SAAS,OAAA;AACT,2GAAA,QAAQ,OAAA;AACR,qHAAA,kBAAkB,OAAA;AAClB,8GAAA,WAAW,OAAA;AACX,kHAAA,eAAe,OAAA","sourcesContent":["/** Error layer lives in `@venizia/ignis-inversion` so browser apps (DI-only, no helpers) share the same class; re-exported by NAME, not `export *`, to keep inversion's DI container off the helpers surface. */\n/** Augment `IErrorKeyRegistry` via whichever module the file imports - see `registry-augmentation.test.ts`. */\nexport {\n ApplicationError,\n ErrorLogLevels,\n ErrorScopes,\n fromError,\n getError,\n isApplicationError,\n MessageCode,\n MessageTemplate,\n} from '@venizia/ignis-inversion';\n\nexport type {\n IErrorKeyRegistry,\n TError,\n TErrorByDefinition,\n TErrorByField,\n TErrorDefinition,\n TErrorDefinitionMessage,\n TErrorKey,\n TErrorLogLevel,\n TErrorMessage,\n TErrorMessageInput,\n TErrorMessageOverride,\n TErrorNormalized,\n TErrorNormalizeTransformFn,\n TErrorScope,\n TRegisterErrors,\n TResponsedError,\n} from '@venizia/ignis-inversion';\n"]}
@@ -1,4 +1,6 @@
1
- export type THfLogLevel = 'debug' | 'info' | 'warn' | 'error' | 'emerg';
1
+ import type { TLogLevel } from '../../common';
2
+ /** The levels the high-frequency logger writes: the shared log levels. */
3
+ export type THfLogLevel = TLogLevel;
2
4
  export type THfSinkBatch = {
3
5
  lines: Array<string>;
4
6
  dropped: number;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/modules/logger/hf/common/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;AAExE,MAAM,MAAM,YAAY,GAAG;IAAE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAErE,uQAAuQ;AACvQ,MAAM,MAAM,OAAO,GAAG,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;AAEpD,MAAM,WAAW,oBAAoB;IACnC,gDAAgD;IAChD,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qFAAqF;IACrF,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,UAAU,GAAG;IAAE,KAAK,EAAE,UAAU,CAAC;IAAC,GAAG,EAAE,YAAY,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/modules/logger/hf/common/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,0EAA0E;AAC1E,MAAM,MAAM,WAAW,GAAG,SAAS,CAAC;AAEpC,MAAM,MAAM,YAAY,GAAG;IAAE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAErE,uQAAuQ;AACvQ,MAAM,MAAM,OAAO,GAAG,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;AAEpD,MAAM,WAAW,oBAAoB;IACnC,gDAAgD;IAChD,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qFAAqF;IACrF,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,UAAU,GAAG;IAAE,KAAK,EAAE,UAAU,CAAC;IAAC,GAAG,EAAE,YAAY,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/modules/logger/hf/common/types.ts"],"names":[],"mappings":"","sourcesContent":["export type THfLogLevel = 'debug' | 'info' | 'warn' | 'error' | 'emerg';\n\nexport type THfSinkBatch = { lines: Array<string>; dropped: number };\n\n/** Declared `=> void` ON PURPOSE: TS's void-return exemption lets both sync and `async` sinks assign to it (`void | Promise<void>` would reject the sync form); the flusher still awaits a returned thenable, so a rejection is caught and logged, never unhandled. */\nexport type THfSink = (batch: THfSinkBatch) => void;\n\nexport interface IHfLogFlusherOptions {\n /** Full custom delivery. Overrides filePath. */\n sink?: THfSink;\n /** Default sink appends here instead of writing to stdout. */\n filePath?: string;\n /** Entries rendered per batch before yielding. Defaults to HF_DEFAULT_BATCH_SIZE. */\n batchSize?: number;\n}\n\nexport type TRingState = { bytes: Uint8Array; f64: Float64Array; writeIndex: number };\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/modules/logger/hf/common/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { TLogLevel } from '../../common';\n\n/** The levels the high-frequency logger writes: the shared log levels. */\nexport type THfLogLevel = TLogLevel;\n\nexport type THfSinkBatch = { lines: Array<string>; dropped: number };\n\n/** Declared `=> void` ON PURPOSE: TS's void-return exemption lets both sync and `async` sinks assign to it (`void | Promise<void>` would reject the sync form); the flusher still awaits a returned thenable, so a rejection is caught and logged, never unhandled. */\nexport type THfSink = (batch: THfSinkBatch) => void;\n\nexport interface IHfLogFlusherOptions {\n /** Full custom delivery. Overrides filePath. */\n sink?: THfSink;\n /** Default sink appends here instead of writing to stdout. */\n filePath?: string;\n /** Entries rendered per batch before yielding. Defaults to HF_DEFAULT_BATCH_SIZE. */\n batchSize?: number;\n}\n\nexport type TRingState = { bytes: Uint8Array; f64: Float64Array; writeIndex: number };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../../../src/modules/logger/hf/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,KAAK,OAAO,EAA+B,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAkBtF,4KAA4K;AAC5K,qBAAa,QAAS,SAAQ,cAAc;IAC1C,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAqB;IACxD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAiC;IACnE,OAAO,CAAC,MAAM,CAAC,KAAK,CAA+B;IACnD,OAAO,CAAC,MAAM,CAAC,YAAY,CAAiC;IAE5D,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;IACxC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IAErC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAa;IAElC,OAAO;IAQP,OAAO,CAAC,MAAM,CAAC,WAAW;IAS1B,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ;IASnC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-100,7 +100,9 @@ class HfLogger extends base_1.AbstractLogger {
100
100
  if (level === common_1.LogLevels.DEBUG && !common_1.SHOULD_LOG_DEBUG) {
101
101
  return;
102
102
  }
103
- const levelCode = common_2.HF_LEVEL_CODES[level] ?? common_2.HF_LEVEL_CODES.info;
103
+ const levelCode = Object.hasOwn(common_2.HF_LEVEL_CODES, level)
104
+ ? common_2.HF_LEVEL_CODES[level]
105
+ : common_2.HF_LEVEL_CODES.info;
104
106
  if (typeof message === 'string') {
105
107
  this.writeString(levelCode, message, args);
106
108
  return;