@fgv/ts-res 5.0.0-21 → 5.0.0-23
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/README.md +794 -137
- package/dist/ts-res.d.ts +506 -33
- package/lib/packlets/common/convert.d.ts +10 -0
- package/lib/packlets/common/convert.js +11 -1
- package/lib/packlets/common/resources.d.ts +40 -1
- package/lib/packlets/common/validate/regularExpressions.d.ts +4 -0
- package/lib/packlets/common/validate/regularExpressions.js +5 -1
- package/lib/packlets/common/validate/resources.d.ts +35 -1
- package/lib/packlets/common/validate/resources.js +54 -0
- package/lib/packlets/config/convert.js +1 -1
- package/lib/packlets/config/json.d.ts +1 -1
- package/lib/packlets/qualifier-types/config/convert.d.ts +22 -1
- package/lib/packlets/qualifier-types/config/convert.js +67 -2
- package/lib/packlets/qualifier-types/config/json.d.ts +11 -2
- package/lib/packlets/qualifier-types/helpers.d.ts +1 -2
- package/lib/packlets/qualifier-types/languageQualifierType.d.ts +27 -1
- package/lib/packlets/qualifier-types/languageQualifierType.js +75 -0
- package/lib/packlets/qualifier-types/literalQualifierType.d.ts +30 -4
- package/lib/packlets/qualifier-types/literalQualifierType.js +77 -0
- package/lib/packlets/qualifier-types/literalValueHierarchy.d.ts +6 -10
- package/lib/packlets/qualifier-types/literalValueHierarchy.js +10 -0
- package/lib/packlets/qualifier-types/qualifierType.d.ts +28 -0
- package/lib/packlets/qualifier-types/territoryQualifierType.d.ts +28 -4
- package/lib/packlets/qualifier-types/territoryQualifierType.js +77 -0
- package/lib/packlets/resource-json/compiled/convert.js +2 -1
- package/lib/packlets/resource-json/compiled/json.d.ts +6 -2
- package/lib/packlets/resource-types/config/convert.js +3 -1
- package/lib/packlets/resource-types/config/json.d.ts +2 -0
- package/lib/packlets/resource-types/jsonResourceType.d.ts +10 -6
- package/lib/packlets/resource-types/jsonResourceType.js +7 -10
- package/lib/packlets/resource-types/resourceType.d.ts +20 -8
- package/lib/packlets/resource-types/resourceType.js +20 -16
- package/lib/packlets/resources/candidateValue.d.ts +92 -0
- package/lib/packlets/resources/candidateValue.js +128 -0
- package/lib/packlets/resources/candidateValueCollector.d.ts +55 -0
- package/lib/packlets/resources/candidateValueCollector.js +96 -0
- package/lib/packlets/resources/index.d.ts +2 -0
- package/lib/packlets/resources/index.js +2 -0
- package/lib/packlets/resources/resource.js +2 -2
- package/lib/packlets/resources/resourceBuilder.d.ts +6 -0
- package/lib/packlets/resources/resourceBuilder.js +3 -1
- package/lib/packlets/resources/resourceCandidate.d.ts +10 -1
- package/lib/packlets/resources/resourceCandidate.js +11 -5
- package/lib/packlets/resources/resourceManagerBuilder.d.ts +7 -0
- package/lib/packlets/resources/resourceManagerBuilder.js +13 -6
- package/lib/packlets/runtime/compiledResourceCollection.d.ts +20 -8
- package/lib/packlets/runtime/compiledResourceCollection.js +25 -4
- package/lib/packlets/runtime/resource-tree/common.d.ts +1 -1
- package/lib/packlets/runtime/resourceResolver.d.ts +39 -1
- package/lib/packlets/runtime/resourceResolver.js +45 -28
- package/lib/test/unit/qualifier-types/testQualifierType.d.ts +4 -0
- package/lib/test/unit/qualifier-types/testQualifierType.js +24 -0
- package/lib/test/unit/resource-types/derivedResourceType.test.d.ts +2 -0
- package/lib/test/unit/resource-types/testDerivedResourceType.d.ts +79 -0
- package/lib/test/unit/resource-types/testDerivedResourceType.js +113 -0
- package/lib/test/unit/resources/candidateValue.test.d.ts +2 -0
- package/lib/test/unit/resources/candidateValueCollector.test.d.ts +2 -0
- package/lib/test/unit/runtime/resourceResolver.coverage.test.d.ts +2 -0
- package/lib/test/unit/runtime/resourceResolver.newFeatures.test.d.ts +2 -0
- package/package.json +7 -7
- package/src/index.ts +0 -75
- package/src/packlets/bundle/bundleBuilder.ts +0 -159
- package/src/packlets/bundle/bundleLoader.ts +0 -157
- package/src/packlets/bundle/bundleNormalizer.ts +0 -173
- package/src/packlets/bundle/bundleUtils.ts +0 -142
- package/src/packlets/bundle/convert.ts +0 -87
- package/src/packlets/bundle/index.ts +0 -52
- package/src/packlets/bundle/model.ts +0 -138
- package/src/packlets/common/conditions.ts +0 -226
- package/src/packlets/common/convert.ts +0 -184
- package/src/packlets/common/helpers/conditions.ts +0 -84
- package/src/packlets/common/helpers/context.ts +0 -88
- package/src/packlets/common/helpers/index.ts +0 -26
- package/src/packlets/common/helpers/qualifierDefaultValues.ts +0 -91
- package/src/packlets/common/helpers/resources.ts +0 -96
- package/src/packlets/common/index.ts +0 -30
- package/src/packlets/common/resources.ts +0 -78
- package/src/packlets/common/validate/conditions.ts +0 -595
- package/src/packlets/common/validate/index.ts +0 -27
- package/src/packlets/common/validate/regularExpressions.ts +0 -92
- package/src/packlets/common/validate/resources.ts +0 -170
- package/src/packlets/conditions/condition.ts +0 -351
- package/src/packlets/conditions/conditionCollector.ts +0 -103
- package/src/packlets/conditions/conditionDecls.ts +0 -50
- package/src/packlets/conditions/conditionSet.ts +0 -318
- package/src/packlets/conditions/conditionSetCollector.ts +0 -127
- package/src/packlets/conditions/conditionSetDecls.ts +0 -41
- package/src/packlets/conditions/conditionToken.ts +0 -180
- package/src/packlets/conditions/convert/conditionSetDecls.ts +0 -72
- package/src/packlets/conditions/convert/decls.ts +0 -95
- package/src/packlets/conditions/convert/index.ts +0 -24
- package/src/packlets/conditions/index.ts +0 -33
- package/src/packlets/config/common.ts +0 -107
- package/src/packlets/config/configInitFactory.ts +0 -142
- package/src/packlets/config/convert.ts +0 -61
- package/src/packlets/config/index.ts +0 -30
- package/src/packlets/config/json.ts +0 -43
- package/src/packlets/config/predefined/default.ts +0 -150
- package/src/packlets/config/predefined/extended.ts +0 -198
- package/src/packlets/config/predefined/index.ts +0 -26
- package/src/packlets/config/systemConfiguration.ts +0 -217
- package/src/packlets/context/contextDecls.ts +0 -76
- package/src/packlets/context/contextToken.ts +0 -252
- package/src/packlets/context/convert/decls.ts +0 -126
- package/src/packlets/context/convert/index.ts +0 -23
- package/src/packlets/context/index.ts +0 -27
- package/src/packlets/decisions/abstractDecision.ts +0 -87
- package/src/packlets/decisions/abstractDecisionCollector.ts +0 -122
- package/src/packlets/decisions/candidate.ts +0 -101
- package/src/packlets/decisions/common.ts +0 -37
- package/src/packlets/decisions/concreteDecision.ts +0 -157
- package/src/packlets/decisions/decision.ts +0 -172
- package/src/packlets/decisions/index.ts +0 -28
- package/src/packlets/import/fsItem.ts +0 -212
- package/src/packlets/import/importContext.ts +0 -183
- package/src/packlets/import/importManager.ts +0 -187
- package/src/packlets/import/importable.ts +0 -107
- package/src/packlets/import/importers/collectionImporter.ts +0 -153
- package/src/packlets/import/importers/fsItemImporter.ts +0 -154
- package/src/packlets/import/importers/importer.ts +0 -58
- package/src/packlets/import/importers/index.ts +0 -27
- package/src/packlets/import/importers/jsonImporter.ts +0 -133
- package/src/packlets/import/importers/pathImporter.ts +0 -134
- package/src/packlets/import/index.ts +0 -29
- package/src/packlets/qualifier-types/config/convert.ts +0 -108
- package/src/packlets/qualifier-types/config/index.ts +0 -27
- package/src/packlets/qualifier-types/config/json.ts +0 -126
- package/src/packlets/qualifier-types/convert.ts +0 -77
- package/src/packlets/qualifier-types/helpers.ts +0 -94
- package/src/packlets/qualifier-types/index.ts +0 -34
- package/src/packlets/qualifier-types/languageQualifierType.ts +0 -143
- package/src/packlets/qualifier-types/literalQualifierType.ts +0 -244
- package/src/packlets/qualifier-types/literalValueHierarchy.ts +0 -332
- package/src/packlets/qualifier-types/qualifierType.ts +0 -360
- package/src/packlets/qualifier-types/qualifierTypeCollector.ts +0 -102
- package/src/packlets/qualifier-types/territoryQualifierType.ts +0 -255
- package/src/packlets/qualifiers/convert/decls.ts +0 -90
- package/src/packlets/qualifiers/convert/index.ts +0 -24
- package/src/packlets/qualifiers/convert/qualifier.ts +0 -55
- package/src/packlets/qualifiers/index.ts +0 -31
- package/src/packlets/qualifiers/qualifier.ts +0 -169
- package/src/packlets/qualifiers/qualifierCollector.ts +0 -194
- package/src/packlets/qualifiers/qualifierDecl.ts +0 -80
- package/src/packlets/qualifiers/qualifierDefaultValueDecls.ts +0 -57
- package/src/packlets/qualifiers/qualifierDefaultValueToken.ts +0 -230
- package/src/packlets/resource-json/compiled/common.ts +0 -35
- package/src/packlets/resource-json/compiled/convert.ts +0 -143
- package/src/packlets/resource-json/compiled/index.ts +0 -27
- package/src/packlets/resource-json/compiled/json.ts +0 -239
- package/src/packlets/resource-json/convert.ts +0 -236
- package/src/packlets/resource-json/helpers.ts +0 -284
- package/src/packlets/resource-json/index.ts +0 -33
- package/src/packlets/resource-json/json.ts +0 -295
- package/src/packlets/resource-json/normalized.ts +0 -211
- package/src/packlets/resource-json/resourceDeclCollection.ts +0 -117
- package/src/packlets/resource-json/resourceDeclContainer.ts +0 -48
- package/src/packlets/resource-json/resourceDeclTree.ts +0 -116
- package/src/packlets/resource-types/config/convert.ts +0 -36
- package/src/packlets/resource-types/config/index.ts +0 -27
- package/src/packlets/resource-types/config/json.ts +0 -30
- package/src/packlets/resource-types/helpers.ts +0 -44
- package/src/packlets/resource-types/index.ts +0 -30
- package/src/packlets/resource-types/jsonResourceType.ts +0 -104
- package/src/packlets/resource-types/resourceType.ts +0 -259
- package/src/packlets/resource-types/resourceTypeCollector.ts +0 -79
- package/src/packlets/resources/candidateReducer.ts +0 -331
- package/src/packlets/resources/common.ts +0 -114
- package/src/packlets/resources/index.ts +0 -28
- package/src/packlets/resources/resource.ts +0 -307
- package/src/packlets/resources/resourceBuilder.ts +0 -269
- package/src/packlets/resources/resourceCandidate.ts +0 -333
- package/src/packlets/resources/resourceManagerBuilder.ts +0 -1169
- package/src/packlets/runtime/cacheListener.ts +0 -113
- package/src/packlets/runtime/cacheMetrics.ts +0 -206
- package/src/packlets/runtime/compiledResourceCollection.ts +0 -607
- package/src/packlets/runtime/conditionSetResolutionResult.ts +0 -160
- package/src/packlets/runtime/context/contextQualifierProvider.ts +0 -117
- package/src/packlets/runtime/context/contextQualifierProviderValidator.ts +0 -281
- package/src/packlets/runtime/context/index.ts +0 -26
- package/src/packlets/runtime/context/simpleContextQualifierProvider.ts +0 -225
- package/src/packlets/runtime/context/validatingSimpleContextQualifierProvider.ts +0 -96
- package/src/packlets/runtime/iResourceManager.ts +0 -130
- package/src/packlets/runtime/index.ts +0 -35
- package/src/packlets/runtime/resource-tree/common.ts +0 -126
- package/src/packlets/runtime/resource-tree/index.ts +0 -26
- package/src/packlets/runtime/resource-tree/readOnlyResourceTree.ts +0 -342
- package/src/packlets/runtime/resource-tree/resourceTreeChildren.ts +0 -125
- package/src/packlets/runtime/resource-tree/resourceTreeChildrenValidator.ts +0 -187
- package/src/packlets/runtime/resourceResolver.ts +0 -626
- package/src/packlets/runtime/validate.ts +0 -63
- package/src/packlets/zip-archive/convert.ts +0 -121
- package/src/packlets/zip-archive/index.ts +0 -76
- package/src/packlets/zip-archive/json.ts +0 -91
- package/src/packlets/zip-archive/types.ts +0 -140
- package/src/packlets/zip-archive/zipArchiveCreator.ts +0 -229
- package/src/packlets/zip-archive/zipArchiveFormat.ts +0 -158
- package/src/packlets/zip-archive/zipArchiveLoader.ts +0 -370
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2025 Erik Fortune
|
|
3
|
-
*
|
|
4
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
6
|
-
* in the Software without restriction, including without limitation the rights
|
|
7
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
9
|
-
* furnished to do so, subject to the following conditions:
|
|
10
|
-
*
|
|
11
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
12
|
-
* copies or substantial portions of the Software.
|
|
13
|
-
*
|
|
14
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
-
* SOFTWARE.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
import { Result, ResultMap, captureResult, succeed, fail, succeedWithDetail } from '@fgv/ts-utils';
|
|
24
|
-
import { QualifierName, QualifierContextValue, QualifierIndex, Validate } from '../../common';
|
|
25
|
-
import { IReadOnlyQualifierCollector, Qualifier } from '../../qualifiers';
|
|
26
|
-
import { ContextQualifierProvider } from './contextQualifierProvider';
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Parameters for creating a {@link Runtime.SimpleContextQualifierProvider | SimpleContextQualifierProvider}.
|
|
30
|
-
* @public
|
|
31
|
-
*/
|
|
32
|
-
export interface ISimpleContextQualifierProviderCreateParams {
|
|
33
|
-
/**
|
|
34
|
-
* The {@link Qualifiers.IReadOnlyQualifierCollector | readonly qualifier collector} that defines and validates qualifiers.
|
|
35
|
-
*/
|
|
36
|
-
qualifiers: IReadOnlyQualifierCollector;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Optional record of initial qualifier name-value pairs to populate the provider.
|
|
40
|
-
*/
|
|
41
|
-
qualifierValues?: Record<string, QualifierContextValue>;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Simple concrete implementation of {@link Runtime.Context.IContextQualifierProvider | IContextQualifierProvider}
|
|
46
|
-
* using a `ResultMap` for qualifier value storage.
|
|
47
|
-
* @public
|
|
48
|
-
*/
|
|
49
|
-
export class SimpleContextQualifierProvider extends ContextQualifierProvider {
|
|
50
|
-
/**
|
|
51
|
-
* The readonly qualifier collector that defines and validates the qualifiers for this context.
|
|
52
|
-
*/
|
|
53
|
-
public readonly qualifiers: IReadOnlyQualifierCollector;
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Internal storage for qualifier values using a ResultMap.
|
|
57
|
-
*/
|
|
58
|
-
private readonly _qualifierValues: ResultMap<QualifierName, QualifierContextValue>;
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Constructor for a {@link Runtime.SimpleContextQualifierProvider | SimpleContextQualifierProvider} object.
|
|
62
|
-
* @param params - {@link Runtime.ISimpleContextQualifierProviderCreateParams | Parameters} used to create the provider.
|
|
63
|
-
*/
|
|
64
|
-
protected constructor(params: ISimpleContextQualifierProviderCreateParams) {
|
|
65
|
-
super();
|
|
66
|
-
this.qualifiers = params.qualifiers;
|
|
67
|
-
this._qualifierValues = new ResultMap<QualifierName, QualifierContextValue>();
|
|
68
|
-
|
|
69
|
-
if (params.qualifierValues) {
|
|
70
|
-
for (const [name, value] of Object.entries(params.qualifierValues)) {
|
|
71
|
-
const qualifierName = Validate.toQualifierName(name).orThrow();
|
|
72
|
-
this._qualifierValues.set(qualifierName, value);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Creates a new {@link Runtime.SimpleContextQualifierProvider | SimpleContextQualifierProvider} object.
|
|
79
|
-
* @param params - {@link Runtime.ISimpleContextQualifierProviderCreateParams | Parameters} used to create the provider.
|
|
80
|
-
* @returns `Success` with the new {@link Runtime.SimpleContextQualifierProvider | SimpleContextQualifierProvider} object if successful,
|
|
81
|
-
* or `Failure` with an error message if not.
|
|
82
|
-
* @public
|
|
83
|
-
*/
|
|
84
|
-
public static create(
|
|
85
|
-
params: ISimpleContextQualifierProviderCreateParams
|
|
86
|
-
): Result<SimpleContextQualifierProvider> {
|
|
87
|
-
return captureResult(() => new SimpleContextQualifierProvider(params));
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Gets a qualifier value by its name, index, or qualifier object.
|
|
92
|
-
* @param nameOrIndexOrQualifier - The {@link QualifierName | qualifier name}, {@link QualifierIndex | index}, or {@link Qualifiers.Qualifier | qualifier object} to look up.
|
|
93
|
-
* @returns `Success` with the {@link QualifierContextValue | qualifier context value} if found,
|
|
94
|
-
* or `Failure` with an error message if not found or an error occurs.
|
|
95
|
-
*/
|
|
96
|
-
public get(
|
|
97
|
-
nameOrIndexOrQualifier: QualifierName | QualifierIndex | Qualifier
|
|
98
|
-
): Result<QualifierContextValue> {
|
|
99
|
-
const qualifierName = this._resolveQualifierName(nameOrIndexOrQualifier);
|
|
100
|
-
/* c8 ignore next 3 - functional code path tested but coverage intermittently missed */
|
|
101
|
-
if (qualifierName.isFailure()) {
|
|
102
|
-
return fail(qualifierName.message);
|
|
103
|
-
}
|
|
104
|
-
return this._qualifierValues.get(qualifierName.value);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Gets a validated qualifier context value by its name, index, or qualifier object.
|
|
109
|
-
* TODO: Implement validation logic using qualifier collectors.
|
|
110
|
-
* @param nameOrIndexOrQualifier - The {@link QualifierName | qualifier name}, {@link QualifierIndex | index}, or {@link Qualifiers.Qualifier | qualifier object} to look up.
|
|
111
|
-
* @returns `Success` with the validated {@link QualifierContextValue | qualifier context value} if found,
|
|
112
|
-
* or `Failure` with an error message if not found, invalid, or an error occurs.
|
|
113
|
-
*/
|
|
114
|
-
public getValidated(
|
|
115
|
-
nameOrIndexOrQualifier: QualifierName | QualifierIndex | Qualifier
|
|
116
|
-
): Result<QualifierContextValue> {
|
|
117
|
-
const qualifierName = this._resolveQualifierName(nameOrIndexOrQualifier);
|
|
118
|
-
if (qualifierName.isFailure()) {
|
|
119
|
-
return fail(qualifierName.message);
|
|
120
|
-
}
|
|
121
|
-
// TODO: Implement validation logic
|
|
122
|
-
return fail(`getValidated not yet implemented for qualifier "${qualifierName.value}"`);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Checks if a qualifier value exists with the given name.
|
|
127
|
-
* @param name - The {@link QualifierName | qualifier name} to check.
|
|
128
|
-
* @returns `Success` with `true` if the qualifier value exists, `false` if it doesn't,
|
|
129
|
-
* or `Failure` with an error message if an error occurs during the check.
|
|
130
|
-
*/
|
|
131
|
-
public has(name: QualifierName): Result<boolean> {
|
|
132
|
-
return succeed(this._qualifierValues.has(name));
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Gets all available qualifier names in this context.
|
|
137
|
-
* @returns `Success` with an array of all {@link QualifierName | qualifier names},
|
|
138
|
-
* or `Failure` with an error message if an error occurs.
|
|
139
|
-
*/
|
|
140
|
-
public getNames(): Result<ReadonlyArray<QualifierName>> {
|
|
141
|
-
return succeed(Array.from(this._qualifierValues.keys()));
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Sets a qualifier value in this provider.
|
|
146
|
-
* @param name - The {@link QualifierName | qualifier name} to set.
|
|
147
|
-
* @param value - The {@link QualifierContextValue | qualifier context value} to set.
|
|
148
|
-
* @returns `Success` with the set {@link QualifierContextValue | qualifier context value} if successful,
|
|
149
|
-
* or `Failure` with an error message if not.
|
|
150
|
-
* @public
|
|
151
|
-
*/
|
|
152
|
-
public set(name: QualifierName, value: QualifierContextValue): Result<QualifierContextValue> {
|
|
153
|
-
this._qualifierValues.set(name, value);
|
|
154
|
-
return succeed(value);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Removes a qualifier value from this provider.
|
|
159
|
-
* @param name - The {@link QualifierName | qualifier name} to remove.
|
|
160
|
-
* @returns `Success` with the removed {@link QualifierContextValue | qualifier context value} if successful,
|
|
161
|
-
* or `Failure` with an error message if not found or an error occurs.
|
|
162
|
-
* @public
|
|
163
|
-
*/
|
|
164
|
-
public remove(name: QualifierName): Result<QualifierContextValue> {
|
|
165
|
-
return this._qualifierValues.get(name).onSuccess((value) => {
|
|
166
|
-
this._qualifierValues.delete(name);
|
|
167
|
-
return succeedWithDetail(value, 'success');
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Gets the number of qualifier values in this provider.
|
|
173
|
-
* @returns The count of qualifier values.
|
|
174
|
-
* @public
|
|
175
|
-
*/
|
|
176
|
-
public get size(): number {
|
|
177
|
-
return this._qualifierValues.size;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Clears all qualifier values from this provider.
|
|
182
|
-
* @public
|
|
183
|
-
*/
|
|
184
|
-
public clear(): void {
|
|
185
|
-
this._qualifierValues.clear();
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* Resolves a qualifier name from a name, index, or qualifier object.
|
|
190
|
-
* @param nameOrIndexOrQualifier - The input to resolve.
|
|
191
|
-
* @returns `Success` with the {@link QualifierName | qualifier name} if successful,
|
|
192
|
-
* or `Failure` with an error message if not found or invalid.
|
|
193
|
-
* @internal
|
|
194
|
-
*/
|
|
195
|
-
private _resolveQualifierName(
|
|
196
|
-
nameOrIndexOrQualifier: QualifierName | QualifierIndex | Qualifier
|
|
197
|
-
): Result<QualifierName> {
|
|
198
|
-
// If it's already a QualifierName (string type with brand)
|
|
199
|
-
if (typeof nameOrIndexOrQualifier === 'string') {
|
|
200
|
-
/* c8 ignore next 1 - functional code path tested but coverage intermittently missed */
|
|
201
|
-
return succeed(nameOrIndexOrQualifier as QualifierName);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
// If it's a Qualifier object
|
|
205
|
-
if (
|
|
206
|
-
typeof nameOrIndexOrQualifier === 'object' &&
|
|
207
|
-
nameOrIndexOrQualifier !== null &&
|
|
208
|
-
'name' in nameOrIndexOrQualifier
|
|
209
|
-
) {
|
|
210
|
-
return succeed(nameOrIndexOrQualifier.name);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
// If it's a QualifierIndex (number type with brand)
|
|
214
|
-
/* c8 ignore next 8 - functional code path tested but coverage intermittently missed */
|
|
215
|
-
if (typeof nameOrIndexOrQualifier === 'number') {
|
|
216
|
-
const qualifier = this.qualifiers.getAt(nameOrIndexOrQualifier as QualifierIndex);
|
|
217
|
-
if (qualifier.isSuccess()) {
|
|
218
|
-
return succeed(qualifier.value.name);
|
|
219
|
-
}
|
|
220
|
-
return fail(`Qualifier not found at index ${nameOrIndexOrQualifier}`);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
return fail(`Invalid qualifier parameter: ${nameOrIndexOrQualifier}`);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2025 Erik Fortune
|
|
3
|
-
*
|
|
4
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
6
|
-
* in the Software without restriction, including without limitation the rights
|
|
7
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
9
|
-
* furnished to do so, subject to the following conditions:
|
|
10
|
-
*
|
|
11
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
12
|
-
* copies or substantial portions of the Software.
|
|
13
|
-
*
|
|
14
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
-
* SOFTWARE.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
import { Result, captureResult } from '@fgv/ts-utils';
|
|
24
|
-
import { QualifierContextValue } from '../../common';
|
|
25
|
-
import { IReadOnlyQualifierCollector } from '../../qualifiers';
|
|
26
|
-
import { SimpleContextQualifierProvider } from './simpleContextQualifierProvider';
|
|
27
|
-
import {
|
|
28
|
-
ContextQualifierProviderValidator,
|
|
29
|
-
IReadOnlyContextQualifierProviderValidator
|
|
30
|
-
} from './contextQualifierProviderValidator';
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Parameters for creating a {@link Runtime.ValidatingSimpleContextQualifierProvider | ValidatingSimpleContextQualifierProvider}.
|
|
34
|
-
* @public
|
|
35
|
-
*/
|
|
36
|
-
export interface IValidatingSimpleContextQualifierProviderCreateParams {
|
|
37
|
-
/**
|
|
38
|
-
* The {@link Qualifiers.IReadOnlyQualifierCollector | readonly qualifier collector} that defines and validates qualifiers.
|
|
39
|
-
*/
|
|
40
|
-
qualifiers: IReadOnlyQualifierCollector;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Optional record of initial qualifier name-value pairs to populate the provider.
|
|
44
|
-
* Accepts string keys and values which will be converted to strongly-typed values.
|
|
45
|
-
*/
|
|
46
|
-
qualifierValues?: Record<string, string>;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* A {@link Runtime.SimpleContextQualifierProvider | SimpleContextQualifierProvider} with a
|
|
51
|
-
* {@link Runtime.Context.ContextQualifierProviderValidator | validator} property that enables
|
|
52
|
-
* validated use of the underlying provider with string keys and values.
|
|
53
|
-
* This eliminates the need for type casting in consumer code.
|
|
54
|
-
* @public
|
|
55
|
-
*/
|
|
56
|
-
export class ValidatingSimpleContextQualifierProvider extends SimpleContextQualifierProvider {
|
|
57
|
-
/**
|
|
58
|
-
* A {@link Runtime.Context.ContextQualifierProviderValidator | ContextQualifierProviderValidator} which validates
|
|
59
|
-
* string inputs before passing them to this provider.
|
|
60
|
-
*/
|
|
61
|
-
public readonly validating: IReadOnlyContextQualifierProviderValidator;
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Constructor for a {@link Runtime.ValidatingSimpleContextQualifierProvider | ValidatingSimpleContextQualifierProvider} object.
|
|
65
|
-
* @param params - {@link Runtime.IValidatingSimpleContextQualifierProviderCreateParams | Parameters} used to create the provider.
|
|
66
|
-
*/
|
|
67
|
-
protected constructor(params: IValidatingSimpleContextQualifierProviderCreateParams) {
|
|
68
|
-
// Convert string values to QualifierContextValue for the base class
|
|
69
|
-
/* c8 ignore next 5 - functional code path tested but coverage intermittently missed */
|
|
70
|
-
const convertedValues: Record<string, QualifierContextValue> | undefined = params.qualifierValues
|
|
71
|
-
? Object.fromEntries(
|
|
72
|
-
Object.entries(params.qualifierValues).map(([key, value]) => [key, value as QualifierContextValue])
|
|
73
|
-
)
|
|
74
|
-
: undefined;
|
|
75
|
-
|
|
76
|
-
super({
|
|
77
|
-
qualifiers: params.qualifiers,
|
|
78
|
-
qualifierValues: convertedValues
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
this.validating = new ContextQualifierProviderValidator({ provider: this });
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Creates a new {@link Runtime.ValidatingSimpleContextQualifierProvider | ValidatingSimpleContextQualifierProvider} object.
|
|
86
|
-
* @param params - {@link Runtime.IValidatingSimpleContextQualifierProviderCreateParams | Parameters} used to create the provider.
|
|
87
|
-
* @returns `Success` with the new {@link Runtime.ValidatingSimpleContextQualifierProvider | ValidatingSimpleContextQualifierProvider} object if successful,
|
|
88
|
-
* or `Failure` with an error message if not.
|
|
89
|
-
* @public
|
|
90
|
-
*/
|
|
91
|
-
public static create(
|
|
92
|
-
params: IValidatingSimpleContextQualifierProviderCreateParams
|
|
93
|
-
): Result<ValidatingSimpleContextQualifierProvider> {
|
|
94
|
-
return captureResult(() => new ValidatingSimpleContextQualifierProvider(params));
|
|
95
|
-
}
|
|
96
|
-
}
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2025 Erik Fortune
|
|
3
|
-
*
|
|
4
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
6
|
-
* in the Software without restriction, including without limitation the rights
|
|
7
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
9
|
-
* furnished to do so, subject to the following conditions:
|
|
10
|
-
*
|
|
11
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
12
|
-
* copies or substantial portions of the Software.
|
|
13
|
-
*
|
|
14
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
-
* SOFTWARE.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
import { Result, Collections } from '@fgv/ts-utils';
|
|
24
|
-
import { JsonObject } from '@fgv/ts-json-base';
|
|
25
|
-
import { ReadOnlyConditionCollector, ReadOnlyConditionSetCollector } from '../conditions';
|
|
26
|
-
import { ReadOnlyAbstractDecisionCollector, ConcreteDecision } from '../decisions';
|
|
27
|
-
import { ResourceId, ResourceValueMergeMethod } from '../common';
|
|
28
|
-
import { IResourceType } from '../resource-types';
|
|
29
|
-
import { IContextDecl, IValidatedContextDecl } from '../context';
|
|
30
|
-
import { IReadOnlyResourceTreeRoot } from './resource-tree';
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Runtime representation of a resource candidate with the minimal data needed for resolution.
|
|
34
|
-
* @public
|
|
35
|
-
*/
|
|
36
|
-
export interface IResourceCandidate {
|
|
37
|
-
/** The JSON value for this candidate */
|
|
38
|
-
readonly json: JsonObject;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Indicates if this candidate is a partial resource.
|
|
42
|
-
*/
|
|
43
|
-
readonly isPartial: boolean;
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Specifies the resource type of this candidate.
|
|
47
|
-
*/
|
|
48
|
-
readonly mergeMethod: ResourceValueMergeMethod;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Interface for a resource that can be used in the runtime layer.
|
|
53
|
-
* This provides the minimal properties needed from a resource without requiring
|
|
54
|
-
* the full Resources layer dependencies.
|
|
55
|
-
* @public
|
|
56
|
-
*/
|
|
57
|
-
export interface IResource {
|
|
58
|
-
/** The resource identifier */
|
|
59
|
-
readonly id: string;
|
|
60
|
-
/** The resource name */
|
|
61
|
-
readonly name: string;
|
|
62
|
-
/** The resource type */
|
|
63
|
-
readonly resourceType: IResourceType;
|
|
64
|
-
/** The decision used to select candidates */
|
|
65
|
-
readonly decision: ConcreteDecision;
|
|
66
|
-
/** The available candidates for this resource */
|
|
67
|
-
readonly candidates: ReadonlyArray<IResourceCandidate>;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Interface defining the read-only properties that the runtime resource resolver needs
|
|
72
|
-
* from a resource manager. This abstraction allows the runtime to work with different
|
|
73
|
-
* implementations without requiring the full ResourceManagerBuilder build mechanics.
|
|
74
|
-
* @public
|
|
75
|
-
*/
|
|
76
|
-
export interface IResourceManager<TR extends IResource = IResource> {
|
|
77
|
-
/**
|
|
78
|
-
* A {@link Conditions.ReadOnlyConditionCollector | ReadOnlyConditionCollector} which
|
|
79
|
-
* contains the {@link Conditions.Condition | conditions} used by resource candidates.
|
|
80
|
-
*/
|
|
81
|
-
readonly conditions: ReadOnlyConditionCollector;
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* A {@link Conditions.ReadOnlyConditionSetCollector | ReadOnlyConditionSetCollector} which
|
|
85
|
-
* contains the {@link Conditions.ConditionSet | condition sets} used by resource candidates.
|
|
86
|
-
*/
|
|
87
|
-
readonly conditionSets: ReadOnlyConditionSetCollector;
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* A {@link Decisions.ReadOnlyAbstractDecisionCollector | ReadOnlyAbstractDecisionCollector} which
|
|
91
|
-
* contains the {@link Decisions.Decision | abstract decisions} used by resource candidates.
|
|
92
|
-
*/
|
|
93
|
-
readonly decisions: ReadOnlyAbstractDecisionCollector;
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Gets a built resource by ID for runtime resolution.
|
|
97
|
-
* @param id - The resource identifier
|
|
98
|
-
* @returns Success with the runtime resource if found, Failure otherwise
|
|
99
|
-
*/
|
|
100
|
-
getBuiltResource(id: string): Result<TR>;
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Gets a resource tree built from the resources in this resource manager.
|
|
104
|
-
* @returns Result containing the resource tree root, or failure if tree construction fails
|
|
105
|
-
*/
|
|
106
|
-
getBuiltResourceTree(): Result<IReadOnlyResourceTreeRoot<TR>>;
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* A read-only result map of all built resources, keyed by resource ID.
|
|
110
|
-
* Resources are built on-demand when accessed and returns Results for error handling.
|
|
111
|
-
*/
|
|
112
|
-
readonly builtResources: Collections.IReadOnlyValidatingResultMap<ResourceId, TR>;
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* The number of resources in this resource manager.
|
|
116
|
-
*/
|
|
117
|
-
readonly numResources: number;
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* The number of candidates in this resource manager.
|
|
121
|
-
*/
|
|
122
|
-
readonly numCandidates: number;
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Validates a context declaration against the qualifiers managed by this resource manager.
|
|
126
|
-
* @param context - The context declaration to validate
|
|
127
|
-
* @returns Success with the validated context if successful, Failure otherwise
|
|
128
|
-
*/
|
|
129
|
-
validateContext(context: IContextDecl): Result<IValidatedContextDecl>;
|
|
130
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2025 Erik Fortune
|
|
3
|
-
*
|
|
4
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
6
|
-
* in the Software without restriction, including without limitation the rights
|
|
7
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
9
|
-
* furnished to do so, subject to the following conditions:
|
|
10
|
-
*
|
|
11
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
12
|
-
* copies or substantial portions of the Software.
|
|
13
|
-
*
|
|
14
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
-
* SOFTWARE.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
export * from './compiledResourceCollection';
|
|
24
|
-
export * from './iResourceManager';
|
|
25
|
-
export * from './context/simpleContextQualifierProvider';
|
|
26
|
-
export * from './context/validatingSimpleContextQualifierProvider';
|
|
27
|
-
export * from './resourceResolver';
|
|
28
|
-
export * from './conditionSetResolutionResult';
|
|
29
|
-
export * from './cacheListener';
|
|
30
|
-
export * from './cacheMetrics';
|
|
31
|
-
|
|
32
|
-
import * as Context from './context';
|
|
33
|
-
import * as ResourceTree from './resource-tree';
|
|
34
|
-
|
|
35
|
-
export { Context, ResourceTree };
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2025 Erik Fortune
|
|
3
|
-
*
|
|
4
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
6
|
-
* in the Software without restriction, including without limitation the rights
|
|
7
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
9
|
-
* furnished to do so, subject to the following conditions:
|
|
10
|
-
*
|
|
11
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
12
|
-
* copies or substantial portions of the Software.
|
|
13
|
-
*
|
|
14
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
-
* SOFTWARE.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
import { IReadOnlyResultMap, Result } from '@fgv/ts-utils';
|
|
24
|
-
import { ResourceId, ResourceName } from '../../common';
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Interface for leaf nodes in a resource tree.
|
|
28
|
-
* Leaf nodes contain resource values and cannot have child nodes.
|
|
29
|
-
* In a valid resource tree, if a path has child resources (e.g., 'app.messages.welcome'),
|
|
30
|
-
* then that path cannot itself be a resource (i.e., 'app' cannot be both a resource and have children).
|
|
31
|
-
* @public
|
|
32
|
-
*/
|
|
33
|
-
export interface IReadOnlyResourceTreeLeaf<T> {
|
|
34
|
-
readonly id: ResourceId;
|
|
35
|
-
readonly name: ResourceName;
|
|
36
|
-
readonly resource: T;
|
|
37
|
-
readonly isLeaf: true;
|
|
38
|
-
readonly isBranch: false;
|
|
39
|
-
readonly isRoot: false;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Interface for branch nodes in a resource tree that contain child nodes.
|
|
44
|
-
* Branch nodes organize the tree structure and cannot have resource values.
|
|
45
|
-
* If a path has child resources, it must be a branch and cannot itself be a resource.
|
|
46
|
-
* @public
|
|
47
|
-
*/
|
|
48
|
-
export interface IReadOnlyResourceTreeBranch<T> {
|
|
49
|
-
readonly id: ResourceId;
|
|
50
|
-
readonly name: ResourceName;
|
|
51
|
-
readonly children: IReadOnlyValidatingResourceTreeChildren<T>;
|
|
52
|
-
readonly isLeaf: false;
|
|
53
|
-
readonly isBranch: true;
|
|
54
|
-
readonly isRoot: false;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Interface for the root node of a resource tree.
|
|
59
|
-
* @public
|
|
60
|
-
*/
|
|
61
|
-
export interface IReadOnlyResourceTreeRoot<T> {
|
|
62
|
-
readonly children: IReadOnlyValidatingResourceTreeChildren<T>;
|
|
63
|
-
readonly isRoot: true;
|
|
64
|
-
readonly isLeaf: false;
|
|
65
|
-
readonly isBranch: false;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Union type representing any node in the resource tree, which can be a leaf or a branch.
|
|
70
|
-
* This allows for flexible handling of different node types in the tree structure.
|
|
71
|
-
* @public
|
|
72
|
-
*/
|
|
73
|
-
export type IReadOnlyResourceTreeNode<T> = IReadOnlyResourceTreeLeaf<T> | IReadOnlyResourceTreeBranch<T>;
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Interface for a read-only result-based resource tree with navigation methods.
|
|
77
|
-
* @public
|
|
78
|
-
*/
|
|
79
|
-
export interface IReadOnlyResourceTreeChildren<
|
|
80
|
-
T,
|
|
81
|
-
TID extends string = ResourceId,
|
|
82
|
-
TNAME extends string = ResourceName
|
|
83
|
-
> extends IReadOnlyResultMap<ResourceName, IReadOnlyResourceTreeNode<T>> {
|
|
84
|
-
/**
|
|
85
|
-
* Gets a tree node by its full ResourceId path.
|
|
86
|
-
* @param id - The ResourceId path to look up
|
|
87
|
-
* @returns Result containing the node if found, or failure if not found
|
|
88
|
-
*/
|
|
89
|
-
getById(id: TID): Result<IReadOnlyResourceTreeNode<T>>;
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Gets a resource node by its direct name (single component).
|
|
93
|
-
* @param name - The ResourceName to look up
|
|
94
|
-
* @returns Result containing the node if it's a resource, or failure if not found or not a resource
|
|
95
|
-
*/
|
|
96
|
-
getResource(name: TNAME): Result<IReadOnlyResourceTreeNode<T>>;
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Gets a branch node by its direct name (single component).
|
|
100
|
-
* @param name - The ResourceName to look up
|
|
101
|
-
* @returns Result containing the node if it's a branch, or failure if not found or not a branch
|
|
102
|
-
*/
|
|
103
|
-
getBranch(name: TNAME): Result<IReadOnlyResourceTreeNode<T>>;
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Gets a resource leaf node by its full ResourceId path.
|
|
107
|
-
* @param id - The ResourceId path to look up
|
|
108
|
-
* @returns Result containing the leaf if found and is a resource, or failure otherwise
|
|
109
|
-
*/
|
|
110
|
-
getResourceById(id: TID): Result<IReadOnlyResourceTreeLeaf<T>>;
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Gets a branch node by its full ResourceId path.
|
|
114
|
-
* @param id - The ResourceId path to look up
|
|
115
|
-
* @returns Result containing the branch if found and has children, or failure otherwise
|
|
116
|
-
*/
|
|
117
|
-
getBranchById(id: TID): Result<IReadOnlyResourceTreeBranch<T>>;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* A read-only interface for accessing resource tree children using weakly-typed string keys.
|
|
122
|
-
* @public
|
|
123
|
-
*/
|
|
124
|
-
export interface IReadOnlyValidatingResourceTreeChildren<T> extends IReadOnlyResourceTreeChildren<T> {
|
|
125
|
-
readonly validating: IReadOnlyResourceTreeChildren<T, string, string>;
|
|
126
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2025 Erik Fortune
|
|
3
|
-
*
|
|
4
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
6
|
-
* in the Software without restriction, including without limitation the rights
|
|
7
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
9
|
-
* furnished to do so, subject to the following conditions:
|
|
10
|
-
*
|
|
11
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
12
|
-
* copies or substantial portions of the Software.
|
|
13
|
-
*
|
|
14
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
-
* SOFTWARE.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
export * from './common';
|
|
24
|
-
export * from './resourceTreeChildren';
|
|
25
|
-
export * from './resourceTreeChildrenValidator';
|
|
26
|
-
export * from './readOnlyResourceTree';
|