@thomasfosterau/effect-rdf 0.0.0 → 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.
- package/LICENSE +21 -0
- package/README.md +2250 -1
- package/dist/Algebra-CGG4oae3.mjs +433 -0
- package/dist/Algebra-CGG4oae3.mjs.map +1 -0
- package/dist/Algebra-uGsIEOUA.d.mts +446 -0
- package/dist/Ast-CPRZmBvk.mjs +552 -0
- package/dist/Ast-CPRZmBvk.mjs.map +1 -0
- package/dist/Ast-vcw2W-lf.d.mts +827 -0
- package/dist/Bindings-Ck3m7JRC.mjs +249 -0
- package/dist/Bindings-Ck3m7JRC.mjs.map +1 -0
- package/dist/Bindings-DiKpBd7f.d.mts +153 -0
- package/dist/ClientErrors-CpXdFX5u.mjs +128 -0
- package/dist/ClientErrors-CpXdFX5u.mjs.map +1 -0
- package/dist/ClientErrors-D4IZHUM-.d.mts +101 -0
- package/dist/ClientFormats-CXomkXLV.mjs +73 -0
- package/dist/ClientFormats-CXomkXLV.mjs.map +1 -0
- package/dist/ClientFormats-Dm57ZPwR.d.mts +36 -0
- package/dist/Csv2Json-DynEcwCh.mjs +194 -0
- package/dist/Csv2Json-DynEcwCh.mjs.map +1 -0
- package/dist/Csv2Json-aXNVDoXQ.d.mts +40 -0
- package/dist/Csv2Rdf-8maXP6mt.d.mts +41 -0
- package/dist/Csv2Rdf-DuSEkaKE.mjs +161 -0
- package/dist/Csv2Rdf-DuSEkaKE.mjs.map +1 -0
- package/dist/Dataset-BlmlcI7J.mjs +782 -0
- package/dist/Dataset-BlmlcI7J.mjs.map +1 -0
- package/dist/Dataset-DS3ESOcO.d.mts +426 -0
- package/dist/Dataset.d.mts +2 -0
- package/dist/Dataset.mjs +1 -0
- package/dist/Datatype-CxMpamHC.d.mts +212 -0
- package/dist/Datatype-DQvkNkiH.mjs +1001 -0
- package/dist/Datatype-DQvkNkiH.mjs.map +1 -0
- package/dist/Dialect-8ChFj5EX.d.mts +113 -0
- package/dist/Dialect-CzVH38uo.mjs +165 -0
- package/dist/Dialect-CzVH38uo.mjs.map +1 -0
- package/dist/DocumentLoader-D3lZREnB.mjs +346 -0
- package/dist/DocumentLoader-D3lZREnB.mjs.map +1 -0
- package/dist/DocumentLoader-ZUCEVrW5.d.mts +178 -0
- package/dist/DublinCore-AnwqxRx6.mjs +137 -0
- package/dist/DublinCore-AnwqxRx6.mjs.map +1 -0
- package/dist/DublinCore-Dq-tVA5d.d.mts +119 -0
- package/dist/Engine-CYPB3g4h.d.mts +144 -0
- package/dist/Engine-DF8PN7g-.mjs +872 -0
- package/dist/Engine-DF8PN7g-.mjs.map +1 -0
- package/dist/Errors-CMdV1RhU.mjs +37 -0
- package/dist/Errors-CMdV1RhU.mjs.map +1 -0
- package/dist/Errors-u2bDjUeM.d.mts +30 -0
- package/dist/Evaluator-DEsU4d1o.d.mts +50 -0
- package/dist/Evaluator-DOY2-guC.mjs +281 -0
- package/dist/Evaluator-DOY2-guC.mjs.map +1 -0
- package/dist/Exif-CpqniYQd.d.mts +78 -0
- package/dist/Exif-DjkCfEB-.mjs +89 -0
- package/dist/Exif-DjkCfEB-.mjs.map +1 -0
- package/dist/Expression-BIMMvduQ.mjs +230 -0
- package/dist/Expression-BIMMvduQ.mjs.map +1 -0
- package/dist/Expression-W8A9cyX7.d.mts +89 -0
- package/dist/Extract-Bop85jES.mjs +220 -0
- package/dist/Extract-Bop85jES.mjs.map +1 -0
- package/dist/Extract-C_pCvuTC.d.mts +88 -0
- package/dist/Federation-BcNrozc1.d.mts +52 -0
- package/dist/Federation-CHScBkaK.mjs +130 -0
- package/dist/Federation-CHScBkaK.mjs.map +1 -0
- package/dist/Functions-AvjNcId_.mjs +1346 -0
- package/dist/Functions-AvjNcId_.mjs.map +1 -0
- package/dist/Functions-OQJZP-F6.d.mts +111 -0
- package/dist/Generator-C52mmq01.d.mts +50 -0
- package/dist/Generator-D3utCJC7.mjs +205 -0
- package/dist/Generator-D3utCJC7.mjs.map +1 -0
- package/dist/Grammar-CPlSxGH6.mjs +200 -0
- package/dist/Grammar-CPlSxGH6.mjs.map +1 -0
- package/dist/Grammar-CRhnRoCu.d.mts +148 -0
- package/dist/Grammar-D6jZdJQ3.d.mts +169 -0
- package/dist/Grammar-mQ8CgE1M.mjs +258 -0
- package/dist/Grammar-mQ8CgE1M.mjs.map +1 -0
- package/dist/GraphStore-DhUa4nFO.d.mts +45 -0
- package/dist/GraphStore-DvbqwKy1.mjs +212 -0
- package/dist/GraphStore-DvbqwKy1.mjs.map +1 -0
- package/dist/Iri-BB8Ks-BF.d.mts +84 -0
- package/dist/Iri-Cr92gsQV.mjs +232 -0
- package/dist/Iri-Cr92gsQV.mjs.map +1 -0
- package/dist/Iri.d.mts +2 -0
- package/dist/Iri.mjs +1 -0
- package/dist/Isomorphism-B6qTY-xy.d.mts +28 -0
- package/dist/Isomorphism-BmqxhKyJ.mjs +232 -0
- package/dist/Isomorphism-BmqxhKyJ.mjs.map +1 -0
- package/dist/Isomorphism-DInKnWIy.mjs +390 -0
- package/dist/Isomorphism-DInKnWIy.mjs.map +1 -0
- package/dist/Isomorphism-DvSfZXLR.d.mts +37 -0
- package/dist/Isomorphism.d.mts +2 -0
- package/dist/Isomorphism.mjs +1 -0
- package/dist/JsonLd-DOwS2FHg.mjs +2836 -0
- package/dist/JsonLd-DOwS2FHg.mjs.map +1 -0
- package/dist/JsonLd-DobFrQNa.d.mts +242 -0
- package/dist/JsonLdError-C9J-BxfG.mjs +106 -0
- package/dist/JsonLdError-C9J-BxfG.mjs.map +1 -0
- package/dist/JsonLdError-DSOfHkOy.d.mts +43 -0
- package/dist/LanguageTag-BCu8rcmX.d.mts +38 -0
- package/dist/LanguageTag-BcOpMGZ4.mjs +89 -0
- package/dist/LanguageTag-BcOpMGZ4.mjs.map +1 -0
- package/dist/LanguageTag.d.mts +2 -0
- package/dist/LanguageTag.mjs +1 -0
- package/dist/Lexical-Cg0JHrf6.mjs +243 -0
- package/dist/Lexical-Cg0JHrf6.mjs.map +1 -0
- package/dist/Lexical-D3zySYVS.d.mts +163 -0
- package/dist/Manifest-B6xf6mUc.mjs +148 -0
- package/dist/Manifest-B6xf6mUc.mjs.map +1 -0
- package/dist/Manifest-DQUMRBFr.d.mts +98 -0
- package/dist/Mapping-BgG74x3U.d.mts +63 -0
- package/dist/Mapping-Dc1ZGirk.mjs +259 -0
- package/dist/Mapping-Dc1ZGirk.mjs.map +1 -0
- package/dist/Mcp-1DwTTKOK.mjs +48 -0
- package/dist/Mcp-1DwTTKOK.mjs.map +1 -0
- package/dist/Mcp-d-pX9erx.d.mts +25 -0
- package/dist/Message-CK_DGQuu.mjs +95 -0
- package/dist/Message-CK_DGQuu.mjs.map +1 -0
- package/dist/Message-fIvTJSXM.d.mts +49 -0
- package/dist/Metadata-BbffwGDZ.mjs +445 -0
- package/dist/Metadata-BbffwGDZ.mjs.map +1 -0
- package/dist/Metadata-CEt3yc1-.d.mts +901 -0
- package/dist/Metadata-D4HsQNXr.mjs +1273 -0
- package/dist/Metadata-D4HsQNXr.mjs.map +1 -0
- package/dist/Metadata-nzS7QKRj.d.mts +350 -0
- package/dist/Model-DaMmxurZ.d.mts +293 -0
- package/dist/Model-DlPzRYhF.mjs +528 -0
- package/dist/Model-DlPzRYhF.mjs.map +1 -0
- package/dist/N3-BzyV-KIH.mjs +974 -0
- package/dist/N3-BzyV-KIH.mjs.map +1 -0
- package/dist/N3-DSLnonDn.d.mts +100 -0
- package/dist/NQuads-C1VBOJ3-.mjs +117 -0
- package/dist/NQuads-C1VBOJ3-.mjs.map +1 -0
- package/dist/NQuads-FjFZikFg.d.mts +76 -0
- package/dist/NTriples-D-kLSEAf.mjs +120 -0
- package/dist/NTriples-D-kLSEAf.mjs.map +1 -0
- package/dist/NTriples-D34OspfW.d.mts +76 -0
- package/dist/Namespace-ClTUO_ya.d.mts +42 -0
- package/dist/Namespace-DHFIsORd.mjs +75 -0
- package/dist/Namespace-DHFIsORd.mjs.map +1 -0
- package/dist/Namespace.d.mts +2 -0
- package/dist/Namespace.mjs +1 -0
- package/dist/Namespaces-Bz85vpjW.mjs +235 -0
- package/dist/Namespaces-Bz85vpjW.mjs.map +1 -0
- package/dist/Namespaces-C1jW6EDo.d.mts +178 -0
- package/dist/Optimizer-BWWQRQPY.mjs +168 -0
- package/dist/Optimizer-BWWQRQPY.mjs.map +1 -0
- package/dist/Optimizer-DUpUow6k.d.mts +26 -0
- package/dist/Options-BLBGL4HE.mjs +72 -0
- package/dist/Options-BLBGL4HE.mjs.map +1 -0
- package/dist/Options-BommQwP9.d.mts +127 -0
- package/dist/Packet-CA76wVX3.mjs +197 -0
- package/dist/Packet-CA76wVX3.mjs.map +1 -0
- package/dist/Packet-Cy5g6XuW.d.mts +130 -0
- package/dist/Parser-p1Gyr0QN.d.mts +85 -0
- package/dist/Parser-xARsOWXk.mjs +1317 -0
- package/dist/Parser-xARsOWXk.mjs.map +1 -0
- package/dist/Path-B20Yp8KE.mjs +284 -0
- package/dist/Path-B20Yp8KE.mjs.map +1 -0
- package/dist/Path-DRB8e-Zn.d.mts +181 -0
- package/dist/Pdf-B9RZn--8.d.mts +77 -0
- package/dist/Pdf-CKK6dkZn.mjs +89 -0
- package/dist/Pdf-CKK6dkZn.mjs.map +1 -0
- package/dist/PdfA-CUjSuntT.d.mts +109 -0
- package/dist/PdfA-CleOhuL6.mjs +124 -0
- package/dist/PdfA-CleOhuL6.mjs.map +1 -0
- package/dist/Photoshop-CiHo80qV.mjs +233 -0
- package/dist/Photoshop-CiHo80qV.mjs.map +1 -0
- package/dist/Photoshop-udKZ0I3N.d.mts +204 -0
- package/dist/PrefixMap-BHFPDLO-.mjs +103 -0
- package/dist/PrefixMap-BHFPDLO-.mjs.map +1 -0
- package/dist/PrefixMap-BMlXrWNd.d.mts +64 -0
- package/dist/PrefixMap.d.mts +2 -0
- package/dist/PrefixMap.mjs +1 -0
- package/dist/Processor-CMmecFsb.mjs +198 -0
- package/dist/Processor-CMmecFsb.mjs.map +1 -0
- package/dist/Processor-FJPvO0CB.d.mts +435 -0
- package/dist/Protocol-BA7OkNgp.mjs +202 -0
- package/dist/Protocol-BA7OkNgp.mjs.map +1 -0
- package/dist/Protocol-DlSoiIKB.d.mts +108 -0
- package/dist/ProtocolErrors-Ckfejnl6.d.mts +84 -0
- package/dist/ProtocolErrors-czDPVcX5.mjs +129 -0
- package/dist/ProtocolErrors-czDPVcX5.mjs.map +1 -0
- package/dist/Query-D9A6LOpP.mjs +364 -0
- package/dist/Query-D9A6LOpP.mjs.map +1 -0
- package/dist/Query-KqSkTYyG.d.mts +96 -0
- package/dist/QueryBuilder-BLK9Vfbz.mjs +674 -0
- package/dist/QueryBuilder-BLK9Vfbz.mjs.map +1 -0
- package/dist/QueryBuilder-DUqh4ECe.d.mts +529 -0
- package/dist/RdfJs-D6-49XB5.mjs +86 -0
- package/dist/RdfJs-D6-49XB5.mjs.map +1 -0
- package/dist/RdfJs-DXFqdWrd.d.mts +76 -0
- package/dist/RdfJs.d.mts +2 -0
- package/dist/RdfJs.mjs +1 -0
- package/dist/RdfJson-5aKPDlPS.d.mts +297 -0
- package/dist/RdfJson-BNocgW4f.mjs +548 -0
- package/dist/RdfJson-BNocgW4f.mjs.map +1 -0
- package/dist/RdfXml-DJ9G4gOq.mjs +1014 -0
- package/dist/RdfXml-DJ9G4gOq.mjs.map +1 -0
- package/dist/RdfXml-_N7yxWEp.d.mts +149 -0
- package/dist/Rdfs-BRVPsAjc.d.mts +84 -0
- package/dist/Rdfs-CyY2wVHI.mjs +167 -0
- package/dist/Rdfs-CyY2wVHI.mjs.map +1 -0
- package/dist/Rdfs.d.mts +2 -0
- package/dist/Rdfs.mjs +1 -0
- package/dist/Reasoner-BxYhx9s7.d.mts +94 -0
- package/dist/Reasoner-Cw90zrjv.mjs +798 -0
- package/dist/Reasoner-Cw90zrjv.mjs.map +1 -0
- package/dist/Reification-BmN4EfnM.d.mts +40 -0
- package/dist/Reification-dpqQvjDE.mjs +82 -0
- package/dist/Reification-dpqQvjDE.mjs.map +1 -0
- package/dist/Reification.d.mts +2 -0
- package/dist/Reification.mjs +1 -0
- package/dist/Report-XHs8htzK.mjs +121 -0
- package/dist/Report-XHs8htzK.mjs.map +1 -0
- package/dist/Report-hcXsc_19.d.mts +115 -0
- package/dist/Resource-B1cI8FyJ.d.mts +218 -0
- package/dist/Resource-sIEeNh15.mjs +374 -0
- package/dist/Resource-sIEeNh15.mjs.map +1 -0
- package/dist/Resource.d.mts +2 -0
- package/dist/Resource.mjs +1 -0
- package/dist/Results-BVNEC-Wt.d.mts +277 -0
- package/dist/Results-peJjGA2V.mjs +621 -0
- package/dist/Results-peJjGA2V.mjs.map +1 -0
- package/dist/ResultsStream-BhF0OcNn.mjs +639 -0
- package/dist/ResultsStream-BhF0OcNn.mjs.map +1 -0
- package/dist/ResultsStream-toYMXrOe.d.mts +100 -0
- package/dist/SemAct-CDchtk49.d.mts +96 -0
- package/dist/SemAct-CmyT4yI8.mjs +118 -0
- package/dist/SemAct-CmyT4yI8.mjs.map +1 -0
- package/dist/Serialization-DP9H5bYQ.mjs +514 -0
- package/dist/Serialization-DP9H5bYQ.mjs.map +1 -0
- package/dist/Serialization-Df8iVauT.d.mts +392 -0
- package/dist/Serialization.d.mts +2 -0
- package/dist/Serialization.mjs +1 -0
- package/dist/ServerFormats-CrRnjjf6.mjs +64 -0
- package/dist/ServerFormats-CrRnjjf6.mjs.map +1 -0
- package/dist/ServerFormats-DjC9NsO_.d.mts +36 -0
- package/dist/ServiceDescription-BERsvg-k.d.mts +54 -0
- package/dist/ServiceDescription-Dq5hxeGy.mjs +97 -0
- package/dist/ServiceDescription-Dq5hxeGy.mjs.map +1 -0
- package/dist/ShExC-Ctf-06CL.d.mts +67 -0
- package/dist/ShExC-DJbB19i3.mjs +1181 -0
- package/dist/ShExC-DJbB19i3.mjs.map +1 -0
- package/dist/ShExError-BeYFD9rv.d.mts +61 -0
- package/dist/ShExError-CVtq2NnM.mjs +64 -0
- package/dist/ShExError-CVtq2NnM.mjs.map +1 -0
- package/dist/ShExJ-C1u_wgyD.d.mts +531 -0
- package/dist/ShExJ-COiPd9Xw.mjs +532 -0
- package/dist/ShExJ-COiPd9Xw.mjs.map +1 -0
- package/dist/ShExR-ByR4mCh-.mjs +480 -0
- package/dist/ShExR-ByR4mCh-.mjs.map +1 -0
- package/dist/ShExR-CqONNNBz.d.mts +40 -0
- package/dist/ShapeMap-C422pxKl.d.mts +140 -0
- package/dist/ShapeMap-CsgKxB2G.mjs +181 -0
- package/dist/ShapeMap-CsgKxB2G.mjs.map +1 -0
- package/dist/Shapes-18GjfyBV.mjs +597 -0
- package/dist/Shapes-18GjfyBV.mjs.map +1 -0
- package/dist/Shapes-BQFDFc4Q.d.mts +306 -0
- package/dist/Sparql-BiYFMSpl.mjs +29 -0
- package/dist/Sparql-BiYFMSpl.mjs.map +1 -0
- package/dist/Sparql-DecpWTPh.d.mts +97 -0
- package/dist/SparqlClient-C_CjXbwj.mjs +333 -0
- package/dist/SparqlClient-C_CjXbwj.mjs.map +1 -0
- package/dist/SparqlClient-UPc88SHy.d.mts +290 -0
- package/dist/SparqlServer-CbUW-pVj.d.mts +71 -0
- package/dist/SparqlServer-Db7w7Cll.mjs +308 -0
- package/dist/SparqlServer-Db7w7Cll.mjs.map +1 -0
- package/dist/SqlStore-BBqFx-Wl.mjs +684 -0
- package/dist/SqlStore-BBqFx-Wl.mjs.map +1 -0
- package/dist/SqlStore-CCJo5I-e.d.mts +117 -0
- package/dist/Store-D0jmVfb3.d.mts +166 -0
- package/dist/Store-DH3Ow1GO.mjs +162 -0
- package/dist/Store-DH3Ow1GO.mjs.map +1 -0
- package/dist/Structure-BjMo4Bkc.mjs +334 -0
- package/dist/Structure-BjMo4Bkc.mjs.map +1 -0
- package/dist/Structure-n4CmDiab.d.mts +63 -0
- package/dist/Table-BGgm9nbM.mjs +538 -0
- package/dist/Table-BGgm9nbM.mjs.map +1 -0
- package/dist/Table-C3reiVrb.d.mts +261 -0
- package/dist/Term-B_4ezyXq.d.mts +619 -0
- package/dist/Term-CFLG1qu4.mjs +991 -0
- package/dist/Term-CFLG1qu4.mjs.map +1 -0
- package/dist/Term.d.mts +2 -0
- package/dist/Term.mjs +1 -0
- package/dist/TermCodec-CDZiEztW.mjs +397 -0
- package/dist/TermCodec-CDZiEztW.mjs.map +1 -0
- package/dist/TermCodec-_03bDXr0.d.mts +209 -0
- package/dist/TermCodec.d.mts +2 -0
- package/dist/TermCodec.mjs +1 -0
- package/dist/TermJson-BOPe0yve.d.mts +232 -0
- package/dist/TermJson-FAg3lvjl.mjs +142 -0
- package/dist/TermJson-FAg3lvjl.mjs.map +1 -0
- package/dist/TermJson.d.mts +2 -0
- package/dist/TermJson.mjs +1 -0
- package/dist/TermSchema-Bn9CoaYA.mjs +30 -0
- package/dist/TermSchema-Bn9CoaYA.mjs.map +1 -0
- package/dist/TermSchema-DBO6MroX.d.mts +6 -0
- package/dist/Testing-B-aPCpmu.mjs +63 -0
- package/dist/Testing-B-aPCpmu.mjs.map +1 -0
- package/dist/Testing-CF6s8P3O.d.mts +53 -0
- package/dist/Tiff-CR-2QeSI.d.mts +148 -0
- package/dist/Tiff-DlsOlZPM.mjs +169 -0
- package/dist/Tiff-DlsOlZPM.mjs.map +1 -0
- package/dist/Tools-7MdRKccr.d.mts +583 -0
- package/dist/Tools-ryxphZbI.mjs +329 -0
- package/dist/Tools-ryxphZbI.mjs.map +1 -0
- package/dist/Translate-B0YKKANS.d.mts +37 -0
- package/dist/Translate-gzWPq0Ia.mjs +308 -0
- package/dist/Translate-gzWPq0Ia.mjs.map +1 -0
- package/dist/Translation-DC9rLm2y.mjs +1535 -0
- package/dist/Translation-DC9rLm2y.mjs.map +1 -0
- package/dist/Translation-K4L9XBqX.d.mts +103 -0
- package/dist/TriG-BkqtqZ6Y.mjs +125 -0
- package/dist/TriG-BkqtqZ6Y.mjs.map +1 -0
- package/dist/TriG-xDjdDatp.d.mts +86 -0
- package/dist/Turtle-Bv1_bisW.d.mts +85 -0
- package/dist/Turtle-CZVUOtwl.mjs +133 -0
- package/dist/Turtle-CZVUOtwl.mjs.map +1 -0
- package/dist/ValidationReport-DBdJshW5.mjs +285 -0
- package/dist/ValidationReport-DBdJshW5.mjs.map +1 -0
- package/dist/ValidationReport-Dx3WxY0h.d.mts +192 -0
- package/dist/Validator-227ff9Rn.d.mts +179 -0
- package/dist/Validator-BzXMKDeJ.mjs +1162 -0
- package/dist/Validator-BzXMKDeJ.mjs.map +1 -0
- package/dist/Validator-Dl8cih5V.d.mts +207 -0
- package/dist/Validator-DmUfMbpL.mjs +568 -0
- package/dist/Validator-DmUfMbpL.mjs.map +1 -0
- package/dist/Vocab-DceKywpq.mjs +168 -0
- package/dist/Vocab-DceKywpq.mjs.map +1 -0
- package/dist/Vocab-Df-L-IwZ.d.mts +46 -0
- package/dist/Vocab-Do56UgBX.d.mts +81 -0
- package/dist/Vocab-TfpWG1Ne.mjs +118 -0
- package/dist/Vocab-TfpWG1Ne.mjs.map +1 -0
- package/dist/Vocab.d.mts +2 -0
- package/dist/Vocab.mjs +1 -0
- package/dist/Vocabulary-C6-GPOy4.d.mts +22 -0
- package/dist/Vocabulary-CnQl-_Z4.mjs +179 -0
- package/dist/Vocabulary-CnQl-_Z4.mjs.map +1 -0
- package/dist/Xml-B7iihYCS.mjs +976 -0
- package/dist/Xml-B7iihYCS.mjs.map +1 -0
- package/dist/Xml-CmfHS7SW.d.mts +267 -0
- package/dist/Xmp-D7CKA7MZ.d.mts +111 -0
- package/dist/Xmp-DCGN9pOD.mjs +307 -0
- package/dist/Xmp-DCGN9pOD.mjs.map +1 -0
- package/dist/XmpBasic-CP38jpR_.mjs +73 -0
- package/dist/XmpBasic-CP38jpR_.mjs.map +1 -0
- package/dist/XmpBasic-Cmbe53rQ.d.mts +64 -0
- package/dist/XmpMM-BfL_TgJF.mjs +73 -0
- package/dist/XmpMM-BfL_TgJF.mjs.map +1 -0
- package/dist/XmpMM-Dqm3IX8p.d.mts +63 -0
- package/dist/XmpRights-BKPtoI5L.mjs +73 -0
- package/dist/XmpRights-BKPtoI5L.mjs.map +1 -0
- package/dist/XmpRights-CaALZQz2.d.mts +63 -0
- package/dist/Xsd-Cdgx5zRB.mjs +405 -0
- package/dist/Xsd-Cdgx5zRB.mjs.map +1 -0
- package/dist/Xsd-D2elNhSm.d.mts +187 -0
- package/dist/Xsd.d.mts +2 -0
- package/dist/Xsd.mjs +1 -0
- package/dist/accessors-CEjaojuQ.mjs +28 -0
- package/dist/accessors-CEjaojuQ.mjs.map +1 -0
- package/dist/codec-Lb2T96rv.d.mts +20 -0
- package/dist/codec-QNo7IdJF.mjs +389 -0
- package/dist/codec-QNo7IdJF.mjs.map +1 -0
- package/dist/csvw/Csv2Json.d.mts +2 -0
- package/dist/csvw/Csv2Json.mjs +1 -0
- package/dist/csvw/Csv2Rdf.d.mts +2 -0
- package/dist/csvw/Csv2Rdf.mjs +1 -0
- package/dist/csvw/Datatype.d.mts +2 -0
- package/dist/csvw/Datatype.mjs +1 -0
- package/dist/csvw/Metadata.d.mts +2 -0
- package/dist/csvw/Metadata.mjs +1 -0
- package/dist/csvw/Processor.d.mts +2 -0
- package/dist/csvw/Processor.mjs +1 -0
- package/dist/csvw/Report.d.mts +2 -0
- package/dist/csvw/Report.mjs +1 -0
- package/dist/csvw/Table.d.mts +2 -0
- package/dist/csvw/Table.mjs +1 -0
- package/dist/csvw/index.d.mts +8 -0
- package/dist/csvw/index.mjs +8 -0
- package/dist/index-Cms2TYfC.d.mts +16 -0
- package/dist/index-Ct8xFmRs.d.mts +7 -0
- package/dist/index-D4QFwOjm.d.mts +28 -0
- package/dist/index.d.mts +18 -0
- package/dist/index.mjs +17 -0
- package/dist/jsonld/DocumentLoader.d.mts +2 -0
- package/dist/jsonld/DocumentLoader.mjs +1 -0
- package/dist/jsonld/JsonLd.d.mts +2 -0
- package/dist/jsonld/JsonLd.mjs +1 -0
- package/dist/jsonld/JsonLdError.d.mts +2 -0
- package/dist/jsonld/JsonLdError.mjs +1 -0
- package/dist/jsonld/index.d.mts +4 -0
- package/dist/jsonld/index.mjs +4 -0
- package/dist/lists-D-OpQ0Ir.mjs +77 -0
- package/dist/lists-D-OpQ0Ir.mjs.map +1 -0
- package/dist/loop-D5-gNx9K.mjs +21 -0
- package/dist/loop-D5-gNx9K.mjs.map +1 -0
- package/dist/loop-DZ2hXlr_.mjs +21 -0
- package/dist/loop-DZ2hXlr_.mjs.map +1 -0
- package/dist/n3/Isomorphism.d.mts +2 -0
- package/dist/n3/Isomorphism.mjs +1 -0
- package/dist/n3/Mapping.d.mts +2 -0
- package/dist/n3/Mapping.mjs +1 -0
- package/dist/n3/Model.d.mts +2 -0
- package/dist/n3/Model.mjs +1 -0
- package/dist/n3/N3.d.mts +2 -0
- package/dist/n3/N3.mjs +1 -0
- package/dist/n3/Reasoner.d.mts +2 -0
- package/dist/n3/Reasoner.mjs +2 -0
- package/dist/n3/Vocab.d.mts +2 -0
- package/dist/n3/Vocab.mjs +1 -0
- package/dist/n3/index.d.mts +7 -0
- package/dist/n3/index.mjs +7 -0
- package/dist/ntriples/Grammar.d.mts +2 -0
- package/dist/ntriples/Grammar.mjs +1 -0
- package/dist/ntriples/Lexical.d.mts +2 -0
- package/dist/ntriples/Lexical.mjs +1 -0
- package/dist/ntriples/NQuads.d.mts +2 -0
- package/dist/ntriples/NQuads.mjs +1 -0
- package/dist/ntriples/NTriples.d.mts +2 -0
- package/dist/ntriples/NTriples.mjs +1 -0
- package/dist/ntriples/index.d.mts +5 -0
- package/dist/ntriples/index.mjs +5 -0
- package/dist/rdfjson/RdfJson.d.mts +2 -0
- package/dist/rdfjson/RdfJson.mjs +1 -0
- package/dist/rdfjson/index.d.mts +2 -0
- package/dist/rdfjson/index.mjs +1 -0
- package/dist/rdfxml/RdfXml.d.mts +2 -0
- package/dist/rdfxml/RdfXml.mjs +1 -0
- package/dist/rdfxml/Xml.d.mts +2 -0
- package/dist/rdfxml/Xml.mjs +1 -0
- package/dist/rdfxml/index.d.mts +3 -0
- package/dist/rdfxml/index.mjs +3 -0
- package/dist/rolldown-runtime-D8jQpDG7.mjs +12 -0
- package/dist/serialize-96KBvKaf.mjs +1463 -0
- package/dist/serialize-96KBvKaf.mjs.map +1 -0
- package/dist/serialize-DsoXdM6n.d.mts +37 -0
- package/dist/shacl/Message.d.mts +2 -0
- package/dist/shacl/Message.mjs +1 -0
- package/dist/shacl/Path.d.mts +2 -0
- package/dist/shacl/Path.mjs +1 -0
- package/dist/shacl/Shapes.d.mts +2 -0
- package/dist/shacl/Shapes.mjs +1 -0
- package/dist/shacl/Sparql.d.mts +2 -0
- package/dist/shacl/Sparql.mjs +1 -0
- package/dist/shacl/ValidationReport.d.mts +2 -0
- package/dist/shacl/ValidationReport.mjs +1 -0
- package/dist/shacl/Validator.d.mts +2 -0
- package/dist/shacl/Validator.mjs +1 -0
- package/dist/shacl/Vocabulary.d.mts +2 -0
- package/dist/shacl/Vocabulary.mjs +1 -0
- package/dist/shacl/index.d.mts +9 -0
- package/dist/shacl/index.mjs +8 -0
- package/dist/shex/SemAct.d.mts +2 -0
- package/dist/shex/SemAct.mjs +1 -0
- package/dist/shex/ShExC.d.mts +2 -0
- package/dist/shex/ShExC.mjs +1 -0
- package/dist/shex/ShExError.d.mts +2 -0
- package/dist/shex/ShExError.mjs +1 -0
- package/dist/shex/ShExJ.d.mts +2 -0
- package/dist/shex/ShExJ.mjs +2 -0
- package/dist/shex/ShExR.d.mts +2 -0
- package/dist/shex/ShExR.mjs +1 -0
- package/dist/shex/ShapeMap.d.mts +2 -0
- package/dist/shex/ShapeMap.mjs +1 -0
- package/dist/shex/Structure.d.mts +2 -0
- package/dist/shex/Structure.mjs +2 -0
- package/dist/shex/Validator.d.mts +2 -0
- package/dist/shex/Validator.mjs +4 -0
- package/dist/shex/index.d.mts +9 -0
- package/dist/shex/index.mjs +9 -0
- package/dist/sparql/Algebra.d.mts +2 -0
- package/dist/sparql/Algebra.mjs +1 -0
- package/dist/sparql/Ast.d.mts +2 -0
- package/dist/sparql/Ast.mjs +1 -0
- package/dist/sparql/Bindings.d.mts +2 -0
- package/dist/sparql/Bindings.mjs +1 -0
- package/dist/sparql/ClientErrors.d.mts +2 -0
- package/dist/sparql/ClientErrors.mjs +1 -0
- package/dist/sparql/ClientFormats.d.mts +2 -0
- package/dist/sparql/ClientFormats.mjs +1 -0
- package/dist/sparql/Engine.d.mts +2 -0
- package/dist/sparql/Engine.mjs +1 -0
- package/dist/sparql/Errors.d.mts +2 -0
- package/dist/sparql/Errors.mjs +1 -0
- package/dist/sparql/Expression.d.mts +2 -0
- package/dist/sparql/Expression.mjs +1 -0
- package/dist/sparql/Federation.d.mts +2 -0
- package/dist/sparql/Federation.mjs +1 -0
- package/dist/sparql/Functions.d.mts +2 -0
- package/dist/sparql/Functions.mjs +1 -0
- package/dist/sparql/Generator.d.mts +2 -0
- package/dist/sparql/Generator.mjs +1 -0
- package/dist/sparql/GraphStore.d.mts +2 -0
- package/dist/sparql/GraphStore.mjs +1 -0
- package/dist/sparql/Optimizer.d.mts +2 -0
- package/dist/sparql/Optimizer.mjs +1 -0
- package/dist/sparql/Options.d.mts +2 -0
- package/dist/sparql/Options.mjs +1 -0
- package/dist/sparql/Parser.d.mts +2 -0
- package/dist/sparql/Parser.mjs +1 -0
- package/dist/sparql/Protocol.d.mts +2 -0
- package/dist/sparql/Protocol.mjs +1 -0
- package/dist/sparql/ProtocolErrors.d.mts +2 -0
- package/dist/sparql/ProtocolErrors.mjs +1 -0
- package/dist/sparql/QueryBuilder.d.mts +2 -0
- package/dist/sparql/QueryBuilder.mjs +1 -0
- package/dist/sparql/Results.d.mts +2 -0
- package/dist/sparql/Results.mjs +1 -0
- package/dist/sparql/ResultsStream.d.mts +2 -0
- package/dist/sparql/ResultsStream.mjs +1 -0
- package/dist/sparql/ServerFormats.d.mts +2 -0
- package/dist/sparql/ServerFormats.mjs +1 -0
- package/dist/sparql/ServiceDescription.d.mts +2 -0
- package/dist/sparql/ServiceDescription.mjs +1 -0
- package/dist/sparql/SparqlClient.d.mts +2 -0
- package/dist/sparql/SparqlClient.mjs +1 -0
- package/dist/sparql/SparqlServer.d.mts +2 -0
- package/dist/sparql/SparqlServer.mjs +1 -0
- package/dist/sparql/Store.d.mts +2 -0
- package/dist/sparql/Store.mjs +1 -0
- package/dist/sparql/TermSchema.d.mts +3 -0
- package/dist/sparql/TermSchema.mjs +2 -0
- package/dist/sparql/Testing.d.mts +2 -0
- package/dist/sparql/Testing.mjs +1 -0
- package/dist/sparql/Translate.d.mts +2 -0
- package/dist/sparql/Translate.mjs +1 -0
- package/dist/sparql/ai/Mcp.d.mts +2 -0
- package/dist/sparql/ai/Mcp.mjs +1 -0
- package/dist/sparql/ai/Tools.d.mts +2 -0
- package/dist/sparql/ai/Tools.mjs +1 -0
- package/dist/sparql/ai/index.d.mts +3 -0
- package/dist/sparql/ai/index.mjs +3 -0
- package/dist/sparql/index.d.mts +30 -0
- package/dist/sparql/index.mjs +29 -0
- package/dist/sparql/shacl/Evaluator.d.mts +2 -0
- package/dist/sparql/shacl/Evaluator.mjs +1 -0
- package/dist/sparql/shacl/Query.d.mts +2 -0
- package/dist/sparql/shacl/Query.mjs +1 -0
- package/dist/sparql/shacl/index.d.mts +3 -0
- package/dist/sparql/shacl/index.mjs +3 -0
- package/dist/sparql/sql/Dialect.d.mts +2 -0
- package/dist/sparql/sql/Dialect.mjs +1 -0
- package/dist/sparql/sql/SqlStore.d.mts +2 -0
- package/dist/sparql/sql/SqlStore.mjs +1 -0
- package/dist/sparql/sql/Translation.d.mts +2 -0
- package/dist/sparql/sql/Translation.mjs +1 -0
- package/dist/sparql/sql/index.d.mts +4 -0
- package/dist/sparql/sql/index.mjs +4 -0
- package/dist/stringMap-D5YIpYtR.mjs +38 -0
- package/dist/stringMap-D5YIpYtR.mjs.map +1 -0
- package/dist/tokens-C6BzeodQ.mjs +24 -0
- package/dist/tokens-C6BzeodQ.mjs.map +1 -0
- package/dist/turtle/Grammar.d.mts +3 -0
- package/dist/turtle/Grammar.mjs +3 -0
- package/dist/turtle/Manifest.d.mts +2 -0
- package/dist/turtle/Manifest.mjs +1 -0
- package/dist/turtle/TriG.d.mts +2 -0
- package/dist/turtle/TriG.mjs +1 -0
- package/dist/turtle/Turtle.d.mts +2 -0
- package/dist/turtle/Turtle.mjs +1 -0
- package/dist/turtle/index.d.mts +5 -0
- package/dist/turtle/index.mjs +5 -0
- package/dist/xmp/DublinCore.d.mts +2 -0
- package/dist/xmp/DublinCore.mjs +1 -0
- package/dist/xmp/Exif.d.mts +2 -0
- package/dist/xmp/Exif.mjs +1 -0
- package/dist/xmp/Extract.d.mts +2 -0
- package/dist/xmp/Extract.mjs +1 -0
- package/dist/xmp/Metadata.d.mts +2 -0
- package/dist/xmp/Metadata.mjs +1 -0
- package/dist/xmp/Namespaces.d.mts +2 -0
- package/dist/xmp/Namespaces.mjs +1 -0
- package/dist/xmp/Packet.d.mts +2 -0
- package/dist/xmp/Packet.mjs +1 -0
- package/dist/xmp/Pdf.d.mts +2 -0
- package/dist/xmp/Pdf.mjs +1 -0
- package/dist/xmp/PdfA.d.mts +2 -0
- package/dist/xmp/PdfA.mjs +1 -0
- package/dist/xmp/Photoshop.d.mts +2 -0
- package/dist/xmp/Photoshop.mjs +1 -0
- package/dist/xmp/Tiff.d.mts +2 -0
- package/dist/xmp/Tiff.mjs +1 -0
- package/dist/xmp/Xmp.d.mts +2 -0
- package/dist/xmp/Xmp.mjs +3 -0
- package/dist/xmp/XmpBasic.d.mts +2 -0
- package/dist/xmp/XmpBasic.mjs +1 -0
- package/dist/xmp/XmpMM.d.mts +2 -0
- package/dist/xmp/XmpMM.mjs +1 -0
- package/dist/xmp/XmpRights.d.mts +2 -0
- package/dist/xmp/XmpRights.mjs +1 -0
- package/dist/xmp/index.d.mts +15 -0
- package/dist/xmp/index.mjs +15 -0
- package/package.json +187 -3
- package/src/Dataset.ts +1085 -0
- package/src/Iri.ts +322 -0
- package/src/Isomorphism.ts +319 -0
- package/src/LanguageTag.ts +98 -0
- package/src/Namespace.ts +100 -0
- package/src/PrefixMap.ts +117 -0
- package/src/RdfJs.ts +146 -0
- package/src/Rdfs.ts +241 -0
- package/src/Reification.ts +103 -0
- package/src/Resource.ts +873 -0
- package/src/Serialization.ts +775 -0
- package/src/Term.ts +1300 -0
- package/src/TermCodec.ts +505 -0
- package/src/TermJson.ts +313 -0
- package/src/Vocab.ts +161 -0
- package/src/Xsd.ts +573 -0
- package/src/csvw/Csv2Json.ts +265 -0
- package/src/csvw/Csv2Rdf.ts +268 -0
- package/src/csvw/Datatype.ts +589 -0
- package/src/csvw/Metadata.ts +1523 -0
- package/src/csvw/Processor.ts +276 -0
- package/src/csvw/Report.ts +135 -0
- package/src/csvw/Table.ts +759 -0
- package/src/csvw/index.ts +22 -0
- package/src/csvw/internal/dateFormat.ts +202 -0
- package/src/csvw/internal/json.ts +104 -0
- package/src/csvw/internal/numberFormat.ts +369 -0
- package/src/csvw/internal/object.ts +23 -0
- package/src/csvw/internal/uriTemplate.ts +130 -0
- package/src/csvw/internal/url.ts +93 -0
- package/src/csvw/internal/vocab.ts +282 -0
- package/src/index.ts +40 -0
- package/src/internal/arbitrary.ts +148 -0
- package/src/internal/loop.ts +24 -0
- package/src/internal/pending.ts +20 -0
- package/src/internal/textDecoder.ts +183 -0
- package/src/jsonld/DocumentLoader.ts +512 -0
- package/src/jsonld/JsonLd.ts +847 -0
- package/src/jsonld/JsonLdError.ts +105 -0
- package/src/jsonld/index.ts +13 -0
- package/src/jsonld/internal/compact.ts +852 -0
- package/src/jsonld/internal/context.ts +781 -0
- package/src/jsonld/internal/expand.ts +614 -0
- package/src/jsonld/internal/flatten.ts +243 -0
- package/src/jsonld/internal/frame.ts +559 -0
- package/src/jsonld/internal/iri.ts +52 -0
- package/src/jsonld/internal/json.ts +19 -0
- package/src/jsonld/internal/linkHeader.ts +60 -0
- package/src/jsonld/internal/rdf.ts +481 -0
- package/src/jsonld/internal/util.ts +367 -0
- package/src/n3/Isomorphism.ts +476 -0
- package/src/n3/Mapping.ts +332 -0
- package/src/n3/Model.ts +696 -0
- package/src/n3/N3.ts +237 -0
- package/src/n3/Reasoner.ts +568 -0
- package/src/n3/Vocab.ts +111 -0
- package/src/n3/index.ts +21 -0
- package/src/n3/internal/builtins.ts +668 -0
- package/src/n3/internal/guards.ts +23 -0
- package/src/n3/internal/lists.ts +106 -0
- package/src/n3/internal/loop.ts +28 -0
- package/src/n3/internal/parser.ts +1032 -0
- package/src/n3/internal/writer.ts +344 -0
- package/src/ntriples/Grammar.ts +317 -0
- package/src/ntriples/Lexical.ts +321 -0
- package/src/ntriples/NQuads.ts +140 -0
- package/src/ntriples/NTriples.ts +143 -0
- package/src/ntriples/index.ts +14 -0
- package/src/ntriples/internal/codec.ts +229 -0
- package/src/ntriples/internal/lineParser.ts +326 -0
- package/src/ntriples/internal/loop.ts +14 -0
- package/src/rdfjson/RdfJson.ts +806 -0
- package/src/rdfjson/index.ts +9 -0
- package/src/rdfjson/internal/json.ts +19 -0
- package/src/rdfxml/RdfXml.ts +1408 -0
- package/src/rdfxml/Xml.ts +419 -0
- package/src/rdfxml/index.ts +11 -0
- package/src/rdfxml/internal/chars.ts +73 -0
- package/src/rdfxml/internal/loop.ts +24 -0
- package/src/rdfxml/internal/parser.ts +1265 -0
- package/src/shacl/Message.ts +102 -0
- package/src/shacl/Path.ts +483 -0
- package/src/shacl/Shapes.ts +913 -0
- package/src/shacl/Sparql.ts +128 -0
- package/src/shacl/ValidationReport.ts +438 -0
- package/src/shacl/Validator.ts +1156 -0
- package/src/shacl/Vocabulary.ts +180 -0
- package/src/shacl/index.ts +22 -0
- package/src/shacl/internal/compare.ts +128 -0
- package/src/shacl/internal/regex.ts +56 -0
- package/src/shex/SemAct.ts +197 -0
- package/src/shex/ShExC.ts +415 -0
- package/src/shex/ShExError.ts +71 -0
- package/src/shex/ShExJ.ts +893 -0
- package/src/shex/ShExR.ts +640 -0
- package/src/shex/ShapeMap.ts +385 -0
- package/src/shex/Structure.ts +467 -0
- package/src/shex/Validator.ts +395 -0
- package/src/shex/index.ts +24 -0
- package/src/shex/internal/engine.ts +682 -0
- package/src/shex/internal/iterate.ts +14 -0
- package/src/shex/internal/json.ts +12 -0
- package/src/shex/internal/lexer.ts +56 -0
- package/src/shex/internal/nodeConstraint.ts +368 -0
- package/src/shex/internal/shexcLexer.ts +387 -0
- package/src/shex/internal/shexcParser.ts +1312 -0
- package/src/shex/internal/tokens.ts +41 -0
- package/src/shex/internal/xpathRegex.ts +290 -0
- package/src/sparql/Algebra.ts +914 -0
- package/src/sparql/Ast.ts +1344 -0
- package/src/sparql/Bindings.ts +272 -0
- package/src/sparql/ClientErrors.ts +156 -0
- package/src/sparql/ClientFormats.ts +70 -0
- package/src/sparql/Engine.ts +699 -0
- package/src/sparql/Errors.ts +30 -0
- package/src/sparql/Expression.ts +360 -0
- package/src/sparql/Federation.ts +187 -0
- package/src/sparql/Functions.ts +689 -0
- package/src/sparql/Generator.ts +426 -0
- package/src/sparql/GraphStore.ts +341 -0
- package/src/sparql/Optimizer.ts +230 -0
- package/src/sparql/Options.ts +191 -0
- package/src/sparql/Parser.ts +173 -0
- package/src/sparql/Protocol.ts +342 -0
- package/src/sparql/ProtocolErrors.ts +113 -0
- package/src/sparql/QueryBuilder.ts +953 -0
- package/src/sparql/Results.ts +844 -0
- package/src/sparql/ResultsStream.ts +771 -0
- package/src/sparql/ServerFormats.ts +75 -0
- package/src/sparql/ServiceDescription.ts +130 -0
- package/src/sparql/SparqlClient.ts +947 -0
- package/src/sparql/SparqlServer.ts +528 -0
- package/src/sparql/Store.ts +311 -0
- package/src/sparql/TermSchema.ts +20 -0
- package/src/sparql/Testing.ts +114 -0
- package/src/sparql/Translate.ts +407 -0
- package/src/sparql/ai/Mcp.ts +43 -0
- package/src/sparql/ai/Tools.ts +481 -0
- package/src/sparql/ai/index.ts +11 -0
- package/src/sparql/index.ts +64 -0
- package/src/sparql/internal/evaluator.ts +947 -0
- package/src/sparql/internal/hash.ts +418 -0
- package/src/sparql/internal/json.ts +12 -0
- package/src/sparql/internal/lexer.ts +488 -0
- package/src/sparql/internal/loop.ts +24 -0
- package/src/sparql/internal/parser.ts +2215 -0
- package/src/sparql/internal/prefetch.ts +46 -0
- package/src/sparql/internal/stringMap.ts +39 -0
- package/src/sparql/internal/textResults.ts +226 -0
- package/src/sparql/internal/values.ts +550 -0
- package/src/sparql/shacl/Evaluator.ts +478 -0
- package/src/sparql/shacl/Query.ts +574 -0
- package/src/sparql/shacl/index.ts +12 -0
- package/src/sparql/sql/Dialect.ts +246 -0
- package/src/sparql/sql/SqlStore.ts +1080 -0
- package/src/sparql/sql/Translation.ts +1898 -0
- package/src/sparql/sql/index.ts +17 -0
- package/src/sparql/sql/internal/encoding.ts +313 -0
- package/src/turtle/Grammar.ts +286 -0
- package/src/turtle/Manifest.ts +215 -0
- package/src/turtle/TriG.ts +158 -0
- package/src/turtle/Turtle.ts +166 -0
- package/src/turtle/index.ts +14 -0
- package/src/turtle/internal/loop.ts +23 -0
- package/src/turtle/internal/parse.ts +112 -0
- package/src/turtle/internal/parser.ts +1303 -0
- package/src/turtle/internal/serialize.ts +79 -0
- package/src/turtle/internal/streamWriter.ts +128 -0
- package/src/turtle/internal/writer.ts +898 -0
- package/src/xmp/DublinCore.ts +147 -0
- package/src/xmp/Exif.ts +109 -0
- package/src/xmp/Extract.ts +351 -0
- package/src/xmp/Metadata.ts +703 -0
- package/src/xmp/Namespaces.ts +228 -0
- package/src/xmp/Packet.ts +297 -0
- package/src/xmp/Pdf.ts +99 -0
- package/src/xmp/PdfA.ts +280 -0
- package/src/xmp/Photoshop.ts +275 -0
- package/src/xmp/Tiff.ts +196 -0
- package/src/xmp/Xmp.ts +430 -0
- package/src/xmp/XmpBasic.ts +90 -0
- package/src/xmp/XmpMM.ts +82 -0
- package/src/xmp/XmpRights.ts +83 -0
- package/src/xmp/index.ts +36 -0
- package/src/xmp/internal/accessors.ts +72 -0
- package/src/xmp/internal/xml.ts +63 -0
|
@@ -0,0 +1,913 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shapes graphs: parsing an RDF shapes graph into a typed, validated model of
|
|
3
|
+
* node shapes and property shapes with their targets and constraints
|
|
4
|
+
* (SHACL Core §2–§4, plus the SHACL-SPARQL constructs needed to delegate to a
|
|
5
|
+
* `Sparql.SparqlConstraintEvaluator`).
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { Effect } from "effect"
|
|
9
|
+
* import { Shapes } from "@thomasfosterau/effect-rdf/shacl"
|
|
10
|
+
*
|
|
11
|
+
* const program = Effect.gen(function* () {
|
|
12
|
+
* const shapes = yield* Shapes.parse(shapesDataset)
|
|
13
|
+
* for (const shape of shapes.shapes) console.log(shape._tag, shape.id.key)
|
|
14
|
+
* })
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @since 0.1.0
|
|
18
|
+
*/
|
|
19
|
+
import { Dataset, Rdfs, Term, Vocab, Xsd } from '../index.ts';
|
|
20
|
+
import * as Arr from 'effect/Array';
|
|
21
|
+
import * as Effect from 'effect/Effect';
|
|
22
|
+
import * as Match from 'effect/Match';
|
|
23
|
+
import * as MutableHashMap from 'effect/MutableHashMap';
|
|
24
|
+
import * as MutableHashSet from 'effect/MutableHashSet';
|
|
25
|
+
import * as Option from 'effect/Option';
|
|
26
|
+
import * as Predicate from 'effect/Predicate';
|
|
27
|
+
import * as Record from 'effect/Record';
|
|
28
|
+
import * as Result from 'effect/Result';
|
|
29
|
+
import * as Schema from 'effect/Schema';
|
|
30
|
+
import * as Regex from './internal/regex.ts';
|
|
31
|
+
import * as Path from './Path.ts';
|
|
32
|
+
import { SH, sh } from './Vocabulary.ts';
|
|
33
|
+
|
|
34
|
+
const { rdfs, xsd } = Vocab;
|
|
35
|
+
|
|
36
|
+
// -----------------------------------------------------------------------------
|
|
37
|
+
// Errors
|
|
38
|
+
// -----------------------------------------------------------------------------
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The shapes graph is ill-formed (§3.4.1 "ill-formed shapes graph"), so it
|
|
42
|
+
* cannot be used for validation.
|
|
43
|
+
*
|
|
44
|
+
* @since 0.1.0
|
|
45
|
+
* @category errors
|
|
46
|
+
*/
|
|
47
|
+
export class ShapesGraphError extends Schema.TaggedError<ShapesGraphError>()('ShapesGraphError', {
|
|
48
|
+
message: Schema.String,
|
|
49
|
+
/** The N-Triples form of the offending node, when known. */
|
|
50
|
+
node: Schema.optional(Schema.String),
|
|
51
|
+
}) {}
|
|
52
|
+
|
|
53
|
+
// -----------------------------------------------------------------------------
|
|
54
|
+
// Models
|
|
55
|
+
// -----------------------------------------------------------------------------
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The identifier of a shape: an IRI or a blank node of the shapes graph.
|
|
59
|
+
*
|
|
60
|
+
* @since 0.1.0
|
|
61
|
+
* @category models
|
|
62
|
+
*/
|
|
63
|
+
export type ShapeId = Term.NamedNode | Term.BlankNode;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* A target declaration (§2.1.3).
|
|
67
|
+
*
|
|
68
|
+
* @since 0.1.0
|
|
69
|
+
* @category models
|
|
70
|
+
*/
|
|
71
|
+
export type Target =
|
|
72
|
+
| { readonly _tag: 'TargetNode'; readonly node: Term.GroundTerm }
|
|
73
|
+
| { readonly _tag: 'TargetClass'; readonly class: Term.Resource; readonly implicit: boolean }
|
|
74
|
+
| { readonly _tag: 'TargetSubjectsOf'; readonly predicate: Term.NamedNode }
|
|
75
|
+
| { readonly _tag: 'TargetObjectsOf'; readonly predicate: Term.NamedNode }
|
|
76
|
+
| {
|
|
77
|
+
/** A SPARQL-based target or custom target type (`sh:target`). */
|
|
78
|
+
readonly _tag: 'SparqlTarget';
|
|
79
|
+
readonly node: Term.GroundTerm;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The node kinds of `sh:nodeKind`.
|
|
84
|
+
*
|
|
85
|
+
* @since 0.1.0
|
|
86
|
+
* @category models
|
|
87
|
+
*/
|
|
88
|
+
export type NodeKind =
|
|
89
|
+
| 'BlankNode'
|
|
90
|
+
| 'IRI'
|
|
91
|
+
| 'Literal'
|
|
92
|
+
| 'BlankNodeOrIRI'
|
|
93
|
+
| 'BlankNodeOrLiteral'
|
|
94
|
+
| 'IRIOrLiteral';
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* A constraint on a value node set, i.e. an instance of a constraint
|
|
98
|
+
* component with its parameter values (§2.2, §4).
|
|
99
|
+
*
|
|
100
|
+
* @since 0.1.0
|
|
101
|
+
* @category models
|
|
102
|
+
*/
|
|
103
|
+
export type Constraint =
|
|
104
|
+
| { readonly _tag: 'Class'; readonly class: Term.Resource }
|
|
105
|
+
| { readonly _tag: 'Datatype'; readonly datatype: Term.NamedNode }
|
|
106
|
+
| { readonly _tag: 'NodeKind'; readonly nodeKind: NodeKind }
|
|
107
|
+
| { readonly _tag: 'MinCount'; readonly minCount: number }
|
|
108
|
+
| { readonly _tag: 'MaxCount'; readonly maxCount: number }
|
|
109
|
+
| { readonly _tag: 'MinExclusive'; readonly value: Term.GroundTerm }
|
|
110
|
+
| { readonly _tag: 'MinInclusive'; readonly value: Term.GroundTerm }
|
|
111
|
+
| { readonly _tag: 'MaxExclusive'; readonly value: Term.GroundTerm }
|
|
112
|
+
| { readonly _tag: 'MaxInclusive'; readonly value: Term.GroundTerm }
|
|
113
|
+
| { readonly _tag: 'MinLength'; readonly minLength: number }
|
|
114
|
+
| { readonly _tag: 'MaxLength'; readonly maxLength: number }
|
|
115
|
+
| {
|
|
116
|
+
readonly _tag: 'Pattern';
|
|
117
|
+
readonly pattern: string;
|
|
118
|
+
readonly flags: string;
|
|
119
|
+
readonly regex: RegExp;
|
|
120
|
+
}
|
|
121
|
+
| { readonly _tag: 'LanguageIn'; readonly languages: ReadonlyArray<string> }
|
|
122
|
+
| { readonly _tag: 'UniqueLang' }
|
|
123
|
+
| { readonly _tag: 'Equals'; readonly predicate: Term.NamedNode }
|
|
124
|
+
| { readonly _tag: 'Disjoint'; readonly predicate: Term.NamedNode }
|
|
125
|
+
| { readonly _tag: 'LessThan'; readonly predicate: Term.NamedNode }
|
|
126
|
+
| { readonly _tag: 'LessThanOrEquals'; readonly predicate: Term.NamedNode }
|
|
127
|
+
| { readonly _tag: 'Not'; readonly shape: ShapeId }
|
|
128
|
+
| { readonly _tag: 'And'; readonly shapes: ReadonlyArray<ShapeId> }
|
|
129
|
+
| { readonly _tag: 'Or'; readonly shapes: ReadonlyArray<ShapeId> }
|
|
130
|
+
| { readonly _tag: 'Xone'; readonly shapes: ReadonlyArray<ShapeId> }
|
|
131
|
+
| { readonly _tag: 'Node'; readonly shape: ShapeId }
|
|
132
|
+
| { readonly _tag: 'Property'; readonly shape: ShapeId }
|
|
133
|
+
| {
|
|
134
|
+
readonly _tag: 'QualifiedMinCount';
|
|
135
|
+
readonly shape: ShapeId;
|
|
136
|
+
readonly count: number;
|
|
137
|
+
readonly disjoint: boolean;
|
|
138
|
+
/** Sibling qualified value shapes (only used when `disjoint`). */
|
|
139
|
+
readonly siblings: ReadonlyArray<ShapeId>;
|
|
140
|
+
}
|
|
141
|
+
| {
|
|
142
|
+
readonly _tag: 'QualifiedMaxCount';
|
|
143
|
+
readonly shape: ShapeId;
|
|
144
|
+
readonly count: number;
|
|
145
|
+
readonly disjoint: boolean;
|
|
146
|
+
readonly siblings: ReadonlyArray<ShapeId>;
|
|
147
|
+
}
|
|
148
|
+
| {
|
|
149
|
+
readonly _tag: 'Closed';
|
|
150
|
+
readonly ignoredProperties: ReadonlyArray<Term.NamedNode>;
|
|
151
|
+
/** Predicates allowed by `sh:property` predicate paths and `sh:ignoredProperties`. */
|
|
152
|
+
readonly allowedProperties: ReadonlyArray<Term.NamedNode>;
|
|
153
|
+
}
|
|
154
|
+
| { readonly _tag: 'HasValue'; readonly value: Term.GroundTerm }
|
|
155
|
+
| { readonly _tag: 'In'; readonly values: ReadonlyArray<Term.GroundTerm> }
|
|
156
|
+
| SparqlConstraint
|
|
157
|
+
| ComponentConstraint;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* A SHACL-SPARQL constraint (`sh:sparql`), evaluated by a
|
|
161
|
+
* `Sparql.SparqlConstraintEvaluator`.
|
|
162
|
+
*
|
|
163
|
+
* @since 0.1.0
|
|
164
|
+
* @category models
|
|
165
|
+
*/
|
|
166
|
+
export interface SparqlConstraint {
|
|
167
|
+
readonly _tag: 'Sparql';
|
|
168
|
+
/** The `sh:SPARQLConstraint` node in the shapes graph. */
|
|
169
|
+
readonly node: Term.NamedNode | Term.BlankNode;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* An instance of a custom (SPARQL-based) constraint component declared in the
|
|
174
|
+
* shapes graph, evaluated by a `Sparql.SparqlConstraintEvaluator`.
|
|
175
|
+
*
|
|
176
|
+
* @since 0.1.0
|
|
177
|
+
* @category models
|
|
178
|
+
*/
|
|
179
|
+
export interface ComponentConstraint {
|
|
180
|
+
readonly _tag: 'Component';
|
|
181
|
+
readonly component: Term.NamedNode | Term.BlankNode;
|
|
182
|
+
/** The parameter bindings of this constraint, keyed by parameter path. */
|
|
183
|
+
readonly parameters: ReadonlyArray<{
|
|
184
|
+
readonly path: Term.NamedNode;
|
|
185
|
+
readonly value: Term.GroundTerm;
|
|
186
|
+
}>;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* The tags of all constraint kinds.
|
|
191
|
+
*
|
|
192
|
+
* @since 0.1.0
|
|
193
|
+
* @category models
|
|
194
|
+
*/
|
|
195
|
+
export type ConstraintTag = Constraint['_tag'];
|
|
196
|
+
|
|
197
|
+
interface ShapeBase {
|
|
198
|
+
readonly id: ShapeId;
|
|
199
|
+
readonly targets: ReadonlyArray<Target>;
|
|
200
|
+
readonly constraints: ReadonlyArray<Constraint>;
|
|
201
|
+
/** `sh:severity`, defaulting to `sh:Violation`. */
|
|
202
|
+
readonly severity: Term.NamedNode;
|
|
203
|
+
/** `sh:message` values. */
|
|
204
|
+
readonly messages: ReadonlyArray<Term.Literal>;
|
|
205
|
+
/** `sh:deactivated true`. */
|
|
206
|
+
readonly deactivated: boolean;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* A node shape (§2.2): its constraints apply to the focus node itself.
|
|
211
|
+
*
|
|
212
|
+
* @since 0.1.0
|
|
213
|
+
* @category models
|
|
214
|
+
*/
|
|
215
|
+
export interface NodeShape extends ShapeBase {
|
|
216
|
+
readonly _tag: 'NodeShape';
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* A property shape (§2.3): its constraints apply to the values reachable
|
|
221
|
+
* from the focus node via `path`.
|
|
222
|
+
*
|
|
223
|
+
* @since 0.1.0
|
|
224
|
+
* @category models
|
|
225
|
+
*/
|
|
226
|
+
export interface PropertyShape extends ShapeBase {
|
|
227
|
+
readonly _tag: 'PropertyShape';
|
|
228
|
+
readonly path: Path.Path;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* @since 0.1.0
|
|
233
|
+
* @category models
|
|
234
|
+
*/
|
|
235
|
+
export type Shape = NodeShape | PropertyShape;
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* A parsed shapes graph.
|
|
239
|
+
*
|
|
240
|
+
* @since 0.1.0
|
|
241
|
+
* @category models
|
|
242
|
+
*/
|
|
243
|
+
export interface ShapesGraph {
|
|
244
|
+
readonly _tag: 'ShapesGraph';
|
|
245
|
+
/** The RDF shapes graph this model was parsed from. */
|
|
246
|
+
readonly dataset: Dataset.Dataset;
|
|
247
|
+
/** Every shape of the shapes graph, in a deterministic order. */
|
|
248
|
+
readonly shapes: ReadonlyArray<Shape>;
|
|
249
|
+
/** Shapes indexed by the N-Triples form of their identifier. */
|
|
250
|
+
readonly index: ReadonlyMap<string, Shape>;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// -----------------------------------------------------------------------------
|
|
254
|
+
// Accessors
|
|
255
|
+
// -----------------------------------------------------------------------------
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* @since 0.1.0
|
|
259
|
+
* @category guards
|
|
260
|
+
*/
|
|
261
|
+
export const isShapesGraph = (u: unknown): u is ShapesGraph => Predicate.isTagged(u, 'ShapesGraph');
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Looks up a shape by its identifier.
|
|
265
|
+
*
|
|
266
|
+
* @since 0.1.0
|
|
267
|
+
* @category accessors
|
|
268
|
+
*/
|
|
269
|
+
export const get = (self: ShapesGraph, id: Term.Term): Option.Option<Shape> =>
|
|
270
|
+
Option.fromNullishOr(self.index.get(id.key));
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* The shapes that declare at least one target and are not deactivated.
|
|
274
|
+
*
|
|
275
|
+
* @since 0.1.0
|
|
276
|
+
* @category accessors
|
|
277
|
+
*/
|
|
278
|
+
export const targetedShapes = (self: ShapesGraph): ReadonlyArray<Shape> =>
|
|
279
|
+
self.shapes.filter((s) => !s.deactivated && Arr.isReadonlyArrayNonEmpty(s.targets));
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Whether the shapes graph uses SHACL-SPARQL features (SPARQL constraints,
|
|
283
|
+
* SPARQL-based constraint components or SPARQL-based targets).
|
|
284
|
+
*
|
|
285
|
+
* @since 0.1.0
|
|
286
|
+
* @category accessors
|
|
287
|
+
*/
|
|
288
|
+
export const usesSparql = (self: ShapesGraph): boolean =>
|
|
289
|
+
self.shapes.some(
|
|
290
|
+
(s) =>
|
|
291
|
+
s.targets.some(Predicate.isTagged('SparqlTarget')) ||
|
|
292
|
+
s.constraints.some(
|
|
293
|
+
(c) => Predicate.isTagged(c, 'Sparql') || Predicate.isTagged(c, 'Component'),
|
|
294
|
+
),
|
|
295
|
+
);
|
|
296
|
+
|
|
297
|
+
const componentNames: Record.ReadonlyRecord<
|
|
298
|
+
Exclude<ConstraintTag, 'Sparql' | 'Component'>,
|
|
299
|
+
string
|
|
300
|
+
> = {
|
|
301
|
+
Class: 'ClassConstraintComponent',
|
|
302
|
+
Datatype: 'DatatypeConstraintComponent',
|
|
303
|
+
NodeKind: 'NodeKindConstraintComponent',
|
|
304
|
+
MinCount: 'MinCountConstraintComponent',
|
|
305
|
+
MaxCount: 'MaxCountConstraintComponent',
|
|
306
|
+
MinExclusive: 'MinExclusiveConstraintComponent',
|
|
307
|
+
MinInclusive: 'MinInclusiveConstraintComponent',
|
|
308
|
+
MaxExclusive: 'MaxExclusiveConstraintComponent',
|
|
309
|
+
MaxInclusive: 'MaxInclusiveConstraintComponent',
|
|
310
|
+
MinLength: 'MinLengthConstraintComponent',
|
|
311
|
+
MaxLength: 'MaxLengthConstraintComponent',
|
|
312
|
+
Pattern: 'PatternConstraintComponent',
|
|
313
|
+
LanguageIn: 'LanguageInConstraintComponent',
|
|
314
|
+
UniqueLang: 'UniqueLangConstraintComponent',
|
|
315
|
+
Equals: 'EqualsConstraintComponent',
|
|
316
|
+
Disjoint: 'DisjointConstraintComponent',
|
|
317
|
+
LessThan: 'LessThanConstraintComponent',
|
|
318
|
+
LessThanOrEquals: 'LessThanOrEqualsConstraintComponent',
|
|
319
|
+
Not: 'NotConstraintComponent',
|
|
320
|
+
And: 'AndConstraintComponent',
|
|
321
|
+
Or: 'OrConstraintComponent',
|
|
322
|
+
Xone: 'XoneConstraintComponent',
|
|
323
|
+
Node: 'NodeConstraintComponent',
|
|
324
|
+
Property: 'PropertyConstraintComponent',
|
|
325
|
+
QualifiedMinCount: 'QualifiedMinCountConstraintComponent',
|
|
326
|
+
QualifiedMaxCount: 'QualifiedMaxCountConstraintComponent',
|
|
327
|
+
Closed: 'ClosedConstraintComponent',
|
|
328
|
+
HasValue: 'HasValueConstraintComponent',
|
|
329
|
+
In: 'InConstraintComponent',
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* The constraint component IRI of a constraint (e.g.
|
|
334
|
+
* `sh:MinCountConstraintComponent`).
|
|
335
|
+
*
|
|
336
|
+
* @since 0.1.0
|
|
337
|
+
* @category accessors
|
|
338
|
+
*/
|
|
339
|
+
export const componentOf = (constraint: Constraint): Term.NamedNode | Term.BlankNode => {
|
|
340
|
+
return Match.value(constraint).pipe(
|
|
341
|
+
Match.tag('Sparql', () => sh.SPARQLConstraintComponent),
|
|
342
|
+
Match.tag('Component', (custom) => custom.component),
|
|
343
|
+
Match.orElse((core) => Term.namedNode(SH + componentNames[core._tag])),
|
|
344
|
+
);
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
// -----------------------------------------------------------------------------
|
|
348
|
+
// Parsing
|
|
349
|
+
// -----------------------------------------------------------------------------
|
|
350
|
+
|
|
351
|
+
class ParseFailure {
|
|
352
|
+
readonly message: string;
|
|
353
|
+
readonly node: Option.Option<Term.Term>;
|
|
354
|
+
constructor(message: string, node: Option.Option<Term.Term>) {
|
|
355
|
+
this.message = message;
|
|
356
|
+
this.node = node;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
const TRUE = Term.literal('true', xsd.boolean).key;
|
|
361
|
+
|
|
362
|
+
const nodeKinds: Record.ReadonlyRecord<string, NodeKind> = Record.fromEntries(
|
|
363
|
+
Arr.map(
|
|
364
|
+
[
|
|
365
|
+
'BlankNode',
|
|
366
|
+
'IRI',
|
|
367
|
+
'Literal',
|
|
368
|
+
'BlankNodeOrIRI',
|
|
369
|
+
'BlankNodeOrLiteral',
|
|
370
|
+
'IRIOrLiteral',
|
|
371
|
+
] as const,
|
|
372
|
+
(k) => [SH + k, k] as const,
|
|
373
|
+
),
|
|
374
|
+
);
|
|
375
|
+
|
|
376
|
+
/** Parameters of the core constraint components (§4). */
|
|
377
|
+
const coreParameters: ReadonlyArray<Term.NamedNode> = [
|
|
378
|
+
sh.class,
|
|
379
|
+
sh.datatype,
|
|
380
|
+
sh.nodeKind,
|
|
381
|
+
sh.minCount,
|
|
382
|
+
sh.maxCount,
|
|
383
|
+
sh.minExclusive,
|
|
384
|
+
sh.minInclusive,
|
|
385
|
+
sh.maxExclusive,
|
|
386
|
+
sh.maxInclusive,
|
|
387
|
+
sh.minLength,
|
|
388
|
+
sh.maxLength,
|
|
389
|
+
sh.pattern,
|
|
390
|
+
sh.flags,
|
|
391
|
+
sh.languageIn,
|
|
392
|
+
sh.uniqueLang,
|
|
393
|
+
sh.equals,
|
|
394
|
+
sh.disjoint,
|
|
395
|
+
sh.lessThan,
|
|
396
|
+
sh.lessThanOrEquals,
|
|
397
|
+
sh.not,
|
|
398
|
+
sh.and,
|
|
399
|
+
sh.or,
|
|
400
|
+
sh.xone,
|
|
401
|
+
sh.node,
|
|
402
|
+
sh.property,
|
|
403
|
+
sh.qualifiedValueShape,
|
|
404
|
+
sh.qualifiedValueShapesDisjoint,
|
|
405
|
+
sh.qualifiedMinCount,
|
|
406
|
+
sh.qualifiedMaxCount,
|
|
407
|
+
sh.closed,
|
|
408
|
+
sh.ignoredProperties,
|
|
409
|
+
sh.hasValue,
|
|
410
|
+
sh.in,
|
|
411
|
+
sh.sparql,
|
|
412
|
+
];
|
|
413
|
+
|
|
414
|
+
const targetPredicates: ReadonlyArray<Term.NamedNode> = [
|
|
415
|
+
sh.targetNode,
|
|
416
|
+
sh.targetClass,
|
|
417
|
+
sh.targetSubjectsOf,
|
|
418
|
+
sh.targetObjectsOf,
|
|
419
|
+
sh.target,
|
|
420
|
+
];
|
|
421
|
+
|
|
422
|
+
const rangeParameters = [
|
|
423
|
+
[sh.minExclusive, 'MinExclusive'],
|
|
424
|
+
[sh.minInclusive, 'MinInclusive'],
|
|
425
|
+
[sh.maxExclusive, 'MaxExclusive'],
|
|
426
|
+
[sh.maxInclusive, 'MaxInclusive'],
|
|
427
|
+
] as const;
|
|
428
|
+
|
|
429
|
+
const pairParameters = [
|
|
430
|
+
[sh.equals, 'Equals'],
|
|
431
|
+
[sh.disjoint, 'Disjoint'],
|
|
432
|
+
[sh.lessThan, 'LessThan'],
|
|
433
|
+
[sh.lessThanOrEquals, 'LessThanOrEquals'],
|
|
434
|
+
] as const;
|
|
435
|
+
|
|
436
|
+
const logicalParameters = [
|
|
437
|
+
[sh.and, 'And'],
|
|
438
|
+
[sh.or, 'Or'],
|
|
439
|
+
[sh.xone, 'Xone'],
|
|
440
|
+
] as const;
|
|
441
|
+
|
|
442
|
+
interface ComponentDeclaration {
|
|
443
|
+
readonly component: Term.NamedNode | Term.BlankNode;
|
|
444
|
+
readonly mandatory: ReadonlyArray<Term.NamedNode>;
|
|
445
|
+
readonly optional: ReadonlyArray<Term.NamedNode>;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
type ComponentParameter = ComponentConstraint['parameters'][number];
|
|
449
|
+
|
|
450
|
+
const isShapeId: (t: Term.Term) => t is ShapeId = Term.isResource;
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* Parses a shapes graph synchronously, returning a `Result`.
|
|
454
|
+
*
|
|
455
|
+
* @since 0.1.0
|
|
456
|
+
* @category parsing
|
|
457
|
+
*/
|
|
458
|
+
export const parseResult = (
|
|
459
|
+
dataset: Dataset.Dataset,
|
|
460
|
+
): Result.Result<ShapesGraph, ShapesGraphError> =>
|
|
461
|
+
Result.try({
|
|
462
|
+
try: () => parseUnsafe(dataset),
|
|
463
|
+
catch: (e) => {
|
|
464
|
+
if (e instanceof ParseFailure) {
|
|
465
|
+
return new ShapesGraphError(
|
|
466
|
+
Option.match(e.node, {
|
|
467
|
+
onNone: () => ({ message: e.message }),
|
|
468
|
+
onSome: (node) => ({ message: e.message, node: node.key }),
|
|
469
|
+
}),
|
|
470
|
+
);
|
|
471
|
+
}
|
|
472
|
+
throw e;
|
|
473
|
+
},
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* Parses a shapes graph into a typed model. Fails with a `ShapesGraphError`
|
|
478
|
+
* when the shapes graph is ill-formed (e.g. malformed paths or lists,
|
|
479
|
+
* parameters with values of the wrong kind, or invalid regular expressions).
|
|
480
|
+
*
|
|
481
|
+
* @since 0.1.0
|
|
482
|
+
* @category parsing
|
|
483
|
+
*/
|
|
484
|
+
export const parse = (dataset: Dataset.Dataset): Effect.Effect<ShapesGraph, ShapesGraphError> =>
|
|
485
|
+
Effect.suspend(() => {
|
|
486
|
+
const result = parseResult(dataset);
|
|
487
|
+
return Result.isSuccess(result) ? Effect.succeed(result.success) : Effect.fail(result.failure);
|
|
488
|
+
});
|
|
489
|
+
|
|
490
|
+
const failShapes = (message: string, node?: Term.Term): never => {
|
|
491
|
+
throw new ParseFailure(message, Option.fromUndefinedOr(node));
|
|
492
|
+
};
|
|
493
|
+
|
|
494
|
+
const isTrue = (t: Term.Term): boolean => t.key === TRUE;
|
|
495
|
+
|
|
496
|
+
const isTrueOption = (t: Option.Option<Term.Term>): boolean => Option.exists(t, isTrue);
|
|
497
|
+
|
|
498
|
+
const shapeRef = (owner: Term.Term, p: Term.NamedNode, t: Term.Term): ShapeId =>
|
|
499
|
+
isShapeId(t)
|
|
500
|
+
? t
|
|
501
|
+
: failShapes(`the value of ${p.key} on ${owner.key} must be an IRI or blank node`, owner);
|
|
502
|
+
|
|
503
|
+
const resourceOf = (owner: Term.Term, t: Term.Term, message: string): Term.Resource =>
|
|
504
|
+
Term.isResource(t) ? t : failShapes(message, owner);
|
|
505
|
+
|
|
506
|
+
const iriOf = (owner: Term.Term, p: Term.NamedNode, t: Term.Term): Term.NamedNode =>
|
|
507
|
+
Term.isNamedNode(t)
|
|
508
|
+
? t
|
|
509
|
+
: failShapes(`the value of ${p.key} on ${owner.key} must be an IRI`, owner);
|
|
510
|
+
|
|
511
|
+
const nonNegativeInteger = (owner: Term.Term, p: Term.NamedNode, t: Term.Term): number => {
|
|
512
|
+
if (Term.isLiteral(t) && Xsd.isIntegerDatatype(t.datatype.value) && Xsd.isWellFormed(t)) {
|
|
513
|
+
const n = Number(t.value);
|
|
514
|
+
if (n >= 0) return n;
|
|
515
|
+
}
|
|
516
|
+
return failShapes(
|
|
517
|
+
`the value of ${p.key} on ${owner.key} must be a non-negative xsd:integer`,
|
|
518
|
+
owner,
|
|
519
|
+
);
|
|
520
|
+
};
|
|
521
|
+
|
|
522
|
+
/** Reads values from the shapes graph, failing on ill-formed lists and repeated values. */
|
|
523
|
+
interface Reader {
|
|
524
|
+
readonly g: Dataset.Dataset;
|
|
525
|
+
readonly objects: (s: Term.Term, p: Term.NamedNode) => ReadonlyArray<Term.GroundTerm>;
|
|
526
|
+
readonly list: (
|
|
527
|
+
owner: Term.Term,
|
|
528
|
+
head: Term.Term,
|
|
529
|
+
p: Term.NamedNode,
|
|
530
|
+
) => ReadonlyArray<Term.GroundTerm>;
|
|
531
|
+
readonly single: (s: Term.Term, p: Term.NamedNode) => Option.Option<Term.GroundTerm>;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
const makeReader = (g: Dataset.Dataset): Reader => {
|
|
535
|
+
const objects = (s: Term.Term, p: Term.NamedNode): ReadonlyArray<Term.GroundTerm> =>
|
|
536
|
+
isShapeId(s) ? Dataset.objectsOf(g, s, p) : [];
|
|
537
|
+
const list = (
|
|
538
|
+
owner: Term.Term,
|
|
539
|
+
head: Term.Term,
|
|
540
|
+
p: Term.NamedNode,
|
|
541
|
+
): ReadonlyArray<Term.GroundTerm> => {
|
|
542
|
+
const items = Term.isObject(head) ? Dataset.list(g, head) : Option.none();
|
|
543
|
+
if (Option.isNone(items))
|
|
544
|
+
return failShapes(
|
|
545
|
+
`the value of ${p.key} on ${owner.key} must be a well-formed RDF list`,
|
|
546
|
+
owner,
|
|
547
|
+
);
|
|
548
|
+
return items.value;
|
|
549
|
+
};
|
|
550
|
+
const single = (s: Term.Term, p: Term.NamedNode): Option.Option<Term.GroundTerm> => {
|
|
551
|
+
const vs = objects(s, p);
|
|
552
|
+
if (vs.length > 1) failShapes(`${s.key} has more than one value for ${p.key}`, s);
|
|
553
|
+
return Arr.head(vs);
|
|
554
|
+
};
|
|
555
|
+
return { g, objects, list, single };
|
|
556
|
+
};
|
|
557
|
+
|
|
558
|
+
// --- Custom constraint components -------------------------------------------
|
|
559
|
+
|
|
560
|
+
const parameterPath = (r: Reader, c: Term.Term, param: Term.GroundTerm): Term.NamedNode =>
|
|
561
|
+
Option.getOrElse(Option.filter(r.single(param, sh.path), Term.isNamedNode), () =>
|
|
562
|
+
failShapes(`parameter ${param.key} of ${c.key} must have an IRI sh:path`, param),
|
|
563
|
+
);
|
|
564
|
+
|
|
565
|
+
const componentDeclarations = (r: Reader): ReadonlyArray<ComponentDeclaration> =>
|
|
566
|
+
Arr.flatMap(Rdfs.instancesOf(r.g, sh.ConstraintComponent), (c) => {
|
|
567
|
+
if (!isShapeId(c) || (Term.isNamedNode(c) && c.value.startsWith(SH))) return [];
|
|
568
|
+
const parameters = Arr.map(r.objects(c, sh.parameter), (param) => {
|
|
569
|
+
const path = parameterPath(r, c, param);
|
|
570
|
+
return { path, optional: isTrueOption(r.single(param, sh.optional)) };
|
|
571
|
+
});
|
|
572
|
+
const mandatory = Arr.map(
|
|
573
|
+
Arr.filter(parameters, (p) => !p.optional),
|
|
574
|
+
(p) => p.path,
|
|
575
|
+
);
|
|
576
|
+
const optional = Arr.map(
|
|
577
|
+
Arr.filter(parameters, (p) => p.optional),
|
|
578
|
+
(p) => p.path,
|
|
579
|
+
);
|
|
580
|
+
return Arr.isReadonlyArrayNonEmpty(mandatory) ? [{ component: c, mandatory, optional }] : [];
|
|
581
|
+
});
|
|
582
|
+
|
|
583
|
+
// --- Collect shapes (§2.1) --------------------------------------------------
|
|
584
|
+
|
|
585
|
+
const collectCandidates = (
|
|
586
|
+
r: Reader,
|
|
587
|
+
components: ReadonlyArray<ComponentDeclaration>,
|
|
588
|
+
): ReadonlyArray<ShapeId> => {
|
|
589
|
+
const candidates = MutableHashMap.empty<string, ShapeId>();
|
|
590
|
+
const addCandidate = (t: Term.Term, reason: string) => {
|
|
591
|
+
if (!isShapeId(t)) failShapes(`${t.key} cannot be a shape (${reason})`, t);
|
|
592
|
+
else if (!MutableHashMap.has(candidates, t.key)) MutableHashMap.set(candidates, t.key, t);
|
|
593
|
+
};
|
|
594
|
+
Arr.forEach([sh.NodeShape, sh.PropertyShape], (cls) =>
|
|
595
|
+
Arr.forEach(Rdfs.instancesOf(r.g, cls), (s) => addCandidate(s, `instance of ${cls.key}`)),
|
|
596
|
+
);
|
|
597
|
+
const subjectTriggers = [
|
|
598
|
+
...targetPredicates,
|
|
599
|
+
...coreParameters,
|
|
600
|
+
...components.flatMap((c) => c.mandatory),
|
|
601
|
+
];
|
|
602
|
+
Arr.forEach(subjectTriggers, (p) =>
|
|
603
|
+
Arr.forEach(Dataset.match(r.g, { predicate: p }), (q) => {
|
|
604
|
+
if (!Term.isTriple(q.subject)) addCandidate(q.subject, `subject of ${p.key}`);
|
|
605
|
+
}),
|
|
606
|
+
);
|
|
607
|
+
Arr.forEach([sh.node, sh.property, sh.qualifiedValueShape, sh.not], (p) =>
|
|
608
|
+
Arr.forEach(Dataset.match(r.g, { predicate: p }), (q) =>
|
|
609
|
+
addCandidate(q.object, `value of ${p.key}`),
|
|
610
|
+
),
|
|
611
|
+
);
|
|
612
|
+
Arr.forEach([sh.and, sh.or, sh.xone], (p) =>
|
|
613
|
+
Arr.forEach(Dataset.match(r.g, { predicate: p }), (q) =>
|
|
614
|
+
Arr.forEach(r.list(q.subject, q.object, p), (member) =>
|
|
615
|
+
addCandidate(member, `member of ${p.key}`),
|
|
616
|
+
),
|
|
617
|
+
),
|
|
618
|
+
);
|
|
619
|
+
return Arr.sort(MutableHashMap.values(candidates), Term.compare);
|
|
620
|
+
};
|
|
621
|
+
|
|
622
|
+
// --- Parse each shape -------------------------------------------------------
|
|
623
|
+
|
|
624
|
+
const parseTargets = (
|
|
625
|
+
r: Reader,
|
|
626
|
+
id: ShapeId,
|
|
627
|
+
classInstances: MutableHashSet.MutableHashSet<string>,
|
|
628
|
+
): ReadonlyArray<Target> => [
|
|
629
|
+
...Arr.map(objects(r, id, sh.targetNode), (node): Target => ({ _tag: 'TargetNode', node })),
|
|
630
|
+
...Arr.map(objects(r, id, sh.targetClass), (c): Target => ({
|
|
631
|
+
_tag: 'TargetClass',
|
|
632
|
+
class: resourceOf(id, c, `the value of sh:targetClass on ${id.key} must be an IRI`),
|
|
633
|
+
implicit: false,
|
|
634
|
+
})),
|
|
635
|
+
...(Term.isNamedNode(id) && MutableHashSet.has(classInstances, id.key)
|
|
636
|
+
? [{ _tag: 'TargetClass', class: id, implicit: true } satisfies Target]
|
|
637
|
+
: []),
|
|
638
|
+
...Arr.map(objects(r, id, sh.targetSubjectsOf), (p): Target => ({
|
|
639
|
+
_tag: 'TargetSubjectsOf',
|
|
640
|
+
predicate: iriOf(id, sh.targetSubjectsOf, p),
|
|
641
|
+
})),
|
|
642
|
+
...Arr.map(objects(r, id, sh.targetObjectsOf), (p): Target => ({
|
|
643
|
+
_tag: 'TargetObjectsOf',
|
|
644
|
+
predicate: iriOf(id, sh.targetObjectsOf, p),
|
|
645
|
+
})),
|
|
646
|
+
...Arr.map(objects(r, id, sh.target), (node): Target => ({ _tag: 'SparqlTarget', node })),
|
|
647
|
+
];
|
|
648
|
+
|
|
649
|
+
const objects = (r: Reader, s: Term.Term, p: Term.NamedNode) => r.objects(s, p);
|
|
650
|
+
|
|
651
|
+
const valueConstraints = (r: Reader, id: ShapeId): ReadonlyArray<Constraint> => [
|
|
652
|
+
...Arr.map(objects(r, id, sh.class), (c): Constraint => ({
|
|
653
|
+
_tag: 'Class',
|
|
654
|
+
class: resourceOf(id, c, `the value of sh:class on ${id.key} must be an IRI`),
|
|
655
|
+
})),
|
|
656
|
+
...Arr.map(objects(r, id, sh.datatype), (d): Constraint => ({
|
|
657
|
+
_tag: 'Datatype',
|
|
658
|
+
datatype: iriOf(id, sh.datatype, d),
|
|
659
|
+
})),
|
|
660
|
+
...Arr.map(objects(r, id, sh.nodeKind), (k): Constraint => ({
|
|
661
|
+
_tag: 'NodeKind',
|
|
662
|
+
nodeKind: Option.getOrElse(Record.get(nodeKinds, Term.isNamedNode(k) ? k.value : ''), () =>
|
|
663
|
+
failShapes(`${k.key} is not a valid sh:nodeKind`, id),
|
|
664
|
+
),
|
|
665
|
+
})),
|
|
666
|
+
...Arr.map(objects(r, id, sh.minCount), (n): Constraint => ({
|
|
667
|
+
_tag: 'MinCount',
|
|
668
|
+
minCount: nonNegativeInteger(id, sh.minCount, n),
|
|
669
|
+
})),
|
|
670
|
+
...Arr.map(objects(r, id, sh.maxCount), (n): Constraint => ({
|
|
671
|
+
_tag: 'MaxCount',
|
|
672
|
+
maxCount: nonNegativeInteger(id, sh.maxCount, n),
|
|
673
|
+
})),
|
|
674
|
+
...Arr.flatMap(rangeParameters, ([p, tag]) =>
|
|
675
|
+
Arr.map(objects(r, id, p), (v): Constraint =>
|
|
676
|
+
Term.isLiteral(v)
|
|
677
|
+
? { _tag: tag, value: v }
|
|
678
|
+
: failShapes(`the value of ${p.key} on ${id.key} must be a literal`, id),
|
|
679
|
+
),
|
|
680
|
+
),
|
|
681
|
+
...Arr.map(objects(r, id, sh.minLength), (n): Constraint => ({
|
|
682
|
+
_tag: 'MinLength',
|
|
683
|
+
minLength: nonNegativeInteger(id, sh.minLength, n),
|
|
684
|
+
})),
|
|
685
|
+
...Arr.map(objects(r, id, sh.maxLength), (n): Constraint => ({
|
|
686
|
+
_tag: 'MaxLength',
|
|
687
|
+
maxLength: nonNegativeInteger(id, sh.maxLength, n),
|
|
688
|
+
})),
|
|
689
|
+
...patternConstraints(r, id),
|
|
690
|
+
...Arr.map(objects(r, id, sh.languageIn), (l): Constraint => ({
|
|
691
|
+
_tag: 'LanguageIn',
|
|
692
|
+
languages: Arr.map(r.list(id, l, sh.languageIn), (t) =>
|
|
693
|
+
Term.isLiteral(t)
|
|
694
|
+
? t.value
|
|
695
|
+
: failShapes(`sh:languageIn members of ${id.key} must be literals`, id),
|
|
696
|
+
),
|
|
697
|
+
})),
|
|
698
|
+
...Arr.flatMap(objects(r, id, sh.uniqueLang), (u): ReadonlyArray<Constraint> =>
|
|
699
|
+
isTrue(u) ? [{ _tag: 'UniqueLang' }] : [],
|
|
700
|
+
),
|
|
701
|
+
...Arr.flatMap(pairParameters, ([p, tag]) =>
|
|
702
|
+
Arr.map(objects(r, id, p), (v): Constraint => ({ _tag: tag, predicate: iriOf(id, p, v) })),
|
|
703
|
+
),
|
|
704
|
+
];
|
|
705
|
+
|
|
706
|
+
const patternConstraints = (r: Reader, id: ShapeId): ReadonlyArray<Constraint> => {
|
|
707
|
+
const patterns = objects(r, id, sh.pattern);
|
|
708
|
+
if (Arr.isReadonlyArrayEmpty(patterns)) return [];
|
|
709
|
+
const flags = Option.match(r.single(id, sh.flags), {
|
|
710
|
+
onNone: () => '',
|
|
711
|
+
onSome: (f) =>
|
|
712
|
+
Term.isLiteral(f)
|
|
713
|
+
? f.value
|
|
714
|
+
: failShapes(`the value of sh:flags on ${id.key} must be a literal`, id),
|
|
715
|
+
});
|
|
716
|
+
return Arr.map(patterns, (p): Constraint => {
|
|
717
|
+
if (!Term.isLiteral(p))
|
|
718
|
+
return failShapes(`the value of sh:pattern on ${id.key} must be a literal`, id);
|
|
719
|
+
return Result.match(Regex.compile(p.value, flags), {
|
|
720
|
+
onFailure: (error) => failShapes(`${error} (sh:pattern on ${id.key})`, id),
|
|
721
|
+
onSuccess: (regex) => ({ _tag: 'Pattern', pattern: p.value, flags, regex }),
|
|
722
|
+
});
|
|
723
|
+
});
|
|
724
|
+
};
|
|
725
|
+
|
|
726
|
+
const shapeConstraints = (r: Reader, id: ShapeId): ReadonlyArray<Constraint> => [
|
|
727
|
+
...Arr.map(objects(r, id, sh.not), (s): Constraint => ({
|
|
728
|
+
_tag: 'Not',
|
|
729
|
+
shape: shapeRef(id, sh.not, s),
|
|
730
|
+
})),
|
|
731
|
+
...Arr.flatMap(logicalParameters, ([p, tag]) =>
|
|
732
|
+
Arr.map(objects(r, id, p), (l): Constraint => ({
|
|
733
|
+
_tag: tag,
|
|
734
|
+
shapes: r.list(id, l, p).map((m) => shapeRef(id, p, m)),
|
|
735
|
+
})),
|
|
736
|
+
),
|
|
737
|
+
...Arr.map(objects(r, id, sh.node), (s): Constraint => ({
|
|
738
|
+
_tag: 'Node',
|
|
739
|
+
shape: shapeRef(id, sh.node, s),
|
|
740
|
+
})),
|
|
741
|
+
...Arr.map(objects(r, id, sh.property), (s): Constraint => ({
|
|
742
|
+
_tag: 'Property',
|
|
743
|
+
shape: shapeRef(id, sh.property, s),
|
|
744
|
+
})),
|
|
745
|
+
];
|
|
746
|
+
|
|
747
|
+
/** The other qualified value shapes of the property shapes beside `id`. */
|
|
748
|
+
const siblingShapes = (r: Reader, id: ShapeId, q: ShapeId): ReadonlyArray<ShapeId> => {
|
|
749
|
+
const siblings = MutableHashMap.empty<string, ShapeId>();
|
|
750
|
+
Arr.forEach(Dataset.subjectsOf(r.g, sh.property, id), (parent) =>
|
|
751
|
+
Arr.forEach(objects(r, parent, sh.property), (sibling) =>
|
|
752
|
+
Arr.forEach(objects(r, sibling, sh.qualifiedValueShape), (sq) => {
|
|
753
|
+
if (sq.key !== q.key && isShapeId(sq)) MutableHashMap.set(siblings, sq.key, sq);
|
|
754
|
+
}),
|
|
755
|
+
),
|
|
756
|
+
);
|
|
757
|
+
return Arr.fromIterable(MutableHashMap.values(siblings));
|
|
758
|
+
};
|
|
759
|
+
|
|
760
|
+
const qualifiedConstraints = (r: Reader, id: ShapeId): ReadonlyArray<Constraint> => {
|
|
761
|
+
const qualifiedShapes = objects(r, id, sh.qualifiedValueShape);
|
|
762
|
+
if (Arr.isReadonlyArrayEmpty(qualifiedShapes)) return [];
|
|
763
|
+
const minNode = r.single(id, sh.qualifiedMinCount);
|
|
764
|
+
const maxNode = r.single(id, sh.qualifiedMaxCount);
|
|
765
|
+
const disjoint = isTrueOption(r.single(id, sh.qualifiedValueShapesDisjoint));
|
|
766
|
+
return Arr.flatMap(qualifiedShapes, (qNode) => {
|
|
767
|
+
const q = shapeRef(id, sh.qualifiedValueShape, qNode);
|
|
768
|
+
const common = { shape: q, disjoint, siblings: disjoint ? siblingShapes(r, id, q) : [] };
|
|
769
|
+
return [
|
|
770
|
+
...Option.toArray(
|
|
771
|
+
Option.map(minNode, (n): Constraint => ({
|
|
772
|
+
_tag: 'QualifiedMinCount',
|
|
773
|
+
count: nonNegativeInteger(id, sh.qualifiedMinCount, n),
|
|
774
|
+
...common,
|
|
775
|
+
})),
|
|
776
|
+
),
|
|
777
|
+
...Option.toArray(
|
|
778
|
+
Option.map(maxNode, (n): Constraint => ({
|
|
779
|
+
_tag: 'QualifiedMaxCount',
|
|
780
|
+
count: nonNegativeInteger(id, sh.qualifiedMaxCount, n),
|
|
781
|
+
...common,
|
|
782
|
+
})),
|
|
783
|
+
),
|
|
784
|
+
];
|
|
785
|
+
});
|
|
786
|
+
};
|
|
787
|
+
|
|
788
|
+
const closedConstraints = (r: Reader, id: ShapeId): ReadonlyArray<Constraint> => {
|
|
789
|
+
if (!isTrueOption(r.single(id, sh.closed))) return [];
|
|
790
|
+
const ignoredProperties = Option.match(r.single(id, sh.ignoredProperties), {
|
|
791
|
+
onNone: (): ReadonlyArray<Term.NamedNode> => [],
|
|
792
|
+
onSome: (node) =>
|
|
793
|
+
Arr.map(r.list(id, node, sh.ignoredProperties), (t) => iriOf(id, sh.ignoredProperties, t)),
|
|
794
|
+
});
|
|
795
|
+
const allowed = MutableHashMap.empty<string, Term.NamedNode>();
|
|
796
|
+
Arr.forEach(objects(r, id, sh.property), (p) =>
|
|
797
|
+
Arr.forEach(objects(r, p, sh.path), (path) => {
|
|
798
|
+
if (Term.isNamedNode(path)) MutableHashMap.set(allowed, path.key, path);
|
|
799
|
+
}),
|
|
800
|
+
);
|
|
801
|
+
Arr.forEach(ignoredProperties, (p) => {
|
|
802
|
+
MutableHashMap.set(allowed, p.key, p);
|
|
803
|
+
});
|
|
804
|
+
return [
|
|
805
|
+
{
|
|
806
|
+
_tag: 'Closed',
|
|
807
|
+
ignoredProperties,
|
|
808
|
+
allowedProperties: Arr.fromIterable(MutableHashMap.values(allowed)),
|
|
809
|
+
},
|
|
810
|
+
];
|
|
811
|
+
};
|
|
812
|
+
|
|
813
|
+
const sparqlConstraints = (r: Reader, id: ShapeId): ReadonlyArray<Constraint> =>
|
|
814
|
+
Arr.flatMap(objects(r, id, sh.sparql), (s): ReadonlyArray<Constraint> => {
|
|
815
|
+
if (!isShapeId(s))
|
|
816
|
+
return failShapes(`the value of sh:sparql on ${id.key} must be an IRI or blank node`, id);
|
|
817
|
+
return isTrueOption(r.single(s, sh.deactivated)) ? [] : [{ _tag: 'Sparql', node: s }];
|
|
818
|
+
});
|
|
819
|
+
|
|
820
|
+
const noParameters: ReadonlyArray<ReadonlyArray<ComponentParameter>> = [[]];
|
|
821
|
+
|
|
822
|
+
const componentConstraints = (
|
|
823
|
+
r: Reader,
|
|
824
|
+
id: ShapeId,
|
|
825
|
+
components: ReadonlyArray<ComponentDeclaration>,
|
|
826
|
+
): ReadonlyArray<Constraint> =>
|
|
827
|
+
Arr.flatMap(components, (decl): ReadonlyArray<Constraint> => {
|
|
828
|
+
const bindings = Arr.map(
|
|
829
|
+
[...decl.mandatory, ...decl.optional],
|
|
830
|
+
(p) => [p, objects(r, id, p)] as const,
|
|
831
|
+
);
|
|
832
|
+
if (decl.mandatory.some((p) => Arr.isReadonlyArrayEmpty(objects(r, id, p)))) return [];
|
|
833
|
+
// One constraint per combination of parameter values.
|
|
834
|
+
const combos = Arr.reduce(bindings, noParameters, (acc, [path, values]) =>
|
|
835
|
+
Arr.isReadonlyArrayEmpty(values)
|
|
836
|
+
? acc
|
|
837
|
+
: Arr.flatMap(acc, (combo) => values.map((value) => Arr.append(combo, { path, value }))),
|
|
838
|
+
);
|
|
839
|
+
return Arr.map(combos, (parameters): Constraint => ({
|
|
840
|
+
_tag: 'Component',
|
|
841
|
+
component: decl.component,
|
|
842
|
+
parameters,
|
|
843
|
+
}));
|
|
844
|
+
});
|
|
845
|
+
|
|
846
|
+
const parseShape = (
|
|
847
|
+
r: Reader,
|
|
848
|
+
components: ReadonlyArray<ComponentDeclaration>,
|
|
849
|
+
classInstances: MutableHashSet.MutableHashSet<string>,
|
|
850
|
+
id: ShapeId,
|
|
851
|
+
): Shape => {
|
|
852
|
+
const targets = parseTargets(r, id, classInstances);
|
|
853
|
+
|
|
854
|
+
// Shape characteristics
|
|
855
|
+
const severity = Option.match(r.single(id, sh.severity), {
|
|
856
|
+
onNone: () => sh.Violation,
|
|
857
|
+
onSome: (node) => iriOf(id, sh.severity, node),
|
|
858
|
+
});
|
|
859
|
+
const messages = objects(r, id, sh.message).filter(Term.isLiteral);
|
|
860
|
+
const deactivated = isTrueOption(r.single(id, sh.deactivated));
|
|
861
|
+
|
|
862
|
+
const constraints: ReadonlyArray<Constraint> = [
|
|
863
|
+
...valueConstraints(r, id),
|
|
864
|
+
...shapeConstraints(r, id),
|
|
865
|
+
...qualifiedConstraints(r, id),
|
|
866
|
+
...closedConstraints(r, id),
|
|
867
|
+
...Arr.map(objects(r, id, sh.hasValue), (v): Constraint => ({ _tag: 'HasValue', value: v })),
|
|
868
|
+
...Arr.map(objects(r, id, sh.in), (l): Constraint => ({
|
|
869
|
+
_tag: 'In',
|
|
870
|
+
values: r.list(id, l, sh.in),
|
|
871
|
+
})),
|
|
872
|
+
...sparqlConstraints(r, id),
|
|
873
|
+
...componentConstraints(r, id, components),
|
|
874
|
+
];
|
|
875
|
+
|
|
876
|
+
// Property shape?
|
|
877
|
+
return Option.match(r.single(id, sh.path), {
|
|
878
|
+
onNone: (): Shape => ({
|
|
879
|
+
_tag: 'NodeShape',
|
|
880
|
+
id,
|
|
881
|
+
targets,
|
|
882
|
+
constraints,
|
|
883
|
+
severity,
|
|
884
|
+
messages,
|
|
885
|
+
deactivated,
|
|
886
|
+
}),
|
|
887
|
+
onSome: (pathNode): Shape => ({
|
|
888
|
+
_tag: 'PropertyShape',
|
|
889
|
+
id,
|
|
890
|
+
path: Result.getOrElse(Path.fromRdf(r.g, pathNode), (failure) =>
|
|
891
|
+
failShapes(`ill-formed sh:path of ${id.key}: ${failure.message}`, id),
|
|
892
|
+
),
|
|
893
|
+
targets,
|
|
894
|
+
constraints,
|
|
895
|
+
severity,
|
|
896
|
+
messages,
|
|
897
|
+
deactivated,
|
|
898
|
+
}),
|
|
899
|
+
});
|
|
900
|
+
};
|
|
901
|
+
|
|
902
|
+
const parseUnsafe = (g: Dataset.Dataset): ShapesGraph => {
|
|
903
|
+
const r = makeReader(g);
|
|
904
|
+
const components = componentDeclarations(r);
|
|
905
|
+
const candidates = collectCandidates(r, components);
|
|
906
|
+
const classInstances = MutableHashSet.fromIterable(
|
|
907
|
+
Arr.map(Rdfs.instancesOf(g, rdfs.Class), (c) => c.key),
|
|
908
|
+
);
|
|
909
|
+
const shapes = Arr.map(candidates, (id) => parseShape(r, components, classInstances, id));
|
|
910
|
+
// The public `index` is a `ReadonlyMap`.
|
|
911
|
+
const index = new Map(shapes.map((s) => [s.id.key, s]));
|
|
912
|
+
return { _tag: 'ShapesGraph', dataset: g, shapes, index };
|
|
913
|
+
};
|