@fgv/ts-res 5.0.0-18 → 5.0.0-19
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/ts-res.d.ts +72 -7
- package/lib/packlets/config/convert.d.ts +9 -0
- package/lib/packlets/config/convert.js +11 -0
- package/lib/packlets/resources/common.d.ts +14 -0
- package/lib/packlets/resources/resourceManagerBuilder.d.ts +51 -7
- package/lib/packlets/resources/resourceManagerBuilder.js +20 -8
- package/lib/test/unit/resources/resourceManagerBuilder.clone.test.d.ts +2 -0
- package/package.json +7 -7
- package/src/packlets/config/convert.ts +12 -1
- package/src/packlets/resources/common.ts +16 -0
- package/src/packlets/resources/resourceManagerBuilder.ts +62 -9
package/dist/ts-res.d.ts
CHANGED
|
@@ -2197,6 +2197,7 @@ declare namespace Convert_8 {
|
|
|
2197
2197
|
|
|
2198
2198
|
declare namespace Convert_9 {
|
|
2199
2199
|
export {
|
|
2200
|
+
validateSystemConfiguration,
|
|
2200
2201
|
systemConfiguration,
|
|
2201
2202
|
predefinedSystemConfiguration
|
|
2202
2203
|
}
|
|
@@ -4945,6 +4946,18 @@ declare interface IResourceManagerCloneOptions extends IResourceDeclarationOptio
|
|
|
4945
4946
|
* These conditions can modify or extend the resource candidates in the cloned manager.
|
|
4946
4947
|
*/
|
|
4947
4948
|
readonly candidates?: ReadonlyArray<ResourceJson.Json.ILooseResourceCandidateDecl>;
|
|
4949
|
+
/**
|
|
4950
|
+
* Optional qualifier collector to use for the cloned manager.
|
|
4951
|
+
* If not provided, uses the same qualifiers as the original manager.
|
|
4952
|
+
* This allows creating clones with different qualifier configurations.
|
|
4953
|
+
*/
|
|
4954
|
+
readonly qualifiers?: IReadOnlyQualifierCollector;
|
|
4955
|
+
/**
|
|
4956
|
+
* Optional resource type collector to use for the cloned manager.
|
|
4957
|
+
* If not provided, uses the same resource types as the original manager.
|
|
4958
|
+
* This allows creating clones with different resource type configurations.
|
|
4959
|
+
*/
|
|
4960
|
+
readonly resourceTypes?: ReadOnlyResourceTypeCollector;
|
|
4948
4961
|
}
|
|
4949
4962
|
|
|
4950
4963
|
/**
|
|
@@ -7758,15 +7771,53 @@ export { ResourceJson }
|
|
|
7758
7771
|
* @public
|
|
7759
7772
|
*/
|
|
7760
7773
|
export declare class ResourceManagerBuilder implements IResourceManager<Resource> {
|
|
7774
|
+
/**
|
|
7775
|
+
* The {@link Qualifiers.IReadOnlyQualifierCollector | qualifiers} used by this resource manager.
|
|
7776
|
+
*/
|
|
7761
7777
|
readonly qualifiers: IReadOnlyQualifierCollector;
|
|
7778
|
+
/**
|
|
7779
|
+
* The {@link ResourceTypes.ReadOnlyResourceTypeCollector | resource types} used by this resource manager.
|
|
7780
|
+
*/
|
|
7762
7781
|
readonly resourceTypes: ReadOnlyResourceTypeCollector;
|
|
7782
|
+
/**
|
|
7783
|
+
* The {@link Conditions.ConditionCollector | condition collector} used by this resource manager.
|
|
7784
|
+
* @internal
|
|
7785
|
+
*/
|
|
7763
7786
|
protected readonly _conditions: ConditionCollector;
|
|
7787
|
+
/**
|
|
7788
|
+
* The {@link Conditions.ConditionSetCollector | condition set collector} used by this resource manager.
|
|
7789
|
+
* @internal
|
|
7790
|
+
*/
|
|
7764
7791
|
protected readonly _conditionSets: ConditionSetCollector;
|
|
7792
|
+
/**
|
|
7793
|
+
* The {@link Decisions.AbstractDecisionCollector | abstract decision collector} used by this resource manager.
|
|
7794
|
+
* @internal
|
|
7795
|
+
*/
|
|
7765
7796
|
protected readonly _decisions: AbstractDecisionCollector;
|
|
7797
|
+
/**
|
|
7798
|
+
* The {@link Resources.ResourceBuilder | resource builders} used by this resource manager.
|
|
7799
|
+
* @internal
|
|
7800
|
+
*/
|
|
7766
7801
|
protected readonly _resources: ValidatingResultMap<ResourceId, ResourceBuilder>;
|
|
7767
|
-
|
|
7802
|
+
/**
|
|
7803
|
+
* The {@link Resources.Resource | resources} built by this resource manager.
|
|
7804
|
+
* @internal
|
|
7805
|
+
*/
|
|
7806
|
+
protected readonly _builtResources: ValidatingResultMap<ResourceId, Resource>;
|
|
7807
|
+
/**
|
|
7808
|
+
* Whether the resources have been built.
|
|
7809
|
+
* @internal
|
|
7810
|
+
*/
|
|
7768
7811
|
protected _built: boolean;
|
|
7812
|
+
/**
|
|
7813
|
+
* The cached resource tree for this resource manager.
|
|
7814
|
+
* @internal
|
|
7815
|
+
*/
|
|
7769
7816
|
protected _cachedResourceTree?: ResourceTree.IReadOnlyResourceTreeRoot<Resource>;
|
|
7817
|
+
/**
|
|
7818
|
+
* The {@link QualifierTypes.ReadOnlyQualifierTypeCollector | qualifier types} used by this resource manager.
|
|
7819
|
+
*/
|
|
7820
|
+
get qualifierTypes(): ReadOnlyQualifierTypeCollector;
|
|
7770
7821
|
/**
|
|
7771
7822
|
* A {@link Conditions.ConditionCollector | ConditionCollector} which
|
|
7772
7823
|
* contains the {@link Conditions.Condition | conditions} used so far by
|
|
@@ -7982,12 +8033,17 @@ export declare class ResourceManagerBuilder implements IResourceManager<Resource
|
|
|
7982
8033
|
*/
|
|
7983
8034
|
getResourceCollectionDecl(options?: IResourceDeclarationOptions): Result<ResourceJson.Normalized.IResourceCollectionDecl>;
|
|
7984
8035
|
/**
|
|
7985
|
-
* Creates a
|
|
7986
|
-
* This
|
|
7987
|
-
*
|
|
7988
|
-
*
|
|
7989
|
-
*
|
|
7990
|
-
* @
|
|
8036
|
+
* Creates a clone of this ResourceManagerBuilder with optional configuration overrides.
|
|
8037
|
+
* This method creates a new ResourceManagerBuilder that can optionally use different
|
|
8038
|
+
* qualifiers and/or resource types than the original. It can also be filtered to include
|
|
8039
|
+
* only candidates that match the provided context and apply candidate edits.
|
|
8040
|
+
*
|
|
8041
|
+
* @param options - Options for the cloning operation:
|
|
8042
|
+
* - `qualifiers`: Optional qualifier collector to use instead of the original
|
|
8043
|
+
* - `resourceTypes`: Optional resource type collector to use instead of the original
|
|
8044
|
+
* - `filterForContext`: Optional context filter for candidates
|
|
8045
|
+
* - `candidates`: Optional candidate edits to apply during cloning
|
|
8046
|
+
* @returns A Result containing the new ResourceManagerBuilder with the specified configuration.
|
|
7991
8047
|
* @public
|
|
7992
8048
|
*/
|
|
7993
8049
|
clone(options?: IResourceManagerCloneOptions): Result<ResourceManagerBuilder>;
|
|
@@ -9320,6 +9376,15 @@ declare const validatedContextQualifierValueDecl: Converter<IValidatedContextQua
|
|
|
9320
9376
|
*/
|
|
9321
9377
|
declare const validatedQualifierDecl: Converter<IValidatedQualifierDecl, IQualifierDeclConvertContext>;
|
|
9322
9378
|
|
|
9379
|
+
/**
|
|
9380
|
+
* Validate a {@link Config.Model.ISystemConfiguration | ISystemConfiguration} object.
|
|
9381
|
+
* @param config - The system configuration to validate
|
|
9382
|
+
* @returns `Success` with the validated system configuration if successful,
|
|
9383
|
+
* or `Failure` with an error message if validation fails.
|
|
9384
|
+
* @public
|
|
9385
|
+
*/
|
|
9386
|
+
declare function validateSystemConfiguration(config: unknown): Result<ISystemConfiguration>;
|
|
9387
|
+
|
|
9323
9388
|
/**
|
|
9324
9389
|
* Validate a ZIP archive manifest object
|
|
9325
9390
|
* @param manifest - Object to validate as manifest
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Result } from '@fgv/ts-utils';
|
|
1
2
|
import { ISystemConfiguration } from './json';
|
|
2
3
|
/**
|
|
3
4
|
* A `Converter` for {@link Config.Model.ISystemConfiguration | ISystemConfiguration} objects.
|
|
@@ -11,4 +12,12 @@ export declare const systemConfiguration: import("@fgv/ts-utils").ObjectConverte
|
|
|
11
12
|
* @public
|
|
12
13
|
*/
|
|
13
14
|
export declare const predefinedSystemConfiguration: import("@fgv/ts-utils").Converter<import("./common").PredefinedSystemConfiguration, readonly import("./common").PredefinedSystemConfiguration[]>;
|
|
15
|
+
/**
|
|
16
|
+
* Validate a {@link Config.Model.ISystemConfiguration | ISystemConfiguration} object.
|
|
17
|
+
* @param config - The system configuration to validate
|
|
18
|
+
* @returns `Success` with the validated system configuration if successful,
|
|
19
|
+
* or `Failure` with an error message if validation fails.
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
export declare function validateSystemConfiguration(config: unknown): Result<ISystemConfiguration>;
|
|
14
23
|
//# sourceMappingURL=convert.d.ts.map
|
|
@@ -55,6 +55,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
55
55
|
})();
|
|
56
56
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
57
|
exports.predefinedSystemConfiguration = exports.systemConfiguration = void 0;
|
|
58
|
+
exports.validateSystemConfiguration = validateSystemConfiguration;
|
|
58
59
|
/* eslint-disable @rushstack/typedef-var */
|
|
59
60
|
const ts_utils_1 = require("@fgv/ts-utils");
|
|
60
61
|
const QualifierTypes = __importStar(require("../qualifier-types"));
|
|
@@ -79,4 +80,14 @@ exports.systemConfiguration = ts_utils_1.Converters.strictObject({
|
|
|
79
80
|
* @public
|
|
80
81
|
*/
|
|
81
82
|
exports.predefinedSystemConfiguration = ts_utils_1.Converters.enumeratedValue(common_1.allPredefinedSystemConfigurations);
|
|
83
|
+
/**
|
|
84
|
+
* Validate a {@link Config.Model.ISystemConfiguration | ISystemConfiguration} object.
|
|
85
|
+
* @param config - The system configuration to validate
|
|
86
|
+
* @returns `Success` with the validated system configuration if successful,
|
|
87
|
+
* or `Failure` with an error message if validation fails.
|
|
88
|
+
* @public
|
|
89
|
+
*/
|
|
90
|
+
function validateSystemConfiguration(config) {
|
|
91
|
+
return exports.systemConfiguration.convert(config);
|
|
92
|
+
}
|
|
82
93
|
//# sourceMappingURL=convert.js.map
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as ResourceJson from '../resource-json';
|
|
2
2
|
import { IValidatedContextDecl } from '../context';
|
|
3
|
+
import { IReadOnlyQualifierCollector } from '../qualifiers';
|
|
4
|
+
import { ReadOnlyResourceTypeCollector } from '../resource-types';
|
|
3
5
|
/**
|
|
4
6
|
* Options for resource declaration operations with strongly-typed context filtering.
|
|
5
7
|
* Extends the base IDeclarationOptions with proper type safety for context filtering.
|
|
@@ -68,5 +70,17 @@ export interface IResourceManagerCloneOptions extends IResourceDeclarationOption
|
|
|
68
70
|
* These conditions can modify or extend the resource candidates in the cloned manager.
|
|
69
71
|
*/
|
|
70
72
|
readonly candidates?: ReadonlyArray<ResourceJson.Json.ILooseResourceCandidateDecl>;
|
|
73
|
+
/**
|
|
74
|
+
* Optional qualifier collector to use for the cloned manager.
|
|
75
|
+
* If not provided, uses the same qualifiers as the original manager.
|
|
76
|
+
* This allows creating clones with different qualifier configurations.
|
|
77
|
+
*/
|
|
78
|
+
readonly qualifiers?: IReadOnlyQualifierCollector;
|
|
79
|
+
/**
|
|
80
|
+
* Optional resource type collector to use for the cloned manager.
|
|
81
|
+
* If not provided, uses the same resource types as the original manager.
|
|
82
|
+
* This allows creating clones with different resource type configurations.
|
|
83
|
+
*/
|
|
84
|
+
readonly resourceTypes?: ReadOnlyResourceTypeCollector;
|
|
71
85
|
}
|
|
72
86
|
//# sourceMappingURL=common.d.ts.map
|
|
@@ -12,6 +12,7 @@ import { IResourceDeclarationOptions, IResourceManagerCloneOptions } from './com
|
|
|
12
12
|
import * as ResourceJson from '../resource-json';
|
|
13
13
|
import * as Context from '../context';
|
|
14
14
|
import * as Config from '../config';
|
|
15
|
+
import { ReadOnlyQualifierTypeCollector } from '../qualifier-types';
|
|
15
16
|
/**
|
|
16
17
|
* Interface for parameters to the {@link Resources.ResourceManagerBuilder.create | ResourceManagerBuilder create method}.
|
|
17
18
|
* @public
|
|
@@ -33,15 +34,53 @@ export type ResourceManagerBuilderResultDetail = Collections.ResultMapResultDeta
|
|
|
33
34
|
* @public
|
|
34
35
|
*/
|
|
35
36
|
export declare class ResourceManagerBuilder implements IResourceManager<Resource> {
|
|
37
|
+
/**
|
|
38
|
+
* The {@link Qualifiers.IReadOnlyQualifierCollector | qualifiers} used by this resource manager.
|
|
39
|
+
*/
|
|
36
40
|
readonly qualifiers: IReadOnlyQualifierCollector;
|
|
41
|
+
/**
|
|
42
|
+
* The {@link ResourceTypes.ReadOnlyResourceTypeCollector | resource types} used by this resource manager.
|
|
43
|
+
*/
|
|
37
44
|
readonly resourceTypes: ReadOnlyResourceTypeCollector;
|
|
45
|
+
/**
|
|
46
|
+
* The {@link Conditions.ConditionCollector | condition collector} used by this resource manager.
|
|
47
|
+
* @internal
|
|
48
|
+
*/
|
|
38
49
|
protected readonly _conditions: ConditionCollector;
|
|
50
|
+
/**
|
|
51
|
+
* The {@link Conditions.ConditionSetCollector | condition set collector} used by this resource manager.
|
|
52
|
+
* @internal
|
|
53
|
+
*/
|
|
39
54
|
protected readonly _conditionSets: ConditionSetCollector;
|
|
55
|
+
/**
|
|
56
|
+
* The {@link Decisions.AbstractDecisionCollector | abstract decision collector} used by this resource manager.
|
|
57
|
+
* @internal
|
|
58
|
+
*/
|
|
40
59
|
protected readonly _decisions: AbstractDecisionCollector;
|
|
60
|
+
/**
|
|
61
|
+
* The {@link Resources.ResourceBuilder | resource builders} used by this resource manager.
|
|
62
|
+
* @internal
|
|
63
|
+
*/
|
|
41
64
|
protected readonly _resources: ValidatingResultMap<ResourceId, ResourceBuilder>;
|
|
42
|
-
|
|
65
|
+
/**
|
|
66
|
+
* The {@link Resources.Resource | resources} built by this resource manager.
|
|
67
|
+
* @internal
|
|
68
|
+
*/
|
|
69
|
+
protected readonly _builtResources: ValidatingResultMap<ResourceId, Resource>;
|
|
70
|
+
/**
|
|
71
|
+
* Whether the resources have been built.
|
|
72
|
+
* @internal
|
|
73
|
+
*/
|
|
43
74
|
protected _built: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* The cached resource tree for this resource manager.
|
|
77
|
+
* @internal
|
|
78
|
+
*/
|
|
44
79
|
protected _cachedResourceTree?: ResourceTree.IReadOnlyResourceTreeRoot<Resource>;
|
|
80
|
+
/**
|
|
81
|
+
* The {@link QualifierTypes.ReadOnlyQualifierTypeCollector | qualifier types} used by this resource manager.
|
|
82
|
+
*/
|
|
83
|
+
get qualifierTypes(): ReadOnlyQualifierTypeCollector;
|
|
45
84
|
/**
|
|
46
85
|
* A {@link Conditions.ConditionCollector | ConditionCollector} which
|
|
47
86
|
* contains the {@link Conditions.Condition | conditions} used so far by
|
|
@@ -257,12 +296,17 @@ export declare class ResourceManagerBuilder implements IResourceManager<Resource
|
|
|
257
296
|
*/
|
|
258
297
|
getResourceCollectionDecl(options?: IResourceDeclarationOptions): Result<ResourceJson.Normalized.IResourceCollectionDecl>;
|
|
259
298
|
/**
|
|
260
|
-
* Creates a
|
|
261
|
-
* This
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
* @
|
|
299
|
+
* Creates a clone of this ResourceManagerBuilder with optional configuration overrides.
|
|
300
|
+
* This method creates a new ResourceManagerBuilder that can optionally use different
|
|
301
|
+
* qualifiers and/or resource types than the original. It can also be filtered to include
|
|
302
|
+
* only candidates that match the provided context and apply candidate edits.
|
|
303
|
+
*
|
|
304
|
+
* @param options - Options for the cloning operation:
|
|
305
|
+
* - `qualifiers`: Optional qualifier collector to use instead of the original
|
|
306
|
+
* - `resourceTypes`: Optional resource type collector to use instead of the original
|
|
307
|
+
* - `filterForContext`: Optional context filter for candidates
|
|
308
|
+
* - `candidates`: Optional candidate edits to apply during cloning
|
|
309
|
+
* @returns A Result containing the new ResourceManagerBuilder with the specified configuration.
|
|
266
310
|
* @public
|
|
267
311
|
*/
|
|
268
312
|
clone(options?: IResourceManagerCloneOptions): Result<ResourceManagerBuilder>;
|
|
@@ -75,6 +75,12 @@ const ts_json_1 = require("@fgv/ts-json");
|
|
|
75
75
|
* @public
|
|
76
76
|
*/
|
|
77
77
|
class ResourceManagerBuilder {
|
|
78
|
+
/**
|
|
79
|
+
* The {@link QualifierTypes.ReadOnlyQualifierTypeCollector | qualifier types} used by this resource manager.
|
|
80
|
+
*/
|
|
81
|
+
get qualifierTypes() {
|
|
82
|
+
return this.qualifiers.qualifierTypes;
|
|
83
|
+
}
|
|
78
84
|
/**
|
|
79
85
|
* A {@link Conditions.ConditionCollector | ConditionCollector} which
|
|
80
86
|
* contains the {@link Conditions.Condition | conditions} used so far by
|
|
@@ -528,20 +534,26 @@ class ResourceManagerBuilder {
|
|
|
528
534
|
});
|
|
529
535
|
}
|
|
530
536
|
/**
|
|
531
|
-
* Creates a
|
|
532
|
-
* This
|
|
533
|
-
*
|
|
534
|
-
*
|
|
535
|
-
*
|
|
536
|
-
* @
|
|
537
|
+
* Creates a clone of this ResourceManagerBuilder with optional configuration overrides.
|
|
538
|
+
* This method creates a new ResourceManagerBuilder that can optionally use different
|
|
539
|
+
* qualifiers and/or resource types than the original. It can also be filtered to include
|
|
540
|
+
* only candidates that match the provided context and apply candidate edits.
|
|
541
|
+
*
|
|
542
|
+
* @param options - Options for the cloning operation:
|
|
543
|
+
* - `qualifiers`: Optional qualifier collector to use instead of the original
|
|
544
|
+
* - `resourceTypes`: Optional resource type collector to use instead of the original
|
|
545
|
+
* - `filterForContext`: Optional context filter for candidates
|
|
546
|
+
* - `candidates`: Optional candidate edits to apply during cloning
|
|
547
|
+
* @returns A Result containing the new ResourceManagerBuilder with the specified configuration.
|
|
537
548
|
* @public
|
|
538
549
|
*/
|
|
539
550
|
/* c8 ignore next 21 - functional code path tested but coverage intermittently missed */
|
|
540
551
|
clone(options) {
|
|
541
552
|
return this.getResourceCollectionDecl(options).onSuccess((collection) => {
|
|
553
|
+
var _a, _b;
|
|
542
554
|
return ResourceManagerBuilder.create({
|
|
543
|
-
qualifiers: this.qualifiers,
|
|
544
|
-
resourceTypes: this.resourceTypes
|
|
555
|
+
qualifiers: (_a = options === null || options === void 0 ? void 0 : options.qualifiers) !== null && _a !== void 0 ? _a : this.qualifiers,
|
|
556
|
+
resourceTypes: (_b = options === null || options === void 0 ? void 0 : options.resourceTypes) !== null && _b !== void 0 ? _b : this.resourceTypes
|
|
545
557
|
}).onSuccess((newManager) => {
|
|
546
558
|
// Check if we have candidates to apply as edits
|
|
547
559
|
const editCandidates = (options === null || options === void 0 ? void 0 : options.candidates) || [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fgv/ts-res",
|
|
3
|
-
"version": "5.0.0-
|
|
3
|
+
"version": "5.0.0-19",
|
|
4
4
|
"description": "Multi-dimensional Resource Runtime",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "dist/ts-res.d.ts",
|
|
@@ -44,16 +44,16 @@
|
|
|
44
44
|
"@rushstack/heft-node-rig": "~2.9.3",
|
|
45
45
|
"@types/heft-jest": "1.0.6",
|
|
46
46
|
"eslint-plugin-tsdoc": "~0.4.0",
|
|
47
|
-
"@fgv/ts-utils-jest": "5.0.0-
|
|
48
|
-
"@fgv/ts-extras": "5.0.0-
|
|
47
|
+
"@fgv/ts-utils-jest": "5.0.0-19",
|
|
48
|
+
"@fgv/ts-extras": "5.0.0-19"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"luxon": "^3.7.1",
|
|
52
52
|
"fflate": "~0.8.2",
|
|
53
|
-
"@fgv/ts-utils": "5.0.0-
|
|
54
|
-
"@fgv/ts-json
|
|
55
|
-
"@fgv/ts-json": "5.0.0-
|
|
56
|
-
"@fgv/ts-bcp47": "5.0.0-
|
|
53
|
+
"@fgv/ts-utils": "5.0.0-19",
|
|
54
|
+
"@fgv/ts-json": "5.0.0-19",
|
|
55
|
+
"@fgv/ts-json-base": "5.0.0-19",
|
|
56
|
+
"@fgv/ts-bcp47": "5.0.0-19"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"build": "heft build --clean",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
|
|
23
23
|
/* eslint-disable @rushstack/typedef-var */
|
|
24
24
|
|
|
25
|
-
import { Converters } from '@fgv/ts-utils';
|
|
25
|
+
import { Converters, Result } from '@fgv/ts-utils';
|
|
26
26
|
import { ISystemConfiguration } from './json';
|
|
27
27
|
import * as QualifierTypes from '../qualifier-types';
|
|
28
28
|
import * as Qualifiers from '../qualifiers';
|
|
@@ -48,3 +48,14 @@ export const systemConfiguration = Converters.strictObject<ISystemConfiguration>
|
|
|
48
48
|
* @public
|
|
49
49
|
*/
|
|
50
50
|
export const predefinedSystemConfiguration = Converters.enumeratedValue(allPredefinedSystemConfigurations);
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Validate a {@link Config.Model.ISystemConfiguration | ISystemConfiguration} object.
|
|
54
|
+
* @param config - The system configuration to validate
|
|
55
|
+
* @returns `Success` with the validated system configuration if successful,
|
|
56
|
+
* or `Failure` with an error message if validation fails.
|
|
57
|
+
* @public
|
|
58
|
+
*/
|
|
59
|
+
export function validateSystemConfiguration(config: unknown): Result<ISystemConfiguration> {
|
|
60
|
+
return systemConfiguration.convert(config);
|
|
61
|
+
}
|
|
@@ -22,6 +22,8 @@
|
|
|
22
22
|
|
|
23
23
|
import * as ResourceJson from '../resource-json';
|
|
24
24
|
import { IValidatedContextDecl } from '../context';
|
|
25
|
+
import { IReadOnlyQualifierCollector } from '../qualifiers';
|
|
26
|
+
import { ReadOnlyResourceTypeCollector } from '../resource-types';
|
|
25
27
|
|
|
26
28
|
/**
|
|
27
29
|
* Options for resource declaration operations with strongly-typed context filtering.
|
|
@@ -95,4 +97,18 @@ export interface IResourceManagerCloneOptions extends IResourceDeclarationOption
|
|
|
95
97
|
* These conditions can modify or extend the resource candidates in the cloned manager.
|
|
96
98
|
*/
|
|
97
99
|
readonly candidates?: ReadonlyArray<ResourceJson.Json.ILooseResourceCandidateDecl>;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Optional qualifier collector to use for the cloned manager.
|
|
103
|
+
* If not provided, uses the same qualifiers as the original manager.
|
|
104
|
+
* This allows creating clones with different qualifier configurations.
|
|
105
|
+
*/
|
|
106
|
+
readonly qualifiers?: IReadOnlyQualifierCollector;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Optional resource type collector to use for the cloned manager.
|
|
110
|
+
* If not provided, uses the same resource types as the original manager.
|
|
111
|
+
* This allows creating clones with different resource type configurations.
|
|
112
|
+
*/
|
|
113
|
+
readonly resourceTypes?: ReadOnlyResourceTypeCollector;
|
|
98
114
|
}
|
|
@@ -58,6 +58,7 @@ import * as ResourceJson from '../resource-json';
|
|
|
58
58
|
import * as Context from '../context';
|
|
59
59
|
import * as Config from '../config';
|
|
60
60
|
import { JsonEditor } from '@fgv/ts-json';
|
|
61
|
+
import { ReadOnlyQualifierTypeCollector } from '../qualifier-types';
|
|
61
62
|
|
|
62
63
|
/**
|
|
63
64
|
* Interface for parameters to the {@link Resources.ResourceManagerBuilder.create | ResourceManagerBuilder create method}.
|
|
@@ -84,18 +85,65 @@ export type ResourceManagerBuilderResultDetail =
|
|
|
84
85
|
* @public
|
|
85
86
|
*/
|
|
86
87
|
export class ResourceManagerBuilder implements IResourceManager<Resource> {
|
|
88
|
+
/**
|
|
89
|
+
* The {@link Qualifiers.IReadOnlyQualifierCollector | qualifiers} used by this resource manager.
|
|
90
|
+
*/
|
|
87
91
|
public readonly qualifiers: IReadOnlyQualifierCollector;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* The {@link ResourceTypes.ReadOnlyResourceTypeCollector | resource types} used by this resource manager.
|
|
95
|
+
*/
|
|
88
96
|
public readonly resourceTypes: ReadOnlyResourceTypeCollector;
|
|
89
97
|
|
|
98
|
+
/**
|
|
99
|
+
* The {@link Conditions.ConditionCollector | condition collector} used by this resource manager.
|
|
100
|
+
* @internal
|
|
101
|
+
*/
|
|
90
102
|
protected readonly _conditions: ConditionCollector;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* The {@link Conditions.ConditionSetCollector | condition set collector} used by this resource manager.
|
|
106
|
+
* @internal
|
|
107
|
+
*/
|
|
91
108
|
protected readonly _conditionSets: ConditionSetCollector;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* The {@link Decisions.AbstractDecisionCollector | abstract decision collector} used by this resource manager.
|
|
112
|
+
* @internal
|
|
113
|
+
*/
|
|
92
114
|
protected readonly _decisions: AbstractDecisionCollector;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* The {@link Resources.ResourceBuilder | resource builders} used by this resource manager.
|
|
118
|
+
* @internal
|
|
119
|
+
*/
|
|
93
120
|
protected readonly _resources: ValidatingResultMap<ResourceId, ResourceBuilder>;
|
|
94
|
-
public readonly _builtResources: ValidatingResultMap<ResourceId, Resource>;
|
|
95
121
|
|
|
122
|
+
/**
|
|
123
|
+
* The {@link Resources.Resource | resources} built by this resource manager.
|
|
124
|
+
* @internal
|
|
125
|
+
*/
|
|
126
|
+
protected readonly _builtResources: ValidatingResultMap<ResourceId, Resource>;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Whether the resources have been built.
|
|
130
|
+
* @internal
|
|
131
|
+
*/
|
|
96
132
|
protected _built: boolean;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* The cached resource tree for this resource manager.
|
|
136
|
+
* @internal
|
|
137
|
+
*/
|
|
97
138
|
protected _cachedResourceTree?: ResourceTree.IReadOnlyResourceTreeRoot<Resource>;
|
|
98
139
|
|
|
140
|
+
/**
|
|
141
|
+
* The {@link QualifierTypes.ReadOnlyQualifierTypeCollector | qualifier types} used by this resource manager.
|
|
142
|
+
*/
|
|
143
|
+
public get qualifierTypes(): ReadOnlyQualifierTypeCollector {
|
|
144
|
+
return this.qualifiers.qualifierTypes;
|
|
145
|
+
}
|
|
146
|
+
|
|
99
147
|
/**
|
|
100
148
|
* A {@link Conditions.ConditionCollector | ConditionCollector} which
|
|
101
149
|
* contains the {@link Conditions.Condition | conditions} used so far by
|
|
@@ -646,20 +694,25 @@ export class ResourceManagerBuilder implements IResourceManager<Resource> {
|
|
|
646
694
|
}
|
|
647
695
|
|
|
648
696
|
/**
|
|
649
|
-
* Creates a
|
|
650
|
-
* This
|
|
651
|
-
*
|
|
652
|
-
*
|
|
653
|
-
*
|
|
654
|
-
* @
|
|
697
|
+
* Creates a clone of this ResourceManagerBuilder with optional configuration overrides.
|
|
698
|
+
* This method creates a new ResourceManagerBuilder that can optionally use different
|
|
699
|
+
* qualifiers and/or resource types than the original. It can also be filtered to include
|
|
700
|
+
* only candidates that match the provided context and apply candidate edits.
|
|
701
|
+
*
|
|
702
|
+
* @param options - Options for the cloning operation:
|
|
703
|
+
* - `qualifiers`: Optional qualifier collector to use instead of the original
|
|
704
|
+
* - `resourceTypes`: Optional resource type collector to use instead of the original
|
|
705
|
+
* - `filterForContext`: Optional context filter for candidates
|
|
706
|
+
* - `candidates`: Optional candidate edits to apply during cloning
|
|
707
|
+
* @returns A Result containing the new ResourceManagerBuilder with the specified configuration.
|
|
655
708
|
* @public
|
|
656
709
|
*/
|
|
657
710
|
/* c8 ignore next 21 - functional code path tested but coverage intermittently missed */
|
|
658
711
|
public clone(options?: IResourceManagerCloneOptions): Result<ResourceManagerBuilder> {
|
|
659
712
|
return this.getResourceCollectionDecl(options).onSuccess((collection) => {
|
|
660
713
|
return ResourceManagerBuilder.create({
|
|
661
|
-
qualifiers: this.qualifiers,
|
|
662
|
-
resourceTypes: this.resourceTypes
|
|
714
|
+
qualifiers: options?.qualifiers ?? this.qualifiers,
|
|
715
|
+
resourceTypes: options?.resourceTypes ?? this.resourceTypes
|
|
663
716
|
}).onSuccess((newManager) => {
|
|
664
717
|
// Check if we have candidates to apply as edits
|
|
665
718
|
const editCandidates = options?.candidates || [];
|