@fgv/ts-res 5.0.0-3 → 5.0.0-31

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 (379) hide show
  1. package/README.md +794 -137
  2. package/dist/ts-res.d.ts +2671 -355
  3. package/dist/tsdoc-metadata.json +1 -1
  4. package/eslint.config.js +16 -0
  5. package/lib/index.d.ts +11 -2
  6. package/lib/index.js +25 -2
  7. package/lib/packlets/bundle/bundleBuilder.d.ts +41 -0
  8. package/lib/packlets/bundle/bundleBuilder.js +134 -0
  9. package/lib/packlets/bundle/bundleLoader.d.ts +72 -0
  10. package/lib/packlets/bundle/bundleLoader.js +105 -0
  11. package/lib/packlets/bundle/bundleNormalizer.d.ts +73 -0
  12. package/lib/packlets/bundle/bundleNormalizer.js +142 -0
  13. package/lib/packlets/bundle/bundleUtils.d.ts +70 -0
  14. package/lib/packlets/bundle/bundleUtils.js +117 -0
  15. package/lib/packlets/bundle/convert.d.ts +33 -0
  16. package/lib/packlets/bundle/convert.js +78 -0
  17. package/lib/packlets/bundle/index.d.ts +21 -0
  18. package/lib/packlets/bundle/index.js +83 -0
  19. package/lib/packlets/bundle/model.d.ts +100 -0
  20. package/lib/packlets/bundle/model.js +24 -0
  21. package/lib/packlets/common/convert.d.ts +15 -0
  22. package/lib/packlets/common/convert.js +16 -1
  23. package/lib/packlets/common/helpers/context.js +1 -0
  24. package/lib/packlets/common/helpers/resources.d.ts +7 -0
  25. package/lib/packlets/common/helpers/resources.js +13 -0
  26. package/lib/packlets/common/resources.d.ts +48 -1
  27. package/lib/packlets/common/validate/conditions.d.ts +17 -1
  28. package/lib/packlets/common/validate/conditions.js +32 -6
  29. package/lib/packlets/common/validate/regularExpressions.d.ts +4 -0
  30. package/lib/packlets/common/validate/regularExpressions.js +5 -1
  31. package/lib/packlets/common/validate/resources.d.ts +35 -1
  32. package/lib/packlets/common/validate/resources.js +55 -0
  33. package/lib/packlets/conditions/condition.js +1 -0
  34. package/lib/packlets/conditions/conditionSet.d.ts +9 -0
  35. package/lib/packlets/conditions/conditionSet.js +75 -1
  36. package/lib/packlets/config/configInitFactory.d.ts +217 -0
  37. package/lib/packlets/config/configInitFactory.js +302 -0
  38. package/lib/packlets/config/convert.d.ts +9 -0
  39. package/lib/packlets/config/convert.js +12 -1
  40. package/lib/packlets/config/index.d.ts +1 -0
  41. package/lib/packlets/config/index.js +1 -0
  42. package/lib/packlets/config/json.d.ts +1 -1
  43. package/lib/packlets/config/systemConfiguration.d.ts +16 -3
  44. package/lib/packlets/config/systemConfiguration.js +19 -40
  45. package/lib/packlets/import/fsItem.d.ts +2 -1
  46. package/lib/packlets/import/fsItem.js +9 -13
  47. package/lib/packlets/import/importManager.d.ts +2 -1
  48. package/lib/packlets/import/importers/jsonImporter.js +1 -0
  49. package/lib/packlets/import/importers/pathImporter.d.ts +2 -1
  50. package/lib/packlets/import/importers/pathImporter.js +2 -1
  51. package/lib/packlets/qualifier-types/config/convert.d.ts +22 -1
  52. package/lib/packlets/qualifier-types/config/convert.js +67 -2
  53. package/lib/packlets/qualifier-types/config/json.d.ts +24 -2
  54. package/lib/packlets/qualifier-types/config/json.js +11 -0
  55. package/lib/packlets/qualifier-types/convert.d.ts +1 -1
  56. package/lib/packlets/qualifier-types/helpers.d.ts +14 -5
  57. package/lib/packlets/qualifier-types/helpers.js +2 -2
  58. package/lib/packlets/qualifier-types/languageQualifierType.d.ts +28 -2
  59. package/lib/packlets/qualifier-types/languageQualifierType.js +73 -0
  60. package/lib/packlets/qualifier-types/literalQualifierType.d.ts +31 -5
  61. package/lib/packlets/qualifier-types/literalQualifierType.js +75 -0
  62. package/lib/packlets/qualifier-types/literalValueHierarchy.d.ts +7 -11
  63. package/lib/packlets/qualifier-types/literalValueHierarchy.js +12 -1
  64. package/lib/packlets/qualifier-types/qualifierType.d.ts +31 -2
  65. package/lib/packlets/qualifier-types/territoryQualifierType.d.ts +31 -5
  66. package/lib/packlets/qualifier-types/territoryQualifierType.js +80 -0
  67. package/lib/packlets/qualifiers/qualifierCollector.js +1 -2
  68. package/lib/packlets/resource-json/compiled/convert.js +2 -1
  69. package/lib/packlets/resource-json/compiled/json.d.ts +6 -2
  70. package/lib/packlets/resource-types/config/convert.d.ts +1 -1
  71. package/lib/packlets/resource-types/config/convert.js +3 -1
  72. package/lib/packlets/resource-types/config/json.d.ts +3 -1
  73. package/lib/packlets/resource-types/jsonResourceType.d.ts +14 -5
  74. package/lib/packlets/resource-types/jsonResourceType.js +8 -4
  75. package/lib/packlets/resource-types/resourceType.d.ts +115 -14
  76. package/lib/packlets/resource-types/resourceType.js +39 -3
  77. package/lib/packlets/resources/candidateReducer.js +3 -0
  78. package/lib/packlets/resources/candidateValue.d.ts +92 -0
  79. package/lib/packlets/resources/candidateValue.js +128 -0
  80. package/lib/packlets/resources/candidateValueCollector.d.ts +55 -0
  81. package/lib/packlets/resources/candidateValueCollector.js +96 -0
  82. package/lib/packlets/resources/common.d.ts +26 -0
  83. package/lib/packlets/resources/index.d.ts +2 -0
  84. package/lib/packlets/resources/index.js +2 -0
  85. package/lib/packlets/resources/resource.d.ts +6 -6
  86. package/lib/packlets/resources/resource.js +5 -10
  87. package/lib/packlets/resources/resourceBuilder.d.ts +6 -0
  88. package/lib/packlets/resources/resourceBuilder.js +4 -1
  89. package/lib/packlets/resources/resourceCandidate.d.ts +15 -2
  90. package/lib/packlets/resources/resourceCandidate.js +17 -5
  91. package/lib/packlets/resources/resourceManagerBuilder.d.ts +189 -11
  92. package/lib/packlets/resources/resourceManagerBuilder.js +481 -17
  93. package/lib/packlets/runtime/cacheListener.d.ts +9 -0
  94. package/lib/packlets/runtime/cacheListener.js +6 -0
  95. package/lib/packlets/runtime/cacheMetrics.d.ts +6 -0
  96. package/lib/packlets/runtime/cacheMetrics.js +11 -0
  97. package/lib/packlets/runtime/compiledResourceCollection.d.ts +23 -11
  98. package/lib/packlets/runtime/compiledResourceCollection.js +65 -28
  99. package/lib/packlets/runtime/conditionSetResolutionResult.js +3 -0
  100. package/lib/packlets/runtime/context/contextQualifierProvider.d.ts +53 -3
  101. package/lib/packlets/runtime/context/contextQualifierProviderValidator.d.ts +82 -37
  102. package/lib/packlets/runtime/context/contextQualifierProviderValidator.js +49 -77
  103. package/lib/packlets/runtime/context/simpleContextQualifierProvider.d.ts +23 -2
  104. package/lib/packlets/runtime/context/simpleContextQualifierProvider.js +53 -31
  105. package/lib/packlets/runtime/context/validatingSimpleContextQualifierProvider.d.ts +4 -4
  106. package/lib/packlets/runtime/context/validatingSimpleContextQualifierProvider.js +2 -2
  107. package/lib/packlets/runtime/iResourceManager.d.ts +13 -5
  108. package/lib/packlets/runtime/index.d.ts +1 -0
  109. package/lib/packlets/runtime/index.js +1 -0
  110. package/lib/packlets/runtime/resource-tree/common.d.ts +1 -1
  111. package/lib/packlets/runtime/resource-tree/resourceTreeChildrenValidator.d.ts +7 -7
  112. package/lib/packlets/runtime/resource-tree/resourceTreeChildrenValidator.js +5 -5
  113. package/lib/packlets/runtime/resourceResolver.d.ts +60 -1
  114. package/lib/packlets/runtime/resourceResolver.js +89 -45
  115. package/lib/packlets/runtime/resourceTreeResolver.d.ts +152 -0
  116. package/lib/packlets/runtime/resourceTreeResolver.js +222 -0
  117. package/lib/packlets/runtime/validate.js +1 -0
  118. package/lib/packlets/zip-archive/convert.d.ts +52 -0
  119. package/lib/packlets/zip-archive/convert.js +103 -0
  120. package/lib/packlets/zip-archive/index.d.ts +23 -0
  121. package/lib/packlets/zip-archive/index.js +95 -0
  122. package/lib/packlets/zip-archive/json.d.ts +64 -0
  123. package/lib/packlets/zip-archive/json.js +24 -0
  124. package/lib/packlets/zip-archive/types.d.ts +98 -0
  125. package/lib/packlets/zip-archive/types.js +39 -0
  126. package/lib/packlets/zip-archive/zipArchiveCreator.d.ts +35 -0
  127. package/lib/packlets/zip-archive/zipArchiveCreator.js +195 -0
  128. package/lib/packlets/zip-archive/zipArchiveFormat.d.ts +70 -0
  129. package/lib/packlets/zip-archive/zipArchiveFormat.js +184 -0
  130. package/lib/packlets/zip-archive/zipArchiveLoader.d.ts +70 -0
  131. package/lib/packlets/zip-archive/zipArchiveLoader.js +285 -0
  132. package/package.json +26 -32
  133. package/CLAUDE.md +0 -186
  134. package/EXAMPLE_INIT_PARAMS.md +0 -88
  135. package/PROGRESS_SUMMARY.md +0 -48
  136. package/lib/index.d.ts.map +0 -1
  137. package/lib/index.js.map +0 -1
  138. package/lib/packlets/common/conditions.d.ts.map +0 -1
  139. package/lib/packlets/common/conditions.js.map +0 -1
  140. package/lib/packlets/common/convert.d.ts.map +0 -1
  141. package/lib/packlets/common/convert.js.map +0 -1
  142. package/lib/packlets/common/helpers/conditions.d.ts.map +0 -1
  143. package/lib/packlets/common/helpers/conditions.js.map +0 -1
  144. package/lib/packlets/common/helpers/context.d.ts.map +0 -1
  145. package/lib/packlets/common/helpers/context.js.map +0 -1
  146. package/lib/packlets/common/helpers/index.d.ts.map +0 -1
  147. package/lib/packlets/common/helpers/index.js.map +0 -1
  148. package/lib/packlets/common/helpers/qualifierDefaultValues.d.ts.map +0 -1
  149. package/lib/packlets/common/helpers/qualifierDefaultValues.js.map +0 -1
  150. package/lib/packlets/common/helpers/resources.d.ts.map +0 -1
  151. package/lib/packlets/common/helpers/resources.js.map +0 -1
  152. package/lib/packlets/common/index.d.ts.map +0 -1
  153. package/lib/packlets/common/index.js.map +0 -1
  154. package/lib/packlets/common/resources.d.ts.map +0 -1
  155. package/lib/packlets/common/resources.js.map +0 -1
  156. package/lib/packlets/common/validate/conditions.d.ts.map +0 -1
  157. package/lib/packlets/common/validate/conditions.js.map +0 -1
  158. package/lib/packlets/common/validate/index.d.ts.map +0 -1
  159. package/lib/packlets/common/validate/index.js.map +0 -1
  160. package/lib/packlets/common/validate/regularExpressions.d.ts.map +0 -1
  161. package/lib/packlets/common/validate/regularExpressions.js.map +0 -1
  162. package/lib/packlets/common/validate/resources.d.ts.map +0 -1
  163. package/lib/packlets/common/validate/resources.js.map +0 -1
  164. package/lib/packlets/conditions/condition.d.ts.map +0 -1
  165. package/lib/packlets/conditions/condition.js.map +0 -1
  166. package/lib/packlets/conditions/conditionCollector.d.ts.map +0 -1
  167. package/lib/packlets/conditions/conditionCollector.js.map +0 -1
  168. package/lib/packlets/conditions/conditionDecls.d.ts.map +0 -1
  169. package/lib/packlets/conditions/conditionDecls.js.map +0 -1
  170. package/lib/packlets/conditions/conditionSet.d.ts.map +0 -1
  171. package/lib/packlets/conditions/conditionSet.js.map +0 -1
  172. package/lib/packlets/conditions/conditionSetCollector.d.ts.map +0 -1
  173. package/lib/packlets/conditions/conditionSetCollector.js.map +0 -1
  174. package/lib/packlets/conditions/conditionSetDecls.d.ts.map +0 -1
  175. package/lib/packlets/conditions/conditionSetDecls.js.map +0 -1
  176. package/lib/packlets/conditions/conditionToken.d.ts.map +0 -1
  177. package/lib/packlets/conditions/conditionToken.js.map +0 -1
  178. package/lib/packlets/conditions/convert/conditionSetDecls.d.ts.map +0 -1
  179. package/lib/packlets/conditions/convert/conditionSetDecls.js.map +0 -1
  180. package/lib/packlets/conditions/convert/decls.d.ts.map +0 -1
  181. package/lib/packlets/conditions/convert/decls.js.map +0 -1
  182. package/lib/packlets/conditions/convert/index.d.ts.map +0 -1
  183. package/lib/packlets/conditions/convert/index.js.map +0 -1
  184. package/lib/packlets/conditions/index.d.ts.map +0 -1
  185. package/lib/packlets/conditions/index.js.map +0 -1
  186. package/lib/packlets/config/common.d.ts.map +0 -1
  187. package/lib/packlets/config/common.js.map +0 -1
  188. package/lib/packlets/config/convert.d.ts.map +0 -1
  189. package/lib/packlets/config/convert.js.map +0 -1
  190. package/lib/packlets/config/index.d.ts.map +0 -1
  191. package/lib/packlets/config/index.js.map +0 -1
  192. package/lib/packlets/config/json.d.ts.map +0 -1
  193. package/lib/packlets/config/json.js.map +0 -1
  194. package/lib/packlets/config/predefined/default.d.ts.map +0 -1
  195. package/lib/packlets/config/predefined/default.js.map +0 -1
  196. package/lib/packlets/config/predefined/extended.d.ts.map +0 -1
  197. package/lib/packlets/config/predefined/extended.js.map +0 -1
  198. package/lib/packlets/config/predefined/index.d.ts.map +0 -1
  199. package/lib/packlets/config/predefined/index.js.map +0 -1
  200. package/lib/packlets/config/systemConfiguration.d.ts.map +0 -1
  201. package/lib/packlets/config/systemConfiguration.js.map +0 -1
  202. package/lib/packlets/context/contextDecls.d.ts.map +0 -1
  203. package/lib/packlets/context/contextDecls.js.map +0 -1
  204. package/lib/packlets/context/contextToken.d.ts.map +0 -1
  205. package/lib/packlets/context/contextToken.js.map +0 -1
  206. package/lib/packlets/context/convert/decls.d.ts.map +0 -1
  207. package/lib/packlets/context/convert/decls.js.map +0 -1
  208. package/lib/packlets/context/convert/index.d.ts.map +0 -1
  209. package/lib/packlets/context/convert/index.js.map +0 -1
  210. package/lib/packlets/context/index.d.ts.map +0 -1
  211. package/lib/packlets/context/index.js.map +0 -1
  212. package/lib/packlets/decisions/abstractDecision.d.ts.map +0 -1
  213. package/lib/packlets/decisions/abstractDecision.js.map +0 -1
  214. package/lib/packlets/decisions/abstractDecisionCollector.d.ts.map +0 -1
  215. package/lib/packlets/decisions/abstractDecisionCollector.js.map +0 -1
  216. package/lib/packlets/decisions/candidate.d.ts.map +0 -1
  217. package/lib/packlets/decisions/candidate.js.map +0 -1
  218. package/lib/packlets/decisions/common.d.ts.map +0 -1
  219. package/lib/packlets/decisions/common.js.map +0 -1
  220. package/lib/packlets/decisions/concreteDecision.d.ts.map +0 -1
  221. package/lib/packlets/decisions/concreteDecision.js.map +0 -1
  222. package/lib/packlets/decisions/decision.d.ts.map +0 -1
  223. package/lib/packlets/decisions/decision.js.map +0 -1
  224. package/lib/packlets/decisions/index.d.ts.map +0 -1
  225. package/lib/packlets/decisions/index.js.map +0 -1
  226. package/lib/packlets/import/fsItem.d.ts.map +0 -1
  227. package/lib/packlets/import/fsItem.js.map +0 -1
  228. package/lib/packlets/import/importContext.d.ts.map +0 -1
  229. package/lib/packlets/import/importContext.js.map +0 -1
  230. package/lib/packlets/import/importManager.d.ts.map +0 -1
  231. package/lib/packlets/import/importManager.js.map +0 -1
  232. package/lib/packlets/import/importable.d.ts.map +0 -1
  233. package/lib/packlets/import/importable.js.map +0 -1
  234. package/lib/packlets/import/importers/collectionImporter.d.ts.map +0 -1
  235. package/lib/packlets/import/importers/collectionImporter.js.map +0 -1
  236. package/lib/packlets/import/importers/fsItemImporter.d.ts.map +0 -1
  237. package/lib/packlets/import/importers/fsItemImporter.js.map +0 -1
  238. package/lib/packlets/import/importers/importer.d.ts.map +0 -1
  239. package/lib/packlets/import/importers/importer.js.map +0 -1
  240. package/lib/packlets/import/importers/index.d.ts.map +0 -1
  241. package/lib/packlets/import/importers/index.js.map +0 -1
  242. package/lib/packlets/import/importers/jsonImporter.d.ts.map +0 -1
  243. package/lib/packlets/import/importers/jsonImporter.js.map +0 -1
  244. package/lib/packlets/import/importers/pathImporter.d.ts.map +0 -1
  245. package/lib/packlets/import/importers/pathImporter.js.map +0 -1
  246. package/lib/packlets/import/index.d.ts.map +0 -1
  247. package/lib/packlets/import/index.js.map +0 -1
  248. package/lib/packlets/qualifier-types/config/convert.d.ts.map +0 -1
  249. package/lib/packlets/qualifier-types/config/convert.js.map +0 -1
  250. package/lib/packlets/qualifier-types/config/index.d.ts.map +0 -1
  251. package/lib/packlets/qualifier-types/config/index.js.map +0 -1
  252. package/lib/packlets/qualifier-types/config/json.d.ts.map +0 -1
  253. package/lib/packlets/qualifier-types/config/json.js.map +0 -1
  254. package/lib/packlets/qualifier-types/convert.d.ts.map +0 -1
  255. package/lib/packlets/qualifier-types/convert.js.map +0 -1
  256. package/lib/packlets/qualifier-types/helpers.d.ts.map +0 -1
  257. package/lib/packlets/qualifier-types/helpers.js.map +0 -1
  258. package/lib/packlets/qualifier-types/index.d.ts.map +0 -1
  259. package/lib/packlets/qualifier-types/index.js.map +0 -1
  260. package/lib/packlets/qualifier-types/languageQualifierType.d.ts.map +0 -1
  261. package/lib/packlets/qualifier-types/languageQualifierType.js.map +0 -1
  262. package/lib/packlets/qualifier-types/literalQualifierType.d.ts.map +0 -1
  263. package/lib/packlets/qualifier-types/literalQualifierType.js.map +0 -1
  264. package/lib/packlets/qualifier-types/literalValueHierarchy.d.ts.map +0 -1
  265. package/lib/packlets/qualifier-types/literalValueHierarchy.js.map +0 -1
  266. package/lib/packlets/qualifier-types/qualifierType.d.ts.map +0 -1
  267. package/lib/packlets/qualifier-types/qualifierType.js.map +0 -1
  268. package/lib/packlets/qualifier-types/qualifierTypeCollector.d.ts.map +0 -1
  269. package/lib/packlets/qualifier-types/qualifierTypeCollector.js.map +0 -1
  270. package/lib/packlets/qualifier-types/territoryQualifierType.d.ts.map +0 -1
  271. package/lib/packlets/qualifier-types/territoryQualifierType.js.map +0 -1
  272. package/lib/packlets/qualifiers/convert/decls.d.ts.map +0 -1
  273. package/lib/packlets/qualifiers/convert/decls.js.map +0 -1
  274. package/lib/packlets/qualifiers/convert/index.d.ts.map +0 -1
  275. package/lib/packlets/qualifiers/convert/index.js.map +0 -1
  276. package/lib/packlets/qualifiers/convert/qualifier.d.ts.map +0 -1
  277. package/lib/packlets/qualifiers/convert/qualifier.js.map +0 -1
  278. package/lib/packlets/qualifiers/index.d.ts.map +0 -1
  279. package/lib/packlets/qualifiers/index.js.map +0 -1
  280. package/lib/packlets/qualifiers/qualifier.d.ts.map +0 -1
  281. package/lib/packlets/qualifiers/qualifier.js.map +0 -1
  282. package/lib/packlets/qualifiers/qualifierCollector.d.ts.map +0 -1
  283. package/lib/packlets/qualifiers/qualifierCollector.js.map +0 -1
  284. package/lib/packlets/qualifiers/qualifierDecl.d.ts.map +0 -1
  285. package/lib/packlets/qualifiers/qualifierDecl.js.map +0 -1
  286. package/lib/packlets/qualifiers/qualifierDefaultValueDecls.d.ts.map +0 -1
  287. package/lib/packlets/qualifiers/qualifierDefaultValueDecls.js.map +0 -1
  288. package/lib/packlets/qualifiers/qualifierDefaultValueToken.d.ts.map +0 -1
  289. package/lib/packlets/qualifiers/qualifierDefaultValueToken.js.map +0 -1
  290. package/lib/packlets/resource-json/compiled/common.d.ts.map +0 -1
  291. package/lib/packlets/resource-json/compiled/common.js.map +0 -1
  292. package/lib/packlets/resource-json/compiled/convert.d.ts.map +0 -1
  293. package/lib/packlets/resource-json/compiled/convert.js.map +0 -1
  294. package/lib/packlets/resource-json/compiled/index.d.ts.map +0 -1
  295. package/lib/packlets/resource-json/compiled/index.js.map +0 -1
  296. package/lib/packlets/resource-json/compiled/json.d.ts.map +0 -1
  297. package/lib/packlets/resource-json/compiled/json.js.map +0 -1
  298. package/lib/packlets/resource-json/convert.d.ts.map +0 -1
  299. package/lib/packlets/resource-json/convert.js.map +0 -1
  300. package/lib/packlets/resource-json/helpers.d.ts.map +0 -1
  301. package/lib/packlets/resource-json/helpers.js.map +0 -1
  302. package/lib/packlets/resource-json/index.d.ts.map +0 -1
  303. package/lib/packlets/resource-json/index.js.map +0 -1
  304. package/lib/packlets/resource-json/json.d.ts.map +0 -1
  305. package/lib/packlets/resource-json/json.js.map +0 -1
  306. package/lib/packlets/resource-json/normalized.d.ts.map +0 -1
  307. package/lib/packlets/resource-json/normalized.js.map +0 -1
  308. package/lib/packlets/resource-json/resourceDeclCollection.d.ts.map +0 -1
  309. package/lib/packlets/resource-json/resourceDeclCollection.js.map +0 -1
  310. package/lib/packlets/resource-json/resourceDeclContainer.d.ts.map +0 -1
  311. package/lib/packlets/resource-json/resourceDeclContainer.js.map +0 -1
  312. package/lib/packlets/resource-json/resourceDeclTree.d.ts.map +0 -1
  313. package/lib/packlets/resource-json/resourceDeclTree.js.map +0 -1
  314. package/lib/packlets/resource-types/config/convert.d.ts.map +0 -1
  315. package/lib/packlets/resource-types/config/convert.js.map +0 -1
  316. package/lib/packlets/resource-types/config/index.d.ts.map +0 -1
  317. package/lib/packlets/resource-types/config/index.js.map +0 -1
  318. package/lib/packlets/resource-types/config/json.d.ts.map +0 -1
  319. package/lib/packlets/resource-types/config/json.js.map +0 -1
  320. package/lib/packlets/resource-types/helpers.d.ts.map +0 -1
  321. package/lib/packlets/resource-types/helpers.js.map +0 -1
  322. package/lib/packlets/resource-types/index.d.ts.map +0 -1
  323. package/lib/packlets/resource-types/index.js.map +0 -1
  324. package/lib/packlets/resource-types/jsonResourceType.d.ts.map +0 -1
  325. package/lib/packlets/resource-types/jsonResourceType.js.map +0 -1
  326. package/lib/packlets/resource-types/resourceType.d.ts.map +0 -1
  327. package/lib/packlets/resource-types/resourceType.js.map +0 -1
  328. package/lib/packlets/resource-types/resourceTypeCollector.d.ts.map +0 -1
  329. package/lib/packlets/resource-types/resourceTypeCollector.js.map +0 -1
  330. package/lib/packlets/resources/candidateReducer.d.ts.map +0 -1
  331. package/lib/packlets/resources/candidateReducer.js.map +0 -1
  332. package/lib/packlets/resources/common.d.ts.map +0 -1
  333. package/lib/packlets/resources/common.js.map +0 -1
  334. package/lib/packlets/resources/index.d.ts.map +0 -1
  335. package/lib/packlets/resources/index.js.map +0 -1
  336. package/lib/packlets/resources/resource.d.ts.map +0 -1
  337. package/lib/packlets/resources/resource.js.map +0 -1
  338. package/lib/packlets/resources/resourceBuilder.d.ts.map +0 -1
  339. package/lib/packlets/resources/resourceBuilder.js.map +0 -1
  340. package/lib/packlets/resources/resourceCandidate.d.ts.map +0 -1
  341. package/lib/packlets/resources/resourceCandidate.js.map +0 -1
  342. package/lib/packlets/resources/resourceManagerBuilder.d.ts.map +0 -1
  343. package/lib/packlets/resources/resourceManagerBuilder.js.map +0 -1
  344. package/lib/packlets/runtime/cacheListener.d.ts.map +0 -1
  345. package/lib/packlets/runtime/cacheListener.js.map +0 -1
  346. package/lib/packlets/runtime/cacheMetrics.d.ts.map +0 -1
  347. package/lib/packlets/runtime/cacheMetrics.js.map +0 -1
  348. package/lib/packlets/runtime/compiledResourceCollection.d.ts.map +0 -1
  349. package/lib/packlets/runtime/compiledResourceCollection.js.map +0 -1
  350. package/lib/packlets/runtime/conditionSetResolutionResult.d.ts.map +0 -1
  351. package/lib/packlets/runtime/conditionSetResolutionResult.js.map +0 -1
  352. package/lib/packlets/runtime/context/contextQualifierProvider.d.ts.map +0 -1
  353. package/lib/packlets/runtime/context/contextQualifierProvider.js.map +0 -1
  354. package/lib/packlets/runtime/context/contextQualifierProviderValidator.d.ts.map +0 -1
  355. package/lib/packlets/runtime/context/contextQualifierProviderValidator.js.map +0 -1
  356. package/lib/packlets/runtime/context/index.d.ts.map +0 -1
  357. package/lib/packlets/runtime/context/index.js.map +0 -1
  358. package/lib/packlets/runtime/context/simpleContextQualifierProvider.d.ts.map +0 -1
  359. package/lib/packlets/runtime/context/simpleContextQualifierProvider.js.map +0 -1
  360. package/lib/packlets/runtime/context/validatingSimpleContextQualifierProvider.d.ts.map +0 -1
  361. package/lib/packlets/runtime/context/validatingSimpleContextQualifierProvider.js.map +0 -1
  362. package/lib/packlets/runtime/iResourceManager.d.ts.map +0 -1
  363. package/lib/packlets/runtime/iResourceManager.js.map +0 -1
  364. package/lib/packlets/runtime/index.d.ts.map +0 -1
  365. package/lib/packlets/runtime/index.js.map +0 -1
  366. package/lib/packlets/runtime/resource-tree/common.d.ts.map +0 -1
  367. package/lib/packlets/runtime/resource-tree/common.js.map +0 -1
  368. package/lib/packlets/runtime/resource-tree/index.d.ts.map +0 -1
  369. package/lib/packlets/runtime/resource-tree/index.js.map +0 -1
  370. package/lib/packlets/runtime/resource-tree/readOnlyResourceTree.d.ts.map +0 -1
  371. package/lib/packlets/runtime/resource-tree/readOnlyResourceTree.js.map +0 -1
  372. package/lib/packlets/runtime/resource-tree/resourceTreeChildren.d.ts.map +0 -1
  373. package/lib/packlets/runtime/resource-tree/resourceTreeChildren.js.map +0 -1
  374. package/lib/packlets/runtime/resource-tree/resourceTreeChildrenValidator.d.ts.map +0 -1
  375. package/lib/packlets/runtime/resource-tree/resourceTreeChildrenValidator.js.map +0 -1
  376. package/lib/packlets/runtime/resourceResolver.d.ts.map +0 -1
  377. package/lib/packlets/runtime/resourceResolver.js.map +0 -1
  378. package/lib/packlets/runtime/validate.d.ts.map +0 -1
  379. package/lib/packlets/runtime/validate.js.map +0 -1
@@ -1,5 +1,6 @@
1
1
  import { Result } from '@fgv/ts-utils';
2
2
  import { JsonValue } from '@fgv/ts-json-base';
3
+ import { IResourceResolver } from '../common';
3
4
  import { Condition, ConditionSet } from '../conditions';
4
5
  import { AbstractDecision } from '../decisions';
5
6
  import { ReadOnlyQualifierTypeCollector } from '../qualifier-types';
@@ -7,6 +8,7 @@ import { IContextQualifierProvider } from './context';
7
8
  import { IResourceManager, IResource, IResourceCandidate } from './iResourceManager';
8
9
  import { ConditionSetResolutionResult, IConditionMatchResult } from './conditionSetResolutionResult';
9
10
  import { IResourceResolverCacheListener } from './cacheListener';
11
+ import { IReadOnlyQualifierCollector } from '../qualifiers';
10
12
  /**
11
13
  * Represents the cached result of resolving a decision.
12
14
  * Contains either a failure indicator or a list of instance indices for matching condition sets,
@@ -20,6 +22,19 @@ export type DecisionResolutionResult = {
20
22
  instanceIndices: ReadonlyArray<number>;
21
23
  defaultInstanceIndices: ReadonlyArray<number>;
22
24
  };
25
+ /**
26
+ * Options for configuring a {@link Runtime.ResourceResolver | ResourceResolver}.
27
+ * @public
28
+ */
29
+ export interface IResourceResolverOptions {
30
+ /**
31
+ * Controls whether null values in resource composition should suppress properties
32
+ * instead of setting them to null. When true, properties with null values from
33
+ * higher-priority partial candidates will be omitted from the final composed resource.
34
+ * @defaultValue false
35
+ */
36
+ suppressNullAsDelete?: boolean;
37
+ }
23
38
  /**
24
39
  * Parameters for creating a {@link Runtime.ResourceResolver | ResourceResolver}.
25
40
  * @public
@@ -44,6 +59,10 @@ export interface IResourceResolverCreateParams {
44
59
  * An optional listener for {@link Runtime.ResourceResolver | ResourceResolver} cache activity.
45
60
  */
46
61
  listener?: IResourceResolverCacheListener;
62
+ /**
63
+ * Optional configuration options for the {@link Runtime.ResourceResolver | ResourceResolver}.
64
+ */
65
+ options?: IResourceResolverOptions;
47
66
  }
48
67
  /**
49
68
  * High-performance runtime resource resolver with O(1) condition caching.
@@ -51,7 +70,7 @@ export interface IResourceResolverCreateParams {
51
70
  * and caching results for optimal performance.
52
71
  * @public
53
72
  */
54
- export declare class ResourceResolver {
73
+ export declare class ResourceResolver implements IResourceResolver {
55
74
  /**
56
75
  * The resource manager that defines available resources and provides condition access.
57
76
  */
@@ -64,6 +83,14 @@ export declare class ResourceResolver {
64
83
  * The context qualifier provider that resolves qualifier values.
65
84
  */
66
85
  readonly contextQualifierProvider: IContextQualifierProvider;
86
+ /**
87
+ * The configuration options for this resource resolver.
88
+ */
89
+ readonly options: IResourceResolverOptions;
90
+ /**
91
+ * The readonly qualifier collector that provides qualifier implementations.
92
+ */
93
+ get qualifiers(): IReadOnlyQualifierCollector;
67
94
  /**
68
95
  * The cache array for resolved conditions, indexed by condition index for O(1) lookup.
69
96
  * Each entry stores the resolved {@link Runtime.IConditionMatchResult | condition match result} for
@@ -148,6 +175,15 @@ export declare class ResourceResolver {
148
175
  * @public
149
176
  */
150
177
  resolveResource(resource: IResource): Result<IResourceCandidate>;
178
+ /**
179
+ * Resolves a resource by finding the best matching candidate.
180
+ * Uses the resource's associated decision to determine the best match based on the current context.
181
+ * @param resource - The string id of the resource to resolve.
182
+ * @returns `Success` with the best matching candidate if successful,
183
+ * or `Failure` with an error message if no candidates match or resolution fails.
184
+ * @public
185
+ */
186
+ resolveResource(resource: string): Result<IResourceCandidate>;
151
187
  /**
152
188
  * Resolves all matching resource candidates in priority order.
153
189
  * Uses the resource's associated decision to determine all matching candidates based on the current context.
@@ -157,6 +193,15 @@ export declare class ResourceResolver {
157
193
  * @public
158
194
  */
159
195
  resolveAllResourceCandidates(resource: IResource): Result<ReadonlyArray<IResourceCandidate>>;
196
+ /**
197
+ * Resolves all matching resource candidates in priority order.
198
+ * Uses the resource's associated decision to determine all matching candidates based on the current context.
199
+ * @param resource - The string id of the resource to resolve.
200
+ * @returns `Success` with an array of all matching candidates in priority order if successful,
201
+ * or `Failure` with an error message if no candidates match or resolution fails.
202
+ * @public
203
+ */
204
+ resolveAllResourceCandidates(resource: string): Result<ReadonlyArray<IResourceCandidate>>;
160
205
  /**
161
206
  * Resolves a resource to a composed value by merging matching candidates according to their merge methods.
162
207
  * Starting from the highest priority candidates, finds the first "full" candidate and merges all higher
@@ -167,6 +212,20 @@ export declare class ResourceResolver {
167
212
  * @public
168
213
  */
169
214
  resolveComposedResourceValue(resource: IResource): Result<JsonValue>;
215
+ /**
216
+ * Resolves a resource to a composed value by merging matching candidates according to their merge methods.
217
+ * Starting from the highest priority candidates, finds the first "full" candidate and merges all higher
218
+ * priority "partial" candidates into it in ascending order of priority.
219
+ * @param resource - The string id of the resource to resolve.
220
+ * @returns `Success` with the composed JsonValue if successful,
221
+ * or `Failure` with an error message if no candidates match or resolution fails.
222
+ * @public
223
+ */
224
+ resolveComposedResourceValue(resource: string): Result<JsonValue>;
225
+ /**
226
+ * {@inheritDoc IResourceResolver.withContext}
227
+ */
228
+ withContext(context: Record<string, string>): Result<ResourceResolver>;
170
229
  /**
171
230
  * Clears all caches (condition, condition set, and decision), forcing all cached items
172
231
  * to be re-evaluated on next access. This should be called when the context changes and cached
@@ -26,6 +26,7 @@ const ts_utils_1 = require("@fgv/ts-utils");
26
26
  const ts_json_base_1 = require("@fgv/ts-json-base");
27
27
  const ts_json_1 = require("@fgv/ts-json");
28
28
  const common_1 = require("../common");
29
+ const context_1 = require("./context");
29
30
  const conditionSetResolutionResult_1 = require("./conditionSetResolutionResult");
30
31
  /**
31
32
  * High-performance runtime resource resolver with O(1) condition caching.
@@ -34,6 +35,12 @@ const conditionSetResolutionResult_1 = require("./conditionSetResolutionResult")
34
35
  * @public
35
36
  */
36
37
  class ResourceResolver {
38
+ /**
39
+ * The readonly qualifier collector that provides qualifier implementations.
40
+ */
41
+ get qualifiers() {
42
+ return this.contextQualifierProvider.qualifiers;
43
+ }
37
44
  /**
38
45
  * The cache array for resolved conditions, indexed by condition index for O(1) lookup.
39
46
  * Each entry stores the resolved {@link Runtime.IConditionMatchResult | condition match result} for
@@ -61,9 +68,13 @@ class ResourceResolver {
61
68
  * @param params - {@link Runtime.IResourceResolverCreateParams | Parameters} used to create the resolver.
62
69
  */
63
70
  constructor(params) {
71
+ var _a, _b;
64
72
  this.resourceManager = params.resourceManager;
65
73
  this.qualifierTypes = params.qualifierTypes;
66
74
  this.contextQualifierProvider = params.contextQualifierProvider;
75
+ this.options = {
76
+ suppressNullAsDelete: (_b = (_a = params.options) === null || _a === void 0 ? void 0 : _a.suppressNullAsDelete) !== null && _b !== void 0 ? _b : false
77
+ };
67
78
  // Initialize condition cache array with size matching the condition collector
68
79
  const conditionCollectorSize = this.resourceManager.conditions.size;
69
80
  this._conditionCache = new Array(conditionCollectorSize);
@@ -94,7 +105,7 @@ class ResourceResolver {
94
105
  * @public
95
106
  */
96
107
  resolveCondition(condition) {
97
- var _a, _b, _c, _d;
108
+ var _a, _b, _c;
98
109
  // Get the condition's index for cache lookup
99
110
  const conditionIndex = condition.index;
100
111
  if (conditionIndex === undefined) {
@@ -107,16 +118,20 @@ class ResourceResolver {
107
118
  return (0, ts_utils_1.succeed)(cachedResult);
108
119
  }
109
120
  // Resolve the condition by getting qualifier value and evaluating with qualifier type
110
- const qualifierValueResult = this.contextQualifierProvider.get(condition.qualifier);
111
- if (qualifierValueResult.isFailure()) {
112
- (_b = this._listener) === null || _b === void 0 ? void 0 : _b.onCacheError('condition', conditionIndex);
113
- return (0, ts_utils_1.fail)(`Failed to get qualifier value for "${condition.qualifier.name}": ${qualifierValueResult.message}`);
114
- }
115
- const qualifierValue = qualifierValueResult.value;
116
- // Evaluate the condition using the qualifier type's matching logic
117
- const score = condition.qualifier.type.matches(condition.value, qualifierValue, condition.operator);
121
+ const score = this.contextQualifierProvider
122
+ .get(condition.qualifier)
123
+ .onSuccess((qualifierValue) => {
124
+ // Evaluate the condition using the qualifier type's matching logic
125
+ return (0, ts_utils_1.succeed)(condition.qualifier.type.matches(condition.value, qualifierValue, condition.operator));
126
+ })
127
+ .onFailure((err) => {
128
+ var _a;
129
+ (_a = this._listener) === null || _a === void 0 ? void 0 : _a.onContextError(condition.qualifier.name, err);
130
+ return (0, ts_utils_1.fail)(err);
131
+ })
132
+ .orDefault(common_1.NoMatch);
118
133
  const priority = condition.priority;
119
- const scoreAsDefault = (_c = condition.scoreAsDefault) !== null && _c !== void 0 ? _c : common_1.NoMatch;
134
+ const scoreAsDefault = (_b = condition.scoreAsDefault) !== null && _b !== void 0 ? _b : common_1.NoMatch;
120
135
  const matchResult = score > common_1.NoMatch
121
136
  ? { score, priority, matchType: 'match' }
122
137
  : scoreAsDefault > common_1.NoMatch
@@ -124,7 +139,7 @@ class ResourceResolver {
124
139
  : { score: common_1.NoMatch, priority, matchType: 'noMatch' };
125
140
  // Cache the resolved value for future O(1) lookup
126
141
  this._conditionCache[conditionIndex] = matchResult;
127
- (_d = this._listener) === null || _d === void 0 ? void 0 : _d.onCacheMiss('condition', conditionIndex);
142
+ (_c = this._listener) === null || _c === void 0 ? void 0 : _c.onCacheMiss('condition', conditionIndex);
128
143
  return (0, ts_utils_1.succeed)(matchResult);
129
144
  }
130
145
  /**
@@ -153,8 +168,8 @@ class ResourceResolver {
153
168
  let matchType = 'match';
154
169
  for (const condition of conditionSet.conditions) {
155
170
  const { value: conditionResult, message: conditionMessage } = this.resolveCondition(condition);
171
+ /* c8 ignore next 4 - defensive coding: extreme internal error scenario not reachable in normal operation */
156
172
  if (conditionMessage !== undefined) {
157
- /* c8 ignore next 2 - defensive coding: extreme internal error scenario not reachable in normal operation */
158
173
  (_b = this._listener) === null || _b === void 0 ? void 0 : _b.onCacheError('conditionSet', conditionSetIndex);
159
174
  return (0, ts_utils_1.fail)(`Failed to resolve condition "${condition.key}": ${conditionMessage}`);
160
175
  }
@@ -176,6 +191,7 @@ class ResourceResolver {
176
191
  return (0, ts_utils_1.fail)(`${conditionSetIndex}: error creating condition set resolution result: ${err}`);
177
192
  });
178
193
  }
194
+ /* c8 ignore next 3 - edge case: matchAsDefault fallback logic rarely triggered */
179
195
  if (conditionResult.matchType === 'matchAsDefault') {
180
196
  matchType = 'matchAsDefault';
181
197
  }
@@ -223,8 +239,8 @@ class ResourceResolver {
223
239
  for (let instanceIndex = 0; instanceIndex < decision.candidates.length; instanceIndex++) {
224
240
  const candidate = decision.candidates[instanceIndex];
225
241
  const conditionSetResult = this.resolveConditionSet(candidate.conditionSet);
242
+ /* c8 ignore next 4 - defensive coding: extreme internal error scenario not reachable in normal operation */
226
243
  if (conditionSetResult.isFailure()) {
227
- /* c8 ignore next 2 - defensive coding: extreme internal error scenario not reachable in normal operation */
228
244
  (_b = this._listener) === null || _b === void 0 ? void 0 : _b.onCacheError('decision', decisionIndex);
229
245
  return (0, ts_utils_1.fail)(`${decision.key}: Failed to resolve condition set": ${conditionSetResult.message}`);
230
246
  }
@@ -237,6 +253,7 @@ class ResourceResolver {
237
253
  });
238
254
  }
239
255
  else if (resolution.matchType === 'matchAsDefault') {
256
+ /* c8 ignore next 4 - edge case: default matching instances rarely used in practice */
240
257
  matchingDefaultInstanceResults.push({
241
258
  index: instanceIndex,
242
259
  result: resolution
@@ -260,15 +277,14 @@ class ResourceResolver {
260
277
  (_c = this._listener) === null || _c === void 0 ? void 0 : _c.onCacheMiss('decision', decisionIndex);
261
278
  return (0, ts_utils_1.succeed)(successResult);
262
279
  }
263
- /**
264
- * Resolves a resource by finding the best matching candidate.
265
- * Uses the resource's associated decision to determine the best match based on the current context.
266
- * @param resource - The {@link Resources.Resource | resource} to resolve.
267
- * @returns `Success` with the best matching candidate if successful,
268
- * or `Failure` with an error message if no candidates match or resolution fails.
269
- * @public
270
- */
271
- resolveResource(resource) {
280
+ resolveResource(idOrResource) {
281
+ /* c8 ignore next 4 - defensive coding: string resource resolution should use direct resource calls */
282
+ if (typeof idOrResource === 'string') {
283
+ return this.resourceManager
284
+ .getBuiltResource(idOrResource)
285
+ .onSuccess((resource) => this.resolveResource(resource));
286
+ }
287
+ const resource = idOrResource;
272
288
  // Get the abstract decision from the resource's concrete decision
273
289
  const abstractDecision = resource.decision.baseDecision;
274
290
  // Resolve the decision to get candidate indices in priority order
@@ -293,15 +309,14 @@ class ResourceResolver {
293
309
  const bestCandidate = resource.candidates[candidateIndex];
294
310
  return (0, ts_utils_1.succeed)(bestCandidate);
295
311
  }
296
- /**
297
- * Resolves all matching resource candidates in priority order.
298
- * Uses the resource's associated decision to determine all matching candidates based on the current context.
299
- * @param resource - The {@link Resources.Resource | resource} to resolve.
300
- * @returns `Success` with an array of all matching candidates in priority order if successful,
301
- * or `Failure` with an error message if no candidates match or resolution fails.
302
- * @public
303
- */
304
- resolveAllResourceCandidates(resource) {
312
+ resolveAllResourceCandidates(idOrResource) {
313
+ /* c8 ignore next 4 - defensive coding: string resource resolution should use direct resource calls */
314
+ if (typeof idOrResource === 'string') {
315
+ return this.resourceManager
316
+ .getBuiltResource(idOrResource)
317
+ .onSuccess((resource) => this.resolveAllResourceCandidates(resource));
318
+ }
319
+ const resource = idOrResource;
305
320
  // Get the abstract decision from the resource's concrete decision
306
321
  const abstractDecision = resource.decision.baseDecision;
307
322
  // Resolve the decision to get candidate indices in priority order
@@ -337,16 +352,14 @@ class ResourceResolver {
337
352
  }
338
353
  return (0, ts_utils_1.succeed)(candidates);
339
354
  }
340
- /**
341
- * Resolves a resource to a composed value by merging matching candidates according to their merge methods.
342
- * Starting from the highest priority candidates, finds the first "full" candidate and merges all higher
343
- * priority "partial" candidates into it in ascending order of priority.
344
- * @param resource - The {@link Resources.Resource | resource} to resolve.
345
- * @returns `Success` with the composed JsonValue if successful,
346
- * or `Failure` with an error message if no candidates match or resolution fails.
347
- * @public
348
- */
349
- resolveComposedResourceValue(resource) {
355
+ resolveComposedResourceValue(idOrResource) {
356
+ /* c8 ignore next 4 - defensive coding: string resource resolution should use direct resource calls */
357
+ if (typeof idOrResource === 'string') {
358
+ return this.resourceManager
359
+ .getBuiltResource(idOrResource)
360
+ .onSuccess((resource) => this.resolveComposedResourceValue(resource));
361
+ }
362
+ const resource = idOrResource;
350
363
  return this.resolveAllResourceCandidates(resource).onSuccess((candidates) => {
351
364
  /* c8 ignore next 3 - defense in depth should never occur */
352
365
  if (candidates.length === 0) {
@@ -370,9 +383,22 @@ class ResourceResolver {
370
383
  // If no full candidate found, use the last candidate as the base
371
384
  const baseCandidateIndex = fullCandidateIndex >= 0 ? fullCandidateIndex : candidates.length - 1;
372
385
  const baseCandidate = candidates[baseCandidateIndex];
373
- // If there are no partial candidates to merge, return the base candidate's value
386
+ // If there are no partial candidates to merge, but null-as-delete is enabled,
387
+ // still process through JsonEditor to handle null properties in the base candidate
374
388
  if (partialCandidates.length === 0) {
375
- return (0, ts_utils_1.succeed)(baseCandidate.json);
389
+ if (this.options.suppressNullAsDelete || !(0, ts_json_base_1.isJsonObject)(baseCandidate.json)) {
390
+ return (0, ts_utils_1.succeed)(baseCandidate.json);
391
+ }
392
+ // Process single candidate through JsonEditor to apply null-as-delete
393
+ const editor = ts_json_1.JsonEditor.create({
394
+ merge: {
395
+ arrayMergeBehavior: 'replace',
396
+ nullAsDelete: true
397
+ }
398
+ }).orThrow(); // Should never fail with valid options
399
+ return editor
400
+ .mergeObjectsInPlace({}, [baseCandidate.json])
401
+ .withErrorFormat((err) => `${resource.id}: Composition failed: ${err}`);
376
402
  }
377
403
  const allCandidates = [
378
404
  baseCandidate.json,
@@ -382,10 +408,11 @@ class ResourceResolver {
382
408
  if (allCandidates.length !== partialCandidates.length + 1) {
383
409
  return (0, ts_utils_1.fail)(`${resource.id}: Unable to compose non-object candidate values.`);
384
410
  }
385
- // Create JsonEditor with array replacement behavior for resource composition
411
+ // Create JsonEditor with array replacement behavior and null-as-delete for resource composition
386
412
  const editor = ts_json_1.JsonEditor.create({
387
413
  merge: {
388
- arrayMergeBehavior: 'replace'
414
+ arrayMergeBehavior: 'replace',
415
+ nullAsDelete: !this.options.suppressNullAsDelete
389
416
  }
390
417
  }).orThrow(); // Should never fail with valid options
391
418
  return editor
@@ -393,6 +420,23 @@ class ResourceResolver {
393
420
  .withErrorFormat((err) => `${resource.id}: Composition failed: ${err}`);
394
421
  });
395
422
  }
423
+ /**
424
+ * {@inheritDoc IResourceResolver.withContext}
425
+ */
426
+ withContext(context) {
427
+ const { resourceManager, qualifierTypes, options } = this;
428
+ return context_1.ValidatingSimpleContextQualifierProvider.create({
429
+ qualifiers: this.qualifiers,
430
+ qualifierValues: context
431
+ }).onSuccess((contextQualifierProvider) => {
432
+ return ResourceResolver.create({
433
+ resourceManager,
434
+ qualifierTypes,
435
+ options,
436
+ contextQualifierProvider
437
+ });
438
+ });
439
+ }
396
440
  /**
397
441
  * Clears all caches (condition, condition set, and decision), forcing all cached items
398
442
  * to be re-evaluated on next access. This should be called when the context changes and cached
@@ -0,0 +1,152 @@
1
+ import { Result } from '@fgv/ts-utils';
2
+ import { JsonValue, JsonObject } from '@fgv/ts-json-base';
3
+ import { IResource } from './iResourceManager';
4
+ import { IReadOnlyResourceTreeNode, IReadOnlyResourceTreeRoot } from './resource-tree/common';
5
+ import { ResourceResolver } from './resourceResolver';
6
+ /**
7
+ * Type for handling resource resolution errors during tree traversal.
8
+ * The handler receives the resource that failed to resolve, the error message, and the resolver for recovery attempts.
9
+ * It can return:
10
+ * - Success(undefined) to omit the property from the result
11
+ * - Success(value) to use an alternate value
12
+ * - Failure to propagate the error
13
+ * @public
14
+ */
15
+ export type ResourceErrorHandler = (resource: IResource, message: string, resolver: ResourceResolver) => Result<JsonValue | undefined>;
16
+ /**
17
+ * Type for handling empty branch nodes during tree composition.
18
+ * The handler receives the branch node, names of failed children, and the resolver for recovery attempts.
19
+ * It can return:
20
+ * - Success(undefined) to omit the branch from the result
21
+ * - Success(value) to use an alternate value for the branch
22
+ * - Failure to propagate the error
23
+ * @public
24
+ */
25
+ export type EmptyBranchHandler = (branchNode: IReadOnlyResourceTreeNode<IResource>, failedChildNames: string[], resolver: ResourceResolver) => Result<JsonValue | undefined>;
26
+ /**
27
+ * Options for configuring resource tree resolution.
28
+ * @public
29
+ */
30
+ export interface IResolveResourceTreeOptions {
31
+ /**
32
+ * Controls how errors are handled when resolving individual resources in the tree.
33
+ * - 'fail': Aggregate all errors and fail if any resource fails to resolve
34
+ * - 'ignore': Skip failed resources and omit them from the result
35
+ * - callback: Custom error handler that can provide alternate values or propagate errors
36
+ * @defaultValue 'fail'
37
+ */
38
+ onResourceError?: 'fail' | 'ignore' | ResourceErrorHandler;
39
+ /**
40
+ * Controls how empty branch nodes are handled during tree composition.
41
+ * - 'allow': Include empty branches as empty objects in the result
42
+ * - 'omit': Exclude empty branches from the parent object
43
+ * - callback: Custom handler that can provide alternate values or recovery logic
44
+ * @defaultValue 'allow'
45
+ */
46
+ onEmptyBranch?: 'allow' | 'omit' | EmptyBranchHandler;
47
+ }
48
+ /**
49
+ * Specialized resolver for resource tree operations, providing enhanced APIs for
50
+ * resolving entire resource trees from either resource IDs or pre-built tree nodes.
51
+ *
52
+ * This class provides a clean separation between individual resource resolution
53
+ * (handled by ResourceResolver) and tree-based operations, with support for
54
+ * lazy tree construction and enhanced error handling.
55
+ *
56
+ * @public
57
+ */
58
+ export declare class ResourceTreeResolver {
59
+ /**
60
+ * The {@link Runtime.ResourceResolver | ResourceResolver} to use for individual resource resolution
61
+ */
62
+ readonly resolver: ResourceResolver;
63
+ /**
64
+ * The {@link Runtime.IResourceManager | IResourceManager} to use for lazy tree construction.
65
+ * @internal
66
+ */
67
+ private readonly _resourceManager;
68
+ /**
69
+ * The built resource tree, lazily built on first access.
70
+ * @internal
71
+ */
72
+ private _tree?;
73
+ /**
74
+ * Creates a {@link Runtime.ResourceTreeResolver | ResourceTreeResolver} instance.
75
+ * @param resolver - The ResourceResolver to use for individual resource resolution
76
+ */
77
+ constructor(resolver: ResourceResolver);
78
+ /**
79
+ * Creates a {@link Runtime.ResourceTreeResolver | ResourceTreeResolver} instance.
80
+ * @param resolver - The ResourceResolver to use for individual resource resolution
81
+ */
82
+ static create(resolver: ResourceResolver): Result<ResourceTreeResolver>;
83
+ /**
84
+ * Gets the built resource tree, building it lazily on first access.
85
+ * @returns The resource tree root
86
+ * @throws Error if no resource manager was provided or tree building fails
87
+ * @public
88
+ */
89
+ get tree(): IReadOnlyResourceTreeRoot<IResource>;
90
+ /**
91
+ * Resolves a resource tree from a resource ID, building the tree lazily from the resource manager.
92
+ * @param resourceId - The ID of the root resource to resolve
93
+ * @param options - Optional configuration for error handling during resolution
94
+ * @returns Success with the composed JsonObject or undefined, or Failure with error message
95
+ * @public
96
+ */
97
+ resolveComposedResourceTree(resourceId: string, options?: IResolveResourceTreeOptions): Result<JsonObject | undefined>;
98
+ /**
99
+ * Resolves a pre-built resource tree node.
100
+ * @param node - The resource tree node to resolve
101
+ * @param options - Optional configuration for error handling during resolution
102
+ * @returns Success with the composed JsonObject or undefined, or Failure with error message
103
+ * @public
104
+ */
105
+ resolveComposedResourceTree(node: IReadOnlyResourceTreeNode<IResource>, options?: IResolveResourceTreeOptions): Result<JsonObject | undefined>;
106
+ private _getTree;
107
+ /**
108
+ * Resolves a tree from a resource ID by first building the tree from the resource manager.
109
+ * @internal
110
+ */
111
+ private _resolveFromResourceId;
112
+ /**
113
+ * Resolves a pre-built tree node using the extracted tree resolution logic.
114
+ * @internal
115
+ */
116
+ private _resolveFromTreeNode;
117
+ /**
118
+ * Handles resource resolution errors according to the specified mode.
119
+ * @param resource - The resource that failed to resolve
120
+ * @param message - The error message from the failed resolution
121
+ * @param mode - The error handling mode
122
+ * @param path - The path to the resource in the tree (for error context)
123
+ * @internal
124
+ */
125
+ private _handleResourceError;
126
+ /**
127
+ * Handles empty branch nodes according to the specified mode.
128
+ * @param node - The empty branch node
129
+ * @param failedChildren - Names of children that failed to resolve
130
+ * @param mode - The empty branch handling mode
131
+ * @param path - The path to the branch in the tree (for error context)
132
+ * @internal
133
+ */
134
+ private _handleEmptyBranch;
135
+ /**
136
+ * Processes a leaf node by resolving its resource value.
137
+ * @param node - The leaf node to process (must be a leaf node)
138
+ * @param path - The path to the node in the tree
139
+ * @param resourceErrorMode - How to handle resource resolution errors
140
+ * @internal
141
+ */
142
+ private _processLeafNode;
143
+ /**
144
+ * Processes a branch node by recursively resolving all its children.
145
+ * @param node - The branch node to process (must be a branch node)
146
+ * @param path - The path to the node in the tree
147
+ * @param options - Resolution options
148
+ * @internal
149
+ */
150
+ private _processBranchNode;
151
+ }
152
+ //# sourceMappingURL=resourceTreeResolver.d.ts.map