@fgv/ts-res 4.5.0-0
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/LICENSE +21 -0
- package/README.md +27 -0
- package/dist/ts-res.d.ts +4282 -0
- package/dist/tsdoc-metadata.json +11 -0
- package/lib/index.d.ts +12 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +79 -0
- package/lib/index.js.map +1 -0
- package/lib/packlets/common/conditions.d.ts +148 -0
- package/lib/packlets/common/conditions.d.ts.map +1 -0
- package/lib/packlets/common/conditions.js +50 -0
- package/lib/packlets/common/conditions.js.map +1 -0
- package/lib/packlets/common/convert.d.ts +111 -0
- package/lib/packlets/common/convert.d.ts.map +1 -0
- package/lib/packlets/common/convert.js +173 -0
- package/lib/packlets/common/convert.js.map +1 -0
- package/lib/packlets/common/helpers/conditions.d.ts +39 -0
- package/lib/packlets/common/helpers/conditions.d.ts.map +1 -0
- package/lib/packlets/common/helpers/conditions.js +105 -0
- package/lib/packlets/common/helpers/conditions.js.map +1 -0
- package/lib/packlets/common/helpers/index.d.ts +3 -0
- package/lib/packlets/common/helpers/index.d.ts.map +1 -0
- package/lib/packlets/common/helpers/index.js +40 -0
- package/lib/packlets/common/helpers/index.js.map +1 -0
- package/lib/packlets/common/helpers/resources.d.ts +34 -0
- package/lib/packlets/common/helpers/resources.d.ts.map +1 -0
- package/lib/packlets/common/helpers/resources.js +81 -0
- package/lib/packlets/common/helpers/resources.js.map +1 -0
- package/lib/packlets/common/index.d.ts +7 -0
- package/lib/packlets/common/index.d.ts.map +1 -0
- package/lib/packlets/common/index.js +69 -0
- package/lib/packlets/common/index.js.map +1 -0
- package/lib/packlets/common/resources.d.ts +41 -0
- package/lib/packlets/common/resources.d.ts.map +1 -0
- package/lib/packlets/common/resources.js +30 -0
- package/lib/packlets/common/resources.js.map +1 -0
- package/lib/packlets/common/validate/conditions.d.ts +248 -0
- package/lib/packlets/common/validate/conditions.d.ts.map +1 -0
- package/lib/packlets/common/validate/conditions.js +436 -0
- package/lib/packlets/common/validate/conditions.js.map +1 -0
- package/lib/packlets/common/validate/index.d.ts +5 -0
- package/lib/packlets/common/validate/index.d.ts.map +1 -0
- package/lib/packlets/common/validate/index.js +65 -0
- package/lib/packlets/common/validate/index.js.map +1 -0
- package/lib/packlets/common/validate/regularExpressions.d.ts +39 -0
- package/lib/packlets/common/validate/regularExpressions.d.ts.map +1 -0
- package/lib/packlets/common/validate/regularExpressions.js +63 -0
- package/lib/packlets/common/validate/regularExpressions.js.map +1 -0
- package/lib/packlets/common/validate/resources.d.ts +97 -0
- package/lib/packlets/common/validate/resources.d.ts.map +1 -0
- package/lib/packlets/common/validate/resources.js +171 -0
- package/lib/packlets/common/validate/resources.js.map +1 -0
- package/lib/packlets/conditions/condition.d.ts +91 -0
- package/lib/packlets/conditions/condition.d.ts.map +1 -0
- package/lib/packlets/conditions/condition.js +146 -0
- package/lib/packlets/conditions/condition.js.map +1 -0
- package/lib/packlets/conditions/conditionCollector.d.ts +54 -0
- package/lib/packlets/conditions/conditionCollector.d.ts.map +1 -0
- package/lib/packlets/conditions/conditionCollector.js +72 -0
- package/lib/packlets/conditions/conditionCollector.js.map +1 -0
- package/lib/packlets/conditions/conditionDecls.d.ts +26 -0
- package/lib/packlets/conditions/conditionDecls.d.ts.map +1 -0
- package/lib/packlets/conditions/conditionDecls.js +24 -0
- package/lib/packlets/conditions/conditionDecls.js.map +1 -0
- package/lib/packlets/conditions/conditionSet.d.ts +99 -0
- package/lib/packlets/conditions/conditionSet.d.ts.map +1 -0
- package/lib/packlets/conditions/conditionSet.js +164 -0
- package/lib/packlets/conditions/conditionSet.js.map +1 -0
- package/lib/packlets/conditions/conditionSetCollector.d.ts +65 -0
- package/lib/packlets/conditions/conditionSetCollector.d.ts.map +1 -0
- package/lib/packlets/conditions/conditionSetCollector.js +90 -0
- package/lib/packlets/conditions/conditionSetCollector.js.map +1 -0
- package/lib/packlets/conditions/conditionSetDecls.d.ts +18 -0
- package/lib/packlets/conditions/conditionSetDecls.d.ts.map +1 -0
- package/lib/packlets/conditions/conditionSetDecls.js +24 -0
- package/lib/packlets/conditions/conditionSetDecls.js.map +1 -0
- package/lib/packlets/conditions/conditionToken.d.ts +86 -0
- package/lib/packlets/conditions/conditionToken.d.ts.map +1 -0
- package/lib/packlets/conditions/conditionToken.js +150 -0
- package/lib/packlets/conditions/conditionToken.js.map +1 -0
- package/lib/packlets/conditions/convert/conditionSetDecls.d.ts +24 -0
- package/lib/packlets/conditions/convert/conditionSetDecls.d.ts.map +1 -0
- package/lib/packlets/conditions/convert/conditionSetDecls.js +54 -0
- package/lib/packlets/conditions/convert/conditionSetDecls.js.map +1 -0
- package/lib/packlets/conditions/convert/decls.d.ts +24 -0
- package/lib/packlets/conditions/convert/decls.d.ts.map +1 -0
- package/lib/packlets/conditions/convert/decls.js +111 -0
- package/lib/packlets/conditions/convert/decls.js.map +1 -0
- package/lib/packlets/conditions/convert/index.d.ts +3 -0
- package/lib/packlets/conditions/convert/index.d.ts.map +1 -0
- package/lib/packlets/conditions/convert/index.js +40 -0
- package/lib/packlets/conditions/convert/index.js.map +1 -0
- package/lib/packlets/conditions/index.d.ts +10 -0
- package/lib/packlets/conditions/index.d.ts.map +1 -0
- package/lib/packlets/conditions/index.js +70 -0
- package/lib/packlets/conditions/index.js.map +1 -0
- package/lib/packlets/decisions/abstractDecision.d.ts +39 -0
- package/lib/packlets/decisions/abstractDecision.d.ts.map +1 -0
- package/lib/packlets/decisions/abstractDecision.js +63 -0
- package/lib/packlets/decisions/abstractDecision.js.map +1 -0
- package/lib/packlets/decisions/abstractDecisionCollector.d.ts +59 -0
- package/lib/packlets/decisions/abstractDecisionCollector.d.ts.map +1 -0
- package/lib/packlets/decisions/abstractDecisionCollector.js +92 -0
- package/lib/packlets/decisions/abstractDecisionCollector.js.map +1 -0
- package/lib/packlets/decisions/candidate.d.ts +58 -0
- package/lib/packlets/decisions/candidate.d.ts.map +1 -0
- package/lib/packlets/decisions/candidate.js +80 -0
- package/lib/packlets/decisions/candidate.js.map +1 -0
- package/lib/packlets/decisions/common.d.ts +15 -0
- package/lib/packlets/decisions/common.d.ts.map +1 -0
- package/lib/packlets/decisions/common.js +24 -0
- package/lib/packlets/decisions/common.js.map +1 -0
- package/lib/packlets/decisions/concreteDecision.d.ts +74 -0
- package/lib/packlets/decisions/concreteDecision.d.ts.map +1 -0
- package/lib/packlets/decisions/concreteDecision.js +114 -0
- package/lib/packlets/decisions/concreteDecision.js.map +1 -0
- package/lib/packlets/decisions/decision.d.ts +91 -0
- package/lib/packlets/decisions/decision.d.ts.map +1 -0
- package/lib/packlets/decisions/decision.js +126 -0
- package/lib/packlets/decisions/decision.js.map +1 -0
- package/lib/packlets/decisions/index.d.ts +7 -0
- package/lib/packlets/decisions/index.d.ts.map +1 -0
- package/lib/packlets/decisions/index.js +44 -0
- package/lib/packlets/decisions/index.js.map +1 -0
- package/lib/packlets/import/fsItem.d.ts +99 -0
- package/lib/packlets/import/fsItem.d.ts.map +1 -0
- package/lib/packlets/import/fsItem.js +174 -0
- package/lib/packlets/import/fsItem.js.map +1 -0
- package/lib/packlets/import/importContext.d.ts +85 -0
- package/lib/packlets/import/importContext.d.ts.map +1 -0
- package/lib/packlets/import/importContext.js +94 -0
- package/lib/packlets/import/importContext.js.map +1 -0
- package/lib/packlets/import/importManager.d.ts +93 -0
- package/lib/packlets/import/importManager.d.ts.map +1 -0
- package/lib/packlets/import/importManager.js +133 -0
- package/lib/packlets/import/importManager.js.map +1 -0
- package/lib/packlets/import/importable.d.ts +71 -0
- package/lib/packlets/import/importable.d.ts.map +1 -0
- package/lib/packlets/import/importable.js +35 -0
- package/lib/packlets/import/importable.js.map +1 -0
- package/lib/packlets/import/importers/collectionImporter.d.ts +60 -0
- package/lib/packlets/import/importers/collectionImporter.d.ts.map +1 -0
- package/lib/packlets/import/importers/collectionImporter.js +146 -0
- package/lib/packlets/import/importers/collectionImporter.js.map +1 -0
- package/lib/packlets/import/importers/fsItemImporter.d.ts +49 -0
- package/lib/packlets/import/importers/fsItemImporter.d.ts.map +1 -0
- package/lib/packlets/import/importers/fsItemImporter.js +120 -0
- package/lib/packlets/import/importers/fsItemImporter.js.map +1 -0
- package/lib/packlets/import/importers/importer.d.ts +31 -0
- package/lib/packlets/import/importers/importer.d.ts.map +1 -0
- package/lib/packlets/import/importers/importer.js +24 -0
- package/lib/packlets/import/importers/importer.js.map +1 -0
- package/lib/packlets/import/importers/index.d.ts +6 -0
- package/lib/packlets/import/importers/index.d.ts.map +1 -0
- package/lib/packlets/import/importers/index.js +43 -0
- package/lib/packlets/import/importers/index.js.map +1 -0
- package/lib/packlets/import/importers/jsonImporter.d.ts +32 -0
- package/lib/packlets/import/importers/jsonImporter.d.ts.map +1 -0
- package/lib/packlets/import/importers/jsonImporter.js +140 -0
- package/lib/packlets/import/importers/jsonImporter.js.map +1 -0
- package/lib/packlets/import/importers/pathImporter.d.ts +61 -0
- package/lib/packlets/import/importers/pathImporter.d.ts.map +1 -0
- package/lib/packlets/import/importers/pathImporter.js +87 -0
- package/lib/packlets/import/importers/pathImporter.js.map +1 -0
- package/lib/packlets/import/index.d.ts +7 -0
- package/lib/packlets/import/index.d.ts.map +1 -0
- package/lib/packlets/import/index.js +67 -0
- package/lib/packlets/import/index.js.map +1 -0
- package/lib/packlets/qualifier-types/convert.d.ts +19 -0
- package/lib/packlets/qualifier-types/convert.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/convert.js +45 -0
- package/lib/packlets/qualifier-types/convert.js.map +1 -0
- package/lib/packlets/qualifier-types/index.d.ts +8 -0
- package/lib/packlets/qualifier-types/index.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/index.js +68 -0
- package/lib/packlets/qualifier-types/index.js.map +1 -0
- package/lib/packlets/qualifier-types/languageQualifierType.d.ts +56 -0
- package/lib/packlets/qualifier-types/languageQualifierType.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/languageQualifierType.js +87 -0
- package/lib/packlets/qualifier-types/languageQualifierType.js.map +1 -0
- package/lib/packlets/qualifier-types/literalQualifierType.d.ts +92 -0
- package/lib/packlets/qualifier-types/literalQualifierType.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/literalQualifierType.js +114 -0
- package/lib/packlets/qualifier-types/literalQualifierType.js.map +1 -0
- package/lib/packlets/qualifier-types/qualifierType.d.ts +184 -0
- package/lib/packlets/qualifier-types/qualifierType.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/qualifierType.js +173 -0
- package/lib/packlets/qualifier-types/qualifierType.js.map +1 -0
- package/lib/packlets/qualifier-types/qualifierTypeCollector.d.ts +40 -0
- package/lib/packlets/qualifier-types/qualifierTypeCollector.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/qualifierTypeCollector.js +102 -0
- package/lib/packlets/qualifier-types/qualifierTypeCollector.js.map +1 -0
- package/lib/packlets/qualifier-types/territoryQualifierType.d.ts +74 -0
- package/lib/packlets/qualifier-types/territoryQualifierType.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/territoryQualifierType.js +113 -0
- package/lib/packlets/qualifier-types/territoryQualifierType.js.map +1 -0
- package/lib/packlets/qualifiers/convert/decls.d.ts +23 -0
- package/lib/packlets/qualifiers/convert/decls.d.ts.map +1 -0
- package/lib/packlets/qualifiers/convert/decls.js +71 -0
- package/lib/packlets/qualifiers/convert/decls.js.map +1 -0
- package/lib/packlets/qualifiers/convert/index.d.ts +3 -0
- package/lib/packlets/qualifiers/convert/index.d.ts.map +1 -0
- package/lib/packlets/qualifiers/convert/index.js +40 -0
- package/lib/packlets/qualifiers/convert/index.js.map +1 -0
- package/lib/packlets/qualifiers/convert/qualifier.d.ts +17 -0
- package/lib/packlets/qualifiers/convert/qualifier.d.ts.map +1 -0
- package/lib/packlets/qualifiers/convert/qualifier.js +43 -0
- package/lib/packlets/qualifiers/convert/qualifier.js.map +1 -0
- package/lib/packlets/qualifiers/index.d.ts +6 -0
- package/lib/packlets/qualifiers/index.d.ts.map +1 -0
- package/lib/packlets/qualifiers/index.js +66 -0
- package/lib/packlets/qualifiers/index.js.map +1 -0
- package/lib/packlets/qualifiers/qualifier.d.ts +68 -0
- package/lib/packlets/qualifiers/qualifier.d.ts.map +1 -0
- package/lib/packlets/qualifiers/qualifier.js +87 -0
- package/lib/packlets/qualifiers/qualifier.js.map +1 -0
- package/lib/packlets/qualifiers/qualifierCollector.d.ts +90 -0
- package/lib/packlets/qualifiers/qualifierCollector.d.ts.map +1 -0
- package/lib/packlets/qualifiers/qualifierCollector.js +157 -0
- package/lib/packlets/qualifiers/qualifierCollector.js.map +1 -0
- package/lib/packlets/qualifiers/qualifierDecl.d.ts +46 -0
- package/lib/packlets/qualifiers/qualifierDecl.d.ts.map +1 -0
- package/lib/packlets/qualifiers/qualifierDecl.js +24 -0
- package/lib/packlets/qualifiers/qualifierDecl.js.map +1 -0
- package/lib/packlets/resource-json/convert.d.ts +54 -0
- package/lib/packlets/resource-json/convert.d.ts.map +1 -0
- package/lib/packlets/resource-json/convert.js +139 -0
- package/lib/packlets/resource-json/convert.js.map +1 -0
- package/lib/packlets/resource-json/helpers.d.ts +41 -0
- package/lib/packlets/resource-json/helpers.d.ts.map +1 -0
- package/lib/packlets/resource-json/helpers.js +96 -0
- package/lib/packlets/resource-json/helpers.js.map +1 -0
- package/lib/packlets/resource-json/index.d.ts +9 -0
- package/lib/packlets/resource-json/index.d.ts.map +1 -0
- package/lib/packlets/resource-json/index.js +72 -0
- package/lib/packlets/resource-json/index.js.map +1 -0
- package/lib/packlets/resource-json/json.d.ts +182 -0
- package/lib/packlets/resource-json/json.d.ts.map +1 -0
- package/lib/packlets/resource-json/json.js +24 -0
- package/lib/packlets/resource-json/json.js.map +1 -0
- package/lib/packlets/resource-json/normalized.d.ts +123 -0
- package/lib/packlets/resource-json/normalized.d.ts.map +1 -0
- package/lib/packlets/resource-json/normalized.js +24 -0
- package/lib/packlets/resource-json/normalized.js.map +1 -0
- package/lib/packlets/resource-json/resourceDeclCollection.d.ts +39 -0
- package/lib/packlets/resource-json/resourceDeclCollection.d.ts.map +1 -0
- package/lib/packlets/resource-json/resourceDeclCollection.js +121 -0
- package/lib/packlets/resource-json/resourceDeclCollection.js.map +1 -0
- package/lib/packlets/resource-json/resourceDeclContainer.d.ts +11 -0
- package/lib/packlets/resource-json/resourceDeclContainer.d.ts.map +1 -0
- package/lib/packlets/resource-json/resourceDeclContainer.js +24 -0
- package/lib/packlets/resource-json/resourceDeclContainer.js.map +1 -0
- package/lib/packlets/resource-json/resourceDeclTree.d.ts +39 -0
- package/lib/packlets/resource-json/resourceDeclTree.d.ts.map +1 -0
- package/lib/packlets/resource-json/resourceDeclTree.js +122 -0
- package/lib/packlets/resource-json/resourceDeclTree.js.map +1 -0
- package/lib/packlets/resource-types/index.d.ts +4 -0
- package/lib/packlets/resource-types/index.d.ts.map +1 -0
- package/lib/packlets/resource-types/index.js +41 -0
- package/lib/packlets/resource-types/index.js.map +1 -0
- package/lib/packlets/resource-types/jsonResourceType.d.ts +65 -0
- package/lib/packlets/resource-types/jsonResourceType.d.ts.map +1 -0
- package/lib/packlets/resource-types/jsonResourceType.js +63 -0
- package/lib/packlets/resource-types/jsonResourceType.js.map +1 -0
- package/lib/packlets/resource-types/resourceType.d.ts +87 -0
- package/lib/packlets/resource-types/resourceType.d.ts.map +1 -0
- package/lib/packlets/resource-types/resourceType.js +62 -0
- package/lib/packlets/resource-types/resourceType.js.map +1 -0
- package/lib/packlets/resource-types/resourceTypeCollector.d.ts +30 -0
- package/lib/packlets/resource-types/resourceTypeCollector.d.ts.map +1 -0
- package/lib/packlets/resource-types/resourceTypeCollector.js +65 -0
- package/lib/packlets/resource-types/resourceTypeCollector.js.map +1 -0
- package/lib/packlets/resources/index.d.ts +5 -0
- package/lib/packlets/resources/index.d.ts.map +1 -0
- package/lib/packlets/resources/index.js +42 -0
- package/lib/packlets/resources/index.js.map +1 -0
- package/lib/packlets/resources/resource.d.ts +75 -0
- package/lib/packlets/resources/resource.d.ts.map +1 -0
- package/lib/packlets/resources/resource.js +109 -0
- package/lib/packlets/resources/resource.js.map +1 -0
- package/lib/packlets/resources/resourceBuilder.d.ts +112 -0
- package/lib/packlets/resources/resourceBuilder.d.ts.map +1 -0
- package/lib/packlets/resources/resourceBuilder.js +162 -0
- package/lib/packlets/resources/resourceBuilder.js.map +1 -0
- package/lib/packlets/resources/resourceCandidate.d.ts +102 -0
- package/lib/packlets/resources/resourceCandidate.d.ts.map +1 -0
- package/lib/packlets/resources/resourceCandidate.js +180 -0
- package/lib/packlets/resources/resourceCandidate.js.map +1 -0
- package/lib/packlets/resources/resourceManager.d.ts +104 -0
- package/lib/packlets/resources/resourceManager.d.ts.map +1 -0
- package/lib/packlets/resources/resourceManager.js +193 -0
- package/lib/packlets/resources/resourceManager.js.map +1 -0
- package/package.json +76 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025 Erik Fortune
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
* in the Software without restriction, including without limitation the rights
|
|
8
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
* furnished to do so, subject to the following conditions:
|
|
11
|
+
*
|
|
12
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
* copies or substantial portions of the Software.
|
|
14
|
+
*
|
|
15
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
* SOFTWARE.
|
|
22
|
+
*/
|
|
23
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
24
|
+
if (k2 === undefined) k2 = k;
|
|
25
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
26
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
27
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
28
|
+
}
|
|
29
|
+
Object.defineProperty(o, k2, desc);
|
|
30
|
+
}) : (function(o, m, k, k2) {
|
|
31
|
+
if (k2 === undefined) k2 = k;
|
|
32
|
+
o[k2] = m[k];
|
|
33
|
+
}));
|
|
34
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
35
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
36
|
+
}) : function(o, v) {
|
|
37
|
+
o["default"] = v;
|
|
38
|
+
});
|
|
39
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
40
|
+
var ownKeys = function(o) {
|
|
41
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
42
|
+
var ar = [];
|
|
43
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
44
|
+
return ar;
|
|
45
|
+
};
|
|
46
|
+
return ownKeys(o);
|
|
47
|
+
};
|
|
48
|
+
return function (mod) {
|
|
49
|
+
if (mod && mod.__esModule) return mod;
|
|
50
|
+
var result = {};
|
|
51
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
52
|
+
__setModuleDefault(result, mod);
|
|
53
|
+
return result;
|
|
54
|
+
};
|
|
55
|
+
})();
|
|
56
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
|
+
exports.QualifierTypeCollector = void 0;
|
|
58
|
+
const Common = __importStar(require("../common"));
|
|
59
|
+
const ts_utils_1 = require("@fgv/ts-utils");
|
|
60
|
+
const qualifierType_1 = require("./qualifierType");
|
|
61
|
+
/**
|
|
62
|
+
* Collector for {@link QualifierTypes.QualifierType | QualifierType} objects.
|
|
63
|
+
* @public
|
|
64
|
+
*/
|
|
65
|
+
class QualifierTypeCollector extends ts_utils_1.ValidatingConvertingCollector {
|
|
66
|
+
/**
|
|
67
|
+
* Constructor for a {@link QualifierTypes.QualifierTypeCollector | QualifierTypeCollector} object.
|
|
68
|
+
* @param params - Optional {@link QualifierTypes.IQualifierTypeCollectorCreateParams | parameters} used to construct the collector.
|
|
69
|
+
*/
|
|
70
|
+
constructor({ qualifierTypes }) {
|
|
71
|
+
super({
|
|
72
|
+
converters: new ts_utils_1.Collections.KeyValueConverters({
|
|
73
|
+
key: Common.Convert.qualifierTypeName,
|
|
74
|
+
value: QualifierTypeCollector._toQualifierType
|
|
75
|
+
}),
|
|
76
|
+
factory: QualifierTypeCollector._qualifierTypeFactory
|
|
77
|
+
});
|
|
78
|
+
/* c8 ignore next 1 - coverage seems to intermittently miss the branch */
|
|
79
|
+
qualifierTypes === null || qualifierTypes === void 0 ? void 0 : qualifierTypes.forEach((qt) => {
|
|
80
|
+
this.add(qt).orThrow();
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Creates a new {@link QualifierTypes.QualifierTypeCollector | QualifierTypeCollector} object.
|
|
85
|
+
* @param params - Optional {@link QualifierTypes.IQualifierTypeCollectorCreateParams | parameters}
|
|
86
|
+
* used to create the collector.
|
|
87
|
+
* @returns `Success` with the new collector if successful, or `Failure` if not.
|
|
88
|
+
*/
|
|
89
|
+
static create(params) {
|
|
90
|
+
/* c8 ignore next 1 - coverage seems to miss the branch intermittently */
|
|
91
|
+
params = params !== null && params !== void 0 ? params : {};
|
|
92
|
+
return (0, ts_utils_1.captureResult)(() => new QualifierTypeCollector(params));
|
|
93
|
+
}
|
|
94
|
+
static _qualifierTypeFactory(key, index, value) {
|
|
95
|
+
return (0, ts_utils_1.succeed)(value);
|
|
96
|
+
}
|
|
97
|
+
static _toQualifierType(from) {
|
|
98
|
+
return from instanceof qualifierType_1.QualifierType ? (0, ts_utils_1.succeed)(from) : (0, ts_utils_1.fail)('not a QualifierType');
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
exports.QualifierTypeCollector = QualifierTypeCollector;
|
|
102
|
+
//# sourceMappingURL=qualifierTypeCollector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qualifierTypeCollector.js","sourceRoot":"","sources":["../../../src/packlets/qualifier-types/qualifierTypeCollector.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kDAAoC;AACpC,4CAOuB;AACvB,mDAAgD;AAehD;;;GAGG;AACH,MAAa,sBAAuB,SAAQ,wCAA2D;IACrG;;;OAGG;IACH,YAAsB,EAAE,cAAc,EAAuC;QAC3E,KAAK,CAAC;YACJ,UAAU,EAAE,IAAI,sBAAW,CAAC,kBAAkB,CAAC;gBAC7C,GAAG,EAAE,MAAM,CAAC,OAAO,CAAC,iBAAiB;gBACrC,KAAK,EAAE,sBAAsB,CAAC,gBAAgB;aAC/C,CAAC;YACF,OAAO,EAAE,sBAAsB,CAAC,qBAAqB;SACtD,CAAC,CAAC;QAEH,yEAAyE;QACzE,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE;YAC7B,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;QACzB,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,MAAM,CAAC,MAA4C;QAC/D,yEAAyE;QACzE,MAAM,GAAG,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,EAAE,CAAC;QACtB,OAAO,IAAA,wBAAa,EAAC,GAAG,EAAE,CAAC,IAAI,sBAAsB,CAAC,MAAM,CAAC,CAAC,CAAC;IACjE,CAAC;IAES,MAAM,CAAC,qBAAqB,CACpC,GAAsB,EACtB,KAAa,EACb,KAAoB;QAEpB,OAAO,IAAA,kBAAO,EAAC,KAAK,CAAC,CAAC;IACxB,CAAC;IAES,MAAM,CAAC,gBAAgB,CAAC,IAAa;QAC7C,OAAO,IAAI,YAAY,6BAAa,CAAC,CAAC,CAAC,IAAA,kBAAO,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAA,eAAI,EAAC,qBAAqB,CAAC,CAAC;IACrF,CAAC;CACF;AA3CD,wDA2CC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport * as Common from '../common';\nimport {\n Collections,\n Result,\n ValidatingConvertingCollector,\n captureResult,\n fail,\n succeed\n} from '@fgv/ts-utils';\nimport { QualifierType } from './qualifierType';\nimport { QualifierTypeName } from '../common';\n\n/**\n * Parameters for creating a new {@link QualifierTypes.QualifierTypeCollector | QualifierTypeCollector}.\n * @public\n */\nexport interface IQualifierTypeCollectorCreateParams {\n /**\n * Optional list of {@link QualifierTypes.QualifierType | QualifierTypes} to add to the collector\n * on creation.\n */\n qualifierTypes?: QualifierType[];\n}\n\n/**\n * Collector for {@link QualifierTypes.QualifierType | QualifierType} objects.\n * @public\n */\nexport class QualifierTypeCollector extends ValidatingConvertingCollector<QualifierType, QualifierType> {\n /**\n * Constructor for a {@link QualifierTypes.QualifierTypeCollector | QualifierTypeCollector} object.\n * @param params - Optional {@link QualifierTypes.IQualifierTypeCollectorCreateParams | parameters} used to construct the collector.\n */\n protected constructor({ qualifierTypes }: IQualifierTypeCollectorCreateParams) {\n super({\n converters: new Collections.KeyValueConverters({\n key: Common.Convert.qualifierTypeName,\n value: QualifierTypeCollector._toQualifierType\n }),\n factory: QualifierTypeCollector._qualifierTypeFactory\n });\n\n /* c8 ignore next 1 - coverage seems to intermittently miss the branch */\n qualifierTypes?.forEach((qt) => {\n this.add(qt).orThrow();\n });\n }\n\n /**\n * Creates a new {@link QualifierTypes.QualifierTypeCollector | QualifierTypeCollector} object.\n * @param params - Optional {@link QualifierTypes.IQualifierTypeCollectorCreateParams | parameters}\n * used to create the collector.\n * @returns `Success` with the new collector if successful, or `Failure` if not.\n */\n public static create(params?: IQualifierTypeCollectorCreateParams): Result<QualifierTypeCollector> {\n /* c8 ignore next 1 - coverage seems to miss the branch intermittently */\n params = params ?? {};\n return captureResult(() => new QualifierTypeCollector(params));\n }\n\n protected static _qualifierTypeFactory(\n key: QualifierTypeName,\n index: number,\n value: QualifierType\n ): Result<QualifierType> {\n return succeed(value);\n }\n\n protected static _toQualifierType(from: unknown): Result<QualifierType> {\n return from instanceof QualifierType ? succeed(from) : fail('not a QualifierType');\n }\n}\n\n/**\n * Interface exposing non-mutating members of a {@link QualifierTypes.QualifierTypeCollector | QualifierTypeCollector}.\n * @public\n */\nexport type ReadOnlyQualifierTypeCollector = Collections.IReadOnlyValidatingCollector<QualifierType>;\n"]}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Result } from '@fgv/ts-utils';
|
|
2
|
+
import { QualifierConditionValue, QualifierContextValue, QualifierMatchScore } from '../common';
|
|
3
|
+
import { QualifierType } from './qualifierType';
|
|
4
|
+
/**
|
|
5
|
+
* Parameters used to create a new {@link QualifierTypes.TerritoryQualifierType | TerritoryQualifierType} instance.
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export interface ITerritoryQualifierTypeCreateParams {
|
|
9
|
+
/**
|
|
10
|
+
* {@inheritdoc QualifierTypes.IQualifierTypeCreateParams.name}
|
|
11
|
+
*/
|
|
12
|
+
name?: string;
|
|
13
|
+
/**
|
|
14
|
+
* {@inheritdoc QualifierTypes.IQualifierTypeCreateParams.allowContextList}
|
|
15
|
+
*/
|
|
16
|
+
allowContextList?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* {@inheritdoc QualifierTypes.IQualifierTypeCreateParams.index}
|
|
19
|
+
*/
|
|
20
|
+
index?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Optional array enumerating allowed territories to further constrain the type.
|
|
23
|
+
*/
|
|
24
|
+
allowedTerritories?: string[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Qualifier type for territory values. Territories are two-letter ISO-3166-2
|
|
28
|
+
* Alpha-2 country codes. Canonical territory codes are uppercase, but this
|
|
29
|
+
* implementation handles incorrect casing.
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
export declare class TerritoryQualifierType extends QualifierType {
|
|
33
|
+
/**
|
|
34
|
+
* Optional array enumerating allowed territories to further constrain the type.
|
|
35
|
+
*/
|
|
36
|
+
readonly allowedTerritories?: ReadonlyArray<QualifierConditionValue>;
|
|
37
|
+
/**
|
|
38
|
+
* Creates a new {@link QualifierTypes.TerritoryQualifierType | TerritoryQualifierType} instance.
|
|
39
|
+
* @public
|
|
40
|
+
*/
|
|
41
|
+
protected constructor({ allowedTerritories, allowContextList, name, index }: ITerritoryQualifierTypeCreateParams);
|
|
42
|
+
/**
|
|
43
|
+
* {@inheritdoc QualifierTypes.QualifierType.isValidConditionValue}
|
|
44
|
+
*/
|
|
45
|
+
isValidConditionValue(value: string): value is QualifierConditionValue;
|
|
46
|
+
/**
|
|
47
|
+
* Creates a new {@link QualifierTypes.TerritoryQualifierType | TerritoryQualifierType} instance.
|
|
48
|
+
* @param params - Optional {@link QualifierTypes.ITerritoryQualifierTypeCreateParams | parameters} to use
|
|
49
|
+
* when creating the instance.
|
|
50
|
+
* @returns `Success` with the new {@link QualifierTypes.TerritoryQualifierType | TerritoryQualifierType} if successful,
|
|
51
|
+
* `Failure` with an error message otherwise.
|
|
52
|
+
* @public
|
|
53
|
+
*/
|
|
54
|
+
static create(params?: ITerritoryQualifierTypeCreateParams): Result<TerritoryQualifierType>;
|
|
55
|
+
/**
|
|
56
|
+
* {@inheritdoc QualifierTypes.QualifierType._matchOne}
|
|
57
|
+
*/
|
|
58
|
+
protected _matchOne(condition: QualifierConditionValue, context: QualifierContextValue): QualifierMatchScore;
|
|
59
|
+
/**
|
|
60
|
+
* Determines whether a value is a valid condition value for a territory qualifier.
|
|
61
|
+
* @param value - The value to validate.
|
|
62
|
+
* @returns `true` if the value is a valid condition value, `false` otherwise.
|
|
63
|
+
* @public
|
|
64
|
+
*/
|
|
65
|
+
static isValidTerritoryConditionValue(value: string): value is QualifierConditionValue;
|
|
66
|
+
/**
|
|
67
|
+
* Converts a string value to a territory condition value.
|
|
68
|
+
* @param value - The value to convert.
|
|
69
|
+
* @returns `Success` with the converted value if successful, `Failure` with an error message otherwise.
|
|
70
|
+
* @public
|
|
71
|
+
*/
|
|
72
|
+
static toTerritoryConditionValue(value: string): Result<QualifierConditionValue>;
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=territoryQualifierType.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"territoryQualifierType.d.ts","sourceRoot":"","sources":["../../../src/packlets/qualifier-types/territoryQualifierType.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAiB,MAAM,EAA6B,MAAM,eAAe,CAAC;AACjF,OAAO,EAIL,uBAAuB,EACvB,qBAAqB,EACrB,mBAAmB,EAEpB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;GAGG;AACH,MAAM,WAAW,mCAAmC;IAClD;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC/B;AAED;;;;;GAKG;AACH,qBAAa,sBAAuB,SAAQ,aAAa;IACvD;;OAEG;IACH,SAAgB,kBAAkB,CAAC,EAAE,aAAa,CAAC,uBAAuB,CAAC,CAAC;IAE5E;;;OAGG;IACH,SAAS,aAAa,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,IAAI,EACJ,KAAK,EACN,EAAE,mCAAmC;IAoBtC;;OAEG;IACI,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,uBAAuB;IAY7E;;;;;;;OAOG;WACW,MAAM,CAAC,MAAM,CAAC,EAAE,mCAAmC,GAAG,MAAM,CAAC,sBAAsB,CAAC;IAMlG;;OAEG;IACH,SAAS,CAAC,SAAS,CACjB,SAAS,EAAE,uBAAuB,EAClC,OAAO,EAAE,qBAAqB,GAC7B,mBAAmB;IAOtB;;;;;OAKG;WACW,8BAA8B,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,uBAAuB;IAI7F;;;;;OAKG;WACW,yBAAyB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,uBAAuB,CAAC;CAMxF"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025 Erik Fortune
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
* in the Software without restriction, including without limitation the rights
|
|
8
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
* furnished to do so, subject to the following conditions:
|
|
11
|
+
*
|
|
12
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
* copies or substantial portions of the Software.
|
|
14
|
+
*
|
|
15
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
* SOFTWARE.
|
|
22
|
+
*/
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.TerritoryQualifierType = void 0;
|
|
25
|
+
const ts_utils_1 = require("@fgv/ts-utils");
|
|
26
|
+
const common_1 = require("../common");
|
|
27
|
+
const qualifierType_1 = require("./qualifierType");
|
|
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
|
+
class TerritoryQualifierType extends qualifierType_1.QualifierType {
|
|
35
|
+
/**
|
|
36
|
+
* Creates a new {@link QualifierTypes.TerritoryQualifierType | TerritoryQualifierType} instance.
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
constructor({ allowedTerritories, allowContextList, name, index }) {
|
|
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 ? common_1.Convert.qualifierTypeIndex.convert(index).orThrow() : undefined;
|
|
43
|
+
const validTerritories = allowedTerritories !== undefined
|
|
44
|
+
? (0, ts_utils_1.mapResults)(allowedTerritories.map((t) => TerritoryQualifierType.toTerritoryConditionValue(t))).orThrow()
|
|
45
|
+
: undefined;
|
|
46
|
+
allowContextList = allowContextList === true;
|
|
47
|
+
super({
|
|
48
|
+
name: name,
|
|
49
|
+
allowContextList,
|
|
50
|
+
index: validIndex
|
|
51
|
+
});
|
|
52
|
+
this.allowedTerritories = validTerritories;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* {@inheritdoc QualifierTypes.QualifierType.isValidConditionValue}
|
|
56
|
+
*/
|
|
57
|
+
isValidConditionValue(value) {
|
|
58
|
+
const normalized = value.toUpperCase();
|
|
59
|
+
/* c8 ignore next 6 - definitely tested but coverage is missing it */
|
|
60
|
+
if (!TerritoryQualifierType.isValidTerritoryConditionValue(normalized)) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
if (this.allowedTerritories !== undefined) {
|
|
64
|
+
return this.allowedTerritories.includes(normalized);
|
|
65
|
+
}
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Creates a new {@link QualifierTypes.TerritoryQualifierType | TerritoryQualifierType} instance.
|
|
70
|
+
* @param params - Optional {@link QualifierTypes.ITerritoryQualifierTypeCreateParams | parameters} to use
|
|
71
|
+
* when creating the instance.
|
|
72
|
+
* @returns `Success` with the new {@link QualifierTypes.TerritoryQualifierType | TerritoryQualifierType} if successful,
|
|
73
|
+
* `Failure` with an error message otherwise.
|
|
74
|
+
* @public
|
|
75
|
+
*/
|
|
76
|
+
static create(params) {
|
|
77
|
+
/* c8 ignore next 1 - coverage having problems with conditional branches */
|
|
78
|
+
params = params !== null && params !== void 0 ? params : {};
|
|
79
|
+
return (0, ts_utils_1.captureResult)(() => new TerritoryQualifierType(params));
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* {@inheritdoc QualifierTypes.QualifierType._matchOne}
|
|
83
|
+
*/
|
|
84
|
+
_matchOne(condition, context) {
|
|
85
|
+
if (this.isValidConditionValue(condition) && condition.toUpperCase() === context.toUpperCase()) {
|
|
86
|
+
return common_1.PerfectMatch;
|
|
87
|
+
}
|
|
88
|
+
return common_1.NoMatch;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Determines whether a value is a valid condition value for a territory qualifier.
|
|
92
|
+
* @param value - The value to validate.
|
|
93
|
+
* @returns `true` if the value is a valid condition value, `false` otherwise.
|
|
94
|
+
* @public
|
|
95
|
+
*/
|
|
96
|
+
static isValidTerritoryConditionValue(value) {
|
|
97
|
+
return common_1.Validate.RegularExpressions.territoryCode.test(value);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Converts a string value to a territory condition value.
|
|
101
|
+
* @param value - The value to convert.
|
|
102
|
+
* @returns `Success` with the converted value if successful, `Failure` with an error message otherwise.
|
|
103
|
+
* @public
|
|
104
|
+
*/
|
|
105
|
+
static toTerritoryConditionValue(value) {
|
|
106
|
+
const normalized = value.toUpperCase();
|
|
107
|
+
return TerritoryQualifierType.isValidTerritoryConditionValue(normalized)
|
|
108
|
+
? (0, ts_utils_1.succeed)(normalized)
|
|
109
|
+
: (0, ts_utils_1.fail)(`${value}: not a valid territory code`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
exports.TerritoryQualifierType = TerritoryQualifierType;
|
|
113
|
+
//# sourceMappingURL=territoryQualifierType.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"territoryQualifierType.js","sourceRoot":"","sources":["../../../src/packlets/qualifier-types/territoryQualifierType.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,4CAAiF;AACjF,sCAQmB;AACnB,mDAAgD;AA4BhD;;;;;GAKG;AACH,MAAa,sBAAuB,SAAQ,6BAAa;IAMvD;;;OAGG;IACH,YAAsB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,IAAI,EACJ,KAAK,EAC+B;QACpC,yEAAyE;QACzE,IAAI,GAAG,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,WAAW,CAAC;QAC3B,MAAM,UAAU,GAAG,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,gBAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;QACzG,MAAM,gBAAgB,GACpB,kBAAkB,KAAK,SAAS;YAC9B,CAAC,CAAC,IAAA,qBAAU,EACR,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,sBAAsB,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,CACnF,CAAC,OAAO,EAAE;YACb,CAAC,CAAC,SAAS,CAAC;QAEhB,gBAAgB,GAAG,gBAAgB,KAAK,IAAI,CAAC;QAC7C,KAAK,CAAC;YACJ,IAAI,EAAE,IAAI;YACV,gBAAgB;YAChB,KAAK,EAAE,UAAU;SAClB,CAAC,CAAC;QACH,IAAI,CAAC,kBAAkB,GAAG,gBAAgB,CAAC;IAC7C,CAAC;IAED;;OAEG;IACI,qBAAqB,CAAC,KAAa;QACxC,MAAM,UAAU,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;QACvC,qEAAqE;QACrE,IAAI,CAAC,sBAAsB,CAAC,8BAA8B,CAAC,UAAU,CAAC,EAAE,CAAC;YACvE,OAAO,KAAK,CAAC;QACf,CAAC;QACD,IAAI,IAAI,CAAC,kBAAkB,KAAK,SAAS,EAAE,CAAC;YAC1C,OAAO,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QACtD,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;OAOG;IACI,MAAM,CAAC,MAAM,CAAC,MAA4C;QAC/D,2EAA2E;QAC3E,MAAM,GAAG,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,EAAE,CAAC;QACtB,OAAO,IAAA,wBAAa,EAAC,GAAG,EAAE,CAAC,IAAI,sBAAsB,CAAC,MAAM,CAAC,CAAC,CAAC;IACjE,CAAC;IAED;;OAEG;IACO,SAAS,CACjB,SAAkC,EAClC,OAA8B;QAE9B,IAAI,IAAI,CAAC,qBAAqB,CAAC,SAAS,CAAC,IAAI,SAAS,CAAC,WAAW,EAAE,KAAK,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC;YAC/F,OAAO,qBAAY,CAAC;QACtB,CAAC;QACD,OAAO,gBAAO,CAAC;IACjB,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,8BAA8B,CAAC,KAAa;QACxD,OAAO,iBAAQ,CAAC,kBAAkB,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC/D,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,yBAAyB,CAAC,KAAa;QACnD,MAAM,UAAU,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;QACvC,OAAO,sBAAsB,CAAC,8BAA8B,CAAC,UAAU,CAAC;YACtE,CAAC,CAAC,IAAA,kBAAO,EAAC,UAAU,CAAC;YACrB,CAAC,CAAC,IAAA,eAAI,EAAC,GAAG,KAAK,8BAA8B,CAAC,CAAC;IACnD,CAAC;CACF;AAnGD,wDAmGC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { captureResult, Result, fail, succeed, mapResults } from '@fgv/ts-utils';\nimport {\n Convert,\n NoMatch,\n PerfectMatch,\n QualifierConditionValue,\n QualifierContextValue,\n QualifierMatchScore,\n Validate\n} from '../common';\nimport { QualifierType } from './qualifierType';\n\n/**\n * Parameters used to create a new {@link QualifierTypes.TerritoryQualifierType | TerritoryQualifierType} instance.\n * @public\n */\nexport interface ITerritoryQualifierTypeCreateParams {\n /**\n * {@inheritdoc QualifierTypes.IQualifierTypeCreateParams.name}\n */\n name?: string;\n\n /**\n * {@inheritdoc QualifierTypes.IQualifierTypeCreateParams.allowContextList}\n */\n allowContextList?: boolean;\n\n /**\n * {@inheritdoc QualifierTypes.IQualifierTypeCreateParams.index}\n */\n index?: number;\n\n /**\n * Optional array enumerating allowed territories to further constrain the type.\n */\n allowedTerritories?: string[];\n}\n\n/**\n * Qualifier type for territory values. Territories are two-letter ISO-3166-2\n * Alpha-2 country codes. Canonical territory codes are uppercase, but this\n * implementation handles incorrect casing.\n * @public\n */\nexport class TerritoryQualifierType extends QualifierType {\n /**\n * Optional array enumerating allowed territories to further constrain the type.\n */\n public readonly allowedTerritories?: ReadonlyArray<QualifierConditionValue>;\n\n /**\n * Creates a new {@link QualifierTypes.TerritoryQualifierType | TerritoryQualifierType} instance.\n * @public\n */\n protected constructor({\n allowedTerritories,\n allowContextList,\n name,\n index\n }: ITerritoryQualifierTypeCreateParams) {\n /* c8 ignore next 7 - coverage seems to be missing coalescing branches */\n name = name ?? 'territory';\n const validIndex = index !== undefined ? Convert.qualifierTypeIndex.convert(index).orThrow() : undefined;\n const validTerritories =\n allowedTerritories !== undefined\n ? mapResults(\n allowedTerritories.map((t) => TerritoryQualifierType.toTerritoryConditionValue(t))\n ).orThrow()\n : undefined;\n\n allowContextList = allowContextList === true;\n super({\n name: name,\n allowContextList,\n index: validIndex\n });\n this.allowedTerritories = validTerritories;\n }\n\n /**\n * {@inheritdoc QualifierTypes.QualifierType.isValidConditionValue}\n */\n public isValidConditionValue(value: string): value is QualifierConditionValue {\n const normalized = value.toUpperCase();\n /* c8 ignore next 6 - definitely tested but coverage is missing it */\n if (!TerritoryQualifierType.isValidTerritoryConditionValue(normalized)) {\n return false;\n }\n if (this.allowedTerritories !== undefined) {\n return this.allowedTerritories.includes(normalized);\n }\n return true;\n }\n\n /**\n * Creates a new {@link QualifierTypes.TerritoryQualifierType | TerritoryQualifierType} instance.\n * @param params - Optional {@link QualifierTypes.ITerritoryQualifierTypeCreateParams | parameters} to use\n * when creating the instance.\n * @returns `Success` with the new {@link QualifierTypes.TerritoryQualifierType | TerritoryQualifierType} if successful,\n * `Failure` with an error message otherwise.\n * @public\n */\n public static create(params?: ITerritoryQualifierTypeCreateParams): Result<TerritoryQualifierType> {\n /* c8 ignore next 1 - coverage having problems with conditional branches */\n params = params ?? {};\n return captureResult(() => new TerritoryQualifierType(params));\n }\n\n /**\n * {@inheritdoc QualifierTypes.QualifierType._matchOne}\n */\n protected _matchOne(\n condition: QualifierConditionValue,\n context: QualifierContextValue\n ): QualifierMatchScore {\n if (this.isValidConditionValue(condition) && condition.toUpperCase() === context.toUpperCase()) {\n return PerfectMatch;\n }\n return NoMatch;\n }\n\n /**\n * Determines whether a value is a valid condition value for a territory qualifier.\n * @param value - The value to validate.\n * @returns `true` if the value is a valid condition value, `false` otherwise.\n * @public\n */\n public static isValidTerritoryConditionValue(value: string): value is QualifierConditionValue {\n return Validate.RegularExpressions.territoryCode.test(value);\n }\n\n /**\n * Converts a string value to a territory condition value.\n * @param value - The value to convert.\n * @returns `Success` with the converted value if successful, `Failure` with an error message otherwise.\n * @public\n */\n public static toTerritoryConditionValue(value: string): Result<QualifierConditionValue> {\n const normalized = value.toUpperCase();\n return TerritoryQualifierType.isValidTerritoryConditionValue(normalized)\n ? succeed(normalized)\n : fail(`${value}: not a valid territory code`);\n }\n}\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { IQualifierDecl, IValidatedQualifierDecl } from '../qualifierDecl';
|
|
2
|
+
import { ReadOnlyQualifierTypeCollector } from '../../qualifier-types';
|
|
3
|
+
/**
|
|
4
|
+
* Converter for a {@link Qualifiers.IQualifierDecl | qualifier declaration}.
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export declare const qualifierDecl: import("@fgv/ts-utils").ObjectConverter<IQualifierDecl, unknown>;
|
|
8
|
+
/**
|
|
9
|
+
* Context necessary to convert a {@link Qualifiers.IValidatedQualifierDecl | validated qualifier declaration}.
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export interface IQualifierDeclConvertContext {
|
|
13
|
+
readonly qualifierTypes: ReadOnlyQualifierTypeCollector;
|
|
14
|
+
qualifierIndex?: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Converter which constructs a {@link Qualifiers.IValidatedQualifierDecl | validated qualifier declaration}
|
|
18
|
+
* from a {@link Qualifiers.IQualifierDecl | qualifier declaration}, instantiating qualifier types by name
|
|
19
|
+
* from a supplied {@link Qualifiers.Convert.IQualifierDeclConvertContext | conversion context}.
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
export declare const validatedQualifierDecl: import("@fgv/ts-utils").Converter<IValidatedQualifierDecl, IQualifierDeclConvertContext>;
|
|
23
|
+
//# sourceMappingURL=decls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decls.d.ts","sourceRoot":"","sources":["../../../../src/packlets/qualifiers/convert/decls.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAE3E,OAAO,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAC;AAIvE;;;GAGG;AACH,eAAO,MAAM,aAAa,kEAMxB,CAAC;AAEH;;;GAGG;AACH,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,cAAc,EAAE,8BAA8B,CAAC;IACxD,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,0FA6BjC,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025 Erik Fortune
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
* in the Software without restriction, including without limitation the rights
|
|
8
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
* furnished to do so, subject to the following conditions:
|
|
11
|
+
*
|
|
12
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
* copies or substantial portions of the Software.
|
|
14
|
+
*
|
|
15
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
* SOFTWARE.
|
|
22
|
+
*/
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.validatedQualifierDecl = exports.qualifierDecl = void 0;
|
|
25
|
+
const ts_utils_1 = require("@fgv/ts-utils");
|
|
26
|
+
const common_1 = require("../../common");
|
|
27
|
+
/* eslint-disable @rushstack/typedef-var */
|
|
28
|
+
/**
|
|
29
|
+
* Converter for a {@link Qualifiers.IQualifierDecl | qualifier declaration}.
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
exports.qualifierDecl = ts_utils_1.Converters.strictObject({
|
|
33
|
+
name: ts_utils_1.Converters.string,
|
|
34
|
+
typeName: ts_utils_1.Converters.string,
|
|
35
|
+
defaultPriority: ts_utils_1.Converters.number,
|
|
36
|
+
token: ts_utils_1.Converters.string.optional(),
|
|
37
|
+
tokenIsOptional: ts_utils_1.Converters.boolean.optional()
|
|
38
|
+
});
|
|
39
|
+
/**
|
|
40
|
+
* Converter which constructs a {@link Qualifiers.IValidatedQualifierDecl | validated qualifier declaration}
|
|
41
|
+
* from a {@link Qualifiers.IQualifierDecl | qualifier declaration}, instantiating qualifier types by name
|
|
42
|
+
* from a supplied {@link Qualifiers.Convert.IQualifierDeclConvertContext | conversion context}.
|
|
43
|
+
* @public
|
|
44
|
+
*/
|
|
45
|
+
exports.validatedQualifierDecl = ts_utils_1.Converters.generic((from, __self, context) => {
|
|
46
|
+
/* c8 ignore next 7 - this is tested but code coverage is losing its mind */
|
|
47
|
+
if (context === undefined) {
|
|
48
|
+
return (0, ts_utils_1.fail)('validatedQualifierDecl converter requires a context');
|
|
49
|
+
}
|
|
50
|
+
const validatedIndexResult = context.qualifierIndex !== undefined
|
|
51
|
+
? common_1.Validate.toQualifierIndex(context.qualifierIndex)
|
|
52
|
+
: (0, ts_utils_1.succeed)(undefined);
|
|
53
|
+
return exports.qualifierDecl.convert(from).onSuccess((decl) => {
|
|
54
|
+
var _a;
|
|
55
|
+
const token = (_a = decl.token) !== null && _a !== void 0 ? _a : decl.name;
|
|
56
|
+
return (0, ts_utils_1.populateObject)({
|
|
57
|
+
name: () => common_1.Validate.toQualifierName(decl.name),
|
|
58
|
+
token: () => common_1.Validate.toQualifierName(token),
|
|
59
|
+
tokenIsOptional: () => (0, ts_utils_1.succeed)(decl.tokenIsOptional === true),
|
|
60
|
+
type: () => context.qualifierTypes.validating.get(decl.typeName),
|
|
61
|
+
defaultPriority: () => common_1.Validate.toConditionPriority(decl.defaultPriority),
|
|
62
|
+
index: () => validatedIndexResult
|
|
63
|
+
}).onSuccess((validated) => {
|
|
64
|
+
if (context.qualifierIndex !== undefined) {
|
|
65
|
+
context.qualifierIndex++;
|
|
66
|
+
}
|
|
67
|
+
return (0, ts_utils_1.succeed)(validated);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
//# sourceMappingURL=decls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decls.js","sourceRoot":"","sources":["../../../../src/packlets/qualifiers/convert/decls.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,4CAAkF;AAElF,yCAAwC;AAGxC,2CAA2C;AAE3C;;;GAGG;AACU,QAAA,aAAa,GAAG,qBAAU,CAAC,YAAY,CAAiB;IACnE,IAAI,EAAE,qBAAU,CAAC,MAAM;IACvB,QAAQ,EAAE,qBAAU,CAAC,MAAM;IAC3B,eAAe,EAAE,qBAAU,CAAC,MAAM;IAClC,KAAK,EAAE,qBAAU,CAAC,MAAM,CAAC,QAAQ,EAAE;IACnC,eAAe,EAAE,qBAAU,CAAC,OAAO,CAAC,QAAQ,EAAE;CAC/C,CAAC,CAAC;AAWH;;;;;GAKG;AACU,QAAA,sBAAsB,GAAG,qBAAU,CAAC,OAAO,CAGtD,CAAC,IAAa,EAAE,MAAM,EAAE,OAAsC,EAAmC,EAAE;IACnG,6EAA6E;IAC7E,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,IAAA,eAAI,EAAC,qDAAqD,CAAC,CAAC;IACrE,CAAC;IACD,MAAM,oBAAoB,GACxB,OAAO,CAAC,cAAc,KAAK,SAAS;QAClC,CAAC,CAAC,iBAAQ,CAAC,gBAAgB,CAAC,OAAO,CAAC,cAAc,CAAC;QACnD,CAAC,CAAC,IAAA,kBAAO,EAAC,SAAS,CAAC,CAAC;IAEzB,OAAO,qBAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE;;QACpD,MAAM,KAAK,GAAG,MAAA,IAAI,CAAC,KAAK,mCAAI,IAAI,CAAC,IAAI,CAAC;QACtC,OAAO,IAAA,yBAAc,EAA0B;YAC7C,IAAI,EAAE,GAAG,EAAE,CAAC,iBAAQ,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC;YAC/C,KAAK,EAAE,GAAG,EAAE,CAAC,iBAAQ,CAAC,eAAe,CAAC,KAAK,CAAC;YAC5C,eAAe,EAAE,GAAG,EAAE,CAAC,IAAA,kBAAO,EAAC,IAAI,CAAC,eAAe,KAAK,IAAI,CAAC;YAC7D,IAAI,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC;YAChE,eAAe,EAAE,GAAG,EAAE,CAAC,iBAAQ,CAAC,mBAAmB,CAAC,IAAI,CAAC,eAAe,CAAC;YACzE,KAAK,EAAE,GAAG,EAAE,CAAC,oBAAoB;SAClC,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,EAAE,EAAE;YACzB,IAAI,OAAO,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;gBACzC,OAAO,CAAC,cAAc,EAAE,CAAC;YAC3B,CAAC;YACD,OAAO,IAAA,kBAAO,EAAC,SAAS,CAAC,CAAC;QAC5B,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Converters, populateObject, Result, fail, succeed } from '@fgv/ts-utils';\nimport { IQualifierDecl, IValidatedQualifierDecl } from '../qualifierDecl';\nimport { Validate } from '../../common';\nimport { ReadOnlyQualifierTypeCollector } from '../../qualifier-types';\n\n/* eslint-disable @rushstack/typedef-var */\n\n/**\n * Converter for a {@link Qualifiers.IQualifierDecl | qualifier declaration}.\n * @public\n */\nexport const qualifierDecl = Converters.strictObject<IQualifierDecl>({\n name: Converters.string,\n typeName: Converters.string,\n defaultPriority: Converters.number,\n token: Converters.string.optional(),\n tokenIsOptional: Converters.boolean.optional()\n});\n\n/**\n * Context necessary to convert a {@link Qualifiers.IValidatedQualifierDecl | validated qualifier declaration}.\n * @public\n */\nexport interface IQualifierDeclConvertContext {\n readonly qualifierTypes: ReadOnlyQualifierTypeCollector;\n qualifierIndex?: number;\n}\n\n/**\n * Converter which constructs a {@link Qualifiers.IValidatedQualifierDecl | validated qualifier declaration}\n * from a {@link Qualifiers.IQualifierDecl | qualifier declaration}, instantiating qualifier types by name\n * from a supplied {@link Qualifiers.Convert.IQualifierDeclConvertContext | conversion context}.\n * @public\n */\nexport const validatedQualifierDecl = Converters.generic<\n IValidatedQualifierDecl,\n IQualifierDeclConvertContext\n>((from: unknown, __self, context?: IQualifierDeclConvertContext): Result<IValidatedQualifierDecl> => {\n /* c8 ignore next 7 - this is tested but code coverage is losing its mind */\n if (context === undefined) {\n return fail('validatedQualifierDecl converter requires a context');\n }\n const validatedIndexResult =\n context.qualifierIndex !== undefined\n ? Validate.toQualifierIndex(context.qualifierIndex)\n : succeed(undefined);\n\n return qualifierDecl.convert(from).onSuccess((decl) => {\n const token = decl.token ?? decl.name;\n return populateObject<IValidatedQualifierDecl>({\n name: () => Validate.toQualifierName(decl.name),\n token: () => Validate.toQualifierName(token),\n tokenIsOptional: () => succeed(decl.tokenIsOptional === true),\n type: () => context.qualifierTypes.validating.get(decl.typeName),\n defaultPriority: () => Validate.toConditionPriority(decl.defaultPriority),\n index: () => validatedIndexResult\n }).onSuccess((validated) => {\n if (context.qualifierIndex !== undefined) {\n context.qualifierIndex++;\n }\n return succeed(validated);\n });\n });\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/packlets/qualifiers/convert/index.ts"],"names":[],"mappings":"AAsBA,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025 Erik Fortune
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
* in the Software without restriction, including without limitation the rights
|
|
8
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
* furnished to do so, subject to the following conditions:
|
|
11
|
+
*
|
|
12
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
* copies or substantial portions of the Software.
|
|
14
|
+
*
|
|
15
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
* SOFTWARE.
|
|
22
|
+
*/
|
|
23
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
24
|
+
if (k2 === undefined) k2 = k;
|
|
25
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
26
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
27
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
28
|
+
}
|
|
29
|
+
Object.defineProperty(o, k2, desc);
|
|
30
|
+
}) : (function(o, m, k, k2) {
|
|
31
|
+
if (k2 === undefined) k2 = k;
|
|
32
|
+
o[k2] = m[k];
|
|
33
|
+
}));
|
|
34
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
35
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
__exportStar(require("./decls"), exports);
|
|
39
|
+
__exportStar(require("./qualifier"), exports);
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/packlets/qualifiers/convert/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;AAEH,0CAAwB;AACxB,8CAA4B","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nexport * from './decls';\nexport * from './qualifier';\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { IReadOnlyQualifierCollector } from '../qualifierCollector';
|
|
2
|
+
import { Qualifier } from '../qualifier';
|
|
3
|
+
/**
|
|
4
|
+
* Context necessary to convert a string or number to a
|
|
5
|
+
* {@link Qualifiers.Qualifier | Qualifier} object.
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export interface IQualifierConvertContext {
|
|
9
|
+
qualifiers: IReadOnlyQualifierCollector;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Converter which choose a qualifier by name or number from a
|
|
13
|
+
* supplied {@link Qualifiers.Convert.IQualifierConvertContext | conversion context}.
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export declare const qualifier: import("@fgv/ts-utils").Converter<Qualifier, IQualifierConvertContext>;
|
|
17
|
+
//# sourceMappingURL=qualifier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qualifier.d.ts","sourceRoot":"","sources":["../../../../src/packlets/qualifiers/convert/qualifier.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAIzC;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC,UAAU,EAAE,2BAA2B,CAAC;CACzC;AAED;;;;GAIG;AACH,eAAO,MAAM,SAAS,wEAYrB,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025 Erik Fortune
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
* in the Software without restriction, including without limitation the rights
|
|
8
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
* furnished to do so, subject to the following conditions:
|
|
11
|
+
*
|
|
12
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
* copies or substantial portions of the Software.
|
|
14
|
+
*
|
|
15
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
* SOFTWARE.
|
|
22
|
+
*/
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.qualifier = void 0;
|
|
25
|
+
const ts_utils_1 = require("@fgv/ts-utils");
|
|
26
|
+
/**
|
|
27
|
+
* Converter which choose a qualifier by name or number from a
|
|
28
|
+
* supplied {@link Qualifiers.Convert.IQualifierConvertContext | conversion context}.
|
|
29
|
+
* @public
|
|
30
|
+
*/
|
|
31
|
+
exports.qualifier = ts_utils_1.Converters.generic((from, __self, context) => {
|
|
32
|
+
if (context === undefined) {
|
|
33
|
+
return (0, ts_utils_1.fail)('qualifier converter requires a context');
|
|
34
|
+
}
|
|
35
|
+
if (typeof from === 'string') {
|
|
36
|
+
return context.qualifiers.validating.get(from);
|
|
37
|
+
}
|
|
38
|
+
else if (typeof from === 'number') {
|
|
39
|
+
return context.qualifiers.getAt(from);
|
|
40
|
+
}
|
|
41
|
+
return (0, ts_utils_1.fail)('qualifier converter requires a string or number');
|
|
42
|
+
});
|
|
43
|
+
//# sourceMappingURL=qualifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qualifier.js","sourceRoot":"","sources":["../../../../src/packlets/qualifiers/convert/qualifier.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,4CAAyD;AAezD;;;;GAIG;AACU,QAAA,SAAS,GAAG,qBAAU,CAAC,OAAO,CACzC,CAAC,IAAa,EAAE,MAAM,EAAE,OAAkC,EAAqB,EAAE;IAC/E,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,IAAA,eAAI,EAAC,wCAAwC,CAAC,CAAC;IACxD,CAAC;IACD,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,OAAO,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC;SAAM,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QACpC,OAAO,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,IAAA,eAAI,EAAC,iDAAiD,CAAC,CAAC;AACjE,CAAC,CACF,CAAC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Converters, Result, fail } from '@fgv/ts-utils';\nimport { IReadOnlyQualifierCollector } from '../qualifierCollector';\nimport { Qualifier } from '../qualifier';\n\n/* eslint-disable @rushstack/typedef-var */\n\n/**\n * Context necessary to convert a string or number to a\n * {@link Qualifiers.Qualifier | Qualifier} object.\n * @public\n */\nexport interface IQualifierConvertContext {\n qualifiers: IReadOnlyQualifierCollector;\n}\n\n/**\n * Converter which choose a qualifier by name or number from a\n * supplied {@link Qualifiers.Convert.IQualifierConvertContext | conversion context}.\n * @public\n */\nexport const qualifier = Converters.generic<Qualifier, IQualifierConvertContext>(\n (from: unknown, __self, context?: IQualifierConvertContext): Result<Qualifier> => {\n if (context === undefined) {\n return fail('qualifier converter requires a context');\n }\n if (typeof from === 'string') {\n return context.qualifiers.validating.get(from);\n } else if (typeof from === 'number') {\n return context.qualifiers.getAt(from);\n }\n return fail('qualifier converter requires a string or number');\n }\n);\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packlets/qualifiers/index.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AAErC,OAAO,EAAE,OAAO,EAAE,CAAC"}
|