@fgv/ts-utils 5.0.0-2 → 5.0.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/.vscode/launch.json +16 -0
- package/.vscode/settings.json +36 -0
- package/config/api-extractor.json +343 -0
- package/config/rig.json +16 -0
- package/dist/ts-utils.d.ts +20 -8
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/packlets/base/result.d.ts +8 -0
- package/lib/packlets/base/result.js +11 -0
- package/lib/packlets/hash/crcNormalizer.js +3 -1
- package/lib/packlets/validation/array.d.ts +2 -1
- package/lib/packlets/validation/array.js +2 -1
- package/lib/packlets/validation/common.d.ts +0 -8
- package/lib/packlets/validation/field.d.ts +1 -1
- package/lib/packlets/validation/field.js +1 -1
- package/lib/packlets/validation/genericValidator.d.ts +1 -6
- package/lib/packlets/validation/genericValidator.js +11 -11
- package/lib/packlets/validation/object.d.ts +1 -1
- package/lib/packlets/validation/object.js +1 -1
- package/lib/packlets/validation/oneOf.d.ts +2 -1
- package/lib/packlets/validation/oneOf.js +2 -1
- package/lib/packlets/validation/typeGuard.d.ts +3 -2
- package/lib/packlets/validation/typeGuard.js +2 -1
- package/lib/packlets/validation/validator.d.ts +7 -0
- package/lib/packlets/validation/validatorBase.d.ts +2 -1
- package/lib/packlets/validation/validatorBase.js +1 -1
- package/lib/packlets/validation/validators.d.ts +2 -2
- package/lib/packlets/validation/validators.js +3 -3
- package/lib/test/helpers/jest/helpers/fsHelpers.d.ts +52 -0
- package/lib/test/helpers/jest/helpers/fsHelpers.js +180 -0
- package/lib/test/helpers/jest/helpers/index.d.ts +2 -0
- package/lib/test/helpers/jest/helpers/index.js +18 -0
- package/lib/test/helpers/jest/index.d.ts +3 -0
- package/lib/test/helpers/jest/index.js +27 -0
- package/lib/test/helpers/jest/matchers/index.d.ts +16 -0
- package/lib/test/helpers/jest/matchers/index.js +19 -0
- package/lib/test/helpers/jest/matchers/toFail/index.d.ts +16 -0
- package/lib/test/helpers/jest/matchers/toFail/index.js +25 -0
- package/lib/test/helpers/jest/matchers/toFail/predicate.d.ts +4 -0
- package/lib/test/helpers/jest/matchers/toFail/predicate.js +9 -0
- package/lib/test/helpers/jest/matchers/toFailTest/index.d.ts +16 -0
- package/lib/test/helpers/jest/matchers/toFailTest/index.js +30 -0
- package/lib/test/helpers/jest/matchers/toFailTest/predicate.d.ts +3 -0
- package/lib/test/helpers/jest/matchers/toFailTest/predicate.js +12 -0
- package/lib/test/helpers/jest/matchers/toFailTestAndMatchSnapshot/index.d.ts +17 -0
- package/lib/test/helpers/jest/matchers/toFailTestAndMatchSnapshot/index.js +26 -0
- package/lib/test/helpers/jest/matchers/toFailTestAndMatchSnapshot/predicate.d.ts +4 -0
- package/lib/test/helpers/jest/matchers/toFailTestAndMatchSnapshot/predicate.js +15 -0
- package/lib/test/helpers/jest/matchers/toFailTestWith/index.d.ts +18 -0
- package/lib/test/helpers/jest/matchers/toFailTestWith/index.js +31 -0
- package/lib/test/helpers/jest/matchers/toFailTestWith/predicate.d.ts +4 -0
- package/lib/test/helpers/jest/matchers/toFailTestWith/predicate.js +30 -0
- package/lib/test/helpers/jest/matchers/toFailWith/index.d.ts +18 -0
- package/lib/test/helpers/jest/matchers/toFailWith/index.js +29 -0
- package/lib/test/helpers/jest/matchers/toFailWith/predicate.d.ts +4 -0
- package/lib/test/helpers/jest/matchers/toFailWith/predicate.js +20 -0
- package/lib/test/helpers/jest/matchers/toFailWithDetail/index.d.ts +19 -0
- package/lib/test/helpers/jest/matchers/toFailWithDetail/index.js +29 -0
- package/lib/test/helpers/jest/matchers/toFailWithDetail/predicate.d.ts +4 -0
- package/lib/test/helpers/jest/matchers/toFailWithDetail/predicate.js +26 -0
- package/lib/test/helpers/jest/matchers/toSucceed/index.d.ts +16 -0
- package/lib/test/helpers/jest/matchers/toSucceed/index.js +25 -0
- package/lib/test/helpers/jest/matchers/toSucceed/predicate.d.ts +4 -0
- package/lib/test/helpers/jest/matchers/toSucceed/predicate.js +9 -0
- package/lib/test/helpers/jest/matchers/toSucceedAndMatchInlineSnapshot/index.d.ts +17 -0
- package/lib/test/helpers/jest/matchers/toSucceedAndMatchInlineSnapshot/index.js +26 -0
- package/lib/test/helpers/jest/matchers/toSucceedAndMatchSnapshot/index.d.ts +17 -0
- package/lib/test/helpers/jest/matchers/toSucceedAndMatchSnapshot/index.js +26 -0
- package/lib/test/helpers/jest/matchers/toSucceedAndSatisfy/index.d.ts +19 -0
- package/lib/test/helpers/jest/matchers/toSucceedAndSatisfy/index.js +55 -0
- package/lib/test/helpers/jest/matchers/toSucceedAndSatisfy/predicate.d.ts +4 -0
- package/lib/test/helpers/jest/matchers/toSucceedAndSatisfy/predicate.js +21 -0
- package/lib/test/helpers/jest/matchers/toSucceedWith/index.d.ts +18 -0
- package/lib/test/helpers/jest/matchers/toSucceedWith/index.js +29 -0
- package/lib/test/helpers/jest/matchers/toSucceedWith/predicate.d.ts +4 -0
- package/lib/test/helpers/jest/matchers/toSucceedWith/predicate.js +16 -0
- package/lib/test/helpers/jest/matchers/toSucceedWithDetail/index.d.ts +18 -0
- package/lib/test/helpers/jest/matchers/toSucceedWithDetail/index.js +29 -0
- package/lib/test/helpers/jest/matchers/toSucceedWithDetail/predicate.d.ts +4 -0
- package/lib/test/helpers/jest/matchers/toSucceedWithDetail/predicate.js +21 -0
- package/lib/test/helpers/jest/resolvers/cli.d.ts +5 -0
- package/lib/test/helpers/jest/resolvers/cli.js +48 -0
- package/lib/test/helpers/jest/resolvers/ide.d.ts +5 -0
- package/lib/test/helpers/jest/resolvers/ide.js +48 -0
- package/lib/test/helpers/jest/ts-utils.d.ts +2 -0
- package/lib/test/helpers/jest/ts-utils.js +18 -0
- package/lib/test/helpers/jest/types/index.d.ts +79 -0
- package/lib/test/helpers/jest/types/index.js +4 -0
- package/lib/test/helpers/jest/utils/matcherHelpers.d.ts +6 -0
- package/lib/test/helpers/jest/utils/matcherHelpers.js +53 -0
- package/lib/test/helpers/jest/utils/snapshotResolver.d.ts +4 -0
- package/lib/test/helpers/jest/utils/snapshotResolver.js +19 -0
- package/lib/test/unit/collections/collectible.test.d.ts +2 -0
- package/lib/test/unit/collections/collector.test.d.ts +2 -0
- package/lib/test/unit/collections/collectors.test.d.ts +2 -0
- package/lib/test/unit/collections/convertingCollector.test.d.ts +2 -0
- package/lib/test/unit/collections/helpers.d.ts +44 -0
- package/lib/test/unit/collections/helpers.js +115 -0
- package/lib/test/unit/collections/resultMap.test.d.ts +2 -0
- package/lib/test/unit/collections/validatingCollector.test.d.ts +2 -0
- package/lib/test/unit/collections/validatingConvertingCollector.test.d.ts +2 -0
- package/lib/test/unit/collections/validatingResultMap.test.d.ts +2 -0
- package/lib/test/unit/converter.test.d.ts +2 -0
- package/lib/test/unit/converters.test.d.ts +2 -0
- package/lib/test/unit/defaultingConverter.test.d.ts +2 -0
- package/lib/test/unit/file-tree/fileItem.test.d.ts +2 -0
- package/lib/test/unit/file-tree/fileTree.test.d.ts +2 -0
- package/lib/test/unit/file-tree/fsTree.test.d.ts +2 -0
- package/lib/test/unit/file-tree/inMemoryTree.test.d.ts +2 -0
- package/lib/test/unit/file-tree/sample/rootFile.json +1 -0
- package/lib/test/unit/file-tree/sample/some/other/path/file2.json +1 -0
- package/lib/test/unit/file-tree/sample/some/path/below/file4.json +1 -0
- package/lib/test/unit/file-tree/sample/some/path/file1.json +1 -0
- package/lib/test/unit/file-tree/sample/some/path/file3.json +1 -0
- package/lib/test/unit/hash.test.d.ts +2 -0
- package/lib/test/unit/logger.test.d.ts +2 -0
- package/lib/test/unit/mapResults.test.d.ts +3 -0
- package/lib/test/unit/messageAggregator.test.d.ts +3 -0
- package/lib/test/unit/normalize.test.d.ts +2 -0
- package/lib/test/unit/result.test.d.ts +3 -0
- package/lib/test/unit/utils.test.d.ts +3 -0
- package/lib/test/unit/validation/array.test.d.ts +2 -0
- package/lib/test/unit/validation/boolean.test.d.ts +2 -0
- package/lib/test/unit/validation/genericValidator.test.d.ts +2 -0
- package/lib/test/unit/validation/number.test.d.ts +2 -0
- package/lib/test/unit/validation/object.test.d.ts +2 -0
- package/lib/test/unit/validation/oneOf.test.d.ts +2 -0
- package/lib/test/unit/validation/recordOf.test.d.ts +2 -0
- package/lib/test/unit/validation/recursiveValidation.test.d.ts +2 -0
- package/lib/test/unit/validation/string.test.d.ts +2 -0
- package/lib/test/unit/validation/traits.test.d.ts +2 -0
- package/lib/test/unit/validation/typeGuard.test.d.ts +2 -0
- package/lib/test/unit/validation/validators.test.d.ts +2 -0
- package/package.json +9 -9
- package/src/index.ts +63 -0
- package/src/packlets/base/brand.ts +28 -0
- package/src/packlets/base/index.ts +31 -0
- package/src/packlets/base/logger.ts +156 -0
- package/src/packlets/base/mapResults.ts +302 -0
- package/src/packlets/base/messageAggregator.ts +120 -0
- package/src/packlets/base/normalize.ts +144 -0
- package/src/packlets/base/result.ts +961 -0
- package/src/packlets/base/utils.ts +236 -0
- package/src/packlets/collections/collectible.ts +238 -0
- package/src/packlets/collections/collector.ts +273 -0
- package/src/packlets/collections/collectorValidator.ts +178 -0
- package/src/packlets/collections/common.ts +27 -0
- package/src/packlets/collections/convertingCollector.ts +223 -0
- package/src/packlets/collections/convertingCollectorValidator.ts +164 -0
- package/src/packlets/collections/index.ts +39 -0
- package/src/packlets/collections/keyValueConverters.ts +142 -0
- package/src/packlets/collections/readonlyResultMap.ts +99 -0
- package/src/packlets/collections/resultMap.ts +322 -0
- package/src/packlets/collections/resultMapValidator.ts +188 -0
- package/src/packlets/collections/utils.ts +33 -0
- package/src/packlets/collections/validatingCollector.ts +123 -0
- package/src/packlets/collections/validatingConvertingCollector.ts +113 -0
- package/src/packlets/collections/validatingResultMap.ts +94 -0
- package/src/packlets/conversion/baseConverter.ts +330 -0
- package/src/packlets/conversion/converter.ts +260 -0
- package/src/packlets/conversion/converters.ts +1039 -0
- package/src/packlets/conversion/defaultingConverter.ts +188 -0
- package/src/packlets/conversion/index.ts +30 -0
- package/src/packlets/conversion/objectConverter.ts +259 -0
- package/src/packlets/conversion/stringConverter.ts +165 -0
- package/src/packlets/file-tree/directoryItem.ts +84 -0
- package/src/packlets/file-tree/fileItem.ts +119 -0
- package/src/packlets/file-tree/fileTree.ts +152 -0
- package/src/packlets/file-tree/fileTreeAccessors.ts +176 -0
- package/src/packlets/file-tree/fsTree.ts +118 -0
- package/src/packlets/file-tree/in-memory/inMemoryTree.ts +171 -0
- package/src/packlets/file-tree/in-memory/index.ts +23 -0
- package/src/packlets/file-tree/in-memory/treeBuilder.ts +203 -0
- package/src/packlets/file-tree/index.ts +31 -0
- package/src/packlets/hash/crcNormalizer.ts +81 -0
- package/src/packlets/hash/hashingNormalizer.ts +102 -0
- package/src/packlets/hash/index.ts +24 -0
- package/src/packlets/validation/array.ts +84 -0
- package/src/packlets/validation/boolean.ts +63 -0
- package/src/packlets/validation/classes.ts +38 -0
- package/src/packlets/validation/common.ts +28 -0
- package/src/packlets/validation/field.ts +99 -0
- package/src/packlets/validation/genericValidator.ts +204 -0
- package/src/packlets/validation/index.ts +31 -0
- package/src/packlets/validation/number.ts +66 -0
- package/src/packlets/validation/object.ts +208 -0
- package/src/packlets/validation/oneOf.ts +78 -0
- package/src/packlets/validation/string.ts +66 -0
- package/src/packlets/validation/traits.ts +113 -0
- package/src/packlets/validation/typeGuard.ts +83 -0
- package/src/packlets/validation/validator.ts +157 -0
- package/src/packlets/validation/validatorBase.ts +66 -0
- package/src/packlets/validation/validators.ts +254 -0
- package/CHANGELOG.md +0 -135
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/packlets/base/brand.d.ts.map +0 -1
- package/lib/packlets/base/brand.js.map +0 -1
- package/lib/packlets/base/index.d.ts.map +0 -1
- package/lib/packlets/base/index.js.map +0 -1
- package/lib/packlets/base/logger.d.ts.map +0 -1
- package/lib/packlets/base/logger.js.map +0 -1
- package/lib/packlets/base/mapResults.d.ts.map +0 -1
- package/lib/packlets/base/mapResults.js.map +0 -1
- package/lib/packlets/base/messageAggregator.d.ts.map +0 -1
- package/lib/packlets/base/messageAggregator.js.map +0 -1
- package/lib/packlets/base/normalize.d.ts.map +0 -1
- package/lib/packlets/base/normalize.js.map +0 -1
- package/lib/packlets/base/result.d.ts.map +0 -1
- package/lib/packlets/base/result.js.map +0 -1
- package/lib/packlets/base/utils.d.ts.map +0 -1
- package/lib/packlets/base/utils.js.map +0 -1
- package/lib/packlets/collections/collectible.d.ts.map +0 -1
- package/lib/packlets/collections/collectible.js.map +0 -1
- package/lib/packlets/collections/collector.d.ts.map +0 -1
- package/lib/packlets/collections/collector.js.map +0 -1
- package/lib/packlets/collections/collectorValidator.d.ts.map +0 -1
- package/lib/packlets/collections/collectorValidator.js.map +0 -1
- package/lib/packlets/collections/common.d.ts.map +0 -1
- package/lib/packlets/collections/common.js.map +0 -1
- package/lib/packlets/collections/convertingCollector.d.ts.map +0 -1
- package/lib/packlets/collections/convertingCollector.js.map +0 -1
- package/lib/packlets/collections/convertingCollectorValidator.d.ts.map +0 -1
- package/lib/packlets/collections/convertingCollectorValidator.js.map +0 -1
- package/lib/packlets/collections/index.d.ts.map +0 -1
- package/lib/packlets/collections/index.js.map +0 -1
- package/lib/packlets/collections/keyValueConverters.d.ts.map +0 -1
- package/lib/packlets/collections/keyValueConverters.js.map +0 -1
- package/lib/packlets/collections/readonlyResultMap.d.ts.map +0 -1
- package/lib/packlets/collections/readonlyResultMap.js.map +0 -1
- package/lib/packlets/collections/resultMap.d.ts.map +0 -1
- package/lib/packlets/collections/resultMap.js.map +0 -1
- package/lib/packlets/collections/resultMapValidator.d.ts.map +0 -1
- package/lib/packlets/collections/resultMapValidator.js.map +0 -1
- package/lib/packlets/collections/utils.d.ts.map +0 -1
- package/lib/packlets/collections/utils.js.map +0 -1
- package/lib/packlets/collections/validatingCollector.d.ts.map +0 -1
- package/lib/packlets/collections/validatingCollector.js.map +0 -1
- package/lib/packlets/collections/validatingConvertingCollector.d.ts.map +0 -1
- package/lib/packlets/collections/validatingConvertingCollector.js.map +0 -1
- package/lib/packlets/collections/validatingResultMap.d.ts.map +0 -1
- package/lib/packlets/collections/validatingResultMap.js.map +0 -1
- package/lib/packlets/conversion/baseConverter.d.ts.map +0 -1
- package/lib/packlets/conversion/baseConverter.js.map +0 -1
- package/lib/packlets/conversion/converter.d.ts.map +0 -1
- package/lib/packlets/conversion/converter.js.map +0 -1
- package/lib/packlets/conversion/converters.d.ts.map +0 -1
- package/lib/packlets/conversion/converters.js.map +0 -1
- package/lib/packlets/conversion/defaultingConverter.d.ts.map +0 -1
- package/lib/packlets/conversion/defaultingConverter.js.map +0 -1
- package/lib/packlets/conversion/index.d.ts.map +0 -1
- package/lib/packlets/conversion/index.js.map +0 -1
- package/lib/packlets/conversion/objectConverter.d.ts.map +0 -1
- package/lib/packlets/conversion/objectConverter.js.map +0 -1
- package/lib/packlets/conversion/stringConverter.d.ts.map +0 -1
- package/lib/packlets/conversion/stringConverter.js.map +0 -1
- package/lib/packlets/file-tree/directoryItem.d.ts.map +0 -1
- package/lib/packlets/file-tree/directoryItem.js.map +0 -1
- package/lib/packlets/file-tree/fileItem.d.ts.map +0 -1
- package/lib/packlets/file-tree/fileItem.js.map +0 -1
- package/lib/packlets/file-tree/fileTree.d.ts.map +0 -1
- package/lib/packlets/file-tree/fileTree.js.map +0 -1
- package/lib/packlets/file-tree/fileTreeAccessors.d.ts.map +0 -1
- package/lib/packlets/file-tree/fileTreeAccessors.js.map +0 -1
- package/lib/packlets/file-tree/fsTree.d.ts.map +0 -1
- package/lib/packlets/file-tree/fsTree.js.map +0 -1
- package/lib/packlets/file-tree/in-memory/inMemoryTree.d.ts.map +0 -1
- package/lib/packlets/file-tree/in-memory/inMemoryTree.js.map +0 -1
- package/lib/packlets/file-tree/in-memory/index.d.ts.map +0 -1
- package/lib/packlets/file-tree/in-memory/index.js.map +0 -1
- package/lib/packlets/file-tree/in-memory/treeBuilder.d.ts.map +0 -1
- package/lib/packlets/file-tree/in-memory/treeBuilder.js.map +0 -1
- package/lib/packlets/file-tree/index.d.ts.map +0 -1
- package/lib/packlets/file-tree/index.js.map +0 -1
- package/lib/packlets/hash/crcNormalizer.d.ts.map +0 -1
- package/lib/packlets/hash/crcNormalizer.js.map +0 -1
- package/lib/packlets/hash/hashingNormalizer.d.ts.map +0 -1
- package/lib/packlets/hash/hashingNormalizer.js.map +0 -1
- package/lib/packlets/hash/index.d.ts.map +0 -1
- package/lib/packlets/hash/index.js.map +0 -1
- package/lib/packlets/validation/array.d.ts.map +0 -1
- package/lib/packlets/validation/array.js.map +0 -1
- package/lib/packlets/validation/boolean.d.ts.map +0 -1
- package/lib/packlets/validation/boolean.js.map +0 -1
- package/lib/packlets/validation/classes.d.ts.map +0 -1
- package/lib/packlets/validation/classes.js.map +0 -1
- package/lib/packlets/validation/common.d.ts.map +0 -1
- package/lib/packlets/validation/common.js.map +0 -1
- package/lib/packlets/validation/field.d.ts.map +0 -1
- package/lib/packlets/validation/field.js.map +0 -1
- package/lib/packlets/validation/genericValidator.d.ts.map +0 -1
- package/lib/packlets/validation/genericValidator.js.map +0 -1
- package/lib/packlets/validation/index.d.ts.map +0 -1
- package/lib/packlets/validation/index.js.map +0 -1
- package/lib/packlets/validation/number.d.ts.map +0 -1
- package/lib/packlets/validation/number.js.map +0 -1
- package/lib/packlets/validation/object.d.ts.map +0 -1
- package/lib/packlets/validation/object.js.map +0 -1
- package/lib/packlets/validation/oneOf.d.ts.map +0 -1
- package/lib/packlets/validation/oneOf.js.map +0 -1
- package/lib/packlets/validation/string.d.ts.map +0 -1
- package/lib/packlets/validation/string.js.map +0 -1
- package/lib/packlets/validation/traits.d.ts.map +0 -1
- package/lib/packlets/validation/traits.js.map +0 -1
- package/lib/packlets/validation/typeGuard.d.ts.map +0 -1
- package/lib/packlets/validation/typeGuard.js.map +0 -1
- package/lib/packlets/validation/validator.d.ts.map +0 -1
- package/lib/packlets/validation/validator.js.map +0 -1
- package/lib/packlets/validation/validatorBase.d.ts.map +0 -1
- package/lib/packlets/validation/validatorBase.js.map +0 -1
- package/lib/packlets/validation/validators.d.ts.map +0 -1
- package/lib/packlets/validation/validators.js.map +0 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
// Use IntelliSense to learn about possible attributes.
|
|
3
|
+
// Hover to view descriptions of existing attributes.
|
|
4
|
+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
5
|
+
"version": "0.2.0",
|
|
6
|
+
"configurations": [
|
|
7
|
+
{
|
|
8
|
+
"type": "node",
|
|
9
|
+
"request": "launch",
|
|
10
|
+
"name": "Launch Program",
|
|
11
|
+
"skipFiles": ["<node_internals>/**"],
|
|
12
|
+
"program": "${workspaceFolder}/lib/index.js",
|
|
13
|
+
"outFiles": ["${workspaceFolder}/**/*.js"]
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"typescript.tsdk": "node_modules\\typescript\\lib",
|
|
3
|
+
"search.exclude": {
|
|
4
|
+
"**/boneyard": true
|
|
5
|
+
},
|
|
6
|
+
"files.exclude": {
|
|
7
|
+
"**/boneyard/**/*.ts": true
|
|
8
|
+
},
|
|
9
|
+
"cSpell.words": [
|
|
10
|
+
"badp",
|
|
11
|
+
"convalidate",
|
|
12
|
+
"Convalidator",
|
|
13
|
+
"dflt",
|
|
14
|
+
"Eulers",
|
|
15
|
+
"fixlint",
|
|
16
|
+
"flintstone",
|
|
17
|
+
"furst",
|
|
18
|
+
"jetson",
|
|
19
|
+
"luxon",
|
|
20
|
+
"nums",
|
|
21
|
+
"oopsy",
|
|
22
|
+
"packlets",
|
|
23
|
+
"papaparse",
|
|
24
|
+
"prefixp",
|
|
25
|
+
"TCONV",
|
|
26
|
+
"TDEST",
|
|
27
|
+
"TELEM",
|
|
28
|
+
"TINDEX",
|
|
29
|
+
"TITEM",
|
|
30
|
+
"TKEY",
|
|
31
|
+
"TSRC",
|
|
32
|
+
"TTOELEM",
|
|
33
|
+
"Unvalidated",
|
|
34
|
+
"xyzzy"
|
|
35
|
+
]
|
|
36
|
+
}
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config file for API Extractor. For more info, please visit: https://api-extractor.com
|
|
3
|
+
*/
|
|
4
|
+
{
|
|
5
|
+
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
|
6
|
+
/**
|
|
7
|
+
* Optionally specifies another JSON config file that this file extends from. This provides a way for
|
|
8
|
+
* standard settings to be shared across multiple projects.
|
|
9
|
+
*
|
|
10
|
+
* If the path starts with "./" or "../", the path is resolved relative to the folder of the file that contains
|
|
11
|
+
* the "extends" field. Otherwise, the first path segment is interpreted as an NPM package name, and will be
|
|
12
|
+
* resolved using NodeJS require().
|
|
13
|
+
*
|
|
14
|
+
* SUPPORTED TOKENS: none
|
|
15
|
+
* DEFAULT VALUE: ""
|
|
16
|
+
*/
|
|
17
|
+
// "extends": "./shared/api-extractor-base.json"
|
|
18
|
+
// "extends": "my-package/include/api-extractor-base.json"
|
|
19
|
+
/**
|
|
20
|
+
* Determines the "<projectFolder>" token that can be used with other config file settings. The project folder
|
|
21
|
+
* typically contains the tsconfig.json and package.json config files, but the path is user-defined.
|
|
22
|
+
*
|
|
23
|
+
* The path is resolved relative to the folder of the config file that contains the setting.
|
|
24
|
+
*
|
|
25
|
+
* The default value for "projectFolder" is the token "<lookup>", which means the folder is determined by traversing
|
|
26
|
+
* parent folders, starting from the folder containing api-extractor.json, and stopping at the first folder
|
|
27
|
+
* that contains a tsconfig.json file. If a tsconfig.json file cannot be found in this way, then an error
|
|
28
|
+
* will be reported.
|
|
29
|
+
*
|
|
30
|
+
* SUPPORTED TOKENS: <lookup>
|
|
31
|
+
* DEFAULT VALUE: "<lookup>"
|
|
32
|
+
*/
|
|
33
|
+
"projectFolder": "..",
|
|
34
|
+
/**
|
|
35
|
+
* (REQUIRED) Specifies the .d.ts file to be used as the starting point for analysis. API Extractor
|
|
36
|
+
* analyzes the symbols exported by this module.
|
|
37
|
+
*
|
|
38
|
+
* The file extension must be ".d.ts" and not ".ts".
|
|
39
|
+
*
|
|
40
|
+
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
|
41
|
+
* prepend a folder token such as "<projectFolder>".
|
|
42
|
+
*
|
|
43
|
+
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
|
|
44
|
+
*/
|
|
45
|
+
"mainEntryPointFilePath": "<projectFolder>/lib/index.d.ts",
|
|
46
|
+
/**
|
|
47
|
+
* A list of NPM package names whose exports should be treated as part of this package.
|
|
48
|
+
*
|
|
49
|
+
* For example, suppose that Webpack is used to generate a distributed bundle for the project "library1",
|
|
50
|
+
* and another NPM package "library2" is embedded in this bundle. Some types from library2 may become part
|
|
51
|
+
* of the exported API for library1, but by default API Extractor would generate a .d.ts rollup that explicitly
|
|
52
|
+
* imports library2. To avoid this, we can specify:
|
|
53
|
+
*
|
|
54
|
+
* "bundledPackages": [ "library2" ],
|
|
55
|
+
*
|
|
56
|
+
* This would direct API Extractor to embed those types directly in the .d.ts rollup, as if they had been
|
|
57
|
+
* local files for library1.
|
|
58
|
+
*/
|
|
59
|
+
"bundledPackages": [],
|
|
60
|
+
/**
|
|
61
|
+
* Determines how the TypeScript compiler engine will be invoked by API Extractor.
|
|
62
|
+
*/
|
|
63
|
+
"compiler": {
|
|
64
|
+
/**
|
|
65
|
+
* Specifies the path to the tsconfig.json file to be used by API Extractor when analyzing the project.
|
|
66
|
+
*
|
|
67
|
+
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
|
68
|
+
* prepend a folder token such as "<projectFolder>".
|
|
69
|
+
*
|
|
70
|
+
* Note: This setting will be ignored if "overrideTsconfig" is used.
|
|
71
|
+
*
|
|
72
|
+
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
|
|
73
|
+
* DEFAULT VALUE: "<projectFolder>/tsconfig.json"
|
|
74
|
+
*/
|
|
75
|
+
// "tsconfigFilePath": "<projectFolder>/tsconfig.json",
|
|
76
|
+
/**
|
|
77
|
+
* Provides a compiler configuration that will be used instead of reading the tsconfig.json file from disk.
|
|
78
|
+
* The object must conform to the TypeScript tsconfig schema:
|
|
79
|
+
*
|
|
80
|
+
* http://json.schemastore.org/tsconfig
|
|
81
|
+
*
|
|
82
|
+
* If omitted, then the tsconfig.json file will be read from the "projectFolder".
|
|
83
|
+
*
|
|
84
|
+
* DEFAULT VALUE: no overrideTsconfig section
|
|
85
|
+
*/
|
|
86
|
+
// "overrideTsconfig": {
|
|
87
|
+
// . . .
|
|
88
|
+
// }
|
|
89
|
+
/**
|
|
90
|
+
* This option causes the compiler to be invoked with the --skipLibCheck option. This option is not recommended
|
|
91
|
+
* and may cause API Extractor to produce incomplete or incorrect declarations, but it may be required when
|
|
92
|
+
* dependencies contain declarations that are incompatible with the TypeScript engine that API Extractor uses
|
|
93
|
+
* for its analysis. Where possible, the underlying issue should be fixed rather than relying on skipLibCheck.
|
|
94
|
+
*
|
|
95
|
+
* DEFAULT VALUE: false
|
|
96
|
+
*/
|
|
97
|
+
// "skipLibCheck": true,
|
|
98
|
+
},
|
|
99
|
+
/**
|
|
100
|
+
* Configures how the API report file (*.api.md) will be generated.
|
|
101
|
+
*/
|
|
102
|
+
"apiReport": {
|
|
103
|
+
/**
|
|
104
|
+
* (REQUIRED) Whether to generate an API report.
|
|
105
|
+
*/
|
|
106
|
+
"enabled": true
|
|
107
|
+
/**
|
|
108
|
+
* The filename for the API report files. It will be combined with "reportFolder" or "reportTempFolder" to produce
|
|
109
|
+
* a full file path.
|
|
110
|
+
*
|
|
111
|
+
* The file extension should be ".api.md", and the string should not contain a path separator such as "\" or "/".
|
|
112
|
+
*
|
|
113
|
+
* SUPPORTED TOKENS: <packageName>, <unscopedPackageName>
|
|
114
|
+
* DEFAULT VALUE: "<unscopedPackageName>.api.md"
|
|
115
|
+
*/
|
|
116
|
+
// "reportFileName": "<unscopedPackageName>.api.md",
|
|
117
|
+
/**
|
|
118
|
+
* Specifies the folder where the API report file is written. The file name portion is determined by
|
|
119
|
+
* the "reportFileName" setting.
|
|
120
|
+
*
|
|
121
|
+
* The API report file is normally tracked by Git. Changes to it can be used to trigger a branch policy,
|
|
122
|
+
* e.g. for an API review.
|
|
123
|
+
*
|
|
124
|
+
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
|
125
|
+
* prepend a folder token such as "<projectFolder>".
|
|
126
|
+
*
|
|
127
|
+
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
|
|
128
|
+
* DEFAULT VALUE: "<projectFolder>/etc/"
|
|
129
|
+
*/
|
|
130
|
+
// "reportFolder": "<projectFolder>/etc/",
|
|
131
|
+
/**
|
|
132
|
+
* Specifies the folder where the temporary report file is written. The file name portion is determined by
|
|
133
|
+
* the "reportFileName" setting.
|
|
134
|
+
*
|
|
135
|
+
* After the temporary file is written to disk, it is compared with the file in the "reportFolder".
|
|
136
|
+
* If they are different, a production build will fail.
|
|
137
|
+
*
|
|
138
|
+
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
|
139
|
+
* prepend a folder token such as "<projectFolder>".
|
|
140
|
+
*
|
|
141
|
+
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
|
|
142
|
+
* DEFAULT VALUE: "<projectFolder>/temp/"
|
|
143
|
+
*/
|
|
144
|
+
// "reportTempFolder": "<projectFolder>/temp/"
|
|
145
|
+
},
|
|
146
|
+
/**
|
|
147
|
+
* Configures how the doc model file (*.api.json) will be generated.
|
|
148
|
+
*/
|
|
149
|
+
"docModel": {
|
|
150
|
+
/**
|
|
151
|
+
* (REQUIRED) Whether to generate a doc model file.
|
|
152
|
+
*/
|
|
153
|
+
"enabled": true
|
|
154
|
+
/**
|
|
155
|
+
* The output path for the doc model file. The file extension should be ".api.json".
|
|
156
|
+
*
|
|
157
|
+
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
|
158
|
+
* prepend a folder token such as "<projectFolder>".
|
|
159
|
+
*
|
|
160
|
+
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
|
|
161
|
+
* DEFAULT VALUE: "<projectFolder>/temp/<unscopedPackageName>.api.json"
|
|
162
|
+
*/
|
|
163
|
+
// "apiJsonFilePath": "<projectFolder>/temp/<unscopedPackageName>.api.json"
|
|
164
|
+
},
|
|
165
|
+
/**
|
|
166
|
+
* Configures how the .d.ts rollup file will be generated.
|
|
167
|
+
*/
|
|
168
|
+
"dtsRollup": {
|
|
169
|
+
/**
|
|
170
|
+
* (REQUIRED) Whether to generate the .d.ts rollup file.
|
|
171
|
+
*/
|
|
172
|
+
"enabled": true
|
|
173
|
+
/**
|
|
174
|
+
* Specifies the output path for a .d.ts rollup file to be generated without any trimming.
|
|
175
|
+
* This file will include all declarations that are exported by the main entry point.
|
|
176
|
+
*
|
|
177
|
+
* If the path is an empty string, then this file will not be written.
|
|
178
|
+
*
|
|
179
|
+
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
|
180
|
+
* prepend a folder token such as "<projectFolder>".
|
|
181
|
+
*
|
|
182
|
+
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
|
|
183
|
+
* DEFAULT VALUE: "<projectFolder>/dist/<unscopedPackageName>.d.ts"
|
|
184
|
+
*/
|
|
185
|
+
// "untrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>.d.ts",
|
|
186
|
+
/**
|
|
187
|
+
* Specifies the output path for a .d.ts rollup file to be generated with trimming for a "beta" release.
|
|
188
|
+
* This file will include only declarations that are marked as "@public" or "@beta".
|
|
189
|
+
*
|
|
190
|
+
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
|
191
|
+
* prepend a folder token such as "<projectFolder>".
|
|
192
|
+
*
|
|
193
|
+
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
|
|
194
|
+
* DEFAULT VALUE: ""
|
|
195
|
+
*/
|
|
196
|
+
// "betaTrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>-beta.d.ts",
|
|
197
|
+
/**
|
|
198
|
+
* Specifies the output path for a .d.ts rollup file to be generated with trimming for a "public" release.
|
|
199
|
+
* This file will include only declarations that are marked as "@public".
|
|
200
|
+
*
|
|
201
|
+
* If the path is an empty string, then this file will not be written.
|
|
202
|
+
*
|
|
203
|
+
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
|
204
|
+
* prepend a folder token such as "<projectFolder>".
|
|
205
|
+
*
|
|
206
|
+
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
|
|
207
|
+
* DEFAULT VALUE: ""
|
|
208
|
+
*/
|
|
209
|
+
// "publicTrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>-public.d.ts",
|
|
210
|
+
/**
|
|
211
|
+
* When a declaration is trimmed, by default it will be replaced by a code comment such as
|
|
212
|
+
* "Excluded from this release type: exampleMember". Set "omitTrimmingComments" to true to remove the
|
|
213
|
+
* declaration completely.
|
|
214
|
+
*
|
|
215
|
+
* DEFAULT VALUE: false
|
|
216
|
+
*/
|
|
217
|
+
// "omitTrimmingComments": true
|
|
218
|
+
},
|
|
219
|
+
/**
|
|
220
|
+
* Configures how the tsdoc-metadata.json file will be generated.
|
|
221
|
+
*/
|
|
222
|
+
"tsdocMetadata": {
|
|
223
|
+
/**
|
|
224
|
+
* Whether to generate the tsdoc-metadata.json file.
|
|
225
|
+
*
|
|
226
|
+
* DEFAULT VALUE: true
|
|
227
|
+
*/
|
|
228
|
+
// "enabled": true,
|
|
229
|
+
/**
|
|
230
|
+
* Specifies where the TSDoc metadata file should be written.
|
|
231
|
+
*
|
|
232
|
+
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
|
233
|
+
* prepend a folder token such as "<projectFolder>".
|
|
234
|
+
*
|
|
235
|
+
* The default value is "<lookup>", which causes the path to be automatically inferred from the "tsdocMetadata",
|
|
236
|
+
* "typings" or "main" fields of the project's package.json. If none of these fields are set, the lookup
|
|
237
|
+
* falls back to "tsdoc-metadata.json" in the package folder.
|
|
238
|
+
*
|
|
239
|
+
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
|
|
240
|
+
* DEFAULT VALUE: "<lookup>"
|
|
241
|
+
*/
|
|
242
|
+
// "tsdocMetadataFilePath": "<projectFolder>/dist/tsdoc-metadata.json"
|
|
243
|
+
},
|
|
244
|
+
/**
|
|
245
|
+
* Specifies what type of newlines API Extractor should use when writing output files. By default, the output files
|
|
246
|
+
* will be written with Windows-style newlines. To use POSIX-style newlines, specify "lf" instead.
|
|
247
|
+
* To use the OS's default newline kind, specify "os".
|
|
248
|
+
*
|
|
249
|
+
* DEFAULT VALUE: "crlf"
|
|
250
|
+
*/
|
|
251
|
+
// "newlineKind": "crlf",
|
|
252
|
+
/**
|
|
253
|
+
* Configures how API Extractor reports error and warning messages produced during analysis.
|
|
254
|
+
*
|
|
255
|
+
* There are three sources of messages: compiler messages, API Extractor messages, and TSDoc messages.
|
|
256
|
+
*/
|
|
257
|
+
"messages": {
|
|
258
|
+
/**
|
|
259
|
+
* Configures handling of diagnostic messages reported by the TypeScript compiler engine while analyzing
|
|
260
|
+
* the input .d.ts files.
|
|
261
|
+
*
|
|
262
|
+
* TypeScript message identifiers start with "TS" followed by an integer. For example: "TS2551"
|
|
263
|
+
*
|
|
264
|
+
* DEFAULT VALUE: A single "default" entry with logLevel=warning.
|
|
265
|
+
*/
|
|
266
|
+
"compilerMessageReporting": {
|
|
267
|
+
/**
|
|
268
|
+
* Configures the default routing for messages that don't match an explicit rule in this table.
|
|
269
|
+
*/
|
|
270
|
+
"default": {
|
|
271
|
+
/**
|
|
272
|
+
* Specifies whether the message should be written to the the tool's output log. Note that
|
|
273
|
+
* the "addToApiReportFile" property may supersede this option.
|
|
274
|
+
*
|
|
275
|
+
* Possible values: "error", "warning", "none"
|
|
276
|
+
*
|
|
277
|
+
* Errors cause the build to fail and return a nonzero exit code. Warnings cause a production build fail
|
|
278
|
+
* and return a nonzero exit code. For a non-production build (e.g. when "api-extractor run" includes
|
|
279
|
+
* the "--local" option), the warning is displayed but the build will not fail.
|
|
280
|
+
*
|
|
281
|
+
* DEFAULT VALUE: "warning"
|
|
282
|
+
*/
|
|
283
|
+
"logLevel": "warning"
|
|
284
|
+
/**
|
|
285
|
+
* When addToApiReportFile is true: If API Extractor is configured to write an API report file (.api.md),
|
|
286
|
+
* then the message will be written inside that file; otherwise, the message is instead logged according to
|
|
287
|
+
* the "logLevel" option.
|
|
288
|
+
*
|
|
289
|
+
* DEFAULT VALUE: false
|
|
290
|
+
*/
|
|
291
|
+
// "addToApiReportFile": false
|
|
292
|
+
}
|
|
293
|
+
// "TS2551": {
|
|
294
|
+
// "logLevel": "warning",
|
|
295
|
+
// "addToApiReportFile": true
|
|
296
|
+
// },
|
|
297
|
+
//
|
|
298
|
+
// . . .
|
|
299
|
+
},
|
|
300
|
+
/**
|
|
301
|
+
* Configures handling of messages reported by API Extractor during its analysis.
|
|
302
|
+
*
|
|
303
|
+
* API Extractor message identifiers start with "ae-". For example: "ae-extra-release-tag"
|
|
304
|
+
*
|
|
305
|
+
* DEFAULT VALUE: See api-extractor-defaults.json for the complete table of extractorMessageReporting mappings
|
|
306
|
+
*/
|
|
307
|
+
"extractorMessageReporting": {
|
|
308
|
+
"default": {
|
|
309
|
+
"logLevel": "warning"
|
|
310
|
+
// "addToApiReportFile": false
|
|
311
|
+
},
|
|
312
|
+
"ae-unresolved-link": {
|
|
313
|
+
"logLevel": "none",
|
|
314
|
+
"addToApiReportFile": true
|
|
315
|
+
}
|
|
316
|
+
// "ae-extra-release-tag": {
|
|
317
|
+
// "logLevel": "warning",
|
|
318
|
+
// "addToApiReportFile": true
|
|
319
|
+
// },
|
|
320
|
+
//
|
|
321
|
+
// . . .
|
|
322
|
+
},
|
|
323
|
+
/**
|
|
324
|
+
* Configures handling of messages reported by the TSDoc parser when analyzing code comments.
|
|
325
|
+
*
|
|
326
|
+
* TSDoc message identifiers start with "tsdoc-". For example: "tsdoc-link-tag-unescaped-text"
|
|
327
|
+
*
|
|
328
|
+
* DEFAULT VALUE: A single "default" entry with logLevel=warning.
|
|
329
|
+
*/
|
|
330
|
+
"tsdocMessageReporting": {
|
|
331
|
+
"default": {
|
|
332
|
+
"logLevel": "warning"
|
|
333
|
+
// "addToApiReportFile": false
|
|
334
|
+
}
|
|
335
|
+
// "tsdoc-link-tag-unescaped-text": {
|
|
336
|
+
// "logLevel": "warning",
|
|
337
|
+
// "addToApiReportFile": true
|
|
338
|
+
// },
|
|
339
|
+
//
|
|
340
|
+
// . . .
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
package/config/rig.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// The "rig.json" file directs tools to look for their config files in an external package.
|
|
2
|
+
// Documentation for this system: https://www.npmjs.com/package/@rushstack/rig-package
|
|
3
|
+
{
|
|
4
|
+
"$schema": "https://developer.microsoft.com/json-schemas/rig-package/rig.schema.json",
|
|
5
|
+
/**
|
|
6
|
+
* (Required) The name of the rig package to inherit from.
|
|
7
|
+
* It should be an NPM package name with the "-rig" suffix.
|
|
8
|
+
*/
|
|
9
|
+
"rigPackageName": "@rushstack/heft-node-rig"
|
|
10
|
+
/**
|
|
11
|
+
* (Optional) Selects a config profile from the rig package. The name must consist of
|
|
12
|
+
* lowercase alphanumeric words separated by hyphens, for example "sample-profile".
|
|
13
|
+
* If omitted, then the "default" profile will be used."
|
|
14
|
+
*/
|
|
15
|
+
// "rigProfile": "your-profile-name"
|
|
16
|
+
}
|
package/dist/ts-utils.d.ts
CHANGED
|
@@ -58,10 +58,11 @@ declare class ArrayValidator<T, TC = unknown> extends ValidatorBase<T[], TC> {
|
|
|
58
58
|
* validator.
|
|
59
59
|
* @param from - The `unknown` value to be tested.
|
|
60
60
|
* @param context - Optional validation context will be propagated to element validator.
|
|
61
|
+
* @param self - Optional self-reference for recursive validation.
|
|
61
62
|
* @returns Returns `true` if `from` is an `array` of valid elements, or
|
|
62
63
|
* {@link Failure} with an error message if not.
|
|
63
64
|
*/
|
|
64
|
-
protected _validate
|
|
65
|
+
protected _validate(from: unknown, context?: TC, self?: Validator<T[], TC>): boolean | Failure<T[]>;
|
|
65
66
|
}
|
|
66
67
|
|
|
67
68
|
/**
|
|
@@ -74,7 +75,6 @@ declare interface ArrayValidatorConstructorParams<T, TC = unknown> extends Valid
|
|
|
74
75
|
|
|
75
76
|
declare namespace Base {
|
|
76
77
|
export {
|
|
77
|
-
ValidatorFunc,
|
|
78
78
|
GenericValidatorConstructorParams,
|
|
79
79
|
GenericValidator
|
|
80
80
|
}
|
|
@@ -3420,7 +3420,7 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
3420
3420
|
* {@inheritdoc Validation.ValidatorBase._validate}
|
|
3421
3421
|
* @internal
|
|
3422
3422
|
*/
|
|
3423
|
-
protected _validate(from: unknown, context?: TC): boolean | Failure<T>;
|
|
3423
|
+
protected _validate(from: unknown, context?: TC, self?: Validator<T, TC>): boolean | Failure<T>;
|
|
3424
3424
|
}
|
|
3425
3425
|
|
|
3426
3426
|
/**
|
|
@@ -3522,10 +3522,11 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
3522
3522
|
* of the configured validators.
|
|
3523
3523
|
* @param from - The `unknown` value to be tested.
|
|
3524
3524
|
* @param context - Optional validation context will be propagated to element validator.
|
|
3525
|
+
* @param self - Optional self-reference for recursive validation.
|
|
3525
3526
|
* @returns Returns `true` if `from` is an `array` of valid elements, or
|
|
3526
3527
|
* {@link Failure} with an error message if not.
|
|
3527
3528
|
*/
|
|
3528
|
-
protected _validate<T>(from: unknown, context?: TC): boolean | Failure<T>;
|
|
3529
|
+
protected _validate<T>(from: unknown, context?: TC, self?: Validator<T, TC>): boolean | Failure<T>;
|
|
3529
3530
|
}
|
|
3530
3531
|
|
|
3531
3532
|
/**
|
|
@@ -4439,11 +4440,12 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
4439
4440
|
* type guard, returning a `Failure<T>` containing more information about a failure.
|
|
4440
4441
|
* @param from - Value to be converted.
|
|
4441
4442
|
* @param context - Optional validation context.
|
|
4443
|
+
* @param self - Optional self-reference for recursive validation.
|
|
4442
4444
|
* @returns `true` if `from` is valid, {@link Failure | Failure<T>}
|
|
4443
4445
|
* with an error message if `from` is invalid.
|
|
4444
4446
|
* @internal
|
|
4445
4447
|
*/
|
|
4446
|
-
protected _validate(from: unknown, context?: TC): boolean | Failure<T>;
|
|
4448
|
+
protected _validate(from: unknown, context?: TC, self?: Validator<T, TC>): boolean | Failure<T>;
|
|
4447
4449
|
}
|
|
4448
4450
|
|
|
4449
4451
|
/**
|
|
@@ -4462,6 +4464,15 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
4462
4464
|
*/
|
|
4463
4465
|
declare type TypeGuardWithContext<T, TC = unknown> = (from: unknown, context?: TC) => from is T;
|
|
4464
4466
|
|
|
4467
|
+
/**
|
|
4468
|
+
* Uses a value or calls a supplied initializer if the supplied value is undefined.
|
|
4469
|
+
* @param value - the value
|
|
4470
|
+
* @param initializer - a function that initializes the value if it is undefined
|
|
4471
|
+
* @returns `Success` with the value if it is defined, or the result of calling the initializer function.
|
|
4472
|
+
* @public
|
|
4473
|
+
*/
|
|
4474
|
+
export declare function useOrInitialize<T>(value: T | undefined, initializer: () => Result<T>): Result<T>;
|
|
4475
|
+
|
|
4465
4476
|
declare namespace Utils {
|
|
4466
4477
|
export {
|
|
4467
4478
|
isIterable
|
|
@@ -4592,12 +4603,12 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
4592
4603
|
Classes,
|
|
4593
4604
|
Validators,
|
|
4594
4605
|
TypeGuardWithContext,
|
|
4595
|
-
ValidatorFunc,
|
|
4596
4606
|
FunctionConstraintTrait,
|
|
4597
4607
|
ConstraintTrait,
|
|
4598
4608
|
ValidatorTraitValues,
|
|
4599
4609
|
defaultValidatorTraits,
|
|
4600
4610
|
ValidatorTraits,
|
|
4611
|
+
ValidatorFunc,
|
|
4601
4612
|
ValidatorOptions,
|
|
4602
4613
|
Constraint,
|
|
4603
4614
|
ValidationErrorFormatter,
|
|
@@ -4713,11 +4724,12 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
4713
4724
|
* Abstract validation method to me implemented by derived classes.
|
|
4714
4725
|
* @param from - Value to be converted.
|
|
4715
4726
|
* @param context - Optional validation context.
|
|
4727
|
+
* @param self - Optional self-reference for recursive validation.
|
|
4716
4728
|
* @returns `true` if `from` is valid, {@link Failure | Failure<T>}
|
|
4717
4729
|
* with an error message if `from` is invalid.
|
|
4718
4730
|
* @internal
|
|
4719
4731
|
*/
|
|
4720
|
-
protected abstract _validate(from: unknown, context?: TC): boolean | Failure<T>;
|
|
4732
|
+
protected abstract _validate(from: unknown, context?: TC, self?: Validator<T, TC>): boolean | Failure<T>;
|
|
4721
4733
|
}
|
|
4722
4734
|
|
|
4723
4735
|
/**
|
|
@@ -4731,7 +4743,7 @@ declare class Collectible<TKEY extends string = string, TINDEX extends number =
|
|
|
4731
4743
|
* an optionally-supplied validation context of type `<TC>`.
|
|
4732
4744
|
* @public
|
|
4733
4745
|
*/
|
|
4734
|
-
declare type ValidatorFunc<T, TC> = (from: unknown, context?: TC) => boolean | Failure<T>;
|
|
4746
|
+
declare type ValidatorFunc<T, TC> = (from: unknown, context?: TC, self?: Validator<T, TC>) => boolean | Failure<T>;
|
|
4735
4747
|
|
|
4736
4748
|
/**
|
|
4737
4749
|
* Options that apply to any {@link Validation.Validator | Validator}.
|
package/dist/tsdoc-metadata.json
CHANGED
|
@@ -458,6 +458,14 @@ export declare function fail<T>(message: string): Failure<T>;
|
|
|
458
458
|
* @public
|
|
459
459
|
*/
|
|
460
460
|
export declare function fails<T>(message: string): Failure<T>;
|
|
461
|
+
/**
|
|
462
|
+
* Uses a value or calls a supplied initializer if the supplied value is undefined.
|
|
463
|
+
* @param value - the value
|
|
464
|
+
* @param initializer - a function that initializes the value if it is undefined
|
|
465
|
+
* @returns `Success` with the value if it is defined, or the result of calling the initializer function.
|
|
466
|
+
* @public
|
|
467
|
+
*/
|
|
468
|
+
export declare function useOrInitialize<T>(value: T | undefined, initializer: () => Result<T>): Result<T>;
|
|
461
469
|
/**
|
|
462
470
|
* Callback to be called when a {@link DetailedResult | DetailedResult} encounters success.
|
|
463
471
|
* @remarks
|
|
@@ -26,6 +26,7 @@ exports.succeed = succeed;
|
|
|
26
26
|
exports.succeeds = succeeds;
|
|
27
27
|
exports.fail = fail;
|
|
28
28
|
exports.fails = fails;
|
|
29
|
+
exports.useOrInitialize = useOrInitialize;
|
|
29
30
|
exports.succeedWithDetail = succeedWithDetail;
|
|
30
31
|
exports.succeedsWithDetail = succeedsWithDetail;
|
|
31
32
|
exports.failWithDetail = failWithDetail;
|
|
@@ -302,6 +303,16 @@ function fail(message) {
|
|
|
302
303
|
function fails(message) {
|
|
303
304
|
return new Failure(message);
|
|
304
305
|
}
|
|
306
|
+
/**
|
|
307
|
+
* Uses a value or calls a supplied initializer if the supplied value is undefined.
|
|
308
|
+
* @param value - the value
|
|
309
|
+
* @param initializer - a function that initializes the value if it is undefined
|
|
310
|
+
* @returns `Success` with the value if it is defined, or the result of calling the initializer function.
|
|
311
|
+
* @public
|
|
312
|
+
*/
|
|
313
|
+
function useOrInitialize(value, initializer) {
|
|
314
|
+
return value !== undefined ? succeed(value) : initializer();
|
|
315
|
+
}
|
|
305
316
|
/**
|
|
306
317
|
* A {@link DetailedSuccess | DetailedSuccess} extends {@link Success | Success} to report optional success
|
|
307
318
|
* details in addition to the error message.
|
|
@@ -69,7 +69,9 @@ class Crc32Normalizer extends hashingNormalizer_1.HashingNormalizer {
|
|
|
69
69
|
super(Crc32Normalizer.crc32Hash);
|
|
70
70
|
}
|
|
71
71
|
static crc32Hash(parts) {
|
|
72
|
-
return crc32(textEncoder.encode(parts.join('|')))
|
|
72
|
+
return crc32(textEncoder.encode(parts.join('|')))
|
|
73
|
+
.toString(16)
|
|
74
|
+
.padStart(8, '0');
|
|
73
75
|
}
|
|
74
76
|
}
|
|
75
77
|
exports.Crc32Normalizer = Crc32Normalizer;
|
|
@@ -32,9 +32,10 @@ export declare class ArrayValidator<T, TC = unknown> extends ValidatorBase<T[],
|
|
|
32
32
|
* validator.
|
|
33
33
|
* @param from - The `unknown` value to be tested.
|
|
34
34
|
* @param context - Optional validation context will be propagated to element validator.
|
|
35
|
+
* @param self - Optional self-reference for recursive validation.
|
|
35
36
|
* @returns Returns `true` if `from` is an `array` of valid elements, or
|
|
36
37
|
* {@link Failure} with an error message if not.
|
|
37
38
|
*/
|
|
38
|
-
protected _validate
|
|
39
|
+
protected _validate(from: unknown, context?: TC, self?: Validator<T[], TC>): boolean | Failure<T[]>;
|
|
39
40
|
}
|
|
40
41
|
//# sourceMappingURL=array.d.ts.map
|
|
@@ -47,10 +47,11 @@ class ArrayValidator extends validatorBase_1.ValidatorBase {
|
|
|
47
47
|
* validator.
|
|
48
48
|
* @param from - The `unknown` value to be tested.
|
|
49
49
|
* @param context - Optional validation context will be propagated to element validator.
|
|
50
|
+
* @param self - Optional self-reference for recursive validation.
|
|
50
51
|
* @returns Returns `true` if `from` is an `array` of valid elements, or
|
|
51
52
|
* {@link Failure} with an error message if not.
|
|
52
53
|
*/
|
|
53
|
-
_validate(from, context) {
|
|
54
|
+
_validate(from, context, self) {
|
|
54
55
|
if (Array.isArray(from)) {
|
|
55
56
|
for (const elem of from) {
|
|
56
57
|
const result = this._validateElement.validate(elem, context);
|
|
@@ -1,15 +1,7 @@
|
|
|
1
|
-
import { Failure } from '../base';
|
|
2
1
|
/**
|
|
3
2
|
* A type guard function which validates a specific type, with an optional context
|
|
4
3
|
* that can be used to shape the validation.
|
|
5
4
|
* @public
|
|
6
5
|
*/
|
|
7
6
|
export type TypeGuardWithContext<T, TC = unknown> = (from: unknown, context?: TC) => from is T;
|
|
8
|
-
/**
|
|
9
|
-
* Type for a validation function, which validates that a supplied `unknown`
|
|
10
|
-
* value is a valid value of type `<T>`, possibly as influenced by
|
|
11
|
-
* an optionally-supplied validation context of type `<TC>`.
|
|
12
|
-
* @public
|
|
13
|
-
*/
|
|
14
|
-
export type ValidatorFunc<T, TC> = (from: unknown, context?: TC) => boolean | Failure<T>;
|
|
15
7
|
//# sourceMappingURL=common.d.ts.map
|
|
@@ -38,6 +38,6 @@ export declare class FieldValidator<T, TC = unknown> extends ValidatorBase<T, TC
|
|
|
38
38
|
/**
|
|
39
39
|
* {@inheritdoc Validation.ValidatorBase._validate}
|
|
40
40
|
*/
|
|
41
|
-
protected _validate(from: unknown, context?: TC): boolean | Failure<T>;
|
|
41
|
+
protected _validate(from: unknown, context?: TC, self?: Validator<T, TC>): boolean | Failure<T>;
|
|
42
42
|
}
|
|
43
43
|
//# sourceMappingURL=field.d.ts.map
|
|
@@ -48,7 +48,7 @@ class FieldValidator extends validatorBase_1.ValidatorBase {
|
|
|
48
48
|
/**
|
|
49
49
|
* {@inheritdoc Validation.ValidatorBase._validate}
|
|
50
50
|
*/
|
|
51
|
-
_validate(from, context) {
|
|
51
|
+
_validate(from, context, self) {
|
|
52
52
|
if (typeof from === 'object' && !Array.isArray(from) && from !== null) {
|
|
53
53
|
const optional = this._fieldOptions.optional === true;
|
|
54
54
|
if ((0, base_1.isKeyOf)(this.fieldName, from)) {
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { Brand, Result } from '../base';
|
|
2
2
|
import { ConstraintTrait, ValidatorTraits } from './traits';
|
|
3
|
-
import { Constraint, ValidationErrorFormatter, Validator, ValidatorOptions } from './validator';
|
|
4
|
-
import { ValidatorFunc } from './common';
|
|
5
|
-
/**
|
|
6
|
-
* @deprecated Use {@link Validation.Common.ValidatorFunc | Validation.Common.ValidatorFunc} instead.
|
|
7
|
-
*/
|
|
8
|
-
export { ValidatorFunc };
|
|
3
|
+
import { Constraint, ValidationErrorFormatter, Validator, ValidatorFunc, ValidatorOptions } from './validator';
|
|
9
4
|
/**
|
|
10
5
|
* Options used to initialize a {@link Validation.Base.GenericValidator | GenericValidator}.
|
|
11
6
|
* @public
|