@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,184 @@
|
|
|
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 { Collections, fail, succeed } from '@fgv/ts-utils';
|
|
23
|
+
import { Convert, NoMatch, PerfectMatch, Validate } from '../common';
|
|
24
|
+
/**
|
|
25
|
+
* Abstract base class for qualifier types. Provides default implementations for
|
|
26
|
+
* the {@link QualifierTypes.IQualifierType | IQualifierType} interface.
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
export class QualifierType {
|
|
30
|
+
/**
|
|
31
|
+
* {@inheritdoc QualifierTypes.IQualifierType.key}
|
|
32
|
+
*/
|
|
33
|
+
get key() {
|
|
34
|
+
return this._collectible.key;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* {@inheritdoc QualifierTypes.IQualifierType.index}
|
|
38
|
+
*/
|
|
39
|
+
get index() {
|
|
40
|
+
return this._collectible.index;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Constructor for use by derived classes.
|
|
44
|
+
* @param name - The name of the qualifier type.
|
|
45
|
+
* @param allowContextList - Flag indicating whether this qualifier type allows a
|
|
46
|
+
* comma-separated list of runtime values in the context. Defaults to `false`.
|
|
47
|
+
*/
|
|
48
|
+
constructor({ name, index, allowContextList }) {
|
|
49
|
+
this.name = Convert.qualifierTypeName.convert(name).orThrow();
|
|
50
|
+
this.allowContextList = allowContextList === true;
|
|
51
|
+
this._collectible = new Collections.Collectible({
|
|
52
|
+
key: this.name,
|
|
53
|
+
index: index,
|
|
54
|
+
indexConverter: Convert.qualifierTypeIndex
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* {@inheritdoc QualifierTypes.IQualifierType.isValidContextValue}
|
|
59
|
+
*/
|
|
60
|
+
isValidContextValue(value) {
|
|
61
|
+
if (this.isValidConditionValue(value)) {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
if (this.allowContextList) {
|
|
65
|
+
/* c8 ignore next 1 - functional code tested but coverage intermittently missed */
|
|
66
|
+
return value.split(',').every((v) => this.isValidConditionValue(v.trim()));
|
|
67
|
+
}
|
|
68
|
+
/* c8 ignore next 1 - functional code tested but coverage intermittently missed */
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* {@inheritdoc QualifierTypes.IQualifierType.isPotentialMatch}
|
|
73
|
+
*/
|
|
74
|
+
isPotentialMatch(conditionValue, contextValue) {
|
|
75
|
+
if (this.isValidConditionValue(conditionValue) && this.isValidContextValue(contextValue)) {
|
|
76
|
+
return this._matchOne(conditionValue, contextValue, 'matches') !== NoMatch;
|
|
77
|
+
}
|
|
78
|
+
/* c8 ignore next 2 - functional code tested but coverage intermittently missed */
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* {@inheritdoc QualifierTypes.IQualifierType.validateCondition}
|
|
83
|
+
*/
|
|
84
|
+
validateCondition(value, operator) {
|
|
85
|
+
operator = operator !== null && operator !== void 0 ? operator : 'matches';
|
|
86
|
+
/* c8 ignore next 2 - functional error case tested but coverage intermittently missed */
|
|
87
|
+
if (operator !== 'matches') {
|
|
88
|
+
return fail(`${operator}: invalid condition operator`);
|
|
89
|
+
/* c8 ignore next 2 - functional error case tested but coverage intermittently missed */
|
|
90
|
+
}
|
|
91
|
+
else if (!this.isValidConditionValue(value)) {
|
|
92
|
+
return fail(`${value}: invalid condition value for qualifierType ${this.name}`);
|
|
93
|
+
}
|
|
94
|
+
return succeed(value);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* {@inheritdoc QualifierTypes.IQualifierType.validateContextValue}
|
|
98
|
+
*/
|
|
99
|
+
validateContextValue(value) {
|
|
100
|
+
/* c8 ignore next 2 - functional error case tested but coverage intermittently missed */
|
|
101
|
+
if (!this.isValidContextValue(value)) {
|
|
102
|
+
return fail(`${value}: invalid context value for qualifierType ${this.name}`);
|
|
103
|
+
}
|
|
104
|
+
return succeed(value);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* {@inheritdoc QualifierTypes.IQualifierType.matches}
|
|
108
|
+
*/
|
|
109
|
+
matches(condition, context, operator) {
|
|
110
|
+
if (this.allowContextList) {
|
|
111
|
+
return this._matchList(condition, QualifierType._splitContext(context), operator);
|
|
112
|
+
}
|
|
113
|
+
return this._matchOne(condition, context, operator);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* {@inheritdoc QualifierTypes.IQualifierType.setIndex}
|
|
117
|
+
*/
|
|
118
|
+
setIndex(index) {
|
|
119
|
+
return this._collectible.setIndex(index);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* {@inheritdoc Validate.isValidQualifierTypeName}
|
|
123
|
+
*/
|
|
124
|
+
static isValidName(name) {
|
|
125
|
+
return Validate.isValidQualifierTypeName(name);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* {@inheritdoc Validate.isValidQualifierTypeIndex}
|
|
129
|
+
*/
|
|
130
|
+
static isValidIndex(index) {
|
|
131
|
+
return Validate.isValidQualifierTypeIndex(index);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Compares two qualifier types by index.
|
|
135
|
+
* @param t1 - The first qualifier type to compare.
|
|
136
|
+
* @param t2 - The second qualifier type to compare.
|
|
137
|
+
* @returns a number indicating the relative order of the two qualifier types.
|
|
138
|
+
*/
|
|
139
|
+
static compare(t1, t2) {
|
|
140
|
+
var _a, _b;
|
|
141
|
+
const i1 = (_a = t1._collectible.index) !== null && _a !== void 0 ? _a : -1;
|
|
142
|
+
const i2 = (_b = t2._collectible.index) !== null && _b !== void 0 ? _b : -1;
|
|
143
|
+
let diff = i1 - i2;
|
|
144
|
+
if (diff === 0) {
|
|
145
|
+
diff = t1.name.localeCompare(t2.name);
|
|
146
|
+
}
|
|
147
|
+
return diff;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Matches a single condition value against a list of context values.
|
|
151
|
+
* @param condition - The {@link QualifierConditionValue | condition value} to match.
|
|
152
|
+
* @param context - The comma-separated list of {@link QualifierContextValue | context values} to match.
|
|
153
|
+
* @param operator - The {@link ConditionOperator | operator} to use in the match.
|
|
154
|
+
* @returns a {@link QualifierMatchScore | score} indicating the extent to which
|
|
155
|
+
* the condition matches the context value.
|
|
156
|
+
* @public
|
|
157
|
+
*/
|
|
158
|
+
_matchList(condition, context, operator) {
|
|
159
|
+
const scorePerPosition = 1 / context.length;
|
|
160
|
+
let baseScore = PerfectMatch - scorePerPosition;
|
|
161
|
+
for (let i = 0; i < context.length; i++) {
|
|
162
|
+
const score = this._matchOne(condition, context[i], operator);
|
|
163
|
+
if (score > NoMatch) {
|
|
164
|
+
const adjusted = baseScore + scorePerPosition * score;
|
|
165
|
+
if (Validate.isValidQualifierMatchScore(adjusted)) {
|
|
166
|
+
return adjusted;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
baseScore -= scorePerPosition;
|
|
170
|
+
}
|
|
171
|
+
return NoMatch;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Splits a comma-separated {@link QualifierContextValue | context value} into an
|
|
175
|
+
* array of individual values.
|
|
176
|
+
* @param value - The value to split.
|
|
177
|
+
* @returns an array of individual context values.
|
|
178
|
+
* @public
|
|
179
|
+
*/
|
|
180
|
+
static _splitContext(value) {
|
|
181
|
+
return value.split(',').map((s) => s.trim());
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
//# sourceMappingURL=qualifierType.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 * as Common from '../common';
|
|
23
|
+
import { Collections, ValidatingConvertingCollector, captureResult, fail, succeed } from '@fgv/ts-utils';
|
|
24
|
+
import { QualifierType } from './qualifierType';
|
|
25
|
+
/**
|
|
26
|
+
* Collector for {@link QualifierTypes.QualifierType | QualifierType} objects.
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
export class QualifierTypeCollector extends ValidatingConvertingCollector {
|
|
30
|
+
/**
|
|
31
|
+
* Constructor for a {@link QualifierTypes.QualifierTypeCollector | QualifierTypeCollector} object.
|
|
32
|
+
* @param params - Optional {@link QualifierTypes.IQualifierTypeCollectorCreateParams | parameters}
|
|
33
|
+
* used to construct the collector.
|
|
34
|
+
*/
|
|
35
|
+
constructor({ qualifierTypes }) {
|
|
36
|
+
super({
|
|
37
|
+
converters: new Collections.KeyValueConverters({
|
|
38
|
+
key: Common.Convert.qualifierTypeName,
|
|
39
|
+
value: QualifierTypeCollector._toQualifierType
|
|
40
|
+
}),
|
|
41
|
+
factory: QualifierTypeCollector._qualifierTypeFactory
|
|
42
|
+
});
|
|
43
|
+
/* c8 ignore next 1 - coverage seems to intermittently miss the branch */
|
|
44
|
+
qualifierTypes === null || qualifierTypes === void 0 ? void 0 : qualifierTypes.forEach((qt) => {
|
|
45
|
+
this.add(qt).orThrow();
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Creates a new {@link QualifierTypes.QualifierTypeCollector | QualifierTypeCollector} object.
|
|
50
|
+
* @param params - Optional {@link QualifierTypes.IQualifierTypeCollectorCreateParams | parameters}
|
|
51
|
+
* used to create the collector.
|
|
52
|
+
* @returns `Success` with the new collector if successful, or `Failure` if not.
|
|
53
|
+
*/
|
|
54
|
+
static create(params) {
|
|
55
|
+
/* c8 ignore next 1 - coverage seems to miss the branch intermittently */
|
|
56
|
+
params = params !== null && params !== void 0 ? params : {};
|
|
57
|
+
return captureResult(() => new QualifierTypeCollector(params));
|
|
58
|
+
}
|
|
59
|
+
static _qualifierTypeFactory(key, index, value) {
|
|
60
|
+
return succeed(value);
|
|
61
|
+
}
|
|
62
|
+
static _toQualifierType(from) {
|
|
63
|
+
return from instanceof QualifierType ? succeed(from) : fail('not a QualifierType');
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=qualifierTypeCollector.js.map
|
|
@@ -0,0 +1,200 @@
|
|
|
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 { captureResult, fail, succeed, mapResults } from '@fgv/ts-utils';
|
|
23
|
+
import { Convert, NoMatch, PerfectMatch, Validate } from '../common';
|
|
24
|
+
import { QualifierType } from './qualifierType';
|
|
25
|
+
import { LiteralValueHierarchy } from './literalValueHierarchy';
|
|
26
|
+
import * as Config from './config';
|
|
27
|
+
import { sanitizeJsonObject } from '@fgv/ts-json-base';
|
|
28
|
+
/**
|
|
29
|
+
* Qualifier type for territory values. Territories are two-letter ISO-3166-2
|
|
30
|
+
* Alpha-2 country codes. Canonical territory codes are uppercase, but this
|
|
31
|
+
* implementation handles incorrect casing.
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
export class TerritoryQualifierType extends QualifierType {
|
|
35
|
+
/**
|
|
36
|
+
* Creates a new {@link QualifierTypes.TerritoryQualifierType | TerritoryQualifierType} instance.
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
constructor({ acceptLowercase, allowedTerritories, allowContextList, name, index, hierarchy }) {
|
|
40
|
+
/* c8 ignore next 7 - coverage seems to be missing coalescing branches */
|
|
41
|
+
name = name !== null && name !== void 0 ? name : 'territory';
|
|
42
|
+
const validIndex = index !== undefined ? Convert.qualifierTypeIndex.convert(index).orThrow() : undefined;
|
|
43
|
+
const validTerritories = allowedTerritories !== undefined
|
|
44
|
+
? mapResults(allowedTerritories.map((t) => TerritoryQualifierType.toTerritoryConditionValue(t.toUpperCase()))).orThrow()
|
|
45
|
+
: undefined;
|
|
46
|
+
allowContextList = allowContextList === true;
|
|
47
|
+
super({
|
|
48
|
+
name: name,
|
|
49
|
+
allowContextList,
|
|
50
|
+
index: validIndex
|
|
51
|
+
});
|
|
52
|
+
/**
|
|
53
|
+
* {@inheritdoc QualifierTypes.IQualifierType.systemTypeName}
|
|
54
|
+
*/
|
|
55
|
+
this.systemTypeName = Convert.qualifierTypeName
|
|
56
|
+
.convert('territory')
|
|
57
|
+
.orThrow();
|
|
58
|
+
this.allowedTerritories = validTerritories;
|
|
59
|
+
this.acceptLowercase = acceptLowercase === true;
|
|
60
|
+
if (hierarchy) {
|
|
61
|
+
/* c8 ignore next 5 - defensive coding: allowedTerritories ?? [] fallback enables open values mode */
|
|
62
|
+
this.hierarchy = LiteralValueHierarchy.create({
|
|
63
|
+
values: allowedTerritories !== null && allowedTerritories !== void 0 ? allowedTerritories : [],
|
|
64
|
+
hierarchy: hierarchy
|
|
65
|
+
}).orThrow();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* {@inheritdoc QualifierTypes.QualifierType.isValidConditionValue}
|
|
70
|
+
*/
|
|
71
|
+
isValidConditionValue(value) {
|
|
72
|
+
const normalized = this.acceptLowercase ? value.toUpperCase() : value;
|
|
73
|
+
/* c8 ignore next 6 - edge case: invalid territory values and allowed territory filtering rarely hit */
|
|
74
|
+
if (!TerritoryQualifierType.isValidTerritoryConditionValue(normalized)) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
if (this.allowedTerritories !== undefined) {
|
|
78
|
+
return this.allowedTerritories.includes(normalized);
|
|
79
|
+
}
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Creates a new {@link QualifierTypes.TerritoryQualifierType | TerritoryQualifierType} instance.
|
|
84
|
+
* @param params - Optional {@link QualifierTypes.ITerritoryQualifierTypeCreateParams | parameters}
|
|
85
|
+
* to use when creating the instance.
|
|
86
|
+
* @returns `Success` with the new {@link QualifierTypes.TerritoryQualifierType | TerritoryQualifierType}
|
|
87
|
+
* if successful, `Failure` with an error message otherwise.
|
|
88
|
+
* @public
|
|
89
|
+
*/
|
|
90
|
+
static create(params) {
|
|
91
|
+
/* c8 ignore next 1 - coverage having problems with conditional branches */
|
|
92
|
+
params = params !== null && params !== void 0 ? params : {};
|
|
93
|
+
return captureResult(() => new TerritoryQualifierType(params));
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Creates a new {@link QualifierTypes.TerritoryQualifierType | TerritoryQualifierType} from a configuration object.
|
|
97
|
+
* @param config - The {@link QualifierTypes.Config.IQualifierTypeConfig | configuration object} containing
|
|
98
|
+
* the name, systemType, and optional territory-specific configuration including allowed territories and hierarchy.
|
|
99
|
+
* @returns `Success` with the new {@link QualifierTypes.TerritoryQualifierType | TerritoryQualifierType}
|
|
100
|
+
* if successful, `Failure` with an error message otherwise.
|
|
101
|
+
* @public
|
|
102
|
+
*/
|
|
103
|
+
static createFromConfig(config) {
|
|
104
|
+
var _a;
|
|
105
|
+
const territoryConfig = (_a = config.configuration) !== null && _a !== void 0 ? _a : {};
|
|
106
|
+
return sanitizeJsonObject({
|
|
107
|
+
name: config.name,
|
|
108
|
+
allowContextList: territoryConfig.allowContextList === true,
|
|
109
|
+
allowedTerritories: territoryConfig.allowedTerritories,
|
|
110
|
+
acceptLowercase: territoryConfig.acceptLowercase === true,
|
|
111
|
+
hierarchy: territoryConfig.hierarchy
|
|
112
|
+
}).onSuccess(TerritoryQualifierType.create);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Gets the {@link QualifierTypes.Config.ISystemTerritoryQualifierTypeConfig | strongly typed configuration}
|
|
116
|
+
* for this qualifier type.
|
|
117
|
+
* @returns `Success` with the configuration if successful, `Failure` with an error message otherwise.
|
|
118
|
+
*/
|
|
119
|
+
getConfiguration() {
|
|
120
|
+
return this.getConfigurationJson().onSuccess((json) => Config.Convert.systemTerritoryQualifierTypeConfig.convert(json));
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* {@inheritdoc QualifierTypes.IQualifierType.getConfigurationJson}
|
|
124
|
+
*/
|
|
125
|
+
getConfigurationJson() {
|
|
126
|
+
const hierarchy = this.hierarchy ? { hierarchy: this.hierarchy.asRecord() } : {};
|
|
127
|
+
const allowedTerritories = this.allowedTerritories
|
|
128
|
+
? { allowedTerritories: [...this.allowedTerritories] }
|
|
129
|
+
: {};
|
|
130
|
+
return succeed({
|
|
131
|
+
name: this.name,
|
|
132
|
+
systemType: 'territory',
|
|
133
|
+
configuration: Object.assign(Object.assign({ allowContextList: this.allowContextList, acceptLowercase: this.acceptLowercase }, allowedTerritories), hierarchy)
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* {@inheritdoc QualifierTypes.IQualifierType.validateConfigurationJson}
|
|
138
|
+
*/
|
|
139
|
+
validateConfigurationJson(from) {
|
|
140
|
+
return Config.Convert.systemTerritoryQualifierTypeConfig.convert(from);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Validates a {@link QualifierTypes.Config.ISystemTerritoryQualifierTypeConfig | strongly typed configuration object}
|
|
144
|
+
* for this qualifier type.
|
|
145
|
+
* @param from - The unknown data to validate as a configuration object.
|
|
146
|
+
* @returns `Success` with the validated configuration if successful, `Failure` with an error message otherwise.
|
|
147
|
+
*/
|
|
148
|
+
validateConfiguration(from) {
|
|
149
|
+
return this.validateConfigurationJson(from).onSuccess((json) => Config.Convert.systemTerritoryQualifierTypeConfig.convert(json));
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* {@inheritdoc QualifierTypes.QualifierType._matchOne}
|
|
153
|
+
*/
|
|
154
|
+
_matchOne(condition, context, __operator) {
|
|
155
|
+
if (this.isValidConditionValue(condition) && this.isValidContextValue(context)) {
|
|
156
|
+
// Normalize to uppercase for territory codes
|
|
157
|
+
const normalizedCondition = condition.toUpperCase();
|
|
158
|
+
const normalizedContext = context.toUpperCase();
|
|
159
|
+
if (normalizedCondition === normalizedContext) {
|
|
160
|
+
return PerfectMatch;
|
|
161
|
+
}
|
|
162
|
+
/* c8 ignore next 8 - edge case: hierarchy matching and fallback logic rarely used */
|
|
163
|
+
if (this.hierarchy) {
|
|
164
|
+
return this.hierarchy.match(normalizedCondition, normalizedContext, __operator);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return NoMatch;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Determines whether a value is a valid condition value for a territory qualifier.
|
|
171
|
+
* @param value - The value to validate.
|
|
172
|
+
* @param acceptLowercase - Flag indicating whether the qualifier type should accept lowercase territory codes.
|
|
173
|
+
* Defaults to `false`.
|
|
174
|
+
* @returns `true` if the value is a valid condition value, `false` otherwise.
|
|
175
|
+
* @public
|
|
176
|
+
*/
|
|
177
|
+
static isValidTerritoryConditionValue(value, acceptLowercase) {
|
|
178
|
+
/* c8 ignore next 3 - edge case: lowercase validation rarely fails */
|
|
179
|
+
if (acceptLowercase !== true && value !== value.toUpperCase()) {
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
return Validate.RegularExpressions.territoryCode.test(value.toUpperCase());
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Converts a string value to a territory condition value.
|
|
186
|
+
* @param value - The value to convert.
|
|
187
|
+
* @param acceptLowercase - Flag indicating whether the qualifier type should accept lowercase territory codes.
|
|
188
|
+
* Defaults to `false`.
|
|
189
|
+
* @returns `Success` with the converted value if successful, `Failure` with an error
|
|
190
|
+
* message otherwise.
|
|
191
|
+
* @public
|
|
192
|
+
*/
|
|
193
|
+
static toTerritoryConditionValue(value, acceptLowercase) {
|
|
194
|
+
const normalized = value.toUpperCase();
|
|
195
|
+
return TerritoryQualifierType.isValidTerritoryConditionValue(normalized, acceptLowercase)
|
|
196
|
+
? succeed(normalized)
|
|
197
|
+
: fail(`${value}: invalid territory code`);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
//# sourceMappingURL=territoryQualifierType.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 { Converters, populateObject, fail, succeed } from '@fgv/ts-utils';
|
|
23
|
+
import { Validate } from '../../common';
|
|
24
|
+
/* eslint-disable @rushstack/typedef-var */
|
|
25
|
+
/**
|
|
26
|
+
* Converter for a {@link Qualifiers.IQualifierDecl | qualifier declaration}.
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
export const qualifierDecl = Converters.strictObject({
|
|
30
|
+
name: Converters.string,
|
|
31
|
+
typeName: Converters.string,
|
|
32
|
+
defaultPriority: Converters.number,
|
|
33
|
+
token: Converters.string.optional(),
|
|
34
|
+
tokenIsOptional: Converters.boolean.optional(),
|
|
35
|
+
defaultValue: Converters.string.optional()
|
|
36
|
+
});
|
|
37
|
+
/**
|
|
38
|
+
* Converter which constructs a {@link Qualifiers.IValidatedQualifierDecl | validated qualifier declaration}
|
|
39
|
+
* from a {@link Qualifiers.IQualifierDecl | qualifier declaration}, instantiating qualifier types by name
|
|
40
|
+
* from a supplied {@link Qualifiers.Convert.IQualifierDeclConvertContext | conversion context}.
|
|
41
|
+
* @public
|
|
42
|
+
*/
|
|
43
|
+
export const validatedQualifierDecl = Converters.generic((from, __self, context) => {
|
|
44
|
+
/* c8 ignore next 7 - this is tested but code coverage is losing its mind */
|
|
45
|
+
if (context === undefined) {
|
|
46
|
+
return fail('validatedQualifierDecl converter requires a context');
|
|
47
|
+
}
|
|
48
|
+
const validatedIndexResult = context.qualifierIndex !== undefined
|
|
49
|
+
? Validate.toQualifierIndex(context.qualifierIndex)
|
|
50
|
+
: succeed(undefined);
|
|
51
|
+
return qualifierDecl.convert(from).onSuccess((decl) => {
|
|
52
|
+
return context.qualifierTypes.validating.get(decl.typeName).asResult.onSuccess((type) => {
|
|
53
|
+
return populateObject({
|
|
54
|
+
name: () => Validate.toQualifierName(decl.name),
|
|
55
|
+
token: () => { var _a; return Validate.toQualifierName((_a = decl.token) !== null && _a !== void 0 ? _a : decl.name); },
|
|
56
|
+
tokenIsOptional: () => succeed(decl.tokenIsOptional === true),
|
|
57
|
+
type: () => succeed(type),
|
|
58
|
+
defaultPriority: () => Validate.toConditionPriority(decl.defaultPriority),
|
|
59
|
+
defaultValue: () => decl.defaultValue ? type.validateContextValue(decl.defaultValue) : succeed(undefined),
|
|
60
|
+
index: () => validatedIndexResult
|
|
61
|
+
}).onSuccess((validated) => {
|
|
62
|
+
if (context.qualifierIndex !== undefined) {
|
|
63
|
+
context.qualifierIndex++;
|
|
64
|
+
}
|
|
65
|
+
return succeed(validated);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
//# sourceMappingURL=decls.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
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 './decls';
|
|
23
|
+
export * from './qualifier';
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,40 @@
|
|
|
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, fail } from '@fgv/ts-utils';
|
|
23
|
+
/**
|
|
24
|
+
* Converter which choose a qualifier by name or number from a
|
|
25
|
+
* supplied {@link Qualifiers.Convert.IQualifierConvertContext | conversion context}.
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
export const qualifier = Converters.generic((from, __self, context) => {
|
|
29
|
+
if (context === undefined) {
|
|
30
|
+
return fail('qualifier converter requires a context');
|
|
31
|
+
}
|
|
32
|
+
if (typeof from === 'string') {
|
|
33
|
+
return context.qualifiers.validating.get(from);
|
|
34
|
+
}
|
|
35
|
+
else if (typeof from === 'number') {
|
|
36
|
+
return context.qualifiers.getAt(from);
|
|
37
|
+
}
|
|
38
|
+
return fail('qualifier converter requires a string or number');
|
|
39
|
+
});
|
|
40
|
+
//# sourceMappingURL=qualifier.js.map
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
export * from './qualifier';
|
|
24
|
+
export * from './qualifierDecl';
|
|
25
|
+
export * from './qualifierCollector';
|
|
26
|
+
export * from './qualifierDefaultValueDecls';
|
|
27
|
+
export * from './qualifierDefaultValueToken';
|
|
28
|
+
export { Convert };
|
|
29
|
+
//# sourceMappingURL=index.js.map
|