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

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 (405) hide show
  1. package/CHANGELOG.json +26 -0
  2. package/CHANGELOG.md +14 -0
  3. package/CLAUDE.md +186 -0
  4. package/EXAMPLE_INIT_PARAMS.md +88 -0
  5. package/PROGRESS_SUMMARY.md +48 -0
  6. package/README.md +535 -14
  7. package/dist/ts-res.d.ts +4241 -318
  8. package/dist/tsdoc-metadata.json +1 -1
  9. package/lib/index.d.ts +4 -1
  10. package/lib/index.d.ts.map +1 -1
  11. package/lib/index.js +7 -1
  12. package/lib/index.js.map +1 -1
  13. package/lib/packlets/common/conditions.d.ts +30 -0
  14. package/lib/packlets/common/conditions.d.ts.map +1 -1
  15. package/lib/packlets/common/conditions.js.map +1 -1
  16. package/lib/packlets/common/convert.d.ts +22 -2
  17. package/lib/packlets/common/convert.d.ts.map +1 -1
  18. package/lib/packlets/common/convert.js +21 -1
  19. package/lib/packlets/common/convert.js.map +1 -1
  20. package/lib/packlets/common/helpers/context.d.ts +39 -0
  21. package/lib/packlets/common/helpers/context.d.ts.map +1 -0
  22. package/lib/packlets/common/helpers/context.js +108 -0
  23. package/lib/packlets/common/helpers/context.js.map +1 -0
  24. package/lib/packlets/common/helpers/index.d.ts +2 -0
  25. package/lib/packlets/common/helpers/index.d.ts.map +1 -1
  26. package/lib/packlets/common/helpers/index.js +2 -0
  27. package/lib/packlets/common/helpers/index.js.map +1 -1
  28. package/lib/packlets/common/helpers/qualifierDefaultValues.d.ts +39 -0
  29. package/lib/packlets/common/helpers/qualifierDefaultValues.d.ts.map +1 -0
  30. package/lib/packlets/common/helpers/qualifierDefaultValues.js +105 -0
  31. package/lib/packlets/common/helpers/qualifierDefaultValues.js.map +1 -0
  32. package/lib/packlets/common/helpers/resources.d.ts.map +1 -1
  33. package/lib/packlets/common/helpers/resources.js +6 -2
  34. package/lib/packlets/common/helpers/resources.js.map +1 -1
  35. package/lib/packlets/common/validate/conditions.d.ts +69 -1
  36. package/lib/packlets/common/validate/conditions.d.ts.map +1 -1
  37. package/lib/packlets/common/validate/conditions.js +126 -0
  38. package/lib/packlets/common/validate/conditions.js.map +1 -1
  39. package/lib/packlets/common/validate/regularExpressions.d.ts +20 -0
  40. package/lib/packlets/common/validate/regularExpressions.d.ts.map +1 -1
  41. package/lib/packlets/common/validate/regularExpressions.js +21 -1
  42. package/lib/packlets/common/validate/regularExpressions.js.map +1 -1
  43. package/lib/packlets/conditions/condition.d.ts +37 -0
  44. package/lib/packlets/conditions/condition.d.ts.map +1 -1
  45. package/lib/packlets/conditions/condition.js +67 -1
  46. package/lib/packlets/conditions/condition.js.map +1 -1
  47. package/lib/packlets/conditions/conditionCollector.d.ts.map +1 -1
  48. package/lib/packlets/conditions/conditionCollector.js +1 -0
  49. package/lib/packlets/conditions/conditionCollector.js.map +1 -1
  50. package/lib/packlets/conditions/conditionSet.d.ts +34 -3
  51. package/lib/packlets/conditions/conditionSet.d.ts.map +1 -1
  52. package/lib/packlets/conditions/conditionSet.js +31 -3
  53. package/lib/packlets/conditions/conditionSet.js.map +1 -1
  54. package/lib/packlets/conditions/conditionSetCollector.d.ts.map +1 -1
  55. package/lib/packlets/conditions/conditionSetCollector.js +3 -0
  56. package/lib/packlets/conditions/conditionSetCollector.js.map +1 -1
  57. package/lib/packlets/conditions/conditionToken.d.ts.map +1 -1
  58. package/lib/packlets/conditions/conditionToken.js +2 -1
  59. package/lib/packlets/conditions/conditionToken.js.map +1 -1
  60. package/lib/packlets/conditions/convert/decls.js +1 -1
  61. package/lib/packlets/conditions/convert/decls.js.map +1 -1
  62. package/lib/packlets/config/common.d.ts +35 -0
  63. package/lib/packlets/config/common.d.ts.map +1 -0
  64. package/lib/packlets/config/common.js +96 -0
  65. package/lib/packlets/config/common.js.map +1 -0
  66. package/lib/packlets/config/convert.d.ts +14 -0
  67. package/lib/packlets/config/convert.d.ts.map +1 -0
  68. package/lib/packlets/config/convert.js +82 -0
  69. package/lib/packlets/config/convert.js.map +1 -0
  70. package/lib/packlets/config/index.d.ts +6 -0
  71. package/lib/packlets/config/index.d.ts.map +1 -0
  72. package/lib/packlets/config/index.js +67 -0
  73. package/lib/packlets/config/index.js.map +1 -0
  74. package/lib/packlets/config/json.d.ts +20 -0
  75. package/lib/packlets/config/json.d.ts.map +1 -0
  76. package/lib/packlets/config/json.js +24 -0
  77. package/lib/packlets/config/json.js.map +1 -0
  78. package/lib/packlets/config/predefined/default.d.ts +57 -0
  79. package/lib/packlets/config/predefined/default.d.ts.map +1 -0
  80. package/lib/packlets/config/predefined/default.js +141 -0
  81. package/lib/packlets/config/predefined/default.js.map +1 -0
  82. package/lib/packlets/config/predefined/extended.d.ts +25 -0
  83. package/lib/packlets/config/predefined/extended.d.ts.map +1 -0
  84. package/lib/packlets/config/predefined/extended.js +193 -0
  85. package/lib/packlets/config/predefined/extended.js.map +1 -0
  86. package/lib/packlets/config/predefined/index.d.ts +4 -0
  87. package/lib/packlets/config/predefined/index.d.ts.map +1 -0
  88. package/lib/packlets/config/predefined/index.js +62 -0
  89. package/lib/packlets/config/predefined/index.js.map +1 -0
  90. package/lib/packlets/config/systemConfiguration.d.ts +81 -0
  91. package/lib/packlets/config/systemConfiguration.d.ts.map +1 -0
  92. package/lib/packlets/config/systemConfiguration.js +172 -0
  93. package/lib/packlets/config/systemConfiguration.js.map +1 -0
  94. package/lib/packlets/context/contextDecls.d.ts +49 -0
  95. package/lib/packlets/context/contextDecls.d.ts.map +1 -0
  96. package/lib/packlets/context/contextDecls.js +24 -0
  97. package/lib/packlets/context/contextDecls.js.map +1 -0
  98. package/lib/packlets/context/contextToken.d.ts +111 -0
  99. package/lib/packlets/context/contextToken.d.ts.map +1 -0
  100. package/lib/packlets/context/contextToken.js +206 -0
  101. package/lib/packlets/context/contextToken.js.map +1 -0
  102. package/lib/packlets/context/convert/decls.d.ts +37 -0
  103. package/lib/packlets/context/convert/decls.d.ts.map +1 -0
  104. package/lib/packlets/context/convert/decls.js +94 -0
  105. package/lib/packlets/context/convert/decls.js.map +1 -0
  106. package/lib/packlets/context/convert/index.d.ts +2 -0
  107. package/lib/packlets/context/convert/index.d.ts.map +1 -0
  108. package/lib/packlets/context/convert/index.js +39 -0
  109. package/lib/packlets/context/convert/index.js.map +1 -0
  110. package/lib/packlets/context/index.d.ts +5 -0
  111. package/lib/packlets/context/index.d.ts.map +1 -0
  112. package/lib/packlets/context/index.js +65 -0
  113. package/lib/packlets/context/index.js.map +1 -0
  114. package/lib/packlets/decisions/abstractDecision.d.ts +8 -0
  115. package/lib/packlets/decisions/abstractDecision.d.ts.map +1 -1
  116. package/lib/packlets/decisions/abstractDecision.js +9 -0
  117. package/lib/packlets/decisions/abstractDecision.js.map +1 -1
  118. package/lib/packlets/decisions/abstractDecisionCollector.d.ts.map +1 -1
  119. package/lib/packlets/decisions/abstractDecisionCollector.js +2 -0
  120. package/lib/packlets/decisions/abstractDecisionCollector.js.map +1 -1
  121. package/lib/packlets/decisions/concreteDecision.d.ts.map +1 -1
  122. package/lib/packlets/decisions/concreteDecision.js +1 -0
  123. package/lib/packlets/decisions/concreteDecision.js.map +1 -1
  124. package/lib/packlets/decisions/decision.d.ts.map +1 -1
  125. package/lib/packlets/decisions/decision.js +4 -0
  126. package/lib/packlets/decisions/decision.js.map +1 -1
  127. package/lib/packlets/import/fsItem.d.ts.map +1 -1
  128. package/lib/packlets/import/fsItem.js +1 -0
  129. package/lib/packlets/import/fsItem.js.map +1 -1
  130. package/lib/packlets/import/importContext.d.ts +19 -0
  131. package/lib/packlets/import/importContext.d.ts.map +1 -1
  132. package/lib/packlets/import/importContext.js +39 -0
  133. package/lib/packlets/import/importContext.js.map +1 -1
  134. package/lib/packlets/import/importManager.d.ts +5 -5
  135. package/lib/packlets/import/importManager.d.ts.map +1 -1
  136. package/lib/packlets/import/importManager.js.map +1 -1
  137. package/lib/packlets/import/importers/collectionImporter.d.ts +11 -13
  138. package/lib/packlets/import/importers/collectionImporter.d.ts.map +1 -1
  139. package/lib/packlets/import/importers/collectionImporter.js +29 -20
  140. package/lib/packlets/import/importers/collectionImporter.js.map +1 -1
  141. package/lib/packlets/import/importers/fsItemImporter.d.ts +2 -2
  142. package/lib/packlets/import/importers/fsItemImporter.d.ts.map +1 -1
  143. package/lib/packlets/import/importers/fsItemImporter.js +2 -2
  144. package/lib/packlets/import/importers/fsItemImporter.js.map +1 -1
  145. package/lib/packlets/import/importers/importer.d.ts +3 -3
  146. package/lib/packlets/import/importers/importer.d.ts.map +1 -1
  147. package/lib/packlets/import/importers/importer.js.map +1 -1
  148. package/lib/packlets/import/importers/jsonImporter.d.ts +2 -3
  149. package/lib/packlets/import/importers/jsonImporter.d.ts.map +1 -1
  150. package/lib/packlets/import/importers/jsonImporter.js +10 -20
  151. package/lib/packlets/import/importers/jsonImporter.js.map +1 -1
  152. package/lib/packlets/import/importers/pathImporter.d.ts +2 -2
  153. package/lib/packlets/import/importers/pathImporter.d.ts.map +1 -1
  154. package/lib/packlets/import/importers/pathImporter.js.map +1 -1
  155. package/lib/packlets/qualifier-types/config/convert.d.ts +44 -0
  156. package/lib/packlets/qualifier-types/config/convert.d.ts.map +1 -0
  157. package/lib/packlets/qualifier-types/config/convert.js +96 -0
  158. package/lib/packlets/qualifier-types/config/convert.js.map +1 -0
  159. package/lib/packlets/qualifier-types/config/index.d.ts +4 -0
  160. package/lib/packlets/qualifier-types/config/index.d.ts.map +1 -0
  161. package/lib/packlets/qualifier-types/config/index.js +64 -0
  162. package/lib/packlets/qualifier-types/config/index.js.map +1 -0
  163. package/lib/packlets/qualifier-types/config/json.d.ts +69 -0
  164. package/lib/packlets/qualifier-types/config/json.d.ts.map +1 -0
  165. package/lib/packlets/qualifier-types/config/json.js +24 -0
  166. package/lib/packlets/qualifier-types/config/json.js.map +1 -0
  167. package/lib/packlets/qualifier-types/convert.d.ts +10 -2
  168. package/lib/packlets/qualifier-types/convert.d.ts.map +1 -1
  169. package/lib/packlets/qualifier-types/convert.js +15 -0
  170. package/lib/packlets/qualifier-types/convert.js.map +1 -1
  171. package/lib/packlets/qualifier-types/helpers.d.ts +27 -0
  172. package/lib/packlets/qualifier-types/helpers.d.ts.map +1 -0
  173. package/lib/packlets/qualifier-types/helpers.js +118 -0
  174. package/lib/packlets/qualifier-types/helpers.js.map +1 -0
  175. package/lib/packlets/qualifier-types/index.d.ts +4 -1
  176. package/lib/packlets/qualifier-types/index.d.ts.map +1 -1
  177. package/lib/packlets/qualifier-types/index.js +5 -1
  178. package/lib/packlets/qualifier-types/index.js.map +1 -1
  179. package/lib/packlets/qualifier-types/languageQualifierType.d.ts +19 -8
  180. package/lib/packlets/qualifier-types/languageQualifierType.d.ts.map +1 -1
  181. package/lib/packlets/qualifier-types/languageQualifierType.js +28 -9
  182. package/lib/packlets/qualifier-types/languageQualifierType.js.map +1 -1
  183. package/lib/packlets/qualifier-types/literalQualifierType.d.ts +42 -13
  184. package/lib/packlets/qualifier-types/literalQualifierType.d.ts.map +1 -1
  185. package/lib/packlets/qualifier-types/literalQualifierType.js +58 -10
  186. package/lib/packlets/qualifier-types/literalQualifierType.js.map +1 -1
  187. package/lib/packlets/qualifier-types/literalValueHierarchy.d.ts +114 -0
  188. package/lib/packlets/qualifier-types/literalValueHierarchy.d.ts.map +1 -0
  189. package/lib/packlets/qualifier-types/literalValueHierarchy.js +228 -0
  190. package/lib/packlets/qualifier-types/literalValueHierarchy.js.map +1 -0
  191. package/lib/packlets/qualifier-types/qualifierType.d.ts +33 -18
  192. package/lib/packlets/qualifier-types/qualifierType.d.ts.map +1 -1
  193. package/lib/packlets/qualifier-types/qualifierType.js +18 -4
  194. package/lib/packlets/qualifier-types/qualifierType.js.map +1 -1
  195. package/lib/packlets/qualifier-types/qualifierTypeCollector.d.ts +4 -2
  196. package/lib/packlets/qualifier-types/qualifierTypeCollector.d.ts.map +1 -1
  197. package/lib/packlets/qualifier-types/qualifierTypeCollector.js +2 -1
  198. package/lib/packlets/qualifier-types/qualifierTypeCollector.js.map +1 -1
  199. package/lib/packlets/qualifier-types/territoryQualifierType.d.ts +47 -11
  200. package/lib/packlets/qualifier-types/territoryQualifierType.d.ts.map +1 -1
  201. package/lib/packlets/qualifier-types/territoryQualifierType.js +61 -17
  202. package/lib/packlets/qualifier-types/territoryQualifierType.js.map +1 -1
  203. package/lib/packlets/qualifiers/convert/decls.d.ts.map +1 -1
  204. package/lib/packlets/qualifiers/convert/decls.js +17 -15
  205. package/lib/packlets/qualifiers/convert/decls.js.map +1 -1
  206. package/lib/packlets/qualifiers/index.d.ts +2 -0
  207. package/lib/packlets/qualifiers/index.d.ts.map +1 -1
  208. package/lib/packlets/qualifiers/index.js +2 -0
  209. package/lib/packlets/qualifiers/index.js.map +1 -1
  210. package/lib/packlets/qualifiers/qualifier.d.ts +22 -2
  211. package/lib/packlets/qualifiers/qualifier.d.ts.map +1 -1
  212. package/lib/packlets/qualifiers/qualifier.js +26 -1
  213. package/lib/packlets/qualifiers/qualifier.js.map +1 -1
  214. package/lib/packlets/qualifiers/qualifierCollector.d.ts.map +1 -1
  215. package/lib/packlets/qualifiers/qualifierCollector.js +4 -0
  216. package/lib/packlets/qualifiers/qualifierCollector.js.map +1 -1
  217. package/lib/packlets/qualifiers/qualifierDecl.d.ts +6 -1
  218. package/lib/packlets/qualifiers/qualifierDecl.d.ts.map +1 -1
  219. package/lib/packlets/qualifiers/qualifierDecl.js.map +1 -1
  220. package/lib/packlets/qualifiers/qualifierDefaultValueDecls.d.ts +32 -0
  221. package/lib/packlets/qualifiers/qualifierDefaultValueDecls.d.ts.map +1 -0
  222. package/lib/packlets/qualifiers/qualifierDefaultValueDecls.js +24 -0
  223. package/lib/packlets/qualifiers/qualifierDefaultValueDecls.js.map +1 -0
  224. package/lib/packlets/qualifiers/qualifierDefaultValueToken.d.ts +96 -0
  225. package/lib/packlets/qualifiers/qualifierDefaultValueToken.d.ts.map +1 -0
  226. package/lib/packlets/qualifiers/qualifierDefaultValueToken.js +179 -0
  227. package/lib/packlets/qualifiers/qualifierDefaultValueToken.js.map +1 -0
  228. package/lib/packlets/resource-json/compiled/common.d.ts +14 -0
  229. package/lib/packlets/resource-json/compiled/common.d.ts.map +1 -0
  230. package/lib/packlets/resource-json/compiled/common.js +24 -0
  231. package/lib/packlets/resource-json/compiled/common.js.map +1 -0
  232. package/lib/packlets/resource-json/compiled/convert.d.ts +63 -0
  233. package/lib/packlets/resource-json/compiled/convert.d.ts.map +1 -0
  234. package/lib/packlets/resource-json/compiled/convert.js +167 -0
  235. package/lib/packlets/resource-json/compiled/convert.js.map +1 -0
  236. package/lib/packlets/resource-json/compiled/index.d.ts +5 -0
  237. package/lib/packlets/resource-json/compiled/index.d.ts.map +1 -0
  238. package/lib/packlets/resource-json/compiled/index.js +65 -0
  239. package/lib/packlets/resource-json/compiled/index.js.map +1 -0
  240. package/lib/packlets/resource-json/compiled/json.d.ts +204 -0
  241. package/lib/packlets/resource-json/compiled/json.d.ts.map +1 -0
  242. package/lib/packlets/resource-json/compiled/json.js +3 -0
  243. package/lib/packlets/resource-json/compiled/json.js.map +1 -0
  244. package/lib/packlets/resource-json/convert.d.ts +16 -0
  245. package/lib/packlets/resource-json/convert.d.ts.map +1 -1
  246. package/lib/packlets/resource-json/convert.js +41 -6
  247. package/lib/packlets/resource-json/convert.js.map +1 -1
  248. package/lib/packlets/resource-json/helpers.d.ts +82 -3
  249. package/lib/packlets/resource-json/helpers.d.ts.map +1 -1
  250. package/lib/packlets/resource-json/helpers.js +185 -2
  251. package/lib/packlets/resource-json/helpers.js.map +1 -1
  252. package/lib/packlets/resource-json/index.d.ts +2 -1
  253. package/lib/packlets/resource-json/index.d.ts.map +1 -1
  254. package/lib/packlets/resource-json/index.js +3 -1
  255. package/lib/packlets/resource-json/index.js.map +1 -1
  256. package/lib/packlets/resource-json/json.d.ts +55 -3
  257. package/lib/packlets/resource-json/json.d.ts.map +1 -1
  258. package/lib/packlets/resource-json/json.js +16 -0
  259. package/lib/packlets/resource-json/json.js.map +1 -1
  260. package/lib/packlets/resource-json/normalized.d.ts +46 -3
  261. package/lib/packlets/resource-json/normalized.d.ts.map +1 -1
  262. package/lib/packlets/resource-json/normalized.js.map +1 -1
  263. package/lib/packlets/resource-json/resourceDeclCollection.d.ts +14 -10
  264. package/lib/packlets/resource-json/resourceDeclCollection.d.ts.map +1 -1
  265. package/lib/packlets/resource-json/resourceDeclCollection.js +18 -14
  266. package/lib/packlets/resource-json/resourceDeclCollection.js.map +1 -1
  267. package/lib/packlets/resource-json/resourceDeclContainer.d.ts +15 -2
  268. package/lib/packlets/resource-json/resourceDeclContainer.d.ts.map +1 -1
  269. package/lib/packlets/resource-json/resourceDeclContainer.js.map +1 -1
  270. package/lib/packlets/resource-json/resourceDeclTree.d.ts +6 -2
  271. package/lib/packlets/resource-json/resourceDeclTree.d.ts.map +1 -1
  272. package/lib/packlets/resource-json/resourceDeclTree.js +12 -3
  273. package/lib/packlets/resource-json/resourceDeclTree.js.map +1 -1
  274. package/lib/packlets/resource-types/config/convert.d.ts +8 -0
  275. package/lib/packlets/resource-types/config/convert.d.ts.map +1 -0
  276. package/lib/packlets/resource-types/config/convert.js +36 -0
  277. package/lib/packlets/resource-types/config/convert.js.map +1 -0
  278. package/lib/packlets/resource-types/config/index.d.ts +4 -0
  279. package/lib/packlets/resource-types/config/index.d.ts.map +1 -0
  280. package/lib/packlets/resource-types/config/index.js +64 -0
  281. package/lib/packlets/resource-types/config/index.js.map +1 -0
  282. package/lib/packlets/resource-types/config/json.d.ts +9 -0
  283. package/lib/packlets/resource-types/config/json.d.ts.map +1 -0
  284. package/lib/packlets/resource-types/config/json.js +24 -0
  285. package/lib/packlets/resource-types/config/json.js.map +1 -0
  286. package/lib/packlets/resource-types/helpers.d.ts +13 -0
  287. package/lib/packlets/resource-types/helpers.d.ts.map +1 -0
  288. package/lib/packlets/resource-types/helpers.js +44 -0
  289. package/lib/packlets/resource-types/helpers.js.map +1 -0
  290. package/lib/packlets/resource-types/index.d.ts +3 -0
  291. package/lib/packlets/resource-types/index.d.ts.map +1 -1
  292. package/lib/packlets/resource-types/index.js +26 -0
  293. package/lib/packlets/resource-types/index.js.map +1 -1
  294. package/lib/packlets/resource-types/jsonResourceType.d.ts +5 -13
  295. package/lib/packlets/resource-types/jsonResourceType.d.ts.map +1 -1
  296. package/lib/packlets/resource-types/jsonResourceType.js +5 -2
  297. package/lib/packlets/resource-types/jsonResourceType.js.map +1 -1
  298. package/lib/packlets/resource-types/resourceType.d.ts +31 -30
  299. package/lib/packlets/resource-types/resourceType.d.ts.map +1 -1
  300. package/lib/packlets/resource-types/resourceType.js.map +1 -1
  301. package/lib/packlets/resources/candidateReducer.d.ts +98 -0
  302. package/lib/packlets/resources/candidateReducer.d.ts.map +1 -0
  303. package/lib/packlets/resources/candidateReducer.js +247 -0
  304. package/lib/packlets/resources/candidateReducer.js.map +1 -0
  305. package/lib/packlets/resources/common.d.ts +60 -0
  306. package/lib/packlets/resources/common.d.ts.map +1 -0
  307. package/lib/packlets/resources/common.js +24 -0
  308. package/lib/packlets/resources/common.js.map +1 -0
  309. package/lib/packlets/resources/index.d.ts +3 -1
  310. package/lib/packlets/resources/index.d.ts.map +1 -1
  311. package/lib/packlets/resources/index.js +3 -1
  312. package/lib/packlets/resources/index.js.map +1 -1
  313. package/lib/packlets/resources/resource.d.ts +57 -5
  314. package/lib/packlets/resources/resource.d.ts.map +1 -1
  315. package/lib/packlets/resources/resource.js +96 -6
  316. package/lib/packlets/resources/resource.js.map +1 -1
  317. package/lib/packlets/resources/resourceBuilder.d.ts +14 -0
  318. package/lib/packlets/resources/resourceBuilder.d.ts.map +1 -1
  319. package/lib/packlets/resources/resourceBuilder.js +19 -1
  320. package/lib/packlets/resources/resourceBuilder.js.map +1 -1
  321. package/lib/packlets/resources/resourceCandidate.d.ts +42 -6
  322. package/lib/packlets/resources/resourceCandidate.d.ts.map +1 -1
  323. package/lib/packlets/resources/resourceCandidate.js +40 -1
  324. package/lib/packlets/resources/resourceCandidate.js.map +1 -1
  325. package/lib/packlets/resources/resourceManagerBuilder.d.ts +220 -0
  326. package/lib/packlets/resources/resourceManagerBuilder.d.ts.map +1 -0
  327. package/lib/packlets/resources/resourceManagerBuilder.js +451 -0
  328. package/lib/packlets/resources/resourceManagerBuilder.js.map +1 -0
  329. package/lib/packlets/runtime/cacheListener.d.ts +62 -0
  330. package/lib/packlets/runtime/cacheListener.d.ts.map +1 -0
  331. package/lib/packlets/runtime/cacheListener.js +56 -0
  332. package/lib/packlets/runtime/cacheListener.js.map +1 -0
  333. package/lib/packlets/runtime/cacheMetrics.d.ts +82 -0
  334. package/lib/packlets/runtime/cacheMetrics.d.ts.map +1 -0
  335. package/lib/packlets/runtime/cacheMetrics.js +143 -0
  336. package/lib/packlets/runtime/cacheMetrics.js.map +1 -0
  337. package/lib/packlets/runtime/compiledResourceCollection.d.ts +167 -0
  338. package/lib/packlets/runtime/compiledResourceCollection.d.ts.map +1 -0
  339. package/lib/packlets/runtime/compiledResourceCollection.js +466 -0
  340. package/lib/packlets/runtime/compiledResourceCollection.js.map +1 -0
  341. package/lib/packlets/runtime/conditionSetResolutionResult.d.ts +70 -0
  342. package/lib/packlets/runtime/conditionSetResolutionResult.d.ts.map +1 -0
  343. package/lib/packlets/runtime/conditionSetResolutionResult.js +135 -0
  344. package/lib/packlets/runtime/conditionSetResolutionResult.js.map +1 -0
  345. package/lib/packlets/runtime/context/contextQualifierProvider.d.ts +80 -0
  346. package/lib/packlets/runtime/context/contextQualifierProvider.d.ts.map +1 -0
  347. package/lib/packlets/runtime/context/contextQualifierProvider.js +33 -0
  348. package/lib/packlets/runtime/context/contextQualifierProvider.js.map +1 -0
  349. package/lib/packlets/runtime/context/contextQualifierProviderValidator.d.ts +165 -0
  350. package/lib/packlets/runtime/context/contextQualifierProviderValidator.d.ts.map +1 -0
  351. package/lib/packlets/runtime/context/contextQualifierProviderValidator.js +179 -0
  352. package/lib/packlets/runtime/context/contextQualifierProviderValidator.js.map +1 -0
  353. package/lib/packlets/runtime/context/index.d.ts +5 -0
  354. package/lib/packlets/runtime/context/index.d.ts.map +1 -0
  355. package/lib/packlets/runtime/context/index.js +42 -0
  356. package/lib/packlets/runtime/context/index.js.map +1 -0
  357. package/lib/packlets/runtime/context/simpleContextQualifierProvider.d.ts +111 -0
  358. package/lib/packlets/runtime/context/simpleContextQualifierProvider.d.ts.map +1 -0
  359. package/lib/packlets/runtime/context/simpleContextQualifierProvider.js +177 -0
  360. package/lib/packlets/runtime/context/simpleContextQualifierProvider.js.map +1 -0
  361. package/lib/packlets/runtime/context/validatingSimpleContextQualifierProvider.d.ts +47 -0
  362. package/lib/packlets/runtime/context/validatingSimpleContextQualifierProvider.d.ts.map +1 -0
  363. package/lib/packlets/runtime/context/validatingSimpleContextQualifierProvider.js +64 -0
  364. package/lib/packlets/runtime/context/validatingSimpleContextQualifierProvider.js.map +1 -0
  365. package/lib/packlets/runtime/iResourceManager.d.ts +88 -0
  366. package/lib/packlets/runtime/iResourceManager.d.ts.map +1 -0
  367. package/lib/packlets/runtime/iResourceManager.js +24 -0
  368. package/lib/packlets/runtime/iResourceManager.js.map +1 -0
  369. package/lib/packlets/runtime/index.d.ts +12 -0
  370. package/lib/packlets/runtime/index.d.ts.map +1 -0
  371. package/lib/packlets/runtime/index.js +73 -0
  372. package/lib/packlets/runtime/index.js.map +1 -0
  373. package/lib/packlets/runtime/resource-tree/common.d.ts +91 -0
  374. package/lib/packlets/runtime/resource-tree/common.d.ts.map +1 -0
  375. package/lib/packlets/runtime/resource-tree/common.js +24 -0
  376. package/lib/packlets/runtime/resource-tree/common.js.map +1 -0
  377. package/lib/packlets/runtime/resource-tree/index.d.ts +5 -0
  378. package/lib/packlets/runtime/resource-tree/index.d.ts.map +1 -0
  379. package/lib/packlets/runtime/resource-tree/index.js +42 -0
  380. package/lib/packlets/runtime/resource-tree/index.js.map +1 -0
  381. package/lib/packlets/runtime/resource-tree/readOnlyResourceTree.d.ts +141 -0
  382. package/lib/packlets/runtime/resource-tree/readOnlyResourceTree.d.ts.map +1 -0
  383. package/lib/packlets/runtime/resource-tree/readOnlyResourceTree.js +224 -0
  384. package/lib/packlets/runtime/resource-tree/readOnlyResourceTree.js.map +1 -0
  385. package/lib/packlets/runtime/resource-tree/resourceTreeChildren.d.ts +24 -0
  386. package/lib/packlets/runtime/resource-tree/resourceTreeChildren.d.ts.map +1 -0
  387. package/lib/packlets/runtime/resource-tree/resourceTreeChildren.js +98 -0
  388. package/lib/packlets/runtime/resource-tree/resourceTreeChildren.js.map +1 -0
  389. package/lib/packlets/runtime/resource-tree/resourceTreeChildrenValidator.d.ts +99 -0
  390. package/lib/packlets/runtime/resource-tree/resourceTreeChildrenValidator.d.ts.map +1 -0
  391. package/lib/packlets/runtime/resource-tree/resourceTreeChildrenValidator.js +165 -0
  392. package/lib/packlets/runtime/resource-tree/resourceTreeChildrenValidator.js.map +1 -0
  393. package/lib/packlets/runtime/resourceResolver.d.ts +196 -0
  394. package/lib/packlets/runtime/resourceResolver.d.ts.map +1 -0
  395. package/lib/packlets/runtime/resourceResolver.js +437 -0
  396. package/lib/packlets/runtime/resourceResolver.js.map +1 -0
  397. package/lib/packlets/runtime/validate.d.ts +13 -0
  398. package/lib/packlets/runtime/validate.d.ts.map +1 -0
  399. package/lib/packlets/runtime/validate.js +49 -0
  400. package/lib/packlets/runtime/validate.js.map +1 -0
  401. package/package.json +76 -75
  402. package/lib/packlets/resources/resourceManager.d.ts +0 -104
  403. package/lib/packlets/resources/resourceManager.d.ts.map +0 -1
  404. package/lib/packlets/resources/resourceManager.js +0 -201
  405. package/lib/packlets/resources/resourceManager.js.map +0 -1
@@ -31,11 +31,37 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
31
31
  if (k2 === undefined) k2 = k;
32
32
  o[k2] = m[k];
33
33
  }));
34
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
35
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
36
+ }) : function(o, v) {
37
+ o["default"] = v;
38
+ });
39
+ var __importStar = (this && this.__importStar) || (function () {
40
+ var ownKeys = function(o) {
41
+ ownKeys = Object.getOwnPropertyNames || function (o) {
42
+ var ar = [];
43
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
44
+ return ar;
45
+ };
46
+ return ownKeys(o);
47
+ };
48
+ return function (mod) {
49
+ if (mod && mod.__esModule) return mod;
50
+ var result = {};
51
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
52
+ __setModuleDefault(result, mod);
53
+ return result;
54
+ };
55
+ })();
34
56
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
35
57
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
36
58
  };
37
59
  Object.defineProperty(exports, "__esModule", { value: true });
60
+ exports.Config = void 0;
61
+ const Config = __importStar(require("./config"));
62
+ exports.Config = Config;
38
63
  __exportStar(require("./resourceType"), exports);
39
64
  __exportStar(require("./resourceTypeCollector"), exports);
40
65
  __exportStar(require("./jsonResourceType"), exports);
66
+ __exportStar(require("./helpers"), exports);
41
67
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/resource-types/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;AAEH,iDAA+B;AAC/B,0DAAwC;AACxC,qDAAmC","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\nexport * from './resourceType';\nexport * from './resourceTypeCollector';\nexport * from './jsonResourceType';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/resource-types/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,iDAAmC;AAO1B,wBAAM;AALf,iDAA+B;AAC/B,0DAAwC;AACxC,qDAAmC;AACnC,4CAA0B","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport * as Config from './config';\n\nexport * from './resourceType';\nexport * from './resourceTypeCollector';\nexport * from './jsonResourceType';\nexport * from './helpers';\n\nexport { Config };\n"]}
@@ -1,6 +1,6 @@
1
- import { JsonObject, JsonValue } from '@fgv/ts-json-base';
2
- import { ResourceType } from './resourceType';
3
- import { ResourceTypeName, ResourceValueMergeMethod } from '../common';
1
+ import { JsonObject } from '@fgv/ts-json-base';
2
+ import { IResourceCandidateValidationProperties, ResourceType } from './resourceType';
3
+ import { ResourceTypeName } from '../common';
4
4
  import { Result } from '@fgv/ts-utils';
5
5
  /**
6
6
  * Parameters to create a {@link ResourceTypes.JsonResourceType | JsonResourceType} instance.
@@ -38,17 +38,9 @@ export declare class JsonResourceType extends ResourceType<JsonObject> {
38
38
  */
39
39
  static create(params?: IJsonResourceTypeCreateParams): Result<JsonResourceType>;
40
40
  /**
41
- * {@inheritdoc ResourceTypes.ResourceType.(validateDeclaration:1)}
41
+ * {@inheritdoc ResourceTypes.ResourceType.validateDeclaration}
42
42
  */
43
- validateDeclaration(json: JsonValue, isPartial: true, mergeMethod?: ResourceValueMergeMethod): Result<Partial<JsonObject>>;
44
- /**
45
- * {@inheritdoc ResourceTypes.ResourceType.(validateDeclaration:2)}
46
- */
47
- validateDeclaration(json: JsonValue, isPartial: false, mergeMethod?: ResourceValueMergeMethod): Result<JsonObject>;
48
- /**
49
- * {@inheritdoc ResourceTypes.ResourceType.(validateDeclaration:3)}
50
- */
51
- validateDeclaration(json: JsonValue, isPartial: boolean, mergeMethod?: ResourceValueMergeMethod): Result<JsonObject | Partial<JsonObject>>;
43
+ validateDeclaration(props: IResourceCandidateValidationProperties): Result<JsonObject>;
52
44
  /**
53
45
  * {@inheritdoc ResourceTypes.ResourceType.(validate:1)}
54
46
  */
@@ -1 +1 @@
1
- {"version":3,"file":"jsonResourceType.d.ts","sourceRoot":"","sources":["../../../src/packlets/resource-types/jsonResourceType.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAgC,UAAU,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACxF,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAW,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAChF,OAAO,EAAiB,MAAM,EAAE,MAAM,eAAe,CAAC;AAEtD;;;GAGG;AACH,MAAM,WAAW,6BAA6B;IAC5C;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,YAAY,CAAC,UAAU,CAAC;IAC5D;;;;;OAKG;IACH,SAAS,aAAa,GAAG,EAAE,gBAAgB,EAAE,KAAK,CAAC,EAAE,MAAM;IAI3D;;;;;OAKG;WACW,MAAM,CAAC,MAAM,CAAC,EAAE,6BAA6B,GAAG,MAAM,CAAC,gBAAgB,CAAC;IAMtF;;OAEG;IACI,mBAAmB,CACxB,IAAI,EAAE,SAAS,EACf,SAAS,EAAE,IAAI,EACf,WAAW,CAAC,EAAE,wBAAwB,GACrC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAC9B;;OAEG;IACI,mBAAmB,CACxB,IAAI,EAAE,SAAS,EACf,SAAS,EAAE,KAAK,EAChB,WAAW,CAAC,EAAE,wBAAwB,GACrC,MAAM,CAAC,UAAU,CAAC;IACrB;;OAEG;IACI,mBAAmB,CACxB,IAAI,EAAE,SAAS,EACf,SAAS,EAAE,OAAO,EAClB,WAAW,CAAC,EAAE,wBAAwB,GACrC,MAAM,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAS3C;;OAEG;IACI,QAAQ,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC;IACtE;;OAEG;IACI,QAAQ,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC;IACvE;;OAEG;IACI,QAAQ,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC;CAI1E"}
1
+ {"version":3,"file":"jsonResourceType.d.ts","sourceRoot":"","sources":["../../../src/packlets/resource-types/jsonResourceType.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAgC,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,sCAAsC,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACtF,OAAO,EAAW,gBAAgB,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAiB,MAAM,EAAE,MAAM,eAAe,CAAC;AAEtD;;;GAGG;AACH,MAAM,WAAW,6BAA6B;IAC5C;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,YAAY,CAAC,UAAU,CAAC;IAC5D;;;;;OAKG;IACH,SAAS,aAAa,GAAG,EAAE,gBAAgB,EAAE,KAAK,CAAC,EAAE,MAAM;IAI3D;;;;;OAKG;WACW,MAAM,CAAC,MAAM,CAAC,EAAE,6BAA6B,GAAG,MAAM,CAAC,gBAAgB,CAAC;IAMtF;;OAEG;IAEI,mBAAmB,CAAC,KAAK,EAAE,sCAAsC,GAAG,MAAM,CAAC,UAAU,CAAC;IAI7F;;OAEG;IACI,QAAQ,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC;IACtE;;OAEG;IACI,QAAQ,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC;IACvE;;OAEG;IACI,QAAQ,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC;CAI1E"}
@@ -52,8 +52,11 @@ class JsonResourceType extends resourceType_1.ResourceType {
52
52
  return (0, ts_utils_1.captureResult)(() => new JsonResourceType(key, params === null || params === void 0 ? void 0 : params.index));
53
53
  });
54
54
  }
55
- validateDeclaration(json, __isPartial, __mergeMethod) {
56
- return ts_json_base_1.Converters.jsonObject.convert(json);
55
+ /**
56
+ * {@inheritdoc ResourceTypes.ResourceType.validateDeclaration}
57
+ */
58
+ validateDeclaration(props) {
59
+ return ts_json_base_1.Converters.jsonObject.convert(props.json);
57
60
  }
58
61
  validate(json, __isPartial) {
59
62
  return ts_json_base_1.Converters.jsonObject.convert(json);
@@ -1 +1 @@
1
- {"version":3,"file":"jsonResourceType.js","sourceRoot":"","sources":["../../../src/packlets/resource-types/jsonResourceType.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,oDAAwF;AACxF,iDAA8C;AAC9C,sCAAgF;AAChF,4CAAsD;AAoBtD;;;GAGG;AACH,MAAa,gBAAiB,SAAQ,2BAAwB;IAC5D;;;;;OAKG;IACH,YAAsB,GAAqB,EAAE,KAAc;QACzD,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACpB,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,MAAM,CAAC,MAAsC;;QACzD,OAAO,gBAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,GAAG,mCAAI,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE;YAC/E,OAAO,IAAA,wBAAa,EAAC,GAAG,EAAE,CAAC,IAAI,gBAAgB,CAAC,GAAG,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC,CAAC,CAAC;QACvE,CAAC,CAAC,CAAC;IACL,CAAC;IA0BM,mBAAmB,CACxB,IAAe,EACf,WAAoB,EACpB,aAAwC;QAExC,OAAO,yBAAc,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC;IAcM,QAAQ,CAAC,IAAgB,EAAE,WAAoB;QACpD,OAAO,yBAAc,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC;CACF;AAtED,4CAsEC","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 { Converters as JsonConverters, JsonObject, JsonValue } from '@fgv/ts-json-base';\nimport { ResourceType } from './resourceType';\nimport { Convert, ResourceTypeName, ResourceValueMergeMethod } from '../common';\nimport { captureResult, Result } from '@fgv/ts-utils';\n\n/**\n * Parameters to create a {@link ResourceTypes.JsonResourceType | JsonResourceType} instance.\n * @public\n */\nexport interface IJsonResourceTypeCreateParams {\n /**\n * Optional key for the new {@link ResourceTypes.JsonResourceType | JsonResourceType} instance.\n * Defaults to 'json'.\n */\n key?: string;\n\n /**\n * Optional index for the new {@link ResourceTypes.JsonResourceType | JsonResourceType}\n * instance.\n */\n index?: number;\n}\n\n/**\n * Implementation of a {@link ResourceTypes.ResourceType | ResourceType} for JSON values.\n * @public\n */\nexport class JsonResourceType extends ResourceType<JsonObject> {\n /**\n * Protected {@link ResourceTypes.JsonResourceType | JsonResourceType} constructor for use by subclasses.\n * Use {@link ResourceTypes.JsonResourceType.create | JsonResourceType.create} to create a new instance.\n * @param key - The key for the new {@link ResourceTypes.JsonResourceType | JsonResourceType} instance.\n * @param index - Optional index for the new {@link ResourceTypes.JsonResourceType | JsonResourceType} instance.\n */\n protected constructor(key: ResourceTypeName, index?: number) {\n super(key, index);\n }\n\n /**\n * Factory method to create a new {@link ResourceTypes.JsonResourceType | JsonResourceType} instance.\n * @param params - {@link ResourceTypes.IJsonResourceTypeCreateParams | Parameters} to create the new instance.\n * @returns `Success` with the new {@link ResourceTypes.JsonResourceType | JsonResourceType} instance if successful\n * or `Failure` with an error message if not.\n */\n public static create(params?: IJsonResourceTypeCreateParams): Result<JsonResourceType> {\n return Convert.resourceTypeName.convert(params?.key ?? 'json').onSuccess((key) => {\n return captureResult(() => new JsonResourceType(key, params?.index));\n });\n }\n\n /**\n * {@inheritdoc ResourceTypes.ResourceType.(validateDeclaration:1)}\n */\n public validateDeclaration(\n json: JsonValue,\n isPartial: true,\n mergeMethod?: ResourceValueMergeMethod\n ): Result<Partial<JsonObject>>;\n /**\n * {@inheritdoc ResourceTypes.ResourceType.(validateDeclaration:2)}\n */\n public validateDeclaration(\n json: JsonValue,\n isPartial: false,\n mergeMethod?: ResourceValueMergeMethod\n ): Result<JsonObject>;\n /**\n * {@inheritdoc ResourceTypes.ResourceType.(validateDeclaration:3)}\n */\n public validateDeclaration(\n json: JsonValue,\n isPartial: boolean,\n mergeMethod?: ResourceValueMergeMethod\n ): Result<JsonObject | Partial<JsonObject>>;\n public validateDeclaration(\n json: JsonValue,\n __isPartial: boolean,\n __mergeMethod?: ResourceValueMergeMethod\n ): Result<JsonObject | Partial<JsonObject>> {\n return JsonConverters.jsonObject.convert(json);\n }\n\n /**\n * {@inheritdoc ResourceTypes.ResourceType.(validate:1)}\n */\n public validate(json: JsonObject, isPartial: true): Result<JsonObject>;\n /**\n * {@inheritdoc ResourceTypes.ResourceType.(validate:2)}\n */\n public validate(json: JsonObject, isPartial: false): Result<JsonObject>;\n /**\n * {@inheritdoc ResourceTypes.ResourceType.(validate:3)}\n */\n public validate(json: JsonObject, isPartial: boolean): Result<JsonObject>;\n public validate(json: JsonObject, __isPartial: boolean): Result<JsonObject> {\n return JsonConverters.jsonObject.convert(json);\n }\n}\n"]}
1
+ {"version":3,"file":"jsonResourceType.js","sourceRoot":"","sources":["../../../src/packlets/resource-types/jsonResourceType.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,oDAA6E;AAC7E,iDAAsF;AACtF,sCAAsD;AACtD,4CAAsD;AAoBtD;;;GAGG;AACH,MAAa,gBAAiB,SAAQ,2BAAwB;IAC5D;;;;;OAKG;IACH,YAAsB,GAAqB,EAAE,KAAc;QACzD,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACpB,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,MAAM,CAAC,MAAsC;;QACzD,OAAO,gBAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,GAAG,mCAAI,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE;YAC/E,OAAO,IAAA,wBAAa,EAAC,GAAG,EAAE,CAAC,IAAI,gBAAgB,CAAC,GAAG,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC,CAAC,CAAC;QACvE,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IAEI,mBAAmB,CAAC,KAA6C;QACtE,OAAO,yBAAc,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACvD,CAAC;IAcM,QAAQ,CAAC,IAAgB,EAAE,WAAqB;QACrD,OAAO,yBAAc,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC;CACF;AA9CD,4CA8CC","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 { Converters as JsonConverters, JsonObject } from '@fgv/ts-json-base';\nimport { IResourceCandidateValidationProperties, ResourceType } from './resourceType';\nimport { Convert, ResourceTypeName } from '../common';\nimport { captureResult, Result } from '@fgv/ts-utils';\n\n/**\n * Parameters to create a {@link ResourceTypes.JsonResourceType | JsonResourceType} instance.\n * @public\n */\nexport interface IJsonResourceTypeCreateParams {\n /**\n * Optional key for the new {@link ResourceTypes.JsonResourceType | JsonResourceType} instance.\n * Defaults to 'json'.\n */\n key?: string;\n\n /**\n * Optional index for the new {@link ResourceTypes.JsonResourceType | JsonResourceType}\n * instance.\n */\n index?: number;\n}\n\n/**\n * Implementation of a {@link ResourceTypes.ResourceType | ResourceType} for JSON values.\n * @public\n */\nexport class JsonResourceType extends ResourceType<JsonObject> {\n /**\n * Protected {@link ResourceTypes.JsonResourceType | JsonResourceType} constructor for use by subclasses.\n * Use {@link ResourceTypes.JsonResourceType.create | JsonResourceType.create} to create a new instance.\n * @param key - The key for the new {@link ResourceTypes.JsonResourceType | JsonResourceType} instance.\n * @param index - Optional index for the new {@link ResourceTypes.JsonResourceType | JsonResourceType} instance.\n */\n protected constructor(key: ResourceTypeName, index?: number) {\n super(key, index);\n }\n\n /**\n * Factory method to create a new {@link ResourceTypes.JsonResourceType | JsonResourceType} instance.\n * @param params - {@link ResourceTypes.IJsonResourceTypeCreateParams | Parameters} to create the new instance.\n * @returns `Success` with the new {@link ResourceTypes.JsonResourceType | JsonResourceType} instance if successful\n * or `Failure` with an error message if not.\n */\n public static create(params?: IJsonResourceTypeCreateParams): Result<JsonResourceType> {\n return Convert.resourceTypeName.convert(params?.key ?? 'json').onSuccess((key) => {\n return captureResult(() => new JsonResourceType(key, params?.index));\n });\n }\n\n /**\n * {@inheritdoc ResourceTypes.ResourceType.validateDeclaration}\n */\n\n public validateDeclaration(props: IResourceCandidateValidationProperties): Result<JsonObject> {\n return JsonConverters.jsonObject.convert(props.json);\n }\n\n /**\n * {@inheritdoc ResourceTypes.ResourceType.(validate:1)}\n */\n public validate(json: JsonObject, isPartial: true): Result<JsonObject>;\n /**\n * {@inheritdoc ResourceTypes.ResourceType.(validate:2)}\n */\n public validate(json: JsonObject, isPartial: false): Result<JsonObject>;\n /**\n * {@inheritdoc ResourceTypes.ResourceType.(validate:3)}\n */\n public validate(json: JsonObject, isPartial: boolean): Result<JsonObject>;\n public validate(json: JsonObject, __isPartial?: boolean): Result<JsonObject> {\n return JsonConverters.jsonObject.convert(json);\n }\n}\n"]}
@@ -1,6 +1,32 @@
1
1
  import { JsonValue } from '@fgv/ts-json-base';
2
2
  import { ICollectible, Result } from '@fgv/ts-utils';
3
- import { ResourceTypeIndex, ResourceTypeName, ResourceValueMergeMethod } from '../common';
3
+ import { ResourceTypeIndex, ResourceTypeName, ResourceValueMergeMethod, ResourceId } from '../common';
4
+ /**
5
+ * Parameters used to validate a {@link ResourceJson.Json.ILooseResourceCandidateDecl | resource candidate declaration}.
6
+ * @public
7
+ */
8
+ export interface IResourceCandidateValidationProperties {
9
+ /**
10
+ * {@inheritdoc ResourceJson.Json.ILooseResourceCandidateDecl.id}
11
+ * @public
12
+ */
13
+ id: ResourceId;
14
+ /**
15
+ * {@inheritdoc ResourceJson.Json.ILooseResourceCandidateDecl.isPartial}
16
+ * @public
17
+ */
18
+ isPartial: boolean;
19
+ /**
20
+ * {@inheritdoc ResourceJson.Json.ILooseResourceCandidateDecl.json}
21
+ * @public
22
+ */
23
+ json: JsonValue;
24
+ /**
25
+ * {@inheritdoc ResourceJson.Json.ILooseResourceCandidateDecl.mergeMethod}
26
+ * @public
27
+ */
28
+ mergeMethod: ResourceValueMergeMethod;
29
+ }
4
30
  /**
5
31
  * Abstract base class for resource types which are responsible for
6
32
  * validating and converting JSON values into the appropriate strongly-typed
@@ -19,39 +45,14 @@ export declare abstract class ResourceType<T = unknown> implements ICollectible<
19
45
  get index(): ResourceTypeIndex | undefined;
20
46
  protected constructor(key: ResourceTypeName, index?: number);
21
47
  /**
22
- * Validates a {@link ResourceJson.Json.ILooseResourceCandidateDecl | resource candidate declaration} for
23
- * a partial resource instance value.
24
- * @param json - The JSON value to validate.
25
- * @param isPartial - `true` indicates that the value is expected to be incomplete.
26
- * @param mergeMethod - The method to use when merging with previously resolved values.
27
- * @returns `Success` with the strongly-typed resource value if the JSON and merge
28
- * method are valid, `Failure` with an error message otherwise.
29
- * @public
30
- */
31
- abstract validateDeclaration(json: JsonValue, isPartial: true, mergeMethod?: ResourceValueMergeMethod): Result<Partial<T>>;
32
- /**
33
- * Validates a {@link ResourceJson.Json.ILooseResourceCandidateDecl | resource candidate declaration} for
34
- * a complete resource instance value.
35
- * @param json - The JSON value to validate.
36
- * @param isPartial - `false` indicates that the value is expected to be complete.
37
- * @param mergeMethod - The method to use when merging with previously resolved values.
38
- * @returns `Success` with the strongly-typed resource value if the JSON and merge method
39
- * are valid, `Failure` with an error message otherwise.
40
- * @public
41
- */
42
- abstract validateDeclaration(json: JsonValue, isPartial: false, mergeMethod?: ResourceValueMergeMethod): Result<T>;
43
- /**
44
- * Validates a {@link ResourceJson.Json.ILooseResourceCandidateDecl | resource candidate declaration} for
48
+ * Validates properties of a {@link ResourceJson.Json.ILooseResourceCandidateDecl | resource candidate declaration} for
45
49
  * a resource instance value.
46
- * @param json - The JSON value to validate.
47
- * @param isPartial - Indicates whether the value is expected to be incomplete.
48
- * @param mergeMethod - The method to use when merging with previously resolved values.
50
+ * @param props - The {@link ResourceTypes.IResourceCandidateValidationProperties | properties } to validate.
49
51
  * @returns `Success` with the strongly-typed resource value if the JSON and merge method
50
52
  * are valid, `Failure` with an error message otherwise.
51
53
  * @public
52
54
  */
53
- abstract validateDeclaration(json: JsonValue, isPartial: boolean, mergeMethod?: ResourceValueMergeMethod): Result<T | Partial<T>>;
54
- abstract validateDeclaration(json: JsonValue, isPartial: boolean, mergeMethod?: ResourceValueMergeMethod): Result<T | Partial<T>>;
55
+ abstract validateDeclaration(props: IResourceCandidateValidationProperties): Result<T | Partial<T>>;
55
56
  /**
56
57
  * Validates a JSON value for use as a partial resource instance value.
57
58
  * @param json - The JSON value to validate.
@@ -78,7 +79,7 @@ export declare abstract class ResourceType<T = unknown> implements ICollectible<
78
79
  * the JSON is valid, `Failure` with an error message otherwise.
79
80
  * @public
80
81
  */
81
- abstract validate(json: JsonValue, isPartial: boolean): Result<T | Partial<T>>;
82
+ abstract validate(json: JsonValue, isPartial?: boolean): Result<T | Partial<T>>;
82
83
  /**
83
84
  * Sets the index for this resource type. Once set, the index cannot be changed.
84
85
  */
@@ -1 +1 @@
1
- {"version":3,"file":"resourceType.d.ts","sourceRoot":"","sources":["../../../src/packlets/resource-types/resourceType.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAe,YAAY,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAGL,iBAAiB,EACjB,gBAAgB,EAChB,wBAAwB,EACzB,MAAM,WAAW,CAAC;AAEnB;;;;;GAKG;AACH,8BAAsB,YAAY,CAAC,CAAC,GAAG,OAAO,CAAE,YAAW,YAAY,CAAC,gBAAgB,EAAE,iBAAiB,CAAC;IAC1G,OAAO,CAAC,YAAY,CAA+D;IACnF;;OAEG;IACH,IAAW,GAAG,IAAI,gBAAgB,CAEjC;IAED;;OAEG;IACH,IAAW,KAAK,IAAI,iBAAiB,GAAG,SAAS,CAEhD;IAED,SAAS,aAAa,GAAG,EAAE,gBAAgB,EAAE,KAAK,CAAC,EAAE,MAAM;IAS3D;;;;;;;;;OASG;aACa,mBAAmB,CACjC,IAAI,EAAE,SAAS,EACf,SAAS,EAAE,IAAI,EACf,WAAW,CAAC,EAAE,wBAAwB,GACrC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAErB;;;;;;;;;OASG;aACa,mBAAmB,CACjC,IAAI,EAAE,SAAS,EACf,SAAS,EAAE,KAAK,EAChB,WAAW,CAAC,EAAE,wBAAwB,GACrC,MAAM,CAAC,CAAC,CAAC;IAEZ;;;;;;;;;OASG;aACa,mBAAmB,CACjC,IAAI,EAAE,SAAS,EACf,SAAS,EAAE,OAAO,EAClB,WAAW,CAAC,EAAE,wBAAwB,GACrC,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;aAET,mBAAmB,CACjC,IAAI,EAAE,SAAS,EACf,SAAS,EAAE,OAAO,EAClB,WAAW,CAAC,EAAE,wBAAwB,GACrC,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAEzB;;;;;;;OAOG;aACa,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAE9E;;;;;;;OAOG;aACa,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC;IAEtE;;;;;;;OAOG;aACa,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,GAAG,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAErF;;OAEG;IACI,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,iBAAiB,CAAC;CAG1D"}
1
+ {"version":3,"file":"resourceType.d.ts","sourceRoot":"","sources":["../../../src/packlets/resource-types/resourceType.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAe,YAAY,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAGL,iBAAiB,EACjB,gBAAgB,EAChB,wBAAwB,EACxB,UAAU,EACX,MAAM,WAAW,CAAC;AAEnB;;;GAGG;AACH,MAAM,WAAW,sCAAsC;IACrD;;;OAGG;IACH,EAAE,EAAE,UAAU,CAAC;IAEf;;;OAGG;IACH,SAAS,EAAE,OAAO,CAAC;IAEnB;;;OAGG;IACH,IAAI,EAAE,SAAS,CAAC;IAEhB;;;OAGG;IACH,WAAW,EAAE,wBAAwB,CAAC;CACvC;AAED;;;;;GAKG;AACH,8BAAsB,YAAY,CAAC,CAAC,GAAG,OAAO,CAAE,YAAW,YAAY,CAAC,gBAAgB,EAAE,iBAAiB,CAAC;IAC1G,OAAO,CAAC,YAAY,CAA+D;IACnF;;OAEG;IACH,IAAW,GAAG,IAAI,gBAAgB,CAEjC;IAED;;OAEG;IACH,IAAW,KAAK,IAAI,iBAAiB,GAAG,SAAS,CAEhD;IAED,SAAS,aAAa,GAAG,EAAE,gBAAgB,EAAE,KAAK,CAAC,EAAE,MAAM;IAS3D;;;;;;;OAOG;aACa,mBAAmB,CAAC,KAAK,EAAE,sCAAsC,GAAG,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAE1G;;;;;;;OAOG;aACa,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAE9E;;;;;;;OAOG;aACa,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC;IAEtE;;;;;;;OAOG;aACa,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAEtF;;OAEG;IACI,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,iBAAiB,CAAC;CAG1D"}
@@ -1 +1 @@
1
- {"version":3,"file":"resourceType.js","sourceRoot":"","sources":["../../../src/packlets/resource-types/resourceType.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAGH,4CAAkE;AAClE,sCAMmB;AAEnB;;;;;GAKG;AACH,MAAsB,YAAY;IAEhC;;OAEG;IACH,IAAW,GAAG;QACZ,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC;IACjC,CAAC;IAED,YAAsB,GAAqB,EAAE,KAAc;QACzD,IAAI,CAAC,YAAY,GAAG,IAAI,sBAAW,CAAC,WAAW,CAAsC;YACnF,GAAG;YACH,qDAAqD;YACrD,KAAK,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,iBAAQ,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,SAAS;YACtF,cAAc,EAAE,gBAAa,CAAC,iBAAiB;SAChD,CAAC,CAAC;IACL,CAAC;IAsFD;;OAEG;IACI,QAAQ,CAAC,KAAa;QAC3B,OAAO,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;CACF;AAnHD,oCAmHC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { JsonValue } from '@fgv/ts-json-base';\nimport { Collections, ICollectible, Result } from '@fgv/ts-utils';\nimport {\n Convert as CommonConvert,\n Validate,\n ResourceTypeIndex,\n ResourceTypeName,\n ResourceValueMergeMethod\n} from '../common';\n\n/**\n * Abstract base class for resource types which are responsible for\n * validating and converting JSON values into the appropriate strongly-typed\n * resource value.\n * @public\n */\nexport abstract class ResourceType<T = unknown> implements ICollectible<ResourceTypeName, ResourceTypeIndex> {\n private _collectible: Collections.Collectible<ResourceTypeName, ResourceTypeIndex>;\n /**\n * The key for this resource type.\n */\n public get key(): ResourceTypeName {\n return this._collectible.key;\n }\n\n /**\n * The index for this resource type.\n */\n public get index(): ResourceTypeIndex | undefined {\n return this._collectible.index;\n }\n\n protected constructor(key: ResourceTypeName, index?: number) {\n this._collectible = new Collections.Collectible<ResourceTypeName, ResourceTypeIndex>({\n key,\n /* c8 ignore next 1 - coverage having a rough time */\n index: index !== undefined ? Validate.toResourceTypeIndex(index).orThrow() : undefined,\n indexConverter: CommonConvert.resourceTypeIndex\n });\n }\n\n /**\n * Validates a {@link ResourceJson.Json.ILooseResourceCandidateDecl | resource candidate declaration} for\n * a partial resource instance value.\n * @param json - The JSON value to validate.\n * @param isPartial - `true` indicates that the value is expected to be incomplete.\n * @param mergeMethod - The method to use when merging with previously resolved values.\n * @returns `Success` with the strongly-typed resource value if the JSON and merge\n * method are valid, `Failure` with an error message otherwise.\n * @public\n */\n public abstract validateDeclaration(\n json: JsonValue,\n isPartial: true,\n mergeMethod?: ResourceValueMergeMethod\n ): Result<Partial<T>>;\n\n /**\n * Validates a {@link ResourceJson.Json.ILooseResourceCandidateDecl | resource candidate declaration} for\n * a complete resource instance value.\n * @param json - The JSON value to validate.\n * @param isPartial - `false` indicates that the value is expected to be complete.\n * @param mergeMethod - The method to use when merging with previously resolved values.\n * @returns `Success` with the strongly-typed resource value if the JSON and merge method\n * are valid, `Failure` with an error message otherwise.\n * @public\n */\n public abstract validateDeclaration(\n json: JsonValue,\n isPartial: false,\n mergeMethod?: ResourceValueMergeMethod\n ): Result<T>;\n\n /**\n * Validates a {@link ResourceJson.Json.ILooseResourceCandidateDecl | resource candidate declaration} for\n * a resource instance value.\n * @param json - The JSON value to validate.\n * @param isPartial - Indicates whether the value is expected to be incomplete.\n * @param mergeMethod - The method to use when merging with previously resolved values.\n * @returns `Success` with the strongly-typed resource value if the JSON and merge method\n * are valid, `Failure` with an error message otherwise.\n * @public\n */\n public abstract validateDeclaration(\n json: JsonValue,\n isPartial: boolean,\n mergeMethod?: ResourceValueMergeMethod\n ): Result<T | Partial<T>>;\n\n public abstract validateDeclaration(\n json: JsonValue,\n isPartial: boolean,\n mergeMethod?: ResourceValueMergeMethod\n ): Result<T | Partial<T>>;\n\n /**\n * Validates a JSON value for use as a partial resource instance value.\n * @param json - The JSON value to validate.\n * @param isPartial - `true` indicates that the value is expected to be partial.\n * @returns `Success` with the strongly-typed partial resource value if the JSON is valid,\n * `Failure` with an error message otherwise.\n * @public\n */\n public abstract validate(json: JsonValue, isPartial: true): Result<Partial<T>>;\n\n /**\n * Validates a JSON value for use as a complete resource instance value.\n * @param json - The JSON value to validate.\n * @param isPartial - `false` indicates that the value is expected to be complete.\n * @returns `Success` with the strongly-typed resource value if the JSON is valid,\n * `Failure` with an error message otherwise.\n * @public\n */\n public abstract validate(json: JsonValue, isPartial: false): Result<T>;\n\n /**\n * Validates a JSON value for use as a full or partial resource instance value.\n * @param json - The JSON value to validate.\n * @param isPartial - Indicates whether the value is expected to be partial.\n * @returns `Success` with the strongly-typed full or partial resource value if\n * the JSON is valid, `Failure` with an error message otherwise.\n * @public\n */\n public abstract validate(json: JsonValue, isPartial: boolean): Result<T | Partial<T>>;\n\n /**\n * Sets the index for this resource type. Once set, the index cannot be changed.\n */\n public setIndex(index: number): Result<ResourceTypeIndex> {\n return this._collectible.setIndex(index);\n }\n}\n"]}
1
+ {"version":3,"file":"resourceType.js","sourceRoot":"","sources":["../../../src/packlets/resource-types/resourceType.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAGH,4CAAkE;AAClE,sCAOmB;AAgCnB;;;;;GAKG;AACH,MAAsB,YAAY;IAEhC;;OAEG;IACH,IAAW,GAAG;QACZ,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC;IACjC,CAAC;IAED,YAAsB,GAAqB,EAAE,KAAc;QACzD,IAAI,CAAC,YAAY,GAAG,IAAI,sBAAW,CAAC,WAAW,CAAsC;YACnF,GAAG;YACH,qDAAqD;YACrD,KAAK,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,iBAAQ,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,SAAS;YACtF,cAAc,EAAE,gBAAa,CAAC,iBAAiB;SAChD,CAAC,CAAC;IACL,CAAC;IA0CD;;OAEG;IACI,QAAQ,CAAC,KAAa;QAC3B,OAAO,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;CACF;AAvED,oCAuEC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { JsonValue } from '@fgv/ts-json-base';\nimport { Collections, ICollectible, Result } from '@fgv/ts-utils';\nimport {\n Convert as CommonConvert,\n Validate,\n ResourceTypeIndex,\n ResourceTypeName,\n ResourceValueMergeMethod,\n ResourceId\n} from '../common';\n\n/**\n * Parameters used to validate a {@link ResourceJson.Json.ILooseResourceCandidateDecl | resource candidate declaration}.\n * @public\n */\nexport interface IResourceCandidateValidationProperties {\n /**\n * {@inheritdoc ResourceJson.Json.ILooseResourceCandidateDecl.id}\n * @public\n */\n id: ResourceId;\n\n /**\n * {@inheritdoc ResourceJson.Json.ILooseResourceCandidateDecl.isPartial}\n * @public\n */\n isPartial: boolean;\n\n /**\n * {@inheritdoc ResourceJson.Json.ILooseResourceCandidateDecl.json}\n * @public\n */\n json: JsonValue;\n\n /**\n * {@inheritdoc ResourceJson.Json.ILooseResourceCandidateDecl.mergeMethod}\n * @public\n */\n mergeMethod: ResourceValueMergeMethod;\n}\n\n/**\n * Abstract base class for resource types which are responsible for\n * validating and converting JSON values into the appropriate strongly-typed\n * resource value.\n * @public\n */\nexport abstract class ResourceType<T = unknown> implements ICollectible<ResourceTypeName, ResourceTypeIndex> {\n private _collectible: Collections.Collectible<ResourceTypeName, ResourceTypeIndex>;\n /**\n * The key for this resource type.\n */\n public get key(): ResourceTypeName {\n return this._collectible.key;\n }\n\n /**\n * The index for this resource type.\n */\n public get index(): ResourceTypeIndex | undefined {\n return this._collectible.index;\n }\n\n protected constructor(key: ResourceTypeName, index?: number) {\n this._collectible = new Collections.Collectible<ResourceTypeName, ResourceTypeIndex>({\n key,\n /* c8 ignore next 1 - coverage having a rough time */\n index: index !== undefined ? Validate.toResourceTypeIndex(index).orThrow() : undefined,\n indexConverter: CommonConvert.resourceTypeIndex\n });\n }\n\n /**\n * Validates properties of a {@link ResourceJson.Json.ILooseResourceCandidateDecl | resource candidate declaration} for\n * a resource instance value.\n * @param props - The {@link ResourceTypes.IResourceCandidateValidationProperties | properties } to validate.\n * @returns `Success` with the strongly-typed resource value if the JSON and merge method\n * are valid, `Failure` with an error message otherwise.\n * @public\n */\n public abstract validateDeclaration(props: IResourceCandidateValidationProperties): Result<T | Partial<T>>;\n\n /**\n * Validates a JSON value for use as a partial resource instance value.\n * @param json - The JSON value to validate.\n * @param isPartial - `true` indicates that the value is expected to be partial.\n * @returns `Success` with the strongly-typed partial resource value if the JSON is valid,\n * `Failure` with an error message otherwise.\n * @public\n */\n public abstract validate(json: JsonValue, isPartial: true): Result<Partial<T>>;\n\n /**\n * Validates a JSON value for use as a complete resource instance value.\n * @param json - The JSON value to validate.\n * @param isPartial - `false` indicates that the value is expected to be complete.\n * @returns `Success` with the strongly-typed resource value if the JSON is valid,\n * `Failure` with an error message otherwise.\n * @public\n */\n public abstract validate(json: JsonValue, isPartial: false): Result<T>;\n\n /**\n * Validates a JSON value for use as a full or partial resource instance value.\n * @param json - The JSON value to validate.\n * @param isPartial - Indicates whether the value is expected to be partial.\n * @returns `Success` with the strongly-typed full or partial resource value if\n * the JSON is valid, `Failure` with an error message otherwise.\n * @public\n */\n public abstract validate(json: JsonValue, isPartial?: boolean): Result<T | Partial<T>>;\n\n /**\n * Sets the index for this resource type. Once set, the index cannot be changed.\n */\n public setIndex(index: number): Result<ResourceTypeIndex> {\n return this._collectible.setIndex(index);\n }\n}\n"]}
@@ -0,0 +1,98 @@
1
+ import { ResourceId, ResourceValueMergeMethod } from '../common';
2
+ import * as Context from '../context';
3
+ import * as ResourceJson from '../resource-json';
4
+ import { ResourceCandidate } from './resourceCandidate';
5
+ import { JsonObject } from '@fgv/ts-json-base';
6
+ import { Result } from '@fgv/ts-utils';
7
+ /**
8
+ * Action taken on a candidate during reduction processing.
9
+ * @public
10
+ */
11
+ export type CandidateAction = 'unchanged' | 'reduced' | 'suppressed';
12
+ /**
13
+ * Information about a candidate being processed by the reducer.
14
+ * @public
15
+ */
16
+ export interface ICandidateInfo {
17
+ readonly originalCandidate: ResourceCandidate;
18
+ action: CandidateAction;
19
+ conditions: ResourceJson.Json.ILooseConditionDecl[];
20
+ conditionSetKey: string;
21
+ readonly json?: JsonObject;
22
+ }
23
+ /**
24
+ * Represents a reduced candidate after applying reduction logic.
25
+ * @public
26
+ */
27
+ export interface IReducedCandidate {
28
+ readonly candidate: ResourceCandidate;
29
+ readonly conditions: ResourceJson.Json.ConditionSetDecl;
30
+ readonly json?: JsonObject;
31
+ readonly isPartial?: boolean;
32
+ readonly mergeMethod?: ResourceValueMergeMethod;
33
+ }
34
+ /**
35
+ * Manages candidate reduction logic for filtering and qualifier reduction operations.
36
+ * Encapsulates the state and logic needed to consistently process candidates for reduction.
37
+ * @public
38
+ */
39
+ export declare class CandidateReducer {
40
+ private readonly _candidateInfos;
41
+ private readonly _filterForContext;
42
+ private readonly _qualifiersToReduce;
43
+ /**
44
+ * Constructor for CandidateReducer.
45
+ * @param candidates - The set of candidates to potentially reduce
46
+ * @param filterForContext - Context to filter candidates against
47
+ */
48
+ constructor(candidates: ReadonlyArray<ResourceCandidate>, filterForContext: Context.IValidatedContextDecl);
49
+ /**
50
+ * Computes a string key for a set of condition declarations for collision detection.
51
+ * @param conditions - The conditions to compute a key for
52
+ * @returns A string key representing the condition set
53
+ */
54
+ private static _computeConditionSetKey;
55
+ /**
56
+ * Merges a partial candidate's JSON value into a base candidate's JSON value.
57
+ * @param baseJson - The base JSON value to merge into
58
+ * @param partialJson - The partial JSON value to merge from
59
+ * @returns The merged JSON value
60
+ * @internal
61
+ */
62
+ private static _mergeJsonValues;
63
+ /**
64
+ * Resolves collisions using smart collision resolution rules.
65
+ * - If a reduced candidate collides with an unchanged candidate and only one reduced candidate collides:
66
+ * - If reduced candidate is complete: suppress unchanged, keep reduced
67
+ * - If reduced candidate is partial: merge into unchanged, suppress reduced
68
+ * - Otherwise: revert reduced candidates to unchanged to avoid collisions
69
+ * @internal
70
+ */
71
+ private _resolveCollisions;
72
+ /**
73
+ * Static convenience method to construct an array of properly reduced
74
+ * {@link ResourceJson.Json.IChildResourceCandidateDecl | child resource candidate declarations}
75
+ * from a set of {@link Resources.ResourceCandidate | resource candidates}.
76
+ * @param candidates - The candidates to reduce
77
+ * @param filterForContext - Optional context to filter against
78
+ * @returns Result with array of reduced candidate declarations, or Failure if reduction fails
79
+ */
80
+ static reduceToChildResourceCandidateDecls(candidates: ReadonlyArray<ResourceCandidate>, filterForContext?: Context.IValidatedContextDecl): Result<ResourceJson.Json.IChildResourceCandidateDecl[]>;
81
+ /**
82
+ * Static convenience method to construct an array of properly reduced
83
+ * {@link ResourceJson.Json.ILooseResourceCandidateDecl | loose resource candidate declarations}
84
+ * from a set of {@link Resources.ResourceCandidate | resource candidates}.
85
+ * @param id - The id of the resource
86
+ * @param candidates - The candidates to reduce
87
+ * @param filterForContext - Optional context to filter against
88
+ * @returns Result with array of reduced candidate declarations, or Failure if reduction fails
89
+ */
90
+ static reduceToLooseResourceCandidateDecls(id: ResourceId, candidates: ReadonlyArray<ResourceCandidate>, filterForContext?: Context.IValidatedContextDecl): Result<ResourceJson.Json.ILooseResourceCandidateDecl[]>;
91
+ /**
92
+ * Reduces a single candidate according to the configured reduction rules.
93
+ * @param candidate - The candidate to reduce
94
+ * @returns Either a reduced candidate declaration or an error if the candidate is not found
95
+ */
96
+ reduceCandidate(candidate: ResourceCandidate): Result<IReducedCandidate | undefined>;
97
+ }
98
+ //# sourceMappingURL=candidateReducer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"candidateReducer.d.ts","sourceRoot":"","sources":["../../../src/packlets/resources/candidateReducer.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAiB,UAAU,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAChF,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,YAAY,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAAE,MAAM,EAA6B,MAAM,eAAe,CAAC;AAElE;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,SAAS,GAAG,YAAY,CAAC;AAErE;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAC9C,MAAM,EAAE,eAAe,CAAC;IACxB,UAAU,EAAE,YAAY,CAAC,IAAI,CAAC,mBAAmB,EAAE,CAAC;IACpD,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC;CAC5B;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAC;IACtC,QAAQ,CAAC,UAAU,EAAE,YAAY,CAAC,IAAI,CAAC,gBAAgB,CAAC;IACxD,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,WAAW,CAAC,EAAE,wBAAwB,CAAC;CACjD;AAED;;;;GAIG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAmB;IACnD,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAgC;IAClE,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAA6B;IAEjE;;;;OAIG;gBAED,UAAU,EAAE,aAAa,CAAC,iBAAiB,CAAC,EAC5C,gBAAgB,EAAE,OAAO,CAAC,qBAAqB;IAiCjD;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,uBAAuB;IAWtC;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAW/B;;;;;;;OAOG;IACH,OAAO,CAAC,kBAAkB;IA2E1B;;;;;;;OAOG;WACW,mCAAmC,CAC/C,UAAU,EAAE,aAAa,CAAC,iBAAiB,CAAC,EAC5C,gBAAgB,CAAC,EAAE,OAAO,CAAC,qBAAqB,GAC/C,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,2BAA2B,EAAE,CAAC;IAyB1D;;;;;;;;OAQG;WACW,mCAAmC,CAC/C,EAAE,EAAE,UAAU,EACd,UAAU,EAAE,aAAa,CAAC,iBAAiB,CAAC,EAC5C,gBAAgB,CAAC,EAAE,OAAO,CAAC,qBAAqB,GAC/C,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,2BAA2B,EAAE,CAAC;IA0B1D;;;;OAIG;IACI,eAAe,CAAC,SAAS,EAAE,iBAAiB,GAAG,MAAM,CAAC,iBAAiB,GAAG,SAAS,CAAC;CAuB5F"}
@@ -0,0 +1,247 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2025 Erik Fortune
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ * of this software and associated documentation files (the "Software"), to deal
7
+ * in the Software without restriction, including without limitation the rights
8
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ * copies of the Software, and to permit persons to whom the Software is
10
+ * furnished to do so, subject to the following conditions:
11
+ *
12
+ * The above copyright notice and this permission notice shall be included in all
13
+ * copies or substantial portions of the Software.
14
+ *
15
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ * SOFTWARE.
22
+ */
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.CandidateReducer = void 0;
25
+ const resourceCandidate_1 = require("./resourceCandidate");
26
+ const ts_json_1 = require("@fgv/ts-json");
27
+ const ts_utils_1 = require("@fgv/ts-utils");
28
+ /**
29
+ * Manages candidate reduction logic for filtering and qualifier reduction operations.
30
+ * Encapsulates the state and logic needed to consistently process candidates for reduction.
31
+ * @public
32
+ */
33
+ class CandidateReducer {
34
+ /**
35
+ * Constructor for CandidateReducer.
36
+ * @param candidates - The set of candidates to potentially reduce
37
+ * @param filterForContext - Context to filter candidates against
38
+ */
39
+ constructor(candidates, filterForContext) {
40
+ var _a;
41
+ this._filterForContext = filterForContext;
42
+ // Use existing logic to determine reducible qualifiers
43
+ this._qualifiersToReduce =
44
+ (_a = resourceCandidate_1.ResourceCandidate.findReducibleQualifiers(candidates, filterForContext)) !== null && _a !== void 0 ? _a : new Set();
45
+ // Initialize candidate info array with initial reduction attempts
46
+ this._candidateInfos = candidates.map((candidate) => {
47
+ const filteredConditions = candidate.conditions.conditions.filter((c) => !this._qualifiersToReduce.has(c.qualifier.name));
48
+ const reducedConditions = filteredConditions.map((c) => c.toLooseConditionDecl());
49
+ const conditionSetKey = CandidateReducer._computeConditionSetKey(reducedConditions);
50
+ const action = filteredConditions.length < candidate.conditions.conditions.length ? 'reduced' : 'unchanged';
51
+ return {
52
+ originalCandidate: candidate,
53
+ action,
54
+ conditions: reducedConditions,
55
+ conditionSetKey,
56
+ json: undefined // Will be set later when needed
57
+ };
58
+ });
59
+ // Resolve collisions by reverting reduced candidates to unchanged when they collide
60
+ this._resolveCollisions();
61
+ }
62
+ /**
63
+ * Computes a string key for a set of condition declarations for collision detection.
64
+ * @param conditions - The conditions to compute a key for
65
+ * @returns A string key representing the condition set
66
+ */
67
+ static _computeConditionSetKey(conditions) {
68
+ if (conditions.length === 0) {
69
+ return '{}';
70
+ }
71
+ // Sort conditions by qualifier name for consistent keys
72
+ const sortedConditions = [...conditions].sort((a, b) => a.qualifierName.localeCompare(b.qualifierName));
73
+ const pairs = sortedConditions.map((c) => `${c.qualifierName}:${c.value}`);
74
+ return `{${pairs.join(',')}}`;
75
+ }
76
+ /**
77
+ * Merges a partial candidate's JSON value into a base candidate's JSON value.
78
+ * @param baseJson - The base JSON value to merge into
79
+ * @param partialJson - The partial JSON value to merge from
80
+ * @returns The merged JSON value
81
+ * @internal
82
+ */
83
+ static _mergeJsonValues(baseJson, partialJson) {
84
+ // Create JsonEditor with array replacement behavior for candidate merging
85
+ const editor = ts_json_1.JsonEditor.create({
86
+ merge: {
87
+ arrayMergeBehavior: 'replace'
88
+ }
89
+ }).orThrow(); // Should never fail with valid options
90
+ return editor.mergeObjectsInPlace({}, [baseJson, partialJson]).orThrow(); // Internal method should throw on error - this indicates a serious bug
91
+ }
92
+ /**
93
+ * Resolves collisions using smart collision resolution rules.
94
+ * - If a reduced candidate collides with an unchanged candidate and only one reduced candidate collides:
95
+ * - If reduced candidate is complete: suppress unchanged, keep reduced
96
+ * - If reduced candidate is partial: merge into unchanged, suppress reduced
97
+ * - Otherwise: revert reduced candidates to unchanged to avoid collisions
98
+ * @internal
99
+ */
100
+ _resolveCollisions() {
101
+ let hasCollisions = true;
102
+ let iterationCount = 0;
103
+ const maxIterations = this._candidateInfos.length; // Safety limit
104
+ while (hasCollisions && iterationCount < maxIterations) {
105
+ hasCollisions = false;
106
+ iterationCount++;
107
+ // Group candidates by their condition set keys (excluding suppressed)
108
+ const conditionKeyGroups = new Map();
109
+ for (const candidateInfo of this._candidateInfos) {
110
+ if (candidateInfo.action !== 'suppressed') {
111
+ // Don't include suppressed candidates
112
+ const key = candidateInfo.conditionSetKey;
113
+ if (!conditionKeyGroups.has(key)) {
114
+ conditionKeyGroups.set(key, []);
115
+ }
116
+ conditionKeyGroups.get(key).push(candidateInfo);
117
+ }
118
+ }
119
+ // Apply smart collision resolution
120
+ for (const [, candidatesWithSameKey] of conditionKeyGroups) {
121
+ if (candidatesWithSameKey.length > 1) {
122
+ // Categorize candidates
123
+ const unchangedCandidates = candidatesWithSameKey.filter((c) => c.action === 'unchanged');
124
+ const reducedCandidates = candidatesWithSameKey.filter((c) => c.action === 'reduced');
125
+ if (unchangedCandidates.length === 1 && reducedCandidates.length === 1) {
126
+ // Simple case: one unchanged vs one reduced - apply smart resolution
127
+ const unchangedCandidate = unchangedCandidates[0];
128
+ const reducedCandidate = reducedCandidates[0];
129
+ if (!reducedCandidate.originalCandidate.isPartial) {
130
+ // Complete reduced candidate wins - suppress unchanged
131
+ unchangedCandidate.action = 'suppressed';
132
+ hasCollisions = true;
133
+ }
134
+ else {
135
+ // Partial reduced candidate - merge into unchanged and suppress reduced
136
+ const mergedJson = CandidateReducer._mergeJsonValues(unchangedCandidate.originalCandidate.json, reducedCandidate.originalCandidate.json);
137
+ // Update unchanged candidate with merged JSON, keeping its isPartial status
138
+ unchangedCandidate.json = mergedJson;
139
+ // Suppress the reduced candidate
140
+ reducedCandidate.action = 'suppressed';
141
+ hasCollisions = true;
142
+ }
143
+ }
144
+ else {
145
+ // Complex collision case - revert all reduced candidates to unchanged
146
+ for (const candidateInfo of reducedCandidates) {
147
+ // Revert to original conditions and mark as unchanged
148
+ const originalConditions = candidateInfo.originalCandidate.conditions.conditions.map((c) => c.toLooseConditionDecl());
149
+ const originalKey = CandidateReducer._computeConditionSetKey(originalConditions);
150
+ // Update the candidate info to revert to original state
151
+ candidateInfo.action = 'unchanged';
152
+ candidateInfo.conditions = originalConditions;
153
+ candidateInfo.conditionSetKey = originalKey;
154
+ hasCollisions = true;
155
+ }
156
+ }
157
+ }
158
+ }
159
+ }
160
+ }
161
+ /**
162
+ * Static convenience method to construct an array of properly reduced
163
+ * {@link ResourceJson.Json.IChildResourceCandidateDecl | child resource candidate declarations}
164
+ * from a set of {@link Resources.ResourceCandidate | resource candidates}.
165
+ * @param candidates - The candidates to reduce
166
+ * @param filterForContext - Optional context to filter against
167
+ * @returns Result with array of reduced candidate declarations, or Failure if reduction fails
168
+ */
169
+ static reduceToChildResourceCandidateDecls(candidates, filterForContext) {
170
+ if (!filterForContext || Object.keys(filterForContext).length === 0) {
171
+ return (0, ts_utils_1.succeed)(candidates.map((candidate) => candidate.toChildResourceCandidateDecl()));
172
+ }
173
+ const reducer = new CandidateReducer(candidates, filterForContext);
174
+ const reductionResults = (0, ts_utils_1.mapResults)(candidates.map((candidate) => reducer.reduceCandidate(candidate)));
175
+ return reductionResults.onSuccess((reductions) => {
176
+ const validReductions = reductions.filter((reduction) => reduction !== undefined);
177
+ return (0, ts_utils_1.succeed)(validReductions.map((reduction) => {
178
+ var _a, _b, _c;
179
+ return ({
180
+ /* c8 ignore next 3 -- defense in depth */
181
+ json: (_a = reduction.json) !== null && _a !== void 0 ? _a : reduction.candidate.json,
182
+ isPartial: (_b = reduction.isPartial) !== null && _b !== void 0 ? _b : reduction.candidate.isPartial,
183
+ mergeMethod: (_c = reduction.mergeMethod) !== null && _c !== void 0 ? _c : reduction.candidate.mergeMethod,
184
+ conditions: reduction.conditions
185
+ });
186
+ }));
187
+ });
188
+ }
189
+ /**
190
+ * Static convenience method to construct an array of properly reduced
191
+ * {@link ResourceJson.Json.ILooseResourceCandidateDecl | loose resource candidate declarations}
192
+ * from a set of {@link Resources.ResourceCandidate | resource candidates}.
193
+ * @param id - The id of the resource
194
+ * @param candidates - The candidates to reduce
195
+ * @param filterForContext - Optional context to filter against
196
+ * @returns Result with array of reduced candidate declarations, or Failure if reduction fails
197
+ */
198
+ static reduceToLooseResourceCandidateDecls(id, candidates, filterForContext) {
199
+ if (!filterForContext || Object.keys(filterForContext).length === 0) {
200
+ return (0, ts_utils_1.succeed)(candidates.map((candidate) => candidate.toLooseResourceCandidateDecl()));
201
+ }
202
+ const reducer = new CandidateReducer(candidates, filterForContext);
203
+ const reductionResults = (0, ts_utils_1.mapResults)(candidates.map((candidate) => reducer.reduceCandidate(candidate)));
204
+ return reductionResults.onSuccess((reductions) => {
205
+ const validReductions = reductions.filter((reduction) => reduction !== undefined);
206
+ return (0, ts_utils_1.succeed)(validReductions.map((reduction) => {
207
+ var _a, _b, _c;
208
+ return ({
209
+ id,
210
+ /* c8 ignore next 3 -- defense in depth */
211
+ json: (_a = reduction.json) !== null && _a !== void 0 ? _a : reduction.candidate.json,
212
+ isPartial: (_b = reduction.isPartial) !== null && _b !== void 0 ? _b : reduction.candidate.isPartial,
213
+ mergeMethod: (_c = reduction.mergeMethod) !== null && _c !== void 0 ? _c : reduction.candidate.mergeMethod,
214
+ conditions: reduction.conditions
215
+ });
216
+ }));
217
+ });
218
+ }
219
+ /**
220
+ * Reduces a single candidate according to the configured reduction rules.
221
+ * @param candidate - The candidate to reduce
222
+ * @returns Either a reduced candidate declaration or an error if the candidate is not found
223
+ */
224
+ reduceCandidate(candidate) {
225
+ var _a;
226
+ const candidateInfo = this._candidateInfos.find((info) => info.originalCandidate === candidate);
227
+ if (!candidateInfo) {
228
+ return (0, ts_utils_1.fail)(`Candidate not found in reducer state`);
229
+ }
230
+ if (candidateInfo.action === 'suppressed') {
231
+ return (0, ts_utils_1.succeed)(undefined);
232
+ }
233
+ // Convert array of conditions back to ConditionSetDecl for compatibility
234
+ const conditionsAsRecord = candidateInfo.conditions.reduce((acc, condition) => {
235
+ return Object.assign(Object.assign({}, acc), { [condition.qualifierName]: condition.value });
236
+ }, {});
237
+ return (0, ts_utils_1.succeed)({
238
+ candidate,
239
+ conditions: conditionsAsRecord,
240
+ json: (_a = candidateInfo.json) !== null && _a !== void 0 ? _a : candidate.json,
241
+ isPartial: candidate.isPartial,
242
+ mergeMethod: candidate.mergeMethod
243
+ });
244
+ }
245
+ }
246
+ exports.CandidateReducer = CandidateReducer;
247
+ //# sourceMappingURL=candidateReducer.js.map