@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,65 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2025 Erik Fortune
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ * of this software and associated documentation files (the "Software"), to deal
7
+ * in the Software without restriction, including without limitation the rights
8
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ * copies of the Software, and to permit persons to whom the Software is
10
+ * furnished to do so, subject to the following conditions:
11
+ *
12
+ * The above copyright notice and this permission notice shall be included in all
13
+ * copies or substantial portions of the Software.
14
+ *
15
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ * SOFTWARE.
22
+ */
23
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
24
+ if (k2 === undefined) k2 = k;
25
+ var desc = Object.getOwnPropertyDescriptor(m, k);
26
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
27
+ desc = { enumerable: true, get: function() { return m[k]; } };
28
+ }
29
+ Object.defineProperty(o, k2, desc);
30
+ }) : (function(o, m, k, k2) {
31
+ if (k2 === undefined) k2 = k;
32
+ o[k2] = m[k];
33
+ }));
34
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
35
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
36
+ }) : function(o, v) {
37
+ o["default"] = v;
38
+ });
39
+ var __importStar = (this && this.__importStar) || (function () {
40
+ var ownKeys = function(o) {
41
+ ownKeys = Object.getOwnPropertyNames || function (o) {
42
+ var ar = [];
43
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
44
+ return ar;
45
+ };
46
+ return ownKeys(o);
47
+ };
48
+ return function (mod) {
49
+ if (mod && mod.__esModule) return mod;
50
+ var result = {};
51
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
52
+ __setModuleDefault(result, mod);
53
+ return result;
54
+ };
55
+ })();
56
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
57
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
58
+ };
59
+ Object.defineProperty(exports, "__esModule", { value: true });
60
+ exports.Convert = void 0;
61
+ const Convert = __importStar(require("./convert"));
62
+ exports.Convert = Convert;
63
+ __exportStar(require("./contextDecls"), exports);
64
+ __exportStar(require("./contextToken"), exports);
65
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/context/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,mDAAqC;AAI5B,0BAAO;AAHhB,iDAA+B;AAC/B,iDAA+B","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport * as Convert from './convert';\nexport * from './contextDecls';\nexport * from './contextToken';\n\nexport { Convert };\n"]}
@@ -1,6 +1,7 @@
1
1
  import { Result } from '@fgv/ts-utils';
2
2
  import { ConditionSet } from '../conditions';
3
3
  import { Decision } from './decision';
4
+ import * as ResourceJson from '../resource-json';
4
5
  /**
5
6
  * Parameters to create an {@link Decisions.AbstractDecision | AbstractDecision}.
6
7
  * @public
@@ -35,5 +36,12 @@ export declare class AbstractDecision extends Decision<number> {
35
36
  * @public
36
37
  */
37
38
  static createAbstractDecision(params: IAbstractDecisionCreateParams): Result<AbstractDecision>;
39
+ /**
40
+ * Converts this abstract decision to a compiled abstract decision representation.
41
+ * @param options - Optional compilation options controlling the output format.
42
+ * @returns A compiled abstract decision object that can be used for serialization or runtime processing.
43
+ * @public
44
+ */
45
+ toCompiled(options?: ResourceJson.Compiled.ICompiledResourceOptions): ResourceJson.Compiled.ICompiledAbstractDecision;
38
46
  }
39
47
  //# sourceMappingURL=abstractDecision.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"abstractDecision.d.ts","sourceRoot":"","sources":["../../../src/packlets/decisions/abstractDecision.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAiB,MAAM,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC;;;GAGG;AACH,MAAM,WAAW,6BAA6B;IAC5C,aAAa,EAAE,YAAY,EAAE,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;GAQG;AACH,qBAAa,gBAAiB,SAAQ,QAAQ,CAAC,MAAM,CAAC;IACpD;;;;;OAKG;IACH,SAAS,aAAa,MAAM,EAAE,6BAA6B;IAO3D;;;;;;;OAOG;WACW,sBAAsB,CAAC,MAAM,EAAE,6BAA6B,GAAG,MAAM,CAAC,gBAAgB,CAAC;CAGtG"}
1
+ {"version":3,"file":"abstractDecision.d.ts","sourceRoot":"","sources":["../../../src/packlets/decisions/abstractDecision.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAiB,MAAM,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,YAAY,MAAM,kBAAkB,CAAC;AAEjD;;;GAGG;AACH,MAAM,WAAW,6BAA6B;IAC5C,aAAa,EAAE,YAAY,EAAE,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;GAQG;AACH,qBAAa,gBAAiB,SAAQ,QAAQ,CAAC,MAAM,CAAC;IACpD;;;;;OAKG;IACH,SAAS,aAAa,MAAM,EAAE,6BAA6B;IAO3D;;;;;;;OAOG;WACW,sBAAsB,CAAC,MAAM,EAAE,6BAA6B,GAAG,MAAM,CAAC,gBAAgB,CAAC;IAIrG;;;;;OAKG;IACI,UAAU,CACf,OAAO,CAAC,EAAE,YAAY,CAAC,QAAQ,CAAC,wBAAwB,GACvD,YAAY,CAAC,QAAQ,CAAC,yBAAyB;CAMnD"}
@@ -58,6 +58,15 @@ class AbstractDecision extends decision_1.Decision {
58
58
  static createAbstractDecision(params) {
59
59
  return (0, ts_utils_1.captureResult)(() => new AbstractDecision(params));
60
60
  }
61
+ /**
62
+ * Converts this abstract decision to a compiled abstract decision representation.
63
+ * @param options - Optional compilation options controlling the output format.
64
+ * @returns A compiled abstract decision object that can be used for serialization or runtime processing.
65
+ * @public
66
+ */
67
+ toCompiled(options) {
68
+ return Object.assign({ conditionSets: this.candidates.map((c) => c.conditionSet.index) }, ((options === null || options === void 0 ? void 0 : options.includeMetadata) === true ? { metadata: { key: this.key } } : {}));
69
+ }
61
70
  }
62
71
  exports.AbstractDecision = AbstractDecision;
63
72
  //# sourceMappingURL=abstractDecision.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"abstractDecision.js","sourceRoot":"","sources":["../../../src/packlets/decisions/abstractDecision.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,4CAAsD;AAEtD,2CAAwC;AACxC,yCAAsC;AAWtC;;;;;;;;GAQG;AACH,MAAa,gBAAiB,SAAQ,mBAAgB;IACpD;;;;;OAKG;IACH,YAAsB,MAAqC;QACzD,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC;aAChD,GAAG,CAAC,CAAC,YAAY,EAAE,KAAK,EAAE,EAAE,CAAC,qBAAS,CAAC,eAAe,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;aAC1F,IAAI,CAAC,qBAAS,CAAC,OAAO,CAAC,CAAC;QAC3B,KAAK,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/D,CAAC;IAED;;;;;;;OAOG;IACI,MAAM,CAAC,sBAAsB,CAAC,MAAqC;QACxE,OAAO,IAAA,wBAAa,EAAC,GAAG,EAAE,CAAC,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC;IAC3D,CAAC;CACF;AAzBD,4CAyBC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { captureResult, Result } from '@fgv/ts-utils';\nimport { ConditionSet } from '../conditions';\nimport { Candidate } from './candidate';\nimport { Decision } from './decision';\n\n/**\n * Parameters to create an {@link Decisions.AbstractDecision | AbstractDecision}.\n * @public\n */\nexport interface IAbstractDecisionCreateParams {\n conditionSets: ConditionSet[];\n index?: number;\n}\n\n/**\n * An abstract decision represents a class of decisions with candidates\n * that differ only in value. It is a {@link Decisions.Decision | IDecision<number>}\n * in which the `number` values are sequentially assigned indexes.\n * This allows us to represent each related {@link Decisions.IDecision | decision} as an\n * {@link Decisions.AbstractDecision | abstract decision} and a matching array containing\n * the corresponding value for each candidate. This representation is highly cacheable.\n * @public\n */\nexport class AbstractDecision extends Decision<number> {\n /**\n * Constructor for an {@link Decisions.AbstractDecision | AbstractDecision} object.\n * @param params - {@link Decisions.IAbstractDecisionCreateParams | Parameters}\n * used to create the decision.\n * @public\n */\n protected constructor(params: IAbstractDecisionCreateParams) {\n const candidates = Array.from(params.conditionSets)\n .map((conditionSet, value) => Candidate.createCandidate({ conditionSet, value }).orThrow())\n .sort(Candidate.compare);\n super({ candidates, index: params.index, isAbstract: true });\n }\n\n /**\n * Creates a new {@link Decisions.AbstractDecision | AbstractDecision} object.\n * @param params - {@link Decisions.IAbstractDecisionCreateParams | Parameters}\n * used to create the decision.\n * @returns `Success` with the new decision if successful, or `Failure` with an\n * error message if not.\n * @public\n */\n public static createAbstractDecision(params: IAbstractDecisionCreateParams): Result<AbstractDecision> {\n return captureResult(() => new AbstractDecision(params));\n }\n}\n"]}
1
+ {"version":3,"file":"abstractDecision.js","sourceRoot":"","sources":["../../../src/packlets/decisions/abstractDecision.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,4CAAsD;AAEtD,2CAAwC;AACxC,yCAAsC;AAYtC;;;;;;;;GAQG;AACH,MAAa,gBAAiB,SAAQ,mBAAgB;IACpD;;;;;OAKG;IACH,YAAsB,MAAqC;QACzD,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC;aAChD,GAAG,CAAC,CAAC,YAAY,EAAE,KAAK,EAAE,EAAE,CAAC,qBAAS,CAAC,eAAe,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;aAC1F,IAAI,CAAC,qBAAS,CAAC,OAAO,CAAC,CAAC;QAC3B,KAAK,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/D,CAAC;IAED;;;;;;;OAOG;IACI,MAAM,CAAC,sBAAsB,CAAC,MAAqC;QACxE,OAAO,IAAA,wBAAa,EAAC,GAAG,EAAE,CAAC,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC;IAC3D,CAAC;IAED;;;;;OAKG;IACI,UAAU,CACf,OAAwD;QAExD,uBACE,aAAa,EAAE,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,KAAM,CAAC,IAC7D,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,eAAe,MAAK,IAAI,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAC7E;IACJ,CAAC;CACF;AAxCD,4CAwCC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { captureResult, Result } from '@fgv/ts-utils';\nimport { ConditionSet } from '../conditions';\nimport { Candidate } from './candidate';\nimport { Decision } from './decision';\nimport * as ResourceJson from '../resource-json';\n\n/**\n * Parameters to create an {@link Decisions.AbstractDecision | AbstractDecision}.\n * @public\n */\nexport interface IAbstractDecisionCreateParams {\n conditionSets: ConditionSet[];\n index?: number;\n}\n\n/**\n * An abstract decision represents a class of decisions with candidates\n * that differ only in value. It is a {@link Decisions.Decision | IDecision<number>}\n * in which the `number` values are sequentially assigned indexes.\n * This allows us to represent each related {@link Decisions.IDecision | decision} as an\n * {@link Decisions.AbstractDecision | abstract decision} and a matching array containing\n * the corresponding value for each candidate. This representation is highly cacheable.\n * @public\n */\nexport class AbstractDecision extends Decision<number> {\n /**\n * Constructor for an {@link Decisions.AbstractDecision | AbstractDecision} object.\n * @param params - {@link Decisions.IAbstractDecisionCreateParams | Parameters}\n * used to create the decision.\n * @public\n */\n protected constructor(params: IAbstractDecisionCreateParams) {\n const candidates = Array.from(params.conditionSets)\n .map((conditionSet, value) => Candidate.createCandidate({ conditionSet, value }).orThrow())\n .sort(Candidate.compare);\n super({ candidates, index: params.index, isAbstract: true });\n }\n\n /**\n * Creates a new {@link Decisions.AbstractDecision | AbstractDecision} object.\n * @param params - {@link Decisions.IAbstractDecisionCreateParams | Parameters}\n * used to create the decision.\n * @returns `Success` with the new decision if successful, or `Failure` with an\n * error message if not.\n * @public\n */\n public static createAbstractDecision(params: IAbstractDecisionCreateParams): Result<AbstractDecision> {\n return captureResult(() => new AbstractDecision(params));\n }\n\n /**\n * Converts this abstract decision to a compiled abstract decision representation.\n * @param options - Optional compilation options controlling the output format.\n * @returns A compiled abstract decision object that can be used for serialization or runtime processing.\n * @public\n */\n public toCompiled(\n options?: ResourceJson.Compiled.ICompiledResourceOptions\n ): ResourceJson.Compiled.ICompiledAbstractDecision {\n return {\n conditionSets: this.candidates.map((c) => c.conditionSet.index!),\n ...(options?.includeMetadata === true ? { metadata: { key: this.key } } : {})\n };\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"abstractDecisionCollector.d.ts","sourceRoot":"","sources":["../../../src/packlets/decisions/abstractDecisionCollector.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAiB,WAAW,EAAE,MAAM,EAAiB,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACvG,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAA4B,aAAa,EAAyB,MAAM,WAAW,CAAC;AAC3F,OAAO,EAAgB,6BAA6B,EAAE,MAAM,eAAe,CAAC;AAE5E;;;GAGG;AACH,MAAM,WAAW,sCAAsC;IACrD;;;OAGG;IACH,aAAa,EAAE,6BAA6B,CAAC;CAC9C;AAED;;;GAGG;AACH,qBAAa,yBAA0B,SAAQ,mBAAmB,CAAC,gBAAgB,CAAC;IAClF;;;OAGG;IACH,SAAgB,aAAa,EAAE,6BAA6B,CAAC;IAE7D;;OAEG;IACH,IAAW,aAAa,IAAI,gBAAgB,CAE3C;IAED;;OAEG;IACH,IAAW,mBAAmB,IAAI,gBAAgB,CAEjD;IAED;;OAEG;IACH,gBAAuB,kBAAkB,EAAE,aAAa,CAAyC;IAEjG;;OAEG;IACH,gBAAuB,wBAAwB,EAAE,aAAa,CAAyC;IAEvG;;OAEG;IACH,SAAS,aAAa,MAAM,EAAE,sCAAsC;IAapE;;;OAGG;WACW,MAAM,CAAC,MAAM,EAAE,sCAAsC,GAAG,MAAM,CAAC,yBAAyB,CAAC;IAIvG,OAAO,CAAC,mBAAmB;IAY3B,OAAO,CAAC,oBAAoB;CAG7B;AAED;;;GAGG;AACH,MAAM,MAAM,iCAAiC,GAAG,WAAW,CAAC,4BAA4B,CAAC,gBAAgB,CAAC,CAAC"}
1
+ {"version":3,"file":"abstractDecisionCollector.d.ts","sourceRoot":"","sources":["../../../src/packlets/decisions/abstractDecisionCollector.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAiB,WAAW,EAAE,MAAM,EAAiB,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACvG,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAA4B,aAAa,EAAyB,MAAM,WAAW,CAAC;AAC3F,OAAO,EAAgB,6BAA6B,EAAE,MAAM,eAAe,CAAC;AAE5E;;;GAGG;AACH,MAAM,WAAW,sCAAsC;IACrD;;;OAGG;IACH,aAAa,EAAE,6BAA6B,CAAC;CAC9C;AAED;;;GAGG;AACH,qBAAa,yBAA0B,SAAQ,mBAAmB,CAAC,gBAAgB,CAAC;IAClF;;;OAGG;IACH,SAAgB,aAAa,EAAE,6BAA6B,CAAC;IAE7D;;OAEG;IACH,IAAW,aAAa,IAAI,gBAAgB,CAE3C;IAED;;OAEG;IACH,IAAW,mBAAmB,IAAI,gBAAgB,CAEjD;IAED;;OAEG;IACH,gBAAuB,kBAAkB,EAAE,aAAa,CAAyC;IAEjG;;OAEG;IACH,gBAAuB,wBAAwB,EAAE,aAAa,CAAyC;IAEvG;;OAEG;IACH,SAAS,aAAa,MAAM,EAAE,sCAAsC;IAapE;;;OAGG;WACW,MAAM,CAAC,MAAM,EAAE,sCAAsC,GAAG,MAAM,CAAC,yBAAyB,CAAC;IAIvG,OAAO,CAAC,mBAAmB;IAc3B,OAAO,CAAC,oBAAoB;CAG7B;AAED;;;GAGG;AACH,MAAM,MAAM,iCAAiC,GAAG,WAAW,CAAC,4BAA4B,CAAC,gBAAgB,CAAC,CAAC"}
@@ -66,6 +66,7 @@ class AbstractDecisionCollector extends ts_utils_1.ValidatingCollector {
66
66
  return (0, ts_utils_1.captureResult)(() => new AbstractDecisionCollector(params));
67
67
  }
68
68
  _toAbstractDecision(from) {
69
+ /* c8 ignore next 3 - functional code path tested but coverage intermittently missed */
69
70
  if (from instanceof abstractDecision_1.AbstractDecision) {
70
71
  return (0, ts_utils_1.succeed)(from);
71
72
  }
@@ -74,6 +75,7 @@ class AbstractDecisionCollector extends ts_utils_1.ValidatingCollector {
74
75
  conditionSets: from
75
76
  });
76
77
  }
78
+ /* c8 ignore next 2 - functional code path tested but coverage intermittently missed */
77
79
  return (0, ts_utils_1.fail)('invalid value: not an abstract decision or condition sets');
78
80
  }
79
81
  _isConditionSetArray(from) {
@@ -1 +1 @@
1
- {"version":3,"file":"abstractDecisionCollector.js","sourceRoot":"","sources":["../../../src/packlets/decisions/abstractDecisionCollector.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,4CAAuG;AACvG,yDAAsD;AACtD,sCAA2F;AAC3F,8CAA4E;AAc5E;;;GAGG;AACH,MAAa,yBAA0B,SAAQ,8BAAqC;IAOlF;;OAEG;IACH,IAAW,aAAa;QACtB,OAAO,IAAI,CAAC,KAAK,CAAC,yBAAyB,CAAC,kBAAkB,CAAC,CAAC,OAAO,EAAE,CAAC;IAC5E,CAAC;IAED;;OAEG;IACH,IAAW,mBAAmB;QAC5B,OAAO,IAAI,C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I;aACpB,CAAC,CAAC;QACL,CAAC;QACD,OAAO,IAAA,eAAI,EAAC,2DAA2D,CAAC,CAAC;IAC3E,CAAC;IAEO,oBAAoB,CAAC,IAAa;QACxC,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,YAAY,yBAAY,CAAC,CAAC;IAC7E,CAAC;;AArEH,8DAsEC;AAjDC;;GAEG;AACoB,4CAAkB,GAAkB,iBAAQ,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;AAEjG;;GAEG;AACoB,kDAAwB,GAAkB,iBAAQ,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { captureResult, Collections, Result, fail, succeed, ValidatingCollector } from '@fgv/ts-utils';\nimport { AbstractDecision } from './abstractDecision';\nimport { Convert as CommonConvert, DecisionIndex, DecisionKey, Validate } from '../common';\nimport { ConditionSet, ReadOnlyConditionSetCollector } from '../conditions';\n\n/**\n * Parameters for creating a {@link Decisions.AbstractDecisionCollector | AbstractDecisionCollector}.\n * @public\n */\nexport interface IAbstractDecisionCollectorCreateParams {\n /**\n * {@link Conditions.ReadOnlyConditionSetCollector | ConditionSetCollector} used to create conditions\n * sets for decisions in this collector.\n */\n conditionSets: ReadOnlyConditionSetCollector;\n}\n\n/**\n * A `ValidatingCollector` for {@link Decisions.AbstractDecision | AbstractDecisions}.\n * @public\n */\nexport class AbstractDecisionCollector extends ValidatingCollector<AbstractDecision> {\n /**\n * The {@link Conditions.ReadOnlyConditionSetCollector | ConditionSetCollector} used to create conditions\n * sets for decisions in this collector.\n */\n public readonly conditionSets: ReadOnlyConditionSetCollector;\n\n /**\n * The empty decision (no condition sets) for this collector.\n */\n public get emptyDecision(): AbstractDecision {\n return this.getAt(AbstractDecisionCollector.EmptyDecisionIndex).orThrow();\n }\n\n /**\n * The default-only decision (one condition set with no conditions) for this collector.\n */\n public get defaultOnlyDecision(): AbstractDecision {\n return this.getAt(AbstractDecisionCollector.DefaultOnlyDecisionIndex).orThrow();\n }\n\n /**\n * The index for the empty decision.\n */\n public static readonly EmptyDecisionIndex: DecisionIndex = Validate.toDecisionIndex(0).orThrow();\n\n /**\n * The index for the default-only decision.\n */\n public static readonly DefaultOnlyDecisionIndex: DecisionIndex = Validate.toDecisionIndex(1).orThrow();\n\n /**\n * Creates a new instance of {@link Decisions.AbstractDecisionCollector | AbstractDecisionCollector}.\n */\n protected constructor(params: IAbstractDecisionCollectorCreateParams) {\n super({\n converters: new Collections.KeyValueConverters<DecisionKey, AbstractDecision>({\n key: CommonConvert.decisionKey,\n value: (from: unknown) => this._toAbstractDecision(from)\n })\n });\n this.conditionSets = params.conditionSets;\n this.add(AbstractDecision.createAbstractDecision({ conditionSets: [] }).orThrow()).orThrow();\n const cs = this.conditionSets.validating.get('').orThrow();\n this.add(AbstractDecision.createAbstractDecision({ conditionSets: [cs] }).orThrow()).orThrow();\n }\n\n /**\n * Creates a new instance of {@link Decisions.AbstractDecisionCollector | AbstractDecisionCollector}.\n * @returns `Success` with the new instance, or `Failure` with an error if the instance could not be created.\n */\n public static create(params: IAbstractDecisionCollectorCreateParams): Result<AbstractDecisionCollector> {\n return captureResult(() => new AbstractDecisionCollector(params));\n }\n\n private _toAbstractDecision(from: unknown): Result<AbstractDecision> {\n if (from instanceof AbstractDecision) {\n return succeed(from);\n }\n if (this._isConditionSetArray(from)) {\n return AbstractDecision.createAbstractDecision({\n conditionSets: from\n });\n }\n return fail('invalid value: not an abstract decision or condition sets');\n }\n\n private _isConditionSetArray(from: unknown): from is ConditionSet[] {\n return Array.isArray(from) && from.every((e) => e instanceof ConditionSet);\n }\n}\n\n/**\n * A read-only {@link Decisions.AbstractDecisionCollector | AbstractDecisionCollector}.\n * @public\n */\nexport type ReadOnlyAbstractDecisionCollector = Collections.IReadOnlyValidatingCollector<AbstractDecision>;\n"]}
1
+ {"version":3,"file":"abstractDecisionCollector.js","sourceRoot":"","sources":["../../../src/packlets/decisions/abstractDecisionCollector.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,4CAAuG;AACvG,yDAAsD;AACtD,sCAA2F;AAC3F,8CAA4E;AAc5E;;;GAGG;AACH,MAAa,yBAA0B,SAAQ,8BAAqC;IAOlF;;OAEG;IACH,IAAW,aAAa;QACtB,OAAO,IAAI,CAAC,KAAK,CAAC,yBAAyB,CAAC,kBAAkB,CAAC,CAAC,OAAO,EAAE,CAAC;IAC5E,CAAC;IAED;;OAEG;IACH,IAAW,mBAAmB;QAC5B,OAAO,IAAI,CAAC,KAAK,CAAC,yBAAyB,CAAC,wBAAwB,CAAC,CAAC,OAAO,EAAE,CAAC;IAClF,CAAC;IAYD;;OAEG;IACH,YAAsB,MAA8C;QAClE,KAAK,CAAC;YACJ,UAAU,EA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a;QACxC,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,YAAY,yBAAY,CAAC,CAAC;IAC7E,CAAC;;AAvEH,8DAwEC;AAnDC;;GAEG;AACoB,4CAAkB,GAAkB,iBAAQ,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;AAEjG;;GAEG;AACoB,kDAAwB,GAAkB,iBAAQ,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { captureResult, Collections, Result, fail, succeed, ValidatingCollector } from '@fgv/ts-utils';\nimport { AbstractDecision } from './abstractDecision';\nimport { Convert as CommonConvert, DecisionIndex, DecisionKey, Validate } from '../common';\nimport { ConditionSet, ReadOnlyConditionSetCollector } from '../conditions';\n\n/**\n * Parameters for creating a {@link Decisions.AbstractDecisionCollector | AbstractDecisionCollector}.\n * @public\n */\nexport interface IAbstractDecisionCollectorCreateParams {\n /**\n * {@link Conditions.ReadOnlyConditionSetCollector | ConditionSetCollector} used to create conditions\n * sets for decisions in this collector.\n */\n conditionSets: ReadOnlyConditionSetCollector;\n}\n\n/**\n * A `ValidatingCollector` for {@link Decisions.AbstractDecision | AbstractDecisions}.\n * @public\n */\nexport class AbstractDecisionCollector extends ValidatingCollector<AbstractDecision> {\n /**\n * The {@link Conditions.ReadOnlyConditionSetCollector | ConditionSetCollector} used to create conditions\n * sets for decisions in this collector.\n */\n public readonly conditionSets: ReadOnlyConditionSetCollector;\n\n /**\n * The empty decision (no condition sets) for this collector.\n */\n public get emptyDecision(): AbstractDecision {\n return this.getAt(AbstractDecisionCollector.EmptyDecisionIndex).orThrow();\n }\n\n /**\n * The default-only decision (one condition set with no conditions) for this collector.\n */\n public get defaultOnlyDecision(): AbstractDecision {\n return this.getAt(AbstractDecisionCollector.DefaultOnlyDecisionIndex).orThrow();\n }\n\n /**\n * The index for the empty decision.\n */\n public static readonly EmptyDecisionIndex: DecisionIndex = Validate.toDecisionIndex(0).orThrow();\n\n /**\n * The index for the default-only decision.\n */\n public static readonly DefaultOnlyDecisionIndex: DecisionIndex = Validate.toDecisionIndex(1).orThrow();\n\n /**\n * Creates a new instance of {@link Decisions.AbstractDecisionCollector | AbstractDecisionCollector}.\n */\n protected constructor(params: IAbstractDecisionCollectorCreateParams) {\n super({\n converters: new Collections.KeyValueConverters<DecisionKey, AbstractDecision>({\n key: CommonConvert.decisionKey,\n value: (from: unknown) => this._toAbstractDecision(from)\n })\n });\n this.conditionSets = params.conditionSets;\n this.add(AbstractDecision.createAbstractDecision({ conditionSets: [] }).orThrow()).orThrow();\n const cs = this.conditionSets.validating.get('').orThrow();\n this.add(AbstractDecision.createAbstractDecision({ conditionSets: [cs] }).orThrow()).orThrow();\n }\n\n /**\n * Creates a new instance of {@link Decisions.AbstractDecisionCollector | AbstractDecisionCollector}.\n * @returns `Success` with the new instance, or `Failure` with an error if the instance could not be created.\n */\n public static create(params: IAbstractDecisionCollectorCreateParams): Result<AbstractDecisionCollector> {\n return captureResult(() => new AbstractDecisionCollector(params));\n }\n\n private _toAbstractDecision(from: unknown): Result<AbstractDecision> {\n /* c8 ignore next 3 - functional code path tested but coverage intermittently missed */\n if (from instanceof AbstractDecision) {\n return succeed(from);\n }\n if (this._isConditionSetArray(from)) {\n return AbstractDecision.createAbstractDecision({\n conditionSets: from\n });\n }\n /* c8 ignore next 2 - functional code path tested but coverage intermittently missed */\n return fail('invalid value: not an abstract decision or condition sets');\n }\n\n private _isConditionSetArray(from: unknown): from is ConditionSet[] {\n return Array.isArray(from) && from.every((e) => e instanceof ConditionSet);\n }\n}\n\n/**\n * A read-only {@link Decisions.AbstractDecisionCollector | AbstractDecisionCollector}.\n * @public\n */\nexport type ReadOnlyAbstractDecisionCollector = Collections.IReadOnlyValidatingCollector<AbstractDecision>;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"concreteDecision.d.ts","sourceRoot":"","sources":["../../../src/packlets/decisions/concreteDecision.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAa,UAAU,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAA0C,MAAM,EAAiB,MAAM,eAAe,CAAC;AAE9F,OAAO,EAA4B,aAAa,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAGjF;;;;;GAKG;AACH,MAAM,WAAW,6BAA6B,CAAC,MAAM,SAAS,SAAS,GAAG,SAAS;IACjF,SAAS,EAAE,yBAAyB,CAAC;IACrC,UAAU,EAAE,aAAa,CAAC,UA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CAAC,GAC5C,MAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAiCnC;;;;OAIG;IACI,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,aAAa,CAAC;CAGtD"}
@@ -93,6 +93,7 @@ class ConcreteDecision {
93
93
  }
94
94
  return (0, ts_utils_1.succeed)(candidate.value);
95
95
  })).onSuccess((values) => {
96
+ /* c8 ignore next 5 - defense in depth against invalid index conversion */
96
97
  if (params.index) {
97
98
  return common_1.Convert.decisionIndex.convert(params.index).onSuccess((index) => {
98
99
  return (0, ts_utils_1.captureResult)(() => new ConcreteDecision({ baseDecision, values, index }));
@@ -1 +1 @@
1
- {"version":3,"file":"concreteDecision.js","sourceRoot":"","sources":["../../../src/packlets/decisions/concreteDecision.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAGH,2CAAoD;AAIpD,4CAA8F;AAC9F,8CAA6C;AAC7C,sCAAiF;AACjF,yCAAsC;AA0BtC;;;;;;GAMG;AACH,MAAa,gBAAgB;IAK3B;;;OAGG;IACH,IAAW,GAAG;QACZ,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC;IACjC,CAAC;IAID;;;;;OAKG;IACH,YAAsB,MAAkD;QACtE,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;QACxC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE;YAC/D,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;YAC3C,OAAO,qBAAS,CAAC,eAAe,CAAC,EAAE,YAAY,EAAE,SAAS,C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AC,SAAS,CAAC,KAAK,CAAC,CAAC;QAClC,CAAC,CAAC,CACH,CAAC,SAAS,CAAC,CAAC,MAAM,EAAE,EAAE;YACrB,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;gBACjB,OAAO,gBAAa,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE;oBAC3E,OAAO,IAAA,wBAAa,EAAC,GAAG,EAAE,CAAC,IAAI,gBAAgB,CAAC,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;gBACpF,CAAC,CAAC,CAAC;YACL,CAAC;YACD,OAAO,IAAA,wBAAa,EAAC,GAAG,EAAE,CAAC,IAAI,gBAAgB,CAAC,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;QAC7E,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACI,QAAQ,CAAC,KAAa;QAC3B,OAAO,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;CACF;AA5FD,4CA4FC","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 { JsonValue } from '@fgv/ts-json-base';\nimport { Candidate, ICandidate } from './candidate';\nimport { IDecision } from './common';\nimport { AbstractDecisionCollector } from './abstractDecisionCollector';\nimport { AbstractDecision } from './abstractDecision';\nimport { captureResult, Collections, mapResults, Result, fail, succeed } from '@fgv/ts-utils';\nimport { ConditionSet } from '../conditions';\nimport { Convert as CommonConvert, DecisionIndex, DecisionKey } from '../common';\nimport { Decision } from './decision';\n\n/**\n * Parameters used to create a new {@link Decisions.ConcreteDecision | ConcreteDecision},\n * given an {@link Decisions.AbstractDecisionCollector | AbstractDecisionCollector} and a\n * list of {@link Decisions.ICandidate | candidates}.\n * @public\n */\nexport interface IConcreteDecisionCreateParams<TVALUE extends JsonValue = JsonValue> {\n decisions: AbstractDecisionCollector;\n candidates: ReadonlyArray<ICandidate<TVALUE>>;\n index?: number;\n}\n\n/**\n * Protected constructor parameters for {@link Decisions.ConcreteDecision | ConcreteDecision},\n * used to create a new concrete decision from an existing {@link Decisions.AbstractDecision | AbstractDecision}\n * and a list of values.\n * @public\n */\nexport interface IConcreteDecisionConstructorParams<TVALUE extends JsonValue = JsonValue> {\n baseDecision: AbstractDecision;\n values: TVALUE[];\n index?: DecisionIndex;\n}\n\n/**\n * A {@link Decisions.ConcreteDecision | concrete decision} is a {@link Decisions.IDecision | decision}\n * implemented as a reference to a common {@link Decisions.AbstractDecision | abstract decision} and a list of\n * values that correspond to the candidates in the abstract decision. This allows us to represent a large\n * number of related decisions with a single abstract decision and a list of values.\n * @public\n */\nexport class ConcreteDecision<TVALUE extends JsonValue = JsonValue> implements IDecision<TVALUE> {\n public readonly baseDecision: AbstractDecision;\n public readonly values: TVALUE[];\n public readonly candidates: ReadonlyArray<ICandidate<TVALUE>>;\n\n /**\n * Unique global key for this decision, derived from the condition set and\n * candidate values.\n */\n public get key(): DecisionKey {\n return this._collectible.key;\n }\n\n /**\n * Unique global index for this decision.\n */\n public get index(): DecisionIndex | undefined {\n return this._collectible.index;\n }\n\n private _collectible: Collections.Collectible<DecisionKey, DecisionIndex>;\n\n /**\n * Constructor for a {@link Decisions.ConcreteDecision | ConcreteDecision} object.\n * @param params - {@link Decisions.IConcreteDecisionConstructorParams | Parameters}\n * used to create the decision.\n * @public\n */\n protected constructor(params: IConcreteDecisionConstructorParams<TVALUE>) {\n this.baseDecision = params.baseDecision;\n this.values = params.values;\n this.candidates = this.baseDecision.candidates.map((candidate) => {\n const value = this.values[candidate.value];\n return Candidate.createCandidate({ conditionSet: candidate.conditionSet, value }).orThrow();\n });\n this._collectible = new Collections.Collectible({\n key: Decision.getKey(this.candidates),\n index: params.index,\n indexConverter: CommonConvert.decisionIndex\n });\n }\n\n /**\n * Creates a new {@link Decisions.ConcreteDecision | ConcreteDecision} object.\n * @param params - {@link Decisions.IConcreteDecisionCreateParams | Parameters}\n * used to create the decision.\n * @returns `Success` with the new decision if successful, or `Failure` with an\n * error message if not.\n * @public\n */\n public static create<TVALUE extends JsonValue = JsonValue>(\n params: IConcreteDecisionCreateParams<TVALUE>\n ): Result<ConcreteDecision<TVALUE>> {\n const conditionSets = params.candidates\n .map((candidate) => candidate.conditionSet)\n .sort(ConditionSet.compare)\n .reverse();\n\n const getBase = params.decisions.validating.getOrAdd(conditionSets);\n /* c8 ignore next 3 - defense in depth against internal error hard to repro */\n if (getBase.isFailure()) {\n return fail<ConcreteDecision<TVALUE>>(getBase.message);\n }\n const baseDecision = getBase.value;\n return mapResults(\n params.candidates.map((candidate, index) => {\n /* c8 ignore next 5 - defense in depth against internal error hard to repro */\n if (candidate.conditionSet.key !== baseDecision.candidates[index].conditionSet.key) {\n return fail<TVALUE>(\n `${candidate.conditionSet.key}: Candidate does not match base decision ${candidate.conditionSet.key}`\n );\n }\n return succeed(candidate.value);\n })\n ).onSuccess((values) => {\n if (params.index) {\n return CommonConvert.decisionIndex.convert(params.index).onSuccess((index) => {\n return captureResult(() => new ConcreteDecision({ baseDecision, values, index }));\n });\n }\n return captureResult(() => new ConcreteDecision({ baseDecision, values }));\n });\n }\n\n /**\n * Sets the index for this decision. Once set, index is immutable.\n * @param index - The index to set.\n * @returns `Success` with the new index if successful, or `Failure` with an error message if not.\n */\n public setIndex(index: number): Result<DecisionIndex> {\n return this._collectible.setIndex(index);\n }\n}\n"]}
1
+ {"version":3,"file":"concreteDecision.js","sourceRoot":"","sources":["../../../src/packlets/decisions/concreteDecision.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAGH,2CAAoD;AAIpD,4CAA8F;AAC9F,8CAA6C;AAC7C,sCAAiF;AACjF,yCAAsC;AA0BtC;;;;;;GAMG;AACH,MAAa,gBAAgB;IAK3B;;;OAGG;IACH,IAAW,GAAG;QACZ,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC;IACjC,CAAC;IAID;;;;;OAKG;IACH,YAAsB,MAAkD;QACtE,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;QACxC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE;YAC/D,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;YAC3C,OAAO,qBAAS,CAAC,eAAe,CAAC,EAAE,YAAY,EAAE,SAAS,CAAC,YAAY,EAAE,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;QAC9F,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,Y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B,0EAA0E;YAC1E,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;gBACjB,OAAO,gBAAa,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE;oBAC3E,OAAO,IAAA,wBAAa,EAAC,GAAG,EAAE,CAAC,IAAI,gBAAgB,CAAC,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;gBACpF,CAAC,CAAC,CAAC;YACL,CAAC;YACD,OAAO,IAAA,wBAAa,EAAC,GAAG,EAAE,CAAC,IAAI,gBAAgB,CAAC,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;QAC7E,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACI,QAAQ,CAAC,KAAa;QAC3B,OAAO,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;CACF;AA7FD,4CA6FC","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 { JsonValue } from '@fgv/ts-json-base';\nimport { Candidate, ICandidate } from './candidate';\nimport { IDecision } from './common';\nimport { AbstractDecisionCollector } from './abstractDecisionCollector';\nimport { AbstractDecision } from './abstractDecision';\nimport { captureResult, Collections, mapResults, Result, fail, succeed } from '@fgv/ts-utils';\nimport { ConditionSet } from '../conditions';\nimport { Convert as CommonConvert, DecisionIndex, DecisionKey } from '../common';\nimport { Decision } from './decision';\n\n/**\n * Parameters used to create a new {@link Decisions.ConcreteDecision | ConcreteDecision},\n * given an {@link Decisions.AbstractDecisionCollector | AbstractDecisionCollector} and a\n * list of {@link Decisions.ICandidate | candidates}.\n * @public\n */\nexport interface IConcreteDecisionCreateParams<TVALUE extends JsonValue = JsonValue> {\n decisions: AbstractDecisionCollector;\n candidates: ReadonlyArray<ICandidate<TVALUE>>;\n index?: number;\n}\n\n/**\n * Protected constructor parameters for {@link Decisions.ConcreteDecision | ConcreteDecision},\n * used to create a new concrete decision from an existing {@link Decisions.AbstractDecision | AbstractDecision}\n * and a list of values.\n * @public\n */\nexport interface IConcreteDecisionConstructorParams<TVALUE extends JsonValue = JsonValue> {\n baseDecision: AbstractDecision;\n values: TVALUE[];\n index?: DecisionIndex;\n}\n\n/**\n * A {@link Decisions.ConcreteDecision | concrete decision} is a {@link Decisions.IDecision | decision}\n * implemented as a reference to a common {@link Decisions.AbstractDecision | abstract decision} and a list of\n * values that correspond to the candidates in the abstract decision. This allows us to represent a large\n * number of related decisions with a single abstract decision and a list of values.\n * @public\n */\nexport class ConcreteDecision<TVALUE extends JsonValue = JsonValue> implements IDecision<TVALUE> {\n public readonly baseDecision: AbstractDecision;\n public readonly values: TVALUE[];\n public readonly candidates: ReadonlyArray<ICandidate<TVALUE>>;\n\n /**\n * Unique global key for this decision, derived from the condition set and\n * candidate values.\n */\n public get key(): DecisionKey {\n return this._collectible.key;\n }\n\n /**\n * Unique global index for this decision.\n */\n public get index(): DecisionIndex | undefined {\n return this._collectible.index;\n }\n\n private _collectible: Collections.Collectible<DecisionKey, DecisionIndex>;\n\n /**\n * Constructor for a {@link Decisions.ConcreteDecision | ConcreteDecision} object.\n * @param params - {@link Decisions.IConcreteDecisionConstructorParams | Parameters}\n * used to create the decision.\n * @public\n */\n protected constructor(params: IConcreteDecisionConstructorParams<TVALUE>) {\n this.baseDecision = params.baseDecision;\n this.values = params.values;\n this.candidates = this.baseDecision.candidates.map((candidate) => {\n const value = this.values[candidate.value];\n return Candidate.createCandidate({ conditionSet: candidate.conditionSet, value }).orThrow();\n });\n this._collectible = new Collections.Collectible({\n key: Decision.getKey(this.candidates),\n index: params.index,\n indexConverter: CommonConvert.decisionIndex\n });\n }\n\n /**\n * Creates a new {@link Decisions.ConcreteDecision | ConcreteDecision} object.\n * @param params - {@link Decisions.IConcreteDecisionCreateParams | Parameters}\n * used to create the decision.\n * @returns `Success` with the new decision if successful, or `Failure` with an\n * error message if not.\n * @public\n */\n public static create<TVALUE extends JsonValue = JsonValue>(\n params: IConcreteDecisionCreateParams<TVALUE>\n ): Result<ConcreteDecision<TVALUE>> {\n const conditionSets = params.candidates\n .map((candidate) => candidate.conditionSet)\n .sort(ConditionSet.compare)\n .reverse();\n\n const getBase = params.decisions.validating.getOrAdd(conditionSets);\n /* c8 ignore next 3 - defense in depth against internal error hard to repro */\n if (getBase.isFailure()) {\n return fail<ConcreteDecision<TVALUE>>(getBase.message);\n }\n const baseDecision = getBase.value;\n return mapResults(\n params.candidates.map((candidate, index) => {\n /* c8 ignore next 5 - defense in depth against internal error hard to repro */\n if (candidate.conditionSet.key !== baseDecision.candidates[index].conditionSet.key) {\n return fail<TVALUE>(\n `${candidate.conditionSet.key}: Candidate does not match base decision ${candidate.conditionSet.key}`\n );\n }\n return succeed(candidate.value);\n })\n ).onSuccess((values) => {\n /* c8 ignore next 5 - defense in depth against invalid index conversion */\n if (params.index) {\n return CommonConvert.decisionIndex.convert(params.index).onSuccess((index) => {\n return captureResult(() => new ConcreteDecision({ baseDecision, values, index }));\n });\n }\n return captureResult(() => new ConcreteDecision({ baseDecision, values }));\n });\n }\n\n /**\n * Sets the index for this decision. Once set, index is immutable.\n * @param index - The index to set.\n * @returns `Success` with the new index if successful, or `Failure` with an error message if not.\n */\n public setIndex(index: number): Result<DecisionIndex> {\n return this._collectible.setIndex(index);\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"decision.d.ts","sourceRoot":"","sources":["../../../src/packlets/decisions/decision.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAoC,MAAM,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EAA4B,aAAa,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB,CAAC,MAAM,SAAS,SAAS,GAAG,SAAS;IACzE,UAAU,EAAE,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;GAIG;AACH,MAAM,WAAW,0BAA0B,CAAC,MAAM,SAAS,SAAS,GAAG,SAAS,CAC9E,SAAQ,qBAAqB,CAAC,MAAM,CAAC;IACrC,UAAU,EAAE,OAAO,CAAC;CACrB;AAED;;;GAGG;AACH,qBAAa,QAAQ,CAAC,MAAM,SAAS,SAAS,GAAG,SAAS,CAAE,YAAW,SAAS,CAAC,MAAM,CAAC;IACtF;;;OAGG;IACH,SAAgB,UAAU,EAAE,aAAa,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;IAE7D;;;OAGG;IACH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8 ignore next 2 - functional code path tested but coverage intermittently missed */
112
+ return Decision.EmptyDecisionKey;
113
+ }
110
114
  const abstractKey = Decision.getAbstractKey(candidates.map((c) => c.conditionSet));
111
115
  const valueKey = ts_utils_1.Hash.Crc32Normalizer.crc32Hash(candidates.map((c) => JSON.stringify(c.value)));
112
116
  return common_1.Convert.decisionKey.convert(`${abstractKey}|${valueKey}`).orThrow();
@@ -1 +1 @@
1
- {"version":3,"file":"decision.js","sourceRoot":"","sources":["../../../src/packlets/decisions/decision.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,4CAAyE;AACzE,sCAAiF;AAEjF,2CAAoD;AAEpD,8CAA6C;AAuB7C;;;GAGG;AACH,MAAa,QAAQ;IAOnB;;;OAGG;IACH,IAAW,GAAG;QACZ,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC;IACjC,CAAC;IAgBD;;;;OAIG;IACH,YAAsB,MAA0C;QAC9D,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC;aAC5C,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,qBAAS,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;aAClD,IAAI,CAAC,qBAAS,CAAC,OAAO,CAAC;aACvB,OAAO,EAAE,CAAC;QAEb,qDAAqD;QACrD,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU;YAC3B,CAAC,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;YACrE,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAErC,IAAI,CAA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,CAAC,GAAG,WAAW,IAAI,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;IACnF,CAAC;;AAhHH,4BAiHC;AA3FC;;GAEG;AACoB,yBAAgB,GAAgB,gBAAa,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;AAEvG;;GAEG;AACoB,+BAAsB,GAAgB,gBAAa,CAAC,WAAW;KACnF,OAAO,CAAC,UAAU,CAAC;KACnB,OAAO,EAAE,CAAC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { captureResult, Collections, Hash, Result } from '@fgv/ts-utils';\nimport { Convert as CommonConvert, DecisionIndex, DecisionKey } from '../common';\nimport { JsonValue } from '@fgv/ts-json-base';\nimport { Candidate, ICandidate } from './candidate';\nimport { IDecision } from './common';\nimport { ConditionSet } from '../conditions';\n\n/**\n * Parameters used to create a new {@link Decisions.Decision | Decision}\n * with the {@link Decisions.Decision.createDecision | createDecision}\n * static method.\n * @public\n */\nexport interface IDecisionCreateParams<TVALUE extends JsonValue = JsonValue> {\n candidates: ReadonlyArray<ICandidate<TVALUE>>;\n index?: number;\n}\n\n/**\n * Parameters used to construct a new {@link Decisions.Decision | Decision} with\n * the protected constructor.\n * @public\n */\nexport interface IDecisionConstructorParams<TVALUE extends JsonValue = JsonValue>\n extends IDecisionCreateParams<TVALUE> {\n isAbstract: boolean;\n}\n\n/**\n * Simple collectible implementation of {@link Decisions.IDecision | IDecision}.\n * @public\n */\nexport class Decision<TVALUE extends JsonValue = JsonValue> implements IDecision<TVALUE> {\n /**\n * The sorted {@link Conditions.ConditionSet | ConditionSets} that make up this decision.\n * @public\n */\n public readonly candidates: ReadonlyArray<Candidate<TVALUE>>;\n\n /**\n * Unique global key for this decision, derived from the contents\n * of the decision.\n */\n public get key(): DecisionKey {\n return this._collectible.key;\n }\n\n /**\n * Unique global index for this decision.\n */\n public get index(): DecisionIndex | undefined {\n return this._collectible.index;\n }\n\n /**\n * Key for the empty decision (no condition sets).\n */\n public static readonly EmptyDecisionKey: DecisionKey = CommonConvert.decisionKey.convert('').orThrow();\n\n /**\n * Key for the default-only decision (single condition set with no conditions).\n */\n public static readonly DefaultOnlyDecisionKey: DecisionKey = CommonConvert.decisionKey\n .convert('00000000')\n .orThrow();\n\n private _collectible: Collections.Collectible<DecisionKey, DecisionIndex>;\n\n /**\n * Constructor for a {@link Decisions.Decision | Decision} object.\n * @param params - {@link Decisions.IDecisionConstructorParams | Parameters} used to create the decision.\n * @public\n */\n protected constructor(params: IDecisionConstructorParams<TVALUE>) {\n this.candidates = Array.from(params.candidates)\n .map((c) => Candidate.createCandidate(c).orThrow())\n .sort(Candidate.compare)\n .reverse();\n\n /* c8 ignore next 3 - coverage having a rough time */\n const key = params.isAbstract\n ? Decision.getAbstractKey(this.candidates.map((c) => c.conditionSet))\n : Decision.getKey(this.candidates);\n\n this._collectible = new Collections.Collectible<DecisionKey, DecisionIndex>({\n key,\n index: params.index,\n indexConverter: CommonConvert.decisionIndex\n });\n }\n\n /**\n * Creates a new {@link Decisions.Decision | Decision} object.\n * @param params - {@link Decisions.IDecisionCreateParams | Parameters} used to create the decision.\n * @returns `Success` with the new decision if successful, or `Failure` with an error message if not.\n * @public\n */\n public static createDecision(params: IDecisionCreateParams): Result<Decision> {\n return captureResult(() => new Decision({ ...params, isAbstract: false }));\n }\n\n /**\n * Sets the index for this decision. Once set, index is immutable.\n * @param index - The index to set.\n * @returns `Success` with the new index if successful, or `Failure` with an error message if not.\n * @public\n */\n public setIndex(index: number): Result<DecisionIndex> {\n return this._collectible.setIndex(index);\n }\n\n /**\n * Helper function to return a stable key for a the condition sets that\n * make up a {@link Decisions.Decision | decision}. The abstract\n * key is a `+`-separated list of the hashes of the sorted condition sets\n * that make up the decision.\n * @param conditionSets - The condition sets to use to create the key.\n * @returns A key derived from the condition set hashes.\n * @public\n */\n public static getAbstractKey(conditionSets: ReadonlyArray<ConditionSet>): DecisionKey {\n return CommonConvert.decisionKey\n .convert(\n Array.from(conditionSets)\n .sort(ConditionSet.compare)\n .reverse()\n .map((c) => c.toHash())\n .join('+')\n )\n .orThrow();\n }\n\n /**\n * Helper function to return a stable key for a set of condition sets.\n * @param conditionSets - The condition sets to use to create the key.\n * @returns A key derived from the condition set hashes.\n * @public\n */\n public static getKey<TVALUE extends JsonValue = JsonValue>(\n candidates: ReadonlyArray<ICandidate<TVALUE>>\n ): DecisionKey {\n const abstractKey = Decision.getAbstractKey(candidates.map((c) => c.conditionSet));\n const valueKey = Hash.Crc32Normalizer.crc32Hash(candidates.map((c) => JSON.stringify(c.value)));\n return CommonConvert.decisionKey.convert(`${abstractKey}|${valueKey}`).orThrow();\n }\n}\n"]}
1
+ {"version":3,"file":"decision.js","sourceRoot":"","sources":["../../../src/packlets/decisions/decision.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,4CAAyE;AACzE,sCAAiF;AAEjF,2CAAoD;A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O,EAAE,CAAC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { captureResult, Collections, Hash, Result } from '@fgv/ts-utils';\nimport { Convert as CommonConvert, DecisionIndex, DecisionKey } from '../common';\nimport { JsonValue } from '@fgv/ts-json-base';\nimport { Candidate, ICandidate } from './candidate';\nimport { IDecision } from './common';\nimport { ConditionSet } from '../conditions';\n\n/**\n * Parameters used to create a new {@link Decisions.Decision | Decision}\n * with the {@link Decisions.Decision.createDecision | createDecision}\n * static method.\n * @public\n */\nexport interface IDecisionCreateParams<TVALUE extends JsonValue = JsonValue> {\n candidates: ReadonlyArray<ICandidate<TVALUE>>;\n index?: number;\n}\n\n/**\n * Parameters used to construct a new {@link Decisions.Decision | Decision} with\n * the protected constructor.\n * @public\n */\nexport interface IDecisionConstructorParams<TVALUE extends JsonValue = JsonValue>\n extends IDecisionCreateParams<TVALUE> {\n isAbstract: boolean;\n}\n\n/**\n * Simple collectible implementation of {@link Decisions.IDecision | IDecision}.\n * @public\n */\nexport class Decision<TVALUE extends JsonValue = JsonValue> implements IDecision<TVALUE> {\n /**\n * The sorted {@link Conditions.ConditionSet | ConditionSets} that make up this decision.\n * @public\n */\n public readonly candidates: ReadonlyArray<Candidate<TVALUE>>;\n\n /**\n * Unique global key for this decision, derived from the contents\n * of the decision.\n */\n public get key(): DecisionKey {\n return this._collectible.key;\n }\n\n /**\n * Unique global index for this decision.\n */\n public get index(): DecisionIndex | undefined {\n return this._collectible.index;\n }\n\n /**\n * Key for the empty decision (no condition sets).\n */\n public static readonly EmptyDecisionKey: DecisionKey = CommonConvert.decisionKey.convert('').orThrow();\n\n /**\n * Key for the default-only decision (single condition set with no conditions).\n */\n public static readonly DefaultOnlyDecisionKey: DecisionKey = CommonConvert.decisionKey\n .convert('00000000')\n .orThrow();\n\n private _collectible: Collections.Collectible<DecisionKey, DecisionIndex>;\n\n /**\n * Constructor for a {@link Decisions.Decision | Decision} object.\n * @param params - {@link Decisions.IDecisionConstructorParams | Parameters} used to create the decision.\n * @public\n */\n protected constructor(params: IDecisionConstructorParams<TVALUE>) {\n this.candidates = Array.from(params.candidates)\n .map((c) => Candidate.createCandidate(c).orThrow())\n .sort(Candidate.compare)\n .reverse();\n\n /* c8 ignore next 3 - coverage having a rough time */\n const key = params.isAbstract\n ? Decision.getAbstractKey(this.candidates.map((c) => c.conditionSet))\n : Decision.getKey(this.candidates);\n\n this._collectible = new Collections.Collectible<DecisionKey, DecisionIndex>({\n key,\n index: params.index,\n indexConverter: CommonConvert.decisionIndex\n });\n }\n\n /**\n * Creates a new {@link Decisions.Decision | Decision} object.\n * @param params - {@link Decisions.IDecisionCreateParams | Parameters} used to create the decision.\n * @returns `Success` with the new decision if successful, or `Failure` with an error message if not.\n * @public\n */\n public static createDecision(params: IDecisionCreateParams): Result<Decision> {\n return captureResult(() => new Decision({ ...params, isAbstract: false }));\n }\n\n /**\n * Sets the index for this decision. Once set, index is immutable.\n * @param index - The index to set.\n * @returns `Success` with the new index if successful, or `Failure` with an error message if not.\n * @public\n */\n public setIndex(index: number): Result<DecisionIndex> {\n return this._collectible.setIndex(index);\n }\n\n /**\n * Helper function to return a stable key for a the condition sets that\n * make up a {@link Decisions.Decision | decision}. The abstract\n * key is a `+`-separated list of the hashes of the sorted condition sets\n * that make up the decision.\n * @param conditionSets - The condition sets to use to create the key.\n * @returns A key derived from the condition set hashes.\n * @public\n */\n public static getAbstractKey(conditionSets: ReadonlyArray<ConditionSet>): DecisionKey {\n return CommonConvert.decisionKey\n .convert(\n Array.from(conditionSets)\n .sort(ConditionSet.compare)\n .reverse()\n .map((c) => c.toHash())\n .join('+')\n )\n .orThrow();\n }\n\n /**\n * Helper function to return a stable key for a set of condition sets.\n * @param conditionSets - The condition sets to use to create the key.\n * @returns A key derived from the condition set hashes.\n * @public\n */\n public static getKey<TVALUE extends JsonValue = JsonValue>(\n candidates: ReadonlyArray<ICandidate<TVALUE>>\n ): DecisionKey {\n if (candidates.length === 0) {\n /* c8 ignore next 2 - functional code path tested but coverage intermittently missed */\n return Decision.EmptyDecisionKey;\n }\n const abstractKey = Decision.getAbstractKey(candidates.map((c) => c.conditionSet));\n const valueKey = Hash.Crc32Normalizer.crc32Hash(candidates.map((c) => JSON.stringify(c.value)));\n return CommonConvert.decisionKey.convert(`${abstractKey}|${valueKey}`).orThrow();\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"fsItem.d.ts","sourceRoot":"","sources":["../../../src/packlets/import/fsItem.ts"],"names":[],"mappings":"AAsBA,OAAO,EAEL,cAAc,EACd,QAAQ,EAER,MAAM,EAIP,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,UAAU,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,SAAS,G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E,kBAAkB,CAAC;IAW7C;;;;;;;OAOG;WACW,gBAAgB,CAC5B,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,2BAA2B,GACtC,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IAyBrC;;;;OAIG;IACI,UAAU,IAAI,MAAM,CAAC,aAAa,CAAC;CAa3C"}
@@ -110,18 +110,14 @@ class FsItem {
110
110
  * that should be silently ignored.
111
111
  */
112
112
  static createForPath(importPath, qualifiers, tree) {
113
- if (tree === undefined) {
114
- const treeResult = ts_utils_1.FileTree.forFilesystem();
115
- /* c8 ignore next 3 - defense in depth should never happen */
116
- if (treeResult.isFailure()) {
117
- return (0, ts_utils_1.failWithDetail)(treeResult.message, 'failed');
118
- }
119
- tree = treeResult.value;
120
- }
121
- return tree
122
- .getItem(importPath)
123
- .withDetail('failed')
124
- .onSuccess((item) => FsItem.createForItem(item, qualifiers));
113
+ return (0, ts_utils_1.useOrInitialize)(tree, () => ts_utils_1.FileTree.forFilesystem())
114
+ .withDetail('failed', 'succeeded')
115
+ .onSuccess((tree) => {
116
+ return tree
117
+ .getItem(importPath)
118
+ .withDetail('failed')
119
+ .onSuccess((item) => FsItem.createForItem(item, qualifiers));
120
+ });
125
121
  }
126
122
  /**
127
123
  * Tries to parse a base name into a base name and a set of conditions.
@@ -1 +1 @@
1
- {"version":3,"file":"fsItem.js","sourceRoot":"","sources":["../../../src/packlets/import/fsItem.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4CASuB;AACvB,sCAA+D;AAC/D,0DAA4C;AAE5C,mDAAgD;AA+BhD;;;GAGG;AACH,MAAa,MAAM;IAqBjB;;;;;;;;OAQG;IACH,YAAsB,KAAmB,EAAE,UAAuC;QAChF,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;QAC7C,IAAI,CA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G,mBAAmB,CAAC,KAAK,CAAC;QAC7C,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC1B,QAAQ,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,aAAa,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACpE,CAAC;QACD,OAAO,IAAA,kBAAO,EAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED;;;;OAIG;IACI,UAAU;QACf,OAAO,iBAAQ,CAAC,oBAAoB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,CAAC,MAAM,EAAE,EAAE;YACvE,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;gBAC3C,OAAO;oBACL,aAAa,EAAE,CAAC,CAAC,SAAS,CAAC,IAAI;oBAC/B,KAAK,EAAE,CAAC,CAAC,KAAK;oBACd,QAAQ,EAAE,CAAC,CAAC,QAAQ;oBACpB,QAAQ,EAAE,CAAC,CAAC,QAAQ;iBACrB,CAAC;YACJ,CAAC,CAAC,CAAC;YACH,OAAO,6BAAa,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;QACtD,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAlJD,wBAkJC","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 {\n captureResult,\n DetailedResult,\n FileTree,\n mapResults,\n Result,\n fail,\n succeed,\n failWithDetail\n} from '@fgv/ts-utils';\nimport { Helpers as CommonHelpers, Validate } from '../common';\nimport * as Conditions from '../conditions';\nimport { IReadOnlyQualifierCollector } from '../qualifiers';\nimport { ImportContext } from './importContext';\n\n/**\n * Result details for {@link Import.FsItem | FsItem} operations.\n * @public\n */\nexport type FsItemResultDetail = 'failed' | 'skipped' | 'succeeded';\n\n/**\n * Interface describing some single file system item.\n * @public\n */\nexport interface IFsItemProps {\n /**\n * The underlying `FileTreeItem` for this item.\n */\n readonly item: FileTree.FileTreeItem;\n\n /**\n * The base name of the file system item, once\n * any conditions set tokens have been removed.\n */\n readonly baseName: string;\n\n /**\n * {@link Conditions.IValidatedConditionDecl | Conditions} extracted\n * from the base name of the {@link Import.FsItem | FsItem}.\n */\n readonly conditions: Conditions.IValidatedConditionDecl[];\n}\n\n/**\n * Class describing some file system item to be imported.\n * @public\n */\nexport class FsItem implements IFsItemProps {\n /**\n * {@inheritDoc Import.IFsItemProps.baseName}\n */\n public readonly baseName: string;\n\n /**\n * {@inheritDoc Import.IFsItemProps.conditions}\n */\n public readonly conditions: Conditions.IValidatedConditionDecl[];\n\n /**\n * {@inheritDoc Import.IFsItemProps.item}\n */\n public readonly item: FileTree.FileTreeItem;\n\n /**\n * The {@link Qualifiers.IReadOnlyQualifierCollector | qualifiers} to use for this item.\n */\n public readonly qualifiers: IReadOnlyQualifierCollector;\n\n /**\n * Protected constructor creates a new {@link Import.FsItem | FsItem}.\n * @param props - The {@link Import.IFsItemProps | file system item properties} to use for this item.\n * @param qualifiers - The {@link Qualifiers.IReadOnlyQualifierCollector | qualifiers} used to parse\n * embedded condition set tokens.\n * @param tree - file tree implementation to use for this item.\n * @returns `Success` containing the new {@link Import.FsItem | FsItem} if successful, or a `Failure`\n * containing an error message if not.\n */\n protected constructor(props: IFsItemProps, qualifiers: IReadOnlyQualifierCollector) {\n const { baseName, conditions, item } = props;\n this.baseName = baseName;\n this.conditions = conditions;\n this.item = item;\n this.qualifiers = qualifiers;\n }\n\n /**\n * Creates a new {@link Import.FsItem | FsItem} from a `FileTreeItem`.\n * @param item - The `FileTreeItem` to import.\n * @param qualifiers - The {@link Qualifiers.IReadOnlyQualifierCollector | qualifiers} used to parse\n * embedded condition set tokens.\n * @returns `Success` containing the new {@link Import.FsItem | FsItem} if successful, or a `Failure`\n * containing an error message if not. Note that the result detail `skipped` indicates that the item\n * was not created because it is not relevant - this is a soft error that should be silently ignored.\n */\n public static createForItem(\n item: FileTree.FileTreeItem,\n qualifiers: IReadOnlyQualifierCollector\n ): DetailedResult<FsItem, FsItemResultDetail> {\n const baseName: string = item.type === 'file' ? item.baseName : item.name;\n\n return FsItem.tryParseBaseName(baseName, qualifiers)\n .withErrorFormat((msg) => `${baseName}: error extracting conditions - ${msg}`)\n .onSuccess(({ baseName: newBaseName, conditions }) => {\n return captureResult(() => new FsItem({ baseName: newBaseName, conditions, item }, qualifiers));\n })\n .withDetail('failed', 'succeeded');\n }\n\n /**\n * Creates a new {@link Import.FsItem | FsItem} from a file system path.\n * @param importPath - The path to the file system item to import.\n * @param qualifiers - The {@link Qualifiers.IReadOnlyQualifierCollector | qualifiers} used to parse\n * embedded condition set tokens.\n * @param fs - An optional {@link Import.IImporterFilesystem | file system implementation} to use for this item.\n * @returns `Success` containing the new {@link Import.FsItem | FsItem} if an item is created\n * successfully, or a `Failure` containing an error message if it is not. Note that the result detail\n * `skipped` indicates that the item was not created because it is not relevant - this is a soft error\n * that should be silently ignored.\n */\n public static createForPath(\n importPath: string,\n qualifiers: IReadOnlyQualifierCollector,\n tree?: FileTree.FileTree\n ): DetailedResult<FsItem, FsItemResultDetail> {\n if (tree === undefined) {\n const treeResult = FileTree.forFilesystem();\n /* c8 ignore next 3 - defense in depth should never happen */\n if (treeResult.isFailure()) {\n return failWithDetail(treeResult.message, 'failed');\n }\n tree = treeResult.value;\n }\n\n return tree\n .getItem(importPath)\n .withDetail<FsItemResultDetail>('failed')\n .onSuccess((item) => FsItem.createForItem(item, qualifiers));\n }\n\n /**\n * Tries to parse a base name into a base name and a set of conditions.\n * @param baseName - The base name to parse.\n * @param qualifiers - The {@link Qualifiers.IReadOnlyQualifierCollector | qualifiers} used to parse\n * embedded condition set tokens.\n * @returns `Success` containing the parsed base name and conditions on success, or `Failure` containing\n * an error message if it is not.\n */\n public static tryParseBaseName(\n baseName: string,\n qualifiers: IReadOnlyQualifierCollector\n ): Result<Omit<IFsItemProps, 'item'>> {\n const nameParts = baseName.split('.');\n const segmentToTest = nameParts.length > 1 ? nameParts[nameParts.length - 1] : nameParts[0];\n const validatedConditions = CommonHelpers.parseConditionSetTokenParts(segmentToTest).onSuccess(\n (parts) => {\n return mapResults(\n parts.map((part) => Conditions.ConditionTokens.validateConditionTokenParts(part, qualifiers))\n ).onFailure((msg) => {\n if (parts.length === 1 && parts[0].qualifier === undefined) {\n return succeed([]);\n }\n return fail(msg);\n });\n }\n );\n if (validatedConditions.isFailure()) {\n return fail(validatedConditions.message);\n }\n const conditions = validatedConditions.value;\n if (conditions.length > 0) {\n baseName = nameParts.filter((s) => s !== segmentToTest).join('.');\n }\n return succeed({ baseName, conditions });\n }\n\n /**\n * Gets the context for this file system item.\n * @returns `Success` containing the {@link Import.ImportContext | import context} for this item\n * if successful, or a `Failure` containing an error message if an error occurs.\n */\n public getContext(): Result<ImportContext> {\n return Validate.toOptionalResourceId(this.baseName).onSuccess((baseId) => {\n const conditions = this.conditions.map((c) => {\n return {\n qualifierName: c.qualifier.name,\n value: c.value,\n operator: c.operator,\n priority: c.priority\n };\n });\n return ImportContext.create({ baseId, conditions });\n });\n }\n}\n"]}
1
+ {"version":3,"file":"fsItem.js","sourceRoot":"","sources":["../../../src/packlets/import/fsItem.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4CASuB;AACvB,sCAA+D;AAC/D,0DAA4C;AAE5C,mDAAgD;AA+BhD;;;GAGG;AACH,MAAa,MAAM;IAqBjB;;;;;;;;OAQG;IACH,YAAsB,KAAmB,EAAE,UAAuC;QAChF,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;QAC7C,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED;;;;;;;;OAQG;IACI,MAAM,CAAC,aAAa,CACzB,IAA2B,EAC3B,UAAuC;QAEvC,MAAM,QAAQ,GAAW,IAAI,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;QAE1E,OAAO,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,UAAU,CAAC;aACjD,eAAe,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,QAAQ,mCAAmC,GAAG,EAAE,CAAC;aAC7E,SAAS,CAAC,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,EAAE,EAAE;YACnD,OAAO,IAAA,wBAAa,EAAC,GAAG,EAAE,CAAC,IAAI,MAAM,CAAC,EAAE,QAAQ,EAAE,WAAW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AAE,UAAU,EAAE,CAAC,CAAC;QACtD,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA7ID,wBA6IC","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 {\n captureResult,\n DetailedResult,\n FileTree,\n mapResults,\n Result,\n fail,\n succeed,\n useOrInitialize\n} from '@fgv/ts-utils';\nimport { Helpers as CommonHelpers, Validate } from '../common';\nimport * as Conditions from '../conditions';\nimport { IReadOnlyQualifierCollector } from '../qualifiers';\nimport { ImportContext } from './importContext';\n\n/**\n * Result details for {@link Import.FsItem | FsItem} operations.\n * @public\n */\nexport type FsItemResultDetail = 'failed' | 'skipped' | 'succeeded';\n\n/**\n * Interface describing some single file system item.\n * @public\n */\nexport interface IFsItemProps {\n /**\n * The underlying `FileTreeItem` for this item.\n */\n readonly item: FileTree.FileTreeItem;\n\n /**\n * The base name of the file system item, once\n * any conditions set tokens have been removed.\n */\n readonly baseName: string;\n\n /**\n * {@link Conditions.IValidatedConditionDecl | Conditions} extracted\n * from the base name of the {@link Import.FsItem | FsItem}.\n */\n readonly conditions: Conditions.IValidatedConditionDecl[];\n}\n\n/**\n * Class describing some file system item to be imported.\n * @public\n */\nexport class FsItem implements IFsItemProps {\n /**\n * {@inheritDoc Import.IFsItemProps.baseName}\n */\n public readonly baseName: string;\n\n /**\n * {@inheritDoc Import.IFsItemProps.conditions}\n */\n public readonly conditions: Conditions.IValidatedConditionDecl[];\n\n /**\n * {@inheritDoc Import.IFsItemProps.item}\n */\n public readonly item: FileTree.FileTreeItem;\n\n /**\n * The {@link Qualifiers.IReadOnlyQualifierCollector | qualifiers} to use for this item.\n */\n public readonly qualifiers: IReadOnlyQualifierCollector;\n\n /**\n * Protected constructor creates a new {@link Import.FsItem | FsItem}.\n * @param props - The {@link Import.IFsItemProps | file system item properties} to use for this item.\n * @param qualifiers - The {@link Qualifiers.IReadOnlyQualifierCollector | qualifiers} used to parse\n * embedded condition set tokens.\n * @param tree - file tree implementation to use for this item.\n * @returns `Success` containing the new {@link Import.FsItem | FsItem} if successful, or a `Failure`\n * containing an error message if not.\n */\n protected constructor(props: IFsItemProps, qualifiers: IReadOnlyQualifierCollector) {\n const { baseName, conditions, item } = props;\n this.baseName = baseName;\n this.conditions = conditions;\n this.item = item;\n this.qualifiers = qualifiers;\n }\n\n /**\n * Creates a new {@link Import.FsItem | FsItem} from a `FileTreeItem`.\n * @param item - The `FileTreeItem` to import.\n * @param qualifiers - The {@link Qualifiers.IReadOnlyQualifierCollector | qualifiers} used to parse\n * embedded condition set tokens.\n * @returns `Success` containing the new {@link Import.FsItem | FsItem} if successful, or a `Failure`\n * containing an error message if not. Note that the result detail `skipped` indicates that the item\n * was not created because it is not relevant - this is a soft error that should be silently ignored.\n */\n public static createForItem(\n item: FileTree.FileTreeItem,\n qualifiers: IReadOnlyQualifierCollector\n ): DetailedResult<FsItem, FsItemResultDetail> {\n const baseName: string = item.type === 'file' ? item.baseName : item.name;\n\n return FsItem.tryParseBaseName(baseName, qualifiers)\n .withErrorFormat((msg) => `${baseName}: error extracting conditions - ${msg}`)\n .onSuccess(({ baseName: newBaseName, conditions }) => {\n return captureResult(() => new FsItem({ baseName: newBaseName, conditions, item }, qualifiers));\n })\n .withDetail('failed', 'succeeded');\n }\n\n /**\n * Creates a new {@link Import.FsItem | FsItem} from a file system path.\n * @param importPath - The path to the file system item to import.\n * @param qualifiers - The {@link Qualifiers.IReadOnlyQualifierCollector | qualifiers} used to parse\n * embedded condition set tokens.\n * @param fs - An optional {@link Import.IImporterFilesystem | file system implementation} to use for this item.\n * @returns `Success` containing the new {@link Import.FsItem | FsItem} if an item is created\n * successfully, or a `Failure` containing an error message if it is not. Note that the result detail\n * `skipped` indicates that the item was not created because it is not relevant - this is a soft error\n * that should be silently ignored.\n */\n public static createForPath(\n importPath: string,\n qualifiers: IReadOnlyQualifierCollector,\n tree?: FileTree.FileTree\n ): DetailedResult<FsItem, FsItemResultDetail> {\n return useOrInitialize(tree, () => FileTree.forFilesystem())\n .withDetail<FsItemResultDetail>('failed', 'succeeded')\n .onSuccess((tree) => {\n return tree\n .getItem(importPath)\n .withDetail<FsItemResultDetail>('failed')\n .onSuccess((item) => FsItem.createForItem(item, qualifiers));\n });\n }\n\n /**\n * Tries to parse a base name into a base name and a set of conditions.\n * @param baseName - The base name to parse.\n * @param qualifiers - The {@link Qualifiers.IReadOnlyQualifierCollector | qualifiers} used to parse\n * embedded condition set tokens.\n * @returns `Success` containing the parsed base name and conditions on success, or `Failure` containing\n * an error message if it is not.\n */\n public static tryParseBaseName(\n baseName: string,\n qualifiers: IReadOnlyQualifierCollector\n ): Result<Omit<IFsItemProps, 'item'>> {\n const nameParts = baseName.split('.');\n const segmentToTest = nameParts.length > 1 ? nameParts[nameParts.length - 1] : nameParts[0];\n const validatedConditions = CommonHelpers.parseConditionSetTokenParts(segmentToTest).onSuccess(\n (parts) => {\n return mapResults(\n parts.map((part) => Conditions.ConditionTokens.validateConditionTokenParts(part, qualifiers))\n ).onFailure((msg) => {\n if (parts.length === 1 && parts[0].qualifier === undefined) {\n return succeed([]);\n }\n return fail(msg);\n });\n }\n );\n if (validatedConditions.isFailure()) {\n return fail(validatedConditions.message);\n }\n const conditions = validatedConditions.value;\n if (conditions.length > 0) {\n baseName = nameParts.filter((s) => s !== segmentToTest).join('.');\n }\n return succeed({ baseName, conditions });\n }\n\n /**\n * Gets the context for this file system item.\n * @returns `Success` containing the {@link Import.ImportContext | import context} for this item\n * if successful, or a `Failure` containing an error message if an error occurs.\n */\n public getContext(): Result<ImportContext> {\n return Validate.toOptionalResourceId(this.baseName).onSuccess((baseId) => {\n const conditions = this.conditions.map((c) => {\n return {\n qualifierName: c.qualifier.name,\n value: c.value,\n operator: c.operator,\n priority: c.priority\n };\n });\n return ImportContext.create({ baseId, conditions });\n });\n }\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import { Result } from '@fgv/ts-utils';
2
2
  import { IConditionDecl } from '../conditions';
3
3
  import { ResourceId } from '../common';
4
+ import * as ResourceJson from '../resource-json';
4
5
  /**
5
6
  * Accumulated context of a resource import operation.
6
7
  * @public
@@ -81,5 +82,23 @@ export declare class ImportContext implements IValidatedImportContext {
81
82
  * message if the operation fails.
82
83
  */
83
84
  extend(context?: IValidatedImportContext): Result<ImportContext>;
85
+ /**
86
+ * Creates a new {@link Import.ImportContext | import context} to import resources from a
87
+ * container with the specified {@link ResourceJson.Normalized.IContainerContextDecl | container context declaration}e
88
+ * @param container - The {@link ResourceJson.Normalized.IContainerContextDecl | container context declaration}
89
+ * to consider when creating the new context.
90
+ * @param importer - The base {@link Import.ImportContext | import context} to adjust for the container
91
+ * context.
92
+ * @returns `Success` with the new {@link Import.ImportContext | import context} if successful,
93
+ * or `Failure` with an error message if the operation fails.
94
+ * @remarks
95
+ * A container context declaration may specify a merge method, which determines how the
96
+ * container context is merged with the base context. The merge method can be one of the following:
97
+ * - `augment`: The base context is augmented with the container context. This is the default behavior.
98
+ * - `replace`: The base context is selectively replaced with the container context. If the container context
99
+ * specifies a base ID or conditions, the corresponding values in the base context are ignored.
100
+ * - `delete`: The base context is deleted. This means that the container context is not used at all.
101
+ */
102
+ static forContainerImport(container?: ResourceJson.Normalized.IContainerContextDecl, importer?: ImportContext): Result<ImportContext | undefined>;
84
103
  }
85
104
  //# sourceMappingURL=importContext.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"importContext.d.ts","sourceRoot":"","sources":["../../../src/packlets/import/importContext.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAiB,MAAM,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;CACrD;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC;IAC7B;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;CACpD;AAED;;;GAGG;AACH,qBAAa,aAAc,YAAW,uBAAuB;IAC3D;;OAEG;IACH,SAAgB,MAAM,EAAE,UAAU,GAAG,SAAS,CAAC;IAE/C;;OAEG;IACH,SAAgB,UAAU,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;IAE1D;;;;;OAKG;IACH,SAAS,aAAa,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,cAAc;IAK5D;;;;;;OAMG;WACW,MAAM,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,MAAM,CAAC,aAAa,CAAC;IAMrE;;;;;OAKG;IACI,cAAc,CAAC,UAAU,EAAE,cAAc,EAAE,GAAG,M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AAc,CAAC,UAAU,EAAE,cAAc,EAAE,GAAG,MAAM,CAAC,aAAa,CAAC;IAO1E;;;;;OAKG;IACI,QAAQ,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,aAAa,CAAC;IAM1D;;;;;;OAMG;IACI,MAAM,CAAC,OAAO,CAAC,EAAE,uBAAuB,GAAG,MAAM,CAAC,aAAa,CAAC;IASvE;;;;;;;;;;;;;;;;OAgBG;WACW,kBAAkB,CAC9B,SAAS,CAAC,EAAE,YAAY,CAAC,UAAU,CAAC,qBAAqB,EACzD,QAAQ,CAAC,EAAE,aAAa,GACvB,MAAM,CAAC,aAAa,GAAG,SAAS,CAAC;CAsBrC"}
@@ -89,6 +89,45 @@ class ImportContext {
89
89
  return ImportContext.create({ baseId, conditions });
90
90
  });
91
91
  }
92
+ /**
93
+ * Creates a new {@link Import.ImportContext | import context} to import resources from a
94
+ * container with the specified {@link ResourceJson.Normalized.IContainerContextDecl | container context declaration}e
95
+ * @param container - The {@link ResourceJson.Normalized.IContainerContextDecl | container context declaration}
96
+ * to consider when creating the new context.
97
+ * @param importer - The base {@link Import.ImportContext | import context} to adjust for the container
98
+ * context.
99
+ * @returns `Success` with the new {@link Import.ImportContext | import context} if successful,
100
+ * or `Failure` with an error message if the operation fails.
101
+ * @remarks
102
+ * A container context declaration may specify a merge method, which determines how the
103
+ * container context is merged with the base context. The merge method can be one of the following:
104
+ * - `augment`: The base context is augmented with the container context. This is the default behavior.
105
+ * - `replace`: The base context is selectively replaced with the container context. If the container context
106
+ * specifies a base ID or conditions, the corresponding values in the base context are ignored.
107
+ * - `delete`: The base context is deleted. This means that the container context is not used at all.
108
+ */
109
+ static forContainerImport(container, importer) {
110
+ var _a;
111
+ if (!importer) {
112
+ return (0, ts_utils_1.succeed)(undefined);
113
+ }
114
+ /* c8 ignore next 1 */
115
+ container = container !== null && container !== void 0 ? container : {};
116
+ const mergeMethod = (_a = container.mergeMethod) !== null && _a !== void 0 ? _a : 'augment';
117
+ switch (mergeMethod) {
118
+ case 'augment':
119
+ return (0, ts_utils_1.succeed)(importer);
120
+ case 'replace': {
121
+ // if the container defines baseId or conditions, then we ignore
122
+ // the corresponding values in the importer
123
+ const baseId = container.baseId ? undefined : importer.baseId;
124
+ const conditions = container.conditions ? undefined : importer.conditions;
125
+ return ImportContext.create({ baseId, conditions });
126
+ }
127
+ case 'delete':
128
+ return (0, ts_utils_1.succeed)(undefined);
129
+ }
130
+ }
92
131
  }
93
132
  exports.ImportContext = ImportContext;
94
133
  //# sourceMappingURL=importContext.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"importContext.js","sourceRoot":"","sources":["../../../src/packlets/import/importContext.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,sCAAoC;AACpC,4CAAsD;AAoCtD;;;GAGG;AACH,MAAa,aAAa;IAWxB;;;;;OAKG;IACH,YAAsB,EAAE,MAAM,EAAE,UAAU,EAAkB;QAC1D,IAAI,CAAC,MAAM,GAAG,gBAAO,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC;QAChE,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,EAAE,CAAC,CAAC;IACjD,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,MAAM,CAAC,OAAwB;QAC3C,oBAAoB;QACpB,OAAO,GAAG,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC;QACxC,OAAO,IAAA,wBAAa,EAAC,GAAG,EAAE,CAAC,IAAI,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;IACzD,CAAC;IAED;;;;;OAKG;IACI,cAAc,CAAC,UAA4B;QAChD,OAAO,aAAa,CAAC,MAAM,CAAC;YAC1B,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,UAAU,EAAE,CAAC,GAAG,IAAI,CAAC,UAAU,EAAE,GAAG,UAAU,CAAC;SAChD,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACI,QAAQ,CAAC,GAAG,KAAe;QAChC,OAAO,gBAAO,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC,MAAM,EAAE,EAAE;YACzE,OAAO,aAAa,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;QACvE,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,OAAiC;QAC7C,sBAAsB;QACtB,OAAO,GAAG,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC;QACxC,MAAM,UAAU,GAAG,CAAC,GAAG,IAAI,CAAC,UAAU,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;QAC/D,OAAO,gBAAO,CAAC,uBAAuB,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,MAAM,EAAE,EAAE;YACvF,OAAO,aAAa,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;QACtD,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA3ED,sCA2EC","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 { Helpers } from '../common';\nimport { captureResult, Result } from '@fgv/ts-utils';\nimport { IConditionDecl } from '../conditions';\nimport { ResourceId } from '../common';\n\n/**\n * Accumulated context of a resource import operation.\n * @public\n */\nexport interface IImportContext {\n /**\n * Base ID for the import context for resources imported\n * in this context.\n */\n readonly baseId?: string;\n /**\n * Conditions to be applied to resources imported in this context.\n */\n readonly conditions?: ReadonlyArray<IConditionDecl>;\n}\n\n/**\n * Accumulated context of a resource import operation.\n * @public\n */\nexport interface IValidatedImportContext {\n /**\n * Base ID for the import context for resources imported\n * in this context.\n */\n readonly baseId?: ResourceId;\n /**\n * Conditions to be applied to resources imported in this context.\n */\n readonly conditions: ReadonlyArray<IConditionDecl>;\n}\n\n/**\n * Class to accumulate context for a resource import operation.\n * @public\n */\nexport class ImportContext implements IValidatedImportContext {\n /**\n * {@inheritdoc Import.IImportContext.baseId}\n */\n public readonly baseId: ResourceId | undefined;\n\n /**\n * {@inheritdoc Import.IImportContext.conditions}\n */\n public readonly conditions: ReadonlyArray<IConditionDecl>;\n\n /**\n * Protected {@link Import.ImportContext | import context} for derived classes.\n * Public consumers use {@link Import.ImportContext.create | create} to create new instances.\n * @param baseId - The base ID for the import context.\n * @param conditions - Conditions to be applied to resources imported in this context.\n */\n protected constructor({ baseId, conditions }: IImportContext) {\n this.baseId = Helpers.joinOptionalResourceIds(baseId).orThrow();\n this.conditions = Array.from(conditions ?? []);\n }\n\n /**\n * Factory method to create a new {@link Import.ImportContext | import context}.\n * @param context - The {@link Import.IImportContext | import context} to create\n * the new context from.\n * @returns `Success` with the new {@link Import.ImportContext | import context}\n * if successful, or `Failure` with an error message if creation fails.\n */\n public static create(context?: IImportContext): Result<ImportContext> {\n /* c8 ignore next */\n context = context ?? { conditions: [] };\n return captureResult(() => new ImportContext(context));\n }\n\n /**\n * Adds conditions to the import context.\n * @param conditions - Conditions to be added to the import context.\n * @returns `Success` with a new {@link Import.ImportContext | import context} containing the added conditions\n * if successful, or `Failure` with an error message if the operation fails.\n */\n public withConditions(conditions: IConditionDecl[]): Result<ImportContext> {\n return ImportContext.create({\n baseId: this.baseId,\n conditions: [...this.conditions, ...conditions]\n });\n }\n\n /**\n * Appends names to the base ID of the import context.\n * @param name - The base name to set.\n * @returns `Success` with a new {@link Import.ImportContext | import context} containing the new base ID\n * if successful, or `Failure` with an error message if the operation fails.\n */\n public withName(...names: string[]): Result<ImportContext> {\n return Helpers.joinResourceIds(this.baseId, ...names).onSuccess((baseId) => {\n return ImportContext.create({ baseId, conditions: this.conditions });\n });\n }\n\n /**\n * Extends the import context with additional name segments and conditions.\n * @param context - The {@link Import.IImportContext | import context} to extend this context with.\n * @returns `Success` with a new {@link Import.ImportContext | import context}\n * containing the extended context if successful, or `Failure` with an error\n * message if the operation fails.\n */\n public extend(context?: IValidatedImportContext): Result<ImportContext> {\n /* c8 ignore next 1 */\n context = context ?? { conditions: [] };\n const conditions = [...this.conditions, ...context.conditions];\n return Helpers.joinOptionalResourceIds(this.baseId, context.baseId).onSuccess((baseId) => {\n return ImportContext.create({ baseId, conditions });\n });\n }\n}\n"]}
1
+ {"version":3,"file":"importContext.js","sourceRoot":"","sources":["../../../src/packlets/import/importContext.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,sCAAoC;AACpC,4CAA+D;AAqC/D;;;GAGG;AACH,MAAa,aAAa;IAWxB;;;;;OAKG;IACH,YAAsB,EAAE,MAAM,EAAE,UAAU,EAAkB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ereby 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 { Helpers } from '../common';\nimport { captureResult, Result, succeed } from '@fgv/ts-utils';\nimport { IConditionDecl } from '../conditions';\nimport { ResourceId } from '../common';\nimport * as ResourceJson from '../resource-json';\n\n/**\n * Accumulated context of a resource import operation.\n * @public\n */\nexport interface IImportContext {\n /**\n * Base ID for the import context for resources imported\n * in this context.\n */\n readonly baseId?: string;\n /**\n * Conditions to be applied to resources imported in this context.\n */\n readonly conditions?: ReadonlyArray<IConditionDecl>;\n}\n\n/**\n * Accumulated context of a resource import operation.\n * @public\n */\nexport interface IValidatedImportContext {\n /**\n * Base ID for the import context for resources imported\n * in this context.\n */\n readonly baseId?: ResourceId;\n /**\n * Conditions to be applied to resources imported in this context.\n */\n readonly conditions: ReadonlyArray<IConditionDecl>;\n}\n\n/**\n * Class to accumulate context for a resource import operation.\n * @public\n */\nexport class ImportContext implements IValidatedImportContext {\n /**\n * {@inheritdoc Import.IImportContext.baseId}\n */\n public readonly baseId: ResourceId | undefined;\n\n /**\n * {@inheritdoc Import.IImportContext.conditions}\n */\n public readonly conditions: ReadonlyArray<IConditionDecl>;\n\n /**\n * Protected {@link Import.ImportContext | import context} for derived classes.\n * Public consumers use {@link Import.ImportContext.create | create} to create new instances.\n * @param baseId - The base ID for the import context.\n * @param conditions - Conditions to be applied to resources imported in this context.\n */\n protected constructor({ baseId, conditions }: IImportContext) {\n this.baseId = Helpers.joinOptionalResourceIds(baseId).orThrow();\n this.conditions = Array.from(conditions ?? []);\n }\n\n /**\n * Factory method to create a new {@link Import.ImportContext | import context}.\n * @param context - The {@link Import.IImportContext | import context} to create\n * the new context from.\n * @returns `Success` with the new {@link Import.ImportContext | import context}\n * if successful, or `Failure` with an error message if creation fails.\n */\n public static create(context?: IImportContext): Result<ImportContext> {\n /* c8 ignore next */\n context = context ?? { conditions: [] };\n return captureResult(() => new ImportContext(context));\n }\n\n /**\n * Adds conditions to the import context.\n * @param conditions - Conditions to be added to the import context.\n * @returns `Success` with a new {@link Import.ImportContext | import context} containing the added conditions\n * if successful, or `Failure` with an error message if the operation fails.\n */\n public withConditions(conditions: IConditionDecl[]): Result<ImportContext> {\n return ImportContext.create({\n baseId: this.baseId,\n conditions: [...this.conditions, ...conditions]\n });\n }\n\n /**\n * Appends names to the base ID of the import context.\n * @param name - The base name to set.\n * @returns `Success` with a new {@link Import.ImportContext | import context} containing the new base ID\n * if successful, or `Failure` with an error message if the operation fails.\n */\n public withName(...names: string[]): Result<ImportContext> {\n return Helpers.joinResourceIds(this.baseId, ...names).onSuccess((baseId) => {\n return ImportContext.create({ baseId, conditions: this.conditions });\n });\n }\n\n /**\n * Extends the import context with additional name segments and conditions.\n * @param context - The {@link Import.IImportContext | import context} to extend this context with.\n * @returns `Success` with a new {@link Import.ImportContext | import context}\n * containing the extended context if successful, or `Failure` with an error\n * message if the operation fails.\n */\n public extend(context?: IValidatedImportContext): Result<ImportContext> {\n /* c8 ignore next 1 */\n context = context ?? { conditions: [] };\n const conditions = [...this.conditions, ...context.conditions];\n return Helpers.joinOptionalResourceIds(this.baseId, context.baseId).onSuccess((baseId) => {\n return ImportContext.create({ baseId, conditions });\n });\n }\n\n /**\n * Creates a new {@link Import.ImportContext | import context} to import resources from a\n * container with the specified {@link ResourceJson.Normalized.IContainerContextDecl | container context declaration}e\n * @param container - The {@link ResourceJson.Normalized.IContainerContextDecl | container context declaration}\n * to consider when creating the new context.\n * @param importer - The base {@link Import.ImportContext | import context} to adjust for the container\n * context.\n * @returns `Success` with the new {@link Import.ImportContext | import context} if successful,\n * or `Failure` with an error message if the operation fails.\n * @remarks\n * A container context declaration may specify a merge method, which determines how the\n * container context is merged with the base context. The merge method can be one of the following:\n * - `augment`: The base context is augmented with the container context. This is the default behavior.\n * - `replace`: The base context is selectively replaced with the container context. If the container context\n * specifies a base ID or conditions, the corresponding values in the base context are ignored.\n * - `delete`: The base context is deleted. This means that the container context is not used at all.\n */\n public static forContainerImport(\n container?: ResourceJson.Normalized.IContainerContextDecl,\n importer?: ImportContext\n ): Result<ImportContext | undefined> {\n if (!importer) {\n return succeed(undefined);\n }\n /* c8 ignore next 1 */\n container = container ?? {};\n const mergeMethod = container.mergeMethod ?? 'augment';\n\n switch (mergeMethod) {\n case 'augment':\n return succeed(importer);\n case 'replace': {\n // if the container defines baseId or conditions, then we ignore\n // the corresponding values in the importer\n const baseId = container.baseId ? undefined : importer.baseId;\n const conditions = container.conditions ? undefined : importer.conditions;\n return ImportContext.create({ baseId, conditions });\n }\n case 'delete':\n return succeed(undefined);\n }\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { FileTree, Result } from '@fgv/ts-utils';
2
- import { ResourceManager } from '../resources';
2
+ import { ResourceManagerBuilder } from '../resources';
3
3
  import { ImportContext } from './importContext';
4
4
  import { IImportable } from './importable';
5
5
  import { IImporter } from './importers';
@@ -10,10 +10,10 @@ import { IReadOnlyQualifierCollector } from '../qualifiers';
10
10
  */
11
11
  export interface IImporterCreateParams {
12
12
  /**
13
- * The {@link Resources.ResourceManager | resource manager} into which resources
13
+ * The {@link Resources.ResourceManagerBuilder | resource manager builder} into which resources
14
14
  * will be imported.
15
15
  */
16
- resources: ResourceManager;
16
+ resources: ResourceManagerBuilder;
17
17
  /**
18
18
  * An optional initial {@link Import.ImportContext | import context} for the import operation.
19
19
  */
@@ -33,10 +33,10 @@ export interface IImporterCreateParams {
33
33
  */
34
34
  export declare class ImportManager {
35
35
  /**
36
- * The {@link Resources.ResourceManager | resource manager} into which resources
36
+ * The {@link Resources.ResourceManagerBuilder | resource manager builder} into which resources
37
37
  * will be imported.
38
38
  */
39
- readonly resources: ResourceManager;
39
+ readonly resources: ResourceManagerBuilder;
40
40
  /**
41
41
  * The list of {@link Import.Importers.IImporter | importers} to use for the
42
42
  * import operations.