@fgv/ts-res 4.5.0-3 → 5.0.0-10

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 (436) hide show
  1. package/CHANGELOG.json +26 -0
  2. package/CHANGELOG.md +14 -0
  3. package/CLAUDE.md +186 -0
  4. package/EXAMPLE_INIT_PARAMS.md +88 -0
  5. package/PROGRESS_SUMMARY.md +48 -0
  6. package/README.md +535 -14
  7. package/dist/ts-res.d.ts +5253 -699
  8. package/dist/tsdoc-metadata.json +1 -1
  9. package/lib/index.d.ts +13 -2
  10. package/lib/index.d.ts.map +1 -1
  11. package/lib/index.js +29 -2
  12. package/lib/index.js.map +1 -1
  13. package/lib/packlets/bundle/bundleBuilder.d.ts +41 -0
  14. package/lib/packlets/bundle/bundleBuilder.d.ts.map +1 -0
  15. package/lib/packlets/bundle/bundleBuilder.js +134 -0
  16. package/lib/packlets/bundle/bundleBuilder.js.map +1 -0
  17. package/lib/packlets/bundle/bundleLoader.d.ts +72 -0
  18. package/lib/packlets/bundle/bundleLoader.d.ts.map +1 -0
  19. package/lib/packlets/bundle/bundleLoader.js +105 -0
  20. package/lib/packlets/bundle/bundleLoader.js.map +1 -0
  21. package/lib/packlets/bundle/bundleNormalizer.d.ts +73 -0
  22. package/lib/packlets/bundle/bundleNormalizer.d.ts.map +1 -0
  23. package/lib/packlets/bundle/bundleNormalizer.js +142 -0
  24. package/lib/packlets/bundle/bundleNormalizer.js.map +1 -0
  25. package/lib/packlets/bundle/bundleUtils.d.ts +70 -0
  26. package/lib/packlets/bundle/bundleUtils.d.ts.map +1 -0
  27. package/lib/packlets/bundle/bundleUtils.js +117 -0
  28. package/lib/packlets/bundle/bundleUtils.js.map +1 -0
  29. package/lib/packlets/bundle/convert.d.ts +33 -0
  30. package/lib/packlets/bundle/convert.d.ts.map +1 -0
  31. package/lib/packlets/bundle/convert.js +78 -0
  32. package/lib/packlets/bundle/convert.js.map +1 -0
  33. package/lib/packlets/bundle/index.d.ts +21 -0
  34. package/lib/packlets/bundle/index.d.ts.map +1 -0
  35. package/lib/packlets/bundle/index.js +83 -0
  36. package/lib/packlets/bundle/index.js.map +1 -0
  37. package/lib/packlets/bundle/model.d.ts +100 -0
  38. package/lib/packlets/bundle/model.d.ts.map +1 -0
  39. package/lib/packlets/bundle/model.js +24 -0
  40. package/lib/packlets/bundle/model.js.map +1 -0
  41. package/lib/packlets/common/conditions.d.ts +30 -0
  42. package/lib/packlets/common/conditions.d.ts.map +1 -1
  43. package/lib/packlets/common/conditions.js.map +1 -1
  44. package/lib/packlets/common/convert.d.ts +22 -2
  45. package/lib/packlets/common/convert.d.ts.map +1 -1
  46. package/lib/packlets/common/convert.js +21 -1
  47. package/lib/packlets/common/convert.js.map +1 -1
  48. package/lib/packlets/common/helpers/context.d.ts +39 -0
  49. package/lib/packlets/common/helpers/context.d.ts.map +1 -0
  50. package/lib/packlets/common/helpers/context.js +108 -0
  51. package/lib/packlets/common/helpers/context.js.map +1 -0
  52. package/lib/packlets/common/helpers/index.d.ts +2 -0
  53. package/lib/packlets/common/helpers/index.d.ts.map +1 -1
  54. package/lib/packlets/common/helpers/index.js +2 -0
  55. package/lib/packlets/common/helpers/index.js.map +1 -1
  56. package/lib/packlets/common/helpers/qualifierDefaultValues.d.ts +39 -0
  57. package/lib/packlets/common/helpers/qualifierDefaultValues.d.ts.map +1 -0
  58. package/lib/packlets/common/helpers/qualifierDefaultValues.js +105 -0
  59. package/lib/packlets/common/helpers/qualifierDefaultValues.js.map +1 -0
  60. package/lib/packlets/common/helpers/resources.d.ts.map +1 -1
  61. package/lib/packlets/common/helpers/resources.js +6 -2
  62. package/lib/packlets/common/helpers/resources.js.map +1 -1
  63. package/lib/packlets/common/resources.d.ts +8 -0
  64. package/lib/packlets/common/resources.d.ts.map +1 -1
  65. package/lib/packlets/common/resources.js.map +1 -1
  66. package/lib/packlets/common/validate/conditions.d.ts +69 -1
  67. package/lib/packlets/common/validate/conditions.d.ts.map +1 -1
  68. package/lib/packlets/common/validate/conditions.js +126 -0
  69. package/lib/packlets/common/validate/conditions.js.map +1 -1
  70. package/lib/packlets/common/validate/regularExpressions.d.ts +20 -0
  71. package/lib/packlets/common/validate/regularExpressions.d.ts.map +1 -1
  72. package/lib/packlets/common/validate/regularExpressions.js +21 -1
  73. package/lib/packlets/common/validate/regularExpressions.js.map +1 -1
  74. package/lib/packlets/conditions/condition.d.ts +37 -0
  75. package/lib/packlets/conditions/condition.d.ts.map +1 -1
  76. package/lib/packlets/conditions/condition.js +67 -1
  77. package/lib/packlets/conditions/condition.js.map +1 -1
  78. package/lib/packlets/conditions/conditionCollector.d.ts.map +1 -1
  79. package/lib/packlets/conditions/conditionCollector.js +1 -0
  80. package/lib/packlets/conditions/conditionCollector.js.map +1 -1
  81. package/lib/packlets/conditions/conditionSet.d.ts +43 -3
  82. package/lib/packlets/conditions/conditionSet.d.ts.map +1 -1
  83. package/lib/packlets/conditions/conditionSet.js +104 -3
  84. package/lib/packlets/conditions/conditionSet.js.map +1 -1
  85. package/lib/packlets/conditions/conditionSetCollector.d.ts.map +1 -1
  86. package/lib/packlets/conditions/conditionSetCollector.js +3 -0
  87. package/lib/packlets/conditions/conditionSetCollector.js.map +1 -1
  88. package/lib/packlets/conditions/conditionToken.d.ts.map +1 -1
  89. package/lib/packlets/conditions/conditionToken.js +2 -1
  90. package/lib/packlets/conditions/conditionToken.js.map +1 -1
  91. package/lib/packlets/conditions/convert/decls.js +1 -1
  92. package/lib/packlets/conditions/convert/decls.js.map +1 -1
  93. package/lib/packlets/config/common.d.ts +35 -0
  94. package/lib/packlets/config/common.d.ts.map +1 -0
  95. package/lib/packlets/config/common.js +96 -0
  96. package/lib/packlets/config/common.js.map +1 -0
  97. package/lib/packlets/config/convert.d.ts +14 -0
  98. package/lib/packlets/config/convert.d.ts.map +1 -0
  99. package/lib/packlets/config/convert.js +82 -0
  100. package/lib/packlets/config/convert.js.map +1 -0
  101. package/lib/packlets/config/index.d.ts +6 -0
  102. package/lib/packlets/config/index.d.ts.map +1 -0
  103. package/lib/packlets/config/index.js +67 -0
  104. package/lib/packlets/config/index.js.map +1 -0
  105. package/lib/packlets/config/json.d.ts +20 -0
  106. package/lib/packlets/config/json.d.ts.map +1 -0
  107. package/lib/packlets/config/json.js +24 -0
  108. package/lib/packlets/config/json.js.map +1 -0
  109. package/lib/packlets/config/predefined/default.d.ts +57 -0
  110. package/lib/packlets/config/predefined/default.d.ts.map +1 -0
  111. package/lib/packlets/config/predefined/default.js +141 -0
  112. package/lib/packlets/config/predefined/default.js.map +1 -0
  113. package/lib/packlets/config/predefined/extended.d.ts +25 -0
  114. package/lib/packlets/config/predefined/extended.d.ts.map +1 -0
  115. package/lib/packlets/config/predefined/extended.js +193 -0
  116. package/lib/packlets/config/predefined/extended.js.map +1 -0
  117. package/lib/packlets/config/predefined/index.d.ts +4 -0
  118. package/lib/packlets/config/predefined/index.d.ts.map +1 -0
  119. package/lib/packlets/config/predefined/index.js +62 -0
  120. package/lib/packlets/config/predefined/index.js.map +1 -0
  121. package/lib/packlets/config/systemConfiguration.d.ts +81 -0
  122. package/lib/packlets/config/systemConfiguration.d.ts.map +1 -0
  123. package/lib/packlets/config/systemConfiguration.js +172 -0
  124. package/lib/packlets/config/systemConfiguration.js.map +1 -0
  125. package/lib/packlets/context/contextDecls.d.ts +49 -0
  126. package/lib/packlets/context/contextDecls.d.ts.map +1 -0
  127. package/lib/packlets/context/contextDecls.js +24 -0
  128. package/lib/packlets/context/contextDecls.js.map +1 -0
  129. package/lib/packlets/context/contextToken.d.ts +111 -0
  130. package/lib/packlets/context/contextToken.d.ts.map +1 -0
  131. package/lib/packlets/context/contextToken.js +206 -0
  132. package/lib/packlets/context/contextToken.js.map +1 -0
  133. package/lib/packlets/context/convert/decls.d.ts +37 -0
  134. package/lib/packlets/context/convert/decls.d.ts.map +1 -0
  135. package/lib/packlets/context/convert/decls.js +94 -0
  136. package/lib/packlets/context/convert/decls.js.map +1 -0
  137. package/lib/packlets/context/convert/index.d.ts +2 -0
  138. package/lib/packlets/context/convert/index.d.ts.map +1 -0
  139. package/lib/packlets/context/convert/index.js +39 -0
  140. package/lib/packlets/context/convert/index.js.map +1 -0
  141. package/lib/packlets/context/index.d.ts +5 -0
  142. package/lib/packlets/context/index.d.ts.map +1 -0
  143. package/lib/packlets/context/index.js +65 -0
  144. package/lib/packlets/context/index.js.map +1 -0
  145. package/lib/packlets/decisions/abstractDecision.d.ts +8 -0
  146. package/lib/packlets/decisions/abstractDecision.d.ts.map +1 -1
  147. package/lib/packlets/decisions/abstractDecision.js +9 -0
  148. package/lib/packlets/decisions/abstractDecision.js.map +1 -1
  149. package/lib/packlets/decisions/abstractDecisionCollector.d.ts.map +1 -1
  150. package/lib/packlets/decisions/abstractDecisionCollector.js +2 -0
  151. package/lib/packlets/decisions/abstractDecisionCollector.js.map +1 -1
  152. package/lib/packlets/decisions/concreteDecision.d.ts.map +1 -1
  153. package/lib/packlets/decisions/concreteDecision.js +1 -0
  154. package/lib/packlets/decisions/concreteDecision.js.map +1 -1
  155. package/lib/packlets/decisions/decision.d.ts.map +1 -1
  156. package/lib/packlets/decisions/decision.js +4 -0
  157. package/lib/packlets/decisions/decision.js.map +1 -1
  158. package/lib/packlets/import/fsItem.d.ts.map +1 -1
  159. package/lib/packlets/import/fsItem.js +8 -12
  160. package/lib/packlets/import/fsItem.js.map +1 -1
  161. package/lib/packlets/import/importContext.d.ts +19 -0
  162. package/lib/packlets/import/importContext.d.ts.map +1 -1
  163. package/lib/packlets/import/importContext.js +39 -0
  164. package/lib/packlets/import/importContext.js.map +1 -1
  165. package/lib/packlets/import/importManager.d.ts +5 -5
  166. package/lib/packlets/import/importManager.d.ts.map +1 -1
  167. package/lib/packlets/import/importManager.js.map +1 -1
  168. package/lib/packlets/import/importers/collectionImporter.d.ts +11 -13
  169. package/lib/packlets/import/importers/collectionImporter.d.ts.map +1 -1
  170. package/lib/packlets/import/importers/collectionImporter.js +29 -20
  171. package/lib/packlets/import/importers/collectionImporter.js.map +1 -1
  172. package/lib/packlets/import/importers/fsItemImporter.d.ts +2 -2
  173. package/lib/packlets/import/importers/fsItemImporter.d.ts.map +1 -1
  174. package/lib/packlets/import/importers/fsItemImporter.js +2 -2
  175. package/lib/packlets/import/importers/fsItemImporter.js.map +1 -1
  176. package/lib/packlets/import/importers/importer.d.ts +3 -3
  177. package/lib/packlets/import/importers/importer.d.ts.map +1 -1
  178. package/lib/packlets/import/importers/importer.js.map +1 -1
  179. package/lib/packlets/import/importers/jsonImporter.d.ts +2 -3
  180. package/lib/packlets/import/importers/jsonImporter.d.ts.map +1 -1
  181. package/lib/packlets/import/importers/jsonImporter.js +11 -20
  182. package/lib/packlets/import/importers/jsonImporter.js.map +1 -1
  183. package/lib/packlets/import/importers/pathImporter.d.ts +2 -2
  184. package/lib/packlets/import/importers/pathImporter.d.ts.map +1 -1
  185. package/lib/packlets/import/importers/pathImporter.js.map +1 -1
  186. package/lib/packlets/qualifier-types/config/convert.d.ts +44 -0
  187. package/lib/packlets/qualifier-types/config/convert.d.ts.map +1 -0
  188. package/lib/packlets/qualifier-types/config/convert.js +96 -0
  189. package/lib/packlets/qualifier-types/config/convert.js.map +1 -0
  190. package/lib/packlets/qualifier-types/config/index.d.ts +4 -0
  191. package/lib/packlets/qualifier-types/config/index.d.ts.map +1 -0
  192. package/lib/packlets/qualifier-types/config/index.js +64 -0
  193. package/lib/packlets/qualifier-types/config/index.js.map +1 -0
  194. package/lib/packlets/qualifier-types/config/json.d.ts +69 -0
  195. package/lib/packlets/qualifier-types/config/json.d.ts.map +1 -0
  196. package/lib/packlets/qualifier-types/config/json.js +24 -0
  197. package/lib/packlets/qualifier-types/config/json.js.map +1 -0
  198. package/lib/packlets/qualifier-types/convert.d.ts +10 -2
  199. package/lib/packlets/qualifier-types/convert.d.ts.map +1 -1
  200. package/lib/packlets/qualifier-types/convert.js +15 -0
  201. package/lib/packlets/qualifier-types/convert.js.map +1 -1
  202. package/lib/packlets/qualifier-types/helpers.d.ts +27 -0
  203. package/lib/packlets/qualifier-types/helpers.d.ts.map +1 -0
  204. package/lib/packlets/qualifier-types/helpers.js +118 -0
  205. package/lib/packlets/qualifier-types/helpers.js.map +1 -0
  206. package/lib/packlets/qualifier-types/index.d.ts +4 -1
  207. package/lib/packlets/qualifier-types/index.d.ts.map +1 -1
  208. package/lib/packlets/qualifier-types/index.js +5 -1
  209. package/lib/packlets/qualifier-types/index.js.map +1 -1
  210. package/lib/packlets/qualifier-types/languageQualifierType.d.ts +19 -8
  211. package/lib/packlets/qualifier-types/languageQualifierType.d.ts.map +1 -1
  212. package/lib/packlets/qualifier-types/languageQualifierType.js +28 -9
  213. package/lib/packlets/qualifier-types/languageQualifierType.js.map +1 -1
  214. package/lib/packlets/qualifier-types/literalQualifierType.d.ts +42 -13
  215. package/lib/packlets/qualifier-types/literalQualifierType.d.ts.map +1 -1
  216. package/lib/packlets/qualifier-types/literalQualifierType.js +58 -10
  217. package/lib/packlets/qualifier-types/literalQualifierType.js.map +1 -1
  218. package/lib/packlets/qualifier-types/literalValueHierarchy.d.ts +114 -0
  219. package/lib/packlets/qualifier-types/literalValueHierarchy.d.ts.map +1 -0
  220. package/lib/packlets/qualifier-types/literalValueHierarchy.js +228 -0
  221. package/lib/packlets/qualifier-types/literalValueHierarchy.js.map +1 -0
  222. package/lib/packlets/qualifier-types/qualifierType.d.ts +33 -18
  223. package/lib/packlets/qualifier-types/qualifierType.d.ts.map +1 -1
  224. package/lib/packlets/qualifier-types/qualifierType.js +18 -4
  225. package/lib/packlets/qualifier-types/qualifierType.js.map +1 -1
  226. package/lib/packlets/qualifier-types/qualifierTypeCollector.d.ts +4 -2
  227. package/lib/packlets/qualifier-types/qualifierTypeCollector.d.ts.map +1 -1
  228. package/lib/packlets/qualifier-types/qualifierTypeCollector.js +2 -1
  229. package/lib/packlets/qualifier-types/qualifierTypeCollector.js.map +1 -1
  230. package/lib/packlets/qualifier-types/territoryQualifierType.d.ts +47 -11
  231. package/lib/packlets/qualifier-types/territoryQualifierType.d.ts.map +1 -1
  232. package/lib/packlets/qualifier-types/territoryQualifierType.js +61 -17
  233. package/lib/packlets/qualifier-types/territoryQualifierType.js.map +1 -1
  234. package/lib/packlets/qualifiers/convert/decls.d.ts.map +1 -1
  235. package/lib/packlets/qualifiers/convert/decls.js +17 -15
  236. package/lib/packlets/qualifiers/convert/decls.js.map +1 -1
  237. package/lib/packlets/qualifiers/index.d.ts +2 -0
  238. package/lib/packlets/qualifiers/index.d.ts.map +1 -1
  239. package/lib/packlets/qualifiers/index.js +2 -0
  240. package/lib/packlets/qualifiers/index.js.map +1 -1
  241. package/lib/packlets/qualifiers/qualifier.d.ts +22 -2
  242. package/lib/packlets/qualifiers/qualifier.d.ts.map +1 -1
  243. package/lib/packlets/qualifiers/qualifier.js +26 -1
  244. package/lib/packlets/qualifiers/qualifier.js.map +1 -1
  245. package/lib/packlets/qualifiers/qualifierCollector.d.ts.map +1 -1
  246. package/lib/packlets/qualifiers/qualifierCollector.js +3 -0
  247. package/lib/packlets/qualifiers/qualifierCollector.js.map +1 -1
  248. package/lib/packlets/qualifiers/qualifierDecl.d.ts +6 -1
  249. package/lib/packlets/qualifiers/qualifierDecl.d.ts.map +1 -1
  250. package/lib/packlets/qualifiers/qualifierDecl.js.map +1 -1
  251. package/lib/packlets/qualifiers/qualifierDefaultValueDecls.d.ts +32 -0
  252. package/lib/packlets/qualifiers/qualifierDefaultValueDecls.d.ts.map +1 -0
  253. package/lib/packlets/qualifiers/qualifierDefaultValueDecls.js +24 -0
  254. package/lib/packlets/qualifiers/qualifierDefaultValueDecls.js.map +1 -0
  255. package/lib/packlets/qualifiers/qualifierDefaultValueToken.d.ts +96 -0
  256. package/lib/packlets/qualifiers/qualifierDefaultValueToken.d.ts.map +1 -0
  257. package/lib/packlets/qualifiers/qualifierDefaultValueToken.js +179 -0
  258. package/lib/packlets/qualifiers/qualifierDefaultValueToken.js.map +1 -0
  259. package/lib/packlets/resource-json/compiled/common.d.ts +14 -0
  260. package/lib/packlets/resource-json/compiled/common.d.ts.map +1 -0
  261. package/lib/packlets/resource-json/compiled/common.js +24 -0
  262. package/lib/packlets/resource-json/compiled/common.js.map +1 -0
  263. package/lib/packlets/resource-json/compiled/convert.d.ts +63 -0
  264. package/lib/packlets/resource-json/compiled/convert.d.ts.map +1 -0
  265. package/lib/packlets/resource-json/compiled/convert.js +167 -0
  266. package/lib/packlets/resource-json/compiled/convert.js.map +1 -0
  267. package/lib/packlets/resource-json/compiled/index.d.ts +5 -0
  268. package/lib/packlets/resource-json/compiled/index.d.ts.map +1 -0
  269. package/lib/packlets/resource-json/compiled/index.js +65 -0
  270. package/lib/packlets/resource-json/compiled/index.js.map +1 -0
  271. package/lib/packlets/resource-json/compiled/json.d.ts +204 -0
  272. package/lib/packlets/resource-json/compiled/json.d.ts.map +1 -0
  273. package/lib/packlets/resource-json/compiled/json.js +3 -0
  274. package/lib/packlets/resource-json/compiled/json.js.map +1 -0
  275. package/lib/packlets/resource-json/convert.d.ts +16 -0
  276. package/lib/packlets/resource-json/convert.d.ts.map +1 -1
  277. package/lib/packlets/resource-json/convert.js +41 -6
  278. package/lib/packlets/resource-json/convert.js.map +1 -1
  279. package/lib/packlets/resource-json/helpers.d.ts +82 -3
  280. package/lib/packlets/resource-json/helpers.d.ts.map +1 -1
  281. package/lib/packlets/resource-json/helpers.js +185 -2
  282. package/lib/packlets/resource-json/helpers.js.map +1 -1
  283. package/lib/packlets/resource-json/index.d.ts +2 -1
  284. package/lib/packlets/resource-json/index.d.ts.map +1 -1
  285. package/lib/packlets/resource-json/index.js +3 -1
  286. package/lib/packlets/resource-json/index.js.map +1 -1
  287. package/lib/packlets/resource-json/json.d.ts +55 -3
  288. package/lib/packlets/resource-json/json.d.ts.map +1 -1
  289. package/lib/packlets/resource-json/json.js +16 -0
  290. package/lib/packlets/resource-json/json.js.map +1 -1
  291. package/lib/packlets/resource-json/normalized.d.ts +46 -3
  292. package/lib/packlets/resource-json/normalized.d.ts.map +1 -1
  293. package/lib/packlets/resource-json/normalized.js.map +1 -1
  294. package/lib/packlets/resource-json/resourceDeclCollection.d.ts +14 -10
  295. package/lib/packlets/resource-json/resourceDeclCollection.d.ts.map +1 -1
  296. package/lib/packlets/resource-json/resourceDeclCollection.js +18 -14
  297. package/lib/packlets/resource-json/resourceDeclCollection.js.map +1 -1
  298. package/lib/packlets/resource-json/resourceDeclContainer.d.ts +15 -2
  299. package/lib/packlets/resource-json/resourceDeclContainer.d.ts.map +1 -1
  300. package/lib/packlets/resource-json/resourceDeclContainer.js.map +1 -1
  301. package/lib/packlets/resource-json/resourceDeclTree.d.ts +6 -2
  302. package/lib/packlets/resource-json/resourceDeclTree.d.ts.map +1 -1
  303. package/lib/packlets/resource-json/resourceDeclTree.js +12 -3
  304. package/lib/packlets/resource-json/resourceDeclTree.js.map +1 -1
  305. package/lib/packlets/resource-types/config/convert.d.ts +8 -0
  306. package/lib/packlets/resource-types/config/convert.d.ts.map +1 -0
  307. package/lib/packlets/resource-types/config/convert.js +36 -0
  308. package/lib/packlets/resource-types/config/convert.js.map +1 -0
  309. package/lib/packlets/resource-types/config/index.d.ts +4 -0
  310. package/lib/packlets/resource-types/config/index.d.ts.map +1 -0
  311. package/lib/packlets/resource-types/config/index.js +64 -0
  312. package/lib/packlets/resource-types/config/index.js.map +1 -0
  313. package/lib/packlets/resource-types/config/json.d.ts +9 -0
  314. package/lib/packlets/resource-types/config/json.d.ts.map +1 -0
  315. package/lib/packlets/resource-types/config/json.js +24 -0
  316. package/lib/packlets/resource-types/config/json.js.map +1 -0
  317. package/lib/packlets/resource-types/helpers.d.ts +13 -0
  318. package/lib/packlets/resource-types/helpers.d.ts.map +1 -0
  319. package/lib/packlets/resource-types/helpers.js +44 -0
  320. package/lib/packlets/resource-types/helpers.js.map +1 -0
  321. package/lib/packlets/resource-types/index.d.ts +3 -0
  322. package/lib/packlets/resource-types/index.d.ts.map +1 -1
  323. package/lib/packlets/resource-types/index.js +26 -0
  324. package/lib/packlets/resource-types/index.js.map +1 -1
  325. package/lib/packlets/resource-types/jsonResourceType.d.ts +8 -16
  326. package/lib/packlets/resource-types/jsonResourceType.d.ts.map +1 -1
  327. package/lib/packlets/resource-types/jsonResourceType.js +6 -3
  328. package/lib/packlets/resource-types/jsonResourceType.js.map +1 -1
  329. package/lib/packlets/resource-types/resourceType.d.ts +45 -35
  330. package/lib/packlets/resource-types/resourceType.d.ts.map +1 -1
  331. package/lib/packlets/resource-types/resourceType.js.map +1 -1
  332. package/lib/packlets/resources/candidateReducer.d.ts +98 -0
  333. package/lib/packlets/resources/candidateReducer.d.ts.map +1 -0
  334. package/lib/packlets/resources/candidateReducer.js +247 -0
  335. package/lib/packlets/resources/candidateReducer.js.map +1 -0
  336. package/lib/packlets/resources/common.d.ts +72 -0
  337. package/lib/packlets/resources/common.d.ts.map +1 -0
  338. package/lib/packlets/resources/common.js +24 -0
  339. package/lib/packlets/resources/common.js.map +1 -0
  340. package/lib/packlets/resources/index.d.ts +3 -1
  341. package/lib/packlets/resources/index.d.ts.map +1 -1
  342. package/lib/packlets/resources/index.js +3 -1
  343. package/lib/packlets/resources/index.js.map +1 -1
  344. package/lib/packlets/resources/resource.d.ts +57 -5
  345. package/lib/packlets/resources/resource.d.ts.map +1 -1
  346. package/lib/packlets/resources/resource.js +96 -6
  347. package/lib/packlets/resources/resource.js.map +1 -1
  348. package/lib/packlets/resources/resourceBuilder.d.ts +14 -0
  349. package/lib/packlets/resources/resourceBuilder.d.ts.map +1 -1
  350. package/lib/packlets/resources/resourceBuilder.js +19 -1
  351. package/lib/packlets/resources/resourceBuilder.js.map +1 -1
  352. package/lib/packlets/resources/resourceCandidate.d.ts +46 -6
  353. package/lib/packlets/resources/resourceCandidate.d.ts.map +1 -1
  354. package/lib/packlets/resources/resourceCandidate.js +46 -1
  355. package/lib/packlets/resources/resourceCandidate.js.map +1 -1
  356. package/lib/packlets/resources/resourceManagerBuilder.d.ts +347 -0
  357. package/lib/packlets/resources/resourceManagerBuilder.d.ts.map +1 -0
  358. package/lib/packlets/resources/resourceManagerBuilder.js +893 -0
  359. package/lib/packlets/resources/resourceManagerBuilder.js.map +1 -0
  360. package/lib/packlets/runtime/cacheListener.d.ts +71 -0
  361. package/lib/packlets/runtime/cacheListener.d.ts.map +1 -0
  362. package/lib/packlets/runtime/cacheListener.js +62 -0
  363. package/lib/packlets/runtime/cacheListener.js.map +1 -0
  364. package/lib/packlets/runtime/cacheMetrics.d.ts +88 -0
  365. package/lib/packlets/runtime/cacheMetrics.d.ts.map +1 -0
  366. package/lib/packlets/runtime/cacheMetrics.js +154 -0
  367. package/lib/packlets/runtime/cacheMetrics.js.map +1 -0
  368. package/lib/packlets/runtime/compiledResourceCollection.d.ts +167 -0
  369. package/lib/packlets/runtime/compiledResourceCollection.d.ts.map +1 -0
  370. package/lib/packlets/runtime/compiledResourceCollection.js +466 -0
  371. package/lib/packlets/runtime/compiledResourceCollection.js.map +1 -0
  372. package/lib/packlets/runtime/conditionSetResolutionResult.d.ts +70 -0
  373. package/lib/packlets/runtime/conditionSetResolutionResult.d.ts.map +1 -0
  374. package/lib/packlets/runtime/conditionSetResolutionResult.js +135 -0
  375. package/lib/packlets/runtime/conditionSetResolutionResult.js.map +1 -0
  376. package/lib/packlets/runtime/context/contextQualifierProvider.d.ts +80 -0
  377. package/lib/packlets/runtime/context/contextQualifierProvider.d.ts.map +1 -0
  378. package/lib/packlets/runtime/context/contextQualifierProvider.js +33 -0
  379. package/lib/packlets/runtime/context/contextQualifierProvider.js.map +1 -0
  380. package/lib/packlets/runtime/context/contextQualifierProviderValidator.d.ts +165 -0
  381. package/lib/packlets/runtime/context/contextQualifierProviderValidator.d.ts.map +1 -0
  382. package/lib/packlets/runtime/context/contextQualifierProviderValidator.js +179 -0
  383. package/lib/packlets/runtime/context/contextQualifierProviderValidator.js.map +1 -0
  384. package/lib/packlets/runtime/context/index.d.ts +5 -0
  385. package/lib/packlets/runtime/context/index.d.ts.map +1 -0
  386. package/lib/packlets/runtime/context/index.js +42 -0
  387. package/lib/packlets/runtime/context/index.js.map +1 -0
  388. package/lib/packlets/runtime/context/simpleContextQualifierProvider.d.ts +111 -0
  389. package/lib/packlets/runtime/context/simpleContextQualifierProvider.d.ts.map +1 -0
  390. package/lib/packlets/runtime/context/simpleContextQualifierProvider.js +177 -0
  391. package/lib/packlets/runtime/context/simpleContextQualifierProvider.js.map +1 -0
  392. package/lib/packlets/runtime/context/validatingSimpleContextQualifierProvider.d.ts +47 -0
  393. package/lib/packlets/runtime/context/validatingSimpleContextQualifierProvider.d.ts.map +1 -0
  394. package/lib/packlets/runtime/context/validatingSimpleContextQualifierProvider.js +64 -0
  395. package/lib/packlets/runtime/context/validatingSimpleContextQualifierProvider.js.map +1 -0
  396. package/lib/packlets/runtime/iResourceManager.d.ts +94 -0
  397. package/lib/packlets/runtime/iResourceManager.d.ts.map +1 -0
  398. package/lib/packlets/runtime/iResourceManager.js +24 -0
  399. package/lib/packlets/runtime/iResourceManager.js.map +1 -0
  400. package/lib/packlets/runtime/index.d.ts +12 -0
  401. package/lib/packlets/runtime/index.d.ts.map +1 -0
  402. package/lib/packlets/runtime/index.js +73 -0
  403. package/lib/packlets/runtime/index.js.map +1 -0
  404. package/lib/packlets/runtime/resource-tree/common.d.ts +91 -0
  405. package/lib/packlets/runtime/resource-tree/common.d.ts.map +1 -0
  406. package/lib/packlets/runtime/resource-tree/common.js +24 -0
  407. package/lib/packlets/runtime/resource-tree/common.js.map +1 -0
  408. package/lib/packlets/runtime/resource-tree/index.d.ts +5 -0
  409. package/lib/packlets/runtime/resource-tree/index.d.ts.map +1 -0
  410. package/lib/packlets/runtime/resource-tree/index.js +42 -0
  411. package/lib/packlets/runtime/resource-tree/index.js.map +1 -0
  412. package/lib/packlets/runtime/resource-tree/readOnlyResourceTree.d.ts +141 -0
  413. package/lib/packlets/runtime/resource-tree/readOnlyResourceTree.d.ts.map +1 -0
  414. package/lib/packlets/runtime/resource-tree/readOnlyResourceTree.js +224 -0
  415. package/lib/packlets/runtime/resource-tree/readOnlyResourceTree.js.map +1 -0
  416. package/lib/packlets/runtime/resource-tree/resourceTreeChildren.d.ts +24 -0
  417. package/lib/packlets/runtime/resource-tree/resourceTreeChildren.d.ts.map +1 -0
  418. package/lib/packlets/runtime/resource-tree/resourceTreeChildren.js +98 -0
  419. package/lib/packlets/runtime/resource-tree/resourceTreeChildren.js.map +1 -0
  420. package/lib/packlets/runtime/resource-tree/resourceTreeChildrenValidator.d.ts +99 -0
  421. package/lib/packlets/runtime/resource-tree/resourceTreeChildrenValidator.d.ts.map +1 -0
  422. package/lib/packlets/runtime/resource-tree/resourceTreeChildrenValidator.js +165 -0
  423. package/lib/packlets/runtime/resource-tree/resourceTreeChildrenValidator.js.map +1 -0
  424. package/lib/packlets/runtime/resourceResolver.d.ts +217 -0
  425. package/lib/packlets/runtime/resourceResolver.d.ts.map +1 -0
  426. package/lib/packlets/runtime/resourceResolver.js +459 -0
  427. package/lib/packlets/runtime/resourceResolver.js.map +1 -0
  428. package/lib/packlets/runtime/validate.d.ts +13 -0
  429. package/lib/packlets/runtime/validate.d.ts.map +1 -0
  430. package/lib/packlets/runtime/validate.js +49 -0
  431. package/lib/packlets/runtime/validate.js.map +1 -0
  432. package/package.json +76 -75
  433. package/lib/packlets/resources/resourceManager.d.ts +0 -104
  434. package/lib/packlets/resources/resourceManager.d.ts.map +0 -1
  435. package/lib/packlets/resources/resourceManager.js +0 -201
  436. package/lib/packlets/resources/resourceManager.js.map +0 -1
@@ -0,0 +1,141 @@
1
+ import { Result } from '@fgv/ts-utils';
2
+ import { ResourceId, ResourceName } from '../../common';
3
+ import { IReadOnlyResourceTreeLeaf, IReadOnlyResourceTreeBranch, IReadOnlyResourceTreeRoot, IReadOnlyValidatingResourceTreeChildren } from './common';
4
+ /**
5
+ * Interface for initializing a resource tree root with child nodes.
6
+ * @public
7
+ */
8
+ export interface IResourceTreeRootInit<T> {
9
+ readonly children: Record<ResourceName, ResourceTreeNodeInit<T>>;
10
+ }
11
+ /**
12
+ * Interface for initializing a leaf node with a resource value.
13
+ * @public
14
+ */
15
+ export interface IResourceTreeLeafInit<T> {
16
+ readonly resource: T;
17
+ }
18
+ /**
19
+ * Interface for initializing a branch node with child nodes.
20
+ * @public
21
+ */
22
+ export interface IResourceTreeBranchInit<T> {
23
+ readonly children: Record<ResourceName, ResourceTreeNodeInit<T>>;
24
+ }
25
+ /**
26
+ * Union type for tree node initialization data.
27
+ * @public
28
+ */
29
+ export type ResourceTreeNodeInit<T> = IResourceTreeLeafInit<T> | IResourceTreeBranchInit<T>;
30
+ /**
31
+ * Type guard to determine if an init object represents a branch or root with children.
32
+ * @param init - The initialization object to test
33
+ * @returns True if the init object has children property
34
+ * @public
35
+ */
36
+ export declare function isResourceTreeRootOrNodeInit<T>(init: ResourceTreeNodeInit<T> | IResourceTreeRootInit<T>): init is IResourceTreeBranchInit<T>;
37
+ /**
38
+ * Type guard to determine if an init object represents a leaf node with a resource.
39
+ * @param init - The initialization object to test
40
+ * @returns True if the init object has a resource but no children
41
+ * @public
42
+ */
43
+ export declare function isResourceTreeLeafInit<T>(init: ResourceTreeNodeInit<T>): init is IResourceTreeLeafInit<T>;
44
+ /**
45
+ * Implementation of a read-only resource tree leaf node that contains a resource value.
46
+ * Leaf nodes represent the actual resources in the tree and cannot have children.
47
+ * @public
48
+ */
49
+ export declare class ReadOnlyResourceTreeLeaf<T> implements IReadOnlyResourceTreeLeaf<T> {
50
+ readonly name: ResourceName;
51
+ readonly id: ResourceId;
52
+ readonly resource: T;
53
+ get isRoot(): false;
54
+ get isBranch(): false;
55
+ get isLeaf(): true;
56
+ /**
57
+ * Creates a new leaf node. Use the static create method instead.
58
+ * @param name - The name of this node (last segment of the path)
59
+ * @param parentPath - The path to the parent node (undefined for root-level nodes)
60
+ * @param resource - The resource value stored in this leaf
61
+ */
62
+ protected constructor(name: ResourceName, parentPath: ResourceId | undefined, resource: T);
63
+ /**
64
+ * Creates a new ReadOnlyResourceTreeLeaf instance.
65
+ * @param name - The name of this node (last segment of the path)
66
+ * @param parentPath - The path to the parent node (undefined for root-level nodes)
67
+ * @param resource - The resource value to store in this leaf
68
+ * @returns Result containing the new leaf node or failure if construction fails
69
+ */
70
+ static create<T>(name: ResourceName, parentPath: ResourceId | undefined, resource: T): Result<ReadOnlyResourceTreeLeaf<T>>;
71
+ }
72
+ /**
73
+ * Implementation of a read-only resource tree branch node that contains child nodes.
74
+ * Branch nodes organize other nodes in a hierarchical structure and may optionally contain a resource value.
75
+ * @public
76
+ */
77
+ export declare class ReadOnlyResourceTreeBranch<T> implements IReadOnlyResourceTreeBranch<T> {
78
+ readonly children: IReadOnlyValidatingResourceTreeChildren<T>;
79
+ readonly name: ResourceName;
80
+ readonly id: ResourceId;
81
+ get isRoot(): false;
82
+ get isBranch(): true;
83
+ get isLeaf(): false;
84
+ /**
85
+ * Creates a new branch node. Use the static create method instead.
86
+ * @param name - The name of this node (last segment of the path)
87
+ * @param parentPath - The path to the parent node (undefined for root-level nodes)
88
+ * @param init - Initialization data containing child nodes
89
+ */
90
+ private constructor();
91
+ /**
92
+ * Creates a new ReadOnlyResourceTreeBranch instance.
93
+ * @param childName - The name of this node (last segment of the path)
94
+ * @param path - The path to the parent node (undefined for root-level nodes)
95
+ * @param childInit - Initialization data containing child nodes
96
+ * @returns Result containing the new branch node or failure if construction fails
97
+ */
98
+ static create<T>(childName: ResourceName, path: ResourceId | undefined, childInit: IResourceTreeBranchInit<T>): Result<ReadOnlyResourceTreeBranch<T>>;
99
+ }
100
+ /**
101
+ * Union type representing any node in a read-only resource tree.
102
+ * @public
103
+ */
104
+ export type ReadOnlyResourceTreeNode<T> = ReadOnlyResourceTreeBranch<T> | ReadOnlyResourceTreeLeaf<T>;
105
+ /**
106
+ * Implementation of a read-only resource tree root that organizes resources hierarchically.
107
+ * The root provides the entry point for tree navigation and resource access by ResourceId paths.
108
+ * @public
109
+ */
110
+ export declare class ReadOnlyResourceTreeRoot<T> implements IReadOnlyResourceTreeRoot<T> {
111
+ readonly children: IReadOnlyValidatingResourceTreeChildren<T>;
112
+ get isRoot(): true;
113
+ get isBranch(): false;
114
+ get isLeaf(): false;
115
+ /**
116
+ * Creates a new root node. Use the static create method instead.
117
+ * @param init - Initialization data containing child nodes
118
+ */
119
+ protected constructor(init: IResourceTreeRootInit<T>);
120
+ /**
121
+ * Creates a new ReadOnlyResourceTreeRoot from an array of resources.
122
+ * @param resources - Array of [ResourceId, resource] pairs to build the tree from
123
+ * @returns Result containing the new root or failure if construction fails
124
+ */
125
+ static create<T>(resources: [ResourceId, T][]): Result<ReadOnlyResourceTreeRoot<T>>;
126
+ /**
127
+ * Creates a new ReadOnlyResourceTreeRoot from initialization data.
128
+ * @param init - Tree initialization structure
129
+ * @returns Result containing the new root or failure if construction fails
130
+ */
131
+ static create<T>(init: IResourceTreeRootInit<T>): Result<ReadOnlyResourceTreeRoot<T>>;
132
+ /**
133
+ * Converts an array of resources into tree initialization data.
134
+ * Validates that resource paths do not conflict - if a path has child resources,
135
+ * it cannot itself be a resource (e.g., if 'app.messages.welcome' exists, then 'app' cannot be a resource).
136
+ * @param resources - Array of [ResourceId, resource] pairs to convert
137
+ * @returns Result containing the initialization structure or failure if validation fails
138
+ */
139
+ static createResourceTreeInit<T>(resources: [ResourceId, T][]): Result<IResourceTreeRootInit<T>>;
140
+ }
141
+ //# sourceMappingURL=readOnlyResourceTree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readOnlyResourceTree.d.ts","sourceRoot":"","sources":["../../../../src/packlets/runtime/resource-tree/readOnlyResourceTree.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAqB,MAAM,EAAsC,MAAM,eAAe,CAAC;AAC9F,OAAO,EAAE,UAAU,EAAE,YAAY,EAAW,MAAM,cAAc,CAAC;AACjE,OAAO,EAEL,yBAAyB,EACzB,2BAA2B,EAC3B,yBAAyB,EACzB,uCAAuC,EACxC,MAAM,UAAU,CAAC;AAGlB;;;GAGG;AACH,MAAM,WAAW,qBAAqB,CAAC,CAAC;IACtC,QAAQ,CAAC,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C,UAAU,EAAE,CAAC,CAAC,EAAE,GAAG,MAAM,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC;IAE1F;;;;OAIG;WACW,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC;IAkB5F;;;;;;OAMG;WACW,sBAAsB,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,UAAU,EAAE,CAAC,CAAC,EAAE,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;CA6CxG"}
@@ -0,0 +1,224 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2025 Erik Fortune
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ * of this software and associated documentation files (the "Software"), to deal
7
+ * in the Software without restriction, including without limitation the rights
8
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ * copies of the Software, and to permit persons to whom the Software is
10
+ * furnished to do so, subject to the following conditions:
11
+ *
12
+ * The above copyright notice and this permission notice shall be included in all
13
+ * copies or substantial portions of the Software.
14
+ *
15
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ * SOFTWARE.
22
+ */
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.ReadOnlyResourceTreeRoot = exports.ReadOnlyResourceTreeBranch = exports.ReadOnlyResourceTreeLeaf = void 0;
25
+ exports.isResourceTreeRootOrNodeInit = isResourceTreeRootOrNodeInit;
26
+ exports.isResourceTreeLeafInit = isResourceTreeLeafInit;
27
+ const ts_utils_1 = require("@fgv/ts-utils");
28
+ const common_1 = require("../../common");
29
+ const resourceTreeChildren_1 = require("./resourceTreeChildren");
30
+ // Type guards
31
+ /**
32
+ * Type guard to determine if an init object represents a branch or root with children.
33
+ * @param init - The initialization object to test
34
+ * @returns True if the init object has children property
35
+ * @public
36
+ */
37
+ function isResourceTreeRootOrNodeInit(init) {
38
+ return 'children' in init;
39
+ }
40
+ /**
41
+ * Type guard to determine if an init object represents a leaf node with a resource.
42
+ * @param init - The initialization object to test
43
+ * @returns True if the init object has a resource but no children
44
+ * @public
45
+ */
46
+ function isResourceTreeLeafInit(init) {
47
+ return 'resource' in init && !('children' in init);
48
+ }
49
+ /**
50
+ * Implementation of a read-only resource tree leaf node that contains a resource value.
51
+ * Leaf nodes represent the actual resources in the tree and cannot have children.
52
+ * @public
53
+ */
54
+ class ReadOnlyResourceTreeLeaf {
55
+ get isRoot() {
56
+ return false;
57
+ }
58
+ get isBranch() {
59
+ return false;
60
+ }
61
+ get isLeaf() {
62
+ return true;
63
+ }
64
+ /**
65
+ * Creates a new leaf node. Use the static create method instead.
66
+ * @param name - The name of this node (last segment of the path)
67
+ * @param parentPath - The path to the parent node (undefined for root-level nodes)
68
+ * @param resource - The resource value stored in this leaf
69
+ */
70
+ constructor(name, parentPath, resource) {
71
+ this.name = name;
72
+ this.id = common_1.Helpers.joinResourceIds(parentPath, name).orThrow();
73
+ this.resource = resource;
74
+ }
75
+ /**
76
+ * Creates a new ReadOnlyResourceTreeLeaf instance.
77
+ * @param name - The name of this node (last segment of the path)
78
+ * @param parentPath - The path to the parent node (undefined for root-level nodes)
79
+ * @param resource - The resource value to store in this leaf
80
+ * @returns Result containing the new leaf node or failure if construction fails
81
+ */
82
+ static create(name, parentPath, resource) {
83
+ return (0, ts_utils_1.captureResult)(() => new ReadOnlyResourceTreeLeaf(name, parentPath, resource));
84
+ }
85
+ }
86
+ exports.ReadOnlyResourceTreeLeaf = ReadOnlyResourceTreeLeaf;
87
+ /**
88
+ * Implementation of a read-only resource tree branch node that contains child nodes.
89
+ * Branch nodes organize other nodes in a hierarchical structure and may optionally contain a resource value.
90
+ * @public
91
+ */
92
+ class ReadOnlyResourceTreeBranch {
93
+ get isRoot() {
94
+ return false;
95
+ }
96
+ get isBranch() {
97
+ return true;
98
+ }
99
+ get isLeaf() {
100
+ return false;
101
+ }
102
+ /**
103
+ * Creates a new branch node. Use the static create method instead.
104
+ * @param name - The name of this node (last segment of the path)
105
+ * @param parentPath - The path to the parent node (undefined for root-level nodes)
106
+ * @param init - Initialization data containing child nodes
107
+ */
108
+ constructor(name, parentPath, init) {
109
+ this.name = name;
110
+ this.id = common_1.Helpers.joinResourceIds(parentPath, name).orThrow();
111
+ const children = (0, ts_utils_1.mapResults)(Array.from(Object.entries(init.children)).map(([childName, childInit]) => {
112
+ if (isResourceTreeLeafInit(childInit)) {
113
+ return ReadOnlyResourceTreeLeaf.create(childName, this.id, childInit.resource);
114
+ }
115
+ return ReadOnlyResourceTreeBranch.create(childName, this.id, childInit);
116
+ })).orThrow();
117
+ this.children = new resourceTreeChildren_1.ReadOnlyResourceTreeChildren(this.id, children.map((c) => [c.name, c]));
118
+ }
119
+ /**
120
+ * Creates a new ReadOnlyResourceTreeBranch instance.
121
+ * @param childName - The name of this node (last segment of the path)
122
+ * @param path - The path to the parent node (undefined for root-level nodes)
123
+ * @param childInit - Initialization data containing child nodes
124
+ * @returns Result containing the new branch node or failure if construction fails
125
+ */
126
+ static create(childName, path, childInit) {
127
+ return (0, ts_utils_1.captureResult)(() => new ReadOnlyResourceTreeBranch(childName, path, childInit));
128
+ }
129
+ }
130
+ exports.ReadOnlyResourceTreeBranch = ReadOnlyResourceTreeBranch;
131
+ /**
132
+ * Implementation of a read-only resource tree root that organizes resources hierarchically.
133
+ * The root provides the entry point for tree navigation and resource access by ResourceId paths.
134
+ * @public
135
+ */
136
+ class ReadOnlyResourceTreeRoot {
137
+ get isRoot() {
138
+ return true;
139
+ }
140
+ get isBranch() {
141
+ return false;
142
+ }
143
+ get isLeaf() {
144
+ return false;
145
+ }
146
+ /**
147
+ * Creates a new root node. Use the static create method instead.
148
+ * @param init - Initialization data containing child nodes
149
+ */
150
+ constructor(init) {
151
+ const children = (0, ts_utils_1.mapResults)(Array.from(Object.entries(init.children)).map(([childName, childInit]) => {
152
+ if (isResourceTreeLeafInit(childInit)) {
153
+ return ReadOnlyResourceTreeLeaf.create(childName, undefined, childInit.resource);
154
+ }
155
+ return ReadOnlyResourceTreeBranch.create(childName, undefined, childInit);
156
+ })).orThrow();
157
+ this.children = new resourceTreeChildren_1.ReadOnlyResourceTreeChildren(undefined, children.map((c) => [c.name, c]));
158
+ }
159
+ /**
160
+ * Creates a new ReadOnlyResourceTreeRoot from either resources or initialization data.
161
+ * @param init - Either an array of [ResourceId, resource] pairs or tree initialization structure
162
+ * @returns Result containing the new root or failure if construction fails
163
+ */
164
+ static create(init) {
165
+ if (Array.isArray(init)) {
166
+ return ReadOnlyResourceTreeRoot.createResourceTreeInit(init).onSuccess((treeInit) => (0, ts_utils_1.captureResult)(() => new ReadOnlyResourceTreeRoot(treeInit)));
167
+ }
168
+ return (0, ts_utils_1.captureResult)(() => new ReadOnlyResourceTreeRoot(init));
169
+ }
170
+ /**
171
+ * Converts an array of resources into tree initialization data.
172
+ * Validates that resource paths do not conflict - if a path has child resources,
173
+ * it cannot itself be a resource (e.g., if 'app.messages.welcome' exists, then 'app' cannot be a resource).
174
+ * @param resources - Array of [ResourceId, resource] pairs to convert
175
+ * @returns Result containing the initialization structure or failure if validation fails
176
+ */
177
+ static createResourceTreeInit(resources) {
178
+ const errors = new ts_utils_1.MessageAggregator();
179
+ const root = { children: {} };
180
+ for (const [id, resource] of resources) {
181
+ common_1.Helpers.splitResourceId(id)
182
+ .onSuccess((pathComponents) => {
183
+ let currentNode = root;
184
+ const resourceName = pathComponents.pop();
185
+ for (const nodeName of pathComponents) {
186
+ if (isResourceTreeRootOrNodeInit(currentNode)) {
187
+ if (!(nodeName in currentNode.children)) {
188
+ currentNode.children[nodeName] = { children: {} };
189
+ }
190
+ if (isResourceTreeLeafInit(currentNode.children[nodeName])) {
191
+ errors.addMessage(`${id}: Expected a branch but found a leaf at ${nodeName}.`);
192
+ }
193
+ else {
194
+ currentNode = currentNode.children[nodeName];
195
+ }
196
+ } /* c8 ignore next 4 - defense in depth, not reachable without chicanery */
197
+ else if (isResourceTreeLeafInit(currentNode)) {
198
+ errors.addMessage(`${id}: Expected a branch but found a leaf.`);
199
+ break;
200
+ } /* c8 ignore next 3 - defense in depth, not reachable without chicanery */
201
+ else {
202
+ errors.addMessage(`${id}: Unexpected structure in resource tree`);
203
+ }
204
+ }
205
+ if (isResourceTreeRootOrNodeInit(currentNode)) {
206
+ if (resourceName in currentNode.children) {
207
+ errors.addMessage(`${id}: Duplicate resource at path.`);
208
+ }
209
+ else {
210
+ currentNode.children[resourceName] = { resource };
211
+ } /* c8 ignore next 3 - defense in depth, not reachable without chicanery */
212
+ }
213
+ else {
214
+ errors.addMessage(`${id}: Expected a branch but found a leaf.`);
215
+ }
216
+ return (0, ts_utils_1.succeed)(currentNode.children[resourceName]);
217
+ })
218
+ .aggregateError(errors);
219
+ }
220
+ return errors.returnOrReport((0, ts_utils_1.succeed)(root));
221
+ }
222
+ }
223
+ exports.ReadOnlyResourceTreeRoot = ReadOnlyResourceTreeRoot;
224
+ //# sourceMappingURL=readOnlyResourceTree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readOnlyResourceTree.js","sourceRoot":"","sources":["../../../../src/packlets/runtime/resource-tree/readOnlyResourceTree.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAkDH,oEAIC;AAQD,wDAEC;AA9DD,4CAA8F;AAC9F,yCAAiE;AAQjE,iEAAsE;AAgC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W,CAAC,QAAQ,EAAE,CAAC;wBACzC,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,+BAA+B,CAAC,CAAC;oBAC1D,CAAC;yBAAM,CAAC;wBACN,WAAW,CAAC,QAAQ,CAAC,YAAY,CAAC,GAAG,EAAE,QAAQ,EAAE,CAAC;oBACpD,CAAC,CAAC,0EAA0E;gBAC9E,CAAC;qBAAM,CAAC;oBACN,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,uCAAuC,CAAC,CAAC;gBAClE,CAAC;gBACD,OAAO,IAAA,kBAAO,EAAC,WAAW,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC;YACrD,CAAC,CAAC;iBACD,cAAc,CAAC,MAAM,CAAC,CAAC;QAC5B,CAAC;QACD,OAAO,MAAM,CAAC,cAAc,CAAC,IAAA,kBAAO,EAAC,IAAI,CAAC,CAAC,CAAC;IAC9C,CAAC;CACF;AA1HD,4DA0HC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { MessageAggregator, Result, captureResult, mapResults, succeed } from '@fgv/ts-utils';\nimport { ResourceId, ResourceName, Helpers } from '../../common';\nimport {\n IReadOnlyResourceTreeNode,\n IReadOnlyResourceTreeLeaf,\n IReadOnlyResourceTreeBranch,\n IReadOnlyResourceTreeRoot,\n IReadOnlyValidatingResourceTreeChildren\n} from './common';\nimport { ReadOnlyResourceTreeChildren } from './resourceTreeChildren';\n\n/**\n * Interface for initializing a resource tree root with child nodes.\n * @public\n */\nexport interface IResourceTreeRootInit<T> {\n readonly children: Record<ResourceName, ResourceTreeNodeInit<T>>;\n}\n\n/**\n * Interface for initializing a leaf node with a resource value.\n * @public\n */\nexport interface IResourceTreeLeafInit<T> {\n readonly resource: T;\n}\n\n/**\n * Interface for initializing a branch node with child nodes.\n * @public\n */\nexport interface IResourceTreeBranchInit<T> {\n readonly children: Record<ResourceName, ResourceTreeNodeInit<T>>;\n}\n\n/**\n * Union type for tree node initialization data.\n * @public\n */\nexport type ResourceTreeNodeInit<T> = IResourceTreeLeafInit<T> | IResourceTreeBranchInit<T>;\n\n// Type guards\n/**\n * Type guard to determine if an init object represents a branch or root with children.\n * @param init - The initialization object to test\n * @returns True if the init object has children property\n * @public\n */\nexport function isResourceTreeRootOrNodeInit<T>(\n init: ResourceTreeNodeInit<T> | IResourceTreeRootInit<T>\n): init is IResourceTreeBranchInit<T> {\n return 'children' in init;\n}\n\n/**\n * Type guard to determine if an init object represents a leaf node with a resource.\n * @param init - The initialization object to test\n * @returns True if the init object has a resource but no children\n * @public\n */\nexport function isResourceTreeLeafInit<T>(init: ResourceTreeNodeInit<T>): init is IResourceTreeLeafInit<T> {\n return 'resource' in init && !('children' in init);\n}\n\n/**\n * Implementation of a read-only resource tree leaf node that contains a resource value.\n * Leaf nodes represent the actual resources in the tree and cannot have children.\n * @public\n */\nexport class ReadOnlyResourceTreeLeaf<T> implements IReadOnlyResourceTreeLeaf<T> {\n public readonly name: ResourceName;\n public readonly id: ResourceId;\n public readonly resource: T;\n\n public get isRoot(): false {\n return false;\n }\n\n public get isBranch(): false {\n return false;\n }\n\n public get isLeaf(): true {\n return true;\n }\n\n /**\n * Creates a new leaf node. Use the static create method instead.\n * @param name - The name of this node (last segment of the path)\n * @param parentPath - The path to the parent node (undefined for root-level nodes)\n * @param resource - The resource value stored in this leaf\n */\n protected constructor(name: ResourceName, parentPath: ResourceId | undefined, resource: T) {\n this.name = name;\n this.id = Helpers.joinResourceIds(parentPath, name).orThrow();\n this.resource = resource;\n }\n\n /**\n * Creates a new ReadOnlyResourceTreeLeaf instance.\n * @param name - The name of this node (last segment of the path)\n * @param parentPath - The path to the parent node (undefined for root-level nodes)\n * @param resource - The resource value to store in this leaf\n * @returns Result containing the new leaf node or failure if construction fails\n */\n public static create<T>(\n name: ResourceName,\n parentPath: ResourceId | undefined,\n resource: T\n ): Result<ReadOnlyResourceTreeLeaf<T>> {\n return captureResult(() => new ReadOnlyResourceTreeLeaf(name, parentPath, resource));\n }\n}\n\n/**\n * Implementation of a read-only resource tree branch node that contains child nodes.\n * Branch nodes organize other nodes in a hierarchical structure and may optionally contain a resource value.\n * @public\n */\nexport class ReadOnlyResourceTreeBranch<T> implements IReadOnlyResourceTreeBranch<T> {\n public readonly children: IReadOnlyValidatingResourceTreeChildren<T>;\n public readonly name: ResourceName;\n public readonly id: ResourceId;\n\n public get isRoot(): false {\n return false;\n }\n\n public get isBranch(): true {\n return true;\n }\n\n public get isLeaf(): false {\n return false;\n }\n\n /**\n * Creates a new branch node. Use the static create method instead.\n * @param name - The name of this node (last segment of the path)\n * @param parentPath - The path to the parent node (undefined for root-level nodes)\n * @param init - Initialization data containing child nodes\n */\n private constructor(\n name: ResourceName,\n parentPath: ResourceId | undefined,\n init: IResourceTreeBranchInit<T>\n ) {\n this.name = name;\n this.id = Helpers.joinResourceIds(parentPath, name).orThrow();\n\n const children = mapResults<IReadOnlyResourceTreeNode<T>>(\n (\n Array.from(Object.entries(init.children)) as [\n ResourceName,\n IResourceTreeBranchInit<T> | IResourceTreeLeafInit<T>\n ][]\n ).map(([childName, childInit]) => {\n if (isResourceTreeLeafInit(childInit)) {\n return ReadOnlyResourceTreeLeaf.create(childName, this.id, childInit.resource);\n }\n return ReadOnlyResourceTreeBranch.create(childName, this.id, childInit);\n })\n ).orThrow();\n\n this.children = new ReadOnlyResourceTreeChildren(\n this.id,\n children.map((c): [ResourceName, IReadOnlyResourceTreeNode<T>] => [c.name, c])\n );\n }\n\n /**\n * Creates a new ReadOnlyResourceTreeBranch instance.\n * @param childName - The name of this node (last segment of the path)\n * @param path - The path to the parent node (undefined for root-level nodes)\n * @param childInit - Initialization data containing child nodes\n * @returns Result containing the new branch node or failure if construction fails\n */\n public static create<T>(\n childName: ResourceName,\n path: ResourceId | undefined,\n childInit: IResourceTreeBranchInit<T>\n ): Result<ReadOnlyResourceTreeBranch<T>> {\n return captureResult(() => new ReadOnlyResourceTreeBranch(childName, path, childInit));\n }\n}\n\n/**\n * Union type representing any node in a read-only resource tree.\n * @public\n */\nexport type ReadOnlyResourceTreeNode<T> = ReadOnlyResourceTreeBranch<T> | ReadOnlyResourceTreeLeaf<T>;\n\n/**\n * Implementation of a read-only resource tree root that organizes resources hierarchically.\n * The root provides the entry point for tree navigation and resource access by ResourceId paths.\n * @public\n */\nexport class ReadOnlyResourceTreeRoot<T> implements IReadOnlyResourceTreeRoot<T> {\n public readonly children: IReadOnlyValidatingResourceTreeChildren<T>;\n\n public get isRoot(): true {\n return true;\n }\n\n public get isBranch(): false {\n return false;\n }\n\n public get isLeaf(): false {\n return false;\n }\n\n /**\n * Creates a new root node. Use the static create method instead.\n * @param init - Initialization data containing child nodes\n */\n protected constructor(init: IResourceTreeRootInit<T>) {\n const children = mapResults<ReadOnlyResourceTreeBranch<T> | ReadOnlyResourceTreeLeaf<T>>(\n (\n Array.from(Object.entries(init.children)) as [\n ResourceName,\n IResourceTreeBranchInit<T> | IResourceTreeLeafInit<T>\n ][]\n ).map(([childName, childInit]) => {\n if (isResourceTreeLeafInit(childInit)) {\n return ReadOnlyResourceTreeLeaf.create(childName, undefined, childInit.resource);\n }\n return ReadOnlyResourceTreeBranch.create(childName, undefined, childInit);\n })\n ).orThrow();\n\n this.children = new ReadOnlyResourceTreeChildren(\n undefined,\n children.map((c): [ResourceName, IReadOnlyResourceTreeNode<T>] => [c.name, c])\n );\n }\n\n /**\n * Creates a new ReadOnlyResourceTreeRoot from an array of resources.\n * @param resources - Array of [ResourceId, resource] pairs to build the tree from\n * @returns Result containing the new root or failure if construction fails\n */\n public static create<T>(resources: [ResourceId, T][]): Result<ReadOnlyResourceTreeRoot<T>>;\n\n /**\n * Creates a new ReadOnlyResourceTreeRoot from initialization data.\n * @param init - Tree initialization structure\n * @returns Result containing the new root or failure if construction fails\n */\n public static create<T>(init: IResourceTreeRootInit<T>): Result<ReadOnlyResourceTreeRoot<T>>;\n\n /**\n * Creates a new ReadOnlyResourceTreeRoot from either resources or initialization data.\n * @param init - Either an array of [ResourceId, resource] pairs or tree initialization structure\n * @returns Result containing the new root or failure if construction fails\n */\n public static create<T>(\n init: IResourceTreeRootInit<T> | [ResourceId, T][]\n ): Result<ReadOnlyResourceTreeRoot<T>> {\n if (Array.isArray(init)) {\n return ReadOnlyResourceTreeRoot.createResourceTreeInit(init).onSuccess((treeInit) =>\n captureResult(() => new ReadOnlyResourceTreeRoot(treeInit))\n );\n }\n return captureResult(() => new ReadOnlyResourceTreeRoot(init));\n }\n\n /**\n * Converts an array of resources into tree initialization data.\n * Validates that resource paths do not conflict - if a path has child resources,\n * it cannot itself be a resource (e.g., if 'app.messages.welcome' exists, then 'app' cannot be a resource).\n * @param resources - Array of [ResourceId, resource] pairs to convert\n * @returns Result containing the initialization structure or failure if validation fails\n */\n public static createResourceTreeInit<T>(resources: [ResourceId, T][]): Result<IResourceTreeRootInit<T>> {\n const errors: MessageAggregator = new MessageAggregator();\n const root: IResourceTreeRootInit<T> = { children: {} };\n\n for (const [id, resource] of resources) {\n Helpers.splitResourceId(id)\n .onSuccess((pathComponents) => {\n let currentNode: IResourceTreeBranchInit<T> | IResourceTreeRootInit<T> = root;\n const resourceName = pathComponents.pop()!;\n\n for (const nodeName of pathComponents) {\n if (isResourceTreeRootOrNodeInit(currentNode)) {\n if (!(nodeName in currentNode.children)) {\n currentNode.children[nodeName] = { children: {} };\n }\n if (isResourceTreeLeafInit(currentNode.children[nodeName])) {\n errors.addMessage(`${id}: Expected a branch but found a leaf at ${nodeName}.`);\n } else {\n currentNode = currentNode.children[nodeName];\n }\n } /* c8 ignore next 4 - defense in depth, not reachable without chicanery */ else if (\n isResourceTreeLeafInit(currentNode)\n ) {\n errors.addMessage(`${id}: Expected a branch but found a leaf.`);\n break;\n } /* c8 ignore next 3 - defense in depth, not reachable without chicanery */ else {\n errors.addMessage(`${id}: Unexpected structure in resource tree`);\n }\n }\n\n if (isResourceTreeRootOrNodeInit(currentNode)) {\n if (resourceName in currentNode.children) {\n errors.addMessage(`${id}: Duplicate resource at path.`);\n } else {\n currentNode.children[resourceName] = { resource };\n } /* c8 ignore next 3 - defense in depth, not reachable without chicanery */\n } else {\n errors.addMessage(`${id}: Expected a branch but found a leaf.`);\n }\n return succeed(currentNode.children[resourceName]);\n })\n .aggregateError(errors);\n }\n return errors.returnOrReport(succeed(root));\n }\n}\n"]}
@@ -0,0 +1,24 @@
1
+ import { Result, ResultMap } from '@fgv/ts-utils';
2
+ import { ResourceId, ResourceName } from '../../common';
3
+ import { IReadOnlyResourceTreeBranch, IReadOnlyResourceTreeChildren, IReadOnlyResourceTreeLeaf, IReadOnlyResourceTreeNode, IReadOnlyValidatingResourceTreeChildren } from './common';
4
+ /**
5
+ * Implementation of a result-based resource tree that provides hierarchical access to resources.
6
+ * Extends ResultMap to provide collection-like access while adding tree-specific navigation methods.
7
+ * @public
8
+ */
9
+ export declare class ReadOnlyResourceTreeChildren<T> extends ResultMap<ResourceName, IReadOnlyResourceTreeNode<T>> implements IReadOnlyValidatingResourceTreeChildren<T> {
10
+ protected path: ResourceId | undefined;
11
+ validating: IReadOnlyResourceTreeChildren<T, string, string>;
12
+ /**
13
+ * Creates a new ReadOnlyResourceTreeChildren instance.
14
+ * @param path - The path to this tree node (undefined for root)
15
+ * @param entries - Array of [name, node] tuples to populate the tree
16
+ */
17
+ constructor(path: ResourceId | undefined, entries: [ResourceName, IReadOnlyResourceTreeNode<T>][]);
18
+ getResource(name: ResourceName): Result<IReadOnlyResourceTreeNode<T>>;
19
+ getBranch(name: ResourceName): Result<IReadOnlyResourceTreeNode<T>>;
20
+ getById(id: ResourceId): Result<IReadOnlyResourceTreeNode<T>>;
21
+ getResourceById(id: ResourceId): Result<IReadOnlyResourceTreeLeaf<T>>;
22
+ getBranchById(id: ResourceId): Result<IReadOnlyResourceTreeBranch<T>>;
23
+ }
24
+ //# sourceMappingURL=resourceTreeChildren.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resourceTreeChildren.d.ts","sourceRoot":"","sources":["../../../../src/packlets/runtime/resource-tree/resourceTreeChildren.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAe,MAAM,EAAE,SAAS,EAAiB,MAAM,eAAe,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,YAAY,EAAW,MAAM,cAAc,CAAC;AACjE,OAAO,EACL,2BAA2B,EAC3B,6BAA6B,EAC7B,yBAAyB,EACzB,yBAAyB,EACzB,uCAAuC,EACxC,MAAM,UAAU,CAAC;AAGlB;;;;GAIG;AACH,qBAAa,4BAA4B,CAAC,CAAC,CACzC,SAAQ,SAAS,CAAC,YAAY,EAAE,yBAAyB,CAAC,CAAC,CAAC,CAC5D,YAAW,uCAAuC,CAAC,CAAC,CAAC;IAErD,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,SAAS,CAAC;IAChC,UAAU,EAAE,6BAA6B,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAEpE;;;;OAIG;gBACgB,IAAI,EAAE,UAAU,GAAG,SAAS,EAAE,OAAO,EAAE,CAAC,YAAY,EAAE,yBAAyB,CAAC,CAAC,CAAC,CAAC,EAAE;IAMjG,WAAW,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC;IAWrE,SAAS,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC;IAWnE,OAAO,CAAC,EAAE,EAAE,UAAU,GAAG,MAAM,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC;IAqB7D,eAAe,CAAC,EAAE,EAAE,UAAU,GAAG,MAAM,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC;IAarE,aAAa,CAAC,EAAE,EAAE,UAAU,GAAG,MAAM,CAAC,2BAA2B,CAAC,CAAC,CAAC,CAAC;CAY7E"}
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2025 Erik Fortune
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ * of this software and associated documentation files (the "Software"), to deal
7
+ * in the Software without restriction, including without limitation the rights
8
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ * copies of the Software, and to permit persons to whom the Software is
10
+ * furnished to do so, subject to the following conditions:
11
+ *
12
+ * The above copyright notice and this permission notice shall be included in all
13
+ * copies or substantial portions of the Software.
14
+ *
15
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ * SOFTWARE.
22
+ */
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.ReadOnlyResourceTreeChildren = void 0;
25
+ const ts_utils_1 = require("@fgv/ts-utils");
26
+ const common_1 = require("../../common");
27
+ const resourceTreeChildrenValidator_1 = require("./resourceTreeChildrenValidator");
28
+ /**
29
+ * Implementation of a result-based resource tree that provides hierarchical access to resources.
30
+ * Extends ResultMap to provide collection-like access while adding tree-specific navigation methods.
31
+ * @public
32
+ */
33
+ class ReadOnlyResourceTreeChildren extends ts_utils_1.ResultMap {
34
+ /**
35
+ * Creates a new ReadOnlyResourceTreeChildren instance.
36
+ * @param path - The path to this tree node (undefined for root)
37
+ * @param entries - Array of [name, node] tuples to populate the tree
38
+ */
39
+ constructor(path, entries) {
40
+ super(entries);
41
+ this.path = path;
42
+ this.validating = new resourceTreeChildrenValidator_1.ResourceTreeChildrenValidator(this);
43
+ }
44
+ getResource(name) {
45
+ return this.get(name).onSuccess((node) => {
46
+ if (node.isLeaf) {
47
+ return (0, ts_utils_1.succeed)(node).withDetail('success');
48
+ }
49
+ return (0, ts_utils_1.fail)(`${name}: not a resource${this.path ? ` in ${this.path}` : ''}.`).withDetail('failure');
50
+ });
51
+ }
52
+ getBranch(name) {
53
+ return this.get(name).onSuccess((node) => {
54
+ if (node.isBranch) {
55
+ return (0, ts_utils_1.succeed)(node).withDetail('success');
56
+ }
57
+ return (0, ts_utils_1.fail)(`${name}: not a branch${this.path ? ` in ${this.path}` : ''}.`).withDetail('failure');
58
+ });
59
+ }
60
+ getById(id) {
61
+ return common_1.Helpers.splitResourceId(id).onSuccess((names) => {
62
+ let name = names.shift();
63
+ if (name !== undefined) {
64
+ let node = this.get(name).orDefault();
65
+ while (node) {
66
+ name = names.shift();
67
+ if (name === undefined) {
68
+ return (0, ts_utils_1.succeed)(node);
69
+ }
70
+ if (node.isLeaf) {
71
+ /* c8 ignore next 1 - defense in depth */
72
+ return (0, ts_utils_1.fail)(`${id}: resource not found${this.path ? ` in ${this.path}` : ''}.`);
73
+ }
74
+ node = node.children.get(name).orDefault();
75
+ }
76
+ }
77
+ return (0, ts_utils_1.fail)(`${id}: resource not found${this.path ? ` in ${this.path}` : ''}.`);
78
+ });
79
+ }
80
+ getResourceById(id) {
81
+ return this.getById(id).onSuccess((node) => {
82
+ if (node.isLeaf) {
83
+ return (0, ts_utils_1.succeed)(node).withDetail('success');
84
+ }
85
+ return (0, ts_utils_1.fail)(`${id}: not a resource${this.path ? ` in ${this.path}` : ''}.`).withDetail('failure');
86
+ });
87
+ }
88
+ getBranchById(id) {
89
+ return this.getById(id).onSuccess((node) => {
90
+ if (node.isBranch) {
91
+ return (0, ts_utils_1.succeed)(node).withDetail('success');
92
+ }
93
+ return (0, ts_utils_1.fail)(`${id}: not a branch${this.path ? ` in ${this.path}` : ''}.`).withDetail('failure');
94
+ });
95
+ }
96
+ }
97
+ exports.ReadOnlyResourceTreeChildren = ReadOnlyResourceTreeChildren;
98
+ //# sourceMappingURL=resourceTreeChildren.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resourceTreeChildren.js","sourceRoot":"","sources":["../../../../src/packlets/runtime/resource-tree/resourceTreeChildren.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,4CAA8E;AAC9E,yCAAiE;AAQjE,mFAAgF;AAEhF;;;;GAIG;AACH,MAAa,4BACX,SAAQ,oBAAqD;IAM7D;;;;OAIG;IACH,YAAmB,IAA4B,EAAE,OAAuD;QACtG,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,IAAI,6DAA6B,CAAI,IAAI,CAAC,CAAC;IAC/D,CAAC;IAEM,WAAW,CAAC,IAAkB;QACnC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE;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,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAClB,OAAO,IAAA,kBAAO,EAAC,IAAsC,CAAC,CAAC,UAAU,CAC/D,SAAS,CACV,CAAC;YACJ,CAAC;YACD,OAAO,IAAA,eAAI,EACT,GAAG,EAAE,iBAAiB,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,CAC7D,CAAC,UAAU,CAAoC,SAAS,CAAC,CAAC;QAC7D,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAtFD,oEAsFC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Collections, Result, ResultMap, fail, succeed } from '@fgv/ts-utils';\nimport { ResourceId, ResourceName, Helpers } from '../../common';\nimport {\n IReadOnlyResourceTreeBranch,\n IReadOnlyResourceTreeChildren,\n IReadOnlyResourceTreeLeaf,\n IReadOnlyResourceTreeNode,\n IReadOnlyValidatingResourceTreeChildren\n} from './common';\nimport { ResourceTreeChildrenValidator } from './resourceTreeChildrenValidator';\n\n/**\n * Implementation of a result-based resource tree that provides hierarchical access to resources.\n * Extends ResultMap to provide collection-like access while adding tree-specific navigation methods.\n * @public\n */\nexport class ReadOnlyResourceTreeChildren<T>\n extends ResultMap<ResourceName, IReadOnlyResourceTreeNode<T>>\n implements IReadOnlyValidatingResourceTreeChildren<T>\n{\n protected path: ResourceId | undefined;\n public validating: IReadOnlyResourceTreeChildren<T, string, string>;\n\n /**\n * Creates a new ReadOnlyResourceTreeChildren instance.\n * @param path - The path to this tree node (undefined for root)\n * @param entries - Array of [name, node] tuples to populate the tree\n */\n public constructor(path: ResourceId | undefined, entries: [ResourceName, IReadOnlyResourceTreeNode<T>][]) {\n super(entries);\n this.path = path;\n this.validating = new ResourceTreeChildrenValidator<T>(this);\n }\n\n public getResource(name: ResourceName): Result<IReadOnlyResourceTreeNode<T>> {\n return this.get(name).onSuccess((node) => {\n if (node.isLeaf) {\n return succeed(node).withDetail<Collections.ResultMapResultDetail>('success');\n }\n return fail<IReadOnlyResourceTreeNode<T>>(\n `${name}: not a resource${this.path ? ` in ${this.path}` : ''}.`\n ).withDetail<Collections.ResultMapResultDetail>('failure');\n });\n }\n\n public getBranch(name: ResourceName): Result<IReadOnlyResourceTreeNode<T>> {\n return this.get(name).onSuccess((node) => {\n if (node.isBranch) {\n return succeed(node).withDetail<Collections.ResultMapResultDetail>('success');\n }\n return fail<IReadOnlyResourceTreeNode<T>>(\n `${name}: not a branch${this.path ? ` in ${this.path}` : ''}.`\n ).withDetail<Collections.ResultMapResultDetail>('failure');\n });\n }\n\n public getById(id: ResourceId): Result<IReadOnlyResourceTreeNode<T>> {\n return Helpers.splitResourceId(id).onSuccess((names) => {\n let name = names.shift();\n if (name !== undefined) {\n let node = this.get(name).orDefault();\n while (node) {\n name = names.shift();\n if (name === undefined) {\n return succeed(node);\n }\n if (node.isLeaf) {\n /* c8 ignore next 1 - defense in depth */\n return fail(`${id}: resource not found${this.path ? ` in ${this.path}` : ''}.`);\n }\n node = (node as IReadOnlyResourceTreeBranch<T>).children.get(name).orDefault();\n }\n }\n return fail(`${id}: resource not found${this.path ? ` in ${this.path}` : ''}.`);\n });\n }\n\n public getResourceById(id: ResourceId): Result<IReadOnlyResourceTreeLeaf<T>> {\n return this.getById(id).onSuccess((node) => {\n if (node.isLeaf) {\n return succeed(node as IReadOnlyResourceTreeLeaf<T>).withDetail<Collections.ResultMapResultDetail>(\n 'success'\n );\n }\n return fail<IReadOnlyResourceTreeLeaf<T>>(\n `${id}: not a resource${this.path ? ` in ${this.path}` : ''}.`\n ).withDetail<Collections.ResultMapResultDetail>('failure');\n });\n }\n\n public getBranchById(id: ResourceId): Result<IReadOnlyResourceTreeBranch<T>> {\n return this.getById(id).onSuccess((node) => {\n if (node.isBranch) {\n return succeed(node as IReadOnlyResourceTreeBranch<T>).withDetail<Collections.ResultMapResultDetail>(\n 'success'\n );\n }\n return fail<IReadOnlyResourceTreeBranch<T>>(\n `${id}: not a branch${this.path ? ` in ${this.path}` : ''}.`\n ).withDetail<Collections.ResultMapResultDetail>('failure');\n });\n }\n}\n"]}