@fgv/ts-res 5.1.0-3 → 5.1.0-30

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 (545) hide show
  1. package/dist/index.browser.js.map +1 -0
  2. package/dist/index.js.map +1 -0
  3. package/dist/packlets/bundle/bundleBuilder.js.map +1 -0
  4. package/dist/packlets/bundle/bundleLoader.js.map +1 -0
  5. package/dist/packlets/bundle/bundleNormalizer.js.map +1 -0
  6. package/dist/packlets/bundle/bundleUtils.js.map +1 -0
  7. package/dist/packlets/bundle/convert.js.map +1 -0
  8. package/dist/packlets/bundle/index.js.map +1 -0
  9. package/dist/packlets/bundle/model.js.map +1 -0
  10. package/dist/packlets/common/conditions.js.map +1 -0
  11. package/dist/packlets/common/convert.js.map +1 -0
  12. package/dist/packlets/common/helpers/conditions.js.map +1 -0
  13. package/dist/packlets/common/helpers/context.js.map +1 -0
  14. package/dist/packlets/common/helpers/index.js.map +1 -0
  15. package/dist/packlets/common/helpers/qualifierDefaultValues.js.map +1 -0
  16. package/dist/packlets/common/helpers/resources.js +2 -4
  17. package/dist/packlets/common/helpers/resources.js.map +1 -0
  18. package/dist/packlets/common/index.js.map +1 -0
  19. package/dist/packlets/common/resources.js.map +1 -0
  20. package/dist/packlets/common/validate/conditions.js +4 -4
  21. package/dist/packlets/common/validate/conditions.js.map +1 -0
  22. package/dist/packlets/common/validate/index.js.map +1 -0
  23. package/dist/packlets/common/validate/regularExpressions.js +2 -2
  24. package/dist/packlets/common/validate/regularExpressions.js.map +1 -0
  25. package/dist/packlets/common/validate/resources.js +1 -1
  26. package/dist/packlets/common/validate/resources.js.map +1 -0
  27. package/dist/packlets/conditions/condition.js +3 -7
  28. package/dist/packlets/conditions/condition.js.map +1 -0
  29. package/dist/packlets/conditions/conditionCollector.js.map +1 -0
  30. package/dist/packlets/conditions/conditionDecls.js.map +1 -0
  31. package/dist/packlets/conditions/conditionSet.js +14 -5
  32. package/dist/packlets/conditions/conditionSet.js.map +1 -0
  33. package/dist/packlets/conditions/conditionSetCollector.js.map +1 -0
  34. package/dist/packlets/conditions/conditionSetDecls.js.map +1 -0
  35. package/dist/packlets/conditions/conditionToken.js.map +1 -0
  36. package/dist/packlets/conditions/convert/conditionSetDecls.js +50 -6
  37. package/dist/packlets/conditions/convert/conditionSetDecls.js.map +1 -0
  38. package/dist/packlets/conditions/convert/decls.js +61 -5
  39. package/dist/packlets/conditions/convert/decls.js.map +1 -0
  40. package/dist/packlets/conditions/convert/index.js.map +1 -0
  41. package/dist/packlets/conditions/index.js.map +1 -0
  42. package/dist/packlets/config/common.js.map +1 -0
  43. package/dist/packlets/config/configInitFactory.js.map +1 -0
  44. package/dist/packlets/config/convert.js.map +1 -0
  45. package/dist/packlets/config/index.browser.js.map +1 -0
  46. package/dist/packlets/config/index.js.map +1 -0
  47. package/dist/packlets/config/json.js.map +1 -0
  48. package/dist/packlets/config/predefined/default.js.map +1 -0
  49. package/dist/packlets/config/predefined/extended.js.map +1 -0
  50. package/dist/packlets/config/predefined/index.js.map +1 -0
  51. package/dist/packlets/config/systemConfiguration.js.map +1 -0
  52. package/dist/packlets/context/contextDecls.js.map +1 -0
  53. package/dist/packlets/context/contextToken.js.map +1 -0
  54. package/dist/packlets/context/convert/decls.js.map +1 -0
  55. package/dist/packlets/context/convert/index.js.map +1 -0
  56. package/dist/packlets/context/index.js.map +1 -0
  57. package/dist/packlets/decisions/abstractDecision.js.map +1 -0
  58. package/dist/packlets/decisions/abstractDecisionCollector.js.map +1 -0
  59. package/dist/packlets/decisions/candidate.js.map +1 -0
  60. package/dist/packlets/decisions/common.js.map +1 -0
  61. package/dist/packlets/decisions/concreteDecision.js.map +1 -0
  62. package/dist/packlets/decisions/decision.js +1 -1
  63. package/dist/packlets/decisions/decision.js.map +1 -0
  64. package/dist/packlets/decisions/index.js.map +1 -0
  65. package/dist/packlets/import/fsItem.js +1 -4
  66. package/dist/packlets/import/fsItem.js.map +1 -0
  67. package/dist/packlets/import/importContext.js +3 -3
  68. package/dist/packlets/import/importContext.js.map +1 -0
  69. package/dist/packlets/import/importManager.js +7 -3
  70. package/dist/packlets/import/importManager.js.map +1 -0
  71. package/dist/packlets/import/importable.js.map +1 -0
  72. package/dist/packlets/import/importers/collectionImporter.js +2 -2
  73. package/dist/packlets/import/importers/collectionImporter.js.map +1 -0
  74. package/dist/packlets/import/importers/fsItemImporter.js +30 -14
  75. package/dist/packlets/import/importers/fsItemImporter.js.map +1 -0
  76. package/dist/packlets/import/importers/importer.js.map +1 -0
  77. package/dist/packlets/import/importers/index.browser.js.map +1 -0
  78. package/dist/packlets/import/importers/index.js.map +1 -0
  79. package/dist/packlets/import/importers/jsonImporter.js +2 -2
  80. package/dist/packlets/import/importers/jsonImporter.js.map +1 -0
  81. package/dist/packlets/import/importers/pathImporter.js +1 -1
  82. package/dist/packlets/import/importers/pathImporter.js.map +1 -0
  83. package/dist/packlets/import/index.browser.js.map +1 -0
  84. package/dist/packlets/import/index.js.map +1 -0
  85. package/dist/packlets/qualifier-types/config/convert.js.map +1 -0
  86. package/dist/packlets/qualifier-types/config/index.js.map +1 -0
  87. package/dist/packlets/qualifier-types/config/json.js.map +1 -0
  88. package/dist/packlets/qualifier-types/convert.js.map +1 -0
  89. package/dist/packlets/qualifier-types/helpers.js.map +1 -0
  90. package/dist/packlets/qualifier-types/index.js.map +1 -0
  91. package/dist/packlets/qualifier-types/languageQualifierType.js +6 -7
  92. package/dist/packlets/qualifier-types/languageQualifierType.js.map +1 -0
  93. package/dist/packlets/qualifier-types/literalQualifierType.js +7 -10
  94. package/dist/packlets/qualifier-types/literalQualifierType.js.map +1 -0
  95. package/dist/packlets/qualifier-types/literalValueHierarchy.js.map +1 -0
  96. package/dist/packlets/qualifier-types/qualifierType.js +12 -13
  97. package/dist/packlets/qualifier-types/qualifierType.js.map +1 -0
  98. package/dist/packlets/qualifier-types/qualifierTypeCollector.js.map +1 -0
  99. package/dist/packlets/qualifier-types/territoryQualifierType.js +5 -5
  100. package/dist/packlets/qualifier-types/territoryQualifierType.js.map +1 -0
  101. package/dist/packlets/qualifiers/convert/decls.js.map +1 -0
  102. package/dist/packlets/qualifiers/convert/index.js.map +1 -0
  103. package/dist/packlets/qualifiers/convert/qualifier.js.map +1 -0
  104. package/dist/packlets/qualifiers/index.js.map +1 -0
  105. package/dist/packlets/qualifiers/qualifier.js +6 -7
  106. package/dist/packlets/qualifiers/qualifier.js.map +1 -0
  107. package/dist/packlets/qualifiers/qualifierCollector.js +153 -9
  108. package/dist/packlets/qualifiers/qualifierCollector.js.map +1 -0
  109. package/dist/packlets/qualifiers/qualifierDecl.js.map +1 -0
  110. package/dist/packlets/qualifiers/qualifierDefaultValueDecls.js.map +1 -0
  111. package/dist/packlets/qualifiers/qualifierDefaultValueToken.js.map +1 -0
  112. package/dist/packlets/resource-json/compiled/common.js.map +1 -0
  113. package/dist/packlets/resource-json/compiled/convert.js.map +1 -0
  114. package/dist/packlets/resource-json/compiled/index.js.map +1 -0
  115. package/dist/packlets/resource-json/compiled/json.js.map +1 -0
  116. package/dist/packlets/resource-json/convert.js +225 -0
  117. package/dist/packlets/resource-json/convert.js.map +1 -0
  118. package/dist/packlets/resource-json/helpers.js.map +1 -0
  119. package/dist/packlets/resource-json/index.js.map +1 -0
  120. package/dist/packlets/resource-json/json.js +2 -2
  121. package/dist/packlets/resource-json/json.js.map +1 -0
  122. package/dist/packlets/resource-json/normalized.js.map +1 -0
  123. package/dist/packlets/resource-json/resourceDeclCollection.js +1 -1
  124. package/dist/packlets/resource-json/resourceDeclCollection.js.map +1 -0
  125. package/dist/packlets/resource-json/resourceDeclContainer.js.map +1 -0
  126. package/dist/packlets/resource-json/resourceDeclTree.js +1 -1
  127. package/dist/packlets/resource-json/resourceDeclTree.js.map +1 -0
  128. package/dist/packlets/resource-types/config/convert.js.map +1 -0
  129. package/dist/packlets/resource-types/config/index.js.map +1 -0
  130. package/dist/packlets/resource-types/config/json.js.map +1 -0
  131. package/dist/packlets/resource-types/helpers.js.map +1 -0
  132. package/dist/packlets/resource-types/index.js.map +1 -0
  133. package/dist/packlets/resource-types/jsonResourceType.js +2 -2
  134. package/dist/packlets/resource-types/jsonResourceType.js.map +1 -0
  135. package/dist/packlets/resource-types/resourceType.js +2 -2
  136. package/dist/packlets/resource-types/resourceType.js.map +1 -0
  137. package/dist/packlets/resource-types/resourceTypeCollector.js.map +1 -0
  138. package/dist/packlets/resources/candidateReducer.js.map +1 -0
  139. package/dist/packlets/resources/candidateValue.js.map +1 -0
  140. package/dist/packlets/resources/candidateValueCollector.js.map +1 -0
  141. package/dist/packlets/resources/common.js.map +1 -0
  142. package/dist/packlets/resources/deltaGenerator.js.map +1 -0
  143. package/dist/packlets/resources/index.js.map +1 -0
  144. package/dist/packlets/resources/resource.js.map +1 -0
  145. package/dist/packlets/resources/resourceBuilder.js +2 -2
  146. package/dist/packlets/resources/resourceBuilder.js.map +1 -0
  147. package/dist/packlets/resources/resourceCandidate.js.map +1 -0
  148. package/dist/packlets/resources/resourceManagerBuilder.js +5 -5
  149. package/dist/packlets/resources/resourceManagerBuilder.js.map +1 -0
  150. package/dist/packlets/runtime/cacheListener.js.map +1 -0
  151. package/dist/packlets/runtime/cacheMetrics.js.map +1 -0
  152. package/dist/packlets/runtime/compiledResourceCollection.js +5 -5
  153. package/dist/packlets/runtime/compiledResourceCollection.js.map +1 -0
  154. package/dist/packlets/runtime/conditionSetResolutionResult.js.map +1 -0
  155. package/dist/packlets/runtime/context/contextQualifierProvider.js.map +1 -0
  156. package/dist/packlets/runtime/context/contextQualifierProviderValidator.js.map +1 -0
  157. package/dist/packlets/runtime/context/index.js.map +1 -0
  158. package/dist/packlets/runtime/context/simpleContextQualifierProvider.js +3 -0
  159. package/dist/packlets/runtime/context/simpleContextQualifierProvider.js.map +1 -0
  160. package/dist/packlets/runtime/context/validatingSimpleContextQualifierProvider.js +3 -5
  161. package/dist/packlets/runtime/context/validatingSimpleContextQualifierProvider.js.map +1 -0
  162. package/dist/packlets/runtime/iResourceManager.js.map +1 -0
  163. package/dist/packlets/runtime/index.js.map +1 -0
  164. package/dist/packlets/runtime/resource-tree/common.js.map +1 -0
  165. package/dist/packlets/runtime/resource-tree/index.js.map +1 -0
  166. package/dist/packlets/runtime/resource-tree/readOnlyResourceTree.js.map +1 -0
  167. package/dist/packlets/runtime/resource-tree/resourceTreeChildren.js.map +1 -0
  168. package/dist/packlets/runtime/resource-tree/resourceTreeChildrenValidator.js.map +1 -0
  169. package/dist/packlets/runtime/resourceResolver.js.map +1 -0
  170. package/dist/packlets/runtime/resourceTreeResolver.js.map +1 -0
  171. package/dist/packlets/runtime/validate.js.map +1 -0
  172. package/dist/packlets/zip-archive/convert.js.map +1 -0
  173. package/dist/packlets/zip-archive/index.browser.js.map +1 -0
  174. package/dist/packlets/zip-archive/index.js.map +1 -0
  175. package/dist/packlets/zip-archive/json.js.map +1 -0
  176. package/dist/packlets/zip-archive/types.js.map +1 -0
  177. package/dist/packlets/zip-archive/zipArchiveCreator.js.map +1 -0
  178. package/dist/packlets/zip-archive/zipArchiveFormat.js.map +1 -0
  179. package/dist/packlets/zip-archive/zipArchiveLoader.js.map +1 -0
  180. package/dist/ts-res.d.ts +576 -164
  181. package/dist/tsdoc-metadata.json +1 -1
  182. package/lib/index.browser.d.ts.map +1 -0
  183. package/lib/index.browser.js.map +1 -0
  184. package/lib/index.d.ts.map +1 -0
  185. package/lib/index.js.map +1 -0
  186. package/lib/packlets/bundle/bundleBuilder.d.ts.map +1 -0
  187. package/lib/packlets/bundle/bundleBuilder.js.map +1 -0
  188. package/lib/packlets/bundle/bundleLoader.d.ts.map +1 -0
  189. package/lib/packlets/bundle/bundleLoader.js.map +1 -0
  190. package/lib/packlets/bundle/bundleNormalizer.d.ts.map +1 -0
  191. package/lib/packlets/bundle/bundleNormalizer.js.map +1 -0
  192. package/lib/packlets/bundle/bundleUtils.d.ts.map +1 -0
  193. package/lib/packlets/bundle/bundleUtils.js.map +1 -0
  194. package/lib/packlets/bundle/convert.d.ts.map +1 -0
  195. package/lib/packlets/bundle/convert.js.map +1 -0
  196. package/lib/packlets/bundle/index.d.ts.map +1 -0
  197. package/lib/packlets/bundle/index.js.map +1 -0
  198. package/lib/packlets/bundle/model.d.ts.map +1 -0
  199. package/lib/packlets/bundle/model.js.map +1 -0
  200. package/lib/packlets/common/conditions.d.ts.map +1 -0
  201. package/lib/packlets/common/conditions.js.map +1 -0
  202. package/lib/packlets/common/convert.d.ts.map +1 -0
  203. package/lib/packlets/common/convert.js.map +1 -0
  204. package/lib/packlets/common/helpers/conditions.d.ts.map +1 -0
  205. package/lib/packlets/common/helpers/conditions.js.map +1 -0
  206. package/lib/packlets/common/helpers/context.d.ts.map +1 -0
  207. package/lib/packlets/common/helpers/context.js.map +1 -0
  208. package/lib/packlets/common/helpers/index.d.ts.map +1 -0
  209. package/lib/packlets/common/helpers/index.js.map +1 -0
  210. package/lib/packlets/common/helpers/qualifierDefaultValues.d.ts.map +1 -0
  211. package/lib/packlets/common/helpers/qualifierDefaultValues.js.map +1 -0
  212. package/lib/packlets/common/helpers/resources.d.ts +2 -4
  213. package/lib/packlets/common/helpers/resources.d.ts.map +1 -0
  214. package/lib/packlets/common/helpers/resources.js +2 -4
  215. package/lib/packlets/common/helpers/resources.js.map +1 -0
  216. package/lib/packlets/common/index.d.ts.map +1 -0
  217. package/lib/packlets/common/index.js.map +1 -0
  218. package/lib/packlets/common/resources.d.ts.map +1 -0
  219. package/lib/packlets/common/resources.js.map +1 -0
  220. package/lib/packlets/common/validate/conditions.d.ts +4 -4
  221. package/lib/packlets/common/validate/conditions.d.ts.map +1 -0
  222. package/lib/packlets/common/validate/conditions.js +4 -4
  223. package/lib/packlets/common/validate/conditions.js.map +1 -0
  224. package/lib/packlets/common/validate/index.d.ts.map +1 -0
  225. package/lib/packlets/common/validate/index.js.map +1 -0
  226. package/lib/packlets/common/validate/regularExpressions.d.ts +2 -2
  227. package/lib/packlets/common/validate/regularExpressions.d.ts.map +1 -0
  228. package/lib/packlets/common/validate/regularExpressions.js +2 -2
  229. package/lib/packlets/common/validate/regularExpressions.js.map +1 -0
  230. package/lib/packlets/common/validate/resources.d.ts +1 -1
  231. package/lib/packlets/common/validate/resources.d.ts.map +1 -0
  232. package/lib/packlets/common/validate/resources.js +1 -1
  233. package/lib/packlets/common/validate/resources.js.map +1 -0
  234. package/lib/packlets/conditions/condition.d.ts +3 -7
  235. package/lib/packlets/conditions/condition.d.ts.map +1 -0
  236. package/lib/packlets/conditions/condition.js +3 -7
  237. package/lib/packlets/conditions/condition.js.map +1 -0
  238. package/lib/packlets/conditions/conditionCollector.d.ts.map +1 -0
  239. package/lib/packlets/conditions/conditionCollector.js.map +1 -0
  240. package/lib/packlets/conditions/conditionDecls.d.ts +6 -1
  241. package/lib/packlets/conditions/conditionDecls.d.ts.map +1 -0
  242. package/lib/packlets/conditions/conditionDecls.js.map +1 -0
  243. package/lib/packlets/conditions/conditionSet.d.ts.map +1 -0
  244. package/lib/packlets/conditions/conditionSet.js +14 -5
  245. package/lib/packlets/conditions/conditionSet.js.map +1 -0
  246. package/lib/packlets/conditions/conditionSetCollector.d.ts.map +1 -0
  247. package/lib/packlets/conditions/conditionSetCollector.js.map +1 -0
  248. package/lib/packlets/conditions/conditionSetDecls.d.ts +7 -2
  249. package/lib/packlets/conditions/conditionSetDecls.d.ts.map +1 -0
  250. package/lib/packlets/conditions/conditionSetDecls.js.map +1 -0
  251. package/lib/packlets/conditions/conditionToken.d.ts.map +1 -0
  252. package/lib/packlets/conditions/conditionToken.js.map +1 -0
  253. package/lib/packlets/conditions/convert/conditionSetDecls.d.ts +30 -2
  254. package/lib/packlets/conditions/convert/conditionSetDecls.d.ts.map +1 -0
  255. package/lib/packlets/conditions/convert/conditionSetDecls.js +51 -5
  256. package/lib/packlets/conditions/convert/conditionSetDecls.js.map +1 -0
  257. package/lib/packlets/conditions/convert/decls.d.ts +39 -3
  258. package/lib/packlets/conditions/convert/decls.d.ts.map +1 -0
  259. package/lib/packlets/conditions/convert/decls.js +63 -5
  260. package/lib/packlets/conditions/convert/decls.js.map +1 -0
  261. package/lib/packlets/conditions/convert/index.d.ts.map +1 -0
  262. package/lib/packlets/conditions/convert/index.js.map +1 -0
  263. package/lib/packlets/conditions/index.d.ts.map +1 -0
  264. package/lib/packlets/conditions/index.js.map +1 -0
  265. package/lib/packlets/config/common.d.ts.map +1 -0
  266. package/lib/packlets/config/common.js.map +1 -0
  267. package/lib/packlets/config/configInitFactory.d.ts.map +1 -0
  268. package/lib/packlets/config/configInitFactory.js.map +1 -0
  269. package/lib/packlets/config/convert.d.ts.map +1 -0
  270. package/lib/packlets/config/convert.js.map +1 -0
  271. package/lib/packlets/config/index.browser.d.ts.map +1 -0
  272. package/lib/packlets/config/index.browser.js.map +1 -0
  273. package/lib/packlets/config/index.d.ts.map +1 -0
  274. package/lib/packlets/config/index.js.map +1 -0
  275. package/lib/packlets/config/json.d.ts.map +1 -0
  276. package/lib/packlets/config/json.js.map +1 -0
  277. package/lib/packlets/config/predefined/default.d.ts.map +1 -0
  278. package/lib/packlets/config/predefined/default.js.map +1 -0
  279. package/lib/packlets/config/predefined/extended.d.ts.map +1 -0
  280. package/lib/packlets/config/predefined/extended.js.map +1 -0
  281. package/lib/packlets/config/predefined/index.d.ts.map +1 -0
  282. package/lib/packlets/config/predefined/index.js.map +1 -0
  283. package/lib/packlets/config/systemConfiguration.d.ts.map +1 -0
  284. package/lib/packlets/config/systemConfiguration.js.map +1 -0
  285. package/lib/packlets/context/contextDecls.d.ts.map +1 -0
  286. package/lib/packlets/context/contextDecls.js.map +1 -0
  287. package/lib/packlets/context/contextToken.d.ts.map +1 -0
  288. package/lib/packlets/context/contextToken.js.map +1 -0
  289. package/lib/packlets/context/convert/decls.d.ts.map +1 -0
  290. package/lib/packlets/context/convert/decls.js.map +1 -0
  291. package/lib/packlets/context/convert/index.d.ts.map +1 -0
  292. package/lib/packlets/context/convert/index.js.map +1 -0
  293. package/lib/packlets/context/index.d.ts.map +1 -0
  294. package/lib/packlets/context/index.js.map +1 -0
  295. package/lib/packlets/decisions/abstractDecision.d.ts.map +1 -0
  296. package/lib/packlets/decisions/abstractDecision.js.map +1 -0
  297. package/lib/packlets/decisions/abstractDecisionCollector.d.ts.map +1 -0
  298. package/lib/packlets/decisions/abstractDecisionCollector.js.map +1 -0
  299. package/lib/packlets/decisions/candidate.d.ts.map +1 -0
  300. package/lib/packlets/decisions/candidate.js.map +1 -0
  301. package/lib/packlets/decisions/common.d.ts.map +1 -0
  302. package/lib/packlets/decisions/common.js.map +1 -0
  303. package/lib/packlets/decisions/concreteDecision.d.ts.map +1 -0
  304. package/lib/packlets/decisions/concreteDecision.js.map +1 -0
  305. package/lib/packlets/decisions/decision.d.ts +1 -1
  306. package/lib/packlets/decisions/decision.d.ts.map +1 -0
  307. package/lib/packlets/decisions/decision.js +1 -1
  308. package/lib/packlets/decisions/decision.js.map +1 -0
  309. package/lib/packlets/decisions/index.d.ts.map +1 -0
  310. package/lib/packlets/decisions/index.js.map +1 -0
  311. package/lib/packlets/import/fsItem.d.ts +1 -4
  312. package/lib/packlets/import/fsItem.d.ts.map +1 -0
  313. package/lib/packlets/import/fsItem.js +1 -4
  314. package/lib/packlets/import/fsItem.js.map +1 -0
  315. package/lib/packlets/import/importContext.d.ts +5 -5
  316. package/lib/packlets/import/importContext.d.ts.map +1 -0
  317. package/lib/packlets/import/importContext.js +3 -3
  318. package/lib/packlets/import/importContext.js.map +1 -0
  319. package/lib/packlets/import/importManager.d.ts +15 -1
  320. package/lib/packlets/import/importManager.d.ts.map +1 -0
  321. package/lib/packlets/import/importManager.js +7 -3
  322. package/lib/packlets/import/importManager.js.map +1 -0
  323. package/lib/packlets/import/importable.d.ts.map +1 -0
  324. package/lib/packlets/import/importable.js.map +1 -0
  325. package/lib/packlets/import/importers/collectionImporter.d.ts +2 -2
  326. package/lib/packlets/import/importers/collectionImporter.d.ts.map +1 -0
  327. package/lib/packlets/import/importers/collectionImporter.js +2 -2
  328. package/lib/packlets/import/importers/collectionImporter.js.map +1 -0
  329. package/lib/packlets/import/importers/fsItemImporter.d.ts +16 -2
  330. package/lib/packlets/import/importers/fsItemImporter.d.ts.map +1 -0
  331. package/lib/packlets/import/importers/fsItemImporter.js +29 -13
  332. package/lib/packlets/import/importers/fsItemImporter.js.map +1 -0
  333. package/lib/packlets/import/importers/importer.d.ts.map +1 -0
  334. package/lib/packlets/import/importers/importer.js.map +1 -0
  335. package/lib/packlets/import/importers/index.browser.d.ts.map +1 -0
  336. package/lib/packlets/import/importers/index.browser.js.map +1 -0
  337. package/lib/packlets/import/importers/index.d.ts.map +1 -0
  338. package/lib/packlets/import/importers/index.js.map +1 -0
  339. package/lib/packlets/import/importers/jsonImporter.d.ts +2 -2
  340. package/lib/packlets/import/importers/jsonImporter.d.ts.map +1 -0
  341. package/lib/packlets/import/importers/jsonImporter.js +2 -2
  342. package/lib/packlets/import/importers/jsonImporter.js.map +1 -0
  343. package/lib/packlets/import/importers/pathImporter.d.ts +1 -1
  344. package/lib/packlets/import/importers/pathImporter.d.ts.map +1 -0
  345. package/lib/packlets/import/importers/pathImporter.js +1 -1
  346. package/lib/packlets/import/importers/pathImporter.js.map +1 -0
  347. package/lib/packlets/import/index.browser.d.ts.map +1 -0
  348. package/lib/packlets/import/index.browser.js.map +1 -0
  349. package/lib/packlets/import/index.d.ts.map +1 -0
  350. package/lib/packlets/import/index.js.map +1 -0
  351. package/lib/packlets/qualifier-types/config/convert.d.ts.map +1 -0
  352. package/lib/packlets/qualifier-types/config/convert.js.map +1 -0
  353. package/lib/packlets/qualifier-types/config/index.d.ts.map +1 -0
  354. package/lib/packlets/qualifier-types/config/index.js.map +1 -0
  355. package/lib/packlets/qualifier-types/config/json.d.ts.map +1 -0
  356. package/lib/packlets/qualifier-types/config/json.js.map +1 -0
  357. package/lib/packlets/qualifier-types/convert.d.ts.map +1 -0
  358. package/lib/packlets/qualifier-types/convert.js.map +1 -0
  359. package/lib/packlets/qualifier-types/helpers.d.ts.map +1 -0
  360. package/lib/packlets/qualifier-types/helpers.js.map +1 -0
  361. package/lib/packlets/qualifier-types/index.d.ts.map +1 -0
  362. package/lib/packlets/qualifier-types/index.js.map +1 -0
  363. package/lib/packlets/qualifier-types/languageQualifierType.d.ts +6 -7
  364. package/lib/packlets/qualifier-types/languageQualifierType.d.ts.map +1 -0
  365. package/lib/packlets/qualifier-types/languageQualifierType.js +6 -7
  366. package/lib/packlets/qualifier-types/languageQualifierType.js.map +1 -0
  367. package/lib/packlets/qualifier-types/literalQualifierType.d.ts +7 -10
  368. package/lib/packlets/qualifier-types/literalQualifierType.d.ts.map +1 -0
  369. package/lib/packlets/qualifier-types/literalQualifierType.js +7 -10
  370. package/lib/packlets/qualifier-types/literalQualifierType.js.map +1 -0
  371. package/lib/packlets/qualifier-types/literalValueHierarchy.d.ts.map +1 -0
  372. package/lib/packlets/qualifier-types/literalValueHierarchy.js.map +1 -0
  373. package/lib/packlets/qualifier-types/qualifierType.d.ts +17 -18
  374. package/lib/packlets/qualifier-types/qualifierType.d.ts.map +1 -0
  375. package/lib/packlets/qualifier-types/qualifierType.js +12 -13
  376. package/lib/packlets/qualifier-types/qualifierType.js.map +1 -0
  377. package/lib/packlets/qualifier-types/qualifierTypeCollector.d.ts.map +1 -0
  378. package/lib/packlets/qualifier-types/qualifierTypeCollector.js.map +1 -0
  379. package/lib/packlets/qualifier-types/territoryQualifierType.d.ts +8 -8
  380. package/lib/packlets/qualifier-types/territoryQualifierType.d.ts.map +1 -0
  381. package/lib/packlets/qualifier-types/territoryQualifierType.js +5 -5
  382. package/lib/packlets/qualifier-types/territoryQualifierType.js.map +1 -0
  383. package/lib/packlets/qualifiers/convert/decls.d.ts.map +1 -0
  384. package/lib/packlets/qualifiers/convert/decls.js.map +1 -0
  385. package/lib/packlets/qualifiers/convert/index.d.ts.map +1 -0
  386. package/lib/packlets/qualifiers/convert/index.js.map +1 -0
  387. package/lib/packlets/qualifiers/convert/qualifier.d.ts.map +1 -0
  388. package/lib/packlets/qualifiers/convert/qualifier.js.map +1 -0
  389. package/lib/packlets/qualifiers/index.d.ts.map +1 -0
  390. package/lib/packlets/qualifiers/index.js.map +1 -0
  391. package/lib/packlets/qualifiers/qualifier.d.ts +6 -7
  392. package/lib/packlets/qualifiers/qualifier.d.ts.map +1 -0
  393. package/lib/packlets/qualifiers/qualifier.js +6 -7
  394. package/lib/packlets/qualifiers/qualifier.js.map +1 -0
  395. package/lib/packlets/qualifiers/qualifierCollector.d.ts +107 -9
  396. package/lib/packlets/qualifiers/qualifierCollector.d.ts.map +1 -0
  397. package/lib/packlets/qualifiers/qualifierCollector.js +152 -8
  398. package/lib/packlets/qualifiers/qualifierCollector.js.map +1 -0
  399. package/lib/packlets/qualifiers/qualifierDecl.d.ts.map +1 -0
  400. package/lib/packlets/qualifiers/qualifierDecl.js.map +1 -0
  401. package/lib/packlets/qualifiers/qualifierDefaultValueDecls.d.ts.map +1 -0
  402. package/lib/packlets/qualifiers/qualifierDefaultValueDecls.js.map +1 -0
  403. package/lib/packlets/qualifiers/qualifierDefaultValueToken.d.ts.map +1 -0
  404. package/lib/packlets/qualifiers/qualifierDefaultValueToken.js.map +1 -0
  405. package/lib/packlets/resource-json/compiled/common.d.ts.map +1 -0
  406. package/lib/packlets/resource-json/compiled/common.js.map +1 -0
  407. package/lib/packlets/resource-json/compiled/convert.d.ts.map +1 -0
  408. package/lib/packlets/resource-json/compiled/convert.js.map +1 -0
  409. package/lib/packlets/resource-json/compiled/index.d.ts.map +1 -0
  410. package/lib/packlets/resource-json/compiled/index.js.map +1 -0
  411. package/lib/packlets/resource-json/compiled/json.d.ts.map +1 -0
  412. package/lib/packlets/resource-json/compiled/json.js.map +1 -0
  413. package/lib/packlets/resource-json/convert.d.ts +85 -0
  414. package/lib/packlets/resource-json/convert.d.ts.map +1 -0
  415. package/lib/packlets/resource-json/convert.js +237 -0
  416. package/lib/packlets/resource-json/convert.js.map +1 -0
  417. package/lib/packlets/resource-json/helpers.d.ts.map +1 -0
  418. package/lib/packlets/resource-json/helpers.js.map +1 -0
  419. package/lib/packlets/resource-json/index.d.ts.map +1 -0
  420. package/lib/packlets/resource-json/index.js.map +1 -0
  421. package/lib/packlets/resource-json/json.d.ts +128 -39
  422. package/lib/packlets/resource-json/json.d.ts.map +1 -0
  423. package/lib/packlets/resource-json/json.js +2 -2
  424. package/lib/packlets/resource-json/json.js.map +1 -0
  425. package/lib/packlets/resource-json/normalized.d.ts.map +1 -0
  426. package/lib/packlets/resource-json/normalized.js.map +1 -0
  427. package/lib/packlets/resource-json/resourceDeclCollection.d.ts +1 -1
  428. package/lib/packlets/resource-json/resourceDeclCollection.d.ts.map +1 -0
  429. package/lib/packlets/resource-json/resourceDeclCollection.js +1 -1
  430. package/lib/packlets/resource-json/resourceDeclCollection.js.map +1 -0
  431. package/lib/packlets/resource-json/resourceDeclContainer.d.ts.map +1 -0
  432. package/lib/packlets/resource-json/resourceDeclContainer.js.map +1 -0
  433. package/lib/packlets/resource-json/resourceDeclTree.d.ts +1 -1
  434. package/lib/packlets/resource-json/resourceDeclTree.d.ts.map +1 -0
  435. package/lib/packlets/resource-json/resourceDeclTree.js +1 -1
  436. package/lib/packlets/resource-json/resourceDeclTree.js.map +1 -0
  437. package/lib/packlets/resource-types/config/convert.d.ts.map +1 -0
  438. package/lib/packlets/resource-types/config/convert.js.map +1 -0
  439. package/lib/packlets/resource-types/config/index.d.ts.map +1 -0
  440. package/lib/packlets/resource-types/config/index.js.map +1 -0
  441. package/lib/packlets/resource-types/config/json.d.ts.map +1 -0
  442. package/lib/packlets/resource-types/config/json.js.map +1 -0
  443. package/lib/packlets/resource-types/helpers.d.ts.map +1 -0
  444. package/lib/packlets/resource-types/helpers.js.map +1 -0
  445. package/lib/packlets/resource-types/index.d.ts.map +1 -0
  446. package/lib/packlets/resource-types/index.js.map +1 -0
  447. package/lib/packlets/resource-types/jsonResourceType.d.ts +17 -5
  448. package/lib/packlets/resource-types/jsonResourceType.d.ts.map +1 -0
  449. package/lib/packlets/resource-types/jsonResourceType.js +2 -2
  450. package/lib/packlets/resource-types/jsonResourceType.js.map +1 -0
  451. package/lib/packlets/resource-types/resourceType.d.ts +5 -5
  452. package/lib/packlets/resource-types/resourceType.d.ts.map +1 -0
  453. package/lib/packlets/resource-types/resourceType.js +2 -2
  454. package/lib/packlets/resource-types/resourceType.js.map +1 -0
  455. package/lib/packlets/resource-types/resourceTypeCollector.d.ts.map +1 -0
  456. package/lib/packlets/resource-types/resourceTypeCollector.js.map +1 -0
  457. package/lib/packlets/resources/candidateReducer.d.ts.map +1 -0
  458. package/lib/packlets/resources/candidateReducer.js.map +1 -0
  459. package/lib/packlets/resources/candidateValue.d.ts.map +1 -0
  460. package/lib/packlets/resources/candidateValue.js.map +1 -0
  461. package/lib/packlets/resources/candidateValueCollector.d.ts.map +1 -0
  462. package/lib/packlets/resources/candidateValueCollector.js.map +1 -0
  463. package/lib/packlets/resources/common.d.ts.map +1 -0
  464. package/lib/packlets/resources/common.js.map +1 -0
  465. package/lib/packlets/resources/deltaGenerator.d.ts.map +1 -0
  466. package/lib/packlets/resources/deltaGenerator.js.map +1 -0
  467. package/lib/packlets/resources/index.d.ts.map +1 -0
  468. package/lib/packlets/resources/index.js.map +1 -0
  469. package/lib/packlets/resources/resource.d.ts.map +1 -0
  470. package/lib/packlets/resources/resource.js.map +1 -0
  471. package/lib/packlets/resources/resourceBuilder.d.ts +2 -2
  472. package/lib/packlets/resources/resourceBuilder.d.ts.map +1 -0
  473. package/lib/packlets/resources/resourceBuilder.js +2 -2
  474. package/lib/packlets/resources/resourceBuilder.js.map +1 -0
  475. package/lib/packlets/resources/resourceCandidate.d.ts.map +1 -0
  476. package/lib/packlets/resources/resourceCandidate.js.map +1 -0
  477. package/lib/packlets/resources/resourceManagerBuilder.d.ts +5 -5
  478. package/lib/packlets/resources/resourceManagerBuilder.d.ts.map +1 -0
  479. package/lib/packlets/resources/resourceManagerBuilder.js +5 -5
  480. package/lib/packlets/resources/resourceManagerBuilder.js.map +1 -0
  481. package/lib/packlets/runtime/cacheListener.d.ts.map +1 -0
  482. package/lib/packlets/runtime/cacheListener.js.map +1 -0
  483. package/lib/packlets/runtime/cacheMetrics.d.ts.map +1 -0
  484. package/lib/packlets/runtime/cacheMetrics.js.map +1 -0
  485. package/lib/packlets/runtime/compiledResourceCollection.d.ts +5 -5
  486. package/lib/packlets/runtime/compiledResourceCollection.d.ts.map +1 -0
  487. package/lib/packlets/runtime/compiledResourceCollection.js +5 -5
  488. package/lib/packlets/runtime/compiledResourceCollection.js.map +1 -0
  489. package/lib/packlets/runtime/conditionSetResolutionResult.d.ts.map +1 -0
  490. package/lib/packlets/runtime/conditionSetResolutionResult.js.map +1 -0
  491. package/lib/packlets/runtime/context/contextQualifierProvider.d.ts.map +1 -0
  492. package/lib/packlets/runtime/context/contextQualifierProvider.js.map +1 -0
  493. package/lib/packlets/runtime/context/contextQualifierProviderValidator.d.ts.map +1 -0
  494. package/lib/packlets/runtime/context/contextQualifierProviderValidator.js.map +1 -0
  495. package/lib/packlets/runtime/context/index.d.ts.map +1 -0
  496. package/lib/packlets/runtime/context/index.js.map +1 -0
  497. package/lib/packlets/runtime/context/simpleContextQualifierProvider.d.ts +9 -2
  498. package/lib/packlets/runtime/context/simpleContextQualifierProvider.d.ts.map +1 -0
  499. package/lib/packlets/runtime/context/simpleContextQualifierProvider.js +3 -0
  500. package/lib/packlets/runtime/context/simpleContextQualifierProvider.js.map +1 -0
  501. package/lib/packlets/runtime/context/validatingSimpleContextQualifierProvider.d.ts +8 -1
  502. package/lib/packlets/runtime/context/validatingSimpleContextQualifierProvider.d.ts.map +1 -0
  503. package/lib/packlets/runtime/context/validatingSimpleContextQualifierProvider.js +3 -5
  504. package/lib/packlets/runtime/context/validatingSimpleContextQualifierProvider.js.map +1 -0
  505. package/lib/packlets/runtime/iResourceManager.d.ts.map +1 -0
  506. package/lib/packlets/runtime/iResourceManager.js.map +1 -0
  507. package/lib/packlets/runtime/index.d.ts.map +1 -0
  508. package/lib/packlets/runtime/index.js.map +1 -0
  509. package/lib/packlets/runtime/resource-tree/common.d.ts.map +1 -0
  510. package/lib/packlets/runtime/resource-tree/common.js.map +1 -0
  511. package/lib/packlets/runtime/resource-tree/index.d.ts.map +1 -0
  512. package/lib/packlets/runtime/resource-tree/index.js.map +1 -0
  513. package/lib/packlets/runtime/resource-tree/readOnlyResourceTree.d.ts.map +1 -0
  514. package/lib/packlets/runtime/resource-tree/readOnlyResourceTree.js.map +1 -0
  515. package/lib/packlets/runtime/resource-tree/resourceTreeChildren.d.ts.map +1 -0
  516. package/lib/packlets/runtime/resource-tree/resourceTreeChildren.js.map +1 -0
  517. package/lib/packlets/runtime/resource-tree/resourceTreeChildrenValidator.d.ts.map +1 -0
  518. package/lib/packlets/runtime/resource-tree/resourceTreeChildrenValidator.js.map +1 -0
  519. package/lib/packlets/runtime/resourceResolver.d.ts.map +1 -0
  520. package/lib/packlets/runtime/resourceResolver.js.map +1 -0
  521. package/lib/packlets/runtime/resourceTreeResolver.d.ts.map +1 -0
  522. package/lib/packlets/runtime/resourceTreeResolver.js.map +1 -0
  523. package/lib/packlets/runtime/validate.d.ts.map +1 -0
  524. package/lib/packlets/runtime/validate.js.map +1 -0
  525. package/lib/packlets/zip-archive/convert.d.ts.map +1 -0
  526. package/lib/packlets/zip-archive/convert.js.map +1 -0
  527. package/lib/packlets/zip-archive/index.browser.d.ts.map +1 -0
  528. package/lib/packlets/zip-archive/index.browser.js.map +1 -0
  529. package/lib/packlets/zip-archive/index.d.ts.map +1 -0
  530. package/lib/packlets/zip-archive/index.js.map +1 -0
  531. package/lib/packlets/zip-archive/json.d.ts.map +1 -0
  532. package/lib/packlets/zip-archive/json.js.map +1 -0
  533. package/lib/packlets/zip-archive/types.d.ts.map +1 -0
  534. package/lib/packlets/zip-archive/types.js.map +1 -0
  535. package/lib/packlets/zip-archive/zipArchiveCreator.d.ts.map +1 -0
  536. package/lib/packlets/zip-archive/zipArchiveCreator.js.map +1 -0
  537. package/lib/packlets/zip-archive/zipArchiveFormat.d.ts.map +1 -0
  538. package/lib/packlets/zip-archive/zipArchiveFormat.js.map +1 -0
  539. package/lib/packlets/zip-archive/zipArchiveLoader.d.ts.map +1 -0
  540. package/lib/packlets/zip-archive/zipArchiveLoader.js.map +1 -0
  541. package/package.json +12 -10
  542. package/dist/test/data/sample.json +0 -32
  543. package/dist/test/unit/qualifier-types/testQualifierType.js +0 -76
  544. package/dist/test/unit/resource-types/testDerivedResourceType.js +0 -109
  545. package/dist/test/unit/resources/deltaGenerator.helpers.js +0 -282
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readOnlyResourceTree.js","sourceRoot":"","sources":["../../../../src/packlets/runtime/resource-tree/readOnlyResourceTree.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,iBAAiB,EAAU,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC9F,OAAO,EAA4B,OAAO,EAAE,MAAM,cAAc,CAAC;AAQjE,OAAO,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;AAgCtE,cAAc;AACd;;;;;GAKG;AACH,MAAM,UAAU,4BAA4B,CAC1C,IAAwD;IAExD,OAAO,UAAU,IAAI,IAAI,CAAC;AAC5B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAI,IAA6B;IACrE,OAAO,UAAU,IAAI,IAAI,IAAI,CAAC,CAAC,UAAU,IAAI,IAAI,CAAC,CAAC;AACrD,CAAC;AAED;;;;GAIG;AACH,MAAM,OAAO,wBAAwB;IAKnC,IAAW,MAAM;QACf,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAW,QAAQ;QACjB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAW,MAAM;QACf,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACH,YAAsB,IAAkB,EAAE,UAAkC,EAAE,QAAW;QACvF,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,EAAE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\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { MessageAggregator, Result, captureResult, mapResults, succeed } from '@fgv/ts-utils';\nimport { ResourceId, ResourceName, Helpers } from '../../common';\nimport {\n IReadOnlyResourceTreeNode,\n IReadOnlyResourceTreeLeaf,\n IReadOnlyResourceTreeBranch,\n IReadOnlyResourceTreeRoot,\n IReadOnlyValidatingResourceTreeChildren\n} from './common';\nimport { ReadOnlyResourceTreeChildren } from './resourceTreeChildren';\n\n/**\n * Interface for initializing a resource tree root with child nodes.\n * @public\n */\nexport interface IResourceTreeRootInit<T> {\n readonly children: Record<ResourceName, ResourceTreeNodeInit<T>>;\n}\n\n/**\n * Interface for initializing a leaf node with a resource value.\n * @public\n */\nexport interface IResourceTreeLeafInit<T> {\n readonly resource: T;\n}\n\n/**\n * Interface for initializing a branch node with child nodes.\n * @public\n */\nexport interface IResourceTreeBranchInit<T> {\n readonly children: Record<ResourceName, ResourceTreeNodeInit<T>>;\n}\n\n/**\n * Union type for tree node initialization data.\n * @public\n */\nexport type ResourceTreeNodeInit<T> = IResourceTreeLeafInit<T> | IResourceTreeBranchInit<T>;\n\n// Type guards\n/**\n * Type guard to determine if an init object represents a branch or root with children.\n * @param init - The initialization object to test\n * @returns True if the init object has children property\n * @public\n */\nexport function isResourceTreeRootOrNodeInit<T>(\n init: ResourceTreeNodeInit<T> | IResourceTreeRootInit<T>\n): init is IResourceTreeBranchInit<T> {\n return 'children' in init;\n}\n\n/**\n * Type guard to determine if an init object represents a leaf node with a resource.\n * @param init - The initialization object to test\n * @returns True if the init object has a resource but no children\n * @public\n */\nexport function isResourceTreeLeafInit<T>(init: ResourceTreeNodeInit<T>): init is IResourceTreeLeafInit<T> {\n return 'resource' in init && !('children' in init);\n}\n\n/**\n * Implementation of a read-only resource tree leaf node that contains a resource value.\n * Leaf nodes represent the actual resources in the tree and cannot have children.\n * @public\n */\nexport class ReadOnlyResourceTreeLeaf<T> implements IReadOnlyResourceTreeLeaf<T> {\n public readonly name: ResourceName;\n public readonly id: ResourceId;\n public readonly resource: T;\n\n public get isRoot(): false {\n return false;\n }\n\n public get isBranch(): false {\n return false;\n }\n\n public get isLeaf(): true {\n return true;\n }\n\n /**\n * Creates a new leaf node. Use the static create method instead.\n * @param name - The name of this node (last segment of the path)\n * @param parentPath - The path to the parent node (undefined for root-level nodes)\n * @param resource - The resource value stored in this leaf\n */\n protected constructor(name: ResourceName, parentPath: ResourceId | undefined, resource: T) {\n this.name = name;\n this.id = Helpers.joinResourceIds(parentPath, name).orThrow();\n this.resource = resource;\n }\n\n /**\n * Creates a new ReadOnlyResourceTreeLeaf instance.\n * @param name - The name of this node (last segment of the path)\n * @param parentPath - The path to the parent node (undefined for root-level nodes)\n * @param resource - The resource value to store in this leaf\n * @returns Result containing the new leaf node or failure if construction fails\n */\n public static create<T>(\n name: ResourceName,\n parentPath: ResourceId | undefined,\n resource: T\n ): Result<ReadOnlyResourceTreeLeaf<T>> {\n return captureResult(() => new ReadOnlyResourceTreeLeaf(name, parentPath, resource));\n }\n}\n\n/**\n * Implementation of a read-only resource tree branch node that contains child nodes.\n * Branch nodes organize other nodes in a hierarchical structure and may optionally contain a resource value.\n * @public\n */\nexport class ReadOnlyResourceTreeBranch<T> implements IReadOnlyResourceTreeBranch<T> {\n public readonly children: IReadOnlyValidatingResourceTreeChildren<T>;\n public readonly name: ResourceName;\n public readonly id: ResourceId;\n\n public get isRoot(): false {\n return false;\n }\n\n public get isBranch(): true {\n return true;\n }\n\n public get isLeaf(): false {\n return false;\n }\n\n /**\n * Creates a new branch node. Use the static create method instead.\n * @param name - The name of this node (last segment of the path)\n * @param parentPath - The path to the parent node (undefined for root-level nodes)\n * @param init - Initialization data containing child nodes\n */\n private constructor(\n name: ResourceName,\n parentPath: ResourceId | undefined,\n init: IResourceTreeBranchInit<T>\n ) {\n this.name = name;\n this.id = Helpers.joinResourceIds(parentPath, name).orThrow();\n\n const children = mapResults<IReadOnlyResourceTreeNode<T>>(\n (\n Array.from(Object.entries(init.children)) as [\n ResourceName,\n IResourceTreeBranchInit<T> | IResourceTreeLeafInit<T>\n ][]\n ).map(([childName, childInit]) => {\n if (isResourceTreeLeafInit(childInit)) {\n return ReadOnlyResourceTreeLeaf.create(childName, this.id, childInit.resource);\n }\n return ReadOnlyResourceTreeBranch.create(childName, this.id, childInit);\n })\n ).orThrow();\n\n this.children = new ReadOnlyResourceTreeChildren(\n this.id,\n children.map((c): [ResourceName, IReadOnlyResourceTreeNode<T>] => [c.name, c])\n );\n }\n\n /**\n * Creates a new ReadOnlyResourceTreeBranch instance.\n * @param childName - The name of this node (last segment of the path)\n * @param path - The path to the parent node (undefined for root-level nodes)\n * @param childInit - Initialization data containing child nodes\n * @returns Result containing the new branch node or failure if construction fails\n */\n public static create<T>(\n childName: ResourceName,\n path: ResourceId | undefined,\n childInit: IResourceTreeBranchInit<T>\n ): Result<ReadOnlyResourceTreeBranch<T>> {\n return captureResult(() => new ReadOnlyResourceTreeBranch(childName, path, childInit));\n }\n}\n\n/**\n * Union type representing any node in a read-only resource tree.\n * @public\n */\nexport type ReadOnlyResourceTreeNode<T> = ReadOnlyResourceTreeBranch<T> | ReadOnlyResourceTreeLeaf<T>;\n\n/**\n * Implementation of a read-only resource tree root that organizes resources hierarchically.\n * The root provides the entry point for tree navigation and resource access by ResourceId paths.\n * @public\n */\nexport class ReadOnlyResourceTreeRoot<T> implements IReadOnlyResourceTreeRoot<T> {\n public readonly children: IReadOnlyValidatingResourceTreeChildren<T>;\n\n public get isRoot(): true {\n return true;\n }\n\n public get isBranch(): false {\n return false;\n }\n\n public get isLeaf(): false {\n return false;\n }\n\n /**\n * Creates a new root node. Use the static create method instead.\n * @param init - Initialization data containing child nodes\n */\n protected constructor(init: IResourceTreeRootInit<T>) {\n const children = mapResults<ReadOnlyResourceTreeBranch<T> | ReadOnlyResourceTreeLeaf<T>>(\n (\n Array.from(Object.entries(init.children)) as [\n ResourceName,\n IResourceTreeBranchInit<T> | IResourceTreeLeafInit<T>\n ][]\n ).map(([childName, childInit]) => {\n if (isResourceTreeLeafInit(childInit)) {\n return ReadOnlyResourceTreeLeaf.create(childName, undefined, childInit.resource);\n }\n return ReadOnlyResourceTreeBranch.create(childName, undefined, childInit);\n })\n ).orThrow();\n\n this.children = new ReadOnlyResourceTreeChildren(\n undefined,\n children.map((c): [ResourceName, IReadOnlyResourceTreeNode<T>] => [c.name, c])\n );\n }\n\n /**\n * Creates a new ReadOnlyResourceTreeRoot from an array of resources.\n * @param resources - Array of [ResourceId, resource] pairs to build the tree from\n * @returns Result containing the new root or failure if construction fails\n */\n public static create<T>(resources: [ResourceId, T][]): Result<ReadOnlyResourceTreeRoot<T>>;\n\n /**\n * Creates a new ReadOnlyResourceTreeRoot from initialization data.\n * @param init - Tree initialization structure\n * @returns Result containing the new root or failure if construction fails\n */\n public static create<T>(init: IResourceTreeRootInit<T>): Result<ReadOnlyResourceTreeRoot<T>>;\n\n /**\n * Creates a new ReadOnlyResourceTreeRoot from either resources or initialization data.\n * @param init - Either an array of [ResourceId, resource] pairs or tree initialization structure\n * @returns Result containing the new root or failure if construction fails\n */\n public static create<T>(\n init: IResourceTreeRootInit<T> | [ResourceId, T][]\n ): Result<ReadOnlyResourceTreeRoot<T>> {\n if (Array.isArray(init)) {\n return ReadOnlyResourceTreeRoot.createResourceTreeInit(init).onSuccess((treeInit) =>\n captureResult(() => new ReadOnlyResourceTreeRoot(treeInit))\n );\n }\n return captureResult(() => new ReadOnlyResourceTreeRoot(init));\n }\n\n /**\n * Converts an array of resources into tree initialization data.\n * Validates that resource paths do not conflict - if a path has child resources,\n * it cannot itself be a resource (e.g., if 'app.messages.welcome' exists, then 'app' cannot be a resource).\n * @param resources - Array of [ResourceId, resource] pairs to convert\n * @returns Result containing the initialization structure or failure if validation fails\n */\n public static createResourceTreeInit<T>(resources: [ResourceId, T][]): Result<IResourceTreeRootInit<T>> {\n const errors: MessageAggregator = new MessageAggregator();\n const root: IResourceTreeRootInit<T> = { children: {} };\n\n for (const [id, resource] of resources) {\n Helpers.splitResourceId(id)\n .onSuccess((pathComponents) => {\n let currentNode: IResourceTreeBranchInit<T> | IResourceTreeRootInit<T> = root;\n const resourceName = pathComponents.pop()!;\n\n for (const nodeName of pathComponents) {\n if (isResourceTreeRootOrNodeInit(currentNode)) {\n if (!(nodeName in currentNode.children)) {\n currentNode.children[nodeName] = { children: {} };\n }\n if (isResourceTreeLeafInit(currentNode.children[nodeName])) {\n errors.addMessage(`${id}: Expected a branch but found a leaf at ${nodeName}.`);\n } else {\n currentNode = currentNode.children[nodeName];\n }\n } /* c8 ignore next 4 - defense in depth, not reachable without chicanery */ else if (\n isResourceTreeLeafInit(currentNode)\n ) {\n errors.addMessage(`${id}: Expected a branch but found a leaf.`);\n break;\n } /* c8 ignore next 3 - defense in depth, not reachable without chicanery */ else {\n errors.addMessage(`${id}: Unexpected structure in resource tree`);\n }\n }\n\n if (isResourceTreeRootOrNodeInit(currentNode)) {\n if (resourceName in currentNode.children) {\n errors.addMessage(`${id}: Duplicate resource at path.`);\n } else {\n currentNode.children[resourceName] = { resource };\n } /* c8 ignore next 3 - defense in depth, not reachable without chicanery */\n } else {\n errors.addMessage(`${id}: Expected a branch but found a leaf.`);\n }\n return succeed(currentNode.children[resourceName]);\n })\n .aggregateError(errors);\n }\n return errors.returnOrReport(succeed(root));\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resourceTreeChildren.js","sourceRoot":"","sources":["../../../../src/packlets/runtime/resource-tree/resourceTreeChildren.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAuB,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC9E,OAAO,EAA4B,OAAO,EAAE,MAAM,cAAc,CAAC;AAQjE,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAEhF;;;;GAIG;AACH,MAAM,OAAO,4BACX,SAAQ,SAAqD;IAM7D;;;;OAIG;IACH,YAAmB,IAA4B,EAAE,OAAuD;QACtG,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,IAAI,6BAA6B,CAAI,IAAI,CAAC,CAAC;IAC/D,CAAC;IAEM,WAAW,CAAC,IAAkB;QACnC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE;YACvC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;gBAChB,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,UAAU,CAAoC,SAAS,CAAC,CAAC;YAChF,CAAC;YACD,kFAAkF;YAClF,OAAO,IAAI,CACT,GAAG,IAAI,mBAAmB,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,CACjE,CAAC,UAAU,CAAoC,SAAS,CAAC,CAAC;QAC7D,CAAC,CAAC,CAAC;IACL,CAAC;IAEM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*\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Collections, Result, ResultMap, fail, succeed } from '@fgv/ts-utils';\nimport { ResourceId, ResourceName, Helpers } from '../../common';\nimport {\n IReadOnlyResourceTreeBranch,\n IReadOnlyResourceTreeChildren,\n IReadOnlyResourceTreeLeaf,\n IReadOnlyResourceTreeNode,\n IReadOnlyValidatingResourceTreeChildren\n} from './common';\nimport { ResourceTreeChildrenValidator } from './resourceTreeChildrenValidator';\n\n/**\n * Implementation of a result-based resource tree that provides hierarchical access to resources.\n * Extends ResultMap to provide collection-like access while adding tree-specific navigation methods.\n * @public\n */\nexport class ReadOnlyResourceTreeChildren<T>\n extends ResultMap<ResourceName, IReadOnlyResourceTreeNode<T>>\n implements IReadOnlyValidatingResourceTreeChildren<T>\n{\n protected path: ResourceId | undefined;\n public validating: IReadOnlyResourceTreeChildren<T, string, string>;\n\n /**\n * Creates a new ReadOnlyResourceTreeChildren instance.\n * @param path - The path to this tree node (undefined for root)\n * @param entries - Array of [name, node] tuples to populate the tree\n */\n public constructor(path: ResourceId | undefined, entries: [ResourceName, IReadOnlyResourceTreeNode<T>][]) {\n super(entries);\n this.path = path;\n this.validating = new ResourceTreeChildrenValidator<T>(this);\n }\n\n public getResource(name: ResourceName): Result<IReadOnlyResourceTreeNode<T>> {\n return this.get(name).onSuccess((node) => {\n if (node.isLeaf) {\n return succeed(node).withDetail<Collections.ResultMapResultDetail>('success');\n }\n /* c8 ignore next 3 - functional code tested but coverage intermittently missed */\n return fail<IReadOnlyResourceTreeNode<T>>(\n `${name}: not a resource${this.path ? ` in ${this.path}` : ''}.`\n ).withDetail<Collections.ResultMapResultDetail>('failure');\n });\n }\n\n public getBranch(name: ResourceName): Result<IReadOnlyResourceTreeNode<T>> {\n return this.get(name).onSuccess((node) => {\n if (node.isBranch) {\n return succeed(node).withDetail<Collections.ResultMapResultDetail>('success');\n }\n /* c8 ignore next 3 - functional code tested but coverage intermittently missed */\n return fail<IReadOnlyResourceTreeNode<T>>(\n `${name}: not a branch${this.path ? ` in ${this.path}` : ''}.`\n ).withDetail<Collections.ResultMapResultDetail>('failure');\n });\n }\n\n public getById(id: ResourceId): Result<IReadOnlyResourceTreeNode<T>> {\n return Helpers.splitResourceId(id).onSuccess((names) => {\n let name = names.shift();\n if (name !== undefined) {\n let node = this.get(name).orDefault();\n while (node) {\n name = names.shift();\n if (name === undefined) {\n return succeed(node);\n }\n if (node.isLeaf) {\n /* c8 ignore next 1 - defense in depth */\n return fail(`${id}: resource not found${this.path ? ` in ${this.path}` : ''}.`);\n }\n node = (node as IReadOnlyResourceTreeBranch<T>).children.get(name).orDefault();\n }\n }\n return fail(`${id}: resource not found${this.path ? ` in ${this.path}` : ''}.`);\n });\n }\n\n public getResourceById(id: ResourceId): Result<IReadOnlyResourceTreeLeaf<T>> {\n return this.getById(id).onSuccess((node) => {\n if (node.isLeaf) {\n return succeed(node as IReadOnlyResourceTreeLeaf<T>).withDetail<Collections.ResultMapResultDetail>(\n 'success'\n );\n }\n return fail<IReadOnlyResourceTreeLeaf<T>>(\n `${id}: not a resource${this.path ? ` in ${this.path}` : ''}.`\n ).withDetail<Collections.ResultMapResultDetail>('failure');\n });\n }\n\n public getBranchById(id: ResourceId): Result<IReadOnlyResourceTreeBranch<T>> {\n return this.getById(id).onSuccess((node) => {\n if (node.isBranch) {\n return succeed(node as IReadOnlyResourceTreeBranch<T>).withDetail<Collections.ResultMapResultDetail>(\n 'success'\n );\n }\n /* c8 ignore next 3 - functional code tested but coverage intermittently missed */\n return fail<IReadOnlyResourceTreeBranch<T>>(\n `${id}: not a branch${this.path ? ` in ${this.path}` : ''}.`\n ).withDetail<Collections.ResultMapResultDetail>('failure');\n });\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resourceTreeChildrenValidator.js","sourceRoot":"","sources":["../../../../src/packlets/runtime/resource-tree/resourceTreeChildrenValidator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAA2D,cAAc,EAAE,MAAM,eAAe,CAAC;AASxG;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,6BAA6B;IAGxC;;;OAGG;IACH,YAAmB,KAAuC;QACxD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED;;;;OAIG;IACI,OAAO,CAAC,EAAU;QACvB,OAAO,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,UAAU,EAAE,EAAE;YACxD,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QACzC,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACI,WAAW,CAAC,IAAY;QAC7B,OAAO,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,YAAY,EAAE,EAAE;YAC9D,OAAO,IAAI,CAAC,MAAM,CAAC,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ACpB,IAAI,QAAQ,CAAC,mBAAmB,CAAC,GAAG,CAAC,EAAE,CAAC;YACtC,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC9B,CAAC;QACD,OAAO,cAAc,CAAC,GAAG,GAAG,0BAA0B,EAAE,aAAa,CAAC,CAAC;IACzE,CAAC;IAED;;;;OAIG;IACI,GAAG,CAAC,GAAW;QACpB,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAmB,CAAC,CAAC;IAC9C,CAAC;IAED;;;OAGG;IACI,IAAI;QACT,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACI,MAAM;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;IAC9B,CAAC;IAED;;;OAGG;IACI,CAAC,MAAM,CAAC,QAAQ,CAAC;QACtB,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;IACxC,CAAC;CACF","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 { Validate } from '../../common';\nimport { Result, IReadOnlyResultMap, DetailedResult, Collections, failWithDetail } from '@fgv/ts-utils';\nimport { ResourceName } from '../../common';\nimport {\n IReadOnlyResourceTreeBranch,\n IReadOnlyResourceTreeChildren,\n IReadOnlyResourceTreeLeaf,\n IReadOnlyResourceTreeNode\n} from './common';\n\n/**\n * A validator wrapper for resource tree children that validates string inputs before\n * delegating to the underlying tree children collection.\n *\n * This class implements {@link Runtime.ResourceTree.IReadOnlyValidatingResourceTreeChildren | IReadOnlyValidatingResourceTreeChildren}\n * by wrapping an {@link Runtime.ResourceTree.IReadOnlyResourceTreeChildren | IReadOnlyResourceTreeChildren} instance and\n * providing string-based access to all tree operations. All string inputs are validated using the library's\n * validation utilities before being passed to the underlying collection.\n *\n * The validator acts as a bridge between string-based external APIs and the\n * strongly-typed internal tree operations, ensuring type safety and consistent\n * error handling throughout the resource tree navigation.\n *\n * @public\n */\nexport class ResourceTreeChildrenValidator<T> implements IReadOnlyResourceTreeChildren<T, string, string> {\n private readonly _inner: IReadOnlyResourceTreeChildren<T>;\n\n /**\n * Creates a new validator wrapper for resource tree children.\n * @param inner - The underlying resource tree children collection to wrap with validation\n */\n public constructor(inner: IReadOnlyResourceTreeChildren<T>) {\n this._inner = inner;\n }\n\n /**\n * Gets a tree node by its string ResourceId path, validating the input.\n * @param id - The string ResourceId path to validate and look up\n * @returns Result containing the node if found, or failure if validation fails or not found\n */\n public getById(id: string): Result<IReadOnlyResourceTreeNode<T>> {\n return Validate.toResourceId(id).onSuccess((resourceId) => {\n return this._inner.getById(resourceId);\n });\n }\n\n /**\n * Gets a resource node by its string name (single component), validating the input.\n * @param name - The string ResourceName to validate and look up\n * @returns Result containing the node if it's a resource, or failure if validation fails or not found\n */\n public getResource(name: string): Result<IReadOnlyResourceTreeNode<T>> {\n return Validate.toResourceName(name).onSuccess((resourceName) => {\n return this._inner.getResource(resourceName);\n });\n }\n\n /**\n * Gets a branch node by its string name (single component), validating the input.\n * @param name - The string ResourceName to validate and look up\n * @returns Result containing the node if it's a branch, or failure if validation fails or not found\n */\n public getBranch(name: string): Result<IReadOnlyResourceTreeNode<T>> {\n return Validate.toResourceName(name).onSuccess((resourceName) => {\n return this._inner.getBranch(resourceName);\n });\n }\n\n /**\n * Gets a resource leaf node by its string ResourceId path, validating the input.\n * @param id - The string ResourceId path to validate and look up\n * @returns Result containing the leaf if found and is a resource, or failure otherwise\n */\n public getResourceById(id: string): Result<IReadOnlyResourceTreeLeaf<T>> {\n return Validate.toResourceId(id).onSuccess((resourceId) => {\n return this._inner.getResourceById(resourceId);\n });\n }\n\n /**\n * Gets a branch node by its string ResourceId path, validating the input.\n * @param id - The string ResourceId path to validate and look up\n * @returns Result containing the branch if found and has children, or failure otherwise\n */\n public getBranchById(id: string): Result<IReadOnlyResourceTreeBranch<T>> {\n return Validate.toResourceId(id).onSuccess((resourceId) => {\n return this._inner.getBranchById(resourceId);\n });\n }\n\n /**\n * The number of direct child nodes in this collection.\n */\n public get size(): number {\n return this._inner.size;\n }\n\n /**\n * Returns an iterator of [ResourceName, node] pairs for all child nodes.\n * @returns Map iterator for all child nodes\n */\n public entries(): IterableIterator<[ResourceName, IReadOnlyResourceTreeNode<T>]> {\n return this._inner.entries();\n }\n\n /**\n * Executes a callback function for each child node in the collection.\n * @param cb - The callback function to execute for each child node\n * @param arg - Optional argument to pass to the callback\n */\n public forEach(\n cb: (value: unknown, key: string, map: IReadOnlyResultMap<string, unknown>, thisArg?: unknown) => void,\n arg?: unknown\n ): void {\n for (const [key, value] of this._inner.entries()) {\n cb(value, key as ResourceName, this, arg);\n }\n }\n\n /**\n * Gets a child node by its string key with detailed error information.\n * @param key - The string key to look up\n * @returns DetailedResult containing the node if found, or failure with details\n */\n public get(key: string): DetailedResult<IReadOnlyResourceTreeNode<T>, Collections.ResultMapResultDetail> {\n if (Validate.isValidResourceName(key)) {\n return this._inner.get(key);\n }\n return failWithDetail(`${key}: invalid resource name.`, 'invalid-key');\n }\n\n /**\n * Checks if a child node exists at the given string key.\n * @param key - The string key to check\n * @returns True if a child node exists at the key, false otherwise\n */\n public has(key: string): boolean {\n return this._inner.has(key as ResourceName);\n }\n\n /**\n * Returns an iterator of ResourceName keys for all child nodes.\n * @returns Map iterator for all child node keys\n */\n public keys(): IterableIterator<ResourceName> {\n return this._inner.keys();\n }\n\n /**\n * Returns an iterator of child node values.\n * @returns Map iterator for all child node values\n */\n public values(): IterableIterator<IReadOnlyResourceTreeNode<T>> {\n return this._inner.values();\n }\n\n /**\n * Returns an iterator for [ResourceName, node] pairs, enabling for...of iteration.\n * @returns Iterable iterator for all child nodes\n */\n public [Symbol.iterator](): IterableIterator<[ResourceName, IReadOnlyResourceTreeNode<T>]> {\n return this._inner[Symbol.iterator]();\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resourceResolver.js","sourceRoot":"","sources":["../../../src/packlets/runtime/resourceResolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAU,aAAa,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EAAyB,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAqB,OAAO,EAAc,MAAM,WAAW,CAAC;AAInE,OAAO,EAA6B,wCAAwC,EAAE,MAAM,WAAW,CAAC;AAEhG,OAAO,EAEL,4BAA4B,EAE7B,MAAM,gCAAgC,CAAC;AA8DxC;;;;;GAKG;AACH,MAAM,OAAO,gBAAgB;IAqB3B;;OAEG;IACH,IAAW,UAAU;QACnB,OAAO,IAAI,CAAC,wBAAwB,CAAC,UAAU,CAAC;IAClD,CAAC;IAED;;OAEG;IACH,IAAW,WAAW;QACpB,OAAO,IAA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AAC,SAAS,0CAAE,YAAY,CAAC,UAAU,CAAC,CAAC;IAC3C,CAAC;IAED;;;;OAIG;IACH,IAAW,kBAAkB;QAC3B,OAAO,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC;IACrC,CAAC;IAED;;;;OAIG;IACH,IAAW,qBAAqB;QAC9B,OAAO,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC;IACxC,CAAC;IAED;;;;OAIG;IACH,IAAW,iBAAiB;QAC1B,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC;IACpC,CAAC;CACF","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 { Result, captureResult, fail, succeed } from '@fgv/ts-utils';\nimport { JsonValue, JsonObject, isJsonObject } from '@fgv/ts-json-base';\nimport { JsonEditor } from '@fgv/ts-json';\nimport { IResourceResolver, NoMatch, ResourceId } from '../common';\nimport { Condition, ConditionSet } from '../conditions';\nimport { AbstractDecision } from '../decisions';\nimport { ReadOnlyQualifierTypeCollector } from '../qualifier-types';\nimport { IContextQualifierProvider, ValidatingSimpleContextQualifierProvider } from './context';\nimport { IResourceManager, IResource, IResourceCandidate } from './iResourceManager';\nimport {\n ConditionMatchType,\n ConditionSetResolutionResult,\n IConditionMatchResult\n} from './conditionSetResolutionResult';\nimport { IResourceResolverCacheListener } from './cacheListener';\nimport { IReadOnlyQualifierCollector } from '../qualifiers';\n\n/**\n * Represents the cached result of resolving a decision.\n * Contains either a failure indicator or a list of instance indices for matching condition sets,\n * ordered by condition set priority.\n * @public\n */\nexport type DecisionResolutionResult =\n | { success: false }\n | { success: true; instanceIndices: ReadonlyArray<number>; defaultInstanceIndices: ReadonlyArray<number> };\n\n/**\n * Options for configuring a {@link Runtime.ResourceResolver | ResourceResolver}.\n * @public\n */\nexport interface IResourceResolverOptions {\n /**\n * Controls whether null values in resource composition should suppress properties\n * instead of setting them to null. When true, properties with null values from\n * higher-priority partial candidates will be omitted from the final composed resource.\n * @defaultValue false\n */\n suppressNullAsDelete?: boolean;\n}\n\n/**\n * Parameters for creating a {@link Runtime.ResourceResolver | ResourceResolver}.\n * @public\n */\nexport interface IResourceResolverCreateParams {\n /**\n * The {@link Runtime.IResourceManager | resource manager} that defines the resources available\n * and provides access to qualifiers and conditions.\n */\n resourceManager: IResourceManager;\n\n /**\n * The {@link QualifierTypes.ReadOnlyQualifierTypeCollector | readonly qualifier type collector}\n * that provides qualifier implementations for condition evaluation.\n */\n qualifierTypes: ReadOnlyQualifierTypeCollector;\n\n /**\n * The {@link Runtime.Context.IContextQualifierProvider | context qualifier provider} that resolves\n * qualifier values for the current context.\n */\n contextQualifierProvider: IContextQualifierProvider;\n\n /**\n * An optional listener for {@link Runtime.ResourceResolver | ResourceResolver} cache activity.\n */\n listener?: IResourceResolverCacheListener;\n\n /**\n * Optional configuration options for the {@link Runtime.ResourceResolver | ResourceResolver}.\n */\n options?: IResourceResolverOptions;\n}\n\n/**\n * High-performance runtime resource resolver with O(1) condition caching.\n * Resolves resources for a given context by evaluating conditions against qualifier values\n * and caching results for optimal performance.\n * @public\n */\nexport class ResourceResolver implements IResourceResolver {\n /**\n * The resource manager that defines available resources and provides condition access.\n */\n public readonly resourceManager: IResourceManager;\n\n /**\n * The readonly qualifier type collector that provides qualifier implementations.\n */\n public readonly qualifierTypes: ReadOnlyQualifierTypeCollector;\n\n /**\n * The context qualifier provider that resolves qualifier values.\n */\n public readonly contextQualifierProvider: IContextQualifierProvider;\n\n /**\n * The configuration options for this resource resolver.\n */\n public readonly options: IResourceResolverOptions;\n\n /**\n * The readonly qualifier collector that provides qualifier implementations.\n */\n public get qualifiers(): IReadOnlyQualifierCollector {\n return this.contextQualifierProvider.qualifiers;\n }\n\n /**\n * The resource IDs that this resolver can resolve.\n */\n public get resourceIds(): ReadonlyArray<ResourceId> {\n return this.resourceManager.resourceIds;\n }\n\n /**\n * The cache array for resolved conditions, indexed by condition index for O(1) lookup.\n * Each entry stores the resolved {@link Runtime.IConditionMatchResult | condition match result} for\n * the corresponding condition.\n */\n public get conditionCache(): ReadonlyArray<IConditionMatchResult | undefined> {\n return this._conditionCache;\n }\n\n /**\n * The cache array for resolved condition sets, indexed by condition set index for O(1) lookup.\n * Each entry stores the resolved ConditionSetResolutionResult for the corresponding condition set.\n */\n public get conditionSetCache(): ReadonlyArray<ConditionSetResolutionResult | undefined> {\n return this._conditionSetCache;\n }\n\n /**\n * The cache array for resolved decisions, indexed by decision index for O(1) lookup.\n * Each entry stores the resolved DecisionResolutionResult for the corresponding decision.\n */\n public get decisionCache(): ReadonlyArray<DecisionResolutionResult | undefined> {\n return this._decisionCache;\n }\n\n /**\n * Cache array for resolved conditions, indexed by condition index for O(1) lookup.\n * Each entry stores the resolved QualifierMatchScore for the corresponding condition.\n */\n private readonly _conditionCache: Array<IConditionMatchResult | undefined>;\n\n /**\n * Cache array for resolved condition sets, indexed by condition set index for O(1) lookup.\n * Each entry stores the resolved ConditionSetResolutionResult for the corresponding condition set.\n */\n private readonly _conditionSetCache: Array<ConditionSetResolutionResult | undefined>;\n\n /**\n * Cache array for resolved decisions, indexed by decision index for O(1) lookup.\n * Each entry stores the resolved DecisionResolutionResult for the corresponding decision.\n */\n private readonly _decisionCache: Array<DecisionResolutionResult | undefined>;\n\n /**\n * The listener for {@link Runtime.ResourceResolver | ResourceResolver} cache activity.\n */\n private readonly _listener?: IResourceResolverCacheListener;\n\n /**\n * Constructor for a {@link Runtime.ResourceResolver | ResourceResolver} object.\n * @param params - {@link Runtime.IResourceResolverCreateParams | Parameters} used to create the resolver.\n */\n protected constructor(params: IResourceResolverCreateParams) {\n this.resourceManager = params.resourceManager;\n this.qualifierTypes = params.qualifierTypes;\n this.contextQualifierProvider = params.contextQualifierProvider;\n this.options = {\n suppressNullAsDelete: params.options?.suppressNullAsDelete ?? false\n };\n\n // Initialize condition cache array with size matching the condition collector\n const conditionCollectorSize = this.resourceManager.conditions.size;\n this._conditionCache = new Array<IConditionMatchResult | undefined>(conditionCollectorSize);\n\n // Initialize condition set cache array with size matching the condition set collector\n const conditionSetCollectorSize = this.resourceManager.conditionSets.size;\n this._conditionSetCache = new Array<ConditionSetResolutionResult | undefined>(conditionSetCollectorSize);\n\n // Initialize decision cache array with size matching the decision collector\n const decisionCollectorSize = this.resourceManager.decisions.size;\n this._decisionCache = new Array<DecisionResolutionResult | undefined>(decisionCollectorSize);\n\n this._listener = params.listener;\n }\n\n /**\n * Creates a new {@link Runtime.ResourceResolver | ResourceResolver} object.\n * @param params - {@link Runtime.IResourceResolverCreateParams | Parameters} used to create the resolver.\n * @returns `Success` with the new {@link Runtime.ResourceResolver | ResourceResolver} object if successful,\n * or `Failure` with an error message if not.\n * @public\n */\n public static create(params: IResourceResolverCreateParams): Result<ResourceResolver> {\n return captureResult(() => new ResourceResolver(params));\n }\n\n /**\n * Resolves a condition by evaluating it against the current context.\n * Uses O(1) caching based on the condition's globally unique sequential index.\n * @param condition - The {@link Conditions.Condition | condition} to resolve.\n * @returns `Success` with the {@link QualifierMatchScore | match score} if successful,\n * or `Failure` with an error message if the condition cannot be resolved.\n * @public\n */\n public resolveCondition(condition: Condition): Result<IConditionMatchResult> {\n // Get the condition's index for cache lookup\n const conditionIndex = condition.index;\n if (conditionIndex === undefined) {\n return fail(`Condition \"${condition.key}\" does not have a valid index`);\n }\n\n // Check cache first for O(1) lookup\n const cachedResult = this._conditionCache[conditionIndex];\n if (cachedResult !== undefined) {\n this._listener?.onCacheHit('condition', conditionIndex);\n return succeed(cachedResult);\n }\n\n // Resolve the condition by getting qualifier value and evaluating with qualifier type\n const score = this.contextQualifierProvider\n .get(condition.qualifier)\n .onSuccess((qualifierValue) => {\n // Evaluate the condition using the qualifier type's matching logic\n return succeed(condition.qualifier.type.matches(condition.value, qualifierValue, condition.operator));\n })\n .onFailure((err) => {\n this._listener?.onContextError(condition.qualifier.name, err);\n return fail(err);\n })\n .orDefault(NoMatch);\n\n const priority = condition.priority;\n const scoreAsDefault = condition.scoreAsDefault ?? NoMatch;\n const matchResult: IConditionMatchResult =\n score > NoMatch\n ? { score, priority, matchType: 'match' }\n : scoreAsDefault > NoMatch\n ? { score: scoreAsDefault, priority, matchType: 'matchAsDefault' }\n : { score: NoMatch, priority, matchType: 'noMatch' };\n\n // Cache the resolved value for future O(1) lookup\n this._conditionCache[conditionIndex] = matchResult;\n this._listener?.onCacheMiss('condition', conditionIndex);\n\n return succeed(matchResult);\n }\n\n /**\n * Resolves a condition set by evaluating all its constituent conditions against the current context.\n * Uses O(1) caching based on the condition set's globally unique sequential index.\n * @param conditionSet - The {@link Conditions.ConditionSet | condition set} to resolve.\n * @returns `Success` with the {@link Runtime.ConditionSetResolutionResult | resolution result} if successful,\n * or `Failure` with an error message if the condition set cannot be resolved.\n * @public\n */\n public resolveConditionSet(conditionSet: ConditionSet): Result<ConditionSetResolutionResult> {\n // Get the condition set's index for cache lookup\n const conditionSetIndex = conditionSet.index;\n if (conditionSetIndex === undefined) {\n return fail(`ConditionSet \"${conditionSet.key}\" does not have a valid index`);\n }\n\n // Check cache first for O(1) lookup\n const cachedResult = this._conditionSetCache[conditionSetIndex];\n if (cachedResult !== undefined) {\n this._listener?.onCacheHit('conditionSet', conditionSetIndex);\n return succeed(cachedResult);\n }\n\n // Resolve all conditions in the condition set\n const conditions: Array<IConditionMatchResult> = [];\n let matchType: ConditionMatchType = 'match';\n\n for (const condition of conditionSet.conditions) {\n const { value: conditionResult, message: conditionMessage } = this.resolveCondition(condition);\n\n /* c8 ignore next 4 - defensive coding: extreme internal error scenario not reachable in normal operation */\n if (conditionMessage !== undefined) {\n this._listener?.onCacheError('conditionSet', conditionSetIndex);\n return fail(`Failed to resolve condition \"${condition.key}\": ${conditionMessage}`);\n }\n\n conditions.push(conditionResult);\n\n if (conditionResult.matchType === 'noMatch') {\n // Cache the failure result\n return ConditionSetResolutionResult.create('noMatch', conditions)\n .onSuccess((result) => {\n this._conditionSetCache[conditionSetIndex] = result;\n this._listener?.onCacheMiss('conditionSet', conditionSetIndex);\n return succeed(result);\n })\n .onFailure((err) => {\n /* c8 ignore next 4 - defensive coding: extreme internal error scenario not reachable in normal operation */\n this._conditionSetCache[conditionSetIndex] = undefined;\n this._listener?.onCacheError('conditionSet', conditionSetIndex);\n return fail(`${conditionSetIndex}: error creating condition set resolution result: ${err}`);\n });\n }\n\n /* c8 ignore next 3 - edge case: matchAsDefault fallback logic rarely triggered */\n if (conditionResult.matchType === 'matchAsDefault') {\n matchType = 'matchAsDefault';\n }\n }\n\n // Cache the successful result\n return ConditionSetResolutionResult.create(matchType, conditions)\n .onSuccess((result) => {\n this._conditionSetCache[conditionSetIndex] = result;\n this._listener?.onCacheMiss('conditionSet', conditionSetIndex);\n return succeed(result);\n })\n .onFailure((err) => {\n /* c8 ignore next 4 - defensive coding: extreme internal error scenario not reachable in normal operation */\n this._conditionSetCache[conditionSetIndex] = undefined;\n this._listener?.onCacheError('conditionSet', conditionSetIndex);\n return fail(`${conditionSetIndex}: error creating condition set resolution result: ${err}`);\n });\n }\n\n /**\n * Resolves a decision by evaluating all its constituent condition sets against the current context.\n * Uses O(1) caching based on the decision's globally unique sequential index.\n * @param decision - The {@link Decisions.AbstractDecision | abstract decision} to resolve.\n * @returns `Success` with the {@link Runtime.DecisionResolutionResult | resolution result} if successful,\n * or `Failure` with an error message if the decision cannot be resolved.\n * @public\n */\n public resolveDecision(decision: AbstractDecision): Result<DecisionResolutionResult> {\n // Get the decision's index for cache lookup\n const decisionIndex = decision.index;\n if (decisionIndex === undefined) {\n return fail(`Decision \"${decision.key}\" does not have a valid index`);\n }\n\n // Check cache first for O(1) lookup\n const cachedResult = this._decisionCache[decisionIndex];\n if (cachedResult !== undefined) {\n this._listener?.onCacheHit('decision', decisionIndex);\n return succeed(cachedResult);\n }\n\n // Resolve all condition sets in the decision\n const matchingInstanceResults: Array<{ index: number; result: ConditionSetResolutionResult }> = [];\n const matchingDefaultInstanceResults: Array<{ index: number; result: ConditionSetResolutionResult }> = [];\n\n for (let instanceIndex = 0; instanceIndex < decision.candidates.length; instanceIndex++) {\n const candidate = decision.candidates[instanceIndex];\n const conditionSetResult = this.resolveConditionSet(candidate.conditionSet);\n\n /* c8 ignore next 4 - defensive in depth */\n if (conditionSetResult.isFailure()) {\n this._listener?.onCacheError('decision', decisionIndex);\n return fail(`${decision.key}: Failed to resolve condition set\": ${conditionSetResult.message}`);\n }\n\n const resolution = conditionSetResult.value;\n\n // Only include condition sets that match\n if (resolution.matchType === 'match') {\n matchingInstanceResults.push({\n index: instanceIndex,\n result: resolution\n });\n } else if (resolution.matchType === 'matchAsDefault') {\n matchingDefaultInstanceResults.push({\n index: instanceIndex,\n result: resolution\n });\n }\n // If condition set doesn't match, we simply skip it and continue (don't fail the decision)\n }\n\n // Sort by condition set resolution priority using the proper comparison logic\n matchingInstanceResults.sort((a, b) => ConditionSetResolutionResult.compare(a.result, b.result));\n matchingDefaultInstanceResults.sort((a, b) => ConditionSetResolutionResult.compare(a.result, b.result));\n\n // Extract just the instance indices in priority order\n const instanceIndices = matchingInstanceResults.map((item) => item.index);\n const defaultInstanceIndices = matchingDefaultInstanceResults.map((item) => item.index);\n\n // Cache the successful result\n const successResult: DecisionResolutionResult = {\n success: true,\n instanceIndices,\n defaultInstanceIndices\n };\n this._decisionCache[decisionIndex] = successResult;\n this._listener?.onCacheMiss('decision', decisionIndex);\n\n return succeed(successResult);\n }\n\n /**\n * Resolves a resource by finding the best matching candidate.\n * Uses the resource's associated decision to determine the best match based on the current context.\n * @param resource - The {@link Resources.Resource | resource} to resolve.\n * @returns `Success` with the best matching candidate if successful,\n * or `Failure` with an error message if no candidates match or resolution fails.\n * @public\n */\n public resolveResource(resource: IResource): Result<IResourceCandidate>;\n\n /**\n * Resolves a resource by finding the best matching candidate.\n * Uses the resource's associated decision to determine the best match based on the current context.\n * @param resource - The string id of the resource to resolve.\n * @returns `Success` with the best matching candidate if successful,\n * or `Failure` with an error message if no candidates match or resolution fails.\n * @public\n */\n public resolveResource(resource: string): Result<IResourceCandidate>;\n public resolveResource(idOrResource: string | IResource): Result<IResourceCandidate> {\n /* c8 ignore next 4 - defensive coding: string resource resolution should use direct resource calls */\n if (typeof idOrResource === 'string') {\n return this.resourceManager\n .getBuiltResource(idOrResource)\n .onSuccess((resource) => this.resolveResource(resource));\n }\n\n const resource = idOrResource;\n\n // Get the abstract decision from the resource's concrete decision\n const abstractDecision = resource.decision.baseDecision;\n\n // Resolve the decision to get candidate indices in priority order\n const decisionResult = this.resolveDecision(abstractDecision);\n /* c8 ignore next 3 - defense in depth almost impossible to hit */\n if (decisionResult.isFailure()) {\n return fail(`Failed to resolve decision for resource \"${resource.id}\": ${decisionResult.message}`);\n }\n\n const resolution = decisionResult.value;\n\n // Check if any candidates matched (regular or default)\n if (\n !resolution.success ||\n (resolution.instanceIndices.length === 0 && resolution.defaultInstanceIndices.length === 0)\n ) {\n return fail(`No matching candidates found for resource \"${resource.id}\"`);\n }\n\n // Prefer regular matches over default matches\n const candidateIndex =\n resolution.instanceIndices.length > 0\n ? resolution.instanceIndices[0] // Best regular match\n : resolution.defaultInstanceIndices[0]; // Best default match\n\n if (candidateIndex >= resource.candidates.length) {\n return fail(`Invalid candidate index ${candidateIndex} for resource \"${resource.id}\"`);\n }\n\n const bestCandidate = resource.candidates[candidateIndex];\n return succeed(bestCandidate);\n }\n\n /**\n * Resolves all matching resource candidates in priority order.\n * Uses the resource's associated decision to determine all matching candidates based on the current context.\n * @param resource - The {@link Resources.Resource | resource} to resolve.\n * @returns `Success` with an array of all matching candidates in priority order if successful,\n * or `Failure` with an error message if no candidates match or resolution fails.\n * @public\n */\n public resolveAllResourceCandidates(resource: IResource): Result<ReadonlyArray<IResourceCandidate>>;\n\n /**\n * Resolves all matching resource candidates in priority order.\n * Uses the resource's associated decision to determine all matching candidates based on the current context.\n * @param resource - The string id of the resource to resolve.\n * @returns `Success` with an array of all matching candidates in priority order if successful,\n * or `Failure` with an error message if no candidates match or resolution fails.\n * @public\n */\n public resolveAllResourceCandidates(resource: string): Result<ReadonlyArray<IResourceCandidate>>;\n public resolveAllResourceCandidates(\n idOrResource: string | IResource\n ): Result<ReadonlyArray<IResourceCandidate>> {\n if (typeof idOrResource === 'string') {\n return this.resourceManager\n .getBuiltResource(idOrResource)\n .onSuccess((resource) => this.resolveAllResourceCandidates(resource));\n }\n\n const resource = idOrResource;\n\n // Get the abstract decision from the resource's concrete decision\n const abstractDecision = resource.decision.baseDecision;\n\n // Resolve the decision to get candidate indices in priority order\n const decisionResult = this.resolveDecision(abstractDecision);\n /* c8 ignore next 3 - defense in depth almost impossible to hit */\n if (decisionResult.isFailure()) {\n return fail(`Failed to resolve decision for resource \"${resource.id}\": ${decisionResult.message}`);\n }\n\n const resolution = decisionResult.value;\n\n // Check if any candidates matched (regular or default)\n if (\n !resolution.success ||\n (resolution.instanceIndices.length === 0 && resolution.defaultInstanceIndices.length === 0)\n ) {\n return fail(`No matching candidates found for resource \"${resource.id}\"`);\n }\n\n // Get all matching candidates: regular matches first, then default matches\n const candidates: IResourceCandidate[] = [];\n\n // Add all regular matches first (already sorted by priority)\n for (const candidateIndex of resolution.instanceIndices) {\n if (candidateIndex >= resource.candidates.length) {\n return fail(`Invalid candidate index ${candidateIndex} for resource \"${resource.id}\"`);\n }\n const candidate = resource.candidates[candidateIndex];\n candidates.push(candidate);\n }\n\n // Add all default matches after regular matches (already sorted by priority)\n for (const candidateIndex of resolution.defaultInstanceIndices) {\n /* c8 ignore next 3 - defense in depth should not happen */\n if (candidateIndex >= resource.candidates.length) {\n return fail(`Invalid candidate index ${candidateIndex} for resource \"${resource.id}\"`);\n }\n const candidate = resource.candidates[candidateIndex];\n candidates.push(candidate);\n }\n\n return succeed(candidates);\n }\n\n /**\n * Resolves a resource to a composed value by merging matching candidates according to their merge methods.\n * Starting from the highest priority candidates, finds the first \"full\" candidate and merges all higher\n * priority \"partial\" candidates into it in ascending order of priority.\n * @param resource - The {@link Resources.Resource | resource} to resolve.\n * @returns `Success` with the composed JsonValue if successful,\n * or `Failure` with an error message if no candidates match or resolution fails.\n * @public\n */\n public resolveComposedResourceValue(resource: IResource): Result<JsonValue>;\n\n /**\n * Resolves a resource to a composed value by merging matching candidates according to their merge methods.\n * Starting from the highest priority candidates, finds the first \"full\" candidate and merges all higher\n * priority \"partial\" candidates into it in ascending order of priority.\n * @param resource - The string id of the resource to resolve.\n * @returns `Success` with the composed JsonValue if successful,\n * or `Failure` with an error message if no candidates match or resolution fails.\n * @public\n */\n public resolveComposedResourceValue(resource: string): Result<JsonValue>;\n public resolveComposedResourceValue(idOrResource: string | IResource): Result<JsonValue> {\n /* c8 ignore next 4 - defensive coding: string resource resolution should use direct resource calls */\n if (typeof idOrResource === 'string') {\n return this.resourceManager\n .getBuiltResource(idOrResource)\n .onSuccess((resource) => this.resolveComposedResourceValue(resource));\n }\n\n const resource = idOrResource;\n\n return this.resolveAllResourceCandidates(resource).onSuccess((candidates) => {\n /* c8 ignore next 3 - defense in depth should never occur */\n if (candidates.length === 0) {\n return fail(`${resource.id}: No matching candidates found.`);\n }\n\n // Find the first full candidate and collect all partial candidates above it\n let fullCandidateIndex = -1;\n const partialCandidates: IResourceCandidate[] = [];\n\n for (let i = 0; i < candidates.length; i++) {\n const candidate = candidates[i];\n if (!candidate.isPartial) {\n // Found the first full candidate\n fullCandidateIndex = i;\n break;\n } else {\n // Collect partial candidates (these are in ascending priority order)\n partialCandidates.unshift(candidate);\n }\n }\n\n // If no full candidate found, use the last candidate as the base\n const baseCandidateIndex = fullCandidateIndex >= 0 ? fullCandidateIndex : candidates.length - 1;\n const baseCandidate = candidates[baseCandidateIndex];\n\n // If there are no partial candidates to merge, but null-as-delete is enabled,\n // still process through JsonEditor to handle null properties in the base candidate\n if (partialCandidates.length === 0) {\n if (this.options.suppressNullAsDelete || !isJsonObject(baseCandidate.json)) {\n return succeed(baseCandidate.json);\n }\n\n // Process single candidate through JsonEditor to apply null-as-delete\n const editor = JsonEditor.create({\n merge: {\n arrayMergeBehavior: 'replace',\n nullAsDelete: true\n }\n }).orThrow(); // Should never fail with valid options\n\n return editor\n .mergeObjectsInPlace({}, [baseCandidate.json])\n .withErrorFormat((err) => `${resource.id}: Composition failed: ${err}`);\n }\n\n const allCandidates = [\n baseCandidate.json,\n ...partialCandidates.map((candidate) => candidate.json)\n ].filter((v): v is JsonObject => isJsonObject(v));\n\n /* c8 ignore next 3 - defensive check: non-object values in resource candidates should be prevented at validation time */\n if (allCandidates.length !== partialCandidates.length + 1) {\n return fail(`${resource.id}: Unable to compose non-object candidate values.`);\n }\n\n // Create JsonEditor with array replacement behavior and null-as-delete for resource composition\n const editor = JsonEditor.create({\n merge: {\n arrayMergeBehavior: 'replace',\n nullAsDelete: !this.options.suppressNullAsDelete\n }\n }).orThrow(); // Should never fail with valid options\n\n return editor\n .mergeObjectsInPlace({}, allCandidates)\n .withErrorFormat((err) => `${resource.id}: Composition failed: ${err}`);\n });\n }\n\n /**\n * {@inheritDoc IResourceResolver.withContext}\n */\n public withContext(context: Record<string, string>): Result<ResourceResolver> {\n const { resourceManager, qualifierTypes, options } = this;\n return ValidatingSimpleContextQualifierProvider.create({\n qualifiers: this.qualifiers,\n qualifierValues: context\n }).onSuccess((contextQualifierProvider) => {\n return ResourceResolver.create({\n resourceManager,\n qualifierTypes,\n options,\n contextQualifierProvider\n });\n });\n }\n\n /**\n * Clears all caches (condition, condition set, and decision), forcing all cached items\n * to be re-evaluated on next access. This should be called when the context changes and cached\n * results are no longer valid.\n * @public\n */\n public clearConditionCache(): void {\n this._conditionCache.fill(undefined);\n this._conditionSetCache.fill(undefined);\n this._decisionCache.fill(undefined);\n\n this._listener?.onCacheClear('condition');\n this._listener?.onCacheClear('conditionSet');\n this._listener?.onCacheClear('decision');\n }\n\n /**\n * Gets the current size of the condition cache array.\n * @returns The size of the condition cache array.\n * @public\n */\n public get conditionCacheSize(): number {\n return this._conditionCache.length;\n }\n\n /**\n * Gets the current size of the condition set cache array.\n * @returns The size of the condition set cache array.\n * @public\n */\n public get conditionSetCacheSize(): number {\n return this._conditionSetCache.length;\n }\n\n /**\n * Gets the current size of the decision cache array.\n * @returns The size of the decision cache array.\n * @public\n */\n public get decisionCacheSize(): number {\n return this._decisionCache.length;\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resourceTreeResolver.js","sourceRoot":"","sources":["../../../src/packlets/runtime/resourceTreeResolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAU,iBAAiB,EAAE,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACxF,OAAO,EAAyB,UAAU,IAAI,cAAc,EAAE,MAAM,mBAAmB,CAAC;AA2DxF;;;;;;;;;GASG;AACH,MAAM,OAAO,oBAAoB;IAiB/B;;;OAGG;IACH,YAAmB,QAA0B;QAC3C,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,gBAAgB,GAAG,QAAQ,CAAC,eAAe,CAAC;IACnD,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC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AC9C,IAAI,iBAAiB,KAAK,MAAM,IAAI,UAAU,CAAC,WAAW,EAAE,CAAC;YAC3D,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;QACzC,CAAC;QAED,sBAAsB;QACtB,IAAI,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC3C,OAAO,IAAI,CAAC,kBAAkB,CAAC,IAAI,EAAE,cAAc,EAAE,eAAe,EAAE,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE;gBAC9F,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;oBACxB,OAAO,OAAO,CAAC,SAAS,CAAC,CAAC;gBAC5B,CAAC;gBACD,2CAA2C;gBAC3C,OAAO,cAAc,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YAClD,CAAC,CAAC,CAAC;QACL,CAAC;QAED,OAAO,OAAO,CAAC,YAAY,CAAC,CAAC;IAC/B,CAAC;CACF","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 { Result, MessageAggregator, succeed, fail, captureResult } from '@fgv/ts-utils';\nimport { JsonValue, JsonObject, Converters as JsonConverters } from '@fgv/ts-json-base';\nimport { IResourceManager, IResource } from './iResourceManager';\nimport { IReadOnlyResourceTreeNode, IReadOnlyResourceTreeRoot } from './resource-tree/common';\nimport { ResourceResolver } from './resourceResolver';\n\n/**\n * Type for handling resource resolution errors during tree traversal.\n * The handler receives the resource that failed to resolve, the error message, and the resolver for recovery attempts.\n * It can return:\n * - Success(undefined) to omit the property from the result\n * - Success(value) to use an alternate value\n * - Failure to propagate the error\n * @public\n */\nexport type ResourceErrorHandler = (\n resource: IResource,\n message: string,\n resolver: ResourceResolver\n) => Result<JsonValue | undefined>;\n\n/**\n * Type for handling empty branch nodes during tree composition.\n * The handler receives the branch node, names of failed children, and the resolver for recovery attempts.\n * It can return:\n * - Success(undefined) to omit the branch from the result\n * - Success(value) to use an alternate value for the branch\n * - Failure to propagate the error\n * @public\n */\nexport type EmptyBranchHandler = (\n branchNode: IReadOnlyResourceTreeNode<IResource>,\n failedChildNames: string[],\n resolver: ResourceResolver\n) => Result<JsonValue | undefined>;\n\n/**\n * Options for configuring resource tree resolution.\n * @public\n */\nexport interface IResolveResourceTreeOptions {\n /**\n * Controls how errors are handled when resolving individual resources in the tree.\n * - 'fail': Aggregate all errors and fail if any resource fails to resolve\n * - 'ignore': Skip failed resources and omit them from the result\n * - callback: Custom error handler that can provide alternate values or propagate errors\n * @defaultValue 'fail'\n */\n onResourceError?: 'fail' | 'ignore' | ResourceErrorHandler;\n\n /**\n * Controls how empty branch nodes are handled during tree composition.\n * - 'allow': Include empty branches as empty objects in the result\n * - 'omit': Exclude empty branches from the parent object\n * - callback: Custom handler that can provide alternate values or recovery logic\n * @defaultValue 'allow'\n */\n onEmptyBranch?: 'allow' | 'omit' | EmptyBranchHandler;\n}\n\n/**\n * Specialized resolver for resource tree operations, providing enhanced APIs for\n * resolving entire resource trees from either resource IDs or pre-built tree nodes.\n *\n * This class provides a clean separation between individual resource resolution\n * (handled by ResourceResolver) and tree-based operations, with support for\n * lazy tree construction and enhanced error handling.\n *\n * @public\n */\nexport class ResourceTreeResolver {\n /**\n * The {@link Runtime.ResourceResolver | ResourceResolver} to use for individual resource resolution\n */\n public readonly resolver: ResourceResolver;\n\n /**\n * The {@link Runtime.IResourceManager | IResourceManager} to use for lazy tree construction.\n * @internal\n */\n private readonly _resourceManager: IResourceManager<IResource>;\n /**\n * The built resource tree, lazily built on first access.\n * @internal\n */\n private _tree?: Result<IReadOnlyResourceTreeRoot<IResource>>;\n\n /**\n * Creates a {@link Runtime.ResourceTreeResolver | ResourceTreeResolver} instance.\n * @param resolver - The ResourceResolver to use for individual resource resolution\n */\n public constructor(resolver: ResourceResolver) {\n this.resolver = resolver;\n this._resourceManager = resolver.resourceManager;\n }\n\n /**\n * Creates a {@link Runtime.ResourceTreeResolver | ResourceTreeResolver} instance.\n * @param resolver - The ResourceResolver to use for individual resource resolution\n */\n public static create(resolver: ResourceResolver): Result<ResourceTreeResolver> {\n return captureResult(() => new ResourceTreeResolver(resolver));\n }\n\n /**\n * Gets the built resource tree, building it lazily on first access.\n * @returns The resource tree root\n * @throws Error if no resource manager was provided or tree building fails\n * @public\n */\n public get tree(): IReadOnlyResourceTreeRoot<IResource> {\n return this._getTree().orThrow();\n }\n\n /**\n * Resolves a resource tree from a resource ID, building the tree lazily from the resource manager.\n * @param resourceId - The ID of the root resource to resolve\n * @param options - Optional configuration for error handling during resolution\n * @returns Success with the composed JsonObject or undefined, or Failure with error message\n * @public\n */\n public resolveComposedResourceTree(\n resourceId: string,\n options?: IResolveResourceTreeOptions\n ): Result<JsonObject | undefined>;\n\n /**\n * Resolves a pre-built resource tree node.\n * @param node - The resource tree node to resolve\n * @param options - Optional configuration for error handling during resolution\n * @returns Success with the composed JsonObject or undefined, or Failure with error message\n * @public\n */\n public resolveComposedResourceTree(\n node: IReadOnlyResourceTreeNode<IResource>,\n options?: IResolveResourceTreeOptions\n ): Result<JsonObject | undefined>;\n\n /**\n * Implementation for both overloads.\n */\n public resolveComposedResourceTree(\n idOrNode: string | IReadOnlyResourceTreeNode<IResource>,\n options?: IResolveResourceTreeOptions\n ): Result<JsonObject | undefined> {\n if (typeof idOrNode === 'string') {\n return this._resolveFromResourceId(idOrNode, options);\n }\n return this._resolveFromTreeNode(idOrNode, options);\n }\n\n private _getTree(): Result<IReadOnlyResourceTreeRoot<IResource>> {\n if (!this._tree) {\n this._tree = this._resourceManager.getBuiltResourceTree();\n }\n return this._tree;\n }\n\n /**\n * Resolves a tree from a resource ID by first building the tree from the resource manager.\n * @internal\n */\n private _resolveFromResourceId(\n resourceId: string,\n options?: IResolveResourceTreeOptions\n ): Result<JsonObject | undefined> {\n return this._getTree().onSuccess((tree) => {\n return tree.children.validating\n .getById(resourceId)\n .onFailure((message) => fail(`${resourceId}: Resource not found in resource tree: ${message}`))\n .onSuccess((rootNode) => this._resolveFromTreeNode(rootNode, options));\n });\n }\n\n /**\n * Resolves a pre-built tree node using the extracted tree resolution logic.\n * @internal\n */\n private _resolveFromTreeNode(\n node: IReadOnlyResourceTreeNode<IResource>,\n options?: IResolveResourceTreeOptions\n ): Result<JsonObject | undefined> {\n const resourceErrorMode = options?.onResourceError ?? 'fail';\n const emptyBranchMode = options?.onEmptyBranch ?? 'allow';\n\n // Handle root node with proper Result chaining\n return node.isLeaf\n ? this._processLeafNode(node, '', resourceErrorMode).onSuccess((value) =>\n value !== undefined ? JsonConverters.jsonObject.convert(value) : succeed(undefined)\n )\n : this._processBranchNode(node, '', {\n onResourceError: resourceErrorMode,\n onEmptyBranch: emptyBranchMode\n }).onSuccess((value) => {\n // Only convert undefined to {} if emptyBranchMode is 'allow'\n // For 'omit' mode or custom handlers returning undefined, preserve undefined\n /* c8 ignore next 3 - defense in depth */\n return succeed(value === undefined && emptyBranchMode === 'allow' ? {} : value);\n });\n }\n\n /**\n * Handles resource resolution errors according to the specified mode.\n * @param resource - The resource that failed to resolve\n * @param message - The error message from the failed resolution\n * @param mode - The error handling mode\n * @param path - The path to the resource in the tree (for error context)\n * @internal\n */\n private _handleResourceError(\n resource: IResource,\n message: string,\n mode: 'fail' | 'ignore' | ResourceErrorHandler,\n path: string\n ): Result<JsonValue | undefined> {\n if (mode === 'ignore') {\n return succeed(undefined);\n }\n if (mode === 'fail') {\n const errorMessage = path ? `${path}: ${message}` : message;\n return fail(errorMessage);\n }\n // Custom handler - pass the resolver for recovery attempts\n return mode(resource, message, this.resolver);\n }\n\n /**\n * Handles empty branch nodes according to the specified mode.\n * @param node - The empty branch node\n * @param failedChildren - Names of children that failed to resolve\n * @param mode - The empty branch handling mode\n * @param path - The path to the branch in the tree (for error context)\n * @internal\n */\n private _handleEmptyBranch(\n node: IReadOnlyResourceTreeNode<IResource>,\n failedChildren: string[],\n mode: 'allow' | 'omit' | EmptyBranchHandler,\n path: string\n ): Result<JsonValue | undefined> {\n if (mode === 'omit') {\n return succeed(undefined);\n }\n if (mode === 'allow') {\n return succeed({});\n }\n // Custom handler - pass the resolver for recovery attempts\n return mode(node, failedChildren, this.resolver);\n }\n\n /**\n * Processes a leaf node by resolving its resource value.\n * @param node - The leaf node to process (must be a leaf node)\n * @param path - The path to the node in the tree\n * @param resourceErrorMode - How to handle resource resolution errors\n * @internal\n */\n private _processLeafNode(\n node: IReadOnlyResourceTreeNode<IResource>,\n path: string,\n resourceErrorMode: 'fail' | 'ignore' | ResourceErrorHandler\n ): Result<JsonValue | undefined> {\n /* c8 ignore next 3 - defense in depth */\n if (!node.isLeaf) {\n return fail(`Internal error: processLeafNode called on non-leaf node at ${path}`);\n }\n\n return this.resolver\n .resolveComposedResourceValue(node.resource)\n .onSuccess<JsonValue | undefined>((value) => succeed(value))\n .onFailure((message) => this._handleResourceError(node.resource, message, resourceErrorMode, path));\n }\n\n /**\n * Processes a branch node by recursively resolving all its children.\n * @param node - The branch node to process (must be a branch node)\n * @param path - The path to the node in the tree\n * @param options - Resolution options\n * @internal\n */\n private _processBranchNode(\n node: IReadOnlyResourceTreeNode<IResource>,\n path: string,\n options: IResolveResourceTreeOptions\n ): Result<JsonObject | undefined> {\n /* c8 ignore next 3 - defense in depth */\n if (node.isLeaf) {\n return fail(`Internal error: processBranchNode called on leaf node at ${path}`);\n }\n\n /* c8 ignore next 2 - ?? is defense in depth */\n const resourceErrorMode = options.onResourceError ?? 'fail';\n const emptyBranchMode = options.onEmptyBranch ?? 'allow';\n const aggregator = new MessageAggregator();\n\n // Process all children\n const childResults: JsonObject = {};\n const failedChildren: string[] = [];\n\n for (const [childName, childNode] of node.children) {\n const childPath = path ? `${path}.${childName}` : childName;\n\n const childResult = childNode.isLeaf\n ? this._processLeafNode(childNode, childPath, resourceErrorMode)\n : this._processBranchNode(childNode, childPath, options);\n\n // Process the child result and update our state\n if (childResult.isSuccess()) {\n const value = childResult.value;\n if (value !== undefined) {\n childResults[childName] = value;\n } else {\n failedChildren.push(childName);\n }\n } else {\n if (resourceErrorMode === 'fail') {\n aggregator.addMessage(childResult.message);\n }\n failedChildren.push(childName);\n }\n }\n\n // Check for accumulated errors in 'fail' mode\n if (resourceErrorMode === 'fail' && aggregator.hasMessages) {\n return fail(aggregator.toString('; '));\n }\n\n // Handle empty branch\n if (Object.keys(childResults).length === 0) {\n return this._handleEmptyBranch(node, failedChildren, emptyBranchMode, path).onSuccess((value) => {\n if (value === undefined) {\n return succeed(undefined);\n }\n // Ensure we return JsonObject or undefined\n return JsonConverters.jsonObject.convert(value);\n });\n }\n\n return succeed(childResults);\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../src/packlets/runtime/validate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,UAAU,EAAa,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,UAA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Content":["/*\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 { Validators, Validator } from '@fgv/ts-utils';\nimport { Validators as JsonValidators } from '@fgv/ts-json-base';\nimport { Validate, ResourceId } from '../common';\nimport { ResourceType } from '../resource-types';\nimport { ConcreteDecision } from '../decisions';\nimport { IResource, IResourceCandidate } from './iResourceManager';\n\n/**\n * Validates an {@link Runtime.IResourceCandidate | IResourceCandidate} object.\n * @public\n */\nexport const resourceCandidate: Validator<IResourceCandidate, unknown> =\n Validators.object<IResourceCandidate>({\n json: JsonValidators.jsonObject,\n isPartial: Validators.boolean,\n mergeMethod: Validators.isA(\n 'resource value merge method',\n (v): v is 'augment' | 'delete' | 'replace' => v === 'augment' || v === 'delete' || v === 'replace'\n )\n });\n\n/**\n * Validates an {@link Runtime.IResource | IResource} object.\n * @public\n */\nexport const resource: Validator<IResource, unknown> = Validators.object<IResource>({\n id: Validators.isA(\n 'ResourceId',\n (v): v is ResourceId => typeof v === 'string' && Validate.isValidResourceId(v)\n ),\n name: Validators.isA(\n 'ResourceName',\n (v): v is string => typeof v === 'string' && Validate.isValidResourceName(v)\n ),\n resourceType: Validators.isA('ResourceType instance', (v): v is ResourceType => v instanceof ResourceType),\n decision: Validators.isA(\n 'ConcreteDecision instance',\n (v): v is ConcreteDecision => v instanceof ConcreteDecision\n ),\n candidates: Validators.arrayOf(resourceCandidate)\n});\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert.js","sourceRoot":"","sources":["../../../src/packlets/zip-archive/convert.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAa,UAAU,EAAa,UAAU,EAAE,MAAM,eAAe,CAAC;AAE7E,OAAO,EAAwB,OAAO,IAAI,aAAa,EAAE,MAAM,WAAW,CAAC;AAE3E;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAoC,UAAU,CAAC,eAAe,CAAC;IAC7F,MAAM;IACN,WAAW;CACH,CAAC,CAAC;AAEZ;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAsB,UAAU,CAAC,eAAe,CAAC,CAAC,MAAM,CAAU,CAAC,CAAC;AAErG;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAC9B,UAAU,CAAC,MAAM,CAA4B;IAC3C,IAAI,EAAE,mBAAmB;IACzB,YAAY,EAAE,UAAU,CAAC,MAAM;IAC/B,WAAW,EAAE,UAAU,CAAC,MAAM;CAC/B,CAAC,CAAC;AAEL;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAC/B,UAAU,CAAC,MAAM,CAA6B;IAC5C,IAAI,EAAE,oBAAoB;IAC1B,YAAY,EAAE,UAAU,CAAC,MAAM;IAC/B,WAAW,EAAE,UAAU,CAAC,MAAM;CAC/B,CAAC,CAAC;AAEL;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAC7B,UAAU,CAAC,MAAM,CAA2B;IAC1C,SAAS,EAAE,UAAU,CAAC,MAAM;IAC5B,KAAK,EAAE,mBAAmB,CAAC,QAAQ,EAAE;IACrC,MAAM,EAAE,oBAAoB,CAAC,QAAQ,EAAE;CACxC,CAAC,CAAC;AAEL;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAsB,UAAU,CAAC,MAAM,CAAC;AAE7D;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAkC,UAAU,CAAC,YAAY,CAAqB;IACrG,IAAI,EAAE,UAAU,CAAC,MAAM;IACvB,IAAI,EAAE,UAAU,CAAC,MAAM;IACvB,OAAO,EAAE,UAAU,CAAC,MAAM;IAC1B,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,sBAAsB;CAC/C,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAuC,UAAU,CAAC,OAAO,CAGrF,CAAC,IAAa,EAAE,IAAiD,EAAE,OAAiB,EAAE,EAAE;IACxF,OAAO,UAAU,CAAC,YAAY,CAA0B;QACtD,IAAI,EAAE,UAAU,CAAC,MAAM;QACvB,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC,YAAY,CAAC;QACvC,cAAc,EAAE,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC;KACzC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC5B,CAAC,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAgD,UAAU,CAAC,GAAG,CAC5F,sBAAsB,EACtB,CAAC,KAAc,EAA6C,EAAE;IAC5D,OAAO,aAAa,CAAC,mBAAmB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,SAAS,EAAE,CAAC;AACtE,CAAC,CACF,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 { Validator, Validators, Converter, Converters } from '@fgv/ts-utils';\nimport * as Json from './json';\nimport { Model as ConfigModel, Convert as ConfigConvert } from '../config';\n\n/**\n * Validator for ZIP archive input type\n * @public\n */\nexport const zipArchiveInputType: Validator<'file' | 'directory'> = Validators.enumeratedValue([\n 'file',\n 'directory'\n] as const);\n\n/**\n * Validator for ZIP archive config type\n * @public\n */\nexport const zipArchiveConfigType: Validator<'file'> = Validators.enumeratedValue(['file'] as const);\n\n/**\n * Validator for ZIP archive input information\n * @public\n */\nexport const zipArchiveInputInfo: Validator<Json.IZipArchiveInputInfo> =\n Validators.object<Json.IZipArchiveInputInfo>({\n type: zipArchiveInputType,\n originalPath: Validators.string,\n archivePath: Validators.string\n });\n\n/**\n * Validator for ZIP archive config information\n * @public\n */\nexport const zipArchiveConfigInfo: Validator<Json.IZipArchiveConfigInfo> =\n Validators.object<Json.IZipArchiveConfigInfo>({\n type: zipArchiveConfigType,\n originalPath: Validators.string,\n archivePath: Validators.string\n });\n\n/**\n * Validator for ZIP archive manifest\n * Compatible with existing tools from ts-res-browser-cli\n * @public\n */\nexport const zipArchiveManifest: Validator<Json.IZipArchiveManifest> =\n Validators.object<Json.IZipArchiveManifest>({\n timestamp: Validators.string,\n input: zipArchiveInputInfo.optional(),\n config: zipArchiveConfigInfo.optional()\n });\n\n/**\n * Validator for MIME type strings\n * @public\n */\nexport const mimeType: Validator<string> = Validators.string;\n\n/**\n * Converter for imported file\n * @public\n */\nexport const importedFile: Converter<Json.IImportedFile> = Converters.strictObject<Json.IImportedFile>({\n name: Converters.string,\n path: Converters.string,\n content: Converters.string,\n type: Converters.string // MIME type as string\n});\n\n/**\n * Converter for imported directory structure (recursive)\n * Note: Uses Converter pattern because Validators don't support recursion with self parameter\n * @public\n */\nexport const importedDirectory: Converter<Json.IImportedDirectory> = Converters.generic<\n Json.IImportedDirectory,\n unknown\n>((from: unknown, self: Converter<Json.IImportedDirectory, unknown>, context?: unknown) => {\n return Converters.strictObject<Json.IImportedDirectory>({\n name: Converters.string,\n files: Converters.arrayOf(importedFile),\n subdirectories: Converters.arrayOf(self)\n }).convert(from, context);\n});\n\n/**\n * Validator for system configuration (delegates to config packlet)\n * This validates that the parsed JSON conforms to the system configuration schema\n * @public\n */\nexport const systemConfiguration: Validator<ConfigModel.ISystemConfiguration> = Validators.isA(\n 'system configuration',\n (value: unknown): value is ConfigModel.ISystemConfiguration => {\n return ConfigConvert.systemConfiguration.convert(value).isSuccess();\n }\n);\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.browser.js","sourceRoot":"","sources":["../../../src/packlets/zip-archive/index.browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,aAAa;AACb,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAEzB,4EAA4E;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAgBtD,mBAAmB;AACnB,OAAO,EACL,wBAAwB,EACxB,uBAAuB,EACvB,0BAA0B,EAC1B,4BAA4B,EAC5B,0BAA0B,EAC1B,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,SAAS,EACV,MAAM,oBAAoB,CAAC;AAE5B,YAAY;AACZ,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAE9C,+EAA+E;AAC/E,iEAAiE;AACjE,6EAA6E","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\n/**\n * Browser-safe ZIP archive functionality for ts-res source file archives\n *\n * This packlet provides consolidated ZIP archive creation and loading functionality\n * for source files, compatible with browsers using fflate.\n *\n * @remarks\n * ZIP archives contain source files for resource ingestion with directory\n * structure preserved and optional validation but no processing or transformation.\n * This is distinct from ZIP bundles which contain processed resource output.\n *\n * ZipArchiveCreator supports browser usage when FileTreeItems are provided directly.\n * Methods accepting file paths require Node.js fs access and should not be called in browser.\n *\n * ZipArchiveLoader is fully browser-compatible and works with File API or ArrayBuffer.\n *\n * @packageDocumentation\n */\n\nimport * as Json from './json';\nimport * as Convert from './convert';\n\n// Namespaces\nexport { Json, Convert };\n\n// Core classes (browser-compatible when used with FileTreeItems or buffers)\nexport { ZipArchiveCreator } from './zipArchiveCreator';\nexport { ZipArchiveLoader } from './zipArchiveLoader';\n\n// Types and interfaces\nexport type {\n IZipArchivePathOptions,\n IZipArchiveFileTreeOptions,\n ZipArchiveOptions,\n IZipArchiveResult,\n IZipArchiveManifest,\n IZipArchiveLoadOptions,\n IZipArchiveLoadResult,\n IImportedFile,\n IImportedDirectory,\n ZipArchiveProgressCallback\n} from './types';\n\n// Format utilities\nexport {\n createZipArchiveManifest,\n parseZipArchiveManifest,\n validateZipArchiveManifest,\n parseZipArchiveConfiguration,\n generateZipArchiveFilename,\n normalizePath,\n getDirectoryName,\n sanitizeFilename,\n isZipFile\n} from './zipArchiveFormat';\n\n// Constants\nexport { ZipArchiveConstants } from './types';\n\n// Note: ZipArchiveCreator._getInputFileTreeItem() and _getConfigFileTreeItem()\n// use FileTree.forFilesystem() internally when given file paths.\n// In browser, provide FileTreeItems directly via IZipArchiveFileTreeOptions.\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/zip-archive/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,aAAa;AACb,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAEzB,eAAe;AACf,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAgBtD,mBAAmB;AACnB,OAAO,EACL,wBAAwB,EACxB,uBAAuB,EACvB,0BAA0B,EAC1B,4BAA4B,EAC5B,0BAA0B,EAC1B,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,SAAS,EACV,MAAM,oBAAoB,CAAC;AAE5B,YAAY;AACZ,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,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\n/**\n * ZIP archive functionality for ts-res source file archives\n *\n * This packlet provides consolidated ZIP archive creation and loading functionality\n * for source files, compatible with existing tools while using fflate for\n * universal browser compatibility.\n *\n * @remarks\n * ZIP archives contain source files for resource ingestion with directory\n * structure preserved and optional validation but no processing or transformation.\n * This is distinct from ZIP bundles which contain processed resource output.\n *\n * @packageDocumentation\n */\n\nimport * as Json from './json';\nimport * as Convert from './convert';\n\n// Namespaces\nexport { Json, Convert };\n\n// Core classes\nexport { ZipArchiveCreator } from './zipArchiveCreator';\nexport { ZipArchiveLoader } from './zipArchiveLoader';\n\n// Types and interfaces\nexport type {\n IZipArchivePathOptions,\n IZipArchiveFileTreeOptions,\n ZipArchiveOptions,\n IZipArchiveResult,\n IZipArchiveManifest,\n IZipArchiveLoadOptions,\n IZipArchiveLoadResult,\n IImportedFile,\n IImportedDirectory,\n ZipArchiveProgressCallback\n} from './types';\n\n// Format utilities\nexport {\n createZipArchiveManifest,\n parseZipArchiveManifest,\n validateZipArchiveManifest,\n parseZipArchiveConfiguration,\n generateZipArchiveFilename,\n normalizePath,\n getDirectoryName,\n sanitizeFilename,\n isZipFile\n} from './zipArchiveFormat';\n\n// Constants\nexport { ZipArchiveConstants } from './types';\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json.js","sourceRoot":"","sources":["../../../src/packlets/zip-archive/json.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG","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\n/**\n * JSON representation of ZIP archive input information\n * @public\n */\nexport interface IZipArchiveInputInfo {\n /** Type of input (file or directory) */\n type: 'file' | 'directory';\n /** Original file/directory path */\n originalPath: string;\n /** Path within the archive (e.g., \"input/mydir\") */\n archivePath: string;\n}\n\n/**\n * JSON representation of ZIP archive config information\n * @public\n */\nexport interface IZipArchiveConfigInfo {\n /** Type of config (always 'file') */\n type: 'file';\n /** Original config file path */\n originalPath: string;\n /** Path within the archive (e.g., \"config.json\") */\n archivePath: string;\n}\n\n/**\n * JSON representation of a ZIP archive manifest\n * Compatible with existing tools from ts-res-browser-cli\n * @public\n */\nexport interface IZipArchiveManifest {\n /** Archive creation timestamp */\n timestamp: string;\n\n /** Optional input source information */\n input?: IZipArchiveInputInfo;\n\n /** Optional configuration file information */\n config?: IZipArchiveConfigInfo;\n}\n\n/**\n * JSON representation of an imported file\n * @public\n */\nexport interface IImportedFile {\n /** File name */\n name: string;\n /** Full path within archive */\n path: string;\n /** File content as string */\n content: string;\n /** MIME type */\n type: string;\n}\n\n/**\n * JSON representation of an imported directory structure\n * @public\n */\nexport interface IImportedDirectory {\n /** Directory name */\n name: string;\n /** Files in this directory */\n files: IImportedFile[];\n /** Subdirectories */\n subdirectories: IImportedDirectory[];\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/packlets/zip-archive/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AA2GH;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,yBAAyB;IACzB,aAAa,EAAE,eAAe;IAC9B,8BAA8B;IAC9B,WAAW,EAAE,aAAa;IAC1B,4BAA4B;IAC5B,SAAS,EAAE,OAAO;IAClB,oCAAoC;IACpC,UAAU,EAAE,QAAQ;CACZ,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 { Model as ConfigModel } from '../config';\nimport * as Json from './json';\nimport {} from '@fgv/ts-utils';\nimport { FileTree } from '@fgv/ts-json-base';\n\n/**\n * Options for creating a ZIP archive buffer\n * @public\n */\nexport interface IZipArchivePathOptions {\n /** File or directory path to include in the archive */\n inputPath?: string;\n /** Optional configuration file path */\n configPath?: string;\n}\n\n/**\n * Options for creating a ZIP archive buffer from a file tree\n * @public\n */\nexport interface IZipArchiveFileTreeOptions {\n /** Input file or directory */\n inputItem?: FileTree.FileTreeItem;\n /** Optional configuration file */\n configItem?: FileTree.IFileTreeFileItem;\n}\n\n/**\n * Options for creating a ZIP archive buffer\n * @public\n */\nexport type ZipArchiveOptions = IZipArchivePathOptions | IZipArchiveFileTreeOptions;\n\n/**\n * Standardized ZIP archive manifest format (compatible with existing tools)\n * @public\n */\nexport type IZipArchiveManifest = Json.IZipArchiveManifest;\n\n/**\n * Result of ZIP archive buffer creation\n * @public\n */\nexport interface IZipArchiveResult {\n /** Raw ZIP data buffer */\n zipBuffer: Uint8Array;\n /** Archive manifest with metadata */\n manifest: IZipArchiveManifest;\n /** Total ZIP size in bytes */\n size: number;\n}\n\n/**\n * Options for loading a ZIP archive\n * @public\n */\nexport interface IZipArchiveLoadOptions {\n /** Validate manifest strictly */\n strictManifestValidation?: boolean;\n}\n\n/**\n * Result of ZIP archive loading\n * @public\n */\nexport interface IZipArchiveLoadResult {\n /** Parsed archive manifest */\n manifest: IZipArchiveManifest | undefined;\n /** Loaded configuration */\n config: ConfigModel.ISystemConfiguration | undefined;\n /** All files extracted from the archive */\n files: IImportedFile[];\n /** Directory structure if available */\n directory: IImportedDirectory | undefined;\n}\n\n/**\n * Imported file representation\n * @public\n */\nexport type IImportedFile = Json.IImportedFile;\n\n/**\n * Imported directory structure\n * @public\n */\nexport type IImportedDirectory = Json.IImportedDirectory;\n\n/**\n * Progress callback for ZIP operations\n * @public\n */\nexport type ZipArchiveProgressCallback = (\n stage:\n | 'reading-file'\n | 'parsing-zip'\n | 'loading-manifest'\n | 'loading-config'\n | 'extracting-files'\n | 'processing-resources'\n | 'creating-zip',\n progress: number, // 0-100\n details: string\n) => void;\n\n/**\n * Constants for ZIP archive structure\n * @public\n */\nexport const ZipArchiveConstants = {\n /** Manifest file name */\n MANIFEST_FILE: 'manifest.json',\n /** Configuration file name */\n CONFIG_FILE: 'config.json',\n /** Input files directory */\n INPUT_DIR: 'input',\n /** Configuration files directory */\n CONFIG_DIR: 'config'\n} as const;\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zipArchiveCreator.js","sourceRoot":"","sources":["../../../src/packlets/zip-archive/zipArchiveCreator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAU,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,aAAa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CAAC,CACpG,CAAC;QACN,CAAC;aAAM,IAAI,YAAY,IAAI,OAAO,IAAI,OAAO,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;YACvE,OAAO,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QACrC,CAAC;QACD,OAAO,OAAO,CAAC,SAAS,CAAC,CAAC;IAC5B,CAAC;CACF","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 { zipSync } from 'fflate';\nimport { Result, succeed, fail } from '@fgv/ts-utils';\nimport { FileTree } from '@fgv/ts-json-base';\nimport type { IZipArchiveResult, ZipArchiveOptions, ZipArchiveProgressCallback } from './types';\nimport { normalizePath } from './zipArchiveFormat';\nimport * as Json from './json';\n\n/**\n * ZIP archive creator using fflate for universal compatibility\n * @public\n */\nexport class ZipArchiveCreator {\n /**\n * Create a ZIP archive buffer from a supplied buffer\n * @param options - Input paths and configuration\n * @param onProgress - Optional progress callback\n * @returns Result containing ZIP buffer and manifest\n */\n public async createFromBuffer(\n options: ZipArchiveOptions,\n onProgress?: ZipArchiveProgressCallback\n ): Promise<Result<IZipArchiveResult>> {\n try {\n onProgress?.('creating-zip', 0, 'Starting ZIP archive creation');\n\n const files: Record<string, Uint8Array> = {};\n const manifest: Json.IZipArchiveManifest = {\n timestamp: new Date().toISOString()\n };\n\n const { value: inputItem, message: inputItemError } = this._getInputFileTreeItem(options);\n if (inputItemError !== undefined) {\n return fail(inputItemError);\n }\n\n if (inputItem !== undefined) {\n onProgress?.('reading-file', 10, `Processing input: ${inputItem.absolutePath}`);\n\n if (inputItem.type === 'directory') {\n // Add entire directory recursively, preserving structure\n const archivePath = `input/${inputItem.name}`;\n\n const addDirResult = await this._addDirectoryTreeToZip(files, inputItem, archivePath, onProgress);\n /* c8 ignore next 3 - defense in depth against internal error */\n if (addDirResult.isFailure()) {\n return fail(addDirResult.message);\n }\n\n manifest.input = {\n type: 'directory',\n originalPath: inputItem.absolutePath,\n archivePath\n };\n } else if (inputItem.type === 'file') {\n // Add single file\n const archivePath = `input/${inputItem.name}`;\n\n const addFileResult = await this._addFileTreeItemToZip(files, inputItem, archivePath);\n /* c8 ignore next 3 - defense in depth against internal error */\n if (addFileResult.isFailure()) {\n return fail(addFileResult.message);\n }\n\n manifest.input = {\n type: 'file',\n originalPath: inputItem.absolutePath,\n archivePath\n };\n }\n }\n\n const { value: configItem, message: configItemError } = this._getConfigFileTreeItem(options);\n if (configItemError !== undefined) {\n return fail(configItemError);\n }\n\n if (configItem !== undefined) {\n onProgress?.('reading-file', 40, `Processing config: ${configItem.absolutePath}`);\n\n const archivePath = `config/${configItem.name}`;\n\n const addConfigResult = await this._addFileTreeItemToZip(files, configItem, archivePath);\n /* c8 ignore next 3 - defense in depth against internal error */\n if (addConfigResult.isFailure()) {\n return fail(addConfigResult.message);\n }\n\n // Update manifest with config info\n manifest.config = {\n type: 'file',\n originalPath: configItem.absolutePath,\n archivePath\n };\n }\n\n // Add manifest to ZIP\n onProgress?.('creating-zip', 70, 'Adding manifest');\n const manifestJson = JSON.stringify(manifest, null, 2);\n files['manifest.json'] = new TextEncoder().encode(manifestJson);\n\n // Create ZIP buffer using fflate\n onProgress?.('creating-zip', 80, 'Compressing files');\n const zipBuffer = zipSync(files, { level: 6 });\n\n const result: IZipArchiveResult = {\n zipBuffer,\n manifest,\n size: zipBuffer.length\n };\n\n onProgress?.('creating-zip', 100, 'ZIP archive buffer created');\n\n return succeed(result);\n /* c8 ignore next 3 - defense in depth against internal error */\n } catch (error) {\n return fail(`Failed to create ZIP archive: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n\n /**\n * Add a single FileTree item to the ZIP archive\n * @param files - ZIP files collection\n * @param fileItem - FileTree file item to add\n * @param archivePath - Path within the archive\n * @returns Result indicating success or failure\n */\n private async _addFileTreeItemToZip(\n files: Record<string, Uint8Array>,\n fileItem: FileTree.IFileTreeFileItem,\n archivePath: string\n ): Promise<Result<void>> {\n return fileItem.getRawContents().onSuccess((content) => {\n const contentBuffer = new TextEncoder().encode(content);\n files[normalizePath(archivePath)] = contentBuffer;\n return succeed(undefined);\n });\n }\n\n /**\n * Add a directory recursively to the ZIP archive using FileTree\n * @param files - ZIP files collection\n * @param directoryItem - FileTree directory item to add\n * @param archivePrefix - Prefix path within the archive\n * @param onProgress - Optional progress callback\n * @returns Result indicating success or failure\n */\n private async _addDirectoryTreeToZip(\n files: Record<string, Uint8Array>,\n directoryItem: FileTree.IFileTreeDirectoryItem,\n archivePrefix: string,\n onProgress?: ZipArchiveProgressCallback\n ): Promise<Result<void>> {\n const childrenResult = directoryItem.getChildren();\n /* c8 ignore next 3 - defense in depth against internal error */\n if (childrenResult.isFailure()) {\n return fail(`Failed to read directory ${directoryItem.absolutePath}: ${childrenResult.message}`);\n }\n\n for (const child of childrenResult.value) {\n const itemArchivePath = normalizePath(`${archivePrefix}/${child.name}`);\n\n if (child.type === 'directory') {\n // Recursively add subdirectory\n const addDirResult = await this._addDirectoryTreeToZip(files, child, itemArchivePath, onProgress);\n /* c8 ignore next 3 - defense in depth against internal error */\n if (addDirResult.isFailure()) {\n return fail(addDirResult.message);\n }\n } else if (child.type === 'file') {\n // Add file\n const addFileResult = await this._addFileTreeItemToZip(files, child, itemArchivePath);\n /* c8 ignore next 3 - defense in depth against internal error */\n if (addFileResult.isFailure()) {\n return fail(addFileResult.message);\n }\n onProgress?.('reading-file', 0, `Added file: ${itemArchivePath}`);\n }\n }\n\n return succeed(undefined);\n }\n\n private _getInputFileTreeItem(options: ZipArchiveOptions): Result<FileTree.FileTreeItem | undefined> {\n if ('inputPath' in options && options.inputPath !== undefined) {\n return FileTree.forFilesystem()\n .withErrorFormat((msg) => `Failed to create file tree: ${msg}`)\n .onSuccess((fileTree) =>\n fileTree.getItem(options.inputPath!).withErrorFormat((msg) => `Failed to get item: ${msg}`)\n );\n } else if ('inputItem' in options) {\n return succeed(options.inputItem);\n }\n return succeed(undefined);\n }\n\n private _getConfigFileTreeItem(options: ZipArchiveOptions): Result<FileTree.IFileTreeFileItem | undefined> {\n if ('configPath' in options && options.configPath !== undefined) {\n return FileTree.forFilesystem()\n .withErrorFormat((msg) => `Failed to create file tree: ${msg}`)\n .onSuccess((fileTree) =>\n fileTree.getFile(options.configPath!).withErrorFormat((msg) => `Failed to get config file: ${msg}`)\n );\n } else if ('configItem' in options && options.configItem !== undefined) {\n return succeed(options.configItem);\n }\n return succeed(undefined);\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zipArchiveFormat.js","sourceRoot":"","sources":["../../../src/packlets/zip-archive/zipArchiveFormat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAU,aAAa,EAAE,MAAM,eAAe,CAAC;AAGtD,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC;;;;;;;;GAQG;AACH,MAAM,UAAU,wBAAwB,CACtC,SAA+B,EAC/B,YAAoB,EACpB,WAAmB,EACnB,UAAmB;I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AAC;AACjD,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 { Result, captureResult } from '@fgv/ts-utils';\nimport { Model as ConfigModel } from '../config';\nimport * as Json from './json';\nimport * as Convert from './convert';\n\n/**\n * Create a ZIP archive manifest object\n * @param inputType - Type of input (file or directory)\n * @param originalPath - Original file/directory path\n * @param archivePath - Path within the archive\n * @param configPath - Optional configuration file path\n * @returns ZIP archive manifest\n * @public\n */\nexport function createZipArchiveManifest(\n inputType: 'file' | 'directory',\n originalPath: string,\n archivePath: string,\n configPath?: string\n): Json.IZipArchiveManifest {\n const manifest: Json.IZipArchiveManifest = {\n timestamp: new Date().toISOString(),\n input: {\n type: inputType,\n originalPath,\n archivePath\n }\n };\n\n if (configPath) {\n manifest.config = {\n type: 'file',\n originalPath: configPath,\n archivePath: 'config.json'\n };\n }\n\n return manifest;\n}\n\n/**\n * Parse and validate a ZIP archive manifest\n * @param manifestData - JSON string containing manifest data\n * @returns Result containing validated manifest\n * @public\n */\nexport function parseZipArchiveManifest(manifestData: string): Result<Json.IZipArchiveManifest> {\n return captureResult(() => {\n const parsed = JSON.parse(manifestData);\n return parsed;\n })\n .onSuccess((parsed) => Convert.zipArchiveManifest.validate(parsed))\n .withErrorFormat((e) => `Failed to parse ZIP archive manifest: ${e}`);\n}\n\n/**\n * Validate a ZIP archive manifest object\n * @param manifest - Object to validate as manifest\n * @returns Result containing validated manifest\n * @public\n */\nexport function validateZipArchiveManifest(manifest: unknown): Result<Json.IZipArchiveManifest> {\n return Convert.zipArchiveManifest.validate(manifest);\n}\n\n/**\n * Parse and validate configuration JSON\n * @param configData - JSON string containing configuration\n * @returns Result containing validated configuration\n * @public\n */\nexport function parseZipArchiveConfiguration(configData: string): Result<ConfigModel.ISystemConfiguration> {\n return captureResult(() => {\n const parsed = JSON.parse(configData);\n return parsed;\n })\n .onSuccess((parsed) => Convert.systemConfiguration.validate(parsed))\n .withErrorFormat((e) => `Failed to parse ZIP archive configuration: ${e}`);\n}\n\n/**\n * Generate a timestamp-based filename for ZIP archives\n * @param customName - Optional custom name prefix\n * @returns Generated filename\n * @public\n */\nexport function generateZipArchiveFilename(customName?: string): string {\n const timestamp = new Date().toISOString().replace(/[:.]/g, '-').replace('T', '_').slice(0, -5);\n return customName ? `${customName}-${timestamp}.zip` : `ts-res-archive-${timestamp}.zip`;\n}\n\n/**\n * Normalize path separators for cross-platform compatibility\n * @param path - Path to normalize\n * @returns Normalized path\n * @public\n */\nexport function normalizePath(path: string): string {\n return path.replace(/\\\\/g, '/').replace(/\\/+/g, '/');\n}\n\n/**\n * Extract directory name from a file path\n * @param path - File path\n * @returns Directory name\n * @public\n */\nexport function getDirectoryName(path: string): string {\n const normalized = normalizePath(path);\n const parts = normalized.split('/');\n return parts[parts.length - 1] || 'archive';\n}\n\n/**\n * Create a safe filename by removing invalid characters\n * @param filename - Original filename\n * @returns Sanitized filename\n * @public\n */\nexport function sanitizeFilename(filename: string): string {\n return filename\n .replace(/[<>:\"/\\\\|?*]/g, '_')\n .replace(/\\s+/g, '_')\n .replace(/_+/g, '_')\n .trim();\n}\n\n/**\n * Validate ZIP file extension\n * @param filename - Filename to validate\n * @returns True if filename has .zip extension\n * @public\n */\nexport function isZipFile(filename: string): boolean {\n return filename.toLowerCase().endsWith('.zip');\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zipArchiveLoader.js","sourceRoot":"","sources":["../../../src/packlets/zip-archive/zipArchiveLoader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAU,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAEtD,4EAA4E;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAU7C,OAAO,EAAE,uBAAuB,EAAE,4BAA4B,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEtG;;;GAGG;AACH,MAAM,OAAO,gBAAgB;IAC3B;;;;;;OAMG;IACI,KAAK,CAAC,YAAY,CACvB,IAAU,EACV,UAAkC,EAAE,EACpC,UAAuC;QAEvC,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAG,cAAc,EAAE,CAAC,EAAE,iBAAiB,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QAE9D,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1B,OAAO,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,oBAAoB,CAAC,CAAC;QACrD,CAAC;QAED,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC;YACxC,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAG,cAAc,EAAE,GAAG,EAAE,oBAAoB,CAAC,CAAC;YAExD,OAAO,MAAM,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;YAC9D,gEAAgE;QAClE,CA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AW,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;QACpD,mDAAmD;QACnD,QAAQ,GAAG,EAAE,CAAC;YACZ,KAAK,MAAM;gBACT,OAAO,kBAAkB,CAAC;YAC5B,KAAK,MAAM,CAAC;YACZ,KAAK,KAAK;gBACR,OAAO,kBAAkB,CAAC;YAC5B,KAAK,KAAK;gBACR,OAAO,iBAAiB,CAAC;YAC3B,KAAK,KAAK;gBACR,OAAO,YAAY,CAAC;YACtB,KAAK,IAAI;gBACP,OAAO,eAAe,CAAC;YACzB,KAAK,IAAI;gBACP,OAAO,wBAAwB,CAAC;YAClC,KAAK,IAAI;gBACP,OAAO,wBAAwB,CAAC;YAClC;gBACE,OAAO,0BAA0B,CAAC;QACtC,CAAC;IACH,CAAC;CACF","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 { Result, succeed, fail } from '@fgv/ts-utils';\nimport { FileTree } from '@fgv/ts-json-base';\n// ZipFileTree is browser-safe - doesn't depend on Node.js crypto/fs modules\nimport { ZipFileTree } from '@fgv/ts-extras';\nimport type {\n IZipArchiveLoadOptions,\n IZipArchiveLoadResult,\n ZipArchiveProgressCallback,\n IImportedFile,\n IImportedDirectory\n} from './types';\nimport { Model as ConfigModel } from '../config';\nimport * as Json from './json';\nimport { parseZipArchiveManifest, parseZipArchiveConfiguration, isZipFile } from './zipArchiveFormat';\n\n/**\n * ZIP archive loader extending ts-extras foundation\n * @public\n */\nexport class ZipArchiveLoader {\n /**\n * Load ZIP archive from File object (Browser)\n * @param file - File object from file input\n * @param options - Loading options\n * @param onProgress - Optional progress callback\n * @returns Result containing loaded archive data\n */\n public async loadFromFile(\n file: File,\n options: IZipArchiveLoadOptions = {},\n onProgress?: ZipArchiveProgressCallback\n ): Promise<Result<IZipArchiveLoadResult>> {\n onProgress?.('reading-file', 0, `Reading file: ${file.name}`);\n\n if (!isZipFile(file.name)) {\n return fail(`File ${file.name} is not a ZIP file`);\n }\n\n try {\n const buffer = await file.arrayBuffer();\n onProgress?.('reading-file', 100, 'File read complete');\n\n return await this.loadFromBuffer(buffer, options, onProgress);\n /* c8 ignore next 3 - defense in depth against internal error */\n } catch (error) {\n return fail(`Failed to read file: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n\n /**\n * Load ZIP archive from ArrayBuffer (Universal)\n * @param buffer - ZIP data buffer\n * @param options - Loading options\n * @param onProgress - Optional progress callback\n * @returns Result containing loaded archive data\n */\n public async loadFromBuffer(\n buffer: ArrayBuffer,\n options: IZipArchiveLoadOptions = {},\n onProgress?: ZipArchiveProgressCallback\n ): Promise<Result<IZipArchiveLoadResult>> {\n onProgress?.('parsing-zip', 0, 'Parsing ZIP archive');\n\n const zipAccessorsResult = ZipFileTree.ZipFileTreeAccessors.fromBuffer(buffer);\n if (zipAccessorsResult.isFailure()) {\n return fail(`Failed to parse ZIP: ${zipAccessorsResult.message}`);\n }\n\n const zipAccessors = zipAccessorsResult.value;\n onProgress?.('parsing-zip', 100, 'ZIP archive parsed');\n\n // Load manifest\n onProgress?.('loading-manifest', 0, 'Loading manifest');\n const manifestResult = this._loadManifestFromAccessors(zipAccessors);\n if (manifestResult.isFailure()) {\n return fail(manifestResult.message);\n }\n const manifest = manifestResult.value;\n onProgress?.('loading-manifest', 100, 'Manifest loaded');\n\n // Load configuration\n onProgress?.('loading-config', 0, 'Loading configuration');\n const configResult = this._loadConfigurationFromAccessors(zipAccessors, manifest, options);\n if (configResult.isFailure()) {\n return fail(configResult.message);\n }\n const config = configResult.value;\n onProgress?.('loading-config', 100, 'Configuration loaded');\n\n // Extract files and directory structure\n onProgress?.('extracting-files', 0, 'Extracting files');\n const filesResult = await this._extractFilesFromAccessors(zipAccessors, onProgress);\n /* c8 ignore next 3 - defense in depth against internal error */\n if (filesResult.isFailure()) {\n return fail(filesResult.message);\n }\n\n const { files, directory } = filesResult.value;\n onProgress?.('extracting-files', 100, `Extracted ${files.length} files`);\n\n onProgress?.('extracting-files', 100, 'ZIP loading complete');\n\n return succeed({\n manifest,\n config,\n files,\n directory\n });\n }\n\n /**\n * Load manifest from ZIP using ZipFileTreeAccessors\n * @param zipAccessors - ZIP file tree accessors\n * @returns Result containing parsed manifest\n */\n private _loadManifestFromAccessors(\n zipAccessors: ZipFileTree.ZipFileTreeAccessors\n ): Result<Json.IZipArchiveManifest | undefined> {\n const manifestResult = zipAccessors.getFileContents('manifest.json');\n if (manifestResult.isFailure()) {\n // Manifest is optional - return success with undefined\n return succeed(undefined);\n }\n\n const parseResult = parseZipArchiveManifest(manifestResult.value);\n if (parseResult.isFailure()) {\n return fail(`Failed to parse manifest.json: ${parseResult.message}`);\n }\n\n return succeed(parseResult.value);\n }\n\n /**\n * Load configuration from ZIP using ZipFileTreeAccessors\n * @param zipAccessors - ZIP file tree accessors\n * @param manifest - Parsed manifest (may be undefined)\n * @param options - Loading options\n * @returns Result containing parsed configuration\n */\n private _loadConfigurationFromAccessors(\n zipAccessors: ZipFileTree.ZipFileTreeAccessors,\n manifest: Json.IZipArchiveManifest | undefined,\n options: IZipArchiveLoadOptions\n ): Result<ConfigModel.ISystemConfiguration | undefined> {\n // Check if manifest specifies a config file\n const manifestSpecifiesConfig = manifest?.config !== undefined;\n\n if (!manifestSpecifiesConfig) {\n // If no config specified in manifest, config is optional\n return succeed(undefined);\n }\n\n // Get the config path from the manifest\n const configPath = manifest!.config!.archivePath;\n return zipAccessors\n .getFileContents(configPath)\n .withErrorFormat(\n () => `Manifest specifies config file at '${configPath}' but it was not found in archive`\n )\n .onSuccess((configContent) => parseZipArchiveConfiguration(configContent))\n .withErrorFormat((e) => `Failed to parse config file '${configPath}': ${e}`);\n }\n\n /**\n * Extract files and directory structure from ZIP\n * @param zipAccessors - ZIP file tree accessors\n * @param onProgress - Optional progress callback\n * @returns Result containing files and directory structure\n */\n private async _extractFilesFromAccessors(\n zipAccessors: ZipFileTree.ZipFileTreeAccessors,\n onProgress?: ZipArchiveProgressCallback\n ): Promise<Result<{ files: IImportedFile[]; directory: IImportedDirectory | undefined }>> {\n try {\n const files: IImportedFile[] = [];\n const directories = new Map<string, IImportedDirectory>();\n\n // Get all children from root\n const rootChildrenResult = zipAccessors.getChildren('/');\n /* c8 ignore next 3 - defense in depth against internal error */\n if (rootChildrenResult.isFailure()) {\n return fail(`Failed to read ZIP contents: ${rootChildrenResult.message}`);\n }\n\n // Process all items recursively\n await this._processFileTreeItems(\n zipAccessors,\n '/',\n rootChildrenResult.value,\n files,\n directories,\n onProgress\n );\n\n // Build directory structure\n const directory = this._buildDirectoryStructure(files, directories);\n\n return succeed({ files, directory });\n /* c8 ignore next 3 - defense in depth against internal error */\n } catch (error) {\n return fail(`Failed to extract files: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n\n /**\n * Recursively process file tree items\n * @param zipAccessors - ZIP file tree accessors\n * @param currentPath - Current directory path\n * @param items - Items to process\n * @param files - Files collection\n * @param directories - Directories collection\n * @param onProgress - Optional progress callback\n * @param processed - Processing counter\n */\n private async _processFileTreeItems(\n zipAccessors: ZipFileTree.ZipFileTreeAccessors,\n currentPath: string,\n items: readonly FileTree.FileTreeItem[],\n files: IImportedFile[],\n directories: Map<string, IImportedDirectory>,\n onProgress?: ZipArchiveProgressCallback,\n processed: { count: number } = { count: 0 }\n ): Promise<void> {\n for (const item of items) {\n /* c8 ignore next 1 - defense in depth */\n const itemPath = item.absolutePath.startsWith('/') ? item.absolutePath.substring(1) : item.absolutePath;\n\n if (item.type === 'directory') {\n // Track directory\n if (!directories.has(itemPath)) {\n directories.set(itemPath, {\n name: item.name,\n files: [],\n subdirectories: []\n });\n }\n\n // Recursively process children\n const childrenResult = zipAccessors.getChildren(item.absolutePath);\n if (childrenResult.isSuccess()) {\n await this._processFileTreeItems(\n zipAccessors,\n item.absolutePath,\n childrenResult.value,\n files,\n directories,\n onProgress,\n processed\n );\n }\n } else if (item.type === 'file') {\n // Get file content\n const contentResult = item.getRawContents();\n const content = contentResult.orDefault('');\n\n files.push({\n name: item.name,\n path: itemPath,\n content,\n type: this._getFileType(item.name)\n });\n }\n\n processed.count++;\n onProgress?.('extracting-files', 0, `Processing ${itemPath}`);\n }\n }\n\n /**\n * Build directory structure from files\n * @param files - Extracted files\n * @param directories - Directories map\n * @returns Root directory structure or null\n */\n private _buildDirectoryStructure(\n files: IImportedFile[],\n directories: Map<string, IImportedDirectory>\n ): IImportedDirectory | undefined {\n /* c8 ignore next 3 - should never happen with fflate */\n if (files.length === 0) {\n return undefined;\n }\n\n const rootDir: IImportedDirectory = {\n name: 'root',\n files: [],\n subdirectories: []\n };\n\n // Process files to build directory structure\n for (const file of files) {\n const pathParts = file.path.split('/').filter((part: string) => part.length > 0);\n\n /* c8 ignore next 1 - defense in depth should never happen */\n if (pathParts.length === 0) continue;\n\n // Ensure all parent directories exist\n let currentDir = rootDir;\n for (let i = 0; i < pathParts.length - 1; i++) {\n const dirName = pathParts[i];\n let foundDir = currentDir.subdirectories.find((d) => d.name === dirName);\n\n if (!foundDir) {\n foundDir = {\n name: dirName,\n files: [],\n subdirectories: []\n };\n currentDir.subdirectories.push(foundDir);\n }\n\n currentDir = foundDir;\n }\n\n // Add file to its parent directory\n currentDir.files.push(file);\n }\n\n return rootDir;\n }\n\n /**\n * Get file MIME type based on extension\n * @param filename - Filename\n * @returns MIME type\n */\n private _getFileType(filename: string): string {\n const ext = filename.toLowerCase().split('.').pop();\n /* c8 ignore next 20 - no need to test every one */\n switch (ext) {\n case 'json':\n return 'application/json';\n case 'yaml':\n case 'yml':\n return 'application/yaml';\n case 'xml':\n return 'application/xml';\n case 'txt':\n return 'text/plain';\n case 'md':\n return 'text/markdown';\n case 'js':\n return 'application/javascript';\n case 'ts':\n return 'application/typescript';\n default:\n return 'application/octet-stream';\n }\n }\n}\n"]}