@fgv/ts-res 5.0.0-10 → 5.0.0-11
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 +16 -1
- package/lib/packlets/common/helpers/resources.d.ts +7 -0
- package/lib/packlets/common/helpers/resources.d.ts.map +1 -1
- package/lib/packlets/common/helpers/resources.js +12 -0
- package/lib/packlets/common/helpers/resources.js.map +1 -1
- package/lib/packlets/resources/resource.d.ts +5 -1
- package/lib/packlets/resources/resource.d.ts.map +1 -1
- package/lib/packlets/resources/resource.js +1 -0
- package/lib/packlets/resources/resource.js.map +1 -1
- package/lib/packlets/runtime/compiledResourceCollection.d.ts.map +1 -1
- package/lib/packlets/runtime/compiledResourceCollection.js +7 -0
- package/lib/packlets/runtime/compiledResourceCollection.js.map +1 -1
- package/lib/packlets/runtime/iResourceManager.d.ts +2 -0
- package/lib/packlets/runtime/iResourceManager.d.ts.map +1 -1
- package/lib/packlets/runtime/iResourceManager.js.map +1 -1
- package/lib/packlets/runtime/validate.d.ts.map +1 -1
- package/lib/packlets/runtime/validate.js +1 -0
- package/lib/packlets/runtime/validate.js.map +1 -1
- package/package.json +12 -12
package/dist/ts-res.d.ts
CHANGED
|
@@ -2488,6 +2488,14 @@ declare class FsItemImporter implements IImporter {
|
|
|
2488
2488
|
*/
|
|
2489
2489
|
declare type FsItemResultDetail = 'failed' | 'skipped' | 'succeeded';
|
|
2490
2490
|
|
|
2491
|
+
/**
|
|
2492
|
+
* Gets the name for a resource ID.
|
|
2493
|
+
* @param id - The resource ID to get the name for.
|
|
2494
|
+
* @returns The resource name if found, or undefined if not.
|
|
2495
|
+
* @public
|
|
2496
|
+
*/
|
|
2497
|
+
declare function getNameForResourceId(id: string | undefined): Result<ResourceName>;
|
|
2498
|
+
|
|
2491
2499
|
/**
|
|
2492
2500
|
* Returns the {@link Config.Model.ISystemConfiguration | system configuration} declaration for the
|
|
2493
2501
|
* specified predefined system configuration.
|
|
@@ -2529,7 +2537,8 @@ declare namespace Helpers {
|
|
|
2529
2537
|
IQualifierDefaultValueTokenParts,
|
|
2530
2538
|
splitResourceId,
|
|
2531
2539
|
joinResourceIds,
|
|
2532
|
-
joinOptionalResourceIds
|
|
2540
|
+
joinOptionalResourceIds,
|
|
2541
|
+
getNameForResourceId
|
|
2533
2542
|
}
|
|
2534
2543
|
}
|
|
2535
2544
|
export { Helpers }
|
|
@@ -4503,6 +4512,8 @@ declare interface IReducedCandidate {
|
|
|
4503
4512
|
declare interface IResource {
|
|
4504
4513
|
/** The resource identifier */
|
|
4505
4514
|
readonly id: string;
|
|
4515
|
+
/** The resource name */
|
|
4516
|
+
readonly name: string;
|
|
4506
4517
|
/** The resource type */
|
|
4507
4518
|
readonly resourceType: ResourceType;
|
|
4508
4519
|
/** The decision used to select candidates */
|
|
@@ -6890,6 +6901,10 @@ export declare class Resource implements IResource {
|
|
|
6890
6901
|
* The unique {@link ResourceId | id} of the resource.
|
|
6891
6902
|
*/
|
|
6892
6903
|
readonly id: ResourceId;
|
|
6904
|
+
/**
|
|
6905
|
+
* The name of the resource.
|
|
6906
|
+
*/
|
|
6907
|
+
readonly name: ResourceName;
|
|
6893
6908
|
/**
|
|
6894
6909
|
* The {@link ResourceTypes.ResourceType | type} of the resource.
|
|
6895
6910
|
*/
|
|
@@ -31,4 +31,11 @@ export declare function joinResourceIds(...ids: (string | undefined)[]): Result<
|
|
|
31
31
|
* @public
|
|
32
32
|
*/
|
|
33
33
|
export declare function joinOptionalResourceIds(...ids: (string | undefined)[]): Result<ResourceId | undefined>;
|
|
34
|
+
/**
|
|
35
|
+
* Gets the name for a resource ID.
|
|
36
|
+
* @param id - The resource ID to get the name for.
|
|
37
|
+
* @returns The resource name if found, or undefined if not.
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
export declare function getNameForResourceId(id: string | undefined): Result<ResourceName>;
|
|
34
41
|
//# sourceMappingURL=resources.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../../../src/packlets/common/helpers/resources.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAqB,MAAM,EAAuB,MAAM,eAAe,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAGxD;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC,YAAY,EAAE,CAAC,CAK9E;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,GAAG,GAAG,EAAE,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,GAAG,MAAM,CAAC,UAAU,CAAC,CAUlF;AAED;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,GAAG,EAAE,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,GAAG,MAAM,CAAC,UAAU,GAAG,SAAS,CAAC,CAUtG"}
|
|
1
|
+
{"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../../../src/packlets/common/helpers/resources.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAqB,MAAM,EAAuB,MAAM,eAAe,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAGxD;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC,YAAY,EAAE,CAAC,CAK9E;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,GAAG,GAAG,EAAE,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,GAAG,MAAM,CAAC,UAAU,CAAC,CAUlF;AAED;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,GAAG,EAAE,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,GAAG,MAAM,CAAC,UAAU,GAAG,SAAS,CAAC,CAUtG;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC,YAAY,CAAC,CAIjF"}
|
|
@@ -24,6 +24,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
24
24
|
exports.splitResourceId = splitResourceId;
|
|
25
25
|
exports.joinResourceIds = joinResourceIds;
|
|
26
26
|
exports.joinOptionalResourceIds = joinOptionalResourceIds;
|
|
27
|
+
exports.getNameForResourceId = getNameForResourceId;
|
|
27
28
|
const ts_utils_1 = require("@fgv/ts-utils");
|
|
28
29
|
const resources_1 = require("../validate/resources");
|
|
29
30
|
/**
|
|
@@ -82,4 +83,15 @@ function joinOptionalResourceIds(...ids) {
|
|
|
82
83
|
const id = parts.join('.');
|
|
83
84
|
return errors.returnOrReport(id ? (0, resources_1.toResourceId)(id) : (0, ts_utils_1.succeed)(undefined));
|
|
84
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* Gets the name for a resource ID.
|
|
88
|
+
* @param id - The resource ID to get the name for.
|
|
89
|
+
* @returns The resource name if found, or undefined if not.
|
|
90
|
+
* @public
|
|
91
|
+
*/
|
|
92
|
+
function getNameForResourceId(id) {
|
|
93
|
+
return splitResourceId(id).onSuccess((parts) => {
|
|
94
|
+
return parts.length > 0 ? (0, ts_utils_1.succeed)(parts[parts.length - 1]) : fail('Empty id has no name');
|
|
95
|
+
});
|
|
96
|
+
}
|
|
85
97
|
//# sourceMappingURL=resources.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resources.js","sourceRoot":"","sources":["../../../../src/packlets/common/helpers/resources.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;AAcH,0CAKC;AAYD,0CAUC;AAYD,0DAUC;
|
|
1
|
+
{"version":3,"file":"resources.js","sourceRoot":"","sources":["../../../../src/packlets/common/helpers/resources.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;AAcH,0CAKC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AAC,GAAG,eAAe,CAAC,EAAE,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;IAC1E,CAAC,CAAC,CAAC;IACL,MAAM,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3B,OAAO,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC,IAAA,wBAAY,EAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAA,kBAAO,EAAC,SAAS,CAAC,CAAC,CAAC;AAC3E,CAAC;AAED;;;;;GAKG;AACH,SAAgB,oBAAoB,CAAC,EAAsB;IACzD,OAAO,eAAe,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE;QAC7C,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAA,kBAAO,EAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;IAC5F,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { MessageAggregator, Result, mapResults, succeed } from '@fgv/ts-utils';\nimport { ResourceId, ResourceName } from '../resources';\nimport { toResourceId, toResourceName } from '../validate/resources';\n\n/**\n * Splits a {@link ResourceId | resource id} into its component {@link ResourceName | resource names}.\n *\n * @param id - The ID to split.\n * @returns `Success`with an array of {@link ResourceName | ResourceName} objects if the ID is valid, or\n * `Failure` with an error message if not.\n * @public\n */\nexport function splitResourceId(id: string | undefined): Result<ResourceName[]> {\n if (id === undefined) {\n return succeed([]);\n }\n return mapResults(id.split('.').map(toResourceName));\n}\n\n/**\n * Joins a list of {@link ResourceId | resource ID} or {@link ResourceName | resource name} with\n * to create a new {@link ResourceId | resource ID}. Fails if resulting ID is invalid or empty.\n *\n * @param base - The base name or ID to join.\n * @param names - Additional names to join.\n * @returns `Success` with the new ID if the base and names are valid, or `Failure` with an error message\n * if not.\n * @public\n */\nexport function joinResourceIds(...ids: (string | undefined)[]): Result<ResourceId> {\n const errors: MessageAggregator = new MessageAggregator();\n const parts: ResourceName[] = [];\n ids\n .filter((id) => id !== '')\n .forEach((id) => {\n parts.push(...splitResourceId(id).aggregateError(errors).orDefault([]));\n });\n const id = parts.join('.');\n return errors.returnOrReport(toResourceId(id));\n}\n\n/**\n * Joins a list of {@link ResourceId | resource ID} or {@link ResourceName | resource name} with\n * to create a new {@link ResourceId | resource ID}. Returns `undefined` if no names are defined.\n *\n * @param base - The base name or ID to join.\n * @param names - Additional names to join.\n * @returns `Success` with the new ID if the base and names are valid, `Success` with `undefined`\n * if names were present, or `Failure` with an error message if the resulting id is invalid.\n * @public\n */\nexport function joinOptionalResourceIds(...ids: (string | undefined)[]): Result<ResourceId | undefined> {\n const errors: MessageAggregator = new MessageAggregator();\n const parts: ResourceName[] = [];\n ids\n .filter((id) => id !== '')\n .forEach((id) => {\n parts.push(...splitResourceId(id).aggregateError(errors).orDefault([]));\n });\n const id = parts.join('.');\n return errors.returnOrReport(id ? toResourceId(id) : succeed(undefined));\n}\n\n/**\n * Gets the name for a resource ID.\n * @param id - The resource ID to get the name for.\n * @returns The resource name if found, or undefined if not.\n * @public\n */\nexport function getNameForResourceId(id: string | undefined): Result<ResourceName> {\n return splitResourceId(id).onSuccess((parts) => {\n return parts.length > 0 ? succeed(parts[parts.length - 1]) : fail('Empty id has no name');\n });\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Result } from '@fgv/ts-utils';
|
|
2
|
-
import { ResourceId } from '../common';
|
|
2
|
+
import { ResourceId, ResourceName } from '../common';
|
|
3
3
|
import { ResourceCandidate } from './resourceCandidate';
|
|
4
4
|
import { ResourceType } from '../resource-types';
|
|
5
5
|
import { ConcreteDecision, AbstractDecisionCollector } from '../decisions';
|
|
@@ -40,6 +40,10 @@ export declare class Resource implements IResource {
|
|
|
40
40
|
* The unique {@link ResourceId | id} of the resource.
|
|
41
41
|
*/
|
|
42
42
|
readonly id: ResourceId;
|
|
43
|
+
/**
|
|
44
|
+
* The name of the resource.
|
|
45
|
+
*/
|
|
46
|
+
readonly name: ResourceName;
|
|
43
47
|
/**
|
|
44
48
|
* The {@link ResourceTypes.ResourceType | type} of the resource.
|
|
45
49
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../../src/packlets/resources/resource.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAqB,MAAM,EAAgC,MAAM,eAAe,CAAC;AACxF,OAAO,
|
|
1
|
+
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../../src/packlets/resources/resource.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAqB,MAAM,EAAgC,MAAM,eAAe,CAAC;AACxF,OAAO,EAAW,UAAU,EAAE,YAAY,EAAY,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uB,CAC5B,OAAO,EAAE,OAAO,CAAC,qBAAqB,EACtC,OAAO,CAAC,EAAE,OAAO,CAAC,oBAAoB,GACrC,aAAa,CAAC,iBAAiB,CAAC;IAInC;;;;OAIG;IACI,mBAAmB,CAAC,OAAO,CAAC,EAAE,2BAA2B,GAAG,YAAY,CAAC,IAAI,CAAC,kBAAkB;IAevG;;;;OAIG;IACI,mBAAmB,CAAC,OAAO,CAAC,EAAE,2BAA2B,GAAG,YAAY,CAAC,IAAI,CAAC,kBAAkB;IAgBvG;;;;;OAKG;IACI,UAAU,CACf,OAAO,CAAC,EAAE,2BAA2B,GAAG,kCAAkC,GACzE,YAAY,CAAC,QAAQ,CAAC,iBAAiB;IAiB1C;;;;;;;OAOG;IACH,OAAO,CAAC,MAAM,CAAC,6BAA6B;IAkB5C;;;;;;;OAOG;IACH,OAAO,CAAC,MAAM,CAAC,wBAAwB;IAevC;;;;;;;OAOG;IACH,OAAO,CAAC,MAAM,CAAC,+BAA+B;IAuB9C;;;;;;;OAOG;IACH,SAAS,CAAC,sBAAsB,CAC9B,OAAO,CAAC,EAAE,2BAA2B,GAAG,kCAAkC,GACzE,aAAa,CAAC,iBAAiB,CAAC;CASpC"}
|
|
@@ -53,6 +53,7 @@ class Resource {
|
|
|
53
53
|
constructor(params) {
|
|
54
54
|
const id = params.id ? common_1.Validate.toResourceId(params.id).orThrow() : undefined;
|
|
55
55
|
this.id = Resource._validateCandidateResourceIds(id, params.candidates).orThrow();
|
|
56
|
+
this.name = common_1.Helpers.getNameForResourceId(this.id).orThrow();
|
|
56
57
|
this._resourceType = resourceCandidate_1.ResourceCandidate.validateResourceTypes(params.candidates, params.resourceType)
|
|
57
58
|
.onSuccess((t) => {
|
|
58
59
|
/* c8 ignore next 3 - functional code path tested but coverage intermittently missed */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource.js","sourceRoot":"","sources":["../../../src/packlets/resources/resource.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;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C,KAAK,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE,CAAC;oBAClD,MAAM,CAAC,UAAU,CAAC,GAAG,SAAS,CAAC,EAAE,8BAA8B,kBAAkB,GAAG,CAAC,CAAC;gBACxF,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,SAAS,CAAC,GAAG,CAAC,kBAAkB,EAAE,SAAS,CAAC,CAAC;YAC/C,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC,cAAc,CAC1B,IAAA,kBAAO,EAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,qCAAiB,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,CAAC,CAClF,CAAC;IACJ,CAAC;IAED;;;;;;;OAOG;IACO,sBAAsB,CAC9B,OAA0E;QAE1E,uFAAuF;QACvF,IAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,gBAAgB,EAAE,CAAC;YAC9B,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CAC1C,SAAS,CAAC,sBAAsB,CAAC,OAAO,CAAC,gBAAiB,EAAE,EAAE,mBAAmB,EAAE,IAAI,EAAE,CAAC,CAC3F,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;CACF;AAnPD,4BAmPC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { MessageAggregator, Result, captureResult, fail, succeed } from '@fgv/ts-utils';\nimport { ResourceId, Validate } from '../common';\nimport { ResourceCandidate } from './resourceCandidate';\nimport { CandidateReducer } from './candidateReducer';\nimport { ResourceType } from '../resource-types';\nimport { ConcreteDecision, AbstractDecisionCollector } from '../decisions';\nimport { IResource } from '../runtime';\nimport { IResourceDeclarationOptions, ICompiledResourceOptionsWithFilter } from './common';\nimport * as ResourceJson from '../resource-json';\nimport * as Context from '../context';\n\n/**\n * Parameters used to create a {@link Resources.Resource | Resource} object.\n * @public\n */\nexport interface IResourceCreateParams {\n /**\n * The id of the resource.\n */\n id?: string;\n /**\n * Optional {@link ResourceTypes.ResourceType | type} of the resource. If not specified, the type will be inferred\n * from the candidates.\n */\n resourceType?: ResourceType;\n /**\n * Array of {@link Resources.ResourceCandidate | candidates} for the resource.\n */\n candidates: ReadonlyArray<ResourceCandidate>;\n /**\n * {@link Decisions.AbstractDecisionCollector | AbstractDecisionCollector} used to create the optimized decision.\n */\n decisions: AbstractDecisionCollector;\n}\n\n/**\n * Represents a single logical resource, with a unique id and a set of possible\n * candidate instances.\n * @public\n */\nexport class Resource implements IResource {\n /**\n * The unique {@link ResourceId | id} of the resource.\n */\n public readonly id: ResourceId;\n /**\n * The {@link ResourceTypes.ResourceType | type} of the resource.\n */\n public readonly _resourceType: ResourceType;\n /**\n * The array of {@link Resources.ResourceCandidate | candidates} for the resource.\n */\n public readonly candidates: ReadonlyArray<ResourceCandidate>;\n /**\n * {@link Decisions.ConcreteDecision | Decision} for optimized resource resolution.\n */\n public readonly decision: ConcreteDecision;\n\n /**\n * Gets the resource type (implements IResource interface).\n */\n public get resourceType(): ResourceType {\n return this._resourceType;\n }\n\n /**\n * Gets the resource type name as a string.\n */\n public get resourceTypeName(): string {\n return this._resourceType.key;\n }\n\n /**\n * Constructor for a {@link Resources.Resource | Resource} object.\n * @param params - {@link Resources.IResourceCreateParams | Parameters} used to create the resource.\n * @public\n */\n protected constructor(params: IResourceCreateParams) {\n const id = params.id ? Validate.toResourceId(params.id).orThrow() : undefined;\n this.id = Resource._validateCandidateResourceIds(id, params.candidates).orThrow();\n this._resourceType = ResourceCandidate.validateResourceTypes(params.candidates, params.resourceType)\n .onSuccess((t) => {\n /* c8 ignore next 3 - functional code path tested but coverage intermittently missed */\n if (t === undefined) {\n return fail<ResourceType>(`${params.id}: no type specified and no candidates with types.`);\n }\n return succeed(t);\n })\n .orThrow();\n\n this.candidates = Resource._validateAndNormalizeCandidates(params.candidates).orThrow();\n this.decision = Resource._createOptimizedDecision(this.candidates, params.decisions).orThrow();\n }\n\n /**\n * Creates a new {@link Resources.Resource | Resource} object.\n * @param params - {@link Resources.IResourceCreateParams | Parameters} used to create the resource.\n * @returns `Success` with the new {@link Resources.Resource | Resource} object if successful,\n * or `Failure` with an error message if not.\n * @public\n */\n public static create(params: IResourceCreateParams): Result<Resource> {\n return captureResult(() => new Resource(params));\n }\n\n /**\n * Gets the candidates for this resource that match the specified {@link Context.IValidatedContextDecl | context}.\n * @param context - The {@link Context.IValidatedContextDecl | context} to match against.\n * @param options - {@link Context.IContextMatchOptions | options} for the context match.\n * @returns The array of {@link Resources.ResourceCandidate | candidates} that match the context.\n */\n public getCandidatesForContext(\n context: Context.IValidatedContextDecl,\n options?: Context.IContextMatchOptions\n ): ReadonlyArray<ResourceCandidate> {\n return this.candidates.filter((c) => c.canMatchPartialContext(context, options));\n }\n\n /**\n * Gets the {@link ResourceJson.Json.IChildResourceDecl | child resource declaration} for this resource.\n * @param options - {@link ResourceJson.Helpers.IDeclarationOptions | options} for the declaration.\n * @returns The {@link ResourceJson.Json.IChildResourceDecl | child resource declaration}.\n */\n public toChildResourceDecl(options?: IResourceDeclarationOptions): ResourceJson.Json.IChildResourceDecl {\n /* c8 ignore next 1 - defense in depth */\n options = options ?? {};\n const matches = this._getMatchingCandidates(options);\n\n const candidates = options.reduceQualifiers\n ? CandidateReducer.reduceToChildResourceCandidateDecls(matches, options.filterForContext).orThrow()\n : matches.map((c) => c.toChildResourceCandidateDecl());\n\n return {\n resourceTypeName: this.resourceTypeName,\n ...(candidates.length > 0 ? { candidates } : {})\n };\n }\n\n /**\n * Gets the {@link ResourceJson.Json.ILooseResourceDecl | loose resource declaration} for this resource.\n * @param options - {@link Resources.IResourceDeclarationOptions | options} for the declaration.\n * @returns The {@link ResourceJson.Json.ILooseResourceDecl | loose resource declaration}.\n */\n public toLooseResourceDecl(options?: IResourceDeclarationOptions): ResourceJson.Json.ILooseResourceDecl {\n /* c8 ignore next 1 - defense in depth */\n options = options ?? {};\n const matches = this._getMatchingCandidates(options);\n\n const candidates = options.reduceQualifiers\n ? CandidateReducer.reduceToChildResourceCandidateDecls(matches, options.filterForContext).orThrow()\n : matches.map((c) => c.toChildResourceCandidateDecl());\n\n return {\n id: this.id,\n resourceTypeName: this.resourceTypeName,\n ...(candidates.length > 0 ? { candidates } : {})\n };\n }\n\n /**\n * Converts this resource to a compiled resource representation.\n * @param options - Optional compilation options controlling the output format and filtering.\n * @returns A compiled resource object that can be used for serialization or runtime processing.\n * @public\n */\n public toCompiled(\n options?: IResourceDeclarationOptions | ICompiledResourceOptionsWithFilter\n ): ResourceJson.Compiled.ICompiledResource {\n const candidates: ResourceJson.Compiled.ICompiledCandidate[] = this._getMatchingCandidates(options).map(\n (c) => ({\n json: c.json,\n isPartial: c.isPartial,\n mergeMethod: c.mergeMethod\n })\n );\n\n return {\n id: this.id,\n type: this.resourceType.index!,\n decision: this.decision.baseDecision.index!,\n candidates\n };\n }\n\n /**\n * Validates that all candidates have the same id as the resource.\n * @param resourceId - The expected id of the resource.\n * @param candidates - The array of candidates to validate.\n * @returns `Success` with the resource id if all candidates have the same id,\n * `Failure` with an error message otherwise.\n * @internal\n */\n private static _validateCandidateResourceIds(\n resourceId: ResourceId | undefined,\n candidates: ReadonlyArray<ResourceCandidate>\n ): Result<ResourceId> {\n /* c8 ignore next 3 - functional code path tested but coverage intermittently missed */\n if (!resourceId && candidates.length === 0) {\n return fail('unknown: no resource id and no candidates.');\n }\n resourceId = resourceId ?? candidates[0].id;\n\n const mismatched = candidates.filter((c) => c.id !== resourceId).map((c) => c.id);\n /* c8 ignore next 3 - functional code path tested but coverage intermittently missed */\n if (mismatched.length > 0) {\n return fail(`${resourceId}: candidates with mismatched ids ${mismatched.join(', ')}.`);\n }\n return succeed(resourceId);\n }\n\n /**\n * Creates an optimized decision for the given candidates using the decisions collector.\n * @param candidates - The validated and normalized candidates to create a decision for.\n * @param decisions - The {@link Decisions.AbstractDecisionCollector | AbstractDecisionCollector} to use.\n * @returns `Success` with the {@link Decisions.ConcreteDecision | ConcreteDecision} if successful,\n * `Failure` with an error message otherwise.\n * @internal\n */\n private static _createOptimizedDecision(\n candidates: ReadonlyArray<ResourceCandidate>,\n decisions: AbstractDecisionCollector\n ): Result<ConcreteDecision> {\n const decisionCandidates = candidates.map((c) => ({\n conditionSet: c.conditions,\n value: c.json\n }));\n\n return ConcreteDecision.create({\n decisions,\n candidates: decisionCandidates\n });\n }\n\n /**\n * Validates and normalizes an array of {@link Resources.ResourceCandidate | candidates}. Fails if there\n * are multiple candidates for the same set of conditions.\n * @param candidates - The array of candidates to validate.\n * @returns `Success` with the validated and sorted array of candidates if successful,\n * `Failure` with an error message otherwise.\n * @internal\n */\n private static _validateAndNormalizeCandidates(\n candidates: ReadonlyArray<ResourceCandidate>\n ): Result<ReadonlyArray<ResourceCandidate>> {\n const errors = new MessageAggregator();\n const validated: Map<string, ResourceCandidate> = new Map();\n\n for (const candidate of candidates) {\n const conditionSetString = candidate.conditions.toString();\n const existing = validated.get(conditionSetString);\n if (existing) {\n /* c8 ignore next 3 - functional code path tested but coverage intermittently missed */\n if (!ResourceCandidate.equal(candidate, existing)) {\n errors.addMessage(`${candidate.id}: duplicate candidates for ${conditionSetString}.`);\n }\n } else {\n validated.set(conditionSetString, candidate);\n }\n }\n return errors.returnOrReport(\n succeed(Array.from(validated.values()).sort(ResourceCandidate.compare).reverse())\n );\n }\n\n /**\n * Gets the appropriate candidates based on filtering options.\n * If a validated filter context is provided, returns only matching candidates.\n * Otherwise returns all candidates.\n * @param options - Options that may contain a validated filter context\n * @returns The filtered array of candidates\n * @internal\n */\n protected _getMatchingCandidates(\n options?: IResourceDeclarationOptions | ICompiledResourceOptionsWithFilter\n ): ReadonlyArray<ResourceCandidate> {\n /* c8 ignore next 5 - functional code path tested but coverage intermittently missed */\n if (options?.filterForContext) {\n return this.candidates.filter((candidate) =>\n candidate.canMatchPartialContext(options.filterForContext!, { partialContextMatch: true })\n );\n }\n return this.candidates;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"resource.js","sourceRoot":"","sources":["../../../src/packlets/resources/resource.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,4CAAwF;AACxF,sCAAwE;AACxE,2DAAwD;AACxD,yDAAsD;AAEtD,4CAA2E;AA8B3E;;;;GAIG;AACH,MAAa,QAAQ;IAwBnB;;OAEG;IACH,IAAW,YAAY;QACrB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,IAAW,gBAAgB;QACzB,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC;IAChC,CAAC;IAED;;;;OAIG;IACH,YAAsB,MAA6B;QACjD,MAAM,EAAE,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,iBAAQ,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CA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AAE,CAAC,CAAC,IAAI,CAAC,qCAAiB,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,CAAC,CAClF,CAAC;IACJ,CAAC;IAED;;;;;;;OAOG;IACO,sBAAsB,CAC9B,OAA0E;QAE1E,uFAAuF;QACvF,IAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,gBAAgB,EAAE,CAAC;YAC9B,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CAC1C,SAAS,CAAC,sBAAsB,CAAC,OAAO,CAAC,gBAAiB,EAAE,EAAE,mBAAmB,EAAE,IAAI,EAAE,CAAC,CAC3F,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;CACF;AA1PD,4BA0PC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { MessageAggregator, Result, captureResult, fail, succeed } from '@fgv/ts-utils';\nimport { Helpers, ResourceId, ResourceName, Validate } from '../common';\nimport { ResourceCandidate } from './resourceCandidate';\nimport { CandidateReducer } from './candidateReducer';\nimport { ResourceType } from '../resource-types';\nimport { ConcreteDecision, AbstractDecisionCollector } from '../decisions';\nimport { IResource } from '../runtime';\nimport { IResourceDeclarationOptions, ICompiledResourceOptionsWithFilter } from './common';\nimport * as ResourceJson from '../resource-json';\nimport * as Context from '../context';\n\n/**\n * Parameters used to create a {@link Resources.Resource | Resource} object.\n * @public\n */\nexport interface IResourceCreateParams {\n /**\n * The id of the resource.\n */\n id?: string;\n /**\n * Optional {@link ResourceTypes.ResourceType | type} of the resource. If not specified, the type will be inferred\n * from the candidates.\n */\n resourceType?: ResourceType;\n /**\n * Array of {@link Resources.ResourceCandidate | candidates} for the resource.\n */\n candidates: ReadonlyArray<ResourceCandidate>;\n /**\n * {@link Decisions.AbstractDecisionCollector | AbstractDecisionCollector} used to create the optimized decision.\n */\n decisions: AbstractDecisionCollector;\n}\n\n/**\n * Represents a single logical resource, with a unique id and a set of possible\n * candidate instances.\n * @public\n */\nexport class Resource implements IResource {\n /**\n * The unique {@link ResourceId | id} of the resource.\n */\n public readonly id: ResourceId;\n\n /**\n * The name of the resource.\n */\n public readonly name: ResourceName;\n\n /**\n * The {@link ResourceTypes.ResourceType | type} of the resource.\n */\n public readonly _resourceType: ResourceType;\n /**\n * The array of {@link Resources.ResourceCandidate | candidates} for the resource.\n */\n public readonly candidates: ReadonlyArray<ResourceCandidate>;\n /**\n * {@link Decisions.ConcreteDecision | Decision} for optimized resource resolution.\n */\n public readonly decision: ConcreteDecision;\n\n /**\n * Gets the resource type (implements IResource interface).\n */\n public get resourceType(): ResourceType {\n return this._resourceType;\n }\n\n /**\n * Gets the resource type name as a string.\n */\n public get resourceTypeName(): string {\n return this._resourceType.key;\n }\n\n /**\n * Constructor for a {@link Resources.Resource | Resource} object.\n * @param params - {@link Resources.IResourceCreateParams | Parameters} used to create the resource.\n * @public\n */\n protected constructor(params: IResourceCreateParams) {\n const id = params.id ? Validate.toResourceId(params.id).orThrow() : undefined;\n this.id = Resource._validateCandidateResourceIds(id, params.candidates).orThrow();\n this.name = Helpers.getNameForResourceId(this.id).orThrow();\n this._resourceType = ResourceCandidate.validateResourceTypes(params.candidates, params.resourceType)\n .onSuccess((t) => {\n /* c8 ignore next 3 - functional code path tested but coverage intermittently missed */\n if (t === undefined) {\n return fail<ResourceType>(`${params.id}: no type specified and no candidates with types.`);\n }\n return succeed(t);\n })\n .orThrow();\n\n this.candidates = Resource._validateAndNormalizeCandidates(params.candidates).orThrow();\n this.decision = Resource._createOptimizedDecision(this.candidates, params.decisions).orThrow();\n }\n\n /**\n * Creates a new {@link Resources.Resource | Resource} object.\n * @param params - {@link Resources.IResourceCreateParams | Parameters} used to create the resource.\n * @returns `Success` with the new {@link Resources.Resource | Resource} object if successful,\n * or `Failure` with an error message if not.\n * @public\n */\n public static create(params: IResourceCreateParams): Result<Resource> {\n return captureResult(() => new Resource(params));\n }\n\n /**\n * Gets the candidates for this resource that match the specified {@link Context.IValidatedContextDecl | context}.\n * @param context - The {@link Context.IValidatedContextDecl | context} to match against.\n * @param options - {@link Context.IContextMatchOptions | options} for the context match.\n * @returns The array of {@link Resources.ResourceCandidate | candidates} that match the context.\n */\n public getCandidatesForContext(\n context: Context.IValidatedContextDecl,\n options?: Context.IContextMatchOptions\n ): ReadonlyArray<ResourceCandidate> {\n return this.candidates.filter((c) => c.canMatchPartialContext(context, options));\n }\n\n /**\n * Gets the {@link ResourceJson.Json.IChildResourceDecl | child resource declaration} for this resource.\n * @param options - {@link ResourceJson.Helpers.IDeclarationOptions | options} for the declaration.\n * @returns The {@link ResourceJson.Json.IChildResourceDecl | child resource declaration}.\n */\n public toChildResourceDecl(options?: IResourceDeclarationOptions): ResourceJson.Json.IChildResourceDecl {\n /* c8 ignore next 1 - defense in depth */\n options = options ?? {};\n const matches = this._getMatchingCandidates(options);\n\n const candidates = options.reduceQualifiers\n ? CandidateReducer.reduceToChildResourceCandidateDecls(matches, options.filterForContext).orThrow()\n : matches.map((c) => c.toChildResourceCandidateDecl());\n\n return {\n resourceTypeName: this.resourceTypeName,\n ...(candidates.length > 0 ? { candidates } : {})\n };\n }\n\n /**\n * Gets the {@link ResourceJson.Json.ILooseResourceDecl | loose resource declaration} for this resource.\n * @param options - {@link Resources.IResourceDeclarationOptions | options} for the declaration.\n * @returns The {@link ResourceJson.Json.ILooseResourceDecl | loose resource declaration}.\n */\n public toLooseResourceDecl(options?: IResourceDeclarationOptions): ResourceJson.Json.ILooseResourceDecl {\n /* c8 ignore next 1 - defense in depth */\n options = options ?? {};\n const matches = this._getMatchingCandidates(options);\n\n const candidates = options.reduceQualifiers\n ? CandidateReducer.reduceToChildResourceCandidateDecls(matches, options.filterForContext).orThrow()\n : matches.map((c) => c.toChildResourceCandidateDecl());\n\n return {\n id: this.id,\n resourceTypeName: this.resourceTypeName,\n ...(candidates.length > 0 ? { candidates } : {})\n };\n }\n\n /**\n * Converts this resource to a compiled resource representation.\n * @param options - Optional compilation options controlling the output format and filtering.\n * @returns A compiled resource object that can be used for serialization or runtime processing.\n * @public\n */\n public toCompiled(\n options?: IResourceDeclarationOptions | ICompiledResourceOptionsWithFilter\n ): ResourceJson.Compiled.ICompiledResource {\n const candidates: ResourceJson.Compiled.ICompiledCandidate[] = this._getMatchingCandidates(options).map(\n (c) => ({\n json: c.json,\n isPartial: c.isPartial,\n mergeMethod: c.mergeMethod\n })\n );\n\n return {\n id: this.id,\n type: this.resourceType.index!,\n decision: this.decision.baseDecision.index!,\n candidates\n };\n }\n\n /**\n * Validates that all candidates have the same id as the resource.\n * @param resourceId - The expected id of the resource.\n * @param candidates - The array of candidates to validate.\n * @returns `Success` with the resource id if all candidates have the same id,\n * `Failure` with an error message otherwise.\n * @internal\n */\n private static _validateCandidateResourceIds(\n resourceId: ResourceId | undefined,\n candidates: ReadonlyArray<ResourceCandidate>\n ): Result<ResourceId> {\n /* c8 ignore next 3 - functional code path tested but coverage intermittently missed */\n if (!resourceId && candidates.length === 0) {\n return fail('unknown: no resource id and no candidates.');\n }\n resourceId = resourceId ?? candidates[0].id;\n\n const mismatched = candidates.filter((c) => c.id !== resourceId).map((c) => c.id);\n /* c8 ignore next 3 - functional code path tested but coverage intermittently missed */\n if (mismatched.length > 0) {\n return fail(`${resourceId}: candidates with mismatched ids ${mismatched.join(', ')}.`);\n }\n return succeed(resourceId);\n }\n\n /**\n * Creates an optimized decision for the given candidates using the decisions collector.\n * @param candidates - The validated and normalized candidates to create a decision for.\n * @param decisions - The {@link Decisions.AbstractDecisionCollector | AbstractDecisionCollector} to use.\n * @returns `Success` with the {@link Decisions.ConcreteDecision | ConcreteDecision} if successful,\n * `Failure` with an error message otherwise.\n * @internal\n */\n private static _createOptimizedDecision(\n candidates: ReadonlyArray<ResourceCandidate>,\n decisions: AbstractDecisionCollector\n ): Result<ConcreteDecision> {\n const decisionCandidates = candidates.map((c) => ({\n conditionSet: c.conditions,\n value: c.json\n }));\n\n return ConcreteDecision.create({\n decisions,\n candidates: decisionCandidates\n });\n }\n\n /**\n * Validates and normalizes an array of {@link Resources.ResourceCandidate | candidates}. Fails if there\n * are multiple candidates for the same set of conditions.\n * @param candidates - The array of candidates to validate.\n * @returns `Success` with the validated and sorted array of candidates if successful,\n * `Failure` with an error message otherwise.\n * @internal\n */\n private static _validateAndNormalizeCandidates(\n candidates: ReadonlyArray<ResourceCandidate>\n ): Result<ReadonlyArray<ResourceCandidate>> {\n const errors = new MessageAggregator();\n const validated: Map<string, ResourceCandidate> = new Map();\n\n for (const candidate of candidates) {\n const conditionSetString = candidate.conditions.toString();\n const existing = validated.get(conditionSetString);\n if (existing) {\n /* c8 ignore next 3 - functional code path tested but coverage intermittently missed */\n if (!ResourceCandidate.equal(candidate, existing)) {\n errors.addMessage(`${candidate.id}: duplicate candidates for ${conditionSetString}.`);\n }\n } else {\n validated.set(conditionSetString, candidate);\n }\n }\n return errors.returnOrReport(\n succeed(Array.from(validated.values()).sort(ResourceCandidate.compare).reverse())\n );\n }\n\n /**\n * Gets the appropriate candidates based on filtering options.\n * If a validated filter context is provided, returns only matching candidates.\n * Otherwise returns all candidates.\n * @param options - Options that may contain a validated filter context\n * @returns The filtered array of candidates\n * @internal\n */\n protected _getMatchingCandidates(\n options?: IResourceDeclarationOptions | ICompiledResourceOptionsWithFilter\n ): ReadonlyArray<ResourceCandidate> {\n /* c8 ignore next 5 - functional code path tested but coverage intermittently missed */\n if (options?.filterForContext) {\n return this.candidates.filter((candidate) =>\n candidate.canMatchPartialContext(options.filterForContext!, { partialContextMatch: true })\n );\n }\n return this.candidates;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compiledResourceCollection.d.ts","sourceRoot":"","sources":["../../../src/packlets/runtime/compiledResourceCollection.ts"],"names":[],"mappings":"AAsBA,OAAO,EAEL,WAAW,EAIX,MAAM,EAGP,MAAM,eAAe,CAAC;AACvB,OAAO,EAGL,0BAA0B,EAC1B,6BAA6B,EAC9B,MAAM,eAAe,CAAC;AACvB,OAAO,EAA6B,iCAAiC,EAAE,MAAM,cAAc,CAAC;AAC5F,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC3E,OAAO,EAAW,UAAU,
|
|
1
|
+
{"version":3,"file":"compiledResourceCollection.d.ts","sourceRoot":"","sources":["../../../src/packlets/runtime/compiledResourceCollection.ts"],"names":[],"mappings":"AAsBA,OAAO,EAEL,WAAW,EAIX,MAAM,EAGP,MAAM,eAAe,CAAC;AACvB,OAAO,EAGL,0BAA0B,EAC1B,6BAA6B,EAC9B,MAAM,eAAe,CAAC;AACvB,OAAO,EAA6B,iCAAiC,EAAE,MAAM,cAAc,CAAC;AAC5F,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC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qBAAqB,CAEhD;IAED;;OAEG;IACH,IAAW,cAAc,IAAI,WAAW,CAAC,4BAA4B,CAAC,UAAU,EAAE,SAAS,CAAC,CAE3F;IAED;;OAEG;IACH,IAAW,YAAY,IAAI,MAAM,CAEhC;IAED,SAAS,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IAElC;;OAEG;IACH,IAAW,aAAa,IAAI,MAAM,CAQjC;IAED;;;;OAIG;IACH,SAAS,aAAa,MAAM,EAAE,uCAAuC;IAgCrE;;;;;;OAMG;WACW,MAAM,CAAC,MAAM,EAAE,uCAAuC,GAAG,MAAM,CAAC,0BAA0B,CAAC;IAIzG;;OAEG;IACI,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC;IAItD;;OAEG;IACI,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,qBAAqB,CAAC;IAM5F;;;;;;;;;;;;OAYG;IACI,oBAAoB,IAAI,MAAM,CAAC,yBAAyB,CAAC,SAAS,CAAC,CAAC;IAkB3E;;;;;;OAMG;IACH,OAAO,CAAC,oBAAoB;IAa5B;;;;;;OAMG;IACH,OAAO,CAAC,gBAAgB;IAsBxB;;;;;;OAMG;IACH,OAAO,CAAC,mBAAmB;IAa3B;;;;;;OAMG;IACH,OAAO,CAAC,gBAAgB;IA6DxB;;;;;;OAMG;IACH,OAAO,CAAC,mBAAmB;IAqD3B;;;;;;OAMG;IACH,OAAO,CAAC,eAAe;IAqDvB;;;;;;;OAOG;IACH,OAAO,CAAC,eAAe;CA0GxB"}
|
|
@@ -446,9 +446,16 @@ class CompiledResourceCollection {
|
|
|
446
446
|
continue;
|
|
447
447
|
}
|
|
448
448
|
const concreteDecision = concreteDecisionResult.value;
|
|
449
|
+
const { value: name, message: nameError } = common_1.Helpers.getNameForResourceId(compiledResource.id);
|
|
450
|
+
/* c8 ignore next 4 - defense in depth nearly impossible to reproduce */
|
|
451
|
+
if (nameError !== undefined) {
|
|
452
|
+
errors.addMessage(`Failed to get name for resource ${compiledResource.id}: ${nameError}`);
|
|
453
|
+
continue;
|
|
454
|
+
}
|
|
449
455
|
// Create minimal resource that implements IResource
|
|
450
456
|
const resource = {
|
|
451
457
|
id: compiledResource.id,
|
|
458
|
+
name,
|
|
452
459
|
resourceType,
|
|
453
460
|
decision: concreteDecision,
|
|
454
461
|
candidates
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compiledResourceCollection.js","sourceRoot":"","sources":["../../../src/packlets/runtime/compiledResourceCollection.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4CASuB;AACvB,8CAKuB;AACvB,4CAA4F;AAC5F,8CAAmD;AACnD,sDAAwE;AACxE,wDAA2E;AAC3E,sCAAgD;AAChD,oDAA+C;AAE/C,4CAAgD;AAChD,qDAAuC;AAEvC,mDAAsF;AACtF,oDAAsC;AAqBtC;;;;;GAKG;AACH,MAAa,0BAA0B;IAWrC;;;OAGG;IACH,IAAW,cAAc;QACvB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;IAED;;;OAGG;IACH,IAAW,UAAU;QACnB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED;;;OAGG;IACH,IAAW,aAAa;QACtB,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,IAAW,cAAc;QACvB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,IAAW,YAAY;QACrB,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC;IACnC,CAAC;IAID;;OAEG;IACH,IAAW,aAAa;QACtB,IAAI,IAAI,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;YACtC,IAAI,CAAC,cAAc,GAAG,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,E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,EAAE;gBACvB,YAAY;gBACZ,QAAQ,EAAE,gBAAgB;gBAC1B,UAAU;aACX,CAAC;YAEF,MAAM,SAAS,GAAG,WAAW,CAAC,GAAG,CAAC,gBAAgB,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;YACjE,sEAAsE;YACtE,IAAI,SAAS,CAAC,SAAS,EAAE,EAAE,CAAC;gBAC1B,MAAM,CAAC,UAAU,CAAC,0BAA0B,gBAAgB,CAAC,EAAE,KAAK,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC;YAC3F,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,IAAA,eAAI,EAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,IAAA,kBAAO,EAAC,WAAW,CAAC,CAAC;IAC7E,CAAC;CACF;AA1gBD,gEA0gBC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport {\n captureResult,\n Collections,\n fail,\n mapResults,\n MessageAggregator,\n Result,\n succeed,\n ValidatingResultMap\n} from '@fgv/ts-utils';\nimport {\n ConditionCollector,\n ConditionSetCollector,\n ReadOnlyConditionCollector,\n ReadOnlyConditionSetCollector\n} from '../conditions';\nimport { AbstractDecisionCollector, ReadOnlyAbstractDecisionCollector } from '../decisions';\nimport { QualifierCollector } from '../qualifiers';\nimport { ResourceType, ResourceTypeCollector } from '../resource-types';\nimport { QualifierType, QualifierTypeCollector } from '../qualifier-types';\nimport { Convert, ResourceId } from '../common';\nimport { Converters } from '@fgv/ts-json-base';\nimport { IResourceManager, IResource, IResourceCandidate } from './iResourceManager';\nimport { ConcreteDecision } from '../decisions';\nimport * as Validate from './validate';\nimport * as ResourceJson from '../resource-json';\nimport { ReadOnlyResourceTreeRoot, IReadOnlyResourceTreeRoot } from './resource-tree';\nimport * as Context from '../context';\n\n/**\n * Interface for parameters to create a {@link Runtime.CompiledResourceCollection | CompiledResourceCollection}.\n * @public\n */\nexport interface ICompiledResourceCollectionCreateParams {\n /**\n * The compiled resource collection data.\n */\n compiledCollection: ResourceJson.Compiled.ICompiledResourceCollection;\n /**\n * Map of qualifier type names to qualifier type objects.\n */\n qualifierTypes: Collections.IReadOnlyResultMap<string, QualifierType>;\n /**\n * Map of resource type names to resource type objects.\n */\n resourceTypes: Collections.IReadOnlyResultMap<string, ResourceType>;\n}\n\n/**\n * A compiled resource collection implements {@link Runtime.IResourceManager | IResourceManager}\n * by reconstructing runtime objects from compiled data. This provides an efficient way to load\n * and use pre-compiled resource collections without rebuilding them from scratch.\n * @public\n */\nexport class CompiledResourceCollection implements IResourceManager<IResource> {\n public readonly conditions: ReadOnlyConditionCollector;\n public readonly conditionSets: ReadOnlyConditionSetCollector;\n public readonly decisions: ReadOnlyAbstractDecisionCollector;\n\n private readonly _qualifierTypes: QualifierTypeCollector;\n private readonly _qualifiers: QualifierCollector;\n private readonly _resourceTypes: ResourceTypeCollector;\n private readonly _builtResources: ValidatingResultMap<ResourceId, IResource>;\n private _cachedResourceTree?: ReadOnlyResourceTreeRoot<IResource>;\n\n /**\n * A {@link QualifierTypes.QualifierTypeCollector | QualifierTypeCollector} which\n * contains the {@link QualifierTypes.QualifierType | qualifier types} used in this collection.\n */\n public get qualifierTypes(): QualifierTypeCollector {\n return this._qualifierTypes;\n }\n\n /**\n * A {@link Qualifiers.QualifierCollector | QualifierCollector} which\n * contains the {@link Qualifiers.Qualifier | qualifiers} used in this collection.\n */\n public get qualifiers(): QualifierCollector {\n return this._qualifiers;\n }\n\n /**\n * A {@link ResourceTypes.ResourceTypeCollector | ResourceTypeCollector} which\n * contains the {@link ResourceTypes.ResourceType | resource types} used in this collection.\n */\n public get resourceTypes(): ResourceTypeCollector {\n return this._resourceTypes;\n }\n\n /**\n * {@inheritdoc Runtime.IResourceManager.builtResources}\n */\n public get builtResources(): Collections.IReadOnlyValidatingResultMap<ResourceId, IResource> {\n return this._builtResources;\n }\n\n /**\n * {@inheritdoc Runtime.IResourceManager.numResources}\n */\n public get numResources(): number {\n return this._builtResources.size;\n }\n\n protected _numCandidates?: number;\n\n /**\n * {@inheritdoc Runtime.IResourceManager.numCandidates}\n */\n public get numCandidates(): number {\n if (this._numCandidates === undefined) {\n this._numCandidates = [...this._builtResources.values()].reduce(\n (acc, resource) => acc + resource.candidates.length,\n 0\n );\n }\n return this._numCandidates;\n }\n\n /**\n * Constructor for a {@link Runtime.CompiledResourceCollection | CompiledResourceCollection} object.\n * @param params - Parameters to create a new {@link Runtime.CompiledResourceCollection | CompiledResourceCollection}.\n * @internal\n */\n protected constructor(params: ICompiledResourceCollectionCreateParams) {\n // Reconstruct collectors from compiled data\n this._qualifierTypes = this._buildQualifierTypes(\n params.compiledCollection,\n params.qualifierTypes\n ).orThrow();\n this._qualifiers = this._buildQualifiers(params.compiledCollection, this._qualifierTypes).orThrow();\n this._resourceTypes = this._buildResourceTypes(params.compiledCollection, params.resourceTypes).orThrow();\n\n // Build collectors from compiled data\n const conditionCollector = this._buildConditions(params.compiledCollection, this._qualifiers).orThrow();\n const conditionSetCollector = this._buildConditionSets(\n params.compiledCollection,\n conditionCollector\n ).orThrow();\n const decisionCollector = this._buildDecisions(\n params.compiledCollection,\n conditionSetCollector\n ).orThrow();\n\n this.conditions = conditionCollector;\n this.conditionSets = conditionSetCollector;\n this.decisions = decisionCollector;\n\n // Build resources from compiled data\n this._builtResources = this._buildResources(\n params.compiledCollection,\n this._resourceTypes,\n decisionCollector\n ).orThrow();\n }\n\n /**\n * Creates a new {@link Runtime.CompiledResourceCollection | CompiledResourceCollection} object.\n * @param params - Parameters to create a new {@link Runtime.CompiledResourceCollection | CompiledResourceCollection}.\n * @returns `Success` with the new {@link Runtime.CompiledResourceCollection | CompiledResourceCollection} object if successful,\n * or `Failure` with an error message if not.\n * @public\n */\n public static create(params: ICompiledResourceCollectionCreateParams): Result<CompiledResourceCollection> {\n return captureResult(() => new CompiledResourceCollection(params));\n }\n\n /**\n * {@inheritdoc Runtime.IResourceManager.getBuiltResource}\n */\n public getBuiltResource(id: string): Result<IResource> {\n return this._builtResources.validating.get(id);\n }\n\n /**\n * {@inheritdoc Runtime.IResourceManager.validateContext}\n */\n public validateContext(context: Context.IContextDecl): Result<Context.IValidatedContextDecl> {\n return Context.Convert.validatedContextDecl.convert(context, {\n qualifiers: this._qualifiers\n });\n }\n\n /**\n * Gets a resource tree built from the resources in this collection.\n * The tree provides hierarchical access to resources based on their ResourceId structure.\n * For example, resources with IDs like \"app.messages.welcome\" create a tree structure\n * where \"app\" and \"messages\" are branch nodes, and \"welcome\" is a leaf containing the resource.\n *\n * String-based validation is available through the `children.validating` property,\n * allowing callers to use `tree.children.validating.getById(stringId)` for validated access.\n *\n * Uses lazy initialization with caching for performance.\n * @returns Result containing the resource tree root, or failure if tree construction fails\n * @public\n */\n public getBuiltResourceTree(): Result<IReadOnlyResourceTreeRoot<IResource>> {\n if (this._cachedResourceTree) {\n return succeed(this._cachedResourceTree);\n }\n\n // Convert all built resources to [ResourceId, IResource] pairs\n const resources: [ResourceId, IResource][] = [];\n for (const [id, resource] of this._builtResources.entries()) {\n resources.push([id, resource]);\n }\n\n // Create the resource tree with lazy initialization\n return ReadOnlyResourceTreeRoot.create(resources).onSuccess((tree) => {\n this._cachedResourceTree = tree;\n return succeed(tree);\n });\n }\n\n /**\n * Reconstructs a QualifierTypeCollector from compiled data.\n * @param compiled - The compiled resource collection\n * @param qualifierTypes - Map of qualifier type names to qualifier type objects\n * @returns The reconstructed QualifierTypeCollector\n * @internal\n */\n private _buildQualifierTypes(\n compiled: ResourceJson.Compiled.ICompiledResourceCollection,\n qualifierTypes: Collections.IReadOnlyResultMap<string, QualifierType>\n ): Result<QualifierTypeCollector> {\n return mapResults(\n compiled.qualifierTypes.map((compiledQualifierType) => qualifierTypes.get(compiledQualifierType.name))\n ).onSuccess((referencedQualifierTypes) => {\n return QualifierTypeCollector.create({\n qualifierTypes: referencedQualifierTypes\n });\n });\n }\n\n /**\n * Reconstructs a QualifierCollector from compiled data.\n * @param compiled - The compiled resource collection\n * @param qualifierTypes - The reconstructed QualifierTypeCollector\n * @returns The reconstructed QualifierCollector\n * @internal\n */\n private _buildQualifiers(\n compiled: ResourceJson.Compiled.ICompiledResourceCollection,\n qualifierTypes: QualifierTypeCollector\n ): Result<QualifierCollector> {\n return mapResults(\n compiled.qualifiers.map((compiledQualifier) => {\n return qualifierTypes.getAt(compiledQualifier.type).onSuccess((qualifierType) => {\n return succeed({\n name: compiledQualifier.name,\n typeName: qualifierType.name,\n defaultPriority: compiledQualifier.defaultPriority\n });\n });\n })\n ).onSuccess((qualifierDecls) => {\n return QualifierCollector.create({\n qualifierTypes,\n qualifiers: qualifierDecls\n });\n });\n }\n\n /**\n * Reconstructs a ResourceTypeCollector from compiled data.\n * @param compiled - The compiled resource collection\n * @param resourceTypes - Map of resource type names to resource type objects\n * @returns The reconstructed ResourceTypeCollector\n * @internal\n */\n private _buildResourceTypes(\n compiled: ResourceJson.Compiled.ICompiledResourceCollection,\n resourceTypes: Collections.IReadOnlyResultMap<string, ResourceType>\n ): Result<ResourceTypeCollector> {\n return mapResults(\n compiled.resourceTypes.map((compiledResourceType) => resourceTypes.get(compiledResourceType.name))\n ).onSuccess((referencedResourceTypes) => {\n return ResourceTypeCollector.create({\n resourceTypes: referencedResourceTypes\n });\n });\n }\n\n /**\n * Reconstructs a ConditionCollector from compiled data.\n * @param compiled - The compiled resource collection\n * @param qualifiers - The reconstructed QualifierCollector\n * @returns The reconstructed ConditionCollector\n * @internal\n */\n private _buildConditions(\n compiled: ResourceJson.Compiled.ICompiledResourceCollection,\n qualifiers: QualifierCollector\n ): Result<ConditionCollector> {\n const errors = new MessageAggregator();\n\n const conditionCollectorResult = ConditionCollector.create({ qualifiers });\n /* c8 ignore next 3 - defensive coding for ConditionCollector creation failure */\n if (conditionCollectorResult.isFailure()) {\n return conditionCollectorResult;\n }\n const conditionCollector = conditionCollectorResult.value;\n\n for (const [index, compiledCondition] of compiled.conditions.entries()) {\n const qualifierResult = qualifiers.getAt(compiledCondition.qualifierIndex);\n if (qualifierResult.isFailure()) {\n errors.addMessage(\n `Invalid qualifier index ${compiledCondition.qualifierIndex} at condition ${index}: ${qualifierResult.message}`\n );\n continue;\n }\n const qualifier = qualifierResult.value;\n\n /* c8 ignore next 1 - not really testable atm as \"matches\" is the only supported operator */\n const operator = compiledCondition.operator ?? 'matches'; // Default to 'matches' if not provided\n const conditionDecl = {\n qualifierName: qualifier.name,\n value: compiledCondition.value,\n operator,\n priority: compiledCondition.priority,\n scoreAsDefault: compiledCondition.scoreAsDefault\n };\n\n const conditionResult = conditionCollector.validating.add(conditionDecl);\n /* c8 ignore next 4 - defensive coding for condition addition failure */\n if (conditionResult.isFailure()) {\n errors.addMessage(`Failed to add condition at index ${index}: ${conditionResult.message}`);\n continue;\n }\n const condition = conditionResult.value;\n\n // Validate that the assigned index matches our expected index\n const expectedIndexResult = Convert.conditionIndex.convert(index);\n /* c8 ignore next 4 - defensive coding for invalid condition index conversion */\n if (expectedIndexResult.isFailure()) {\n errors.addMessage(`Invalid condition index ${index}: ${expectedIndexResult.message}`);\n continue;\n }\n const expectedIndex = expectedIndexResult.value;\n\n /* c8 ignore next 5 - defensive coding for condition index mismatch */\n if (condition.index !== expectedIndex) {\n errors.addMessage(\n `Index mismatch at condition ${index}: expected ${expectedIndex}, got ${condition.index}`\n );\n }\n }\n\n return errors.hasMessages ? fail(errors.toString()) : succeed(conditionCollector);\n }\n\n /**\n * Reconstructs a ConditionSetCollector from compiled data.\n * @param compiled - The compiled resource collection\n * @param conditions - The reconstructed ConditionCollector\n * @returns The reconstructed ConditionSetCollector\n * @internal\n */\n private _buildConditionSets(\n compiled: ResourceJson.Compiled.ICompiledResourceCollection,\n conditions: ConditionCollector\n ): Result<ConditionSetCollector> {\n const errors = new MessageAggregator();\n\n const conditionSetCollectorResult = ConditionSetCollector.create({ conditions });\n /* c8 ignore next 3 - defensive coding for ConditionSetCollector creation failure */\n if (conditionSetCollectorResult.isFailure()) {\n return conditionSetCollectorResult;\n }\n const conditionSetCollector = conditionSetCollectorResult.value;\n\n for (const [index, compiledConditionSet] of compiled.conditionSets.entries()) {\n const referencedConditionsResult = mapResults(\n compiledConditionSet.conditions.map((conditionIndex) => conditions.getAt(conditionIndex))\n );\n if (referencedConditionsResult.isFailure()) {\n errors.addMessage(\n `Failed to resolve conditions for condition set ${index}: ${referencedConditionsResult.message}`\n );\n continue;\n }\n const referencedConditions = referencedConditionsResult.value;\n\n const conditionSetResult = conditionSetCollector.validating.getOrAdd(referencedConditions);\n /* c8 ignore next 4 - defensive coding for condition set addition failure */\n if (conditionSetResult.isFailure()) {\n errors.addMessage(`Failed to add condition set at index ${index}: ${conditionSetResult.message}`);\n continue;\n }\n const conditionSet = conditionSetResult.value;\n\n // Validate that the assigned index matches our expected index\n const expectedIndexResult = Convert.conditionSetIndex.convert(index);\n /* c8 ignore next 4 - defensive coding for invalid condition set index conversion */\n if (expectedIndexResult.isFailure()) {\n errors.addMessage(`Invalid condition set index ${index}: ${expectedIndexResult.message}`);\n continue;\n }\n const expectedIndex = expectedIndexResult.value;\n\n /* c8 ignore next 5 - defensive coding for condition set index mismatch */\n if (conditionSet.index !== expectedIndex) {\n errors.addMessage(\n `Index mismatch at condition set ${index}: expected ${expectedIndex}, got ${conditionSet.index}`\n );\n }\n }\n\n return errors.hasMessages ? fail(errors.toString()) : succeed(conditionSetCollector);\n }\n\n /**\n * Reconstructs an AbstractDecisionCollector from compiled data.\n * @param compiled - The compiled resource collection\n * @param conditionSets - The reconstructed ConditionSetCollector\n * @returns The reconstructed AbstractDecisionCollector\n * @internal\n */\n private _buildDecisions(\n compiled: ResourceJson.Compiled.ICompiledResourceCollection,\n conditionSets: ConditionSetCollector\n ): Result<AbstractDecisionCollector> {\n const errors = new MessageAggregator();\n\n const decisionCollectorResult = AbstractDecisionCollector.create({ conditionSets });\n /* c8 ignore next 3 - defensive coding for AbstractDecisionCollector creation failure */\n if (decisionCollectorResult.isFailure()) {\n return decisionCollectorResult;\n }\n const decisionCollector = decisionCollectorResult.value;\n\n for (const [index, compiledDecision] of compiled.decisions.entries()) {\n const referencedConditionSetsResult = mapResults(\n compiledDecision.conditionSets.map((conditionSetIndex) => conditionSets.getAt(conditionSetIndex))\n );\n if (referencedConditionSetsResult.isFailure()) {\n errors.addMessage(\n `Failed to resolve condition sets for decision ${index}: ${referencedConditionSetsResult.message}`\n );\n continue;\n }\n const referencedConditionSets = referencedConditionSetsResult.value;\n\n const decisionResult = decisionCollector.validating.getOrAdd(referencedConditionSets);\n /* c8 ignore next 4 - defensive coding for decision addition failure */\n if (decisionResult.isFailure()) {\n errors.addMessage(`Failed to add decision at index ${index}: ${decisionResult.message}`);\n continue;\n }\n const decision = decisionResult.value;\n\n // Validate that the assigned index matches our expected index\n const expectedIndexResult = Convert.decisionIndex.convert(index);\n /* c8 ignore next 4 - defensive coding for invalid decision index conversion */\n if (expectedIndexResult.isFailure()) {\n errors.addMessage(`Invalid decision index ${index}: ${expectedIndexResult.message}`);\n continue;\n }\n const expectedIndex = expectedIndexResult.value;\n\n /* c8 ignore next 5 - defensive coding for decision index mismatch */\n if (decision.index !== expectedIndex) {\n errors.addMessage(\n `Index mismatch at decision ${index}: expected ${expectedIndex}, got ${decision.index}`\n );\n }\n }\n\n return errors.hasMessages ? fail(errors.toString()) : succeed(decisionCollector);\n }\n\n /**\n * Reconstructs a ValidatingResultMap of resources from compiled data.\n * @param compiled - The compiled resource collection\n * @param resourceTypes - The reconstructed ResourceTypeCollector\n * @param decisions - The reconstructed AbstractDecisionCollector\n * @returns The reconstructed ValidatingResultMap of resources\n * @internal\n */\n private _buildResources(\n compiled: ResourceJson.Compiled.ICompiledResourceCollection,\n resourceTypes: ResourceTypeCollector,\n decisions: AbstractDecisionCollector\n ): Result<ValidatingResultMap<ResourceId, IResource>> {\n const errors = new MessageAggregator();\n\n const resourceMap = new ValidatingResultMap<ResourceId, IResource>({\n converters: new Collections.KeyValueConverters<ResourceId, IResource>({\n key: Convert.resourceId,\n value: (from: unknown): Result<IResource> => {\n return Validate.resource.validate(from);\n }\n })\n });\n\n for (const compiledResource of compiled.resources) {\n const resourceTypeResult = resourceTypes.getAt(compiledResource.type);\n if (resourceTypeResult.isFailure()) {\n errors.addMessage(\n `Invalid resource type index ${compiledResource.type} for resource ${compiledResource.id}: ${resourceTypeResult.message}`\n );\n continue;\n }\n const resourceType = resourceTypeResult.value;\n\n const decisionResult = decisions.getAt(compiledResource.decision);\n if (decisionResult.isFailure()) {\n errors.addMessage(\n `Invalid decision index ${compiledResource.decision} for resource ${compiledResource.id}: ${decisionResult.message}`\n );\n continue;\n }\n const decision = decisionResult.value;\n\n // Build candidates from compiled data\n const candidateDeclsResult = mapResults(\n compiledResource.candidates.map((compiledCandidate) =>\n Converters.jsonObject.convert(compiledCandidate.json).onSuccess((json) => {\n return succeed({\n json,\n isPartial: compiledCandidate.isPartial,\n mergeMethod: compiledCandidate.mergeMethod\n });\n })\n )\n );\n if (candidateDeclsResult.isFailure()) {\n errors.addMessage(\n `Failed to convert candidate JSON for resource ${compiledResource.id}: ${candidateDeclsResult.message}`\n );\n continue;\n }\n const candidateDecls = candidateDeclsResult.value;\n\n // Create minimal candidates that implement IResourceCandidate\n const candidates: IResourceCandidate[] = candidateDecls.map((candidateDecl) => ({\n json: candidateDecl.json,\n isPartial: candidateDecl.isPartial,\n mergeMethod: candidateDecl.mergeMethod\n }));\n\n // Create a ConcreteDecision from the abstract decision and candidate values\n const candidatesWithConditionSets = decision.candidates.map((baseCandidate, idx) => ({\n conditionSet: baseCandidate.conditionSet,\n value: candidates[idx].json\n }));\n\n const concreteDecisionResult = ConcreteDecision.create({\n decisions,\n candidates: candidatesWithConditionSets\n });\n /* c8 ignore next 6 - defensive coding for ConcreteDecision creation failure */\n if (concreteDecisionResult.isFailure()) {\n errors.addMessage(\n `Failed to create concrete decision for resource ${compiledResource.id}: ${concreteDecisionResult.message}`\n );\n continue;\n }\n const concreteDecision = concreteDecisionResult.value;\n\n // Create minimal resource that implements IResource\n const resource: IResource = {\n id: compiledResource.id,\n resourceType,\n decision: concreteDecision,\n candidates\n };\n\n const setResult = resourceMap.set(compiledResource.id, resource);\n /* c8 ignore next 3 - defensive coding for resource map set failure */\n if (setResult.isFailure()) {\n errors.addMessage(`Failed to add resource ${compiledResource.id}: ${setResult.message}`);\n }\n }\n\n return errors.hasMessages ? fail(errors.toString()) : succeed(resourceMap);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"compiledResourceCollection.js","sourceRoot":"","sources":["../../../src/packlets/runtime/compiledResourceCollection.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4CASuB;AACvB,8CAKuB;AACvB,4CAA4F;AAC5F,8CAAmD;AACnD,sDAAwE;AACxE,wDAA2E;AAC3E,sCAAyD;AACzD,oDAA+C;AAE/C,4CAAgD;AAChD,qDAAuC;AAEvC,mDAAsF;AACtF,oDAA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AC,OAAO,EAAE,CAAC,CAAC;YAC3F,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,IAAA,eAAI,EAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,IAAA,kBAAO,EAAC,WAAW,CAAC,CAAC;IAC7E,CAAC;CACF;AAlhBD,gEAkhBC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport {\n captureResult,\n Collections,\n fail,\n mapResults,\n MessageAggregator,\n Result,\n succeed,\n ValidatingResultMap\n} from '@fgv/ts-utils';\nimport {\n ConditionCollector,\n ConditionSetCollector,\n ReadOnlyConditionCollector,\n ReadOnlyConditionSetCollector\n} from '../conditions';\nimport { AbstractDecisionCollector, ReadOnlyAbstractDecisionCollector } from '../decisions';\nimport { QualifierCollector } from '../qualifiers';\nimport { ResourceType, ResourceTypeCollector } from '../resource-types';\nimport { QualifierType, QualifierTypeCollector } from '../qualifier-types';\nimport { Convert, ResourceId, Helpers } from '../common';\nimport { Converters } from '@fgv/ts-json-base';\nimport { IResourceManager, IResource, IResourceCandidate } from './iResourceManager';\nimport { ConcreteDecision } from '../decisions';\nimport * as Validate from './validate';\nimport * as ResourceJson from '../resource-json';\nimport { ReadOnlyResourceTreeRoot, IReadOnlyResourceTreeRoot } from './resource-tree';\nimport * as Context from '../context';\n\n/**\n * Interface for parameters to create a {@link Runtime.CompiledResourceCollection | CompiledResourceCollection}.\n * @public\n */\nexport interface ICompiledResourceCollectionCreateParams {\n /**\n * The compiled resource collection data.\n */\n compiledCollection: ResourceJson.Compiled.ICompiledResourceCollection;\n /**\n * Map of qualifier type names to qualifier type objects.\n */\n qualifierTypes: Collections.IReadOnlyResultMap<string, QualifierType>;\n /**\n * Map of resource type names to resource type objects.\n */\n resourceTypes: Collections.IReadOnlyResultMap<string, ResourceType>;\n}\n\n/**\n * A compiled resource collection implements {@link Runtime.IResourceManager | IResourceManager}\n * by reconstructing runtime objects from compiled data. This provides an efficient way to load\n * and use pre-compiled resource collections without rebuilding them from scratch.\n * @public\n */\nexport class CompiledResourceCollection implements IResourceManager<IResource> {\n public readonly conditions: ReadOnlyConditionCollector;\n public readonly conditionSets: ReadOnlyConditionSetCollector;\n public readonly decisions: ReadOnlyAbstractDecisionCollector;\n\n private readonly _qualifierTypes: QualifierTypeCollector;\n private readonly _qualifiers: QualifierCollector;\n private readonly _resourceTypes: ResourceTypeCollector;\n private readonly _builtResources: ValidatingResultMap<ResourceId, IResource>;\n private _cachedResourceTree?: ReadOnlyResourceTreeRoot<IResource>;\n\n /**\n * A {@link QualifierTypes.QualifierTypeCollector | QualifierTypeCollector} which\n * contains the {@link QualifierTypes.QualifierType | qualifier types} used in this collection.\n */\n public get qualifierTypes(): QualifierTypeCollector {\n return this._qualifierTypes;\n }\n\n /**\n * A {@link Qualifiers.QualifierCollector | QualifierCollector} which\n * contains the {@link Qualifiers.Qualifier | qualifiers} used in this collection.\n */\n public get qualifiers(): QualifierCollector {\n return this._qualifiers;\n }\n\n /**\n * A {@link ResourceTypes.ResourceTypeCollector | ResourceTypeCollector} which\n * contains the {@link ResourceTypes.ResourceType | resource types} used in this collection.\n */\n public get resourceTypes(): ResourceTypeCollector {\n return this._resourceTypes;\n }\n\n /**\n * {@inheritdoc Runtime.IResourceManager.builtResources}\n */\n public get builtResources(): Collections.IReadOnlyValidatingResultMap<ResourceId, IResource> {\n return this._builtResources;\n }\n\n /**\n * {@inheritdoc Runtime.IResourceManager.numResources}\n */\n public get numResources(): number {\n return this._builtResources.size;\n }\n\n protected _numCandidates?: number;\n\n /**\n * {@inheritdoc Runtime.IResourceManager.numCandidates}\n */\n public get numCandidates(): number {\n if (this._numCandidates === undefined) {\n this._numCandidates = [...this._builtResources.values()].reduce(\n (acc, resource) => acc + resource.candidates.length,\n 0\n );\n }\n return this._numCandidates;\n }\n\n /**\n * Constructor for a {@link Runtime.CompiledResourceCollection | CompiledResourceCollection} object.\n * @param params - Parameters to create a new {@link Runtime.CompiledResourceCollection | CompiledResourceCollection}.\n * @internal\n */\n protected constructor(params: ICompiledResourceCollectionCreateParams) {\n // Reconstruct collectors from compiled data\n this._qualifierTypes = this._buildQualifierTypes(\n params.compiledCollection,\n params.qualifierTypes\n ).orThrow();\n this._qualifiers = this._buildQualifiers(params.compiledCollection, this._qualifierTypes).orThrow();\n this._resourceTypes = this._buildResourceTypes(params.compiledCollection, params.resourceTypes).orThrow();\n\n // Build collectors from compiled data\n const conditionCollector = this._buildConditions(params.compiledCollection, this._qualifiers).orThrow();\n const conditionSetCollector = this._buildConditionSets(\n params.compiledCollection,\n conditionCollector\n ).orThrow();\n const decisionCollector = this._buildDecisions(\n params.compiledCollection,\n conditionSetCollector\n ).orThrow();\n\n this.conditions = conditionCollector;\n this.conditionSets = conditionSetCollector;\n this.decisions = decisionCollector;\n\n // Build resources from compiled data\n this._builtResources = this._buildResources(\n params.compiledCollection,\n this._resourceTypes,\n decisionCollector\n ).orThrow();\n }\n\n /**\n * Creates a new {@link Runtime.CompiledResourceCollection | CompiledResourceCollection} object.\n * @param params - Parameters to create a new {@link Runtime.CompiledResourceCollection | CompiledResourceCollection}.\n * @returns `Success` with the new {@link Runtime.CompiledResourceCollection | CompiledResourceCollection} object if successful,\n * or `Failure` with an error message if not.\n * @public\n */\n public static create(params: ICompiledResourceCollectionCreateParams): Result<CompiledResourceCollection> {\n return captureResult(() => new CompiledResourceCollection(params));\n }\n\n /**\n * {@inheritdoc Runtime.IResourceManager.getBuiltResource}\n */\n public getBuiltResource(id: string): Result<IResource> {\n return this._builtResources.validating.get(id);\n }\n\n /**\n * {@inheritdoc Runtime.IResourceManager.validateContext}\n */\n public validateContext(context: Context.IContextDecl): Result<Context.IValidatedContextDecl> {\n return Context.Convert.validatedContextDecl.convert(context, {\n qualifiers: this._qualifiers\n });\n }\n\n /**\n * Gets a resource tree built from the resources in this collection.\n * The tree provides hierarchical access to resources based on their ResourceId structure.\n * For example, resources with IDs like \"app.messages.welcome\" create a tree structure\n * where \"app\" and \"messages\" are branch nodes, and \"welcome\" is a leaf containing the resource.\n *\n * String-based validation is available through the `children.validating` property,\n * allowing callers to use `tree.children.validating.getById(stringId)` for validated access.\n *\n * Uses lazy initialization with caching for performance.\n * @returns Result containing the resource tree root, or failure if tree construction fails\n * @public\n */\n public getBuiltResourceTree(): Result<IReadOnlyResourceTreeRoot<IResource>> {\n if (this._cachedResourceTree) {\n return succeed(this._cachedResourceTree);\n }\n\n // Convert all built resources to [ResourceId, IResource] pairs\n const resources: [ResourceId, IResource][] = [];\n for (const [id, resource] of this._builtResources.entries()) {\n resources.push([id, resource]);\n }\n\n // Create the resource tree with lazy initialization\n return ReadOnlyResourceTreeRoot.create(resources).onSuccess((tree) => {\n this._cachedResourceTree = tree;\n return succeed(tree);\n });\n }\n\n /**\n * Reconstructs a QualifierTypeCollector from compiled data.\n * @param compiled - The compiled resource collection\n * @param qualifierTypes - Map of qualifier type names to qualifier type objects\n * @returns The reconstructed QualifierTypeCollector\n * @internal\n */\n private _buildQualifierTypes(\n compiled: ResourceJson.Compiled.ICompiledResourceCollection,\n qualifierTypes: Collections.IReadOnlyResultMap<string, QualifierType>\n ): Result<QualifierTypeCollector> {\n return mapResults(\n compiled.qualifierTypes.map((compiledQualifierType) => qualifierTypes.get(compiledQualifierType.name))\n ).onSuccess((referencedQualifierTypes) => {\n return QualifierTypeCollector.create({\n qualifierTypes: referencedQualifierTypes\n });\n });\n }\n\n /**\n * Reconstructs a QualifierCollector from compiled data.\n * @param compiled - The compiled resource collection\n * @param qualifierTypes - The reconstructed QualifierTypeCollector\n * @returns The reconstructed QualifierCollector\n * @internal\n */\n private _buildQualifiers(\n compiled: ResourceJson.Compiled.ICompiledResourceCollection,\n qualifierTypes: QualifierTypeCollector\n ): Result<QualifierCollector> {\n return mapResults(\n compiled.qualifiers.map((compiledQualifier) => {\n return qualifierTypes.getAt(compiledQualifier.type).onSuccess((qualifierType) => {\n return succeed({\n name: compiledQualifier.name,\n typeName: qualifierType.name,\n defaultPriority: compiledQualifier.defaultPriority\n });\n });\n })\n ).onSuccess((qualifierDecls) => {\n return QualifierCollector.create({\n qualifierTypes,\n qualifiers: qualifierDecls\n });\n });\n }\n\n /**\n * Reconstructs a ResourceTypeCollector from compiled data.\n * @param compiled - The compiled resource collection\n * @param resourceTypes - Map of resource type names to resource type objects\n * @returns The reconstructed ResourceTypeCollector\n * @internal\n */\n private _buildResourceTypes(\n compiled: ResourceJson.Compiled.ICompiledResourceCollection,\n resourceTypes: Collections.IReadOnlyResultMap<string, ResourceType>\n ): Result<ResourceTypeCollector> {\n return mapResults(\n compiled.resourceTypes.map((compiledResourceType) => resourceTypes.get(compiledResourceType.name))\n ).onSuccess((referencedResourceTypes) => {\n return ResourceTypeCollector.create({\n resourceTypes: referencedResourceTypes\n });\n });\n }\n\n /**\n * Reconstructs a ConditionCollector from compiled data.\n * @param compiled - The compiled resource collection\n * @param qualifiers - The reconstructed QualifierCollector\n * @returns The reconstructed ConditionCollector\n * @internal\n */\n private _buildConditions(\n compiled: ResourceJson.Compiled.ICompiledResourceCollection,\n qualifiers: QualifierCollector\n ): Result<ConditionCollector> {\n const errors = new MessageAggregator();\n\n const conditionCollectorResult = ConditionCollector.create({ qualifiers });\n /* c8 ignore next 3 - defensive coding for ConditionCollector creation failure */\n if (conditionCollectorResult.isFailure()) {\n return conditionCollectorResult;\n }\n const conditionCollector = conditionCollectorResult.value;\n\n for (const [index, compiledCondition] of compiled.conditions.entries()) {\n const qualifierResult = qualifiers.getAt(compiledCondition.qualifierIndex);\n if (qualifierResult.isFailure()) {\n errors.addMessage(\n `Invalid qualifier index ${compiledCondition.qualifierIndex} at condition ${index}: ${qualifierResult.message}`\n );\n continue;\n }\n const qualifier = qualifierResult.value;\n\n /* c8 ignore next 1 - not really testable atm as \"matches\" is the only supported operator */\n const operator = compiledCondition.operator ?? 'matches'; // Default to 'matches' if not provided\n const conditionDecl = {\n qualifierName: qualifier.name,\n value: compiledCondition.value,\n operator,\n priority: compiledCondition.priority,\n scoreAsDefault: compiledCondition.scoreAsDefault\n };\n\n const conditionResult = conditionCollector.validating.add(conditionDecl);\n /* c8 ignore next 4 - defensive coding for condition addition failure */\n if (conditionResult.isFailure()) {\n errors.addMessage(`Failed to add condition at index ${index}: ${conditionResult.message}`);\n continue;\n }\n const condition = conditionResult.value;\n\n // Validate that the assigned index matches our expected index\n const expectedIndexResult = Convert.conditionIndex.convert(index);\n /* c8 ignore next 4 - defensive coding for invalid condition index conversion */\n if (expectedIndexResult.isFailure()) {\n errors.addMessage(`Invalid condition index ${index}: ${expectedIndexResult.message}`);\n continue;\n }\n const expectedIndex = expectedIndexResult.value;\n\n /* c8 ignore next 5 - defensive coding for condition index mismatch */\n if (condition.index !== expectedIndex) {\n errors.addMessage(\n `Index mismatch at condition ${index}: expected ${expectedIndex}, got ${condition.index}`\n );\n }\n }\n\n return errors.hasMessages ? fail(errors.toString()) : succeed(conditionCollector);\n }\n\n /**\n * Reconstructs a ConditionSetCollector from compiled data.\n * @param compiled - The compiled resource collection\n * @param conditions - The reconstructed ConditionCollector\n * @returns The reconstructed ConditionSetCollector\n * @internal\n */\n private _buildConditionSets(\n compiled: ResourceJson.Compiled.ICompiledResourceCollection,\n conditions: ConditionCollector\n ): Result<ConditionSetCollector> {\n const errors = new MessageAggregator();\n\n const conditionSetCollectorResult = ConditionSetCollector.create({ conditions });\n /* c8 ignore next 3 - defensive coding for ConditionSetCollector creation failure */\n if (conditionSetCollectorResult.isFailure()) {\n return conditionSetCollectorResult;\n }\n const conditionSetCollector = conditionSetCollectorResult.value;\n\n for (const [index, compiledConditionSet] of compiled.conditionSets.entries()) {\n const referencedConditionsResult = mapResults(\n compiledConditionSet.conditions.map((conditionIndex) => conditions.getAt(conditionIndex))\n );\n if (referencedConditionsResult.isFailure()) {\n errors.addMessage(\n `Failed to resolve conditions for condition set ${index}: ${referencedConditionsResult.message}`\n );\n continue;\n }\n const referencedConditions = referencedConditionsResult.value;\n\n const conditionSetResult = conditionSetCollector.validating.getOrAdd(referencedConditions);\n /* c8 ignore next 4 - defensive coding for condition set addition failure */\n if (conditionSetResult.isFailure()) {\n errors.addMessage(`Failed to add condition set at index ${index}: ${conditionSetResult.message}`);\n continue;\n }\n const conditionSet = conditionSetResult.value;\n\n // Validate that the assigned index matches our expected index\n const expectedIndexResult = Convert.conditionSetIndex.convert(index);\n /* c8 ignore next 4 - defensive coding for invalid condition set index conversion */\n if (expectedIndexResult.isFailure()) {\n errors.addMessage(`Invalid condition set index ${index}: ${expectedIndexResult.message}`);\n continue;\n }\n const expectedIndex = expectedIndexResult.value;\n\n /* c8 ignore next 5 - defensive coding for condition set index mismatch */\n if (conditionSet.index !== expectedIndex) {\n errors.addMessage(\n `Index mismatch at condition set ${index}: expected ${expectedIndex}, got ${conditionSet.index}`\n );\n }\n }\n\n return errors.hasMessages ? fail(errors.toString()) : succeed(conditionSetCollector);\n }\n\n /**\n * Reconstructs an AbstractDecisionCollector from compiled data.\n * @param compiled - The compiled resource collection\n * @param conditionSets - The reconstructed ConditionSetCollector\n * @returns The reconstructed AbstractDecisionCollector\n * @internal\n */\n private _buildDecisions(\n compiled: ResourceJson.Compiled.ICompiledResourceCollection,\n conditionSets: ConditionSetCollector\n ): Result<AbstractDecisionCollector> {\n const errors = new MessageAggregator();\n\n const decisionCollectorResult = AbstractDecisionCollector.create({ conditionSets });\n /* c8 ignore next 3 - defensive coding for AbstractDecisionCollector creation failure */\n if (decisionCollectorResult.isFailure()) {\n return decisionCollectorResult;\n }\n const decisionCollector = decisionCollectorResult.value;\n\n for (const [index, compiledDecision] of compiled.decisions.entries()) {\n const referencedConditionSetsResult = mapResults(\n compiledDecision.conditionSets.map((conditionSetIndex) => conditionSets.getAt(conditionSetIndex))\n );\n if (referencedConditionSetsResult.isFailure()) {\n errors.addMessage(\n `Failed to resolve condition sets for decision ${index}: ${referencedConditionSetsResult.message}`\n );\n continue;\n }\n const referencedConditionSets = referencedConditionSetsResult.value;\n\n const decisionResult = decisionCollector.validating.getOrAdd(referencedConditionSets);\n /* c8 ignore next 4 - defensive coding for decision addition failure */\n if (decisionResult.isFailure()) {\n errors.addMessage(`Failed to add decision at index ${index}: ${decisionResult.message}`);\n continue;\n }\n const decision = decisionResult.value;\n\n // Validate that the assigned index matches our expected index\n const expectedIndexResult = Convert.decisionIndex.convert(index);\n /* c8 ignore next 4 - defensive coding for invalid decision index conversion */\n if (expectedIndexResult.isFailure()) {\n errors.addMessage(`Invalid decision index ${index}: ${expectedIndexResult.message}`);\n continue;\n }\n const expectedIndex = expectedIndexResult.value;\n\n /* c8 ignore next 5 - defensive coding for decision index mismatch */\n if (decision.index !== expectedIndex) {\n errors.addMessage(\n `Index mismatch at decision ${index}: expected ${expectedIndex}, got ${decision.index}`\n );\n }\n }\n\n return errors.hasMessages ? fail(errors.toString()) : succeed(decisionCollector);\n }\n\n /**\n * Reconstructs a ValidatingResultMap of resources from compiled data.\n * @param compiled - The compiled resource collection\n * @param resourceTypes - The reconstructed ResourceTypeCollector\n * @param decisions - The reconstructed AbstractDecisionCollector\n * @returns The reconstructed ValidatingResultMap of resources\n * @internal\n */\n private _buildResources(\n compiled: ResourceJson.Compiled.ICompiledResourceCollection,\n resourceTypes: ResourceTypeCollector,\n decisions: AbstractDecisionCollector\n ): Result<ValidatingResultMap<ResourceId, IResource>> {\n const errors = new MessageAggregator();\n\n const resourceMap = new ValidatingResultMap<ResourceId, IResource>({\n converters: new Collections.KeyValueConverters<ResourceId, IResource>({\n key: Convert.resourceId,\n value: (from: unknown): Result<IResource> => {\n return Validate.resource.validate(from);\n }\n })\n });\n\n for (const compiledResource of compiled.resources) {\n const resourceTypeResult = resourceTypes.getAt(compiledResource.type);\n if (resourceTypeResult.isFailure()) {\n errors.addMessage(\n `Invalid resource type index ${compiledResource.type} for resource ${compiledResource.id}: ${resourceTypeResult.message}`\n );\n continue;\n }\n const resourceType = resourceTypeResult.value;\n\n const decisionResult = decisions.getAt(compiledResource.decision);\n if (decisionResult.isFailure()) {\n errors.addMessage(\n `Invalid decision index ${compiledResource.decision} for resource ${compiledResource.id}: ${decisionResult.message}`\n );\n continue;\n }\n const decision = decisionResult.value;\n\n // Build candidates from compiled data\n const candidateDeclsResult = mapResults(\n compiledResource.candidates.map((compiledCandidate) =>\n Converters.jsonObject.convert(compiledCandidate.json).onSuccess((json) => {\n return succeed({\n json,\n isPartial: compiledCandidate.isPartial,\n mergeMethod: compiledCandidate.mergeMethod\n });\n })\n )\n );\n if (candidateDeclsResult.isFailure()) {\n errors.addMessage(\n `Failed to convert candidate JSON for resource ${compiledResource.id}: ${candidateDeclsResult.message}`\n );\n continue;\n }\n const candidateDecls = candidateDeclsResult.value;\n\n // Create minimal candidates that implement IResourceCandidate\n const candidates: IResourceCandidate[] = candidateDecls.map((candidateDecl) => ({\n json: candidateDecl.json,\n isPartial: candidateDecl.isPartial,\n mergeMethod: candidateDecl.mergeMethod\n }));\n\n // Create a ConcreteDecision from the abstract decision and candidate values\n const candidatesWithConditionSets = decision.candidates.map((baseCandidate, idx) => ({\n conditionSet: baseCandidate.conditionSet,\n value: candidates[idx].json\n }));\n\n const concreteDecisionResult = ConcreteDecision.create({\n decisions,\n candidates: candidatesWithConditionSets\n });\n /* c8 ignore next 6 - defensive coding for ConcreteDecision creation failure */\n if (concreteDecisionResult.isFailure()) {\n errors.addMessage(\n `Failed to create concrete decision for resource ${compiledResource.id}: ${concreteDecisionResult.message}`\n );\n continue;\n }\n const concreteDecision = concreteDecisionResult.value;\n\n const { value: name, message: nameError } = Helpers.getNameForResourceId(compiledResource.id);\n /* c8 ignore next 4 - defense in depth nearly impossible to reproduce */\n if (nameError !== undefined) {\n errors.addMessage(`Failed to get name for resource ${compiledResource.id}: ${nameError}`);\n continue;\n }\n\n // Create minimal resource that implements IResource\n const resource: IResource = {\n id: compiledResource.id,\n name,\n resourceType,\n decision: concreteDecision,\n candidates\n };\n\n const setResult = resourceMap.set(compiledResource.id, resource);\n /* c8 ignore next 3 - defensive coding for resource map set failure */\n if (setResult.isFailure()) {\n errors.addMessage(`Failed to add resource ${compiledResource.id}: ${setResult.message}`);\n }\n }\n\n return errors.hasMessages ? fail(errors.toString()) : succeed(resourceMap);\n }\n}\n"]}
|
|
@@ -31,6 +31,8 @@ export interface IResourceCandidate {
|
|
|
31
31
|
export interface IResource {
|
|
32
32
|
/** The resource identifier */
|
|
33
33
|
readonly id: string;
|
|
34
|
+
/** The resource name */
|
|
35
|
+
readonly name: string;
|
|
34
36
|
/** The resource type */
|
|
35
37
|
readonly resourceType: ResourceType;
|
|
36
38
|
/** The decision used to select candidates */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iResourceManager.d.ts","sourceRoot":"","sources":["../../../src/packlets/runtime/iResourceManager.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,0BAA0B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EAAE,EAAE,MAAM,CAAC;IACpB,wBAAwB;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,wBAAwB;IACxB,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC,6CAA6C;IAC7C,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC,iDAAiD;IACjD,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC,kBAAkB,CAAC,CAAC;CACxD;AAED;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB,CAAC,EAAE,SAAS,SAAS,GAAG,SAAS;IAChE;;;OAGG;IACH,QAAQ,CAAC,UAAU,EAAE,0BAA0B,CAAC;IAEhD;;;OAGG;IACH,QAAQ,CAAC,aAAa,EAAE,6BAA6B,CAAC;IAEtD;;;OAGG;IACH,QAAQ,CAAC,SAAS,EAAE,iCAAiC,CAAC;IAEtD;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC;IAEzC;;;OAGG;IACH,oBAAoB,IAAI,MAAM,CAAC,yBAAyB,CAAC,EAAE,CAAC,CAAC,CAAC;IAE9D;;;OAGG;IACH,QAAQ,CAAC,cAAc,EAAE,WAAW,CAAC,4BAA4B,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IAElF;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAE9B;;OAEG;IACH,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAE/B;;;;OAIG;IACH,eAAe,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAC;CACvE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iResourceManager.js","sourceRoot":"","sources":["../../../src/packlets/runtime/iResourceManager.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Result, Collections } from '@fgv/ts-utils';\nimport { JsonObject } from '@fgv/ts-json-base';\nimport { ReadOnlyConditionCollector, ReadOnlyConditionSetCollector } from '../conditions';\nimport { ReadOnlyAbstractDecisionCollector, ConcreteDecision } from '../decisions';\nimport { ResourceId, ResourceValueMergeMethod } from '../common';\nimport { ResourceType } from '../resource-types';\nimport { IContextDecl, IValidatedContextDecl } from '../context';\nimport { IReadOnlyResourceTreeRoot } from './resource-tree';\n\n/**\n * Runtime representation of a resource candidate with the minimal data needed for resolution.\n * @public\n */\nexport interface IResourceCandidate {\n /** The JSON value for this candidate */\n readonly json: JsonObject;\n\n /**\n * Indicates if this candidate is a partial resource.\n */\n readonly isPartial: boolean;\n\n /**\n * Specifies the resource type of this candidate.\n */\n readonly mergeMethod: ResourceValueMergeMethod;\n}\n\n/**\n * Interface for a resource that can be used in the runtime layer.\n * This provides the minimal properties needed from a resource without requiring\n * the full Resources layer dependencies.\n * @public\n */\nexport interface IResource {\n /** The resource identifier */\n readonly id: string;\n /** The resource type */\n readonly resourceType: ResourceType;\n /** The decision used to select candidates */\n readonly decision: ConcreteDecision;\n /** The available candidates for this resource */\n readonly candidates: ReadonlyArray<IResourceCandidate>;\n}\n\n/**\n * Interface defining the read-only properties that the runtime resource resolver needs\n * from a resource manager. This abstraction allows the runtime to work with different\n * implementations without requiring the full ResourceManagerBuilder build mechanics.\n * @public\n */\nexport interface IResourceManager<TR extends IResource = IResource> {\n /**\n * A {@link Conditions.ReadOnlyConditionCollector | ReadOnlyConditionCollector} which\n * contains the {@link Conditions.Condition | conditions} used by resource candidates.\n */\n readonly conditions: ReadOnlyConditionCollector;\n\n /**\n * A {@link Conditions.ReadOnlyConditionSetCollector | ReadOnlyConditionSetCollector} which\n * contains the {@link Conditions.ConditionSet | condition sets} used by resource candidates.\n */\n readonly conditionSets: ReadOnlyConditionSetCollector;\n\n /**\n * A {@link Decisions.ReadOnlyAbstractDecisionCollector | ReadOnlyAbstractDecisionCollector} which\n * contains the {@link Decisions.Decision | abstract decisions} used by resource candidates.\n */\n readonly decisions: ReadOnlyAbstractDecisionCollector;\n\n /**\n * Gets a built resource by ID for runtime resolution.\n * @param id - The resource identifier\n * @returns Success with the runtime resource if found, Failure otherwise\n */\n getBuiltResource(id: string): Result<TR>;\n\n /**\n * Gets a resource tree built from the resources in this resource manager.\n * @returns Result containing the resource tree root, or failure if tree construction fails\n */\n getBuiltResourceTree(): Result<IReadOnlyResourceTreeRoot<TR>>;\n\n /**\n * A read-only result map of all built resources, keyed by resource ID.\n * Resources are built on-demand when accessed and returns Results for error handling.\n */\n readonly builtResources: Collections.IReadOnlyValidatingResultMap<ResourceId, TR>;\n\n /**\n * The number of resources in this resource manager.\n */\n readonly numResources: number;\n\n /**\n * The number of candidates in this resource manager.\n */\n readonly numCandidates: number;\n\n /**\n * Validates a context declaration against the qualifiers managed by this resource manager.\n * @param context - The context declaration to validate\n * @returns Success with the validated context if successful, Failure otherwise\n */\n validateContext(context: IContextDecl): Result<IValidatedContextDecl>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"iResourceManager.js","sourceRoot":"","sources":["../../../src/packlets/runtime/iResourceManager.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Result, Collections } from '@fgv/ts-utils';\nimport { JsonObject } from '@fgv/ts-json-base';\nimport { ReadOnlyConditionCollector, ReadOnlyConditionSetCollector } from '../conditions';\nimport { ReadOnlyAbstractDecisionCollector, ConcreteDecision } from '../decisions';\nimport { ResourceId, ResourceValueMergeMethod } from '../common';\nimport { ResourceType } from '../resource-types';\nimport { IContextDecl, IValidatedContextDecl } from '../context';\nimport { IReadOnlyResourceTreeRoot } from './resource-tree';\n\n/**\n * Runtime representation of a resource candidate with the minimal data needed for resolution.\n * @public\n */\nexport interface IResourceCandidate {\n /** The JSON value for this candidate */\n readonly json: JsonObject;\n\n /**\n * Indicates if this candidate is a partial resource.\n */\n readonly isPartial: boolean;\n\n /**\n * Specifies the resource type of this candidate.\n */\n readonly mergeMethod: ResourceValueMergeMethod;\n}\n\n/**\n * Interface for a resource that can be used in the runtime layer.\n * This provides the minimal properties needed from a resource without requiring\n * the full Resources layer dependencies.\n * @public\n */\nexport interface IResource {\n /** The resource identifier */\n readonly id: string;\n /** The resource name */\n readonly name: string;\n /** The resource type */\n readonly resourceType: ResourceType;\n /** The decision used to select candidates */\n readonly decision: ConcreteDecision;\n /** The available candidates for this resource */\n readonly candidates: ReadonlyArray<IResourceCandidate>;\n}\n\n/**\n * Interface defining the read-only properties that the runtime resource resolver needs\n * from a resource manager. This abstraction allows the runtime to work with different\n * implementations without requiring the full ResourceManagerBuilder build mechanics.\n * @public\n */\nexport interface IResourceManager<TR extends IResource = IResource> {\n /**\n * A {@link Conditions.ReadOnlyConditionCollector | ReadOnlyConditionCollector} which\n * contains the {@link Conditions.Condition | conditions} used by resource candidates.\n */\n readonly conditions: ReadOnlyConditionCollector;\n\n /**\n * A {@link Conditions.ReadOnlyConditionSetCollector | ReadOnlyConditionSetCollector} which\n * contains the {@link Conditions.ConditionSet | condition sets} used by resource candidates.\n */\n readonly conditionSets: ReadOnlyConditionSetCollector;\n\n /**\n * A {@link Decisions.ReadOnlyAbstractDecisionCollector | ReadOnlyAbstractDecisionCollector} which\n * contains the {@link Decisions.Decision | abstract decisions} used by resource candidates.\n */\n readonly decisions: ReadOnlyAbstractDecisionCollector;\n\n /**\n * Gets a built resource by ID for runtime resolution.\n * @param id - The resource identifier\n * @returns Success with the runtime resource if found, Failure otherwise\n */\n getBuiltResource(id: string): Result<TR>;\n\n /**\n * Gets a resource tree built from the resources in this resource manager.\n * @returns Result containing the resource tree root, or failure if tree construction fails\n */\n getBuiltResourceTree(): Result<IReadOnlyResourceTreeRoot<TR>>;\n\n /**\n * A read-only result map of all built resources, keyed by resource ID.\n * Resources are built on-demand when accessed and returns Results for error handling.\n */\n readonly builtResources: Collections.IReadOnlyValidatingResultMap<ResourceId, TR>;\n\n /**\n * The number of resources in this resource manager.\n */\n readonly numResources: number;\n\n /**\n * The number of candidates in this resource manager.\n */\n readonly numCandidates: number;\n\n /**\n * Validates a context declaration against the qualifiers managed by this resource manager.\n * @param context - The context declaration to validate\n * @returns Success with the validated context if successful, Failure otherwise\n */\n validateContext(context: IContextDecl): Result<IValidatedContextDecl>;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../src/packlets/runtime/validate.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAc,SAAS,EAAE,MAAM,eAAe,CAAC;AAKtD,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAEnE;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,SAAS,CAAC,kBAAkB,EAAE,OAAO,CAQjE,CAAC;AAEL;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,SAAS,CAAC,SAAS,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../src/packlets/runtime/validate.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAc,SAAS,EAAE,MAAM,eAAe,CAAC;AAKtD,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAEnE;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,SAAS,CAAC,kBAAkB,EAAE,OAAO,CAQjE,CAAC;AAEL;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,SAAS,CAAC,SAAS,EAAE,OAAO,CAejD,CAAC"}
|
|
@@ -42,6 +42,7 @@ exports.resourceCandidate = ts_utils_1.Validators.object({
|
|
|
42
42
|
*/
|
|
43
43
|
exports.resource = ts_utils_1.Validators.object({
|
|
44
44
|
id: ts_utils_1.Validators.isA('ResourceId', (v) => typeof v === 'string' && common_1.Validate.isValidResourceId(v)),
|
|
45
|
+
name: ts_utils_1.Validators.isA('ResourceName', (v) => typeof v === 'string' && common_1.Validate.isValidResourceName(v)),
|
|
45
46
|
resourceType: ts_utils_1.Validators.isA('ResourceType instance', (v) => v instanceof resource_types_1.ResourceType),
|
|
46
47
|
decision: ts_utils_1.Validators.isA('ConcreteDecision instance', (v) => v instanceof decisions_1.ConcreteDecision),
|
|
47
48
|
candidates: ts_utils_1.Validators.arrayOf(exports.resourceCandidate)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../src/packlets/runtime/validate.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,4CAAsD;AACtD,oDAAiE;AACjE,sCAAiD;AACjD,sDAAiD;AACjD,4CAAgD;AAGhD;;;GAGG;AACU,QAAA,iBAAiB,GAC5B,qBAAU,CAAC,MAAM,CAAqB;IACpC,IAAI,EAAE,yBAAc,CAAC,UAAU;IAC/B,SAAS,EAAE,qBAAU,CAAC,OAAO;IAC7B,WAAW,EAAE,qBAAU,CAAC,GAAG,CACzB,6BAA6B,EAC7B,CAAC,CAAC,EAAyC,EAAE,CAAC,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,SAAS,CACnG;CACF,CAAC,CAAC;AAEL;;;GAGG;AACU,QAAA,QAAQ,GAAkC,qBAAU,CAAC,MAAM,CAAY;IAClF,EAAE,EAAE,qBAAU,CAAC,GAAG,CAChB,YAAY,EACZ,CAAC,CAAC,EAAmB,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,iBAAQ,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAC/E;IACD,YAAY,EAAE,qBAAU,CAAC,GAAG,CAAC,uBAAuB,EAAE,CAAC,CAAC,EAAqB,EAAE,CAAC,CAAC,YAAY,6BAAY,CAAC;IAC1G,QAAQ,EAAE,qBAAU,CAAC,GAAG,CACtB,2BAA2B,EAC3B,CAAC,CAAC,EAAyB,EAAE,CAAC,CAAC,YAAY,4BAAgB,CAC5D;IACD,UAAU,EAAE,qBAAU,CAAC,OAAO,CAAC,yBAAiB,CAAC;CAClD,CAAC,CAAC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Validators, Validator } from '@fgv/ts-utils';\nimport { Validators as JsonValidators } from '@fgv/ts-json-base';\nimport { Validate, ResourceId } from '../common';\nimport { ResourceType } from '../resource-types';\nimport { ConcreteDecision } from '../decisions';\nimport { IResource, IResourceCandidate } from './iResourceManager';\n\n/**\n * Validates an {@link Runtime.IResourceCandidate | IResourceCandidate} object.\n * @public\n */\nexport const resourceCandidate: Validator<IResourceCandidate, unknown> =\n Validators.object<IResourceCandidate>({\n json: JsonValidators.jsonObject,\n isPartial: Validators.boolean,\n mergeMethod: Validators.isA(\n 'resource value merge method',\n (v): v is 'augment' | 'delete' | 'replace' => v === 'augment' || v === 'delete' || v === 'replace'\n )\n });\n\n/**\n * Validates an {@link Runtime.IResource | IResource} object.\n * @public\n */\nexport const resource: Validator<IResource, unknown> = Validators.object<IResource>({\n id: Validators.isA(\n 'ResourceId',\n (v): v is ResourceId => typeof v === 'string' && Validate.isValidResourceId(v)\n ),\n resourceType: Validators.isA('ResourceType instance', (v): v is ResourceType => v instanceof ResourceType),\n decision: Validators.isA(\n 'ConcreteDecision instance',\n (v): v is ConcreteDecision => v instanceof ConcreteDecision\n ),\n candidates: Validators.arrayOf(resourceCandidate)\n});\n"]}
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../src/packlets/runtime/validate.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,4CAAsD;AACtD,oDAAiE;AACjE,sCAAiD;AACjD,sDAAiD;AACjD,4CAAgD;AAGhD;;;GAGG;AACU,QAAA,iBAAiB,GAC5B,qBAAU,CAAC,MAAM,CAAqB;IACpC,IAAI,EAAE,yBAAc,CAAC,UAAU;IAC/B,SAAS,EAAE,qBAAU,CAAC,OAAO;IAC7B,WAAW,EAAE,qBAAU,CAAC,GAAG,CACzB,6BAA6B,EAC7B,CAAC,CAAC,EAAyC,EAAE,CAAC,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,SAAS,CACnG;CACF,CAAC,CAAC;AAEL;;;GAGG;AACU,QAAA,QAAQ,GAAkC,qBAAU,CAAC,MAAM,CAAY;IAClF,EAAE,EAAE,qBAAU,CAAC,GAAG,CAChB,YAAY,EACZ,CAAC,CAAC,EAAmB,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,iBAAQ,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAC/E;IACD,IAAI,EAAE,qBAAU,CAAC,GAAG,CAClB,cAAc,EACd,CAAC,CAAC,EAAe,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,iBAAQ,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAC7E;IACD,YAAY,EAAE,qBAAU,CAAC,GAAG,CAAC,uBAAuB,EAAE,CAAC,CAAC,EAAqB,EAAE,CAAC,CAAC,YAAY,6BAAY,CAAC;IAC1G,QAAQ,EAAE,qBAAU,CAAC,GAAG,CACtB,2BAA2B,EAC3B,CAAC,CAAC,EAAyB,EAAE,CAAC,CAAC,YAAY,4BAAgB,CAC5D;IACD,UAAU,EAAE,qBAAU,CAAC,OAAO,CAAC,yBAAiB,CAAC;CAClD,CAAC,CAAC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Validators, Validator } from '@fgv/ts-utils';\nimport { Validators as JsonValidators } from '@fgv/ts-json-base';\nimport { Validate, ResourceId } from '../common';\nimport { ResourceType } from '../resource-types';\nimport { ConcreteDecision } from '../decisions';\nimport { IResource, IResourceCandidate } from './iResourceManager';\n\n/**\n * Validates an {@link Runtime.IResourceCandidate | IResourceCandidate} object.\n * @public\n */\nexport const resourceCandidate: Validator<IResourceCandidate, unknown> =\n Validators.object<IResourceCandidate>({\n json: JsonValidators.jsonObject,\n isPartial: Validators.boolean,\n mergeMethod: Validators.isA(\n 'resource value merge method',\n (v): v is 'augment' | 'delete' | 'replace' => v === 'augment' || v === 'delete' || v === 'replace'\n )\n });\n\n/**\n * Validates an {@link Runtime.IResource | IResource} object.\n * @public\n */\nexport const resource: Validator<IResource, unknown> = Validators.object<IResource>({\n id: Validators.isA(\n 'ResourceId',\n (v): v is ResourceId => typeof v === 'string' && Validate.isValidResourceId(v)\n ),\n name: Validators.isA(\n 'ResourceName',\n (v): v is string => typeof v === 'string' && Validate.isValidResourceName(v)\n ),\n resourceType: Validators.isA('ResourceType instance', (v): v is ResourceType => v instanceof ResourceType),\n decision: Validators.isA(\n 'ConcreteDecision instance',\n (v): v is ConcreteDecision => v instanceof ConcreteDecision\n ),\n candidates: Validators.arrayOf(resourceCandidate)\n});\n"]}
|
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-11",
|
|
4
4
|
"description": "Multi-dimensional Resource Runtime",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "dist/ts-res.d.ts",
|
|
@@ -44,22 +44,22 @@
|
|
|
44
44
|
"@rushstack/heft-node-rig": "~2.9.0",
|
|
45
45
|
"@types/heft-jest": "1.0.6",
|
|
46
46
|
"eslint-plugin-tsdoc": "~0.4.0",
|
|
47
|
-
"@fgv/ts-utils": "5.0.0-
|
|
48
|
-
"@fgv/ts-extras": "5.0.0-
|
|
49
|
-
"@fgv/ts-utils
|
|
50
|
-
"@fgv/ts-
|
|
51
|
-
"@fgv/ts-
|
|
52
|
-
"@fgv/ts-json": "5.0.0-
|
|
47
|
+
"@fgv/ts-utils-jest": "5.0.0-11",
|
|
48
|
+
"@fgv/ts-extras": "5.0.0-11",
|
|
49
|
+
"@fgv/ts-utils": "5.0.0-11",
|
|
50
|
+
"@fgv/ts-bcp47": "5.0.0-11",
|
|
51
|
+
"@fgv/ts-json": "5.0.0-11",
|
|
52
|
+
"@fgv/ts-json-base": "5.0.0-11"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"luxon": "^3.6.1"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"@fgv/ts-utils": "5.0.0-
|
|
59
|
-
"@fgv/ts-
|
|
60
|
-
"@fgv/ts-
|
|
61
|
-
"@fgv/ts-bcp47": "5.0.0-
|
|
62
|
-
"@fgv/ts-json": "5.0.0-
|
|
58
|
+
"@fgv/ts-utils": "5.0.0-11",
|
|
59
|
+
"@fgv/ts-json-base": "5.0.0-11",
|
|
60
|
+
"@fgv/ts-extras": "5.0.0-11",
|
|
61
|
+
"@fgv/ts-bcp47": "5.0.0-11",
|
|
62
|
+
"@fgv/ts-json": "5.0.0-11"
|
|
63
63
|
},
|
|
64
64
|
"scripts": {
|
|
65
65
|
"build": "heft build --clean",
|