@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,248 @@
|
|
|
1
|
+
import { Result } from '@fgv/ts-utils';
|
|
2
|
+
import { ConditionPriority, QualifierName, QualifierTypeName, QualifierIndex, QualifierTypeIndex, ConditionIndex, ConditionSetIndex, QualifierMatchScore, ConditionKey, ConditionSetKey, DecisionKey, DecisionIndex, ConditionSetHash, ConditionOperator, ConditionToken, ConditionSetToken } from '../conditions';
|
|
3
|
+
/**
|
|
4
|
+
* Determines whether a string is a valid qualifier name.
|
|
5
|
+
* @param name - the string to validate
|
|
6
|
+
* @returns true if the string is a valid qualifier name, false otherwise.
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export declare function isValidQualifierName(name: string): name is QualifierName;
|
|
10
|
+
/***
|
|
11
|
+
* Determines whether a string is a valid qualifier type name.
|
|
12
|
+
* @param name - the string to validate
|
|
13
|
+
* @returns true if the string is a valid qualifier type name, false otherwise.
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export declare function isValidQualifierTypeName(name: string): name is QualifierTypeName;
|
|
17
|
+
/**
|
|
18
|
+
* Determines whether a number is a valid priority.
|
|
19
|
+
* @param priority - the number to validate
|
|
20
|
+
* @returns true if the number is a valid priority, false otherwise.
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export declare function isValidConditionPriority(priority: number): priority is ConditionPriority;
|
|
24
|
+
/**
|
|
25
|
+
* Determines whether a number is a valid qualifier index.
|
|
26
|
+
* @param index - the number to validate
|
|
27
|
+
* @returns true if the number is a valid qualifier index, false otherwise.
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
export declare function isValidQualifierIndex(index: number): index is QualifierIndex;
|
|
31
|
+
/**
|
|
32
|
+
* Determines whether a number is a valid qualifier type index.
|
|
33
|
+
* @param index - the number to validate
|
|
34
|
+
* @returns true if the number is a valid qualifier type index, false otherwise.
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
export declare function isValidQualifierTypeIndex(index: number): index is QualifierTypeIndex;
|
|
38
|
+
/**
|
|
39
|
+
* Determines whether a supplied value is a valid {@link QualifierMatchScore | match score}.
|
|
40
|
+
* @param value - The value to validate.
|
|
41
|
+
* @returns - `true` if the value is a valid match score, `false` otherwise.
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
44
|
+
export declare function isValidQualifierMatchScore(value: number): value is QualifierMatchScore;
|
|
45
|
+
/**
|
|
46
|
+
* Determines whether a number is a valid condition index.
|
|
47
|
+
* @param index - the number to validate
|
|
48
|
+
* @returns true if the number is a valid condition index, false otherwise.
|
|
49
|
+
* @public
|
|
50
|
+
*/
|
|
51
|
+
export declare function isValidConditionIndex(index: number): index is ConditionIndex;
|
|
52
|
+
/**
|
|
53
|
+
* Determines whether a string is a valid condition operator.
|
|
54
|
+
* @param operator - the string to validate
|
|
55
|
+
* @returns true if the string is a valid condition operator, false otherwise.
|
|
56
|
+
* @public
|
|
57
|
+
*/
|
|
58
|
+
export declare function isValidConditionOperator(operator: string): operator is ConditionOperator;
|
|
59
|
+
/**
|
|
60
|
+
* Determines whether a string is a valid condition key. A condition key has
|
|
61
|
+
* the format:
|
|
62
|
+
* `<qualifierName>(-<operator>)?-[<value>]@<priority>`
|
|
63
|
+
* where operator is omitted for the default 'matches' operator.
|
|
64
|
+
* @param key - the string to validate
|
|
65
|
+
* @returns `true` if the string is a valid condition key, `false` otherwise.
|
|
66
|
+
* @public
|
|
67
|
+
*/
|
|
68
|
+
export declare function isValidConditionKey(key: string): key is ConditionKey;
|
|
69
|
+
/**
|
|
70
|
+
* Determines whether a string is a valid {@link ConditionToken | condition token}.
|
|
71
|
+
* A condition token has the format:
|
|
72
|
+
* `<qualifierName>=<value>` or `<value>`
|
|
73
|
+
* @param token -
|
|
74
|
+
* @returns `true` if the string is a valid condition token, `false` otherwise.
|
|
75
|
+
* @public
|
|
76
|
+
*/
|
|
77
|
+
export declare function isValidConditionToken(token: string): token is ConditionToken;
|
|
78
|
+
/**
|
|
79
|
+
* Determines whether a number is a valid condition set index.
|
|
80
|
+
* @param index - the number to validate
|
|
81
|
+
* @returns true if the number is a valid condition set index, false otherwise.
|
|
82
|
+
* @public
|
|
83
|
+
*/
|
|
84
|
+
export declare function isValidConditionSetIndex(index: number): index is ConditionSetIndex;
|
|
85
|
+
/**
|
|
86
|
+
* Determines whether a string is a valid condition set key.
|
|
87
|
+
* @param key - the string to validate.
|
|
88
|
+
* @returns `true` if the string is a valid condition set key, `false` otherwise.
|
|
89
|
+
* @public
|
|
90
|
+
*/
|
|
91
|
+
export declare function isValidConditionSetKey(key: string): key is ConditionSetKey;
|
|
92
|
+
/**
|
|
93
|
+
* Determines whether a string is a valid condition set token.
|
|
94
|
+
* @param token - the string to validate.
|
|
95
|
+
* @returns `true` if the string is a valid condition set token, `false` otherwise.
|
|
96
|
+
* @public
|
|
97
|
+
*/
|
|
98
|
+
export declare function isValidConditionSetToken(token: string): token is ConditionSetToken;
|
|
99
|
+
/**
|
|
100
|
+
* Determines whether a string is a valid condition set hash.
|
|
101
|
+
* @param hash - the string to validate.
|
|
102
|
+
* @returns `true` if the string is a valid condition set hash, `false` otherwise.
|
|
103
|
+
* @public
|
|
104
|
+
*/
|
|
105
|
+
export declare function isValidConditionSetHash(hash: string): hash is ConditionSetHash;
|
|
106
|
+
/**
|
|
107
|
+
* Determines whether a string is a valid decision key.
|
|
108
|
+
* @param key - the string to validate
|
|
109
|
+
* @returns `true` if the string is a valid decision key, `false` otherwise.
|
|
110
|
+
* @public
|
|
111
|
+
*/
|
|
112
|
+
export declare function isValidDecisionKey(key: string): key is DecisionKey;
|
|
113
|
+
/**
|
|
114
|
+
* Determines whether a number is a valid decision index.
|
|
115
|
+
* @param index - the number to validate
|
|
116
|
+
* @returns `true` if the number is a valid decision index, `false` otherwise.
|
|
117
|
+
* @public
|
|
118
|
+
*/
|
|
119
|
+
export declare function isValidDecisionIndex(index: number): index is DecisionIndex;
|
|
120
|
+
/**
|
|
121
|
+
* Converts a string to a {@link QualifierName} if it is a valid qualifier name.
|
|
122
|
+
* @param name - the string to convert
|
|
123
|
+
* @returns `Success` with the converted {@link QualifierName} if successful, or `Failure` with an
|
|
124
|
+
* error message if not.
|
|
125
|
+
* @public
|
|
126
|
+
*/
|
|
127
|
+
export declare function toQualifierName(name: string): Result<QualifierName>;
|
|
128
|
+
/**
|
|
129
|
+
* Converts a number to a {@link QualifierIndex} if it is a valid qualifier index.
|
|
130
|
+
* @param index - the number to convert
|
|
131
|
+
* @returns `Success` with the converted {@link QualifierIndex} if successful, or `Failure` with an
|
|
132
|
+
* error message if not.
|
|
133
|
+
* @public
|
|
134
|
+
*/
|
|
135
|
+
export declare function toQualifierIndex(index: number): Result<QualifierIndex>;
|
|
136
|
+
/**
|
|
137
|
+
* Converts a string to a {@link QualifierTypeName} if it is a valid qualifier type name.
|
|
138
|
+
* @param name - the string to convert
|
|
139
|
+
* @returns `Success` with the converted {@link QualifierTypeName} if successful, or `Failure` with an
|
|
140
|
+
* error message if not.
|
|
141
|
+
* @public
|
|
142
|
+
*/
|
|
143
|
+
export declare function toQualifierTypeName(name: string): Result<QualifierTypeName>;
|
|
144
|
+
/**
|
|
145
|
+
* Converts a number to a {@link QualifierTypeIndex} if it is a valid qualifier type index.
|
|
146
|
+
* @param index - the number to convert
|
|
147
|
+
* @returns `Success` with the converted {@link QualifierTypeIndex} if successful, or `Failure` with an
|
|
148
|
+
* error message if not.
|
|
149
|
+
* @public
|
|
150
|
+
*/
|
|
151
|
+
export declare function toQualifierTypeIndex(index: number): Result<QualifierTypeIndex>;
|
|
152
|
+
/**
|
|
153
|
+
* Converts a number to a {@link QualifierMatchScore | match score} if it is a valid score.
|
|
154
|
+
* @param value - The number to convert.
|
|
155
|
+
* @returns `Success` with the converted score if successful, or `Failure` with an error message
|
|
156
|
+
* if not.
|
|
157
|
+
* @public
|
|
158
|
+
*/
|
|
159
|
+
export declare function toQualifierMatchScore(value: number): Result<QualifierMatchScore>;
|
|
160
|
+
/**
|
|
161
|
+
* Converts a number to a {@link ConditionPriority} if it is a valid priority.
|
|
162
|
+
* @param priority - the number to convert
|
|
163
|
+
* @returns `Success` with the converted {@link ConditionPriority} if successful, or `Failure` with an
|
|
164
|
+
* error message if not.
|
|
165
|
+
* @public
|
|
166
|
+
*/
|
|
167
|
+
export declare function toConditionPriority(priority: number): Result<ConditionPriority>;
|
|
168
|
+
/**
|
|
169
|
+
* Converts a number to a {@link ConditionIndex} if it is a valid condition index.
|
|
170
|
+
* @param index - the number to convert
|
|
171
|
+
* @returns `Success` with the converted {@link ConditionIndex} if successful, or `Failure` with an
|
|
172
|
+
* error message if not.
|
|
173
|
+
* @public
|
|
174
|
+
*/
|
|
175
|
+
export declare function toConditionIndex(index: number): Result<ConditionIndex>;
|
|
176
|
+
/**
|
|
177
|
+
* Converts a string to a {@link ConditionOperator} if it is a valid condition operator.
|
|
178
|
+
* @param operator - the string to convert
|
|
179
|
+
* @returns `Success` with the converted {@link ConditionOperator} if successful, or `Failure` with an
|
|
180
|
+
* error message if not.
|
|
181
|
+
* @public
|
|
182
|
+
*/
|
|
183
|
+
export declare function toConditionOperator(operator: string): Result<ConditionOperator>;
|
|
184
|
+
/**
|
|
185
|
+
* Converts a string to a {@link ConditionKey} if it is a valid condition key.
|
|
186
|
+
* @param key - the string to convert
|
|
187
|
+
* @returns `Success` with the converted {@link ConditionKey} if successful, or `Failure` with an
|
|
188
|
+
* error message if not.
|
|
189
|
+
* @public
|
|
190
|
+
*/
|
|
191
|
+
export declare function toConditionKey(key: string): Result<ConditionKey>;
|
|
192
|
+
/**
|
|
193
|
+
* Converts a string to a {@link ConditionToken} if it is a valid condition token.
|
|
194
|
+
* @param token - the string to convert
|
|
195
|
+
* @returns `Success` with the converted {@link ConditionToken} if successful, or `Failure` with an
|
|
196
|
+
* error message if not.
|
|
197
|
+
* @public
|
|
198
|
+
*/
|
|
199
|
+
export declare function toConditionToken(token: string): Result<ConditionToken>;
|
|
200
|
+
/**
|
|
201
|
+
* Converts a number to a {@link ConditionSetIndex} if it is a valid condition set index.
|
|
202
|
+
* @param index - the number to convert
|
|
203
|
+
* @returns `Success` with the converted {@link ConditionSetIndex} if successful, or `Failure` with an
|
|
204
|
+
* error message if not.
|
|
205
|
+
* @public
|
|
206
|
+
*/
|
|
207
|
+
export declare function toConditionSetIndex(index: number): Result<ConditionSetIndex>;
|
|
208
|
+
/**
|
|
209
|
+
* Converts a string to a {@link ConditionSetKey} if it is a valid condition set key.
|
|
210
|
+
* @param key - the string to convert
|
|
211
|
+
* @returns `Success` with the converted {@link ConditionSetKey} if successful, or `Failure` with an
|
|
212
|
+
* error message if not.
|
|
213
|
+
* @public
|
|
214
|
+
*/
|
|
215
|
+
export declare function toConditionSetKey(key: string): Result<ConditionSetKey>;
|
|
216
|
+
/**
|
|
217
|
+
* Converts a string to a {@link ConditionSetToken} if it is a valid condition set token.
|
|
218
|
+
* @param token - the string to convert
|
|
219
|
+
* @returns `Success` with the converted {@link ConditionSetToken} if successful, or `Failure` with an
|
|
220
|
+
* error message if not.
|
|
221
|
+
* @public
|
|
222
|
+
*/
|
|
223
|
+
export declare function toConditionSetToken(token: string): Result<ConditionSetToken>;
|
|
224
|
+
/**
|
|
225
|
+
* Converts a string to a {@link ConditionSetHash} if it is a valid condition set hash.
|
|
226
|
+
* @param key - the string to convert
|
|
227
|
+
* @returns `Success` with the converted {@link ConditionSetHash} if successful, or `Failure` with an
|
|
228
|
+
* error message if not.
|
|
229
|
+
* @public
|
|
230
|
+
*/
|
|
231
|
+
export declare function toConditionSetHash(hash: string): Result<ConditionSetHash>;
|
|
232
|
+
/**
|
|
233
|
+
* Converts a number to a {@link DecisionIndex} if it is a valid decision index.
|
|
234
|
+
* @param index - the number to convert
|
|
235
|
+
* @returns `Success` with the converted {@link DecisionIndex} if successful, or `Failure` with an
|
|
236
|
+
* error message if not.
|
|
237
|
+
* @public
|
|
238
|
+
*/
|
|
239
|
+
export declare function toDecisionKey(key: string): Result<DecisionKey>;
|
|
240
|
+
/**
|
|
241
|
+
* Converts a number to a {@link DecisionIndex} if it is a valid decision index.
|
|
242
|
+
* @param index - the number to convert
|
|
243
|
+
* @returns `Success` with the converted {@link DecisionIndex} if successful, or `Failure` with an
|
|
244
|
+
* error message if not.
|
|
245
|
+
* @public
|
|
246
|
+
*/
|
|
247
|
+
export declare function toDecisionIndex(index: number): Result<DecisionIndex>;
|
|
248
|
+
//# sourceMappingURL=conditions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conditions.d.ts","sourceRoot":"","sources":["../../../../src/packlets/common/validate/conditions.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,MAAM,EAAiB,MAAM,eAAe,CAAC;AACtD,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EACZ,eAAe,EACf,WAAW,EACX,aAAa,EACb,gBAAgB,EAKhB,iBAAiB,EAEjB,cAAc,EACd,iBAAiB,EAClB,MAAM,eAAe,CAAC;AASvB;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,aAAa,CAExE;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,iBAAiB,CAEhF;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,IAAI,iBAAiB,CAExF;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,cAAc,CAE5E;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,kBAAkB,CAEpF;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,mBAAmB,CAEtF;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,cAAc,CAE5E;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,IAAI,iBAAiB,CAExF;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,IAAI,YAAY,CAEpE;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,cAAc,CAM5E;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,iBAAiB,CAElF;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,IAAI,eAAe,CAM1E;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,iBAAiB,CAElF;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,gBAAgB,CAE9E;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,IAAI,WAAW,CAKlE;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,aAAa,CAE1E;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,aAAa,CAAC,CAKnE;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,cAAc,CAAC,CAMtE;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAK3E;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAK9E;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAKhF;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAM/E;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,cAAc,CAAC,CAMtE;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAK/E;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,YAAY,CAAC,CAMhE;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,cAAc,CAAC,CAMtE;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAM5E;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,eAAe,CAAC,CAMtE;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAK5E;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAKzE;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,WAAW,CAAC,CAM9D;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,aAAa,CAAC,CAMpE"}
|
|
@@ -0,0 +1,436 @@
|
|
|
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.isValidQualifierName = isValidQualifierName;
|
|
25
|
+
exports.isValidQualifierTypeName = isValidQualifierTypeName;
|
|
26
|
+
exports.isValidConditionPriority = isValidConditionPriority;
|
|
27
|
+
exports.isValidQualifierIndex = isValidQualifierIndex;
|
|
28
|
+
exports.isValidQualifierTypeIndex = isValidQualifierTypeIndex;
|
|
29
|
+
exports.isValidQualifierMatchScore = isValidQualifierMatchScore;
|
|
30
|
+
exports.isValidConditionIndex = isValidConditionIndex;
|
|
31
|
+
exports.isValidConditionOperator = isValidConditionOperator;
|
|
32
|
+
exports.isValidConditionKey = isValidConditionKey;
|
|
33
|
+
exports.isValidConditionToken = isValidConditionToken;
|
|
34
|
+
exports.isValidConditionSetIndex = isValidConditionSetIndex;
|
|
35
|
+
exports.isValidConditionSetKey = isValidConditionSetKey;
|
|
36
|
+
exports.isValidConditionSetToken = isValidConditionSetToken;
|
|
37
|
+
exports.isValidConditionSetHash = isValidConditionSetHash;
|
|
38
|
+
exports.isValidDecisionKey = isValidDecisionKey;
|
|
39
|
+
exports.isValidDecisionIndex = isValidDecisionIndex;
|
|
40
|
+
exports.toQualifierName = toQualifierName;
|
|
41
|
+
exports.toQualifierIndex = toQualifierIndex;
|
|
42
|
+
exports.toQualifierTypeName = toQualifierTypeName;
|
|
43
|
+
exports.toQualifierTypeIndex = toQualifierTypeIndex;
|
|
44
|
+
exports.toQualifierMatchScore = toQualifierMatchScore;
|
|
45
|
+
exports.toConditionPriority = toConditionPriority;
|
|
46
|
+
exports.toConditionIndex = toConditionIndex;
|
|
47
|
+
exports.toConditionOperator = toConditionOperator;
|
|
48
|
+
exports.toConditionKey = toConditionKey;
|
|
49
|
+
exports.toConditionToken = toConditionToken;
|
|
50
|
+
exports.toConditionSetIndex = toConditionSetIndex;
|
|
51
|
+
exports.toConditionSetKey = toConditionSetKey;
|
|
52
|
+
exports.toConditionSetToken = toConditionSetToken;
|
|
53
|
+
exports.toConditionSetHash = toConditionSetHash;
|
|
54
|
+
exports.toDecisionKey = toDecisionKey;
|
|
55
|
+
exports.toDecisionIndex = toDecisionIndex;
|
|
56
|
+
const ts_utils_1 = require("@fgv/ts-utils");
|
|
57
|
+
const conditions_1 = require("../conditions");
|
|
58
|
+
const regularExpressions_1 = require("./regularExpressions");
|
|
59
|
+
/**
|
|
60
|
+
* Determines whether a string is a valid qualifier name.
|
|
61
|
+
* @param name - the string to validate
|
|
62
|
+
* @returns true if the string is a valid qualifier name, false otherwise.
|
|
63
|
+
* @public
|
|
64
|
+
*/
|
|
65
|
+
function isValidQualifierName(name) {
|
|
66
|
+
return regularExpressions_1.identifier.test(name);
|
|
67
|
+
}
|
|
68
|
+
/***
|
|
69
|
+
* Determines whether a string is a valid qualifier type name.
|
|
70
|
+
* @param name - the string to validate
|
|
71
|
+
* @returns true if the string is a valid qualifier type name, false otherwise.
|
|
72
|
+
* @public
|
|
73
|
+
*/
|
|
74
|
+
function isValidQualifierTypeName(name) {
|
|
75
|
+
return regularExpressions_1.identifier.test(name);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Determines whether a number is a valid priority.
|
|
79
|
+
* @param priority - the number to validate
|
|
80
|
+
* @returns true if the number is a valid priority, false otherwise.
|
|
81
|
+
* @public
|
|
82
|
+
*/
|
|
83
|
+
function isValidConditionPriority(priority) {
|
|
84
|
+
return priority >= conditions_1.MinConditionPriority && priority <= conditions_1.MaxConditionPriority;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Determines whether a number is a valid qualifier index.
|
|
88
|
+
* @param index - the number to validate
|
|
89
|
+
* @returns true if the number is a valid qualifier index, false otherwise.
|
|
90
|
+
* @public
|
|
91
|
+
*/
|
|
92
|
+
function isValidQualifierIndex(index) {
|
|
93
|
+
return index >= 0;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Determines whether a number is a valid qualifier type index.
|
|
97
|
+
* @param index - the number to validate
|
|
98
|
+
* @returns true if the number is a valid qualifier type index, false otherwise.
|
|
99
|
+
* @public
|
|
100
|
+
*/
|
|
101
|
+
function isValidQualifierTypeIndex(index) {
|
|
102
|
+
return index >= 0;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Determines whether a supplied value is a valid {@link QualifierMatchScore | match score}.
|
|
106
|
+
* @param value - The value to validate.
|
|
107
|
+
* @returns - `true` if the value is a valid match score, `false` otherwise.
|
|
108
|
+
* @public
|
|
109
|
+
*/
|
|
110
|
+
function isValidQualifierMatchScore(value) {
|
|
111
|
+
return value >= conditions_1.NoMatch && value <= conditions_1.PerfectMatch;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Determines whether a number is a valid condition index.
|
|
115
|
+
* @param index - the number to validate
|
|
116
|
+
* @returns true if the number is a valid condition index, false otherwise.
|
|
117
|
+
* @public
|
|
118
|
+
*/
|
|
119
|
+
function isValidConditionIndex(index) {
|
|
120
|
+
return index >= 0;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Determines whether a string is a valid condition operator.
|
|
124
|
+
* @param operator - the string to validate
|
|
125
|
+
* @returns true if the string is a valid condition operator, false otherwise.
|
|
126
|
+
* @public
|
|
127
|
+
*/
|
|
128
|
+
function isValidConditionOperator(operator) {
|
|
129
|
+
return conditions_1.allConditionOperators.includes(operator);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Determines whether a string is a valid condition key. A condition key has
|
|
133
|
+
* the format:
|
|
134
|
+
* `<qualifierName>(-<operator>)?-[<value>]@<priority>`
|
|
135
|
+
* where operator is omitted for the default 'matches' operator.
|
|
136
|
+
* @param key - the string to validate
|
|
137
|
+
* @returns `true` if the string is a valid condition key, `false` otherwise.
|
|
138
|
+
* @public
|
|
139
|
+
*/
|
|
140
|
+
function isValidConditionKey(key) {
|
|
141
|
+
return regularExpressions_1.conditionKey.test(key);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Determines whether a string is a valid {@link ConditionToken | condition token}.
|
|
145
|
+
* A condition token has the format:
|
|
146
|
+
* `<qualifierName>=<value>` or `<value>`
|
|
147
|
+
* @param token -
|
|
148
|
+
* @returns `true` if the string is a valid condition token, `false` otherwise.
|
|
149
|
+
* @public
|
|
150
|
+
*/
|
|
151
|
+
function isValidConditionToken(token) {
|
|
152
|
+
/* c8 ignore next 3 - coverage is having a bad day */
|
|
153
|
+
if (token === '') {
|
|
154
|
+
return true;
|
|
155
|
+
}
|
|
156
|
+
return regularExpressions_1.conditionToken.test(token);
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Determines whether a number is a valid condition set index.
|
|
160
|
+
* @param index - the number to validate
|
|
161
|
+
* @returns true if the number is a valid condition set index, false otherwise.
|
|
162
|
+
* @public
|
|
163
|
+
*/
|
|
164
|
+
function isValidConditionSetIndex(index) {
|
|
165
|
+
return index >= 0;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Determines whether a string is a valid condition set key.
|
|
169
|
+
* @param key - the string to validate.
|
|
170
|
+
* @returns `true` if the string is a valid condition set key, `false` otherwise.
|
|
171
|
+
* @public
|
|
172
|
+
*/
|
|
173
|
+
function isValidConditionSetKey(key) {
|
|
174
|
+
if (key === '') {
|
|
175
|
+
return true;
|
|
176
|
+
}
|
|
177
|
+
// a condition set key is a `+` separated list of condition keys
|
|
178
|
+
return key.split('+').every(isValidConditionKey);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Determines whether a string is a valid condition set token.
|
|
182
|
+
* @param token - the string to validate.
|
|
183
|
+
* @returns `true` if the string is a valid condition set token, `false` otherwise.
|
|
184
|
+
* @public
|
|
185
|
+
*/
|
|
186
|
+
function isValidConditionSetToken(token) {
|
|
187
|
+
return token.split(',').every(isValidConditionToken);
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Determines whether a string is a valid condition set hash.
|
|
191
|
+
* @param hash - the string to validate.
|
|
192
|
+
* @returns `true` if the string is a valid condition set hash, `false` otherwise.
|
|
193
|
+
* @public
|
|
194
|
+
*/
|
|
195
|
+
function isValidConditionSetHash(hash) {
|
|
196
|
+
return regularExpressions_1.conditionSetHash.test(hash);
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Determines whether a string is a valid decision key.
|
|
200
|
+
* @param key - the string to validate
|
|
201
|
+
* @returns `true` if the string is a valid decision key, `false` otherwise.
|
|
202
|
+
* @public
|
|
203
|
+
*/
|
|
204
|
+
function isValidDecisionKey(key) {
|
|
205
|
+
if (key === '') {
|
|
206
|
+
return true;
|
|
207
|
+
}
|
|
208
|
+
return regularExpressions_1.decisionKey.test(key);
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Determines whether a number is a valid decision index.
|
|
212
|
+
* @param index - the number to validate
|
|
213
|
+
* @returns `true` if the number is a valid decision index, `false` otherwise.
|
|
214
|
+
* @public
|
|
215
|
+
*/
|
|
216
|
+
function isValidDecisionIndex(index) {
|
|
217
|
+
return index >= 0;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Converts a string to a {@link QualifierName} if it is a valid qualifier name.
|
|
221
|
+
* @param name - the string to convert
|
|
222
|
+
* @returns `Success` with the converted {@link QualifierName} if successful, or `Failure` with an
|
|
223
|
+
* error message if not.
|
|
224
|
+
* @public
|
|
225
|
+
*/
|
|
226
|
+
function toQualifierName(name) {
|
|
227
|
+
if (!isValidQualifierName(name)) {
|
|
228
|
+
return (0, ts_utils_1.fail)(`${name}: not a valid qualifier name`);
|
|
229
|
+
}
|
|
230
|
+
return (0, ts_utils_1.succeed)(name);
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Converts a number to a {@link QualifierIndex} if it is a valid qualifier index.
|
|
234
|
+
* @param index - the number to convert
|
|
235
|
+
* @returns `Success` with the converted {@link QualifierIndex} if successful, or `Failure` with an
|
|
236
|
+
* error message if not.
|
|
237
|
+
* @public
|
|
238
|
+
*/
|
|
239
|
+
function toQualifierIndex(index) {
|
|
240
|
+
/* c8 ignore next 3 - coverage is having a bad day */
|
|
241
|
+
if (!isValidQualifierIndex(index)) {
|
|
242
|
+
return (0, ts_utils_1.fail)(`${index}: not a valid qualifier index`);
|
|
243
|
+
}
|
|
244
|
+
return (0, ts_utils_1.succeed)(index);
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Converts a string to a {@link QualifierTypeName} if it is a valid qualifier type name.
|
|
248
|
+
* @param name - the string to convert
|
|
249
|
+
* @returns `Success` with the converted {@link QualifierTypeName} if successful, or `Failure` with an
|
|
250
|
+
* error message if not.
|
|
251
|
+
* @public
|
|
252
|
+
*/
|
|
253
|
+
function toQualifierTypeName(name) {
|
|
254
|
+
if (!isValidQualifierTypeName(name)) {
|
|
255
|
+
return (0, ts_utils_1.fail)(`${name}: not a valid qualifier type name`);
|
|
256
|
+
}
|
|
257
|
+
return (0, ts_utils_1.succeed)(name);
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Converts a number to a {@link QualifierTypeIndex} if it is a valid qualifier type index.
|
|
261
|
+
* @param index - the number to convert
|
|
262
|
+
* @returns `Success` with the converted {@link QualifierTypeIndex} if successful, or `Failure` with an
|
|
263
|
+
* error message if not.
|
|
264
|
+
* @public
|
|
265
|
+
*/
|
|
266
|
+
function toQualifierTypeIndex(index) {
|
|
267
|
+
if (!isValidQualifierTypeIndex(index)) {
|
|
268
|
+
return (0, ts_utils_1.fail)(`${index}: not a valid qualifier type index`);
|
|
269
|
+
}
|
|
270
|
+
return (0, ts_utils_1.succeed)(index);
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Converts a number to a {@link QualifierMatchScore | match score} if it is a valid score.
|
|
274
|
+
* @param value - The number to convert.
|
|
275
|
+
* @returns `Success` with the converted score if successful, or `Failure` with an error message
|
|
276
|
+
* if not.
|
|
277
|
+
* @public
|
|
278
|
+
*/
|
|
279
|
+
function toQualifierMatchScore(value) {
|
|
280
|
+
if (!isValidQualifierMatchScore(value)) {
|
|
281
|
+
return (0, ts_utils_1.fail)(`${value}: not a valid match score`);
|
|
282
|
+
}
|
|
283
|
+
return (0, ts_utils_1.succeed)(value);
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Converts a number to a {@link ConditionPriority} if it is a valid priority.
|
|
287
|
+
* @param priority - the number to convert
|
|
288
|
+
* @returns `Success` with the converted {@link ConditionPriority} if successful, or `Failure` with an
|
|
289
|
+
* error message if not.
|
|
290
|
+
* @public
|
|
291
|
+
*/
|
|
292
|
+
function toConditionPriority(priority) {
|
|
293
|
+
/* c8 ignore next 3 - coverage is having a bad day */
|
|
294
|
+
if (!isValidConditionPriority(priority)) {
|
|
295
|
+
return (0, ts_utils_1.fail)(`${priority}: not a valid priority`);
|
|
296
|
+
}
|
|
297
|
+
return (0, ts_utils_1.succeed)(priority);
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Converts a number to a {@link ConditionIndex} if it is a valid condition index.
|
|
301
|
+
* @param index - the number to convert
|
|
302
|
+
* @returns `Success` with the converted {@link ConditionIndex} if successful, or `Failure` with an
|
|
303
|
+
* error message if not.
|
|
304
|
+
* @public
|
|
305
|
+
*/
|
|
306
|
+
function toConditionIndex(index) {
|
|
307
|
+
/* c8 ignore next 3 - coverage is having a bad day */
|
|
308
|
+
if (!isValidConditionIndex(index)) {
|
|
309
|
+
return (0, ts_utils_1.fail)(`${index}: not a valid condition index`);
|
|
310
|
+
}
|
|
311
|
+
return (0, ts_utils_1.succeed)(index);
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Converts a string to a {@link ConditionOperator} if it is a valid condition operator.
|
|
315
|
+
* @param operator - the string to convert
|
|
316
|
+
* @returns `Success` with the converted {@link ConditionOperator} if successful, or `Failure` with an
|
|
317
|
+
* error message if not.
|
|
318
|
+
* @public
|
|
319
|
+
*/
|
|
320
|
+
function toConditionOperator(operator) {
|
|
321
|
+
if (!isValidConditionOperator(operator)) {
|
|
322
|
+
return (0, ts_utils_1.fail)(`${operator}: not a valid condition operator`);
|
|
323
|
+
}
|
|
324
|
+
return (0, ts_utils_1.succeed)(operator);
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Converts a string to a {@link ConditionKey} if it is a valid condition key.
|
|
328
|
+
* @param key - the string to convert
|
|
329
|
+
* @returns `Success` with the converted {@link ConditionKey} if successful, or `Failure` with an
|
|
330
|
+
* error message if not.
|
|
331
|
+
* @public
|
|
332
|
+
*/
|
|
333
|
+
function toConditionKey(key) {
|
|
334
|
+
/* c8 ignore next 3 - coverage is having a bad day */
|
|
335
|
+
if (!isValidConditionKey(key)) {
|
|
336
|
+
return (0, ts_utils_1.fail)(`${key}: not a valid condition key`);
|
|
337
|
+
}
|
|
338
|
+
return (0, ts_utils_1.succeed)(key);
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Converts a string to a {@link ConditionToken} if it is a valid condition token.
|
|
342
|
+
* @param token - the string to convert
|
|
343
|
+
* @returns `Success` with the converted {@link ConditionToken} if successful, or `Failure` with an
|
|
344
|
+
* error message if not.
|
|
345
|
+
* @public
|
|
346
|
+
*/
|
|
347
|
+
function toConditionToken(token) {
|
|
348
|
+
/* c8 ignore next 3 - coverage is having a bad day */
|
|
349
|
+
if (!isValidConditionToken(token)) {
|
|
350
|
+
return (0, ts_utils_1.fail)(`${token}: not a valid condition token`);
|
|
351
|
+
}
|
|
352
|
+
return (0, ts_utils_1.succeed)(token);
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Converts a number to a {@link ConditionSetIndex} if it is a valid condition set index.
|
|
356
|
+
* @param index - the number to convert
|
|
357
|
+
* @returns `Success` with the converted {@link ConditionSetIndex} if successful, or `Failure` with an
|
|
358
|
+
* error message if not.
|
|
359
|
+
* @public
|
|
360
|
+
*/
|
|
361
|
+
function toConditionSetIndex(index) {
|
|
362
|
+
/* c8 ignore next 3 - coverage is having a bad day */
|
|
363
|
+
if (!isValidConditionSetIndex(index)) {
|
|
364
|
+
return (0, ts_utils_1.fail)(`${index}: not a valid condition set index`);
|
|
365
|
+
}
|
|
366
|
+
return (0, ts_utils_1.succeed)(index);
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Converts a string to a {@link ConditionSetKey} if it is a valid condition set key.
|
|
370
|
+
* @param key - the string to convert
|
|
371
|
+
* @returns `Success` with the converted {@link ConditionSetKey} if successful, or `Failure` with an
|
|
372
|
+
* error message if not.
|
|
373
|
+
* @public
|
|
374
|
+
*/
|
|
375
|
+
function toConditionSetKey(key) {
|
|
376
|
+
/* c8 ignore next 3 - coverage is having a bad day */
|
|
377
|
+
if (!isValidConditionSetKey(key)) {
|
|
378
|
+
return (0, ts_utils_1.fail)(`${key}: not a valid condition set key`);
|
|
379
|
+
}
|
|
380
|
+
return (0, ts_utils_1.succeed)(key);
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Converts a string to a {@link ConditionSetToken} if it is a valid condition set token.
|
|
384
|
+
* @param token - the string to convert
|
|
385
|
+
* @returns `Success` with the converted {@link ConditionSetToken} if successful, or `Failure` with an
|
|
386
|
+
* error message if not.
|
|
387
|
+
* @public
|
|
388
|
+
*/
|
|
389
|
+
function toConditionSetToken(token) {
|
|
390
|
+
if (!isValidConditionSetToken(token)) {
|
|
391
|
+
return (0, ts_utils_1.fail)(`${token}: not a valid condition set token`);
|
|
392
|
+
}
|
|
393
|
+
return (0, ts_utils_1.succeed)(token);
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Converts a string to a {@link ConditionSetHash} if it is a valid condition set hash.
|
|
397
|
+
* @param key - the string to convert
|
|
398
|
+
* @returns `Success` with the converted {@link ConditionSetHash} if successful, or `Failure` with an
|
|
399
|
+
* error message if not.
|
|
400
|
+
* @public
|
|
401
|
+
*/
|
|
402
|
+
function toConditionSetHash(hash) {
|
|
403
|
+
if (!isValidConditionSetHash(hash)) {
|
|
404
|
+
return (0, ts_utils_1.fail)(`${hash}: not a valid condition set hash`);
|
|
405
|
+
}
|
|
406
|
+
return (0, ts_utils_1.succeed)(hash);
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Converts a number to a {@link DecisionIndex} if it is a valid decision index.
|
|
410
|
+
* @param index - the number to convert
|
|
411
|
+
* @returns `Success` with the converted {@link DecisionIndex} if successful, or `Failure` with an
|
|
412
|
+
* error message if not.
|
|
413
|
+
* @public
|
|
414
|
+
*/
|
|
415
|
+
function toDecisionKey(key) {
|
|
416
|
+
/* c8 ignore next 3 - coverage is having a bad day */
|
|
417
|
+
if (!isValidDecisionKey(key)) {
|
|
418
|
+
return (0, ts_utils_1.fail)(`${key}: not a valid decision key`);
|
|
419
|
+
}
|
|
420
|
+
return (0, ts_utils_1.succeed)(key);
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Converts a number to a {@link DecisionIndex} if it is a valid decision index.
|
|
424
|
+
* @param index - the number to convert
|
|
425
|
+
* @returns `Success` with the converted {@link DecisionIndex} if successful, or `Failure` with an
|
|
426
|
+
* error message if not.
|
|
427
|
+
* @public
|
|
428
|
+
*/
|
|
429
|
+
function toDecisionIndex(index) {
|
|
430
|
+
/* c8 ignore next 3 - coverage is having a bad day */
|
|
431
|
+
if (!isValidDecisionIndex(index)) {
|
|
432
|
+
return (0, ts_utils_1.fail)(`${index}: not a valid decision index`);
|
|
433
|
+
}
|
|
434
|
+
return (0, ts_utils_1.succeed)(index);
|
|
435
|
+
}
|
|
436
|
+
//# sourceMappingURL=conditions.js.map
|