glossarist 0.4.50 → 0.4.52

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 (709) hide show
  1. package/dist/compiled-format.d.ts +43 -0
  2. package/dist/compiled-format.d.ts.map +1 -0
  3. package/{src/compiled-format.ts → dist/compiled-format.js} +28 -46
  4. package/dist/compiled-format.js.map +1 -0
  5. package/dist/concept-collection.d.ts +39 -0
  6. package/dist/concept-collection.d.ts.map +1 -0
  7. package/dist/concept-collection.js +127 -0
  8. package/dist/concept-collection.js.map +1 -0
  9. package/dist/concept-diff.d.ts +14 -0
  10. package/dist/concept-diff.d.ts.map +1 -0
  11. package/{src/concept-diff.ts → dist/concept-diff.js} +2 -20
  12. package/dist/concept-diff.js.map +1 -0
  13. package/dist/concept-parser.d.ts +11 -0
  14. package/dist/concept-parser.d.ts.map +1 -0
  15. package/dist/concept-parser.js +209 -0
  16. package/dist/concept-parser.js.map +1 -0
  17. package/dist/concept-reader.d.ts +55 -0
  18. package/dist/concept-reader.d.ts.map +1 -0
  19. package/{src/concept-reader.ts → dist/concept-reader.js} +70 -76
  20. package/dist/concept-reader.js.map +1 -0
  21. package/dist/concept-serializer.d.ts +9 -0
  22. package/dist/concept-serializer.d.ts.map +1 -0
  23. package/dist/concept-serializer.js +87 -0
  24. package/dist/concept-serializer.js.map +1 -0
  25. package/dist/concept-writer.d.ts +10 -0
  26. package/dist/concept-writer.d.ts.map +1 -0
  27. package/dist/concept-writer.js +28 -0
  28. package/dist/concept-writer.js.map +1 -0
  29. package/dist/dataset-asset.d.ts +49 -0
  30. package/dist/dataset-asset.d.ts.map +1 -0
  31. package/{src/dataset-asset.ts → dist/dataset-asset.js} +16 -33
  32. package/dist/dataset-asset.js.map +1 -0
  33. package/dist/diff/canonical-json.d.ts +7 -0
  34. package/dist/diff/canonical-json.d.ts.map +1 -0
  35. package/dist/diff/canonical-json.js +28 -0
  36. package/dist/diff/canonical-json.js.map +1 -0
  37. package/dist/diff/change.d.ts +67 -0
  38. package/dist/diff/change.d.ts.map +1 -0
  39. package/dist/diff/change.js +131 -0
  40. package/dist/diff/change.js.map +1 -0
  41. package/dist/diff/collection-diff.d.ts +50 -0
  42. package/dist/diff/collection-diff.d.ts.map +1 -0
  43. package/dist/diff/collection-diff.js +182 -0
  44. package/dist/diff/collection-diff.js.map +1 -0
  45. package/dist/diff/concept-diff.d.ts +188 -0
  46. package/dist/diff/concept-diff.d.ts.map +1 -0
  47. package/dist/diff/concept-diff.js +624 -0
  48. package/dist/diff/concept-diff.js.map +1 -0
  49. package/dist/diff/diff-patch.d.ts +7 -0
  50. package/dist/diff/diff-patch.d.ts.map +1 -0
  51. package/dist/diff/diff-patch.js +225 -0
  52. package/dist/diff/diff-patch.js.map +1 -0
  53. package/dist/diff/diff-renderer.d.ts +44 -0
  54. package/dist/diff/diff-renderer.d.ts.map +1 -0
  55. package/dist/diff/diff-renderer.js +263 -0
  56. package/dist/diff/diff-renderer.js.map +1 -0
  57. package/dist/diff/identity.d.ts +2 -0
  58. package/dist/diff/identity.d.ts.map +1 -0
  59. package/dist/diff/identity.js +29 -0
  60. package/dist/diff/identity.js.map +1 -0
  61. package/dist/diff/index.d.ts +8 -0
  62. package/dist/diff/index.d.ts.map +1 -0
  63. package/dist/diff/index.js +8 -0
  64. package/dist/diff/index.js.map +1 -0
  65. package/dist/diff/list-diff.d.ts +36 -0
  66. package/dist/diff/list-diff.d.ts.map +1 -0
  67. package/dist/diff/list-diff.js +185 -0
  68. package/dist/diff/list-diff.js.map +1 -0
  69. package/dist/diff/similarity.d.ts +4 -0
  70. package/dist/diff/similarity.d.ts.map +1 -0
  71. package/dist/diff/similarity.js +20 -0
  72. package/dist/diff/similarity.js.map +1 -0
  73. package/dist/diff/text-diff.d.ts +42 -0
  74. package/dist/diff/text-diff.d.ts.map +1 -0
  75. package/dist/diff/text-diff.js +134 -0
  76. package/dist/diff/text-diff.js.map +1 -0
  77. package/dist/entity-directory.d.ts +13 -0
  78. package/dist/entity-directory.d.ts.map +1 -0
  79. package/dist/entity-directory.js +35 -0
  80. package/dist/entity-directory.js.map +1 -0
  81. package/dist/errors.d.ts +15 -0
  82. package/dist/errors.d.ts.map +1 -0
  83. package/dist/errors.js +23 -0
  84. package/dist/errors.js.map +1 -0
  85. package/dist/gcr-reader.d.ts +57 -0
  86. package/dist/gcr-reader.d.ts.map +1 -0
  87. package/dist/gcr-reader.js +264 -0
  88. package/dist/gcr-reader.js.map +1 -0
  89. package/dist/gcr-writer.d.ts +23 -0
  90. package/dist/gcr-writer.d.ts.map +1 -0
  91. package/dist/gcr-writer.js +84 -0
  92. package/dist/gcr-writer.js.map +1 -0
  93. package/dist/index.d.ts +25 -0
  94. package/dist/index.d.ts.map +1 -0
  95. package/dist/index.js +38 -0
  96. package/dist/index.js.map +1 -0
  97. package/dist/managed-concept-collection.d.ts +31 -0
  98. package/dist/managed-concept-collection.d.ts.map +1 -0
  99. package/dist/managed-concept-collection.js +87 -0
  100. package/dist/managed-concept-collection.js.map +1 -0
  101. package/dist/migration/hyperedge-migrator.d.ts +33 -0
  102. package/dist/migration/hyperedge-migrator.d.ts.map +1 -0
  103. package/dist/migration/hyperedge-migrator.js +70 -0
  104. package/dist/migration/hyperedge-migrator.js.map +1 -0
  105. package/dist/models/abstract-hyperedge.d.ts +35 -0
  106. package/dist/models/abstract-hyperedge.d.ts.map +1 -0
  107. package/dist/models/abstract-hyperedge.js +112 -0
  108. package/dist/models/abstract-hyperedge.js.map +1 -0
  109. package/dist/models/base.d.ts +58 -0
  110. package/dist/models/base.d.ts.map +1 -0
  111. package/dist/models/base.js +77 -0
  112. package/dist/models/base.js.map +1 -0
  113. package/dist/models/bibliography-data.d.ts +20 -0
  114. package/dist/models/bibliography-data.d.ts.map +1 -0
  115. package/dist/models/bibliography-data.js +43 -0
  116. package/dist/models/bibliography-data.js.map +1 -0
  117. package/dist/models/bibliography-entry.d.ts +19 -0
  118. package/dist/models/bibliography-entry.d.ts.map +1 -0
  119. package/dist/models/bibliography-entry.js +34 -0
  120. package/dist/models/bibliography-entry.js.map +1 -0
  121. package/dist/models/citation.d.ts +40 -0
  122. package/dist/models/citation.d.ts.map +1 -0
  123. package/dist/models/citation.js +82 -0
  124. package/dist/models/citation.js.map +1 -0
  125. package/dist/models/completeness.d.ts +9 -0
  126. package/dist/models/completeness.d.ts.map +1 -0
  127. package/{src/models/completeness.ts → dist/models/completeness.js} +4 -9
  128. package/dist/models/completeness.js.map +1 -0
  129. package/dist/models/concept-date.d.ts +20 -0
  130. package/dist/models/concept-date.d.ts.map +1 -0
  131. package/dist/models/concept-date.js +36 -0
  132. package/dist/models/concept-date.js.map +1 -0
  133. package/dist/models/concept-ref.d.ts +32 -0
  134. package/dist/models/concept-ref.d.ts.map +1 -0
  135. package/dist/models/concept-ref.js +53 -0
  136. package/dist/models/concept-ref.js.map +1 -0
  137. package/dist/models/concept-reference.d.ts +22 -0
  138. package/dist/models/concept-reference.d.ts.map +1 -0
  139. package/dist/models/concept-reference.js +39 -0
  140. package/dist/models/concept-reference.js.map +1 -0
  141. package/dist/models/concept-source.d.ts +53 -0
  142. package/dist/models/concept-source.d.ts.map +1 -0
  143. package/dist/models/concept-source.js +66 -0
  144. package/dist/models/concept-source.js.map +1 -0
  145. package/dist/models/concept-system-type.d.ts +6 -0
  146. package/dist/models/concept-system-type.d.ts.map +1 -0
  147. package/dist/models/concept-system-type.js +22 -0
  148. package/dist/models/concept-system-type.js.map +1 -0
  149. package/dist/models/concept-system.d.ts +44 -0
  150. package/dist/models/concept-system.d.ts.map +1 -0
  151. package/dist/models/concept-system.js +115 -0
  152. package/dist/models/concept-system.js.map +1 -0
  153. package/dist/models/concept-type.d.ts +7 -0
  154. package/dist/models/concept-type.d.ts.map +1 -0
  155. package/{src/models/concept-type.ts → dist/models/concept-type.js} +8 -19
  156. package/dist/models/concept-type.js.map +1 -0
  157. package/dist/models/concept.d.ts +94 -0
  158. package/dist/models/concept.d.ts.map +1 -0
  159. package/dist/models/concept.js +368 -0
  160. package/dist/models/concept.js.map +1 -0
  161. package/dist/models/dataset-color.d.ts +28 -0
  162. package/dist/models/dataset-color.d.ts.map +1 -0
  163. package/dist/models/dataset-color.js +74 -0
  164. package/dist/models/dataset-color.js.map +1 -0
  165. package/dist/models/definition-type.d.ts +9 -0
  166. package/dist/models/definition-type.d.ts.map +1 -0
  167. package/{src/models/definition-type.ts → dist/models/definition-type.js} +6 -15
  168. package/dist/models/definition-type.js.map +1 -0
  169. package/dist/models/designation-relationship.d.ts +17 -0
  170. package/dist/models/designation-relationship.d.ts.map +1 -0
  171. package/dist/models/designation-relationship.js +30 -0
  172. package/dist/models/designation-relationship.js.map +1 -0
  173. package/dist/models/designation.d.ts +110 -0
  174. package/dist/models/designation.d.ts.map +1 -0
  175. package/dist/models/designation.js +224 -0
  176. package/dist/models/designation.js.map +1 -0
  177. package/dist/models/detailed-definition.d.ts +34 -0
  178. package/dist/models/detailed-definition.d.ts.map +1 -0
  179. package/dist/models/detailed-definition.js +63 -0
  180. package/dist/models/detailed-definition.js.map +1 -0
  181. package/dist/models/enum.d.ts +21 -0
  182. package/dist/models/enum.d.ts.map +1 -0
  183. package/dist/models/enum.js +39 -0
  184. package/dist/models/enum.js.map +1 -0
  185. package/dist/models/equivalence-degree.d.ts +7 -0
  186. package/dist/models/equivalence-degree.d.ts.map +1 -0
  187. package/dist/models/equivalence-degree.js +20 -0
  188. package/dist/models/equivalence-degree.js.map +1 -0
  189. package/dist/models/figure.d.ts +40 -0
  190. package/dist/models/figure.d.ts.map +1 -0
  191. package/dist/models/figure.js +82 -0
  192. package/dist/models/figure.js.map +1 -0
  193. package/dist/models/formula.d.ts +15 -0
  194. package/dist/models/formula.d.ts.map +1 -0
  195. package/dist/models/formula.js +27 -0
  196. package/dist/models/formula.js.map +1 -0
  197. package/dist/models/gcr-metadata.d.ts +62 -0
  198. package/dist/models/gcr-metadata.d.ts.map +1 -0
  199. package/dist/models/gcr-metadata.js +102 -0
  200. package/dist/models/gcr-metadata.js.map +1 -0
  201. package/dist/models/gcr-statistics.d.ts +30 -0
  202. package/dist/models/gcr-statistics.d.ts.map +1 -0
  203. package/dist/models/gcr-statistics.js +53 -0
  204. package/dist/models/gcr-statistics.js.map +1 -0
  205. package/dist/models/generic-hyperedge.d.ts +32 -0
  206. package/dist/models/generic-hyperedge.d.ts.map +1 -0
  207. package/dist/models/generic-hyperedge.js +51 -0
  208. package/dist/models/generic-hyperedge.js.map +1 -0
  209. package/dist/models/generic-member.d.ts +14 -0
  210. package/dist/models/generic-member.d.ts.map +1 -0
  211. package/dist/models/generic-member.js +51 -0
  212. package/dist/models/generic-member.js.map +1 -0
  213. package/dist/models/grammar-info.d.ts +34 -0
  214. package/dist/models/grammar-info.d.ts.map +1 -0
  215. package/dist/models/grammar-info.js +59 -0
  216. package/dist/models/grammar-info.js.map +1 -0
  217. package/dist/models/hyperedge-colors.d.ts +19 -0
  218. package/dist/models/hyperedge-colors.d.ts.map +1 -0
  219. package/dist/models/hyperedge-colors.js +61 -0
  220. package/dist/models/hyperedge-colors.js.map +1 -0
  221. package/dist/models/hyperedge-index.d.ts +34 -0
  222. package/dist/models/hyperedge-index.d.ts.map +1 -0
  223. package/dist/models/hyperedge-index.js +85 -0
  224. package/dist/models/hyperedge-index.js.map +1 -0
  225. package/dist/models/hyperedge-member.d.ts +28 -0
  226. package/dist/models/hyperedge-member.d.ts.map +1 -0
  227. package/dist/models/hyperedge-member.js +92 -0
  228. package/dist/models/hyperedge-member.js.map +1 -0
  229. package/dist/models/hyperedge-registry.d.ts +47 -0
  230. package/dist/models/hyperedge-registry.d.ts.map +1 -0
  231. package/dist/models/hyperedge-registry.js +118 -0
  232. package/dist/models/hyperedge-registry.js.map +1 -0
  233. package/dist/models/index.d.ts +53 -0
  234. package/dist/models/index.d.ts.map +1 -0
  235. package/{src/models/index.ts → dist/models/index.js} +11 -63
  236. package/dist/models/index.js.map +1 -0
  237. package/dist/models/locality.d.ts +17 -0
  238. package/dist/models/locality.d.ts.map +1 -0
  239. package/dist/models/locality.js +26 -0
  240. package/dist/models/locality.js.map +1 -0
  241. package/dist/models/localized-concept.d.ts +102 -0
  242. package/dist/models/localized-concept.d.ts.map +1 -0
  243. package/dist/models/localized-concept.js +195 -0
  244. package/dist/models/localized-concept.js.map +1 -0
  245. package/dist/models/localized-string.d.ts +5 -0
  246. package/dist/models/localized-string.d.ts.map +1 -0
  247. package/dist/models/localized-string.js +20 -0
  248. package/dist/models/localized-string.js.map +1 -0
  249. package/dist/models/multiplicity.d.ts +42 -0
  250. package/dist/models/multiplicity.d.ts.map +1 -0
  251. package/dist/models/multiplicity.js +84 -0
  252. package/dist/models/multiplicity.js.map +1 -0
  253. package/dist/models/non-verb-rep.d.ts +20 -0
  254. package/dist/models/non-verb-rep.d.ts.map +1 -0
  255. package/dist/models/non-verb-rep.js +32 -0
  256. package/dist/models/non-verb-rep.js.map +1 -0
  257. package/dist/models/non-verbal-entity.d.ts +30 -0
  258. package/dist/models/non-verbal-entity.d.ts.map +1 -0
  259. package/dist/models/non-verbal-entity.js +48 -0
  260. package/dist/models/non-verbal-entity.js.map +1 -0
  261. package/dist/models/non-verbal-reference.d.ts +23 -0
  262. package/dist/models/non-verbal-reference.d.ts.map +1 -0
  263. package/dist/models/non-verbal-reference.js +44 -0
  264. package/dist/models/non-verbal-reference.js.map +1 -0
  265. package/dist/models/non-verbal-references.d.ts +12 -0
  266. package/dist/models/non-verbal-references.d.ts.map +1 -0
  267. package/dist/models/non-verbal-references.js +20 -0
  268. package/dist/models/non-verbal-references.js.map +1 -0
  269. package/dist/models/partitive-count.d.ts +10 -0
  270. package/dist/models/partitive-count.d.ts.map +1 -0
  271. package/{src/models/partitive-count.ts → dist/models/partitive-count.js} +5 -9
  272. package/dist/models/partitive-count.js.map +1 -0
  273. package/dist/models/partitive-enumeration.d.ts +5 -0
  274. package/dist/models/partitive-enumeration.d.ts.map +1 -0
  275. package/dist/models/partitive-enumeration.js +16 -0
  276. package/dist/models/partitive-enumeration.js.map +1 -0
  277. package/dist/models/partitive-hyperedge.d.ts +43 -0
  278. package/dist/models/partitive-hyperedge.d.ts.map +1 -0
  279. package/dist/models/partitive-hyperedge.js +63 -0
  280. package/dist/models/partitive-hyperedge.js.map +1 -0
  281. package/dist/models/partitive-member.d.ts +14 -0
  282. package/dist/models/partitive-member.d.ts.map +1 -0
  283. package/dist/models/partitive-member.js +44 -0
  284. package/dist/models/partitive-member.js.map +1 -0
  285. package/dist/models/partitive-presence.d.ts +9 -0
  286. package/dist/models/partitive-presence.d.ts.map +1 -0
  287. package/{src/models/partitive-presence.ts → dist/models/partitive-presence.js} +4 -8
  288. package/dist/models/partitive-presence.js.map +1 -0
  289. package/dist/models/plurality-marker.d.ts +5 -0
  290. package/dist/models/plurality-marker.d.ts.map +1 -0
  291. package/dist/models/plurality-marker.js +20 -0
  292. package/dist/models/plurality-marker.js.map +1 -0
  293. package/dist/models/pronunciation.d.ts +19 -0
  294. package/dist/models/pronunciation.d.ts.map +1 -0
  295. package/dist/models/pronunciation.js +34 -0
  296. package/dist/models/pronunciation.js.map +1 -0
  297. package/dist/models/register.d.ts +104 -0
  298. package/dist/models/register.d.ts.map +1 -0
  299. package/dist/models/register.js +297 -0
  300. package/dist/models/register.js.map +1 -0
  301. package/dist/models/registrable.d.ts +25 -0
  302. package/dist/models/registrable.d.ts.map +1 -0
  303. package/dist/models/registrable.js +23 -0
  304. package/dist/models/registrable.js.map +1 -0
  305. package/dist/models/related-concept.d.ts +33 -0
  306. package/dist/models/related-concept.d.ts.map +1 -0
  307. package/dist/models/related-concept.js +95 -0
  308. package/dist/models/related-concept.js.map +1 -0
  309. package/dist/models/relation-categories.d.ts +38 -0
  310. package/dist/models/relation-categories.d.ts.map +1 -0
  311. package/dist/models/relation-categories.js +135 -0
  312. package/dist/models/relation-categories.js.map +1 -0
  313. package/dist/models/relation-colors.d.ts +35 -0
  314. package/dist/models/relation-colors.d.ts.map +1 -0
  315. package/dist/models/relation-colors.js +68 -0
  316. package/dist/models/relation-colors.js.map +1 -0
  317. package/dist/models/relation-loader.d.ts +41 -0
  318. package/dist/models/relation-loader.d.ts.map +1 -0
  319. package/dist/models/relation-loader.js +101 -0
  320. package/dist/models/relation-loader.js.map +1 -0
  321. package/dist/models/section.d.ts +22 -0
  322. package/dist/models/section.d.ts.map +1 -0
  323. package/dist/models/section.js +47 -0
  324. package/dist/models/section.js.map +1 -0
  325. package/dist/models/sequential-hyperedge.d.ts +32 -0
  326. package/dist/models/sequential-hyperedge.d.ts.map +1 -0
  327. package/dist/models/sequential-hyperedge.js +49 -0
  328. package/dist/models/sequential-hyperedge.js.map +1 -0
  329. package/dist/models/sequential-member.d.ts +8 -0
  330. package/dist/models/sequential-member.d.ts.map +1 -0
  331. package/{src/models/sequential-member.ts → dist/models/sequential-member.js} +4 -9
  332. package/dist/models/sequential-member.js.map +1 -0
  333. package/dist/models/shared-non-verbal-entity.d.ts +16 -0
  334. package/dist/models/shared-non-verbal-entity.d.ts.map +1 -0
  335. package/dist/models/shared-non-verbal-entity.js +28 -0
  336. package/dist/models/shared-non-verbal-entity.js.map +1 -0
  337. package/dist/models/table.d.ts +15 -0
  338. package/dist/models/table.d.ts.map +1 -0
  339. package/dist/models/table.js +27 -0
  340. package/dist/models/table.js.map +1 -0
  341. package/dist/rdf/agents-emitter.d.ts +37 -0
  342. package/dist/rdf/agents-emitter.d.ts.map +1 -0
  343. package/dist/rdf/agents-emitter.js +107 -0
  344. package/dist/rdf/agents-emitter.js.map +1 -0
  345. package/dist/rdf/bibliography-emitter.d.ts +16 -0
  346. package/dist/rdf/bibliography-emitter.d.ts.map +1 -0
  347. package/dist/rdf/bibliography-emitter.js +84 -0
  348. package/dist/rdf/bibliography-emitter.js.map +1 -0
  349. package/dist/rdf/bnode-id.d.ts +2 -0
  350. package/dist/rdf/bnode-id.d.ts.map +1 -0
  351. package/dist/rdf/bnode-id.js +57 -0
  352. package/dist/rdf/bnode-id.js.map +1 -0
  353. package/dist/rdf/build-activity-emitter.d.ts +42 -0
  354. package/dist/rdf/build-activity-emitter.d.ts.map +1 -0
  355. package/dist/rdf/build-activity-emitter.js +103 -0
  356. package/dist/rdf/build-activity-emitter.js.map +1 -0
  357. package/dist/rdf/curie.d.ts +7 -0
  358. package/dist/rdf/curie.d.ts.map +1 -0
  359. package/dist/rdf/curie.js +45 -0
  360. package/dist/rdf/curie.js.map +1 -0
  361. package/dist/rdf/dataset-emitter.d.ts +37 -0
  362. package/dist/rdf/dataset-emitter.d.ts.map +1 -0
  363. package/dist/rdf/dataset-emitter.js +126 -0
  364. package/dist/rdf/dataset-emitter.js.map +1 -0
  365. package/dist/rdf/deterministic-id.d.ts +3 -0
  366. package/dist/rdf/deterministic-id.d.ts.map +1 -0
  367. package/dist/rdf/deterministic-id.js +68 -0
  368. package/dist/rdf/deterministic-id.js.map +1 -0
  369. package/dist/rdf/document-writer.d.ts +11 -0
  370. package/dist/rdf/document-writer.d.ts.map +1 -0
  371. package/dist/rdf/document-writer.js +77 -0
  372. package/dist/rdf/document-writer.js.map +1 -0
  373. package/dist/rdf/gloss-concept.d.ts +27 -0
  374. package/dist/rdf/gloss-concept.d.ts.map +1 -0
  375. package/dist/rdf/gloss-concept.js +95 -0
  376. package/dist/rdf/gloss-concept.js.map +1 -0
  377. package/dist/rdf/gloss-designation.d.ts +17 -0
  378. package/dist/rdf/gloss-designation.d.ts.map +1 -0
  379. package/dist/rdf/gloss-designation.js +46 -0
  380. package/dist/rdf/gloss-designation.js.map +1 -0
  381. package/dist/rdf/gloss-detailed-definition.d.ts +14 -0
  382. package/dist/rdf/gloss-detailed-definition.d.ts.map +1 -0
  383. package/dist/rdf/gloss-detailed-definition.js +53 -0
  384. package/dist/rdf/gloss-detailed-definition.js.map +1 -0
  385. package/dist/rdf/gloss-generic-hyperedge.d.ts +27 -0
  386. package/dist/rdf/gloss-generic-hyperedge.d.ts.map +1 -0
  387. package/{src/rdf/gloss-generic-hyperedge.ts → dist/rdf/gloss-generic-hyperedge.js} +36 -50
  388. package/dist/rdf/gloss-generic-hyperedge.js.map +1 -0
  389. package/dist/rdf/gloss-localized-concept.d.ts +24 -0
  390. package/dist/rdf/gloss-localized-concept.d.ts.map +1 -0
  391. package/dist/rdf/gloss-localized-concept.js +71 -0
  392. package/dist/rdf/gloss-localized-concept.js.map +1 -0
  393. package/dist/rdf/gloss-non-verbal-rep.d.ts +33 -0
  394. package/dist/rdf/gloss-non-verbal-rep.d.ts.map +1 -0
  395. package/dist/rdf/gloss-non-verbal-rep.js +163 -0
  396. package/dist/rdf/gloss-non-verbal-rep.js.map +1 -0
  397. package/dist/rdf/gloss-partitive-member.d.ts +8 -0
  398. package/dist/rdf/gloss-partitive-member.d.ts.map +1 -0
  399. package/{src/rdf/gloss-partitive-member.ts → dist/rdf/gloss-partitive-member.js} +23 -41
  400. package/dist/rdf/gloss-partitive-member.js.map +1 -0
  401. package/dist/rdf/gloss-partitive-relation.d.ts +26 -0
  402. package/dist/rdf/gloss-partitive-relation.d.ts.map +1 -0
  403. package/dist/rdf/gloss-partitive-relation.js +73 -0
  404. package/dist/rdf/gloss-partitive-relation.js.map +1 -0
  405. package/dist/rdf/gloss-source.d.ts +23 -0
  406. package/dist/rdf/gloss-source.d.ts.map +1 -0
  407. package/dist/rdf/gloss-source.js +52 -0
  408. package/dist/rdf/gloss-source.js.map +1 -0
  409. package/dist/rdf/group-emitter.d.ts +46 -0
  410. package/dist/rdf/group-emitter.d.ts.map +1 -0
  411. package/dist/rdf/group-emitter.js +107 -0
  412. package/dist/rdf/group-emitter.js.map +1 -0
  413. package/dist/rdf/image-variant-emitter.d.ts +12 -0
  414. package/dist/rdf/image-variant-emitter.d.ts.map +1 -0
  415. package/dist/rdf/image-variant-emitter.js +55 -0
  416. package/dist/rdf/image-variant-emitter.js.map +1 -0
  417. package/dist/rdf/index.d.ts +26 -0
  418. package/dist/rdf/index.d.ts.map +1 -0
  419. package/{src/rdf/index.ts → dist/rdf/index.js} +8 -37
  420. package/dist/rdf/index.js.map +1 -0
  421. package/dist/rdf/normalize-enum.d.ts +3 -0
  422. package/dist/rdf/normalize-enum.d.ts.map +1 -0
  423. package/{src/rdf/normalize-enum.ts → dist/rdf/normalize-enum.js} +11 -10
  424. package/dist/rdf/normalize-enum.js.map +1 -0
  425. package/dist/rdf/predicates.d.ts +277 -0
  426. package/dist/rdf/predicates.d.ts.map +1 -0
  427. package/dist/rdf/predicates.js +279 -0
  428. package/dist/rdf/predicates.js.map +1 -0
  429. package/dist/rdf/prefixes.d.ts +16 -0
  430. package/dist/rdf/prefixes.d.ts.map +1 -0
  431. package/{src/rdf/prefixes.ts → dist/rdf/prefixes.js} +10 -12
  432. package/dist/rdf/prefixes.js.map +1 -0
  433. package/dist/rdf/provenance-emitter.d.ts +28 -0
  434. package/dist/rdf/provenance-emitter.d.ts.map +1 -0
  435. package/dist/rdf/provenance-emitter.js +74 -0
  436. package/dist/rdf/provenance-emitter.js.map +1 -0
  437. package/dist/rdf/sections-builder.d.ts +17 -0
  438. package/dist/rdf/sections-builder.d.ts.map +1 -0
  439. package/dist/rdf/sections-builder.js +137 -0
  440. package/dist/rdf/sections-builder.js.map +1 -0
  441. package/dist/rdf/shacl-entry.d.ts +2 -0
  442. package/dist/rdf/shacl-entry.d.ts.map +1 -0
  443. package/{src/rdf/shacl-entry.ts → dist/rdf/shacl-entry.js} +1 -1
  444. package/dist/rdf/shacl-entry.js.map +1 -0
  445. package/dist/rdf/shacl.d.ts +10 -0
  446. package/dist/rdf/shacl.d.ts.map +1 -0
  447. package/{src/rdf/shacl.ts → dist/rdf/shacl.js} +38 -57
  448. package/dist/rdf/shacl.js.map +1 -0
  449. package/dist/rdf/terms.d.ts +10 -0
  450. package/dist/rdf/terms.d.ts.map +1 -0
  451. package/{src/rdf/terms.ts → dist/rdf/terms.js} +6 -3
  452. package/dist/rdf/terms.js.map +1 -0
  453. package/dist/rdf/version-emitter.d.ts +57 -0
  454. package/dist/rdf/version-emitter.d.ts.map +1 -0
  455. package/dist/rdf/version-emitter.js +68 -0
  456. package/dist/rdf/version-emitter.js.map +1 -0
  457. package/dist/rdf/vocabulary-emitter.d.ts +32 -0
  458. package/dist/rdf/vocabulary-emitter.d.ts.map +1 -0
  459. package/dist/rdf/vocabulary-emitter.js +46 -0
  460. package/dist/rdf/vocabulary-emitter.js.map +1 -0
  461. package/dist/rdf/write-turtle-sync.d.ts +7 -0
  462. package/dist/rdf/write-turtle-sync.d.ts.map +1 -0
  463. package/dist/rdf/write-turtle-sync.js +130 -0
  464. package/dist/rdf/write-turtle-sync.js.map +1 -0
  465. package/dist/reference-mention.d.ts +49 -0
  466. package/dist/reference-mention.d.ts.map +1 -0
  467. package/dist/reference-mention.js +98 -0
  468. package/dist/reference-mention.js.map +1 -0
  469. package/dist/reference-resolver.d.ts +52 -0
  470. package/dist/reference-resolver.d.ts.map +1 -0
  471. package/dist/reference-resolver.js +311 -0
  472. package/dist/reference-resolver.js.map +1 -0
  473. package/dist/render-classification.d.ts +19 -0
  474. package/dist/render-classification.d.ts.map +1 -0
  475. package/dist/render-classification.js +82 -0
  476. package/dist/render-classification.js.map +1 -0
  477. package/dist/sort.d.ts +5 -0
  478. package/dist/sort.d.ts.map +1 -0
  479. package/dist/sort.js +25 -0
  480. package/dist/sort.js.map +1 -0
  481. package/dist/transforms/concept-to-gloss.transform.d.ts +32 -0
  482. package/dist/transforms/concept-to-gloss.transform.d.ts.map +1 -0
  483. package/dist/transforms/concept-to-gloss.transform.js +60 -0
  484. package/dist/transforms/concept-to-gloss.transform.js.map +1 -0
  485. package/dist/transforms/index.d.ts +2 -0
  486. package/dist/transforms/index.d.ts.map +1 -0
  487. package/{src/transforms/index.ts → dist/transforms/index.js} +1 -0
  488. package/dist/transforms/index.js.map +1 -0
  489. package/dist/utils/assertions.d.ts +4 -0
  490. package/dist/utils/assertions.d.ts.map +1 -0
  491. package/dist/utils/assertions.js +17 -0
  492. package/dist/utils/assertions.js.map +1 -0
  493. package/dist/utils/external-detection.d.ts +38 -0
  494. package/dist/utils/external-detection.d.ts.map +1 -0
  495. package/dist/utils/external-detection.js +55 -0
  496. package/dist/utils/external-detection.js.map +1 -0
  497. package/dist/uuid.d.ts +4 -0
  498. package/dist/uuid.d.ts.map +1 -0
  499. package/dist/uuid.js +23 -0
  500. package/dist/uuid.js.map +1 -0
  501. package/dist/v1-reader.d.ts +8 -0
  502. package/dist/v1-reader.d.ts.map +1 -0
  503. package/dist/v1-reader.js +56 -0
  504. package/dist/v1-reader.js.map +1 -0
  505. package/dist/validators/asset-index.d.ts +23 -0
  506. package/dist/validators/asset-index.d.ts.map +1 -0
  507. package/dist/validators/asset-index.js +58 -0
  508. package/dist/validators/asset-index.js.map +1 -0
  509. package/dist/validators/binary-has-part-redundancy-rule.d.ts +8 -0
  510. package/dist/validators/binary-has-part-redundancy-rule.d.ts.map +1 -0
  511. package/dist/validators/binary-has-part-redundancy-rule.js +57 -0
  512. package/dist/validators/binary-has-part-redundancy-rule.js.map +1 -0
  513. package/dist/validators/concept-validator.d.ts +21 -0
  514. package/dist/validators/concept-validator.d.ts.map +1 -0
  515. package/dist/validators/concept-validator.js +76 -0
  516. package/dist/validators/concept-validator.js.map +1 -0
  517. package/dist/validators/delimiting-coherence-rule.d.ts +8 -0
  518. package/dist/validators/delimiting-coherence-rule.d.ts.map +1 -0
  519. package/dist/validators/delimiting-coherence-rule.js +72 -0
  520. package/dist/validators/delimiting-coherence-rule.js.map +1 -0
  521. package/dist/validators/extensional-completeness.d.ts +18 -0
  522. package/dist/validators/extensional-completeness.d.ts.map +1 -0
  523. package/dist/validators/extensional-completeness.js +41 -0
  524. package/dist/validators/extensional-completeness.js.map +1 -0
  525. package/dist/validators/external-concept-shape-rule.d.ts +8 -0
  526. package/dist/validators/external-concept-shape-rule.d.ts.map +1 -0
  527. package/dist/validators/external-concept-shape-rule.js +48 -0
  528. package/dist/validators/external-concept-shape-rule.js.map +1 -0
  529. package/dist/validators/gcr-validator.d.ts +11 -0
  530. package/dist/validators/gcr-validator.d.ts.map +1 -0
  531. package/dist/validators/gcr-validator.js +76 -0
  532. package/dist/validators/gcr-validator.js.map +1 -0
  533. package/dist/validators/hyperedge-coherence-rule.d.ts +9 -0
  534. package/dist/validators/hyperedge-coherence-rule.d.ts.map +1 -0
  535. package/dist/validators/hyperedge-coherence-rule.js +78 -0
  536. package/dist/validators/hyperedge-coherence-rule.js.map +1 -0
  537. package/dist/validators/index.d.ts +21 -0
  538. package/dist/validators/index.d.ts.map +1 -0
  539. package/{src/validators/index.ts → dist/validators/index.js} +25 -51
  540. package/dist/validators/index.js.map +1 -0
  541. package/dist/validators/partitive-relation-coherence-rule.d.ts +2 -0
  542. package/dist/validators/partitive-relation-coherence-rule.d.ts.map +1 -0
  543. package/{src/validators/partitive-relation-coherence-rule.ts → dist/validators/partitive-relation-coherence-rule.js} +1 -1
  544. package/dist/validators/partitive-relation-coherence-rule.js.map +1 -0
  545. package/dist/validators/ref-keys.d.ts +8 -0
  546. package/dist/validators/ref-keys.d.ts.map +1 -0
  547. package/dist/validators/ref-keys.js +27 -0
  548. package/dist/validators/ref-keys.js.map +1 -0
  549. package/dist/validators/register-validator.d.ts +10 -0
  550. package/dist/validators/register-validator.d.ts.map +1 -0
  551. package/dist/validators/register-validator.js +18 -0
  552. package/dist/validators/register-validator.js.map +1 -0
  553. package/dist/validators/relationship-type-rule.d.ts +13 -0
  554. package/dist/validators/relationship-type-rule.d.ts.map +1 -0
  555. package/dist/validators/relationship-type-rule.js +34 -0
  556. package/dist/validators/relationship-type-rule.js.map +1 -0
  557. package/dist/validators/sourced-from-locality-rule.d.ts +8 -0
  558. package/dist/validators/sourced-from-locality-rule.d.ts.map +1 -0
  559. package/dist/validators/sourced-from-locality-rule.js +37 -0
  560. package/dist/validators/sourced-from-locality-rule.js.map +1 -0
  561. package/dist/validators/v3-rules.d.ts +60 -0
  562. package/dist/validators/v3-rules.d.ts.map +1 -0
  563. package/dist/validators/v3-rules.js +327 -0
  564. package/dist/validators/v3-rules.js.map +1 -0
  565. package/dist/validators/validation-error.d.ts +13 -0
  566. package/dist/validators/validation-error.d.ts.map +1 -0
  567. package/dist/validators/validation-error.js +17 -0
  568. package/dist/validators/validation-error.js.map +1 -0
  569. package/dist/validators/validation-result.d.ts +17 -0
  570. package/dist/validators/validation-result.d.ts.map +1 -0
  571. package/dist/validators/validation-result.js +47 -0
  572. package/dist/validators/validation-result.js.map +1 -0
  573. package/dist/validators/validation-rule.d.ts +10 -0
  574. package/dist/validators/validation-rule.d.ts.map +1 -0
  575. package/dist/validators/validation-rule.js +17 -0
  576. package/dist/validators/validation-rule.js.map +1 -0
  577. package/package.json +37 -42
  578. package/src/concept-collection.ts +0 -172
  579. package/src/concept-parser.ts +0 -235
  580. package/src/concept-reader.d.ts +0 -13
  581. package/src/concept-serializer.ts +0 -110
  582. package/src/concept-writer.d.ts +0 -7
  583. package/src/concept-writer.ts +0 -47
  584. package/src/diff/canonical-json.ts +0 -29
  585. package/src/diff/change.ts +0 -175
  586. package/src/diff/collection-diff.ts +0 -245
  587. package/src/diff/concept-diff.ts +0 -853
  588. package/src/diff/diff-patch.ts +0 -276
  589. package/src/diff/diff-renderer.ts +0 -348
  590. package/src/diff/identity.ts +0 -33
  591. package/src/diff/index.d.ts +0 -242
  592. package/src/diff/index.ts +0 -50
  593. package/src/diff/list-diff.ts +0 -231
  594. package/src/diff/similarity.ts +0 -20
  595. package/src/diff/text-diff.ts +0 -167
  596. package/src/entity-directory.ts +0 -43
  597. package/src/errors.d.ts +0 -11
  598. package/src/errors.ts +0 -24
  599. package/src/gcr-reader.d.ts +0 -65
  600. package/src/gcr-reader.ts +0 -512
  601. package/src/gcr-writer.d.ts +0 -22
  602. package/src/gcr-writer.ts +0 -99
  603. package/src/index.d.ts +0 -124
  604. package/src/index.ts +0 -92
  605. package/src/managed-concept-collection.ts +0 -130
  606. package/src/migration/hyperedge-migrator.ts +0 -104
  607. package/src/models/abstract-hyperedge.ts +0 -164
  608. package/src/models/base.ts +0 -110
  609. package/src/models/bibliography-data.ts +0 -64
  610. package/src/models/bibliography-entry.ts +0 -40
  611. package/src/models/citation.ts +0 -98
  612. package/src/models/concept-date.ts +0 -48
  613. package/src/models/concept-ref.ts +0 -64
  614. package/src/models/concept-reference.ts +0 -50
  615. package/src/models/concept-source.ts +0 -96
  616. package/src/models/concept-system-type.ts +0 -39
  617. package/src/models/concept-system.ts +0 -152
  618. package/src/models/concept.ts +0 -499
  619. package/src/models/dataset-color.ts +0 -88
  620. package/src/models/designation-relationship.ts +0 -39
  621. package/src/models/designation.ts +0 -297
  622. package/src/models/detailed-definition.ts +0 -92
  623. package/src/models/enum.ts +0 -60
  624. package/src/models/equivalence-degree.ts +0 -34
  625. package/src/models/figure.ts +0 -110
  626. package/src/models/formula.ts +0 -36
  627. package/src/models/gcr-metadata.ts +0 -118
  628. package/src/models/gcr-statistics.ts +0 -76
  629. package/src/models/generic-hyperedge.ts +0 -72
  630. package/src/models/generic-member.ts +0 -80
  631. package/src/models/grammar-info.ts +0 -78
  632. package/src/models/hyperedge-colors.ts +0 -87
  633. package/src/models/hyperedge-index.ts +0 -101
  634. package/src/models/hyperedge-member.ts +0 -121
  635. package/src/models/hyperedge-registry.ts +0 -145
  636. package/src/models/index.d.ts +0 -586
  637. package/src/models/locality.ts +0 -34
  638. package/src/models/localized-concept.ts +0 -284
  639. package/src/models/localized-string.ts +0 -32
  640. package/src/models/multiplicity.ts +0 -134
  641. package/src/models/non-verb-rep.ts +0 -48
  642. package/src/models/non-verbal-entity.ts +0 -65
  643. package/src/models/non-verbal-reference.ts +0 -73
  644. package/src/models/non-verbal-references.ts +0 -29
  645. package/src/models/partitive-enumeration.ts +0 -27
  646. package/src/models/partitive-hyperedge.ts +0 -90
  647. package/src/models/partitive-member.ts +0 -56
  648. package/src/models/plurality-marker.ts +0 -31
  649. package/src/models/pronunciation.ts +0 -40
  650. package/src/models/register.ts +0 -315
  651. package/src/models/registrable.ts +0 -48
  652. package/src/models/related-concept.ts +0 -117
  653. package/src/models/relation-categories.ts +0 -167
  654. package/src/models/relation-colors.ts +0 -90
  655. package/src/models/relation-loader.ts +0 -115
  656. package/src/models/section.ts +0 -61
  657. package/src/models/sequential-hyperedge.ts +0 -70
  658. package/src/models/shared-non-verbal-entity.ts +0 -36
  659. package/src/models/table.ts +0 -36
  660. package/src/rdf/agents-emitter.ts +0 -137
  661. package/src/rdf/bibliography-emitter.ts +0 -126
  662. package/src/rdf/bnode-id.ts +0 -55
  663. package/src/rdf/build-activity-emitter.ts +0 -129
  664. package/src/rdf/curie.ts +0 -46
  665. package/src/rdf/dataset-emitter.ts +0 -170
  666. package/src/rdf/deterministic-id.ts +0 -69
  667. package/src/rdf/document-writer.ts +0 -87
  668. package/src/rdf/gloss-concept.ts +0 -115
  669. package/src/rdf/gloss-designation.ts +0 -72
  670. package/src/rdf/gloss-detailed-definition.ts +0 -69
  671. package/src/rdf/gloss-localized-concept.ts +0 -79
  672. package/src/rdf/gloss-non-verbal-rep.ts +0 -202
  673. package/src/rdf/gloss-partitive-relation.ts +0 -89
  674. package/src/rdf/gloss-source.ts +0 -56
  675. package/src/rdf/group-emitter.ts +0 -133
  676. package/src/rdf/image-variant-emitter.ts +0 -80
  677. package/src/rdf/index.d.ts +0 -371
  678. package/src/rdf/predicates.d.ts +0 -527
  679. package/src/rdf/predicates.ts +0 -287
  680. package/src/rdf/provenance-emitter.ts +0 -87
  681. package/src/rdf/sections-builder.ts +0 -190
  682. package/src/rdf/shacl-entry.d.ts +0 -6
  683. package/src/rdf/version-emitter.ts +0 -97
  684. package/src/rdf/vocabulary-emitter.ts +0 -67
  685. package/src/rdf/write-turtle-sync.ts +0 -179
  686. package/src/reference-mention.ts +0 -114
  687. package/src/reference-resolver.ts +0 -361
  688. package/src/render-classification.ts +0 -85
  689. package/src/sort.ts +0 -22
  690. package/src/transforms/concept-to-gloss.transform.ts +0 -81
  691. package/src/transforms/index.d.ts +0 -26
  692. package/src/uuid.ts +0 -32
  693. package/src/v1-reader.ts +0 -66
  694. package/src/validators/asset-index.ts +0 -72
  695. package/src/validators/binary-has-part-redundancy-rule.ts +0 -67
  696. package/src/validators/concept-validator.ts +0 -93
  697. package/src/validators/delimiting-coherence-rule.ts +0 -105
  698. package/src/validators/external-concept-shape-rule.ts +0 -60
  699. package/src/validators/gcr-validator.ts +0 -76
  700. package/src/validators/hyperedge-coherence-rule.ts +0 -98
  701. package/src/validators/index.d.ts +0 -43
  702. package/src/validators/ref-keys.ts +0 -31
  703. package/src/validators/register-validator.ts +0 -18
  704. package/src/validators/relationship-type-rule.ts +0 -39
  705. package/src/validators/sourced-from-locality-rule.ts +0 -53
  706. package/src/validators/v3-rules.ts +0 -382
  707. package/src/validators/validation-error.ts +0 -19
  708. package/src/validators/validation-result.ts +0 -52
  709. package/src/validators/validation-rule.ts +0 -21
@@ -1,276 +0,0 @@
1
- import { Concept } from '../models/concept.js';
2
- import { ConceptSource } from '../models/concept-source.js';
3
- import { ConceptDate } from '../models/concept-date.js';
4
- import { RelatedConcept } from '../models/related-concept.js';
5
- import { Designation } from '../models/designation.js';
6
- import { DetailedDefinition } from '../models/detailed-definition.js';
7
- import { HyperedgeRegistry } from '../models/hyperedge-registry.js';
8
- import { Added, Removed, Changed } from './change.js';
9
- import { ListDiff } from './list-diff.js';
10
- import { TextDiff, TextHunk } from './text-diff.js';
11
- import { identityOf } from './identity.js';
12
- import {
13
- ConceptDiff,
14
- ConceptLevelDiff,
15
- LocalizedConceptDiff,
16
- MetadataDiff,
17
- } from './concept-diff.js';
18
-
19
- // Wire-name (camelCase JS field → snake_case JSON key) for metadata
20
- // fields patched onto Concept and LocalizedConcept.
21
- //
22
- // These mirror `Concept.wireNameFor` / `LocalizedConcept.wireNameFor`.
23
- // The duplication is intentional: diff-patch.js cannot import those
24
- // models lazily without making applyDiff async (a breaking API change),
25
- // and the field set is small and stable. A spec
26
- // (test/diff/field-sync.test.js) asserts the two stay in sync.
27
-
28
- const CONCEPT_METADATA_JSON_KEYS = Object.freeze({
29
- status: 'status',
30
- term: 'term',
31
- uri: 'uri',
32
- schemaVersion: 'schema_version',
33
- });
34
-
35
- const LOC_METADATA_JSON_KEYS = Object.freeze({
36
- entryStatus: 'entry_status',
37
- classification: 'classification',
38
- reviewType: 'review_type',
39
- domain: 'domain',
40
- release: 'release',
41
- lineageSourceSimilarity: 'lineage_source_similarity',
42
- script: 'script',
43
- system: 'system',
44
- reviewDate: 'review_date',
45
- reviewDecisionDate: 'review_decision_date',
46
- reviewDecisionEvent: 'review_decision_event',
47
- reviewStatus: 'review_status',
48
- reviewDecision: 'review_decision',
49
- reviewDecisionNotes: 'review_decision_notes',
50
- });
51
-
52
- export function applyDiff(oldConcept, diff) {
53
- const json = oldConcept.toJSON();
54
-
55
- applyConceptLevelPatch(json, diff.concept);
56
- applyLanguagePatch(json, diff);
57
-
58
- for (const [lang, lcDiff] of Object.entries(diff.localizations)) {
59
- applyLocalizedPatch(json, lang, lcDiff);
60
- }
61
-
62
- return Concept.fromJSON(json);
63
- }
64
-
65
- export function reverseDiff(diff) {
66
- const concept = new ConceptLevelDiff({
67
- sources: reverseListDiff(diff.concept.sources),
68
- dates: reverseListDiff(diff.concept.dates),
69
- relatedConcepts: reverseListDiff(diff.concept.relatedConcepts),
70
- relations: reverseListDiff(diff.concept.relations),
71
- groups: reverseListDiff(diff.concept.groups),
72
- sections: reverseListDiff(diff.concept.sections),
73
- tags: reverseListDiff(diff.concept.tags),
74
- metadata: reverseMetadataDiff(diff.concept.metadata),
75
- });
76
-
77
- const languages = reverseListDiff(diff.languages);
78
-
79
- const localizations = {};
80
- for (const [lang, lcDiff] of Object.entries(diff.localizations)) {
81
- localizations[lang] = new LocalizedConceptDiff({
82
- // @ts-expect-error TODO(Phase 2e): type this fully
83
- languageCode: lcDiff.languageCode,
84
- // @ts-expect-error TODO(Phase 2e): type this fully
85
- designations: reverseListDiff(lcDiff.designations),
86
- // @ts-expect-error TODO(Phase 2e): type this fully
87
- definitions: reverseListDiff(lcDiff.definitions),
88
- // @ts-expect-error TODO(Phase 2e): type this fully
89
- notes: reverseListDiff(lcDiff.notes),
90
- // @ts-expect-error TODO(Phase 2e): type this fully
91
- examples: reverseListDiff(lcDiff.examples),
92
- // @ts-expect-error TODO(Phase 2e): type this fully
93
- sources: reverseListDiff(lcDiff.sources),
94
- // @ts-expect-error TODO(Phase 2e): type this fully
95
- dates: reverseListDiff(lcDiff.dates),
96
- // @ts-expect-error TODO(Phase 2e): type this fully
97
- related: reverseListDiff(lcDiff.related),
98
- // @ts-expect-error TODO(Phase 2e): type this fully
99
- metadata: reverseMetadataDiff(lcDiff.metadata),
100
- // @ts-expect-error TODO(Phase 2e): type this fully
101
- totalItems: lcDiff._totalItems,
102
- });
103
- }
104
-
105
- return new ConceptDiff({
106
- oldId: diff.newId,
107
- newId: diff.oldId,
108
- concept,
109
- languages,
110
- localizations,
111
- totalItems: diff._totalItems,
112
- });
113
- }
114
-
115
- function applyConceptLevelPatch(json, conceptDiff) {
116
- json.sources = applyListPatch(json.sources ?? [], conceptDiff.sources, ConceptSource.identityOf);
117
- json.dates = applyListPatch(json.dates ?? [], conceptDiff.dates, ConceptDate.identityOf);
118
- json.related = applyListPatch(json.related ?? [], conceptDiff.relatedConcepts, RelatedConcept.identityOf);
119
-
120
- // Unified hyperedge diff → typed wire keys. Iterate the registry;
121
- // for each registered class, partition the unified diff by that
122
- // class and apply to the class's wireKey. Adding a new hyperedge
123
- // type means this loop picks it up automatically — no edits here.
124
- for (const cls of HyperedgeRegistry.allClasses()) {
125
- const partition = partitionListDiff(conceptDiff.relations, cls);
126
- if (!partition.hasChanges) continue;
127
- const wireKey = cls.wireKey;
128
- // v1 wire keys (partitive_hyperedges) on the input are migrated
129
- // to v2 wire key here: read from either, write to v2 only.
130
- const v1ReadKeys = cls.v1WireKeys ?? [];
131
- const existing = v1ReadKeys
132
- .map(k => json[k])
133
- .find(arr => Array.isArray(arr)) ?? json[wireKey] ?? [];
134
- // @ts-expect-error TODO(Phase 2e): type this fully
135
- json[wireKey] = applyListPatch(existing, partition, cls.identityOf);
136
- for (const k of v1ReadKeys) {
137
- if (json[k] != null && json[wireKey] != null) delete json[k];
138
- }
139
- }
140
-
141
- // @ts-expect-error TODO(Phase 2e): type this fully
142
- json.tags = applyListPatch(json.tags ?? [], conceptDiff.tags);
143
-
144
- applyMetadataPatch(json, conceptDiff.metadata, CONCEPT_METADATA_JSON_KEYS);
145
- }
146
-
147
- function applyLanguagePatch(json, conceptDiff) {
148
- if (!json.localizations) json.localizations = {};
149
- for (const entry of conceptDiff.languages.added) {
150
- if (!(entry.value in json.localizations)) {
151
- json.localizations[entry.value] = {};
152
- }
153
- }
154
- for (const entry of conceptDiff.languages.removed) {
155
- delete json.localizations[entry.value];
156
- }
157
- }
158
-
159
- function applyLocalizedPatch(json, lang, lcDiff) {
160
- if (!json.localizations) json.localizations = {};
161
- if (!(lang in json.localizations)) {
162
- json.localizations[lang] = {};
163
- }
164
- const loc = json.localizations[lang];
165
-
166
- loc.terms = applyListPatch(loc.terms ?? [], lcDiff.designations, Designation.identityOf);
167
- loc.definition = applyListPatch(loc.definition ?? [], lcDiff.definitions, DetailedDefinition.identityOf);
168
- loc.notes = applyListPatch(loc.notes ?? [], lcDiff.notes, DetailedDefinition.identityOf);
169
- loc.examples = applyListPatch(loc.examples ?? [], lcDiff.examples, DetailedDefinition.identityOf);
170
- loc.sources = applyListPatch(loc.sources ?? [], lcDiff.sources, ConceptSource.identityOf);
171
- loc.dates = applyListPatch(loc.dates ?? [], lcDiff.dates, ConceptDate.identityOf);
172
- loc.related = applyListPatch(loc.related ?? [], lcDiff.related, RelatedConcept.identityOf);
173
-
174
- applyMetadataPatch(loc, lcDiff.metadata, LOC_METADATA_JSON_KEYS);
175
- }
176
-
177
- function applyListPatch(existingItems, listDiff, identityFn) {
178
- const fn = identityFn ?? identityOf;
179
- let result = [...existingItems];
180
-
181
- for (const entry of listDiff.added) {
182
- result.push(toJsonValue(entry.value));
183
- }
184
-
185
- for (const entry of listDiff.removed) {
186
- const targetKey = fn(entry.value);
187
- result = result.filter(item => fn(item) !== targetKey);
188
- }
189
-
190
- for (const entry of listDiff.changed) {
191
- const oldKey = fn(entry.oldValue);
192
- result = result.map(item =>
193
- fn(item) === oldKey ? toJsonValue(entry.newValue) : item,
194
- );
195
- }
196
-
197
- return result;
198
- }
199
-
200
- function applyMetadataPatch(target, metadataDiff, keyMap) {
201
- for (const [field, change] of Object.entries(metadataDiff.changes)) {
202
- const jsonKey = keyMap[field];
203
- if (!jsonKey) continue;
204
- // @ts-expect-error TODO(Phase 2e): type this fully
205
- if (change.newValue == null) {
206
- delete target[jsonKey];
207
- } else {
208
- // @ts-expect-error TODO(Phase 2e): type this fully
209
- target[jsonKey] = change.newValue;
210
- }
211
- }
212
- }
213
-
214
- function reverseListDiff(listDiff) {
215
- const added = listDiff.removed.map(r => new Added({ value: r.value, path: r.path }));
216
- const removed = listDiff.added.map(a => new Removed({ value: a.value, path: a.path }));
217
- const changed = listDiff.changed.map(c => new Changed({
218
- oldValue: c.newValue,
219
- newValue: c.oldValue,
220
- // @ts-expect-error TODO(Phase 2e): type this fully
221
- textDiff: c.textDiff ? reverseTextDiff(c.textDiff) : null,
222
- path: c.path,
223
- }));
224
- return new ListDiff({ added, removed, changed });
225
- }
226
-
227
- function reverseMetadataDiff(metadataDiff) {
228
- const changes = {};
229
- for (const [field, change] of Object.entries(metadataDiff.changes)) {
230
- changes[field] = new Changed({
231
- // @ts-expect-error TODO(Phase 2e): type this fully
232
- oldValue: change.newValue,
233
- // @ts-expect-error TODO(Phase 2e): type this fully
234
- newValue: change.oldValue,
235
- });
236
- }
237
- return new MetadataDiff({ changes });
238
- }
239
-
240
- function reverseTextDiff(textDiff) {
241
- const hunks = textDiff.hunks.map(h => {
242
- if (h.type === 'added') return new TextHunk({ type: 'removed', text: h.text });
243
- if (h.type === 'removed') return new TextHunk({ type: 'added', text: h.text });
244
- return new TextHunk({ type: 'equal', text: h.text });
245
- });
246
- return new TextDiff({
247
- oldText: textDiff.newText,
248
- newText: textDiff.oldText,
249
- hunks,
250
- });
251
- }
252
-
253
- function toJsonValue(value) {
254
- if (value == null) return null;
255
- if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
256
- return value;
257
- }
258
- if (typeof value.toJSON === 'function') return value.toJSON();
259
- return value;
260
- }
261
-
262
- // Project a unified relations ListDiff onto a single concrete class.
263
- // Entries whose value (old or new) is an instance of `Cls` survive;
264
- // everything else is filtered out. Cross-type changed entries (e.g.
265
- // old was PartitiveHyperedge, new is GenericHyperedge) are not yet
266
- // supported — those would need to surface as a remove + add pair.
267
- function partitionListDiff(listDiff, Cls) {
268
- if (!listDiff) return new ListDiff({ added: [], removed: [], changed: [] });
269
- return new ListDiff({
270
- added: listDiff.added.filter(e => e.value instanceof Cls),
271
- removed: listDiff.removed.filter(e => e.value instanceof Cls),
272
- changed: listDiff.changed.filter(e =>
273
- (e.oldValue == null || e.oldValue instanceof Cls) &&
274
- (e.newValue == null || e.newValue instanceof Cls)),
275
- });
276
- }
@@ -1,348 +0,0 @@
1
- import { TextDiff } from './text-diff.js';
2
- import { resolveMultiplicity } from '../models/multiplicity.js';
3
-
4
- const COLORS = {
5
- red: s => `\x1b[31m${s}\x1b[0m`,
6
- green: s => `\x1b[32m${s}\x1b[0m`,
7
- yellow: s => `\x1b[33m${s}\x1b[0m`,
8
- cyan: s => `\x1b[36m${s}\x1b[0m`,
9
- dim: s => `\x1b[2m${s}\x1b[0m`,
10
- bold: s => `\x1b[1m${s}\x1b[0m`,
11
- };
12
-
13
- export function renderConceptDiff(diff, options = {}) {
14
- // @ts-expect-error TODO(Phase 2e): type this fully
15
- const colors = options.colors ?? false;
16
- // @ts-expect-error TODO(Phase 2e): type this fully
17
- const showUnchanged = options.showUnchanged ?? false;
18
- const lines = [];
19
-
20
- const pct = Math.round(diff.similarity * 100);
21
- const idPart = diff.oldId && diff.newId && diff.oldId !== diff.newId
22
- ? `${diff.oldId} → ${diff.newId}`
23
- : (diff.newId ?? diff.oldId ?? '?');
24
-
25
- const similarityStr = colors ? colorizeSimilarity(pct) : `${pct}%`;
26
- // @ts-expect-error TODO(Phase 2e): type this fully
27
- lines.push(`Concept "${idPart}" — ${similarityStr} similar`);
28
-
29
- if (!diff.hasChanges && !showUnchanged) {
30
- // @ts-expect-error TODO(Phase 2e): type this fully
31
- lines.push(' (no changes)');
32
- return lines.join('\n');
33
- }
34
-
35
- if (diff.concept.hasChanges || showUnchanged) {
36
- // @ts-expect-error TODO(Phase 2e): type this fully
37
- lines.push('');
38
- // @ts-expect-error TODO(Phase 2e): type this fully
39
- lines.push('Concept-level:');
40
- // @ts-expect-error TODO(Phase 2e): type this fully
41
- lines.push(renderConceptLevel(diff.concept, colors));
42
- }
43
-
44
- if (diff.languages.hasChanges || showUnchanged) {
45
- // @ts-expect-error TODO(Phase 2e): type this fully
46
- lines.push('');
47
- // @ts-expect-error TODO(Phase 2e): type this fully
48
- lines.push('Languages:');
49
- // @ts-expect-error TODO(Phase 2e): type this fully
50
- lines.push(renderLanguageSet(diff.languages, colors));
51
- }
52
-
53
- for (const lang of diff.localizationLanguages) {
54
- const lcDiff = diff.localization(lang);
55
- if (!lcDiff) continue;
56
- if (lcDiff.hasChanges || showUnchanged) {
57
- // @ts-expect-error TODO(Phase 2e): type this fully
58
- lines.push('');
59
- // @ts-expect-error TODO(Phase 2e): type this fully
60
- lines.push(`Localization (${lang}):`);
61
- // @ts-expect-error TODO(Phase 2e): type this fully
62
- lines.push(renderLocalized(lcDiff, colors));
63
- }
64
- }
65
-
66
- return lines.join('\n');
67
- }
68
-
69
- export function renderCollectionDiff(diff, options = {}) {
70
- // @ts-expect-error TODO(Phase 2e): type this fully
71
- const colors = options.colors ?? false;
72
- const lines = [];
73
-
74
- const pct = Math.round(diff.similarity * 100);
75
- const similarityStr = colors ? colorizeSimilarity(pct) : `${pct}%`;
76
-
77
- // @ts-expect-error TODO(Phase 2e): type this fully
78
- lines.push(`Collection comparison — ${similarityStr} similar overall`);
79
- // @ts-expect-error TODO(Phase 2e): type this fully
80
- lines.push(` Old: ${diff.oldCount} concepts`);
81
- // @ts-expect-error TODO(Phase 2e): type this fully
82
- lines.push(` New: ${diff.newCount} concepts`);
83
- // @ts-expect-error TODO(Phase 2e): type this fully
84
- lines.push(` Matched: ${diff.matched.length}`);
85
- // @ts-expect-error TODO(Phase 2e): type this fully
86
- lines.push(` Added: ${diff.added.length}`);
87
- // @ts-expect-error TODO(Phase 2e): type this fully
88
- lines.push(` Removed: ${diff.removed.length}`);
89
-
90
- if (diff.added.length > 0) {
91
- // @ts-expect-error TODO(Phase 2e): type this fully
92
- lines.push('');
93
- // @ts-expect-error TODO(Phase 2e): type this fully
94
- lines.push(colors ? COLORS.green('Added concepts:') : 'Added concepts:');
95
- for (const entry of diff.added) {
96
- // @ts-expect-error TODO(Phase 2e): type this fully
97
- lines.push(` + ${entry.value}`);
98
- }
99
- }
100
-
101
- if (diff.removed.length > 0) {
102
- // @ts-expect-error TODO(Phase 2e): type this fully
103
- lines.push('');
104
- // @ts-expect-error TODO(Phase 2e): type this fully
105
- lines.push(colors ? COLORS.red('Removed concepts:') : 'Removed concepts:');
106
- for (const entry of diff.removed) {
107
- // @ts-expect-error TODO(Phase 2e): type this fully
108
- lines.push(` - ${entry.value}`);
109
- }
110
- }
111
-
112
- const changedDiffs = Object.entries(diff.conceptDiffs)
113
- // @ts-expect-error TODO(Phase 2e): type this fully
114
- .filter(([, d]) => d.hasChanges)
115
- // @ts-expect-error TODO(Phase 2e): type this fully
116
- .sort(([, a], [, b]) => a.similarity - b.similarity);
117
-
118
- if (changedDiffs.length > 0) {
119
- // @ts-expect-error TODO(Phase 2e): type this fully
120
- lines.push('');
121
- // @ts-expect-error TODO(Phase 2e): type this fully
122
- lines.push('Changed concepts:');
123
- for (const [id, conceptDiff] of changedDiffs) {
124
- // @ts-expect-error TODO(Phase 2e): type this fully
125
- const conceptPct = Math.round(conceptDiff.similarity * 100);
126
- const pctStr = colors ? colorizeSimilarity(conceptPct) : `${conceptPct}%`;
127
- // @ts-expect-error TODO(Phase 2e): type this fully
128
- lines.push(` ${id}: ${pctStr}`);
129
- }
130
- }
131
-
132
- return lines.join('\n');
133
- }
134
-
135
- export function renderTextDiff(textDiff, options = {}) {
136
- if (!(textDiff instanceof TextDiff)) {
137
- textDiff = TextDiff.fromJSON(textDiff);
138
- }
139
- // @ts-expect-error TODO(Phase 2e): type this fully
140
- const colors = options.colors ?? false;
141
- const lines = [];
142
-
143
- for (const hunk of textDiff.hunks) {
144
- if (hunk.type === 'equal') {
145
- // @ts-expect-error TODO(Phase 2e): type this fully
146
- lines.push(` ${hunk.text}`);
147
- } else if (hunk.type === 'added') {
148
- // @ts-expect-error TODO(Phase 2e): type this fully
149
- lines.push(colors ? `+ ${COLORS.green(hunk.text)}` : `+ ${hunk.text}`);
150
- } else if (hunk.type === 'removed') {
151
- // @ts-expect-error TODO(Phase 2e): type this fully
152
- lines.push(colors ? `- ${COLORS.red(hunk.text)}` : `- ${hunk.text}`);
153
- }
154
- }
155
-
156
- return lines.join('\n');
157
- }
158
-
159
- function renderConceptLevel(diff, colors) {
160
- const lines = [];
161
- // @ts-expect-error TODO(Phase 2e): type this fully
162
- lines.push(...renderListDiff('Sources', diff.sources, colors, itemLabel));
163
- // @ts-expect-error TODO(Phase 2e): type this fully
164
- lines.push(...renderListDiff('Dates', diff.dates, colors, itemLabel));
165
- // @ts-expect-error TODO(Phase 2e): type this fully
166
- lines.push(...renderListDiff('Related', diff.relatedConcepts, colors, itemLabel));
167
- // Unified hyperedge section. Replaces the per-type sections
168
- // (Partitive relations, Generic relations) — the underlying diff
169
- // is a single ListDiff over the unified .relations array.
170
- // @ts-expect-error TODO(Phase 2e): type this fully
171
- lines.push(...renderListDiff('Hyperedges', diff.relations, colors, relationLabel));
172
- // @ts-expect-error TODO(Phase 2e): type this fully
173
- lines.push(...renderListDiff('Groups', diff.groups, colors, itemLabel));
174
- // @ts-expect-error TODO(Phase 2e): type this fully
175
- lines.push(...renderListDiff('Sections', diff.sections, colors, itemLabel));
176
- // @ts-expect-error TODO(Phase 2e): type this fully
177
- lines.push(...renderListDiff('Tags', diff.tags, colors, itemLabel));
178
- // @ts-expect-error TODO(Phase 2e): type this fully
179
- lines.push(...renderMetadataDiff(diff.metadata));
180
- return lines.filter(Boolean).join('\n');
181
- }
182
-
183
- function renderLanguageSet(diff, colors) {
184
- const lines = [];
185
- for (const entry of diff.added) {
186
- // @ts-expect-error TODO(Phase 2e): type this fully
187
- lines.push(colors ? ` + ${COLORS.green(entry.value)}` : ` + ${entry.value}`);
188
- }
189
- for (const entry of diff.removed) {
190
- // @ts-expect-error TODO(Phase 2e): type this fully
191
- lines.push(colors ? ` - ${COLORS.red(entry.value)}` : ` - ${entry.value}`);
192
- }
193
- return lines.join('\n');
194
- }
195
-
196
- function renderLocalized(diff, colors) {
197
- const lines = [];
198
- // @ts-expect-error TODO(Phase 2e): type this fully
199
- lines.push(...renderListDiff('Designations', diff.designations, colors, designationLabel));
200
- // @ts-expect-error TODO(Phase 2e): type this fully
201
- lines.push(...renderListDiff('Definitions', diff.definitions, colors, definitionLabel));
202
- // @ts-expect-error TODO(Phase 2e): type this fully
203
- lines.push(...renderListDiff('Notes', diff.notes, colors, definitionLabel));
204
- // @ts-expect-error TODO(Phase 2e): type this fully
205
- lines.push(...renderListDiff('Examples', diff.examples, colors, definitionLabel));
206
- // @ts-expect-error TODO(Phase 2e): type this fully
207
- lines.push(...renderListDiff('Sources', diff.sources, colors, itemLabel));
208
- // @ts-expect-error TODO(Phase 2e): type this fully
209
- lines.push(...renderListDiff('Dates', diff.dates, colors, itemLabel));
210
- // @ts-expect-error TODO(Phase 2e): type this fully
211
- lines.push(...renderListDiff('Related', diff.related, colors, itemLabel));
212
- // @ts-expect-error TODO(Phase 2e): type this fully
213
- lines.push(...renderMetadataDiff(diff.metadata));
214
- return lines.filter(Boolean).join('\n');
215
- }
216
-
217
- function renderListDiff(label, listDiff, colors, labelFn) {
218
- if (!listDiff.hasChanges) return [];
219
- const lines = [` ${label}:`];
220
- for (const entry of listDiff.added) {
221
- const text = ` + ${labelFn(entry.value)}`;
222
- lines.push(colors ? COLORS.green(text) : text);
223
- }
224
- for (const entry of listDiff.removed) {
225
- const text = ` - ${labelFn(entry.value)}`;
226
- lines.push(colors ? COLORS.red(text) : text);
227
- }
228
- for (const entry of listDiff.changed) {
229
- const oldLabel = labelFn(entry.oldValue);
230
- const newLabel = labelFn(entry.newValue);
231
- lines.push(` ~ ${oldLabel} → ${newLabel}`);
232
- }
233
- return lines;
234
- }
235
-
236
- function renderMetadataDiff(metadataDiff) {
237
- if (!metadataDiff.hasChanges) return [];
238
- const lines = [` Metadata:`];
239
- for (const [field, change] of Object.entries(metadataDiff.changes)) {
240
- // @ts-expect-error TODO(Phase 2e): type this fully
241
- const oldVal = formatScalar(change.oldValue);
242
- // @ts-expect-error TODO(Phase 2e): type this fully
243
- const newVal = formatScalar(change.newValue);
244
- lines.push(` ~ ${field}: ${oldVal} → ${newVal}`);
245
- }
246
- return lines;
247
- }
248
-
249
- function designationLabel(d) {
250
- if (!d) return '?';
251
- const text = d.designation ?? '?';
252
- const status = d.normativeStatus ? ` (${d.normativeStatus})` : '';
253
- return `${text}${status}`;
254
- }
255
-
256
- function definitionLabel(d) {
257
- if (!d) return '?';
258
- return d.content ?? '?';
259
- }
260
-
261
- function relationLabel(r) {
262
- if (!r) return '?';
263
- const c = r.comprehensive;
264
- const head = c?.id ?? c?.source ?? c?.text ?? '?';
265
- // PartitiveHyperedge exposes .partitives as the wire alias for
266
- // .members; GenericHyperedge uses .members directly. Read both.
267
- const members = Array.isArray(r.partitives) ? r.partitives : r.members;
268
- const memberText = Array.isArray(members)
269
- ? members.map(m => {
270
- const ref = m?.ref ?? m ?? {};
271
- let tail = '';
272
- const mult = resolveMultiplicity(m);
273
- if (mult && mult !== 'compulsory') tail += ` (${mult})`;
274
- // PartitiveMember uses is_delimiting (boolean flag).
275
- if (m?.is_delimiting === true) tail += ' ⊘';
276
- // GenericMember uses delimitingCharacteristic (string value per
277
- // ISO 704:2022 §5.5.4.2.1) — show the delimiting characteristic
278
- // text so reviewers can see the intension difference.
279
- if (m?.delimitingCharacteristic) {
280
- const c = Object.values(m.delimitingCharacteristic)[0];
281
- if (typeof c === 'string' && c.length > 0) tail += ` ⟨${c}⟩`;
282
- }
283
- return `${ref.id ?? ref.source ?? ref.text ?? '?'}${tail}`;
284
- }).join(', ')
285
- : '';
286
- const completeness = r.completeness ? ` (${r.completeness})` : '';
287
- const criterion = r.criterion
288
- ? ` / ${Object.values(r.criterion)[0] ?? ''}`
289
- : '';
290
- // Each hyperedge leaf declares a short static kindLabel (PART, GEN, …).
291
- // Read it via the constructor so adding a new hyperedge type needs no
292
- // renderer edit. The blank-string default keeps backward-compat with
293
- // any AbstractHyperedge subclass that doesn't declare kindLabel.
294
- const kindLabel = r?.constructor?.kindLabel ?? '';
295
- const typeTag = kindLabel ? `${kindLabel} ` : '';
296
- return `${typeTag}${head} → {${memberText}}${completeness}${criterion}`;
297
- }
298
-
299
- // Aggregate multiplicity + delimiting stats across a concept's
300
- // PartitiveRelations. Used by dataset-level summaries, not by the
301
- // per-relation diff label.
302
- //
303
- // v4: presence and count are independent dimensions. Stats include
304
- // byPresence and byCount breakdowns so tools can query each axis
305
- // independently ("show me all optional parts" or "show me all
306
- // multiple-count parts").
307
- export function multiplicityStats(relations) {
308
- const byMultiplicity = {};
309
- const byPresence = {};
310
- const byCount = {};
311
- let delimitingCount = 0;
312
- let total = 0;
313
- for (const rel of relations ?? []) {
314
- for (const m of rel?.partitives ?? []) {
315
- total += 1;
316
- const mult = resolveMultiplicity(m);
317
- byMultiplicity[mult] = (byMultiplicity[mult] ?? 0) + 1;
318
- const p = m?.presence ?? 'required';
319
- const c = m?.count ?? 'exactly_one';
320
- byPresence[p] = (byPresence[p] ?? 0) + 1;
321
- byCount[c] = (byCount[c] ?? 0) + 1;
322
- if (m?.is_delimiting === true) delimitingCount += 1;
323
- }
324
- }
325
- return { total, byMultiplicity, byPresence, byCount, delimiting: delimitingCount };
326
- }
327
-
328
- function itemLabel(item) {
329
- if (item == null) return '?';
330
- if (typeof item === 'string') return item;
331
- if (typeof item === 'number') return String(item);
332
- if (typeof item.toJSON === 'function') {
333
- return JSON.stringify(item.toJSON());
334
- }
335
- return String(item);
336
- }
337
-
338
- function formatScalar(val) {
339
- if (val == null) return '∅';
340
- if (typeof val === 'string') return val;
341
- return String(val);
342
- }
343
-
344
- function colorizeSimilarity(pct) {
345
- if (pct >= 95) return COLORS.green(`${pct}%`);
346
- if (pct >= 80) return COLORS.yellow(`${pct}%`);
347
- return COLORS.red(`${pct}%`);
348
- }
@@ -1,33 +0,0 @@
1
- // Shared identity helper for the diff layer.
2
- //
3
- // Per invariant N1, identity is a model concern. Models expose
4
- // `identity()` returning a stable string. This helper dispatches: if
5
- // the value is a model with `identity()`, call it; otherwise fall
6
- // back to canonical JSON of `toJSON()`.
7
-
8
- import { canonicalJson } from './canonical-json.js';
9
-
10
- interface Identifiable {
11
- identity(): string;
12
- }
13
- interface HasToJSON {
14
- toJSON(): unknown;
15
- }
16
-
17
- function hasIdentity(v: unknown): v is Identifiable {
18
- return v != null && typeof v === 'object' && typeof (v as { identity?: unknown }).identity === 'function';
19
- }
20
-
21
- function hasToJSON(v: unknown): v is HasToJSON {
22
- return v != null && typeof v === 'object' && typeof (v as { toJSON?: unknown }).toJSON === 'function';
23
- }
24
-
25
- export function identityOf(item: unknown): string {
26
- if (item == null) return '';
27
- if (hasIdentity(item)) return item.identity();
28
- if (typeof item === 'string') return item;
29
- if (typeof item === 'number') return String(item);
30
- if (typeof item === 'boolean') return String(item);
31
- if (hasToJSON(item)) return canonicalJson(item.toJSON());
32
- return canonicalJson(item);
33
- }