@fgv/ts-res 5.0.0-22 → 5.0.0-24

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 (288) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +665 -44
  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 +14 -0
  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/jsonResourceType.d.ts +4 -0
  28. package/lib/packlets/resource-types/jsonResourceType.js +4 -0
  29. package/lib/packlets/resource-types/resourceType.d.ts +4 -0
  30. package/lib/packlets/resources/candidateValue.d.ts +92 -0
  31. package/lib/{test/unit/qualifier-types/testQualifierType.js → packlets/resources/candidateValue.js} +63 -24
  32. package/lib/packlets/resources/candidateValueCollector.d.ts +55 -0
  33. package/lib/packlets/resources/candidateValueCollector.js +96 -0
  34. package/lib/packlets/resources/index.d.ts +2 -0
  35. package/lib/packlets/resources/index.js +2 -0
  36. package/lib/packlets/resources/resource.js +2 -2
  37. package/lib/packlets/resources/resourceBuilder.d.ts +6 -0
  38. package/lib/packlets/resources/resourceBuilder.js +3 -1
  39. package/lib/packlets/resources/resourceCandidate.d.ts +10 -1
  40. package/lib/packlets/resources/resourceCandidate.js +11 -5
  41. package/lib/packlets/resources/resourceManagerBuilder.d.ts +7 -0
  42. package/lib/packlets/resources/resourceManagerBuilder.js +13 -6
  43. package/lib/packlets/runtime/compiledResourceCollection.d.ts +20 -8
  44. package/lib/packlets/runtime/compiledResourceCollection.js +25 -4
  45. package/lib/packlets/runtime/index.d.ts +1 -0
  46. package/lib/packlets/runtime/index.js +1 -0
  47. package/lib/packlets/runtime/resource-tree/common.d.ts +1 -1
  48. package/lib/packlets/runtime/resourceTreeResolver.d.ts +152 -0
  49. package/lib/packlets/runtime/resourceTreeResolver.js +222 -0
  50. package/package.json +12 -12
  51. package/.vscode/4.json +0 -3
  52. package/.vscode/launch.json +0 -16
  53. package/.vscode/settings.json +0 -3
  54. package/dist/ts-res.d.ts +0 -9713
  55. package/dist/tsdoc-metadata.json +0 -11
  56. package/lib/test/data/sample.json +0 -32
  57. package/lib/test/unit/bundle/bundleBuilder.test.d.ts +0 -2
  58. package/lib/test/unit/bundle/bundleLoader.test.d.ts +0 -2
  59. package/lib/test/unit/bundle/bundleUtils.test.d.ts +0 -2
  60. package/lib/test/unit/bundle/convert.test.d.ts +0 -2
  61. package/lib/test/unit/bundle/integration.test.d.ts +0 -2
  62. package/lib/test/unit/bundle/model.test.d.ts +0 -2
  63. package/lib/test/unit/bundle/normalization.test.d.ts +0 -2
  64. package/lib/test/unit/common/conditions.test.d.ts +0 -2
  65. package/lib/test/unit/common/helpers/conditions.test.d.ts +0 -2
  66. package/lib/test/unit/common/helpers/contexts.test.d.ts +0 -2
  67. package/lib/test/unit/common/helpers/qualifierDefaultValues.test.d.ts +0 -2
  68. package/lib/test/unit/common/resources.test.d.ts +0 -2
  69. package/lib/test/unit/conditions/condition.test.d.ts +0 -2
  70. package/lib/test/unit/conditions/conditionCollector.test.d.ts +0 -2
  71. package/lib/test/unit/conditions/conditionScoreAsDefault.test.d.ts +0 -2
  72. package/lib/test/unit/conditions/conditionSet.test.d.ts +0 -2
  73. package/lib/test/unit/conditions/conditionSetCollector.test.d.ts +0 -2
  74. package/lib/test/unit/conditions/conditionToken.test.d.ts +0 -2
  75. package/lib/test/unit/conditions/convert.test.d.ts +0 -2
  76. package/lib/test/unit/config/common.test.d.ts +0 -2
  77. package/lib/test/unit/config/convert.test.d.ts +0 -2
  78. package/lib/test/unit/config/predefined/default.test.d.ts +0 -2
  79. package/lib/test/unit/config/predefined/extended.test.d.ts +0 -2
  80. package/lib/test/unit/config/systemConfiguration.test.d.ts +0 -2
  81. package/lib/test/unit/config/systemConfigurationInitParams.test.d.ts +0 -2
  82. package/lib/test/unit/context/contextToken.test.d.ts +0 -2
  83. package/lib/test/unit/context/convert.test.d.ts +0 -2
  84. package/lib/test/unit/decisions/abstractDecision.test.d.ts +0 -2
  85. package/lib/test/unit/decisions/abstractDecisionCollector.test.d.ts +0 -2
  86. package/lib/test/unit/decisions/candidate.test.d.ts +0 -2
  87. package/lib/test/unit/decisions/concreteDecision.test.d.ts +0 -2
  88. package/lib/test/unit/decisions/decision.test.d.ts +0 -2
  89. package/lib/test/unit/import/collectionImporter.test.d.ts +0 -2
  90. package/lib/test/unit/import/fsItem.test.d.ts +0 -2
  91. package/lib/test/unit/import/fsItemImporter.test.d.ts +0 -2
  92. package/lib/test/unit/import/importContext.test.d.ts +0 -2
  93. package/lib/test/unit/import/importManager.test.d.ts +0 -2
  94. package/lib/test/unit/import/jsonImporter.test.d.ts +0 -2
  95. package/lib/test/unit/import/pathImporter.test.d.ts +0 -2
  96. package/lib/test/unit/qualifier-types/convert.test.d.ts +0 -2
  97. package/lib/test/unit/qualifier-types/helpers.test.d.ts +0 -2
  98. package/lib/test/unit/qualifier-types/languageQualifierType.test.d.ts +0 -2
  99. package/lib/test/unit/qualifier-types/literalQualifierType.test.d.ts +0 -2
  100. package/lib/test/unit/qualifier-types/literalValueHierarchy.test.d.ts +0 -2
  101. package/lib/test/unit/qualifier-types/qualifierType.test.d.ts +0 -2
  102. package/lib/test/unit/qualifier-types/qualifierTypeCollector.test.d.ts +0 -2
  103. package/lib/test/unit/qualifier-types/territoryQualifierType.test.d.ts +0 -2
  104. package/lib/test/unit/qualifier-types/testQualifierType.d.ts +0 -15
  105. package/lib/test/unit/qualifiers/convert.test.d.ts +0 -2
  106. package/lib/test/unit/qualifiers/qualifierCollector.test.d.ts +0 -2
  107. package/lib/test/unit/qualifiers/qualifierDefaultValue.test.d.ts +0 -2
  108. package/lib/test/unit/qualifiers/qualifierDefaultValueToken.test.d.ts +0 -2
  109. package/lib/test/unit/resource-json/convert.test.d.ts +0 -2
  110. package/lib/test/unit/resource-json/nameInheritance.test.d.ts +0 -2
  111. package/lib/test/unit/resource-json/resourceDeclCollection.test.d.ts +0 -2
  112. package/lib/test/unit/resource-json/resourceDeclTree.test.d.ts +0 -2
  113. package/lib/test/unit/resource-types/derivedResourceType.test.d.ts +0 -2
  114. package/lib/test/unit/resource-types/jsonResourceType.test.d.ts +0 -2
  115. package/lib/test/unit/resource-types/resourceTypeCollector.test.d.ts +0 -2
  116. package/lib/test/unit/resource-types/testDerivedResourceType.d.ts +0 -78
  117. package/lib/test/unit/resource-types/testDerivedResourceType.js +0 -110
  118. package/lib/test/unit/resources/candidateReducer.integration.test.d.ts +0 -2
  119. package/lib/test/unit/resources/candidateReducer.test.d.ts +0 -2
  120. package/lib/test/unit/resources/reduceCandidates.test.d.ts +0 -2
  121. package/lib/test/unit/resources/reduceQualifiers.comprehensive.test.d.ts +0 -2
  122. package/lib/test/unit/resources/reduceQualifiers.test.d.ts +0 -2
  123. package/lib/test/unit/resources/resource.test.d.ts +0 -2
  124. package/lib/test/unit/resources/resourceBuilder.test.d.ts +0 -2
  125. package/lib/test/unit/resources/resourceCandidate.test.d.ts +0 -2
  126. package/lib/test/unit/resources/resourceManagerBuilder.clone.test.d.ts +0 -2
  127. package/lib/test/unit/resources/resourceManagerBuilder.getBuiltResourceTree.test.d.ts +0 -2
  128. package/lib/test/unit/resources/resourceManagerBuilder.test.d.ts +0 -2
  129. package/lib/test/unit/runtime/cacheListener.test.d.ts +0 -2
  130. package/lib/test/unit/runtime/cacheMetrics.test.d.ts +0 -2
  131. package/lib/test/unit/runtime/compiledResourceCollection.test.d.ts +0 -2
  132. package/lib/test/unit/runtime/conditionSetResolutionResult.comprehensive.test.d.ts +0 -2
  133. package/lib/test/unit/runtime/conditionSetResolutionResult.test.d.ts +0 -2
  134. package/lib/test/unit/runtime/context/contextQualifierProvider.test.d.ts +0 -2
  135. package/lib/test/unit/runtime/context/contextQualifierProviderValidator.test.d.ts +0 -2
  136. package/lib/test/unit/runtime/context/simpleContextQualifierProvider.test.d.ts +0 -2
  137. package/lib/test/unit/runtime/context/validatingSimpleContextQualifierProvider.test.d.ts +0 -2
  138. package/lib/test/unit/runtime/resource-tree/readOnlyResourceTree.test.d.ts +0 -2
  139. package/lib/test/unit/runtime/resource-tree/resourceTreeChildren.test.d.ts +0 -2
  140. package/lib/test/unit/runtime/resource-tree/resourceTreeChildrenValidator.test.d.ts +0 -2
  141. package/lib/test/unit/runtime/resourceResolver.coverage.test.d.ts +0 -2
  142. package/lib/test/unit/runtime/resourceResolver.defaultResolution.test.d.ts +0 -2
  143. package/lib/test/unit/runtime/resourceResolver.newFeatures.test.d.ts +0 -2
  144. package/lib/test/unit/runtime/resourceResolver.test.d.ts +0 -2
  145. package/lib/test/unit/runtime/validate.test.d.ts +0 -2
  146. package/lib/test/unit/zip-archive/convert.test.d.ts +0 -2
  147. package/lib/test/unit/zip-archive/json.test.d.ts +0 -2
  148. package/lib/test/unit/zip-archive/zipArchiveCreator.test.d.ts +0 -2
  149. package/lib/test/unit/zip-archive/zipArchiveFormat.test.d.ts +0 -2
  150. package/lib/test/unit/zip-archive/zipArchiveIdempotency.test.d.ts +0 -2
  151. package/lib/test/unit/zip-archive/zipArchiveLoader.test.d.ts +0 -2
  152. package/src/index.ts +0 -75
  153. package/src/packlets/bundle/bundleBuilder.ts +0 -159
  154. package/src/packlets/bundle/bundleLoader.ts +0 -157
  155. package/src/packlets/bundle/bundleNormalizer.ts +0 -173
  156. package/src/packlets/bundle/bundleUtils.ts +0 -142
  157. package/src/packlets/bundle/convert.ts +0 -87
  158. package/src/packlets/bundle/index.ts +0 -52
  159. package/src/packlets/bundle/model.ts +0 -138
  160. package/src/packlets/common/conditions.ts +0 -226
  161. package/src/packlets/common/convert.ts +0 -184
  162. package/src/packlets/common/helpers/conditions.ts +0 -84
  163. package/src/packlets/common/helpers/context.ts +0 -88
  164. package/src/packlets/common/helpers/index.ts +0 -26
  165. package/src/packlets/common/helpers/qualifierDefaultValues.ts +0 -91
  166. package/src/packlets/common/helpers/resources.ts +0 -96
  167. package/src/packlets/common/index.ts +0 -30
  168. package/src/packlets/common/resources.ts +0 -105
  169. package/src/packlets/common/validate/conditions.ts +0 -595
  170. package/src/packlets/common/validate/index.ts +0 -27
  171. package/src/packlets/common/validate/regularExpressions.ts +0 -92
  172. package/src/packlets/common/validate/resources.ts +0 -170
  173. package/src/packlets/conditions/condition.ts +0 -351
  174. package/src/packlets/conditions/conditionCollector.ts +0 -103
  175. package/src/packlets/conditions/conditionDecls.ts +0 -50
  176. package/src/packlets/conditions/conditionSet.ts +0 -318
  177. package/src/packlets/conditions/conditionSetCollector.ts +0 -127
  178. package/src/packlets/conditions/conditionSetDecls.ts +0 -41
  179. package/src/packlets/conditions/conditionToken.ts +0 -180
  180. package/src/packlets/conditions/convert/conditionSetDecls.ts +0 -72
  181. package/src/packlets/conditions/convert/decls.ts +0 -95
  182. package/src/packlets/conditions/convert/index.ts +0 -24
  183. package/src/packlets/conditions/index.ts +0 -33
  184. package/src/packlets/config/common.ts +0 -107
  185. package/src/packlets/config/configInitFactory.ts +0 -142
  186. package/src/packlets/config/convert.ts +0 -61
  187. package/src/packlets/config/index.ts +0 -30
  188. package/src/packlets/config/json.ts +0 -43
  189. package/src/packlets/config/predefined/default.ts +0 -150
  190. package/src/packlets/config/predefined/extended.ts +0 -198
  191. package/src/packlets/config/predefined/index.ts +0 -26
  192. package/src/packlets/config/systemConfiguration.ts +0 -217
  193. package/src/packlets/context/contextDecls.ts +0 -76
  194. package/src/packlets/context/contextToken.ts +0 -252
  195. package/src/packlets/context/convert/decls.ts +0 -126
  196. package/src/packlets/context/convert/index.ts +0 -23
  197. package/src/packlets/context/index.ts +0 -27
  198. package/src/packlets/decisions/abstractDecision.ts +0 -87
  199. package/src/packlets/decisions/abstractDecisionCollector.ts +0 -122
  200. package/src/packlets/decisions/candidate.ts +0 -101
  201. package/src/packlets/decisions/common.ts +0 -37
  202. package/src/packlets/decisions/concreteDecision.ts +0 -157
  203. package/src/packlets/decisions/decision.ts +0 -172
  204. package/src/packlets/decisions/index.ts +0 -28
  205. package/src/packlets/import/fsItem.ts +0 -212
  206. package/src/packlets/import/importContext.ts +0 -183
  207. package/src/packlets/import/importManager.ts +0 -187
  208. package/src/packlets/import/importable.ts +0 -107
  209. package/src/packlets/import/importers/collectionImporter.ts +0 -153
  210. package/src/packlets/import/importers/fsItemImporter.ts +0 -154
  211. package/src/packlets/import/importers/importer.ts +0 -58
  212. package/src/packlets/import/importers/index.ts +0 -27
  213. package/src/packlets/import/importers/jsonImporter.ts +0 -133
  214. package/src/packlets/import/importers/pathImporter.ts +0 -134
  215. package/src/packlets/import/index.ts +0 -29
  216. package/src/packlets/qualifier-types/config/convert.ts +0 -108
  217. package/src/packlets/qualifier-types/config/index.ts +0 -27
  218. package/src/packlets/qualifier-types/config/json.ts +0 -126
  219. package/src/packlets/qualifier-types/convert.ts +0 -77
  220. package/src/packlets/qualifier-types/helpers.ts +0 -94
  221. package/src/packlets/qualifier-types/index.ts +0 -34
  222. package/src/packlets/qualifier-types/languageQualifierType.ts +0 -143
  223. package/src/packlets/qualifier-types/literalQualifierType.ts +0 -244
  224. package/src/packlets/qualifier-types/literalValueHierarchy.ts +0 -332
  225. package/src/packlets/qualifier-types/qualifierType.ts +0 -360
  226. package/src/packlets/qualifier-types/qualifierTypeCollector.ts +0 -102
  227. package/src/packlets/qualifier-types/territoryQualifierType.ts +0 -255
  228. package/src/packlets/qualifiers/convert/decls.ts +0 -90
  229. package/src/packlets/qualifiers/convert/index.ts +0 -24
  230. package/src/packlets/qualifiers/convert/qualifier.ts +0 -55
  231. package/src/packlets/qualifiers/index.ts +0 -31
  232. package/src/packlets/qualifiers/qualifier.ts +0 -169
  233. package/src/packlets/qualifiers/qualifierCollector.ts +0 -194
  234. package/src/packlets/qualifiers/qualifierDecl.ts +0 -80
  235. package/src/packlets/qualifiers/qualifierDefaultValueDecls.ts +0 -57
  236. package/src/packlets/qualifiers/qualifierDefaultValueToken.ts +0 -230
  237. package/src/packlets/resource-json/compiled/common.ts +0 -35
  238. package/src/packlets/resource-json/compiled/convert.ts +0 -143
  239. package/src/packlets/resource-json/compiled/index.ts +0 -27
  240. package/src/packlets/resource-json/compiled/json.ts +0 -239
  241. package/src/packlets/resource-json/convert.ts +0 -236
  242. package/src/packlets/resource-json/helpers.ts +0 -284
  243. package/src/packlets/resource-json/index.ts +0 -33
  244. package/src/packlets/resource-json/json.ts +0 -295
  245. package/src/packlets/resource-json/normalized.ts +0 -211
  246. package/src/packlets/resource-json/resourceDeclCollection.ts +0 -117
  247. package/src/packlets/resource-json/resourceDeclContainer.ts +0 -48
  248. package/src/packlets/resource-json/resourceDeclTree.ts +0 -116
  249. package/src/packlets/resource-types/config/convert.ts +0 -38
  250. package/src/packlets/resource-types/config/index.ts +0 -27
  251. package/src/packlets/resource-types/config/json.ts +0 -33
  252. package/src/packlets/resource-types/helpers.ts +0 -44
  253. package/src/packlets/resource-types/index.ts +0 -30
  254. package/src/packlets/resource-types/jsonResourceType.ts +0 -102
  255. package/src/packlets/resource-types/resourceType.ts +0 -292
  256. package/src/packlets/resource-types/resourceTypeCollector.ts +0 -79
  257. package/src/packlets/resources/candidateReducer.ts +0 -331
  258. package/src/packlets/resources/common.ts +0 -114
  259. package/src/packlets/resources/index.ts +0 -28
  260. package/src/packlets/resources/resource.ts +0 -307
  261. package/src/packlets/resources/resourceBuilder.ts +0 -269
  262. package/src/packlets/resources/resourceCandidate.ts +0 -333
  263. package/src/packlets/resources/resourceManagerBuilder.ts +0 -1169
  264. package/src/packlets/runtime/cacheListener.ts +0 -113
  265. package/src/packlets/runtime/cacheMetrics.ts +0 -206
  266. package/src/packlets/runtime/compiledResourceCollection.ts +0 -607
  267. package/src/packlets/runtime/conditionSetResolutionResult.ts +0 -160
  268. package/src/packlets/runtime/context/contextQualifierProvider.ts +0 -117
  269. package/src/packlets/runtime/context/contextQualifierProviderValidator.ts +0 -281
  270. package/src/packlets/runtime/context/index.ts +0 -26
  271. package/src/packlets/runtime/context/simpleContextQualifierProvider.ts +0 -225
  272. package/src/packlets/runtime/context/validatingSimpleContextQualifierProvider.ts +0 -96
  273. package/src/packlets/runtime/iResourceManager.ts +0 -130
  274. package/src/packlets/runtime/index.ts +0 -35
  275. package/src/packlets/runtime/resource-tree/common.ts +0 -126
  276. package/src/packlets/runtime/resource-tree/index.ts +0 -26
  277. package/src/packlets/runtime/resource-tree/readOnlyResourceTree.ts +0 -342
  278. package/src/packlets/runtime/resource-tree/resourceTreeChildren.ts +0 -125
  279. package/src/packlets/runtime/resource-tree/resourceTreeChildrenValidator.ts +0 -187
  280. package/src/packlets/runtime/resourceResolver.ts +0 -712
  281. package/src/packlets/runtime/validate.ts +0 -63
  282. package/src/packlets/zip-archive/convert.ts +0 -121
  283. package/src/packlets/zip-archive/index.ts +0 -76
  284. package/src/packlets/zip-archive/json.ts +0 -91
  285. package/src/packlets/zip-archive/types.ts +0 -140
  286. package/src/packlets/zip-archive/zipArchiveCreator.ts +0 -229
  287. package/src/packlets/zip-archive/zipArchiveFormat.ts +0 -158
  288. package/src/packlets/zip-archive/zipArchiveLoader.ts +0 -370
@@ -20,12 +20,46 @@
20
20
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  * SOFTWARE.
22
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
+ })();
23
56
  Object.defineProperty(exports, "__esModule", { value: true });
24
57
  exports.LiteralQualifierType = void 0;
25
58
  const ts_utils_1 = require("@fgv/ts-utils");
26
59
  const common_1 = require("../common");
27
60
  const qualifierType_1 = require("./qualifierType");
28
61
  const literalValueHierarchy_1 = require("./literalValueHierarchy");
62
+ const Config = __importStar(require("./config"));
29
63
  const ts_json_base_1 = require("@fgv/ts-json-base");
30
64
  /**
31
65
  * A {@link QualifierTypes.QualifierType | qualifier} that matches a literal value,
@@ -49,6 +83,10 @@ class LiteralQualifierType extends qualifierType_1.QualifierType {
49
83
  allowContextList,
50
84
  index: index !== undefined ? common_1.Convert.qualifierTypeIndex.convert(index).orThrow() : undefined
51
85
  });
86
+ /**
87
+ * {@inheritdoc QualifierTypes.IQualifierType.systemTypeName}
88
+ */
89
+ this.systemTypeName = common_1.Convert.qualifierTypeName.convert('literal').orThrow();
52
90
  this.caseSensitive = caseSensitive === true;
53
91
  this.enumeratedValues = enumeratedValues
54
92
  ? (0, ts_utils_1.mapResults)(Array.from(enumeratedValues).map(LiteralQualifierType.toLiteralConditionValue)).orThrow()
@@ -91,6 +129,45 @@ class LiteralQualifierType extends qualifierType_1.QualifierType {
91
129
  }
92
130
  return false;
93
131
  }
132
+ /**
133
+ * Gets a {@link QualifierTypes.Config.ISystemLiteralQualifierTypeConfig | strongly typed configuration object}
134
+ * for this qualifier type.
135
+ * @returns `Success` with the configuration if successful, `Failure` with an error message otherwise.
136
+ */
137
+ getConfiguration() {
138
+ return this.getConfigurationJson().onSuccess((json) => Config.Convert.systemLiteralQualifierTypeConfig.convert(json));
139
+ }
140
+ /**
141
+ * {@inheritdoc QualifierTypes.IQualifierType.getConfigurationJson}
142
+ */
143
+ getConfigurationJson() {
144
+ const hierarchy = this.hierarchy ? { hierarchy: this.hierarchy.asRecord() } : {};
145
+ const enumeratedValues = this.enumeratedValues
146
+ ? { enumeratedValues: [...this.enumeratedValues] }
147
+ : {};
148
+ return (0, ts_utils_1.succeed)({
149
+ name: this.name,
150
+ systemType: 'literal',
151
+ configuration: Object.assign(Object.assign({ allowContextList: this.allowContextList, caseSensitive: this.caseSensitive }, enumeratedValues), hierarchy)
152
+ });
153
+ }
154
+ /**
155
+ * {@inheritdoc QualifierTypes.IQualifierType.validateConfigurationJson}
156
+ */
157
+ validateConfigurationJson(from) {
158
+ return Config.Convert.systemLiteralQualifierTypeConfig
159
+ .convert(from)
160
+ .onSuccess((config) => (0, ts_utils_1.succeed)(config));
161
+ }
162
+ /**
163
+ * Validates a {@link QualifierTypes.Config.ISystemLiteralQualifierTypeConfig | strongly typed configuration object}
164
+ * for this qualifier type.
165
+ * @param from - The unknown data to validate as a configuration object.
166
+ * @returns `Success` with the validated configuration if successful, `Failure` with an error message otherwise.
167
+ */
168
+ validateConfiguration(from) {
169
+ return this.validateConfigurationJson(from).onSuccess((json) => Config.Convert.systemLiteralQualifierTypeConfig.convert(json));
170
+ }
94
171
  /**
95
172
  * {@inheritdoc QualifierTypes.QualifierType._matchOne}
96
173
  */
@@ -1,15 +1,6 @@
1
1
  import { Result } from '@fgv/ts-utils';
2
2
  import { ConditionOperator, QualifierConditionValue, QualifierContextValue, QualifierMatchScore } from '../common';
3
- /**
4
- * Declares a hierarchy of literal values. The keys are the names of the values, and the
5
- * values are the names of their parents.
6
- * @remarks
7
- * The hierarchy is defined as a tree, where each value can have multiple children but
8
- * only one parent. The root of the tree has no parent. The hierarchy is used to
9
- * determine the relationship between values when matching conditions and contexts.
10
- * @public
11
- */
12
- export type LiteralValueHierarchyDecl<T extends string> = Partial<Record<T, T>>;
3
+ import { LiteralValueHierarchyDecl } from './config';
13
4
  /**
14
5
  * Describes a single valid literal value including optional parent and child values.
15
6
  * @public
@@ -110,5 +101,10 @@ export declare class LiteralValueHierarchy<T extends string = string> {
110
101
  */
111
102
  match(condition: QualifierConditionValue, context: QualifierContextValue, __operator?: ConditionOperator): QualifierMatchScore;
112
103
  protected static _buildValuesFromHierarchy<T extends string>(params: ILiteralValueHierarchyCreateParams<T>): Result<ReadonlyMap<T, ILiteralValue<T>>>;
104
+ /**
105
+ * Converts the hierarchy to a record of parent-child relationships.
106
+ * @returns A record of parent-child relationships.
107
+ */
108
+ asRecord(): Record<string, string>;
113
109
  }
114
110
  //# sourceMappingURL=literalValueHierarchy.d.ts.map
@@ -223,6 +223,16 @@ class LiteralValueHierarchy {
223
223
  }
224
224
  return errors.returnOrReport((0, ts_utils_1.succeed)(valueMap));
225
225
  }
226
+ /**
227
+ * Converts the hierarchy to a record of parent-child relationships.
228
+ * @returns A record of parent-child relationships.
229
+ */
230
+ asRecord() {
231
+ const entries = Array.from(this.values.values())
232
+ .filter((v) => v.parent !== undefined)
233
+ .map((v) => [v.name, v.parent.name]);
234
+ return Object.fromEntries(entries);
235
+ }
226
236
  }
227
237
  exports.LiteralValueHierarchy = LiteralValueHierarchy;
228
238
  //# sourceMappingURL=literalValueHierarchy.js.map
@@ -1,5 +1,6 @@
1
1
  import { Collections, ICollectible, Result } from '@fgv/ts-utils';
2
2
  import { ConditionOperator, QualifierConditionValue, QualifierContextValue, QualifierMatchScore, QualifierTypeIndex, QualifierTypeName } from '../common';
3
+ import { JsonObject } from '@fgv/ts-json-base';
3
4
  /**
4
5
  * Interface for a qualifier type. A qualifier type implements the build and
5
6
  * runtime semantics for some class of related qualifiers (e.g. language,
@@ -11,6 +12,10 @@ export interface IQualifierType extends ICollectible<QualifierTypeName, Qualifie
11
12
  * The name of the qualifier type.
12
13
  */
13
14
  readonly name: QualifierTypeName;
15
+ /**
16
+ * Name of the underlying system type.
17
+ */
18
+ readonly systemTypeName: QualifierTypeName;
14
19
  /**
15
20
  * Unique key for this qualifier.
16
21
  */
@@ -73,6 +78,17 @@ export interface IQualifierType extends ICollectible<QualifierTypeName, Qualifie
73
78
  * Sets the index for this qualifier type. Once set, index is immutable.
74
79
  */
75
80
  setIndex(index: number): Result<QualifierTypeIndex>;
81
+ /**
82
+ * Gets the configuration for this qualifier type.
83
+ * @returns `Success` with the configuration if successful, `Failure` with an error message otherwise.
84
+ */
85
+ getConfigurationJson(): Result<JsonObject>;
86
+ /**
87
+ * Validates configuration JSON data for this qualifier type.
88
+ * @param from - The unknown data to validate as configuration JSON.
89
+ * @returns `Success` with validated JSON configuration if valid, `Failure` with an error message otherwise.
90
+ */
91
+ validateConfigurationJson(from: unknown): Result<JsonObject>;
76
92
  }
77
93
  /**
78
94
  * Parameters used to create a base {@link QualifierTypes.QualifierType | qualifier type}.
@@ -103,6 +119,10 @@ export declare abstract class QualifierType implements IQualifierType {
103
119
  * {@inheritdoc QualifierTypes.IQualifierType.name}
104
120
  */
105
121
  readonly name: QualifierTypeName;
122
+ /**
123
+ * {@inheritdoc QualifierTypes.IQualifierType.systemTypeName}
124
+ */
125
+ abstract readonly systemTypeName: QualifierTypeName;
106
126
  /**
107
127
  * {@inheritdoc QualifierTypes.IQualifierType.key}
108
128
  */
@@ -148,6 +168,14 @@ export declare abstract class QualifierType implements IQualifierType {
148
168
  * {@inheritdoc QualifierTypes.IQualifierType.matches}
149
169
  */
150
170
  matches(condition: QualifierConditionValue, context: QualifierContextValue, operator: ConditionOperator): QualifierMatchScore;
171
+ /**
172
+ * {@inheritdoc QualifierTypes.IQualifierType.getConfigurationJson}
173
+ */
174
+ abstract getConfigurationJson(): Result<JsonObject>;
175
+ /**
176
+ * {@inheritdoc QualifierTypes.IQualifierType.validateConfigurationJson}
177
+ */
178
+ abstract validateConfigurationJson(from: unknown): Result<JsonObject>;
151
179
  /**
152
180
  * {@inheritdoc QualifierTypes.IQualifierType.setIndex}
153
181
  */
@@ -1,8 +1,9 @@
1
1
  import { Result } from '@fgv/ts-utils';
2
- import { QualifierConditionValue, QualifierContextValue, QualifierMatchScore, ConditionOperator } from '../common';
2
+ import { QualifierConditionValue, QualifierContextValue, QualifierMatchScore, ConditionOperator, QualifierTypeName } from '../common';
3
3
  import { QualifierType } from './qualifierType';
4
- import { LiteralValueHierarchy, LiteralValueHierarchyDecl } from './literalValueHierarchy';
4
+ import { LiteralValueHierarchy } from './literalValueHierarchy';
5
5
  import * as Config from './config';
6
+ import { JsonObject } from '@fgv/ts-json-base';
6
7
  /**
7
8
  * Parameters used to create a new {@link QualifierTypes.TerritoryQualifierType | TerritoryQualifierType} instance.
8
9
  * @public
@@ -30,10 +31,10 @@ export interface ITerritoryQualifierTypeCreateParams {
30
31
  */
31
32
  acceptLowercase?: boolean;
32
33
  /**
33
- * Optional {@link QualifierTypes.LiteralValueHierarchyDecl | hierarchy declaration}
34
+ * Optional {@link QualifierTypes.Config.LiteralValueHierarchyDecl | hierarchy declaration}
34
35
  * of territory values to use for matching. If not provided, no hierarchy will be used.
35
36
  */
36
- hierarchy?: LiteralValueHierarchyDecl<string>;
37
+ hierarchy?: Config.LiteralValueHierarchyDecl<string>;
37
38
  }
38
39
  /**
39
40
  * Qualifier type for territory values. Territories are two-letter ISO-3166-2
@@ -42,6 +43,10 @@ export interface ITerritoryQualifierTypeCreateParams {
42
43
  * @public
43
44
  */
44
45
  export declare class TerritoryQualifierType extends QualifierType {
46
+ /**
47
+ * {@inheritdoc QualifierTypes.IQualifierType.systemTypeName}
48
+ */
49
+ readonly systemTypeName: QualifierTypeName;
45
50
  /**
46
51
  * Optional array enumerating allowed territories to further constrain the type.
47
52
  */
@@ -83,6 +88,25 @@ export declare class TerritoryQualifierType extends QualifierType {
83
88
  * @public
84
89
  */
85
90
  static createFromConfig(config: Config.IQualifierTypeConfig<Config.ITerritoryQualifierTypeConfig>): Result<TerritoryQualifierType>;
91
+ /**
92
+ * {@inheritdoc QualifierTypes.IQualifierType.getConfigurationJson}
93
+ */
94
+ getConfiguration(): Result<Config.ISystemTerritoryQualifierTypeConfig>;
95
+ /**
96
+ * {@inheritdoc QualifierTypes.IQualifierType.getConfigurationJson}
97
+ */
98
+ getConfigurationJson(): Result<JsonObject>;
99
+ /**
100
+ * {@inheritdoc QualifierTypes.IQualifierType.validateConfigurationJson}
101
+ */
102
+ validateConfigurationJson(from: unknown): Result<JsonObject>;
103
+ /**
104
+ * Validates a {@link QualifierTypes.Config.ISystemTerritoryQualifierTypeConfig | strongly typed configuration object}
105
+ * for this qualifier type.
106
+ * @param from - The unknown data to validate as a configuration object.
107
+ * @returns `Success` with the validated configuration if successful, `Failure` with an error message otherwise.
108
+ */
109
+ validateConfiguration(from: unknown): Result<Config.ISystemTerritoryQualifierTypeConfig>;
86
110
  /**
87
111
  * {@inheritdoc QualifierTypes.QualifierType._matchOne}
88
112
  */
@@ -20,12 +20,46 @@
20
20
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  * SOFTWARE.
22
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
+ })();
23
56
  Object.defineProperty(exports, "__esModule", { value: true });
24
57
  exports.TerritoryQualifierType = void 0;
25
58
  const ts_utils_1 = require("@fgv/ts-utils");
26
59
  const common_1 = require("../common");
27
60
  const qualifierType_1 = require("./qualifierType");
28
61
  const literalValueHierarchy_1 = require("./literalValueHierarchy");
62
+ const Config = __importStar(require("./config"));
29
63
  const ts_json_base_1 = require("@fgv/ts-json-base");
30
64
  /**
31
65
  * Qualifier type for territory values. Territories are two-letter ISO-3166-2
@@ -51,6 +85,12 @@ class TerritoryQualifierType extends qualifierType_1.QualifierType {
51
85
  allowContextList,
52
86
  index: validIndex
53
87
  });
88
+ /**
89
+ * {@inheritdoc QualifierTypes.IQualifierType.systemTypeName}
90
+ */
91
+ this.systemTypeName = common_1.Convert.qualifierTypeName
92
+ .convert('territory')
93
+ .orThrow();
54
94
  this.allowedTerritories = validTerritories;
55
95
  this.acceptLowercase = acceptLowercase === true;
56
96
  if (hierarchy) {
@@ -106,6 +146,43 @@ class TerritoryQualifierType extends qualifierType_1.QualifierType {
106
146
  hierarchy: territoryConfig.hierarchy
107
147
  }).onSuccess(TerritoryQualifierType.create);
108
148
  }
149
+ /**
150
+ * {@inheritdoc QualifierTypes.IQualifierType.getConfigurationJson}
151
+ */
152
+ getConfiguration() {
153
+ return this.getConfigurationJson().onSuccess((json) => Config.Convert.systemTerritoryQualifierTypeConfig.convert(json));
154
+ }
155
+ /**
156
+ * {@inheritdoc QualifierTypes.IQualifierType.getConfigurationJson}
157
+ */
158
+ getConfigurationJson() {
159
+ const hierarchy = this.hierarchy ? { hierarchy: this.hierarchy.asRecord() } : {};
160
+ const allowedTerritories = this.allowedTerritories
161
+ ? { allowedTerritories: [...this.allowedTerritories] }
162
+ : {};
163
+ return (0, ts_utils_1.succeed)({
164
+ name: this.name,
165
+ systemType: 'territory',
166
+ configuration: Object.assign(Object.assign({ allowContextList: this.allowContextList, acceptLowercase: this.acceptLowercase }, allowedTerritories), hierarchy)
167
+ });
168
+ }
169
+ /**
170
+ * {@inheritdoc QualifierTypes.IQualifierType.validateConfigurationJson}
171
+ */
172
+ validateConfigurationJson(from) {
173
+ return Config.Convert.systemTerritoryQualifierTypeConfig
174
+ .convert(from)
175
+ .onSuccess((config) => (0, ts_utils_1.succeed)(config));
176
+ }
177
+ /**
178
+ * Validates a {@link QualifierTypes.Config.ISystemTerritoryQualifierTypeConfig | strongly typed configuration object}
179
+ * for this qualifier type.
180
+ * @param from - The unknown data to validate as a configuration object.
181
+ * @returns `Success` with the validated configuration if successful, `Failure` with an error message otherwise.
182
+ */
183
+ validateConfiguration(from) {
184
+ return this.validateConfigurationJson(from).onSuccess((json) => Config.Convert.systemTerritoryQualifierTypeConfig.convert(json));
185
+ }
109
186
  /**
110
187
  * {@inheritdoc QualifierTypes.QualifierType._matchOne}
111
188
  */
@@ -136,7 +136,7 @@ exports.compiledAbstractDecision = ts_utils_1.Converters.strictObject({
136
136
  * @public
137
137
  */
138
138
  exports.compiledCandidate = ts_utils_1.Converters.strictObject({
139
- json: ts_json_base_1.Converters.jsonValue,
139
+ valueIndex: Common.Convert.candidateValueIndex,
140
140
  isPartial: ts_utils_1.Converters.boolean,
141
141
  mergeMethod: Common.Convert.resourceValueMergeMethod
142
142
  });
@@ -162,6 +162,7 @@ exports.compiledResourceCollection = ts_utils_1.Converters.strictObject({
162
162
  conditions: ts_utils_1.Converters.arrayOf(exports.compiledCondition),
163
163
  conditionSets: ts_utils_1.Converters.arrayOf(exports.compiledConditionSet),
164
164
  decisions: ts_utils_1.Converters.arrayOf(exports.compiledAbstractDecision),
165
+ candidateValues: ts_utils_1.Converters.arrayOf(ts_json_base_1.Converters.jsonValue),
165
166
  resources: ts_utils_1.Converters.arrayOf(exports.compiledResource)
166
167
  });
167
168
  //# sourceMappingURL=convert.js.map
@@ -132,9 +132,9 @@ export interface ICompiledAbstractDecision {
132
132
  */
133
133
  export interface ICompiledCandidate {
134
134
  /**
135
- * The JSON value of the candidate.
135
+ * The global index of the JSON value of the candidate.
136
136
  */
137
- json: JsonValue;
137
+ valueIndex: Common.CandidateValueIndex;
138
138
  /**
139
139
  * Indicates if this is a partial resource that needs to be merged.
140
140
  */
@@ -196,6 +196,10 @@ export interface ICompiledResourceCollection {
196
196
  * Array of all decisions in the collection.
197
197
  */
198
198
  decisions: ReadonlyArray<ICompiledAbstractDecision>;
199
+ /**
200
+ * Array of all candidate values in the collection.
201
+ */
202
+ candidateValues: ReadonlyArray<JsonValue>;
199
203
  /**
200
204
  * Array of all resources in the collection.
201
205
  */
@@ -28,6 +28,10 @@ export interface IJsonResourceTypeCreateParams {
28
28
  * @public
29
29
  */
30
30
  export declare class JsonResourceType extends ResourceType<JsonObject> {
31
+ /**
32
+ * {@inheritdoc ResourceTypes.ResourceType.systemTypeName}
33
+ */
34
+ readonly systemTypeName: ResourceTypeName;
31
35
  /**
32
36
  * Protected {@link ResourceTypes.JsonResourceType | JsonResourceType} constructor for use by subclasses.
33
37
  * Use {@link ResourceTypes.JsonResourceType.create | JsonResourceType.create} to create a new instance.
@@ -39,6 +39,10 @@ class JsonResourceType extends resourceType_1.ResourceType {
39
39
  */
40
40
  constructor(key, index, template) {
41
41
  super(key, index, template);
42
+ /**
43
+ * {@inheritdoc ResourceTypes.ResourceType.systemTypeName}
44
+ */
45
+ this.systemTypeName = common_1.Convert.resourceTypeName.convert('json').orThrow();
42
46
  }
43
47
  /**
44
48
  * Factory method to create a new {@link ResourceTypes.JsonResourceType | JsonResourceType} instance.
@@ -108,6 +108,10 @@ export declare abstract class ResourceType<T = unknown> implements IResourceType
108
108
  * {@inheritdoc ResourceTypes.IResourceType.key}
109
109
  */
110
110
  get key(): ResourceTypeName;
111
+ /**
112
+ * Name of the underlying system type.
113
+ */
114
+ abstract readonly systemTypeName: ResourceTypeName;
111
115
  /**
112
116
  * {@inheritdoc ResourceTypes.IResourceType.index}
113
117
  */
@@ -0,0 +1,92 @@
1
+ import { JsonValue } from '@fgv/ts-json-base';
2
+ import { Collections, Hash, Result } from '@fgv/ts-utils';
3
+ import { CandidateValueIndex, CandidateValueKey } from '../common';
4
+ /**
5
+ * Interface for a candidate value that can be collected and indexed.
6
+ * Candidate values are normalized JSON values that can be shared across
7
+ * multiple resource candidates to reduce duplication.
8
+ * @public
9
+ */
10
+ export interface ICandidateValue extends Collections.ICollectible<CandidateValueKey, CandidateValueIndex> {
11
+ /**
12
+ * The unique key for this candidate value, derived from the hash of the normalized JSON.
13
+ */
14
+ readonly key: CandidateValueKey;
15
+ /**
16
+ * The index of this candidate value in the collection.
17
+ */
18
+ readonly index: CandidateValueIndex | undefined;
19
+ /**
20
+ * The normalized JSON value.
21
+ */
22
+ readonly json: JsonValue;
23
+ /**
24
+ * Sets the index of this candidate value.
25
+ * @param index - The index to set.
26
+ * @returns `Success` with the index if successful, or `Failure` with an error message if not.
27
+ */
28
+ setIndex(index: number): Result<CandidateValueIndex>;
29
+ }
30
+ /**
31
+ * Parameters for creating a {@link Resources.CandidateValue | CandidateValue}.
32
+ * @public
33
+ */
34
+ export interface ICandidateValueCreateParams {
35
+ /**
36
+ * The JSON value to store. Will be normalized during creation.
37
+ */
38
+ json: JsonValue;
39
+ /**
40
+ * Optional normalizer to use for normalizing the JSON value.
41
+ * If not provided, a default Crc32Normalizer will be used.
42
+ */
43
+ normalizer?: Hash.Crc32Normalizer;
44
+ /**
45
+ * Optional index if the value is already indexed.
46
+ */
47
+ index?: number;
48
+ }
49
+ /**
50
+ * Implementation of a candidate value that stores normalized JSON data.
51
+ * The value is normalized on creation and a hash-based key is generated
52
+ * for efficient deduplication.
53
+ * @public
54
+ */
55
+ export declare class CandidateValue implements ICandidateValue {
56
+ private readonly _collectible;
57
+ private readonly _json;
58
+ /**
59
+ * The unique key for this candidate value.
60
+ */
61
+ get key(): CandidateValueKey;
62
+ /**
63
+ * The index of this candidate value in the collection.
64
+ */
65
+ get index(): CandidateValueIndex | undefined;
66
+ /**
67
+ * The normalized JSON value.
68
+ */
69
+ get json(): JsonValue;
70
+ /**
71
+ * Constructor for a {@link Resources.CandidateValue} object.
72
+ * @param params - Parameters to create the candidate value.
73
+ * @internal
74
+ */
75
+ protected constructor(params: ICandidateValueCreateParams);
76
+ /**
77
+ * Creates a new {@link Resources.CandidateValue} object.
78
+ * @param params - Parameters to create the candidate value.
79
+ * @returns `Success` with the new candidate value if successful,
80
+ * or `Failure` with an error message if not.
81
+ * @public
82
+ */
83
+ static create(params: ICandidateValueCreateParams): Result<CandidateValue>;
84
+ /**
85
+ * Sets the index of this candidate value.
86
+ * @param index - The index to set.
87
+ * @returns `Success` with the index if successful, or `Failure` with an error message if not.
88
+ * @public
89
+ */
90
+ setIndex(index: number): Result<CandidateValueIndex>;
91
+ }
92
+ //# sourceMappingURL=candidateValue.d.ts.map
@@ -54,36 +54,75 @@ var __importStar = (this && this.__importStar) || (function () {
54
54
  };
55
55
  })();
56
56
  Object.defineProperty(exports, "__esModule", { value: true });
57
- exports.TestQualifierType = void 0;
57
+ exports.CandidateValue = void 0;
58
58
  const ts_utils_1 = require("@fgv/ts-utils");
59
- const TsRes = __importStar(require("../../../index"));
60
- class TestQualifierType extends TsRes.QualifierTypes.QualifierType {
59
+ const common_1 = require("../common");
60
+ const Common = __importStar(require("../common"));
61
+ /**
62
+ * Implementation of a candidate value that stores normalized JSON data.
63
+ * The value is normalized on creation and a hash-based key is generated
64
+ * for efficient deduplication.
65
+ * @public
66
+ */
67
+ class CandidateValue {
68
+ /**
69
+ * The unique key for this candidate value.
70
+ */
71
+ get key() {
72
+ return this._collectible.key;
73
+ }
74
+ /**
75
+ * The index of this candidate value in the collection.
76
+ */
77
+ get index() {
78
+ return this._collectible.index;
79
+ }
80
+ /**
81
+ * The normalized JSON value.
82
+ */
83
+ get json() {
84
+ return this._json;
85
+ }
86
+ /**
87
+ * Constructor for a {@link Resources.CandidateValue} object.
88
+ * @param params - Parameters to create the candidate value.
89
+ * @internal
90
+ */
61
91
  constructor(params) {
62
92
  var _a;
63
- super({
64
- name: (_a = params === null || params === void 0 ? void 0 : params.name) !== null && _a !== void 0 ? _a : 'test',
65
- allowContextList: (params === null || params === void 0 ? void 0 : params.allowContextList) === 'true',
66
- index: params === null || params === void 0 ? void 0 : params.index
93
+ const normalizer = (_a = params.normalizer) !== null && _a !== void 0 ? _a : new ts_utils_1.Hash.Crc32Normalizer();
94
+ // Normalize the JSON value
95
+ const normalizedResult = normalizer.normalize(params.json);
96
+ this._json = normalizedResult.orThrow();
97
+ // Generate key from the normalized value using computeHash
98
+ const keyResult = normalizer.computeHash(this._json);
99
+ const key = common_1.Convert.candidateValueKey.convert(keyResult.orThrow()).orThrow();
100
+ // Create the collectible with the key and optional index
101
+ this._collectible = new ts_utils_1.Collections.Collectible({
102
+ key,
103
+ index: params.index,
104
+ indexConverter: Common.Convert.candidateValueIndex
67
105
  });
68
106
  }
107
+ /**
108
+ * Creates a new {@link Resources.CandidateValue} object.
109
+ * @param params - Parameters to create the candidate value.
110
+ * @returns `Success` with the new candidate value if successful,
111
+ * or `Failure` with an error message if not.
112
+ * @public
113
+ */
69
114
  static create(params) {
70
- return (0, ts_utils_1.captureResult)(() => new TestQualifierType(params));
71
- }
72
- isValidConditionValue(value) {
73
- return true;
74
- }
75
- validateCondition(value, operator) {
76
- return this.isValidConditionValue(value) ? (0, ts_utils_1.succeed)(value) : (0, ts_utils_1.fail)(`Invalid condition value: ${value}`);
115
+ return (0, ts_utils_1.captureResult)(() => new CandidateValue(params));
77
116
  }
78
- _matchOne(condition, context, operator) {
79
- if (condition === context) {
80
- return TsRes.PerfectMatch;
81
- }
82
- if (condition.toLowerCase() === context.toLowerCase()) {
83
- return 0.5;
84
- }
85
- return TsRes.NoMatch;
117
+ /**
118
+ * Sets the index of this candidate value.
119
+ * @param index - The index to set.
120
+ * @returns `Success` with the index if successful, or `Failure` with an error message if not.
121
+ * @public
122
+ */
123
+ setIndex(index) {
124
+ return this._collectible.setIndex(index);
86
125
  }
87
126
  }
88
- exports.TestQualifierType = TestQualifierType;
89
- //# sourceMappingURL=testQualifierType.js.map
127
+ exports.CandidateValue = CandidateValue;
128
+ //# sourceMappingURL=candidateValue.js.map