@fgv/ts-utils 5.1.0-4 → 5.1.0-40

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 (303) hide show
  1. package/README.md +21 -0
  2. package/dist/index.js +2 -2
  3. package/dist/index.js.map +1 -0
  4. package/dist/packlets/base/brand.js.map +1 -0
  5. package/dist/packlets/base/index.js +2 -0
  6. package/dist/packlets/base/index.js.map +1 -0
  7. package/dist/packlets/base/mapResults.js.map +1 -0
  8. package/dist/packlets/base/messageAggregator.js.map +1 -0
  9. package/dist/packlets/base/normalize.js +54 -1
  10. package/dist/packlets/base/normalize.js.map +1 -0
  11. package/dist/packlets/base/result.js +326 -2
  12. package/dist/packlets/base/result.js.map +1 -0
  13. package/dist/packlets/base/shouldNotFail.js +123 -0
  14. package/dist/packlets/base/shouldNotFail.js.map +1 -0
  15. package/dist/packlets/base/utils.js.map +1 -0
  16. package/dist/packlets/base/uuid.js +55 -0
  17. package/dist/packlets/base/uuid.js.map +1 -0
  18. package/dist/packlets/collections/aggregatedResultMap.js.map +1 -0
  19. package/dist/packlets/collections/collectible.js.map +1 -0
  20. package/dist/packlets/collections/collector.js +23 -9
  21. package/dist/packlets/collections/collector.js.map +1 -0
  22. package/dist/packlets/collections/collectorValidator.js +6 -1
  23. package/dist/packlets/collections/collectorValidator.js.map +1 -0
  24. package/dist/packlets/collections/common.js.map +1 -0
  25. package/dist/packlets/collections/converters.js.map +1 -0
  26. package/dist/packlets/collections/convertingCollector.js.map +1 -0
  27. package/dist/packlets/collections/convertingCollectorValidator.js.map +1 -0
  28. package/dist/packlets/collections/convertingResultMap.js.map +1 -0
  29. package/dist/packlets/collections/index.js +1 -0
  30. package/dist/packlets/collections/index.js.map +1 -0
  31. package/dist/packlets/collections/keyValueConverters.js.map +1 -0
  32. package/dist/packlets/collections/readOnlyConvertingResultMap.js +18 -0
  33. package/dist/packlets/collections/readOnlyConvertingResultMap.js.map +1 -0
  34. package/dist/packlets/collections/readonlyResultMap.js.map +1 -0
  35. package/dist/packlets/collections/resultMap.js.map +1 -0
  36. package/dist/packlets/collections/resultMapValidator.js.map +1 -0
  37. package/dist/packlets/collections/retainingRingBuffer.js +159 -0
  38. package/dist/packlets/collections/retainingRingBuffer.js.map +1 -0
  39. package/dist/packlets/collections/utils.js.map +1 -0
  40. package/dist/packlets/collections/validatingCollector.js.map +1 -0
  41. package/dist/packlets/collections/validatingConvertingCollector.js.map +1 -0
  42. package/dist/packlets/collections/validatingConvertingResultMap.js.map +1 -0
  43. package/dist/packlets/collections/validatingResultMap.js.map +1 -0
  44. package/dist/packlets/conversion/advancedConverters.js.map +1 -0
  45. package/dist/packlets/conversion/baseConverter.js +107 -18
  46. package/dist/packlets/conversion/baseConverter.js.map +1 -0
  47. package/dist/packlets/conversion/basicConverters.js +24 -5
  48. package/dist/packlets/conversion/basicConverters.js.map +1 -0
  49. package/dist/packlets/conversion/converter.js +11 -1
  50. package/dist/packlets/conversion/converter.js.map +1 -0
  51. package/dist/packlets/conversion/converters.js.map +1 -0
  52. package/dist/packlets/conversion/defaultingConverter.js.map +1 -0
  53. package/dist/packlets/conversion/index.js.map +1 -0
  54. package/dist/packlets/conversion/objectConverter.js.map +1 -0
  55. package/dist/packlets/conversion/stringConverter.js.map +1 -0
  56. package/dist/packlets/hash/crcNormalizer.js.map +1 -0
  57. package/dist/packlets/hash/hashingNormalizer.js.map +1 -0
  58. package/dist/packlets/hash/index.js.map +1 -0
  59. package/dist/packlets/logging/bootLogger.js.map +1 -0
  60. package/dist/packlets/logging/index.js +2 -0
  61. package/dist/packlets/logging/index.js.map +1 -0
  62. package/dist/packlets/logging/logReporter.js.map +1 -0
  63. package/dist/packlets/logging/logger.js +51 -18
  64. package/dist/packlets/logging/logger.js.map +1 -0
  65. package/dist/packlets/logging/multiLogger.js +104 -0
  66. package/dist/packlets/logging/multiLogger.js.map +1 -0
  67. package/dist/packlets/logging/retainingLogger.js +114 -0
  68. package/dist/packlets/logging/retainingLogger.js.map +1 -0
  69. package/dist/packlets/logging-interface/index.js +28 -0
  70. package/dist/packlets/logging-interface/index.js.map +1 -0
  71. package/dist/packlets/validation/array.js.map +1 -0
  72. package/dist/packlets/validation/boolean.js.map +1 -0
  73. package/dist/packlets/validation/classes.js.map +1 -0
  74. package/dist/packlets/validation/common.js.map +1 -0
  75. package/dist/packlets/validation/compositeId.js.map +1 -0
  76. package/dist/packlets/validation/field.js.map +1 -0
  77. package/dist/packlets/validation/genericValidator.js.map +1 -0
  78. package/dist/packlets/validation/index.js.map +1 -0
  79. package/dist/packlets/validation/number.js.map +1 -0
  80. package/dist/packlets/validation/object.js.map +1 -0
  81. package/dist/packlets/validation/oneOf.js.map +1 -0
  82. package/dist/packlets/validation/string.js.map +1 -0
  83. package/dist/packlets/validation/traits.js.map +1 -0
  84. package/dist/packlets/validation/typeGuard.js.map +1 -0
  85. package/dist/packlets/validation/validator.js.map +1 -0
  86. package/dist/packlets/validation/validatorBase.js.map +1 -0
  87. package/dist/packlets/validation/validators.js.map +1 -0
  88. package/dist/ts-utils.d.ts +1089 -59
  89. package/dist/tsdoc-metadata.json +1 -1
  90. package/lib/index.d.ts +2 -2
  91. package/lib/index.d.ts.map +1 -0
  92. package/lib/index.js +2 -1
  93. package/lib/index.js.map +1 -0
  94. package/lib/packlets/base/brand.d.ts.map +1 -0
  95. package/lib/packlets/base/brand.js.map +1 -0
  96. package/lib/packlets/base/index.d.ts +2 -0
  97. package/lib/packlets/base/index.d.ts.map +1 -0
  98. package/lib/packlets/base/index.js +2 -0
  99. package/lib/packlets/base/index.js.map +1 -0
  100. package/lib/packlets/base/mapResults.d.ts.map +1 -0
  101. package/lib/packlets/base/mapResults.js.map +1 -0
  102. package/lib/packlets/base/messageAggregator.d.ts.map +1 -0
  103. package/lib/packlets/base/messageAggregator.js.map +1 -0
  104. package/lib/packlets/base/normalize.d.ts +24 -0
  105. package/lib/packlets/base/normalize.d.ts.map +1 -0
  106. package/lib/packlets/base/normalize.js +53 -0
  107. package/lib/packlets/base/normalize.js.map +1 -0
  108. package/lib/packlets/base/result.d.ts +295 -1
  109. package/lib/packlets/base/result.d.ts.map +1 -0
  110. package/lib/packlets/base/result.js +330 -3
  111. package/lib/packlets/base/result.js.map +1 -0
  112. package/lib/packlets/base/shouldNotFail.d.ts +53 -0
  113. package/lib/packlets/base/shouldNotFail.d.ts.map +1 -0
  114. package/lib/packlets/base/shouldNotFail.js +129 -0
  115. package/lib/packlets/base/shouldNotFail.js.map +1 -0
  116. package/lib/packlets/base/utils.d.ts +12 -0
  117. package/lib/packlets/base/utils.d.ts.map +1 -0
  118. package/lib/packlets/base/utils.js.map +1 -0
  119. package/lib/packlets/base/uuid.d.ts +27 -0
  120. package/lib/packlets/base/uuid.d.ts.map +1 -0
  121. package/lib/packlets/base/uuid.js +59 -0
  122. package/lib/packlets/base/uuid.js.map +1 -0
  123. package/lib/packlets/collections/aggregatedResultMap.d.ts.map +1 -0
  124. package/lib/packlets/collections/aggregatedResultMap.js.map +1 -0
  125. package/lib/packlets/collections/collectible.d.ts.map +1 -0
  126. package/lib/packlets/collections/collectible.js.map +1 -0
  127. package/lib/packlets/collections/collector.d.ts +23 -9
  128. package/lib/packlets/collections/collector.d.ts.map +1 -0
  129. package/lib/packlets/collections/collector.js +23 -9
  130. package/lib/packlets/collections/collector.js.map +1 -0
  131. package/lib/packlets/collections/collectorValidator.d.ts +29 -5
  132. package/lib/packlets/collections/collectorValidator.d.ts.map +1 -0
  133. package/lib/packlets/collections/collectorValidator.js +6 -1
  134. package/lib/packlets/collections/collectorValidator.js.map +1 -0
  135. package/lib/packlets/collections/common.d.ts.map +1 -0
  136. package/lib/packlets/collections/common.js.map +1 -0
  137. package/lib/packlets/collections/converters.d.ts.map +1 -0
  138. package/lib/packlets/collections/converters.js.map +1 -0
  139. package/lib/packlets/collections/convertingCollector.d.ts +21 -3
  140. package/lib/packlets/collections/convertingCollector.d.ts.map +1 -0
  141. package/lib/packlets/collections/convertingCollector.js.map +1 -0
  142. package/lib/packlets/collections/convertingCollectorValidator.d.ts +22 -3
  143. package/lib/packlets/collections/convertingCollectorValidator.d.ts.map +1 -0
  144. package/lib/packlets/collections/convertingCollectorValidator.js.map +1 -0
  145. package/lib/packlets/collections/convertingResultMap.d.ts.map +1 -0
  146. package/lib/packlets/collections/convertingResultMap.js.map +1 -0
  147. package/lib/packlets/collections/index.d.ts +1 -0
  148. package/lib/packlets/collections/index.d.ts.map +1 -0
  149. package/lib/packlets/collections/index.js +1 -0
  150. package/lib/packlets/collections/index.js.map +1 -0
  151. package/lib/packlets/collections/keyValueConverters.d.ts.map +1 -0
  152. package/lib/packlets/collections/keyValueConverters.js.map +1 -0
  153. package/lib/packlets/collections/readOnlyConvertingResultMap.d.ts +13 -1
  154. package/lib/packlets/collections/readOnlyConvertingResultMap.d.ts.map +1 -0
  155. package/lib/packlets/collections/readOnlyConvertingResultMap.js +19 -1
  156. package/lib/packlets/collections/readOnlyConvertingResultMap.js.map +1 -0
  157. package/lib/packlets/collections/readonlyResultMap.d.ts +18 -7
  158. package/lib/packlets/collections/readonlyResultMap.d.ts.map +1 -0
  159. package/lib/packlets/collections/readonlyResultMap.js.map +1 -0
  160. package/lib/packlets/collections/resultMap.d.ts.map +1 -0
  161. package/lib/packlets/collections/resultMap.js.map +1 -0
  162. package/lib/packlets/collections/resultMapValidator.d.ts.map +1 -0
  163. package/lib/packlets/collections/resultMapValidator.js.map +1 -0
  164. package/lib/packlets/collections/retainingRingBuffer.d.ts +147 -0
  165. package/lib/packlets/collections/retainingRingBuffer.d.ts.map +1 -0
  166. package/lib/packlets/collections/retainingRingBuffer.js +163 -0
  167. package/lib/packlets/collections/retainingRingBuffer.js.map +1 -0
  168. package/lib/packlets/collections/utils.d.ts.map +1 -0
  169. package/lib/packlets/collections/utils.js.map +1 -0
  170. package/lib/packlets/collections/validatingCollector.d.ts +7 -3
  171. package/lib/packlets/collections/validatingCollector.d.ts.map +1 -0
  172. package/lib/packlets/collections/validatingCollector.js.map +1 -0
  173. package/lib/packlets/collections/validatingConvertingCollector.d.ts.map +1 -0
  174. package/lib/packlets/collections/validatingConvertingCollector.js.map +1 -0
  175. package/lib/packlets/collections/validatingConvertingResultMap.d.ts.map +1 -0
  176. package/lib/packlets/collections/validatingConvertingResultMap.js.map +1 -0
  177. package/lib/packlets/collections/validatingResultMap.d.ts +2 -1
  178. package/lib/packlets/collections/validatingResultMap.d.ts.map +1 -0
  179. package/lib/packlets/collections/validatingResultMap.js.map +1 -0
  180. package/lib/packlets/conversion/advancedConverters.d.ts.map +1 -0
  181. package/lib/packlets/conversion/advancedConverters.js.map +1 -0
  182. package/lib/packlets/conversion/baseConverter.d.ts +108 -19
  183. package/lib/packlets/conversion/baseConverter.d.ts.map +1 -0
  184. package/lib/packlets/conversion/baseConverter.js +107 -18
  185. package/lib/packlets/conversion/baseConverter.js.map +1 -0
  186. package/lib/packlets/conversion/basicConverters.d.ts +14 -0
  187. package/lib/packlets/conversion/basicConverters.d.ts.map +1 -0
  188. package/lib/packlets/conversion/basicConverters.js +24 -5
  189. package/lib/packlets/conversion/basicConverters.js.map +1 -0
  190. package/lib/packlets/conversion/converter.d.ts +9 -1
  191. package/lib/packlets/conversion/converter.d.ts.map +1 -0
  192. package/lib/packlets/conversion/converter.js +12 -0
  193. package/lib/packlets/conversion/converter.js.map +1 -0
  194. package/lib/packlets/conversion/converters.d.ts.map +1 -0
  195. package/lib/packlets/conversion/converters.js.map +1 -0
  196. package/lib/packlets/conversion/defaultingConverter.d.ts.map +1 -0
  197. package/lib/packlets/conversion/defaultingConverter.js.map +1 -0
  198. package/lib/packlets/conversion/index.d.ts.map +1 -0
  199. package/lib/packlets/conversion/index.js.map +1 -0
  200. package/lib/packlets/conversion/objectConverter.d.ts.map +1 -0
  201. package/lib/packlets/conversion/objectConverter.js.map +1 -0
  202. package/lib/packlets/conversion/stringConverter.d.ts.map +1 -0
  203. package/lib/packlets/conversion/stringConverter.js.map +1 -0
  204. package/lib/packlets/hash/crcNormalizer.d.ts.map +1 -0
  205. package/lib/packlets/hash/crcNormalizer.js.map +1 -0
  206. package/lib/packlets/hash/hashingNormalizer.d.ts.map +1 -0
  207. package/lib/packlets/hash/hashingNormalizer.js.map +1 -0
  208. package/lib/packlets/hash/index.d.ts.map +1 -0
  209. package/lib/packlets/hash/index.js.map +1 -0
  210. package/lib/packlets/logging/bootLogger.d.ts.map +1 -0
  211. package/lib/packlets/logging/bootLogger.js.map +1 -0
  212. package/lib/packlets/logging/index.d.ts +2 -0
  213. package/lib/packlets/logging/index.d.ts.map +1 -0
  214. package/lib/packlets/logging/index.js +2 -0
  215. package/lib/packlets/logging/index.js.map +1 -0
  216. package/lib/packlets/logging/logReporter.d.ts.map +1 -0
  217. package/lib/packlets/logging/logReporter.js.map +1 -0
  218. package/lib/packlets/logging/logger.d.ts +25 -70
  219. package/lib/packlets/logging/logger.d.ts.map +1 -0
  220. package/lib/packlets/logging/logger.js +54 -20
  221. package/lib/packlets/logging/logger.js.map +1 -0
  222. package/lib/packlets/logging/multiLogger.d.ts +54 -0
  223. package/lib/packlets/logging/multiLogger.d.ts.map +1 -0
  224. package/lib/packlets/logging/multiLogger.js +108 -0
  225. package/lib/packlets/logging/multiLogger.js.map +1 -0
  226. package/lib/packlets/logging/retainingLogger.d.ts +123 -0
  227. package/lib/packlets/logging/retainingLogger.d.ts.map +1 -0
  228. package/lib/packlets/logging/retainingLogger.js +118 -0
  229. package/lib/packlets/logging/retainingLogger.js.map +1 -0
  230. package/lib/packlets/logging-interface/index.d.ts +98 -0
  231. package/lib/packlets/logging-interface/index.d.ts.map +1 -0
  232. package/lib/packlets/logging-interface/index.js +32 -0
  233. package/lib/packlets/logging-interface/index.js.map +1 -0
  234. package/lib/packlets/validation/array.d.ts.map +1 -0
  235. package/lib/packlets/validation/array.js.map +1 -0
  236. package/lib/packlets/validation/boolean.d.ts.map +1 -0
  237. package/lib/packlets/validation/boolean.js.map +1 -0
  238. package/lib/packlets/validation/classes.d.ts.map +1 -0
  239. package/lib/packlets/validation/classes.js.map +1 -0
  240. package/lib/packlets/validation/common.d.ts.map +1 -0
  241. package/lib/packlets/validation/common.js.map +1 -0
  242. package/lib/packlets/validation/compositeId.d.ts.map +1 -0
  243. package/lib/packlets/validation/compositeId.js.map +1 -0
  244. package/lib/packlets/validation/field.d.ts.map +1 -0
  245. package/lib/packlets/validation/field.js.map +1 -0
  246. package/lib/packlets/validation/genericValidator.d.ts.map +1 -0
  247. package/lib/packlets/validation/genericValidator.js.map +1 -0
  248. package/lib/packlets/validation/index.d.ts.map +1 -0
  249. package/lib/packlets/validation/index.js.map +1 -0
  250. package/lib/packlets/validation/number.d.ts.map +1 -0
  251. package/lib/packlets/validation/number.js.map +1 -0
  252. package/lib/packlets/validation/object.d.ts.map +1 -0
  253. package/lib/packlets/validation/object.js.map +1 -0
  254. package/lib/packlets/validation/oneOf.d.ts.map +1 -0
  255. package/lib/packlets/validation/oneOf.js.map +1 -0
  256. package/lib/packlets/validation/string.d.ts.map +1 -0
  257. package/lib/packlets/validation/string.js.map +1 -0
  258. package/lib/packlets/validation/traits.d.ts.map +1 -0
  259. package/lib/packlets/validation/traits.js.map +1 -0
  260. package/lib/packlets/validation/typeGuard.d.ts.map +1 -0
  261. package/lib/packlets/validation/typeGuard.js.map +1 -0
  262. package/lib/packlets/validation/validator.d.ts.map +1 -0
  263. package/lib/packlets/validation/validator.js.map +1 -0
  264. package/lib/packlets/validation/validatorBase.d.ts +2 -1
  265. package/lib/packlets/validation/validatorBase.d.ts.map +1 -0
  266. package/lib/packlets/validation/validatorBase.js.map +1 -0
  267. package/lib/packlets/validation/validators.d.ts.map +1 -0
  268. package/lib/packlets/validation/validators.js.map +1 -0
  269. package/package.json +3 -3
  270. package/dist/test/helpers/jest/helpers/fsHelpers.js +0 -139
  271. package/dist/test/helpers/jest/helpers/index.js +0 -2
  272. package/dist/test/helpers/jest/index.js +0 -17
  273. package/dist/test/helpers/jest/matchers/index.js +0 -14
  274. package/dist/test/helpers/jest/matchers/toFail/index.js +0 -23
  275. package/dist/test/helpers/jest/matchers/toFail/predicate.js +0 -5
  276. package/dist/test/helpers/jest/matchers/toFailTest/index.js +0 -28
  277. package/dist/test/helpers/jest/matchers/toFailTest/predicate.js +0 -8
  278. package/dist/test/helpers/jest/matchers/toFailTestAndMatchSnapshot/index.js +0 -24
  279. package/dist/test/helpers/jest/matchers/toFailTestAndMatchSnapshot/predicate.js +0 -11
  280. package/dist/test/helpers/jest/matchers/toFailTestWith/index.js +0 -29
  281. package/dist/test/helpers/jest/matchers/toFailTestWith/predicate.js +0 -26
  282. package/dist/test/helpers/jest/matchers/toFailWith/index.js +0 -27
  283. package/dist/test/helpers/jest/matchers/toFailWith/predicate.js +0 -16
  284. package/dist/test/helpers/jest/matchers/toFailWithDetail/index.js +0 -27
  285. package/dist/test/helpers/jest/matchers/toFailWithDetail/predicate.js +0 -22
  286. package/dist/test/helpers/jest/matchers/toSucceed/index.js +0 -23
  287. package/dist/test/helpers/jest/matchers/toSucceed/predicate.js +0 -5
  288. package/dist/test/helpers/jest/matchers/toSucceedAndMatchInlineSnapshot/index.js +0 -24
  289. package/dist/test/helpers/jest/matchers/toSucceedAndMatchSnapshot/index.js +0 -24
  290. package/dist/test/helpers/jest/matchers/toSucceedAndSatisfy/index.js +0 -53
  291. package/dist/test/helpers/jest/matchers/toSucceedAndSatisfy/predicate.js +0 -17
  292. package/dist/test/helpers/jest/matchers/toSucceedWith/index.js +0 -27
  293. package/dist/test/helpers/jest/matchers/toSucceedWith/predicate.js +0 -12
  294. package/dist/test/helpers/jest/matchers/toSucceedWithDetail/index.js +0 -27
  295. package/dist/test/helpers/jest/matchers/toSucceedWithDetail/predicate.js +0 -17
  296. package/dist/test/helpers/jest/resolvers/cli.js +0 -10
  297. package/dist/test/helpers/jest/resolvers/ide.js +0 -10
  298. package/dist/test/helpers/jest/ts-utils.js +0 -2
  299. package/dist/test/helpers/jest/types/index.js +0 -3
  300. package/dist/test/helpers/jest/utils/matcherHelpers.js +0 -47
  301. package/dist/test/helpers/jest/utils/snapshotResolver.js +0 -11
  302. package/dist/test/unit/collections/helpers.js +0 -106
  303. package/dist/test/unit/hashTextEncodeCompat.js +0 -23
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readOnlyConvertingResultMap.js","sourceRoot":"","sources":["../../../src/packlets/collections/readOnlyConvertingResultMap.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,kCAAmG;AACnG,8CAAsD;AAuBtD,sGAAsG;AACtG,mGAAmG;AACnG,gIAAgI;AAChI,MAAM,6BAA6B,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAU,CAAC;AAe1E,6DAA6D;AAC7D,MAAM,2CAA2C,GAAgD,IAAI,CAAC;AAEtG;;;GAGG;AACU,QAAA,0BAA0B,GAAuC,6BAA6B,CAAC;AAE5G;;;;GAIG;AACU,QAAA,uBAAuB,GAGhC,uBAAU,CAAC,eAAe,CAA0B,kCAA0B,CAAC,CAAC;AA6BpF;;;;GAIG;AACH,MAAa,2BAA2B;IA4BtC;;;OAGG;IACH,YAAmB,MAAwE;;QACzF,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,MAAM,GAAG,IAAI,GAAG,EAAe,CAAC;QACrC,IAAI,CAAC,kBAAkB,GAAG,MAAA,MAAM,CAAC,iBAAiB,mCAAI,QAAQ,CAAC;QAC/D,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC;IAC/B,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,MAAM,CAClB,MAAwE;QAExE,OAAO,IAAA,oBAAa,EAAC,GAAG,EAAE,CAAC,IAAI,2BAA2B,CAAC,MAAM,CAAC,CAAC,CAAC;IACtE,CAAC;IAED;;OAEG;IACH,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IAC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,EAAE,CAAC;YACzB,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QACzC,IAAI,MAAM,CAAC,SAAS,EAAE,EAAE,CAAC;YACvB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;YACnC,OAAO,MAAM,CAAC,KAAK,CAAC;QACtB,CAAC;QAED,QAAQ,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAChC,KAAK,MAAM;gBACT,MAAM,IAAI,KAAK,CAAC,8BAA8B,GAAG,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;YAC3E,KAAK,MAAM;gBACT,MAAA,IAAI,CAAC,OAAO,0CAAE,GAAG,CAAC,SAAS,EAAE,8BAA8B,GAAG,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;gBACtF,MAAM;QACV,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;OAGG;IACO,gBAAgB,CAAC,GAAO;QAChC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;IAED;;OAEG;IACO,WAAW;QACnB,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;CACF;AAhND,kEAgNC","sourcesContent":["/*\n * Copyright (c) 2026 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { captureResult, DetailedResult, failWithDetail, Result, succeedWithDetail } from '../base';\nimport { Converter, Converters } from '../conversion';\nimport { ILogger } from '../logging-interface';\nimport { KeyValueEntry } from './common';\nimport { IReadOnlyResultMap, ResultMapForEachCb, ResultMapResultDetail } from './readonlyResultMap';\n\n/**\n * A function that converts a source value to a target value.\n * @public\n */\nexport type ConvertingResultMapValueConverter<TK extends string, TSRC, TTARGET> = (\n src: TSRC,\n key: TK\n) => Result<TTARGET>;\n\n/**\n * Error handling behavior for conversion failures during iteration.\n * - `'ignore'`: Silently skip failed conversions (default behavior)\n * - `'warn'`: Log warning and skip failed conversions\n * - `'fail'`: Throw error on first conversion failure\n * @public\n */\nexport type ConversionErrorHandling = 'ignore' | 'warn' | 'fail';\n\n// Untyped (literal-tuple-inferred) source of truth for allConversionErrorHandling, kept separate from\n// the widened public export below so the exhaustiveness check actually inspects the literal values\n// instead of being widened away to {@link Collections.ConversionErrorHandling | ConversionErrorHandling} before the check runs.\nconst conversionErrorHandlingValues = ['ignore', 'warn', 'fail'] as const;\n\n/**\n * Compile-time exhaustiveness guard ensuring {@link conversionErrorHandlingValues} exactly matches every\n * member of {@link Collections.ConversionErrorHandling | ConversionErrorHandling}. Adding or removing a\n * union member without updating the array fails the build.\n * Deliberately not exported - this exists only to force the compiler to evaluate the check below.\n */\ntype _ConversionErrorHandlingExhaustivenessCheck = [\n Exclude<ConversionErrorHandling, (typeof conversionErrorHandlingValues)[number]>,\n Exclude<(typeof conversionErrorHandlingValues)[number], ConversionErrorHandling>\n] extends [never, never]\n ? true\n : never;\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nconst _conversionErrorHandlingExhaustivenessCheck: _ConversionErrorHandlingExhaustivenessCheck = true;\n\n/**\n * Exhaustive list of all {@link Collections.ConversionErrorHandling | ConversionErrorHandling} values.\n * @public\n */\nexport const allConversionErrorHandling: readonly ConversionErrorHandling[] = conversionErrorHandlingValues;\n\n/**\n * A ready-made {@link Converter | Converter} for\n * {@link Collections.ConversionErrorHandling | ConversionErrorHandling} values.\n * @public\n */\nexport const conversionErrorHandling: Converter<\n ConversionErrorHandling,\n ReadonlyArray<ConversionErrorHandling>\n> = Converters.enumeratedValue<ConversionErrorHandling>(allConversionErrorHandling);\n\n/**\n * Parameters for constructing a {@link Collections.ReadOnlyConvertingResultMap | ReadOnlyConvertingResultMap}.\n * @public\n */\nexport interface IReadOnlyConvertingResultMapConstructorParams<TK extends string, TSRC, TTARGET> {\n /**\n * The inner map containing source values.\n */\n inner: IReadOnlyResultMap<TK, TSRC>;\n\n /**\n * The converter function to transform source values to target values.\n */\n converter: ConvertingResultMapValueConverter<TK, TSRC, TTARGET>;\n\n /**\n * Error handling behavior for conversion failures during iteration.\n * Defaults to `'ignore'` (silently skip failed conversions).\n */\n onConversionError?: ConversionErrorHandling;\n\n /**\n * Optional logger for warnings when `onConversionError` is `'warn'`.\n */\n logger?: ILogger;\n}\n\n/**\n * A read-only result map that wraps an inner {@link Collections.IReadOnlyResultMap | IReadOnlyResultMap}\n * of source type and returns lazily-converted, cached values of a target type.\n * @public\n */\nexport class ReadOnlyConvertingResultMap<TK extends string, TSRC, TTARGET>\n implements IReadOnlyResultMap<TK, TTARGET>\n{\n /**\n * The inner map containing source values.\n */\n protected readonly _inner: IReadOnlyResultMap<TK, TSRC>;\n\n /**\n * The converter function to transform source values to target values.\n */\n protected readonly _converter: ConvertingResultMapValueConverter<TK, TSRC, TTARGET>;\n\n /**\n * Cache of converted target values.\n */\n protected readonly _cache: Map<TK, TTARGET>;\n\n /**\n * Error handling behavior for conversion failures during iteration.\n */\n protected readonly _onConversionError: ConversionErrorHandling;\n\n /**\n * Optional logger for warnings.\n */\n protected readonly _logger?: ILogger;\n\n /**\n * Constructs a new {@link Collections.ReadOnlyConvertingResultMap | ReadOnlyConvertingResultMap}.\n * @param params - Parameters for constructing the map.\n */\n public constructor(params: IReadOnlyConvertingResultMapConstructorParams<TK, TSRC, TTARGET>) {\n this._inner = params.inner;\n this._converter = params.converter;\n this._cache = new Map<TK, TTARGET>();\n this._onConversionError = params.onConversionError ?? 'ignore';\n this._logger = params.logger;\n }\n\n /**\n * Creates a new {@link Collections.ReadOnlyConvertingResultMap | ReadOnlyConvertingResultMap}.\n * @param params - Parameters for constructing the map.\n * @returns `Success` with the new map, or `Failure` with error details if an error occurred.\n */\n public static create<TK extends string, TSRC, TTARGET>(\n params: IReadOnlyConvertingResultMapConstructorParams<TK, TSRC, TTARGET>\n ): Result<ReadOnlyConvertingResultMap<TK, TSRC, TTARGET>> {\n return captureResult(() => new ReadOnlyConvertingResultMap(params));\n }\n\n /**\n * The number of entries in the map.\n */\n public get size(): number {\n return this._inner.size;\n }\n\n /**\n * Gets a converted value from the map by key.\n * @param key - The key to retrieve.\n * @returns `Success` with the converted value and detail `exists` if the key was found,\n * `Failure` with detail `not-found` if the key was not found, or `Failure` with\n * detail `invalid-value` if conversion failed.\n */\n public get(key: TK): DetailedResult<TTARGET, ResultMapResultDetail> {\n const cached = this._cache.get(key);\n if (cached !== undefined) {\n return succeedWithDetail(cached, 'exists');\n }\n\n return this._inner.get(key).onSuccess((src) => {\n return this._convertAndCache(key, src);\n });\n }\n\n /**\n * Checks if the map contains a key.\n * @param key - The key to check.\n * @returns `true` if the key exists, `false` otherwise.\n */\n public has(key: TK): boolean {\n return this._inner.has(key);\n }\n\n /**\n * Returns an iterator over the map entries with converted values.\n * @returns An iterator over the map entries.\n */\n public *entries(): IterableIterator<KeyValueEntry<TK, TTARGET>> {\n for (const [key, src] of this._inner.entries()) {\n const target = this._getOrConvert(key, src);\n if (target !== undefined) {\n yield [key, target];\n }\n }\n }\n\n /**\n * Returns an iterator over the map keys.\n * @returns An iterator over the map keys.\n */\n public keys(): IterableIterator<TK> {\n return this._inner.keys();\n }\n\n /**\n * Returns an iterator over the converted map values.\n * @returns An iterator over the map values.\n */\n public *values(): IterableIterator<TTARGET> {\n for (const [key, src] of this._inner.entries()) {\n const target = this._getOrConvert(key, src);\n if (target !== undefined) {\n yield target;\n }\n }\n }\n\n /**\n * Calls a callback for each entry in the map with converted values.\n * @param cb - The callback to call for each entry.\n * @param thisArg - Optional `this` argument for the callback.\n */\n public forEach(cb: ResultMapForEachCb<TK, TTARGET>, thisArg?: unknown): void {\n for (const [key, src] of this._inner.entries()) {\n const target = this._getOrConvert(key, src);\n if (target !== undefined) {\n cb.call(thisArg, target, key, this);\n }\n }\n }\n\n /**\n * Gets an iterator over the map entries.\n * @returns An iterator over the map entries.\n */\n public [Symbol.iterator](): IterableIterator<KeyValueEntry<TK, TTARGET>> {\n return this.entries();\n }\n\n /**\n * Gets a read-only version of this map.\n * @returns A read-only version of this map.\n */\n public toReadOnly(): IReadOnlyResultMap<TK, TTARGET> {\n return this;\n }\n\n /**\n * Converts a source value to a target value and caches the result.\n * @param key - The key of the value.\n * @param src - The source value to convert.\n * @returns `Success` with the converted value if successful, `Failure` otherwise.\n */\n protected _convertAndCache(key: TK, src: TSRC): DetailedResult<TTARGET, ResultMapResultDetail> {\n const result = this._converter(src, key);\n if (result.isFailure()) {\n return failWithDetail(result.message, 'invalid-value');\n }\n this._cache.set(key, result.value);\n return succeedWithDetail(result.value, 'exists');\n }\n\n /**\n * Gets a cached value or converts and caches a source value.\n * Used by iterators. Handles conversion failures according to `_onConversionError`.\n * @param key - The key of the value.\n * @param src - The source value to convert if not cached.\n * @returns The converted value, or `undefined` if conversion failed.\n * @throws Error if `_onConversionError` is `'fail'` and conversion fails.\n */\n protected _getOrConvert(key: TK, src: TSRC): TTARGET | undefined {\n const cached = this._cache.get(key);\n if (cached !== undefined) {\n return cached;\n }\n\n const result = this._converter(src, key);\n if (result.isSuccess()) {\n this._cache.set(key, result.value);\n return result.value;\n }\n\n switch (this._onConversionError) {\n case 'fail':\n throw new Error(`Conversion failed for key '${key}': ${result.message}`);\n case 'warn':\n this._logger?.log('warning', `Conversion failed for key '${key}': ${result.message}`);\n break;\n }\n return undefined;\n }\n\n /**\n * Clears a single entry from the cache.\n * @param key - The key to clear from the cache.\n */\n protected _clearCacheEntry(key: TK): void {\n this._cache.delete(key);\n }\n\n /**\n * Clears all entries from the cache.\n */\n protected _clearCache(): void {\n this._cache.clear();\n }\n}\n"]}
@@ -18,31 +18,42 @@ export type ResultMapForEachCb<TK extends string = string, TE = unknown> = (valu
18
18
  */
19
19
  export interface IReadOnlyResultMap<TK extends string = string, TV = unknown> {
20
20
  /**
21
- * {@inheritDoc Collections.ResultMap.size}
21
+ * Returns the number of entries in the map.
22
22
  */
23
23
  readonly size: number;
24
24
  /**
25
- * {@inheritDoc Collections.ResultMap.entries}
25
+ * Returns an iterator over the map entries.
26
+ * @returns An iterator over the map entries.
26
27
  */
27
28
  entries(): IterableIterator<KeyValueEntry<TK, TV>>;
28
29
  /**
29
- * {@inheritDoc Collections.ResultMap.forEach}
30
+ * Calls a function for each entry in the map.
31
+ * @param cb - The function to call for each entry.
32
+ * @param arg - An optional argument to pass to the callback.
30
33
  */
31
34
  forEach(cb: ResultMapForEachCb, arg?: unknown): void;
32
35
  /**
33
- * {@inheritDoc Collections.ResultMap.get}
36
+ * Gets a value from the map.
37
+ * @param key - The key to retrieve.
38
+ * @returns `Success` with the value and detail `exists` if the key was found,
39
+ * `Failure` with detail `not-found` if the key was not found or with detail
40
+ * `invalid-key` if the key is invalid.
34
41
  */
35
42
  get(key: TK): DetailedResult<TV, ResultMapResultDetail>;
36
43
  /**
37
- * {@inheritDoc Collections.ResultMap.has}
44
+ * Returns `true` if the map contains a key.
45
+ * @param key - The key to check.
46
+ * @returns `true` if the key exists, `false` otherwise.
38
47
  */
39
48
  has(key: TK): boolean;
40
49
  /**
41
- * {@inheritDoc Collections.ResultMap.keys}
50
+ * Returns an iterator over the map keys.
51
+ * @returns An iterator over the map keys.
42
52
  */
43
53
  keys(): IterableIterator<TK>;
44
54
  /**
45
- * {@inheritDoc Collections.ResultMap.values}
55
+ * Returns an iterator over the map values.
56
+ * @returns An iterator over the map values.
46
57
  */
47
58
  values(): IterableIterator<TV>;
48
59
  /**
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readonlyResultMap.d.ts","sourceRoot":"","sources":["../../../src/packlets/collections/readonlyResultMap.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAC7B,OAAO,GACP,SAAS,GACT,QAAQ,GACR,SAAS,GACT,aAAa,GACb,eAAe,GACf,WAAW,GACX,SAAS,GACT,SAAS,CAAC;AAEd;;;GAGG;AACH,MAAM,MAAM,kBAAkB,CAAC,EAAE,SAAS,MAAM,GAAG,MAAM,EAAE,EAAE,GAAG,OAAO,IAAI,CACzE,KAAK,EAAE,EAAE,EACT,GAAG,EAAE,EAAE,EACP,GAAG,EAAE,kBAAkB,CAAC,EAAE,EAAE,EAAE,CAAC,EAC/B,OAAO,CAAC,EAAE,OAAO,KACd,IAAI,CAAC;AAEV;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB,CAAC,EAAE,SAAS,MAAM,GAAG,MAAM,EAAE,EAAE,GAAG,OAAO;IAC1E;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,OAAO,IAAI,gBAAgB,CAAC,aAAa,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;IAEnD;;;;OAIG;IACH,OAAO,CAAC,EAAE,EAAE,kBAAkB,EAAE,GAAG,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAErD;;;;;;OAMG;IACH,GAAG,CAAC,GAAG,EAAE,EAAE,GAAG,cAAc,CAAC,EAAE,EAAE,qBAAqB,CAAC,CAAC;IAExD;;;;OAIG;IACH,GAAG,CAAC,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC;IAEtB;;;OAGG;IACH,IAAI,IAAI,gBAAgB,CAAC,EAAE,CAAC,CAAC;IAE7B;;;OAGG;IACH,MAAM,IAAI,gBAAgB,CAAC,EAAE,CAAC,CAAC;IAE/B;;;OAGG;IACH,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC,aAAa,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;CAC9D"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readonlyResultMap.js","sourceRoot":"","sources":["../../../src/packlets/collections/readonlyResultMap.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { DetailedResult } from '../base';\nimport { KeyValueEntry } from './common';\n\n/**\n * Additional success or failure details for {@link Collections.ResultMap | ResultMap} calls.\n * @public\n */\nexport type ResultMapResultDetail =\n | 'added'\n | 'deleted'\n | 'exists'\n | 'failure'\n | 'invalid-key'\n | 'invalid-value'\n | 'not-found'\n | 'success'\n | 'updated';\n\n/**\n * Callback for {@link Collections.ResultMap | ResultMap} `forEach` method.\n * @public\n */\nexport type ResultMapForEachCb<TK extends string = string, TE = unknown> = (\n value: TE,\n key: TK,\n map: IReadOnlyResultMap<TK, TE>,\n thisArg?: unknown\n) => void;\n\n/**\n * A readonly `ReadonlyMap<TK, TV>`-like object which reports success or failure\n * with additional details using the\n * {@link https://github.com/ErikFortune/fgv/tree/main/libraries/ts-utils#the-result-pattern | result pattern}.\n * @public\n */\nexport interface IReadOnlyResultMap<TK extends string = string, TV = unknown> {\n /**\n * Returns the number of entries in the map.\n */\n readonly size: number;\n\n /**\n * Returns an iterator over the map entries.\n * @returns An iterator over the map entries.\n */\n entries(): IterableIterator<KeyValueEntry<TK, TV>>;\n\n /**\n * Calls a function for each entry in the map.\n * @param cb - The function to call for each entry.\n * @param arg - An optional argument to pass to the callback.\n */\n forEach(cb: ResultMapForEachCb, arg?: unknown): void;\n\n /**\n * Gets a value from the map.\n * @param key - The key to retrieve.\n * @returns `Success` with the value and detail `exists` if the key was found,\n * `Failure` with detail `not-found` if the key was not found or with detail\n * `invalid-key` if the key is invalid.\n */\n get(key: TK): DetailedResult<TV, ResultMapResultDetail>;\n\n /**\n * Returns `true` if the map contains a key.\n * @param key - The key to check.\n * @returns `true` if the key exists, `false` otherwise.\n */\n has(key: TK): boolean;\n\n /**\n * Returns an iterator over the map keys.\n * @returns An iterator over the map keys.\n */\n keys(): IterableIterator<TK>;\n\n /**\n * Returns an iterator over the map values.\n * @returns An iterator over the map values.\n */\n values(): IterableIterator<TV>;\n\n /**\n * Gets an iterator over the map entries.\n * @returns An iterator over the map entries.\n */\n [Symbol.iterator](): IterableIterator<KeyValueEntry<TK, TV>>;\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resultMap.d.ts","sourceRoot":"","sources":["../../../src/packlets/collections/resultMap.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAiB,cAAc,EAAkB,MAAM,EAA8B,MAAM,SAAS,CAAC;AAC5G,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAGpG;;;GAGG;AACH,MAAM,WAAW,2BAA2B,CAAC,EAAE,SAAS,MAAM,GAAG,MAAM,EAAE,EAAE,GAAG,OAAO;IACnF,OAAO,CAAC,EAAE,QAAQ,CAAC,aAAa,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;CAC3C;AAED;;;GAGG;AACH,MAAM,MAAM,qBAAqB,CAAC,EAAE,SAAS,MAAM,GAAG,MAAM,EAAE,EAAE,GAAG,OAAO,IAAI,CAAC,GAAG,EAAE,EAAE,KAAK,MAAM,CAAC,EAAE,CAAC,CAAC;AAEtG;;;GAGG;AACH,MAAM,WAAW,UAAU,CAAC,EAAE,SAAS,MAAM,GAAG,MAAM,EAAE,EAAE,GAAG,OAAO,CAAE,SAAQ,kBAAkB,CAAC,EAAE,EAAE,EAAE,CAAC;IACtG;;;;;;;OAOG;IACH,GAAG,CAAC,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,GAAG,cAAc,CAAC,EAAE,EAAE,qBAAqB,CAAC,CAAC;IAEnE;;;;;;;;OAQG;IACH,GAAG,CAAC,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,GAAG,cAAc,CAAC,EAAE,EAAE,qBAAqB,CAAC,CAAC;IAEnE;;;;;;;;OAQG;IACH,MAAM,CAAC,GAAG,EAAE,EAAE,EAAE,K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OAAO,IAAA,qBAAc,EAAC,GAAG,GAAG,cAAc,EAAE,WAAW,CAAC,CAAC;IAC3D,CAAC;IAED;;;OAGG;IACI,MAAM;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;IAC9B,CAAC;IAED;;;OAGG;IACI,CAAC,MAAM,CAAC,QAAQ,CAAC;QACtB,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;IACxC,CAAC;IAED;;;OAGG;IACI,UAAU;QACf,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;OAMG;IACO,wBAAwB,CAChC,KAAyC;QAEzC,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC;IACrC,CAAC;CACF;AAlRD,8BAkRC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { captureResult, DetailedResult, failWithDetail, Result, succeed, succeedWithDetail } from '../base';\nimport { KeyValueEntry } from './common';\nimport { IReadOnlyResultMap, ResultMapForEachCb, ResultMapResultDetail } from './readonlyResultMap';\nimport { isIterable } from './utils';\n\n/**\n * Parameters for constructing a {@link Collections.ResultMap | ResultMap}.\n * @public\n */\nexport interface IResultMapConstructorParams<TK extends string = string, TV = unknown> {\n entries?: Iterable<KeyValueEntry<TK, TV>>;\n}\n\n/**\n * Deferred constructor for the {@link Collections.ResultMap.getOrAdd | getOrAdd} method.\n * @public\n */\nexport type ResultMapValueFactory<TK extends string = string, TV = unknown> = (key: TK) => Result<TV>;\n\n/**\n * Interface for a mutable {@link Collections.ResultMap | ResultMap}.\n * @public\n */\nexport interface IResultMap<TK extends string = string, TV = unknown> extends IReadOnlyResultMap<TK, TV> {\n /**\n * Sets a key/value pair in the map if the key does not already exist.\n * @param key - The key to set.\n * @param value - The value to set.\n * @returns `Success` with the value and detail `added` if the key was added,\n * `Failure` with detail `exists` if the key already exists. Fails with detail\n * 'invalid-key' or 'invalid-value' and an error message if either is invalid.\n */\n add(key: TK, value: TV): DetailedResult<TV, ResultMapResultDetail>;\n\n /**\n * Sets a key/value pair in the map regardless of whether the key already exists.\n * @param key - The key to set.\n * @param value - The value to set.\n * @returns `Success` with the new value and the detail `updated` if the\n * key was found and updated, `Success` with the new value and detail\n * `added` if the key was not found and added. Fails with detail\n * 'invalid-key' or 'invalid-value' and an error message if either is invalid.\n */\n set(key: TK, value: TV): DetailedResult<TV, ResultMapResultDetail>;\n\n /**\n * Updates the value associated with a key in the map.\n * @param key - The key to update.\n * @param value - The value to set.\n * @returns `Success` with the value and detail 'updated' if the key was found\n * and the value updated, `Failure` an error message and with detail `not-found`\n * if the key was not found, or with detail 'invalid-key' or 'invalid-value'\n * if either is invalid.\n */\n update(key: TK, value: TV): DetailedResult<TV, ResultMapResultDetail>;\n\n /**\n * Deletes a key from the map.\n * @param key - The key to delete.\n * @returns `Success` with the previous value and the detail 'deleted'\n * if the key was found and deleted, `Failure` with detail 'not-found'\n * if the key was not found, or with detail 'invalid-key' if the key is invalid.\n */\n delete(key: TK): DetailedResult<TV, ResultMapResultDetail>;\n\n /**\n * Gets a value from the map.\n * @param key - The key to retrieve.\n * @returns `Success` with the value and detail `exists` if the key was found,\n * `Failure` with detail `not-found` if the key was not found or with detail\n * `invalid-key` if the key is invalid.\n */\n get(key: TK): DetailedResult<TV, ResultMapResultDetail>;\n\n /**\n * Gets a value from the map, or adds a supplied value if it does not exist.\n * @param key - The key to be retrieved or created.\n * @param value - The value to add if the key does not exist.\n * @returns `Success` with the value and detail `exists` if the key was found,\n * `Success` with the value and detail `added` if the key was not found and added.\n * Fails with detail 'invalid-key' or 'invalid-value' and an error message if either\n * is invalid.\n * {@label WITH_VALUE}\n */\n getOrAdd(key: TK, value: TV): DetailedResult<TV, ResultMapResultDetail>;\n\n /**\n * Gets a value from the map, or adds a value created by a factory function if it does not exist.\n * @param key - The key of the element to be retrieved or created.\n * @param factory - A {@link Collections.ResultMapValueFactory | factory function} to create the value if\n * the key does not exist.\n * @returns `Success` with the value and detail `exists` if the key was found, `Success` with\n * the value and detail `added` if the key was not found and added. Fails with detail 'invalid-key'\n * or 'invalid-value' and an error message if either is invalid.\n * {@label WITH_FACTORY}\n */\n getOrAdd(key: TK, factory: ResultMapValueFactory<TK, TV>): DetailedResult<TV, ResultMapResultDetail>;\n\n /**\n * Returns an iterator over the map entries.\n * @returns An iterator over the map entries.\n */\n entries(): IterableIterator<KeyValueEntry<TK, TV>>;\n\n /**\n * Returns the number of entries in the map.\n */\n readonly size: number;\n\n /**\n * Returns an iterator over the map keys.\n * @returns An iterator over the map keys.\n */\n keys(): IterableIterator<TK>;\n\n /**\n * Returns an iterator over the map values.\n * @returns An iterator over the map values.\n */\n values(): IterableIterator<TV>;\n\n /**\n * Calls a function for each entry in the map.\n * @param cb - The function to call for each entry.\n * @param arg - An optional argument to pass to the callback.\n */\n forEach(cb: ResultMapForEachCb<TK, TV>, arg?: unknown): void;\n\n /**\n * Clears all entries from the map.\n */\n clear(): void;\n\n /**\n * Gets a readonly version of this map.\n */\n toReadOnly(): IReadOnlyResultMap<TK, TV>;\n}\n\n/**\n * A {@link Collections.ResultMap | ResultMap} class as a `Map<TK, TV>`-like object which\n * reports success or failure with additional details using the\n * {@link https://github.com/ErikFortune/fgv/tree/main/libraries/ts-utils#the-result-pattern | result pattern}.\n * @public\n */\nexport class ResultMap<TK extends string = string, TV = unknown> implements IResultMap<TK, TV> {\n /**\n * Protected raw access to the inner `Map<TK, TV>` object.\n * @public\n */\n protected readonly _inner: Map<TK, TV>;\n\n /**\n * Constructs a new {@link Collections.ResultMap | ResultMap}.\n * @param iterable - An iterable to initialize the map.\n */\n public constructor(iterable?: Iterable<KeyValueEntry<TK, TV>>);\n\n /**\n * Constructs a new {@link Collections.ResultMap | ResultMap}.\n * @param params - An optional set of parameters to configure the map.\n */\n public constructor(params: IResultMapConstructorParams);\n\n /**\n * Constructs a new {@link Collections.ResultMap | ResultMap}.\n * @param iterableOrParams - An iterable to initialize the map, or a set of parameters\n * to configure the map.\n */\n public constructor(\n iterableOrParams?: Iterable<KeyValueEntry<TK, TV>> | IResultMapConstructorParams<TK, TV>\n ) {\n const params = isIterable(iterableOrParams) ? { entries: iterableOrParams } : iterableOrParams ?? {};\n this._inner = new Map(params.entries);\n }\n\n /**\n * Creates a new {@link Collections.ResultMap | ResultMap}.\n * @param elements - An optional iterable to initialize the map.\n * @returns `Success` with the new map, or `Failure` with error details\n * if an error occurred.\n * @public\n */\n public static create<TK extends string = string, TV = unknown>(\n elements: Iterable<KeyValueEntry<TK, TV>>\n ): Result<ResultMap<TK, TV>>;\n\n /**\n * Creates a new {@link Collections.ResultMap | ResultMap}.\n * @param params - An optional set of parameters to configure the map.\n * @returns `Success` with the new map, or `Failure` with error details\n * if an error occurred.\n * @public\n */\n public static create<TK extends string = string, TV = unknown>(\n params?: IResultMapConstructorParams<TK, TV>\n ): Result<ResultMap<TK, TV>>;\n\n /**\n * Creates a new {@link Collections.ResultMap | ResultMap}.\n * @param elementsOrParams - An optional iterable to initialize the map, or a set of parameters\n * to configure the map.\n * @returns `Success` with the new map, or `Failure` with error details\n * if an error occurred.\n * @public\n */\n public static create<TK extends string = string, TV = unknown>(\n elementsOrParams?: Iterable<KeyValueEntry<TK, TV>> | IResultMapConstructorParams<TK, TV>\n ): Result<ResultMap<TK, TV>> {\n return captureResult(() => new ResultMap(elementsOrParams as IResultMapConstructorParams<TK, TV>));\n }\n\n /**\n * Sets a key/value pair in the map if the key does not already exist.\n * @param key - The key to set.\n * @param value - The value to set.\n * @returns `Success` with the value and detail `added` if the key was added,\n * `Failure` with detail `exists` if the key already exists. Fails with detail\n * 'invalid-key' or 'invalid-value' and an error message if either is invalid.\n */\n public add(key: TK, value: TV): DetailedResult<TV, ResultMapResultDetail> {\n if (this._inner.has(key)) {\n return failWithDetail(`${key}: already exists.`, 'exists');\n }\n this._inner.set(key, value);\n return succeedWithDetail(value, 'added');\n }\n\n /**\n * Clears the map.\n */\n public clear(): void {\n this._inner.clear();\n }\n\n /**\n * Deletes a key from the map.\n * @param key - The key to delete.\n * @returns `Success` with the previous value and the detail 'deleted'\n * if the key was found and deleted, `Failure` with detail 'not-found'\n * if the key was not found, or with detail 'invalid-key' if the key is invalid.\n */\n public delete(key: TK): DetailedResult<TV, ResultMapResultDetail> {\n const was = this._inner.get(key);\n if (this._inner.delete(key)) {\n return succeedWithDetail(was!, 'deleted');\n }\n return failWithDetail(`${key}: not found.`, 'not-found');\n }\n\n /**\n * Returns an iterator over the map entries.\n * @returns An iterator over the map entries.\n */\n public entries(): IterableIterator<KeyValueEntry<TK, TV>> {\n return this._inner.entries();\n }\n\n /**\n * Calls a function for each entry in the map.\n * @param cb - The function to call for each entry.\n * @param arg - An optional argument to pass to the callback.\n */\n public forEach(cb: ResultMapForEachCb<TK, TV>, arg?: unknown): void {\n for (const [key, value] of this._inner.entries()) {\n cb(value, key as TK, this, arg);\n }\n }\n\n /**\n * Gets a value from the map.\n * @param key - The key to retrieve.\n * @returns `Success` with the value and detail `exists` if the key was found,\n * `Failure` with detail `not-found` if the key was not found or with detail\n * `invalid-key` if the key is invalid.\n */\n public get(key: TK): DetailedResult<TV, ResultMapResultDetail> {\n if (this._inner.has(key)) {\n return succeedWithDetail(this._inner.get(key)!, 'exists');\n }\n return failWithDetail(`${key}: not found.`, 'not-found');\n }\n\n /**\n * Gets a value from the map, or adds a supplied value it if it does not exist.\n * @param key - The key to be retrieved or created.\n * @param value - The value to add if the key does not exist.\n * @returns `Success` with the value and detail `exists` if the key was found,\n * `Success` with the value and detail `added` if the key was not found and added.\n * Fails with detail 'invalid-key' or 'invalid-value' and an error message if either\n * is invalid.\n * {@label WITH_VALUE}\n */\n public getOrAdd(key: TK, value: TV): DetailedResult<TV, ResultMapResultDetail>;\n\n /**\n * Gets a value from the map, or adds a value created by a factory function if it does not exist.\n * @param key - The key of the element to be retrieved or created.\n * @param factory - A {@link Collections.ResultMapValueFactory | factory function} to create the value if\n * the key does not exist.\n * @returns `Success` with the value and detail `exists` if the key was found, `Success` with\n * the value and detail `added` if the key was not found and added. Fails with detail 'invalid-key'\n * or 'invalid-value' and an error message if either is invalid.\n * {@label WITH_FACTORY}\n */\n public getOrAdd(key: TK, factory: ResultMapValueFactory<TK, TV>): DetailedResult<TV, ResultMapResultDetail>;\n public getOrAdd(\n key: TK,\n valueOrFactory: TV | ResultMapValueFactory<TK, TV>\n ): DetailedResult<TV, ResultMapResultDetail> {\n if (this._inner.has(key)) {\n return succeedWithDetail(this._inner.get(key)!, 'exists');\n }\n\n const factory: ResultMapValueFactory<TK, TV> = this._isResultMapValueFactory(valueOrFactory)\n ? valueOrFactory\n : () => succeed(valueOrFactory);\n\n return factory(key)\n .onSuccess((val) => {\n this._inner.set(key, val);\n return succeedWithDetail(val, 'added');\n })\n .withDetail('invalid-value', 'added');\n }\n\n /**\n * Returns `true` if the map contains a key.\n * @param key - The key to check.\n * @returns `true` if the key exists, `false` otherwise.\n */\n public has(key: TK): boolean {\n return this._inner.has(key);\n }\n\n /**\n * Returns an iterator over the map keys.\n * @returns An iterator over the map keys.\n */\n public keys(): IterableIterator<TK> {\n return this._inner.keys();\n }\n\n /**\n * Sets a key/value pair in the map.\n * @param key - The key to set.\n * @param value - The value to set.\n * @returns `Success` with the new value and the detail `updated` if the\n * key was found and updated, `Success` with the new value and detail\n * `added` if the key was not found and added. Fails with detail\n * 'invalid-key' or 'invalid-value' and an error message if either is invalid.\n */\n public set(key: TK, value: TV): DetailedResult<TV, ResultMapResultDetail> {\n const detail: ResultMapResultDetail = this._inner.has(key) ? 'updated' : 'added';\n this._inner.set(key, value);\n return succeedWithDetail(value, detail);\n }\n\n /**\n * Returns the number of entries in the map.\n */\n public get size(): number {\n return this._inner.size;\n }\n\n /**\n * Updates an existing key in the map - the map is not updated if the key does\n * not exist.\n * @param key - The key to update.\n * @param value - The value to set.\n * @returns `Success` with the value and detail 'exists' if the key was found\n * and the value updated, `Failure` an error message and with detail `not-found`\n * if the key was not found, or with detail 'invalid-key' or 'invalid-value'\n * if either is invalid.\n */\n public update(key: TK, value: TV): DetailedResult<TV, ResultMapResultDetail> {\n if (this._inner.has(key)) {\n this._inner.set(key, value);\n return succeedWithDetail(value, 'updated');\n }\n return failWithDetail(`${key}: not found.`, 'not-found');\n }\n\n /**\n * Returns an iterator over the map values.\n * @returns An iterator over the map values.\n */\n public values(): IterableIterator<TV> {\n return this._inner.values();\n }\n\n /**\n * Gets an iterator over the map entries.\n * @returns An iterator over the map entries.\n */\n public [Symbol.iterator](): IterableIterator<KeyValueEntry<TK, TV>> {\n return this._inner[Symbol.iterator]();\n }\n\n /**\n * Gets a readonly version of this map.\n * @returns A readonly version of this map.\n */\n public toReadOnly(): IReadOnlyResultMap<TK, TV> {\n return this;\n }\n\n /**\n * Determines if a value is a {@link Collections.ResultMapValueFactory | ResultMapValueFactory}.\n * @param value - The value to check.\n * @returns `true` if the value is a {@link Collections.ResultMapValueFactory | ResultMapValueFactory},\n * `false` otherwise.\n * @public\n */\n protected _isResultMapValueFactory<TK extends string, TV>(\n value: TV | ResultMapValueFactory<TK, TV>\n ): value is ResultMapValueFactory<TK, TV> {\n return typeof value === 'function';\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resultMapValidator.d.ts","sourceRoot":"","sources":["../../../src/packlets/collections/resultMapValidator.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,cAAc,EAAqC,MAAM,SAAS,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D;;;GAGG;AACH,MAAM,WAAW,2BAA2B,CAAC,EAAE,SAAS,MAAM,GAAG,MAAM,EAAE,EAAE,GAAG,OAAO;IACnF;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,kBAAkB,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IAEzC;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAAC,EAAE,EAAE,qBAAqB,CAAC,CAAC;IAE5D;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CAC3B;AAED;;;GAGG;AACH,MAAM,WAAW,+BAA+B,CAAC,EAAE,SAAS,MAAM,GAAG,MAAM,EAAE,EAAE,GAAG,OAAO;IACvF,GAAG,EAAE,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IACvB,UAAU,EAAE,kBAAkB,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;CACxC;AAED;;;;GAIG;AACH,qBAAa,0BAA0B,CAAC,EAAE,SAAS,MAAM,GAAG,MAAM,EAAE,EAAE,GAAG,OAAO,CAC9E,YAAW,2BAA2B,CAAC,EAAE,EAAE,EAAE,CAAC;IAE9C;;OAEG;IACH,SAAgB,UAAU,EAAE,kBAAkB,CAAC,EAAE,EA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AAE,KAAK,EAAE,OAAO,GAAG,cAAc,CAAC,EAAE,EAAE,qBAAqB,CAAC;IAEvF;;OAEG;IACI,QAAQ,CACb,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,qBAAqB,CAAC,EAAE,EAAE,EAAE,CAAC,GACrC,cAAc,CAAC,EAAE,EAAE,qBAAqB,CAAC;IAwB5C;;OAEG;IACI,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIhC;;OAEG;IACI,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,cAAc,CAAC,EAAE,EAAE,qBAAqB,CAAC;IAMlF;;OAEG;IACI,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,cAAc,CAAC,EAAE,EAAE,qBAAqB,CAAC;IAMrF;;OAEG;IACI,UAAU,IAAI,2BAA2B,CAAC,EAAE,EAAE,EAAE,CAAC;IAIxD;;;;;;OAMG;IACH,SAAS,CAAC,wBAAwB,CAAC,EAAE,SAAS,MAAM,EAAE,EAAE,EACtD,KAAK,EAAE,EAAE,GAAG,qBAAqB,CAAC,EAAE,EAAE,EAAE,CAAC,GACxC,KAAK,IAAI,qBAAqB,CAAC,EAAE,EAAE,EAAE,CAAC;CAG1C"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resultMapValidator.js","sourceRoot":"","sources":["../../../src/packlets/collections/resultMapValidator.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,kCAA4E;AAmC5E;;;;GAIG;AACH,MAAa,0BAA0B;IAQrC;;OAEG;IACH,IAAW,GAAG;QACZ,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAID;;;;OAIG;IACH,YAAmB,GAA+B,EAAE,UAAsC;QACxF,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED;;;;OAIG;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*\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { DetailedResult, failWithDetail, succeedWithDetail } from '../base';\nimport { IReadOnlyResultMap, ResultMapResultDetail } from './readonlyResultMap';\nimport { ResultMap, ResultMapValueFactory } from './resultMap';\nimport { KeyValueConverters } from './keyValueConverters';\n\n/**\n * A read-only interface exposing non-mutating methods of a {@link Collections.ResultMapValidator | ResultMapValidator}.\n * @public\n */\nexport interface IReadOnlyResultMapValidator<TK extends string = string, TV = unknown> {\n /**\n * {@inheritDoc Collections.ReadOnlyResultMapValidator.map}\n */\n readonly map: IReadOnlyResultMap<TK, TV>;\n\n /**\n * {@inheritDoc Collections.ResultMap.get}\n */\n get(key: string): DetailedResult<TV, ResultMapResultDetail>;\n\n /**\n * {@inheritDoc Collections.ResultMap.has}\n */\n has(key: string): boolean;\n}\n\n/**\n * Parameters for constructing a {@link Collections.ResultMapValidator | ResultMapValidator}.\n * @public\n */\nexport interface IResultMapValidatorCreateParams<TK extends string = string, TV = unknown> {\n map: ResultMap<TK, TV>;\n converters: KeyValueConverters<TK, TV>;\n}\n\n/**\n * A read-only validator for any {@link Collections.IReadOnlyResultMap | IReadOnlyResultMap}\n * that validates weakly-typed keys before accessing values.\n * @public\n */\nexport class ReadOnlyResultMapValidator<TK extends string = string, TV = unknown>\n implements IReadOnlyResultMapValidator<TK, TV>\n{\n /**\n * The key-value converters used for validation.\n */\n public readonly converters: KeyValueConverters<TK, TV>;\n\n /**\n * The underlying map.\n */\n public get map(): IReadOnlyResultMap<TK, TV> {\n return this._map;\n }\n\n private readonly _map: IReadOnlyResultMap<TK, TV>;\n\n /**\n * Constructs a new {@link Collections.ReadOnlyResultMapValidator | ReadOnlyResultMapValidator}.\n * @param map - The map to validate access to.\n * @param converters - The key-value converters for validation.\n */\n public constructor(map: IReadOnlyResultMap<TK, TV>, converters: KeyValueConverters<TK, TV>) {\n this._map = map;\n this.converters = converters;\n }\n\n /**\n * Gets a value from the map by key, validating the key first.\n * @param key - The key to retrieve (will be validated).\n * @returns `Success` with the value if found, `Failure` otherwise.\n */\n public get(key: string): DetailedResult<TV, ResultMapResultDetail> {\n return this.converters.convertKey(key).onSuccess((validKey) => {\n return this._map.get(validKey);\n });\n }\n\n /**\n * Checks if the map contains a key, validating the key first.\n * @param key - The key to check (will be validated).\n * @returns `true` if the key exists and is valid, `false` otherwise.\n */\n public has(key: string): boolean {\n const result = this.converters.convertKey(key);\n if (result.isFailure()) {\n return false;\n }\n return this._map.has(result.value);\n }\n}\n\n/**\n * A {@link Collections.ResultMap | ResultMap} wrapper which validates weakly-typed keys\n * before calling the wrapped result map.\n * @public\n */\nexport class ResultMapValidator<TK extends string = string, TV = unknown>\n implements IReadOnlyResultMapValidator<TK, TV>\n{\n public readonly converters: KeyValueConverters<TK, TV>;\n public get map(): IReadOnlyResultMap<TK, TV> {\n return this._map;\n }\n\n protected _map: ResultMap<TK, TV>;\n\n /**\n * Constructs a new {@link Collections.ResultMapValidator | ResultMapValidator}.\n * @param params - Required parameters for constructing the result map validator.\n */\n public constructor(params: IResultMapValidatorCreateParams<TK, TV>) {\n this._map = params.map;\n this.converters = params.converters;\n }\n\n /**\n * {@inheritDoc Collections.ResultMap.add}\n */\n public add(key: string, value: unknown): DetailedResult<TV, ResultMapResultDetail> {\n return this.converters.convertEntry([key, value]).onSuccess(([vk, vv]) => {\n return this._map.add(vk, vv);\n });\n }\n\n /**\n * {@inheritDoc Collections.ResultMap.delete}\n */\n public delete(key: string): DetailedResult<TV, ResultMapResultDetail> {\n return this.converters.convertKey(key).onSuccess((k) => {\n return this._map.delete(k);\n });\n }\n\n /**\n * {@inheritDoc Collections.ResultMap.get}\n */\n public get(key: string): DetailedResult<TV, ResultMapResultDetail> {\n return this.converters.convertKey(key).onSuccess((k) => {\n return this._map.get(k);\n });\n }\n\n /**\n * {@inheritDoc Collections.ResultMap.getOrAdd}\n */\n public getOrAdd(key: string, value: unknown): DetailedResult<TV, ResultMapResultDetail>;\n\n /**\n * {@inheritDoc Collections.ResultMap.getOrAdd}\n */\n public getOrAdd(\n key: string,\n factory: ResultMapValueFactory<TK, TV>\n ): DetailedResult<TV, ResultMapResultDetail>;\n public getOrAdd(\n key: string,\n valueOrFactory: unknown | ResultMapValueFactory<TK, TV>\n ): DetailedResult<TV, ResultMapResultDetail> {\n if (!this._isResultMapValueFactory(valueOrFactory)) {\n return this.converters.convertEntry([key, valueOrFactory]).onSuccess(([vk, vv]) => {\n return this._map.getOrAdd(vk, vv);\n });\n } else {\n return this.converters.convertKey(key).onSuccess((k) => {\n return this._map.get(k).onFailure(() => {\n const value = valueOrFactory(k)\n .onSuccess((value) => this.converters.convertEntry([k, value]))\n .onSuccess(([__key, value]) => succeedWithDetail(value, 'added'));\n\n return value.success\n ? this._map.add(k, value.value)\n : failWithDetail<TV, ResultMapResultDetail>(value.message, 'invalid-value');\n });\n });\n }\n }\n\n /**\n * {@inheritDoc Collections.ResultMap.has}\n */\n public has(key: string): boolean {\n return this._map.has(key as TK);\n }\n\n /**\n * {@inheritDoc Collections.ResultMap.set}\n */\n public set(key: string, value: unknown): DetailedResult<TV, ResultMapResultDetail> {\n return this.converters.convertEntry([key, value]).onSuccess(([vk, vv]) => {\n return this._map.set(vk, vv);\n });\n }\n\n /**\n * {@inheritDoc Collections.ResultMap.update}\n */\n public update(key: string, value: unknown): DetailedResult<TV, ResultMapResultDetail> {\n return this.converters.convertEntry([key, value]).onSuccess(([vk, vv]) => {\n return this._map.update(vk, vv);\n });\n }\n\n /**\n * Gets a read-only version of this validator.\n */\n public toReadOnly(): IReadOnlyResultMapValidator<TK, TV> {\n return this;\n }\n\n /**\n * Determines if a value is a {@link Collections.ResultMapValueFactory | ResultMapValueFactory}.\n * @param value - The value to check.\n * @returns `true` if the value is a {@link Collections.ResultMapValueFactory | ResultMapValueFactory},\n * `false` otherwise.\n * @public\n */\n protected _isResultMapValueFactory<TK extends string, TV>(\n value: TV | ResultMapValueFactory<TK, TV>\n ): value is ResultMapValueFactory<TK, TV> {\n return typeof value === 'function';\n }\n}\n"]}
@@ -0,0 +1,147 @@
1
+ /**
2
+ * Minimal structural contract a {@link RetainingRingBuffer} record must satisfy:
3
+ * a monotonic `seq` the buffer pages on. Records carry their own `seq` (assigned
4
+ * by the caller) so the buffer is agnostic about how records are minted — a logger
5
+ * assigns `seq` from its own counter, an observability layer assigns a library-global
6
+ * `seq` shared across several buffers, etc.
7
+ * @public
8
+ */
9
+ export interface IRetainedRecord {
10
+ /**
11
+ * Monotonic sequence number, assigned by the caller. The buffer requires
12
+ * **strictly increasing** `seq` across successive {@link RetainingRingBuffer.push | push}
13
+ * calls — `sinceSeq` cursor paging uses a strict `seq > sinceSeq` filter, so
14
+ * duplicate `seq` values held by a consumer cursor would never be re-yielded
15
+ * if pushed afterward. {@link RetainingRingBuffer.lastSeq | lastSeq} likewise
16
+ * advances only past values strictly greater than its current value.
17
+ */
18
+ readonly seq: number;
19
+ }
20
+ /**
21
+ * Query options for {@link RetainingRingBuffer.query}.
22
+ * @public
23
+ */
24
+ export interface IRetainingRingBufferQuery<T extends IRetainedRecord> {
25
+ /**
26
+ * If supplied, only records with `seq > sinceSeq` are returned, enabling
27
+ * incremental paging from a previously-held cursor.
28
+ */
29
+ readonly sinceSeq?: number;
30
+ /**
31
+ * If supplied, returns at most this many records — the most recent N (tail),
32
+ * still ordered oldest-first.
33
+ */
34
+ readonly limit?: number;
35
+ /**
36
+ * If supplied, only records for which the predicate returns `true` are
37
+ * returned. Applied before `limit`, so `limit` bounds the filtered tail.
38
+ */
39
+ readonly filter?: (record: T) => boolean;
40
+ }
41
+ /**
42
+ * Construction options for {@link RetainingRingBuffer}.
43
+ * @public
44
+ */
45
+ export interface IRetainingRingBufferCreateParams {
46
+ /**
47
+ * The maximum number of records retained before the oldest is overwritten.
48
+ * Defaults to `1000`. Normalized to a positive integer: a fractional value is
49
+ * floored toward the integer below (`2.9` → `2`), and a non-finite or sub-1
50
+ * value is floored to `1` (the ring requires a positive integer capacity to
51
+ * be well-defined).
52
+ */
53
+ readonly maxRecords?: number;
54
+ }
55
+ /**
56
+ * A generic bounded most-recent-N ring of records, with monotonic-`seq` cursor
57
+ * paging and predicate filtering.
58
+ *
59
+ * @remarks
60
+ * The buffer is a pure storage substrate: the caller mints each record (assigning
61
+ * its own `seq` and any other fields) and {@link RetainingRingBuffer.push | push}es
62
+ * it. The buffer never reshapes a record — it only retains, evicts the oldest when
63
+ * full (O(1), no `shift()` re-indexing regardless of capacity), and answers queries.
64
+ *
65
+ * Separating record minting from retention lets one `seq` authority feed several
66
+ * buffers consistently (e.g. an observability layer that assigns a library-global
67
+ * `seq` and fans the same record out to multiple retaining stores), and lets a
68
+ * single-authority consumer (e.g. a logger) own its own `seq` counter. It is the
69
+ * shared mechanism beneath `RetainingLogger` and
70
+ * any schema-aware observation store.
71
+ *
72
+ * @public
73
+ */
74
+ export declare class RetainingRingBuffer<T extends IRetainedRecord> {
75
+ /**
76
+ * The fixed ring capacity — the maximum number of records retained before the
77
+ * oldest is overwritten. A positive integer (see the constructor normalization).
78
+ * @internal
79
+ */
80
+ private readonly _capacity;
81
+ /**
82
+ * The backing store, used as a circular buffer. Grows lazily up to `_capacity`,
83
+ * after which records overwrite the oldest slot in place — eviction is O(1), with
84
+ * no `shift()` re-indexing regardless of capacity.
85
+ * @internal
86
+ */
87
+ private _buffer;
88
+ /**
89
+ * Index of the oldest retained record within `_buffer` once the ring is full.
90
+ * @internal
91
+ */
92
+ private _head;
93
+ /**
94
+ * The number of valid records currently retained (`<= _capacity`).
95
+ * @internal
96
+ */
97
+ private _count;
98
+ /**
99
+ * The highest `seq` ever pushed; monotonic, stable across eviction and
100
+ * {@link RetainingRingBuffer.clear | clear()}.
101
+ * @internal
102
+ */
103
+ private _lastSeq;
104
+ /**
105
+ * Creates a new retaining ring buffer.
106
+ * @param params - {@link IRetainingRingBufferCreateParams | Construction options}.
107
+ */
108
+ constructor(params?: IRetainingRingBufferCreateParams);
109
+ /**
110
+ * The number of records currently retained.
111
+ */
112
+ get size(): number;
113
+ /**
114
+ * The highest `seq` pushed so far. A client can hold this value and pass it as
115
+ * `sinceSeq` to page only records pushed afterward. Stable across eviction and
116
+ * {@link RetainingRingBuffer.clear | clear()}.
117
+ */
118
+ get lastSeq(): number;
119
+ /**
120
+ * The retained records, oldest-first.
121
+ */
122
+ get records(): ReadonlyArray<T>;
123
+ /**
124
+ * Retains a record, evicting the oldest if the ring is full.
125
+ * @param record - The record to retain. Its `seq` should be greater than the
126
+ * `seq` of the previously-pushed record so cursor paging stays monotonic.
127
+ * @returns The same record, for call-site chaining.
128
+ */
129
+ push(record: T): T;
130
+ /**
131
+ * Returns retained records, oldest-first, optionally filtered and paged.
132
+ * @param query - {@link IRetainingRingBufferQuery | Filtering and paging options}.
133
+ * @returns The matching records, oldest-first.
134
+ */
135
+ query(query?: IRetainingRingBufferQuery<T>): ReadonlyArray<T>;
136
+ /**
137
+ * Clears all retained records. Does NOT reset {@link RetainingRingBuffer.lastSeq | lastSeq},
138
+ * so a client holding a `sinceSeq` cursor never re-sees a sequence number.
139
+ */
140
+ clear(): void;
141
+ /**
142
+ * Materializes the ring into a plain oldest-first array.
143
+ * @internal
144
+ */
145
+ private _toOrderedArray;
146
+ }
147
+ //# sourceMappingURL=retainingRingBuffer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retainingRingBuffer.d.ts","sourceRoot":"","sources":["../../../src/packlets/collections/retainingRingBuffer.ts"],"names":[],"mappings":"AAsBA;;;;;;;GAOG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;;;OAOG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,yBAAyB,CAAC,CAAC,SAAS,eAAe;IAClE;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,OAAO,CAAC;CAC1C;AAED;;;GAGG;AACH,MAAM,WAAW,gCAAgC;IAC/C;;;;;;OAMG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,mBAAmB,CAAC,CAAC,SAAS,eAAe;IACxD;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IAEnC;;;;;OAKG;IACH,OAAO,CAAC,OAAO,CAAW;IAE1B;;;OAGG;IACH,OAAO,CAAC,KAAK,CAAa;IAE1B;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAa;IAE3B;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAa;IAE7B;;;OAGG;gBACgB,MAAM,CAAC,EAAE,gCAAgC;IAQ5D;;OAEG;IACH,IAAW,IAAI,IAAI,MAAM,CAExB;IAED;;;;OAIG;IACH,IAAW,OAAO,IAAI,MAAM,CAE3B;IAED;;OAEG;IACH,IAAW,OAAO,IAAI,aAAa,CAAC,CAAC,CAAC,CAErC;IAED;;;;;OAKG;IACI,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC;IAgBzB;;;;OAIG;IACI,KAAK,CAAC,KAAK,CAAC,EAAE,yBAAyB,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC;IAepE;;;OAGG;IACI,KAAK,IAAI,IAAI;IAMpB;;;OAGG;IACH,OAAO,CAAC,eAAe;CAOxB"}
@@ -0,0 +1,163 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2026 Erik Fortune
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ * of this software and associated documentation files (the "Software"), to deal
7
+ * in the Software without restriction, including without limitation the rights
8
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ * copies of the Software, and to permit persons to whom the Software is
10
+ * furnished to do so, subject to the following conditions:
11
+ *
12
+ * The above copyright notice and this permission notice shall be included in all
13
+ * copies or substantial portions of the Software.
14
+ *
15
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ * SOFTWARE.
22
+ */
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.RetainingRingBuffer = void 0;
25
+ /**
26
+ * A generic bounded most-recent-N ring of records, with monotonic-`seq` cursor
27
+ * paging and predicate filtering.
28
+ *
29
+ * @remarks
30
+ * The buffer is a pure storage substrate: the caller mints each record (assigning
31
+ * its own `seq` and any other fields) and {@link RetainingRingBuffer.push | push}es
32
+ * it. The buffer never reshapes a record — it only retains, evicts the oldest when
33
+ * full (O(1), no `shift()` re-indexing regardless of capacity), and answers queries.
34
+ *
35
+ * Separating record minting from retention lets one `seq` authority feed several
36
+ * buffers consistently (e.g. an observability layer that assigns a library-global
37
+ * `seq` and fans the same record out to multiple retaining stores), and lets a
38
+ * single-authority consumer (e.g. a logger) own its own `seq` counter. It is the
39
+ * shared mechanism beneath `RetainingLogger` and
40
+ * any schema-aware observation store.
41
+ *
42
+ * @public
43
+ */
44
+ class RetainingRingBuffer {
45
+ /**
46
+ * Creates a new retaining ring buffer.
47
+ * @param params - {@link IRetainingRingBufferCreateParams | Construction options}.
48
+ */
49
+ constructor(params) {
50
+ var _a;
51
+ /**
52
+ * The backing store, used as a circular buffer. Grows lazily up to `_capacity`,
53
+ * after which records overwrite the oldest slot in place — eviction is O(1), with
54
+ * no `shift()` re-indexing regardless of capacity.
55
+ * @internal
56
+ */
57
+ this._buffer = [];
58
+ /**
59
+ * Index of the oldest retained record within `_buffer` once the ring is full.
60
+ * @internal
61
+ */
62
+ this._head = 0;
63
+ /**
64
+ * The number of valid records currently retained (`<= _capacity`).
65
+ * @internal
66
+ */
67
+ this._count = 0;
68
+ /**
69
+ * The highest `seq` ever pushed; monotonic, stable across eviction and
70
+ * {@link RetainingRingBuffer.clear | clear()}.
71
+ * @internal
72
+ */
73
+ this._lastSeq = 0;
74
+ const maxRecords = (_a = params === null || params === void 0 ? void 0 : params.maxRecords) !== null && _a !== void 0 ? _a : 1000;
75
+ // The ring requires a positive integer capacity to be well-defined; a non-finite
76
+ // or sub-1 value would make the modular index arithmetic meaningless, so floor it
77
+ // to a sane minimum of 1 rather than crash on degenerate input.
78
+ this._capacity = Number.isFinite(maxRecords) && maxRecords >= 1 ? Math.floor(maxRecords) : 1;
79
+ }
80
+ /**
81
+ * The number of records currently retained.
82
+ */
83
+ get size() {
84
+ return this._count;
85
+ }
86
+ /**
87
+ * The highest `seq` pushed so far. A client can hold this value and pass it as
88
+ * `sinceSeq` to page only records pushed afterward. Stable across eviction and
89
+ * {@link RetainingRingBuffer.clear | clear()}.
90
+ */
91
+ get lastSeq() {
92
+ return this._lastSeq;
93
+ }
94
+ /**
95
+ * The retained records, oldest-first.
96
+ */
97
+ get records() {
98
+ return this._toOrderedArray();
99
+ }
100
+ /**
101
+ * Retains a record, evicting the oldest if the ring is full.
102
+ * @param record - The record to retain. Its `seq` should be greater than the
103
+ * `seq` of the previously-pushed record so cursor paging stays monotonic.
104
+ * @returns The same record, for call-site chaining.
105
+ */
106
+ push(record) {
107
+ if (record.seq > this._lastSeq) {
108
+ this._lastSeq = record.seq;
109
+ }
110
+ if (this._count < this._capacity) {
111
+ // Still filling: append to the next free slot (head stays 0 during this phase).
112
+ this._buffer.push(record);
113
+ this._count += 1;
114
+ }
115
+ else {
116
+ // Full: overwrite the oldest record in place and advance the head.
117
+ this._buffer[this._head] = record;
118
+ this._head = (this._head + 1) % this._capacity;
119
+ }
120
+ return record;
121
+ }
122
+ /**
123
+ * Returns retained records, oldest-first, optionally filtered and paged.
124
+ * @param query - {@link IRetainingRingBufferQuery | Filtering and paging options}.
125
+ * @returns The matching records, oldest-first.
126
+ */
127
+ query(query) {
128
+ let result = this._toOrderedArray();
129
+ if ((query === null || query === void 0 ? void 0 : query.sinceSeq) !== undefined) {
130
+ const sinceSeq = query.sinceSeq;
131
+ result = result.filter((r) => r.seq > sinceSeq);
132
+ }
133
+ if ((query === null || query === void 0 ? void 0 : query.filter) !== undefined) {
134
+ result = result.filter(query.filter);
135
+ }
136
+ if ((query === null || query === void 0 ? void 0 : query.limit) !== undefined && result.length > query.limit) {
137
+ result = result.slice(result.length - query.limit);
138
+ }
139
+ return result;
140
+ }
141
+ /**
142
+ * Clears all retained records. Does NOT reset {@link RetainingRingBuffer.lastSeq | lastSeq},
143
+ * so a client holding a `sinceSeq` cursor never re-sees a sequence number.
144
+ */
145
+ clear() {
146
+ this._buffer = [];
147
+ this._head = 0;
148
+ this._count = 0;
149
+ }
150
+ /**
151
+ * Materializes the ring into a plain oldest-first array.
152
+ * @internal
153
+ */
154
+ _toOrderedArray() {
155
+ const result = [];
156
+ for (let i = 0; i < this._count; i++) {
157
+ result.push(this._buffer[(this._head + i) % this._capacity]);
158
+ }
159
+ return result;
160
+ }
161
+ }
162
+ exports.RetainingRingBuffer = RetainingRingBuffer;
163
+ //# sourceMappingURL=retainingRingBuffer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retainingRingBuffer.js","sourceRoot":"","sources":["../../../src/packlets/collections/retainingRingBuffer.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AA2DH;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAa,mBAAmB;IAmC9B;;;OAGG;IACH,YAAmB,MAAyC;;QA/B5D;;;;;WAKG;QACK,YAAO,GAAQ,EAAE,CAAC;QAE1B;;;WAGG;QACK,UAAK,GAAW,CAAC,CAAC;QAE1B;;;WAGG;QACK,WAAM,GAAW,CAAC,CAAC;QAE3B;;;;WAIG;QACK,aAAQ,GAAW,CAAC,CAAC;QAO3B,MAAM,UAAU,GAAG,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,UAAU,mCAAI,IAAI,CAAC;QAC9C,iFAAiF;QACjF,kFAAkF;QAClF,gEAAgE;QAChE,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,UAAU,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/F,CAAC;IAED;;OAEG;IACH,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;;;OAIG;IACH,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,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AC,CAAC;QACvC,CAAC;QACD,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,MAAK,SAAS,IAAI,MAAM,CAAC,MAAM,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC;YAC9D,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;QACrD,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;OAGG;IACI,KAAK;QACV,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAClB,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QACf,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAClB,CAAC;IAED;;;OAGG;IACK,eAAe;QACrB,MAAM,MAAM,GAAQ,EAAE,CAAC;QACvB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACrC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;QAC/D,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AArID,kDAqIC","sourcesContent":["/*\n * Copyright (c) 2026 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n/**\n * Minimal structural contract a {@link RetainingRingBuffer} record must satisfy:\n * a monotonic `seq` the buffer pages on. Records carry their own `seq` (assigned\n * by the caller) so the buffer is agnostic about how records are minted — a logger\n * assigns `seq` from its own counter, an observability layer assigns a library-global\n * `seq` shared across several buffers, etc.\n * @public\n */\nexport interface IRetainedRecord {\n /**\n * Monotonic sequence number, assigned by the caller. The buffer requires\n * **strictly increasing** `seq` across successive {@link RetainingRingBuffer.push | push}\n * calls — `sinceSeq` cursor paging uses a strict `seq > sinceSeq` filter, so\n * duplicate `seq` values held by a consumer cursor would never be re-yielded\n * if pushed afterward. {@link RetainingRingBuffer.lastSeq | lastSeq} likewise\n * advances only past values strictly greater than its current value.\n */\n readonly seq: number;\n}\n\n/**\n * Query options for {@link RetainingRingBuffer.query}.\n * @public\n */\nexport interface IRetainingRingBufferQuery<T extends IRetainedRecord> {\n /**\n * If supplied, only records with `seq > sinceSeq` are returned, enabling\n * incremental paging from a previously-held cursor.\n */\n readonly sinceSeq?: number;\n /**\n * If supplied, returns at most this many records — the most recent N (tail),\n * still ordered oldest-first.\n */\n readonly limit?: number;\n /**\n * If supplied, only records for which the predicate returns `true` are\n * returned. Applied before `limit`, so `limit` bounds the filtered tail.\n */\n readonly filter?: (record: T) => boolean;\n}\n\n/**\n * Construction options for {@link RetainingRingBuffer}.\n * @public\n */\nexport interface IRetainingRingBufferCreateParams {\n /**\n * The maximum number of records retained before the oldest is overwritten.\n * Defaults to `1000`. Normalized to a positive integer: a fractional value is\n * floored toward the integer below (`2.9` → `2`), and a non-finite or sub-1\n * value is floored to `1` (the ring requires a positive integer capacity to\n * be well-defined).\n */\n readonly maxRecords?: number;\n}\n\n/**\n * A generic bounded most-recent-N ring of records, with monotonic-`seq` cursor\n * paging and predicate filtering.\n *\n * @remarks\n * The buffer is a pure storage substrate: the caller mints each record (assigning\n * its own `seq` and any other fields) and {@link RetainingRingBuffer.push | push}es\n * it. The buffer never reshapes a record — it only retains, evicts the oldest when\n * full (O(1), no `shift()` re-indexing regardless of capacity), and answers queries.\n *\n * Separating record minting from retention lets one `seq` authority feed several\n * buffers consistently (e.g. an observability layer that assigns a library-global\n * `seq` and fans the same record out to multiple retaining stores), and lets a\n * single-authority consumer (e.g. a logger) own its own `seq` counter. It is the\n * shared mechanism beneath `RetainingLogger` and\n * any schema-aware observation store.\n *\n * @public\n */\nexport class RetainingRingBuffer<T extends IRetainedRecord> {\n /**\n * The fixed ring capacity — the maximum number of records retained before the\n * oldest is overwritten. A positive integer (see the constructor normalization).\n * @internal\n */\n private readonly _capacity: number;\n\n /**\n * The backing store, used as a circular buffer. Grows lazily up to `_capacity`,\n * after which records overwrite the oldest slot in place — eviction is O(1), with\n * no `shift()` re-indexing regardless of capacity.\n * @internal\n */\n private _buffer: T[] = [];\n\n /**\n * Index of the oldest retained record within `_buffer` once the ring is full.\n * @internal\n */\n private _head: number = 0;\n\n /**\n * The number of valid records currently retained (`<= _capacity`).\n * @internal\n */\n private _count: number = 0;\n\n /**\n * The highest `seq` ever pushed; monotonic, stable across eviction and\n * {@link RetainingRingBuffer.clear | clear()}.\n * @internal\n */\n private _lastSeq: number = 0;\n\n /**\n * Creates a new retaining ring buffer.\n * @param params - {@link IRetainingRingBufferCreateParams | Construction options}.\n */\n public constructor(params?: IRetainingRingBufferCreateParams) {\n const maxRecords = params?.maxRecords ?? 1000;\n // The ring requires a positive integer capacity to be well-defined; a non-finite\n // or sub-1 value would make the modular index arithmetic meaningless, so floor it\n // to a sane minimum of 1 rather than crash on degenerate input.\n this._capacity = Number.isFinite(maxRecords) && maxRecords >= 1 ? Math.floor(maxRecords) : 1;\n }\n\n /**\n * The number of records currently retained.\n */\n public get size(): number {\n return this._count;\n }\n\n /**\n * The highest `seq` pushed so far. A client can hold this value and pass it as\n * `sinceSeq` to page only records pushed afterward. Stable across eviction and\n * {@link RetainingRingBuffer.clear | clear()}.\n */\n public get lastSeq(): number {\n return this._lastSeq;\n }\n\n /**\n * The retained records, oldest-first.\n */\n public get records(): ReadonlyArray<T> {\n return this._toOrderedArray();\n }\n\n /**\n * Retains a record, evicting the oldest if the ring is full.\n * @param record - The record to retain. Its `seq` should be greater than the\n * `seq` of the previously-pushed record so cursor paging stays monotonic.\n * @returns The same record, for call-site chaining.\n */\n public push(record: T): T {\n if (record.seq > this._lastSeq) {\n this._lastSeq = record.seq;\n }\n if (this._count < this._capacity) {\n // Still filling: append to the next free slot (head stays 0 during this phase).\n this._buffer.push(record);\n this._count += 1;\n } else {\n // Full: overwrite the oldest record in place and advance the head.\n this._buffer[this._head] = record;\n this._head = (this._head + 1) % this._capacity;\n }\n return record;\n }\n\n /**\n * Returns retained records, oldest-first, optionally filtered and paged.\n * @param query - {@link IRetainingRingBufferQuery | Filtering and paging options}.\n * @returns The matching records, oldest-first.\n */\n public query(query?: IRetainingRingBufferQuery<T>): ReadonlyArray<T> {\n let result: ReadonlyArray<T> = this._toOrderedArray();\n if (query?.sinceSeq !== undefined) {\n const sinceSeq = query.sinceSeq;\n result = result.filter((r) => r.seq > sinceSeq);\n }\n if (query?.filter !== undefined) {\n result = result.filter(query.filter);\n }\n if (query?.limit !== undefined && result.length > query.limit) {\n result = result.slice(result.length - query.limit);\n }\n return result;\n }\n\n /**\n * Clears all retained records. Does NOT reset {@link RetainingRingBuffer.lastSeq | lastSeq},\n * so a client holding a `sinceSeq` cursor never re-sees a sequence number.\n */\n public clear(): void {\n this._buffer = [];\n this._head = 0;\n this._count = 0;\n }\n\n /**\n * Materializes the ring into a plain oldest-first array.\n * @internal\n */\n private _toOrderedArray(): T[] {\n const result: T[] = [];\n for (let i = 0; i < this._count; i++) {\n result.push(this._buffer[(this._head + i) % this._capacity]);\n }\n return result;\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/packlets/collections/utils.ts"],"names":[],"mappings":"AAsBA;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,EAAE,GAAG,OAAO,EAAE,EAAE,SAAS,QAAQ,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,GAAG,OAAO,EAC3F,KAAK,EAAE,EAAE,GAAG,EAAE,GACb,KAAK,IAAI,EAAE,CAEb"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/packlets/collections/utils.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;AAQH,gCAIC;AAVD;;;;;GAKG;AACH,SAAgB,UAAU,CACxB,KAAc;IAEd,OAAO,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,IAAI,KAAK,CAAC,KAAK,IAAI,CAAC;AACnF,CAAC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n/**\n * Determines if a supplied value is an iterable object or some other type.\n * @param value - The value to be tested.\n * @returns `true` if the value is an iterable object, `false` otherwise.\n * @public\n */\nexport function isIterable<TE = unknown, TI extends Iterable<TE> = Iterable<TE>, TO = unknown>(\n value: TI | TO\n): value is TI {\n return (value && typeof value === 'object' && Symbol.iterator in value) === true;\n}\n"]}
@@ -12,15 +12,19 @@ import { CollectorValidator } from './collectorValidator';
12
12
  */
13
13
  export interface IReadOnlyValidatingCollector<TITEM extends ICollectible<any, any>> extends IReadOnlyValidatingResultMap<CollectibleKey<TITEM>, TITEM> {
14
14
  /**
15
- * {@inheritDoc Collections.ValidatingCollector.validating}
15
+ * A {@link Collections.CollectorValidator | CollectorValidator} which validates keys and values
16
+ * before inserting them into this collector.
16
17
  */
17
18
  readonly validating: IReadOnlyCollectorValidator<TITEM>;
18
19
  /**
19
- * {@inheritDoc Collections.IReadOnlyCollector.getAt}
20
+ * Gets the item at a specified index.
21
+ * @param index - The index of the item to retrieve.
22
+ * @returns `Success` with the item if it exists, or `Failure` with an error if the index is out of range.
20
23
  */
21
24
  getAt(index: number): Result<TITEM>;
22
25
  /**
23
- * {@inheritDoc Collections.IReadOnlyCollector.valuesByIndex}
26
+ * Gets all items in the collection, ordered by index.
27
+ * @returns An array of items in the collection, ordered by index.
24
28
  */
25
29
  valuesByIndex(): ReadonlyArray<TITEM>;
26
30
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validatingCollector.d.ts","sourceRoot":"","sources":["../../../src/packlets/collections/validatingCollector.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAiB,MAAM,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAA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IAEjF;;;;OAIG;gBACgB,MAAM,EAAE,qCAAqC,CAAC,KAAK,CAAC;IASvE;;;;;OAKG;WACW,yBAAyB,CAErC,KAAK,SAAS,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,EACpC,MAAM,EAAE,qCAAqC,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;IAI3F;;;;OAIG;IACI,UAAU,IAAI,4BAA4B,CAAC,KAAK,CAAC;CAGzD"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validatingCollector.js","sourceRoot":"","sources":["../../../src/packlets/collections/validatingCollector.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,kCAAgD;AAKhD,2CAAwC;AACxC,6DAA0D;AAmD1D;;;;GAIG;AACH,MAAa,mBAGX,SAAQ,qBAAgB;IASxB;;;;OAIG;IACH,YAAmB,MAAoD;;QACrE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,UAAU,CAAC;QACrC,IAAI,CAAC,UAAU,GAAG,IAAI,uCAAkB,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC;QAC7F,KAAK,MAAM,IAAI,IAAI,MAAA,MAAM,CAAC,KAAK,mCAAI,EAAE,EAAE,CAAC;YACtC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;QAC3C,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,yBAAyB,CAGrC,MAAoD;QACpD,OAAO,IAAA,oBAAa,EAAC,GAAG,EAAE,CAAC,IAAI,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC;IAC9D,CAAC;IAED;;;;OAIG;IACI,UAAU;QACf,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA/CD,kDA+CC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { captureResult, Result } from '../base';\nimport { CollectibleKey, ICollectible } from './collectible';\nimport { IReadOnlyCollectorValidator } from './collectorValidator';\nimport { IReadOnlyValidatingResultMap } from './validatingResultMap';\nimport { KeyValueConverters } from './keyValueConverters';\nimport { Collector } from './collector';\nimport { CollectorValidator } from './collectorValidator';\n\n/**\n * A read-only interface exposing non-mutating methods of a\n * {@link Collections.ValidatingCollector | ValidatingCollector}.\n * @public\n */\n\nexport interface IReadOnlyValidatingCollector<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TITEM extends ICollectible<any, any>\n> extends IReadOnlyValidatingResultMap<CollectibleKey<TITEM>, TITEM> {\n /**\n * A {@link Collections.CollectorValidator | CollectorValidator} which validates keys and values\n * before inserting them into this collector.\n */\n readonly validating: IReadOnlyCollectorValidator<TITEM>;\n\n /**\n * Gets the item at a specified index.\n * @param index - The index of the item to retrieve.\n * @returns `Success` with the item if it exists, or `Failure` with an error if the index is out of range.\n */\n getAt(index: number): Result<TITEM>;\n\n /**\n * Gets all items in the collection, ordered by index.\n * @returns An array of items in the collection, ordered by index.\n */\n valuesByIndex(): ReadonlyArray<TITEM>;\n}\n\n/**\n * Parameters for constructing a {@link Collections.ValidatingCollector | ValidatingCollector}.\n * @public\n */\nexport interface IValidatingCollectorConstructorParams<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TITEM extends ICollectible<any, any>\n> {\n /**\n * {@inheritDoc Collections.ICollectorValidatorCreateParams.converters}\n */\n converters: KeyValueConverters<CollectibleKey<TITEM>, TITEM>;\n\n /**\n * {@inheritDoc Collections.ICollectorConstructorParams.items}\n */\n items?: unknown[];\n}\n\n/**\n * A {@link Collections.Collector | Collector} with a {@link Collections.CollectorValidator | CollectorValidator}\n * property that enables validated use of the underlying map with weakly-typed keys and values.\n * @public\n */\nexport class ValidatingCollector<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TITEM extends ICollectible<any, any>\n> extends Collector<TITEM> {\n /**\n * A {@link Collections.CollectorValidator | CollectorValidator} which validates keys and values\n * before inserting them into this collector.\n */\n public readonly validating: CollectorValidator<TITEM>;\n\n protected readonly _converters: KeyValueConverters<CollectibleKey<TITEM>, TITEM>;\n\n /**\n * Constructs a new {@link Collections.ValidatingCollector | ValidatingConvertingCollector}\n * from the supplied {@link Collections.IValidatingCollectorConstructorParams | parameters}.\n * @param params - Required parameters for constructing the collector.\n */\n public constructor(params: IValidatingCollectorConstructorParams<TITEM>) {\n super();\n this._converters = params.converters;\n this.validating = new CollectorValidator({ collector: this, converters: params.converters });\n for (const item of params.items ?? []) {\n this.validating.getOrAdd(item).orThrow();\n }\n }\n\n /**\n * Creates a new {@link Collections.ValidatingCollector | ValidatingCollector} instance from\n * the supplied {@link Collections.IValidatingCollectorConstructorParams | parameters}.\n * @param params - Required parameters for constructing the collector.\n * @returns {@link Success} with the new collector if successful, {@link Failure} otherwise.\n */\n public static createValidatingCollector<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TITEM extends ICollectible<any, any>\n >(params: IValidatingCollectorConstructorParams<TITEM>): Result<ValidatingCollector<TITEM>> {\n return captureResult(() => new ValidatingCollector(params));\n }\n\n /**\n * Gets a read-only version of this collector as a\n * {@link Collections.IReadOnlyValidatingResultMap | read-only map}.\n * @returns\n */\n public toReadOnly(): IReadOnlyValidatingCollector<TITEM> {\n return this;\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validatingConvertingCollector.d.ts","sourceRoot":"","sources":["../../../src/packlets/collections/validatingConvertingCollector.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAiB,MAAM,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACjF,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAErE;;;GAGG;AACH,MAAM,WAAW,+CAA+C,CAE9D,KAAK,SAAS,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,EACpC,IAAI,GAAG,KAAK;IAEZ;;OAEG;IACH,OAAO,EAAE,kBAAkB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAEzC;;OAEG;IACH,UAAU,EAAE,kBAAkB,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC;IAE5D;;OAEG;IACH,OAAO,CAAC,EAAE,aAAa,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC;CACxD;AAED;;;;;GAKG;AACH,qBAAa,6BAA6B,CAExC,KAAK,SAAS,YA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