@fgv/ts-res 5.0.1-9 → 5.0.1
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/dist/index.browser.js +53 -0
- package/dist/index.js +45 -0
- package/dist/packlets/bundle/bundleBuilder.js +130 -0
- package/dist/packlets/bundle/bundleLoader.js +101 -0
- package/dist/packlets/bundle/bundleNormalizer.js +138 -0
- package/dist/packlets/bundle/bundleUtils.js +113 -0
- package/dist/packlets/bundle/convert.js +75 -0
- package/dist/packlets/bundle/index.js +42 -0
- package/dist/packlets/bundle/model.js +23 -0
- package/dist/packlets/common/conditions.js +47 -0
- package/dist/packlets/common/convert.js +172 -0
- package/dist/packlets/common/helpers/conditions.js +66 -0
- package/dist/packlets/common/helpers/context.js +70 -0
- package/dist/packlets/common/helpers/index.js +26 -0
- package/dist/packlets/common/helpers/qualifierDefaultValues.js +66 -0
- package/dist/packlets/common/helpers/resources.js +93 -0
- package/dist/packlets/common/index.js +28 -0
- package/dist/packlets/common/resources.js +27 -0
- package/dist/packlets/common/validate/conditions.js +544 -0
- package/dist/packlets/common/validate/index.js +26 -0
- package/dist/packlets/common/validate/regularExpressions.js +84 -0
- package/dist/packlets/common/validate/resources.js +209 -0
- package/dist/packlets/conditions/condition.js +252 -0
- package/dist/packlets/conditions/conditionCollector.js +69 -0
- package/dist/packlets/conditions/conditionDecls.js +23 -0
- package/dist/packlets/conditions/conditionSet.js +247 -0
- package/dist/packlets/conditions/conditionSetCollector.js +89 -0
- package/dist/packlets/conditions/conditionSetDecls.js +23 -0
- package/dist/packlets/conditions/conditionToken.js +147 -0
- package/dist/packlets/conditions/convert/conditionSetDecls.js +51 -0
- package/dist/packlets/conditions/convert/decls.js +75 -0
- package/dist/packlets/conditions/convert/index.js +24 -0
- package/dist/packlets/conditions/index.js +31 -0
- package/dist/packlets/config/common.js +78 -0
- package/dist/packlets/config/configInitFactory.js +258 -0
- package/dist/packlets/config/convert.js +56 -0
- package/dist/packlets/config/index.browser.js +34 -0
- package/dist/packlets/config/index.js +28 -0
- package/dist/packlets/config/json.js +23 -0
- package/dist/packlets/config/predefined/default.js +138 -0
- package/dist/packlets/config/predefined/extended.js +190 -0
- package/dist/packlets/config/predefined/index.js +25 -0
- package/dist/packlets/config/systemConfiguration.js +147 -0
- package/dist/packlets/context/contextDecls.js +23 -0
- package/dist/packlets/context/contextToken.js +202 -0
- package/dist/packlets/context/convert/decls.js +91 -0
- package/dist/packlets/context/convert/index.js +23 -0
- package/dist/packlets/context/index.js +26 -0
- package/dist/packlets/decisions/abstractDecision.js +68 -0
- package/dist/packlets/decisions/abstractDecisionCollector.js +90 -0
- package/dist/packlets/decisions/candidate.js +76 -0
- package/dist/packlets/decisions/common.js +23 -0
- package/dist/packlets/decisions/concreteDecision.js +111 -0
- package/dist/packlets/decisions/decision.js +126 -0
- package/dist/packlets/decisions/index.js +28 -0
- package/dist/packlets/import/fsItem.js +134 -0
- package/dist/packlets/import/importContext.js +129 -0
- package/dist/packlets/import/importManager.js +129 -0
- package/dist/packlets/import/importable.js +32 -0
- package/dist/packlets/import/importers/collectionImporter.js +118 -0
- package/dist/packlets/import/importers/fsItemImporter.js +116 -0
- package/dist/packlets/import/importers/importer.js +23 -0
- package/dist/packlets/import/importers/index.browser.js +29 -0
- package/dist/packlets/import/importers/index.js +27 -0
- package/dist/packlets/import/importers/jsonImporter.js +94 -0
- package/dist/packlets/import/importers/pathImporter.js +84 -0
- package/dist/packlets/import/index.browser.js +34 -0
- package/dist/packlets/import/index.js +28 -0
- package/dist/packlets/qualifier-types/config/convert.js +124 -0
- package/dist/packlets/qualifier-types/config/index.js +25 -0
- package/dist/packlets/qualifier-types/config/json.js +32 -0
- package/dist/packlets/qualifier-types/convert.js +56 -0
- package/dist/packlets/qualifier-types/helpers.js +82 -0
- package/dist/packlets/qualifier-types/index.js +32 -0
- package/dist/packlets/qualifier-types/languageQualifierType.js +142 -0
- package/dist/packlets/qualifier-types/literalQualifierType.js +200 -0
- package/dist/packlets/qualifier-types/literalValueHierarchy.js +236 -0
- package/dist/packlets/qualifier-types/qualifierType.js +184 -0
- package/dist/packlets/qualifier-types/qualifierTypeCollector.js +66 -0
- package/dist/packlets/qualifier-types/territoryQualifierType.js +200 -0
- package/dist/packlets/qualifiers/convert/decls.js +70 -0
- package/dist/packlets/qualifiers/convert/index.js +24 -0
- package/dist/packlets/qualifiers/convert/qualifier.js +40 -0
- package/dist/packlets/qualifiers/index.js +29 -0
- package/dist/packlets/qualifiers/qualifier.js +108 -0
- package/dist/packlets/qualifiers/qualifierCollector.js +123 -0
- package/dist/packlets/qualifiers/qualifierDecl.js +23 -0
- package/dist/packlets/qualifiers/qualifierDefaultValueDecls.js +23 -0
- package/dist/packlets/qualifiers/qualifierDefaultValueToken.js +175 -0
- package/dist/packlets/resource-json/compiled/common.js +23 -0
- package/dist/packlets/resource-json/compiled/convert.js +132 -0
- package/dist/packlets/resource-json/compiled/index.js +26 -0
- package/dist/packlets/resource-json/compiled/json.js +2 -0
- package/dist/packlets/resource-json/convert.js +171 -0
- package/dist/packlets/resource-json/helpers.js +241 -0
- package/dist/packlets/resource-json/index.js +31 -0
- package/dist/packlets/resource-json/json.js +36 -0
- package/dist/packlets/resource-json/normalized.js +23 -0
- package/dist/packlets/resource-json/resourceDeclCollection.js +88 -0
- package/dist/packlets/resource-json/resourceDeclContainer.js +23 -0
- package/dist/packlets/resource-json/resourceDeclTree.js +94 -0
- package/dist/packlets/resource-types/config/convert.js +35 -0
- package/dist/packlets/resource-types/config/index.js +25 -0
- package/dist/packlets/resource-types/config/json.js +23 -0
- package/dist/packlets/resource-types/helpers.js +42 -0
- package/dist/packlets/resource-types/index.js +28 -0
- package/dist/packlets/resource-types/jsonResourceType.js +66 -0
- package/dist/packlets/resource-types/resourceType.js +95 -0
- package/dist/packlets/resource-types/resourceTypeCollector.js +61 -0
- package/dist/packlets/resources/candidateReducer.js +246 -0
- package/dist/packlets/resources/candidateValue.js +92 -0
- package/dist/packlets/resources/candidateValueCollector.js +94 -0
- package/dist/packlets/resources/common.js +23 -0
- package/dist/packlets/resources/deltaGenerator.js +338 -0
- package/dist/packlets/resources/index.js +31 -0
- package/dist/packlets/resources/resource.js +207 -0
- package/dist/packlets/resources/resourceBuilder.js +183 -0
- package/dist/packlets/resources/resourceCandidate.js +216 -0
- package/dist/packlets/resources/resourceManagerBuilder.js +890 -0
- package/dist/packlets/runtime/cacheListener.js +58 -0
- package/dist/packlets/runtime/cacheMetrics.js +149 -0
- package/dist/packlets/runtime/compiledResourceCollection.js +473 -0
- package/dist/packlets/runtime/conditionSetResolutionResult.js +134 -0
- package/dist/packlets/runtime/context/contextQualifierProvider.js +29 -0
- package/dist/packlets/runtime/context/contextQualifierProviderValidator.js +146 -0
- package/dist/packlets/runtime/context/index.js +26 -0
- package/dist/packlets/runtime/context/simpleContextQualifierProvider.js +196 -0
- package/dist/packlets/runtime/context/validatingSimpleContextQualifierProvider.js +60 -0
- package/dist/packlets/runtime/iResourceManager.js +23 -0
- package/dist/packlets/runtime/index.js +34 -0
- package/dist/packlets/runtime/resource-tree/common.js +23 -0
- package/dist/packlets/runtime/resource-tree/index.js +26 -0
- package/dist/packlets/runtime/resource-tree/readOnlyResourceTree.js +216 -0
- package/dist/packlets/runtime/resource-tree/resourceTreeChildren.js +97 -0
- package/dist/packlets/runtime/resource-tree/resourceTreeChildrenValidator.js +161 -0
- package/dist/packlets/runtime/resourceResolver.js +481 -0
- package/dist/packlets/runtime/resourceTreeResolver.js +220 -0
- package/dist/packlets/runtime/validate.js +47 -0
- package/dist/packlets/zip-archive/convert.js +100 -0
- package/dist/packlets/zip-archive/index.browser.js +54 -0
- package/dist/packlets/zip-archive/index.js +47 -0
- package/dist/packlets/zip-archive/json.js +23 -0
- package/dist/packlets/zip-archive/types.js +36 -0
- package/dist/packlets/zip-archive/zipArchiveCreator.js +191 -0
- package/dist/packlets/zip-archive/zipArchiveFormat.js +140 -0
- package/dist/packlets/zip-archive/zipArchiveLoader.js +282 -0
- package/dist/test/data/sample.json +32 -0
- package/dist/test/unit/qualifier-types/testQualifierType.js +76 -0
- package/dist/test/unit/resource-types/testDerivedResourceType.js +109 -0
- package/dist/test/unit/resources/deltaGenerator.helpers.js +282 -0
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/index.browser.d.ts +24 -0
- package/lib/index.browser.js +116 -0
- package/lib/packlets/config/index.browser.d.ts +7 -0
- package/lib/packlets/config/index.browser.js +74 -0
- package/lib/packlets/import/importers/index.browser.d.ts +4 -0
- package/lib/packlets/import/importers/index.browser.js +45 -0
- package/lib/packlets/import/index.browser.d.ts +7 -0
- package/lib/packlets/import/index.browser.js +74 -0
- package/lib/packlets/zip-archive/index.browser.d.ts +27 -0
- package/lib/packlets/zip-archive/index.browser.js +102 -0
- package/package.json +21 -7
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Erik Fortune
|
|
3
|
+
*
|
|
4
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
* in the Software without restriction, including without limitation the rights
|
|
7
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
* furnished to do so, subject to the following conditions:
|
|
10
|
+
*
|
|
11
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
* copies or substantial portions of the Software.
|
|
13
|
+
*
|
|
14
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
* SOFTWARE.
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Bundle packlet providing functionality for creating and loading resource bundles.
|
|
24
|
+
*
|
|
25
|
+
* Resource bundles encapsulate compiled resources, configuration, and metadata with
|
|
26
|
+
* integrity verification. They provide a portable way to distribute pre-compiled
|
|
27
|
+
* resource collections.
|
|
28
|
+
*
|
|
29
|
+
* @packageDocumentation
|
|
30
|
+
*/
|
|
31
|
+
import * as Model from './model';
|
|
32
|
+
import * as Convert from './convert';
|
|
33
|
+
// Builder and loader classes
|
|
34
|
+
export { BundleBuilder } from './bundleBuilder';
|
|
35
|
+
export { BundleLoader } from './bundleLoader';
|
|
36
|
+
// Utilities
|
|
37
|
+
export { BundleUtils } from './bundleUtils';
|
|
38
|
+
export { Model, Convert };
|
|
39
|
+
// Internal utilities (not part of public API)
|
|
40
|
+
/** @internal */
|
|
41
|
+
export { BundleNormalizer } from './bundleNormalizer';
|
|
42
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Erik Fortune
|
|
3
|
+
*
|
|
4
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
* in the Software without restriction, including without limitation the rights
|
|
7
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
* furnished to do so, subject to the following conditions:
|
|
10
|
+
*
|
|
11
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
* copies or substantial portions of the Software.
|
|
13
|
+
*
|
|
14
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
* SOFTWARE.
|
|
21
|
+
*/
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=model.js.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Erik Fortune
|
|
3
|
+
*
|
|
4
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
* in the Software without restriction, including without limitation the rights
|
|
7
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
* furnished to do so, subject to the following conditions:
|
|
10
|
+
*
|
|
11
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
* copies or substantial portions of the Software.
|
|
13
|
+
*
|
|
14
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
* SOFTWARE.
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* {@link QualifierMatchScore | Match score} indicating no match.
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
export const NoMatch = 0.0;
|
|
27
|
+
/**
|
|
28
|
+
* {@link QualifierMatchScore | Match score} indicating a perfect match.
|
|
29
|
+
* @public
|
|
30
|
+
*/
|
|
31
|
+
export const PerfectMatch = 1.0;
|
|
32
|
+
/**
|
|
33
|
+
* Minimum valid priority for a condition.
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
export const MinConditionPriority = 0;
|
|
37
|
+
/**
|
|
38
|
+
* Maximum valid priority for a condition.
|
|
39
|
+
* @public
|
|
40
|
+
*/
|
|
41
|
+
export const MaxConditionPriority = 1000;
|
|
42
|
+
/**
|
|
43
|
+
* Array of all valid condition operators.
|
|
44
|
+
* @public
|
|
45
|
+
*/
|
|
46
|
+
export const allConditionOperators = ['always', 'never', 'matches'];
|
|
47
|
+
//# sourceMappingURL=conditions.js.map
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Erik Fortune
|
|
3
|
+
*
|
|
4
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
* in the Software without restriction, including without limitation the rights
|
|
7
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
* furnished to do so, subject to the following conditions:
|
|
10
|
+
*
|
|
11
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
* copies or substantial portions of the Software.
|
|
13
|
+
*
|
|
14
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
* SOFTWARE.
|
|
21
|
+
*/
|
|
22
|
+
import { Converters } from '@fgv/ts-utils';
|
|
23
|
+
import * as Validate from './validate';
|
|
24
|
+
import { allConditionOperators } from './conditions';
|
|
25
|
+
import { allResourceValueMergeMethods } from './resources';
|
|
26
|
+
/* eslint-disable @rushstack/typedef-var */
|
|
27
|
+
/**
|
|
28
|
+
* `Converter` which validates an `unknown` value as a {@link QualifierName | QualifierName}.
|
|
29
|
+
* @public
|
|
30
|
+
*/
|
|
31
|
+
export const qualifierName = Converters.string.map(Validate.toQualifierName);
|
|
32
|
+
/**
|
|
33
|
+
* `Converter` which validates an `unknown` value as a {@link QualifierIndex | QualifierIndex}.
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
export const qualifierIndex = Converters.number.map(Validate.toQualifierIndex);
|
|
37
|
+
/**
|
|
38
|
+
* `Converter` which validates an `unknown` value as a {@link QualifierTypeName | QualifierTypeName}.
|
|
39
|
+
* @public
|
|
40
|
+
*/
|
|
41
|
+
export const qualifierTypeName = Converters.string.map(Validate.toQualifierTypeName);
|
|
42
|
+
/**
|
|
43
|
+
* `Converter` which validates an `unknown` value as a {@link QualifierTypeIndex | QualifierTypeIndex}.
|
|
44
|
+
* @public
|
|
45
|
+
*/
|
|
46
|
+
export const qualifierTypeIndex = Converters.number.map(Validate.toQualifierTypeIndex);
|
|
47
|
+
/**
|
|
48
|
+
* `Converter` which validates an `unknown` value as a {@link QualifierContextValue | QualifierContextValue}.
|
|
49
|
+
* @public
|
|
50
|
+
*/
|
|
51
|
+
export const qualifierContextValue = Converters.string.map(Validate.toQualifierContextValue);
|
|
52
|
+
/**
|
|
53
|
+
* `Converter` which validates an `unknown` value as a {@link QualifierConditionValue | QualifierConditionValue}.
|
|
54
|
+
* @public
|
|
55
|
+
*/
|
|
56
|
+
export const qualifierMatchScore = Converters.number.map(Validate.toQualifierMatchScore);
|
|
57
|
+
/**
|
|
58
|
+
* `Converter` which validates an `unknown` value as a {@link ConditionPriority | ConditionPriority}.
|
|
59
|
+
* @public
|
|
60
|
+
*/
|
|
61
|
+
export const conditionPriority = Converters.number.map(Validate.toConditionPriority);
|
|
62
|
+
/**
|
|
63
|
+
* `Converter` which validates an `unknown` value as a {@link ConditionOperator | ConditionOperator}.
|
|
64
|
+
* @public
|
|
65
|
+
*/
|
|
66
|
+
export const conditionOperator = Converters.enumeratedValue(allConditionOperators);
|
|
67
|
+
/**
|
|
68
|
+
* `Converter` which validates an `unknown` value as a {@link ConditionIndex | ConditionIndex}.
|
|
69
|
+
* @public
|
|
70
|
+
*/
|
|
71
|
+
export const conditionIndex = Converters.number.map(Validate.toConditionIndex);
|
|
72
|
+
/**
|
|
73
|
+
* `Converter` which validates an `unknown` value as a {@link ConditionKey | ConditionKey}.
|
|
74
|
+
* @public
|
|
75
|
+
*/
|
|
76
|
+
export const conditionKey = Converters.string.map(Validate.toConditionKey);
|
|
77
|
+
/**
|
|
78
|
+
* `Converter` which validates an `unknown` value as a {@link ConditionToken | ConditionToken}.
|
|
79
|
+
* @public
|
|
80
|
+
*/
|
|
81
|
+
export const conditionToken = Converters.string.map(Validate.toConditionToken);
|
|
82
|
+
/**
|
|
83
|
+
* `Converter` which validates an `unknown` value as a {@link ConditionSetIndex | ConditionSetIndex}.
|
|
84
|
+
* @public
|
|
85
|
+
*/
|
|
86
|
+
export const conditionSetIndex = Converters.number.map(Validate.toConditionSetIndex);
|
|
87
|
+
/**
|
|
88
|
+
* `Converter` which validates an `unknown` value as a {@link ConditionSetKey | ConditionSetKey}.
|
|
89
|
+
* @public
|
|
90
|
+
*/
|
|
91
|
+
export const conditionSetKey = Converters.string.map(Validate.toConditionSetKey);
|
|
92
|
+
/**
|
|
93
|
+
* `Converter` which validates an `unknown` value as a {@link ConditionSetToken | ConditionSetToken}.
|
|
94
|
+
* @public
|
|
95
|
+
*/
|
|
96
|
+
export const conditionSetToken = Converters.string.map(Validate.toConditionSetToken);
|
|
97
|
+
/**
|
|
98
|
+
* `Converter` which validates an `unknown` value as a {@link ConditionSetHash | ConditionSetHash}.
|
|
99
|
+
* @public
|
|
100
|
+
*/
|
|
101
|
+
export const conditionSetHash = Converters.string.map(Validate.toConditionSetHash);
|
|
102
|
+
/**
|
|
103
|
+
* `Converter` which validates an `unknown` value as a {@link DecisionIndex | DecisionIndex}.
|
|
104
|
+
* @public
|
|
105
|
+
*/
|
|
106
|
+
export const decisionIndex = Converters.number.map(Validate.toDecisionIndex);
|
|
107
|
+
/**
|
|
108
|
+
* `Converter` which validates an `unknown` value as a {@link DecisionKey | DecisionKey}.
|
|
109
|
+
* @public
|
|
110
|
+
*/
|
|
111
|
+
export const decisionKey = Converters.string.map(Validate.toDecisionKey);
|
|
112
|
+
/**
|
|
113
|
+
* `Converter` which validates an `unknown` value as a {@link ResourceId | ResourceId}.
|
|
114
|
+
* @public
|
|
115
|
+
*/
|
|
116
|
+
export const resourceId = Converters.string.map(Validate.toResourceId);
|
|
117
|
+
/**
|
|
118
|
+
* `Converter` which validates an `unknown` value as a {@link ResourceName | ResourceName}.
|
|
119
|
+
* @public
|
|
120
|
+
*/
|
|
121
|
+
export const resourceName = Converters.string.map(Validate.toResourceName);
|
|
122
|
+
/**
|
|
123
|
+
* `Converter` which validates an `unknown` value as a {@link ResourceIndex | ResourceIndex}.
|
|
124
|
+
* @public
|
|
125
|
+
*/
|
|
126
|
+
export const resourceIndex = Converters.number.map(Validate.toResourceIndex);
|
|
127
|
+
/**
|
|
128
|
+
* `Converter` which validates an `unknown` value as a {@link ResourceTypeName | ResourceTypeName}.
|
|
129
|
+
* @public
|
|
130
|
+
*/
|
|
131
|
+
export const resourceTypeName = Converters.string.map(Validate.toResourceTypeName);
|
|
132
|
+
/**
|
|
133
|
+
* `Converter` which validates an `unknown` value as a {@link ResourceTypeIndex | ResourceTypeIndex}.
|
|
134
|
+
* @public
|
|
135
|
+
*/
|
|
136
|
+
export const resourceTypeIndex = Converters.number.map(Validate.toResourceTypeIndex);
|
|
137
|
+
/**
|
|
138
|
+
* `Converter` which validates an `unknown` value as a {@link CandidateValueKey | CandidateValueKey}.
|
|
139
|
+
* @public
|
|
140
|
+
*/
|
|
141
|
+
export const candidateValueKey = Converters.string.map(Validate.toCandidateValueKey);
|
|
142
|
+
/**
|
|
143
|
+
* `Converter` which validates an `unknown` value as a {@link CandidateValueIndex | CandidateValueIndex}.
|
|
144
|
+
* @public
|
|
145
|
+
*/
|
|
146
|
+
export const candidateValueIndex = Converters.number.map(Validate.toCandidateValueIndex);
|
|
147
|
+
/**
|
|
148
|
+
* `Converter` for a resource value merge method.
|
|
149
|
+
* @public
|
|
150
|
+
*/
|
|
151
|
+
export const resourceValueMergeMethod = Converters.enumeratedValue(allResourceValueMergeMethods);
|
|
152
|
+
/**
|
|
153
|
+
* `Converter` which validates an `unknown` value as a {@link ContextQualifierToken | ContextQualifierToken}.
|
|
154
|
+
* @public
|
|
155
|
+
*/
|
|
156
|
+
export const contextQualifierToken = Converters.string.map(Validate.toContextQualifierToken);
|
|
157
|
+
/**
|
|
158
|
+
* `Converter` which validates an `unknown` value as a {@link ContextToken | ContextToken}.
|
|
159
|
+
* @public
|
|
160
|
+
*/
|
|
161
|
+
export const contextToken = Converters.string.map(Validate.toContextToken);
|
|
162
|
+
/**
|
|
163
|
+
* `Converter` which validates an `unknown` value as a {@link QualifierDefaultValueToken | QualifierDefaultValueToken}.
|
|
164
|
+
* @public
|
|
165
|
+
*/
|
|
166
|
+
export const qualifierDefaultValueToken = Converters.string.map(Validate.toQualifierDefaultValueToken);
|
|
167
|
+
/**
|
|
168
|
+
* `Converter` which validates an `unknown` value as a {@link QualifierDefaultValuesToken | QualifierDefaultValuesToken}.
|
|
169
|
+
* @public
|
|
170
|
+
*/
|
|
171
|
+
export const qualifierDefaultValuesToken = Converters.string.map(Validate.toQualifierDefaultValuesToken);
|
|
172
|
+
//# sourceMappingURL=convert.js.map
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Erik Fortune
|
|
3
|
+
*
|
|
4
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
* in the Software without restriction, including without limitation the rights
|
|
7
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
* furnished to do so, subject to the following conditions:
|
|
10
|
+
*
|
|
11
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
* copies or substantial portions of the Software.
|
|
13
|
+
*
|
|
14
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
* SOFTWARE.
|
|
21
|
+
*/
|
|
22
|
+
import { mapResults, succeed } from '@fgv/ts-utils';
|
|
23
|
+
import * as Validate from '../validate';
|
|
24
|
+
/**
|
|
25
|
+
* Converts a {@link Helpers.IConditionTokenParts | the parts that make up a condition token} into
|
|
26
|
+
* a syntactically validated {@link ConditionToken | condition token}.
|
|
27
|
+
* @param parts - the parts to convert
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
export function buildConditionToken({ qualifier, value }) {
|
|
31
|
+
return Validate.toConditionToken(qualifier ? `${qualifier}=${value}` : value);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Converts an array of {@link Helpers.IConditionTokenParts | condition token parts} into an array of
|
|
35
|
+
* syntactically validated {@link ConditionToken | condition tokens}.
|
|
36
|
+
* @param parts - the parts to convert
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
export function buildConditionSetToken(parts) {
|
|
40
|
+
return mapResults(parts.map(buildConditionToken)).onSuccess((tokens) => Validate.toConditionSetToken(tokens.join(',')));
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Parses a condition token string into its {@link Helpers.IConditionTokenParts | parts}.
|
|
44
|
+
* @param token - the token string to parse.
|
|
45
|
+
* @returns `Success` with the parts if successful, `Failure` with an error message if not.
|
|
46
|
+
* @public
|
|
47
|
+
*/
|
|
48
|
+
export function parseConditionTokenParts(token) {
|
|
49
|
+
return Validate.toConditionToken(token).onSuccess((t) => {
|
|
50
|
+
const parts = t.split('=');
|
|
51
|
+
if (parts.length === 1) {
|
|
52
|
+
return succeed({ value: parts[0] });
|
|
53
|
+
}
|
|
54
|
+
return succeed({ qualifier: parts[0], value: parts[1] });
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Parses a condition set token string into an array of {@link Helpers.IConditionTokenParts | condition token parts}.
|
|
59
|
+
* @param token - the conditions set token string to parse.
|
|
60
|
+
* @returns `Success` with the parts if successful, `Failure` with an error message if not.
|
|
61
|
+
* @public
|
|
62
|
+
*/
|
|
63
|
+
export function parseConditionSetTokenParts(token) {
|
|
64
|
+
return mapResults(token.split(',').map(parseConditionTokenParts));
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=conditions.js.map
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Erik Fortune
|
|
3
|
+
*
|
|
4
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
* in the Software without restriction, including without limitation the rights
|
|
7
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
* furnished to do so, subject to the following conditions:
|
|
10
|
+
*
|
|
11
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
* copies or substantial portions of the Software.
|
|
13
|
+
*
|
|
14
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
* SOFTWARE.
|
|
21
|
+
*/
|
|
22
|
+
import { mapResults, succeed } from '@fgv/ts-utils';
|
|
23
|
+
import * as Validate from '../validate';
|
|
24
|
+
/**
|
|
25
|
+
* Converts a {@link Helpers.IContextTokenParts | the parts that make up a context qualifier token} into
|
|
26
|
+
* a syntactically validated {@link ContextQualifierToken | context qualifier token}.
|
|
27
|
+
* @param parts - the parts to convert
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
export function buildContextQualifierToken({ qualifier, value }) {
|
|
31
|
+
/* c8 ignore next 1 - edge case: ternary expression alternate branch rarely hit */
|
|
32
|
+
return Validate.toContextQualifierToken(qualifier ? `${qualifier}=${value}` : value);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Converts an array of {@link Helpers.IContextTokenParts | context qualifier token parts} into a
|
|
36
|
+
* syntactically validated {@link ContextToken | context token}.
|
|
37
|
+
* @param parts - the parts to convert
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
export function buildContextToken(parts) {
|
|
41
|
+
return mapResults(parts.map(buildContextQualifierToken)).onSuccess((tokens) => Validate.toContextToken(tokens.join('|')));
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Parses a context qualifier token string into its {@link Helpers.IContextTokenParts | parts}.
|
|
45
|
+
* @param token - the token string to parse.
|
|
46
|
+
* @returns `Success` with the parts if successful, `Failure` with an error message if not.
|
|
47
|
+
* @public
|
|
48
|
+
*/
|
|
49
|
+
export function parseContextQualifierTokenParts(token) {
|
|
50
|
+
return Validate.toContextQualifierToken(token).onSuccess((t) => {
|
|
51
|
+
const parts = t.split('=');
|
|
52
|
+
if (parts.length === 1) {
|
|
53
|
+
return succeed({ value: parts[0] });
|
|
54
|
+
}
|
|
55
|
+
return succeed({ qualifier: parts[0], value: parts[1] });
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Parses a context token string into an array of {@link Helpers.IContextTokenParts | context qualifier token parts}.
|
|
60
|
+
* @param token - the context token string to parse.
|
|
61
|
+
* @returns `Success` with the parts if successful, `Failure` with an error message if not.
|
|
62
|
+
* @public
|
|
63
|
+
*/
|
|
64
|
+
export function parseContextTokenParts(token) {
|
|
65
|
+
if (token === '') {
|
|
66
|
+
return succeed([]);
|
|
67
|
+
}
|
|
68
|
+
return mapResults(token.split('|').map((part) => parseContextQualifierTokenParts(part.trim())));
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Erik Fortune
|
|
3
|
+
*
|
|
4
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
* in the Software without restriction, including without limitation the rights
|
|
7
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
* furnished to do so, subject to the following conditions:
|
|
10
|
+
*
|
|
11
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
* copies or substantial portions of the Software.
|
|
13
|
+
*
|
|
14
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
* SOFTWARE.
|
|
21
|
+
*/
|
|
22
|
+
export * from './conditions';
|
|
23
|
+
export * from './context';
|
|
24
|
+
export * from './qualifierDefaultValues';
|
|
25
|
+
export * from './resources';
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Erik Fortune
|
|
3
|
+
*
|
|
4
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
* in the Software without restriction, including without limitation the rights
|
|
7
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
* furnished to do so, subject to the following conditions:
|
|
10
|
+
*
|
|
11
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
* copies or substantial portions of the Software.
|
|
13
|
+
*
|
|
14
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
* SOFTWARE.
|
|
21
|
+
*/
|
|
22
|
+
import { mapResults, succeed } from '@fgv/ts-utils';
|
|
23
|
+
import * as Validate from '../validate';
|
|
24
|
+
/**
|
|
25
|
+
* Converts a {@link Helpers.IQualifierDefaultValueTokenParts | the parts that make up a qualifier default value token} into
|
|
26
|
+
* a syntactically validated {@link QualifierDefaultValueToken | qualifier default value token}.
|
|
27
|
+
* @param parts - the parts to convert
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
export function buildQualifierDefaultValueToken({ qualifier, value }) {
|
|
31
|
+
return Validate.toQualifierDefaultValueToken(`${qualifier}=${value}`);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Converts an array of {@link Helpers.IQualifierDefaultValueTokenParts | qualifier default value token parts} into a
|
|
35
|
+
* syntactically validated {@link QualifierDefaultValuesToken | qualifier default values token}.
|
|
36
|
+
* @param parts - the parts to convert
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
export function buildQualifierDefaultValuesToken(parts) {
|
|
40
|
+
return mapResults(parts.map(buildQualifierDefaultValueToken)).onSuccess((tokens) => Validate.toQualifierDefaultValuesToken(tokens.join('|')));
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Parses a qualifier default value token string into its {@link Helpers.IQualifierDefaultValueTokenParts | parts}.
|
|
44
|
+
* @param token - the token string to parse.
|
|
45
|
+
* @returns `Success` with the parts if successful, `Failure` with an error message if not.
|
|
46
|
+
* @public
|
|
47
|
+
*/
|
|
48
|
+
export function parseQualifierDefaultValueTokenParts(token) {
|
|
49
|
+
return Validate.toQualifierDefaultValueToken(token).onSuccess((t) => {
|
|
50
|
+
const [qualifier, value] = t.split('=');
|
|
51
|
+
return succeed({ qualifier, value });
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Parses a qualifier default values token string into an array of {@link Helpers.IQualifierDefaultValueTokenParts | qualifier default value token parts}.
|
|
56
|
+
* @param token - the qualifier default values token string to parse.
|
|
57
|
+
* @returns `Success` with the parts if successful, `Failure` with an error message if not.
|
|
58
|
+
* @public
|
|
59
|
+
*/
|
|
60
|
+
export function parseQualifierDefaultValuesTokenParts(token) {
|
|
61
|
+
if (token === '') {
|
|
62
|
+
return succeed([]);
|
|
63
|
+
}
|
|
64
|
+
return mapResults(token.split('|').map((part) => parseQualifierDefaultValueTokenParts(part.trim())));
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=qualifierDefaultValues.js.map
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Erik Fortune
|
|
3
|
+
*
|
|
4
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
* in the Software without restriction, including without limitation the rights
|
|
7
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
* furnished to do so, subject to the following conditions:
|
|
10
|
+
*
|
|
11
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
* copies or substantial portions of the Software.
|
|
13
|
+
*
|
|
14
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
* SOFTWARE.
|
|
21
|
+
*/
|
|
22
|
+
import { MessageAggregator, mapResults, succeed } from '@fgv/ts-utils';
|
|
23
|
+
import { toResourceId, toResourceName } from '../validate/resources';
|
|
24
|
+
/**
|
|
25
|
+
* Splits a {@link ResourceId | resource id} into its component {@link ResourceName | resource names}.
|
|
26
|
+
*
|
|
27
|
+
* @param id - The ID to split.
|
|
28
|
+
* @returns `Success`with an array of {@link ResourceName | ResourceName} objects if the ID is valid, or
|
|
29
|
+
* `Failure` with an error message if not.
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
export function splitResourceId(id) {
|
|
33
|
+
/* c8 ignore next 3 - edge case: undefined resource ID should not occur in normal operation */
|
|
34
|
+
if (id === undefined) {
|
|
35
|
+
return succeed([]);
|
|
36
|
+
}
|
|
37
|
+
return mapResults(id.split('.').map(toResourceName));
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Joins a list of {@link ResourceId | resource ID} or {@link ResourceName | resource name} with
|
|
41
|
+
* to create a new {@link ResourceId | resource ID}. Fails if resulting ID is invalid or empty.
|
|
42
|
+
*
|
|
43
|
+
* @param base - The base name or ID to join.
|
|
44
|
+
* @param names - Additional names to join.
|
|
45
|
+
* @returns `Success` with the new ID if the base and names are valid, or `Failure` with an error message
|
|
46
|
+
* if not.
|
|
47
|
+
* @public
|
|
48
|
+
*/
|
|
49
|
+
export function joinResourceIds(...ids) {
|
|
50
|
+
const errors = new MessageAggregator();
|
|
51
|
+
const parts = [];
|
|
52
|
+
ids
|
|
53
|
+
.filter((id) => id !== '')
|
|
54
|
+
.forEach((id) => {
|
|
55
|
+
parts.push(...splitResourceId(id).aggregateError(errors).orDefault([]));
|
|
56
|
+
});
|
|
57
|
+
const id = parts.join('.');
|
|
58
|
+
return errors.returnOrReport(toResourceId(id));
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Joins a list of {@link ResourceId | resource ID} or {@link ResourceName | resource name} with
|
|
62
|
+
* to create a new {@link ResourceId | resource ID}. Returns `undefined` if no names are defined.
|
|
63
|
+
*
|
|
64
|
+
* @param base - The base name or ID to join.
|
|
65
|
+
* @param names - Additional names to join.
|
|
66
|
+
* @returns `Success` with the new ID if the base and names are valid, `Success` with `undefined`
|
|
67
|
+
* if names were present, or `Failure` with an error message if the resulting id is invalid.
|
|
68
|
+
* @public
|
|
69
|
+
*/
|
|
70
|
+
export function joinOptionalResourceIds(...ids) {
|
|
71
|
+
const errors = new MessageAggregator();
|
|
72
|
+
const parts = [];
|
|
73
|
+
ids
|
|
74
|
+
.filter((id) => id !== '')
|
|
75
|
+
.forEach((id) => {
|
|
76
|
+
parts.push(...splitResourceId(id).aggregateError(errors).orDefault([]));
|
|
77
|
+
});
|
|
78
|
+
const id = parts.join('.');
|
|
79
|
+
return errors.returnOrReport(id ? toResourceId(id) : succeed(undefined));
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Gets the name for a resource ID.
|
|
83
|
+
* @param id - The resource ID to get the name for.
|
|
84
|
+
* @returns `Success` with the resource name if found, or `Failure` with an error message if not.
|
|
85
|
+
* @public
|
|
86
|
+
*/
|
|
87
|
+
export function getNameForResourceId(id) {
|
|
88
|
+
return splitResourceId(id).onSuccess((parts) => {
|
|
89
|
+
/* c8 ignore next 1 - tested but coverage having issues */
|
|
90
|
+
return parts.length > 0 ? succeed(parts[parts.length - 1]) : fail(`${id}: invalid resource id`);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=resources.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Erik Fortune
|
|
3
|
+
*
|
|
4
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
* in the Software without restriction, including without limitation the rights
|
|
7
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
* furnished to do so, subject to the following conditions:
|
|
10
|
+
*
|
|
11
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
* copies or substantial portions of the Software.
|
|
13
|
+
*
|
|
14
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
* SOFTWARE.
|
|
21
|
+
*/
|
|
22
|
+
import * as Convert from './convert';
|
|
23
|
+
import * as Helpers from './helpers';
|
|
24
|
+
import * as Validate from './validate';
|
|
25
|
+
export * from './conditions';
|
|
26
|
+
export * from './resources';
|
|
27
|
+
export { Convert, Helpers, Validate };
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Erik Fortune
|
|
3
|
+
*
|
|
4
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
* in the Software without restriction, including without limitation the rights
|
|
7
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
* furnished to do so, subject to the following conditions:
|
|
10
|
+
*
|
|
11
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
* copies or substantial portions of the Software.
|
|
13
|
+
*
|
|
14
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
* SOFTWARE.
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Array of all possible {@link ResourceValueMergeMethod | resource merge type} values.
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
export const allResourceValueMergeMethods = ['augment', 'delete', 'replace'];
|
|
27
|
+
//# sourceMappingURL=resources.js.map
|