@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.
- package/README.md +21 -0
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -0
- package/dist/packlets/base/brand.js.map +1 -0
- package/dist/packlets/base/index.js +2 -0
- package/dist/packlets/base/index.js.map +1 -0
- package/dist/packlets/base/mapResults.js.map +1 -0
- package/dist/packlets/base/messageAggregator.js.map +1 -0
- package/dist/packlets/base/normalize.js +54 -1
- package/dist/packlets/base/normalize.js.map +1 -0
- package/dist/packlets/base/result.js +326 -2
- package/dist/packlets/base/result.js.map +1 -0
- package/dist/packlets/base/shouldNotFail.js +123 -0
- package/dist/packlets/base/shouldNotFail.js.map +1 -0
- package/dist/packlets/base/utils.js.map +1 -0
- package/dist/packlets/base/uuid.js +55 -0
- package/dist/packlets/base/uuid.js.map +1 -0
- package/dist/packlets/collections/aggregatedResultMap.js.map +1 -0
- package/dist/packlets/collections/collectible.js.map +1 -0
- package/dist/packlets/collections/collector.js +23 -9
- package/dist/packlets/collections/collector.js.map +1 -0
- package/dist/packlets/collections/collectorValidator.js +6 -1
- package/dist/packlets/collections/collectorValidator.js.map +1 -0
- package/dist/packlets/collections/common.js.map +1 -0
- package/dist/packlets/collections/converters.js.map +1 -0
- package/dist/packlets/collections/convertingCollector.js.map +1 -0
- package/dist/packlets/collections/convertingCollectorValidator.js.map +1 -0
- package/dist/packlets/collections/convertingResultMap.js.map +1 -0
- package/dist/packlets/collections/index.js +1 -0
- package/dist/packlets/collections/index.js.map +1 -0
- package/dist/packlets/collections/keyValueConverters.js.map +1 -0
- package/dist/packlets/collections/readOnlyConvertingResultMap.js +18 -0
- package/dist/packlets/collections/readOnlyConvertingResultMap.js.map +1 -0
- package/dist/packlets/collections/readonlyResultMap.js.map +1 -0
- package/dist/packlets/collections/resultMap.js.map +1 -0
- package/dist/packlets/collections/resultMapValidator.js.map +1 -0
- package/dist/packlets/collections/retainingRingBuffer.js +159 -0
- package/dist/packlets/collections/retainingRingBuffer.js.map +1 -0
- package/dist/packlets/collections/utils.js.map +1 -0
- package/dist/packlets/collections/validatingCollector.js.map +1 -0
- package/dist/packlets/collections/validatingConvertingCollector.js.map +1 -0
- package/dist/packlets/collections/validatingConvertingResultMap.js.map +1 -0
- package/dist/packlets/collections/validatingResultMap.js.map +1 -0
- package/dist/packlets/conversion/advancedConverters.js.map +1 -0
- package/dist/packlets/conversion/baseConverter.js +107 -18
- package/dist/packlets/conversion/baseConverter.js.map +1 -0
- package/dist/packlets/conversion/basicConverters.js +24 -5
- package/dist/packlets/conversion/basicConverters.js.map +1 -0
- package/dist/packlets/conversion/converter.js +11 -1
- package/dist/packlets/conversion/converter.js.map +1 -0
- package/dist/packlets/conversion/converters.js.map +1 -0
- package/dist/packlets/conversion/defaultingConverter.js.map +1 -0
- package/dist/packlets/conversion/index.js.map +1 -0
- package/dist/packlets/conversion/objectConverter.js.map +1 -0
- package/dist/packlets/conversion/stringConverter.js.map +1 -0
- package/dist/packlets/hash/crcNormalizer.js.map +1 -0
- package/dist/packlets/hash/hashingNormalizer.js.map +1 -0
- package/dist/packlets/hash/index.js.map +1 -0
- package/dist/packlets/logging/bootLogger.js.map +1 -0
- package/dist/packlets/logging/index.js +2 -0
- package/dist/packlets/logging/index.js.map +1 -0
- package/dist/packlets/logging/logReporter.js.map +1 -0
- package/dist/packlets/logging/logger.js +51 -18
- package/dist/packlets/logging/logger.js.map +1 -0
- package/dist/packlets/logging/multiLogger.js +104 -0
- package/dist/packlets/logging/multiLogger.js.map +1 -0
- package/dist/packlets/logging/retainingLogger.js +114 -0
- package/dist/packlets/logging/retainingLogger.js.map +1 -0
- package/dist/packlets/logging-interface/index.js +28 -0
- package/dist/packlets/logging-interface/index.js.map +1 -0
- package/dist/packlets/validation/array.js.map +1 -0
- package/dist/packlets/validation/boolean.js.map +1 -0
- package/dist/packlets/validation/classes.js.map +1 -0
- package/dist/packlets/validation/common.js.map +1 -0
- package/dist/packlets/validation/compositeId.js.map +1 -0
- package/dist/packlets/validation/field.js.map +1 -0
- package/dist/packlets/validation/genericValidator.js.map +1 -0
- package/dist/packlets/validation/index.js.map +1 -0
- package/dist/packlets/validation/number.js.map +1 -0
- package/dist/packlets/validation/object.js.map +1 -0
- package/dist/packlets/validation/oneOf.js.map +1 -0
- package/dist/packlets/validation/string.js.map +1 -0
- package/dist/packlets/validation/traits.js.map +1 -0
- package/dist/packlets/validation/typeGuard.js.map +1 -0
- package/dist/packlets/validation/validator.js.map +1 -0
- package/dist/packlets/validation/validatorBase.js.map +1 -0
- package/dist/packlets/validation/validators.js.map +1 -0
- package/dist/ts-utils.d.ts +1089 -59
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -0
- package/lib/packlets/base/brand.d.ts.map +1 -0
- package/lib/packlets/base/brand.js.map +1 -0
- package/lib/packlets/base/index.d.ts +2 -0
- package/lib/packlets/base/index.d.ts.map +1 -0
- package/lib/packlets/base/index.js +2 -0
- package/lib/packlets/base/index.js.map +1 -0
- package/lib/packlets/base/mapResults.d.ts.map +1 -0
- package/lib/packlets/base/mapResults.js.map +1 -0
- package/lib/packlets/base/messageAggregator.d.ts.map +1 -0
- package/lib/packlets/base/messageAggregator.js.map +1 -0
- package/lib/packlets/base/normalize.d.ts +24 -0
- package/lib/packlets/base/normalize.d.ts.map +1 -0
- package/lib/packlets/base/normalize.js +53 -0
- package/lib/packlets/base/normalize.js.map +1 -0
- package/lib/packlets/base/result.d.ts +295 -1
- package/lib/packlets/base/result.d.ts.map +1 -0
- package/lib/packlets/base/result.js +330 -3
- package/lib/packlets/base/result.js.map +1 -0
- package/lib/packlets/base/shouldNotFail.d.ts +53 -0
- package/lib/packlets/base/shouldNotFail.d.ts.map +1 -0
- package/lib/packlets/base/shouldNotFail.js +129 -0
- package/lib/packlets/base/shouldNotFail.js.map +1 -0
- package/lib/packlets/base/utils.d.ts +12 -0
- package/lib/packlets/base/utils.d.ts.map +1 -0
- package/lib/packlets/base/utils.js.map +1 -0
- package/lib/packlets/base/uuid.d.ts +27 -0
- package/lib/packlets/base/uuid.d.ts.map +1 -0
- package/lib/packlets/base/uuid.js +59 -0
- package/lib/packlets/base/uuid.js.map +1 -0
- package/lib/packlets/collections/aggregatedResultMap.d.ts.map +1 -0
- package/lib/packlets/collections/aggregatedResultMap.js.map +1 -0
- package/lib/packlets/collections/collectible.d.ts.map +1 -0
- package/lib/packlets/collections/collectible.js.map +1 -0
- package/lib/packlets/collections/collector.d.ts +23 -9
- package/lib/packlets/collections/collector.d.ts.map +1 -0
- package/lib/packlets/collections/collector.js +23 -9
- package/lib/packlets/collections/collector.js.map +1 -0
- package/lib/packlets/collections/collectorValidator.d.ts +29 -5
- package/lib/packlets/collections/collectorValidator.d.ts.map +1 -0
- package/lib/packlets/collections/collectorValidator.js +6 -1
- package/lib/packlets/collections/collectorValidator.js.map +1 -0
- package/lib/packlets/collections/common.d.ts.map +1 -0
- package/lib/packlets/collections/common.js.map +1 -0
- package/lib/packlets/collections/converters.d.ts.map +1 -0
- package/lib/packlets/collections/converters.js.map +1 -0
- package/lib/packlets/collections/convertingCollector.d.ts +21 -3
- package/lib/packlets/collections/convertingCollector.d.ts.map +1 -0
- package/lib/packlets/collections/convertingCollector.js.map +1 -0
- package/lib/packlets/collections/convertingCollectorValidator.d.ts +22 -3
- package/lib/packlets/collections/convertingCollectorValidator.d.ts.map +1 -0
- package/lib/packlets/collections/convertingCollectorValidator.js.map +1 -0
- package/lib/packlets/collections/convertingResultMap.d.ts.map +1 -0
- package/lib/packlets/collections/convertingResultMap.js.map +1 -0
- package/lib/packlets/collections/index.d.ts +1 -0
- package/lib/packlets/collections/index.d.ts.map +1 -0
- package/lib/packlets/collections/index.js +1 -0
- package/lib/packlets/collections/index.js.map +1 -0
- package/lib/packlets/collections/keyValueConverters.d.ts.map +1 -0
- package/lib/packlets/collections/keyValueConverters.js.map +1 -0
- package/lib/packlets/collections/readOnlyConvertingResultMap.d.ts +13 -1
- package/lib/packlets/collections/readOnlyConvertingResultMap.d.ts.map +1 -0
- package/lib/packlets/collections/readOnlyConvertingResultMap.js +19 -1
- package/lib/packlets/collections/readOnlyConvertingResultMap.js.map +1 -0
- package/lib/packlets/collections/readonlyResultMap.d.ts +18 -7
- package/lib/packlets/collections/readonlyResultMap.d.ts.map +1 -0
- package/lib/packlets/collections/readonlyResultMap.js.map +1 -0
- package/lib/packlets/collections/resultMap.d.ts.map +1 -0
- package/lib/packlets/collections/resultMap.js.map +1 -0
- package/lib/packlets/collections/resultMapValidator.d.ts.map +1 -0
- package/lib/packlets/collections/resultMapValidator.js.map +1 -0
- package/lib/packlets/collections/retainingRingBuffer.d.ts +147 -0
- package/lib/packlets/collections/retainingRingBuffer.d.ts.map +1 -0
- package/lib/packlets/collections/retainingRingBuffer.js +163 -0
- package/lib/packlets/collections/retainingRingBuffer.js.map +1 -0
- package/lib/packlets/collections/utils.d.ts.map +1 -0
- package/lib/packlets/collections/utils.js.map +1 -0
- package/lib/packlets/collections/validatingCollector.d.ts +7 -3
- package/lib/packlets/collections/validatingCollector.d.ts.map +1 -0
- package/lib/packlets/collections/validatingCollector.js.map +1 -0
- package/lib/packlets/collections/validatingConvertingCollector.d.ts.map +1 -0
- package/lib/packlets/collections/validatingConvertingCollector.js.map +1 -0
- package/lib/packlets/collections/validatingConvertingResultMap.d.ts.map +1 -0
- package/lib/packlets/collections/validatingConvertingResultMap.js.map +1 -0
- package/lib/packlets/collections/validatingResultMap.d.ts +2 -1
- package/lib/packlets/collections/validatingResultMap.d.ts.map +1 -0
- package/lib/packlets/collections/validatingResultMap.js.map +1 -0
- package/lib/packlets/conversion/advancedConverters.d.ts.map +1 -0
- package/lib/packlets/conversion/advancedConverters.js.map +1 -0
- package/lib/packlets/conversion/baseConverter.d.ts +108 -19
- package/lib/packlets/conversion/baseConverter.d.ts.map +1 -0
- package/lib/packlets/conversion/baseConverter.js +107 -18
- package/lib/packlets/conversion/baseConverter.js.map +1 -0
- package/lib/packlets/conversion/basicConverters.d.ts +14 -0
- package/lib/packlets/conversion/basicConverters.d.ts.map +1 -0
- package/lib/packlets/conversion/basicConverters.js +24 -5
- package/lib/packlets/conversion/basicConverters.js.map +1 -0
- package/lib/packlets/conversion/converter.d.ts +9 -1
- package/lib/packlets/conversion/converter.d.ts.map +1 -0
- package/lib/packlets/conversion/converter.js +12 -0
- package/lib/packlets/conversion/converter.js.map +1 -0
- package/lib/packlets/conversion/converters.d.ts.map +1 -0
- package/lib/packlets/conversion/converters.js.map +1 -0
- package/lib/packlets/conversion/defaultingConverter.d.ts.map +1 -0
- package/lib/packlets/conversion/defaultingConverter.js.map +1 -0
- package/lib/packlets/conversion/index.d.ts.map +1 -0
- package/lib/packlets/conversion/index.js.map +1 -0
- package/lib/packlets/conversion/objectConverter.d.ts.map +1 -0
- package/lib/packlets/conversion/objectConverter.js.map +1 -0
- package/lib/packlets/conversion/stringConverter.d.ts.map +1 -0
- package/lib/packlets/conversion/stringConverter.js.map +1 -0
- package/lib/packlets/hash/crcNormalizer.d.ts.map +1 -0
- package/lib/packlets/hash/crcNormalizer.js.map +1 -0
- package/lib/packlets/hash/hashingNormalizer.d.ts.map +1 -0
- package/lib/packlets/hash/hashingNormalizer.js.map +1 -0
- package/lib/packlets/hash/index.d.ts.map +1 -0
- package/lib/packlets/hash/index.js.map +1 -0
- package/lib/packlets/logging/bootLogger.d.ts.map +1 -0
- package/lib/packlets/logging/bootLogger.js.map +1 -0
- package/lib/packlets/logging/index.d.ts +2 -0
- package/lib/packlets/logging/index.d.ts.map +1 -0
- package/lib/packlets/logging/index.js +2 -0
- package/lib/packlets/logging/index.js.map +1 -0
- package/lib/packlets/logging/logReporter.d.ts.map +1 -0
- package/lib/packlets/logging/logReporter.js.map +1 -0
- package/lib/packlets/logging/logger.d.ts +25 -70
- package/lib/packlets/logging/logger.d.ts.map +1 -0
- package/lib/packlets/logging/logger.js +54 -20
- package/lib/packlets/logging/logger.js.map +1 -0
- package/lib/packlets/logging/multiLogger.d.ts +54 -0
- package/lib/packlets/logging/multiLogger.d.ts.map +1 -0
- package/lib/packlets/logging/multiLogger.js +108 -0
- package/lib/packlets/logging/multiLogger.js.map +1 -0
- package/lib/packlets/logging/retainingLogger.d.ts +123 -0
- package/lib/packlets/logging/retainingLogger.d.ts.map +1 -0
- package/lib/packlets/logging/retainingLogger.js +118 -0
- package/lib/packlets/logging/retainingLogger.js.map +1 -0
- package/lib/packlets/logging-interface/index.d.ts +98 -0
- package/lib/packlets/logging-interface/index.d.ts.map +1 -0
- package/lib/packlets/logging-interface/index.js +32 -0
- package/lib/packlets/logging-interface/index.js.map +1 -0
- package/lib/packlets/validation/array.d.ts.map +1 -0
- package/lib/packlets/validation/array.js.map +1 -0
- package/lib/packlets/validation/boolean.d.ts.map +1 -0
- package/lib/packlets/validation/boolean.js.map +1 -0
- package/lib/packlets/validation/classes.d.ts.map +1 -0
- package/lib/packlets/validation/classes.js.map +1 -0
- package/lib/packlets/validation/common.d.ts.map +1 -0
- package/lib/packlets/validation/common.js.map +1 -0
- package/lib/packlets/validation/compositeId.d.ts.map +1 -0
- package/lib/packlets/validation/compositeId.js.map +1 -0
- package/lib/packlets/validation/field.d.ts.map +1 -0
- package/lib/packlets/validation/field.js.map +1 -0
- package/lib/packlets/validation/genericValidator.d.ts.map +1 -0
- package/lib/packlets/validation/genericValidator.js.map +1 -0
- package/lib/packlets/validation/index.d.ts.map +1 -0
- package/lib/packlets/validation/index.js.map +1 -0
- package/lib/packlets/validation/number.d.ts.map +1 -0
- package/lib/packlets/validation/number.js.map +1 -0
- package/lib/packlets/validation/object.d.ts.map +1 -0
- package/lib/packlets/validation/object.js.map +1 -0
- package/lib/packlets/validation/oneOf.d.ts.map +1 -0
- package/lib/packlets/validation/oneOf.js.map +1 -0
- package/lib/packlets/validation/string.d.ts.map +1 -0
- package/lib/packlets/validation/string.js.map +1 -0
- package/lib/packlets/validation/traits.d.ts.map +1 -0
- package/lib/packlets/validation/traits.js.map +1 -0
- package/lib/packlets/validation/typeGuard.d.ts.map +1 -0
- package/lib/packlets/validation/typeGuard.js.map +1 -0
- package/lib/packlets/validation/validator.d.ts.map +1 -0
- package/lib/packlets/validation/validator.js.map +1 -0
- package/lib/packlets/validation/validatorBase.d.ts +2 -1
- package/lib/packlets/validation/validatorBase.d.ts.map +1 -0
- package/lib/packlets/validation/validatorBase.js.map +1 -0
- package/lib/packlets/validation/validators.d.ts.map +1 -0
- package/lib/packlets/validation/validators.js.map +1 -0
- package/package.json +3 -3
- package/dist/test/helpers/jest/helpers/fsHelpers.js +0 -139
- package/dist/test/helpers/jest/helpers/index.js +0 -2
- package/dist/test/helpers/jest/index.js +0 -17
- package/dist/test/helpers/jest/matchers/index.js +0 -14
- package/dist/test/helpers/jest/matchers/toFail/index.js +0 -23
- package/dist/test/helpers/jest/matchers/toFail/predicate.js +0 -5
- package/dist/test/helpers/jest/matchers/toFailTest/index.js +0 -28
- package/dist/test/helpers/jest/matchers/toFailTest/predicate.js +0 -8
- package/dist/test/helpers/jest/matchers/toFailTestAndMatchSnapshot/index.js +0 -24
- package/dist/test/helpers/jest/matchers/toFailTestAndMatchSnapshot/predicate.js +0 -11
- package/dist/test/helpers/jest/matchers/toFailTestWith/index.js +0 -29
- package/dist/test/helpers/jest/matchers/toFailTestWith/predicate.js +0 -26
- package/dist/test/helpers/jest/matchers/toFailWith/index.js +0 -27
- package/dist/test/helpers/jest/matchers/toFailWith/predicate.js +0 -16
- package/dist/test/helpers/jest/matchers/toFailWithDetail/index.js +0 -27
- package/dist/test/helpers/jest/matchers/toFailWithDetail/predicate.js +0 -22
- package/dist/test/helpers/jest/matchers/toSucceed/index.js +0 -23
- package/dist/test/helpers/jest/matchers/toSucceed/predicate.js +0 -5
- package/dist/test/helpers/jest/matchers/toSucceedAndMatchInlineSnapshot/index.js +0 -24
- package/dist/test/helpers/jest/matchers/toSucceedAndMatchSnapshot/index.js +0 -24
- package/dist/test/helpers/jest/matchers/toSucceedAndSatisfy/index.js +0 -53
- package/dist/test/helpers/jest/matchers/toSucceedAndSatisfy/predicate.js +0 -17
- package/dist/test/helpers/jest/matchers/toSucceedWith/index.js +0 -27
- package/dist/test/helpers/jest/matchers/toSucceedWith/predicate.js +0 -12
- package/dist/test/helpers/jest/matchers/toSucceedWithDetail/index.js +0 -27
- package/dist/test/helpers/jest/matchers/toSucceedWithDetail/predicate.js +0 -17
- package/dist/test/helpers/jest/resolvers/cli.js +0 -10
- package/dist/test/helpers/jest/resolvers/ide.js +0 -10
- package/dist/test/helpers/jest/ts-utils.js +0 -2
- package/dist/test/helpers/jest/types/index.js +0 -3
- package/dist/test/helpers/jest/utils/matcherHelpers.js +0 -47
- package/dist/test/helpers/jest/utils/snapshotResolver.js +0 -11
- package/dist/test/unit/collections/helpers.js +0 -106
- package/dist/test/unit/hashTextEncodeCompat.js +0 -23
package/dist/ts-utils.d.ts
CHANGED
|
@@ -336,6 +336,30 @@ declare class AggregatedResultMapValidator<TCOMPOSITEID extends string, TCOLLECT
|
|
|
336
336
|
delete(key: string): DetailedResult<TITEM, ResultMapResultDetail>;
|
|
337
337
|
}
|
|
338
338
|
|
|
339
|
+
/**
|
|
340
|
+
* Exhaustive list of all {@link Collections.ConversionErrorHandling | ConversionErrorHandling} values.
|
|
341
|
+
* @public
|
|
342
|
+
*/
|
|
343
|
+
declare const allConversionErrorHandling: readonly ConversionErrorHandling[];
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Exhaustive list of all {@link MessageLogLevel} values.
|
|
347
|
+
* @public
|
|
348
|
+
*/
|
|
349
|
+
export declare const allMessageLogLevels: readonly MessageLogLevel[];
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Exhaustive list of all {@link Conversion.OnError | OnError} values.
|
|
353
|
+
* @public
|
|
354
|
+
*/
|
|
355
|
+
declare const allOnError: readonly OnError[];
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Exhaustive list of all {@link Logging.ReporterLogLevel | ReporterLogLevel} values.
|
|
359
|
+
* @public
|
|
360
|
+
*/
|
|
361
|
+
declare const allReporterLogLevels: readonly ReporterLogLevel[];
|
|
362
|
+
|
|
339
363
|
/**
|
|
340
364
|
* Determines if an iterable collection of {@link Result | Result<T>} were all successful.
|
|
341
365
|
* @param results - The collection of {@link Result | Result<T>} to be tested.
|
|
@@ -420,6 +444,145 @@ declare interface ArrayValidatorConstructorParams<T, TC = unknown> extends Valid
|
|
|
420
444
|
*/
|
|
421
445
|
declare function asValidator<T, TC = unknown>(converterOrValidator: Converter<T, TC> | Validator<T, TC>): Validator<T, TC>;
|
|
422
446
|
|
|
447
|
+
/**
|
|
448
|
+
* Async continuation callback to be called in the event that a
|
|
449
|
+
* {@link Result} fails, returning a `PromiseLike` of a new {@link Result}.
|
|
450
|
+
* @remarks
|
|
451
|
+
* See {@link AsyncSuccessContinuation} for the rationale behind accepting
|
|
452
|
+
* any `PromiseLike<Result<T>>` rather than only a `Promise<Result<T>>`.
|
|
453
|
+
* @public
|
|
454
|
+
*/
|
|
455
|
+
export declare type AsyncFailureContinuation<T> = (message: string) => PromiseLike<Result<T>>;
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* Wraps a `Promise` of a {@link Result} to enable fluent chaining of both
|
|
459
|
+
* synchronous and asynchronous operations.
|
|
460
|
+
*
|
|
461
|
+
* @remarks
|
|
462
|
+
* `AsyncResult<T>` implements `PromiseLike` so it can be directly `await`ed.
|
|
463
|
+
* Use the `thenOnSuccess` and `thenOnFailure` methods on {@link Result} to bridge
|
|
464
|
+
* from synchronous to asynchronous result chains.
|
|
465
|
+
*
|
|
466
|
+
* @example
|
|
467
|
+
* ```typescript
|
|
468
|
+
* const result: Result<Final> = await parseInput(input)
|
|
469
|
+
* .thenOnSuccess(async (parsed) => fetchData(parsed))
|
|
470
|
+
* .onSuccess((data) => transform(data))
|
|
471
|
+
* .thenOnSuccess(async (transformed) => saveData(transformed))
|
|
472
|
+
* .withErrorFormat((msg) => `pipeline failed: ${msg}`);
|
|
473
|
+
* ```
|
|
474
|
+
*
|
|
475
|
+
* @public
|
|
476
|
+
*/
|
|
477
|
+
export declare class AsyncResult<T> implements PromiseLike<Result<T>> {
|
|
478
|
+
private readonly _promise;
|
|
479
|
+
/**
|
|
480
|
+
* Constructs an {@link AsyncResult} wrapping the supplied promise (or any
|
|
481
|
+
* `PromiseLike` that resolves to a {@link Result}, such as another
|
|
482
|
+
* {@link AsyncResult}).
|
|
483
|
+
* @remarks
|
|
484
|
+
* If the supplied promise rejects, the rejection is caught and converted
|
|
485
|
+
* to a {@link Failure}, ensuring that awaiting an {@link AsyncResult} always
|
|
486
|
+
* yields a {@link Result}.
|
|
487
|
+
* @param promise - A `Promise` (or `PromiseLike`) that resolves to a
|
|
488
|
+
* {@link Result}.
|
|
489
|
+
*/
|
|
490
|
+
constructor(promise: PromiseLike<Result<T>>);
|
|
491
|
+
/**
|
|
492
|
+
* Calls a supplied {@link SuccessContinuation | success continuation} if
|
|
493
|
+
* the wrapped result is successful.
|
|
494
|
+
* @param cb - The synchronous {@link SuccessContinuation | success continuation}
|
|
495
|
+
* to be called in the event of success.
|
|
496
|
+
* @returns A new {@link AsyncResult} wrapping the continuation result.
|
|
497
|
+
*/
|
|
498
|
+
onSuccess<TN>(cb: SuccessContinuation<T, TN>): AsyncResult<TN>;
|
|
499
|
+
/**
|
|
500
|
+
* Calls a supplied {@link AsyncSuccessContinuation | async success continuation} if
|
|
501
|
+
* the wrapped result is successful.
|
|
502
|
+
* @remarks
|
|
503
|
+
* Both synchronous throws and async rejections from the callback are caught
|
|
504
|
+
* and converted to a {@link Failure}.
|
|
505
|
+
* @param cb - The {@link AsyncSuccessContinuation | async success continuation}
|
|
506
|
+
* to be called in the event of success.
|
|
507
|
+
* @returns A new {@link AsyncResult} wrapping the async continuation result.
|
|
508
|
+
*/
|
|
509
|
+
thenOnSuccess<TN>(cb: AsyncSuccessContinuation<T, TN>): AsyncResult<TN>;
|
|
510
|
+
/**
|
|
511
|
+
* Calls a supplied {@link FailureContinuation | failure continuation} if
|
|
512
|
+
* the wrapped result is a failure.
|
|
513
|
+
* @param cb - The synchronous {@link FailureContinuation | failure continuation}
|
|
514
|
+
* to be called in the event of failure.
|
|
515
|
+
* @returns A new {@link AsyncResult} wrapping the continuation result.
|
|
516
|
+
*/
|
|
517
|
+
onFailure(cb: FailureContinuation<T>): AsyncResult<T>;
|
|
518
|
+
/**
|
|
519
|
+
* Calls a supplied {@link AsyncFailureContinuation | async failure continuation} if
|
|
520
|
+
* the wrapped result is a failure.
|
|
521
|
+
* @remarks
|
|
522
|
+
* Both synchronous throws and async rejections from the callback are caught
|
|
523
|
+
* and converted to a {@link Failure}.
|
|
524
|
+
* @param cb - The {@link AsyncFailureContinuation | async failure continuation}
|
|
525
|
+
* to be called in the event of failure.
|
|
526
|
+
* @returns A new {@link AsyncResult} wrapping the async continuation result.
|
|
527
|
+
*/
|
|
528
|
+
thenOnFailure(cb: AsyncFailureContinuation<T>): AsyncResult<T>;
|
|
529
|
+
/**
|
|
530
|
+
* Calls a supplied {@link ErrorFormatter | error formatter} if
|
|
531
|
+
* the wrapped result is a failure.
|
|
532
|
+
* @param cb - The {@link ErrorFormatter | error formatter} to
|
|
533
|
+
* be called in the event of failure.
|
|
534
|
+
* @returns A new {@link AsyncResult} with the formatted error message,
|
|
535
|
+
* or the original success result.
|
|
536
|
+
*/
|
|
537
|
+
withErrorFormat(cb: ErrorFormatter): AsyncResult<T>;
|
|
538
|
+
/**
|
|
539
|
+
* Propagates the wrapped result, appending any error message to the
|
|
540
|
+
* supplied errors aggregator.
|
|
541
|
+
* @param errors - {@link IMessageAggregator | Error aggregator} in which
|
|
542
|
+
* errors will be aggregated.
|
|
543
|
+
* @param formatter - An optional {@link ErrorFormatter | error formatter}
|
|
544
|
+
* to be used to format the error message.
|
|
545
|
+
* @returns A new {@link AsyncResult} wrapping the result after aggregation.
|
|
546
|
+
*/
|
|
547
|
+
aggregateError(errors: IMessageAggregator, formatter?: ErrorFormatter): AsyncResult<T>;
|
|
548
|
+
/**
|
|
549
|
+
* Reports the wrapped result to the supplied reporter.
|
|
550
|
+
* @param reporter - The {@link IResultReporter | reporter} to which the result
|
|
551
|
+
* will be reported.
|
|
552
|
+
* @param options - The {@link IResultReportOptions | options} for reporting the result.
|
|
553
|
+
* @returns A new {@link AsyncResult} wrapping the result after reporting.
|
|
554
|
+
*/
|
|
555
|
+
report(reporter?: IResultReporter<T>, options?: IResultReportOptions<unknown>): AsyncResult<T>;
|
|
556
|
+
/**
|
|
557
|
+
* Implementation of `PromiseLike.then` enabling `await` on {@link AsyncResult}.
|
|
558
|
+
* @param onfulfilled - Callback invoked when the promise resolves.
|
|
559
|
+
* @param onrejected - Callback invoked when the promise rejects.
|
|
560
|
+
* @returns A `Promise` resolving to the callback result.
|
|
561
|
+
*/
|
|
562
|
+
then<TResult1 = Result<T>, TResult2 = never>(onfulfilled?: ((value: Result<T>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
563
|
+
/**
|
|
564
|
+
* Creates an {@link AsyncResult} from a {@link Result}.
|
|
565
|
+
* @param result - The {@link Result} to wrap.
|
|
566
|
+
* @returns A new {@link AsyncResult} wrapping the supplied result.
|
|
567
|
+
*/
|
|
568
|
+
static from<T>(result: Result<T>): AsyncResult<T>;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
/**
|
|
572
|
+
* Async continuation callback to be called in the event that a
|
|
573
|
+
* {@link Result} is successful, returning a `PromiseLike` of a new
|
|
574
|
+
* {@link Result}.
|
|
575
|
+
* @remarks
|
|
576
|
+
* Typed as `PromiseLike<Result<TN>>` rather than `Promise<Result<TN>>` so
|
|
577
|
+
* callers can return the result of {@link captureAsyncResult} (which is an
|
|
578
|
+
* {@link AsyncResult}, itself a `PromiseLike<Result<TN>>`) directly from a
|
|
579
|
+
* `thenOnSuccess` callback without an `async` wrapper to coerce the
|
|
580
|
+
* contextual return type back through `Awaited<>`. The continuation result
|
|
581
|
+
* is always wrapped into an {@link AsyncResult}, so chaining is unaffected.
|
|
582
|
+
* @public
|
|
583
|
+
*/
|
|
584
|
+
export declare type AsyncSuccessContinuation<T, TN> = (value: T) => PromiseLike<Result<TN>>;
|
|
585
|
+
|
|
423
586
|
declare namespace Base {
|
|
424
587
|
export {
|
|
425
588
|
GenericValidatorConstructorParams,
|
|
@@ -454,63 +617,149 @@ declare class BaseConverter<T, TC = unknown> implements Converter<T, TC> {
|
|
|
454
617
|
*/
|
|
455
618
|
constructor(converter: ConverterFunc<T, TC>, defaultContext?: TC, traits?: ConverterTraits);
|
|
456
619
|
/**
|
|
457
|
-
*
|
|
620
|
+
* Indicates whether this element is explicitly optional.
|
|
458
621
|
*/
|
|
459
622
|
get isOptional(): boolean;
|
|
460
623
|
/**
|
|
461
|
-
*
|
|
624
|
+
* Returns the brand for a branded type.
|
|
462
625
|
*/
|
|
463
626
|
get brand(): string | undefined;
|
|
464
627
|
/**
|
|
465
|
-
*
|
|
628
|
+
* Converts from `unknown` to `<T>`. For objects and arrays, is guaranteed
|
|
629
|
+
* to return a new entity, with any unrecognized properties removed.
|
|
630
|
+
* @param from - The `unknown` to be converted
|
|
631
|
+
* @param context - An optional conversion context of type `<TC>` to be used in
|
|
632
|
+
* the conversion.
|
|
633
|
+
* @param selfOverride - An optional override for the `self` reference passed to the
|
|
634
|
+
* converter function, enabling outer converters (e.g. discriminated-object) to thread
|
|
635
|
+
* themselves through to per-arm converters for recursive parsing.
|
|
636
|
+
* @returns A {@link Result} with a {@link Success} and a value on success or an
|
|
637
|
+
* {@link Failure} with a a message on failure.
|
|
466
638
|
*/
|
|
467
|
-
convert(from: unknown, context?: TC): Result<T>;
|
|
639
|
+
convert(from: unknown, context?: TC, selfOverride?: Converter<T, TC>): Result<T>;
|
|
468
640
|
/**
|
|
469
|
-
*
|
|
641
|
+
* Converts from `unknown` to `<T>` or `undefined`, as appropriate.
|
|
642
|
+
*
|
|
643
|
+
* @remarks
|
|
644
|
+
* If `onError` is `failOnError`, the converter succeeds for
|
|
645
|
+
* `undefined` or any convertible value, but reports an error
|
|
646
|
+
* if it encounters a value that cannot be converted.
|
|
647
|
+
*
|
|
648
|
+
* If `onError` is `ignoreErrors` (default) then values that
|
|
649
|
+
* cannot be converted result in a successful return of `undefined`.
|
|
650
|
+
* @param from - The `unknown` to be converted
|
|
651
|
+
* @param context - An optional conversion context of type `<TC>` to be used in
|
|
652
|
+
* the conversion.
|
|
653
|
+
* @param onError - Specifies handling of values that cannot be converted (default `ignoreErrors`).
|
|
654
|
+
* @returns A {@link Result} with a {@link Success} and a value on success or an
|
|
655
|
+
* {@link Failure} with a a message on failure.
|
|
470
656
|
*/
|
|
471
657
|
convertOptional(from: unknown, context?: TC, onError?: OnError): Result<T | undefined>;
|
|
472
658
|
/**
|
|
473
|
-
* {@
|
|
659
|
+
* Creates a {@link Converter} for an optional value.
|
|
660
|
+
*
|
|
661
|
+
* @remarks
|
|
662
|
+
* If `onError` is `failOnError`, the resulting converter will accept `undefined`
|
|
663
|
+
* or a convertible value, but report an error if it encounters a value that cannot be
|
|
664
|
+
* converted.
|
|
665
|
+
*
|
|
666
|
+
* If `onError` is `ignoreErrors` (default) then values that cannot be converted will
|
|
667
|
+
* result in a successful return of `undefined`.
|
|
668
|
+
*
|
|
669
|
+
* @param onError - Specifies handling of values that cannot be converted (default `ignoreErrors`).
|
|
670
|
+
* @returns A new {@link Converter} returning `<T|undefined>`.
|
|
474
671
|
*/
|
|
475
672
|
optional(onError?: OnError): Converter<T | undefined, TC>;
|
|
476
673
|
/**
|
|
477
|
-
* {@
|
|
674
|
+
* Creates a {@link Converter} which applies a (possibly) mapping conversion to
|
|
675
|
+
* the converted value of this {@link Converter}.
|
|
676
|
+
* @param mapper - A function which maps from the the result type `<T>` of this
|
|
677
|
+
* converter to a new result type `<T2>`.
|
|
678
|
+
* @returns A new {@link Converter} returning `<T2>`.
|
|
478
679
|
*/
|
|
479
680
|
map<T2>(mapper: (from: T, context?: TC) => Result<T2>): Converter<T2, TC>;
|
|
480
681
|
/**
|
|
481
|
-
* {@
|
|
682
|
+
* Creates a {@link Converter} which applies an additional supplied
|
|
683
|
+
* converter to the result of this converter.
|
|
684
|
+
*
|
|
685
|
+
* @param mapConverter - The {@link Converter} to be applied to the
|
|
686
|
+
* converted result from this {@link Converter}.
|
|
687
|
+
* @returns A new {@link Converter} returning `<T2>`.
|
|
482
688
|
*/
|
|
483
689
|
mapConvert<T2>(mapConverter: Converter<T2>): Converter<T2, TC>;
|
|
484
690
|
/**
|
|
485
|
-
* {@
|
|
691
|
+
* Creates a {@link Converter} which maps the individual items of a collection
|
|
692
|
+
* resulting from this {@link Converter} using the supplied map function.
|
|
693
|
+
*
|
|
694
|
+
* @remarks
|
|
695
|
+
* Fails if `from` is not an array.
|
|
696
|
+
*
|
|
697
|
+
* @param mapper - The map function to be applied to each element of the
|
|
698
|
+
* result of this {@link Converter}.
|
|
699
|
+
* @returns A new {@link Converter} returning `<TI[]>`.
|
|
486
700
|
*/
|
|
487
701
|
mapItems<TI>(mapper: (from: unknown, context?: TC) => Result<TI>): Converter<TI[], TC>;
|
|
488
702
|
/**
|
|
489
|
-
* {@
|
|
703
|
+
* Creates a {@link Converter} which maps the individual items of a collection
|
|
704
|
+
* resulting from this {@link Converter} using the supplied {@link Converter}.
|
|
705
|
+
*
|
|
706
|
+
* @remarks
|
|
707
|
+
* Fails if `from` is not an array.
|
|
708
|
+
*
|
|
709
|
+
* @param mapConverter - The {@link Converter} to be applied to each element of the
|
|
710
|
+
* result of this {@link Converter}.
|
|
711
|
+
* @returns A new {@link Converter} returning `<TI[]>`.
|
|
490
712
|
*/
|
|
491
713
|
mapConvertItems<TI>(mapConverter: Converter<TI, unknown>): Converter<TI[], TC>;
|
|
492
714
|
/**
|
|
493
|
-
* {@
|
|
715
|
+
* Creates a {@link Converter | Converter} which applies a supplied action after
|
|
716
|
+
* conversion. The supplied action is always called regardless of success or failure
|
|
717
|
+
* of the base conversion and is allowed to mutate the return type.
|
|
718
|
+
* @param action - The action to be applied.
|
|
494
719
|
*/
|
|
495
720
|
withAction<TI>(action: (result: Result<T>, context?: TC) => Result<TI>): Converter<TI, TC>;
|
|
496
721
|
/**
|
|
497
|
-
* {@
|
|
722
|
+
* Creates a {@link Converter} which applies a supplied type guard to the conversion
|
|
723
|
+
* result.
|
|
724
|
+
* @param guard - The type guard function to apply.
|
|
725
|
+
* @param message - Optional message to be reported if the type guard fails.
|
|
726
|
+
* @returns A new {@link Converter} returning `<TI>`.
|
|
498
727
|
*/
|
|
499
728
|
withTypeGuard<TI>(guard: (from: unknown, context?: TC) => from is TI, message?: string): Converter<TI, TC>;
|
|
500
729
|
/**
|
|
501
|
-
* {@
|
|
730
|
+
* Creates a {@link Converter} which applies a supplied type guard to each member of
|
|
731
|
+
* the conversion result from this converter.
|
|
732
|
+
*
|
|
733
|
+
* @remarks
|
|
734
|
+
* Fails if the conversion result is not an array or if any member fails the
|
|
735
|
+
* type guard.
|
|
736
|
+
* @param guard - The type guard function to apply to each element.
|
|
737
|
+
* @param message - Optional message to be reported if the type guard fails.
|
|
738
|
+
* @returns A new {@link Converter} returning `<TI>`.
|
|
502
739
|
*/
|
|
503
740
|
withItemTypeGuard<TI>(guard: (from: unknown, context?: TC) => from is TI, message?: string): Converter<TI[], TC>;
|
|
504
741
|
/**
|
|
505
|
-
* {@
|
|
742
|
+
* Creates a {@link Converter} which applies an optional constraint to the result
|
|
743
|
+
* of this conversion. If this {@link Converter} (the base converter) succeeds, the new
|
|
744
|
+
* converter calls a supplied constraint evaluation function with the conversion, which
|
|
745
|
+
* fails the entire conversion if the constraint function returns either `false` or
|
|
746
|
+
* {@link Failure | Failure<T>}.
|
|
747
|
+
*
|
|
748
|
+
* @param constraint - Constraint evaluation function.
|
|
749
|
+
* @param options - {@link Conversion.ConstraintOptions | Options} for constraint evaluation.
|
|
750
|
+
* @returns A new {@link Converter} returning `<T>`.
|
|
506
751
|
*/
|
|
507
752
|
withConstraint(constraint: (val: T, context?: TC) => boolean | Result<T>, options?: ConstraintOptions): Converter<T, TC>;
|
|
508
753
|
/**
|
|
509
|
-
*
|
|
754
|
+
* Returns a converter which adds a brand to the type to prevent mismatched usage
|
|
755
|
+
* of simple types.
|
|
756
|
+
* @param brand - The brand to be applied to the result value.
|
|
757
|
+
* @returns A {@link Converter} returning `Brand<T, B>`.
|
|
510
758
|
*/
|
|
511
759
|
withBrand<B extends string>(brand: B): Converter<Brand<T, B>, TC>;
|
|
512
760
|
/**
|
|
513
|
-
*
|
|
761
|
+
* Returns a Converter which always succeeds with a default value rather than failing.
|
|
762
|
+
* @param defaultValue - The default value to use if conversion fails.
|
|
514
763
|
*/
|
|
515
764
|
withDefault<TD = T>(defaultValue: TD): DefaultingConverter<T, TD, TC>;
|
|
516
765
|
or(other: Converter<T, TC>): Converter<T, TC>;
|
|
@@ -519,7 +768,10 @@ declare class BaseConverter<T, TC = unknown> implements Converter<T, TC> {
|
|
|
519
768
|
*/
|
|
520
769
|
protected _context(supplied?: TC): TC | undefined;
|
|
521
770
|
/**
|
|
522
|
-
* {@
|
|
771
|
+
* Creates a new {@link Converter} which is derived from this one but which returns an
|
|
772
|
+
* error message formatted by the supplied formatter if the conversion fails.
|
|
773
|
+
* @param formatter - The formatter to be applied.
|
|
774
|
+
* @returns A new {@link Converter} returning `<T>`.
|
|
523
775
|
*/
|
|
524
776
|
withFormattedError(formatter: ConversionErrorFormatter<TC>): Converter<T, TC>;
|
|
525
777
|
/**
|
|
@@ -778,13 +1030,36 @@ declare class CacheInvalidatingResultMapWrapper<TK extends string, TSRC, TTARGET
|
|
|
778
1030
|
toReadOnly(): IReadOnlyResultMap<TK, TSRC>;
|
|
779
1031
|
}
|
|
780
1032
|
|
|
1033
|
+
/**
|
|
1034
|
+
* Wraps an async function which might throw to convert exception results
|
|
1035
|
+
* to {@link Failure}.
|
|
1036
|
+
* @remarks
|
|
1037
|
+
* Returns an {@link AsyncResult} so callers can fluently chain
|
|
1038
|
+
* (`.onSuccess` / `.thenOnSuccess` / `.withErrorFormat`) directly off the
|
|
1039
|
+
* captured result. Because {@link AsyncResult} implements
|
|
1040
|
+
* `PromiseLike<Result<T>>`, existing `await captureAsyncResult(...)` call
|
|
1041
|
+
* sites continue to work unchanged and yield the same {@link Result}.
|
|
1042
|
+
*
|
|
1043
|
+
* Synchronous throws from `func` (before it returns its `Promise`), promise
|
|
1044
|
+
* rejections, and successful resolutions are all funneled through the
|
|
1045
|
+
* returned {@link AsyncResult}, which resolves to a {@link Failure} for the
|
|
1046
|
+
* throw/reject cases and a {@link Success} wrapping the resolved value
|
|
1047
|
+
* otherwise.
|
|
1048
|
+
* @param func - The async function to be captured.
|
|
1049
|
+
* @returns An {@link AsyncResult} resolving to {@link Success} with a value
|
|
1050
|
+
* of type `<T>` on success, or {@link Failure} with the thrown error message
|
|
1051
|
+
* if `func` throws or rejects.
|
|
1052
|
+
* @public
|
|
1053
|
+
*/
|
|
1054
|
+
export declare function captureAsyncResult<T>(func: () => Promise<T>): AsyncResult<T>;
|
|
1055
|
+
|
|
781
1056
|
/**
|
|
782
1057
|
* Wraps a function which might throw to convert exception results
|
|
783
1058
|
* to {@link Failure}.
|
|
784
1059
|
* @param func - The function to be captured.
|
|
785
1060
|
* @returns Returns {@link Success} with a value of type `<T>` on
|
|
786
1061
|
* success , or {@link Failure} with the thrown error message if
|
|
787
|
-
* `func` throws an `Error
|
|
1062
|
+
* `func` throws an `Error` or string.
|
|
788
1063
|
* @public
|
|
789
1064
|
*/
|
|
790
1065
|
export declare function captureResult<T>(func: () => T): Result<T>;
|
|
@@ -938,8 +1213,14 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
938
1213
|
IReadOnlyResultMap,
|
|
939
1214
|
ConvertingResultMapValueConverter,
|
|
940
1215
|
ConversionErrorHandling,
|
|
1216
|
+
allConversionErrorHandling,
|
|
1217
|
+
conversionErrorHandling,
|
|
941
1218
|
IReadOnlyConvertingResultMapConstructorParams,
|
|
942
1219
|
ReadOnlyConvertingResultMap,
|
|
1220
|
+
IRetainedRecord,
|
|
1221
|
+
IRetainingRingBufferQuery,
|
|
1222
|
+
IRetainingRingBufferCreateParams,
|
|
1223
|
+
RetainingRingBuffer,
|
|
943
1224
|
IResultMapConstructorParams,
|
|
944
1225
|
ResultMapValueFactory,
|
|
945
1226
|
IResultMap,
|
|
@@ -987,7 +1268,7 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
987
1268
|
private readonly _byKey;
|
|
988
1269
|
private readonly _byIndex;
|
|
989
1270
|
/**
|
|
990
|
-
*
|
|
1271
|
+
* Returns the number of entries in the map.
|
|
991
1272
|
*/
|
|
992
1273
|
get size(): number;
|
|
993
1274
|
/**
|
|
@@ -1014,19 +1295,28 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
1014
1295
|
*/
|
|
1015
1296
|
add(item: TITEM): DetailedResult<TITEM, CollectorResultDetail>;
|
|
1016
1297
|
/**
|
|
1017
|
-
*
|
|
1298
|
+
* Returns an iterator over the map entries.
|
|
1299
|
+
* @returns An iterator over the map entries.
|
|
1018
1300
|
*/
|
|
1019
1301
|
entries(): IterableIterator<KeyValueEntry<CollectibleKey<TITEM>, TITEM>>;
|
|
1020
1302
|
/**
|
|
1021
|
-
*
|
|
1303
|
+
* Calls a function for each entry in the map.
|
|
1304
|
+
* @param callback - The function to call for each entry.
|
|
1305
|
+
* @param arg - An optional argument to pass to the callback.
|
|
1022
1306
|
*/
|
|
1023
1307
|
forEach(callback: ResultMapForEachCb<CollectibleKey<TITEM>, TITEM>, arg?: unknown): void;
|
|
1024
1308
|
/**
|
|
1025
|
-
*
|
|
1309
|
+
* Gets a value by key.
|
|
1310
|
+
* @param key - The key to look up.
|
|
1311
|
+
* @returns Returns {@link DetailedSuccess | Success} with the value and detail `exists` if found,
|
|
1312
|
+
* or {@link DetailedFailure | Failure} with detail `not-found` if the key does not exist.
|
|
1026
1313
|
*/
|
|
1027
1314
|
get(key: CollectibleKey<TITEM>): DetailedResult<TITEM, ResultMapResultDetail>;
|
|
1028
1315
|
/**
|
|
1029
|
-
*
|
|
1316
|
+
* Gets the item at a specified index.
|
|
1317
|
+
* @param index - The index of the item to retrieve.
|
|
1318
|
+
* @returns Returns {@link Success | Success} with the item if it exists, or {@link Failure | Failure}
|
|
1319
|
+
* with an error if the index is out of range.
|
|
1030
1320
|
*/
|
|
1031
1321
|
getAt(index: number): Result<TITEM>;
|
|
1032
1322
|
/**
|
|
@@ -1051,19 +1341,24 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
1051
1341
|
*/
|
|
1052
1342
|
getOrAdd(key: CollectibleKey<TITEM>, factory: CollectibleFactoryCallback<TITEM>): DetailedResult<TITEM, CollectorResultDetail>;
|
|
1053
1343
|
/**
|
|
1054
|
-
*
|
|
1344
|
+
* Returns true if the map contains an entry with the given key.
|
|
1345
|
+
* @param key - The key to check for.
|
|
1346
|
+
* @returns `true` if the key exists, `false` otherwise.
|
|
1055
1347
|
*/
|
|
1056
1348
|
has(key: CollectibleKey<TITEM>): boolean;
|
|
1057
1349
|
/**
|
|
1058
|
-
*
|
|
1350
|
+
* Returns an iterator over the map keys.
|
|
1351
|
+
* @returns An iterator over the map keys.
|
|
1059
1352
|
*/
|
|
1060
1353
|
keys(): IterableIterator<CollectibleKey<TITEM>>;
|
|
1061
1354
|
/**
|
|
1062
|
-
*
|
|
1355
|
+
* Returns an iterator over the map values.
|
|
1356
|
+
* @returns An iterator over the map values.
|
|
1063
1357
|
*/
|
|
1064
1358
|
values(): IterableIterator<TITEM>;
|
|
1065
1359
|
/**
|
|
1066
|
-
*
|
|
1360
|
+
* Gets all items in the collection, ordered by index.
|
|
1361
|
+
* @returns An array of items in the collection, ordered by index.
|
|
1067
1362
|
*/
|
|
1068
1363
|
valuesByIndex(): ReadonlyArray<TITEM>;
|
|
1069
1364
|
/**
|
|
@@ -1099,7 +1394,12 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
1099
1394
|
*/
|
|
1100
1395
|
constructor(params: ICollectorValidatorCreateParams<TITEM>);
|
|
1101
1396
|
/**
|
|
1102
|
-
*
|
|
1397
|
+
* Adds an item to the collection, failing if a different item with the same key already exists. Note
|
|
1398
|
+
* that adding an object that is already in the collection again will succeed without updating the collection.
|
|
1399
|
+
* @param item - The item to add.
|
|
1400
|
+
* @returns Returns {@link DetailedSuccess | Success} with the item and detail `added` if it was added
|
|
1401
|
+
* or detail `exists` if the item was already in the map. Returns {@link DetailedFailure | Failure} with
|
|
1402
|
+
* an error message and appropriate detail if the item could not be added.
|
|
1103
1403
|
*/
|
|
1104
1404
|
add(item: unknown): DetailedResult<TITEM, CollectorResultDetail>;
|
|
1105
1405
|
/**
|
|
@@ -1107,12 +1407,24 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
1107
1407
|
*/
|
|
1108
1408
|
get(key: string): DetailedResult<TITEM, ResultMapResultDetail>;
|
|
1109
1409
|
/**
|
|
1110
|
-
*
|
|
1410
|
+
* Gets an existing item with a key matching the supplied key, or adds a new item to the collector
|
|
1411
|
+
* using a factory callback if no item with that key exists.
|
|
1412
|
+
* @param key - The weakly-typed key of the item to get or add.
|
|
1413
|
+
* @param factory - The factory callback to create the item.
|
|
1414
|
+
* @returns Returns {@link DetailedSuccess | Success} with the item stored in the collector -
|
|
1415
|
+
* detail `exists` indicates that an existing item was returned and detail `added` indicates
|
|
1416
|
+
* that the item was added. Returns {@link DetailedFailure | Failure} with an error and
|
|
1417
|
+
* appropriate detail if the item could not be added.
|
|
1111
1418
|
*/
|
|
1112
1419
|
getOrAdd(key: string, factory: ResultMapValueFactory<CollectibleKey<TITEM>, TITEM>): DetailedResult<TITEM, CollectorResultDetail>;
|
|
1113
1420
|
/**
|
|
1114
|
-
*
|
|
1115
|
-
*
|
|
1421
|
+
* Gets an existing item with a key matching that of the supplied item, or adds the supplied
|
|
1422
|
+
* item to the collector if no item with that key exists.
|
|
1423
|
+
* @param item - The weakly-typed item to get or add.
|
|
1424
|
+
* @returns Returns {@link DetailedSuccess | Success} with the item stored in the collector -
|
|
1425
|
+
* detail `exists` indicates that an existing item was returned and detail `added` indicates
|
|
1426
|
+
* that the item was added. Returns {@link DetailedFailure | Failure} with an error and
|
|
1427
|
+
* appropriate detail if the item could not be added.
|
|
1116
1428
|
*/
|
|
1117
1429
|
getOrAdd(item: unknown): DetailedResult<TITEM, CollectorResultDetail>;
|
|
1118
1430
|
/**
|
|
@@ -1268,6 +1580,7 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
1268
1580
|
ConverterFunc,
|
|
1269
1581
|
BaseConverter,
|
|
1270
1582
|
OnError,
|
|
1583
|
+
allOnError,
|
|
1271
1584
|
ConverterTraits,
|
|
1272
1585
|
ConversionErrorFormatter,
|
|
1273
1586
|
ConstraintOptions,
|
|
@@ -1302,6 +1615,13 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
1302
1615
|
*/
|
|
1303
1616
|
declare type ConversionErrorHandling = 'ignore' | 'warn' | 'fail';
|
|
1304
1617
|
|
|
1618
|
+
/**
|
|
1619
|
+
* A ready-made {@link Converter | Converter} for
|
|
1620
|
+
* {@link Collections.ConversionErrorHandling | ConversionErrorHandling} values.
|
|
1621
|
+
* @public
|
|
1622
|
+
*/
|
|
1623
|
+
declare const conversionErrorHandling: Converter<ConversionErrorHandling, ReadonlyArray<ConversionErrorHandling>>;
|
|
1624
|
+
|
|
1305
1625
|
/**
|
|
1306
1626
|
* Deprecated name for {@link Conversion.Infer | Infer
|
|
1307
1627
|
* } retained for compatibility.
|
|
@@ -1332,10 +1652,13 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
1332
1652
|
* @param from - The `unknown` to be converted
|
|
1333
1653
|
* @param context - An optional conversion context of type `<TC>` to be used in
|
|
1334
1654
|
* the conversion.
|
|
1655
|
+
* @param selfOverride - An optional override for the `self` reference passed to the
|
|
1656
|
+
* converter function, enabling outer converters (e.g. discriminated-object) to thread
|
|
1657
|
+
* themselves through to per-arm converters for recursive parsing.
|
|
1335
1658
|
* @returns A {@link Result} with a {@link Success} and a value on success or an
|
|
1336
1659
|
* {@link Failure} with a a message on failure.
|
|
1337
1660
|
*/
|
|
1338
|
-
convert(from: unknown, context?: TC): Result<T>;
|
|
1661
|
+
convert(from: unknown, context?: TC, selfOverride?: Converter<T, TC>): Result<T>;
|
|
1339
1662
|
/**
|
|
1340
1663
|
* Converts from `unknown` to `<T>` or `undefined`, as appropriate.
|
|
1341
1664
|
*
|
|
@@ -1521,6 +1844,8 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
1521
1844
|
discriminatedObject,
|
|
1522
1845
|
OnError,
|
|
1523
1846
|
string,
|
|
1847
|
+
messageLogLevel,
|
|
1848
|
+
onError,
|
|
1524
1849
|
value,
|
|
1525
1850
|
number,
|
|
1526
1851
|
boolean,
|
|
@@ -1577,7 +1902,12 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
1577
1902
|
*/
|
|
1578
1903
|
static createConvertingCollector<TITEM extends ICollectible<any, any>, TSRC = TITEM>(params: IConvertingCollectorConstructorParams<TITEM, TSRC>): Result<ConvertingCollector<TITEM, TSRC>>;
|
|
1579
1904
|
/**
|
|
1580
|
-
*
|
|
1905
|
+
* Adds an item to the collection, failing if a different item with the same key already exists. Note
|
|
1906
|
+
* that adding an object that is already in the collection again will succeed without updating the collection.
|
|
1907
|
+
* @param item - The item to add.
|
|
1908
|
+
* @returns Returns {@link DetailedSuccess | Success} with the item and detail `added` if it was added
|
|
1909
|
+
* or detail `exists` if the item was already in the map. Returns {@link DetailedFailure | Failure} with
|
|
1910
|
+
* an error message and appropriate detail if the item could not be added.
|
|
1581
1911
|
*/
|
|
1582
1912
|
add(item: TITEM): DetailedResult<TITEM, CollectorResultDetail>;
|
|
1583
1913
|
/**
|
|
@@ -1600,11 +1930,24 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
1600
1930
|
*/
|
|
1601
1931
|
add(key: CollectibleKey<TITEM>, cb: CollectibleFactoryCallback<TITEM>): DetailedResult<TITEM, CollectorResultDetail>;
|
|
1602
1932
|
/**
|
|
1603
|
-
*
|
|
1933
|
+
* Gets an existing item with a key matching that of the supplied item, or adds the supplied
|
|
1934
|
+
* item to the collector if no item with that key exists.
|
|
1935
|
+
* @param item - The item to get or add.
|
|
1936
|
+
* @returns Returns {@link DetailedSuccess | Success} with the item stored in the collector -
|
|
1937
|
+
* detail `exists` indicates that an existing item was returned and detail `added` indicates
|
|
1938
|
+
* that the item was added. Returns {@link DetailedFailure | Failure} with an error and
|
|
1939
|
+
* appropriate detail if the item could not be added.
|
|
1604
1940
|
*/
|
|
1605
1941
|
getOrAdd(item: TITEM): DetailedResult<TITEM, CollectorResultDetail>;
|
|
1606
1942
|
/**
|
|
1607
|
-
*
|
|
1943
|
+
* Gets an existing item with a key matching the supplied key, or adds a new item to the collector
|
|
1944
|
+
* using a factory callback if no item with that key exists.
|
|
1945
|
+
* @param key - The key of the item to get or add.
|
|
1946
|
+
* @param callback - The factory callback to create the item.
|
|
1947
|
+
* @returns Returns {@link DetailedSuccess | Success} with the item stored in the collector -
|
|
1948
|
+
* detail `exists` indicates that an existing item was returned and detail `added` indicates
|
|
1949
|
+
* that the item was added. Returns {@link DetailedFailure | Failure} with an error and
|
|
1950
|
+
* appropriate detail if the item could not be added.
|
|
1608
1951
|
*/
|
|
1609
1952
|
getOrAdd(key: CollectibleKey<TITEM>, callback: CollectibleFactoryCallback<TITEM>): DetailedResult<TITEM, CollectorResultDetail>;
|
|
1610
1953
|
/**
|
|
@@ -1662,7 +2005,12 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
1662
2005
|
*/
|
|
1663
2006
|
constructor(params: IConvertingCollectorValidatorCreateParams<TITEM, TSRC>);
|
|
1664
2007
|
/**
|
|
1665
|
-
*
|
|
2008
|
+
* Adds an item to the collector using the default factory at a specified key,
|
|
2009
|
+
* failing if an item with that key already exists.
|
|
2010
|
+
* @param key - The weakly-typed key of the item to add.
|
|
2011
|
+
* @param value - The source representation of the item to be added.
|
|
2012
|
+
* @returns Returns {@link Success | Success} with the item if it is added, or {@link Failure | Failure} with
|
|
2013
|
+
* an error if the item cannot be created and indexed.
|
|
1666
2014
|
*/
|
|
1667
2015
|
add(key: string, value: unknown): DetailedResult<TITEM, CollectorResultDetail>;
|
|
1668
2016
|
/**
|
|
@@ -1675,11 +2023,25 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
1675
2023
|
*/
|
|
1676
2024
|
get(key: string): DetailedResult<TITEM, ResultMapResultDetail>;
|
|
1677
2025
|
/**
|
|
1678
|
-
*
|
|
2026
|
+
* Gets an existing item with a key matching the supplied key, or adds a new item to the collector
|
|
2027
|
+
* by converting the supplied weakly-typed value if no item with that key exists.
|
|
2028
|
+
* @param key - The weakly-typed key of the item to get or add.
|
|
2029
|
+
* @param value - The weakly-typed source value to convert and add if the key does not exist.
|
|
2030
|
+
* @returns Returns {@link DetailedSuccess | Success} with the item stored in the collector -
|
|
2031
|
+
* detail `exists` indicates that an existing item was returned and detail `added` indicates
|
|
2032
|
+
* that the item was added. Returns {@link DetailedFailure | Failure} with an error and
|
|
2033
|
+
* appropriate detail if the item could not be added.
|
|
1679
2034
|
*/
|
|
1680
2035
|
getOrAdd(key: string, value: unknown): DetailedResult<TITEM, CollectorResultDetail>;
|
|
1681
2036
|
/**
|
|
1682
|
-
*
|
|
2037
|
+
* Gets an existing item with a key matching the supplied key, or adds a new item to the collector
|
|
2038
|
+
* using a factory callback if no item with that key exists.
|
|
2039
|
+
* @param key - The weakly-typed key of the item to get or add.
|
|
2040
|
+
* @param factory - The factory callback to create the item.
|
|
2041
|
+
* @returns Returns {@link DetailedSuccess | Success} with the item stored in the collector -
|
|
2042
|
+
* detail `exists` indicates that an existing item was returned and detail `added` indicates
|
|
2043
|
+
* that the item was added. Returns {@link DetailedFailure | Failure} with an error and
|
|
2044
|
+
* appropriate detail if the item could not be added.
|
|
1683
2045
|
*/
|
|
1684
2046
|
getOrAdd(key: string, factory: ResultMapValueFactory<CollectibleKey<TITEM>, TITEM>): DetailedResult<TITEM, CollectorResultDetail>;
|
|
1685
2047
|
/**
|
|
@@ -1987,6 +2349,9 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
1987
2349
|
*
|
|
1988
2350
|
* If the source is not an object, the discriminator property is missing, or the discriminator has
|
|
1989
2351
|
* a value not present in the converters, conversion fails and returns {@link Failure | Failure} with more information.
|
|
2352
|
+
*
|
|
2353
|
+
* The `self` reference of the outer converter is threaded through to per-arm converter invocations,
|
|
2354
|
+
* enabling recursive discriminated-union parsers where arms recurse via `self`.
|
|
1990
2355
|
* @param discriminatorProp - Name of the property used to discriminate types.
|
|
1991
2356
|
* @param converters - {@link Converters.DiscriminatedObjectConverters | String-keyed record of converters and validators}
|
|
1992
2357
|
* to invoke, where each key corresponds to a value of the discriminator property.
|
|
@@ -2070,6 +2435,14 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
2070
2435
|
*/
|
|
2071
2436
|
export declare type ErrorFormatter<TD = unknown> = (message: string, detail?: TD) => string;
|
|
2072
2437
|
|
|
2438
|
+
/**
|
|
2439
|
+
* Extracts a message string from an unknown thrown/rejected value.
|
|
2440
|
+
* @param err - The caught error value.
|
|
2441
|
+
* @returns The error message string.
|
|
2442
|
+
* @internal
|
|
2443
|
+
*/
|
|
2444
|
+
export declare function _errorMessage(err: unknown): string;
|
|
2445
|
+
|
|
2073
2446
|
/**
|
|
2074
2447
|
* Returns {@link Failure | Failure<T>} with the supplied error message.
|
|
2075
2448
|
* @param message - Error message to be returned.
|
|
@@ -2135,6 +2508,10 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
2135
2508
|
* {@inheritDoc IResult.orThrow}
|
|
2136
2509
|
*/
|
|
2137
2510
|
orThrow(cb: ErrorFormatter): never;
|
|
2511
|
+
/**
|
|
2512
|
+
* {@inheritDoc IResult.shouldNotFail}
|
|
2513
|
+
*/
|
|
2514
|
+
shouldNotFail(label?: string, frameDepth?: number): never;
|
|
2138
2515
|
/**
|
|
2139
2516
|
* {@inheritDoc IResult.orDefault}
|
|
2140
2517
|
*/
|
|
@@ -2161,6 +2538,14 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
2161
2538
|
* {@inheritDoc IResult.onFailure}
|
|
2162
2539
|
*/
|
|
2163
2540
|
onFailure(cb: FailureContinuation<T>): Result<T>;
|
|
2541
|
+
/**
|
|
2542
|
+
* {@inheritDoc IResult.thenOnSuccess}
|
|
2543
|
+
*/
|
|
2544
|
+
thenOnSuccess<TN>(__: AsyncSuccessContinuation<T, TN>): AsyncResult<TN>;
|
|
2545
|
+
/**
|
|
2546
|
+
* {@inheritDoc IResult.thenOnFailure}
|
|
2547
|
+
*/
|
|
2548
|
+
thenOnFailure(cb: AsyncFailureContinuation<T>): AsyncResult<T>;
|
|
2164
2549
|
/**
|
|
2165
2550
|
* {@inheritDoc IResult.withErrorFormat}
|
|
2166
2551
|
*/
|
|
@@ -2181,6 +2566,41 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
2181
2566
|
* {@inheritDoc IResult.report}
|
|
2182
2567
|
*/
|
|
2183
2568
|
report(reporter?: IResultReporter<T>, options?: IResultReportOptions<unknown>): Failure<T>;
|
|
2569
|
+
/**
|
|
2570
|
+
* Re-types this {@link Failure | Failure<T>} as {@link Failure | Failure<U>} for
|
|
2571
|
+
* propagation under a different success type.
|
|
2572
|
+
* @remarks
|
|
2573
|
+
* Supports the canonical Result early-return-after-`isFailure()` pattern when the
|
|
2574
|
+
* outer function's success type differs from the inner Result's success type:
|
|
2575
|
+
*
|
|
2576
|
+
* ```ts
|
|
2577
|
+
* const storeResult = await PromptStoreFixture.build(seed);
|
|
2578
|
+
* if (storeResult.isFailure()) {
|
|
2579
|
+
* return storeResult.withType<PromptLibrary>();
|
|
2580
|
+
* }
|
|
2581
|
+
* return PromptLibrary.create({ store: storeResult.value, ... });
|
|
2582
|
+
* ```
|
|
2583
|
+
*
|
|
2584
|
+
* Without this helper, TypeScript rejects `return storeResult` because
|
|
2585
|
+
* `Failure<IPromptStore>` is invariant in `T` and not assignable to
|
|
2586
|
+
* `Result<PromptLibrary>`. The workaround `return fail<U>(r.message)` is
|
|
2587
|
+
* semantically equivalent but allocates a new {@link Failure} instance;
|
|
2588
|
+
* `withType` returns `this` and only retypes statically.
|
|
2589
|
+
*
|
|
2590
|
+
* This method is sound because a {@link Failure} variant carries no `T`-shaped
|
|
2591
|
+
* data — only an error message — so re-typing it as `Failure<U>` cannot
|
|
2592
|
+
* misrepresent any value. The same operation is NOT exposed on {@link Success}
|
|
2593
|
+
* because `Success<T>` carries `T`-shaped data and re-typing would be a lie.
|
|
2594
|
+
*
|
|
2595
|
+
* For `DetailedResult` propagation that preserves a typed `detail`, consider
|
|
2596
|
+
* propagating the {@link DetailedFailure} directly through `onSuccess` (which
|
|
2597
|
+
* already re-types the success arm) rather than reaching for `withType`.
|
|
2598
|
+
*
|
|
2599
|
+
* @returns This same {@link Failure} instance, statically retyped as
|
|
2600
|
+
* {@link Failure | Failure<U>}.
|
|
2601
|
+
* @public
|
|
2602
|
+
*/
|
|
2603
|
+
withType<U>(): Failure<U>;
|
|
2184
2604
|
/**
|
|
2185
2605
|
* Get a 'friendly' string representation of this object.
|
|
2186
2606
|
* @remarks
|
|
@@ -2280,6 +2700,20 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
2280
2700
|
[key in keyof T]: Validator<T[key], TC>;
|
|
2281
2701
|
};
|
|
2282
2702
|
|
|
2703
|
+
/**
|
|
2704
|
+
* Finds the caller frame at the supplied depth in a stack string.
|
|
2705
|
+
*
|
|
2706
|
+
* Filters out frames whose **parsed function name** contains `shouldNotFail`
|
|
2707
|
+
* (the file path is deliberately NOT inspected — consumer test files may
|
|
2708
|
+
* themselves be named after `shouldNotFail` and their frames must not be
|
|
2709
|
+
* filtered out). Covers both the V8 path — where `Error.captureStackTrace`
|
|
2710
|
+
* should have done this already but the extra filter is harmless — and the
|
|
2711
|
+
* WebKit fallback path where `captureStackTrace` is unavailable. `frameDepth`
|
|
2712
|
+
* is 1-indexed: `1` selects the immediate caller.
|
|
2713
|
+
* @internal
|
|
2714
|
+
*/
|
|
2715
|
+
export declare function _findShouldNotFailFrame(stack: string | undefined, frameDepth: number): _IShouldNotFailFrame;
|
|
2716
|
+
|
|
2283
2717
|
/**
|
|
2284
2718
|
* Returns the first successful result from a collection of {@link Result | Result<T>} or {@link DeferredResult | DeferredResult<T>}.
|
|
2285
2719
|
* @param results - The collection of {@link Result | Result<T>} or {@link DeferredResult | DeferredResult<T>} to be tested.
|
|
@@ -2288,6 +2722,13 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
2288
2722
|
*/
|
|
2289
2723
|
export declare function firstSuccess<T>(results: Iterable<Result<T> | DeferredResult<T>>): Result<T>;
|
|
2290
2724
|
|
|
2725
|
+
/**
|
|
2726
|
+
* Composes the error message thrown by `Result<T>.shouldNotFail` from the
|
|
2727
|
+
* captured frame and optional label.
|
|
2728
|
+
* @internal
|
|
2729
|
+
*/
|
|
2730
|
+
export declare function _formatShouldNotFailMessage(originalMessage: string, label: string | undefined, frame: _IShouldNotFailFrame): string;
|
|
2731
|
+
|
|
2291
2732
|
/**
|
|
2292
2733
|
* A {@link Validation.ConstraintTrait | ConstraintTrait} indicating that
|
|
2293
2734
|
* a {@link Validation.Constraint | Constraint<T>} function provides an
|
|
@@ -2298,6 +2739,18 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
2298
2739
|
type: 'function';
|
|
2299
2740
|
}
|
|
2300
2741
|
|
|
2742
|
+
/**
|
|
2743
|
+
* Generates a cryptographically random UUIDv4 using the platform's Web Crypto
|
|
2744
|
+
* API (`globalThis.crypto.randomUUID`). Works in Node.js \>= 18 and modern
|
|
2745
|
+
* browsers without per-call runtime checks.
|
|
2746
|
+
* @returns A new {@link Uuid}.
|
|
2747
|
+
* @throws An `Error` if the runtime does not expose `globalThis.crypto.randomUUID`.
|
|
2748
|
+
* This indicates an unsupported platform, not a per-call failure mode, so it is
|
|
2749
|
+
* surfaced as a thrown error rather than a `Result`.
|
|
2750
|
+
* @public
|
|
2751
|
+
*/
|
|
2752
|
+
export declare function generateUuid(): Uuid;
|
|
2753
|
+
|
|
2301
2754
|
/**
|
|
2302
2755
|
* Helper function to create a {@link Converter | Converter} from a supplied {@link Conversion.ConverterFunc | ConverterFunc}.
|
|
2303
2756
|
* @param convert - the function to be wrapped
|
|
@@ -2760,6 +3213,28 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
2760
3213
|
warnWithDetail(message: string, detail: unknown): Success<string | undefined>;
|
|
2761
3214
|
}
|
|
2762
3215
|
|
|
3216
|
+
/**
|
|
3217
|
+
* Options for {@link Logging.RetainingLogger.getRecords | RetainingLogger.getRecords}.
|
|
3218
|
+
* @public
|
|
3219
|
+
*/
|
|
3220
|
+
declare interface IGetRecordsOptions {
|
|
3221
|
+
/**
|
|
3222
|
+
* If supplied, only records whose level would be emitted at this threshold
|
|
3223
|
+
* (per {@link Logging.shouldLog | shouldLog}) are returned.
|
|
3224
|
+
*/
|
|
3225
|
+
readonly minLevel?: ReporterLogLevel;
|
|
3226
|
+
/**
|
|
3227
|
+
* If supplied, only records with `seq > sinceSeq` are returned, enabling
|
|
3228
|
+
* incremental paging from a previously-held cursor.
|
|
3229
|
+
*/
|
|
3230
|
+
readonly sinceSeq?: number;
|
|
3231
|
+
/**
|
|
3232
|
+
* If supplied, returns at most this many records — the most recent N (tail),
|
|
3233
|
+
* still ordered oldest-first.
|
|
3234
|
+
*/
|
|
3235
|
+
readonly limit?: number;
|
|
3236
|
+
}
|
|
3237
|
+
|
|
2763
3238
|
/**
|
|
2764
3239
|
* Parameters for constructing a {@link Collections.KeyValueConverters | KeyValueConverters} instance.
|
|
2765
3240
|
* @public
|
|
@@ -2829,6 +3304,34 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
2829
3304
|
error(message?: unknown, ...parameters: unknown[]): Success<string | undefined>;
|
|
2830
3305
|
}
|
|
2831
3306
|
|
|
3307
|
+
/**
|
|
3308
|
+
* A retained log record. Preserves the level and an ordering cursor so consumers
|
|
3309
|
+
* can filter by severity and page incrementally.
|
|
3310
|
+
* @public
|
|
3311
|
+
*/
|
|
3312
|
+
declare interface ILogRecord {
|
|
3313
|
+
/**
|
|
3314
|
+
* Monotonic 1-based sequence number, stable across ring eviction.
|
|
3315
|
+
*/
|
|
3316
|
+
readonly seq: number;
|
|
3317
|
+
/**
|
|
3318
|
+
* Milliseconds since epoch when the record was logged (from the injected clock).
|
|
3319
|
+
*/
|
|
3320
|
+
readonly timestamp: number;
|
|
3321
|
+
/**
|
|
3322
|
+
* The level the record was logged at.
|
|
3323
|
+
*/
|
|
3324
|
+
readonly level: MessageLogLevel;
|
|
3325
|
+
/**
|
|
3326
|
+
* The formatted message (same formatting {@link Logging.LoggerBase._format | LoggerBase._format} produces).
|
|
3327
|
+
*/
|
|
3328
|
+
readonly message: string;
|
|
3329
|
+
/**
|
|
3330
|
+
* The raw structured inputs `[message, ...parameters]` before formatting.
|
|
3331
|
+
*/
|
|
3332
|
+
readonly args?: readonly unknown[];
|
|
3333
|
+
}
|
|
3334
|
+
|
|
2832
3335
|
/**
|
|
2833
3336
|
* Parameters for creating a {@link Logging.LogReporter | LogReporter}.
|
|
2834
3337
|
* @public
|
|
@@ -3016,7 +3519,14 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
3016
3519
|
*/
|
|
3017
3520
|
has(key: string): boolean;
|
|
3018
3521
|
/**
|
|
3019
|
-
*
|
|
3522
|
+
* Gets an existing item with a key matching the supplied key, or adds a new item to the collector
|
|
3523
|
+
* using a factory callback if no item with that key exists.
|
|
3524
|
+
* @param key - The weakly-typed key of the item to get or add.
|
|
3525
|
+
* @param factory - The factory callback to create the item.
|
|
3526
|
+
* @returns Returns {@link DetailedSuccess | Success} with the item stored in the collector -
|
|
3527
|
+
* detail `exists` indicates that an existing item was returned and detail `added` indicates
|
|
3528
|
+
* that the item was added. Returns {@link DetailedFailure | Failure} with an error and
|
|
3529
|
+
* appropriate detail if the item could not be added.
|
|
3020
3530
|
*/
|
|
3021
3531
|
getOrAdd(key: string, factory: ResultMapValueFactory<CollectibleKey<TITEM>, TITEM>): DetailedResult<TITEM, CollectorResultDetail>;
|
|
3022
3532
|
}
|
|
@@ -3053,31 +3563,42 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
3053
3563
|
*/
|
|
3054
3564
|
export declare interface IReadOnlyResultMap<TK extends string = string, TV = unknown> {
|
|
3055
3565
|
/**
|
|
3056
|
-
*
|
|
3566
|
+
* Returns the number of entries in the map.
|
|
3057
3567
|
*/
|
|
3058
3568
|
readonly size: number;
|
|
3059
3569
|
/**
|
|
3060
|
-
*
|
|
3570
|
+
* Returns an iterator over the map entries.
|
|
3571
|
+
* @returns An iterator over the map entries.
|
|
3061
3572
|
*/
|
|
3062
3573
|
entries(): IterableIterator<KeyValueEntry<TK, TV>>;
|
|
3063
3574
|
/**
|
|
3064
|
-
*
|
|
3575
|
+
* Calls a function for each entry in the map.
|
|
3576
|
+
* @param cb - The function to call for each entry.
|
|
3577
|
+
* @param arg - An optional argument to pass to the callback.
|
|
3065
3578
|
*/
|
|
3066
3579
|
forEach(cb: ResultMapForEachCb, arg?: unknown): void;
|
|
3067
3580
|
/**
|
|
3068
|
-
*
|
|
3581
|
+
* Gets a value from the map.
|
|
3582
|
+
* @param key - The key to retrieve.
|
|
3583
|
+
* @returns `Success` with the value and detail `exists` if the key was found,
|
|
3584
|
+
* `Failure` with detail `not-found` if the key was not found or with detail
|
|
3585
|
+
* `invalid-key` if the key is invalid.
|
|
3069
3586
|
*/
|
|
3070
3587
|
get(key: TK): DetailedResult<TV, ResultMapResultDetail>;
|
|
3071
3588
|
/**
|
|
3072
|
-
*
|
|
3589
|
+
* Returns `true` if the map contains a key.
|
|
3590
|
+
* @param key - The key to check.
|
|
3591
|
+
* @returns `true` if the key exists, `false` otherwise.
|
|
3073
3592
|
*/
|
|
3074
3593
|
has(key: TK): boolean;
|
|
3075
3594
|
/**
|
|
3076
|
-
*
|
|
3595
|
+
* Returns an iterator over the map keys.
|
|
3596
|
+
* @returns An iterator over the map keys.
|
|
3077
3597
|
*/
|
|
3078
3598
|
keys(): IterableIterator<TK>;
|
|
3079
3599
|
/**
|
|
3080
|
-
*
|
|
3600
|
+
* Returns an iterator over the map values.
|
|
3601
|
+
* @returns An iterator over the map values.
|
|
3081
3602
|
*/
|
|
3082
3603
|
values(): IterableIterator<TV>;
|
|
3083
3604
|
/**
|
|
@@ -3113,15 +3634,19 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
3113
3634
|
*/
|
|
3114
3635
|
declare interface IReadOnlyValidatingCollector<TITEM extends ICollectible<any, any>> extends IReadOnlyValidatingResultMap<CollectibleKey<TITEM>, TITEM> {
|
|
3115
3636
|
/**
|
|
3116
|
-
* {@
|
|
3637
|
+
* A {@link Collections.CollectorValidator | CollectorValidator} which validates keys and values
|
|
3638
|
+
* before inserting them into this collector.
|
|
3117
3639
|
*/
|
|
3118
3640
|
readonly validating: IReadOnlyCollectorValidator<TITEM>;
|
|
3119
3641
|
/**
|
|
3120
|
-
*
|
|
3642
|
+
* Gets the item at a specified index.
|
|
3643
|
+
* @param index - The index of the item to retrieve.
|
|
3644
|
+
* @returns `Success` with the item if it exists, or `Failure` with an error if the index is out of range.
|
|
3121
3645
|
*/
|
|
3122
3646
|
getAt(index: number): Result<TITEM>;
|
|
3123
3647
|
/**
|
|
3124
|
-
*
|
|
3648
|
+
* Gets all items in the collection, ordered by index.
|
|
3649
|
+
* @returns An array of items in the collection, ordered by index.
|
|
3125
3650
|
*/
|
|
3126
3651
|
valuesByIndex(): ReadonlyArray<TITEM>;
|
|
3127
3652
|
}
|
|
@@ -3132,7 +3657,8 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
3132
3657
|
*/
|
|
3133
3658
|
declare interface IReadOnlyValidatingResultMap<TK extends string = string, TV = unknown> extends IReadOnlyResultMap<TK, TV> {
|
|
3134
3659
|
/**
|
|
3135
|
-
* {@
|
|
3660
|
+
* A {@link Collections.ResultMapValidator | ResultMapValidator} which validates keys and values
|
|
3661
|
+
* before inserting them into this collection.
|
|
3136
3662
|
*/
|
|
3137
3663
|
readonly validating: IReadOnlyResultMapValidator<TK, TV>;
|
|
3138
3664
|
}
|
|
@@ -3234,6 +3760,47 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
3234
3760
|
* {@label formatter}
|
|
3235
3761
|
*/
|
|
3236
3762
|
orThrow(cb: ErrorFormatter): T;
|
|
3763
|
+
/**
|
|
3764
|
+
* Asserts at the call site that this {@link IResult | result} MUST be a success.
|
|
3765
|
+
* Returns the value on success; on failure, throws an `Error` whose message
|
|
3766
|
+
* is composed from the original failure message and the captured call-site
|
|
3767
|
+
* location (file, line, and where useful function name).
|
|
3768
|
+
*
|
|
3769
|
+
* @remarks
|
|
3770
|
+
* Use for declaration-time / setup-time invariants — module-level `const`
|
|
3771
|
+
* initializers, static class properties, static initialization blocks, and
|
|
3772
|
+
* test fixtures — where a failure indicates a coding bug that should
|
|
3773
|
+
* surface at the call site rather than propagate as a `Result`. For chains
|
|
3774
|
+
* where the throw is intentional control flow, prefer `orThrow`.
|
|
3775
|
+
*
|
|
3776
|
+
* On V8 (Node + Chromium) `Error.captureStackTrace` is used to elide
|
|
3777
|
+
* `shouldNotFail` itself from the captured stack so the parsed frame is
|
|
3778
|
+
* the user's call site directly. On WebKit (where `captureStackTrace` is
|
|
3779
|
+
* unavailable) the stack is parsed manually and frames whose **parsed
|
|
3780
|
+
* function name** contains `shouldNotFail` are filtered out — the raw
|
|
3781
|
+
* stack-line text (including the file path) is deliberately NOT inspected,
|
|
3782
|
+
* so consumer files named after `shouldNotFail` are not collateral damage.
|
|
3783
|
+
* Function names and exact line numbers depend on source-map availability
|
|
3784
|
+
* in the runtime. When no caller frame is recoverable (e.g. `frameDepth`
|
|
3785
|
+
* out of range, or `frameDepth: 0`) the message falls back to the
|
|
3786
|
+
* label-only form (or the bare original message when no label is given).
|
|
3787
|
+
*
|
|
3788
|
+
* Error message format (depending on whether a label and a usable function
|
|
3789
|
+
* name are available):
|
|
3790
|
+
* - both: `<label> (at <fn> in <file>:<line>): <original>`
|
|
3791
|
+
* - label only: `<label> (at <file>:<line>): <original>`
|
|
3792
|
+
* - fn only: `<fn> at <file>:<line>: <original>`
|
|
3793
|
+
* - neither: `<file>:<line>: <original>`
|
|
3794
|
+
*
|
|
3795
|
+
* @param label - Optional human-meaningful identifier (e.g. the constant
|
|
3796
|
+
* name) prefixed to the error message.
|
|
3797
|
+
* @param frameDepth - Optional 1-indexed depth into the caller stack.
|
|
3798
|
+
* Default `1` (immediate caller). Library authors wrapping `shouldNotFail`
|
|
3799
|
+
* inside their own helper pass `2` to attribute to their caller.
|
|
3800
|
+
* @returns The result value, if the operation was successful.
|
|
3801
|
+
* @throws `Error` if the result was a failure.
|
|
3802
|
+
*/
|
|
3803
|
+
shouldNotFail(label?: string, frameDepth?: number): T;
|
|
3237
3804
|
/**
|
|
3238
3805
|
* Gets the value associated with a successful {@link IResult | result},
|
|
3239
3806
|
* or a default value if the corresponding operation failed.
|
|
@@ -3276,6 +3843,30 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
3276
3843
|
* was successful, propagates the result value from the successful event.
|
|
3277
3844
|
*/
|
|
3278
3845
|
onFailure(cb: FailureContinuation<T>): Result<T>;
|
|
3846
|
+
/**
|
|
3847
|
+
* Calls a supplied {@link AsyncSuccessContinuation | async success continuation} if
|
|
3848
|
+
* the operation was a success, bridging into an {@link AsyncResult} chain.
|
|
3849
|
+
* @remarks
|
|
3850
|
+
* If the async callback rejects, the rejection is caught and converted
|
|
3851
|
+
* to a {@link Failure}.
|
|
3852
|
+
* @param cb - The {@link AsyncSuccessContinuation | async success continuation} to
|
|
3853
|
+
* be called in the event of success.
|
|
3854
|
+
* @returns An {@link AsyncResult} wrapping the async continuation result, or
|
|
3855
|
+
* propagating the error message from this failure.
|
|
3856
|
+
*/
|
|
3857
|
+
thenOnSuccess<TN>(cb: AsyncSuccessContinuation<T, TN>): AsyncResult<TN>;
|
|
3858
|
+
/**
|
|
3859
|
+
* Calls a supplied {@link AsyncFailureContinuation | async failure continuation} if
|
|
3860
|
+
* the operation failed, bridging into an {@link AsyncResult} chain.
|
|
3861
|
+
* @remarks
|
|
3862
|
+
* If the async callback rejects, the rejection is caught and converted
|
|
3863
|
+
* to a {@link Failure}.
|
|
3864
|
+
* @param cb - The {@link AsyncFailureContinuation | async failure continuation} to
|
|
3865
|
+
* be called in the event of failure.
|
|
3866
|
+
* @returns An {@link AsyncResult} wrapping the async continuation result, or
|
|
3867
|
+
* propagating the success value from this result.
|
|
3868
|
+
*/
|
|
3869
|
+
thenOnFailure(cb: AsyncFailureContinuation<T>): AsyncResult<T>;
|
|
3279
3870
|
/**
|
|
3280
3871
|
* Calls a supplied {@link ErrorFormatter | error formatter} if
|
|
3281
3872
|
* the operation failed.
|
|
@@ -3490,6 +4081,63 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
3490
4081
|
*/
|
|
3491
4082
|
export declare type IResultValueType<T> = T extends IResult<infer TV> ? TV : never;
|
|
3492
4083
|
|
|
4084
|
+
/**
|
|
4085
|
+
* Minimal structural contract a {@link RetainingRingBuffer} record must satisfy:
|
|
4086
|
+
* a monotonic `seq` the buffer pages on. Records carry their own `seq` (assigned
|
|
4087
|
+
* by the caller) so the buffer is agnostic about how records are minted — a logger
|
|
4088
|
+
* assigns `seq` from its own counter, an observability layer assigns a library-global
|
|
4089
|
+
* `seq` shared across several buffers, etc.
|
|
4090
|
+
* @public
|
|
4091
|
+
*/
|
|
4092
|
+
export declare interface IRetainedRecord {
|
|
4093
|
+
/**
|
|
4094
|
+
* Monotonic sequence number, assigned by the caller. The buffer requires
|
|
4095
|
+
* **strictly increasing** `seq` across successive {@link RetainingRingBuffer.push | push}
|
|
4096
|
+
* calls — `sinceSeq` cursor paging uses a strict `seq > sinceSeq` filter, so
|
|
4097
|
+
* duplicate `seq` values held by a consumer cursor would never be re-yielded
|
|
4098
|
+
* if pushed afterward. {@link RetainingRingBuffer.lastSeq | lastSeq} likewise
|
|
4099
|
+
* advances only past values strictly greater than its current value.
|
|
4100
|
+
*/
|
|
4101
|
+
readonly seq: number;
|
|
4102
|
+
}
|
|
4103
|
+
|
|
4104
|
+
/**
|
|
4105
|
+
* Construction options for {@link RetainingRingBuffer}.
|
|
4106
|
+
* @public
|
|
4107
|
+
*/
|
|
4108
|
+
export declare interface IRetainingRingBufferCreateParams {
|
|
4109
|
+
/**
|
|
4110
|
+
* The maximum number of records retained before the oldest is overwritten.
|
|
4111
|
+
* Defaults to `1000`. Normalized to a positive integer: a fractional value is
|
|
4112
|
+
* floored toward the integer below (`2.9` → `2`), and a non-finite or sub-1
|
|
4113
|
+
* value is floored to `1` (the ring requires a positive integer capacity to
|
|
4114
|
+
* be well-defined).
|
|
4115
|
+
*/
|
|
4116
|
+
readonly maxRecords?: number;
|
|
4117
|
+
}
|
|
4118
|
+
|
|
4119
|
+
/**
|
|
4120
|
+
* Query options for {@link RetainingRingBuffer.query}.
|
|
4121
|
+
* @public
|
|
4122
|
+
*/
|
|
4123
|
+
export declare interface IRetainingRingBufferQuery<T extends IRetainedRecord> {
|
|
4124
|
+
/**
|
|
4125
|
+
* If supplied, only records with `seq > sinceSeq` are returned, enabling
|
|
4126
|
+
* incremental paging from a previously-held cursor.
|
|
4127
|
+
*/
|
|
4128
|
+
readonly sinceSeq?: number;
|
|
4129
|
+
/**
|
|
4130
|
+
* If supplied, returns at most this many records — the most recent N (tail),
|
|
4131
|
+
* still ordered oldest-first.
|
|
4132
|
+
*/
|
|
4133
|
+
readonly limit?: number;
|
|
4134
|
+
/**
|
|
4135
|
+
* If supplied, only records for which the predicate returns `true` are
|
|
4136
|
+
* returned. Applied before `limit`, so `limit` bounds the filtered tail.
|
|
4137
|
+
*/
|
|
4138
|
+
readonly filter?: (record: T) => boolean;
|
|
4139
|
+
}
|
|
4140
|
+
|
|
3493
4141
|
/**
|
|
3494
4142
|
* Helper function to create a {@link Converter | Converter} from a supplied type guard function.
|
|
3495
4143
|
* @param description - a description of the thing to be validated for use in error messages
|
|
@@ -3527,6 +4175,25 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
3527
4175
|
*/
|
|
3528
4176
|
declare function isDetailLogger(logger: ILogger): logger is IDetailLogger;
|
|
3529
4177
|
|
|
4178
|
+
/**
|
|
4179
|
+
* Internal helpers for `Result<T>.shouldNotFail()`. Parsing and message
|
|
4180
|
+
* composition live here so the `Result` class file stays focused on the
|
|
4181
|
+
* Result hierarchy itself; the helpers are exported with the `_` prefix
|
|
4182
|
+
* convention and `@internal` tag so unit tests can cover them directly
|
|
4183
|
+
* without adding test-only public exports.
|
|
4184
|
+
*/
|
|
4185
|
+
/**
|
|
4186
|
+
* Parsed stack-frame information used by `Result<T>.shouldNotFail`.
|
|
4187
|
+
* All fields are optional — runtimes that don't expose stack traces produce
|
|
4188
|
+
* an empty frame and the call site is omitted from the message.
|
|
4189
|
+
* @internal
|
|
4190
|
+
*/
|
|
4191
|
+
export declare interface _IShouldNotFailFrame {
|
|
4192
|
+
fn?: string;
|
|
4193
|
+
file?: string;
|
|
4194
|
+
line?: number;
|
|
4195
|
+
}
|
|
4196
|
+
|
|
3530
4197
|
/**
|
|
3531
4198
|
* Determines if a supplied value is an iterable object or some other type.
|
|
3532
4199
|
* @param value - The value to be tested.
|
|
@@ -3554,6 +4221,14 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
3554
4221
|
*/
|
|
3555
4222
|
declare function isValidator<T, TC>(converterOrValidator: Converter<T, TC> | Validator<T, TC>): converterOrValidator is Validator<T, TC>;
|
|
3556
4223
|
|
|
4224
|
+
/**
|
|
4225
|
+
* Type guard that returns `true` when the input is a canonical UUIDv4 string.
|
|
4226
|
+
* @param value - The string to test.
|
|
4227
|
+
* @returns `true` if `value` is a canonical UUIDv4, narrowing it to {@link Uuid}.
|
|
4228
|
+
* @public
|
|
4229
|
+
*/
|
|
4230
|
+
export declare function isValidUuid(value: string): value is Uuid;
|
|
4231
|
+
|
|
3557
4232
|
/**
|
|
3558
4233
|
* Parameters for constructing a {@link Collections.ValidatingCollector | ValidatingCollector}.
|
|
3559
4234
|
* @public
|
|
@@ -3750,36 +4425,61 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
3750
4425
|
*/
|
|
3751
4426
|
declare abstract class LoggerBase implements IDetailLogger {
|
|
3752
4427
|
/**
|
|
3753
|
-
*
|
|
4428
|
+
* The level of logging to be used.
|
|
3754
4429
|
*/
|
|
3755
4430
|
logLevel: ReporterLogLevel;
|
|
3756
4431
|
protected constructor(logLevel?: ReporterLogLevel);
|
|
3757
4432
|
/**
|
|
3758
|
-
*
|
|
4433
|
+
* Logs a detail message.
|
|
4434
|
+
* @param message - The message to log.
|
|
4435
|
+
* @param parameters - The parameters to log.
|
|
4436
|
+
* @returns `Success` with the logged message if the level is enabled, or
|
|
4437
|
+
* `Success` with `undefined` if the message is suppressed.
|
|
3759
4438
|
*/
|
|
3760
4439
|
detail(message?: unknown, ...parameters: unknown[]): Success<string | undefined>;
|
|
3761
4440
|
/**
|
|
3762
|
-
*
|
|
4441
|
+
* Logs an info message.
|
|
4442
|
+
* @param message - The message to log.
|
|
4443
|
+
* @param parameters - The parameters to log.
|
|
4444
|
+
* @returns `Success` with the logged message if the level is enabled, or
|
|
4445
|
+
* `Success` with `undefined` if the message is suppressed.
|
|
3763
4446
|
*/
|
|
3764
4447
|
info(message?: unknown, ...parameters: unknown[]): Success<string | undefined>;
|
|
3765
4448
|
/**
|
|
3766
|
-
*
|
|
4449
|
+
* Logs a warning message.
|
|
4450
|
+
* @param message - The message to log.
|
|
4451
|
+
* @param parameters - The parameters to log.
|
|
4452
|
+
* @returns `Success` with the logged message if the level is enabled, or
|
|
4453
|
+
* `Success` with `undefined` if the message is suppressed.
|
|
3767
4454
|
*/
|
|
3768
4455
|
warn(message?: unknown, ...parameters: unknown[]): Success<string | undefined>;
|
|
3769
4456
|
/**
|
|
3770
|
-
*
|
|
4457
|
+
* Logs an error message.
|
|
4458
|
+
* @param message - The message to log.
|
|
4459
|
+
* @param parameters - The parameters to log.
|
|
4460
|
+
* @returns `Success` with the logged message if the level is enabled, or
|
|
4461
|
+
* `Success` with `undefined` if the message is suppressed.
|
|
3771
4462
|
*/
|
|
3772
4463
|
error(message?: unknown, ...parameters: unknown[]): Success<string | undefined>;
|
|
3773
4464
|
/**
|
|
3774
|
-
*
|
|
4465
|
+
* Logs a short error summary at `error` level, then emits `detail` at `detail` level.
|
|
4466
|
+
* @param message - Short human-readable summary.
|
|
4467
|
+
* @param detail - Full detail (e.g. raw converter error) logged at `detail` level.
|
|
3775
4468
|
*/
|
|
3776
4469
|
errorWithDetail(message: string, detail: unknown): Success<string | undefined>;
|
|
3777
4470
|
/**
|
|
3778
|
-
*
|
|
4471
|
+
* Logs a short warning summary at `warning` level, then emits `detail` at `detail` level.
|
|
4472
|
+
* @param message - Short human-readable summary.
|
|
4473
|
+
* @param detail - Full detail logged at `detail` level.
|
|
3779
4474
|
*/
|
|
3780
4475
|
warnWithDetail(message: string, detail: unknown): Success<string | undefined>;
|
|
3781
4476
|
/**
|
|
3782
|
-
*
|
|
4477
|
+
* Logs a message at the given level.
|
|
4478
|
+
* @param level - The level of the message.
|
|
4479
|
+
* @param message - The message to log.
|
|
4480
|
+
* @param parameters - The parameters to log.
|
|
4481
|
+
* @returns `Success` with the logged message if the level is enabled, or
|
|
4482
|
+
* `Success` with `undefined` if the message is suppressed.
|
|
3783
4483
|
*/
|
|
3784
4484
|
log(level: MessageLogLevel, message?: unknown, ...parameters: unknown[]): Success<string | undefined>;
|
|
3785
4485
|
/**
|
|
@@ -3790,6 +4490,19 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
3790
4490
|
* @public
|
|
3791
4491
|
*/
|
|
3792
4492
|
protected _format(message?: unknown, ...parameters: unknown[]): string;
|
|
4493
|
+
/**
|
|
4494
|
+
* Inner hook called for logged messages alongside {@link Logging.LoggerBase._log | _log},
|
|
4495
|
+
* exposing the structured `(level, formatted, message, parameters)` form before it is
|
|
4496
|
+
* collapsed to the formatted string. The default implementation is a no-op; subclasses
|
|
4497
|
+
* that need to retain structured records (e.g. {@link Logging.RetainingLogger | RetainingLogger})
|
|
4498
|
+
* override this. Fired only in the `shouldLog` branch, so suppressed messages never reach it.
|
|
4499
|
+
* @param __level - The {@link MessageLogLevel | level} of the message.
|
|
4500
|
+
* @param __formatted - The formatted message (same string passed to `_log`).
|
|
4501
|
+
* @param __message - The raw message argument before formatting.
|
|
4502
|
+
* @param __parameters - The raw parameter arguments before formatting.
|
|
4503
|
+
* @public
|
|
4504
|
+
*/
|
|
4505
|
+
protected _logStructured(__level: MessageLogLevel, __formatted: string, __message?: unknown, __parameters?: readonly unknown[]): void;
|
|
3793
4506
|
/**
|
|
3794
4507
|
* Inner method called for suppressed log messages.
|
|
3795
4508
|
* @public
|
|
@@ -3814,6 +4527,8 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
3814
4527
|
ReporterLogLevel,
|
|
3815
4528
|
ILogger,
|
|
3816
4529
|
IDetailLogger,
|
|
4530
|
+
allReporterLogLevels,
|
|
4531
|
+
reporterLogLevel,
|
|
3817
4532
|
LoggerBase,
|
|
3818
4533
|
InMemoryLogger,
|
|
3819
4534
|
ConsoleLogger,
|
|
@@ -3821,7 +4536,11 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
3821
4536
|
LogValueFormatter,
|
|
3822
4537
|
LogMessageFormatter,
|
|
3823
4538
|
ILogReporterCreateParams,
|
|
3824
|
-
LogReporter
|
|
4539
|
+
LogReporter,
|
|
4540
|
+
MultiLogger,
|
|
4541
|
+
ILogRecord,
|
|
4542
|
+
IGetRecordsOptions,
|
|
4543
|
+
RetainingLogger
|
|
3825
4544
|
}
|
|
3826
4545
|
}
|
|
3827
4546
|
export { Logging }
|
|
@@ -4115,6 +4834,64 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
4115
4834
|
*/
|
|
4116
4835
|
export declare type MessageLogLevel = 'quiet' | 'detail' | 'info' | 'warning' | 'error';
|
|
4117
4836
|
|
|
4837
|
+
/**
|
|
4838
|
+
* A ready-made {@link Converter | Converter} for {@link MessageLogLevel} values.
|
|
4839
|
+
* @public
|
|
4840
|
+
*/
|
|
4841
|
+
declare const messageLogLevel: Converter<MessageLogLevel, ReadonlyArray<MessageLogLevel>>;
|
|
4842
|
+
|
|
4843
|
+
/**
|
|
4844
|
+
* An {@link Logging.ILogger | ILogger} that fans every log call out to N child loggers,
|
|
4845
|
+
* each applying its own threshold.
|
|
4846
|
+
*
|
|
4847
|
+
* @remarks
|
|
4848
|
+
* The composite does not pre-filter — it forwards the raw `(level, message, ...params)`
|
|
4849
|
+
* to each child's public method so each child formats and filters per its own rules.
|
|
4850
|
+
* This lets a single pinned logger feed, for example, a {@link Logging.ConsoleLogger | ConsoleLogger}
|
|
4851
|
+
* (stdout) and a {@link Logging.RetainingLogger | RetainingLogger} (observability buffer)
|
|
4852
|
+
* with independent log levels.
|
|
4853
|
+
*
|
|
4854
|
+
* @public
|
|
4855
|
+
*/
|
|
4856
|
+
declare class MultiLogger implements ILogger {
|
|
4857
|
+
/**
|
|
4858
|
+
* The child loggers calls are fanned out to.
|
|
4859
|
+
* @internal
|
|
4860
|
+
*/
|
|
4861
|
+
private readonly _loggers;
|
|
4862
|
+
/**
|
|
4863
|
+
* Creates a new multi logger.
|
|
4864
|
+
* @param loggers - The child loggers to fan calls out to.
|
|
4865
|
+
*/
|
|
4866
|
+
constructor(loggers: ReadonlyArray<ILogger>);
|
|
4867
|
+
/**
|
|
4868
|
+
* The most-verbose (most-permissive) level among the children, so an upstream
|
|
4869
|
+
* `shouldLog` gate does not suppress a call before it can fan out to a more
|
|
4870
|
+
* permissive child. Computed on access, since a child's level may change.
|
|
4871
|
+
*/
|
|
4872
|
+
get logLevel(): ReporterLogLevel;
|
|
4873
|
+
/**
|
|
4874
|
+
* {@inheritDoc Logging.ILogger.log}
|
|
4875
|
+
*/
|
|
4876
|
+
log(level: MessageLogLevel, message?: unknown, ...parameters: unknown[]): Success<string | undefined>;
|
|
4877
|
+
/**
|
|
4878
|
+
* {@inheritDoc Logging.ILogger.detail}
|
|
4879
|
+
*/
|
|
4880
|
+
detail(message?: unknown, ...parameters: unknown[]): Success<string | undefined>;
|
|
4881
|
+
/**
|
|
4882
|
+
* {@inheritDoc Logging.ILogger.info}
|
|
4883
|
+
*/
|
|
4884
|
+
info(message?: unknown, ...parameters: unknown[]): Success<string | undefined>;
|
|
4885
|
+
/**
|
|
4886
|
+
* {@inheritDoc Logging.ILogger.warn}
|
|
4887
|
+
*/
|
|
4888
|
+
warn(message?: unknown, ...parameters: unknown[]): Success<string | undefined>;
|
|
4889
|
+
/**
|
|
4890
|
+
* {@inheritDoc Logging.ILogger.error}
|
|
4891
|
+
*/
|
|
4892
|
+
error(message?: unknown, ...parameters: unknown[]): Success<string | undefined>;
|
|
4893
|
+
}
|
|
4894
|
+
|
|
4118
4895
|
/**
|
|
4119
4896
|
* A no-op {@link Logging.LoggerBase | LoggerBase} that does not log anything.
|
|
4120
4897
|
* @public
|
|
@@ -4144,6 +4921,30 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
4144
4921
|
* @returns A normalized version of the value
|
|
4145
4922
|
*/
|
|
4146
4923
|
normalize<T>(from: T): Result<T>;
|
|
4924
|
+
/**
|
|
4925
|
+
* Produces a stable, byte-identical JSON string following RFC 8785
|
|
4926
|
+
* (JSON Canonicalization Scheme) key-ordering rules.
|
|
4927
|
+
*
|
|
4928
|
+
* Builds the output string directly rather than constructing an intermediate
|
|
4929
|
+
* JS object, so integer-string keys (`"10"`, `"2"`) retain lexicographic
|
|
4930
|
+
* order instead of being reordered numerically by the JS engine during
|
|
4931
|
+
* `JSON.stringify`.
|
|
4932
|
+
*
|
|
4933
|
+
* @param from - Any JSON-compatible value (string, number, boolean, null,
|
|
4934
|
+
* plain object, or array). Fails for non-JSON types (Map, Set, Date,
|
|
4935
|
+
* RegExp, function, symbol, bigint, undefined).
|
|
4936
|
+
* @returns `Result<string>` — the canonical JSON string, or a failure if
|
|
4937
|
+
* `from` contains non-serializable types.
|
|
4938
|
+
* @public
|
|
4939
|
+
*/
|
|
4940
|
+
canonicalize(from: unknown): Result<string>;
|
|
4941
|
+
/**
|
|
4942
|
+
* Recursively builds a byte-identical RFC 8785 JSON string.
|
|
4943
|
+
* @throws For non-JSON-serializable types (non-finite numbers, Date, RegExp,
|
|
4944
|
+
* Map, Set, class instances, function, symbol, bigint, undefined).
|
|
4945
|
+
* Callers must wrap in captureResult.
|
|
4946
|
+
*/
|
|
4947
|
+
protected _canonicalizeRfc8785(value: unknown): string;
|
|
4147
4948
|
/**
|
|
4148
4949
|
* Compares two property names from some object being normalized.
|
|
4149
4950
|
* @param k1 - First key to be compared.
|
|
@@ -4170,6 +4971,14 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
4170
4971
|
normalizeLiteral<T>(from: T): Result<T>;
|
|
4171
4972
|
}
|
|
4172
4973
|
|
|
4974
|
+
/**
|
|
4975
|
+
* Normalizes a function name from a stack frame, returning `undefined` when
|
|
4976
|
+
* the name is empty or one of the well-known anonymous-IIFE noise patterns
|
|
4977
|
+
* (typically emitted by V8 for module-top-level code).
|
|
4978
|
+
* @internal
|
|
4979
|
+
*/
|
|
4980
|
+
export declare function _normalizeShouldNotFailFnName(fn: string | undefined): string | undefined;
|
|
4981
|
+
|
|
4173
4982
|
/**
|
|
4174
4983
|
* A {@link Converter | Converter} which converts `unknown` to a `number`.
|
|
4175
4984
|
* @remarks
|
|
@@ -4513,6 +5322,13 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
4513
5322
|
*/
|
|
4514
5323
|
export declare function omit<T extends object, K extends keyof T>(from: T, exclude: K[]): Omit<T, K>;
|
|
4515
5324
|
|
|
5325
|
+
/**
|
|
5326
|
+
* Union of all values in an array/tuple type, preserving literal types if possible.
|
|
5327
|
+
* If T is not an array/tuple, results in `never`.
|
|
5328
|
+
* @public
|
|
5329
|
+
*/
|
|
5330
|
+
export declare type OneOf<T> = T extends readonly unknown[] ? T[number] : never;
|
|
5331
|
+
|
|
4516
5332
|
/**
|
|
4517
5333
|
* A helper function to create a {@link Converter | Converter} for polymorphic values.
|
|
4518
5334
|
* Returns a converter which invokes the wrapped converters in sequence, returning the
|
|
@@ -4588,6 +5404,12 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
4588
5404
|
*/
|
|
4589
5405
|
declare type OnError = 'failOnError' | 'ignoreErrors';
|
|
4590
5406
|
|
|
5407
|
+
/**
|
|
5408
|
+
* A ready-made {@link Converter | Converter} for {@link Conversion.OnError | OnError} values.
|
|
5409
|
+
* @public
|
|
5410
|
+
*/
|
|
5411
|
+
declare const onError: Converter<OnError, ReadonlyArray<OnError>>;
|
|
5412
|
+
|
|
4591
5413
|
/**
|
|
4592
5414
|
* A {@link Converter | Converter} to convert an optional `boolean` value.
|
|
4593
5415
|
* @remarks
|
|
@@ -4682,6 +5504,15 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
4682
5504
|
*/
|
|
4683
5505
|
declare const optionalString: Converter<string | undefined, unknown>;
|
|
4684
5506
|
|
|
5507
|
+
/**
|
|
5508
|
+
* Parses a single stack-trace line in either V8 or WebKit format.
|
|
5509
|
+
*
|
|
5510
|
+
* V8: ` at <fn> (<file>:<line>:<col>)` or ` at <file>:<line>:<col>`
|
|
5511
|
+
* WebKit: `<fn>@<file>:<line>:<col>` or `@<file>:<line>:<col>`
|
|
5512
|
+
* @internal
|
|
5513
|
+
*/
|
|
5514
|
+
export declare function _parseStackFrame(line: string): _IShouldNotFailFrame;
|
|
5515
|
+
|
|
4685
5516
|
/**
|
|
4686
5517
|
* Simple implicit pick function, which picks a set of properties from a supplied
|
|
4687
5518
|
* object. Ignores picked properties that do not exist regardless of type signature.
|
|
@@ -4988,6 +5819,12 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
4988
5819
|
*/
|
|
4989
5820
|
declare type ReporterLogLevel = 'all' | 'detail' | 'info' | 'warning' | 'error' | 'silent';
|
|
4990
5821
|
|
|
5822
|
+
/**
|
|
5823
|
+
* A ready-made {@link Converter | Converter} for {@link Logging.ReporterLogLevel | ReporterLogLevel} values.
|
|
5824
|
+
* @public
|
|
5825
|
+
*/
|
|
5826
|
+
declare const reporterLogLevel: Converter<ReporterLogLevel, ReadonlyArray<ReporterLogLevel>>;
|
|
5827
|
+
|
|
4991
5828
|
/**
|
|
4992
5829
|
* Represents the {@link IResult | result} of some operation or sequence of operations.
|
|
4993
5830
|
* @remarks
|
|
@@ -5260,6 +6097,172 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
5260
6097
|
*/
|
|
5261
6098
|
export declare type ResultValueType<T> = T extends Result<infer TV> ? TV : never;
|
|
5262
6099
|
|
|
6100
|
+
/**
|
|
6101
|
+
* An {@link Logging.ILogger | ILogger} that retains structured log records in a bounded
|
|
6102
|
+
* most-recent-N ring, with a query API supporting min-severity filtering and
|
|
6103
|
+
* since-cursor incremental paging.
|
|
6104
|
+
*
|
|
6105
|
+
* @remarks
|
|
6106
|
+
* Records are captured via the {@link Logging.LoggerBase._logStructured | _logStructured} hook,
|
|
6107
|
+
* so the full structured form (`level` + formatted `message` + raw `args`) is retained.
|
|
6108
|
+
* The logger emits nowhere itself — pair it with a {@link Logging.MultiLogger | MultiLogger}
|
|
6109
|
+
* to also feed a {@link Logging.ConsoleLogger | ConsoleLogger} or other durable sink.
|
|
6110
|
+
*
|
|
6111
|
+
* @public
|
|
6112
|
+
*/
|
|
6113
|
+
declare class RetainingLogger extends LoggerBase {
|
|
6114
|
+
/**
|
|
6115
|
+
* Injected clock used to timestamp records.
|
|
6116
|
+
* @internal
|
|
6117
|
+
*/
|
|
6118
|
+
private readonly _now;
|
|
6119
|
+
/**
|
|
6120
|
+
* The monotonic sequence counter. The logger owns `seq` assignment and
|
|
6121
|
+
* increments this before each push so the buffer receives strictly increasing
|
|
6122
|
+
* sequence numbers.
|
|
6123
|
+
* @internal
|
|
6124
|
+
*/
|
|
6125
|
+
private _nextSeq;
|
|
6126
|
+
/**
|
|
6127
|
+
* The backing ring buffer. Retains up to `maxRecords` log records, evicting
|
|
6128
|
+
* the oldest when full. The buffer is a pure seq-ring — it does not assign
|
|
6129
|
+
* `seq`; the logger does.
|
|
6130
|
+
* @internal
|
|
6131
|
+
*/
|
|
6132
|
+
private readonly _ring;
|
|
6133
|
+
/**
|
|
6134
|
+
* Creates a new retaining logger.
|
|
6135
|
+
* @param logLevel - The level of logging to retain. Defaults to `'detail'` to capture
|
|
6136
|
+
* broadly and filter at query time.
|
|
6137
|
+
* @param maxRecords - The maximum number of records to retain. Defaults to `1000`.
|
|
6138
|
+
* @param now - Injected clock returning milliseconds since epoch. Defaults to `Date.now`.
|
|
6139
|
+
*/
|
|
6140
|
+
constructor(logLevel?: ReporterLogLevel, maxRecords?: number, now?: () => number);
|
|
6141
|
+
/**
|
|
6142
|
+
* The retained records, oldest-first.
|
|
6143
|
+
*/
|
|
6144
|
+
get records(): ReadonlyArray<ILogRecord>;
|
|
6145
|
+
/**
|
|
6146
|
+
* The most recently assigned sequence number. A client can hold this value and
|
|
6147
|
+
* pass it as `sinceSeq` to page only records logged afterward.
|
|
6148
|
+
*/
|
|
6149
|
+
get lastSeq(): number;
|
|
6150
|
+
/**
|
|
6151
|
+
* Returns retained records, oldest-first, optionally filtered.
|
|
6152
|
+
* @param options - {@link Logging.IGetRecordsOptions | Filtering and paging options}.
|
|
6153
|
+
* @returns The matching records, oldest-first.
|
|
6154
|
+
*/
|
|
6155
|
+
getRecords(options?: IGetRecordsOptions): ReadonlyArray<ILogRecord>;
|
|
6156
|
+
/**
|
|
6157
|
+
* Clears all retained records. Does NOT reset the sequence counter, so a client
|
|
6158
|
+
* holding a `sinceSeq` cursor never re-sees a sequence number.
|
|
6159
|
+
*/
|
|
6160
|
+
clear(): void;
|
|
6161
|
+
/**
|
|
6162
|
+
* {@inheritDoc Logging.LoggerBase._logStructured}
|
|
6163
|
+
* @internal
|
|
6164
|
+
*/
|
|
6165
|
+
protected _logStructured(level: MessageLogLevel, formatted: string, message: unknown, parameters: readonly unknown[]): void;
|
|
6166
|
+
/**
|
|
6167
|
+
* {@inheritDoc Logging.LoggerBase._log}
|
|
6168
|
+
* @internal
|
|
6169
|
+
*/
|
|
6170
|
+
protected _log(message: string, __level: MessageLogLevel): Success<string | undefined>;
|
|
6171
|
+
}
|
|
6172
|
+
|
|
6173
|
+
/**
|
|
6174
|
+
* A generic bounded most-recent-N ring of records, with monotonic-`seq` cursor
|
|
6175
|
+
* paging and predicate filtering.
|
|
6176
|
+
*
|
|
6177
|
+
* @remarks
|
|
6178
|
+
* The buffer is a pure storage substrate: the caller mints each record (assigning
|
|
6179
|
+
* its own `seq` and any other fields) and {@link RetainingRingBuffer.push | push}es
|
|
6180
|
+
* it. The buffer never reshapes a record — it only retains, evicts the oldest when
|
|
6181
|
+
* full (O(1), no `shift()` re-indexing regardless of capacity), and answers queries.
|
|
6182
|
+
*
|
|
6183
|
+
* Separating record minting from retention lets one `seq` authority feed several
|
|
6184
|
+
* buffers consistently (e.g. an observability layer that assigns a library-global
|
|
6185
|
+
* `seq` and fans the same record out to multiple retaining stores), and lets a
|
|
6186
|
+
* single-authority consumer (e.g. a logger) own its own `seq` counter. It is the
|
|
6187
|
+
* shared mechanism beneath `RetainingLogger` and
|
|
6188
|
+
* any schema-aware observation store.
|
|
6189
|
+
*
|
|
6190
|
+
* @public
|
|
6191
|
+
*/
|
|
6192
|
+
export declare class RetainingRingBuffer<T extends IRetainedRecord> {
|
|
6193
|
+
/**
|
|
6194
|
+
* The fixed ring capacity — the maximum number of records retained before the
|
|
6195
|
+
* oldest is overwritten. A positive integer (see the constructor normalization).
|
|
6196
|
+
* @internal
|
|
6197
|
+
*/
|
|
6198
|
+
private readonly _capacity;
|
|
6199
|
+
/**
|
|
6200
|
+
* The backing store, used as a circular buffer. Grows lazily up to `_capacity`,
|
|
6201
|
+
* after which records overwrite the oldest slot in place — eviction is O(1), with
|
|
6202
|
+
* no `shift()` re-indexing regardless of capacity.
|
|
6203
|
+
* @internal
|
|
6204
|
+
*/
|
|
6205
|
+
private _buffer;
|
|
6206
|
+
/**
|
|
6207
|
+
* Index of the oldest retained record within `_buffer` once the ring is full.
|
|
6208
|
+
* @internal
|
|
6209
|
+
*/
|
|
6210
|
+
private _head;
|
|
6211
|
+
/**
|
|
6212
|
+
* The number of valid records currently retained (`<= _capacity`).
|
|
6213
|
+
* @internal
|
|
6214
|
+
*/
|
|
6215
|
+
private _count;
|
|
6216
|
+
/**
|
|
6217
|
+
* The highest `seq` ever pushed; monotonic, stable across eviction and
|
|
6218
|
+
* {@link RetainingRingBuffer.clear | clear()}.
|
|
6219
|
+
* @internal
|
|
6220
|
+
*/
|
|
6221
|
+
private _lastSeq;
|
|
6222
|
+
/**
|
|
6223
|
+
* Creates a new retaining ring buffer.
|
|
6224
|
+
* @param params - {@link IRetainingRingBufferCreateParams | Construction options}.
|
|
6225
|
+
*/
|
|
6226
|
+
constructor(params?: IRetainingRingBufferCreateParams);
|
|
6227
|
+
/**
|
|
6228
|
+
* The number of records currently retained.
|
|
6229
|
+
*/
|
|
6230
|
+
get size(): number;
|
|
6231
|
+
/**
|
|
6232
|
+
* The highest `seq` pushed so far. A client can hold this value and pass it as
|
|
6233
|
+
* `sinceSeq` to page only records pushed afterward. Stable across eviction and
|
|
6234
|
+
* {@link RetainingRingBuffer.clear | clear()}.
|
|
6235
|
+
*/
|
|
6236
|
+
get lastSeq(): number;
|
|
6237
|
+
/**
|
|
6238
|
+
* The retained records, oldest-first.
|
|
6239
|
+
*/
|
|
6240
|
+
get records(): ReadonlyArray<T>;
|
|
6241
|
+
/**
|
|
6242
|
+
* Retains a record, evicting the oldest if the ring is full.
|
|
6243
|
+
* @param record - The record to retain. Its `seq` should be greater than the
|
|
6244
|
+
* `seq` of the previously-pushed record so cursor paging stays monotonic.
|
|
6245
|
+
* @returns The same record, for call-site chaining.
|
|
6246
|
+
*/
|
|
6247
|
+
push(record: T): T;
|
|
6248
|
+
/**
|
|
6249
|
+
* Returns retained records, oldest-first, optionally filtered and paged.
|
|
6250
|
+
* @param query - {@link IRetainingRingBufferQuery | Filtering and paging options}.
|
|
6251
|
+
* @returns The matching records, oldest-first.
|
|
6252
|
+
*/
|
|
6253
|
+
query(query?: IRetainingRingBufferQuery<T>): ReadonlyArray<T>;
|
|
6254
|
+
/**
|
|
6255
|
+
* Clears all retained records. Does NOT reset {@link RetainingRingBuffer.lastSeq | lastSeq},
|
|
6256
|
+
* so a client holding a `sinceSeq` cursor never re-sees a sequence number.
|
|
6257
|
+
*/
|
|
6258
|
+
clear(): void;
|
|
6259
|
+
/**
|
|
6260
|
+
* Materializes the ring into a plain oldest-first array.
|
|
6261
|
+
* @internal
|
|
6262
|
+
*/
|
|
6263
|
+
private _toOrderedArray;
|
|
6264
|
+
}
|
|
6265
|
+
|
|
5263
6266
|
/**
|
|
5264
6267
|
* Compares two log levels.
|
|
5265
6268
|
* @param message - The first log level.
|
|
@@ -5424,6 +6427,13 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
5424
6427
|
message?: string;
|
|
5425
6428
|
}
|
|
5426
6429
|
|
|
6430
|
+
/**
|
|
6431
|
+
* Union of all string values in an array/tuple type, preserving literal types if possible.
|
|
6432
|
+
* If T is not an array/tuple, results in `never`.
|
|
6433
|
+
* @public
|
|
6434
|
+
*/
|
|
6435
|
+
export declare type StringOneOf<T> = Extract<OneOf<T>, string>;
|
|
6436
|
+
|
|
5427
6437
|
/**
|
|
5428
6438
|
* An in-place {@link Validation.Validator | Validator} for `string` values.
|
|
5429
6439
|
* @public
|
|
@@ -5531,6 +6541,10 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
5531
6541
|
* {@inheritDoc IResult.orThrow}
|
|
5532
6542
|
*/
|
|
5533
6543
|
orThrow(cb: ErrorFormatter): T;
|
|
6544
|
+
/**
|
|
6545
|
+
* {@inheritDoc IResult.shouldNotFail}
|
|
6546
|
+
*/
|
|
6547
|
+
shouldNotFail(__label?: string, __frameDepth?: number): T;
|
|
5534
6548
|
/**
|
|
5535
6549
|
* {@inheritDoc IResult.orDefault}
|
|
5536
6550
|
*/
|
|
@@ -5557,6 +6571,14 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
5557
6571
|
* {@inheritDoc IResult.onFailure}
|
|
5558
6572
|
*/
|
|
5559
6573
|
onFailure(__: FailureContinuation<T>): Result<T>;
|
|
6574
|
+
/**
|
|
6575
|
+
* {@inheritDoc IResult.thenOnSuccess}
|
|
6576
|
+
*/
|
|
6577
|
+
thenOnSuccess<TN>(cb: AsyncSuccessContinuation<T, TN>): AsyncResult<TN>;
|
|
6578
|
+
/**
|
|
6579
|
+
* {@inheritDoc IResult.thenOnFailure}
|
|
6580
|
+
*/
|
|
6581
|
+
thenOnFailure(__: AsyncFailureContinuation<T>): AsyncResult<T>;
|
|
5560
6582
|
/**
|
|
5561
6583
|
* {@inheritDoc IResult.withErrorFormat}
|
|
5562
6584
|
*/
|
|
@@ -5746,6 +6768,14 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
5746
6768
|
}
|
|
5747
6769
|
}
|
|
5748
6770
|
|
|
6771
|
+
/**
|
|
6772
|
+
* A canonical UUIDv4 string: 8-4-4-4-12 lowercase hex digits with version
|
|
6773
|
+
* nibble `4` and variant nibble in `[89ab]`. Produced by {@link generateUuid}
|
|
6774
|
+
* and validated by {@link isValidUuid}.
|
|
6775
|
+
* @public
|
|
6776
|
+
*/
|
|
6777
|
+
export declare type Uuid = Brand<string, 'Uuid'>;
|
|
6778
|
+
|
|
5749
6779
|
/**
|
|
5750
6780
|
* Helper function to create a {@link Converter | Converter} from any {@link Validation.Validator}
|
|
5751
6781
|
* @param converterOrValidator - the {@link Validation.Validator} to be wrapped or {@link Converter | Converter}
|