@fgv/ts-res 4.5.0-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +27 -0
- package/dist/ts-res.d.ts +4282 -0
- package/dist/tsdoc-metadata.json +11 -0
- package/lib/index.d.ts +12 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +79 -0
- package/lib/index.js.map +1 -0
- package/lib/packlets/common/conditions.d.ts +148 -0
- package/lib/packlets/common/conditions.d.ts.map +1 -0
- package/lib/packlets/common/conditions.js +50 -0
- package/lib/packlets/common/conditions.js.map +1 -0
- package/lib/packlets/common/convert.d.ts +111 -0
- package/lib/packlets/common/convert.d.ts.map +1 -0
- package/lib/packlets/common/convert.js +173 -0
- package/lib/packlets/common/convert.js.map +1 -0
- package/lib/packlets/common/helpers/conditions.d.ts +39 -0
- package/lib/packlets/common/helpers/conditions.d.ts.map +1 -0
- package/lib/packlets/common/helpers/conditions.js +105 -0
- package/lib/packlets/common/helpers/conditions.js.map +1 -0
- package/lib/packlets/common/helpers/index.d.ts +3 -0
- package/lib/packlets/common/helpers/index.d.ts.map +1 -0
- package/lib/packlets/common/helpers/index.js +40 -0
- package/lib/packlets/common/helpers/index.js.map +1 -0
- package/lib/packlets/common/helpers/resources.d.ts +34 -0
- package/lib/packlets/common/helpers/resources.d.ts.map +1 -0
- package/lib/packlets/common/helpers/resources.js +81 -0
- package/lib/packlets/common/helpers/resources.js.map +1 -0
- package/lib/packlets/common/index.d.ts +7 -0
- package/lib/packlets/common/index.d.ts.map +1 -0
- package/lib/packlets/common/index.js +69 -0
- package/lib/packlets/common/index.js.map +1 -0
- package/lib/packlets/common/resources.d.ts +41 -0
- package/lib/packlets/common/resources.d.ts.map +1 -0
- package/lib/packlets/common/resources.js +30 -0
- package/lib/packlets/common/resources.js.map +1 -0
- package/lib/packlets/common/validate/conditions.d.ts +248 -0
- package/lib/packlets/common/validate/conditions.d.ts.map +1 -0
- package/lib/packlets/common/validate/conditions.js +436 -0
- package/lib/packlets/common/validate/conditions.js.map +1 -0
- package/lib/packlets/common/validate/index.d.ts +5 -0
- package/lib/packlets/common/validate/index.d.ts.map +1 -0
- package/lib/packlets/common/validate/index.js +65 -0
- package/lib/packlets/common/validate/index.js.map +1 -0
- package/lib/packlets/common/validate/regularExpressions.d.ts +39 -0
- package/lib/packlets/common/validate/regularExpressions.d.ts.map +1 -0
- package/lib/packlets/common/validate/regularExpressions.js +63 -0
- package/lib/packlets/common/validate/regularExpressions.js.map +1 -0
- package/lib/packlets/common/validate/resources.d.ts +97 -0
- package/lib/packlets/common/validate/resources.d.ts.map +1 -0
- package/lib/packlets/common/validate/resources.js +171 -0
- package/lib/packlets/common/validate/resources.js.map +1 -0
- package/lib/packlets/conditions/condition.d.ts +91 -0
- package/lib/packlets/conditions/condition.d.ts.map +1 -0
- package/lib/packlets/conditions/condition.js +146 -0
- package/lib/packlets/conditions/condition.js.map +1 -0
- package/lib/packlets/conditions/conditionCollector.d.ts +54 -0
- package/lib/packlets/conditions/conditionCollector.d.ts.map +1 -0
- package/lib/packlets/conditions/conditionCollector.js +72 -0
- package/lib/packlets/conditions/conditionCollector.js.map +1 -0
- package/lib/packlets/conditions/conditionDecls.d.ts +26 -0
- package/lib/packlets/conditions/conditionDecls.d.ts.map +1 -0
- package/lib/packlets/conditions/conditionDecls.js +24 -0
- package/lib/packlets/conditions/conditionDecls.js.map +1 -0
- package/lib/packlets/conditions/conditionSet.d.ts +99 -0
- package/lib/packlets/conditions/conditionSet.d.ts.map +1 -0
- package/lib/packlets/conditions/conditionSet.js +164 -0
- package/lib/packlets/conditions/conditionSet.js.map +1 -0
- package/lib/packlets/conditions/conditionSetCollector.d.ts +65 -0
- package/lib/packlets/conditions/conditionSetCollector.d.ts.map +1 -0
- package/lib/packlets/conditions/conditionSetCollector.js +90 -0
- package/lib/packlets/conditions/conditionSetCollector.js.map +1 -0
- package/lib/packlets/conditions/conditionSetDecls.d.ts +18 -0
- package/lib/packlets/conditions/conditionSetDecls.d.ts.map +1 -0
- package/lib/packlets/conditions/conditionSetDecls.js +24 -0
- package/lib/packlets/conditions/conditionSetDecls.js.map +1 -0
- package/lib/packlets/conditions/conditionToken.d.ts +86 -0
- package/lib/packlets/conditions/conditionToken.d.ts.map +1 -0
- package/lib/packlets/conditions/conditionToken.js +150 -0
- package/lib/packlets/conditions/conditionToken.js.map +1 -0
- package/lib/packlets/conditions/convert/conditionSetDecls.d.ts +24 -0
- package/lib/packlets/conditions/convert/conditionSetDecls.d.ts.map +1 -0
- package/lib/packlets/conditions/convert/conditionSetDecls.js +54 -0
- package/lib/packlets/conditions/convert/conditionSetDecls.js.map +1 -0
- package/lib/packlets/conditions/convert/decls.d.ts +24 -0
- package/lib/packlets/conditions/convert/decls.d.ts.map +1 -0
- package/lib/packlets/conditions/convert/decls.js +111 -0
- package/lib/packlets/conditions/convert/decls.js.map +1 -0
- package/lib/packlets/conditions/convert/index.d.ts +3 -0
- package/lib/packlets/conditions/convert/index.d.ts.map +1 -0
- package/lib/packlets/conditions/convert/index.js +40 -0
- package/lib/packlets/conditions/convert/index.js.map +1 -0
- package/lib/packlets/conditions/index.d.ts +10 -0
- package/lib/packlets/conditions/index.d.ts.map +1 -0
- package/lib/packlets/conditions/index.js +70 -0
- package/lib/packlets/conditions/index.js.map +1 -0
- package/lib/packlets/decisions/abstractDecision.d.ts +39 -0
- package/lib/packlets/decisions/abstractDecision.d.ts.map +1 -0
- package/lib/packlets/decisions/abstractDecision.js +63 -0
- package/lib/packlets/decisions/abstractDecision.js.map +1 -0
- package/lib/packlets/decisions/abstractDecisionCollector.d.ts +59 -0
- package/lib/packlets/decisions/abstractDecisionCollector.d.ts.map +1 -0
- package/lib/packlets/decisions/abstractDecisionCollector.js +92 -0
- package/lib/packlets/decisions/abstractDecisionCollector.js.map +1 -0
- package/lib/packlets/decisions/candidate.d.ts +58 -0
- package/lib/packlets/decisions/candidate.d.ts.map +1 -0
- package/lib/packlets/decisions/candidate.js +80 -0
- package/lib/packlets/decisions/candidate.js.map +1 -0
- package/lib/packlets/decisions/common.d.ts +15 -0
- package/lib/packlets/decisions/common.d.ts.map +1 -0
- package/lib/packlets/decisions/common.js +24 -0
- package/lib/packlets/decisions/common.js.map +1 -0
- package/lib/packlets/decisions/concreteDecision.d.ts +74 -0
- package/lib/packlets/decisions/concreteDecision.d.ts.map +1 -0
- package/lib/packlets/decisions/concreteDecision.js +114 -0
- package/lib/packlets/decisions/concreteDecision.js.map +1 -0
- package/lib/packlets/decisions/decision.d.ts +91 -0
- package/lib/packlets/decisions/decision.d.ts.map +1 -0
- package/lib/packlets/decisions/decision.js +126 -0
- package/lib/packlets/decisions/decision.js.map +1 -0
- package/lib/packlets/decisions/index.d.ts +7 -0
- package/lib/packlets/decisions/index.d.ts.map +1 -0
- package/lib/packlets/decisions/index.js +44 -0
- package/lib/packlets/decisions/index.js.map +1 -0
- package/lib/packlets/import/fsItem.d.ts +99 -0
- package/lib/packlets/import/fsItem.d.ts.map +1 -0
- package/lib/packlets/import/fsItem.js +174 -0
- package/lib/packlets/import/fsItem.js.map +1 -0
- package/lib/packlets/import/importContext.d.ts +85 -0
- package/lib/packlets/import/importContext.d.ts.map +1 -0
- package/lib/packlets/import/importContext.js +94 -0
- package/lib/packlets/import/importContext.js.map +1 -0
- package/lib/packlets/import/importManager.d.ts +93 -0
- package/lib/packlets/import/importManager.d.ts.map +1 -0
- package/lib/packlets/import/importManager.js +133 -0
- package/lib/packlets/import/importManager.js.map +1 -0
- package/lib/packlets/import/importable.d.ts +71 -0
- package/lib/packlets/import/importable.d.ts.map +1 -0
- package/lib/packlets/import/importable.js +35 -0
- package/lib/packlets/import/importable.js.map +1 -0
- package/lib/packlets/import/importers/collectionImporter.d.ts +60 -0
- package/lib/packlets/import/importers/collectionImporter.d.ts.map +1 -0
- package/lib/packlets/import/importers/collectionImporter.js +146 -0
- package/lib/packlets/import/importers/collectionImporter.js.map +1 -0
- package/lib/packlets/import/importers/fsItemImporter.d.ts +49 -0
- package/lib/packlets/import/importers/fsItemImporter.d.ts.map +1 -0
- package/lib/packlets/import/importers/fsItemImporter.js +120 -0
- package/lib/packlets/import/importers/fsItemImporter.js.map +1 -0
- package/lib/packlets/import/importers/importer.d.ts +31 -0
- package/lib/packlets/import/importers/importer.d.ts.map +1 -0
- package/lib/packlets/import/importers/importer.js +24 -0
- package/lib/packlets/import/importers/importer.js.map +1 -0
- package/lib/packlets/import/importers/index.d.ts +6 -0
- package/lib/packlets/import/importers/index.d.ts.map +1 -0
- package/lib/packlets/import/importers/index.js +43 -0
- package/lib/packlets/import/importers/index.js.map +1 -0
- package/lib/packlets/import/importers/jsonImporter.d.ts +32 -0
- package/lib/packlets/import/importers/jsonImporter.d.ts.map +1 -0
- package/lib/packlets/import/importers/jsonImporter.js +140 -0
- package/lib/packlets/import/importers/jsonImporter.js.map +1 -0
- package/lib/packlets/import/importers/pathImporter.d.ts +61 -0
- package/lib/packlets/import/importers/pathImporter.d.ts.map +1 -0
- package/lib/packlets/import/importers/pathImporter.js +87 -0
- package/lib/packlets/import/importers/pathImporter.js.map +1 -0
- package/lib/packlets/import/index.d.ts +7 -0
- package/lib/packlets/import/index.d.ts.map +1 -0
- package/lib/packlets/import/index.js +67 -0
- package/lib/packlets/import/index.js.map +1 -0
- package/lib/packlets/qualifier-types/convert.d.ts +19 -0
- package/lib/packlets/qualifier-types/convert.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/convert.js +45 -0
- package/lib/packlets/qualifier-types/convert.js.map +1 -0
- package/lib/packlets/qualifier-types/index.d.ts +8 -0
- package/lib/packlets/qualifier-types/index.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/index.js +68 -0
- package/lib/packlets/qualifier-types/index.js.map +1 -0
- package/lib/packlets/qualifier-types/languageQualifierType.d.ts +56 -0
- package/lib/packlets/qualifier-types/languageQualifierType.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/languageQualifierType.js +87 -0
- package/lib/packlets/qualifier-types/languageQualifierType.js.map +1 -0
- package/lib/packlets/qualifier-types/literalQualifierType.d.ts +92 -0
- package/lib/packlets/qualifier-types/literalQualifierType.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/literalQualifierType.js +114 -0
- package/lib/packlets/qualifier-types/literalQualifierType.js.map +1 -0
- package/lib/packlets/qualifier-types/qualifierType.d.ts +184 -0
- package/lib/packlets/qualifier-types/qualifierType.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/qualifierType.js +173 -0
- package/lib/packlets/qualifier-types/qualifierType.js.map +1 -0
- package/lib/packlets/qualifier-types/qualifierTypeCollector.d.ts +40 -0
- package/lib/packlets/qualifier-types/qualifierTypeCollector.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/qualifierTypeCollector.js +102 -0
- package/lib/packlets/qualifier-types/qualifierTypeCollector.js.map +1 -0
- package/lib/packlets/qualifier-types/territoryQualifierType.d.ts +74 -0
- package/lib/packlets/qualifier-types/territoryQualifierType.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/territoryQualifierType.js +113 -0
- package/lib/packlets/qualifier-types/territoryQualifierType.js.map +1 -0
- package/lib/packlets/qualifiers/convert/decls.d.ts +23 -0
- package/lib/packlets/qualifiers/convert/decls.d.ts.map +1 -0
- package/lib/packlets/qualifiers/convert/decls.js +71 -0
- package/lib/packlets/qualifiers/convert/decls.js.map +1 -0
- package/lib/packlets/qualifiers/convert/index.d.ts +3 -0
- package/lib/packlets/qualifiers/convert/index.d.ts.map +1 -0
- package/lib/packlets/qualifiers/convert/index.js +40 -0
- package/lib/packlets/qualifiers/convert/index.js.map +1 -0
- package/lib/packlets/qualifiers/convert/qualifier.d.ts +17 -0
- package/lib/packlets/qualifiers/convert/qualifier.d.ts.map +1 -0
- package/lib/packlets/qualifiers/convert/qualifier.js +43 -0
- package/lib/packlets/qualifiers/convert/qualifier.js.map +1 -0
- package/lib/packlets/qualifiers/index.d.ts +6 -0
- package/lib/packlets/qualifiers/index.d.ts.map +1 -0
- package/lib/packlets/qualifiers/index.js +66 -0
- package/lib/packlets/qualifiers/index.js.map +1 -0
- package/lib/packlets/qualifiers/qualifier.d.ts +68 -0
- package/lib/packlets/qualifiers/qualifier.d.ts.map +1 -0
- package/lib/packlets/qualifiers/qualifier.js +87 -0
- package/lib/packlets/qualifiers/qualifier.js.map +1 -0
- package/lib/packlets/qualifiers/qualifierCollector.d.ts +90 -0
- package/lib/packlets/qualifiers/qualifierCollector.d.ts.map +1 -0
- package/lib/packlets/qualifiers/qualifierCollector.js +157 -0
- package/lib/packlets/qualifiers/qualifierCollector.js.map +1 -0
- package/lib/packlets/qualifiers/qualifierDecl.d.ts +46 -0
- package/lib/packlets/qualifiers/qualifierDecl.d.ts.map +1 -0
- package/lib/packlets/qualifiers/qualifierDecl.js +24 -0
- package/lib/packlets/qualifiers/qualifierDecl.js.map +1 -0
- package/lib/packlets/resource-json/convert.d.ts +54 -0
- package/lib/packlets/resource-json/convert.d.ts.map +1 -0
- package/lib/packlets/resource-json/convert.js +139 -0
- package/lib/packlets/resource-json/convert.js.map +1 -0
- package/lib/packlets/resource-json/helpers.d.ts +41 -0
- package/lib/packlets/resource-json/helpers.d.ts.map +1 -0
- package/lib/packlets/resource-json/helpers.js +96 -0
- package/lib/packlets/resource-json/helpers.js.map +1 -0
- package/lib/packlets/resource-json/index.d.ts +9 -0
- package/lib/packlets/resource-json/index.d.ts.map +1 -0
- package/lib/packlets/resource-json/index.js +72 -0
- package/lib/packlets/resource-json/index.js.map +1 -0
- package/lib/packlets/resource-json/json.d.ts +182 -0
- package/lib/packlets/resource-json/json.d.ts.map +1 -0
- package/lib/packlets/resource-json/json.js +24 -0
- package/lib/packlets/resource-json/json.js.map +1 -0
- package/lib/packlets/resource-json/normalized.d.ts +123 -0
- package/lib/packlets/resource-json/normalized.d.ts.map +1 -0
- package/lib/packlets/resource-json/normalized.js +24 -0
- package/lib/packlets/resource-json/normalized.js.map +1 -0
- package/lib/packlets/resource-json/resourceDeclCollection.d.ts +39 -0
- package/lib/packlets/resource-json/resourceDeclCollection.d.ts.map +1 -0
- package/lib/packlets/resource-json/resourceDeclCollection.js +121 -0
- package/lib/packlets/resource-json/resourceDeclCollection.js.map +1 -0
- package/lib/packlets/resource-json/resourceDeclContainer.d.ts +11 -0
- package/lib/packlets/resource-json/resourceDeclContainer.d.ts.map +1 -0
- package/lib/packlets/resource-json/resourceDeclContainer.js +24 -0
- package/lib/packlets/resource-json/resourceDeclContainer.js.map +1 -0
- package/lib/packlets/resource-json/resourceDeclTree.d.ts +39 -0
- package/lib/packlets/resource-json/resourceDeclTree.d.ts.map +1 -0
- package/lib/packlets/resource-json/resourceDeclTree.js +122 -0
- package/lib/packlets/resource-json/resourceDeclTree.js.map +1 -0
- package/lib/packlets/resource-types/index.d.ts +4 -0
- package/lib/packlets/resource-types/index.d.ts.map +1 -0
- package/lib/packlets/resource-types/index.js +41 -0
- package/lib/packlets/resource-types/index.js.map +1 -0
- package/lib/packlets/resource-types/jsonResourceType.d.ts +65 -0
- package/lib/packlets/resource-types/jsonResourceType.d.ts.map +1 -0
- package/lib/packlets/resource-types/jsonResourceType.js +63 -0
- package/lib/packlets/resource-types/jsonResourceType.js.map +1 -0
- package/lib/packlets/resource-types/resourceType.d.ts +87 -0
- package/lib/packlets/resource-types/resourceType.d.ts.map +1 -0
- package/lib/packlets/resource-types/resourceType.js +62 -0
- package/lib/packlets/resource-types/resourceType.js.map +1 -0
- package/lib/packlets/resource-types/resourceTypeCollector.d.ts +30 -0
- package/lib/packlets/resource-types/resourceTypeCollector.d.ts.map +1 -0
- package/lib/packlets/resource-types/resourceTypeCollector.js +65 -0
- package/lib/packlets/resource-types/resourceTypeCollector.js.map +1 -0
- package/lib/packlets/resources/index.d.ts +5 -0
- package/lib/packlets/resources/index.d.ts.map +1 -0
- package/lib/packlets/resources/index.js +42 -0
- package/lib/packlets/resources/index.js.map +1 -0
- package/lib/packlets/resources/resource.d.ts +75 -0
- package/lib/packlets/resources/resource.d.ts.map +1 -0
- package/lib/packlets/resources/resource.js +109 -0
- package/lib/packlets/resources/resource.js.map +1 -0
- package/lib/packlets/resources/resourceBuilder.d.ts +112 -0
- package/lib/packlets/resources/resourceBuilder.d.ts.map +1 -0
- package/lib/packlets/resources/resourceBuilder.js +162 -0
- package/lib/packlets/resources/resourceBuilder.js.map +1 -0
- package/lib/packlets/resources/resourceCandidate.d.ts +102 -0
- package/lib/packlets/resources/resourceCandidate.d.ts.map +1 -0
- package/lib/packlets/resources/resourceCandidate.js +180 -0
- package/lib/packlets/resources/resourceCandidate.js.map +1 -0
- package/lib/packlets/resources/resourceManager.d.ts +104 -0
- package/lib/packlets/resources/resourceManager.d.ts.map +1 -0
- package/lib/packlets/resources/resourceManager.js +193 -0
- package/lib/packlets/resources/resourceManager.js.map +1 -0
- package/package.json +76 -0
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { JsonObject } from '@fgv/ts-json-base';
|
|
2
|
+
import { ConditionOperator, ResourceValueMergeMethod } from '../common';
|
|
3
|
+
/**
|
|
4
|
+
* Non-validated loose declaration of a {@link Conditions.Condition | condition}.
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export interface ILooseConditionDecl {
|
|
8
|
+
/**
|
|
9
|
+
* The name of the {@link Qualifiers.Qualifier | qualifier} to be compared.
|
|
10
|
+
*/
|
|
11
|
+
qualifierName: string;
|
|
12
|
+
/**
|
|
13
|
+
* The value to be compared.
|
|
14
|
+
*/
|
|
15
|
+
value: string;
|
|
16
|
+
/**
|
|
17
|
+
* The operator to be used in the comparison.
|
|
18
|
+
* Default is 'matches'.
|
|
19
|
+
*/
|
|
20
|
+
operator?: ConditionOperator;
|
|
21
|
+
/**
|
|
22
|
+
* The priority of the condition. Default is the default priority for the qualifier.
|
|
23
|
+
*/
|
|
24
|
+
priority?: number;
|
|
25
|
+
/**
|
|
26
|
+
* The score to be used if the condition is used as a default.
|
|
27
|
+
*/
|
|
28
|
+
scoreAsDefault?: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Non-validated child declaration of a {@link Conditions.Condition | condition}.
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
export interface IChildConditionDecl {
|
|
35
|
+
/**
|
|
36
|
+
* The value to be compared.
|
|
37
|
+
*/
|
|
38
|
+
value: string;
|
|
39
|
+
/**
|
|
40
|
+
* The operator to be used in the comparison.
|
|
41
|
+
* Default is 'matches'.
|
|
42
|
+
*/
|
|
43
|
+
operator?: ConditionOperator;
|
|
44
|
+
/**
|
|
45
|
+
* The priority of the condition. Default is the default priority for the qualifier.
|
|
46
|
+
*/
|
|
47
|
+
priority?: number;
|
|
48
|
+
/**
|
|
49
|
+
* The score to be used if the condition is used as a default.
|
|
50
|
+
*/
|
|
51
|
+
scoreAsDefault?: number;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Non-validated declaration of a {@link Conditions.Condition | condition}.
|
|
55
|
+
* @public
|
|
56
|
+
*/
|
|
57
|
+
export type ConditionSetDeclAsArray = ReadonlyArray<ILooseConditionDecl>;
|
|
58
|
+
/**
|
|
59
|
+
* Non-validated declaration of a {@link Conditions.Condition | condition}.
|
|
60
|
+
* @public
|
|
61
|
+
*/
|
|
62
|
+
export type ConditionSetDeclAsRecord = Record<string, string | IChildConditionDecl>;
|
|
63
|
+
/**
|
|
64
|
+
* Non-validated declaration of a {@link Conditions.Condition | condition}.
|
|
65
|
+
* @public
|
|
66
|
+
*/
|
|
67
|
+
export type ConditionSetDecl = ConditionSetDeclAsArray | ConditionSetDeclAsRecord;
|
|
68
|
+
/**
|
|
69
|
+
* Non-validated child declaration of a {@link Resources.ResourceCandidate | resource candidate}.
|
|
70
|
+
* @public
|
|
71
|
+
*/
|
|
72
|
+
export interface IChildResourceCandidateDecl {
|
|
73
|
+
/**
|
|
74
|
+
* The JSON value of the resource.
|
|
75
|
+
*/
|
|
76
|
+
readonly json: JsonObject;
|
|
77
|
+
/**
|
|
78
|
+
* The conditions that must be met for the resource to be selected.
|
|
79
|
+
*/
|
|
80
|
+
readonly conditions?: ConditionSetDecl;
|
|
81
|
+
/**
|
|
82
|
+
* If true, the resource is only a partial representation of the full resource.
|
|
83
|
+
*/
|
|
84
|
+
readonly isPartial?: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* The merge method to be used when merging the resource into the existing resource.
|
|
87
|
+
* default is 'augment'.
|
|
88
|
+
*/
|
|
89
|
+
readonly mergeMethod?: ResourceValueMergeMethod;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Non-validated loose declaration of a {@link Resources.ResourceCandidate | resource candidate}.
|
|
93
|
+
* @public
|
|
94
|
+
*/
|
|
95
|
+
export interface ILooseResourceCandidateDecl extends IChildResourceCandidateDecl {
|
|
96
|
+
/**
|
|
97
|
+
* The {@link ResourceId | id} of the resource.
|
|
98
|
+
*/
|
|
99
|
+
readonly id: string;
|
|
100
|
+
/**
|
|
101
|
+
* The JSON value of the resource.
|
|
102
|
+
*/
|
|
103
|
+
readonly json: JsonObject;
|
|
104
|
+
/**
|
|
105
|
+
* The conditions that must be met for the resource to be selected.
|
|
106
|
+
*/
|
|
107
|
+
readonly conditions?: ConditionSetDecl;
|
|
108
|
+
/**
|
|
109
|
+
* If true, the resource is only a partial representation of the full resource.
|
|
110
|
+
*/
|
|
111
|
+
readonly isPartial?: boolean;
|
|
112
|
+
/**
|
|
113
|
+
* The merge method to be used when merging the resource into the existing resource.
|
|
114
|
+
* default is 'augment'.
|
|
115
|
+
*/
|
|
116
|
+
readonly mergeMethod?: ResourceValueMergeMethod;
|
|
117
|
+
/**
|
|
118
|
+
* The type of the resource.
|
|
119
|
+
*/
|
|
120
|
+
readonly resourceTypeName?: string;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Non-validated child declaration of a {@link Resources.Resource | resource}.
|
|
124
|
+
* @public
|
|
125
|
+
*/
|
|
126
|
+
export interface IChildResourceDecl {
|
|
127
|
+
/**
|
|
128
|
+
* The name of the type of this resource.
|
|
129
|
+
*/
|
|
130
|
+
readonly resourceTypeName: string;
|
|
131
|
+
/**
|
|
132
|
+
* Possible candidates for this value.
|
|
133
|
+
*/
|
|
134
|
+
readonly candidates?: ReadonlyArray<IChildResourceCandidateDecl>;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Non-validated loose declaration of a {@link Resources.Resource | resource}.
|
|
138
|
+
* @public
|
|
139
|
+
*/
|
|
140
|
+
export interface ILooseResourceDecl extends IChildResourceDecl {
|
|
141
|
+
/**
|
|
142
|
+
* The id of the resource.
|
|
143
|
+
*/
|
|
144
|
+
readonly id: string;
|
|
145
|
+
/**
|
|
146
|
+
* The name of the type of this resource.
|
|
147
|
+
*/
|
|
148
|
+
readonly resourceTypeName: string;
|
|
149
|
+
/**
|
|
150
|
+
* Possible candidates for this value.
|
|
151
|
+
*/
|
|
152
|
+
readonly candidates?: ReadonlyArray<IChildResourceCandidateDecl>;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Normalized non-validated declaration of a {@link Resources.Resource | resource} tree node.
|
|
156
|
+
* @public
|
|
157
|
+
*/
|
|
158
|
+
export interface IResourceTreeChildNodeDecl {
|
|
159
|
+
readonly resources?: Record<string, IChildResourceDecl>;
|
|
160
|
+
readonly children?: Record<string, IResourceTreeChildNodeDecl>;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Normalized non-validated declaration of a {@link Resources.Resource | resource} tree root.
|
|
164
|
+
* @public
|
|
165
|
+
*/
|
|
166
|
+
export interface IResourceTreeRootDecl extends IResourceTreeChildNodeDecl {
|
|
167
|
+
readonly baseName?: string;
|
|
168
|
+
readonly resources?: Record<string, IChildResourceDecl>;
|
|
169
|
+
readonly children?: Record<string, IResourceTreeChildNodeDecl>;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Non-validated declaration of a collection of resources.
|
|
173
|
+
* @public
|
|
174
|
+
*/
|
|
175
|
+
export interface IResourceCollectionDecl {
|
|
176
|
+
readonly baseName?: string;
|
|
177
|
+
readonly baseConditions?: ConditionSetDecl;
|
|
178
|
+
readonly candidates?: ReadonlyArray<ILooseResourceCandidateDecl>;
|
|
179
|
+
readonly resources?: ReadonlyArray<ILooseResourceDecl>;
|
|
180
|
+
readonly collections?: ReadonlyArray<IResourceCollectionDecl>;
|
|
181
|
+
}
|
|
182
|
+
//# sourceMappingURL=json.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../../src/packlets/resource-json/json.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAExE;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAE7B;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAE7B;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;GAGG;AACH,MAAM,MAAM,uBAAuB,GAAG,aAAa,CAAC,mBAAmB,CAAC,CAAC;AAEzE;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,mBAAmB,CAAC,CAAC;AAEpF;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,uBAAuB,GAAG,wBAAwB,CA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AAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IACxD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,0BAA0B,CAAC,CAAC;CAChE;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAsB,SAAQ,0BAA0B;IACvE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IACxD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,0BAA0B,CAAC,CAAC;CAChE;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,cAAc,CAAC,EAAE,gBAAgB,CAAC;IAC3C,QAAQ,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC,2BAA2B,CAAC,CAAC;IACjE,QAAQ,CAAC,SAAS,CAAC,EAAE,aAAa,CAAC,kBAAkB,CAAC,CAAC;IACvD,QAAQ,CAAC,WAAW,CAAC,EAAE,aAAa,CAAC,uBAAuB,CAAC,CAAC;CAC/D"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025 Erik Fortune
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
* in the Software without restriction, including without limitation the rights
|
|
8
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
* furnished to do so, subject to the following conditions:
|
|
11
|
+
*
|
|
12
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
* copies or substantial portions of the Software.
|
|
14
|
+
*
|
|
15
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
* SOFTWARE.
|
|
22
|
+
*/
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
//# sourceMappingURL=json.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.js","sourceRoot":"","sources":["../../../src/packlets/resource-json/json.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 { JsonObject } from '@fgv/ts-json-base';\nimport { ConditionOperator, ResourceValueMergeMethod } from '../common';\n\n/**\n * Non-validated loose declaration of a {@link Conditions.Condition | condition}.\n * @public\n */\nexport interface ILooseConditionDecl {\n /**\n * The name of the {@link Qualifiers.Qualifier | qualifier} to be compared.\n */\n qualifierName: string;\n /**\n * The value to be compared.\n */\n value: string;\n /**\n * The operator to be used in the comparison.\n * Default is 'matches'.\n */\n operator?: ConditionOperator;\n\n /**\n * The priority of the condition. Default is the default priority for the qualifier.\n */\n priority?: number;\n\n /**\n * The score to be used if the condition is used as a default.\n */\n scoreAsDefault?: number;\n}\n\n/**\n * Non-validated child declaration of a {@link Conditions.Condition | condition}.\n * @public\n */\nexport interface IChildConditionDecl {\n /**\n * The value to be compared.\n */\n value: string;\n /**\n * The operator to be used in the comparison.\n * Default is 'matches'.\n */\n operator?: ConditionOperator;\n\n /**\n * The priority of the condition. Default is the default priority for the qualifier.\n */\n priority?: number;\n\n /**\n * The score to be used if the condition is used as a default.\n */\n scoreAsDefault?: number;\n}\n\n/**\n * Non-validated declaration of a {@link Conditions.Condition | condition}.\n * @public\n */\nexport type ConditionSetDeclAsArray = ReadonlyArray<ILooseConditionDecl>;\n\n/**\n * Non-validated declaration of a {@link Conditions.Condition | condition}.\n * @public\n */\nexport type ConditionSetDeclAsRecord = Record<string, string | IChildConditionDecl>;\n\n/**\n * Non-validated declaration of a {@link Conditions.Condition | condition}.\n * @public\n */\nexport type ConditionSetDecl = ConditionSetDeclAsArray | ConditionSetDeclAsRecord;\n\n/**\n * Non-validated child declaration of a {@link Resources.ResourceCandidate | resource candidate}.\n * @public\n */\nexport interface IChildResourceCandidateDecl {\n /**\n * The JSON value of the resource.\n */\n readonly json: JsonObject;\n\n /**\n * The conditions that must be met for the resource to be selected.\n */\n readonly conditions?: ConditionSetDecl;\n\n /**\n * If true, the resource is only a partial representation of the full resource.\n */\n readonly isPartial?: boolean;\n\n /**\n * The merge method to be used when merging the resource into the existing resource.\n * default is 'augment'.\n */\n readonly mergeMethod?: ResourceValueMergeMethod;\n}\n\n/**\n * Non-validated loose declaration of a {@link Resources.ResourceCandidate | resource candidate}.\n * @public\n */\nexport interface ILooseResourceCandidateDecl extends IChildResourceCandidateDecl {\n /**\n * The {@link ResourceId | id} of the resource.\n */\n readonly id: string;\n\n /**\n * The JSON value of the resource.\n */\n readonly json: JsonObject;\n\n /**\n * The conditions that must be met for the resource to be selected.\n */\n readonly conditions?: ConditionSetDecl;\n\n /**\n * If true, the resource is only a partial representation of the full resource.\n */\n readonly isPartial?: boolean;\n\n /**\n * The merge method to be used when merging the resource into the existing resource.\n * default is 'augment'.\n */\n readonly mergeMethod?: ResourceValueMergeMethod;\n\n /**\n * The type of the resource.\n */\n readonly resourceTypeName?: string;\n}\n\n/**\n * Non-validated child declaration of a {@link Resources.Resource | resource}.\n * @public\n */\nexport interface IChildResourceDecl {\n /**\n * The name of the type of this resource.\n */\n readonly resourceTypeName: string;\n\n /**\n * Possible candidates for this value.\n */\n readonly candidates?: ReadonlyArray<IChildResourceCandidateDecl>;\n}\n\n/**\n * Non-validated loose declaration of a {@link Resources.Resource | resource}.\n * @public\n */\nexport interface ILooseResourceDecl extends IChildResourceDecl {\n /**\n * The id of the resource.\n */\n readonly id: string;\n\n /**\n * The name of the type of this resource.\n */\n readonly resourceTypeName: string;\n\n /**\n * Possible candidates for this value.\n */\n readonly candidates?: ReadonlyArray<IChildResourceCandidateDecl>;\n}\n\n/**\n * Normalized non-validated declaration of a {@link Resources.Resource | resource} tree node.\n * @public\n */\nexport interface IResourceTreeChildNodeDecl {\n readonly resources?: Record<string, IChildResourceDecl>;\n readonly children?: Record<string, IResourceTreeChildNodeDecl>;\n}\n\n/**\n * Normalized non-validated declaration of a {@link Resources.Resource | resource} tree root.\n * @public\n */\nexport interface IResourceTreeRootDecl extends IResourceTreeChildNodeDecl {\n readonly baseName?: string;\n readonly resources?: Record<string, IChildResourceDecl>;\n readonly children?: Record<string, IResourceTreeChildNodeDecl>;\n}\n\n/**\n * Non-validated declaration of a collection of resources.\n * @public\n */\nexport interface IResourceCollectionDecl {\n readonly baseName?: string;\n readonly baseConditions?: ConditionSetDecl;\n readonly candidates?: ReadonlyArray<ILooseResourceCandidateDecl>;\n readonly resources?: ReadonlyArray<ILooseResourceDecl>;\n readonly collections?: ReadonlyArray<IResourceCollectionDecl>;\n}\n"]}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { JsonObject } from '@fgv/ts-json-base';
|
|
2
|
+
import { ResourceValueMergeMethod } from '../common';
|
|
3
|
+
import { ILooseConditionDecl } from './json';
|
|
4
|
+
/**
|
|
5
|
+
* Normalized non-validated declaration of a {@link Conditions.Condition | condition}.
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export type ConditionSetDecl = ReadonlyArray<ILooseConditionDecl>;
|
|
9
|
+
/**
|
|
10
|
+
* Normalized non-validated child declaration of a {@link Resources.ResourceCandidate | resource candidate}.
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export interface IChildResourceCandidateDecl {
|
|
14
|
+
/**
|
|
15
|
+
* The JSON value of the resource.
|
|
16
|
+
*/
|
|
17
|
+
readonly json: JsonObject;
|
|
18
|
+
/**
|
|
19
|
+
* The conditions that must be met for the resource to be selected.
|
|
20
|
+
*/
|
|
21
|
+
readonly conditions?: ConditionSetDecl;
|
|
22
|
+
/**
|
|
23
|
+
* If true, the resource is only a partial representation of the full resource.
|
|
24
|
+
*/
|
|
25
|
+
readonly isPartial?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* The merge method to be used when merging the resource into the existing resource.
|
|
28
|
+
* default is 'augment'.
|
|
29
|
+
*/
|
|
30
|
+
readonly mergeMethod?: ResourceValueMergeMethod;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Normalized non-validated loose declaration of a {@link Resources.ResourceCandidate | resource candidate}.
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
export interface ILooseResourceCandidateDecl extends IChildResourceCandidateDecl {
|
|
37
|
+
/**
|
|
38
|
+
* The {@link ResourceId | id} of the resource.
|
|
39
|
+
*/
|
|
40
|
+
readonly id: string;
|
|
41
|
+
/**
|
|
42
|
+
* The JSON value of the resource.
|
|
43
|
+
*/
|
|
44
|
+
readonly json: JsonObject;
|
|
45
|
+
/**
|
|
46
|
+
* The conditions that must be met for the resource to be selected.
|
|
47
|
+
*/
|
|
48
|
+
readonly conditions?: ConditionSetDecl;
|
|
49
|
+
/**
|
|
50
|
+
* If true, the resource is only a partial representation of the full resource.
|
|
51
|
+
*/
|
|
52
|
+
readonly isPartial?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* The merge method to be used when merging the resource into the existing resource.
|
|
55
|
+
* default is 'augment'.
|
|
56
|
+
*/
|
|
57
|
+
readonly mergeMethod?: ResourceValueMergeMethod;
|
|
58
|
+
/**
|
|
59
|
+
* The type of the resource.
|
|
60
|
+
*/
|
|
61
|
+
readonly resourceTypeName?: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Normalized non-validated child declaration of a {@link Resources.Resource | resource}.
|
|
65
|
+
* @public
|
|
66
|
+
*/
|
|
67
|
+
export interface IChildResourceDecl {
|
|
68
|
+
/**
|
|
69
|
+
* The name of the type of this resource.
|
|
70
|
+
*/
|
|
71
|
+
readonly resourceTypeName: string;
|
|
72
|
+
/**
|
|
73
|
+
* Possible candidates for this value.
|
|
74
|
+
*/
|
|
75
|
+
readonly candidates?: ReadonlyArray<IChildResourceCandidateDecl>;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Normalized non-validated loose declaration of a {@link Resources.Resource | resource}.
|
|
79
|
+
* @public
|
|
80
|
+
*/
|
|
81
|
+
export interface ILooseResourceDecl extends IChildResourceDecl {
|
|
82
|
+
/**
|
|
83
|
+
* The id of the resource.
|
|
84
|
+
*/
|
|
85
|
+
readonly id: string;
|
|
86
|
+
/**
|
|
87
|
+
* The name of the type of this resource.
|
|
88
|
+
*/
|
|
89
|
+
readonly resourceTypeName: string;
|
|
90
|
+
/**
|
|
91
|
+
* Possible candidates for this value.
|
|
92
|
+
*/
|
|
93
|
+
readonly candidates?: ReadonlyArray<IChildResourceCandidateDecl>;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Normalized non-validated declaration of a {@link Resources.Resource | resource} tree node.
|
|
97
|
+
* @public
|
|
98
|
+
*/
|
|
99
|
+
export interface IResourceTreeChildNodeDecl {
|
|
100
|
+
readonly resources?: Record<string, IChildResourceDecl>;
|
|
101
|
+
readonly children?: Record<string, IResourceTreeChildNodeDecl>;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Normalized non-validated declaration of a {@link Resources.Resource | resource} tree root.
|
|
105
|
+
* @public
|
|
106
|
+
*/
|
|
107
|
+
export interface IResourceTreeRootDecl extends IResourceTreeChildNodeDecl {
|
|
108
|
+
readonly baseName?: string;
|
|
109
|
+
readonly resources?: Record<string, IChildResourceDecl>;
|
|
110
|
+
readonly children?: Record<string, IResourceTreeChildNodeDecl>;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Normalized non-validated declaration of a collection of resources.
|
|
114
|
+
* @public
|
|
115
|
+
*/
|
|
116
|
+
export interface IResourceCollectionDecl {
|
|
117
|
+
readonly baseName?: string;
|
|
118
|
+
readonly baseConditions?: ConditionSetDecl;
|
|
119
|
+
readonly candidates?: ReadonlyArray<ILooseResourceCandidateDecl>;
|
|
120
|
+
readonly resources?: ReadonlyArray<ILooseResourceDecl>;
|
|
121
|
+
readonly collections?: ReadonlyArray<IResourceCollectionDecl>;
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=normalized.d.ts.map
|
|
@@ -0,0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
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
* in the Software without restriction, including without limitation the rights
|
|
8
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
* furnished to do so, subject to the following conditions:
|
|
11
|
+
*
|
|
12
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
* copies or substantial portions of the Software.
|
|
14
|
+
*
|
|
15
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
* SOFTWARE.
|
|
22
|
+
*/
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
//# sourceMappingURL=normalized.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalized.js","sourceRoot":"","sources":["../../../src/packlets/resource-json/normalized.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 { JsonObject } from '@fgv/ts-json-base';\nimport { ResourceValueMergeMethod } from '../common';\nimport { ILooseConditionDecl } from './json';\n\n/**\n * Normalized non-validated declaration of a {@link Conditions.Condition | condition}.\n * @public\n */\nexport type ConditionSetDecl = ReadonlyArray<ILooseConditionDecl>;\n\n/**\n * Normalized non-validated child declaration of a {@link Resources.ResourceCandidate | resource candidate}.\n * @public\n */\nexport interface IChildResourceCandidateDecl {\n /**\n * The JSON value of the resource.\n */\n readonly json: JsonObject;\n\n /**\n * The conditions that must be met for the resource to be selected.\n */\n readonly conditions?: ConditionSetDecl;\n\n /**\n * If true, the resource is only a partial representation of the full resource.\n */\n readonly isPartial?: boolean;\n\n /**\n * The merge method to be used when merging the resource into the existing resource.\n * default is 'augment'.\n */\n readonly mergeMethod?: ResourceValueMergeMethod;\n}\n\n/**\n * Normalized non-validated loose declaration of a {@link Resources.ResourceCandidate | resource candidate}.\n * @public\n */\nexport interface ILooseResourceCandidateDecl extends IChildResourceCandidateDecl {\n /**\n * The {@link ResourceId | id} of the resource.\n */\n readonly id: string;\n\n /**\n * The JSON value of the resource.\n */\n readonly json: JsonObject;\n\n /**\n * The conditions that must be met for the resource to be selected.\n */\n readonly conditions?: ConditionSetDecl;\n\n /**\n * If true, the resource is only a partial representation of the full resource.\n */\n readonly isPartial?: boolean;\n\n /**\n * The merge method to be used when merging the resource into the existing resource.\n * default is 'augment'.\n */\n readonly mergeMethod?: ResourceValueMergeMethod;\n\n /**\n * The type of the resource.\n */\n readonly resourceTypeName?: string;\n}\n\n/**\n * Normalized non-validated child declaration of a {@link Resources.Resource | resource}.\n * @public\n */\nexport interface IChildResourceDecl {\n /**\n * The name of the type of this resource.\n */\n readonly resourceTypeName: string;\n\n /**\n * Possible candidates for this value.\n */\n readonly candidates?: ReadonlyArray<IChildResourceCandidateDecl>;\n}\n\n/**\n * Normalized non-validated loose declaration of a {@link Resources.Resource | resource}.\n * @public\n */\nexport interface ILooseResourceDecl extends IChildResourceDecl {\n /**\n * The id of the resource.\n */\n readonly id: string;\n\n /**\n * The name of the type of this resource.\n */\n readonly resourceTypeName: string;\n\n /**\n * Possible candidates for this value.\n */\n readonly candidates?: ReadonlyArray<IChildResourceCandidateDecl>;\n}\n\n/**\n * Normalized non-validated declaration of a {@link Resources.Resource | resource} tree node.\n * @public\n */\nexport interface IResourceTreeChildNodeDecl {\n readonly resources?: Record<string, IChildResourceDecl>;\n readonly children?: Record<string, IResourceTreeChildNodeDecl>;\n}\n\n/**\n * Normalized non-validated declaration of a {@link Resources.Resource | resource} tree root.\n * @public\n */\nexport interface IResourceTreeRootDecl extends IResourceTreeChildNodeDecl {\n readonly baseName?: string;\n readonly resources?: Record<string, IChildResourceDecl>;\n readonly children?: Record<string, IResourceTreeChildNodeDecl>;\n}\n\n/**\n * Normalized non-validated declaration of a collection of resources.\n * @public\n */\nexport interface IResourceCollectionDecl {\n readonly baseName?: string;\n readonly baseConditions?: ConditionSetDecl;\n readonly candidates?: ReadonlyArray<ILooseResourceCandidateDecl>;\n readonly resources?: ReadonlyArray<ILooseResourceDecl>;\n readonly collections?: ReadonlyArray<IResourceCollectionDecl>;\n}\n"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Result } from '@fgv/ts-utils';
|
|
2
|
+
import { IResourceDeclContainer } from './resourceDeclContainer';
|
|
3
|
+
import * as Normalized from './normalized';
|
|
4
|
+
/**
|
|
5
|
+
* Class that extracts resources and candidates from a
|
|
6
|
+
* {@link ResourceJson.Json.IResourceCollectionDecl | resource collection declaration}.
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export declare class ResourceDeclCollection implements IResourceDeclContainer {
|
|
10
|
+
/**
|
|
11
|
+
* The {@link ResourceJson.Normalized.IResourceCollectionDecl | resource collection declaration}
|
|
12
|
+
* being processed.
|
|
13
|
+
*/
|
|
14
|
+
readonly collection: Normalized.IResourceCollectionDecl;
|
|
15
|
+
protected _resources: Normalized.ILooseResourceDecl[];
|
|
16
|
+
protected _candidates: Normalized.ILooseResourceCandidateDecl[];
|
|
17
|
+
protected constructor(collection: Normalized.IResourceCollectionDecl);
|
|
18
|
+
/**
|
|
19
|
+
* Creates a new {@link ResourceJson.ResourceDeclCollection | ResourceDeclCollection} from an
|
|
20
|
+
* untyped {@link ResourceJson.Json.IResourceCollectionDecl | resource collection declaration}.
|
|
21
|
+
* @param from - The JSON object to convert.
|
|
22
|
+
* @returns `Success` with the new collection if the JSON object is valid, otherwise `Failure`.
|
|
23
|
+
*/
|
|
24
|
+
static create(from: unknown): Result<ResourceDeclCollection>;
|
|
25
|
+
/**
|
|
26
|
+
* Gets the loose resources extracted from the collection.
|
|
27
|
+
* @returns The {@link ResourceJson.Normalized.ILooseResourceDecl | loose resource declarations}
|
|
28
|
+
* extracted from the collection.
|
|
29
|
+
*/
|
|
30
|
+
getLooseResources(): ReadonlyArray<Normalized.ILooseResourceDecl>;
|
|
31
|
+
/**
|
|
32
|
+
* Gets the loose candidates extracted from the collection.
|
|
33
|
+
* @returns The {@link ResourceJson.Normalized.ILooseResourceCandidateDecl | loose resource candidate declarations}
|
|
34
|
+
* extracted from the collection.
|
|
35
|
+
*/
|
|
36
|
+
getLooseCandidates(): ReadonlyArray<Normalized.ILooseResourceCandidateDecl>;
|
|
37
|
+
private _extract;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=resourceDeclCollection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resourceDeclCollection.d.ts","sourceRoot":"","sources":["../../../src/packlets/resource-json/resourceDeclCollection.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAgD,MAAM,EAAW,MAAM,eAAe,CAAC;AAC9F,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC;AAK3C;;;;GAIG;AACH,qBAAa,sBAAuB,YAAW,sBAAsB;IACnE;;;OAGG;IACH,SAAgB,UAAU,EAAE,UAAU,CAAC,uBAAuB,CAAC;IAE/D,SAAS,CAAC,UAAU,EAAE,UAAU,CAAC,kBAAkB,EAAE,CAAM;IAC3D,SAAS,CAAC,WAAW,EAAE,UAAU,CAAC,2BAA2B,EAAE,CAAM;IAErE,SAAS,aAAa,UAAU,EAAE,UAAU,CAAC,uBAAuB;IAKpE;;;;;OAKG;WACW,MAAM,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC,sBAAsB,CAAC;IASnE;;;;OAIG;IACI,iBAAiB,IAAI,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC;IAIxE;;;;OAIG;IACI,kBAAkB,IAAI,aAAa,CAAC,UAAU,CAAC,2BAA2B,CAAC;IAIlF,OAAO,CAAC,QAAQ;CAwBjB"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025 Erik Fortune
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
* in the Software without restriction, including without limitation the rights
|
|
8
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
* furnished to do so, subject to the following conditions:
|
|
11
|
+
*
|
|
12
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
* copies or substantial portions of the Software.
|
|
14
|
+
*
|
|
15
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
* SOFTWARE.
|
|
22
|
+
*/
|
|
23
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
24
|
+
if (k2 === undefined) k2 = k;
|
|
25
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
26
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
27
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
28
|
+
}
|
|
29
|
+
Object.defineProperty(o, k2, desc);
|
|
30
|
+
}) : (function(o, m, k, k2) {
|
|
31
|
+
if (k2 === undefined) k2 = k;
|
|
32
|
+
o[k2] = m[k];
|
|
33
|
+
}));
|
|
34
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
35
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
36
|
+
}) : function(o, v) {
|
|
37
|
+
o["default"] = v;
|
|
38
|
+
});
|
|
39
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
40
|
+
var ownKeys = function(o) {
|
|
41
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
42
|
+
var ar = [];
|
|
43
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
44
|
+
return ar;
|
|
45
|
+
};
|
|
46
|
+
return ownKeys(o);
|
|
47
|
+
};
|
|
48
|
+
return function (mod) {
|
|
49
|
+
if (mod && mod.__esModule) return mod;
|
|
50
|
+
var result = {};
|
|
51
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
52
|
+
__setModuleDefault(result, mod);
|
|
53
|
+
return result;
|
|
54
|
+
};
|
|
55
|
+
})();
|
|
56
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
|
+
exports.ResourceDeclCollection = void 0;
|
|
58
|
+
const ts_utils_1 = require("@fgv/ts-utils");
|
|
59
|
+
const Convert = __importStar(require("./convert"));
|
|
60
|
+
const common_1 = require("../common");
|
|
61
|
+
const helpers_1 = require("./helpers");
|
|
62
|
+
/**
|
|
63
|
+
* Class that extracts resources and candidates from a
|
|
64
|
+
* {@link ResourceJson.Json.IResourceCollectionDecl | resource collection declaration}.
|
|
65
|
+
* @public
|
|
66
|
+
*/
|
|
67
|
+
class ResourceDeclCollection {
|
|
68
|
+
constructor(collection) {
|
|
69
|
+
this._resources = [];
|
|
70
|
+
this._candidates = [];
|
|
71
|
+
this.collection = collection;
|
|
72
|
+
this._extract(collection).orThrow();
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Creates a new {@link ResourceJson.ResourceDeclCollection | ResourceDeclCollection} from an
|
|
76
|
+
* untyped {@link ResourceJson.Json.IResourceCollectionDecl | resource collection declaration}.
|
|
77
|
+
* @param from - The JSON object to convert.
|
|
78
|
+
* @returns `Success` with the new collection if the JSON object is valid, otherwise `Failure`.
|
|
79
|
+
*/
|
|
80
|
+
static create(from) {
|
|
81
|
+
return Convert.resourceCollectionDecl
|
|
82
|
+
.convert(from)
|
|
83
|
+
.withErrorFormat((err) => `Invalid resource collection: ${err}`)
|
|
84
|
+
.onSuccess((decl) => {
|
|
85
|
+
return (0, ts_utils_1.captureResult)(() => new ResourceDeclCollection(decl));
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Gets the loose resources extracted from the collection.
|
|
90
|
+
* @returns The {@link ResourceJson.Normalized.ILooseResourceDecl | loose resource declarations}
|
|
91
|
+
* extracted from the collection.
|
|
92
|
+
*/
|
|
93
|
+
getLooseResources() {
|
|
94
|
+
return this._resources;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Gets the loose candidates extracted from the collection.
|
|
98
|
+
* @returns The {@link ResourceJson.Normalized.ILooseResourceCandidateDecl | loose resource candidate declarations}
|
|
99
|
+
* extracted from the collection.
|
|
100
|
+
*/
|
|
101
|
+
getLooseCandidates() {
|
|
102
|
+
return this._candidates;
|
|
103
|
+
}
|
|
104
|
+
_extract(collection, parentName, parentConditions) {
|
|
105
|
+
const errors = new ts_utils_1.MessageAggregator();
|
|
106
|
+
return common_1.Helpers.joinOptionalResourceIds(parentName, collection.baseName).onSuccess((baseName) => {
|
|
107
|
+
var _a, _b, _c, _d, _e, _f;
|
|
108
|
+
const baseConditions = [...(parentConditions !== null && parentConditions !== void 0 ? parentConditions : []), ...((_a = collection.baseConditions) !== null && _a !== void 0 ? _a : [])];
|
|
109
|
+
const mergedCandidates = (_c = (_b = collection.candidates) === null || _b === void 0 ? void 0 : _b.map((candidate) => (0, helpers_1.mergeLooseCandidate)(candidate, baseName, baseConditions))) !== null && _c !== void 0 ? _c : [];
|
|
110
|
+
this._candidates.push(...(0, ts_utils_1.mapResults)(mergedCandidates).aggregateError(errors).orDefault([]));
|
|
111
|
+
const mergedResources = (_e = (_d = collection.resources) === null || _d === void 0 ? void 0 : _d.map((resource) => (0, helpers_1.mergeLooseResource)(resource, baseName, baseConditions))) !== null && _e !== void 0 ? _e : [];
|
|
112
|
+
this._resources.push(...(0, ts_utils_1.mapResults)(mergedResources).aggregateError(errors).orDefault([]));
|
|
113
|
+
(_f = collection.collections) === null || _f === void 0 ? void 0 : _f.forEach((subCollection) => {
|
|
114
|
+
this._extract(subCollection, baseName, baseConditions).aggregateError(errors);
|
|
115
|
+
});
|
|
116
|
+
return errors.returnOrReport((0, ts_utils_1.succeed)(this));
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
exports.ResourceDeclCollection = ResourceDeclCollection;
|
|
121
|
+
//# sourceMappingURL=resourceDeclCollection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resourceDeclCollection.js","sourceRoot":"","sources":["../../../src/packlets/resource-json/resourceDeclCollection.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4CAA8F;AAE9F,mDAAqC;AAGrC,sCAAqD;AACrD,uCAAoE;AAEpE;;;;GAIG;AACH,MAAa,sBAAsB;IAUjC,YAAsB,UAA8C;QAH1D,eAAU,GAAoC,EAAE,CAAC;QACjD,gBAAW,GAA6C,EAAE,CAAC;QAGnE,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE,CAAC;IACtC,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,MAAM,CAAC,IAAa;QAChC,OAAO,OAAO,CAAC,sBAAsB;aAClC,OAAO,CAAC,IAAI,CAAC;aACb,eAAe,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,gCAAgC,GAAG,EAAE,CAAC;aAC/D,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE;YAClB,OAAO,IAAA,wBAAa,EAAC,GAAG,EAAE,CAAC,IAAI,sBAAsB,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C,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;YAE1F,MAAA,UAAU,CAAC,WAAW,0CAAE,OAAO,CAAC,CAAC,aAAa,EAAE,EAAE;gBAChD,IAAI,CAAC,QAAQ,CAAC,aAAa,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;YAChF,CAAC,CAAC,CAAC;YACH,OAAO,MAAM,CAAC,cAAc,CAAC,IAAA,kBAAO,EAAC,IAAI,CAAC,CAAC,CAAC;QAC9C,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAxED,wDAwEC","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 { captureResult, mapResults, MessageAggregator, Result, succeed } from '@fgv/ts-utils';\nimport { IResourceDeclContainer } from './resourceDeclContainer';\nimport * as Convert from './convert';\nimport * as Normalized from './normalized';\nimport * as Json from './json';\nimport { Helpers as CommonHelpers } from '../common';\nimport { mergeLooseCandidate, mergeLooseResource } from './helpers';\n\n/**\n * Class that extracts resources and candidates from a\n * {@link ResourceJson.Json.IResourceCollectionDecl | resource collection declaration}.\n * @public\n */\nexport class ResourceDeclCollection implements IResourceDeclContainer {\n /**\n * The {@link ResourceJson.Normalized.IResourceCollectionDecl | resource collection declaration}\n * being processed.\n */\n public readonly collection: Normalized.IResourceCollectionDecl;\n\n protected _resources: Normalized.ILooseResourceDecl[] = [];\n protected _candidates: Normalized.ILooseResourceCandidateDecl[] = [];\n\n protected constructor(collection: Normalized.IResourceCollectionDecl) {\n this.collection = collection;\n this._extract(collection).orThrow();\n }\n\n /**\n * Creates a new {@link ResourceJson.ResourceDeclCollection | ResourceDeclCollection} from an\n * untyped {@link ResourceJson.Json.IResourceCollectionDecl | resource collection declaration}.\n * @param from - The JSON object to convert.\n * @returns `Success` with the new collection if the JSON object is valid, otherwise `Failure`.\n */\n public static create(from: unknown): Result<ResourceDeclCollection> {\n return Convert.resourceCollectionDecl\n .convert(from)\n .withErrorFormat((err) => `Invalid resource collection: ${err}`)\n .onSuccess((decl) => {\n return captureResult(() => new ResourceDeclCollection(decl));\n });\n }\n\n /**\n * Gets the loose resources extracted from the collection.\n * @returns The {@link ResourceJson.Normalized.ILooseResourceDecl | loose resource declarations}\n * extracted from the collection.\n */\n public getLooseResources(): ReadonlyArray<Normalized.ILooseResourceDecl> {\n return this._resources;\n }\n\n /**\n * Gets the loose candidates extracted from the collection.\n * @returns The {@link ResourceJson.Normalized.ILooseResourceCandidateDecl | loose resource candidate declarations}\n * extracted from the collection.\n */\n public getLooseCandidates(): ReadonlyArray<Normalized.ILooseResourceCandidateDecl> {\n return this._candidates;\n }\n\n private _extract(\n collection: Normalized.IResourceCollectionDecl,\n parentName?: string,\n parentConditions?: Json.ILooseConditionDecl[]\n ): Result<this> {\n const errors: MessageAggregator = new MessageAggregator();\n return CommonHelpers.joinOptionalResourceIds(parentName, collection.baseName).onSuccess((baseName) => {\n const baseConditions = [...(parentConditions ?? []), ...(collection.baseConditions ?? [])];\n\n const mergedCandidates =\n collection.candidates?.map((candidate) => mergeLooseCandidate(candidate, baseName, baseConditions)) ??\n [];\n this._candidates.push(...mapResults(mergedCandidates).aggregateError(errors).orDefault([]));\n\n const mergedResources =\n collection.resources?.map((resource) => mergeLooseResource(resource, baseName, baseConditions)) ?? [];\n this._resources.push(...mapResults(mergedResources).aggregateError(errors).orDefault([]));\n\n collection.collections?.forEach((subCollection) => {\n this._extract(subCollection, baseName, baseConditions).aggregateError(errors);\n });\n return errors.returnOrReport(succeed(this));\n });\n }\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as Normalized from './normalized';
|
|
2
|
+
/**
|
|
3
|
+
* Generic container for resource and resource candidate
|
|
4
|
+
* declarations.
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export interface IResourceDeclContainer {
|
|
8
|
+
getLooseResources(): ReadonlyArray<Normalized.ILooseResourceDecl>;
|
|
9
|
+
getLooseCandidates(): ReadonlyArray<Normalized.ILooseResourceCandidateDecl>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=resourceDeclContainer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resourceDeclContainer.d.ts","sourceRoot":"","sources":["../../../src/packlets/resource-json/resourceDeclContainer.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC;AAE3C;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC,iBAAiB,IAAI,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC;IAClE,kBAAkB,IAAI,aAAa,CAAC,UAAU,CAAC,2BAA2B,CAAC,CAAC;CAC7E"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025 Erik Fortune
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
* in the Software without restriction, including without limitation the rights
|
|
8
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
* furnished to do so, subject to the following conditions:
|
|
11
|
+
*
|
|
12
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
* copies or substantial portions of the Software.
|
|
14
|
+
*
|
|
15
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
* SOFTWARE.
|
|
22
|
+
*/
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
//# sourceMappingURL=resourceDeclContainer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resourceDeclContainer.js","sourceRoot":"","sources":["../../../src/packlets/resource-json/resourceDeclContainer.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 * as Normalized from './normalized';\n\n/**\n * Generic container for resource and resource candidate\n * declarations.\n * @public\n */\nexport interface IResourceDeclContainer {\n getLooseResources(): ReadonlyArray<Normalized.ILooseResourceDecl>;\n getLooseCandidates(): ReadonlyArray<Normalized.ILooseResourceCandidateDecl>;\n}\n"]}
|