@fgv/ts-res 5.0.0-3 → 5.0.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 (362) hide show
  1. package/README.md +794 -137
  2. package/dist/ts-res.d.ts +2344 -187
  3. package/dist/tsdoc-metadata.json +1 -1
  4. package/eslint.config.js +16 -0
  5. package/lib/index.d.ts +11 -2
  6. package/lib/index.js +25 -2
  7. package/lib/packlets/bundle/bundleBuilder.d.ts +41 -0
  8. package/lib/packlets/bundle/bundleBuilder.js +134 -0
  9. package/lib/packlets/bundle/bundleLoader.d.ts +72 -0
  10. package/lib/packlets/bundle/bundleLoader.js +105 -0
  11. package/lib/packlets/bundle/bundleNormalizer.d.ts +73 -0
  12. package/lib/packlets/bundle/bundleNormalizer.js +142 -0
  13. package/lib/packlets/bundle/bundleUtils.d.ts +70 -0
  14. package/lib/packlets/bundle/bundleUtils.js +117 -0
  15. package/lib/packlets/bundle/convert.d.ts +33 -0
  16. package/lib/packlets/bundle/convert.js +78 -0
  17. package/lib/packlets/bundle/index.d.ts +21 -0
  18. package/lib/packlets/bundle/index.js +83 -0
  19. package/lib/packlets/bundle/model.d.ts +100 -0
  20. package/lib/packlets/bundle/model.js +24 -0
  21. package/lib/packlets/common/convert.d.ts +10 -0
  22. package/lib/packlets/common/convert.js +11 -1
  23. package/lib/packlets/common/helpers/resources.d.ts +7 -0
  24. package/lib/packlets/common/helpers/resources.js +12 -0
  25. package/lib/packlets/common/resources.d.ts +48 -1
  26. package/lib/packlets/common/validate/regularExpressions.d.ts +4 -0
  27. package/lib/packlets/common/validate/regularExpressions.js +5 -1
  28. package/lib/packlets/common/validate/resources.d.ts +35 -1
  29. package/lib/packlets/common/validate/resources.js +54 -0
  30. package/lib/packlets/conditions/conditionSet.d.ts +9 -0
  31. package/lib/packlets/conditions/conditionSet.js +74 -1
  32. package/lib/packlets/config/configInitFactory.d.ts +217 -0
  33. package/lib/packlets/config/configInitFactory.js +302 -0
  34. package/lib/packlets/config/convert.d.ts +9 -0
  35. package/lib/packlets/config/convert.js +12 -1
  36. package/lib/packlets/config/index.d.ts +1 -0
  37. package/lib/packlets/config/index.js +1 -0
  38. package/lib/packlets/config/json.d.ts +1 -1
  39. package/lib/packlets/config/systemConfiguration.d.ts +16 -3
  40. package/lib/packlets/config/systemConfiguration.js +19 -40
  41. package/lib/packlets/import/fsItem.js +8 -13
  42. package/lib/packlets/import/importers/jsonImporter.js +1 -0
  43. package/lib/packlets/qualifier-types/config/convert.d.ts +22 -1
  44. package/lib/packlets/qualifier-types/config/convert.js +67 -2
  45. package/lib/packlets/qualifier-types/config/json.d.ts +24 -2
  46. package/lib/packlets/qualifier-types/config/json.js +11 -0
  47. package/lib/packlets/qualifier-types/convert.d.ts +1 -1
  48. package/lib/packlets/qualifier-types/helpers.d.ts +14 -5
  49. package/lib/packlets/qualifier-types/helpers.js +2 -2
  50. package/lib/packlets/qualifier-types/languageQualifierType.d.ts +28 -2
  51. package/lib/packlets/qualifier-types/languageQualifierType.js +73 -0
  52. package/lib/packlets/qualifier-types/literalQualifierType.d.ts +31 -5
  53. package/lib/packlets/qualifier-types/literalQualifierType.js +75 -0
  54. package/lib/packlets/qualifier-types/literalValueHierarchy.d.ts +7 -11
  55. package/lib/packlets/qualifier-types/literalValueHierarchy.js +11 -1
  56. package/lib/packlets/qualifier-types/qualifierType.d.ts +31 -2
  57. package/lib/packlets/qualifier-types/territoryQualifierType.d.ts +31 -5
  58. package/lib/packlets/qualifier-types/territoryQualifierType.js +77 -0
  59. package/lib/packlets/qualifiers/qualifierCollector.js +1 -2
  60. package/lib/packlets/resource-json/compiled/convert.js +2 -1
  61. package/lib/packlets/resource-json/compiled/json.d.ts +6 -2
  62. package/lib/packlets/resource-types/config/convert.d.ts +1 -1
  63. package/lib/packlets/resource-types/config/convert.js +3 -1
  64. package/lib/packlets/resource-types/config/json.d.ts +3 -1
  65. package/lib/packlets/resource-types/jsonResourceType.d.ts +14 -5
  66. package/lib/packlets/resource-types/jsonResourceType.js +8 -4
  67. package/lib/packlets/resource-types/resourceType.d.ts +115 -14
  68. package/lib/packlets/resource-types/resourceType.js +39 -3
  69. package/lib/packlets/resources/candidateValue.d.ts +92 -0
  70. package/lib/packlets/resources/candidateValue.js +128 -0
  71. package/lib/packlets/resources/candidateValueCollector.d.ts +55 -0
  72. package/lib/packlets/resources/candidateValueCollector.js +96 -0
  73. package/lib/packlets/resources/common.d.ts +26 -0
  74. package/lib/packlets/resources/index.d.ts +2 -0
  75. package/lib/packlets/resources/index.js +2 -0
  76. package/lib/packlets/resources/resource.d.ts +6 -6
  77. package/lib/packlets/resources/resource.js +5 -10
  78. package/lib/packlets/resources/resourceBuilder.d.ts +6 -0
  79. package/lib/packlets/resources/resourceBuilder.js +3 -1
  80. package/lib/packlets/resources/resourceCandidate.d.ts +15 -2
  81. package/lib/packlets/resources/resourceCandidate.js +17 -5
  82. package/lib/packlets/resources/resourceManagerBuilder.d.ts +189 -11
  83. package/lib/packlets/resources/resourceManagerBuilder.js +478 -17
  84. package/lib/packlets/runtime/cacheListener.d.ts +9 -0
  85. package/lib/packlets/runtime/cacheListener.js +6 -0
  86. package/lib/packlets/runtime/cacheMetrics.d.ts +6 -0
  87. package/lib/packlets/runtime/cacheMetrics.js +11 -0
  88. package/lib/packlets/runtime/compiledResourceCollection.d.ts +23 -11
  89. package/lib/packlets/runtime/compiledResourceCollection.js +32 -4
  90. package/lib/packlets/runtime/iResourceManager.d.ts +13 -5
  91. package/lib/packlets/runtime/index.d.ts +1 -0
  92. package/lib/packlets/runtime/index.js +1 -0
  93. package/lib/packlets/runtime/resource-tree/common.d.ts +1 -1
  94. package/lib/packlets/runtime/resource-tree/resourceTreeChildrenValidator.d.ts +7 -7
  95. package/lib/packlets/runtime/resource-tree/resourceTreeChildrenValidator.js +5 -5
  96. package/lib/packlets/runtime/resourceResolver.d.ts +60 -1
  97. package/lib/packlets/runtime/resourceResolver.js +84 -45
  98. package/lib/packlets/runtime/resourceTreeResolver.d.ts +152 -0
  99. package/lib/packlets/runtime/resourceTreeResolver.js +222 -0
  100. package/lib/packlets/runtime/validate.js +1 -0
  101. package/lib/packlets/zip-archive/convert.d.ts +52 -0
  102. package/lib/packlets/zip-archive/convert.js +103 -0
  103. package/lib/packlets/zip-archive/index.d.ts +23 -0
  104. package/lib/packlets/zip-archive/index.js +95 -0
  105. package/lib/packlets/zip-archive/json.d.ts +64 -0
  106. package/lib/packlets/zip-archive/json.js +24 -0
  107. package/lib/packlets/zip-archive/types.d.ts +98 -0
  108. package/lib/packlets/zip-archive/types.js +39 -0
  109. package/lib/packlets/zip-archive/zipArchiveCreator.d.ts +35 -0
  110. package/lib/packlets/zip-archive/zipArchiveCreator.js +194 -0
  111. package/lib/packlets/zip-archive/zipArchiveFormat.d.ts +70 -0
  112. package/lib/packlets/zip-archive/zipArchiveFormat.js +184 -0
  113. package/lib/packlets/zip-archive/zipArchiveLoader.d.ts +70 -0
  114. package/lib/packlets/zip-archive/zipArchiveLoader.js +285 -0
  115. package/package.json +26 -32
  116. package/CLAUDE.md +0 -186
  117. package/EXAMPLE_INIT_PARAMS.md +0 -88
  118. package/PROGRESS_SUMMARY.md +0 -48
  119. package/lib/index.d.ts.map +0 -1
  120. package/lib/index.js.map +0 -1
  121. package/lib/packlets/common/conditions.d.ts.map +0 -1
  122. package/lib/packlets/common/conditions.js.map +0 -1
  123. package/lib/packlets/common/convert.d.ts.map +0 -1
  124. package/lib/packlets/common/convert.js.map +0 -1
  125. package/lib/packlets/common/helpers/conditions.d.ts.map +0 -1
  126. package/lib/packlets/common/helpers/conditions.js.map +0 -1
  127. package/lib/packlets/common/helpers/context.d.ts.map +0 -1
  128. package/lib/packlets/common/helpers/context.js.map +0 -1
  129. package/lib/packlets/common/helpers/index.d.ts.map +0 -1
  130. package/lib/packlets/common/helpers/index.js.map +0 -1
  131. package/lib/packlets/common/helpers/qualifierDefaultValues.d.ts.map +0 -1
  132. package/lib/packlets/common/helpers/qualifierDefaultValues.js.map +0 -1
  133. package/lib/packlets/common/helpers/resources.d.ts.map +0 -1
  134. package/lib/packlets/common/helpers/resources.js.map +0 -1
  135. package/lib/packlets/common/index.d.ts.map +0 -1
  136. package/lib/packlets/common/index.js.map +0 -1
  137. package/lib/packlets/common/resources.d.ts.map +0 -1
  138. package/lib/packlets/common/resources.js.map +0 -1
  139. package/lib/packlets/common/validate/conditions.d.ts.map +0 -1
  140. package/lib/packlets/common/validate/conditions.js.map +0 -1
  141. package/lib/packlets/common/validate/index.d.ts.map +0 -1
  142. package/lib/packlets/common/validate/index.js.map +0 -1
  143. package/lib/packlets/common/validate/regularExpressions.d.ts.map +0 -1
  144. package/lib/packlets/common/validate/regularExpressions.js.map +0 -1
  145. package/lib/packlets/common/validate/resources.d.ts.map +0 -1
  146. package/lib/packlets/common/validate/resources.js.map +0 -1
  147. package/lib/packlets/conditions/condition.d.ts.map +0 -1
  148. package/lib/packlets/conditions/condition.js.map +0 -1
  149. package/lib/packlets/conditions/conditionCollector.d.ts.map +0 -1
  150. package/lib/packlets/conditions/conditionCollector.js.map +0 -1
  151. package/lib/packlets/conditions/conditionDecls.d.ts.map +0 -1
  152. package/lib/packlets/conditions/conditionDecls.js.map +0 -1
  153. package/lib/packlets/conditions/conditionSet.d.ts.map +0 -1
  154. package/lib/packlets/conditions/conditionSet.js.map +0 -1
  155. package/lib/packlets/conditions/conditionSetCollector.d.ts.map +0 -1
  156. package/lib/packlets/conditions/conditionSetCollector.js.map +0 -1
  157. package/lib/packlets/conditions/conditionSetDecls.d.ts.map +0 -1
  158. package/lib/packlets/conditions/conditionSetDecls.js.map +0 -1
  159. package/lib/packlets/conditions/conditionToken.d.ts.map +0 -1
  160. package/lib/packlets/conditions/conditionToken.js.map +0 -1
  161. package/lib/packlets/conditions/convert/conditionSetDecls.d.ts.map +0 -1
  162. package/lib/packlets/conditions/convert/conditionSetDecls.js.map +0 -1
  163. package/lib/packlets/conditions/convert/decls.d.ts.map +0 -1
  164. package/lib/packlets/conditions/convert/decls.js.map +0 -1
  165. package/lib/packlets/conditions/convert/index.d.ts.map +0 -1
  166. package/lib/packlets/conditions/convert/index.js.map +0 -1
  167. package/lib/packlets/conditions/index.d.ts.map +0 -1
  168. package/lib/packlets/conditions/index.js.map +0 -1
  169. package/lib/packlets/config/common.d.ts.map +0 -1
  170. package/lib/packlets/config/common.js.map +0 -1
  171. package/lib/packlets/config/convert.d.ts.map +0 -1
  172. package/lib/packlets/config/convert.js.map +0 -1
  173. package/lib/packlets/config/index.d.ts.map +0 -1
  174. package/lib/packlets/config/index.js.map +0 -1
  175. package/lib/packlets/config/json.d.ts.map +0 -1
  176. package/lib/packlets/config/json.js.map +0 -1
  177. package/lib/packlets/config/predefined/default.d.ts.map +0 -1
  178. package/lib/packlets/config/predefined/default.js.map +0 -1
  179. package/lib/packlets/config/predefined/extended.d.ts.map +0 -1
  180. package/lib/packlets/config/predefined/extended.js.map +0 -1
  181. package/lib/packlets/config/predefined/index.d.ts.map +0 -1
  182. package/lib/packlets/config/predefined/index.js.map +0 -1
  183. package/lib/packlets/config/systemConfiguration.d.ts.map +0 -1
  184. package/lib/packlets/config/systemConfiguration.js.map +0 -1
  185. package/lib/packlets/context/contextDecls.d.ts.map +0 -1
  186. package/lib/packlets/context/contextDecls.js.map +0 -1
  187. package/lib/packlets/context/contextToken.d.ts.map +0 -1
  188. package/lib/packlets/context/contextToken.js.map +0 -1
  189. package/lib/packlets/context/convert/decls.d.ts.map +0 -1
  190. package/lib/packlets/context/convert/decls.js.map +0 -1
  191. package/lib/packlets/context/convert/index.d.ts.map +0 -1
  192. package/lib/packlets/context/convert/index.js.map +0 -1
  193. package/lib/packlets/context/index.d.ts.map +0 -1
  194. package/lib/packlets/context/index.js.map +0 -1
  195. package/lib/packlets/decisions/abstractDecision.d.ts.map +0 -1
  196. package/lib/packlets/decisions/abstractDecision.js.map +0 -1
  197. package/lib/packlets/decisions/abstractDecisionCollector.d.ts.map +0 -1
  198. package/lib/packlets/decisions/abstractDecisionCollector.js.map +0 -1
  199. package/lib/packlets/decisions/candidate.d.ts.map +0 -1
  200. package/lib/packlets/decisions/candidate.js.map +0 -1
  201. package/lib/packlets/decisions/common.d.ts.map +0 -1
  202. package/lib/packlets/decisions/common.js.map +0 -1
  203. package/lib/packlets/decisions/concreteDecision.d.ts.map +0 -1
  204. package/lib/packlets/decisions/concreteDecision.js.map +0 -1
  205. package/lib/packlets/decisions/decision.d.ts.map +0 -1
  206. package/lib/packlets/decisions/decision.js.map +0 -1
  207. package/lib/packlets/decisions/index.d.ts.map +0 -1
  208. package/lib/packlets/decisions/index.js.map +0 -1
  209. package/lib/packlets/import/fsItem.d.ts.map +0 -1
  210. package/lib/packlets/import/fsItem.js.map +0 -1
  211. package/lib/packlets/import/importContext.d.ts.map +0 -1
  212. package/lib/packlets/import/importContext.js.map +0 -1
  213. package/lib/packlets/import/importManager.d.ts.map +0 -1
  214. package/lib/packlets/import/importManager.js.map +0 -1
  215. package/lib/packlets/import/importable.d.ts.map +0 -1
  216. package/lib/packlets/import/importable.js.map +0 -1
  217. package/lib/packlets/import/importers/collectionImporter.d.ts.map +0 -1
  218. package/lib/packlets/import/importers/collectionImporter.js.map +0 -1
  219. package/lib/packlets/import/importers/fsItemImporter.d.ts.map +0 -1
  220. package/lib/packlets/import/importers/fsItemImporter.js.map +0 -1
  221. package/lib/packlets/import/importers/importer.d.ts.map +0 -1
  222. package/lib/packlets/import/importers/importer.js.map +0 -1
  223. package/lib/packlets/import/importers/index.d.ts.map +0 -1
  224. package/lib/packlets/import/importers/index.js.map +0 -1
  225. package/lib/packlets/import/importers/jsonImporter.d.ts.map +0 -1
  226. package/lib/packlets/import/importers/jsonImporter.js.map +0 -1
  227. package/lib/packlets/import/importers/pathImporter.d.ts.map +0 -1
  228. package/lib/packlets/import/importers/pathImporter.js.map +0 -1
  229. package/lib/packlets/import/index.d.ts.map +0 -1
  230. package/lib/packlets/import/index.js.map +0 -1
  231. package/lib/packlets/qualifier-types/config/convert.d.ts.map +0 -1
  232. package/lib/packlets/qualifier-types/config/convert.js.map +0 -1
  233. package/lib/packlets/qualifier-types/config/index.d.ts.map +0 -1
  234. package/lib/packlets/qualifier-types/config/index.js.map +0 -1
  235. package/lib/packlets/qualifier-types/config/json.d.ts.map +0 -1
  236. package/lib/packlets/qualifier-types/config/json.js.map +0 -1
  237. package/lib/packlets/qualifier-types/convert.d.ts.map +0 -1
  238. package/lib/packlets/qualifier-types/convert.js.map +0 -1
  239. package/lib/packlets/qualifier-types/helpers.d.ts.map +0 -1
  240. package/lib/packlets/qualifier-types/helpers.js.map +0 -1
  241. package/lib/packlets/qualifier-types/index.d.ts.map +0 -1
  242. package/lib/packlets/qualifier-types/index.js.map +0 -1
  243. package/lib/packlets/qualifier-types/languageQualifierType.d.ts.map +0 -1
  244. package/lib/packlets/qualifier-types/languageQualifierType.js.map +0 -1
  245. package/lib/packlets/qualifier-types/literalQualifierType.d.ts.map +0 -1
  246. package/lib/packlets/qualifier-types/literalQualifierType.js.map +0 -1
  247. package/lib/packlets/qualifier-types/literalValueHierarchy.d.ts.map +0 -1
  248. package/lib/packlets/qualifier-types/literalValueHierarchy.js.map +0 -1
  249. package/lib/packlets/qualifier-types/qualifierType.d.ts.map +0 -1
  250. package/lib/packlets/qualifier-types/qualifierType.js.map +0 -1
  251. package/lib/packlets/qualifier-types/qualifierTypeCollector.d.ts.map +0 -1
  252. package/lib/packlets/qualifier-types/qualifierTypeCollector.js.map +0 -1
  253. package/lib/packlets/qualifier-types/territoryQualifierType.d.ts.map +0 -1
  254. package/lib/packlets/qualifier-types/territoryQualifierType.js.map +0 -1
  255. package/lib/packlets/qualifiers/convert/decls.d.ts.map +0 -1
  256. package/lib/packlets/qualifiers/convert/decls.js.map +0 -1
  257. package/lib/packlets/qualifiers/convert/index.d.ts.map +0 -1
  258. package/lib/packlets/qualifiers/convert/index.js.map +0 -1
  259. package/lib/packlets/qualifiers/convert/qualifier.d.ts.map +0 -1
  260. package/lib/packlets/qualifiers/convert/qualifier.js.map +0 -1
  261. package/lib/packlets/qualifiers/index.d.ts.map +0 -1
  262. package/lib/packlets/qualifiers/index.js.map +0 -1
  263. package/lib/packlets/qualifiers/qualifier.d.ts.map +0 -1
  264. package/lib/packlets/qualifiers/qualifier.js.map +0 -1
  265. package/lib/packlets/qualifiers/qualifierCollector.d.ts.map +0 -1
  266. package/lib/packlets/qualifiers/qualifierCollector.js.map +0 -1
  267. package/lib/packlets/qualifiers/qualifierDecl.d.ts.map +0 -1
  268. package/lib/packlets/qualifiers/qualifierDecl.js.map +0 -1
  269. package/lib/packlets/qualifiers/qualifierDefaultValueDecls.d.ts.map +0 -1
  270. package/lib/packlets/qualifiers/qualifierDefaultValueDecls.js.map +0 -1
  271. package/lib/packlets/qualifiers/qualifierDefaultValueToken.d.ts.map +0 -1
  272. package/lib/packlets/qualifiers/qualifierDefaultValueToken.js.map +0 -1
  273. package/lib/packlets/resource-json/compiled/common.d.ts.map +0 -1
  274. package/lib/packlets/resource-json/compiled/common.js.map +0 -1
  275. package/lib/packlets/resource-json/compiled/convert.d.ts.map +0 -1
  276. package/lib/packlets/resource-json/compiled/convert.js.map +0 -1
  277. package/lib/packlets/resource-json/compiled/index.d.ts.map +0 -1
  278. package/lib/packlets/resource-json/compiled/index.js.map +0 -1
  279. package/lib/packlets/resource-json/compiled/json.d.ts.map +0 -1
  280. package/lib/packlets/resource-json/compiled/json.js.map +0 -1
  281. package/lib/packlets/resource-json/convert.d.ts.map +0 -1
  282. package/lib/packlets/resource-json/convert.js.map +0 -1
  283. package/lib/packlets/resource-json/helpers.d.ts.map +0 -1
  284. package/lib/packlets/resource-json/helpers.js.map +0 -1
  285. package/lib/packlets/resource-json/index.d.ts.map +0 -1
  286. package/lib/packlets/resource-json/index.js.map +0 -1
  287. package/lib/packlets/resource-json/json.d.ts.map +0 -1
  288. package/lib/packlets/resource-json/json.js.map +0 -1
  289. package/lib/packlets/resource-json/normalized.d.ts.map +0 -1
  290. package/lib/packlets/resource-json/normalized.js.map +0 -1
  291. package/lib/packlets/resource-json/resourceDeclCollection.d.ts.map +0 -1
  292. package/lib/packlets/resource-json/resourceDeclCollection.js.map +0 -1
  293. package/lib/packlets/resource-json/resourceDeclContainer.d.ts.map +0 -1
  294. package/lib/packlets/resource-json/resourceDeclContainer.js.map +0 -1
  295. package/lib/packlets/resource-json/resourceDeclTree.d.ts.map +0 -1
  296. package/lib/packlets/resource-json/resourceDeclTree.js.map +0 -1
  297. package/lib/packlets/resource-types/config/convert.d.ts.map +0 -1
  298. package/lib/packlets/resource-types/config/convert.js.map +0 -1
  299. package/lib/packlets/resource-types/config/index.d.ts.map +0 -1
  300. package/lib/packlets/resource-types/config/index.js.map +0 -1
  301. package/lib/packlets/resource-types/config/json.d.ts.map +0 -1
  302. package/lib/packlets/resource-types/config/json.js.map +0 -1
  303. package/lib/packlets/resource-types/helpers.d.ts.map +0 -1
  304. package/lib/packlets/resource-types/helpers.js.map +0 -1
  305. package/lib/packlets/resource-types/index.d.ts.map +0 -1
  306. package/lib/packlets/resource-types/index.js.map +0 -1
  307. package/lib/packlets/resource-types/jsonResourceType.d.ts.map +0 -1
  308. package/lib/packlets/resource-types/jsonResourceType.js.map +0 -1
  309. package/lib/packlets/resource-types/resourceType.d.ts.map +0 -1
  310. package/lib/packlets/resource-types/resourceType.js.map +0 -1
  311. package/lib/packlets/resource-types/resourceTypeCollector.d.ts.map +0 -1
  312. package/lib/packlets/resource-types/resourceTypeCollector.js.map +0 -1
  313. package/lib/packlets/resources/candidateReducer.d.ts.map +0 -1
  314. package/lib/packlets/resources/candidateReducer.js.map +0 -1
  315. package/lib/packlets/resources/common.d.ts.map +0 -1
  316. package/lib/packlets/resources/common.js.map +0 -1
  317. package/lib/packlets/resources/index.d.ts.map +0 -1
  318. package/lib/packlets/resources/index.js.map +0 -1
  319. package/lib/packlets/resources/resource.d.ts.map +0 -1
  320. package/lib/packlets/resources/resource.js.map +0 -1
  321. package/lib/packlets/resources/resourceBuilder.d.ts.map +0 -1
  322. package/lib/packlets/resources/resourceBuilder.js.map +0 -1
  323. package/lib/packlets/resources/resourceCandidate.d.ts.map +0 -1
  324. package/lib/packlets/resources/resourceCandidate.js.map +0 -1
  325. package/lib/packlets/resources/resourceManagerBuilder.d.ts.map +0 -1
  326. package/lib/packlets/resources/resourceManagerBuilder.js.map +0 -1
  327. package/lib/packlets/runtime/cacheListener.d.ts.map +0 -1
  328. package/lib/packlets/runtime/cacheListener.js.map +0 -1
  329. package/lib/packlets/runtime/cacheMetrics.d.ts.map +0 -1
  330. package/lib/packlets/runtime/cacheMetrics.js.map +0 -1
  331. package/lib/packlets/runtime/compiledResourceCollection.d.ts.map +0 -1
  332. package/lib/packlets/runtime/compiledResourceCollection.js.map +0 -1
  333. package/lib/packlets/runtime/conditionSetResolutionResult.d.ts.map +0 -1
  334. package/lib/packlets/runtime/conditionSetResolutionResult.js.map +0 -1
  335. package/lib/packlets/runtime/context/contextQualifierProvider.d.ts.map +0 -1
  336. package/lib/packlets/runtime/context/contextQualifierProvider.js.map +0 -1
  337. package/lib/packlets/runtime/context/contextQualifierProviderValidator.d.ts.map +0 -1
  338. package/lib/packlets/runtime/context/contextQualifierProviderValidator.js.map +0 -1
  339. package/lib/packlets/runtime/context/index.d.ts.map +0 -1
  340. package/lib/packlets/runtime/context/index.js.map +0 -1
  341. package/lib/packlets/runtime/context/simpleContextQualifierProvider.d.ts.map +0 -1
  342. package/lib/packlets/runtime/context/simpleContextQualifierProvider.js.map +0 -1
  343. package/lib/packlets/runtime/context/validatingSimpleContextQualifierProvider.d.ts.map +0 -1
  344. package/lib/packlets/runtime/context/validatingSimpleContextQualifierProvider.js.map +0 -1
  345. package/lib/packlets/runtime/iResourceManager.d.ts.map +0 -1
  346. package/lib/packlets/runtime/iResourceManager.js.map +0 -1
  347. package/lib/packlets/runtime/index.d.ts.map +0 -1
  348. package/lib/packlets/runtime/index.js.map +0 -1
  349. package/lib/packlets/runtime/resource-tree/common.d.ts.map +0 -1
  350. package/lib/packlets/runtime/resource-tree/common.js.map +0 -1
  351. package/lib/packlets/runtime/resource-tree/index.d.ts.map +0 -1
  352. package/lib/packlets/runtime/resource-tree/index.js.map +0 -1
  353. package/lib/packlets/runtime/resource-tree/readOnlyResourceTree.d.ts.map +0 -1
  354. package/lib/packlets/runtime/resource-tree/readOnlyResourceTree.js.map +0 -1
  355. package/lib/packlets/runtime/resource-tree/resourceTreeChildren.d.ts.map +0 -1
  356. package/lib/packlets/runtime/resource-tree/resourceTreeChildren.js.map +0 -1
  357. package/lib/packlets/runtime/resource-tree/resourceTreeChildrenValidator.d.ts.map +0 -1
  358. package/lib/packlets/runtime/resource-tree/resourceTreeChildrenValidator.js.map +0 -1
  359. package/lib/packlets/runtime/resourceResolver.d.ts.map +0 -1
  360. package/lib/packlets/runtime/resourceResolver.js.map +0 -1
  361. package/lib/packlets/runtime/validate.d.ts.map +0 -1
  362. package/lib/packlets/runtime/validate.js.map +0 -1
@@ -0,0 +1,285 @@
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.ZipArchiveLoader = void 0;
25
+ const ts_utils_1 = require("@fgv/ts-utils");
26
+ const ts_extras_1 = require("@fgv/ts-extras");
27
+ const zipArchiveFormat_1 = require("./zipArchiveFormat");
28
+ /**
29
+ * ZIP archive loader extending ts-extras foundation
30
+ * @public
31
+ */
32
+ class ZipArchiveLoader {
33
+ /**
34
+ * Load ZIP archive from File object (Browser)
35
+ * @param file - File object from file input
36
+ * @param options - Loading options
37
+ * @param onProgress - Optional progress callback
38
+ * @returns Result containing loaded archive data
39
+ */
40
+ async loadFromFile(file, options = {}, onProgress) {
41
+ onProgress === null || onProgress === void 0 ? void 0 : onProgress('reading-file', 0, `Reading file: ${file.name}`);
42
+ if (!(0, zipArchiveFormat_1.isZipFile)(file.name)) {
43
+ return (0, ts_utils_1.fail)(`File ${file.name} is not a ZIP file`);
44
+ }
45
+ try {
46
+ const buffer = await file.arrayBuffer();
47
+ onProgress === null || onProgress === void 0 ? void 0 : onProgress('reading-file', 100, 'File read complete');
48
+ return await this.loadFromBuffer(buffer, options, onProgress);
49
+ /* c8 ignore next 3 - defense in depth against internal error */
50
+ }
51
+ catch (error) {
52
+ return (0, ts_utils_1.fail)(`Failed to read file: ${error instanceof Error ? error.message : String(error)}`);
53
+ }
54
+ }
55
+ /**
56
+ * Load ZIP archive from ArrayBuffer (Universal)
57
+ * @param buffer - ZIP data buffer
58
+ * @param options - Loading options
59
+ * @param onProgress - Optional progress callback
60
+ * @returns Result containing loaded archive data
61
+ */
62
+ async loadFromBuffer(buffer, options = {}, onProgress) {
63
+ onProgress === null || onProgress === void 0 ? void 0 : onProgress('parsing-zip', 0, 'Parsing ZIP archive');
64
+ const zipAccessorsResult = ts_extras_1.ZipFileTree.ZipFileTreeAccessors.fromBuffer(buffer);
65
+ if (zipAccessorsResult.isFailure()) {
66
+ return (0, ts_utils_1.fail)(`Failed to parse ZIP: ${zipAccessorsResult.message}`);
67
+ }
68
+ const zipAccessors = zipAccessorsResult.value;
69
+ onProgress === null || onProgress === void 0 ? void 0 : onProgress('parsing-zip', 100, 'ZIP archive parsed');
70
+ // Load manifest
71
+ onProgress === null || onProgress === void 0 ? void 0 : onProgress('loading-manifest', 0, 'Loading manifest');
72
+ const manifestResult = this._loadManifestFromAccessors(zipAccessors);
73
+ if (manifestResult.isFailure()) {
74
+ return (0, ts_utils_1.fail)(manifestResult.message);
75
+ }
76
+ const manifest = manifestResult.value;
77
+ onProgress === null || onProgress === void 0 ? void 0 : onProgress('loading-manifest', 100, 'Manifest loaded');
78
+ // Load configuration
79
+ onProgress === null || onProgress === void 0 ? void 0 : onProgress('loading-config', 0, 'Loading configuration');
80
+ const configResult = this._loadConfigurationFromAccessors(zipAccessors, manifest, options);
81
+ if (configResult.isFailure()) {
82
+ return (0, ts_utils_1.fail)(configResult.message);
83
+ }
84
+ const config = configResult.value;
85
+ onProgress === null || onProgress === void 0 ? void 0 : onProgress('loading-config', 100, 'Configuration loaded');
86
+ // Extract files and directory structure
87
+ onProgress === null || onProgress === void 0 ? void 0 : onProgress('extracting-files', 0, 'Extracting files');
88
+ const filesResult = await this._extractFilesFromAccessors(zipAccessors, onProgress);
89
+ /* c8 ignore next 3 - defense in depth against internal error */
90
+ if (filesResult.isFailure()) {
91
+ return (0, ts_utils_1.fail)(filesResult.message);
92
+ }
93
+ const { files, directory } = filesResult.value;
94
+ onProgress === null || onProgress === void 0 ? void 0 : onProgress('extracting-files', 100, `Extracted ${files.length} files`);
95
+ onProgress === null || onProgress === void 0 ? void 0 : onProgress('extracting-files', 100, 'ZIP loading complete');
96
+ return (0, ts_utils_1.succeed)({
97
+ manifest,
98
+ config,
99
+ files,
100
+ directory
101
+ });
102
+ }
103
+ /**
104
+ * Load manifest from ZIP using ZipFileTreeAccessors
105
+ * @param zipAccessors - ZIP file tree accessors
106
+ * @returns Result containing parsed manifest
107
+ */
108
+ _loadManifestFromAccessors(zipAccessors) {
109
+ const manifestResult = zipAccessors.getFileContents('manifest.json');
110
+ if (manifestResult.isFailure()) {
111
+ // Manifest is optional - return success with undefined
112
+ return (0, ts_utils_1.succeed)(undefined);
113
+ }
114
+ const parseResult = (0, zipArchiveFormat_1.parseZipArchiveManifest)(manifestResult.value);
115
+ if (parseResult.isFailure()) {
116
+ return (0, ts_utils_1.fail)(`Failed to parse manifest.json: ${parseResult.message}`);
117
+ }
118
+ return (0, ts_utils_1.succeed)(parseResult.value);
119
+ }
120
+ /**
121
+ * Load configuration from ZIP using ZipFileTreeAccessors
122
+ * @param zipAccessors - ZIP file tree accessors
123
+ * @param manifest - Parsed manifest (may be undefined)
124
+ * @param options - Loading options
125
+ * @returns Result containing parsed configuration
126
+ */
127
+ _loadConfigurationFromAccessors(zipAccessors, manifest, options) {
128
+ // Check if manifest specifies a config file
129
+ const manifestSpecifiesConfig = (manifest === null || manifest === void 0 ? void 0 : manifest.config) !== undefined;
130
+ if (!manifestSpecifiesConfig) {
131
+ // If no config specified in manifest, config is optional
132
+ return (0, ts_utils_1.succeed)(undefined);
133
+ }
134
+ // Get the config path from the manifest
135
+ const configPath = manifest.config.archivePath;
136
+ return zipAccessors
137
+ .getFileContents(configPath)
138
+ .withErrorFormat(() => `Manifest specifies config file at '${configPath}' but it was not found in archive`)
139
+ .onSuccess((configContent) => (0, zipArchiveFormat_1.parseZipArchiveConfiguration)(configContent))
140
+ .withErrorFormat((e) => `Failed to parse config file '${configPath}': ${e}`);
141
+ }
142
+ /**
143
+ * Extract files and directory structure from ZIP
144
+ * @param zipAccessors - ZIP file tree accessors
145
+ * @param onProgress - Optional progress callback
146
+ * @returns Result containing files and directory structure
147
+ */
148
+ async _extractFilesFromAccessors(zipAccessors, onProgress) {
149
+ try {
150
+ const files = [];
151
+ const directories = new Map();
152
+ // Get all children from root
153
+ const rootChildrenResult = zipAccessors.getChildren('/');
154
+ /* c8 ignore next 3 - defense in depth against internal error */
155
+ if (rootChildrenResult.isFailure()) {
156
+ return (0, ts_utils_1.fail)(`Failed to read ZIP contents: ${rootChildrenResult.message}`);
157
+ }
158
+ // Process all items recursively
159
+ await this._processFileTreeItems(zipAccessors, '/', rootChildrenResult.value, files, directories, onProgress);
160
+ // Build directory structure
161
+ const directory = this._buildDirectoryStructure(files, directories);
162
+ return (0, ts_utils_1.succeed)({ files, directory });
163
+ /* c8 ignore next 3 - defense in depth against internal error */
164
+ }
165
+ catch (error) {
166
+ return (0, ts_utils_1.fail)(`Failed to extract files: ${error instanceof Error ? error.message : String(error)}`);
167
+ }
168
+ }
169
+ /**
170
+ * Recursively process file tree items
171
+ * @param zipAccessors - ZIP file tree accessors
172
+ * @param currentPath - Current directory path
173
+ * @param items - Items to process
174
+ * @param files - Files collection
175
+ * @param directories - Directories collection
176
+ * @param onProgress - Optional progress callback
177
+ * @param processed - Processing counter
178
+ */
179
+ async _processFileTreeItems(zipAccessors, currentPath, items, files, directories, onProgress, processed = { count: 0 }) {
180
+ for (const item of items) {
181
+ /* c8 ignore next 1 - defense in depth */
182
+ const itemPath = item.absolutePath.startsWith('/') ? item.absolutePath.substring(1) : item.absolutePath;
183
+ if (item.type === 'directory') {
184
+ // Track directory
185
+ if (!directories.has(itemPath)) {
186
+ directories.set(itemPath, {
187
+ name: item.name,
188
+ files: [],
189
+ subdirectories: []
190
+ });
191
+ }
192
+ // Recursively process children
193
+ const childrenResult = zipAccessors.getChildren(item.absolutePath);
194
+ if (childrenResult.isSuccess()) {
195
+ await this._processFileTreeItems(zipAccessors, item.absolutePath, childrenResult.value, files, directories, onProgress, processed);
196
+ }
197
+ }
198
+ else if (item.type === 'file') {
199
+ // Get file content
200
+ const contentResult = item.getRawContents();
201
+ const content = contentResult.orDefault('');
202
+ files.push({
203
+ name: item.name,
204
+ path: itemPath,
205
+ content,
206
+ type: this._getFileType(item.name)
207
+ });
208
+ }
209
+ processed.count++;
210
+ onProgress === null || onProgress === void 0 ? void 0 : onProgress('extracting-files', 0, `Processing ${itemPath}`);
211
+ }
212
+ }
213
+ /**
214
+ * Build directory structure from files
215
+ * @param files - Extracted files
216
+ * @param directories - Directories map
217
+ * @returns Root directory structure or null
218
+ */
219
+ _buildDirectoryStructure(files, directories) {
220
+ /* c8 ignore next 3 - should never happen with fflate */
221
+ if (files.length === 0) {
222
+ return undefined;
223
+ }
224
+ const rootDir = {
225
+ name: 'root',
226
+ files: [],
227
+ subdirectories: []
228
+ };
229
+ // Process files to build directory structure
230
+ for (const file of files) {
231
+ const pathParts = file.path.split('/').filter((part) => part.length > 0);
232
+ /* c8 ignore next 1 - defense in depth should never happen */
233
+ if (pathParts.length === 0)
234
+ continue;
235
+ // Ensure all parent directories exist
236
+ let currentDir = rootDir;
237
+ for (let i = 0; i < pathParts.length - 1; i++) {
238
+ const dirName = pathParts[i];
239
+ let foundDir = currentDir.subdirectories.find((d) => d.name === dirName);
240
+ if (!foundDir) {
241
+ foundDir = {
242
+ name: dirName,
243
+ files: [],
244
+ subdirectories: []
245
+ };
246
+ currentDir.subdirectories.push(foundDir);
247
+ }
248
+ currentDir = foundDir;
249
+ }
250
+ // Add file to its parent directory
251
+ currentDir.files.push(file);
252
+ }
253
+ return rootDir;
254
+ }
255
+ /**
256
+ * Get file MIME type based on extension
257
+ * @param filename - Filename
258
+ * @returns MIME type
259
+ */
260
+ _getFileType(filename) {
261
+ const ext = filename.toLowerCase().split('.').pop();
262
+ /* c8 ignore next 20 - no need to test every one */
263
+ switch (ext) {
264
+ case 'json':
265
+ return 'application/json';
266
+ case 'yaml':
267
+ case 'yml':
268
+ return 'application/yaml';
269
+ case 'xml':
270
+ return 'application/xml';
271
+ case 'txt':
272
+ return 'text/plain';
273
+ case 'md':
274
+ return 'text/markdown';
275
+ case 'js':
276
+ return 'application/javascript';
277
+ case 'ts':
278
+ return 'application/typescript';
279
+ default:
280
+ return 'application/octet-stream';
281
+ }
282
+ }
283
+ }
284
+ exports.ZipArchiveLoader = ZipArchiveLoader;
285
+ //# sourceMappingURL=zipArchiveLoader.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fgv/ts-res",
3
- "version": "5.0.0-3",
3
+ "version": "5.0.0-30",
4
4
  "description": "Multi-dimensional Resource Runtime",
5
5
  "main": "lib/index.js",
6
6
  "types": "dist/ts-res.d.ts",
@@ -18,48 +18,42 @@
18
18
  "homepage": "https://github.com/ErikFortune/fgv/tree/main/libraries/ts-res#readme",
19
19
  "sideEffects": false,
20
20
  "devDependencies": {
21
- "@microsoft/api-documenter": "^7.26.29",
22
- "@microsoft/api-extractor": "^7.49.1",
21
+ "@microsoft/api-documenter": "^7.26.31",
22
+ "@microsoft/api-extractor": "^7.52.10",
23
23
  "@types/jest": "^29.5.14",
24
- "@types/luxon": "^3.6.2",
24
+ "@types/luxon": "^3.7.1",
25
25
  "@types/node": "^20.14.9",
26
- "@typescript-eslint/eslint-plugin": "^7.14.1",
27
- "@typescript-eslint/parser": "^7.14.1",
28
- "eslint": "^8.57.0",
29
- "eslint-config-prettier": "^10.1.5",
26
+ "@typescript-eslint/eslint-plugin": "^8.42.0",
27
+ "@typescript-eslint/parser": "^8.42.0",
28
+ "eslint": "^9.35.0",
29
+ "eslint-config-prettier": "^10.1.8",
30
30
  "eslint-plugin-import": "^2.32.0",
31
31
  "eslint-plugin-node": "^11.1.0",
32
- "eslint-plugin-prettier": "^5.5.1",
33
- "eslint-plugin-promise": "^6.2.0",
32
+ "eslint-plugin-prettier": "^5.5.4",
33
+ "eslint-plugin-promise": "^7.2.1",
34
34
  "jest": "^29.7.0",
35
35
  "prettier": "^3.6.2",
36
- "rimraf": "^5.0.7",
37
- "ts-jest": "^29.4.0",
36
+ "rimraf": "^6.0.1",
37
+ "ts-jest": "^29.4.1",
38
38
  "ts-node": "^10.9.2",
39
- "typescript": "^5.7.3",
40
- "eslint-plugin-n": "^16.6.2",
41
- "@rushstack/eslint-config": "~4.4.0",
42
- "@rushstack/heft": "~0.74.0",
43
- "@rushstack/heft-jest-plugin": "~0.16.9",
44
- "@rushstack/heft-node-rig": "~2.9.0",
39
+ "typescript": "5.8.3",
40
+ "eslint-plugin-n": "^17.21.3",
41
+ "@rushstack/eslint-config": "4.4.0",
42
+ "@rushstack/heft": "0.74.4",
43
+ "@rushstack/heft-jest-plugin": "0.16.13",
44
+ "@rushstack/heft-node-rig": "2.9.5",
45
45
  "@types/heft-jest": "1.0.6",
46
46
  "eslint-plugin-tsdoc": "~0.4.0",
47
- "@fgv/ts-utils": "5.0.0-3",
48
- "@fgv/ts-utils-jest": "5.0.0-3",
49
- "@fgv/ts-extras": "5.0.0-3",
50
- "@fgv/ts-json-base": "5.0.0-3",
51
- "@fgv/ts-bcp47": "5.0.0-3",
52
- "@fgv/ts-json": "5.0.0-3"
47
+ "@fgv/ts-utils-jest": "5.0.0-30",
48
+ "@fgv/ts-extras": "5.0.0-30"
53
49
  },
54
50
  "dependencies": {
55
- "luxon": "^3.6.1"
56
- },
57
- "peerDependencies": {
58
- "@fgv/ts-utils": "5.0.0-3",
59
- "@fgv/ts-json-base": "5.0.0-3",
60
- "@fgv/ts-extras": "5.0.0-3",
61
- "@fgv/ts-bcp47": "5.0.0-3",
62
- "@fgv/ts-json": "5.0.0-3"
51
+ "luxon": "^3.7.2",
52
+ "fflate": "~0.8.2",
53
+ "@fgv/ts-json-base": "5.0.0-30",
54
+ "@fgv/ts-bcp47": "5.0.0-30",
55
+ "@fgv/ts-json": "5.0.0-30",
56
+ "@fgv/ts-utils": "5.0.0-30"
63
57
  },
64
58
  "scripts": {
65
59
  "build": "heft build --clean",
package/CLAUDE.md DELETED
@@ -1,186 +0,0 @@
1
- # CLAUDE.md
2
-
3
- This file provides ts-res-specific guidance to Claude Code (claude.ai/code) when working with the `@fgv/ts-res` library.
4
-
5
- **For general repository guidelines, testing philosophy, and TypeScript standards, see the root [CLAUDE.md](../../CLAUDE.md).**
6
-
7
- ## Project Overview
8
-
9
- This is `@fgv/ts-res`, a TypeScript library for multidimensional resource management with internationalization and localization support. It provides a sophisticated system for managing resources with complex conditional logic based on qualifiers like language, territory, and custom dimensions.
10
-
11
- ## Development Commands
12
-
13
- ### Build & Test
14
- - `rushx build` - Build the project (uses heft build --clean)
15
- - `rushx test` - Run tests (uses heft test --clean)
16
- - `rushx build-all` - Build project and generate documentation
17
- - `rushx coverage` - Run tests with coverage reporting
18
- - `rushx clean` - Clean build artifacts
19
-
20
- ### Linting & Code Quality
21
- - `rushx lint` - Run ESLint on source files
22
- - `rushx fixlint` - Run ESLint with automatic fixes
23
- - Tests must maintain 100% coverage (branches, functions, lines, statements)
24
-
25
- ### Documentation
26
- - `rushx build-docs` - Generate API documentation using api-documenter
27
- - Documentation is generated in the `docs/` directory
28
- - **IMPORTANT**: Always run `rushx build-docs` before check-in when making public API changes to regenerate API documentation
29
-
30
- ### Testing
31
- - Uses Jest with ts-jest for TypeScript support
32
- - Run single test: `jest path/to/test.test.ts`
33
- - Run with open handles detection: `rushx test-handles`
34
- - Clear Jest cache: `rushx clean-jest`
35
-
36
- ## Architecture
37
-
38
- The library is organized into "packlets" - cohesive modules that group related functionality:
39
-
40
- ### Core Components
41
-
42
- **Resources** (`src/packlets/resources/`):
43
- - `ResourceManager` - Central orchestrator for all resource operations
44
- - `Resource` - Individual resource with candidates for different contexts
45
- - `ResourceCandidate` - Specific resource variant with conditions and merge method
46
- - `ResourceBuilder` - Builder pattern for constructing resources
47
-
48
- **Conditions** (`src/packlets/conditions/`):
49
- - `Condition` - Individual condition with qualifier, operator, and value
50
- - `ConditionSet` - Collection of conditions that must all match
51
- - `ConditionCollector` - Manages and validates condition collections
52
- - `ConditionSetCollector` - Manages condition set collections
53
-
54
- **Qualifiers** (`src/packlets/qualifiers/`):
55
- - `Qualifier` - Named dimension for resource qualification (e.g., "language", "territory")
56
- - `QualifierCollector` - Manages qualifier definitions and validation
57
-
58
- **Qualifier Types** (`src/packlets/qualifier-types/`):
59
- - `QualifierType` - Defines validation and matching logic for qualifier values
60
- - `LanguageQualifierType` - BCP47 language tag validation
61
- - `TerritoryQualifierType` - Territory/region validation
62
- - `LiteralQualifierType` - Enumerated literal values with optional hierarchy
63
-
64
- **Decisions** (`src/packlets/decisions/`):
65
- - `Decision` - Represents a resolved resource choice for a context
66
- - `AbstractDecision` - Template for decisions with condition sets
67
- - `ConcreteDecision` - Fully resolved decision with specific candidates
68
-
69
- **Context** (`src/packlets/context/`):
70
- - Defines the context against which resources are matched (e.g., {language: "en-US", territory: "US"})
71
-
72
- **Import** (`src/packlets/import/`):
73
- - `ImportManager` - Orchestrates importing resources from various sources
74
- - `FsItemImporter` - Imports from file system items
75
- - `PathImporter` - Imports from file paths
76
- - `JsonImporter` - Imports from JSON structures
77
- - `CollectionImporter` - Imports from resource collections
78
-
79
- **Resource JSON** (`src/packlets/resource-json/`):
80
- - JSON serialization and deserialization of resource structures
81
- - Supports both tree and collection formats
82
-
83
- ### Key Patterns
84
-
85
- 1. **Result Pattern**: All operations that can fail return `Result<T>` objects from `@fgv/ts-utils`. Avoid throwing errors directly as much as possible, preferring to return a Result and use .orThrow() on paths that must throw.
86
- 2. **Collector Pattern**: Used throughout for managing collections with validation
87
- 3. **Builder Pattern**: `ResourceBuilder` for constructing complex resources
88
- 4. **Converter Pattern**: Each major type has convert functions for declaration-to-object transformation
89
- 5. **Type-Safe Validation Pattern**: Always use proper Converter and Validator objects for type validation instead of manual checks and unsafe casts (see [root CLAUDE.md](../../CLAUDE.md) for detailed guidelines)
90
-
91
- ### Dependencies
92
-
93
- - `@fgv/ts-utils` - Core utilities including Result pattern and collections
94
- - `@fgv/ts-extras` - Additional utility functions
95
- - `@fgv/ts-json-base` - JSON validation and processing
96
- - `@fgv/ts-bcp47` - BCP47 language tag processing
97
- - `@fgv/ts-json` - JSON schema validation
98
- - `luxon` - Date/time handling
99
-
100
- ## Testing Approach
101
-
102
- **This library follows the repository-wide testing philosophy outlined in the [root CLAUDE.md](../../CLAUDE.md).**
103
-
104
- **For comprehensive coverage guidelines and systematic approaches to achieving 100% test coverage, see [COVERAGE_GUIDELINES.md](../../COVERAGE_GUIDELINES.md).**
105
-
106
- ### ts-res-Specific Testing Patterns
107
-
108
- #### Testing ts-res Components
109
- ```typescript
110
- // ✅ Good - Test through ResourceManager public API
111
- expect(ResourceManager.create(params)).toSucceedAndSatisfy((manager) => {
112
- expect(manager.qualifiers.size).toBe(2);
113
- expect(manager.resourceTypes.size).toBe(1);
114
- expect(manager.getResource('test')).toSucceed();
115
- });
116
-
117
- // ✅ Good - Test internal validators through Runtime exports
118
- expect(TsRes.Runtime.resourceCandidate.validate(data)).toSucceed();
119
-
120
- // ✅ Good - Test interface through concrete implementation
121
- const leafNode: IReadOnlyResourceTreeLeaf<T> = ResourceTreeLeaf.create(...).orThrow();
122
- expect(leafNode.isLeaf).toBe(true);
123
- ```
124
-
125
- #### ts-res Result Pattern Examples
126
- ```typescript
127
- // ✅ Good - Setup uses standard Result methods
128
- beforeEach(() => {
129
- const qualifierTypesResult = QualifierTypeCollector.create(params);
130
- qualifierTypes = qualifierTypesResult.orThrow(); // OK in setup
131
-
132
- // Or use onSuccess for conditional setup
133
- resourceManager = ResourceManager.create(params).onSuccess((manager) => {
134
- manager.addResource(testResource).orThrow(); // OK in setup
135
- return manager;
136
- }).orThrow();
137
- });
138
-
139
- // ✅ Good - Test cases use Result matchers
140
- test('should create manager', () => {
141
- expect(ResourceManager.create(params)).toSucceedAndSatisfy((manager) => {
142
- expect(manager.qualifiers.size).toBe(2);
143
- });
144
- });
145
- ```
146
-
147
- #### ts-res Error Testing
148
- ```typescript
149
- // ✅ Good - Test ts-res-specific error conditions
150
- expect(qualifierCollector.create(invalidParams)).toFailWith(/invalid qualifier/i);
151
- expect(resourceManager.getResource('missing')).toFailWith(/resource not found/i);
152
- expect(conditionSet.validate(context)).toFailWith(/condition not satisfied/i);
153
- ```
154
-
155
- #### TypeScript in ts-res Tests
156
- ```typescript
157
- // ✅ Good - Proper type assertions for ts-res branded types
158
- const corruptedData = {
159
- id: 'invalid' as unknown as TsRes.ResourceId,
160
- type: 999 as unknown as TsRes.ResourceTypeIndex
161
- };
162
-
163
- // ❌ Bad - Never use any type
164
- const corruptedData = {
165
- id: 'invalid' as any,
166
- type: 999 as any
167
- };
168
- ```
169
-
170
- ## Development Workflow
171
-
172
- ### Before Check-in Checklist
173
- When making changes that affect the public API:
174
- 1. Run `rushx test` to ensure all tests pass
175
- 2. Run `rushx lint` to ensure code quality
176
- 3. **Run `rushx build-docs` to regenerate API documentation**
177
- 4. Commit changes including updated documentation files
178
-
179
- ## Code Organization
180
-
181
- - Main entry point: `src/index.ts`
182
- - Packlet-based organization under `src/packlets/`
183
- - Each packlet has its own `index.ts` for exports
184
- - Common utilities in `src/packlets/common/`
185
- - Comprehensive type definitions throughout
186
- - Uses Rush monorepo tooling with workspace dependencies
@@ -1,88 +0,0 @@
1
- # SystemConfiguration InitParams Example
2
-
3
- This example demonstrates the new `ISystemConfigurationInitParams` functionality that allows setting qualifier default values during SystemConfiguration creation.
4
-
5
- ## Basic Usage
6
-
7
- ```typescript
8
- import * as TsRes from '@fgv/ts-res';
9
-
10
- // Create a SystemConfiguration with qualifier default values
11
- const initParams: TsRes.Config.ISystemConfigurationInitParams = {
12
- qualifierDefaultValues: {
13
- 'language': 'en-US',
14
- 'currentTerritory': 'US'
15
- }
16
- };
17
-
18
- const systemConfig = TsRes.Config.SystemConfiguration.create(
19
- baseConfig,
20
- initParams
21
- ).orThrow();
22
-
23
- // The qualifiers now have default values
24
- const languageQualifier = systemConfig.qualifiers.validating.get('language').orThrow();
25
- console.log(languageQualifier.defaultValue); // 'en-US'
26
-
27
- const territoryQualifier = systemConfig.qualifiers.validating.get('currentTerritory').orThrow();
28
- console.log(territoryQualifier.defaultValue); // 'US'
29
- ```
30
-
31
- ## Using with Predefined Configurations
32
-
33
- ```typescript
34
- // Apply qualifier default values to a predefined configuration
35
- const systemConfig = TsRes.Config.getPredefinedSystemConfiguration(
36
- 'default',
37
- {
38
- qualifierDefaultValues: {
39
- 'language': 'fr-FR',
40
- 'currentTerritory': 'FR'
41
- }
42
- }
43
- ).orThrow();
44
- ```
45
-
46
- ## Removing Default Values
47
-
48
- ```typescript
49
- // Use null to remove existing default values
50
- const initParams: TsRes.Config.ISystemConfigurationInitParams = {
51
- qualifierDefaultValues: {
52
- 'language': null // Removes the default value
53
- }
54
- };
55
- ```
56
-
57
- ## Validation
58
-
59
- The system validates default values according to the qualifier type rules:
60
-
61
- ```typescript
62
- // This will fail because 'invalid-language-tag' is not a valid BCP47 language tag
63
- const badParams: TsRes.Config.ISystemConfigurationInitParams = {
64
- qualifierDefaultValues: {
65
- 'language': 'invalid-language-tag'
66
- }
67
- };
68
-
69
- const result = TsRes.Config.SystemConfiguration.create(baseConfig, badParams);
70
- // result.isFailure() === true
71
- // result.message includes validation error
72
- ```
73
-
74
- ## Helper Function
75
-
76
- You can also use the helper function directly:
77
-
78
- ```typescript
79
- const updatedConfig = TsRes.Config.updateSystemConfigurationQualifierDefaultValues(
80
- originalConfig,
81
- {
82
- 'language': 'de-DE',
83
- 'currentTerritory': 'DE'
84
- }
85
- ).orThrow();
86
-
87
- const systemConfig = TsRes.Config.SystemConfiguration.create(updatedConfig).orThrow();
88
- ```