@fgv/ts-utils 5.1.0-2 → 5.1.0-21
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.map +1 -0
- package/dist/packlets/base/brand.js.map +1 -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.map +1 -0
- package/dist/packlets/base/result.js +227 -2
- package/dist/packlets/base/result.js.map +1 -0
- package/dist/packlets/base/utils.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.map +1 -0
- package/dist/packlets/collections/keyValueConverters.js.map +1 -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/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 +102 -16
- package/dist/packlets/conversion/baseConverter.js.map +1 -0
- package/dist/packlets/conversion/basicConverters.js.map +1 -0
- 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.map +1 -0
- package/dist/packlets/logging/logReporter.js.map +1 -0
- package/dist/packlets/logging/logger.js +33 -8
- package/dist/packlets/logging/logger.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 +441 -56
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/index.d.ts.map +1 -0
- 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.map +1 -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.map +1 -0
- package/lib/packlets/base/normalize.js.map +1 -0
- package/lib/packlets/base/result.d.ts +179 -1
- package/lib/packlets/base/result.d.ts.map +1 -0
- package/lib/packlets/base/result.js +231 -3
- package/lib/packlets/base/result.js.map +1 -0
- package/lib/packlets/base/utils.d.ts.map +1 -0
- package/lib/packlets/base/utils.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.map +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.map +1 -0
- 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/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 +102 -16
- package/lib/packlets/conversion/baseConverter.d.ts.map +1 -0
- package/lib/packlets/conversion/baseConverter.js +102 -16
- package/lib/packlets/conversion/baseConverter.js.map +1 -0
- package/lib/packlets/conversion/basicConverters.d.ts.map +1 -0
- package/lib/packlets/conversion/basicConverters.js.map +1 -0
- package/lib/packlets/conversion/converter.d.ts.map +1 -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.map +1 -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 +33 -8
- package/lib/packlets/logging/logger.d.ts.map +1 -0
- package/lib/packlets/logging/logger.js +33 -8
- package/lib/packlets/logging/logger.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 +20 -18
- 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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"advancedConverters.js","sourceRoot":"","sources":["../../../src/packlets/conversion/advancedConverters.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;G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AC;QACvD,CAAC;QAED,IAAI,IAAI,CAAC,MAAM,KAAK,UAAU,CAAC,MAAM,EAAE,CAAC;YACtC,OAAO,IAAA,WAAI,EACT,4BAA4B,UAAU,CAAC,MAAM,SAAS,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAC7F,CAAC;QACJ,CAAC;QAED,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE;YAClD,OAAO,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC;QACjD,CAAC,CAAC,CAAC;QAEH,OAAO,IAAA,iBAAU,EAAC,OAAO,CAAkE,CAAC;IAC9F,CAAC,CACF,CAAC;AACJ,CAAC","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { fail, isKeyOf, mapResults, succeed, Success } from '../base';\nimport { Validator } from '../validation';\nimport { BaseConverter, ConverterResultTypes } from './baseConverter';\nimport { Converter } from './converter';\nimport { literal } from './basicConverters';\nimport { FieldConverters, ObjectConverter } from './objectConverter';\n\n/**\n * Represents a composite ID constructed of two strongly-typed string IDs\n * separated by a delimiter.\n * @public\n */\nexport interface ICompositeId<TCOLLECTIONID extends string, TITEMID extends string> {\n readonly collectionId: TCOLLECTIONID;\n readonly separator: string;\n readonly itemId: TITEMID;\n}\n\n/**\n * Represents a partial composite ID, where separator is optional.\n * @public\n */\nexport interface IPartialCompositeId<TCOLLECTIONID extends string, TITEMID extends string> {\n readonly collectionId: TCOLLECTIONID;\n readonly separator?: string;\n readonly itemId: TITEMID;\n}\n\n/**\n * Creates an {@link ObjectConverter | ObjectConverter} for a strongly-typed {@link Converters.ICompositeId | CompositeId}.\n * @param collectionIdValidator - {@link Converter | Converter} or {@link Validator | Validator} for the collection ID portion.\n * @param separator - The separator string.\n * @param itemIdValidator - {@link Converter | Converter} or {@link Validator | Validator} for the item ID portion.\n * @returns An {@link ObjectConverter | ObjectConverter} for the strongly-typed composite ICompositeId.\n * @public\n */\nexport function compositeIdFromObject<TCOLLECTIONID extends string, TITEMID extends string, TC = unknown>(\n collectionIdValidator: Converter<TCOLLECTIONID, TC> | Validator<TCOLLECTIONID, TC>,\n separator: string,\n itemIdValidator: Converter<TITEMID, TC> | Validator<TITEMID, TC>\n): Converter<ICompositeId<TCOLLECTIONID, TITEMID>, TC> {\n return new ObjectConverter<IPartialCompositeId<TCOLLECTIONID, TITEMID>, TC>({\n collectionId: collectionIdValidator,\n separator: literal(separator).optional(),\n itemId: itemIdValidator\n }).map<ICompositeId<TCOLLECTIONID, TITEMID>>((obj) =>\n Success.with({\n collectionId: obj.collectionId,\n separator: obj.separator ?? separator,\n itemId: obj.itemId\n })\n );\n}\n\n/**\n * Converts a composite ID string into a strongly-typed {@link Converters.ICompositeId | CompositeId}.\n * @param collectionIdConverter - {@link Converter | Converter} or {@link Validator | Validator} for the collection ID portion.\n * @param separator - The separator string.\n * @param itemIdConverter - {@link Converter | Converter} or {@link Validator | Validator} for the item ID portion.\n * @returns A {@link Converter | Converter} for the strongly-typed {@link Converters.ICompositeId | CompositeId}.\n * @public\n */\nexport function compositeIdFromString<TCOLLECTIONID extends string, TITEMID extends string, TC = unknown>(\n collectionIdConverter: Converter<TCOLLECTIONID, TC> | Validator<TCOLLECTIONID, TC>,\n separator: string,\n itemIdConverter: Converter<TITEMID, TC> | Validator<TITEMID, TC>\n): Converter<ICompositeId<TCOLLECTIONID, TITEMID>, TC> {\n return new BaseConverter<ICompositeId<TCOLLECTIONID, TITEMID>, TC>(\n (from: unknown, __self?: Converter<ICompositeId<TCOLLECTIONID, TITEMID>, TC>, context?: TC) => {\n if (typeof from !== 'string') {\n return fail(`${from}: invalid non-string composite ID.`);\n }\n const parts = from.split(separator);\n if (parts.length < 2) {\n return fail(`${from}: invalid composite ID - separator '${separator}' not found.`);\n } else if (parts.length > 2) {\n return fail(`${from}: invalid composite ID - multiple separators '${separator}.' found.`);\n }\n return collectionIdConverter.convert(parts[0], context).onSuccess((collectionId) => {\n return itemIdConverter.convert(parts[1], context).onSuccess((itemId) => {\n return succeed({\n collectionId,\n separator,\n itemId\n });\n });\n });\n }\n );\n}\n\n/**\n * Creates a {@link Converter | Converter} for a strongly-typed {@link Converters.ICompositeId | CompositeId} from\n * either a string or an object representation.\n * @param collectionIdConverter - {@link Converter | Converter} or {@link Validator | Validator} for the collection ID portion.\n * @param separator - The separator string.\n * @param itemIdConverter - {@link Converter | Converter} or {@link Validator | Validator} for the item ID portion.\n * @returns A {@link Converter | Converter} for the strongly-typed {@link Converters.ICompositeId | CompositeId}.\n * @public\n */\nexport function compositeId<TCOLLECTIONID extends string, TITEMID extends string, TC = unknown>(\n collectionIdConverter: Converter<TCOLLECTIONID, TC> | Validator<TCOLLECTIONID, TC>,\n separator: string,\n itemIdConverter: Converter<TITEMID, TC> | Validator<TITEMID, TC>\n): Converter<ICompositeId<TCOLLECTIONID, TITEMID>, TC> {\n return compositeIdFromObject(collectionIdConverter, separator, itemIdConverter).or(\n compositeIdFromString(collectionIdConverter, separator, itemIdConverter)\n );\n}\n\n/**\n * Converts a strongly-typed {@link Converters.ICompositeId | CompositeId} into a string.\n * @param compositeIdConverter - {@link Converter | Converter} or {@link Validator | Validator} that validates/converts the composite ID string.\n * @param collectionIdConverter - {@link Converter | Converter} or {@link Validator | Validator} for the collection ID portion.\n * @param separator - The separator string.\n * @param itemIdConverter - {@link Converter | Converter} or {@link Validator | Validator} for the item ID portion.\n * @returns A {@link Converter | Converter} which produces a composite ID string.\n * @public\n */\nexport function compositeIdString<\n T extends string,\n TCOLLECTIONID extends string,\n TITEMID extends string,\n TC = unknown\n>(\n compositeIdConverter: Validator<T, TC> | Converter<T, TC>,\n collectionIdConverter: Converter<TCOLLECTIONID, TC> | Validator<TCOLLECTIONID, TC>,\n separator: string,\n itemIdConverter: Converter<TITEMID, TC> | Validator<TITEMID, TC>\n): Converter<T, TC> {\n const objectConverter = compositeIdFromObject(collectionIdConverter, separator, itemIdConverter);\n return new BaseConverter<T, TC>((from: unknown, __self?: Converter<T, TC>, context?: TC) => {\n if (typeof from === 'string') {\n return compositeIdConverter.convert(from, context);\n }\n return objectConverter.convert(from, context).onSuccess((compositeId) => {\n return compositeIdConverter.convert(`${compositeId.collectionId}${separator}${compositeId.itemId}`);\n });\n });\n}\n\n/**\n * Helper to create a {@link Converter | Converter} which converts a source object to a new object with a\n * different shape.\n *\n * @remarks\n * On successful conversion, the resulting {@link Converter | Converter} returns {@link Success | Success} with a new\n * object, which contains the converted values under the key names specified at initialization time.\n * It returns {@link Failure | Failure} with an error message if any fields to be extracted do not exist\n * or cannot be converted.\n *\n * Fields that succeed but convert to undefined are omitted from the result object but do not\n * fail the conversion.\n *\n * @param properties - An object with key names that correspond to the target object and an\n * appropriate {@link Conversion.FieldConverters | FieldConverter} which extracts and converts\n * a single filed from the source object.\n * @returns A {@link Converter | Converter} with the specified conversion behavior.\n * @public\n */\nexport function transform<T, TC = unknown>(properties: FieldConverters<T, TC>): Converter<T, TC> {\n return new BaseConverter((from: unknown, __self, context?: TC) => {\n // eslint bug thinks key is used before defined\n\n const converted = {} as { [key in keyof T]: T[key] };\n const errors: string[] = [];\n\n for (const key in properties) {\n if (properties[key]) {\n const result = properties[key].convert(from, context);\n if (result.isSuccess() && result.value !== undefined) {\n converted[key] = result.value;\n } else if (result.isFailure()) {\n errors.push(result.message);\n }\n }\n }\n\n return errors.length === 0 ? succeed(converted) : fail(errors.join('\\n'));\n });\n}\n\n/**\n * Per-property converters and configuration for each field in the destination object of\n * a {@link Converters.transformObject} call.\n * @public\n */\nexport type FieldTransformers<TSRC, TDEST, TC = unknown> = {\n [key in keyof TDEST]: {\n /**\n * The name of the property in the source object to be converted.\n */\n from: keyof TSRC;\n /**\n * The converter or validator used to convert the property.\n */\n converter: Converter<TDEST[key], TC> | Validator<TDEST[key], TC>;\n /**\n * If `true` then a missing source property is ignored. If `false` or omitted\n * then a missing source property causes an error.\n */\n optional?: boolean;\n };\n};\n\n/**\n * Options for a {@link Converters.transformObject} call.\n * @public\n */\n\nexport interface TransformObjectOptions<TSRC> {\n /**\n * If `strict` is `true` then unused properties in the source object cause\n * an error, otherwise they are ignored.\n */\n strict: true;\n\n /**\n * An optional list of source properties to be ignored when strict mode\n * is enabled.\n */\n ignore?: (keyof TSRC)[];\n\n /**\n * An optional description of this transform to be used for error messages.\n */\n description?: string;\n}\n\n/**\n * Helper to create a strongly-typed {@link Converter | Converter} which converts a source object to a\n * new object with a different shape.\n *\n * @remarks\n * On successful conversion, the resulting {@link Converter | Converter} returns {@link Success | Success} with a new\n * object, which contains the converted values under the key names specified at initialization time.\n *\n * It returns {@link Failure | Failure} with an error message if any fields to be extracted do not exist\n * or cannot be converted.\n *\n * @param destinationFields - An object with key names that correspond to the target object and an\n * appropriate {@link Converters.FieldTransformers | FieldTransformers} which specifies the name\n * of the corresponding property in the source object, the converter or validator used for each source\n * property and any other configuration to guide the conversion.\n * @param options - Options which affect the transformation.\n *\n * @returns A {@link Converter | Converter} with the specified conversion behavior.\n * @public\n */\nexport function transformObject<TSRC, TDEST, TC = unknown>(\n destinationFields: FieldTransformers<TSRC, TDEST, TC>,\n options?: TransformObjectOptions<TSRC>\n): Converter<TDEST, TC> {\n return new BaseConverter((from: unknown, __self, context?: TC) => {\n // eslint bug thinks key is used before defined\n\n const converted = {} as { [key in keyof TDEST]: TDEST[key] };\n const errors: string[] = [];\n const used: Set<keyof TSRC> = new Set(options?.ignore);\n\n if (typeof from === 'object' && !Array.isArray(from) && from !== null) {\n for (const destinationKey in destinationFields) {\n if (destinationFields[destinationKey]) {\n const srcKey = destinationFields[destinationKey].from;\n const converter = destinationFields[destinationKey].converter;\n\n if (isKeyOf(srcKey, from)) {\n const result = converter.convert(from[srcKey], context);\n if (result.isSuccess() && result.value !== undefined) {\n converted[destinationKey] = result.value;\n } else if (result.isFailure()) {\n errors.push(`${srcKey}->${destinationKey}: ${result.message}`);\n }\n used.add(srcKey);\n } else if (destinationFields[destinationKey].optional !== true) {\n errors.push(`${String(srcKey)}: required property missing in source object.`);\n }\n }\n }\n\n if (options?.strict === true) {\n for (const key in from) {\n if (isKeyOf(key, from) && !used.has(key as keyof TSRC)) {\n errors.push(`${key}: unexpected property in source object`);\n }\n }\n }\n } else {\n errors.push('source is not an object');\n }\n\n return errors.length === 0\n ? succeed(converted)\n : fail(options?.description ? `${options.description}:\\n ${errors.join('\\n ')}` : errors.join('\\n'));\n });\n}\n\n/**\n * Creates a {@link Converter | Converter} that converts an array to a strongly-typed tuple,\n * using the supplied tuple of {@link Converter | Converters} to convert each element.\n *\n * @remarks\n * The resulting {@link Converter | Converter} returns {@link Success | Success} with a tuple\n * containing the converted values if all conversions succeed. Returns {@link Failure | Failure}\n * with an error message if the source is not an array, has the wrong number of elements, or\n * any element conversion fails.\n *\n * @example\n * ```typescript\n * const converter = tuple([Converters.string, Converters.number, Converters.boolean]);\n * // Type is Converter<[string, number, boolean]>\n *\n * converter.convert(['hello', 42, true]);\n * // Returns Success with ['hello', 42, true]\n * ```\n *\n * @param converters - A tuple of {@link Converter | Converters} defining the expected types\n * for each element of the tuple.\n * @returns A {@link Converter | Converter} that returns a strongly-typed tuple.\n * @public\n */\nexport function tuple<T extends readonly Converter<unknown, TC>[], TC = unknown>(\n converters: [...T]\n): Converter<ConverterResultTypes<T>, TC> {\n return new BaseConverter<ConverterResultTypes<T>, TC>(\n (from: unknown, __self: Converter<ConverterResultTypes<T>, TC>, context?: TC) => {\n if (!Array.isArray(from)) {\n return fail(`Not an array: ${JSON.stringify(from)}`);\n }\n\n if (from.length !== converters.length) {\n return fail(\n `Expected array of length ${converters.length}, got ${from.length}: ${JSON.stringify(from)}`\n );\n }\n\n const results = converters.map((converter, index) => {\n return converter.convert(from[index], context);\n });\n\n return mapResults(results) as ReturnType<Converter<ConverterResultTypes<T>, TC>['convert']>;\n }\n );\n}\n"]}
|
|
@@ -64,63 +64,146 @@ export declare class BaseConverter<T, TC = unknown> implements Converter<T, TC>
|
|
|
64
64
|
*/
|
|
65
65
|
constructor(converter: ConverterFunc<T, TC>, defaultContext?: TC, traits?: ConverterTraits);
|
|
66
66
|
/**
|
|
67
|
-
*
|
|
67
|
+
* Indicates whether this element is explicitly optional.
|
|
68
68
|
*/
|
|
69
69
|
get isOptional(): boolean;
|
|
70
70
|
/**
|
|
71
|
-
*
|
|
71
|
+
* Returns the brand for a branded type.
|
|
72
72
|
*/
|
|
73
73
|
get brand(): string | undefined;
|
|
74
74
|
/**
|
|
75
|
-
*
|
|
75
|
+
* Converts from `unknown` to `<T>`. For objects and arrays, is guaranteed
|
|
76
|
+
* to return a new entity, with any unrecognized properties removed.
|
|
77
|
+
* @param from - The `unknown` to be converted
|
|
78
|
+
* @param context - An optional conversion context of type `<TC>` to be used in
|
|
79
|
+
* the conversion.
|
|
80
|
+
* @returns A {@link Result} with a {@link Success} and a value on success or an
|
|
81
|
+
* {@link Failure} with a a message on failure.
|
|
76
82
|
*/
|
|
77
83
|
convert(from: unknown, context?: TC): Result<T>;
|
|
78
84
|
/**
|
|
79
|
-
*
|
|
85
|
+
* Converts from `unknown` to `<T>` or `undefined`, as appropriate.
|
|
86
|
+
*
|
|
87
|
+
* @remarks
|
|
88
|
+
* If `onError` is `failOnError`, the converter succeeds for
|
|
89
|
+
* `undefined` or any convertible value, but reports an error
|
|
90
|
+
* if it encounters a value that cannot be converted.
|
|
91
|
+
*
|
|
92
|
+
* If `onError` is `ignoreErrors` (default) then values that
|
|
93
|
+
* cannot be converted result in a successful return of `undefined`.
|
|
94
|
+
* @param from - The `unknown` to be converted
|
|
95
|
+
* @param context - An optional conversion context of type `<TC>` to be used in
|
|
96
|
+
* the conversion.
|
|
97
|
+
* @param onError - Specifies handling of values that cannot be converted (default `ignoreErrors`).
|
|
98
|
+
* @returns A {@link Result} with a {@link Success} and a value on success or an
|
|
99
|
+
* {@link Failure} with a a message on failure.
|
|
80
100
|
*/
|
|
81
101
|
convertOptional(from: unknown, context?: TC, onError?: OnError): Result<T | undefined>;
|
|
82
102
|
/**
|
|
83
|
-
* {@
|
|
103
|
+
* Creates a {@link Converter} for an optional value.
|
|
104
|
+
*
|
|
105
|
+
* @remarks
|
|
106
|
+
* If `onError` is `failOnError`, the resulting converter will accept `undefined`
|
|
107
|
+
* or a convertible value, but report an error if it encounters a value that cannot be
|
|
108
|
+
* converted.
|
|
109
|
+
*
|
|
110
|
+
* If `onError` is `ignoreErrors` (default) then values that cannot be converted will
|
|
111
|
+
* result in a successful return of `undefined`.
|
|
112
|
+
*
|
|
113
|
+
* @param onError - Specifies handling of values that cannot be converted (default `ignoreErrors`).
|
|
114
|
+
* @returns A new {@link Converter} returning `<T|undefined>`.
|
|
84
115
|
*/
|
|
85
116
|
optional(onError?: OnError): Converter<T | undefined, TC>;
|
|
86
117
|
/**
|
|
87
|
-
* {@
|
|
118
|
+
* Creates a {@link Converter} which applies a (possibly) mapping conversion to
|
|
119
|
+
* the converted value of this {@link Converter}.
|
|
120
|
+
* @param mapper - A function which maps from the the result type `<T>` of this
|
|
121
|
+
* converter to a new result type `<T2>`.
|
|
122
|
+
* @returns A new {@link Converter} returning `<T2>`.
|
|
88
123
|
*/
|
|
89
124
|
map<T2>(mapper: (from: T, context?: TC) => Result<T2>): Converter<T2, TC>;
|
|
90
125
|
/**
|
|
91
|
-
* {@
|
|
126
|
+
* Creates a {@link Converter} which applies an additional supplied
|
|
127
|
+
* converter to the result of this converter.
|
|
128
|
+
*
|
|
129
|
+
* @param mapConverter - The {@link Converter} to be applied to the
|
|
130
|
+
* converted result from this {@link Converter}.
|
|
131
|
+
* @returns A new {@link Converter} returning `<T2>`.
|
|
92
132
|
*/
|
|
93
133
|
mapConvert<T2>(mapConverter: Converter<T2>): Converter<T2, TC>;
|
|
94
134
|
/**
|
|
95
|
-
* {@
|
|
135
|
+
* Creates a {@link Converter} which maps the individual items of a collection
|
|
136
|
+
* resulting from this {@link Converter} using the supplied map function.
|
|
137
|
+
*
|
|
138
|
+
* @remarks
|
|
139
|
+
* Fails if `from` is not an array.
|
|
140
|
+
*
|
|
141
|
+
* @param mapper - The map function to be applied to each element of the
|
|
142
|
+
* result of this {@link Converter}.
|
|
143
|
+
* @returns A new {@link Converter} returning `<TI[]>`.
|
|
96
144
|
*/
|
|
97
145
|
mapItems<TI>(mapper: (from: unknown, context?: TC) => Result<TI>): Converter<TI[], TC>;
|
|
98
146
|
/**
|
|
99
|
-
* {@
|
|
147
|
+
* Creates a {@link Converter} which maps the individual items of a collection
|
|
148
|
+
* resulting from this {@link Converter} using the supplied {@link Converter}.
|
|
149
|
+
*
|
|
150
|
+
* @remarks
|
|
151
|
+
* Fails if `from` is not an array.
|
|
152
|
+
*
|
|
153
|
+
* @param mapConverter - The {@link Converter} to be applied to each element of the
|
|
154
|
+
* result of this {@link Converter}.
|
|
155
|
+
* @returns A new {@link Converter} returning `<TI[]>`.
|
|
100
156
|
*/
|
|
101
157
|
mapConvertItems<TI>(mapConverter: Converter<TI, unknown>): Converter<TI[], TC>;
|
|
102
158
|
/**
|
|
103
|
-
* {@
|
|
159
|
+
* Creates a {@link Converter | Converter} which applies a supplied action after
|
|
160
|
+
* conversion. The supplied action is always called regardless of success or failure
|
|
161
|
+
* of the base conversion and is allowed to mutate the return type.
|
|
162
|
+
* @param action - The action to be applied.
|
|
104
163
|
*/
|
|
105
164
|
withAction<TI>(action: (result: Result<T>, context?: TC) => Result<TI>): Converter<TI, TC>;
|
|
106
165
|
/**
|
|
107
|
-
* {@
|
|
166
|
+
* Creates a {@link Converter} which applies a supplied type guard to the conversion
|
|
167
|
+
* result.
|
|
168
|
+
* @param guard - The type guard function to apply.
|
|
169
|
+
* @param message - Optional message to be reported if the type guard fails.
|
|
170
|
+
* @returns A new {@link Converter} returning `<TI>`.
|
|
108
171
|
*/
|
|
109
172
|
withTypeGuard<TI>(guard: (from: unknown, context?: TC) => from is TI, message?: string): Converter<TI, TC>;
|
|
110
173
|
/**
|
|
111
|
-
* {@
|
|
174
|
+
* Creates a {@link Converter} which applies a supplied type guard to each member of
|
|
175
|
+
* the conversion result from this converter.
|
|
176
|
+
*
|
|
177
|
+
* @remarks
|
|
178
|
+
* Fails if the conversion result is not an array or if any member fails the
|
|
179
|
+
* type guard.
|
|
180
|
+
* @param guard - The type guard function to apply to each element.
|
|
181
|
+
* @param message - Optional message to be reported if the type guard fails.
|
|
182
|
+
* @returns A new {@link Converter} returning `<TI>`.
|
|
112
183
|
*/
|
|
113
184
|
withItemTypeGuard<TI>(guard: (from: unknown, context?: TC) => from is TI, message?: string): Converter<TI[], TC>;
|
|
114
185
|
/**
|
|
115
|
-
* {@
|
|
186
|
+
* Creates a {@link Converter} which applies an optional constraint to the result
|
|
187
|
+
* of this conversion. If this {@link Converter} (the base converter) succeeds, the new
|
|
188
|
+
* converter calls a supplied constraint evaluation function with the conversion, which
|
|
189
|
+
* fails the entire conversion if the constraint function returns either `false` or
|
|
190
|
+
* {@link Failure | Failure<T>}.
|
|
191
|
+
*
|
|
192
|
+
* @param constraint - Constraint evaluation function.
|
|
193
|
+
* @param options - {@link Conversion.ConstraintOptions | Options} for constraint evaluation.
|
|
194
|
+
* @returns A new {@link Converter} returning `<T>`.
|
|
116
195
|
*/
|
|
117
196
|
withConstraint(constraint: (val: T, context?: TC) => boolean | Result<T>, options?: ConstraintOptions): Converter<T, TC>;
|
|
118
197
|
/**
|
|
119
|
-
*
|
|
198
|
+
* Returns a converter which adds a brand to the type to prevent mismatched usage
|
|
199
|
+
* of simple types.
|
|
200
|
+
* @param brand - The brand to be applied to the result value.
|
|
201
|
+
* @returns A {@link Converter} returning `Brand<T, B>`.
|
|
120
202
|
*/
|
|
121
203
|
withBrand<B extends string>(brand: B): Converter<Brand<T, B>, TC>;
|
|
122
204
|
/**
|
|
123
|
-
*
|
|
205
|
+
* Returns a Converter which always succeeds with a default value rather than failing.
|
|
206
|
+
* @param defaultValue - The default value to use if conversion fails.
|
|
124
207
|
*/
|
|
125
208
|
withDefault<TD = T>(defaultValue: TD): DefaultingConverter<T, TD, TC>;
|
|
126
209
|
or(other: Converter<T, TC>): Converter<T, TC>;
|
|
@@ -129,7 +212,10 @@ export declare class BaseConverter<T, TC = unknown> implements Converter<T, TC>
|
|
|
129
212
|
*/
|
|
130
213
|
protected _context(supplied?: TC): TC | undefined;
|
|
131
214
|
/**
|
|
132
|
-
* {@
|
|
215
|
+
* Creates a new {@link Converter} which is derived from this one but which returns an
|
|
216
|
+
* error message formatted by the supplied formatter if the conversion fails.
|
|
217
|
+
* @param formatter - The formatter to be applied.
|
|
218
|
+
* @returns A new {@link Converter} returning `<T>`.
|
|
133
219
|
*/
|
|
134
220
|
withFormattedError(formatter: ConversionErrorFormatter<TC>): Converter<T, TC>;
|
|
135
221
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baseConverter.d.ts","sourceRoot":"","sources":["../../../src/packlets/conversion/baseConverter.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,KAAK,EAAE,MA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AC,EAAE,EAAE,KAAK,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,EACzD,OAAO,CAAC,EAAE,iBAAiB,GAC1B,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC;IAkBnB;;;;;OAKG;IACI,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;IAYxE;;;OAGG;IACI,WAAW,CAAC,EAAE,GAAG,CAAC,EAAE,YAAY,EAAE,EAAE,GAAG,mBAAmB,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC;IAIrE,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC;IAQpD;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,SAAS;IAIjD;;;;;OAKG;IACI,kBAAkB,CAAC,SAAS,EAAE,wBAAwB,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC;IAQpF;;OAEG;IACH,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe;IAQrE;;OAEG;IACH,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,IAAI;CAKxD"}
|
|
@@ -47,25 +47,45 @@ class BaseConverter {
|
|
|
47
47
|
this._brand = traits === null || traits === void 0 ? void 0 : traits.brand;
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
|
-
*
|
|
50
|
+
* Indicates whether this element is explicitly optional.
|
|
51
51
|
*/
|
|
52
52
|
get isOptional() {
|
|
53
53
|
return this._isOptional;
|
|
54
54
|
}
|
|
55
55
|
/**
|
|
56
|
-
*
|
|
56
|
+
* Returns the brand for a branded type.
|
|
57
57
|
*/
|
|
58
58
|
get brand() {
|
|
59
59
|
return this._brand;
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
62
|
-
*
|
|
62
|
+
* Converts from `unknown` to `<T>`. For objects and arrays, is guaranteed
|
|
63
|
+
* to return a new entity, with any unrecognized properties removed.
|
|
64
|
+
* @param from - The `unknown` to be converted
|
|
65
|
+
* @param context - An optional conversion context of type `<TC>` to be used in
|
|
66
|
+
* the conversion.
|
|
67
|
+
* @returns A {@link Result} with a {@link Success} and a value on success or an
|
|
68
|
+
* {@link Failure} with a a message on failure.
|
|
63
69
|
*/
|
|
64
70
|
convert(from, context) {
|
|
65
71
|
return this._converter(from, this, context !== null && context !== void 0 ? context : this._defaultContext);
|
|
66
72
|
}
|
|
67
73
|
/**
|
|
68
|
-
*
|
|
74
|
+
* Converts from `unknown` to `<T>` or `undefined`, as appropriate.
|
|
75
|
+
*
|
|
76
|
+
* @remarks
|
|
77
|
+
* If `onError` is `failOnError`, the converter succeeds for
|
|
78
|
+
* `undefined` or any convertible value, but reports an error
|
|
79
|
+
* if it encounters a value that cannot be converted.
|
|
80
|
+
*
|
|
81
|
+
* If `onError` is `ignoreErrors` (default) then values that
|
|
82
|
+
* cannot be converted result in a successful return of `undefined`.
|
|
83
|
+
* @param from - The `unknown` to be converted
|
|
84
|
+
* @param context - An optional conversion context of type `<TC>` to be used in
|
|
85
|
+
* the conversion.
|
|
86
|
+
* @param onError - Specifies handling of values that cannot be converted (default `ignoreErrors`).
|
|
87
|
+
* @returns A {@link Result} with a {@link Success} and a value on success or an
|
|
88
|
+
* {@link Failure} with a a message on failure.
|
|
69
89
|
*/
|
|
70
90
|
convertOptional(from, context, onError) {
|
|
71
91
|
const result = this._converter(from, this, this._context(context));
|
|
@@ -76,7 +96,18 @@ class BaseConverter {
|
|
|
76
96
|
return result;
|
|
77
97
|
}
|
|
78
98
|
/**
|
|
79
|
-
* {@
|
|
99
|
+
* Creates a {@link Converter} for an optional value.
|
|
100
|
+
*
|
|
101
|
+
* @remarks
|
|
102
|
+
* If `onError` is `failOnError`, the resulting converter will accept `undefined`
|
|
103
|
+
* or a convertible value, but report an error if it encounters a value that cannot be
|
|
104
|
+
* converted.
|
|
105
|
+
*
|
|
106
|
+
* If `onError` is `ignoreErrors` (default) then values that cannot be converted will
|
|
107
|
+
* result in a successful return of `undefined`.
|
|
108
|
+
*
|
|
109
|
+
* @param onError - Specifies handling of values that cannot be converted (default `ignoreErrors`).
|
|
110
|
+
* @returns A new {@link Converter} returning `<T|undefined>`.
|
|
80
111
|
*/
|
|
81
112
|
optional(onError) {
|
|
82
113
|
return new BaseConverter((from, __self, context) => {
|
|
@@ -85,7 +116,11 @@ class BaseConverter {
|
|
|
85
116
|
})._with(this._traits({ isOptional: true }));
|
|
86
117
|
}
|
|
87
118
|
/**
|
|
88
|
-
* {@
|
|
119
|
+
* Creates a {@link Converter} which applies a (possibly) mapping conversion to
|
|
120
|
+
* the converted value of this {@link Converter}.
|
|
121
|
+
* @param mapper - A function which maps from the the result type `<T>` of this
|
|
122
|
+
* converter to a new result type `<T2>`.
|
|
123
|
+
* @returns A new {@link Converter} returning `<T2>`.
|
|
89
124
|
*/
|
|
90
125
|
map(mapper) {
|
|
91
126
|
return new BaseConverter((from, __self, context) => {
|
|
@@ -97,7 +132,12 @@ class BaseConverter {
|
|
|
97
132
|
})._with(this._traits());
|
|
98
133
|
}
|
|
99
134
|
/**
|
|
100
|
-
* {@
|
|
135
|
+
* Creates a {@link Converter} which applies an additional supplied
|
|
136
|
+
* converter to the result of this converter.
|
|
137
|
+
*
|
|
138
|
+
* @param mapConverter - The {@link Converter} to be applied to the
|
|
139
|
+
* converted result from this {@link Converter}.
|
|
140
|
+
* @returns A new {@link Converter} returning `<T2>`.
|
|
101
141
|
*/
|
|
102
142
|
mapConvert(mapConverter) {
|
|
103
143
|
return new BaseConverter((from, __self, context) => {
|
|
@@ -109,7 +149,15 @@ class BaseConverter {
|
|
|
109
149
|
})._with(this._traits());
|
|
110
150
|
}
|
|
111
151
|
/**
|
|
112
|
-
* {@
|
|
152
|
+
* Creates a {@link Converter} which maps the individual items of a collection
|
|
153
|
+
* resulting from this {@link Converter} using the supplied map function.
|
|
154
|
+
*
|
|
155
|
+
* @remarks
|
|
156
|
+
* Fails if `from` is not an array.
|
|
157
|
+
*
|
|
158
|
+
* @param mapper - The map function to be applied to each element of the
|
|
159
|
+
* result of this {@link Converter}.
|
|
160
|
+
* @returns A new {@link Converter} returning `<TI[]>`.
|
|
113
161
|
*/
|
|
114
162
|
mapItems(mapper) {
|
|
115
163
|
return new BaseConverter((from, __self, context) => {
|
|
@@ -122,7 +170,15 @@ class BaseConverter {
|
|
|
122
170
|
});
|
|
123
171
|
}
|
|
124
172
|
/**
|
|
125
|
-
* {@
|
|
173
|
+
* Creates a {@link Converter} which maps the individual items of a collection
|
|
174
|
+
* resulting from this {@link Converter} using the supplied {@link Converter}.
|
|
175
|
+
*
|
|
176
|
+
* @remarks
|
|
177
|
+
* Fails if `from` is not an array.
|
|
178
|
+
*
|
|
179
|
+
* @param mapConverter - The {@link Converter} to be applied to each element of the
|
|
180
|
+
* result of this {@link Converter}.
|
|
181
|
+
* @returns A new {@link Converter} returning `<TI[]>`.
|
|
126
182
|
*/
|
|
127
183
|
mapConvertItems(mapConverter) {
|
|
128
184
|
return new BaseConverter((from, __self, context) => {
|
|
@@ -135,7 +191,10 @@ class BaseConverter {
|
|
|
135
191
|
});
|
|
136
192
|
}
|
|
137
193
|
/**
|
|
138
|
-
* {@
|
|
194
|
+
* Creates a {@link Converter | Converter} which applies a supplied action after
|
|
195
|
+
* conversion. The supplied action is always called regardless of success or failure
|
|
196
|
+
* of the base conversion and is allowed to mutate the return type.
|
|
197
|
+
* @param action - The action to be applied.
|
|
139
198
|
*/
|
|
140
199
|
withAction(action) {
|
|
141
200
|
return new BaseConverter((from, __self, context) => {
|
|
@@ -143,7 +202,11 @@ class BaseConverter {
|
|
|
143
202
|
})._with(this._traits());
|
|
144
203
|
}
|
|
145
204
|
/**
|
|
146
|
-
* {@
|
|
205
|
+
* Creates a {@link Converter} which applies a supplied type guard to the conversion
|
|
206
|
+
* result.
|
|
207
|
+
* @param guard - The type guard function to apply.
|
|
208
|
+
* @param message - Optional message to be reported if the type guard fails.
|
|
209
|
+
* @returns A new {@link Converter} returning `<TI>`.
|
|
147
210
|
*/
|
|
148
211
|
withTypeGuard(guard, message) {
|
|
149
212
|
return new BaseConverter((from, __self, context) => {
|
|
@@ -156,7 +219,15 @@ class BaseConverter {
|
|
|
156
219
|
})._with(this._traits());
|
|
157
220
|
}
|
|
158
221
|
/**
|
|
159
|
-
* {@
|
|
222
|
+
* Creates a {@link Converter} which applies a supplied type guard to each member of
|
|
223
|
+
* the conversion result from this converter.
|
|
224
|
+
*
|
|
225
|
+
* @remarks
|
|
226
|
+
* Fails if the conversion result is not an array or if any member fails the
|
|
227
|
+
* type guard.
|
|
228
|
+
* @param guard - The type guard function to apply to each element.
|
|
229
|
+
* @param message - Optional message to be reported if the type guard fails.
|
|
230
|
+
* @returns A new {@link Converter} returning `<TI>`.
|
|
160
231
|
*/
|
|
161
232
|
withItemTypeGuard(guard, message) {
|
|
162
233
|
return new BaseConverter((from, __self, context) => {
|
|
@@ -174,7 +245,15 @@ class BaseConverter {
|
|
|
174
245
|
})._with(this._traits());
|
|
175
246
|
}
|
|
176
247
|
/**
|
|
177
|
-
* {@
|
|
248
|
+
* Creates a {@link Converter} which applies an optional constraint to the result
|
|
249
|
+
* of this conversion. If this {@link Converter} (the base converter) succeeds, the new
|
|
250
|
+
* converter calls a supplied constraint evaluation function with the conversion, which
|
|
251
|
+
* fails the entire conversion if the constraint function returns either `false` or
|
|
252
|
+
* {@link Failure | Failure<T>}.
|
|
253
|
+
*
|
|
254
|
+
* @param constraint - Constraint evaluation function.
|
|
255
|
+
* @param options - {@link Conversion.ConstraintOptions | Options} for constraint evaluation.
|
|
256
|
+
* @returns A new {@link Converter} returning `<T>`.
|
|
178
257
|
*/
|
|
179
258
|
withConstraint(constraint, options) {
|
|
180
259
|
return new BaseConverter((from, __self, context) => {
|
|
@@ -193,7 +272,10 @@ class BaseConverter {
|
|
|
193
272
|
})._with(this._traits());
|
|
194
273
|
}
|
|
195
274
|
/**
|
|
196
|
-
*
|
|
275
|
+
* Returns a converter which adds a brand to the type to prevent mismatched usage
|
|
276
|
+
* of simple types.
|
|
277
|
+
* @param brand - The brand to be applied to the result value.
|
|
278
|
+
* @returns A {@link Converter} returning `Brand<T, B>`.
|
|
197
279
|
*/
|
|
198
280
|
withBrand(brand) {
|
|
199
281
|
if (this._brand) {
|
|
@@ -206,7 +288,8 @@ class BaseConverter {
|
|
|
206
288
|
})._with(this._traits({ brand }));
|
|
207
289
|
}
|
|
208
290
|
/**
|
|
209
|
-
*
|
|
291
|
+
* Returns a Converter which always succeeds with a default value rather than failing.
|
|
292
|
+
* @param defaultValue - The default value to use if conversion fails.
|
|
210
293
|
*/
|
|
211
294
|
withDefault(defaultValue) {
|
|
212
295
|
return new defaultingConverter_1.GenericDefaultingConverter(this, defaultValue);
|
|
@@ -225,7 +308,10 @@ class BaseConverter {
|
|
|
225
308
|
return supplied !== null && supplied !== void 0 ? supplied : this._defaultContext;
|
|
226
309
|
}
|
|
227
310
|
/**
|
|
228
|
-
* {@
|
|
311
|
+
* Creates a new {@link Converter} which is derived from this one but which returns an
|
|
312
|
+
* error message formatted by the supplied formatter if the conversion fails.
|
|
313
|
+
* @param formatter - The formatter to be applied.
|
|
314
|
+
* @returns A new {@link Converter} returning `<T>`.
|
|
229
315
|
*/
|
|
230
316
|
withFormattedError(formatter) {
|
|
231
317
|
return new BaseConverter((from, __self, context) => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baseConverter.js","sourceRoot":"","sources":["../../../src/packlets/conversion/baseConverter.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,kCAAmE;AASnE,+DAAmE;AAmDnE;;;GAGG;AACH,MAAa,aAAa;IAg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C,CAAC;IAC3B,CAAC;IAED;;OAEG;IACO,OAAO,CAAC,MAAiC;QACjD,uBACE,UAAU,EAAE,IAAI,CAAC,UAAU,EAC3B,KAAK,EAAE,IAAI,CAAC,KAAK,IACd,CAAC,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,EAAE,CAAC,EACjB;IACJ,CAAC;IAED;;OAEG;IACO,KAAK,CAAC,MAAgC;QAC9C,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,UAAU,KAAK,IAAI,CAAC;QAC9C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAlWD,sCAkWC","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\nimport { Brand, Result, fail, mapResults, succeed } from '../base';\nimport {\n ConstraintOptions,\n ConversionErrorFormatter,\n Converter,\n ConverterTraits,\n DefaultingConverter,\n OnError\n} from './converter';\nimport { GenericDefaultingConverter } from './defaultingConverter';\n\n/**\n * Internal helper that recursively unwraps converter and array types.\n * @internal\n */\ntype InnerInferredType<TCONV> = TCONV extends Converter<infer TTO>\n ? TTO extends Array<infer TTOELEM>\n ? InnerInferredType<TTOELEM>[]\n : TTO\n : TCONV extends Array<infer TELEM>\n ? InnerInferredType<TELEM>[]\n : TCONV;\n\n/**\n * Infers the type that will be returned by an instantiated converter. Works\n * for complex as well as simple types, including nested arrays.\n * @example `Infer<typeof Converters.mapOf(Converters.stringArray)>` is `Map<string, string[]>`\n * @public\n */\nexport type Infer<TCONV> = TCONV extends Converter<infer TTO, unknown> ? InnerInferredType<TTO> : never;\n\n/**\n * Deprecated name for {@link Conversion.Infer | Infer\n * } retained for compatibility.\n * @deprecated Use {@link Conversion.Infer | Infer} instead.\n * @public\n */\nexport type ConvertedToType<TCONV> = Infer<TCONV>;\n\n/**\n * Helper type to extract the result type from a {@link Converter | Converter}.\n * For simple single-level extraction. For complex nested types, use {@link Conversion.Infer | Infer}.\n * @public\n */\nexport type ConverterResultType<C> = C extends Converter<infer T, unknown> ? T : never;\n\n/**\n * Helper type to map a tuple of {@link Converter | Converters} to a tuple of their result types.\n * @public\n */\nexport type ConverterResultTypes<T extends readonly Converter<unknown, unknown>[]> = {\n [K in keyof T]: T[K] extends Converter<infer R, unknown> ? R : never;\n};\n\n/**\n * Function signature for a converter function.\n * @public\n */\nexport type ConverterFunc<T, TC> = (from: unknown, self: Converter<T, TC>, context?: TC) => Result<T>;\n\n/**\n * Base templated wrapper to simplify creation of new {@link Converter}s.\n * @public\n */\nexport class BaseConverter<T, TC = unknown> implements Converter<T, TC> {\n /**\n * @internal\n */\n protected readonly _defaultContext?: TC;\n /**\n * @internal\n */\n protected _isOptional: boolean = false;\n /**\n * @internal\n */\n protected _brand?: string;\n\n private readonly _converter: (from: unknown, self: Converter<T, TC>, context?: TC) => Result<T>;\n\n /**\n * Constructs a new {@link Converter} which uses the supplied function to perform the conversion.\n * @param converter - The conversion function to be applied.\n * @param defaultContext - Optional conversion context to be used by default.\n * @param traits - Optional {@link Conversion.ConverterTraits | traits} to be assigned to the resulting\n * converter.\n */\n public constructor(converter: ConverterFunc<T, TC>, defaultContext?: TC, traits?: ConverterTraits) {\n this._converter = converter;\n this._defaultContext = defaultContext;\n this._isOptional = traits?.isOptional === true;\n this._brand = traits?.brand;\n }\n\n /**\n * Indicates whether this element is explicitly optional.\n */\n public get isOptional(): boolean {\n return this._isOptional;\n }\n\n /**\n * Returns the brand for a branded type.\n */\n public get brand(): string | undefined {\n return this._brand;\n }\n\n /**\n * Converts from `unknown` to `<T>`. For objects and arrays, is guaranteed\n * to return a new entity, with any unrecognized properties removed.\n * @param from - The `unknown` to be converted\n * @param context - An optional conversion context of type `<TC>` to be used in\n * the conversion.\n * @returns A {@link Result} with a {@link Success} and a value on success or an\n * {@link Failure} with a a message on failure.\n */\n public convert(from: unknown, context?: TC): Result<T> {\n return this._converter(from, this, context ?? this._defaultContext);\n }\n\n /**\n * Converts from `unknown` to `<T>` or `undefined`, as appropriate.\n *\n * @remarks\n * If `onError` is `failOnError`, the converter succeeds for\n * `undefined` or any convertible value, but reports an error\n * if it encounters a value that cannot be converted.\n *\n * If `onError` is `ignoreErrors` (default) then values that\n * cannot be converted result in a successful return of `undefined`.\n * @param from - The `unknown` to be converted\n * @param context - An optional conversion context of type `<TC>` to be used in\n * the conversion.\n * @param onError - Specifies handling of values that cannot be converted (default `ignoreErrors`).\n * @returns A {@link Result} with a {@link Success} and a value on success or an\n * {@link Failure} with a a message on failure.\n */\n public convertOptional(from: unknown, context?: TC, onError?: OnError): Result<T | undefined> {\n const result = this._converter(from, this, this._context(context));\n if (result.isFailure()) {\n onError = onError ?? 'ignoreErrors';\n return from === undefined || onError === 'ignoreErrors' ? succeed(undefined) : result;\n }\n return result;\n }\n\n /**\n * Creates a {@link Converter} for an optional value.\n *\n * @remarks\n * If `onError` is `failOnError`, the resulting converter will accept `undefined`\n * or a convertible value, but report an error if it encounters a value that cannot be\n * converted.\n *\n * If `onError` is `ignoreErrors` (default) then values that cannot be converted will\n * result in a successful return of `undefined`.\n *\n * @param onError - Specifies handling of values that cannot be converted (default `ignoreErrors`).\n * @returns A new {@link Converter} returning `<T|undefined>`.\n */\n public optional(onError?: OnError): Converter<T | undefined, TC> {\n return new BaseConverter((from: unknown, __self: Converter<T | undefined, TC>, context?: TC) => {\n onError = onError ?? 'failOnError';\n return this.convertOptional(from, this._context(context), onError);\n })._with(this._traits({ isOptional: true }));\n }\n\n /**\n * Creates a {@link Converter} which applies a (possibly) mapping conversion to\n * the converted value of this {@link Converter}.\n * @param mapper - A function which maps from the the result type `<T>` of this\n * converter to a new result type `<T2>`.\n * @returns A new {@link Converter} returning `<T2>`.\n */\n public map<T2>(mapper: (from: T, context?: TC) => Result<T2>): Converter<T2, TC> {\n return new BaseConverter<T2, TC>((from: unknown, __self: Converter<T2, TC>, context?: TC) => {\n const innerResult = this._converter(from, this, this._context(context));\n if (innerResult.isSuccess()) {\n return mapper(innerResult.value, this._context(context));\n }\n return fail(innerResult.message);\n })._with(this._traits());\n }\n\n /**\n * Creates a {@link Converter} which applies an additional supplied\n * converter to the result of this converter.\n *\n * @param mapConverter - The {@link Converter} to be applied to the\n * converted result from this {@link Converter}.\n * @returns A new {@link Converter} returning `<T2>`.\n */\n public mapConvert<T2>(mapConverter: Converter<T2>): Converter<T2, TC> {\n return new BaseConverter<T2, TC>((from: unknown, __self: Converter<T2, TC>, context?: TC) => {\n const innerResult = this._converter(from, this, this._context(context));\n if (innerResult.isSuccess()) {\n return mapConverter.convert(innerResult.value, this._context(context));\n }\n return fail(innerResult.message);\n })._with(this._traits());\n }\n\n /**\n * Creates a {@link Converter} which maps the individual items of a collection\n * resulting from this {@link Converter} using the supplied map function.\n *\n * @remarks\n * Fails if `from` is not an array.\n *\n * @param mapper - The map function to be applied to each element of the\n * result of this {@link Converter}.\n * @returns A new {@link Converter} returning `<TI[]>`.\n */\n public mapItems<TI>(mapper: (from: unknown, context?: TC) => Result<TI>): Converter<TI[], TC> {\n return new BaseConverter<TI[], TC>((from: unknown, __self: Converter<TI[], TC>, context?: TC) => {\n return this._converter(from, this, this._context(context)).onSuccess((items) => {\n if (Array.isArray(items)) {\n return mapResults(items.map((i) => mapper(i, this._context(context))));\n }\n return fail('Cannot map items - not an array');\n });\n });\n }\n\n /**\n * Creates a {@link Converter} which maps the individual items of a collection\n * resulting from this {@link Converter} using the supplied {@link Converter}.\n *\n * @remarks\n * Fails if `from` is not an array.\n *\n * @param mapConverter - The {@link Converter} to be applied to each element of the\n * result of this {@link Converter}.\n * @returns A new {@link Converter} returning `<TI[]>`.\n */\n public mapConvertItems<TI>(mapConverter: Converter<TI, unknown>): Converter<TI[], TC> {\n return new BaseConverter<TI[], TC>((from: unknown, __self: Converter<TI[], TC>, context?: TC) => {\n return this._converter(from, this, this._context(context)).onSuccess((items) => {\n if (Array.isArray(items)) {\n return mapResults(items.map((i) => mapConverter.convert(i, this._context(context))));\n }\n return fail('Cannot map items - not an array');\n });\n });\n }\n\n /**\n * Creates a {@link Converter | Converter} which applies a supplied action after\n * conversion. The supplied action is always called regardless of success or failure\n * of the base conversion and is allowed to mutate the return type.\n * @param action - The action to be applied.\n */\n public withAction<TI>(action: (result: Result<T>, context?: TC) => Result<TI>): Converter<TI, TC> {\n return new BaseConverter<TI, TC>((from: unknown, __self: Converter<TI, TC>, context?: TC) => {\n return action(this._converter(from, this, this._context(context)), this._context(context));\n })._with(this._traits());\n }\n\n /**\n * Creates a {@link Converter} which applies a supplied type guard to the conversion\n * result.\n * @param guard - The type guard function to apply.\n * @param message - Optional message to be reported if the type guard fails.\n * @returns A new {@link Converter} returning `<TI>`.\n */\n public withTypeGuard<TI>(\n guard: (from: unknown, context?: TC) => from is TI,\n message?: string\n ): Converter<TI, TC> {\n return new BaseConverter<TI, TC>((from: unknown, __self: Converter<TI, TC>, context?: TC) => {\n return this._converter(from, this, this._context(context)).onSuccess((inner) => {\n message = message ?? 'invalid type';\n return guard(inner, this._context(context))\n ? succeed(inner)\n : fail(`${message}: ${JSON.stringify(from)}`);\n });\n })._with(this._traits());\n }\n\n /**\n * Creates a {@link Converter} which applies a supplied type guard to each member of\n * the conversion result from this converter.\n *\n * @remarks\n * Fails if the conversion result is not an array or if any member fails the\n * type guard.\n * @param guard - The type guard function to apply to each element.\n * @param message - Optional message to be reported if the type guard fails.\n * @returns A new {@link Converter} returning `<TI>`.\n */\n public withItemTypeGuard<TI>(\n guard: (from: unknown, context?: TC) => from is TI,\n message?: string\n ): Converter<TI[], TC> {\n return new BaseConverter<TI[], TC>((from: unknown, __self: Converter<TI[], TC>, context?: TC) => {\n return this._converter(from, this, this._context(context)).onSuccess((items) => {\n if (Array.isArray(items)) {\n return mapResults(\n items.map((i) => {\n message = message ?? 'invalid type';\n return guard(i, this._context(context))\n ? succeed(i)\n : fail(`${message}: ${JSON.stringify(from)}`);\n })\n );\n }\n return fail('Cannot guard item type - not an array');\n });\n })._with(this._traits());\n }\n\n /**\n * Creates a {@link Converter} which applies an optional constraint to the result\n * of this conversion. If this {@link Converter} (the base converter) succeeds, the new\n * converter calls a supplied constraint evaluation function with the conversion, which\n * fails the entire conversion if the constraint function returns either `false` or\n * {@link Failure | Failure<T>}.\n *\n * @param constraint - Constraint evaluation function.\n * @param options - {@link Conversion.ConstraintOptions | Options} for constraint evaluation.\n * @returns A new {@link Converter} returning `<T>`.\n */\n public withConstraint(\n constraint: (val: T, context?: TC) => boolean | Result<T>,\n options?: ConstraintOptions\n ): Converter<T, TC> {\n return new BaseConverter<T, TC>((from: unknown, __self: Converter<T, TC>, context?: TC) => {\n const result = this._converter(from, this, this._context(context));\n if (result.isSuccess()) {\n const constraintResult = constraint(result.value, this._context(context));\n if (typeof constraintResult === 'boolean') {\n return constraintResult\n ? result\n : fail(\n `\"${JSON.stringify(result.value)}\": ${options?.description ?? 'does not meet constraint'}`\n );\n }\n return constraintResult;\n }\n return result;\n })._with(this._traits());\n }\n\n /**\n * Returns a converter which adds a brand to the type to prevent mismatched usage\n * of simple types.\n * @param brand - The brand to be applied to the result value.\n * @returns A {@link Converter} returning `Brand<T, B>`.\n */\n public withBrand<B extends string>(brand: B): Converter<Brand<T, B>, TC> {\n if (this._brand) {\n throw new Error(`Cannot replace existing brand \"${this._brand}\" with \"${brand}\".`);\n }\n\n return new BaseConverter<Brand<T, B>, TC>((from: unknown, __self: Converter<T, TC>, context?: TC) => {\n return this._converter(from, this, this._context(context)).onSuccess((v) => {\n return succeed(v as Brand<T, B>);\n });\n })._with(this._traits({ brand }));\n }\n\n /**\n * Returns a Converter which always succeeds with a default value rather than failing.\n * @param defaultValue - The default value to use if conversion fails.\n */\n public withDefault<TD = T>(defaultValue: TD): DefaultingConverter<T, TD, TC> {\n return new GenericDefaultingConverter<T, TD, TC>(this, defaultValue);\n }\n\n public or(other: Converter<T, TC>): Converter<T, TC> {\n return new BaseConverter<T, TC>((from: unknown, __self: Converter<T, TC>, context?: TC) => {\n return this._converter(from, this, this._context(context)).onFailure(() => {\n return other.convert(from, this._context(context));\n });\n });\n }\n\n /**\n * @internal\n */\n protected _context(supplied?: TC): TC | undefined {\n return supplied ?? this._defaultContext;\n }\n\n /**\n * Creates a new {@link Converter} which is derived from this one but which returns an\n * error message formatted by the supplied formatter if the conversion fails.\n * @param formatter - The formatter to be applied.\n * @returns A new {@link Converter} returning `<T>`.\n */\n public withFormattedError(formatter: ConversionErrorFormatter<TC>): Converter<T, TC> {\n return new BaseConverter<T, TC>((from: unknown, __self: Converter<T, TC>, context?: TC) => {\n return this._converter(from, this, this._context(context)).onFailure((msg) => {\n return fail(formatter(from, msg, this._context(context)));\n });\n })._with(this._traits());\n }\n\n /**\n * @internal\n */\n protected _traits(traits?: Partial<ConverterTraits>): ConverterTraits {\n return {\n isOptional: this.isOptional,\n brand: this.brand,\n ...(traits ?? {})\n };\n }\n\n /**\n * @internal\n */\n protected _with(traits: Partial<ConverterTraits>): this {\n this._isOptional = traits.isOptional === true;\n this._brand = traits.brand;\n return this;\n }\n}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