@fgv/ts-utils 5.1.0-3 → 5.1.0-30

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 (261) hide show
  1. package/README.md +21 -0
  2. package/dist/index.js.map +1 -0
  3. package/dist/packlets/base/brand.js.map +1 -0
  4. package/dist/packlets/base/index.js +2 -0
  5. package/dist/packlets/base/index.js.map +1 -0
  6. package/dist/packlets/base/mapResults.js.map +1 -0
  7. package/dist/packlets/base/messageAggregator.js.map +1 -0
  8. package/dist/packlets/base/normalize.js +54 -1
  9. package/dist/packlets/base/normalize.js.map +1 -0
  10. package/dist/packlets/base/result.js +299 -2
  11. package/dist/packlets/base/result.js.map +1 -0
  12. package/dist/packlets/base/shouldNotFail.js +123 -0
  13. package/dist/packlets/base/shouldNotFail.js.map +1 -0
  14. package/dist/packlets/base/utils.js.map +1 -0
  15. package/dist/packlets/base/uuid.js +55 -0
  16. package/dist/packlets/base/uuid.js.map +1 -0
  17. package/dist/packlets/collections/aggregatedResultMap.js.map +1 -0
  18. package/dist/packlets/collections/collectible.js.map +1 -0
  19. package/dist/packlets/collections/collector.js +23 -9
  20. package/dist/packlets/collections/collector.js.map +1 -0
  21. package/dist/packlets/collections/collectorValidator.js +6 -1
  22. package/dist/packlets/collections/collectorValidator.js.map +1 -0
  23. package/dist/packlets/collections/common.js.map +1 -0
  24. package/dist/packlets/collections/converters.js.map +1 -0
  25. package/dist/packlets/collections/convertingCollector.js.map +1 -0
  26. package/dist/packlets/collections/convertingCollectorValidator.js.map +1 -0
  27. package/dist/packlets/collections/convertingResultMap.js.map +1 -0
  28. package/dist/packlets/collections/index.js.map +1 -0
  29. package/dist/packlets/collections/keyValueConverters.js.map +1 -0
  30. package/dist/packlets/collections/readOnlyConvertingResultMap.js.map +1 -0
  31. package/dist/packlets/collections/readonlyResultMap.js.map +1 -0
  32. package/dist/packlets/collections/resultMap.js.map +1 -0
  33. package/dist/packlets/collections/resultMapValidator.js.map +1 -0
  34. package/dist/packlets/collections/utils.js.map +1 -0
  35. package/dist/packlets/collections/validatingCollector.js.map +1 -0
  36. package/dist/packlets/collections/validatingConvertingCollector.js.map +1 -0
  37. package/dist/packlets/collections/validatingConvertingResultMap.js.map +1 -0
  38. package/dist/packlets/collections/validatingResultMap.js.map +1 -0
  39. package/dist/packlets/conversion/advancedConverters.js.map +1 -0
  40. package/dist/packlets/conversion/baseConverter.js +102 -16
  41. package/dist/packlets/conversion/baseConverter.js.map +1 -0
  42. package/dist/packlets/conversion/basicConverters.js.map +1 -0
  43. package/dist/packlets/conversion/converter.js.map +1 -0
  44. package/dist/packlets/conversion/converters.js.map +1 -0
  45. package/dist/packlets/conversion/defaultingConverter.js.map +1 -0
  46. package/dist/packlets/conversion/index.js.map +1 -0
  47. package/dist/packlets/conversion/objectConverter.js.map +1 -0
  48. package/dist/packlets/conversion/stringConverter.js.map +1 -0
  49. package/dist/packlets/hash/crcNormalizer.js.map +1 -0
  50. package/dist/packlets/hash/hashingNormalizer.js.map +1 -0
  51. package/dist/packlets/hash/index.js.map +1 -0
  52. package/dist/packlets/logging/bootLogger.js.map +1 -0
  53. package/dist/packlets/logging/index.js.map +1 -0
  54. package/dist/packlets/logging/logReporter.js.map +1 -0
  55. package/dist/packlets/logging/logger.js +33 -8
  56. package/dist/packlets/logging/logger.js.map +1 -0
  57. package/dist/packlets/validation/array.js.map +1 -0
  58. package/dist/packlets/validation/boolean.js.map +1 -0
  59. package/dist/packlets/validation/classes.js.map +1 -0
  60. package/dist/packlets/validation/common.js.map +1 -0
  61. package/dist/packlets/validation/compositeId.js.map +1 -0
  62. package/dist/packlets/validation/field.js.map +1 -0
  63. package/dist/packlets/validation/genericValidator.js.map +1 -0
  64. package/dist/packlets/validation/index.js.map +1 -0
  65. package/dist/packlets/validation/number.js.map +1 -0
  66. package/dist/packlets/validation/object.js.map +1 -0
  67. package/dist/packlets/validation/oneOf.js.map +1 -0
  68. package/dist/packlets/validation/string.js.map +1 -0
  69. package/dist/packlets/validation/traits.js.map +1 -0
  70. package/dist/packlets/validation/typeGuard.js.map +1 -0
  71. package/dist/packlets/validation/validator.js.map +1 -0
  72. package/dist/packlets/validation/validatorBase.js.map +1 -0
  73. package/dist/packlets/validation/validators.js.map +1 -0
  74. package/dist/ts-utils.d.ts +648 -56
  75. package/dist/tsdoc-metadata.json +1 -1
  76. package/lib/index.d.ts.map +1 -0
  77. package/lib/index.js.map +1 -0
  78. package/lib/packlets/base/brand.d.ts.map +1 -0
  79. package/lib/packlets/base/brand.js.map +1 -0
  80. package/lib/packlets/base/index.d.ts +2 -0
  81. package/lib/packlets/base/index.d.ts.map +1 -0
  82. package/lib/packlets/base/index.js +2 -0
  83. package/lib/packlets/base/index.js.map +1 -0
  84. package/lib/packlets/base/mapResults.d.ts.map +1 -0
  85. package/lib/packlets/base/mapResults.js.map +1 -0
  86. package/lib/packlets/base/messageAggregator.d.ts.map +1 -0
  87. package/lib/packlets/base/messageAggregator.js.map +1 -0
  88. package/lib/packlets/base/normalize.d.ts +24 -0
  89. package/lib/packlets/base/normalize.d.ts.map +1 -0
  90. package/lib/packlets/base/normalize.js +53 -0
  91. package/lib/packlets/base/normalize.js.map +1 -0
  92. package/lib/packlets/base/result.d.ts +263 -1
  93. package/lib/packlets/base/result.d.ts.map +1 -0
  94. package/lib/packlets/base/result.js +303 -3
  95. package/lib/packlets/base/result.js.map +1 -0
  96. package/lib/packlets/base/shouldNotFail.d.ts +53 -0
  97. package/lib/packlets/base/shouldNotFail.d.ts.map +1 -0
  98. package/lib/packlets/base/shouldNotFail.js +129 -0
  99. package/lib/packlets/base/shouldNotFail.js.map +1 -0
  100. package/lib/packlets/base/utils.d.ts +12 -0
  101. package/lib/packlets/base/utils.d.ts.map +1 -0
  102. package/lib/packlets/base/utils.js.map +1 -0
  103. package/lib/packlets/base/uuid.d.ts +27 -0
  104. package/lib/packlets/base/uuid.d.ts.map +1 -0
  105. package/lib/packlets/base/uuid.js +59 -0
  106. package/lib/packlets/base/uuid.js.map +1 -0
  107. package/lib/packlets/collections/aggregatedResultMap.d.ts.map +1 -0
  108. package/lib/packlets/collections/aggregatedResultMap.js.map +1 -0
  109. package/lib/packlets/collections/collectible.d.ts.map +1 -0
  110. package/lib/packlets/collections/collectible.js.map +1 -0
  111. package/lib/packlets/collections/collector.d.ts +23 -9
  112. package/lib/packlets/collections/collector.d.ts.map +1 -0
  113. package/lib/packlets/collections/collector.js +23 -9
  114. package/lib/packlets/collections/collector.js.map +1 -0
  115. package/lib/packlets/collections/collectorValidator.d.ts +29 -5
  116. package/lib/packlets/collections/collectorValidator.d.ts.map +1 -0
  117. package/lib/packlets/collections/collectorValidator.js +6 -1
  118. package/lib/packlets/collections/collectorValidator.js.map +1 -0
  119. package/lib/packlets/collections/common.d.ts.map +1 -0
  120. package/lib/packlets/collections/common.js.map +1 -0
  121. package/lib/packlets/collections/converters.d.ts.map +1 -0
  122. package/lib/packlets/collections/converters.js.map +1 -0
  123. package/lib/packlets/collections/convertingCollector.d.ts +21 -3
  124. package/lib/packlets/collections/convertingCollector.d.ts.map +1 -0
  125. package/lib/packlets/collections/convertingCollector.js.map +1 -0
  126. package/lib/packlets/collections/convertingCollectorValidator.d.ts +22 -3
  127. package/lib/packlets/collections/convertingCollectorValidator.d.ts.map +1 -0
  128. package/lib/packlets/collections/convertingCollectorValidator.js.map +1 -0
  129. package/lib/packlets/collections/convertingResultMap.d.ts.map +1 -0
  130. package/lib/packlets/collections/convertingResultMap.js.map +1 -0
  131. package/lib/packlets/collections/index.d.ts.map +1 -0
  132. package/lib/packlets/collections/index.js.map +1 -0
  133. package/lib/packlets/collections/keyValueConverters.d.ts.map +1 -0
  134. package/lib/packlets/collections/keyValueConverters.js.map +1 -0
  135. package/lib/packlets/collections/readOnlyConvertingResultMap.d.ts.map +1 -0
  136. package/lib/packlets/collections/readOnlyConvertingResultMap.js.map +1 -0
  137. package/lib/packlets/collections/readonlyResultMap.d.ts +18 -7
  138. package/lib/packlets/collections/readonlyResultMap.d.ts.map +1 -0
  139. package/lib/packlets/collections/readonlyResultMap.js.map +1 -0
  140. package/lib/packlets/collections/resultMap.d.ts.map +1 -0
  141. package/lib/packlets/collections/resultMap.js.map +1 -0
  142. package/lib/packlets/collections/resultMapValidator.d.ts.map +1 -0
  143. package/lib/packlets/collections/resultMapValidator.js.map +1 -0
  144. package/lib/packlets/collections/utils.d.ts.map +1 -0
  145. package/lib/packlets/collections/utils.js.map +1 -0
  146. package/lib/packlets/collections/validatingCollector.d.ts +7 -3
  147. package/lib/packlets/collections/validatingCollector.d.ts.map +1 -0
  148. package/lib/packlets/collections/validatingCollector.js.map +1 -0
  149. package/lib/packlets/collections/validatingConvertingCollector.d.ts.map +1 -0
  150. package/lib/packlets/collections/validatingConvertingCollector.js.map +1 -0
  151. package/lib/packlets/collections/validatingConvertingResultMap.d.ts.map +1 -0
  152. package/lib/packlets/collections/validatingConvertingResultMap.js.map +1 -0
  153. package/lib/packlets/collections/validatingResultMap.d.ts +2 -1
  154. package/lib/packlets/collections/validatingResultMap.d.ts.map +1 -0
  155. package/lib/packlets/collections/validatingResultMap.js.map +1 -0
  156. package/lib/packlets/conversion/advancedConverters.d.ts.map +1 -0
  157. package/lib/packlets/conversion/advancedConverters.js.map +1 -0
  158. package/lib/packlets/conversion/baseConverter.d.ts +102 -16
  159. package/lib/packlets/conversion/baseConverter.d.ts.map +1 -0
  160. package/lib/packlets/conversion/baseConverter.js +102 -16
  161. package/lib/packlets/conversion/baseConverter.js.map +1 -0
  162. package/lib/packlets/conversion/basicConverters.d.ts.map +1 -0
  163. package/lib/packlets/conversion/basicConverters.js.map +1 -0
  164. package/lib/packlets/conversion/converter.d.ts.map +1 -0
  165. package/lib/packlets/conversion/converter.js.map +1 -0
  166. package/lib/packlets/conversion/converters.d.ts.map +1 -0
  167. package/lib/packlets/conversion/converters.js.map +1 -0
  168. package/lib/packlets/conversion/defaultingConverter.d.ts.map +1 -0
  169. package/lib/packlets/conversion/defaultingConverter.js.map +1 -0
  170. package/lib/packlets/conversion/index.d.ts.map +1 -0
  171. package/lib/packlets/conversion/index.js.map +1 -0
  172. package/lib/packlets/conversion/objectConverter.d.ts.map +1 -0
  173. package/lib/packlets/conversion/objectConverter.js.map +1 -0
  174. package/lib/packlets/conversion/stringConverter.d.ts.map +1 -0
  175. package/lib/packlets/conversion/stringConverter.js.map +1 -0
  176. package/lib/packlets/hash/crcNormalizer.d.ts.map +1 -0
  177. package/lib/packlets/hash/crcNormalizer.js.map +1 -0
  178. package/lib/packlets/hash/hashingNormalizer.d.ts.map +1 -0
  179. package/lib/packlets/hash/hashingNormalizer.js.map +1 -0
  180. package/lib/packlets/hash/index.d.ts.map +1 -0
  181. package/lib/packlets/hash/index.js.map +1 -0
  182. package/lib/packlets/logging/bootLogger.d.ts.map +1 -0
  183. package/lib/packlets/logging/bootLogger.js.map +1 -0
  184. package/lib/packlets/logging/index.d.ts.map +1 -0
  185. package/lib/packlets/logging/index.js.map +1 -0
  186. package/lib/packlets/logging/logReporter.d.ts.map +1 -0
  187. package/lib/packlets/logging/logReporter.js.map +1 -0
  188. package/lib/packlets/logging/logger.d.ts +33 -8
  189. package/lib/packlets/logging/logger.d.ts.map +1 -0
  190. package/lib/packlets/logging/logger.js +33 -8
  191. package/lib/packlets/logging/logger.js.map +1 -0
  192. package/lib/packlets/validation/array.d.ts.map +1 -0
  193. package/lib/packlets/validation/array.js.map +1 -0
  194. package/lib/packlets/validation/boolean.d.ts.map +1 -0
  195. package/lib/packlets/validation/boolean.js.map +1 -0
  196. package/lib/packlets/validation/classes.d.ts.map +1 -0
  197. package/lib/packlets/validation/classes.js.map +1 -0
  198. package/lib/packlets/validation/common.d.ts.map +1 -0
  199. package/lib/packlets/validation/common.js.map +1 -0
  200. package/lib/packlets/validation/compositeId.d.ts.map +1 -0
  201. package/lib/packlets/validation/compositeId.js.map +1 -0
  202. package/lib/packlets/validation/field.d.ts.map +1 -0
  203. package/lib/packlets/validation/field.js.map +1 -0
  204. package/lib/packlets/validation/genericValidator.d.ts.map +1 -0
  205. package/lib/packlets/validation/genericValidator.js.map +1 -0
  206. package/lib/packlets/validation/index.d.ts.map +1 -0
  207. package/lib/packlets/validation/index.js.map +1 -0
  208. package/lib/packlets/validation/number.d.ts.map +1 -0
  209. package/lib/packlets/validation/number.js.map +1 -0
  210. package/lib/packlets/validation/object.d.ts.map +1 -0
  211. package/lib/packlets/validation/object.js.map +1 -0
  212. package/lib/packlets/validation/oneOf.d.ts.map +1 -0
  213. package/lib/packlets/validation/oneOf.js.map +1 -0
  214. package/lib/packlets/validation/string.d.ts.map +1 -0
  215. package/lib/packlets/validation/string.js.map +1 -0
  216. package/lib/packlets/validation/traits.d.ts.map +1 -0
  217. package/lib/packlets/validation/traits.js.map +1 -0
  218. package/lib/packlets/validation/typeGuard.d.ts.map +1 -0
  219. package/lib/packlets/validation/typeGuard.js.map +1 -0
  220. package/lib/packlets/validation/validator.d.ts.map +1 -0
  221. package/lib/packlets/validation/validator.js.map +1 -0
  222. package/lib/packlets/validation/validatorBase.d.ts +2 -1
  223. package/lib/packlets/validation/validatorBase.d.ts.map +1 -0
  224. package/lib/packlets/validation/validatorBase.js.map +1 -0
  225. package/lib/packlets/validation/validators.d.ts.map +1 -0
  226. package/lib/packlets/validation/validators.js.map +1 -0
  227. package/package.json +6 -4
  228. package/dist/test/helpers/jest/helpers/fsHelpers.js +0 -139
  229. package/dist/test/helpers/jest/helpers/index.js +0 -2
  230. package/dist/test/helpers/jest/index.js +0 -17
  231. package/dist/test/helpers/jest/matchers/index.js +0 -14
  232. package/dist/test/helpers/jest/matchers/toFail/index.js +0 -23
  233. package/dist/test/helpers/jest/matchers/toFail/predicate.js +0 -5
  234. package/dist/test/helpers/jest/matchers/toFailTest/index.js +0 -28
  235. package/dist/test/helpers/jest/matchers/toFailTest/predicate.js +0 -8
  236. package/dist/test/helpers/jest/matchers/toFailTestAndMatchSnapshot/index.js +0 -24
  237. package/dist/test/helpers/jest/matchers/toFailTestAndMatchSnapshot/predicate.js +0 -11
  238. package/dist/test/helpers/jest/matchers/toFailTestWith/index.js +0 -29
  239. package/dist/test/helpers/jest/matchers/toFailTestWith/predicate.js +0 -26
  240. package/dist/test/helpers/jest/matchers/toFailWith/index.js +0 -27
  241. package/dist/test/helpers/jest/matchers/toFailWith/predicate.js +0 -16
  242. package/dist/test/helpers/jest/matchers/toFailWithDetail/index.js +0 -27
  243. package/dist/test/helpers/jest/matchers/toFailWithDetail/predicate.js +0 -22
  244. package/dist/test/helpers/jest/matchers/toSucceed/index.js +0 -23
  245. package/dist/test/helpers/jest/matchers/toSucceed/predicate.js +0 -5
  246. package/dist/test/helpers/jest/matchers/toSucceedAndMatchInlineSnapshot/index.js +0 -24
  247. package/dist/test/helpers/jest/matchers/toSucceedAndMatchSnapshot/index.js +0 -24
  248. package/dist/test/helpers/jest/matchers/toSucceedAndSatisfy/index.js +0 -53
  249. package/dist/test/helpers/jest/matchers/toSucceedAndSatisfy/predicate.js +0 -17
  250. package/dist/test/helpers/jest/matchers/toSucceedWith/index.js +0 -27
  251. package/dist/test/helpers/jest/matchers/toSucceedWith/predicate.js +0 -12
  252. package/dist/test/helpers/jest/matchers/toSucceedWithDetail/index.js +0 -27
  253. package/dist/test/helpers/jest/matchers/toSucceedWithDetail/predicate.js +0 -17
  254. package/dist/test/helpers/jest/resolvers/cli.js +0 -10
  255. package/dist/test/helpers/jest/resolvers/ide.js +0 -10
  256. package/dist/test/helpers/jest/ts-utils.js +0 -2
  257. package/dist/test/helpers/jest/types/index.js +0 -3
  258. package/dist/test/helpers/jest/utils/matcherHelpers.js +0 -47
  259. package/dist/test/helpers/jest/utils/snapshotResolver.js +0 -11
  260. package/dist/test/unit/collections/helpers.js +0 -106
  261. package/dist/test/unit/hashTextEncodeCompat.js +0 -23
@@ -420,6 +420,131 @@ declare interface ArrayValidatorConstructorParams<T, TC = unknown> extends Valid
420
420
  */
421
421
  declare function asValidator<T, TC = unknown>(converterOrValidator: Converter<T, TC> | Validator<T, TC>): Validator<T, TC>;
422
422
 
423
+ /**
424
+ * Async continuation callback to be called in the event that a
425
+ * {@link Result} fails, returning a `Promise` of a new {@link Result}.
426
+ * @public
427
+ */
428
+ export declare type AsyncFailureContinuation<T> = (message: string) => Promise<Result<T>>;
429
+
430
+ /**
431
+ * Wraps a `Promise` of a {@link Result} to enable fluent chaining of both
432
+ * synchronous and asynchronous operations.
433
+ *
434
+ * @remarks
435
+ * `AsyncResult<T>` implements `PromiseLike` so it can be directly `await`ed.
436
+ * Use the `thenOnSuccess` and `thenOnFailure` methods on {@link Result} to bridge
437
+ * from synchronous to asynchronous result chains.
438
+ *
439
+ * @example
440
+ * ```typescript
441
+ * const result: Result<Final> = await parseInput(input)
442
+ * .thenOnSuccess(async (parsed) => fetchData(parsed))
443
+ * .onSuccess((data) => transform(data))
444
+ * .thenOnSuccess(async (transformed) => saveData(transformed))
445
+ * .withErrorFormat((msg) => `pipeline failed: ${msg}`);
446
+ * ```
447
+ *
448
+ * @public
449
+ */
450
+ export declare class AsyncResult<T> implements PromiseLike<Result<T>> {
451
+ private readonly _promise;
452
+ /**
453
+ * Constructs an {@link AsyncResult} wrapping the supplied promise.
454
+ * @remarks
455
+ * If the supplied promise rejects, the rejection is caught and converted
456
+ * to a {@link Failure}, ensuring that awaiting an {@link AsyncResult} always
457
+ * yields a {@link Result}.
458
+ * @param promise - A `Promise` that resolves to a {@link Result}.
459
+ */
460
+ constructor(promise: Promise<Result<T>>);
461
+ /**
462
+ * Calls a supplied {@link SuccessContinuation | success continuation} if
463
+ * the wrapped result is successful.
464
+ * @param cb - The synchronous {@link SuccessContinuation | success continuation}
465
+ * to be called in the event of success.
466
+ * @returns A new {@link AsyncResult} wrapping the continuation result.
467
+ */
468
+ onSuccess<TN>(cb: SuccessContinuation<T, TN>): AsyncResult<TN>;
469
+ /**
470
+ * Calls a supplied {@link AsyncSuccessContinuation | async success continuation} if
471
+ * the wrapped result is successful.
472
+ * @remarks
473
+ * Both synchronous throws and async rejections from the callback are caught
474
+ * and converted to a {@link Failure}.
475
+ * @param cb - The {@link AsyncSuccessContinuation | async success continuation}
476
+ * to be called in the event of success.
477
+ * @returns A new {@link AsyncResult} wrapping the async continuation result.
478
+ */
479
+ thenOnSuccess<TN>(cb: AsyncSuccessContinuation<T, TN>): AsyncResult<TN>;
480
+ /**
481
+ * Calls a supplied {@link FailureContinuation | failure continuation} if
482
+ * the wrapped result is a failure.
483
+ * @param cb - The synchronous {@link FailureContinuation | failure continuation}
484
+ * to be called in the event of failure.
485
+ * @returns A new {@link AsyncResult} wrapping the continuation result.
486
+ */
487
+ onFailure(cb: FailureContinuation<T>): AsyncResult<T>;
488
+ /**
489
+ * Calls a supplied {@link AsyncFailureContinuation | async failure continuation} if
490
+ * the wrapped result is a failure.
491
+ * @remarks
492
+ * Both synchronous throws and async rejections from the callback are caught
493
+ * and converted to a {@link Failure}.
494
+ * @param cb - The {@link AsyncFailureContinuation | async failure continuation}
495
+ * to be called in the event of failure.
496
+ * @returns A new {@link AsyncResult} wrapping the async continuation result.
497
+ */
498
+ thenOnFailure(cb: AsyncFailureContinuation<T>): AsyncResult<T>;
499
+ /**
500
+ * Calls a supplied {@link ErrorFormatter | error formatter} if
501
+ * the wrapped result is a failure.
502
+ * @param cb - The {@link ErrorFormatter | error formatter} to
503
+ * be called in the event of failure.
504
+ * @returns A new {@link AsyncResult} with the formatted error message,
505
+ * or the original success result.
506
+ */
507
+ withErrorFormat(cb: ErrorFormatter): AsyncResult<T>;
508
+ /**
509
+ * Propagates the wrapped result, appending any error message to the
510
+ * supplied errors aggregator.
511
+ * @param errors - {@link IMessageAggregator | Error aggregator} in which
512
+ * errors will be aggregated.
513
+ * @param formatter - An optional {@link ErrorFormatter | error formatter}
514
+ * to be used to format the error message.
515
+ * @returns A new {@link AsyncResult} wrapping the result after aggregation.
516
+ */
517
+ aggregateError(errors: IMessageAggregator, formatter?: ErrorFormatter): AsyncResult<T>;
518
+ /**
519
+ * Reports the wrapped result to the supplied reporter.
520
+ * @param reporter - The {@link IResultReporter | reporter} to which the result
521
+ * will be reported.
522
+ * @param options - The {@link IResultReportOptions | options} for reporting the result.
523
+ * @returns A new {@link AsyncResult} wrapping the result after reporting.
524
+ */
525
+ report(reporter?: IResultReporter<T>, options?: IResultReportOptions<unknown>): AsyncResult<T>;
526
+ /**
527
+ * Implementation of `PromiseLike.then` enabling `await` on {@link AsyncResult}.
528
+ * @param onfulfilled - Callback invoked when the promise resolves.
529
+ * @param onrejected - Callback invoked when the promise rejects.
530
+ * @returns A `Promise` resolving to the callback result.
531
+ */
532
+ then<TResult1 = Result<T>, TResult2 = never>(onfulfilled?: ((value: Result<T>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
533
+ /**
534
+ * Creates an {@link AsyncResult} from a {@link Result}.
535
+ * @param result - The {@link Result} to wrap.
536
+ * @returns A new {@link AsyncResult} wrapping the supplied result.
537
+ */
538
+ static from<T>(result: Result<T>): AsyncResult<T>;
539
+ }
540
+
541
+ /**
542
+ * Async continuation callback to be called in the event that a
543
+ * {@link Result} is successful, returning a `Promise` of a new {@link Result}.
544
+ * @public
545
+ */
546
+ export declare type AsyncSuccessContinuation<T, TN> = (value: T) => Promise<Result<TN>>;
547
+
423
548
  declare namespace Base {
424
549
  export {
425
550
  GenericValidatorConstructorParams,
@@ -454,63 +579,146 @@ declare class BaseConverter<T, TC = unknown> implements Converter<T, TC> {
454
579
  */
455
580
  constructor(converter: ConverterFunc<T, TC>, defaultContext?: TC, traits?: ConverterTraits);
456
581
  /**
457
- * {@inheritDoc Converter.isOptional}
582
+ * Indicates whether this element is explicitly optional.
458
583
  */
459
584
  get isOptional(): boolean;
460
585
  /**
461
- * {@inheritDoc Converter.brand}
586
+ * Returns the brand for a branded type.
462
587
  */
463
588
  get brand(): string | undefined;
464
589
  /**
465
- * {@inheritDoc Converter.convert}
590
+ * Converts from `unknown` to `<T>`. For objects and arrays, is guaranteed
591
+ * to return a new entity, with any unrecognized properties removed.
592
+ * @param from - The `unknown` to be converted
593
+ * @param context - An optional conversion context of type `<TC>` to be used in
594
+ * the conversion.
595
+ * @returns A {@link Result} with a {@link Success} and a value on success or an
596
+ * {@link Failure} with a a message on failure.
466
597
  */
467
598
  convert(from: unknown, context?: TC): Result<T>;
468
599
  /**
469
- * {@inheritDoc Converter.convertOptional}
600
+ * Converts from `unknown` to `<T>` or `undefined`, as appropriate.
601
+ *
602
+ * @remarks
603
+ * If `onError` is `failOnError`, the converter succeeds for
604
+ * `undefined` or any convertible value, but reports an error
605
+ * if it encounters a value that cannot be converted.
606
+ *
607
+ * If `onError` is `ignoreErrors` (default) then values that
608
+ * cannot be converted result in a successful return of `undefined`.
609
+ * @param from - The `unknown` to be converted
610
+ * @param context - An optional conversion context of type `<TC>` to be used in
611
+ * the conversion.
612
+ * @param onError - Specifies handling of values that cannot be converted (default `ignoreErrors`).
613
+ * @returns A {@link Result} with a {@link Success} and a value on success or an
614
+ * {@link Failure} with a a message on failure.
470
615
  */
471
616
  convertOptional(from: unknown, context?: TC, onError?: OnError): Result<T | undefined>;
472
617
  /**
473
- * {@inheritDoc Converter.optional}
618
+ * Creates a {@link Converter} for an optional value.
619
+ *
620
+ * @remarks
621
+ * If `onError` is `failOnError`, the resulting converter will accept `undefined`
622
+ * or a convertible value, but report an error if it encounters a value that cannot be
623
+ * converted.
624
+ *
625
+ * If `onError` is `ignoreErrors` (default) then values that cannot be converted will
626
+ * result in a successful return of `undefined`.
627
+ *
628
+ * @param onError - Specifies handling of values that cannot be converted (default `ignoreErrors`).
629
+ * @returns A new {@link Converter} returning `<T|undefined>`.
474
630
  */
475
631
  optional(onError?: OnError): Converter<T | undefined, TC>;
476
632
  /**
477
- * {@inheritDoc Converter.map}
633
+ * Creates a {@link Converter} which applies a (possibly) mapping conversion to
634
+ * the converted value of this {@link Converter}.
635
+ * @param mapper - A function which maps from the the result type `<T>` of this
636
+ * converter to a new result type `<T2>`.
637
+ * @returns A new {@link Converter} returning `<T2>`.
478
638
  */
479
639
  map<T2>(mapper: (from: T, context?: TC) => Result<T2>): Converter<T2, TC>;
480
640
  /**
481
- * {@inheritDoc Converter.mapConvert}
641
+ * Creates a {@link Converter} which applies an additional supplied
642
+ * converter to the result of this converter.
643
+ *
644
+ * @param mapConverter - The {@link Converter} to be applied to the
645
+ * converted result from this {@link Converter}.
646
+ * @returns A new {@link Converter} returning `<T2>`.
482
647
  */
483
648
  mapConvert<T2>(mapConverter: Converter<T2>): Converter<T2, TC>;
484
649
  /**
485
- * {@inheritDoc Converter.mapItems}
650
+ * Creates a {@link Converter} which maps the individual items of a collection
651
+ * resulting from this {@link Converter} using the supplied map function.
652
+ *
653
+ * @remarks
654
+ * Fails if `from` is not an array.
655
+ *
656
+ * @param mapper - The map function to be applied to each element of the
657
+ * result of this {@link Converter}.
658
+ * @returns A new {@link Converter} returning `<TI[]>`.
486
659
  */
487
660
  mapItems<TI>(mapper: (from: unknown, context?: TC) => Result<TI>): Converter<TI[], TC>;
488
661
  /**
489
- * {@inheritDoc Converter.mapConvertItems}
662
+ * Creates a {@link Converter} which maps the individual items of a collection
663
+ * resulting from this {@link Converter} using the supplied {@link Converter}.
664
+ *
665
+ * @remarks
666
+ * Fails if `from` is not an array.
667
+ *
668
+ * @param mapConverter - The {@link Converter} to be applied to each element of the
669
+ * result of this {@link Converter}.
670
+ * @returns A new {@link Converter} returning `<TI[]>`.
490
671
  */
491
672
  mapConvertItems<TI>(mapConverter: Converter<TI, unknown>): Converter<TI[], TC>;
492
673
  /**
493
- * {@inheritDoc Converter.withAction}
674
+ * Creates a {@link Converter | Converter} which applies a supplied action after
675
+ * conversion. The supplied action is always called regardless of success or failure
676
+ * of the base conversion and is allowed to mutate the return type.
677
+ * @param action - The action to be applied.
494
678
  */
495
679
  withAction<TI>(action: (result: Result<T>, context?: TC) => Result<TI>): Converter<TI, TC>;
496
680
  /**
497
- * {@inheritDoc Converter.withTypeGuard}
681
+ * Creates a {@link Converter} which applies a supplied type guard to the conversion
682
+ * result.
683
+ * @param guard - The type guard function to apply.
684
+ * @param message - Optional message to be reported if the type guard fails.
685
+ * @returns A new {@link Converter} returning `<TI>`.
498
686
  */
499
687
  withTypeGuard<TI>(guard: (from: unknown, context?: TC) => from is TI, message?: string): Converter<TI, TC>;
500
688
  /**
501
- * {@inheritDoc Converter.withItemTypeGuard}
689
+ * Creates a {@link Converter} which applies a supplied type guard to each member of
690
+ * the conversion result from this converter.
691
+ *
692
+ * @remarks
693
+ * Fails if the conversion result is not an array or if any member fails the
694
+ * type guard.
695
+ * @param guard - The type guard function to apply to each element.
696
+ * @param message - Optional message to be reported if the type guard fails.
697
+ * @returns A new {@link Converter} returning `<TI>`.
502
698
  */
503
699
  withItemTypeGuard<TI>(guard: (from: unknown, context?: TC) => from is TI, message?: string): Converter<TI[], TC>;
504
700
  /**
505
- * {@inheritDoc Converter.withConstraint}
701
+ * Creates a {@link Converter} which applies an optional constraint to the result
702
+ * of this conversion. If this {@link Converter} (the base converter) succeeds, the new
703
+ * converter calls a supplied constraint evaluation function with the conversion, which
704
+ * fails the entire conversion if the constraint function returns either `false` or
705
+ * {@link Failure | Failure<T>}.
706
+ *
707
+ * @param constraint - Constraint evaluation function.
708
+ * @param options - {@link Conversion.ConstraintOptions | Options} for constraint evaluation.
709
+ * @returns A new {@link Converter} returning `<T>`.
506
710
  */
507
711
  withConstraint(constraint: (val: T, context?: TC) => boolean | Result<T>, options?: ConstraintOptions): Converter<T, TC>;
508
712
  /**
509
- * {@inheritDoc Converter.withBrand}
713
+ * Returns a converter which adds a brand to the type to prevent mismatched usage
714
+ * of simple types.
715
+ * @param brand - The brand to be applied to the result value.
716
+ * @returns A {@link Converter} returning `Brand<T, B>`.
510
717
  */
511
718
  withBrand<B extends string>(brand: B): Converter<Brand<T, B>, TC>;
512
719
  /**
513
- * {@inheritDoc Converter.withDefault}
720
+ * Returns a Converter which always succeeds with a default value rather than failing.
721
+ * @param defaultValue - The default value to use if conversion fails.
514
722
  */
515
723
  withDefault<TD = T>(defaultValue: TD): DefaultingConverter<T, TD, TC>;
516
724
  or(other: Converter<T, TC>): Converter<T, TC>;
@@ -519,7 +727,10 @@ declare class BaseConverter<T, TC = unknown> implements Converter<T, TC> {
519
727
  */
520
728
  protected _context(supplied?: TC): TC | undefined;
521
729
  /**
522
- * {@inheritDoc Converter.withFormattedError}
730
+ * Creates a new {@link Converter} which is derived from this one but which returns an
731
+ * error message formatted by the supplied formatter if the conversion fails.
732
+ * @param formatter - The formatter to be applied.
733
+ * @returns A new {@link Converter} returning `<T>`.
523
734
  */
524
735
  withFormattedError(formatter: ConversionErrorFormatter<TC>): Converter<T, TC>;
525
736
  /**
@@ -778,13 +989,23 @@ declare class CacheInvalidatingResultMapWrapper<TK extends string, TSRC, TTARGET
778
989
  toReadOnly(): IReadOnlyResultMap<TK, TSRC>;
779
990
  }
780
991
 
992
+ /**
993
+ * Wraps an async function which might throw to convert exception results
994
+ * to {@link Failure}.
995
+ * @param func - The async function to be captured.
996
+ * @returns Returns a `Promise` of {@link Success} with a value of type `<T>` on
997
+ * success, or {@link Failure} with the thrown error message if `func` throws or rejects.
998
+ * @public
999
+ */
1000
+ export declare function captureAsyncResult<T>(func: () => Promise<T>): Promise<Result<T>>;
1001
+
781
1002
  /**
782
1003
  * Wraps a function which might throw to convert exception results
783
1004
  * to {@link Failure}.
784
1005
  * @param func - The function to be captured.
785
1006
  * @returns Returns {@link Success} with a value of type `<T>` on
786
1007
  * success , or {@link Failure} with the thrown error message if
787
- * `func` throws an `Error`.
1008
+ * `func` throws an `Error` or string.
788
1009
  * @public
789
1010
  */
790
1011
  export declare function captureResult<T>(func: () => T): Result<T>;
@@ -987,7 +1208,7 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
987
1208
  private readonly _byKey;
988
1209
  private readonly _byIndex;
989
1210
  /**
990
- * {@inheritDoc Collections.ResultMap.size}
1211
+ * Returns the number of entries in the map.
991
1212
  */
992
1213
  get size(): number;
993
1214
  /**
@@ -1014,19 +1235,28 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
1014
1235
  */
1015
1236
  add(item: TITEM): DetailedResult<TITEM, CollectorResultDetail>;
1016
1237
  /**
1017
- * {@inheritDoc Collections.ResultMap.entries}
1238
+ * Returns an iterator over the map entries.
1239
+ * @returns An iterator over the map entries.
1018
1240
  */
1019
1241
  entries(): IterableIterator<KeyValueEntry<CollectibleKey<TITEM>, TITEM>>;
1020
1242
  /**
1021
- * {@inheritDoc Collections.ResultMap.forEach}
1243
+ * Calls a function for each entry in the map.
1244
+ * @param callback - The function to call for each entry.
1245
+ * @param arg - An optional argument to pass to the callback.
1022
1246
  */
1023
1247
  forEach(callback: ResultMapForEachCb<CollectibleKey<TITEM>, TITEM>, arg?: unknown): void;
1024
1248
  /**
1025
- * {@inheritDoc Collections.ResultMap.get}
1249
+ * Gets a value by key.
1250
+ * @param key - The key to look up.
1251
+ * @returns Returns {@link DetailedSuccess | Success} with the value and detail `exists` if found,
1252
+ * or {@link DetailedFailure | Failure} with detail `not-found` if the key does not exist.
1026
1253
  */
1027
1254
  get(key: CollectibleKey<TITEM>): DetailedResult<TITEM, ResultMapResultDetail>;
1028
1255
  /**
1029
- * {@inheritDoc Collections.IReadOnlyCollector.getAt}
1256
+ * Gets the item at a specified index.
1257
+ * @param index - The index of the item to retrieve.
1258
+ * @returns Returns {@link Success | Success} with the item if it exists, or {@link Failure | Failure}
1259
+ * with an error if the index is out of range.
1030
1260
  */
1031
1261
  getAt(index: number): Result<TITEM>;
1032
1262
  /**
@@ -1051,19 +1281,24 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
1051
1281
  */
1052
1282
  getOrAdd(key: CollectibleKey<TITEM>, factory: CollectibleFactoryCallback<TITEM>): DetailedResult<TITEM, CollectorResultDetail>;
1053
1283
  /**
1054
- * {@inheritDoc Collections.ResultMap.has}
1284
+ * Returns true if the map contains an entry with the given key.
1285
+ * @param key - The key to check for.
1286
+ * @returns `true` if the key exists, `false` otherwise.
1055
1287
  */
1056
1288
  has(key: CollectibleKey<TITEM>): boolean;
1057
1289
  /**
1058
- * {@inheritDoc Collections.ResultMap.keys}
1290
+ * Returns an iterator over the map keys.
1291
+ * @returns An iterator over the map keys.
1059
1292
  */
1060
1293
  keys(): IterableIterator<CollectibleKey<TITEM>>;
1061
1294
  /**
1062
- * {@inheritDoc Collections.ResultMap.values}
1295
+ * Returns an iterator over the map values.
1296
+ * @returns An iterator over the map values.
1063
1297
  */
1064
1298
  values(): IterableIterator<TITEM>;
1065
1299
  /**
1066
- * {@inheritDoc Collections.IReadOnlyCollector.valuesByIndex}
1300
+ * Gets all items in the collection, ordered by index.
1301
+ * @returns An array of items in the collection, ordered by index.
1067
1302
  */
1068
1303
  valuesByIndex(): ReadonlyArray<TITEM>;
1069
1304
  /**
@@ -1099,7 +1334,12 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
1099
1334
  */
1100
1335
  constructor(params: ICollectorValidatorCreateParams<TITEM>);
1101
1336
  /**
1102
- * {@inheritDoc Collections.Collector.add}
1337
+ * Adds an item to the collection, failing if a different item with the same key already exists. Note
1338
+ * that adding an object that is already in the collection again will succeed without updating the collection.
1339
+ * @param item - The item to add.
1340
+ * @returns Returns {@link DetailedSuccess | Success} with the item and detail `added` if it was added
1341
+ * or detail `exists` if the item was already in the map. Returns {@link DetailedFailure | Failure} with
1342
+ * an error message and appropriate detail if the item could not be added.
1103
1343
  */
1104
1344
  add(item: unknown): DetailedResult<TITEM, CollectorResultDetail>;
1105
1345
  /**
@@ -1107,12 +1347,24 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
1107
1347
  */
1108
1348
  get(key: string): DetailedResult<TITEM, ResultMapResultDetail>;
1109
1349
  /**
1110
- * {@inheritDoc Collections.Collector.getOrAdd}
1350
+ * Gets an existing item with a key matching the supplied key, or adds a new item to the collector
1351
+ * using a factory callback if no item with that key exists.
1352
+ * @param key - The weakly-typed key of the item to get or add.
1353
+ * @param factory - The factory callback to create the item.
1354
+ * @returns Returns {@link DetailedSuccess | Success} with the item stored in the collector -
1355
+ * detail `exists` indicates that an existing item was returned and detail `added` indicates
1356
+ * that the item was added. Returns {@link DetailedFailure | Failure} with an error and
1357
+ * appropriate detail if the item could not be added.
1111
1358
  */
1112
1359
  getOrAdd(key: string, factory: ResultMapValueFactory<CollectibleKey<TITEM>, TITEM>): DetailedResult<TITEM, CollectorResultDetail>;
1113
1360
  /**
1114
- * {@inheritDoc Collections.Collector.getOrAdd}
1115
- * @param item - The item to add to the collector.
1361
+ * Gets an existing item with a key matching that of the supplied item, or adds the supplied
1362
+ * item to the collector if no item with that key exists.
1363
+ * @param item - The weakly-typed item to get or add.
1364
+ * @returns Returns {@link DetailedSuccess | Success} with the item stored in the collector -
1365
+ * detail `exists` indicates that an existing item was returned and detail `added` indicates
1366
+ * that the item was added. Returns {@link DetailedFailure | Failure} with an error and
1367
+ * appropriate detail if the item could not be added.
1116
1368
  */
1117
1369
  getOrAdd(item: unknown): DetailedResult<TITEM, CollectorResultDetail>;
1118
1370
  /**
@@ -1577,7 +1829,12 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
1577
1829
  */
1578
1830
  static createConvertingCollector<TITEM extends ICollectible<any, any>, TSRC = TITEM>(params: IConvertingCollectorConstructorParams<TITEM, TSRC>): Result<ConvertingCollector<TITEM, TSRC>>;
1579
1831
  /**
1580
- * {@inheritDoc Collections.Collector.add}
1832
+ * Adds an item to the collection, failing if a different item with the same key already exists. Note
1833
+ * that adding an object that is already in the collection again will succeed without updating the collection.
1834
+ * @param item - The item to add.
1835
+ * @returns Returns {@link DetailedSuccess | Success} with the item and detail `added` if it was added
1836
+ * or detail `exists` if the item was already in the map. Returns {@link DetailedFailure | Failure} with
1837
+ * an error message and appropriate detail if the item could not be added.
1581
1838
  */
1582
1839
  add(item: TITEM): DetailedResult<TITEM, CollectorResultDetail>;
1583
1840
  /**
@@ -1600,11 +1857,24 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
1600
1857
  */
1601
1858
  add(key: CollectibleKey<TITEM>, cb: CollectibleFactoryCallback<TITEM>): DetailedResult<TITEM, CollectorResultDetail>;
1602
1859
  /**
1603
- * {@inheritDoc Collections.Collector.getOrAdd}
1860
+ * Gets an existing item with a key matching that of the supplied item, or adds the supplied
1861
+ * item to the collector if no item with that key exists.
1862
+ * @param item - The item to get or add.
1863
+ * @returns Returns {@link DetailedSuccess | Success} with the item stored in the collector -
1864
+ * detail `exists` indicates that an existing item was returned and detail `added` indicates
1865
+ * that the item was added. Returns {@link DetailedFailure | Failure} with an error and
1866
+ * appropriate detail if the item could not be added.
1604
1867
  */
1605
1868
  getOrAdd(item: TITEM): DetailedResult<TITEM, CollectorResultDetail>;
1606
1869
  /**
1607
- * {@inheritDoc Collections.Collector.getOrAdd}
1870
+ * Gets an existing item with a key matching the supplied key, or adds a new item to the collector
1871
+ * using a factory callback if no item with that key exists.
1872
+ * @param key - The key of the item to get or add.
1873
+ * @param callback - The factory callback to create the item.
1874
+ * @returns Returns {@link DetailedSuccess | Success} with the item stored in the collector -
1875
+ * detail `exists` indicates that an existing item was returned and detail `added` indicates
1876
+ * that the item was added. Returns {@link DetailedFailure | Failure} with an error and
1877
+ * appropriate detail if the item could not be added.
1608
1878
  */
1609
1879
  getOrAdd(key: CollectibleKey<TITEM>, callback: CollectibleFactoryCallback<TITEM>): DetailedResult<TITEM, CollectorResultDetail>;
1610
1880
  /**
@@ -1662,7 +1932,12 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
1662
1932
  */
1663
1933
  constructor(params: IConvertingCollectorValidatorCreateParams<TITEM, TSRC>);
1664
1934
  /**
1665
- * {@inheritDoc Collections.ConvertingCollector.add}
1935
+ * Adds an item to the collector using the default factory at a specified key,
1936
+ * failing if an item with that key already exists.
1937
+ * @param key - The weakly-typed key of the item to add.
1938
+ * @param value - The source representation of the item to be added.
1939
+ * @returns Returns {@link Success | Success} with the item if it is added, or {@link Failure | Failure} with
1940
+ * an error if the item cannot be created and indexed.
1666
1941
  */
1667
1942
  add(key: string, value: unknown): DetailedResult<TITEM, CollectorResultDetail>;
1668
1943
  /**
@@ -1675,11 +1950,25 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
1675
1950
  */
1676
1951
  get(key: string): DetailedResult<TITEM, ResultMapResultDetail>;
1677
1952
  /**
1678
- * {@inheritDoc Collections.ConvertingCollector.getOrAdd}
1953
+ * Gets an existing item with a key matching the supplied key, or adds a new item to the collector
1954
+ * by converting the supplied weakly-typed value if no item with that key exists.
1955
+ * @param key - The weakly-typed key of the item to get or add.
1956
+ * @param value - The weakly-typed source value to convert and add if the key does not exist.
1957
+ * @returns Returns {@link DetailedSuccess | Success} with the item stored in the collector -
1958
+ * detail `exists` indicates that an existing item was returned and detail `added` indicates
1959
+ * that the item was added. Returns {@link DetailedFailure | Failure} with an error and
1960
+ * appropriate detail if the item could not be added.
1679
1961
  */
1680
1962
  getOrAdd(key: string, value: unknown): DetailedResult<TITEM, CollectorResultDetail>;
1681
1963
  /**
1682
- * {@inheritDoc Collections.Collector.getOrAdd}
1964
+ * Gets an existing item with a key matching the supplied key, or adds a new item to the collector
1965
+ * using a factory callback if no item with that key exists.
1966
+ * @param key - The weakly-typed key of the item to get or add.
1967
+ * @param factory - The factory callback to create the item.
1968
+ * @returns Returns {@link DetailedSuccess | Success} with the item stored in the collector -
1969
+ * detail `exists` indicates that an existing item was returned and detail `added` indicates
1970
+ * that the item was added. Returns {@link DetailedFailure | Failure} with an error and
1971
+ * appropriate detail if the item could not be added.
1683
1972
  */
1684
1973
  getOrAdd(key: string, factory: ResultMapValueFactory<CollectibleKey<TITEM>, TITEM>): DetailedResult<TITEM, CollectorResultDetail>;
1685
1974
  /**
@@ -2070,6 +2359,14 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
2070
2359
  */
2071
2360
  export declare type ErrorFormatter<TD = unknown> = (message: string, detail?: TD) => string;
2072
2361
 
2362
+ /**
2363
+ * Extracts a message string from an unknown thrown/rejected value.
2364
+ * @param err - The caught error value.
2365
+ * @returns The error message string.
2366
+ * @internal
2367
+ */
2368
+ export declare function _errorMessage(err: unknown): string;
2369
+
2073
2370
  /**
2074
2371
  * Returns {@link Failure | Failure<T>} with the supplied error message.
2075
2372
  * @param message - Error message to be returned.
@@ -2135,6 +2432,10 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
2135
2432
  * {@inheritDoc IResult.orThrow}
2136
2433
  */
2137
2434
  orThrow(cb: ErrorFormatter): never;
2435
+ /**
2436
+ * {@inheritDoc IResult.shouldNotFail}
2437
+ */
2438
+ shouldNotFail(label?: string, frameDepth?: number): never;
2138
2439
  /**
2139
2440
  * {@inheritDoc IResult.orDefault}
2140
2441
  */
@@ -2161,6 +2462,14 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
2161
2462
  * {@inheritDoc IResult.onFailure}
2162
2463
  */
2163
2464
  onFailure(cb: FailureContinuation<T>): Result<T>;
2465
+ /**
2466
+ * {@inheritDoc IResult.thenOnSuccess}
2467
+ */
2468
+ thenOnSuccess<TN>(__: AsyncSuccessContinuation<T, TN>): AsyncResult<TN>;
2469
+ /**
2470
+ * {@inheritDoc IResult.thenOnFailure}
2471
+ */
2472
+ thenOnFailure(cb: AsyncFailureContinuation<T>): AsyncResult<T>;
2164
2473
  /**
2165
2474
  * {@inheritDoc IResult.withErrorFormat}
2166
2475
  */
@@ -2181,6 +2490,41 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
2181
2490
  * {@inheritDoc IResult.report}
2182
2491
  */
2183
2492
  report(reporter?: IResultReporter<T>, options?: IResultReportOptions<unknown>): Failure<T>;
2493
+ /**
2494
+ * Re-types this {@link Failure | Failure<T>} as {@link Failure | Failure<U>} for
2495
+ * propagation under a different success type.
2496
+ * @remarks
2497
+ * Supports the canonical Result early-return-after-`isFailure()` pattern when the
2498
+ * outer function's success type differs from the inner Result's success type:
2499
+ *
2500
+ * ```ts
2501
+ * const storeResult = await PromptStoreFixture.build(seed);
2502
+ * if (storeResult.isFailure()) {
2503
+ * return storeResult.withType<PromptLibrary>();
2504
+ * }
2505
+ * return PromptLibrary.create({ store: storeResult.value, ... });
2506
+ * ```
2507
+ *
2508
+ * Without this helper, TypeScript rejects `return storeResult` because
2509
+ * `Failure<IPromptStore>` is invariant in `T` and not assignable to
2510
+ * `Result<PromptLibrary>`. The workaround `return fail<U>(r.message)` is
2511
+ * semantically equivalent but allocates a new {@link Failure} instance;
2512
+ * `withType` returns `this` and only retypes statically.
2513
+ *
2514
+ * This method is sound because a {@link Failure} variant carries no `T`-shaped
2515
+ * data — only an error message — so re-typing it as `Failure<U>` cannot
2516
+ * misrepresent any value. The same operation is NOT exposed on {@link Success}
2517
+ * because `Success<T>` carries `T`-shaped data and re-typing would be a lie.
2518
+ *
2519
+ * For `DetailedResult` propagation that preserves a typed `detail`, consider
2520
+ * propagating the {@link DetailedFailure} directly through `onSuccess` (which
2521
+ * already re-types the success arm) rather than reaching for `withType`.
2522
+ *
2523
+ * @returns This same {@link Failure} instance, statically retyped as
2524
+ * {@link Failure | Failure<U>}.
2525
+ * @public
2526
+ */
2527
+ withType<U>(): Failure<U>;
2184
2528
  /**
2185
2529
  * Get a 'friendly' string representation of this object.
2186
2530
  * @remarks
@@ -2280,6 +2624,20 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
2280
2624
  [key in keyof T]: Validator<T[key], TC>;
2281
2625
  };
2282
2626
 
2627
+ /**
2628
+ * Finds the caller frame at the supplied depth in a stack string.
2629
+ *
2630
+ * Filters out frames whose **parsed function name** contains `shouldNotFail`
2631
+ * (the file path is deliberately NOT inspected — consumer test files may
2632
+ * themselves be named after `shouldNotFail` and their frames must not be
2633
+ * filtered out). Covers both the V8 path — where `Error.captureStackTrace`
2634
+ * should have done this already but the extra filter is harmless — and the
2635
+ * WebKit fallback path where `captureStackTrace` is unavailable. `frameDepth`
2636
+ * is 1-indexed: `1` selects the immediate caller.
2637
+ * @internal
2638
+ */
2639
+ export declare function _findShouldNotFailFrame(stack: string | undefined, frameDepth: number): _IShouldNotFailFrame;
2640
+
2283
2641
  /**
2284
2642
  * Returns the first successful result from a collection of {@link Result | Result<T>} or {@link DeferredResult | DeferredResult<T>}.
2285
2643
  * @param results - The collection of {@link Result | Result<T>} or {@link DeferredResult | DeferredResult<T>} to be tested.
@@ -2288,6 +2646,13 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
2288
2646
  */
2289
2647
  export declare function firstSuccess<T>(results: Iterable<Result<T> | DeferredResult<T>>): Result<T>;
2290
2648
 
2649
+ /**
2650
+ * Composes the error message thrown by `Result<T>.shouldNotFail` from the
2651
+ * captured frame and optional label.
2652
+ * @internal
2653
+ */
2654
+ export declare function _formatShouldNotFailMessage(originalMessage: string, label: string | undefined, frame: _IShouldNotFailFrame): string;
2655
+
2291
2656
  /**
2292
2657
  * A {@link Validation.ConstraintTrait | ConstraintTrait} indicating that
2293
2658
  * a {@link Validation.Constraint | Constraint<T>} function provides an
@@ -2298,6 +2663,18 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
2298
2663
  type: 'function';
2299
2664
  }
2300
2665
 
2666
+ /**
2667
+ * Generates a cryptographically random UUIDv4 using the platform's Web Crypto
2668
+ * API (`globalThis.crypto.randomUUID`). Works in Node.js \>= 18 and modern
2669
+ * browsers without per-call runtime checks.
2670
+ * @returns A new {@link Uuid}.
2671
+ * @throws An `Error` if the runtime does not expose `globalThis.crypto.randomUUID`.
2672
+ * This indicates an unsupported platform, not a per-call failure mode, so it is
2673
+ * surfaced as a thrown error rather than a `Result`.
2674
+ * @public
2675
+ */
2676
+ export declare function generateUuid(): Uuid;
2677
+
2301
2678
  /**
2302
2679
  * Helper function to create a {@link Converter | Converter} from a supplied {@link Conversion.ConverterFunc | ConverterFunc}.
2303
2680
  * @param convert - the function to be wrapped
@@ -3016,7 +3393,14 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
3016
3393
  */
3017
3394
  has(key: string): boolean;
3018
3395
  /**
3019
- * {@inheritDoc Collections.Collector.getOrAdd}
3396
+ * Gets an existing item with a key matching the supplied key, or adds a new item to the collector
3397
+ * using a factory callback if no item with that key exists.
3398
+ * @param key - The weakly-typed key of the item to get or add.
3399
+ * @param factory - The factory callback to create the item.
3400
+ * @returns Returns {@link DetailedSuccess | Success} with the item stored in the collector -
3401
+ * detail `exists` indicates that an existing item was returned and detail `added` indicates
3402
+ * that the item was added. Returns {@link DetailedFailure | Failure} with an error and
3403
+ * appropriate detail if the item could not be added.
3020
3404
  */
3021
3405
  getOrAdd(key: string, factory: ResultMapValueFactory<CollectibleKey<TITEM>, TITEM>): DetailedResult<TITEM, CollectorResultDetail>;
3022
3406
  }
@@ -3053,31 +3437,42 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
3053
3437
  */
3054
3438
  export declare interface IReadOnlyResultMap<TK extends string = string, TV = unknown> {
3055
3439
  /**
3056
- * {@inheritDoc Collections.ResultMap.size}
3440
+ * Returns the number of entries in the map.
3057
3441
  */
3058
3442
  readonly size: number;
3059
3443
  /**
3060
- * {@inheritDoc Collections.ResultMap.entries}
3444
+ * Returns an iterator over the map entries.
3445
+ * @returns An iterator over the map entries.
3061
3446
  */
3062
3447
  entries(): IterableIterator<KeyValueEntry<TK, TV>>;
3063
3448
  /**
3064
- * {@inheritDoc Collections.ResultMap.forEach}
3449
+ * Calls a function for each entry in the map.
3450
+ * @param cb - The function to call for each entry.
3451
+ * @param arg - An optional argument to pass to the callback.
3065
3452
  */
3066
3453
  forEach(cb: ResultMapForEachCb, arg?: unknown): void;
3067
3454
  /**
3068
- * {@inheritDoc Collections.ResultMap.get}
3455
+ * Gets a value from the map.
3456
+ * @param key - The key to retrieve.
3457
+ * @returns `Success` with the value and detail `exists` if the key was found,
3458
+ * `Failure` with detail `not-found` if the key was not found or with detail
3459
+ * `invalid-key` if the key is invalid.
3069
3460
  */
3070
3461
  get(key: TK): DetailedResult<TV, ResultMapResultDetail>;
3071
3462
  /**
3072
- * {@inheritDoc Collections.ResultMap.has}
3463
+ * Returns `true` if the map contains a key.
3464
+ * @param key - The key to check.
3465
+ * @returns `true` if the key exists, `false` otherwise.
3073
3466
  */
3074
3467
  has(key: TK): boolean;
3075
3468
  /**
3076
- * {@inheritDoc Collections.ResultMap.keys}
3469
+ * Returns an iterator over the map keys.
3470
+ * @returns An iterator over the map keys.
3077
3471
  */
3078
3472
  keys(): IterableIterator<TK>;
3079
3473
  /**
3080
- * {@inheritDoc Collections.ResultMap.values}
3474
+ * Returns an iterator over the map values.
3475
+ * @returns An iterator over the map values.
3081
3476
  */
3082
3477
  values(): IterableIterator<TV>;
3083
3478
  /**
@@ -3113,15 +3508,19 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
3113
3508
  */
3114
3509
  declare interface IReadOnlyValidatingCollector<TITEM extends ICollectible<any, any>> extends IReadOnlyValidatingResultMap<CollectibleKey<TITEM>, TITEM> {
3115
3510
  /**
3116
- * {@inheritDoc Collections.ValidatingCollector.validating}
3511
+ * A {@link Collections.CollectorValidator | CollectorValidator} which validates keys and values
3512
+ * before inserting them into this collector.
3117
3513
  */
3118
3514
  readonly validating: IReadOnlyCollectorValidator<TITEM>;
3119
3515
  /**
3120
- * {@inheritDoc Collections.IReadOnlyCollector.getAt}
3516
+ * Gets the item at a specified index.
3517
+ * @param index - The index of the item to retrieve.
3518
+ * @returns `Success` with the item if it exists, or `Failure` with an error if the index is out of range.
3121
3519
  */
3122
3520
  getAt(index: number): Result<TITEM>;
3123
3521
  /**
3124
- * {@inheritDoc Collections.IReadOnlyCollector.valuesByIndex}
3522
+ * Gets all items in the collection, ordered by index.
3523
+ * @returns An array of items in the collection, ordered by index.
3125
3524
  */
3126
3525
  valuesByIndex(): ReadonlyArray<TITEM>;
3127
3526
  }
@@ -3132,7 +3531,8 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
3132
3531
  */
3133
3532
  declare interface IReadOnlyValidatingResultMap<TK extends string = string, TV = unknown> extends IReadOnlyResultMap<TK, TV> {
3134
3533
  /**
3135
- * {@inheritDoc Collections.ValidatingResultMap.validating}
3534
+ * A {@link Collections.ResultMapValidator | ResultMapValidator} which validates keys and values
3535
+ * before inserting them into this collection.
3136
3536
  */
3137
3537
  readonly validating: IReadOnlyResultMapValidator<TK, TV>;
3138
3538
  }
@@ -3234,6 +3634,47 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
3234
3634
  * {@label formatter}
3235
3635
  */
3236
3636
  orThrow(cb: ErrorFormatter): T;
3637
+ /**
3638
+ * Asserts at the call site that this {@link IResult | result} MUST be a success.
3639
+ * Returns the value on success; on failure, throws an `Error` whose message
3640
+ * is composed from the original failure message and the captured call-site
3641
+ * location (file, line, and where useful function name).
3642
+ *
3643
+ * @remarks
3644
+ * Use for declaration-time / setup-time invariants — module-level `const`
3645
+ * initializers, static class properties, static initialization blocks, and
3646
+ * test fixtures — where a failure indicates a coding bug that should
3647
+ * surface at the call site rather than propagate as a `Result`. For chains
3648
+ * where the throw is intentional control flow, prefer `orThrow`.
3649
+ *
3650
+ * On V8 (Node + Chromium) `Error.captureStackTrace` is used to elide
3651
+ * `shouldNotFail` itself from the captured stack so the parsed frame is
3652
+ * the user's call site directly. On WebKit (where `captureStackTrace` is
3653
+ * unavailable) the stack is parsed manually and frames whose **parsed
3654
+ * function name** contains `shouldNotFail` are filtered out — the raw
3655
+ * stack-line text (including the file path) is deliberately NOT inspected,
3656
+ * so consumer files named after `shouldNotFail` are not collateral damage.
3657
+ * Function names and exact line numbers depend on source-map availability
3658
+ * in the runtime. When no caller frame is recoverable (e.g. `frameDepth`
3659
+ * out of range, or `frameDepth: 0`) the message falls back to the
3660
+ * label-only form (or the bare original message when no label is given).
3661
+ *
3662
+ * Error message format (depending on whether a label and a usable function
3663
+ * name are available):
3664
+ * - both: `<label> (at <fn> in <file>:<line>): <original>`
3665
+ * - label only: `<label> (at <file>:<line>): <original>`
3666
+ * - fn only: `<fn> at <file>:<line>: <original>`
3667
+ * - neither: `<file>:<line>: <original>`
3668
+ *
3669
+ * @param label - Optional human-meaningful identifier (e.g. the constant
3670
+ * name) prefixed to the error message.
3671
+ * @param frameDepth - Optional 1-indexed depth into the caller stack.
3672
+ * Default `1` (immediate caller). Library authors wrapping `shouldNotFail`
3673
+ * inside their own helper pass `2` to attribute to their caller.
3674
+ * @returns The result value, if the operation was successful.
3675
+ * @throws `Error` if the result was a failure.
3676
+ */
3677
+ shouldNotFail(label?: string, frameDepth?: number): T;
3237
3678
  /**
3238
3679
  * Gets the value associated with a successful {@link IResult | result},
3239
3680
  * or a default value if the corresponding operation failed.
@@ -3276,6 +3717,30 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
3276
3717
  * was successful, propagates the result value from the successful event.
3277
3718
  */
3278
3719
  onFailure(cb: FailureContinuation<T>): Result<T>;
3720
+ /**
3721
+ * Calls a supplied {@link AsyncSuccessContinuation | async success continuation} if
3722
+ * the operation was a success, bridging into an {@link AsyncResult} chain.
3723
+ * @remarks
3724
+ * If the async callback rejects, the rejection is caught and converted
3725
+ * to a {@link Failure}.
3726
+ * @param cb - The {@link AsyncSuccessContinuation | async success continuation} to
3727
+ * be called in the event of success.
3728
+ * @returns An {@link AsyncResult} wrapping the async continuation result, or
3729
+ * propagating the error message from this failure.
3730
+ */
3731
+ thenOnSuccess<TN>(cb: AsyncSuccessContinuation<T, TN>): AsyncResult<TN>;
3732
+ /**
3733
+ * Calls a supplied {@link AsyncFailureContinuation | async failure continuation} if
3734
+ * the operation failed, bridging into an {@link AsyncResult} chain.
3735
+ * @remarks
3736
+ * If the async callback rejects, the rejection is caught and converted
3737
+ * to a {@link Failure}.
3738
+ * @param cb - The {@link AsyncFailureContinuation | async failure continuation} to
3739
+ * be called in the event of failure.
3740
+ * @returns An {@link AsyncResult} wrapping the async continuation result, or
3741
+ * propagating the success value from this result.
3742
+ */
3743
+ thenOnFailure(cb: AsyncFailureContinuation<T>): AsyncResult<T>;
3279
3744
  /**
3280
3745
  * Calls a supplied {@link ErrorFormatter | error formatter} if
3281
3746
  * the operation failed.
@@ -3527,6 +3992,25 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
3527
3992
  */
3528
3993
  declare function isDetailLogger(logger: ILogger): logger is IDetailLogger;
3529
3994
 
3995
+ /**
3996
+ * Internal helpers for `Result<T>.shouldNotFail()`. Parsing and message
3997
+ * composition live here so the `Result` class file stays focused on the
3998
+ * Result hierarchy itself; the helpers are exported with the `_` prefix
3999
+ * convention and `@internal` tag so unit tests can cover them directly
4000
+ * without adding test-only public exports.
4001
+ */
4002
+ /**
4003
+ * Parsed stack-frame information used by `Result<T>.shouldNotFail`.
4004
+ * All fields are optional — runtimes that don't expose stack traces produce
4005
+ * an empty frame and the call site is omitted from the message.
4006
+ * @internal
4007
+ */
4008
+ export declare interface _IShouldNotFailFrame {
4009
+ fn?: string;
4010
+ file?: string;
4011
+ line?: number;
4012
+ }
4013
+
3530
4014
  /**
3531
4015
  * Determines if a supplied value is an iterable object or some other type.
3532
4016
  * @param value - The value to be tested.
@@ -3554,6 +4038,14 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
3554
4038
  */
3555
4039
  declare function isValidator<T, TC>(converterOrValidator: Converter<T, TC> | Validator<T, TC>): converterOrValidator is Validator<T, TC>;
3556
4040
 
4041
+ /**
4042
+ * Type guard that returns `true` when the input is a canonical UUIDv4 string.
4043
+ * @param value - The string to test.
4044
+ * @returns `true` if `value` is a canonical UUIDv4, narrowing it to {@link Uuid}.
4045
+ * @public
4046
+ */
4047
+ export declare function isValidUuid(value: string): value is Uuid;
4048
+
3557
4049
  /**
3558
4050
  * Parameters for constructing a {@link Collections.ValidatingCollector | ValidatingCollector}.
3559
4051
  * @public
@@ -3750,36 +4242,61 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
3750
4242
  */
3751
4243
  declare abstract class LoggerBase implements IDetailLogger {
3752
4244
  /**
3753
- * {@inheritDoc Logging.ILogger.logLevel}
4245
+ * The level of logging to be used.
3754
4246
  */
3755
4247
  logLevel: ReporterLogLevel;
3756
4248
  protected constructor(logLevel?: ReporterLogLevel);
3757
4249
  /**
3758
- * {@inheritDoc Logging.ILogger.detail}
4250
+ * Logs a detail message.
4251
+ * @param message - The message to log.
4252
+ * @param parameters - The parameters to log.
4253
+ * @returns `Success` with the logged message if the level is enabled, or
4254
+ * `Success` with `undefined` if the message is suppressed.
3759
4255
  */
3760
4256
  detail(message?: unknown, ...parameters: unknown[]): Success<string | undefined>;
3761
4257
  /**
3762
- * {@inheritDoc Logging.ILogger.info}
4258
+ * Logs an info message.
4259
+ * @param message - The message to log.
4260
+ * @param parameters - The parameters to log.
4261
+ * @returns `Success` with the logged message if the level is enabled, or
4262
+ * `Success` with `undefined` if the message is suppressed.
3763
4263
  */
3764
4264
  info(message?: unknown, ...parameters: unknown[]): Success<string | undefined>;
3765
4265
  /**
3766
- * {@inheritDoc Logging.ILogger.warn}
4266
+ * Logs a warning message.
4267
+ * @param message - The message to log.
4268
+ * @param parameters - The parameters to log.
4269
+ * @returns `Success` with the logged message if the level is enabled, or
4270
+ * `Success` with `undefined` if the message is suppressed.
3767
4271
  */
3768
4272
  warn(message?: unknown, ...parameters: unknown[]): Success<string | undefined>;
3769
4273
  /**
3770
- * {@inheritDoc Logging.ILogger.error}
4274
+ * Logs an error message.
4275
+ * @param message - The message to log.
4276
+ * @param parameters - The parameters to log.
4277
+ * @returns `Success` with the logged message if the level is enabled, or
4278
+ * `Success` with `undefined` if the message is suppressed.
3771
4279
  */
3772
4280
  error(message?: unknown, ...parameters: unknown[]): Success<string | undefined>;
3773
4281
  /**
3774
- * {@inheritDoc Logging.IDetailLogger.errorWithDetail}
4282
+ * Logs a short error summary at `error` level, then emits `detail` at `detail` level.
4283
+ * @param message - Short human-readable summary.
4284
+ * @param detail - Full detail (e.g. raw converter error) logged at `detail` level.
3775
4285
  */
3776
4286
  errorWithDetail(message: string, detail: unknown): Success<string | undefined>;
3777
4287
  /**
3778
- * {@inheritDoc Logging.IDetailLogger.warnWithDetail}
4288
+ * Logs a short warning summary at `warning` level, then emits `detail` at `detail` level.
4289
+ * @param message - Short human-readable summary.
4290
+ * @param detail - Full detail logged at `detail` level.
3779
4291
  */
3780
4292
  warnWithDetail(message: string, detail: unknown): Success<string | undefined>;
3781
4293
  /**
3782
- * {@inheritDoc Logging.ILogger.log}
4294
+ * Logs a message at the given level.
4295
+ * @param level - The level of the message.
4296
+ * @param message - The message to log.
4297
+ * @param parameters - The parameters to log.
4298
+ * @returns `Success` with the logged message if the level is enabled, or
4299
+ * `Success` with `undefined` if the message is suppressed.
3783
4300
  */
3784
4301
  log(level: MessageLogLevel, message?: unknown, ...parameters: unknown[]): Success<string | undefined>;
3785
4302
  /**
@@ -4144,6 +4661,30 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
4144
4661
  * @returns A normalized version of the value
4145
4662
  */
4146
4663
  normalize<T>(from: T): Result<T>;
4664
+ /**
4665
+ * Produces a stable, byte-identical JSON string following RFC 8785
4666
+ * (JSON Canonicalization Scheme) key-ordering rules.
4667
+ *
4668
+ * Builds the output string directly rather than constructing an intermediate
4669
+ * JS object, so integer-string keys (`"10"`, `"2"`) retain lexicographic
4670
+ * order instead of being reordered numerically by the JS engine during
4671
+ * `JSON.stringify`.
4672
+ *
4673
+ * @param from - Any JSON-compatible value (string, number, boolean, null,
4674
+ * plain object, or array). Fails for non-JSON types (Map, Set, Date,
4675
+ * RegExp, function, symbol, bigint, undefined).
4676
+ * @returns `Result<string>` — the canonical JSON string, or a failure if
4677
+ * `from` contains non-serializable types.
4678
+ * @public
4679
+ */
4680
+ canonicalize(from: unknown): Result<string>;
4681
+ /**
4682
+ * Recursively builds a byte-identical RFC 8785 JSON string.
4683
+ * @throws For non-JSON-serializable types (non-finite numbers, Date, RegExp,
4684
+ * Map, Set, class instances, function, symbol, bigint, undefined).
4685
+ * Callers must wrap in captureResult.
4686
+ */
4687
+ protected _canonicalizeRfc8785(value: unknown): string;
4147
4688
  /**
4148
4689
  * Compares two property names from some object being normalized.
4149
4690
  * @param k1 - First key to be compared.
@@ -4170,6 +4711,14 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
4170
4711
  normalizeLiteral<T>(from: T): Result<T>;
4171
4712
  }
4172
4713
 
4714
+ /**
4715
+ * Normalizes a function name from a stack frame, returning `undefined` when
4716
+ * the name is empty or one of the well-known anonymous-IIFE noise patterns
4717
+ * (typically emitted by V8 for module-top-level code).
4718
+ * @internal
4719
+ */
4720
+ export declare function _normalizeShouldNotFailFnName(fn: string | undefined): string | undefined;
4721
+
4173
4722
  /**
4174
4723
  * A {@link Converter | Converter} which converts `unknown` to a `number`.
4175
4724
  * @remarks
@@ -4513,6 +5062,13 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
4513
5062
  */
4514
5063
  export declare function omit<T extends object, K extends keyof T>(from: T, exclude: K[]): Omit<T, K>;
4515
5064
 
5065
+ /**
5066
+ * Union of all values in an array/tuple type, preserving literal types if possible.
5067
+ * If T is not an array/tuple, results in `never`.
5068
+ * @public
5069
+ */
5070
+ export declare type OneOf<T> = T extends readonly unknown[] ? T[number] : never;
5071
+
4516
5072
  /**
4517
5073
  * A helper function to create a {@link Converter | Converter} for polymorphic values.
4518
5074
  * Returns a converter which invokes the wrapped converters in sequence, returning the
@@ -4682,6 +5238,15 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
4682
5238
  */
4683
5239
  declare const optionalString: Converter<string | undefined, unknown>;
4684
5240
 
5241
+ /**
5242
+ * Parses a single stack-trace line in either V8 or WebKit format.
5243
+ *
5244
+ * V8: ` at <fn> (<file>:<line>:<col>)` or ` at <file>:<line>:<col>`
5245
+ * WebKit: `<fn>@<file>:<line>:<col>` or `@<file>:<line>:<col>`
5246
+ * @internal
5247
+ */
5248
+ export declare function _parseStackFrame(line: string): _IShouldNotFailFrame;
5249
+
4685
5250
  /**
4686
5251
  * Simple implicit pick function, which picks a set of properties from a supplied
4687
5252
  * object. Ignores picked properties that do not exist regardless of type signature.
@@ -5424,6 +5989,13 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
5424
5989
  message?: string;
5425
5990
  }
5426
5991
 
5992
+ /**
5993
+ * Union of all string values in an array/tuple type, preserving literal types if possible.
5994
+ * If T is not an array/tuple, results in `never`.
5995
+ * @public
5996
+ */
5997
+ export declare type StringOneOf<T> = Extract<OneOf<T>, string>;
5998
+
5427
5999
  /**
5428
6000
  * An in-place {@link Validation.Validator | Validator} for `string` values.
5429
6001
  * @public
@@ -5531,6 +6103,10 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
5531
6103
  * {@inheritDoc IResult.orThrow}
5532
6104
  */
5533
6105
  orThrow(cb: ErrorFormatter): T;
6106
+ /**
6107
+ * {@inheritDoc IResult.shouldNotFail}
6108
+ */
6109
+ shouldNotFail(__label?: string, __frameDepth?: number): T;
5534
6110
  /**
5535
6111
  * {@inheritDoc IResult.orDefault}
5536
6112
  */
@@ -5557,6 +6133,14 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
5557
6133
  * {@inheritDoc IResult.onFailure}
5558
6134
  */
5559
6135
  onFailure(__: FailureContinuation<T>): Result<T>;
6136
+ /**
6137
+ * {@inheritDoc IResult.thenOnSuccess}
6138
+ */
6139
+ thenOnSuccess<TN>(cb: AsyncSuccessContinuation<T, TN>): AsyncResult<TN>;
6140
+ /**
6141
+ * {@inheritDoc IResult.thenOnFailure}
6142
+ */
6143
+ thenOnFailure(__: AsyncFailureContinuation<T>): AsyncResult<T>;
5560
6144
  /**
5561
6145
  * {@inheritDoc IResult.withErrorFormat}
5562
6146
  */
@@ -5746,6 +6330,14 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
5746
6330
  }
5747
6331
  }
5748
6332
 
6333
+ /**
6334
+ * A canonical UUIDv4 string: 8-4-4-4-12 lowercase hex digits with version
6335
+ * nibble `4` and variant nibble in `[89ab]`. Produced by {@link generateUuid}
6336
+ * and validated by {@link isValidUuid}.
6337
+ * @public
6338
+ */
6339
+ export declare type Uuid = Brand<string, 'Uuid'>;
6340
+
5749
6341
  /**
5750
6342
  * Helper function to create a {@link Converter | Converter} from any {@link Validation.Validator}
5751
6343
  * @param converterOrValidator - the {@link Validation.Validator} to be wrapped or {@link Converter | Converter}