@fgv/ts-res 5.0.0-21 → 5.0.0-23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (197) hide show
  1. package/README.md +794 -137
  2. package/dist/ts-res.d.ts +506 -33
  3. package/lib/packlets/common/convert.d.ts +10 -0
  4. package/lib/packlets/common/convert.js +11 -1
  5. package/lib/packlets/common/resources.d.ts +40 -1
  6. package/lib/packlets/common/validate/regularExpressions.d.ts +4 -0
  7. package/lib/packlets/common/validate/regularExpressions.js +5 -1
  8. package/lib/packlets/common/validate/resources.d.ts +35 -1
  9. package/lib/packlets/common/validate/resources.js +54 -0
  10. package/lib/packlets/config/convert.js +1 -1
  11. package/lib/packlets/config/json.d.ts +1 -1
  12. package/lib/packlets/qualifier-types/config/convert.d.ts +22 -1
  13. package/lib/packlets/qualifier-types/config/convert.js +67 -2
  14. package/lib/packlets/qualifier-types/config/json.d.ts +11 -2
  15. package/lib/packlets/qualifier-types/helpers.d.ts +1 -2
  16. package/lib/packlets/qualifier-types/languageQualifierType.d.ts +27 -1
  17. package/lib/packlets/qualifier-types/languageQualifierType.js +75 -0
  18. package/lib/packlets/qualifier-types/literalQualifierType.d.ts +30 -4
  19. package/lib/packlets/qualifier-types/literalQualifierType.js +77 -0
  20. package/lib/packlets/qualifier-types/literalValueHierarchy.d.ts +6 -10
  21. package/lib/packlets/qualifier-types/literalValueHierarchy.js +10 -0
  22. package/lib/packlets/qualifier-types/qualifierType.d.ts +28 -0
  23. package/lib/packlets/qualifier-types/territoryQualifierType.d.ts +28 -4
  24. package/lib/packlets/qualifier-types/territoryQualifierType.js +77 -0
  25. package/lib/packlets/resource-json/compiled/convert.js +2 -1
  26. package/lib/packlets/resource-json/compiled/json.d.ts +6 -2
  27. package/lib/packlets/resource-types/config/convert.js +3 -1
  28. package/lib/packlets/resource-types/config/json.d.ts +2 -0
  29. package/lib/packlets/resource-types/jsonResourceType.d.ts +10 -6
  30. package/lib/packlets/resource-types/jsonResourceType.js +7 -10
  31. package/lib/packlets/resource-types/resourceType.d.ts +20 -8
  32. package/lib/packlets/resource-types/resourceType.js +20 -16
  33. package/lib/packlets/resources/candidateValue.d.ts +92 -0
  34. package/lib/packlets/resources/candidateValue.js +128 -0
  35. package/lib/packlets/resources/candidateValueCollector.d.ts +55 -0
  36. package/lib/packlets/resources/candidateValueCollector.js +96 -0
  37. package/lib/packlets/resources/index.d.ts +2 -0
  38. package/lib/packlets/resources/index.js +2 -0
  39. package/lib/packlets/resources/resource.js +2 -2
  40. package/lib/packlets/resources/resourceBuilder.d.ts +6 -0
  41. package/lib/packlets/resources/resourceBuilder.js +3 -1
  42. package/lib/packlets/resources/resourceCandidate.d.ts +10 -1
  43. package/lib/packlets/resources/resourceCandidate.js +11 -5
  44. package/lib/packlets/resources/resourceManagerBuilder.d.ts +7 -0
  45. package/lib/packlets/resources/resourceManagerBuilder.js +13 -6
  46. package/lib/packlets/runtime/compiledResourceCollection.d.ts +20 -8
  47. package/lib/packlets/runtime/compiledResourceCollection.js +25 -4
  48. package/lib/packlets/runtime/resource-tree/common.d.ts +1 -1
  49. package/lib/packlets/runtime/resourceResolver.d.ts +39 -1
  50. package/lib/packlets/runtime/resourceResolver.js +45 -28
  51. package/lib/test/unit/qualifier-types/testQualifierType.d.ts +4 -0
  52. package/lib/test/unit/qualifier-types/testQualifierType.js +24 -0
  53. package/lib/test/unit/resource-types/derivedResourceType.test.d.ts +2 -0
  54. package/lib/test/unit/resource-types/testDerivedResourceType.d.ts +79 -0
  55. package/lib/test/unit/resource-types/testDerivedResourceType.js +113 -0
  56. package/lib/test/unit/resources/candidateValue.test.d.ts +2 -0
  57. package/lib/test/unit/resources/candidateValueCollector.test.d.ts +2 -0
  58. package/lib/test/unit/runtime/resourceResolver.coverage.test.d.ts +2 -0
  59. package/lib/test/unit/runtime/resourceResolver.newFeatures.test.d.ts +2 -0
  60. package/package.json +7 -7
  61. package/src/index.ts +0 -75
  62. package/src/packlets/bundle/bundleBuilder.ts +0 -159
  63. package/src/packlets/bundle/bundleLoader.ts +0 -157
  64. package/src/packlets/bundle/bundleNormalizer.ts +0 -173
  65. package/src/packlets/bundle/bundleUtils.ts +0 -142
  66. package/src/packlets/bundle/convert.ts +0 -87
  67. package/src/packlets/bundle/index.ts +0 -52
  68. package/src/packlets/bundle/model.ts +0 -138
  69. package/src/packlets/common/conditions.ts +0 -226
  70. package/src/packlets/common/convert.ts +0 -184
  71. package/src/packlets/common/helpers/conditions.ts +0 -84
  72. package/src/packlets/common/helpers/context.ts +0 -88
  73. package/src/packlets/common/helpers/index.ts +0 -26
  74. package/src/packlets/common/helpers/qualifierDefaultValues.ts +0 -91
  75. package/src/packlets/common/helpers/resources.ts +0 -96
  76. package/src/packlets/common/index.ts +0 -30
  77. package/src/packlets/common/resources.ts +0 -78
  78. package/src/packlets/common/validate/conditions.ts +0 -595
  79. package/src/packlets/common/validate/index.ts +0 -27
  80. package/src/packlets/common/validate/regularExpressions.ts +0 -92
  81. package/src/packlets/common/validate/resources.ts +0 -170
  82. package/src/packlets/conditions/condition.ts +0 -351
  83. package/src/packlets/conditions/conditionCollector.ts +0 -103
  84. package/src/packlets/conditions/conditionDecls.ts +0 -50
  85. package/src/packlets/conditions/conditionSet.ts +0 -318
  86. package/src/packlets/conditions/conditionSetCollector.ts +0 -127
  87. package/src/packlets/conditions/conditionSetDecls.ts +0 -41
  88. package/src/packlets/conditions/conditionToken.ts +0 -180
  89. package/src/packlets/conditions/convert/conditionSetDecls.ts +0 -72
  90. package/src/packlets/conditions/convert/decls.ts +0 -95
  91. package/src/packlets/conditions/convert/index.ts +0 -24
  92. package/src/packlets/conditions/index.ts +0 -33
  93. package/src/packlets/config/common.ts +0 -107
  94. package/src/packlets/config/configInitFactory.ts +0 -142
  95. package/src/packlets/config/convert.ts +0 -61
  96. package/src/packlets/config/index.ts +0 -30
  97. package/src/packlets/config/json.ts +0 -43
  98. package/src/packlets/config/predefined/default.ts +0 -150
  99. package/src/packlets/config/predefined/extended.ts +0 -198
  100. package/src/packlets/config/predefined/index.ts +0 -26
  101. package/src/packlets/config/systemConfiguration.ts +0 -217
  102. package/src/packlets/context/contextDecls.ts +0 -76
  103. package/src/packlets/context/contextToken.ts +0 -252
  104. package/src/packlets/context/convert/decls.ts +0 -126
  105. package/src/packlets/context/convert/index.ts +0 -23
  106. package/src/packlets/context/index.ts +0 -27
  107. package/src/packlets/decisions/abstractDecision.ts +0 -87
  108. package/src/packlets/decisions/abstractDecisionCollector.ts +0 -122
  109. package/src/packlets/decisions/candidate.ts +0 -101
  110. package/src/packlets/decisions/common.ts +0 -37
  111. package/src/packlets/decisions/concreteDecision.ts +0 -157
  112. package/src/packlets/decisions/decision.ts +0 -172
  113. package/src/packlets/decisions/index.ts +0 -28
  114. package/src/packlets/import/fsItem.ts +0 -212
  115. package/src/packlets/import/importContext.ts +0 -183
  116. package/src/packlets/import/importManager.ts +0 -187
  117. package/src/packlets/import/importable.ts +0 -107
  118. package/src/packlets/import/importers/collectionImporter.ts +0 -153
  119. package/src/packlets/import/importers/fsItemImporter.ts +0 -154
  120. package/src/packlets/import/importers/importer.ts +0 -58
  121. package/src/packlets/import/importers/index.ts +0 -27
  122. package/src/packlets/import/importers/jsonImporter.ts +0 -133
  123. package/src/packlets/import/importers/pathImporter.ts +0 -134
  124. package/src/packlets/import/index.ts +0 -29
  125. package/src/packlets/qualifier-types/config/convert.ts +0 -108
  126. package/src/packlets/qualifier-types/config/index.ts +0 -27
  127. package/src/packlets/qualifier-types/config/json.ts +0 -126
  128. package/src/packlets/qualifier-types/convert.ts +0 -77
  129. package/src/packlets/qualifier-types/helpers.ts +0 -94
  130. package/src/packlets/qualifier-types/index.ts +0 -34
  131. package/src/packlets/qualifier-types/languageQualifierType.ts +0 -143
  132. package/src/packlets/qualifier-types/literalQualifierType.ts +0 -244
  133. package/src/packlets/qualifier-types/literalValueHierarchy.ts +0 -332
  134. package/src/packlets/qualifier-types/qualifierType.ts +0 -360
  135. package/src/packlets/qualifier-types/qualifierTypeCollector.ts +0 -102
  136. package/src/packlets/qualifier-types/territoryQualifierType.ts +0 -255
  137. package/src/packlets/qualifiers/convert/decls.ts +0 -90
  138. package/src/packlets/qualifiers/convert/index.ts +0 -24
  139. package/src/packlets/qualifiers/convert/qualifier.ts +0 -55
  140. package/src/packlets/qualifiers/index.ts +0 -31
  141. package/src/packlets/qualifiers/qualifier.ts +0 -169
  142. package/src/packlets/qualifiers/qualifierCollector.ts +0 -194
  143. package/src/packlets/qualifiers/qualifierDecl.ts +0 -80
  144. package/src/packlets/qualifiers/qualifierDefaultValueDecls.ts +0 -57
  145. package/src/packlets/qualifiers/qualifierDefaultValueToken.ts +0 -230
  146. package/src/packlets/resource-json/compiled/common.ts +0 -35
  147. package/src/packlets/resource-json/compiled/convert.ts +0 -143
  148. package/src/packlets/resource-json/compiled/index.ts +0 -27
  149. package/src/packlets/resource-json/compiled/json.ts +0 -239
  150. package/src/packlets/resource-json/convert.ts +0 -236
  151. package/src/packlets/resource-json/helpers.ts +0 -284
  152. package/src/packlets/resource-json/index.ts +0 -33
  153. package/src/packlets/resource-json/json.ts +0 -295
  154. package/src/packlets/resource-json/normalized.ts +0 -211
  155. package/src/packlets/resource-json/resourceDeclCollection.ts +0 -117
  156. package/src/packlets/resource-json/resourceDeclContainer.ts +0 -48
  157. package/src/packlets/resource-json/resourceDeclTree.ts +0 -116
  158. package/src/packlets/resource-types/config/convert.ts +0 -36
  159. package/src/packlets/resource-types/config/index.ts +0 -27
  160. package/src/packlets/resource-types/config/json.ts +0 -30
  161. package/src/packlets/resource-types/helpers.ts +0 -44
  162. package/src/packlets/resource-types/index.ts +0 -30
  163. package/src/packlets/resource-types/jsonResourceType.ts +0 -104
  164. package/src/packlets/resource-types/resourceType.ts +0 -259
  165. package/src/packlets/resource-types/resourceTypeCollector.ts +0 -79
  166. package/src/packlets/resources/candidateReducer.ts +0 -331
  167. package/src/packlets/resources/common.ts +0 -114
  168. package/src/packlets/resources/index.ts +0 -28
  169. package/src/packlets/resources/resource.ts +0 -307
  170. package/src/packlets/resources/resourceBuilder.ts +0 -269
  171. package/src/packlets/resources/resourceCandidate.ts +0 -333
  172. package/src/packlets/resources/resourceManagerBuilder.ts +0 -1169
  173. package/src/packlets/runtime/cacheListener.ts +0 -113
  174. package/src/packlets/runtime/cacheMetrics.ts +0 -206
  175. package/src/packlets/runtime/compiledResourceCollection.ts +0 -607
  176. package/src/packlets/runtime/conditionSetResolutionResult.ts +0 -160
  177. package/src/packlets/runtime/context/contextQualifierProvider.ts +0 -117
  178. package/src/packlets/runtime/context/contextQualifierProviderValidator.ts +0 -281
  179. package/src/packlets/runtime/context/index.ts +0 -26
  180. package/src/packlets/runtime/context/simpleContextQualifierProvider.ts +0 -225
  181. package/src/packlets/runtime/context/validatingSimpleContextQualifierProvider.ts +0 -96
  182. package/src/packlets/runtime/iResourceManager.ts +0 -130
  183. package/src/packlets/runtime/index.ts +0 -35
  184. package/src/packlets/runtime/resource-tree/common.ts +0 -126
  185. package/src/packlets/runtime/resource-tree/index.ts +0 -26
  186. package/src/packlets/runtime/resource-tree/readOnlyResourceTree.ts +0 -342
  187. package/src/packlets/runtime/resource-tree/resourceTreeChildren.ts +0 -125
  188. package/src/packlets/runtime/resource-tree/resourceTreeChildrenValidator.ts +0 -187
  189. package/src/packlets/runtime/resourceResolver.ts +0 -626
  190. package/src/packlets/runtime/validate.ts +0 -63
  191. package/src/packlets/zip-archive/convert.ts +0 -121
  192. package/src/packlets/zip-archive/index.ts +0 -76
  193. package/src/packlets/zip-archive/json.ts +0 -91
  194. package/src/packlets/zip-archive/types.ts +0 -140
  195. package/src/packlets/zip-archive/zipArchiveCreator.ts +0 -229
  196. package/src/packlets/zip-archive/zipArchiveFormat.ts +0 -158
  197. package/src/packlets/zip-archive/zipArchiveLoader.ts +0 -370
package/dist/ts-res.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Brand } from '@fgv/ts-utils';
2
2
  import { Collections } from '@fgv/ts-utils';
3
3
  import { Converter } from '@fgv/ts-utils';
4
+ import { Converters } from '@fgv/ts-json-base';
4
5
  import { DetailedResult } from '@fgv/ts-utils';
5
6
  import { FileTree } from '@fgv/ts-utils';
6
7
  import { Hash } from '@fgv/ts-utils';
@@ -132,6 +133,13 @@ declare const allPredefinedSystemConfigurations: ReadonlyArray<PredefinedSystemC
132
133
  */
133
134
  export declare const allResourceValueMergeMethods: ResourceValueMergeMethod[];
134
135
 
136
+ /**
137
+ * A `Converter` for {@link QualifierTypes.Config.IAnyQualifierTypeConfig | AnyQualifierTypeConfig} objects.
138
+ * @returns A `Converter` for {@link QualifierTypes.Config.IAnyQualifierTypeConfig | AnyQualifierTypeConfig} objects.
139
+ * @public
140
+ */
141
+ declare const anyQualifierTypeConfig: Converter<Model_2.IAnyQualifierTypeConfig, unknown>;
142
+
135
143
  /**
136
144
  * Converts an array of {@link Helpers.IConditionTokenParts | condition token parts} into an array of
137
145
  * syntactically validated {@link ConditionToken | condition tokens}.
@@ -577,6 +585,120 @@ declare class CandidateReducer {
577
585
  reduceCandidate(candidate: ResourceCandidate): Result<IReducedCandidate | undefined>;
578
586
  }
579
587
 
588
+ /**
589
+ * Implementation of a candidate value that stores normalized JSON data.
590
+ * The value is normalized on creation and a hash-based key is generated
591
+ * for efficient deduplication.
592
+ * @public
593
+ */
594
+ declare class CandidateValue implements ICandidateValue {
595
+ private readonly _collectible;
596
+ private readonly _json;
597
+ /**
598
+ * The unique key for this candidate value.
599
+ */
600
+ get key(): CandidateValueKey;
601
+ /**
602
+ * The index of this candidate value in the collection.
603
+ */
604
+ get index(): CandidateValueIndex | undefined;
605
+ /**
606
+ * The normalized JSON value.
607
+ */
608
+ get json(): JsonValue;
609
+ /**
610
+ * Constructor for a {@link Resources.CandidateValue} object.
611
+ * @param params - Parameters to create the candidate value.
612
+ * @internal
613
+ */
614
+ protected constructor(params: ICandidateValueCreateParams);
615
+ /**
616
+ * Creates a new {@link Resources.CandidateValue} object.
617
+ * @param params - Parameters to create the candidate value.
618
+ * @returns `Success` with the new candidate value if successful,
619
+ * or `Failure` with an error message if not.
620
+ * @public
621
+ */
622
+ static create(params: ICandidateValueCreateParams): Result<CandidateValue>;
623
+ /**
624
+ * Sets the index of this candidate value.
625
+ * @param index - The index to set.
626
+ * @returns `Success` with the index if successful, or `Failure` with an error message if not.
627
+ * @public
628
+ */
629
+ setIndex(index: number): Result<CandidateValueIndex>;
630
+ }
631
+
632
+ /**
633
+ * A `ValidatingCollector` for {@link Resources.CandidateValue | CandidateValues},
634
+ * which collects candidate values supplied as either {@link Resources.CandidateValue | CandidateValue} or
635
+ * `JsonValue`.
636
+ * @public
637
+ */
638
+ declare class CandidateValueCollector extends ValidatingCollector<CandidateValue> {
639
+ readonly normalizer: Hash.HashingNormalizer;
640
+ /**
641
+ * Constructor for a {@link Resources.CandidateValueCollector} object.
642
+ * @param params - Parameters to create the collector.
643
+ * @internal
644
+ */
645
+ protected constructor(params?: ICandidateValueCollectorCreateParams);
646
+ /**
647
+ * Creates a new {@link Resources.CandidateValueCollector} object.
648
+ * @param params - Parameters to create the collector.
649
+ * @returns `Success` with the new collector if successful,
650
+ * or `Failure` with an error message if not.
651
+ * @public
652
+ */
653
+ static create(params?: ICandidateValueCollectorCreateParams): Result<CandidateValueCollector>;
654
+ /**
655
+ * Returns an array of JSON values ordered by their indices.
656
+ * @returns Array of JsonValue objects in index order.
657
+ * @public
658
+ */
659
+ getValuesByIndex(): JsonValue[];
660
+ /**
661
+ * Converter method to handle CandidateValue | JsonValue.
662
+ * @param from - The value to convert.
663
+ * @returns `Success` with the CandidateValue if successful, or `Failure` with an error message if not.
664
+ * @internal
665
+ */
666
+ private _toCandidateValue;
667
+ }
668
+
669
+ /**
670
+ * Branded number representing a validated candidate value index.
671
+ * Candidate value indices are used to identify candidate values
672
+ * within a resource set and to enable sharing of like values.
673
+ * @public
674
+ */
675
+ export declare type CandidateValueIndex = Brand<number, 'CandidateValueIndex'>;
676
+
677
+ /**
678
+ * `Converter` which validates an `unknown` value as a {@link CandidateValueIndex | CandidateValueIndex}.
679
+ * @public
680
+ */
681
+ declare const candidateValueIndex: Converter<CandidateValueIndex, unknown>;
682
+
683
+ /**
684
+ * Branded string representing a validated candidate value key.
685
+ * Candidate value keys are used to identify candidate values
686
+ * within a resource set and to enable sharing of like values.
687
+ * @public
688
+ */
689
+ export declare type CandidateValueKey = Brand<string, 'CandidateValueKey'>;
690
+
691
+ /**
692
+ * `Converter` which validates an `unknown` value as a {@link CandidateValueKey | CandidateValueKey}.
693
+ * @public
694
+ */
695
+ declare const candidateValueKey: Converter<CandidateValueKey, unknown>;
696
+
697
+ /**
698
+ * @internal
699
+ */
700
+ declare const candidateValueKey_2: RegExp;
701
+
580
702
  /**
581
703
  * A factory that chains multiple factories together.
582
704
  * @public
@@ -707,7 +829,10 @@ declare namespace Common {
707
829
  ResourceTypeIndex,
708
830
  ResourceValueMergeMethod,
709
831
  allResourceValueMergeMethods,
710
- CandidateCompleteness
832
+ CandidateCompleteness,
833
+ CandidateValueIndex,
834
+ CandidateValueKey,
835
+ IResourceResolver
711
836
  }
712
837
  }
713
838
 
@@ -803,23 +928,28 @@ declare class CompiledResourceCollection implements IResourceManager<IResource>
803
928
  private readonly _qualifierTypes;
804
929
  private readonly _qualifiers;
805
930
  private readonly _resourceTypes;
931
+ private readonly _candidateValues;
806
932
  private readonly _builtResources;
807
933
  private _cachedResourceTree?;
808
934
  /**
809
- * A {@link QualifierTypes.QualifierTypeCollector | QualifierTypeCollector} which
935
+ * A {@link QualifierTypes.ReadOnlyQualifierTypeCollector | ReadOnlyQualifierTypeCollector} which
810
936
  * contains the {@link QualifierTypes.QualifierType | qualifier types} used in this collection.
811
937
  */
812
- get qualifierTypes(): QualifierTypeCollector;
938
+ get qualifierTypes(): ReadOnlyQualifierTypeCollector;
813
939
  /**
814
- * A {@link Qualifiers.QualifierCollector | QualifierCollector} which
940
+ * A {@link Qualifiers.IReadOnlyQualifierCollector | ReadOnlyQualifierCollector} which
815
941
  * contains the {@link Qualifiers.Qualifier | qualifiers} used in this collection.
816
942
  */
817
- get qualifiers(): QualifierCollector;
943
+ get qualifiers(): IReadOnlyQualifierCollector;
818
944
  /**
819
945
  * A {@link ResourceTypes.ResourceTypeCollector | ResourceTypeCollector} which
820
946
  * contains the {@link ResourceTypes.ResourceType | resource types} used in this collection.
821
947
  */
822
- get resourceTypes(): ResourceTypeCollector;
948
+ get resourceTypes(): ReadOnlyResourceTypeCollector;
949
+ /**
950
+ * The candidate values in the collection.
951
+ */
952
+ get candidateValues(): ReadonlyArray<JsonValue>;
823
953
  /**
824
954
  * {@inheritdoc Runtime.IResourceManager.builtResources}
825
955
  */
@@ -917,6 +1047,12 @@ declare class CompiledResourceCollection implements IResourceManager<IResource>
917
1047
  * @internal
918
1048
  */
919
1049
  private _buildDecisions;
1050
+ /**
1051
+ * Gets a candidate value from the collection.
1052
+ * @param valueIndex - The index of the candidate value to get.
1053
+ * @returns
1054
+ */
1055
+ private _getCandidateValue;
920
1056
  /**
921
1057
  * Reconstructs a ValidatingResultMap of resources from compiled data.
922
1058
  * @param compiled - The compiled resource collection
@@ -1713,6 +1849,7 @@ declare namespace Config_2 {
1713
1849
  isSystemQualifierTypeConfig,
1714
1850
  IQualifierTypeConfig,
1715
1851
  ILanguageQualifierTypeConfig,
1852
+ LiteralValueHierarchyDecl,
1716
1853
  ITerritoryQualifierTypeConfig,
1717
1854
  ILiteralQualifierTypeConfig,
1718
1855
  ISystemLanguageQualifierTypeConfig,
@@ -2070,6 +2207,8 @@ declare namespace Convert {
2070
2207
  resourceIndex,
2071
2208
  resourceTypeName,
2072
2209
  resourceTypeIndex,
2210
+ candidateValueKey,
2211
+ candidateValueIndex,
2073
2212
  resourceValueMergeMethod,
2074
2213
  contextQualifierToken,
2075
2214
  contextToken,
@@ -2116,13 +2255,16 @@ declare namespace Convert_12 {
2116
2255
 
2117
2256
  declare namespace Convert_2 {
2118
2257
  export {
2258
+ qualifierTypeConfig,
2119
2259
  languageQualifierTypeConfig,
2120
2260
  territoryQualifierTypeConfig,
2121
2261
  literalQualifierTypeConfig,
2122
2262
  systemLanguageQualifierTypeConfig,
2123
2263
  systemTerritoryQualifierTypeConfig,
2124
2264
  systemLiteralQualifierTypeConfig,
2125
- systemQualifierTypeConfig
2265
+ systemQualifierTypeConfig,
2266
+ jsonQualifierTypeConfig,
2267
+ anyQualifierTypeConfig
2126
2268
  }
2127
2269
  }
2128
2270
 
@@ -2213,7 +2355,7 @@ declare namespace Convert_9 {
2213
2355
  * if successful, `Failure` with an error message otherwise.
2214
2356
  * @public
2215
2357
  */
2216
- declare function createQualifierTypeFromConfig(typeConfig: Config_2.IQualifierTypeConfig<JsonObject>): Result<QualifierType>;
2358
+ declare function createQualifierTypeFromConfig(typeConfig: Config_2.IAnyQualifierTypeConfig): Result<QualifierType>;
2217
2359
 
2218
2360
  /**
2219
2361
  * Creates a {@link QualifierTypes.QualifierType | QualifierType} from a system configuration object.
@@ -2869,6 +3011,69 @@ declare interface ICandidateInfo {
2869
3011
  readonly json?: JsonObject;
2870
3012
  }
2871
3013
 
3014
+ /**
3015
+ * Interface for a candidate value that can be collected and indexed.
3016
+ * Candidate values are normalized JSON values that can be shared across
3017
+ * multiple resource candidates to reduce duplication.
3018
+ * @public
3019
+ */
3020
+ declare interface ICandidateValue extends Collections.ICollectible<CandidateValueKey, CandidateValueIndex> {
3021
+ /**
3022
+ * The unique key for this candidate value, derived from the hash of the normalized JSON.
3023
+ */
3024
+ readonly key: CandidateValueKey;
3025
+ /**
3026
+ * The index of this candidate value in the collection.
3027
+ */
3028
+ readonly index: CandidateValueIndex | undefined;
3029
+ /**
3030
+ * The normalized JSON value.
3031
+ */
3032
+ readonly json: JsonValue;
3033
+ /**
3034
+ * Sets the index of this candidate value.
3035
+ * @param index - The index to set.
3036
+ * @returns `Success` with the index if successful, or `Failure` with an error message if not.
3037
+ */
3038
+ setIndex(index: number): Result<CandidateValueIndex>;
3039
+ }
3040
+
3041
+ /**
3042
+ * Parameters for creating a {@link Resources.CandidateValueCollector}.
3043
+ * @public
3044
+ */
3045
+ declare interface ICandidateValueCollectorCreateParams {
3046
+ /**
3047
+ * Optional normalizer to use for normalizing JSON values.
3048
+ * If not provided, a default Crc32Normalizer will be used.
3049
+ */
3050
+ normalizer?: Hash.HashingNormalizer;
3051
+ /**
3052
+ * Optional initial candidate values to add to the collection.
3053
+ */
3054
+ candidateValues?: (CandidateValue | JsonValue)[];
3055
+ }
3056
+
3057
+ /**
3058
+ * Parameters for creating a {@link Resources.CandidateValue | CandidateValue}.
3059
+ * @public
3060
+ */
3061
+ declare interface ICandidateValueCreateParams {
3062
+ /**
3063
+ * The JSON value to store. Will be normalized during creation.
3064
+ */
3065
+ json: JsonValue;
3066
+ /**
3067
+ * Optional normalizer to use for normalizing the JSON value.
3068
+ * If not provided, a default Crc32Normalizer will be used.
3069
+ */
3070
+ normalizer?: Hash.Crc32Normalizer;
3071
+ /**
3072
+ * Optional index if the value is already indexed.
3073
+ */
3074
+ index?: number;
3075
+ }
3076
+
2872
3077
  /**
2873
3078
  * Non-validated child declaration of a {@link Conditions.Condition | condition}.
2874
3079
  * @public
@@ -2992,9 +3197,9 @@ declare interface ICompiledAbstractDecision {
2992
3197
  */
2993
3198
  declare interface ICompiledCandidate {
2994
3199
  /**
2995
- * The JSON value of the candidate.
3200
+ * The global index of the JSON value of the candidate.
2996
3201
  */
2997
- json: JsonValue;
3202
+ valueIndex: Common.CandidateValueIndex;
2998
3203
  /**
2999
3204
  * Indicates if this is a partial resource that needs to be merged.
3000
3205
  */
@@ -3167,6 +3372,10 @@ declare interface ICompiledResourceCollection {
3167
3372
  * Array of all decisions in the collection.
3168
3373
  */
3169
3374
  decisions: ReadonlyArray<ICompiledAbstractDecision>;
3375
+ /**
3376
+ * Array of all candidate values in the collection.
3377
+ */
3378
+ candidateValues: ReadonlyArray<JsonValue>;
3170
3379
  /**
3171
3380
  * Array of all resources in the collection.
3172
3381
  */
@@ -3828,6 +4037,11 @@ declare interface IJsonResourceTypeCreateParams {
3828
4037
  * instance.
3829
4038
  */
3830
4039
  index?: number;
4040
+ /**
4041
+ * Optional template for new instances of {@link ResourceTypes.JsonResourceType | JsonResourceType}
4042
+ * resources.
4043
+ */
4044
+ template?: JsonObject;
3831
4045
  }
3832
4046
 
3833
4047
  /**
@@ -3892,10 +4106,10 @@ declare interface ILiteralQualifierTypeCreateParams {
3892
4106
  */
3893
4107
  enumeratedValues?: ReadonlyArray<string>;
3894
4108
  /**
3895
- * Optional {@link QualifierTypes.LiteralValueHierarchyDecl | hierarchy declaration}
4109
+ * Optional {@link QualifierTypes.Config.LiteralValueHierarchyDecl | hierarchy declaration}
3896
4110
  * of literal values to use for matching. If not provided, no hierarchy will be used.
3897
4111
  */
3898
- hierarchy?: LiteralValueHierarchyDecl<string>;
4112
+ hierarchy?: Config_2.LiteralValueHierarchyDecl<string>;
3899
4113
  /**
3900
4114
  * Global index for this qualifier type.
3901
4115
  */
@@ -4354,6 +4568,10 @@ declare interface IQualifierType extends ICollectible<QualifierTypeName, Qualifi
4354
4568
  * The name of the qualifier type.
4355
4569
  */
4356
4570
  readonly name: QualifierTypeName;
4571
+ /**
4572
+ * Name of the underlying system type.
4573
+ */
4574
+ readonly systemTypeName: QualifierTypeName;
4357
4575
  /**
4358
4576
  * Unique key for this qualifier.
4359
4577
  */
@@ -4416,6 +4634,17 @@ declare interface IQualifierType extends ICollectible<QualifierTypeName, Qualifi
4416
4634
  * Sets the index for this qualifier type. Once set, index is immutable.
4417
4635
  */
4418
4636
  setIndex(index: number): Result<QualifierTypeIndex>;
4637
+ /**
4638
+ * Gets the configuration for this qualifier type.
4639
+ * @returns `Success` with the configuration if successful, `Failure` with an error message otherwise.
4640
+ */
4641
+ getConfigurationJson(): Result<JsonObject>;
4642
+ /**
4643
+ * Validates configuration JSON data for this qualifier type.
4644
+ * @param from - The unknown data to validate as configuration JSON.
4645
+ * @returns `Success` with validated JSON configuration if valid, `Failure` with an error message otherwise.
4646
+ */
4647
+ validateConfigurationJson(from: unknown): Result<JsonObject>;
4419
4648
  }
4420
4649
 
4421
4650
  /**
@@ -4576,7 +4805,7 @@ declare interface IReadOnlyResourceTreeBranch<T> {
4576
4805
  * Interface for a read-only result-based resource tree with navigation methods.
4577
4806
  * @public
4578
4807
  */
4579
- declare interface IReadOnlyResourceTreeChildren<T, TID extends string = ResourceId, TNAME extends string = ResourceName> extends IReadOnlyResultMap<ResourceName, IReadOnlyResourceTreeNode<T>> {
4808
+ declare interface IReadOnlyResourceTreeChildren<T, TID extends string = ResourceId, TNAME extends string = ResourceName> extends IReadOnlyResultMap<TNAME, IReadOnlyResourceTreeNode<T>> {
4580
4809
  /**
4581
4810
  * Gets a tree node by its full ResourceId path.
4582
4811
  * @param id - The ResourceId path to look up
@@ -4692,6 +4921,7 @@ declare interface IResourceBuilderCreateParams {
4692
4921
  conditionSets: ConditionSetCollector;
4693
4922
  resourceTypes: ReadOnlyResourceTypeCollector;
4694
4923
  decisions: AbstractDecisionCollector;
4924
+ candidateValues: CandidateValueCollector;
4695
4925
  }
4696
4926
 
4697
4927
  /**
@@ -4721,6 +4951,7 @@ declare interface IResourceCandidateCreateParams {
4721
4951
  resourceType?: ResourceType;
4722
4952
  parentConditions?: ReadonlyArray<Condition>;
4723
4953
  conditionSets: ConditionSetCollector;
4954
+ candidateValues: CandidateValueCollector;
4724
4955
  }
4725
4956
 
4726
4957
  /**
@@ -4960,6 +5191,31 @@ declare interface IResourceManagerCloneOptions extends IResourceDeclarationOptio
4960
5191
  readonly resourceTypes?: ReadOnlyResourceTypeCollector;
4961
5192
  }
4962
5193
 
5194
+ /**
5195
+ * Minimal resource resolver
5196
+ * @public
5197
+ */
5198
+ export declare interface IResourceResolver {
5199
+ /**
5200
+ * Resolves a resource to a composed value by merging matching candidates according to their merge methods.
5201
+ * Starting from the highest priority candidates, finds the first "full" candidate and merges all higher
5202
+ * priority "partial" candidates into it in ascending order of priority.
5203
+ * @param resource - The string id of the resource to resolve.
5204
+ * @returns `Success` with the composed JsonValue if successful,
5205
+ * or `Failure` with an error message if no candidates match or resolution fails.
5206
+ * @public
5207
+ */
5208
+ resolveComposedResourceValue(resource: string): Result<JsonValue>;
5209
+ /**
5210
+ * Creates a new {@link IResourceResolver | resource resolver} with the given context.
5211
+ * @param context - The context to use for the new resource resolver.
5212
+ * @returns `Success` with the new resource resolver if successful,
5213
+ * or `Failure` with an error message if the context is invalid.
5214
+ * @public
5215
+ */
5216
+ withContext(context: Record<string, string>): Result<IResourceResolver>;
5217
+ }
5218
+
4963
5219
  /**
4964
5220
  * A listener for {@link Runtime.ResourceResolver | ResourceResolver} cache activity.
4965
5221
  * @public
@@ -5161,11 +5417,14 @@ declare interface IResourceType<T = unknown> extends ICollectible<ResourceTypeNa
5161
5417
  /**
5162
5418
  * Creates a template for a new resource of this type.
5163
5419
  * The template provides a default structure for creating new resource instances.
5164
- * @param resourceId - The id for the new resource
5165
- * @returns A loose resource declaration with default values for this resource type
5420
+ * @param resourceId - The id for the new resource.
5421
+ * @param init - An optional initial value for the resource.
5422
+ * @param resolver - An optional resource resolver that can be used to create the template.
5423
+ * @param conditions - An optional set of conditions that must be met for the resource to be selected.
5424
+ * @returns A loose resource declaration with default values for this resource type.
5166
5425
  * @public
5167
5426
  */
5168
- createTemplate(resourceId: ResourceId): ResourceJson.Json.ILooseResourceDecl;
5427
+ createTemplate(resourceId: ResourceId, init?: JsonValue, conditions?: ResourceJson.Json.ConditionSetDecl, resolver?: IResourceResolver): Result<ResourceJson.Json.ILooseResourceDecl>;
5169
5428
  }
5170
5429
 
5171
5430
  /**
@@ -5175,6 +5434,7 @@ declare interface IResourceType<T = unknown> extends ICollectible<ResourceTypeNa
5175
5434
  declare interface IResourceTypeConfig {
5176
5435
  name: string;
5177
5436
  typeName: string;
5437
+ template?: JsonObject;
5178
5438
  }
5179
5439
 
5180
5440
  /**
@@ -5238,6 +5498,24 @@ declare function isResourceTreeRootOrNodeInit<T>(init: ResourceTreeNodeInit<T> |
5238
5498
  */
5239
5499
  declare function isSystemQualifierTypeConfig(config: IAnyQualifierTypeConfig): config is ISystemQualifierTypeConfig;
5240
5500
 
5501
+ /**
5502
+ * Checks if the given index is a valid candidate value index.
5503
+ *
5504
+ * @param index - The index to validate.
5505
+ * @returns `true` if the index is a valid candidate value index, otherwise `false`.
5506
+ * @public
5507
+ */
5508
+ declare function isValidCandidateValueIndex(index: number): index is CandidateValueIndex;
5509
+
5510
+ /**
5511
+ * Checks if the given key is a valid candidate value key.
5512
+ *
5513
+ * @param key - The key to validate.
5514
+ * @returns `true` if the key is a valid candidate value key, otherwise `false`.
5515
+ * @public
5516
+ */
5517
+ declare function isValidCandidateValueKey(key: string): key is CandidateValueKey;
5518
+
5241
5519
  /**
5242
5520
  * Determines whether a number is a valid condition index.
5243
5521
  * @param index - the number to validate
@@ -5466,7 +5744,7 @@ declare interface ISystemConfiguration {
5466
5744
  /** Optional description explaining the purpose and use case of the configuration. */
5467
5745
  description?: string;
5468
5746
  /** Qualifier type configurations that define the available qualifier types in the system. */
5469
- qualifierTypes: QualifierTypes.Config.ISystemQualifierTypeConfig[];
5747
+ qualifierTypes: QualifierTypes.Config.IAnyQualifierTypeConfig[];
5470
5748
  /** Qualifier declarations that define the available qualifiers in the system. */
5471
5749
  qualifiers: Qualifiers.IQualifierDecl[];
5472
5750
  /** Resource type configurations that define the available resource types in the system. */
@@ -5535,7 +5813,7 @@ declare interface ITerritoryQualifierTypeConfig {
5535
5813
  acceptLowercase?: boolean;
5536
5814
  allowedTerritories?: string[];
5537
5815
  /**
5538
- * Optional {@link QualifierTypes.LiteralValueHierarchyDecl | hierarchy declaration}
5816
+ * Optional {@link QualifierTypes.Config.LiteralValueHierarchyDecl | hierarchy declaration}
5539
5817
  * of territory values to use for matching. If not provided, no hierarchy will be used.
5540
5818
  */
5541
5819
  hierarchy?: LiteralValueHierarchyDecl<string>;
@@ -5568,10 +5846,10 @@ declare interface ITerritoryQualifierTypeCreateParams {
5568
5846
  */
5569
5847
  acceptLowercase?: boolean;
5570
5848
  /**
5571
- * Optional {@link QualifierTypes.LiteralValueHierarchyDecl | hierarchy declaration}
5849
+ * Optional {@link QualifierTypes.Config.LiteralValueHierarchyDecl | hierarchy declaration}
5572
5850
  * of territory values to use for matching. If not provided, no hierarchy will be used.
5573
5851
  */
5574
- hierarchy?: LiteralValueHierarchyDecl<string>;
5852
+ hierarchy?: Config_2.LiteralValueHierarchyDecl<string>;
5575
5853
  }
5576
5854
 
5577
5855
  /**
@@ -5888,18 +6166,29 @@ declare class JsonImporter implements IImporter {
5888
6166
  private _tryImportResourceTree;
5889
6167
  }
5890
6168
 
6169
+ /**
6170
+ * A `Converter` for {@link QualifierTypes.Config.IQualifierTypeConfig | QualifierTypeConfig} objects.
6171
+ * @returns A `Converter` for {@link QualifierTypes.Config.IQualifierTypeConfig | QualifierTypeConfig} objects.
6172
+ * @public
6173
+ */
6174
+ declare const jsonQualifierTypeConfig: Converter<Model_2.IQualifierTypeConfig<JsonObject>, Converters.IJsonConverterContext>;
6175
+
5891
6176
  /**
5892
6177
  * Implementation of a {@link ResourceTypes.ResourceType | ResourceType} for JSON values.
5893
6178
  * @public
5894
6179
  */
5895
6180
  declare class JsonResourceType extends ResourceType<JsonObject> {
6181
+ /**
6182
+ * {@inheritdoc ResourceTypes.ResourceType.systemTypeName}
6183
+ */
6184
+ readonly systemTypeName: ResourceTypeName;
5896
6185
  /**
5897
6186
  * Protected {@link ResourceTypes.JsonResourceType | JsonResourceType} constructor for use by subclasses.
5898
6187
  * Use {@link ResourceTypes.JsonResourceType.create | JsonResourceType.create} to create a new instance.
5899
6188
  * @param key - The key for the new {@link ResourceTypes.JsonResourceType | JsonResourceType} instance.
5900
6189
  * @param index - Optional index for the new {@link ResourceTypes.JsonResourceType | JsonResourceType} instance.
5901
6190
  */
5902
- protected constructor(key: ResourceTypeName, index?: number);
6191
+ protected constructor(key: ResourceTypeName, index?: number, template?: JsonObject);
5903
6192
  /**
5904
6193
  * Factory method to create a new {@link ResourceTypes.JsonResourceType | JsonResourceType} instance.
5905
6194
  * @param params - {@link ResourceTypes.IJsonResourceTypeCreateParams | Parameters} to create the new instance.
@@ -5923,11 +6212,6 @@ declare class JsonResourceType extends ResourceType<JsonObject> {
5923
6212
  * {@inheritdoc ResourceTypes.ResourceType.(validate:3)}
5924
6213
  */
5925
6214
  validate(json: JsonObject, completeness: 'partial'): Result<JsonObject>;
5926
- /**
5927
- * Gets the default template value for a JSON resource type.
5928
- * @returns An empty object as the default JSON value
5929
- */
5930
- protected getDefaultTemplateValue(): JsonObject;
5931
6215
  }
5932
6216
 
5933
6217
  /**
@@ -5955,6 +6239,10 @@ declare const LanguagePrioritySystemConfiguration: ISystemConfiguration;
5955
6239
  * @public
5956
6240
  */
5957
6241
  declare class LanguageQualifierType extends QualifierType {
6242
+ /**
6243
+ * {@inheritdoc QualifierTypes.IQualifierType.systemTypeName}
6244
+ */
6245
+ readonly systemTypeName: QualifierTypeName;
5958
6246
  /**
5959
6247
  * Creates a new instance of a {@link QualifierTypes.LanguageQualifierType | language qualifier type}.
5960
6248
  * @param name - Optional name for the qualifier type. Defaults to 'language'.
@@ -5984,6 +6272,27 @@ declare class LanguageQualifierType extends QualifierType {
5984
6272
  * {@inheritdoc QualifierTypes.IQualifierType.isValidConditionValue}
5985
6273
  */
5986
6274
  isValidConditionValue(value: string): value is QualifierConditionValue;
6275
+ /**
6276
+ * Gets a {@link QualifierTypes.Config.ISystemLanguageQualifierTypeConfig | strongly typed configuration object}
6277
+ * for this qualifier type.
6278
+ * @returns `Success` with the configuration if successful, `Failure` with an error message otherwise.
6279
+ */
6280
+ getConfiguration(): Result<Config_2.ISystemLanguageQualifierTypeConfig>;
6281
+ /**
6282
+ * {@inheritdoc QualifierTypes.IQualifierType.getConfigurationJson}
6283
+ */
6284
+ getConfigurationJson(): Result<JsonObject>;
6285
+ /**
6286
+ * {@inheritdoc QualifierTypes.IQualifierType.validateConfigurationJson}
6287
+ */
6288
+ validateConfigurationJson(from: unknown): Result<JsonObject>;
6289
+ /**
6290
+ * Validates a {@link QualifierTypes.Config.ISystemLanguageQualifierTypeConfig | strongly typed configuration object}
6291
+ * for this qualifier type.
6292
+ * @param from - The unknown data to validate as a configuration object.
6293
+ * @returns `Success` with the validated configuration if successful, `Failure` with an error message otherwise.
6294
+ */
6295
+ validateConfiguration(from: unknown): Result<Config_2.ISystemLanguageQualifierTypeConfig>;
5987
6296
  /**
5988
6297
  * Matches a single language condition against a single language context value using
5989
6298
  * {@link https://github.com/ErikFortune/fgv/tree/main/libraries/ts-bcp47#tag-matching | similarity matching}.
@@ -6008,6 +6317,10 @@ declare const languageQualifierTypeConfig: ObjectConverter<Model_2.ILanguageQual
6008
6317
  * @public
6009
6318
  */
6010
6319
  declare class LiteralQualifierType extends QualifierType {
6320
+ /**
6321
+ * {@inheritdoc QualifierTypes.IQualifierType.systemTypeName}
6322
+ */
6323
+ readonly systemTypeName: QualifierTypeName;
6011
6324
  /**
6012
6325
  * Indicates whether the qualifier match is case-sensitive.
6013
6326
  */
@@ -6043,6 +6356,27 @@ declare class LiteralQualifierType extends QualifierType {
6043
6356
  * {@inheritdoc QualifierTypes.IQualifierType.isPotentialMatch}
6044
6357
  */
6045
6358
  isPotentialMatch(conditionValue: string, contextValue: string): boolean;
6359
+ /**
6360
+ * Gets a {@link QualifierTypes.Config.ISystemLiteralQualifierTypeConfig | strongly typed configuration object}
6361
+ * for this qualifier type.
6362
+ * @returns `Success` with the configuration if successful, `Failure` with an error message otherwise.
6363
+ */
6364
+ getConfiguration(): Result<Config_2.ISystemLiteralQualifierTypeConfig>;
6365
+ /**
6366
+ * {@inheritdoc QualifierTypes.IQualifierType.getConfigurationJson}
6367
+ */
6368
+ getConfigurationJson(): Result<JsonObject>;
6369
+ /**
6370
+ * {@inheritdoc QualifierTypes.IQualifierType.validateConfigurationJson}
6371
+ */
6372
+ validateConfigurationJson(from: unknown): Result<JsonObject>;
6373
+ /**
6374
+ * Validates a {@link QualifierTypes.Config.ISystemLiteralQualifierTypeConfig | strongly typed configuration object}
6375
+ * for this qualifier type.
6376
+ * @param from - The unknown data to validate as a configuration object.
6377
+ * @returns `Success` with the validated configuration if successful, `Failure` with an error message otherwise.
6378
+ */
6379
+ validateConfiguration(from: unknown): Result<Config_2.ISystemLiteralQualifierTypeConfig>;
6046
6380
  /**
6047
6381
  * {@inheritdoc QualifierTypes.QualifierType._matchOne}
6048
6382
  */
@@ -6172,6 +6506,11 @@ declare class LiteralValueHierarchy<T extends string = string> {
6172
6506
  */
6173
6507
  match(condition: QualifierConditionValue, context: QualifierContextValue, __operator?: ConditionOperator): QualifierMatchScore;
6174
6508
  protected static _buildValuesFromHierarchy<T extends string>(params: ILiteralValueHierarchyCreateParams<T>): Result<ReadonlyMap<T, ILiteralValue<T>>>;
6509
+ /**
6510
+ * Converts the hierarchy to a record of parent-child relationships.
6511
+ * @returns A record of parent-child relationships.
6512
+ */
6513
+ asRecord(): Record<string, string>;
6175
6514
  }
6176
6515
 
6177
6516
  /**
@@ -6357,6 +6696,7 @@ declare namespace Model_2 {
6357
6696
  isSystemQualifierTypeConfig,
6358
6697
  IQualifierTypeConfig,
6359
6698
  ILanguageQualifierTypeConfig,
6699
+ LiteralValueHierarchyDecl,
6360
6700
  ITerritoryQualifierTypeConfig,
6361
6701
  ILiteralQualifierTypeConfig,
6362
6702
  ISystemLanguageQualifierTypeConfig,
@@ -6956,6 +7296,10 @@ export declare abstract class QualifierType implements IQualifierType {
6956
7296
  * {@inheritdoc QualifierTypes.IQualifierType.name}
6957
7297
  */
6958
7298
  readonly name: QualifierTypeName;
7299
+ /**
7300
+ * {@inheritdoc QualifierTypes.IQualifierType.systemTypeName}
7301
+ */
7302
+ abstract readonly systemTypeName: QualifierTypeName;
6959
7303
  /**
6960
7304
  * {@inheritdoc QualifierTypes.IQualifierType.key}
6961
7305
  */
@@ -7001,6 +7345,14 @@ export declare abstract class QualifierType implements IQualifierType {
7001
7345
  * {@inheritdoc QualifierTypes.IQualifierType.matches}
7002
7346
  */
7003
7347
  matches(condition: QualifierConditionValue, context: QualifierContextValue, operator: ConditionOperator): QualifierMatchScore;
7348
+ /**
7349
+ * {@inheritdoc QualifierTypes.IQualifierType.getConfigurationJson}
7350
+ */
7351
+ abstract getConfigurationJson(): Result<JsonObject>;
7352
+ /**
7353
+ * {@inheritdoc QualifierTypes.IQualifierType.validateConfigurationJson}
7354
+ */
7355
+ abstract validateConfigurationJson(from: unknown): Result<JsonObject>;
7004
7356
  /**
7005
7357
  * {@inheritdoc QualifierTypes.IQualifierType.setIndex}
7006
7358
  */
@@ -7080,6 +7432,14 @@ declare class QualifierTypeCollector extends ValidatingConvertingCollector<Quali
7080
7432
  protected static _toQualifierType(from: unknown): Result<QualifierType>;
7081
7433
  }
7082
7434
 
7435
+ /**
7436
+ * A `Converter` for {@link QualifierTypes.Config.IQualifierTypeConfig | QualifierTypeConfig} objects.
7437
+ * @returns A `Converter` for {@link QualifierTypes.Config.IQualifierTypeConfig | QualifierTypeConfig} objects.
7438
+ * @param config - A `Converter` for the configuration object.
7439
+ * @public
7440
+ */
7441
+ declare function qualifierTypeConfig<T, TD = unknown>(config: Converter<T, TD>): Converter<Model_2.IQualifierTypeConfig<T>, TD>;
7442
+
7083
7443
  /**
7084
7444
  * A factory that creates a {@link QualifierTypes.QualifierType | QualifierType} from a {@link QualifierTypes.Config.IAnyQualifierTypeConfig | system qualifier type configuration}
7085
7445
  * by chaining a supplied factory with a {@link Config.BuiltInQualifierTypeFactory | built-in factory} that handles built-in qualifier types.
@@ -7129,7 +7489,6 @@ declare namespace QualifierTypes {
7129
7489
  LanguageQualifierType,
7130
7490
  ILiteralQualifierTypeCreateParams,
7131
7491
  LiteralQualifierType,
7132
- LiteralValueHierarchyDecl,
7133
7492
  ILiteralValue,
7134
7493
  ILiteralValueHierarchyCreateParams,
7135
7494
  LiteralValueHierarchy,
@@ -7307,6 +7666,7 @@ declare namespace RegularExpressions {
7307
7666
  contextToken_2 as contextToken,
7308
7667
  conditionSetHash_2 as conditionSetHash,
7309
7668
  decisionKey_2 as decisionKey,
7669
+ candidateValueKey_2 as candidateValueKey,
7310
7670
  qualifierDefaultValueToken_2 as qualifierDefaultValueToken,
7311
7671
  qualifierDefaultValuesToken_2 as qualifierDefaultValuesToken,
7312
7672
  territoryCode
@@ -7463,6 +7823,10 @@ declare class ResourceBuilder {
7463
7823
  * Collector for {@link Decisions.AbstractDecision | abstract decisions}.
7464
7824
  */
7465
7825
  protected _decisions: AbstractDecisionCollector;
7826
+ /**
7827
+ * Collector for candidate values.
7828
+ */
7829
+ protected _candidateValues: CandidateValueCollector;
7466
7830
  /**
7467
7831
  * Constructor for a {@link Resources.ResourceBuilder | ResourceBuilder} object.
7468
7832
  * @param params - Parameters to construct the new {@link Resources.ResourceBuilder | ResourceBuilder}.
@@ -7540,10 +7904,16 @@ export declare class ResourceCandidate implements IResourceCandidate {
7540
7904
  * is a possible instance.
7541
7905
  */
7542
7906
  readonly id: ResourceId;
7907
+ /**
7908
+ * The candidate value that contains the JSON representation of the instance data.
7909
+ */
7910
+ readonly candidateValue: CandidateValue;
7543
7911
  /**
7544
7912
  * The JSON representation of the instance data to be applied.
7913
+ * @remarks
7914
+ * This property provides access to the JSON data from the underlying candidate value.
7545
7915
  */
7546
- readonly json: JsonObject;
7916
+ get json(): JsonObject;
7547
7917
  /**
7548
7918
  * The conditions under which this candidate applies.
7549
7919
  */
@@ -7807,6 +8177,11 @@ export declare class ResourceManagerBuilder implements IResourceManager<Resource
7807
8177
  * @internal
7808
8178
  */
7809
8179
  protected readonly _decisions: AbstractDecisionCollector;
8180
+ /**
8181
+ * The candidate value collector used by this resource manager.
8182
+ * @internal
8183
+ */
8184
+ protected readonly _candidateValues: CandidateValueCollector;
7810
8185
  /**
7811
8186
  * The {@link Resources.ResourceBuilder | resource builders} used by this resource manager.
7812
8187
  * @internal
@@ -8133,6 +8508,7 @@ export declare class ResourceManagerBuilder implements IResourceManager<Resource
8133
8508
  * @param decision - The decision containing condition sets.
8134
8509
  * @param resourceType - The resource type for the candidates.
8135
8510
  * @param builder - The builder to add candidates to.
8511
+ * @param candidateValues - Array of candidate values indexed by valueIndex.
8136
8512
  * @returns `Success` if all candidates were added successfully, `Failure` otherwise.
8137
8513
  * @internal
8138
8514
  */
@@ -8163,7 +8539,7 @@ declare const resourceName: Converter<ResourceName, unknown>;
8163
8539
  * and caching results for optimal performance.
8164
8540
  * @public
8165
8541
  */
8166
- export declare class ResourceResolver {
8542
+ export declare class ResourceResolver implements IResourceResolver {
8167
8543
  /**
8168
8544
  * The resource manager that defines available resources and provides condition access.
8169
8545
  */
@@ -8180,6 +8556,10 @@ export declare class ResourceResolver {
8180
8556
  * The configuration options for this resource resolver.
8181
8557
  */
8182
8558
  readonly options: IResourceResolverOptions;
8559
+ /**
8560
+ * The readonly qualifier collector that provides qualifier implementations.
8561
+ */
8562
+ get qualifiers(): IReadOnlyQualifierCollector;
8183
8563
  /**
8184
8564
  * The cache array for resolved conditions, indexed by condition index for O(1) lookup.
8185
8565
  * Each entry stores the resolved {@link Runtime.IConditionMatchResult | condition match result} for
@@ -8264,6 +8644,15 @@ export declare class ResourceResolver {
8264
8644
  * @public
8265
8645
  */
8266
8646
  resolveResource(resource: IResource): Result<IResourceCandidate>;
8647
+ /**
8648
+ * Resolves a resource by finding the best matching candidate.
8649
+ * Uses the resource's associated decision to determine the best match based on the current context.
8650
+ * @param resource - The string id of the resource to resolve.
8651
+ * @returns `Success` with the best matching candidate if successful,
8652
+ * or `Failure` with an error message if no candidates match or resolution fails.
8653
+ * @public
8654
+ */
8655
+ resolveResource(resource: string): Result<IResourceCandidate>;
8267
8656
  /**
8268
8657
  * Resolves all matching resource candidates in priority order.
8269
8658
  * Uses the resource's associated decision to determine all matching candidates based on the current context.
@@ -8273,6 +8662,15 @@ export declare class ResourceResolver {
8273
8662
  * @public
8274
8663
  */
8275
8664
  resolveAllResourceCandidates(resource: IResource): Result<ReadonlyArray<IResourceCandidate>>;
8665
+ /**
8666
+ * Resolves all matching resource candidates in priority order.
8667
+ * Uses the resource's associated decision to determine all matching candidates based on the current context.
8668
+ * @param resource - The string id of the resource to resolve.
8669
+ * @returns `Success` with an array of all matching candidates in priority order if successful,
8670
+ * or `Failure` with an error message if no candidates match or resolution fails.
8671
+ * @public
8672
+ */
8673
+ resolveAllResourceCandidates(resource: string): Result<ReadonlyArray<IResourceCandidate>>;
8276
8674
  /**
8277
8675
  * Resolves a resource to a composed value by merging matching candidates according to their merge methods.
8278
8676
  * Starting from the highest priority candidates, finds the first "full" candidate and merges all higher
@@ -8283,6 +8681,20 @@ export declare class ResourceResolver {
8283
8681
  * @public
8284
8682
  */
8285
8683
  resolveComposedResourceValue(resource: IResource): Result<JsonValue>;
8684
+ /**
8685
+ * Resolves a resource to a composed value by merging matching candidates according to their merge methods.
8686
+ * Starting from the highest priority candidates, finds the first "full" candidate and merges all higher
8687
+ * priority "partial" candidates into it in ascending order of priority.
8688
+ * @param resource - The string id of the resource to resolve.
8689
+ * @returns `Success` with the composed JsonValue if successful,
8690
+ * or `Failure` with an error message if no candidates match or resolution fails.
8691
+ * @public
8692
+ */
8693
+ resolveComposedResourceValue(resource: string): Result<JsonValue>;
8694
+ /**
8695
+ * {@inheritDoc IResourceResolver.withContext}
8696
+ */
8697
+ withContext(context: Record<string, string>): Result<ResourceResolver>;
8286
8698
  /**
8287
8699
  * Clears all caches (condition, condition set, and decision), forcing all cached items
8288
8700
  * to be re-evaluated on next access. This should be called when the context changes and cached
@@ -8370,6 +8782,11 @@ declare namespace Resources {
8370
8782
  ICandidateInfo,
8371
8783
  IReducedCandidate,
8372
8784
  CandidateReducer,
8785
+ ICandidateValue,
8786
+ ICandidateValueCreateParams,
8787
+ CandidateValue,
8788
+ ICandidateValueCollectorCreateParams,
8789
+ CandidateValueCollector,
8373
8790
  IResourceCandidateCreateParams,
8374
8791
  ICandidateDeclOptions,
8375
8792
  ResourceCandidate,
@@ -8533,15 +8950,20 @@ declare const resourceTreeRootDecl: Converter<Normalized.IResourceTreeRootDecl>;
8533
8950
  */
8534
8951
  export declare abstract class ResourceType<T = unknown> implements IResourceType<T> {
8535
8952
  private _collectible;
8953
+ private _template;
8536
8954
  /**
8537
8955
  * {@inheritdoc ResourceTypes.IResourceType.key}
8538
8956
  */
8539
8957
  get key(): ResourceTypeName;
8958
+ /**
8959
+ * Name of the underlying system type.
8960
+ */
8961
+ abstract readonly systemTypeName: ResourceTypeName;
8540
8962
  /**
8541
8963
  * {@inheritdoc ResourceTypes.IResourceType.index}
8542
8964
  */
8543
8965
  get index(): ResourceTypeIndex | undefined;
8544
- protected constructor(key: ResourceTypeName, index?: number);
8966
+ protected constructor(key: ResourceTypeName, index?: number, template?: JsonObject);
8545
8967
  /**
8546
8968
  * Validates properties of a {@link ResourceJson.Json.ILooseResourceCandidateDecl | resource candidate declaration} for
8547
8969
  * a resource instance value.
@@ -8596,16 +9018,20 @@ export declare abstract class ResourceType<T = unknown> implements IResourceType
8596
9018
  * Default implementation provides a basic template.
8597
9019
  * Subclasses can override to provide type-specific templates.
8598
9020
  * @param resourceId - The id for the new resource
9021
+ * @param init - An optional initial value for the resource.
9022
+ * @param conditions - An optional set of conditions that must be met for the resource to be selected.
9023
+ * @param resolver - An optional resource resolver that can be used to create the template.
8599
9024
  * @returns A loose resource declaration with default values for this resource type
8600
9025
  * @public
8601
9026
  */
8602
- createTemplate(resourceId: ResourceId): ResourceJson.Json.ILooseResourceDecl;
9027
+ createTemplate(resourceId: ResourceId, init?: JsonValue, conditions?: ResourceJson.Json.ConditionSetDecl, resolver?: IResourceResolver): Result<ResourceJson.Json.ILooseResourceDecl>;
8603
9028
  /**
8604
9029
  * Gets the default template value for this resource type.
8605
9030
  * Subclasses should override this to provide type-specific default values.
8606
9031
  * @returns The default JSON value for a new resource of this type
9032
+ * @public
8607
9033
  */
8608
- protected getDefaultTemplateValue(): JsonObject;
9034
+ getDefaultTemplateCandidate(json?: JsonValue, conditions?: ResourceJson.Json.ConditionSetDecl, __resolver?: IResourceResolver): Result<ResourceJson.Json.IChildResourceCandidateDecl>;
8609
9035
  }
8610
9036
 
8611
9037
  /**
@@ -8982,6 +9408,10 @@ declare const TerritoryPrioritySystemConfiguration: ISystemConfiguration;
8982
9408
  * @public
8983
9409
  */
8984
9410
  declare class TerritoryQualifierType extends QualifierType {
9411
+ /**
9412
+ * {@inheritdoc QualifierTypes.IQualifierType.systemTypeName}
9413
+ */
9414
+ readonly systemTypeName: QualifierTypeName;
8985
9415
  /**
8986
9416
  * Optional array enumerating allowed territories to further constrain the type.
8987
9417
  */
@@ -9023,6 +9453,25 @@ declare class TerritoryQualifierType extends QualifierType {
9023
9453
  * @public
9024
9454
  */
9025
9455
  static createFromConfig(config: Config_2.IQualifierTypeConfig<Config_2.ITerritoryQualifierTypeConfig>): Result<TerritoryQualifierType>;
9456
+ /**
9457
+ * {@inheritdoc QualifierTypes.IQualifierType.getConfigurationJson}
9458
+ */
9459
+ getConfiguration(): Result<Config_2.ISystemTerritoryQualifierTypeConfig>;
9460
+ /**
9461
+ * {@inheritdoc QualifierTypes.IQualifierType.getConfigurationJson}
9462
+ */
9463
+ getConfigurationJson(): Result<JsonObject>;
9464
+ /**
9465
+ * {@inheritdoc QualifierTypes.IQualifierType.validateConfigurationJson}
9466
+ */
9467
+ validateConfigurationJson(from: unknown): Result<JsonObject>;
9468
+ /**
9469
+ * Validates a {@link QualifierTypes.Config.ISystemTerritoryQualifierTypeConfig | strongly typed configuration object}
9470
+ * for this qualifier type.
9471
+ * @param from - The unknown data to validate as a configuration object.
9472
+ * @returns `Success` with the validated configuration if successful, `Failure` with an error message otherwise.
9473
+ */
9474
+ validateConfiguration(from: unknown): Result<Config_2.ISystemTerritoryQualifierTypeConfig>;
9026
9475
  /**
9027
9476
  * {@inheritdoc QualifierTypes.QualifierType._matchOne}
9028
9477
  */
@@ -9055,6 +9504,26 @@ declare class TerritoryQualifierType extends QualifierType {
9055
9504
  */
9056
9505
  declare const territoryQualifierTypeConfig: ObjectConverter<Model_2.ITerritoryQualifierTypeConfig, unknown>;
9057
9506
 
9507
+ /**
9508
+ * Converts a number to a {@link CandidateValueIndex | candidate value index}.
9509
+ *
9510
+ * @param index - The number to convert.
9511
+ * @returns `Success` with the converted index if valid, or `Failure` with an error message
9512
+ * if not.
9513
+ * @public
9514
+ */
9515
+ declare function toCandidateValueIndex(index: number): Result<CandidateValueIndex>;
9516
+
9517
+ /**
9518
+ * Converts a string to a {@link CandidateValueKey | candidate value key}.
9519
+ *
9520
+ * @param key - The key to convert.
9521
+ * @returns `Success` with the converted key if valid, or `Failure` with an error message
9522
+ * if not.
9523
+ * @public
9524
+ */
9525
+ declare function toCandidateValueKey(key: string): Result<CandidateValueKey>;
9526
+
9058
9527
  /**
9059
9528
  * Converts a number to a {@link ConditionIndex} if it is a valid condition index.
9060
9529
  * @param index - the number to convert
@@ -9354,12 +9823,16 @@ declare namespace Validate {
9354
9823
  isValidResourceIndex,
9355
9824
  isValidResourceTypeName,
9356
9825
  isValidResourceTypeIndex,
9826
+ isValidCandidateValueIndex,
9827
+ isValidCandidateValueKey,
9357
9828
  toResourceName,
9358
9829
  toResourceId,
9359
9830
  toOptionalResourceId,
9360
9831
  toResourceIndex,
9361
9832
  toResourceTypeName,
9362
- toResourceTypeIndex
9833
+ toResourceTypeIndex,
9834
+ toCandidateValueKey,
9835
+ toCandidateValueIndex
9363
9836
  }
9364
9837
  }
9365
9838
  export { Validate }