@fgv/ts-res 5.1.0-15 → 5.1.0-17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/packlets/common/helpers/resources.js +2 -4
- package/dist/packlets/common/validate/conditions.js +4 -4
- package/dist/packlets/common/validate/regularExpressions.js +2 -2
- package/dist/packlets/common/validate/resources.js +1 -1
- package/dist/packlets/conditions/condition.js +3 -7
- package/dist/packlets/decisions/decision.js +1 -1
- package/dist/packlets/import/fsItem.js +1 -4
- package/dist/packlets/import/importContext.js +3 -3
- package/dist/packlets/import/importers/collectionImporter.js +2 -2
- package/dist/packlets/import/importers/fsItemImporter.js +1 -1
- package/dist/packlets/import/importers/jsonImporter.js +2 -2
- package/dist/packlets/import/importers/pathImporter.js +1 -1
- package/dist/packlets/qualifier-types/languageQualifierType.js +6 -7
- package/dist/packlets/qualifier-types/literalQualifierType.js +7 -10
- package/dist/packlets/qualifier-types/qualifierType.js +12 -13
- package/dist/packlets/qualifier-types/territoryQualifierType.js +5 -5
- package/dist/packlets/qualifiers/qualifier.js +6 -7
- package/dist/packlets/qualifiers/qualifierCollector.js +2 -2
- package/dist/packlets/resource-json/resourceDeclCollection.js +1 -1
- package/dist/packlets/resource-json/resourceDeclTree.js +1 -1
- package/dist/packlets/resource-types/jsonResourceType.js +2 -2
- package/dist/packlets/resource-types/resourceType.js +2 -2
- package/dist/packlets/resources/resourceBuilder.js +2 -2
- package/dist/packlets/resources/resourceManagerBuilder.js +5 -5
- package/dist/packlets/runtime/compiledResourceCollection.js +5 -5
- package/dist/ts-res.d.ts +108 -111
- package/lib/packlets/common/helpers/resources.d.ts +2 -4
- package/lib/packlets/common/helpers/resources.js +2 -4
- package/lib/packlets/common/validate/conditions.d.ts +4 -4
- package/lib/packlets/common/validate/conditions.js +4 -4
- package/lib/packlets/common/validate/regularExpressions.d.ts +2 -2
- package/lib/packlets/common/validate/regularExpressions.js +2 -2
- package/lib/packlets/common/validate/resources.d.ts +1 -1
- package/lib/packlets/common/validate/resources.js +1 -1
- package/lib/packlets/conditions/condition.d.ts +3 -7
- package/lib/packlets/conditions/condition.js +3 -7
- package/lib/packlets/decisions/decision.d.ts +1 -1
- package/lib/packlets/decisions/decision.js +1 -1
- package/lib/packlets/import/fsItem.d.ts +1 -4
- package/lib/packlets/import/fsItem.js +1 -4
- package/lib/packlets/import/importContext.d.ts +5 -5
- package/lib/packlets/import/importContext.js +3 -3
- package/lib/packlets/import/importers/collectionImporter.d.ts +2 -2
- package/lib/packlets/import/importers/collectionImporter.js +2 -2
- package/lib/packlets/import/importers/fsItemImporter.d.ts +1 -1
- package/lib/packlets/import/importers/fsItemImporter.js +1 -1
- package/lib/packlets/import/importers/jsonImporter.d.ts +2 -2
- package/lib/packlets/import/importers/jsonImporter.js +2 -2
- package/lib/packlets/import/importers/pathImporter.d.ts +1 -1
- package/lib/packlets/import/importers/pathImporter.js +1 -1
- package/lib/packlets/qualifier-types/languageQualifierType.d.ts +6 -7
- package/lib/packlets/qualifier-types/languageQualifierType.js +6 -7
- package/lib/packlets/qualifier-types/literalQualifierType.d.ts +7 -10
- package/lib/packlets/qualifier-types/literalQualifierType.js +7 -10
- package/lib/packlets/qualifier-types/qualifierType.d.ts +17 -18
- package/lib/packlets/qualifier-types/qualifierType.js +12 -13
- package/lib/packlets/qualifier-types/territoryQualifierType.d.ts +8 -8
- package/lib/packlets/qualifier-types/territoryQualifierType.js +5 -5
- package/lib/packlets/qualifiers/qualifier.d.ts +6 -7
- package/lib/packlets/qualifiers/qualifier.js +6 -7
- package/lib/packlets/qualifiers/qualifierCollector.d.ts +3 -3
- package/lib/packlets/qualifiers/qualifierCollector.js +2 -2
- package/lib/packlets/resource-json/resourceDeclCollection.d.ts +1 -1
- package/lib/packlets/resource-json/resourceDeclCollection.js +1 -1
- package/lib/packlets/resource-json/resourceDeclTree.d.ts +1 -1
- package/lib/packlets/resource-json/resourceDeclTree.js +1 -1
- package/lib/packlets/resource-types/jsonResourceType.d.ts +17 -5
- package/lib/packlets/resource-types/jsonResourceType.js +2 -2
- package/lib/packlets/resource-types/resourceType.d.ts +5 -5
- package/lib/packlets/resource-types/resourceType.js +2 -2
- package/lib/packlets/resources/resourceBuilder.d.ts +2 -2
- package/lib/packlets/resources/resourceBuilder.js +2 -2
- package/lib/packlets/resources/resourceManagerBuilder.d.ts +5 -5
- package/lib/packlets/resources/resourceManagerBuilder.js +5 -5
- package/lib/packlets/runtime/compiledResourceCollection.d.ts +5 -5
- package/lib/packlets/runtime/compiledResourceCollection.js +5 -5
- package/package.json +9 -9
|
@@ -40,8 +40,7 @@ export function splitResourceId(id) {
|
|
|
40
40
|
* Joins a list of {@link ResourceId | resource ID} or {@link ResourceName | resource name} with
|
|
41
41
|
* to create a new {@link ResourceId | resource ID}. Fails if resulting ID is invalid or empty.
|
|
42
42
|
*
|
|
43
|
-
* @param
|
|
44
|
-
* @param names - Additional names to join.
|
|
43
|
+
* @param ids - The names or IDs to join.
|
|
45
44
|
* @returns `Success` with the new ID if the base and names are valid, or `Failure` with an error message
|
|
46
45
|
* if not.
|
|
47
46
|
* @public
|
|
@@ -61,8 +60,7 @@ export function joinResourceIds(...ids) {
|
|
|
61
60
|
* Joins a list of {@link ResourceId | resource ID} or {@link ResourceName | resource name} with
|
|
62
61
|
* to create a new {@link ResourceId | resource ID}. Returns `undefined` if no names are defined.
|
|
63
62
|
*
|
|
64
|
-
* @param
|
|
65
|
-
* @param names - Additional names to join.
|
|
63
|
+
* @param ids - The names or IDs to join.
|
|
66
64
|
* @returns `Success` with the new ID if the base and names are valid, `Success` with `undefined`
|
|
67
65
|
* if names were present, or `Failure` with an error message if the resulting id is invalid.
|
|
68
66
|
* @public
|
|
@@ -389,7 +389,7 @@ export function toConditionSetToken(token) {
|
|
|
389
389
|
}
|
|
390
390
|
/**
|
|
391
391
|
* Converts a string to a {@link ConditionSetHash} if it is a valid condition set hash.
|
|
392
|
-
* @param
|
|
392
|
+
* @param hash - the string to convert
|
|
393
393
|
* @returns `Success` with the converted {@link ConditionSetHash} if successful, or `Failure` with an
|
|
394
394
|
* error message if not.
|
|
395
395
|
* @public
|
|
@@ -401,9 +401,9 @@ export function toConditionSetHash(hash) {
|
|
|
401
401
|
return succeed(hash);
|
|
402
402
|
}
|
|
403
403
|
/**
|
|
404
|
-
* Converts a
|
|
405
|
-
* @param
|
|
406
|
-
* @returns `Success` with the converted {@link
|
|
404
|
+
* Converts a string to a {@link DecisionKey} if it is a valid decision key.
|
|
405
|
+
* @param key - the string to convert
|
|
406
|
+
* @returns `Success` with the converted {@link DecisionKey} if successful, or `Failure` with an
|
|
407
407
|
* error message if not.
|
|
408
408
|
* @public
|
|
409
409
|
*/
|
|
@@ -33,8 +33,8 @@ export const segmentedIdentifier = /^[a-zA-Z_][a-zA-Z0-9_\-]*(\.[a-zA-Z_][a-zA-Z
|
|
|
33
33
|
export const identifierList = /^[a-zA-Z_][a-zA-Z0-9_\-]*(,[a-zA-Z_][a-zA-Z0-9_\-]*)*$/;
|
|
34
34
|
/**
|
|
35
35
|
* The format of a {@link ConditionKey | condition key} is:
|
|
36
|
-
*
|
|
37
|
-
*
|
|
36
|
+
* \<qualifierName\>-\[<value>\]\[\@<priority>\]\(\<scoreAsDefault\>\) where operator is `matches`, or
|
|
37
|
+
* \<qualifierName\>-\<operator\>-\[<value>\]\[\@<priority>\]\(\<scoreAsDefault\>\)
|
|
38
38
|
* @internal
|
|
39
39
|
*/
|
|
40
40
|
export const conditionKey = /^[a-zA-Z_][a-zA-Z0-9_\-]*(-matches)?-\[.*\](?:@[0-9]{1,4})?(?:\([01](?:\.[0-9]+)?\))?$/;
|
|
@@ -94,7 +94,7 @@ export function isValidCandidateValueKey(key) {
|
|
|
94
94
|
/**
|
|
95
95
|
* Converts a string to a {@link ResourceName | resource name}.
|
|
96
96
|
*
|
|
97
|
-
* @param
|
|
97
|
+
* @param name - The string to convert.
|
|
98
98
|
* @returns `Success` with the converted name if valid, or `Failure` with an error message
|
|
99
99
|
* if not.
|
|
100
100
|
* @public
|
|
@@ -30,12 +30,8 @@ const scoreFormatter = new Intl.NumberFormat('en-US', { minimumFractionDigits: 0
|
|
|
30
30
|
export class Condition {
|
|
31
31
|
/**
|
|
32
32
|
* Constructs a new {@link Conditions.Condition | Condition} object.
|
|
33
|
-
* @param
|
|
34
|
-
*
|
|
35
|
-
* @param operator - The {@link ConditionOperator | operator} used when matching context value to condition value.
|
|
36
|
-
* @param priority - The {@link ConditionPriority | relative priority} of this condition.
|
|
37
|
-
* @param scoreAsDefault - The {@link QualifierMatchScore | score} to be used when this condition is the default.
|
|
38
|
-
* @param index - The index of this condition.
|
|
33
|
+
* @param params - The {@link Conditions.IValidatedConditionDecl | validated condition declaration}
|
|
34
|
+
* used to construct this condition.
|
|
39
35
|
* @public
|
|
40
36
|
*/
|
|
41
37
|
constructor({ qualifier, value, operator, priority, scoreAsDefault, index }) {
|
|
@@ -85,7 +81,7 @@ export class Condition {
|
|
|
85
81
|
* @returns A {@link QualifierMatchScore | match score} indicating match quality if the condition is present
|
|
86
82
|
* in the context to be matched, `undefined` otherwise.
|
|
87
83
|
* @remarks
|
|
88
|
-
* If {@link Context.IContextMatchOptions.partialContextMatch | `options.partialContextMatch
|
|
84
|
+
* If {@link Context.IContextMatchOptions.partialContextMatch | `options.partialContextMatch`} is `true`, then
|
|
89
85
|
* the method will return `undefined` if the corresponding qualifier is not present in the context.
|
|
90
86
|
*/
|
|
91
87
|
getContextMatch(context, options) {
|
|
@@ -99,7 +99,7 @@ export class Decision {
|
|
|
99
99
|
}
|
|
100
100
|
/**
|
|
101
101
|
* Helper function to return a stable key for a set of condition sets.
|
|
102
|
-
* @param
|
|
102
|
+
* @param candidates - The candidates whose condition sets are used to create the key.
|
|
103
103
|
* @returns A key derived from the condition set hashes.
|
|
104
104
|
* @public
|
|
105
105
|
*/
|
|
@@ -34,9 +34,6 @@ export class FsItem {
|
|
|
34
34
|
* @param props - The {@link Import.IFsItemProps | file system item properties} to use for this item.
|
|
35
35
|
* @param qualifiers - The {@link Qualifiers.IReadOnlyQualifierCollector | qualifiers} used to parse
|
|
36
36
|
* embedded condition set tokens.
|
|
37
|
-
* @param tree - file tree implementation to use for this item.
|
|
38
|
-
* @returns `Success` containing the new {@link Import.FsItem | FsItem} if successful, or a `Failure`
|
|
39
|
-
* containing an error message if not.
|
|
40
37
|
*/
|
|
41
38
|
constructor(props, qualifiers) {
|
|
42
39
|
const { baseName, conditions, item } = props;
|
|
@@ -68,7 +65,7 @@ export class FsItem {
|
|
|
68
65
|
* @param importPath - The path to the file system item to import.
|
|
69
66
|
* @param qualifiers - The {@link Qualifiers.IReadOnlyQualifierCollector | qualifiers} used to parse
|
|
70
67
|
* embedded condition set tokens.
|
|
71
|
-
* @param
|
|
68
|
+
* @param tree - An optional {@link FileTree.FileTree | file tree} to use for this item.
|
|
72
69
|
* @returns `Success` containing the new {@link Import.FsItem | FsItem} if an item is created
|
|
73
70
|
* successfully, or a `Failure` containing an error message if it is not. Note that the result detail
|
|
74
71
|
* `skipped` indicates that the item was not created because it is not relevant - this is a soft error
|
|
@@ -29,8 +29,8 @@ export class ImportContext {
|
|
|
29
29
|
/**
|
|
30
30
|
* Protected {@link Import.ImportContext | import context} for derived classes.
|
|
31
31
|
* Public consumers use {@link Import.ImportContext.create | create} to create new instances.
|
|
32
|
-
* @param
|
|
33
|
-
*
|
|
32
|
+
* @param params - The {@link Import.IImportContext | import context} parameters including
|
|
33
|
+
* the base ID and conditions to be applied to resources imported in this context.
|
|
34
34
|
*/
|
|
35
35
|
constructor({ baseId, conditions }) {
|
|
36
36
|
this.baseId = Helpers.joinOptionalResourceIds(baseId).orThrow();
|
|
@@ -62,7 +62,7 @@ export class ImportContext {
|
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
64
|
* Appends names to the base ID of the import context.
|
|
65
|
-
* @param
|
|
65
|
+
* @param names - The name segments to append to the base ID.
|
|
66
66
|
* @returns `Success` with a new {@link Import.ImportContext | import context} containing the new base ID
|
|
67
67
|
* if successful, or `Failure` with an error message if the operation fails.
|
|
68
68
|
*/
|
|
@@ -35,7 +35,7 @@ export class CollectionImporter {
|
|
|
35
35
|
*/
|
|
36
36
|
constructor() {
|
|
37
37
|
/**
|
|
38
|
-
* {@
|
|
38
|
+
* {@inheritDoc Import.Importers.IImporter.types}
|
|
39
39
|
*/
|
|
40
40
|
this.types = ['resourceCollection', 'resourceTree'];
|
|
41
41
|
}
|
|
@@ -48,7 +48,7 @@ export class CollectionImporter {
|
|
|
48
48
|
return captureResult(() => new CollectionImporter());
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
|
-
* {@
|
|
51
|
+
* {@inheritDoc Import.Importers.IImporter.import}
|
|
52
52
|
*/
|
|
53
53
|
import(item, manager) {
|
|
54
54
|
var _a, _b;
|
|
@@ -49,7 +49,7 @@ export class FsItemImporter {
|
|
|
49
49
|
return captureResult(() => new FsItemImporter(params));
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
52
|
-
* {@
|
|
52
|
+
* {@inheritDoc Import.Importers.IImporter.import}
|
|
53
53
|
*/
|
|
54
54
|
import(item, __manager) {
|
|
55
55
|
const { value: fsItem, message: getTreeMessage, detail: getTreeDetail } = this._getFileTreeItemFromImportable(item);
|
|
@@ -32,7 +32,7 @@ export class JsonImporter {
|
|
|
32
32
|
*/
|
|
33
33
|
constructor() {
|
|
34
34
|
/**
|
|
35
|
-
* {@
|
|
35
|
+
* {@inheritDoc Import.Importers.IImporter.types}
|
|
36
36
|
*/
|
|
37
37
|
this.types = ['json'];
|
|
38
38
|
}
|
|
@@ -45,7 +45,7 @@ export class JsonImporter {
|
|
|
45
45
|
return captureResult(() => new JsonImporter());
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
|
-
* {@
|
|
48
|
+
* {@inheritDoc Import.Importers.IImporter.import}
|
|
49
49
|
*/
|
|
50
50
|
import(item, manager) {
|
|
51
51
|
var _a, _b;
|
|
@@ -51,7 +51,7 @@ export class PathImporter {
|
|
|
51
51
|
return captureResult(() => new PathImporter(params));
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
|
-
* {@
|
|
54
|
+
* {@inheritDoc Import.Importers.IImporter.import}
|
|
55
55
|
*/
|
|
56
56
|
import(item, __manager) {
|
|
57
57
|
const { value: fsItem, message: getTreeMessage, detail: getTreeDetail } = this._getFileTreeItemFromImportable(item);
|
|
@@ -34,9 +34,8 @@ import { sanitizeJsonObject } from '@fgv/ts-json-base';
|
|
|
34
34
|
export class LanguageQualifierType extends QualifierType {
|
|
35
35
|
/**
|
|
36
36
|
* Creates a new instance of a {@link QualifierTypes.LanguageQualifierType | language qualifier type}.
|
|
37
|
-
* @param
|
|
38
|
-
*
|
|
39
|
-
* list of values. Defaults to `true`.
|
|
37
|
+
* @param params - The {@link QualifierTypes.ILanguageQualifierTypeCreateParams | create parameters}
|
|
38
|
+
* for this qualifier type.
|
|
40
39
|
* @public
|
|
41
40
|
*/
|
|
42
41
|
constructor({ name, allowContextList, index }) {
|
|
@@ -47,7 +46,7 @@ export class LanguageQualifierType extends QualifierType {
|
|
|
47
46
|
super(Object.assign({ name,
|
|
48
47
|
allowContextList }, validated));
|
|
49
48
|
/**
|
|
50
|
-
* {@
|
|
49
|
+
* {@inheritDoc QualifierTypes.IQualifierType.systemTypeName}
|
|
51
50
|
*/
|
|
52
51
|
this.systemTypeName = Convert.qualifierTypeName.convert('language').orThrow();
|
|
53
52
|
}
|
|
@@ -79,7 +78,7 @@ export class LanguageQualifierType extends QualifierType {
|
|
|
79
78
|
}).onSuccess(LanguageQualifierType.create);
|
|
80
79
|
}
|
|
81
80
|
/**
|
|
82
|
-
* {@
|
|
81
|
+
* {@inheritDoc QualifierTypes.IQualifierType.isValidConditionValue}
|
|
83
82
|
*/
|
|
84
83
|
isValidConditionValue(value) {
|
|
85
84
|
return Bcp47.tag(value)
|
|
@@ -95,7 +94,7 @@ export class LanguageQualifierType extends QualifierType {
|
|
|
95
94
|
return this.getConfigurationJson().onSuccess((json) => Config.Convert.systemLanguageQualifierTypeConfig.convert(json));
|
|
96
95
|
}
|
|
97
96
|
/**
|
|
98
|
-
* {@
|
|
97
|
+
* {@inheritDoc QualifierTypes.IQualifierType.getConfigurationJson}
|
|
99
98
|
*/
|
|
100
99
|
getConfigurationJson() {
|
|
101
100
|
return succeed({
|
|
@@ -107,7 +106,7 @@ export class LanguageQualifierType extends QualifierType {
|
|
|
107
106
|
});
|
|
108
107
|
}
|
|
109
108
|
/**
|
|
110
|
-
* {@
|
|
109
|
+
* {@inheritDoc QualifierTypes.IQualifierType.validateConfigurationJson}
|
|
111
110
|
*/
|
|
112
111
|
validateConfigurationJson(from) {
|
|
113
112
|
return Config.Convert.systemLanguageQualifierTypeConfig.convert(from);
|
|
@@ -33,11 +33,8 @@ import { sanitizeJsonObject } from '@fgv/ts-json-base';
|
|
|
33
33
|
export class LiteralQualifierType extends QualifierType {
|
|
34
34
|
/**
|
|
35
35
|
* Constructs a new {@link QualifierTypes.LiteralQualifierType | LiteralQualifierType}.
|
|
36
|
-
* @param
|
|
37
|
-
*
|
|
38
|
-
* case-sensitive. Defaults to `false`.
|
|
39
|
-
* @param allowContextList - Optional flag indicating whether the context can be a
|
|
40
|
-
* list of values. Defaults to `false`.
|
|
36
|
+
* @param params - The {@link QualifierTypes.ILiteralQualifierTypeCreateParams | create parameters}
|
|
37
|
+
* for this qualifier type.
|
|
41
38
|
* @public
|
|
42
39
|
*/
|
|
43
40
|
constructor({ name, caseSensitive, allowContextList, enumeratedValues, hierarchy, index }) {
|
|
@@ -48,7 +45,7 @@ export class LiteralQualifierType extends QualifierType {
|
|
|
48
45
|
index: index !== undefined ? Convert.qualifierTypeIndex.convert(index).orThrow() : undefined
|
|
49
46
|
});
|
|
50
47
|
/**
|
|
51
|
-
* {@
|
|
48
|
+
* {@inheritDoc QualifierTypes.IQualifierType.systemTypeName}
|
|
52
49
|
*/
|
|
53
50
|
this.systemTypeName = Convert.qualifierTypeName.convert('literal').orThrow();
|
|
54
51
|
this.caseSensitive = caseSensitive === true;
|
|
@@ -80,7 +77,7 @@ export class LiteralQualifierType extends QualifierType {
|
|
|
80
77
|
return LiteralQualifierType.isValidLiteralConditionValue(value);
|
|
81
78
|
}
|
|
82
79
|
/**
|
|
83
|
-
* {@
|
|
80
|
+
* {@inheritDoc QualifierTypes.IQualifierType.isPotentialMatch}
|
|
84
81
|
*/
|
|
85
82
|
isPotentialMatch(conditionValue, contextValue) {
|
|
86
83
|
if (this.isValidConditionValue(conditionValue) && this.isValidContextValue(contextValue)) {
|
|
@@ -102,7 +99,7 @@ export class LiteralQualifierType extends QualifierType {
|
|
|
102
99
|
return this.getConfigurationJson().onSuccess((json) => Config.Convert.systemLiteralQualifierTypeConfig.convert(json));
|
|
103
100
|
}
|
|
104
101
|
/**
|
|
105
|
-
* {@
|
|
102
|
+
* {@inheritDoc QualifierTypes.IQualifierType.getConfigurationJson}
|
|
106
103
|
*/
|
|
107
104
|
getConfigurationJson() {
|
|
108
105
|
const hierarchy = this.hierarchy ? { hierarchy: this.hierarchy.asRecord() } : {};
|
|
@@ -116,7 +113,7 @@ export class LiteralQualifierType extends QualifierType {
|
|
|
116
113
|
});
|
|
117
114
|
}
|
|
118
115
|
/**
|
|
119
|
-
* {@
|
|
116
|
+
* {@inheritDoc QualifierTypes.IQualifierType.validateConfigurationJson}
|
|
120
117
|
*/
|
|
121
118
|
validateConfigurationJson(from) {
|
|
122
119
|
return Config.Convert.systemLiteralQualifierTypeConfig.convert(from);
|
|
@@ -131,7 +128,7 @@ export class LiteralQualifierType extends QualifierType {
|
|
|
131
128
|
return Config.Convert.systemLiteralQualifierTypeConfig.convert(from);
|
|
132
129
|
}
|
|
133
130
|
/**
|
|
134
|
-
* {@
|
|
131
|
+
* {@inheritDoc QualifierTypes.QualifierType._matchOne}
|
|
135
132
|
*/
|
|
136
133
|
_matchOne(condition, context, __operator) {
|
|
137
134
|
if (this.hierarchy) {
|
|
@@ -28,22 +28,21 @@ import { Convert, NoMatch, PerfectMatch, Validate } from '../common';
|
|
|
28
28
|
*/
|
|
29
29
|
export class QualifierType {
|
|
30
30
|
/**
|
|
31
|
-
* {@
|
|
31
|
+
* {@inheritDoc QualifierTypes.IQualifierType.key}
|
|
32
32
|
*/
|
|
33
33
|
get key() {
|
|
34
34
|
return this._collectible.key;
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
|
-
* {@
|
|
37
|
+
* {@inheritDoc QualifierTypes.IQualifierType.index}
|
|
38
38
|
*/
|
|
39
39
|
get index() {
|
|
40
40
|
return this._collectible.index;
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
43
|
* Constructor for use by derived classes.
|
|
44
|
-
* @param
|
|
45
|
-
*
|
|
46
|
-
* comma-separated list of runtime values in the context. Defaults to `false`.
|
|
44
|
+
* @param params - The {@link QualifierTypes.IQualifierTypeCreateParams | create parameters}
|
|
45
|
+
* for this qualifier type.
|
|
47
46
|
*/
|
|
48
47
|
constructor({ name, index, allowContextList }) {
|
|
49
48
|
this.name = Convert.qualifierTypeName.convert(name).orThrow();
|
|
@@ -55,7 +54,7 @@ export class QualifierType {
|
|
|
55
54
|
});
|
|
56
55
|
}
|
|
57
56
|
/**
|
|
58
|
-
* {@
|
|
57
|
+
* {@inheritDoc QualifierTypes.IQualifierType.isValidContextValue}
|
|
59
58
|
*/
|
|
60
59
|
isValidContextValue(value) {
|
|
61
60
|
if (this.isValidConditionValue(value)) {
|
|
@@ -69,7 +68,7 @@ export class QualifierType {
|
|
|
69
68
|
return false;
|
|
70
69
|
}
|
|
71
70
|
/**
|
|
72
|
-
* {@
|
|
71
|
+
* {@inheritDoc QualifierTypes.IQualifierType.isPotentialMatch}
|
|
73
72
|
*/
|
|
74
73
|
isPotentialMatch(conditionValue, contextValue) {
|
|
75
74
|
if (this.isValidConditionValue(conditionValue) && this.isValidContextValue(contextValue)) {
|
|
@@ -79,7 +78,7 @@ export class QualifierType {
|
|
|
79
78
|
return false;
|
|
80
79
|
}
|
|
81
80
|
/**
|
|
82
|
-
* {@
|
|
81
|
+
* {@inheritDoc QualifierTypes.IQualifierType.validateCondition}
|
|
83
82
|
*/
|
|
84
83
|
validateCondition(value, operator) {
|
|
85
84
|
operator = operator !== null && operator !== void 0 ? operator : 'matches';
|
|
@@ -94,7 +93,7 @@ export class QualifierType {
|
|
|
94
93
|
return succeed(value);
|
|
95
94
|
}
|
|
96
95
|
/**
|
|
97
|
-
* {@
|
|
96
|
+
* {@inheritDoc QualifierTypes.IQualifierType.validateContextValue}
|
|
98
97
|
*/
|
|
99
98
|
validateContextValue(value) {
|
|
100
99
|
/* c8 ignore next 2 - functional error case tested but coverage intermittently missed */
|
|
@@ -104,7 +103,7 @@ export class QualifierType {
|
|
|
104
103
|
return succeed(value);
|
|
105
104
|
}
|
|
106
105
|
/**
|
|
107
|
-
* {@
|
|
106
|
+
* {@inheritDoc QualifierTypes.IQualifierType.matches}
|
|
108
107
|
*/
|
|
109
108
|
matches(condition, context, operator) {
|
|
110
109
|
if (this.allowContextList) {
|
|
@@ -113,19 +112,19 @@ export class QualifierType {
|
|
|
113
112
|
return this._matchOne(condition, context, operator);
|
|
114
113
|
}
|
|
115
114
|
/**
|
|
116
|
-
* {@
|
|
115
|
+
* {@inheritDoc QualifierTypes.IQualifierType.setIndex}
|
|
117
116
|
*/
|
|
118
117
|
setIndex(index) {
|
|
119
118
|
return this._collectible.setIndex(index);
|
|
120
119
|
}
|
|
121
120
|
/**
|
|
122
|
-
* {@
|
|
121
|
+
* {@inheritDoc Validate.isValidQualifierTypeName}
|
|
123
122
|
*/
|
|
124
123
|
static isValidName(name) {
|
|
125
124
|
return Validate.isValidQualifierTypeName(name);
|
|
126
125
|
}
|
|
127
126
|
/**
|
|
128
|
-
* {@
|
|
127
|
+
* {@inheritDoc Validate.isValidQualifierTypeIndex}
|
|
129
128
|
*/
|
|
130
129
|
static isValidIndex(index) {
|
|
131
130
|
return Validate.isValidQualifierTypeIndex(index);
|
|
@@ -50,7 +50,7 @@ export class TerritoryQualifierType extends QualifierType {
|
|
|
50
50
|
index: validIndex
|
|
51
51
|
});
|
|
52
52
|
/**
|
|
53
|
-
* {@
|
|
53
|
+
* {@inheritDoc QualifierTypes.IQualifierType.systemTypeName}
|
|
54
54
|
*/
|
|
55
55
|
this.systemTypeName = Convert.qualifierTypeName
|
|
56
56
|
.convert('territory')
|
|
@@ -66,7 +66,7 @@ export class TerritoryQualifierType extends QualifierType {
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
69
|
-
* {@
|
|
69
|
+
* {@inheritDoc QualifierTypes.QualifierType.isValidConditionValue}
|
|
70
70
|
*/
|
|
71
71
|
isValidConditionValue(value) {
|
|
72
72
|
const normalized = this.acceptLowercase ? value.toUpperCase() : value;
|
|
@@ -120,7 +120,7 @@ export class TerritoryQualifierType extends QualifierType {
|
|
|
120
120
|
return this.getConfigurationJson().onSuccess((json) => Config.Convert.systemTerritoryQualifierTypeConfig.convert(json));
|
|
121
121
|
}
|
|
122
122
|
/**
|
|
123
|
-
* {@
|
|
123
|
+
* {@inheritDoc QualifierTypes.IQualifierType.getConfigurationJson}
|
|
124
124
|
*/
|
|
125
125
|
getConfigurationJson() {
|
|
126
126
|
const hierarchy = this.hierarchy ? { hierarchy: this.hierarchy.asRecord() } : {};
|
|
@@ -134,7 +134,7 @@ export class TerritoryQualifierType extends QualifierType {
|
|
|
134
134
|
});
|
|
135
135
|
}
|
|
136
136
|
/**
|
|
137
|
-
* {@
|
|
137
|
+
* {@inheritDoc QualifierTypes.IQualifierType.validateConfigurationJson}
|
|
138
138
|
*/
|
|
139
139
|
validateConfigurationJson(from) {
|
|
140
140
|
return Config.Convert.systemTerritoryQualifierTypeConfig.convert(from);
|
|
@@ -149,7 +149,7 @@ export class TerritoryQualifierType extends QualifierType {
|
|
|
149
149
|
return this.validateConfigurationJson(from).onSuccess((json) => Config.Convert.systemTerritoryQualifierTypeConfig.convert(json));
|
|
150
150
|
}
|
|
151
151
|
/**
|
|
152
|
-
* {@
|
|
152
|
+
* {@inheritDoc QualifierTypes.QualifierType._matchOne}
|
|
153
153
|
*/
|
|
154
154
|
_matchOne(condition, context, __operator) {
|
|
155
155
|
if (this.isValidConditionValue(condition) && this.isValidContextValue(context)) {
|
|
@@ -42,9 +42,8 @@ export class Qualifier {
|
|
|
42
42
|
/**
|
|
43
43
|
* Constructs a new instance of a {@link Qualifiers.Qualifier | Qualifier} from the
|
|
44
44
|
* supplied {@link Qualifiers.IValidatedQualifierDecl | validated declaration}.
|
|
45
|
-
* @param
|
|
46
|
-
*
|
|
47
|
-
* @param defaultPriority - The default {@link ConditionPriority | priority} of conditions
|
|
45
|
+
* @param decl - The {@link Qualifiers.IValidatedQualifierDecl | validated declaration}
|
|
46
|
+
* describing the qualifier to construct.
|
|
48
47
|
* @public
|
|
49
48
|
*/
|
|
50
49
|
constructor({ name, token, type, defaultPriority, tokenIsOptional, defaultValue, index }) {
|
|
@@ -81,25 +80,25 @@ export class Qualifier {
|
|
|
81
80
|
return this._collectible.setIndex(index);
|
|
82
81
|
}
|
|
83
82
|
/**
|
|
84
|
-
* {@
|
|
83
|
+
* {@inheritDoc QualifierTypes.QualifierType.isValidContextValue}
|
|
85
84
|
*/
|
|
86
85
|
isValidContextValue(value) {
|
|
87
86
|
return this.type.isValidContextValue(value);
|
|
88
87
|
}
|
|
89
88
|
/**
|
|
90
|
-
* {@
|
|
89
|
+
* {@inheritDoc QualifierTypes.QualifierType.isValidConditionValue}
|
|
91
90
|
*/
|
|
92
91
|
isValidConditionValue(value) {
|
|
93
92
|
return this.type.isValidConditionValue(value);
|
|
94
93
|
}
|
|
95
94
|
/**
|
|
96
|
-
* {@
|
|
95
|
+
* {@inheritDoc QualifierTypes.QualifierType.validateCondition}
|
|
97
96
|
*/
|
|
98
97
|
validateCondition(value, operator) {
|
|
99
98
|
return this.type.validateCondition(value, operator);
|
|
100
99
|
}
|
|
101
100
|
/**
|
|
102
|
-
* {@
|
|
101
|
+
* {@inheritDoc QualifierTypes.QualifierType.validateContextValue}
|
|
103
102
|
*/
|
|
104
103
|
validateContextValue(value) {
|
|
105
104
|
return this.type.validateContextValue(value);
|
|
@@ -57,7 +57,7 @@ export class QualifierCollector extends ValidatingConvertingCollector {
|
|
|
57
57
|
return captureResult(() => new QualifierCollector(params));
|
|
58
58
|
}
|
|
59
59
|
/**
|
|
60
|
-
* {@
|
|
60
|
+
* {@inheritDoc Qualifiers.IReadOnlyQualifierCollector.getByNameOrToken}
|
|
61
61
|
*/
|
|
62
62
|
getByNameOrToken(nameOrToken) {
|
|
63
63
|
return this.validating.get(nameOrToken).onFailure((message) => {
|
|
@@ -70,7 +70,7 @@ export class QualifierCollector extends ValidatingConvertingCollector {
|
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
73
|
-
* {@
|
|
73
|
+
* {@inheritDoc Qualifiers.IReadOnlyQualifierCollector.hasNameOrToken}
|
|
74
74
|
*/
|
|
75
75
|
hasNameOrToken(nameOrToken) {
|
|
76
76
|
/* c8 ignore next 3 - functional code path tested but coverage intermittently missed */
|
|
@@ -29,7 +29,7 @@ import { mergeContextDecl, mergeImporterCandidate, mergeImporterResource } from
|
|
|
29
29
|
*/
|
|
30
30
|
export class ResourceDeclCollection {
|
|
31
31
|
/**
|
|
32
|
-
* {@
|
|
32
|
+
* {@inheritDoc ResourceJson.IResourceDeclContainer.context}
|
|
33
33
|
*/
|
|
34
34
|
get context() {
|
|
35
35
|
return this.collection.context;
|
|
@@ -30,7 +30,7 @@ import { mergeChildResource } from './helpers';
|
|
|
30
30
|
*/
|
|
31
31
|
export class ResourceDeclTree {
|
|
32
32
|
/**
|
|
33
|
-
* {@
|
|
33
|
+
* {@inheritDoc ResourceJson.IResourceDeclContainer.context}
|
|
34
34
|
*/
|
|
35
35
|
get context() {
|
|
36
36
|
return this.tree.context;
|
|
@@ -37,7 +37,7 @@ export class JsonResourceType extends ResourceType {
|
|
|
37
37
|
constructor(key, index, template) {
|
|
38
38
|
super(key, index, template);
|
|
39
39
|
/**
|
|
40
|
-
* {@
|
|
40
|
+
* {@inheritDoc ResourceTypes.ResourceType.systemTypeName}
|
|
41
41
|
*/
|
|
42
42
|
this.systemTypeName = Convert.resourceTypeName.convert('json').orThrow();
|
|
43
43
|
}
|
|
@@ -54,7 +54,7 @@ export class JsonResourceType extends ResourceType {
|
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
|
-
* {@
|
|
57
|
+
* {@inheritDoc ResourceTypes.ResourceType.validateDeclaration}
|
|
58
58
|
*/
|
|
59
59
|
validateDeclaration(props) {
|
|
60
60
|
return JsonConverters.jsonObject.convert(props.json);
|
|
@@ -30,13 +30,13 @@ import { Convert as CommonConvert, Validate } from '../common';
|
|
|
30
30
|
*/
|
|
31
31
|
export class ResourceType {
|
|
32
32
|
/**
|
|
33
|
-
* {@
|
|
33
|
+
* {@inheritDoc ResourceTypes.IResourceType.key}
|
|
34
34
|
*/
|
|
35
35
|
get key() {
|
|
36
36
|
return this._collectible.key;
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
|
-
* {@
|
|
39
|
+
* {@inheritDoc ResourceTypes.IResourceType.index}
|
|
40
40
|
*/
|
|
41
41
|
get index() {
|
|
42
42
|
return this._collectible.index;
|
|
@@ -81,7 +81,7 @@ export class ResourceBuilder {
|
|
|
81
81
|
/**
|
|
82
82
|
* Given a {@link ResourceJson.Json.IChildResourceCandidateDecl | child resource candidate declaration}, creates and adds a
|
|
83
83
|
* {@link Resources.ResourceCandidate | candidate} to the resource being built.
|
|
84
|
-
* @param
|
|
84
|
+
* @param childDecl - The {@link ResourceJson.Json.IChildResourceCandidateDecl | IChildResourceCandidateDecl} to add to the
|
|
85
85
|
* resource being built.
|
|
86
86
|
* @returns `Success` with the added {@link Resources.ResourceCandidate | candidate} if successful,
|
|
87
87
|
* or `Failure` with an error message if not.
|
|
@@ -113,7 +113,7 @@ export class ResourceBuilder {
|
|
|
113
113
|
/**
|
|
114
114
|
* Given a {@link ResourceJson.Json.ILooseResourceCandidateDecl | resource candidate declaration}, creates and adds a
|
|
115
115
|
* {@link Resources.ResourceCandidate | candidate} to the resource being built.
|
|
116
|
-
* @param
|
|
116
|
+
* @param decl - The {@link ResourceJson.Json.ILooseResourceCandidateDecl | IResourceCandidateDecl} to add to the
|
|
117
117
|
* resource being built.
|
|
118
118
|
* @returns `Success` with the added {@link Resources.ResourceCandidate | candidate} if successful,
|
|
119
119
|
* or `Failure` with an error message if not. Fails with error detail 'type-mismatch' if the candidate
|
|
@@ -90,13 +90,13 @@ export class ResourceManagerBuilder {
|
|
|
90
90
|
return this._resources.size;
|
|
91
91
|
}
|
|
92
92
|
/**
|
|
93
|
-
* {@
|
|
93
|
+
* {@inheritDoc Runtime.IResourceManager.numResources}
|
|
94
94
|
*/
|
|
95
95
|
get numResources() {
|
|
96
96
|
return this._resources.size;
|
|
97
97
|
}
|
|
98
98
|
/**
|
|
99
|
-
* {@
|
|
99
|
+
* {@inheritDoc Runtime.IResourceManager.numCandidates}
|
|
100
100
|
*/
|
|
101
101
|
get numCandidates() {
|
|
102
102
|
if (this._numCandidates === undefined) {
|
|
@@ -105,7 +105,7 @@ export class ResourceManagerBuilder {
|
|
|
105
105
|
return this._numCandidates;
|
|
106
106
|
}
|
|
107
107
|
/**
|
|
108
|
-
* {@
|
|
108
|
+
* {@inheritDoc Runtime.IResourceManager.builtResources}
|
|
109
109
|
*/
|
|
110
110
|
get builtResources() {
|
|
111
111
|
return this._performBuild().orThrow();
|
|
@@ -194,7 +194,7 @@ export class ResourceManagerBuilder {
|
|
|
194
194
|
/**
|
|
195
195
|
* Given a {@link ResourceJson.Json.ILooseResourceCandidateDecl | resource candidate declaration}, builds and adds
|
|
196
196
|
* a {@link Resources.ResourceCandidate | candidate} to the manager.
|
|
197
|
-
* @param
|
|
197
|
+
* @param decl - The {@link ResourceJson.Json.ILooseResourceCandidateDecl | loose resource candidate declaration} to add.
|
|
198
198
|
* @returns `Success` with the candidate if successful, or `Failure` with an error message if not.
|
|
199
199
|
* @public
|
|
200
200
|
*/
|
|
@@ -272,7 +272,7 @@ export class ResourceManagerBuilder {
|
|
|
272
272
|
}
|
|
273
273
|
/**
|
|
274
274
|
* Adds a condition set to the manager.
|
|
275
|
-
* @param
|
|
275
|
+
* @param conditions - The {@link ResourceJson.Normalized.ConditionSetDecl | condition set declaration} to add.
|
|
276
276
|
* @returns `Success` with the condition set if successful, or `Failure` with an error message if not.
|
|
277
277
|
* @public
|
|
278
278
|
*/
|