@thomasfosterau/effect-rdf 0.0.0-stage → 0.1.0

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 (776) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +2251 -2
  3. package/dist/Algebra-CGG4oae3.mjs +433 -0
  4. package/dist/Algebra-CGG4oae3.mjs.map +1 -0
  5. package/dist/Algebra-uGsIEOUA.d.mts +446 -0
  6. package/dist/Ast-CPRZmBvk.mjs +552 -0
  7. package/dist/Ast-CPRZmBvk.mjs.map +1 -0
  8. package/dist/Ast-vcw2W-lf.d.mts +827 -0
  9. package/dist/Bindings-Ck3m7JRC.mjs +249 -0
  10. package/dist/Bindings-Ck3m7JRC.mjs.map +1 -0
  11. package/dist/Bindings-DiKpBd7f.d.mts +153 -0
  12. package/dist/ClientErrors-CpXdFX5u.mjs +128 -0
  13. package/dist/ClientErrors-CpXdFX5u.mjs.map +1 -0
  14. package/dist/ClientErrors-D4IZHUM-.d.mts +101 -0
  15. package/dist/ClientFormats-CXomkXLV.mjs +73 -0
  16. package/dist/ClientFormats-CXomkXLV.mjs.map +1 -0
  17. package/dist/ClientFormats-Dm57ZPwR.d.mts +36 -0
  18. package/dist/Csv2Json-DynEcwCh.mjs +194 -0
  19. package/dist/Csv2Json-DynEcwCh.mjs.map +1 -0
  20. package/dist/Csv2Json-aXNVDoXQ.d.mts +40 -0
  21. package/dist/Csv2Rdf-8maXP6mt.d.mts +41 -0
  22. package/dist/Csv2Rdf-DuSEkaKE.mjs +161 -0
  23. package/dist/Csv2Rdf-DuSEkaKE.mjs.map +1 -0
  24. package/dist/Dataset-BlmlcI7J.mjs +782 -0
  25. package/dist/Dataset-BlmlcI7J.mjs.map +1 -0
  26. package/dist/Dataset-DS3ESOcO.d.mts +426 -0
  27. package/dist/Dataset.d.mts +2 -0
  28. package/dist/Dataset.mjs +1 -0
  29. package/dist/Datatype-CxMpamHC.d.mts +212 -0
  30. package/dist/Datatype-DQvkNkiH.mjs +1001 -0
  31. package/dist/Datatype-DQvkNkiH.mjs.map +1 -0
  32. package/dist/Dialect-8ChFj5EX.d.mts +113 -0
  33. package/dist/Dialect-CzVH38uo.mjs +165 -0
  34. package/dist/Dialect-CzVH38uo.mjs.map +1 -0
  35. package/dist/DocumentLoader-D3lZREnB.mjs +346 -0
  36. package/dist/DocumentLoader-D3lZREnB.mjs.map +1 -0
  37. package/dist/DocumentLoader-ZUCEVrW5.d.mts +178 -0
  38. package/dist/DublinCore-AnwqxRx6.mjs +137 -0
  39. package/dist/DublinCore-AnwqxRx6.mjs.map +1 -0
  40. package/dist/DublinCore-Dq-tVA5d.d.mts +119 -0
  41. package/dist/Engine-CYPB3g4h.d.mts +144 -0
  42. package/dist/Engine-DF8PN7g-.mjs +872 -0
  43. package/dist/Engine-DF8PN7g-.mjs.map +1 -0
  44. package/dist/Errors-CMdV1RhU.mjs +37 -0
  45. package/dist/Errors-CMdV1RhU.mjs.map +1 -0
  46. package/dist/Errors-u2bDjUeM.d.mts +30 -0
  47. package/dist/Evaluator-DEsU4d1o.d.mts +50 -0
  48. package/dist/Evaluator-DOY2-guC.mjs +281 -0
  49. package/dist/Evaluator-DOY2-guC.mjs.map +1 -0
  50. package/dist/Exif-CpqniYQd.d.mts +78 -0
  51. package/dist/Exif-DjkCfEB-.mjs +89 -0
  52. package/dist/Exif-DjkCfEB-.mjs.map +1 -0
  53. package/dist/Expression-BIMMvduQ.mjs +230 -0
  54. package/dist/Expression-BIMMvduQ.mjs.map +1 -0
  55. package/dist/Expression-W8A9cyX7.d.mts +89 -0
  56. package/dist/Extract-Bop85jES.mjs +220 -0
  57. package/dist/Extract-Bop85jES.mjs.map +1 -0
  58. package/dist/Extract-C_pCvuTC.d.mts +88 -0
  59. package/dist/Federation-BcNrozc1.d.mts +52 -0
  60. package/dist/Federation-CHScBkaK.mjs +130 -0
  61. package/dist/Federation-CHScBkaK.mjs.map +1 -0
  62. package/dist/Functions-AvjNcId_.mjs +1346 -0
  63. package/dist/Functions-AvjNcId_.mjs.map +1 -0
  64. package/dist/Functions-OQJZP-F6.d.mts +111 -0
  65. package/dist/Generator-C52mmq01.d.mts +50 -0
  66. package/dist/Generator-D3utCJC7.mjs +205 -0
  67. package/dist/Generator-D3utCJC7.mjs.map +1 -0
  68. package/dist/Grammar-CPlSxGH6.mjs +200 -0
  69. package/dist/Grammar-CPlSxGH6.mjs.map +1 -0
  70. package/dist/Grammar-CRhnRoCu.d.mts +148 -0
  71. package/dist/Grammar-D6jZdJQ3.d.mts +169 -0
  72. package/dist/Grammar-mQ8CgE1M.mjs +258 -0
  73. package/dist/Grammar-mQ8CgE1M.mjs.map +1 -0
  74. package/dist/GraphStore-DhUa4nFO.d.mts +45 -0
  75. package/dist/GraphStore-DvbqwKy1.mjs +212 -0
  76. package/dist/GraphStore-DvbqwKy1.mjs.map +1 -0
  77. package/dist/Iri-BB8Ks-BF.d.mts +84 -0
  78. package/dist/Iri-Cr92gsQV.mjs +232 -0
  79. package/dist/Iri-Cr92gsQV.mjs.map +1 -0
  80. package/dist/Iri.d.mts +2 -0
  81. package/dist/Iri.mjs +1 -0
  82. package/dist/Isomorphism-B6qTY-xy.d.mts +28 -0
  83. package/dist/Isomorphism-BmqxhKyJ.mjs +232 -0
  84. package/dist/Isomorphism-BmqxhKyJ.mjs.map +1 -0
  85. package/dist/Isomorphism-DInKnWIy.mjs +390 -0
  86. package/dist/Isomorphism-DInKnWIy.mjs.map +1 -0
  87. package/dist/Isomorphism-DvSfZXLR.d.mts +37 -0
  88. package/dist/Isomorphism.d.mts +2 -0
  89. package/dist/Isomorphism.mjs +1 -0
  90. package/dist/JsonLd-DOwS2FHg.mjs +2836 -0
  91. package/dist/JsonLd-DOwS2FHg.mjs.map +1 -0
  92. package/dist/JsonLd-DobFrQNa.d.mts +242 -0
  93. package/dist/JsonLdError-C9J-BxfG.mjs +106 -0
  94. package/dist/JsonLdError-C9J-BxfG.mjs.map +1 -0
  95. package/dist/JsonLdError-DSOfHkOy.d.mts +43 -0
  96. package/dist/LanguageTag-BCu8rcmX.d.mts +38 -0
  97. package/dist/LanguageTag-BcOpMGZ4.mjs +89 -0
  98. package/dist/LanguageTag-BcOpMGZ4.mjs.map +1 -0
  99. package/dist/LanguageTag.d.mts +2 -0
  100. package/dist/LanguageTag.mjs +1 -0
  101. package/dist/Lexical-Cg0JHrf6.mjs +243 -0
  102. package/dist/Lexical-Cg0JHrf6.mjs.map +1 -0
  103. package/dist/Lexical-D3zySYVS.d.mts +163 -0
  104. package/dist/Manifest-B6xf6mUc.mjs +148 -0
  105. package/dist/Manifest-B6xf6mUc.mjs.map +1 -0
  106. package/dist/Manifest-DQUMRBFr.d.mts +98 -0
  107. package/dist/Mapping-BgG74x3U.d.mts +63 -0
  108. package/dist/Mapping-Dc1ZGirk.mjs +259 -0
  109. package/dist/Mapping-Dc1ZGirk.mjs.map +1 -0
  110. package/dist/Mcp-1DwTTKOK.mjs +48 -0
  111. package/dist/Mcp-1DwTTKOK.mjs.map +1 -0
  112. package/dist/Mcp-d-pX9erx.d.mts +25 -0
  113. package/dist/Message-CK_DGQuu.mjs +95 -0
  114. package/dist/Message-CK_DGQuu.mjs.map +1 -0
  115. package/dist/Message-fIvTJSXM.d.mts +49 -0
  116. package/dist/Metadata-BbffwGDZ.mjs +445 -0
  117. package/dist/Metadata-BbffwGDZ.mjs.map +1 -0
  118. package/dist/Metadata-CEt3yc1-.d.mts +901 -0
  119. package/dist/Metadata-D4HsQNXr.mjs +1273 -0
  120. package/dist/Metadata-D4HsQNXr.mjs.map +1 -0
  121. package/dist/Metadata-nzS7QKRj.d.mts +350 -0
  122. package/dist/Model-DaMmxurZ.d.mts +293 -0
  123. package/dist/Model-DlPzRYhF.mjs +528 -0
  124. package/dist/Model-DlPzRYhF.mjs.map +1 -0
  125. package/dist/N3-BzyV-KIH.mjs +974 -0
  126. package/dist/N3-BzyV-KIH.mjs.map +1 -0
  127. package/dist/N3-DSLnonDn.d.mts +100 -0
  128. package/dist/NQuads-C1VBOJ3-.mjs +117 -0
  129. package/dist/NQuads-C1VBOJ3-.mjs.map +1 -0
  130. package/dist/NQuads-FjFZikFg.d.mts +76 -0
  131. package/dist/NTriples-D-kLSEAf.mjs +120 -0
  132. package/dist/NTriples-D-kLSEAf.mjs.map +1 -0
  133. package/dist/NTriples-D34OspfW.d.mts +76 -0
  134. package/dist/Namespace-ClTUO_ya.d.mts +42 -0
  135. package/dist/Namespace-DHFIsORd.mjs +75 -0
  136. package/dist/Namespace-DHFIsORd.mjs.map +1 -0
  137. package/dist/Namespace.d.mts +2 -0
  138. package/dist/Namespace.mjs +1 -0
  139. package/dist/Namespaces-Bz85vpjW.mjs +235 -0
  140. package/dist/Namespaces-Bz85vpjW.mjs.map +1 -0
  141. package/dist/Namespaces-C1jW6EDo.d.mts +178 -0
  142. package/dist/Optimizer-BWWQRQPY.mjs +168 -0
  143. package/dist/Optimizer-BWWQRQPY.mjs.map +1 -0
  144. package/dist/Optimizer-DUpUow6k.d.mts +26 -0
  145. package/dist/Options-BLBGL4HE.mjs +72 -0
  146. package/dist/Options-BLBGL4HE.mjs.map +1 -0
  147. package/dist/Options-BommQwP9.d.mts +127 -0
  148. package/dist/Packet-CA76wVX3.mjs +197 -0
  149. package/dist/Packet-CA76wVX3.mjs.map +1 -0
  150. package/dist/Packet-Cy5g6XuW.d.mts +130 -0
  151. package/dist/Parser-p1Gyr0QN.d.mts +85 -0
  152. package/dist/Parser-xARsOWXk.mjs +1317 -0
  153. package/dist/Parser-xARsOWXk.mjs.map +1 -0
  154. package/dist/Path-B20Yp8KE.mjs +284 -0
  155. package/dist/Path-B20Yp8KE.mjs.map +1 -0
  156. package/dist/Path-DRB8e-Zn.d.mts +181 -0
  157. package/dist/Pdf-B9RZn--8.d.mts +77 -0
  158. package/dist/Pdf-CKK6dkZn.mjs +89 -0
  159. package/dist/Pdf-CKK6dkZn.mjs.map +1 -0
  160. package/dist/PdfA-CUjSuntT.d.mts +109 -0
  161. package/dist/PdfA-CleOhuL6.mjs +124 -0
  162. package/dist/PdfA-CleOhuL6.mjs.map +1 -0
  163. package/dist/Photoshop-CiHo80qV.mjs +233 -0
  164. package/dist/Photoshop-CiHo80qV.mjs.map +1 -0
  165. package/dist/Photoshop-udKZ0I3N.d.mts +204 -0
  166. package/dist/PrefixMap-BHFPDLO-.mjs +103 -0
  167. package/dist/PrefixMap-BHFPDLO-.mjs.map +1 -0
  168. package/dist/PrefixMap-BMlXrWNd.d.mts +64 -0
  169. package/dist/PrefixMap.d.mts +2 -0
  170. package/dist/PrefixMap.mjs +1 -0
  171. package/dist/Processor-CMmecFsb.mjs +198 -0
  172. package/dist/Processor-CMmecFsb.mjs.map +1 -0
  173. package/dist/Processor-FJPvO0CB.d.mts +435 -0
  174. package/dist/Protocol-BA7OkNgp.mjs +202 -0
  175. package/dist/Protocol-BA7OkNgp.mjs.map +1 -0
  176. package/dist/Protocol-DlSoiIKB.d.mts +108 -0
  177. package/dist/ProtocolErrors-Ckfejnl6.d.mts +84 -0
  178. package/dist/ProtocolErrors-czDPVcX5.mjs +129 -0
  179. package/dist/ProtocolErrors-czDPVcX5.mjs.map +1 -0
  180. package/dist/Query-D9A6LOpP.mjs +364 -0
  181. package/dist/Query-D9A6LOpP.mjs.map +1 -0
  182. package/dist/Query-KqSkTYyG.d.mts +96 -0
  183. package/dist/QueryBuilder-BLK9Vfbz.mjs +674 -0
  184. package/dist/QueryBuilder-BLK9Vfbz.mjs.map +1 -0
  185. package/dist/QueryBuilder-DUqh4ECe.d.mts +529 -0
  186. package/dist/RdfJs-D6-49XB5.mjs +86 -0
  187. package/dist/RdfJs-D6-49XB5.mjs.map +1 -0
  188. package/dist/RdfJs-DXFqdWrd.d.mts +76 -0
  189. package/dist/RdfJs.d.mts +2 -0
  190. package/dist/RdfJs.mjs +1 -0
  191. package/dist/RdfJson-5aKPDlPS.d.mts +297 -0
  192. package/dist/RdfJson-BNocgW4f.mjs +548 -0
  193. package/dist/RdfJson-BNocgW4f.mjs.map +1 -0
  194. package/dist/RdfXml-DJ9G4gOq.mjs +1014 -0
  195. package/dist/RdfXml-DJ9G4gOq.mjs.map +1 -0
  196. package/dist/RdfXml-_N7yxWEp.d.mts +149 -0
  197. package/dist/Rdfs-BRVPsAjc.d.mts +84 -0
  198. package/dist/Rdfs-CyY2wVHI.mjs +167 -0
  199. package/dist/Rdfs-CyY2wVHI.mjs.map +1 -0
  200. package/dist/Rdfs.d.mts +2 -0
  201. package/dist/Rdfs.mjs +1 -0
  202. package/dist/Reasoner-BxYhx9s7.d.mts +94 -0
  203. package/dist/Reasoner-Cw90zrjv.mjs +798 -0
  204. package/dist/Reasoner-Cw90zrjv.mjs.map +1 -0
  205. package/dist/Reification-BmN4EfnM.d.mts +40 -0
  206. package/dist/Reification-dpqQvjDE.mjs +82 -0
  207. package/dist/Reification-dpqQvjDE.mjs.map +1 -0
  208. package/dist/Reification.d.mts +2 -0
  209. package/dist/Reification.mjs +1 -0
  210. package/dist/Report-XHs8htzK.mjs +121 -0
  211. package/dist/Report-XHs8htzK.mjs.map +1 -0
  212. package/dist/Report-hcXsc_19.d.mts +115 -0
  213. package/dist/Resource-B1cI8FyJ.d.mts +218 -0
  214. package/dist/Resource-sIEeNh15.mjs +374 -0
  215. package/dist/Resource-sIEeNh15.mjs.map +1 -0
  216. package/dist/Resource.d.mts +2 -0
  217. package/dist/Resource.mjs +1 -0
  218. package/dist/Results-BVNEC-Wt.d.mts +277 -0
  219. package/dist/Results-peJjGA2V.mjs +621 -0
  220. package/dist/Results-peJjGA2V.mjs.map +1 -0
  221. package/dist/ResultsStream-BhF0OcNn.mjs +639 -0
  222. package/dist/ResultsStream-BhF0OcNn.mjs.map +1 -0
  223. package/dist/ResultsStream-toYMXrOe.d.mts +100 -0
  224. package/dist/SemAct-CDchtk49.d.mts +96 -0
  225. package/dist/SemAct-CmyT4yI8.mjs +118 -0
  226. package/dist/SemAct-CmyT4yI8.mjs.map +1 -0
  227. package/dist/Serialization-DP9H5bYQ.mjs +514 -0
  228. package/dist/Serialization-DP9H5bYQ.mjs.map +1 -0
  229. package/dist/Serialization-Df8iVauT.d.mts +392 -0
  230. package/dist/Serialization.d.mts +2 -0
  231. package/dist/Serialization.mjs +1 -0
  232. package/dist/ServerFormats-CrRnjjf6.mjs +64 -0
  233. package/dist/ServerFormats-CrRnjjf6.mjs.map +1 -0
  234. package/dist/ServerFormats-DjC9NsO_.d.mts +36 -0
  235. package/dist/ServiceDescription-BERsvg-k.d.mts +54 -0
  236. package/dist/ServiceDescription-Dq5hxeGy.mjs +97 -0
  237. package/dist/ServiceDescription-Dq5hxeGy.mjs.map +1 -0
  238. package/dist/ShExC-Ctf-06CL.d.mts +67 -0
  239. package/dist/ShExC-DJbB19i3.mjs +1181 -0
  240. package/dist/ShExC-DJbB19i3.mjs.map +1 -0
  241. package/dist/ShExError-BeYFD9rv.d.mts +61 -0
  242. package/dist/ShExError-CVtq2NnM.mjs +64 -0
  243. package/dist/ShExError-CVtq2NnM.mjs.map +1 -0
  244. package/dist/ShExJ-C1u_wgyD.d.mts +531 -0
  245. package/dist/ShExJ-COiPd9Xw.mjs +532 -0
  246. package/dist/ShExJ-COiPd9Xw.mjs.map +1 -0
  247. package/dist/ShExR-ByR4mCh-.mjs +480 -0
  248. package/dist/ShExR-ByR4mCh-.mjs.map +1 -0
  249. package/dist/ShExR-CqONNNBz.d.mts +40 -0
  250. package/dist/ShapeMap-C422pxKl.d.mts +140 -0
  251. package/dist/ShapeMap-CsgKxB2G.mjs +181 -0
  252. package/dist/ShapeMap-CsgKxB2G.mjs.map +1 -0
  253. package/dist/Shapes-18GjfyBV.mjs +597 -0
  254. package/dist/Shapes-18GjfyBV.mjs.map +1 -0
  255. package/dist/Shapes-BQFDFc4Q.d.mts +306 -0
  256. package/dist/Sparql-BiYFMSpl.mjs +29 -0
  257. package/dist/Sparql-BiYFMSpl.mjs.map +1 -0
  258. package/dist/Sparql-DecpWTPh.d.mts +97 -0
  259. package/dist/SparqlClient-C_CjXbwj.mjs +333 -0
  260. package/dist/SparqlClient-C_CjXbwj.mjs.map +1 -0
  261. package/dist/SparqlClient-UPc88SHy.d.mts +290 -0
  262. package/dist/SparqlServer-CbUW-pVj.d.mts +71 -0
  263. package/dist/SparqlServer-Db7w7Cll.mjs +308 -0
  264. package/dist/SparqlServer-Db7w7Cll.mjs.map +1 -0
  265. package/dist/SqlStore-BBqFx-Wl.mjs +684 -0
  266. package/dist/SqlStore-BBqFx-Wl.mjs.map +1 -0
  267. package/dist/SqlStore-CCJo5I-e.d.mts +117 -0
  268. package/dist/Store-D0jmVfb3.d.mts +166 -0
  269. package/dist/Store-DH3Ow1GO.mjs +162 -0
  270. package/dist/Store-DH3Ow1GO.mjs.map +1 -0
  271. package/dist/Structure-BjMo4Bkc.mjs +334 -0
  272. package/dist/Structure-BjMo4Bkc.mjs.map +1 -0
  273. package/dist/Structure-n4CmDiab.d.mts +63 -0
  274. package/dist/Table-BGgm9nbM.mjs +538 -0
  275. package/dist/Table-BGgm9nbM.mjs.map +1 -0
  276. package/dist/Table-C3reiVrb.d.mts +261 -0
  277. package/dist/Term-B_4ezyXq.d.mts +619 -0
  278. package/dist/Term-CFLG1qu4.mjs +991 -0
  279. package/dist/Term-CFLG1qu4.mjs.map +1 -0
  280. package/dist/Term.d.mts +2 -0
  281. package/dist/Term.mjs +1 -0
  282. package/dist/TermCodec-CDZiEztW.mjs +397 -0
  283. package/dist/TermCodec-CDZiEztW.mjs.map +1 -0
  284. package/dist/TermCodec-_03bDXr0.d.mts +209 -0
  285. package/dist/TermCodec.d.mts +2 -0
  286. package/dist/TermCodec.mjs +1 -0
  287. package/dist/TermJson-BOPe0yve.d.mts +232 -0
  288. package/dist/TermJson-FAg3lvjl.mjs +142 -0
  289. package/dist/TermJson-FAg3lvjl.mjs.map +1 -0
  290. package/dist/TermJson.d.mts +2 -0
  291. package/dist/TermJson.mjs +1 -0
  292. package/dist/TermSchema-Bn9CoaYA.mjs +30 -0
  293. package/dist/TermSchema-Bn9CoaYA.mjs.map +1 -0
  294. package/dist/TermSchema-DBO6MroX.d.mts +6 -0
  295. package/dist/Testing-B-aPCpmu.mjs +63 -0
  296. package/dist/Testing-B-aPCpmu.mjs.map +1 -0
  297. package/dist/Testing-CF6s8P3O.d.mts +53 -0
  298. package/dist/Tiff-CR-2QeSI.d.mts +148 -0
  299. package/dist/Tiff-DlsOlZPM.mjs +169 -0
  300. package/dist/Tiff-DlsOlZPM.mjs.map +1 -0
  301. package/dist/Tools-7MdRKccr.d.mts +583 -0
  302. package/dist/Tools-ryxphZbI.mjs +329 -0
  303. package/dist/Tools-ryxphZbI.mjs.map +1 -0
  304. package/dist/Translate-B0YKKANS.d.mts +37 -0
  305. package/dist/Translate-gzWPq0Ia.mjs +308 -0
  306. package/dist/Translate-gzWPq0Ia.mjs.map +1 -0
  307. package/dist/Translation-DC9rLm2y.mjs +1535 -0
  308. package/dist/Translation-DC9rLm2y.mjs.map +1 -0
  309. package/dist/Translation-K4L9XBqX.d.mts +103 -0
  310. package/dist/TriG-BkqtqZ6Y.mjs +125 -0
  311. package/dist/TriG-BkqtqZ6Y.mjs.map +1 -0
  312. package/dist/TriG-xDjdDatp.d.mts +86 -0
  313. package/dist/Turtle-Bv1_bisW.d.mts +85 -0
  314. package/dist/Turtle-CZVUOtwl.mjs +133 -0
  315. package/dist/Turtle-CZVUOtwl.mjs.map +1 -0
  316. package/dist/ValidationReport-DBdJshW5.mjs +285 -0
  317. package/dist/ValidationReport-DBdJshW5.mjs.map +1 -0
  318. package/dist/ValidationReport-Dx3WxY0h.d.mts +192 -0
  319. package/dist/Validator-227ff9Rn.d.mts +179 -0
  320. package/dist/Validator-BzXMKDeJ.mjs +1162 -0
  321. package/dist/Validator-BzXMKDeJ.mjs.map +1 -0
  322. package/dist/Validator-Dl8cih5V.d.mts +207 -0
  323. package/dist/Validator-DmUfMbpL.mjs +568 -0
  324. package/dist/Validator-DmUfMbpL.mjs.map +1 -0
  325. package/dist/Vocab-DceKywpq.mjs +168 -0
  326. package/dist/Vocab-DceKywpq.mjs.map +1 -0
  327. package/dist/Vocab-Df-L-IwZ.d.mts +46 -0
  328. package/dist/Vocab-Do56UgBX.d.mts +81 -0
  329. package/dist/Vocab-TfpWG1Ne.mjs +118 -0
  330. package/dist/Vocab-TfpWG1Ne.mjs.map +1 -0
  331. package/dist/Vocab.d.mts +2 -0
  332. package/dist/Vocab.mjs +1 -0
  333. package/dist/Vocabulary-C6-GPOy4.d.mts +22 -0
  334. package/dist/Vocabulary-CnQl-_Z4.mjs +179 -0
  335. package/dist/Vocabulary-CnQl-_Z4.mjs.map +1 -0
  336. package/dist/Xml-B7iihYCS.mjs +976 -0
  337. package/dist/Xml-B7iihYCS.mjs.map +1 -0
  338. package/dist/Xml-CmfHS7SW.d.mts +267 -0
  339. package/dist/Xmp-D7CKA7MZ.d.mts +111 -0
  340. package/dist/Xmp-DCGN9pOD.mjs +307 -0
  341. package/dist/Xmp-DCGN9pOD.mjs.map +1 -0
  342. package/dist/XmpBasic-CP38jpR_.mjs +73 -0
  343. package/dist/XmpBasic-CP38jpR_.mjs.map +1 -0
  344. package/dist/XmpBasic-Cmbe53rQ.d.mts +64 -0
  345. package/dist/XmpMM-BfL_TgJF.mjs +73 -0
  346. package/dist/XmpMM-BfL_TgJF.mjs.map +1 -0
  347. package/dist/XmpMM-Dqm3IX8p.d.mts +63 -0
  348. package/dist/XmpRights-BKPtoI5L.mjs +73 -0
  349. package/dist/XmpRights-BKPtoI5L.mjs.map +1 -0
  350. package/dist/XmpRights-CaALZQz2.d.mts +63 -0
  351. package/dist/Xsd-Cdgx5zRB.mjs +405 -0
  352. package/dist/Xsd-Cdgx5zRB.mjs.map +1 -0
  353. package/dist/Xsd-D2elNhSm.d.mts +187 -0
  354. package/dist/Xsd.d.mts +2 -0
  355. package/dist/Xsd.mjs +1 -0
  356. package/dist/accessors-CEjaojuQ.mjs +28 -0
  357. package/dist/accessors-CEjaojuQ.mjs.map +1 -0
  358. package/dist/codec-Lb2T96rv.d.mts +20 -0
  359. package/dist/codec-QNo7IdJF.mjs +389 -0
  360. package/dist/codec-QNo7IdJF.mjs.map +1 -0
  361. package/dist/csvw/Csv2Json.d.mts +2 -0
  362. package/dist/csvw/Csv2Json.mjs +1 -0
  363. package/dist/csvw/Csv2Rdf.d.mts +2 -0
  364. package/dist/csvw/Csv2Rdf.mjs +1 -0
  365. package/dist/csvw/Datatype.d.mts +2 -0
  366. package/dist/csvw/Datatype.mjs +1 -0
  367. package/dist/csvw/Metadata.d.mts +2 -0
  368. package/dist/csvw/Metadata.mjs +1 -0
  369. package/dist/csvw/Processor.d.mts +2 -0
  370. package/dist/csvw/Processor.mjs +1 -0
  371. package/dist/csvw/Report.d.mts +2 -0
  372. package/dist/csvw/Report.mjs +1 -0
  373. package/dist/csvw/Table.d.mts +2 -0
  374. package/dist/csvw/Table.mjs +1 -0
  375. package/dist/csvw/index.d.mts +8 -0
  376. package/dist/csvw/index.mjs +8 -0
  377. package/dist/index-Cms2TYfC.d.mts +16 -0
  378. package/dist/index-Ct8xFmRs.d.mts +7 -0
  379. package/dist/index-D4QFwOjm.d.mts +28 -0
  380. package/dist/index.d.mts +18 -0
  381. package/dist/index.mjs +17 -0
  382. package/dist/jsonld/DocumentLoader.d.mts +2 -0
  383. package/dist/jsonld/DocumentLoader.mjs +1 -0
  384. package/dist/jsonld/JsonLd.d.mts +2 -0
  385. package/dist/jsonld/JsonLd.mjs +1 -0
  386. package/dist/jsonld/JsonLdError.d.mts +2 -0
  387. package/dist/jsonld/JsonLdError.mjs +1 -0
  388. package/dist/jsonld/index.d.mts +4 -0
  389. package/dist/jsonld/index.mjs +4 -0
  390. package/dist/lists-D-OpQ0Ir.mjs +77 -0
  391. package/dist/lists-D-OpQ0Ir.mjs.map +1 -0
  392. package/dist/loop-D5-gNx9K.mjs +21 -0
  393. package/dist/loop-D5-gNx9K.mjs.map +1 -0
  394. package/dist/loop-DZ2hXlr_.mjs +21 -0
  395. package/dist/loop-DZ2hXlr_.mjs.map +1 -0
  396. package/dist/n3/Isomorphism.d.mts +2 -0
  397. package/dist/n3/Isomorphism.mjs +1 -0
  398. package/dist/n3/Mapping.d.mts +2 -0
  399. package/dist/n3/Mapping.mjs +1 -0
  400. package/dist/n3/Model.d.mts +2 -0
  401. package/dist/n3/Model.mjs +1 -0
  402. package/dist/n3/N3.d.mts +2 -0
  403. package/dist/n3/N3.mjs +1 -0
  404. package/dist/n3/Reasoner.d.mts +2 -0
  405. package/dist/n3/Reasoner.mjs +2 -0
  406. package/dist/n3/Vocab.d.mts +2 -0
  407. package/dist/n3/Vocab.mjs +1 -0
  408. package/dist/n3/index.d.mts +7 -0
  409. package/dist/n3/index.mjs +7 -0
  410. package/dist/ntriples/Grammar.d.mts +2 -0
  411. package/dist/ntriples/Grammar.mjs +1 -0
  412. package/dist/ntriples/Lexical.d.mts +2 -0
  413. package/dist/ntriples/Lexical.mjs +1 -0
  414. package/dist/ntriples/NQuads.d.mts +2 -0
  415. package/dist/ntriples/NQuads.mjs +1 -0
  416. package/dist/ntriples/NTriples.d.mts +2 -0
  417. package/dist/ntriples/NTriples.mjs +1 -0
  418. package/dist/ntriples/index.d.mts +5 -0
  419. package/dist/ntriples/index.mjs +5 -0
  420. package/dist/rdfjson/RdfJson.d.mts +2 -0
  421. package/dist/rdfjson/RdfJson.mjs +1 -0
  422. package/dist/rdfjson/index.d.mts +2 -0
  423. package/dist/rdfjson/index.mjs +1 -0
  424. package/dist/rdfxml/RdfXml.d.mts +2 -0
  425. package/dist/rdfxml/RdfXml.mjs +1 -0
  426. package/dist/rdfxml/Xml.d.mts +2 -0
  427. package/dist/rdfxml/Xml.mjs +1 -0
  428. package/dist/rdfxml/index.d.mts +3 -0
  429. package/dist/rdfxml/index.mjs +3 -0
  430. package/dist/rolldown-runtime-D8jQpDG7.mjs +12 -0
  431. package/dist/serialize-96KBvKaf.mjs +1463 -0
  432. package/dist/serialize-96KBvKaf.mjs.map +1 -0
  433. package/dist/serialize-DsoXdM6n.d.mts +37 -0
  434. package/dist/shacl/Message.d.mts +2 -0
  435. package/dist/shacl/Message.mjs +1 -0
  436. package/dist/shacl/Path.d.mts +2 -0
  437. package/dist/shacl/Path.mjs +1 -0
  438. package/dist/shacl/Shapes.d.mts +2 -0
  439. package/dist/shacl/Shapes.mjs +1 -0
  440. package/dist/shacl/Sparql.d.mts +2 -0
  441. package/dist/shacl/Sparql.mjs +1 -0
  442. package/dist/shacl/ValidationReport.d.mts +2 -0
  443. package/dist/shacl/ValidationReport.mjs +1 -0
  444. package/dist/shacl/Validator.d.mts +2 -0
  445. package/dist/shacl/Validator.mjs +1 -0
  446. package/dist/shacl/Vocabulary.d.mts +2 -0
  447. package/dist/shacl/Vocabulary.mjs +1 -0
  448. package/dist/shacl/index.d.mts +9 -0
  449. package/dist/shacl/index.mjs +8 -0
  450. package/dist/shex/SemAct.d.mts +2 -0
  451. package/dist/shex/SemAct.mjs +1 -0
  452. package/dist/shex/ShExC.d.mts +2 -0
  453. package/dist/shex/ShExC.mjs +1 -0
  454. package/dist/shex/ShExError.d.mts +2 -0
  455. package/dist/shex/ShExError.mjs +1 -0
  456. package/dist/shex/ShExJ.d.mts +2 -0
  457. package/dist/shex/ShExJ.mjs +2 -0
  458. package/dist/shex/ShExR.d.mts +2 -0
  459. package/dist/shex/ShExR.mjs +1 -0
  460. package/dist/shex/ShapeMap.d.mts +2 -0
  461. package/dist/shex/ShapeMap.mjs +1 -0
  462. package/dist/shex/Structure.d.mts +2 -0
  463. package/dist/shex/Structure.mjs +2 -0
  464. package/dist/shex/Validator.d.mts +2 -0
  465. package/dist/shex/Validator.mjs +4 -0
  466. package/dist/shex/index.d.mts +9 -0
  467. package/dist/shex/index.mjs +9 -0
  468. package/dist/sparql/Algebra.d.mts +2 -0
  469. package/dist/sparql/Algebra.mjs +1 -0
  470. package/dist/sparql/Ast.d.mts +2 -0
  471. package/dist/sparql/Ast.mjs +1 -0
  472. package/dist/sparql/Bindings.d.mts +2 -0
  473. package/dist/sparql/Bindings.mjs +1 -0
  474. package/dist/sparql/ClientErrors.d.mts +2 -0
  475. package/dist/sparql/ClientErrors.mjs +1 -0
  476. package/dist/sparql/ClientFormats.d.mts +2 -0
  477. package/dist/sparql/ClientFormats.mjs +1 -0
  478. package/dist/sparql/Engine.d.mts +2 -0
  479. package/dist/sparql/Engine.mjs +1 -0
  480. package/dist/sparql/Errors.d.mts +2 -0
  481. package/dist/sparql/Errors.mjs +1 -0
  482. package/dist/sparql/Expression.d.mts +2 -0
  483. package/dist/sparql/Expression.mjs +1 -0
  484. package/dist/sparql/Federation.d.mts +2 -0
  485. package/dist/sparql/Federation.mjs +1 -0
  486. package/dist/sparql/Functions.d.mts +2 -0
  487. package/dist/sparql/Functions.mjs +1 -0
  488. package/dist/sparql/Generator.d.mts +2 -0
  489. package/dist/sparql/Generator.mjs +1 -0
  490. package/dist/sparql/GraphStore.d.mts +2 -0
  491. package/dist/sparql/GraphStore.mjs +1 -0
  492. package/dist/sparql/Optimizer.d.mts +2 -0
  493. package/dist/sparql/Optimizer.mjs +1 -0
  494. package/dist/sparql/Options.d.mts +2 -0
  495. package/dist/sparql/Options.mjs +1 -0
  496. package/dist/sparql/Parser.d.mts +2 -0
  497. package/dist/sparql/Parser.mjs +1 -0
  498. package/dist/sparql/Protocol.d.mts +2 -0
  499. package/dist/sparql/Protocol.mjs +1 -0
  500. package/dist/sparql/ProtocolErrors.d.mts +2 -0
  501. package/dist/sparql/ProtocolErrors.mjs +1 -0
  502. package/dist/sparql/QueryBuilder.d.mts +2 -0
  503. package/dist/sparql/QueryBuilder.mjs +1 -0
  504. package/dist/sparql/Results.d.mts +2 -0
  505. package/dist/sparql/Results.mjs +1 -0
  506. package/dist/sparql/ResultsStream.d.mts +2 -0
  507. package/dist/sparql/ResultsStream.mjs +1 -0
  508. package/dist/sparql/ServerFormats.d.mts +2 -0
  509. package/dist/sparql/ServerFormats.mjs +1 -0
  510. package/dist/sparql/ServiceDescription.d.mts +2 -0
  511. package/dist/sparql/ServiceDescription.mjs +1 -0
  512. package/dist/sparql/SparqlClient.d.mts +2 -0
  513. package/dist/sparql/SparqlClient.mjs +1 -0
  514. package/dist/sparql/SparqlServer.d.mts +2 -0
  515. package/dist/sparql/SparqlServer.mjs +1 -0
  516. package/dist/sparql/Store.d.mts +2 -0
  517. package/dist/sparql/Store.mjs +1 -0
  518. package/dist/sparql/TermSchema.d.mts +3 -0
  519. package/dist/sparql/TermSchema.mjs +2 -0
  520. package/dist/sparql/Testing.d.mts +2 -0
  521. package/dist/sparql/Testing.mjs +1 -0
  522. package/dist/sparql/Translate.d.mts +2 -0
  523. package/dist/sparql/Translate.mjs +1 -0
  524. package/dist/sparql/ai/Mcp.d.mts +2 -0
  525. package/dist/sparql/ai/Mcp.mjs +1 -0
  526. package/dist/sparql/ai/Tools.d.mts +2 -0
  527. package/dist/sparql/ai/Tools.mjs +1 -0
  528. package/dist/sparql/ai/index.d.mts +3 -0
  529. package/dist/sparql/ai/index.mjs +3 -0
  530. package/dist/sparql/index.d.mts +30 -0
  531. package/dist/sparql/index.mjs +29 -0
  532. package/dist/sparql/shacl/Evaluator.d.mts +2 -0
  533. package/dist/sparql/shacl/Evaluator.mjs +1 -0
  534. package/dist/sparql/shacl/Query.d.mts +2 -0
  535. package/dist/sparql/shacl/Query.mjs +1 -0
  536. package/dist/sparql/shacl/index.d.mts +3 -0
  537. package/dist/sparql/shacl/index.mjs +3 -0
  538. package/dist/sparql/sql/Dialect.d.mts +2 -0
  539. package/dist/sparql/sql/Dialect.mjs +1 -0
  540. package/dist/sparql/sql/SqlStore.d.mts +2 -0
  541. package/dist/sparql/sql/SqlStore.mjs +1 -0
  542. package/dist/sparql/sql/Translation.d.mts +2 -0
  543. package/dist/sparql/sql/Translation.mjs +1 -0
  544. package/dist/sparql/sql/index.d.mts +4 -0
  545. package/dist/sparql/sql/index.mjs +4 -0
  546. package/dist/stringMap-D5YIpYtR.mjs +38 -0
  547. package/dist/stringMap-D5YIpYtR.mjs.map +1 -0
  548. package/dist/tokens-C6BzeodQ.mjs +24 -0
  549. package/dist/tokens-C6BzeodQ.mjs.map +1 -0
  550. package/dist/turtle/Grammar.d.mts +3 -0
  551. package/dist/turtle/Grammar.mjs +3 -0
  552. package/dist/turtle/Manifest.d.mts +2 -0
  553. package/dist/turtle/Manifest.mjs +1 -0
  554. package/dist/turtle/TriG.d.mts +2 -0
  555. package/dist/turtle/TriG.mjs +1 -0
  556. package/dist/turtle/Turtle.d.mts +2 -0
  557. package/dist/turtle/Turtle.mjs +1 -0
  558. package/dist/turtle/index.d.mts +5 -0
  559. package/dist/turtle/index.mjs +5 -0
  560. package/dist/xmp/DublinCore.d.mts +2 -0
  561. package/dist/xmp/DublinCore.mjs +1 -0
  562. package/dist/xmp/Exif.d.mts +2 -0
  563. package/dist/xmp/Exif.mjs +1 -0
  564. package/dist/xmp/Extract.d.mts +2 -0
  565. package/dist/xmp/Extract.mjs +1 -0
  566. package/dist/xmp/Metadata.d.mts +2 -0
  567. package/dist/xmp/Metadata.mjs +1 -0
  568. package/dist/xmp/Namespaces.d.mts +2 -0
  569. package/dist/xmp/Namespaces.mjs +1 -0
  570. package/dist/xmp/Packet.d.mts +2 -0
  571. package/dist/xmp/Packet.mjs +1 -0
  572. package/dist/xmp/Pdf.d.mts +2 -0
  573. package/dist/xmp/Pdf.mjs +1 -0
  574. package/dist/xmp/PdfA.d.mts +2 -0
  575. package/dist/xmp/PdfA.mjs +1 -0
  576. package/dist/xmp/Photoshop.d.mts +2 -0
  577. package/dist/xmp/Photoshop.mjs +1 -0
  578. package/dist/xmp/Tiff.d.mts +2 -0
  579. package/dist/xmp/Tiff.mjs +1 -0
  580. package/dist/xmp/Xmp.d.mts +2 -0
  581. package/dist/xmp/Xmp.mjs +3 -0
  582. package/dist/xmp/XmpBasic.d.mts +2 -0
  583. package/dist/xmp/XmpBasic.mjs +1 -0
  584. package/dist/xmp/XmpMM.d.mts +2 -0
  585. package/dist/xmp/XmpMM.mjs +1 -0
  586. package/dist/xmp/XmpRights.d.mts +2 -0
  587. package/dist/xmp/XmpRights.mjs +1 -0
  588. package/dist/xmp/index.d.mts +15 -0
  589. package/dist/xmp/index.mjs +15 -0
  590. package/package.json +195 -3
  591. package/src/Dataset.ts +1085 -0
  592. package/src/Iri.ts +322 -0
  593. package/src/Isomorphism.ts +319 -0
  594. package/src/LanguageTag.ts +98 -0
  595. package/src/Namespace.ts +100 -0
  596. package/src/PrefixMap.ts +117 -0
  597. package/src/RdfJs.ts +146 -0
  598. package/src/Rdfs.ts +241 -0
  599. package/src/Reification.ts +103 -0
  600. package/src/Resource.ts +873 -0
  601. package/src/Serialization.ts +775 -0
  602. package/src/Term.ts +1300 -0
  603. package/src/TermCodec.ts +505 -0
  604. package/src/TermJson.ts +313 -0
  605. package/src/Vocab.ts +161 -0
  606. package/src/Xsd.ts +573 -0
  607. package/src/csvw/Csv2Json.ts +265 -0
  608. package/src/csvw/Csv2Rdf.ts +268 -0
  609. package/src/csvw/Datatype.ts +589 -0
  610. package/src/csvw/Metadata.ts +1523 -0
  611. package/src/csvw/Processor.ts +276 -0
  612. package/src/csvw/Report.ts +135 -0
  613. package/src/csvw/Table.ts +759 -0
  614. package/src/csvw/index.ts +22 -0
  615. package/src/csvw/internal/dateFormat.ts +202 -0
  616. package/src/csvw/internal/json.ts +104 -0
  617. package/src/csvw/internal/numberFormat.ts +369 -0
  618. package/src/csvw/internal/object.ts +23 -0
  619. package/src/csvw/internal/uriTemplate.ts +130 -0
  620. package/src/csvw/internal/url.ts +93 -0
  621. package/src/csvw/internal/vocab.ts +282 -0
  622. package/src/index.ts +40 -0
  623. package/src/internal/arbitrary.ts +148 -0
  624. package/src/internal/loop.ts +24 -0
  625. package/src/internal/pending.ts +20 -0
  626. package/src/internal/textDecoder.ts +183 -0
  627. package/src/jsonld/DocumentLoader.ts +512 -0
  628. package/src/jsonld/JsonLd.ts +847 -0
  629. package/src/jsonld/JsonLdError.ts +105 -0
  630. package/src/jsonld/index.ts +13 -0
  631. package/src/jsonld/internal/compact.ts +852 -0
  632. package/src/jsonld/internal/context.ts +781 -0
  633. package/src/jsonld/internal/expand.ts +614 -0
  634. package/src/jsonld/internal/flatten.ts +243 -0
  635. package/src/jsonld/internal/frame.ts +559 -0
  636. package/src/jsonld/internal/iri.ts +52 -0
  637. package/src/jsonld/internal/json.ts +19 -0
  638. package/src/jsonld/internal/linkHeader.ts +60 -0
  639. package/src/jsonld/internal/rdf.ts +481 -0
  640. package/src/jsonld/internal/util.ts +367 -0
  641. package/src/n3/Isomorphism.ts +476 -0
  642. package/src/n3/Mapping.ts +332 -0
  643. package/src/n3/Model.ts +696 -0
  644. package/src/n3/N3.ts +237 -0
  645. package/src/n3/Reasoner.ts +568 -0
  646. package/src/n3/Vocab.ts +111 -0
  647. package/src/n3/index.ts +21 -0
  648. package/src/n3/internal/builtins.ts +668 -0
  649. package/src/n3/internal/guards.ts +23 -0
  650. package/src/n3/internal/lists.ts +106 -0
  651. package/src/n3/internal/loop.ts +28 -0
  652. package/src/n3/internal/parser.ts +1032 -0
  653. package/src/n3/internal/writer.ts +344 -0
  654. package/src/ntriples/Grammar.ts +317 -0
  655. package/src/ntriples/Lexical.ts +321 -0
  656. package/src/ntriples/NQuads.ts +140 -0
  657. package/src/ntriples/NTriples.ts +143 -0
  658. package/src/ntriples/index.ts +14 -0
  659. package/src/ntriples/internal/codec.ts +229 -0
  660. package/src/ntriples/internal/lineParser.ts +326 -0
  661. package/src/ntriples/internal/loop.ts +14 -0
  662. package/src/rdfjson/RdfJson.ts +806 -0
  663. package/src/rdfjson/index.ts +9 -0
  664. package/src/rdfjson/internal/json.ts +19 -0
  665. package/src/rdfxml/RdfXml.ts +1408 -0
  666. package/src/rdfxml/Xml.ts +419 -0
  667. package/src/rdfxml/index.ts +11 -0
  668. package/src/rdfxml/internal/chars.ts +73 -0
  669. package/src/rdfxml/internal/loop.ts +24 -0
  670. package/src/rdfxml/internal/parser.ts +1265 -0
  671. package/src/shacl/Message.ts +102 -0
  672. package/src/shacl/Path.ts +483 -0
  673. package/src/shacl/Shapes.ts +913 -0
  674. package/src/shacl/Sparql.ts +128 -0
  675. package/src/shacl/ValidationReport.ts +438 -0
  676. package/src/shacl/Validator.ts +1156 -0
  677. package/src/shacl/Vocabulary.ts +180 -0
  678. package/src/shacl/index.ts +22 -0
  679. package/src/shacl/internal/compare.ts +128 -0
  680. package/src/shacl/internal/regex.ts +56 -0
  681. package/src/shex/SemAct.ts +197 -0
  682. package/src/shex/ShExC.ts +415 -0
  683. package/src/shex/ShExError.ts +71 -0
  684. package/src/shex/ShExJ.ts +893 -0
  685. package/src/shex/ShExR.ts +640 -0
  686. package/src/shex/ShapeMap.ts +385 -0
  687. package/src/shex/Structure.ts +467 -0
  688. package/src/shex/Validator.ts +395 -0
  689. package/src/shex/index.ts +24 -0
  690. package/src/shex/internal/engine.ts +682 -0
  691. package/src/shex/internal/iterate.ts +14 -0
  692. package/src/shex/internal/json.ts +12 -0
  693. package/src/shex/internal/lexer.ts +56 -0
  694. package/src/shex/internal/nodeConstraint.ts +368 -0
  695. package/src/shex/internal/shexcLexer.ts +387 -0
  696. package/src/shex/internal/shexcParser.ts +1312 -0
  697. package/src/shex/internal/tokens.ts +41 -0
  698. package/src/shex/internal/xpathRegex.ts +290 -0
  699. package/src/sparql/Algebra.ts +914 -0
  700. package/src/sparql/Ast.ts +1344 -0
  701. package/src/sparql/Bindings.ts +272 -0
  702. package/src/sparql/ClientErrors.ts +156 -0
  703. package/src/sparql/ClientFormats.ts +70 -0
  704. package/src/sparql/Engine.ts +699 -0
  705. package/src/sparql/Errors.ts +30 -0
  706. package/src/sparql/Expression.ts +360 -0
  707. package/src/sparql/Federation.ts +187 -0
  708. package/src/sparql/Functions.ts +689 -0
  709. package/src/sparql/Generator.ts +426 -0
  710. package/src/sparql/GraphStore.ts +341 -0
  711. package/src/sparql/Optimizer.ts +230 -0
  712. package/src/sparql/Options.ts +191 -0
  713. package/src/sparql/Parser.ts +173 -0
  714. package/src/sparql/Protocol.ts +342 -0
  715. package/src/sparql/ProtocolErrors.ts +113 -0
  716. package/src/sparql/QueryBuilder.ts +953 -0
  717. package/src/sparql/Results.ts +844 -0
  718. package/src/sparql/ResultsStream.ts +771 -0
  719. package/src/sparql/ServerFormats.ts +75 -0
  720. package/src/sparql/ServiceDescription.ts +130 -0
  721. package/src/sparql/SparqlClient.ts +947 -0
  722. package/src/sparql/SparqlServer.ts +528 -0
  723. package/src/sparql/Store.ts +311 -0
  724. package/src/sparql/TermSchema.ts +20 -0
  725. package/src/sparql/Testing.ts +114 -0
  726. package/src/sparql/Translate.ts +407 -0
  727. package/src/sparql/ai/Mcp.ts +43 -0
  728. package/src/sparql/ai/Tools.ts +481 -0
  729. package/src/sparql/ai/index.ts +11 -0
  730. package/src/sparql/index.ts +64 -0
  731. package/src/sparql/internal/evaluator.ts +947 -0
  732. package/src/sparql/internal/hash.ts +418 -0
  733. package/src/sparql/internal/json.ts +12 -0
  734. package/src/sparql/internal/lexer.ts +488 -0
  735. package/src/sparql/internal/loop.ts +24 -0
  736. package/src/sparql/internal/parser.ts +2215 -0
  737. package/src/sparql/internal/prefetch.ts +46 -0
  738. package/src/sparql/internal/stringMap.ts +39 -0
  739. package/src/sparql/internal/textResults.ts +226 -0
  740. package/src/sparql/internal/values.ts +550 -0
  741. package/src/sparql/shacl/Evaluator.ts +478 -0
  742. package/src/sparql/shacl/Query.ts +574 -0
  743. package/src/sparql/shacl/index.ts +12 -0
  744. package/src/sparql/sql/Dialect.ts +246 -0
  745. package/src/sparql/sql/SqlStore.ts +1080 -0
  746. package/src/sparql/sql/Translation.ts +1898 -0
  747. package/src/sparql/sql/index.ts +17 -0
  748. package/src/sparql/sql/internal/encoding.ts +313 -0
  749. package/src/turtle/Grammar.ts +286 -0
  750. package/src/turtle/Manifest.ts +215 -0
  751. package/src/turtle/TriG.ts +158 -0
  752. package/src/turtle/Turtle.ts +166 -0
  753. package/src/turtle/index.ts +14 -0
  754. package/src/turtle/internal/loop.ts +23 -0
  755. package/src/turtle/internal/parse.ts +112 -0
  756. package/src/turtle/internal/parser.ts +1303 -0
  757. package/src/turtle/internal/serialize.ts +79 -0
  758. package/src/turtle/internal/streamWriter.ts +128 -0
  759. package/src/turtle/internal/writer.ts +898 -0
  760. package/src/xmp/DublinCore.ts +147 -0
  761. package/src/xmp/Exif.ts +109 -0
  762. package/src/xmp/Extract.ts +351 -0
  763. package/src/xmp/Metadata.ts +703 -0
  764. package/src/xmp/Namespaces.ts +228 -0
  765. package/src/xmp/Packet.ts +297 -0
  766. package/src/xmp/Pdf.ts +99 -0
  767. package/src/xmp/PdfA.ts +280 -0
  768. package/src/xmp/Photoshop.ts +275 -0
  769. package/src/xmp/Tiff.ts +196 -0
  770. package/src/xmp/Xmp.ts +430 -0
  771. package/src/xmp/XmpBasic.ts +90 -0
  772. package/src/xmp/XmpMM.ts +82 -0
  773. package/src/xmp/XmpRights.ts +83 -0
  774. package/src/xmp/index.ts +36 -0
  775. package/src/xmp/internal/accessors.ts +72 -0
  776. package/src/xmp/internal/xml.ts +63 -0
@@ -0,0 +1,1312 @@
1
+ /**
2
+ * The ShEx compact syntax (ShExC) parser, producing ShExJ. It is written
3
+ * with `@thomasfosterau/effect-parse` as a compiled grammar over the tokens
4
+ * of `shexcLexer.ts` (whose IRIs are already resolved), followed by a pass
5
+ * over the declarations in document order for the checks that depend on
6
+ * what was declared before (duplicate labels, shape and triple expression
7
+ * labels). The construction of ShExJ objects mirrors the reference grammar
8
+ * (shex.js `ShExJison.jison`) so that the output matches the ShExJ
9
+ * representations of the shexTest suite.
10
+ *
11
+ * Like the reference grammar, the parser is LL(1): every choice is made by
12
+ * dispatching on the kind of the next token (and committing to it), never by
13
+ * trying alternatives in turn.
14
+ *
15
+ * @internal
16
+ */
17
+ import * as Compiler from '@thomasfosterau/effect-parse/Compiler';
18
+ import * as ParseError from '@thomasfosterau/effect-parse/ParseError';
19
+ import * as Parser from '@thomasfosterau/effect-parse/Parser';
20
+ import * as Token from '@thomasfosterau/effect-parse/Token';
21
+ import * as PrefixMap from '../../PrefixMap.ts';
22
+ import * as Arr from 'effect/Array';
23
+ import * as Match from 'effect/Match';
24
+ import * as MutableHashSet from 'effect/MutableHashSet';
25
+ import * as Option from 'effect/Option';
26
+ import * as Record from 'effect/Record';
27
+ import * as Result from 'effect/Result';
28
+ import type * as ShExJ from '../ShExJ.ts';
29
+ import { quote } from './lexer.ts';
30
+ import { resolve, type Tok, tokenize } from './shexcLexer.ts';
31
+ import * as Predicate from 'effect/Predicate';
32
+
33
+ const RDF_TYPE = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type';
34
+ const XSD = 'http://www.w3.org/2001/XMLSchema#';
35
+ const XSD_INTEGER = `${XSD}integer`;
36
+ const XSD_DECIMAL = `${XSD}decimal`;
37
+ const XSD_DOUBLE = `${XSD}double`;
38
+ const XSD_FLOAT = `${XSD}float`;
39
+ const XSD_BOOLEAN = `${XSD}boolean`;
40
+
41
+ const numericDatatypes = MutableHashSet.fromIterable(
42
+ [
43
+ 'integer',
44
+ 'decimal',
45
+ 'float',
46
+ 'double',
47
+ 'string',
48
+ 'boolean',
49
+ 'dateTime',
50
+ 'nonPositiveInteger',
51
+ 'negativeInteger',
52
+ 'long',
53
+ 'int',
54
+ 'short',
55
+ 'byte',
56
+ 'nonNegativeInteger',
57
+ 'unsignedLong',
58
+ 'unsignedInt',
59
+ 'unsignedShort',
60
+ 'unsignedByte',
61
+ 'positiveInteger',
62
+ ].map((l) => XSD + l),
63
+ );
64
+
65
+ const numericFacetNames = ['mininclusive', 'minexclusive', 'maxinclusive', 'maxexclusive'];
66
+
67
+ /** A placeholder for the empty shape `.` / `{ }` (omitted as a value expression). */
68
+ const EMPTY: ShExJ.Shape = { type: 'Shape' };
69
+
70
+ type Mutable<T> = { -readonly [K in keyof T]: T[K] };
71
+ type AnyShapeExpr = ShExJ.ShapeExprOrRef;
72
+
73
+ /** Options for the ShExC parser. */
74
+ export interface ParserOptions {
75
+ readonly baseIri: Option.Option<string>;
76
+ readonly prefixes: PrefixMap.PrefixMap;
77
+ }
78
+
79
+ /** The result of parsing ShExC. */
80
+ export interface ParserResult {
81
+ readonly schema: ShExJ.Schema;
82
+ readonly prefixes: PrefixMap.PrefixMap;
83
+ readonly baseIri: Option.Option<string>;
84
+ }
85
+
86
+ /** A parse error at a character offset. */
87
+ export interface ShExCError {
88
+ readonly message: string;
89
+ readonly offset: number;
90
+ }
91
+
92
+ /** An error found by the grammar, at a token index. */
93
+ interface SemanticError {
94
+ readonly message: string;
95
+ readonly at: number;
96
+ }
97
+
98
+ type P<A> = Parser.Parser<A, SemanticError, never, ReadonlyArray<Tok>>;
99
+
100
+ // -----------------------------------------------------------------------------
101
+ // Token parsers
102
+ // -----------------------------------------------------------------------------
103
+
104
+ /** A token of the given kind (see `Tok.kind`). */
105
+ const tok = (kind: string, label = `'${kind}'`): P<Tok> =>
106
+ Token.oneOf<ReadonlyArray<Tok>>((t) => t.kind === kind).pipe(Parser.expected(label));
107
+
108
+ const anyToken = Token.oneOf<ReadonlyArray<Tok>>(() => true);
109
+ const nextKind = Parser.peek(anyToken).pipe(Parser.map((t) => t.kind));
110
+
111
+ /**
112
+ * Chooses a parser by the kind of the next token, failing (without consuming
113
+ * input) when no case matches and there is no `otherwise`.
114
+ */
115
+ const select = <A, B = never>(
116
+ label: string,
117
+ cases: ReadonlyArray<readonly [ReadonlyArray<string>, P<A>]>,
118
+ otherwise?: P<B>,
119
+ ): P<A | B> => {
120
+ // The first case listing a kind wins, as `fromEntries` keeps the last entry for a key.
121
+ const record = Record.fromEntries(
122
+ Arr.flatMap(Arr.reverse(cases), ([kinds, p]) => Arr.map(kinds, (k) => [k, p] as const)),
123
+ );
124
+ const chosen: P<A | B> =
125
+ otherwise === undefined
126
+ ? Parser.dispatch(nextKind, record)
127
+ : Parser.dispatch(nextKind, record, otherwise);
128
+ return chosen.pipe(Parser.expected(label));
129
+ };
130
+
131
+ /** Fails with a semantic error at token index `at`. */
132
+ const failAt = <A>(message: string, at: number): Result.Result<A, SemanticError> =>
133
+ Result.fail({ message, at });
134
+
135
+ /** Whether the next token is of one of `kinds` (consumed if so). */
136
+ const accept = (...kinds: ReadonlyArray<string>): P<boolean> =>
137
+ Parser.opt(Token.oneOf<ReadonlyArray<Tok>>((t) => kinds.includes(t.kind))).pipe(
138
+ Parser.map(Option.isSome),
139
+ );
140
+
141
+ const IRI_KINDS = ['IRIREF', 'PNAME'];
142
+
143
+ /** The IRI of a resolved token (at token index `at`), or its resolution error. */
144
+ const tokenIri = (t: Tok, at: number): Result.Result<string, SemanticError> =>
145
+ Option.isNone(t.error) ? Result.succeed(t.iri) : failAt(t.error.value, at);
146
+
147
+ /** The IRI of an IRIREF or PNAME token, or the token's resolution error. */
148
+ const iri: P<string> = Parser.seq(
149
+ Parser.location,
150
+ Token.oneOf<ReadonlyArray<Tok>>((t) => t.kind === 'IRIREF' || t.kind === 'PNAME'),
151
+ ).pipe(
152
+ Parser.tryMap(([at, t]) => tokenIri(t, at)),
153
+ Parser.cut,
154
+ Parser.expected('an IRI'),
155
+ );
156
+
157
+ const blankNode = tok('BLANK_NODE_LABEL', 'a blank node').pipe(Parser.map((t) => t.text));
158
+
159
+ /** shapeExprLabel / tripleExprLabel: iri | blankNode */
160
+ const label: P<string> = select('an IRI or a blank node', [
161
+ [IRI_KINDS, iri],
162
+ [['BLANK_NODE_LABEL'], blankNode],
163
+ ]);
164
+
165
+ const predicate: P<string> = select('a predicate', [
166
+ [['a'], anyToken.pipe(Parser.as(RDF_TYPE))],
167
+ [IRI_KINDS, iri],
168
+ ]);
169
+
170
+ const LITERAL_KINDS = ['STRING', 'LANG_STRING', 'INTEGER', 'DECIMAL', 'DOUBLE', 'true', 'false'];
171
+
172
+ const literal: P<ShExJ.ObjectLiteral> = select('a literal', [
173
+ [['INTEGER'], anyToken.pipe(Parser.map((t) => ({ value: t.text, type: XSD_INTEGER })))],
174
+ [['DECIMAL'], anyToken.pipe(Parser.map((t) => ({ value: t.text, type: XSD_DECIMAL })))],
175
+ [['DOUBLE'], anyToken.pipe(Parser.map((t) => ({ value: t.text, type: XSD_DOUBLE })))],
176
+ [
177
+ ['LANG_STRING'],
178
+ anyToken.pipe(Parser.map((t) => ({ value: t.text, language: t.suffix.toLowerCase() }))),
179
+ ],
180
+ [
181
+ ['STRING'],
182
+ Parser.seq(anyToken, Parser.opt(Parser.preceded(tok('^^'), Parser.cut(iri)))).pipe(
183
+ Parser.map(([t, datatype]): ShExJ.ObjectLiteral =>
184
+ Option.isSome(datatype) ? { value: t.text, type: datatype.value } : { value: t.text },
185
+ ),
186
+ ),
187
+ ],
188
+ [['true', 'false'], anyToken.pipe(Parser.map((t) => ({ value: t.text, type: XSD_BOOLEAN })))],
189
+ ]);
190
+
191
+ // -----------------------------------------------------------------------------
192
+ // Shape expression helpers
193
+ // -----------------------------------------------------------------------------
194
+
195
+ /**
196
+ * A shape expression, and whether it was written in parentheses: a
197
+ * parenthesised `AND` is not merged into an enclosing `AND`.
198
+ */
199
+ interface Atom {
200
+ readonly e: AnyShapeExpr;
201
+ readonly nested: boolean;
202
+ }
203
+
204
+ const plain = (e: AnyShapeExpr): Atom => ({ e, nested: false });
205
+
206
+ const isJunction = (e: AnyShapeExpr): e is ShExJ.ShapeAnd | ShExJ.ShapeOr =>
207
+ !Predicate.isString(e) && (e.type === 'ShapeAnd' || e.type === 'ShapeOr');
208
+
209
+ const junction = (
210
+ type: 'ShapeAnd' | 'ShapeOr',
211
+ atom: Atom,
212
+ juncts: ReadonlyArray<AnyShapeExpr>,
213
+ ): AnyShapeExpr => {
214
+ if (Arr.isReadonlyArrayEmpty(juncts)) return atom.e;
215
+ const e = atom.e;
216
+ if (isJunction(e) && e.type === type && !atom.nested) {
217
+ return { ...e, shapeExprs: e.shapeExprs.concat(juncts) };
218
+ }
219
+ return { type, shapeExprs: [e, ...juncts] };
220
+ };
221
+
222
+ /**
223
+ * What follows the first atom of a shape expression: `(OR shapeAnd)+` or
224
+ * `(AND shapeNot)+ (OR shapeAnd)*`. The atom is inserted in front of the
225
+ * disjuncts or the conjuncts respectively.
226
+ */
227
+ type Rest =
228
+ | { readonly _tag: 'Or'; readonly ors: ReadonlyArray<AnyShapeExpr> }
229
+ | {
230
+ readonly _tag: 'And';
231
+ readonly ands: ReadonlyArray<AnyShapeExpr>;
232
+ readonly ors: ReadonlyArray<AnyShapeExpr>;
233
+ };
234
+
235
+ const isAndRest = Predicate.isTagged('And');
236
+
237
+ const prepend = (rest: Rest, atoms: ReadonlyArray<AnyShapeExpr>): AnyShapeExpr => {
238
+ if (!isAndRest(rest)) return { type: 'ShapeOr', shapeExprs: [...atoms, ...rest.ors] };
239
+ const and: ShExJ.ShapeAnd = { type: 'ShapeAnd', shapeExprs: [...atoms, ...rest.ands] };
240
+ return Arr.isReadonlyArrayNonEmpty(rest.ors)
241
+ ? { type: 'ShapeOr', shapeExprs: [and, ...rest.ors] }
242
+ : and;
243
+ };
244
+
245
+ const prependAtom = (atom: Atom, rest: Option.Option<Rest>): AnyShapeExpr =>
246
+ Option.match(rest, {
247
+ onNone: () => atom.e,
248
+ onSome: (r) => {
249
+ const e = atom.e;
250
+ return !Predicate.isString(e) &&
251
+ e.type === 'ShapeAnd' &&
252
+ isAndRest(r) &&
253
+ Arr.isReadonlyArrayEmpty(r.ors) &&
254
+ !atom.nested
255
+ ? prepend(r, e.shapeExprs)
256
+ : prepend(r, [e]);
257
+ },
258
+ });
259
+
260
+ // -----------------------------------------------------------------------------
261
+ // Annotations, semantic actions and cardinalities
262
+ // -----------------------------------------------------------------------------
263
+
264
+ const annotations: P<Array<ShExJ.Annotation>> = Parser.repeat(
265
+ Parser.preceded(
266
+ tok('//'),
267
+ Parser.cut(
268
+ Parser.seq(predicate, select('an IRI or a literal', [[IRI_KINDS, iri]], literal)).pipe(
269
+ Parser.map(([pred, object]): ShExJ.Annotation => ({
270
+ type: 'Annotation',
271
+ predicate: pred,
272
+ object,
273
+ })),
274
+ ),
275
+ ),
276
+ ),
277
+ );
278
+
279
+ const codeDecls: P<Array<ShExJ.SemAct>> = Parser.repeat(
280
+ Parser.preceded(
281
+ tok('%'),
282
+ Parser.cut(
283
+ Parser.seq(
284
+ iri,
285
+ select('code or %', [
286
+ [['CODE'], anyToken.pipe(Parser.map((t) => Option.some(t.text)))],
287
+ [['%'], anyToken.pipe(Parser.as(Option.none<string>()))],
288
+ ]),
289
+ ).pipe(
290
+ Parser.map(([name, code]): ShExJ.SemAct =>
291
+ Option.match(code, {
292
+ onNone: () => ({ type: 'SemAct', name }),
293
+ onSome: (c) => ({ type: 'SemAct', name, code: c }),
294
+ }),
295
+ ),
296
+ ),
297
+ ),
298
+ ),
299
+ { min: 1 },
300
+ );
301
+
302
+ const semanticActions: P<Option.Option<Array<ShExJ.SemAct>>> = Parser.opt(codeDecls);
303
+
304
+ const cardinality: P<Option.Option<{ min: number; max: number }>> = Parser.opt(
305
+ select('a cardinality', [
306
+ [['*'], anyToken.pipe(Parser.as({ min: 0, max: -1 }))],
307
+ [['+'], anyToken.pipe(Parser.as({ min: 1, max: -1 }))],
308
+ [['?'], anyToken.pipe(Parser.as({ min: 0, max: 1 }))],
309
+ [['REPEAT_RANGE'], anyToken.pipe(Parser.map((t) => ({ min: t.min, max: t.max })))],
310
+ ]),
311
+ );
312
+
313
+ // -----------------------------------------------------------------------------
314
+ // Node constraints
315
+ // -----------------------------------------------------------------------------
316
+
317
+ const integer = Parser.cut(tok('INTEGER', 'an integer')).pipe(
318
+ Parser.map((t) => parseInt(t.text, 10)),
319
+ );
320
+
321
+ const rawNumeric: P<number> = select('a numeric literal', [
322
+ [['INTEGER'], anyToken.pipe(Parser.map((t) => parseInt(t.text, 10)))],
323
+ [['DECIMAL', 'DOUBLE'], anyToken.pipe(Parser.map((t) => parseFloat(t.text)))],
324
+ [
325
+ ['STRING'],
326
+ Parser.seq(
327
+ anyToken,
328
+ Parser.cut(Parser.preceded(tok('^^'), Parser.seq(Parser.location, iri))),
329
+ ).pipe(
330
+ Parser.tryMap(([t, [at, dt]]) => {
331
+ const value = t.text;
332
+ if (dt === XSD_DECIMAL || dt === XSD_FLOAT || dt === XSD_DOUBLE) {
333
+ return Result.succeed(parseFloat(value));
334
+ }
335
+ if (MutableHashSet.has(numericDatatypes, dt)) return Result.succeed(parseInt(value, 10));
336
+ return failAt<number>(`numeric range facet expected numeric datatype instead of ${dt}`, at);
337
+ }),
338
+ Parser.cut,
339
+ ),
340
+ ],
341
+ ]);
342
+
343
+ type Facet = readonly [key: string, value: number | string, at: number, flags?: string];
344
+
345
+ const LENGTH_FACETS = ['LENGTH', 'MINLENGTH', 'MAXLENGTH'];
346
+ const DIGITS_FACETS = ['TOTALDIGITS', 'FRACTIONDIGITS'];
347
+ const RANGE_FACETS = ['MININCLUSIVE', 'MINEXCLUSIVE', 'MAXINCLUSIVE', 'MAXEXCLUSIVE'];
348
+ const NUMERIC_FACETS = [...DIGITS_FACETS, ...RANGE_FACETS];
349
+
350
+ /** Facet name → its value, as the facets are read. */
351
+ interface FacetValues {
352
+ [facet: string]: number | string;
353
+ }
354
+
355
+ type FacetCase = readonly [ReadonlyArray<string>, P<Facet>];
356
+
357
+ const integerFacet: P<Facet> = Parser.seq(Parser.location, anyToken, integer).pipe(
358
+ Parser.map(([at, t, n]): Facet => [t.text.toLowerCase(), n, at]),
359
+ );
360
+
361
+ const stringFacetCases: ReadonlyArray<FacetCase> = [
362
+ [
363
+ ['REGEXP'],
364
+ Parser.seq(Parser.location, anyToken).pipe(
365
+ Parser.map(([at, t]): Facet => ['pattern', t.text, at, t.suffix]),
366
+ ),
367
+ ],
368
+ [LENGTH_FACETS, integerFacet],
369
+ ];
370
+
371
+ const numericFacetCases: ReadonlyArray<FacetCase> = [
372
+ [DIGITS_FACETS, integerFacet],
373
+ [
374
+ RANGE_FACETS,
375
+ Parser.seq(Parser.location, anyToken, Parser.cut(rawNumeric)).pipe(
376
+ Parser.map(([at, t, n]): Facet => [t.text.toLowerCase(), n, at]),
377
+ ),
378
+ ],
379
+ ];
380
+
381
+ const noFacets = (): Result.Result<FacetValues, SemanticError> => Result.succeed({});
382
+
383
+ const facets = (strings: boolean, numerics: boolean): P<Mutable<ShExJ.Facets>> =>
384
+ Parser.repeat(
385
+ select('a facet', [
386
+ ...(strings ? stringFacetCases : []),
387
+ ...(numerics ? numericFacetCases : []),
388
+ ]),
389
+ ).pipe(
390
+ Parser.tryMap((list) =>
391
+ Arr.reduce(list, noFacets(), (acc, [key, value, at, flags]) =>
392
+ Result.flatMap(acc, (out) => {
393
+ if (key in out) return failAt<FacetValues>(`facet ${key} defined multiple times`, at);
394
+ out[key] = value;
395
+ if (flags !== undefined && flags !== '') out['flags'] = flags;
396
+ return Result.succeed(out);
397
+ }),
398
+ ),
399
+ ),
400
+ Parser.cut,
401
+ );
402
+
403
+ // Value sets ---------------------------------------------------------------------
404
+
405
+ const tilde = accept('~');
406
+
407
+ const exclusion = <A>(p: P<A>): P<A> => Parser.preceded(tok('-'), Parser.cut(p));
408
+
409
+ const iriExclusion: P<string | ShExJ.IriStem> = exclusion(
410
+ Parser.seq(iri, tilde).pipe(
411
+ Parser.map(([base, stem]) => (stem ? { type: 'IriStem', stem: base } : base)),
412
+ ),
413
+ );
414
+
415
+ const literalExclusion: P<string | ShExJ.LiteralStem> = exclusion(
416
+ Parser.seq(literal, tilde).pipe(
417
+ Parser.map(([lit, stem]) => (stem ? { type: 'LiteralStem', stem: lit.value } : lit.value)),
418
+ ),
419
+ );
420
+
421
+ const langTag = tok('LANGTAG', 'a language tag').pipe(Parser.map((t) => t.text));
422
+
423
+ const languageExclusion: P<string | ShExJ.LanguageStem> = exclusion(
424
+ Parser.seq(langTag, tilde).pipe(
425
+ Parser.map(([tag, stem]) => (stem ? { type: 'LanguageStem', stem: tag } : tag)),
426
+ ),
427
+ );
428
+
429
+ const stemmed = <A, X>(
430
+ head: P<A>,
431
+ exclude: P<X>,
432
+ build: (head: A, stem: boolean, exclusions: Array<X>) => ShExJ.ValueSetValue,
433
+ ): P<ShExJ.ValueSetValue> =>
434
+ Parser.seq(head, Parser.opt(Parser.preceded(tok('~'), Parser.repeat(exclude)))).pipe(
435
+ Parser.map(([h, exclusions]) =>
436
+ build(
437
+ h,
438
+ Option.isSome(exclusions),
439
+ Option.getOrElse(exclusions, () => []),
440
+ ),
441
+ ),
442
+ );
443
+
444
+ /** The exclusions after a `.` wildcard: their kind is chosen by the first one. */
445
+ // SAFETY: each branch builds the value set value for its exclusion kind.
446
+ const wildcardExclusions: P<ShExJ.ValueSetValue> = Parser.preceded(
447
+ Parser.peek(tok('-')),
448
+ Parser.dispatch(
449
+ Parser.peek(Parser.preceded(anyToken, anyToken)).pipe(Parser.map((t) => t.kind)),
450
+ {
451
+ LANGTAG: Parser.repeat(languageExclusion).pipe(
452
+ Parser.map((exclusions): ShExJ.ValueSetValue => ({
453
+ type: 'LanguageStemRange',
454
+ stem: { type: 'Wildcard' },
455
+ exclusions,
456
+ })),
457
+ ),
458
+ ...Record.fromEntries(
459
+ Arr.map(
460
+ IRI_KINDS,
461
+ (k) =>
462
+ [
463
+ k,
464
+ Parser.repeat(iriExclusion).pipe(
465
+ Parser.map((exclusions): ShExJ.ValueSetValue => ({
466
+ type: 'IriStemRange',
467
+ stem: { type: 'Wildcard' },
468
+ exclusions,
469
+ })),
470
+ ),
471
+ ] as const,
472
+ ),
473
+ ),
474
+ },
475
+ Parser.repeat(literalExclusion).pipe(
476
+ Parser.map((exclusions): ShExJ.ValueSetValue => ({
477
+ type: 'LiteralStemRange',
478
+ stem: { type: 'Wildcard' },
479
+ exclusions,
480
+ })),
481
+ ),
482
+ ),
483
+ ).pipe(Parser.expected("'-'"));
484
+
485
+ const valueSetValue: P<ShExJ.ValueSetValue> = select('a value set value', [
486
+ [
487
+ IRI_KINDS,
488
+ Parser.cut(
489
+ stemmed(iri, iriExclusion, (stem, isStem, exclusions) =>
490
+ !isStem
491
+ ? stem
492
+ : Arr.isReadonlyArrayNonEmpty(exclusions)
493
+ ? { type: 'IriStemRange', stem, exclusions }
494
+ : { type: 'IriStem', stem },
495
+ ),
496
+ ),
497
+ ],
498
+ [
499
+ LITERAL_KINDS,
500
+ Parser.cut(
501
+ stemmed(literal, literalExclusion, (lit, isStem, exclusions) =>
502
+ !isStem
503
+ ? lit
504
+ : Arr.isReadonlyArrayNonEmpty(exclusions)
505
+ ? { type: 'LiteralStemRange', stem: lit.value, exclusions }
506
+ : { type: 'LiteralStem', stem: lit.value },
507
+ ),
508
+ ),
509
+ ],
510
+ [
511
+ ['LANGTAG'],
512
+ Parser.cut(
513
+ stemmed(langTag, languageExclusion, (tag, isStem, exclusions) =>
514
+ !isStem
515
+ ? { type: 'Language', languageTag: tag }
516
+ : Arr.isReadonlyArrayNonEmpty(exclusions)
517
+ ? { type: 'LanguageStemRange', stem: tag, exclusions }
518
+ : { type: 'LanguageStem', stem: tag },
519
+ ),
520
+ ),
521
+ ],
522
+ [
523
+ ['@'],
524
+ Parser.preceded(
525
+ anyToken,
526
+ Parser.cut(Parser.preceded(tok('~'), Parser.repeat(languageExclusion))),
527
+ ).pipe(
528
+ Parser.map((exclusions): ShExJ.ValueSetValue =>
529
+ Arr.isReadonlyArrayNonEmpty(exclusions)
530
+ ? { type: 'LanguageStemRange', stem: '', exclusions }
531
+ : { type: 'LanguageStem', stem: '' },
532
+ ),
533
+ ),
534
+ ],
535
+ [['.'], Parser.preceded(anyToken, Parser.cut(wildcardExclusions))],
536
+ ]);
537
+
538
+ const valueSet: P<Array<ShExJ.ValueSetValue>> = Parser.delimited(
539
+ tok('['),
540
+ Parser.cut(Parser.repeat(valueSetValue)),
541
+ Parser.cut(tok(']')),
542
+ );
543
+
544
+ const litInlineNodeConstraint: P<ShExJ.NodeConstraint> = select('a node constraint', [
545
+ [
546
+ ['LITERAL'],
547
+ Parser.preceded(anyToken, facets(true, true)).pipe(
548
+ Parser.map((f): ShExJ.NodeConstraint => ({
549
+ type: 'NodeConstraint',
550
+ nodeKind: 'literal',
551
+ ...f,
552
+ })),
553
+ ),
554
+ ],
555
+ [
556
+ IRI_KINDS,
557
+ Parser.seq(Parser.location, iri, facets(true, true)).pipe(
558
+ Parser.tryMap(([at, datatype, f]) =>
559
+ Option.match(
560
+ MutableHashSet.has(numericDatatypes, datatype)
561
+ ? Option.none()
562
+ : Arr.findFirst(numericFacetNames, (name) => name in f),
563
+ {
564
+ onNone: () =>
565
+ Result.succeed<ShExJ.NodeConstraint>({ type: 'NodeConstraint', datatype, ...f }),
566
+ onSome: (name) =>
567
+ failAt<ShExJ.NodeConstraint>(
568
+ `facet ${name} not allowed for unknown datatype ${datatype}`,
569
+ at,
570
+ ),
571
+ },
572
+ ),
573
+ ),
574
+ Parser.cut,
575
+ ),
576
+ ],
577
+ [
578
+ ['['],
579
+ Parser.terminated(valueSet, facets(true, true)).pipe(
580
+ Parser.map((values): ShExJ.NodeConstraint => ({ type: 'NodeConstraint', values })),
581
+ ),
582
+ ],
583
+ [
584
+ NUMERIC_FACETS,
585
+ facets(false, true).pipe(
586
+ Parser.map((f): ShExJ.NodeConstraint => ({ type: 'NodeConstraint', ...f })),
587
+ ),
588
+ ],
589
+ ]);
590
+
591
+ const NODE_KINDS = ['IRI', 'BNODE', 'NONLITERAL'];
592
+ const NON_LIT_KINDS = [...NODE_KINDS, 'LENGTH', 'MINLENGTH', 'MAXLENGTH', 'REGEXP'];
593
+ const LIT_KINDS = ['LITERAL', ...NUMERIC_FACETS, ...IRI_KINDS, '['];
594
+
595
+ const nodeKindOf = (kind: string): ShExJ.NodeKind =>
596
+ kind === 'IRI' ? 'iri' : kind === 'BNODE' ? 'bnode' : 'nonliteral';
597
+
598
+ const nonLitInlineNodeConstraint: P<ShExJ.NodeConstraint> = Parser.seq(
599
+ Parser.opt(select('a node kind', [[NODE_KINDS, anyToken.pipe(Parser.map((t) => t.text))]])),
600
+ facets(true, false),
601
+ ).pipe(
602
+ Parser.map(([kind, f]): ShExJ.NodeConstraint =>
603
+ Option.isSome(kind)
604
+ ? { type: 'NodeConstraint', nodeKind: nodeKindOf(kind.value), ...f }
605
+ : { type: 'NodeConstraint', ...f },
606
+ ),
607
+ );
608
+
609
+ /** A non-literal node constraint, if one starts here. */
610
+ const nonLitNodeConstraintOpt: P<Option.Option<ShExJ.NodeConstraint>> = Parser.opt(
611
+ select('a node constraint', [[NON_LIT_KINDS, Parser.cut(nonLitInlineNodeConstraint)]]),
612
+ );
613
+
614
+ const withAnnotations = (nc: P<ShExJ.NodeConstraint>): P<ShExJ.NodeConstraint> =>
615
+ Parser.seq(nc, annotations, semanticActions).pipe(
616
+ Parser.map(([constraint, annots, semActs]) => {
617
+ if (Arr.isReadonlyArrayEmpty(annots) && Option.isNone(semActs)) return constraint;
618
+ const out: Mutable<ShExJ.NodeConstraint> = constraint;
619
+ if (Arr.isReadonlyArrayNonEmpty(annots)) out.annotations = annots;
620
+ if (Option.isSome(semActs)) out.semActs = semActs.value;
621
+ return out;
622
+ }),
623
+ );
624
+
625
+ /** A non-literal node constraint with its annotations, if one starts here. */
626
+ const annotatedNonLitNodeConstraintOpt: P<Option.Option<ShExJ.NodeConstraint>> = Parser.opt(
627
+ select('a node constraint', [
628
+ [NON_LIT_KINDS, Parser.cut(withAnnotations(nonLitInlineNodeConstraint))],
629
+ ]),
630
+ );
631
+
632
+ // -----------------------------------------------------------------------------
633
+ // Shape expressions
634
+ // -----------------------------------------------------------------------------
635
+
636
+ const REF_KINDS = ['ATPNAME', '@'];
637
+ const SHAPE_DEF_KINDS = ['{', '&', 'EXTENDS', 'EXTRA', 'CLOSED'];
638
+
639
+ const shapeRef: P<string> = select('a shape reference', [
640
+ [
641
+ ['ATPNAME'],
642
+ Parser.seq(Parser.location, anyToken).pipe(
643
+ Parser.tryMap(([at, t]) => tokenIri(t, at)),
644
+ Parser.cut,
645
+ ),
646
+ ],
647
+ [['@'], Parser.preceded(anyToken, Parser.cut(label))],
648
+ ]);
649
+
650
+ const shapeExpressionBody: P<AnyShapeExpr> = Parser.suspend(() => shapeExpressionBodyDef);
651
+ const tripleExpression: P<ShExJ.TripleExprOrRef> = Parser.suspend(() => tripleExpressionDef);
652
+ const extendsShapeOr: P<AnyShapeExpr> = Parser.suspend(() => extendsShapeOrDef);
653
+ const inlineShapeExpression: P<AnyShapeExpr> = Parser.suspend(() => inlineShapeExpressionDef);
654
+
655
+ const parenthesised: P<Atom> = Parser.delimited(
656
+ anyToken,
657
+ Parser.cut(shapeExpressionBody),
658
+ Parser.cut(tok(')')),
659
+ ).pipe(Parser.map((e) => ({ e, nested: true })));
660
+
661
+ const empty: P<Atom> = anyToken.pipe(Parser.as(plain(EMPTY)));
662
+
663
+ type Qualifier =
664
+ | { readonly _tag: 'Extends'; readonly e: AnyShapeExpr }
665
+ | { readonly _tag: 'Extra'; readonly predicates: Array<string> }
666
+ | { readonly _tag: 'Closed' };
667
+
668
+ const inlineShapeDefinition: P<ShExJ.Shape> = Parser.seq(
669
+ Parser.repeat(
670
+ select<Qualifier>('a shape qualifier', [
671
+ [
672
+ ['EXTENDS', '&'],
673
+ Parser.preceded(anyToken, Parser.cut(extendsShapeOr)).pipe(
674
+ Parser.map((e): Qualifier => ({ _tag: 'Extends', e })),
675
+ ),
676
+ ],
677
+ [
678
+ ['EXTRA'],
679
+ Parser.preceded(anyToken, Parser.cut(Parser.repeat(predicate, { min: 1 }))).pipe(
680
+ Parser.map((predicates): Qualifier => ({ _tag: 'Extra', predicates })),
681
+ ),
682
+ ],
683
+ [['CLOSED'], anyToken.pipe(Parser.as<Qualifier>({ _tag: 'Closed' }))],
684
+ ]),
685
+ ),
686
+ Parser.delimited(
687
+ Parser.cut(tok('{')),
688
+ select(
689
+ 'a triple expression',
690
+ [[['}'], Parser.succeed(Option.none<ShExJ.TripleExprOrRef>())]],
691
+ Parser.cut(tripleExpression).pipe(Parser.map(Option.some)),
692
+ ),
693
+ Parser.cut(tok('}')),
694
+ ),
695
+ ).pipe(
696
+ Parser.map(([qualifiers, expression]): ShExJ.Shape => {
697
+ if (Option.isNone(expression) && Arr.isReadonlyArrayEmpty(qualifiers)) return EMPTY;
698
+ const extendsList = Arr.filterMap(qualifiers, (q) =>
699
+ Predicate.isTagged(q, 'Extends') ? Result.succeed(q.e) : Result.failVoid,
700
+ );
701
+ const extra = Arr.flatMap(qualifiers, (q) =>
702
+ Predicate.isTagged(q, 'Extra') ? q.predicates : [],
703
+ );
704
+ const shape: Mutable<ShExJ.Shape> = { type: 'Shape' };
705
+ if (Option.isSome(expression)) shape.expression = expression.value;
706
+ if (Arr.isReadonlyArrayNonEmpty(extendsList)) shape.extends = extendsList;
707
+ if (Arr.some(qualifiers, (q) => Predicate.isTagged(q, 'Extra'))) shape.extra = extra;
708
+ if (Arr.some(qualifiers, (q) => Predicate.isTagged(q, 'Closed'))) shape.closed = true;
709
+ return shape;
710
+ }),
711
+ );
712
+
713
+ const shapeDefinition: P<AnyShapeExpr> = Parser.seq(
714
+ inlineShapeDefinition,
715
+ annotations,
716
+ semanticActions,
717
+ ).pipe(
718
+ Parser.map(([def, annots, semActs]) => {
719
+ const out: Mutable<ShExJ.Shape> = def === EMPTY ? { type: 'Shape' } : def;
720
+ if (Arr.isReadonlyArrayNonEmpty(annots)) out.annotations = annots;
721
+ if (Option.isSome(semActs)) out.semActs = semActs.value;
722
+ return out;
723
+ }),
724
+ );
725
+
726
+ const shapeOrRef: P<AnyShapeExpr> = select(
727
+ 'a shape definition or reference',
728
+ [[REF_KINDS, shapeRef]],
729
+ shapeDefinition,
730
+ );
731
+
732
+ const inlineShapeOrRef: P<AnyShapeExpr> = select(
733
+ 'a shape definition or reference',
734
+ [[REF_KINDS, shapeRef]],
735
+ inlineShapeDefinition,
736
+ );
737
+
738
+ /** A shape definition or reference, if one starts here. */
739
+ const shapeOrRefOpt = (p: P<AnyShapeExpr>): P<Option.Option<AnyShapeExpr>> =>
740
+ Parser.opt(
741
+ select('a shape definition or reference', [
742
+ [[...SHAPE_DEF_KINDS, ...REF_KINDS], Parser.cut(p)],
743
+ ]),
744
+ );
745
+
746
+ /** A node constraint, conjoined with the shape definition or reference after it if any. */
747
+ const andRef = (nc: ShExJ.NodeConstraint, ref: Option.Option<AnyShapeExpr>): AnyShapeExpr =>
748
+ Option.isSome(ref) ? { type: 'ShapeAnd', shapeExprs: [{ ...nc }, ref.value] } : nc;
749
+
750
+ /** shapeAtom (with `allowRef`) and shapeAtomNoRef. */
751
+ const shapeAtom = (allowRef: boolean): P<Atom> =>
752
+ select('a shape expression', [
753
+ [
754
+ NON_LIT_KINDS,
755
+ Parser.cut(
756
+ Parser.seq(withAnnotations(nonLitInlineNodeConstraint), shapeOrRefOpt(shapeOrRef)).pipe(
757
+ Parser.map(([nc, ref]) => plain(andRef(nc, ref))),
758
+ ),
759
+ ),
760
+ ],
761
+ [LIT_KINDS, Parser.cut(withAnnotations(litInlineNodeConstraint)).pipe(Parser.map(plain))],
762
+ [
763
+ allowRef ? [...SHAPE_DEF_KINDS, ...REF_KINDS] : SHAPE_DEF_KINDS,
764
+ Parser.cut(
765
+ Parser.seq(shapeOrRef, annotatedNonLitNodeConstraintOpt).pipe(
766
+ Parser.map(([sor, nc]) =>
767
+ plain(
768
+ Option.match(nc, {
769
+ onNone: () => sor,
770
+ onSome: (c) => junction('ShapeAnd', plain(sor), [c]),
771
+ }),
772
+ ),
773
+ ),
774
+ ),
775
+ ),
776
+ ],
777
+ [['('], parenthesised],
778
+ [['.'], empty],
779
+ ]);
780
+
781
+ const shapeNot: P<Atom> = select(
782
+ 'a shape expression',
783
+ [
784
+ [
785
+ ['NOT'],
786
+ Parser.preceded(anyToken, Parser.cut(shapeAtom(true))).pipe(
787
+ Parser.map((a) => plain({ type: 'ShapeNot', shapeExpr: a.e })),
788
+ ),
789
+ ],
790
+ ],
791
+ shapeAtom(true),
792
+ );
793
+
794
+ const shapeAnd: P<AnyShapeExpr> = Parser.seq(
795
+ shapeNot,
796
+ Parser.repeat(Parser.preceded(tok('AND'), Parser.cut(shapeNot))),
797
+ ).pipe(
798
+ Parser.map(([first, rest]) =>
799
+ junction(
800
+ 'ShapeAnd',
801
+ first,
802
+ rest.map((a) => a.e),
803
+ ),
804
+ ),
805
+ );
806
+
807
+ const ors = Parser.repeat(Parser.preceded(tok('OR'), Parser.cut(shapeAnd)));
808
+
809
+ const shapeOrRest: P<Rest> = select("'AND' or 'OR'", [
810
+ [['OR'], ors.pipe(Parser.map((operands): Rest => ({ _tag: 'Or', ors: operands })))],
811
+ [
812
+ ['AND'],
813
+ Parser.seq(Parser.repeat(Parser.preceded(tok('AND'), Parser.cut(shapeNot))), ors).pipe(
814
+ Parser.map(([conjuncts, operands]): Rest => ({
815
+ _tag: 'And',
816
+ ands: Arr.flatMap(conjuncts, (c) =>
817
+ !Predicate.isString(c.e) && c.e.type === 'ShapeAnd' && !c.nested ? c.e.shapeExprs : [c.e],
818
+ ),
819
+ ors: operands,
820
+ })),
821
+ ),
822
+ ],
823
+ ]);
824
+
825
+ /**
826
+ * shapeExpression ::= NOT? shapeAtomNoRef shapeOr? | NOT shapeRef shapeOr? | shapeRef shapeOr
827
+ */
828
+ const shapeExpressionBodyDef: P<AnyShapeExpr> = select(
829
+ 'a shape expression',
830
+ [
831
+ [
832
+ ['NOT'],
833
+ Parser.preceded(
834
+ anyToken,
835
+ Parser.cut(
836
+ select(
837
+ 'a shape expression',
838
+ [
839
+ [
840
+ REF_KINDS,
841
+ Parser.seq(shapeRef, Parser.opt(shapeOrRest)).pipe(
842
+ Parser.map(([ref, rest]) =>
843
+ prependAtom(plain({ type: 'ShapeNot', shapeExpr: ref }), rest),
844
+ ),
845
+ ),
846
+ ],
847
+ ],
848
+ Parser.seq(shapeAtom(false), Parser.opt(shapeOrRest)).pipe(
849
+ Parser.map(([a, rest]) =>
850
+ prependAtom(plain({ type: 'ShapeNot', shapeExpr: a.e }), rest),
851
+ ),
852
+ ),
853
+ ),
854
+ ),
855
+ ),
856
+ ],
857
+ [
858
+ REF_KINDS,
859
+ Parser.seq(shapeRef, Parser.cut(shapeOrRest)).pipe(
860
+ Parser.map(([ref, rest]) => prepend(rest, [ref])),
861
+ ),
862
+ ],
863
+ ],
864
+ Parser.seq(shapeAtom(false), Parser.opt(shapeOrRest)).pipe(
865
+ Parser.map(([a, rest]) => prependAtom(a, rest)),
866
+ ),
867
+ );
868
+
869
+ // Inline shape expressions -----------------------------------------------------
870
+
871
+ /** The atoms of inline and EXTENDS shape expressions, which differ in one case. */
872
+ const inlineAtom = (extendsAtom: boolean): P<Atom> =>
873
+ select('a shape expression', [
874
+ [
875
+ NON_LIT_KINDS,
876
+ Parser.cut(
877
+ extendsAtom
878
+ ? Parser.seq(nonLitInlineNodeConstraint, inlineShapeOrRef).pipe(
879
+ Parser.map(([nc, ref]) => plain({ type: 'ShapeAnd', shapeExprs: [{ ...nc }, ref] })),
880
+ )
881
+ : Parser.seq(nonLitInlineNodeConstraint, shapeOrRefOpt(inlineShapeOrRef)).pipe(
882
+ Parser.map(([nc, ref]) => plain(andRef(nc, ref))),
883
+ ),
884
+ ),
885
+ ],
886
+ [LIT_KINDS, Parser.cut(litInlineNodeConstraint).pipe(Parser.map(plain))],
887
+ [
888
+ [...SHAPE_DEF_KINDS, ...REF_KINDS],
889
+ Parser.cut(
890
+ Parser.seq(inlineShapeOrRef, nonLitNodeConstraintOpt).pipe(
891
+ Parser.map(([sor, nc]) =>
892
+ plain(
893
+ Option.match(nc, {
894
+ onNone: () => sor,
895
+ onSome: (c): AnyShapeExpr => ({ type: 'ShapeAnd', shapeExprs: [sor, c] }),
896
+ }),
897
+ ),
898
+ ),
899
+ ),
900
+ ),
901
+ ],
902
+ [['('], parenthesised],
903
+ [['.'], empty],
904
+ ]);
905
+
906
+ const junctions = (atom: P<Atom>) => {
907
+ const not: P<Atom> = select(
908
+ 'a shape expression',
909
+ [
910
+ [
911
+ ['NOT'],
912
+ Parser.preceded(anyToken, Parser.cut(atom)).pipe(
913
+ Parser.map((a) => plain({ type: 'ShapeNot', shapeExpr: a.e })),
914
+ ),
915
+ ],
916
+ ],
917
+ atom,
918
+ );
919
+ const and: P<AnyShapeExpr> = Parser.seq(
920
+ not,
921
+ Parser.repeat(Parser.preceded(tok('AND'), Parser.cut(not))),
922
+ ).pipe(
923
+ Parser.map(([first, rest]) =>
924
+ junction(
925
+ 'ShapeAnd',
926
+ first,
927
+ rest.map((a) => a.e),
928
+ ),
929
+ ),
930
+ );
931
+ return Parser.seq(and, Parser.repeat(Parser.preceded(tok('OR'), Parser.cut(and)))).pipe(
932
+ Parser.map(([first, rest]) => junction('ShapeOr', plain(first), rest)),
933
+ );
934
+ };
935
+
936
+ const inlineShapeExpressionDef: P<AnyShapeExpr> = junctions(inlineAtom(false));
937
+ const extendsShapeOrDef: P<AnyShapeExpr> = junctions(inlineAtom(true));
938
+
939
+ // -----------------------------------------------------------------------------
940
+ // Triple expressions
941
+ // -----------------------------------------------------------------------------
942
+
943
+ /** The token index of the label of each labelled triple expression. */
944
+ const labelAt = new WeakMap<object, number>();
945
+
946
+ const tripleConstraint: P<ShExJ.TripleConstraint> = Parser.seq(
947
+ accept('^'),
948
+ predicate,
949
+ inlineShapeExpression,
950
+ cardinality,
951
+ annotations,
952
+ semanticActions,
953
+ ).pipe(
954
+ Parser.map(([inverse, pred, valueExpr, card, annots, semActs]) => {
955
+ const tc: Mutable<ShExJ.TripleConstraint> = inverse
956
+ ? { type: 'TripleConstraint', inverse: true, predicate: pred }
957
+ : { type: 'TripleConstraint', predicate: pred };
958
+ if (valueExpr !== EMPTY) tc.valueExpr = valueExpr;
959
+ if (Option.isSome(card)) {
960
+ tc.min = card.value.min;
961
+ tc.max = card.value.max;
962
+ }
963
+ if (Option.isSome(semActs)) tc.semActs = semActs.value;
964
+ if (Arr.isReadonlyArrayNonEmpty(annots)) tc.annotations = annots;
965
+ return tc;
966
+ }),
967
+ );
968
+
969
+ const bracketedTripleExpr: P<ShExJ.TripleExprOrRef> = Parser.seq(
970
+ Parser.location,
971
+ Parser.delimited(anyToken, Parser.cut(tripleExpression), Parser.cut(tok(')'))),
972
+ cardinality,
973
+ annotations,
974
+ semanticActions,
975
+ ).pipe(
976
+ Parser.tryMap(([at, expr, card, annots, semActs]) => {
977
+ if (Option.isNone(card) && Arr.isReadonlyArrayEmpty(annots) && Option.isNone(semActs)) {
978
+ return Result.succeed(expr);
979
+ }
980
+ if (Predicate.isString(expr)) {
981
+ return failAt<ShExJ.TripleExprOrRef>(
982
+ `a group containing only the inclusion &<${expr}> can't take a cardinality, an annotation or a semantic action`,
983
+ at,
984
+ );
985
+ }
986
+ const out: Mutable<ShExJ.TripleExpr> =
987
+ Option.isSome(card) &&
988
+ expr.type === 'TripleConstraint' &&
989
+ (expr.min !== undefined || expr.max !== undefined)
990
+ ? { type: 'EachOf', expressions: [expr] }
991
+ : expr;
992
+ if (Option.isSome(card)) {
993
+ out.min = card.value.min;
994
+ out.max = card.value.max;
995
+ }
996
+ if (Arr.isReadonlyArrayNonEmpty(annots)) out.annotations = annots;
997
+ if (Option.isSome(semActs)) out.semActs = [...(out.semActs ?? []), ...semActs.value];
998
+ return Result.succeed<ShExJ.TripleExprOrRef>(out);
999
+ }),
1000
+ Parser.cut,
1001
+ );
1002
+
1003
+ const bracketedOrConstraint: P<ShExJ.TripleExprOrRef> = select(
1004
+ 'a triple expression',
1005
+ [[['('], bracketedTripleExpr]],
1006
+ tripleConstraint,
1007
+ );
1008
+
1009
+ const UNARY_KINDS = ['$', '&', '(', '^', 'a', ...IRI_KINDS];
1010
+
1011
+ const unaryTripleExpr: P<ShExJ.TripleExprOrRef> = select('a triple expression', [
1012
+ [['&'], Parser.preceded(anyToken, Parser.cut(label))],
1013
+ [
1014
+ ['$'],
1015
+ Parser.seq(
1016
+ Parser.preceded(anyToken, Parser.cut(Parser.seq(Parser.location, label))),
1017
+ Parser.cut(bracketedOrConstraint),
1018
+ ).pipe(
1019
+ Parser.tryMap(([[at, id], expr]) => {
1020
+ if (Predicate.isString(expr)) {
1021
+ return failAt<ShExJ.TripleExprOrRef>(
1022
+ `a group containing only the inclusion &<${expr}> can't take a label`,
1023
+ at,
1024
+ );
1025
+ }
1026
+ const labelled = { id, ...expr };
1027
+ labelAt.set(labelled, at);
1028
+ return Result.succeed<ShExJ.TripleExprOrRef>(labelled);
1029
+ }),
1030
+ Parser.cut,
1031
+ ),
1032
+ ],
1033
+ [['(', '^', 'a', ...IRI_KINDS], Parser.cut(bracketedOrConstraint)],
1034
+ ]);
1035
+
1036
+ const separator = select('; or ,', [[[';', ','], anyToken]]);
1037
+
1038
+ const groupTripleExpr: P<ShExJ.TripleExprOrRef> = Parser.terminated(
1039
+ Parser.seq(
1040
+ unaryTripleExpr,
1041
+ Parser.repeat(
1042
+ Parser.preceded(separator, select('a triple expression', [[UNARY_KINDS, unaryTripleExpr]])),
1043
+ ),
1044
+ ),
1045
+ Parser.opt(separator),
1046
+ ).pipe(
1047
+ Parser.map(([first, rest]) =>
1048
+ Arr.isReadonlyArrayEmpty(rest) ? first : { type: 'EachOf', expressions: [first, ...rest] },
1049
+ ),
1050
+ );
1051
+
1052
+ const tripleExpressionDef: P<ShExJ.TripleExprOrRef> = Parser.seq(
1053
+ groupTripleExpr,
1054
+ Parser.repeat(Parser.preceded(tok('|'), Parser.cut(groupTripleExpr))),
1055
+ ).pipe(
1056
+ Parser.map(([first, rest]) =>
1057
+ Arr.isReadonlyArrayEmpty(rest) ? first : { type: 'OneOf', expressions: [first, ...rest] },
1058
+ ),
1059
+ );
1060
+
1061
+ // -----------------------------------------------------------------------------
1062
+ // Document
1063
+ // -----------------------------------------------------------------------------
1064
+
1065
+ type Statement =
1066
+ | { readonly _tag: 'Import'; readonly iri: string }
1067
+ | { readonly _tag: 'Start'; readonly expr: AnyShapeExpr; readonly at: number }
1068
+ | { readonly _tag: 'Decl'; readonly decl: ShExJ.ShapeDecl; readonly at: number };
1069
+
1070
+ const noStatement = Option.none<Statement>();
1071
+
1072
+ const directiveCases: ReadonlyArray<readonly [ReadonlyArray<string>, P<Option.Option<Statement>>]> =
1073
+ [
1074
+ [
1075
+ ['BASE'],
1076
+ Parser.preceded(anyToken, Parser.cut(tok('IRIREF', 'an IRI reference'))).pipe(
1077
+ Parser.as(noStatement),
1078
+ ),
1079
+ ],
1080
+ [
1081
+ ['PREFIX'],
1082
+ Parser.preceded(
1083
+ anyToken,
1084
+ Parser.cut(
1085
+ Parser.seq(
1086
+ Token.oneOf<ReadonlyArray<Tok>>((t) => t.type === 'PNAME' && t.iri === '').pipe(
1087
+ Parser.expected('a prefix name'),
1088
+ ),
1089
+ iri,
1090
+ ),
1091
+ ),
1092
+ ).pipe(Parser.as(noStatement)),
1093
+ ],
1094
+ [
1095
+ ['IMPORT'],
1096
+ Parser.preceded(anyToken, Parser.cut(iri)).pipe(
1097
+ Parser.map((base) => Option.some<Statement>({ _tag: 'Import', iri: base })),
1098
+ ),
1099
+ ],
1100
+ ];
1101
+
1102
+ const directive: P<Option.Option<Statement>> = select('a directive', directiveCases);
1103
+
1104
+ const startDecl: P<Statement> = Parser.seq(
1105
+ Parser.location,
1106
+ Parser.preceded(anyToken, Parser.cut(Parser.preceded(tok('='), Parser.seq(shapeAnd, ors)))),
1107
+ ).pipe(
1108
+ Parser.map(([at, [first, rest]]): Statement => ({
1109
+ _tag: 'Start',
1110
+ expr: junction('ShapeOr', plain(first), rest),
1111
+ at,
1112
+ })),
1113
+ );
1114
+
1115
+ const shapeExprDecl: P<Statement> = Parser.seq(
1116
+ accept('ABSTRACT'),
1117
+ Parser.location,
1118
+ label,
1119
+ Parser.repeat(
1120
+ Parser.preceded(
1121
+ select("'RESTRICTS' or '-'", [[['RESTRICTS', '-'], anyToken]]),
1122
+ Parser.cut(shapeOrRef),
1123
+ ),
1124
+ ),
1125
+ select(
1126
+ 'a shape expression',
1127
+ [
1128
+ [['EXTERNAL'], anyToken.pipe(Parser.as<AnyShapeExpr>({ type: 'ShapeExternal' }))],
1129
+ [
1130
+ REF_KINDS,
1131
+ Parser.seq(shapeRef, Parser.opt(shapeOrRest)).pipe(
1132
+ Parser.map(([ref, rest]) =>
1133
+ Option.match(rest, { onNone: () => ref, onSome: (r) => prepend(r, [ref]) }),
1134
+ ),
1135
+ ),
1136
+ ],
1137
+ ],
1138
+ shapeExpressionBody,
1139
+ ),
1140
+ ).pipe(
1141
+ Parser.map(([abstract, at, name, restricts, body]): Statement => {
1142
+ const shapeExpr = body === EMPTY ? { type: 'Shape' as const } : body;
1143
+ const decl: Mutable<ShExJ.ShapeDecl> = { type: 'ShapeDecl', id: name, shapeExpr };
1144
+ if (abstract) decl.abstract = true;
1145
+ if (Arr.isReadonlyArrayNonEmpty(restricts)) decl.restricts = restricts;
1146
+ return { _tag: 'Decl', decl, at };
1147
+ }),
1148
+ );
1149
+
1150
+ const statement: P<Option.Option<Statement>> = select('a directive or shape declaration', [
1151
+ ...directiveCases,
1152
+ [['START'], startDecl.pipe(Parser.map(Option.some))],
1153
+ [
1154
+ ['ABSTRACT', 'BLANK_NODE_LABEL', ...IRI_KINDS],
1155
+ Parser.cut(shapeExprDecl).pipe(Parser.map(Option.some)),
1156
+ ],
1157
+ ]);
1158
+
1159
+ const document = Compiler.jit(
1160
+ Parser.terminated(
1161
+ Parser.seq(Parser.repeat(directive), Parser.opt(codeDecls), Parser.repeat(statement)),
1162
+ Parser.eof,
1163
+ ),
1164
+ );
1165
+
1166
+ // -----------------------------------------------------------------------------
1167
+ // Checks in document order
1168
+ // -----------------------------------------------------------------------------
1169
+
1170
+ type Visit = (t: ShExJ.TripleExpr, id: string) => void;
1171
+
1172
+ const labelledShape = (s: AnyShapeExpr, f: Visit): void => {
1173
+ if (!Predicate.isString(s)) labelledShapeExpr(s, f);
1174
+ };
1175
+
1176
+ const labelledTriple = (t: ShExJ.TripleExprOrRef, f: Visit): void => {
1177
+ if (Predicate.isString(t)) return;
1178
+ if (t.type === 'TripleConstraint') {
1179
+ if (t.valueExpr !== undefined) labelledShape(t.valueExpr, f);
1180
+ } else t.expressions.forEach((e) => labelledTriple(e, f));
1181
+ if (t.id !== undefined) f(t, t.id);
1182
+ };
1183
+
1184
+ // Built once: it runs for every shape expression of every declaration.
1185
+ const labelledShapeExpr: (s: ShExJ.ShapeExpr, f: Visit) => void = Match.fn(
1186
+ (s: ShExJ.ShapeExpr, _f: Visit) => s,
1187
+ ).pipe(
1188
+ Match.when({ type: Match.is('ShapeOr', 'ShapeAnd') }, (s, _s, f) =>
1189
+ s.shapeExprs.forEach((e) => labelledShape(e, f)),
1190
+ ),
1191
+ Match.when({ type: 'ShapeNot' }, (s, _s, f) => labelledShape(s.shapeExpr, f)),
1192
+ Match.when({ type: 'Shape' }, (s, _s, f) => {
1193
+ s.extends?.forEach((e) => labelledShape(e, f));
1194
+ if (s.expression !== undefined) labelledTriple(s.expression, f);
1195
+ }),
1196
+ Match.orElse(() => undefined),
1197
+ );
1198
+
1199
+ /**
1200
+ * Calls `f` on each labelled triple expression of a shape expression, in
1201
+ * document order (each after the labelled expressions it contains).
1202
+ */
1203
+ const eachLabelled = (e: AnyShapeExpr, f: Visit): void => labelledShape(e, f);
1204
+
1205
+ const assemble = (
1206
+ statements: ReadonlyArray<Statement>,
1207
+ startActs: Option.Option<ReadonlyArray<ShExJ.SemAct>>,
1208
+ ): Result.Result<ShExJ.Schema, SemanticError> => {
1209
+ const imports: Array<string> = [];
1210
+ // In document order, which the schema keeps.
1211
+ const shapes: Array<ShExJ.ShapeDecl> = [];
1212
+ const shapeIds = MutableHashSet.empty<string>();
1213
+ const productions = MutableHashSet.empty<string>();
1214
+ let error = Option.none<SemanticError>();
1215
+ const production: Visit = (t, id) => {
1216
+ if (Option.isSome(error)) return;
1217
+ const at = labelAt.get(t) ?? 0;
1218
+ if (MutableHashSet.has(shapeIds, id))
1219
+ error = Option.some({ message: `${id} is a shape expression`, at });
1220
+ else if (MutableHashSet.has(productions, id))
1221
+ error = Option.some({ message: `${id} already defined`, at });
1222
+ else MutableHashSet.add(productions, id);
1223
+ };
1224
+ const step = (
1225
+ start: Option.Option<AnyShapeExpr>,
1226
+ s: Statement,
1227
+ ): Result.Result<Option.Option<AnyShapeExpr>, SemanticError> => {
1228
+ if (Predicate.isTagged(s, 'Import')) {
1229
+ imports.push(s.iri);
1230
+ return Result.succeed(start);
1231
+ }
1232
+ if (Predicate.isTagged(s, 'Start')) {
1233
+ if (Option.isSome(start)) return failAt('start already defined', s.at);
1234
+ eachLabelled(s.expr, production);
1235
+ return Option.isSome(error) ? Result.fail(error.value) : Result.succeed(Option.some(s.expr));
1236
+ }
1237
+ const { decl, at } = s;
1238
+ decl.restricts?.forEach((r) => eachLabelled(r, production));
1239
+ eachLabelled(decl.shapeExpr, production);
1240
+ if (Option.isSome(error)) return Result.fail(error.value);
1241
+ if (MutableHashSet.has(productions, decl.id))
1242
+ return failAt(`${decl.id} is a triple expression`, at);
1243
+ if (MutableHashSet.has(shapeIds, decl.id)) return failAt(`${decl.id} already defined`, at);
1244
+ MutableHashSet.add(shapeIds, decl.id);
1245
+ shapes.push(decl);
1246
+ return Result.succeed(start);
1247
+ };
1248
+ const noStart: Result.Result<Option.Option<AnyShapeExpr>, SemanticError> = Result.succeed(
1249
+ Option.none(),
1250
+ );
1251
+ return Arr.reduce(statements, noStart, (acc, s) =>
1252
+ Result.flatMap(acc, (start) => step(start, s)),
1253
+ ).pipe(
1254
+ Result.map((start) => {
1255
+ const schema: Mutable<ShExJ.Schema> = { type: 'Schema' };
1256
+ if (Arr.isReadonlyArrayNonEmpty(imports)) schema.imports = imports;
1257
+ if (Option.isSome(startActs)) schema.startActs = startActs.value;
1258
+ if (Option.isSome(start)) schema.start = start.value;
1259
+ if (Arr.isReadonlyArrayNonEmpty(shapes)) schema.shapes = shapes;
1260
+ return schema;
1261
+ }),
1262
+ );
1263
+ };
1264
+
1265
+ // -----------------------------------------------------------------------------
1266
+ // Entry point
1267
+ // -----------------------------------------------------------------------------
1268
+
1269
+ const offsetOf = (tokens: ReadonlyArray<Tok>, input: string, at: number): number =>
1270
+ tokens[at]?.start ?? input.length;
1271
+
1272
+ const grammarError = (
1273
+ input: string,
1274
+ tokens: ReadonlyArray<Tok>,
1275
+ error: ParseError.ParseError<SemanticError>,
1276
+ ): ShExCError => {
1277
+ if (error.cause !== undefined) {
1278
+ return { message: error.cause.message, offset: offsetOf(tokens, input, error.cause.at) };
1279
+ }
1280
+ const t = tokens[error.offset];
1281
+ if (t?.type === 'ERROR') return { message: t.text, offset: t.start };
1282
+ const found = t === undefined ? 'end of input' : quote(input.slice(t.start, t.end));
1283
+ const expected = ParseError.formatExpected(error.expected);
1284
+ return {
1285
+ message: expected === '' ? `unexpected ${found}` : `expected ${expected}, found ${found}`,
1286
+ offset: offsetOf(tokens, input, error.offset),
1287
+ };
1288
+ };
1289
+
1290
+ /** Parses a ShExC document. Errors carry the character offset. */
1291
+ export const parseShExC = (
1292
+ input: string,
1293
+ options: ParserOptions,
1294
+ ): Result.Result<ParserResult, ShExCError> => {
1295
+ const tokens = tokenize(input);
1296
+ const resolved = resolve(tokens, options.baseIri, options.prefixes);
1297
+ const parsed = Parser.parse(document, tokens);
1298
+ if (Result.isFailure(parsed)) return Result.fail(grammarError(input, tokens, parsed.failure));
1299
+ const [directives, startActs, statements] = parsed.success;
1300
+ const schema = assemble(Arr.getSomes([...directives, ...statements]), startActs);
1301
+ if (Result.isFailure(schema)) {
1302
+ return Result.fail({
1303
+ message: schema.failure.message,
1304
+ offset: offsetOf(tokens, input, schema.failure.at),
1305
+ });
1306
+ }
1307
+ return Result.succeed({
1308
+ schema: schema.success,
1309
+ prefixes: resolved.prefixes,
1310
+ baseIri: resolved.baseIri,
1311
+ });
1312
+ };