@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.
- package/LICENSE +21 -0
- package/README.md +2251 -2
- 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 +195 -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,1156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SHACL Core validation (§3–§4): validates a data graph against a shapes
|
|
3
|
+
* graph and produces a `ValidationReport`.
|
|
4
|
+
*
|
|
5
|
+
* ```ts
|
|
6
|
+
* import { Effect } from "effect"
|
|
7
|
+
* import { Validator, ValidationReport } from "@thomasfosterau/effect-rdf/shacl"
|
|
8
|
+
*
|
|
9
|
+
* const program = Effect.gen(function* () {
|
|
10
|
+
* const report = yield* Validator.validate(dataGraph, shapesGraph)
|
|
11
|
+
* console.log(ValidationReport.format(report))
|
|
12
|
+
* })
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* The `Validator` service pre-compiles a shapes graph once and validates many
|
|
16
|
+
* data graphs against it:
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* const program = Effect.gen(function* () {
|
|
20
|
+
* const validator = yield* Validator.Validator
|
|
21
|
+
* const ok = yield* validator.conforms(dataGraph)
|
|
22
|
+
* }).pipe(Effect.provide(Validator.layer(shapesGraph)))
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @since 0.1.0
|
|
26
|
+
*/
|
|
27
|
+
import { Dataset, Term, Vocab, Xsd } from '../index.ts';
|
|
28
|
+
import * as Arr from 'effect/Array';
|
|
29
|
+
import * as Context from 'effect/Context';
|
|
30
|
+
import * as Effect from 'effect/Effect';
|
|
31
|
+
import { constVoid, identity, pipe } from 'effect/Function';
|
|
32
|
+
import * as Iterable from 'effect/Iterable';
|
|
33
|
+
import * as Layer from 'effect/Layer';
|
|
34
|
+
import * as Match from 'effect/Match';
|
|
35
|
+
import * as MutableHashMap from 'effect/MutableHashMap';
|
|
36
|
+
import * as MutableHashSet from 'effect/MutableHashSet';
|
|
37
|
+
import * as Option from 'effect/Option';
|
|
38
|
+
import * as Predicate from 'effect/Predicate';
|
|
39
|
+
import * as Record from 'effect/Record';
|
|
40
|
+
import * as Schema from 'effect/Schema';
|
|
41
|
+
import * as SchemaIssue from 'effect/SchemaIssue';
|
|
42
|
+
import * as SchemaTransformation from 'effect/SchemaTransformation';
|
|
43
|
+
import { compareTerms } from './internal/compare.ts';
|
|
44
|
+
import * as Message from './Message.ts';
|
|
45
|
+
import * as Path from './Path.ts';
|
|
46
|
+
import * as Shapes from './Shapes.ts';
|
|
47
|
+
import * as Sparql from './Sparql.ts';
|
|
48
|
+
import * as ValidationReport from './ValidationReport.ts';
|
|
49
|
+
import { SH, sh } from './Vocabulary.ts';
|
|
50
|
+
|
|
51
|
+
/** A string as a JSON string literal, for messages. */
|
|
52
|
+
const quote = Schema.encodeSync(Schema.fromJsonString(Schema.String));
|
|
53
|
+
|
|
54
|
+
const { rdf, rdfs, xsd } = Vocab;
|
|
55
|
+
|
|
56
|
+
// -----------------------------------------------------------------------------
|
|
57
|
+
// Errors
|
|
58
|
+
// -----------------------------------------------------------------------------
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Validation reached a shape again for the same focus node while still
|
|
62
|
+
* validating it (a recursive shape). The SHACL specification leaves the
|
|
63
|
+
* validation of recursive shapes undefined.
|
|
64
|
+
*
|
|
65
|
+
* @since 0.1.0
|
|
66
|
+
* @category errors
|
|
67
|
+
*/
|
|
68
|
+
export class RecursiveShapeError extends Schema.TaggedError<RecursiveShapeError>()(
|
|
69
|
+
'RecursiveShapeError',
|
|
70
|
+
{
|
|
71
|
+
message: Schema.String,
|
|
72
|
+
shape: Schema.String,
|
|
73
|
+
focusNode: Schema.String,
|
|
74
|
+
},
|
|
75
|
+
) {}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* The shapes graph uses a feature this validator cannot evaluate (currently:
|
|
79
|
+
* SHACL-SPARQL constraints and targets when no
|
|
80
|
+
* `Sparql.SparqlConstraintEvaluator` is provided).
|
|
81
|
+
*
|
|
82
|
+
* @since 0.1.0
|
|
83
|
+
* @category errors
|
|
84
|
+
*/
|
|
85
|
+
export class UnsupportedFeatureError extends Schema.TaggedError<UnsupportedFeatureError>()(
|
|
86
|
+
'UnsupportedFeatureError',
|
|
87
|
+
{
|
|
88
|
+
message: Schema.String,
|
|
89
|
+
feature: Schema.String,
|
|
90
|
+
shape: Schema.String,
|
|
91
|
+
},
|
|
92
|
+
) {}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* The data graph does not conform to the shapes graph (raised by
|
|
96
|
+
* `Validator.check` and `assertConforms`).
|
|
97
|
+
*
|
|
98
|
+
* @since 0.1.0
|
|
99
|
+
* @category errors
|
|
100
|
+
*/
|
|
101
|
+
export class ConformanceError extends Schema.TaggedError<ConformanceError>()('ConformanceError', {
|
|
102
|
+
message: Schema.String,
|
|
103
|
+
report: ValidationReport.ValidationReportSchema,
|
|
104
|
+
}) {}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* The errors that can prevent validation from producing a report (SHACL
|
|
108
|
+
* "failures").
|
|
109
|
+
*
|
|
110
|
+
* @since 0.1.0
|
|
111
|
+
* @category errors
|
|
112
|
+
*/
|
|
113
|
+
export type ValidationError =
|
|
114
|
+
| Shapes.ShapesGraphError
|
|
115
|
+
| RecursiveShapeError
|
|
116
|
+
| UnsupportedFeatureError
|
|
117
|
+
| Sparql.SparqlEvaluationError;
|
|
118
|
+
|
|
119
|
+
// -----------------------------------------------------------------------------
|
|
120
|
+
// Options
|
|
121
|
+
// -----------------------------------------------------------------------------
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Validation options.
|
|
125
|
+
*
|
|
126
|
+
* @since 0.1.0
|
|
127
|
+
* @category models
|
|
128
|
+
*/
|
|
129
|
+
export interface ValidateOptions {
|
|
130
|
+
/**
|
|
131
|
+
* Validate the union of the data graph and the shapes graph (useful when
|
|
132
|
+
* the data graph declares `sh:shapesGraph`, or the shapes and data live in
|
|
133
|
+
* the same document). Default `false`.
|
|
134
|
+
*/
|
|
135
|
+
readonly includeShapesGraph?: boolean | undefined;
|
|
136
|
+
/**
|
|
137
|
+
* What to do with SHACL-SPARQL constraints and targets when no
|
|
138
|
+
* `Sparql.SparqlConstraintEvaluator` is provided: `"fail"` (default) fails
|
|
139
|
+
* with an `UnsupportedFeatureError`, `"ignore"` skips them.
|
|
140
|
+
*/
|
|
141
|
+
readonly sparql?: 'fail' | 'ignore' | undefined;
|
|
142
|
+
/**
|
|
143
|
+
* What to do when a shape is (directly or indirectly) validated against a
|
|
144
|
+
* focus node while it is already being validated against the same node:
|
|
145
|
+
* `"fail"` (default) fails with a `RecursiveShapeError`, `"ignore"` treats
|
|
146
|
+
* the recursive reference as conforming.
|
|
147
|
+
*/
|
|
148
|
+
readonly recursion?: 'fail' | 'ignore' | undefined;
|
|
149
|
+
/**
|
|
150
|
+
* Attach the nested results that caused `sh:node`, `sh:not`, `sh:and`,
|
|
151
|
+
* `sh:or`, `sh:xone` and qualified value shape results as `sh:detail`.
|
|
152
|
+
* Default `false`.
|
|
153
|
+
*/
|
|
154
|
+
readonly details?: boolean | undefined;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// -----------------------------------------------------------------------------
|
|
158
|
+
// Engine
|
|
159
|
+
// -----------------------------------------------------------------------------
|
|
160
|
+
|
|
161
|
+
type EngineError = RecursiveShapeError | UnsupportedFeatureError | Sparql.SparqlEvaluationError;
|
|
162
|
+
type Results = ReadonlyArray<ValidationReport.ValidationResult>;
|
|
163
|
+
|
|
164
|
+
const langMatches = (tag: string, range: string): boolean => {
|
|
165
|
+
if (tag === '') return false;
|
|
166
|
+
if (range === '*') return true;
|
|
167
|
+
const t = tag.toLowerCase();
|
|
168
|
+
const r = range.toLowerCase();
|
|
169
|
+
return t === r || t.startsWith(`${r}-`);
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
type BasicNodeKind = 'IRI' | 'BlankNode' | 'Literal';
|
|
173
|
+
|
|
174
|
+
const IRI = Option.some<BasicNodeKind>('IRI');
|
|
175
|
+
const BLANK_NODE = Option.some<BasicNodeKind>('BlankNode');
|
|
176
|
+
const LITERAL = Option.some<BasicNodeKind>('Literal');
|
|
177
|
+
|
|
178
|
+
const nodeKindOf = (t: Term.Term): Option.Option<BasicNodeKind> =>
|
|
179
|
+
Term.isNamedNode(t)
|
|
180
|
+
? IRI
|
|
181
|
+
: Term.isBlankNode(t)
|
|
182
|
+
? BLANK_NODE
|
|
183
|
+
: Term.isLiteral(t)
|
|
184
|
+
? LITERAL
|
|
185
|
+
: Option.none();
|
|
186
|
+
|
|
187
|
+
const matchesNodeKind = (t: Term.Term, kind: Shapes.NodeKind): boolean =>
|
|
188
|
+
Option.exists(nodeKindOf(t), (k) => kind.includes(k));
|
|
189
|
+
|
|
190
|
+
const hasDatatype = (v: Term.Term, datatype: Term.NamedNode): boolean => {
|
|
191
|
+
if (!Term.isLiteral(v) || v.datatype.value !== datatype.value) return false;
|
|
192
|
+
if (datatype.value === rdf.langString.value || datatype.value === rdf.dirLangString.value)
|
|
193
|
+
return v.language !== '';
|
|
194
|
+
if (v.language !== '') return false;
|
|
195
|
+
return Xsd.isWellFormed(v);
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
const stringValue = (v: Term.Term): Option.Option<string> =>
|
|
199
|
+
Term.isNamedNode(v) || Term.isLiteral(v) ? Option.some(v.value) : Option.none();
|
|
200
|
+
|
|
201
|
+
/** Whether a value node has no string value, or one that fails `ok`. */
|
|
202
|
+
const failsString = (v: Term.Term, ok: (s: string) => boolean): boolean =>
|
|
203
|
+
!Option.exists(stringValue(v), ok);
|
|
204
|
+
|
|
205
|
+
const show = (t: Term.Term) => t.key;
|
|
206
|
+
|
|
207
|
+
/** A high surrogate and the code unit after it: one code point. */
|
|
208
|
+
const surrogatePair = /[\uD800-\uDBFF][\s\S]/g;
|
|
209
|
+
|
|
210
|
+
/** The length of a string in Unicode code points (as XPath `fn:string-length`). */
|
|
211
|
+
const codePointLength = (s: string): number => s.replace(surrogatePair, '_').length;
|
|
212
|
+
|
|
213
|
+
type Sign = -1 | 0 | 1;
|
|
214
|
+
|
|
215
|
+
/** Whether `a` and `b` are comparable and their order satisfies `ok`. */
|
|
216
|
+
const ordered = (a: Term.Term, b: Term.Term, ok: (sign: Sign) => boolean): boolean =>
|
|
217
|
+
Option.exists(compareTerms(a, b), ok);
|
|
218
|
+
|
|
219
|
+
const defaultMessage = (constraint: Shapes.Constraint, value: Option.Option<Term.Term>): string => {
|
|
220
|
+
const v = Option.match(value, { onNone: () => 'Value', onSome: (t) => `Value ${show(t)}` });
|
|
221
|
+
return Match.value(constraint)
|
|
222
|
+
.pipe(
|
|
223
|
+
Match.tag('Class', (c) => `${v} is not an instance of ${show(c.class)}`),
|
|
224
|
+
Match.tag('Datatype', (c) => `${v} does not have datatype ${show(c.datatype)}`),
|
|
225
|
+
Match.tag('NodeKind', (c) => `${v} does not have node kind sh:${c.nodeKind}`),
|
|
226
|
+
Match.tag('MinCount', (c) => `Less than ${c.minCount} values`),
|
|
227
|
+
Match.tag('MaxCount', (c) => `More than ${c.maxCount} values`),
|
|
228
|
+
Match.tag('MinExclusive', (c) => `${v} is not greater than ${show(c.value)}`),
|
|
229
|
+
Match.tag('MinInclusive', (c) => `${v} is not greater than or equal to ${show(c.value)}`),
|
|
230
|
+
Match.tag('MaxExclusive', (c) => `${v} is not less than ${show(c.value)}`),
|
|
231
|
+
Match.tag('MaxInclusive', (c) => `${v} is not less than or equal to ${show(c.value)}`),
|
|
232
|
+
Match.tag('MinLength', (c) => `${v} is shorter than ${c.minLength} characters`),
|
|
233
|
+
Match.tag('MaxLength', (c) => `${v} is longer than ${c.maxLength} characters`),
|
|
234
|
+
Match.tag('Pattern', (c) => `${v} does not match pattern ${quote(c.pattern)}`),
|
|
235
|
+
Match.tag(
|
|
236
|
+
'LanguageIn',
|
|
237
|
+
(c) => `${v} does not have a language tag in [${c.languages.join(', ')}]`,
|
|
238
|
+
),
|
|
239
|
+
Match.tag('UniqueLang', () => 'Language tag used by more than one value'),
|
|
240
|
+
Match.tag('Equals', (c) => `${v} is not equal to the values of ${show(c.predicate)}`),
|
|
241
|
+
Match.tag('Disjoint', (c) => `${v} is also a value of ${show(c.predicate)}`),
|
|
242
|
+
Match.tag('LessThan', (c) => `${v} is not less than the values of ${show(c.predicate)}`),
|
|
243
|
+
Match.tag(
|
|
244
|
+
'LessThanOrEquals',
|
|
245
|
+
(c) => `${v} is not less than or equal to the values of ${show(c.predicate)}`,
|
|
246
|
+
),
|
|
247
|
+
)
|
|
248
|
+
.pipe(
|
|
249
|
+
Match.tag('Not', (c) => `${v} conforms to the negated shape ${show(c.shape)}`),
|
|
250
|
+
Match.tag('And', () => `${v} does not conform to all of the shapes`),
|
|
251
|
+
Match.tag('Or', () => `${v} does not conform to any of the shapes`),
|
|
252
|
+
Match.tag('Xone', () => `${v} does not conform to exactly one of the shapes`),
|
|
253
|
+
Match.tag('Node', (c) => `${v} does not conform to shape ${show(c.shape)}`),
|
|
254
|
+
Match.tag('Property', (c) => `${v} does not conform to property shape ${show(c.shape)}`),
|
|
255
|
+
Match.tag(
|
|
256
|
+
'QualifiedMinCount',
|
|
257
|
+
(c) => `Less than ${c.count} values conform to shape ${show(c.shape)}`,
|
|
258
|
+
),
|
|
259
|
+
Match.tag(
|
|
260
|
+
'QualifiedMaxCount',
|
|
261
|
+
(c) => `More than ${c.count} values conform to shape ${show(c.shape)}`,
|
|
262
|
+
),
|
|
263
|
+
Match.tag(
|
|
264
|
+
'Closed',
|
|
265
|
+
() =>
|
|
266
|
+
`Predicate is not allowed by the closed shape (value ${Option.match(value, { onNone: () => '', onSome: show })})`,
|
|
267
|
+
),
|
|
268
|
+
Match.tag('HasValue', (c) => `Missing expected value ${show(c.value)}`),
|
|
269
|
+
Match.tag('In', () => `${v} is not one of the allowed values`),
|
|
270
|
+
Match.tag('Sparql', 'Component', () => `${v} violates a SPARQL-based constraint`),
|
|
271
|
+
Match.exhaustive,
|
|
272
|
+
);
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
const integer = (n: number) => Term.literal(String(n), xsd.integer);
|
|
276
|
+
const boolean = (b: boolean) => Term.literal(String(b), xsd.boolean);
|
|
277
|
+
const listText = (terms: ReadonlyArray<Term.Term>) =>
|
|
278
|
+
Term.literal(terms.map(Message.display).join(', '));
|
|
279
|
+
|
|
280
|
+
/** The parameter values of a core constraint by parameter name (for message templates). */
|
|
281
|
+
const coreParameters = (
|
|
282
|
+
constraint: Shapes.Constraint,
|
|
283
|
+
): ReadonlyArray<readonly [string, Term.Term]> => {
|
|
284
|
+
return Match.value(constraint)
|
|
285
|
+
.pipe(
|
|
286
|
+
Match.withReturnType<ReadonlyArray<readonly [string, Term.Term]>>(),
|
|
287
|
+
Match.tag('Class', (c) => [['class', c.class]]),
|
|
288
|
+
Match.tag('Datatype', (c) => [['datatype', c.datatype]]),
|
|
289
|
+
Match.tag('NodeKind', (c) => [['nodeKind', Term.namedNode(SH + c.nodeKind)]]),
|
|
290
|
+
Match.tag('MinCount', (c) => [['minCount', integer(c.minCount)]]),
|
|
291
|
+
Match.tag('MaxCount', (c) => [['maxCount', integer(c.maxCount)]]),
|
|
292
|
+
Match.tag('MinExclusive', (c) => [['minExclusive', c.value]]),
|
|
293
|
+
Match.tag('MinInclusive', (c) => [['minInclusive', c.value]]),
|
|
294
|
+
Match.tag('MaxExclusive', (c) => [['maxExclusive', c.value]]),
|
|
295
|
+
Match.tag('MaxInclusive', (c) => [['maxInclusive', c.value]]),
|
|
296
|
+
Match.tag('MinLength', (c) => [['minLength', integer(c.minLength)]]),
|
|
297
|
+
Match.tag('MaxLength', (c) => [['maxLength', integer(c.maxLength)]]),
|
|
298
|
+
Match.tag('Pattern', (c) => [
|
|
299
|
+
['pattern', Term.literal(c.pattern)],
|
|
300
|
+
['flags', Term.literal(c.flags)],
|
|
301
|
+
]),
|
|
302
|
+
Match.tag('LanguageIn', (c) => [['languageIn', Term.literal(c.languages.join(', '))]]),
|
|
303
|
+
Match.tag('UniqueLang', () => [['uniqueLang', boolean(true)]]),
|
|
304
|
+
Match.tag('Equals', (c) => [['equals', c.predicate]]),
|
|
305
|
+
Match.tag('Disjoint', (c) => [['disjoint', c.predicate]]),
|
|
306
|
+
Match.tag('LessThan', (c) => [['lessThan', c.predicate]]),
|
|
307
|
+
Match.tag('LessThanOrEquals', (c) => [['lessThanOrEquals', c.predicate]]),
|
|
308
|
+
)
|
|
309
|
+
.pipe(
|
|
310
|
+
Match.tag('Not', (c) => [['not', c.shape]]),
|
|
311
|
+
Match.tag('And', (c) => [['and', listText(c.shapes)]]),
|
|
312
|
+
Match.tag('Or', (c) => [['or', listText(c.shapes)]]),
|
|
313
|
+
Match.tag('Xone', (c) => [['xone', listText(c.shapes)]]),
|
|
314
|
+
Match.tag('Node', (c) => [['node', c.shape]]),
|
|
315
|
+
Match.tag('Property', (c) => [['property', c.shape]]),
|
|
316
|
+
Match.tag('QualifiedMinCount', (c) => [
|
|
317
|
+
['qualifiedValueShape', c.shape],
|
|
318
|
+
['qualifiedMinCount', integer(c.count)],
|
|
319
|
+
['qualifiedValueShapesDisjoint', boolean(c.disjoint)],
|
|
320
|
+
]),
|
|
321
|
+
Match.tag('QualifiedMaxCount', (c) => [
|
|
322
|
+
['qualifiedValueShape', c.shape],
|
|
323
|
+
['qualifiedMaxCount', integer(c.count)],
|
|
324
|
+
['qualifiedValueShapesDisjoint', boolean(c.disjoint)],
|
|
325
|
+
]),
|
|
326
|
+
Match.tag('Closed', (c) => [
|
|
327
|
+
['closed', boolean(true)],
|
|
328
|
+
['ignoredProperties', listText(c.ignoredProperties)],
|
|
329
|
+
]),
|
|
330
|
+
Match.tag('HasValue', (c) => [['hasValue', c.value]]),
|
|
331
|
+
Match.tag('In', (c) => [['in', listText(c.values)]]),
|
|
332
|
+
Match.tag('Sparql', () => []),
|
|
333
|
+
Match.tag('Component', (c) =>
|
|
334
|
+
c.parameters.map((p) => [Message.localName(p.path), p.value] as const),
|
|
335
|
+
),
|
|
336
|
+
Match.exhaustive,
|
|
337
|
+
);
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
/** The `path` variable of message templates: the predicate, or the path in SPARQL syntax. */
|
|
341
|
+
const pathTerm = (path: Path.Path): Term.Term =>
|
|
342
|
+
Predicate.isTagged(path, 'PredicatePath') ? path.predicate : Term.literal(Path.toSparql(path));
|
|
343
|
+
|
|
344
|
+
/** Substitutes `{?var}` / `{$var}` placeholders of result messages. */
|
|
345
|
+
const substituteMessages = (
|
|
346
|
+
messages: ReadonlyArray<Term.Literal>,
|
|
347
|
+
lookup: (name: string) => Option.Option<Term.Term>,
|
|
348
|
+
): ReadonlyArray<Term.Literal> =>
|
|
349
|
+
messages.map((m) => Message.substitute(m, (name) => Option.getOrUndefined(lookup(name))));
|
|
350
|
+
|
|
351
|
+
/** The value of the last parameter of that name. */
|
|
352
|
+
const parameterNamed = (
|
|
353
|
+
parameters: ReadonlyArray<readonly [string, Term.Term]>,
|
|
354
|
+
name: string,
|
|
355
|
+
): Option.Option<Term.Term> =>
|
|
356
|
+
Option.map(
|
|
357
|
+
Arr.findLast(parameters, ([n]) => n === name),
|
|
358
|
+
([, t]) => t,
|
|
359
|
+
);
|
|
360
|
+
|
|
361
|
+
/** The built-in template variables `this`, `value` and `path`. */
|
|
362
|
+
const builtinVariable = (
|
|
363
|
+
name: string,
|
|
364
|
+
focus: Term.Term,
|
|
365
|
+
value: Option.Option<Term.Term>,
|
|
366
|
+
resultPath: Option.Option<Path.Path>,
|
|
367
|
+
): Option.Option<Option.Option<Term.Term>> =>
|
|
368
|
+
Match.value(name).pipe(
|
|
369
|
+
Match.withReturnType<Option.Option<Option.Option<Term.Term>>>(),
|
|
370
|
+
Match.when('this', () => Option.some(Option.some(focus))),
|
|
371
|
+
Match.when('value', () => Option.some(value)),
|
|
372
|
+
Match.when('path', () => Option.some(Option.map(resultPath, pathTerm))),
|
|
373
|
+
Match.orElse(() => Option.none()),
|
|
374
|
+
);
|
|
375
|
+
|
|
376
|
+
interface Engine {
|
|
377
|
+
readonly validateShape: (
|
|
378
|
+
shape: Shapes.Shape,
|
|
379
|
+
focus: Term.GroundTerm,
|
|
380
|
+
) => Effect.Effect<Results, EngineError>;
|
|
381
|
+
readonly focusNodes: (
|
|
382
|
+
shape: Shapes.Shape,
|
|
383
|
+
) => Effect.Effect<ReadonlyArray<Term.GroundTerm>, EngineError>;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
const noValue = Option.none<Term.GroundTerm>();
|
|
387
|
+
|
|
388
|
+
type Keys = MutableHashSet.MutableHashSet<string>;
|
|
389
|
+
|
|
390
|
+
const keysOf = (terms: ReadonlyArray<Term.Term>): Keys =>
|
|
391
|
+
MutableHashSet.fromIterable(Arr.map(terms, (t) => t.key));
|
|
392
|
+
|
|
393
|
+
/** Ground terms by their N-Triples form, in insertion order. */
|
|
394
|
+
type Nodes = MutableHashMap.MutableHashMap<string, Term.GroundTerm>;
|
|
395
|
+
|
|
396
|
+
const addNew = (out: Nodes) => (t: Term.GroundTerm) => {
|
|
397
|
+
if (!MutableHashMap.has(out, t.key)) MutableHashMap.set(out, t.key, t);
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
const valuesOf = (nodes: Nodes): ReadonlyArray<Term.GroundTerm> =>
|
|
401
|
+
Arr.fromIterable(MutableHashMap.values(nodes));
|
|
402
|
+
|
|
403
|
+
/** Number of value nodes conforming to each member shape, for `sh:and` / `sh:or` / `sh:xone`. */
|
|
404
|
+
type LogicalTest = (conforming: number, members: number) => boolean;
|
|
405
|
+
|
|
406
|
+
const andFails: LogicalTest = (conforming, members) => conforming < members;
|
|
407
|
+
const orFails: LogicalTest = (conforming) => conforming === 0;
|
|
408
|
+
const xoneFails: LogicalTest = (conforming) => conforming !== 1;
|
|
409
|
+
|
|
410
|
+
const makeEngine = (
|
|
411
|
+
data: Dataset.Dataset,
|
|
412
|
+
shapes: Shapes.ShapesGraph,
|
|
413
|
+
options: ValidateOptions,
|
|
414
|
+
evaluator: Option.Option<Sparql.SparqlConstraintEvaluator['Service']>,
|
|
415
|
+
): Engine => {
|
|
416
|
+
const memo = MutableHashMap.empty<string, Results>();
|
|
417
|
+
const active: Keys = MutableHashSet.empty();
|
|
418
|
+
const superClassCache = MutableHashMap.empty<string, Keys>();
|
|
419
|
+
const withDetails = options.details === true;
|
|
420
|
+
|
|
421
|
+
// -- RDFS reasoning (SHACL instances / SHACL types, §1.5) ------------------
|
|
422
|
+
const computeSuperClasses = (cls: Term.GroundTerm): Keys => {
|
|
423
|
+
const seen: Keys = MutableHashSet.make(cls.key);
|
|
424
|
+
const unseen = (sup: Term.GroundTerm): boolean => {
|
|
425
|
+
if (MutableHashSet.has(seen, sup.key)) return false;
|
|
426
|
+
MutableHashSet.add(seen, sup.key);
|
|
427
|
+
return true;
|
|
428
|
+
};
|
|
429
|
+
const nextLevel = (
|
|
430
|
+
frontier: ReadonlyArray<Term.GroundTerm>,
|
|
431
|
+
): Option.Option<readonly [void, ReadonlyArray<Term.GroundTerm>]> =>
|
|
432
|
+
Arr.isReadonlyArrayEmpty(frontier)
|
|
433
|
+
? Option.none()
|
|
434
|
+
: Option.some([
|
|
435
|
+
undefined,
|
|
436
|
+
Arr.flatMap(frontier, (c) =>
|
|
437
|
+
Term.isLiteral(c)
|
|
438
|
+
? []
|
|
439
|
+
: Arr.filter(Dataset.objectsOf(data, c, rdfs.subClassOf), unseen),
|
|
440
|
+
),
|
|
441
|
+
]);
|
|
442
|
+
Iterable.forEach(
|
|
443
|
+
Iterable.unfold<ReadonlyArray<Term.GroundTerm>, void>([cls], nextLevel),
|
|
444
|
+
constVoid,
|
|
445
|
+
);
|
|
446
|
+
MutableHashMap.set(superClassCache, cls.key, seen);
|
|
447
|
+
return seen;
|
|
448
|
+
};
|
|
449
|
+
const superClassesOf = (cls: Term.GroundTerm): Keys =>
|
|
450
|
+
Option.getOrElse(MutableHashMap.get(superClassCache, cls.key), () => computeSuperClasses(cls));
|
|
451
|
+
const isInstanceOf = (node: Term.GroundTerm, cls: Term.Term): boolean =>
|
|
452
|
+
!Term.isLiteral(node) &&
|
|
453
|
+
Dataset.objectsOf(data, node, rdf.type).some((t) =>
|
|
454
|
+
MutableHashSet.has(superClassesOf(t), cls.key),
|
|
455
|
+
);
|
|
456
|
+
const instancesOf = (cls: Term.Resource): ReadonlyArray<Term.GroundTerm> => {
|
|
457
|
+
const out: Nodes = MutableHashMap.empty();
|
|
458
|
+
Arr.forEach(Dataset.match(data, { predicate: rdf.type }), (q) => {
|
|
459
|
+
if (
|
|
460
|
+
!MutableHashMap.has(out, q.subject.key) &&
|
|
461
|
+
MutableHashSet.has(superClassesOf(q.object), cls.key)
|
|
462
|
+
)
|
|
463
|
+
MutableHashMap.set(out, q.subject.key, q.subject);
|
|
464
|
+
});
|
|
465
|
+
return valuesOf(out);
|
|
466
|
+
};
|
|
467
|
+
|
|
468
|
+
const objectsOf = (s: Term.GroundTerm, p: Term.NamedNode): ReadonlyArray<Term.GroundTerm> =>
|
|
469
|
+
Term.isLiteral(s) ? [] : Dataset.objectsOf(data, s, p);
|
|
470
|
+
|
|
471
|
+
const shapeById = (id: Shapes.ShapeId): Shapes.Shape =>
|
|
472
|
+
Option.getOrElse(Shapes.get(shapes, id), (): Shapes.Shape => ({
|
|
473
|
+
_tag: 'NodeShape',
|
|
474
|
+
id,
|
|
475
|
+
targets: [],
|
|
476
|
+
constraints: [],
|
|
477
|
+
severity: sh.Violation,
|
|
478
|
+
messages: [],
|
|
479
|
+
deactivated: false,
|
|
480
|
+
}));
|
|
481
|
+
|
|
482
|
+
const unsupported = (
|
|
483
|
+
shape: Shapes.Shape,
|
|
484
|
+
feature: string,
|
|
485
|
+
): Effect.Effect<Results, EngineError> =>
|
|
486
|
+
options.sparql === 'ignore'
|
|
487
|
+
? Effect.succeed([])
|
|
488
|
+
: Effect.fail(
|
|
489
|
+
new UnsupportedFeatureError({
|
|
490
|
+
message: `${feature} used by shape ${shape.id.key} requires a SparqlConstraintEvaluator`,
|
|
491
|
+
feature,
|
|
492
|
+
shape: shape.id.key,
|
|
493
|
+
}),
|
|
494
|
+
);
|
|
495
|
+
|
|
496
|
+
const recursive = (
|
|
497
|
+
shape: Shapes.Shape,
|
|
498
|
+
focus: Term.GroundTerm,
|
|
499
|
+
): Effect.Effect<Results, EngineError> =>
|
|
500
|
+
options.recursion === 'ignore'
|
|
501
|
+
? Effect.succeed([])
|
|
502
|
+
: Effect.fail(
|
|
503
|
+
new RecursiveShapeError({
|
|
504
|
+
message: `shape ${shape.id.key} is recursive for focus node ${focus.key}`,
|
|
505
|
+
shape: shape.id.key,
|
|
506
|
+
focusNode: focus.key,
|
|
507
|
+
}),
|
|
508
|
+
);
|
|
509
|
+
|
|
510
|
+
const validateShape = (
|
|
511
|
+
shape: Shapes.Shape,
|
|
512
|
+
focus: Term.GroundTerm,
|
|
513
|
+
): Effect.Effect<Results, EngineError> =>
|
|
514
|
+
Effect.suspend(() => {
|
|
515
|
+
if (shape.deactivated) return Effect.succeed([]);
|
|
516
|
+
const key = `${shape.id.key} ${focus.key}`;
|
|
517
|
+
const cached = MutableHashMap.get(memo, key);
|
|
518
|
+
if (Option.isSome(cached)) return Effect.succeed(cached.value);
|
|
519
|
+
if (MutableHashSet.has(active, key)) return recursive(shape, focus);
|
|
520
|
+
MutableHashSet.add(active, key);
|
|
521
|
+
const valueNodes = Predicate.isTagged(shape, 'PropertyShape')
|
|
522
|
+
? Path.evaluate(data, focus, shape.path)
|
|
523
|
+
: [focus];
|
|
524
|
+
return Effect.forEach(shape.constraints, (c) => evaluate(shape, focus, valueNodes, c), {
|
|
525
|
+
concurrency: 1,
|
|
526
|
+
}).pipe(
|
|
527
|
+
Effect.map((rs) => {
|
|
528
|
+
const results = rs.flat();
|
|
529
|
+
MutableHashSet.remove(active, key);
|
|
530
|
+
MutableHashMap.set(memo, key, results);
|
|
531
|
+
return results;
|
|
532
|
+
}),
|
|
533
|
+
);
|
|
534
|
+
});
|
|
535
|
+
|
|
536
|
+
const conforms = (
|
|
537
|
+
id: Shapes.ShapeId,
|
|
538
|
+
node: Term.GroundTerm,
|
|
539
|
+
): Effect.Effect<boolean, EngineError> =>
|
|
540
|
+
Effect.map(validateShape(shapeById(id), node), (rs) => Arr.isReadonlyArrayEmpty(rs));
|
|
541
|
+
|
|
542
|
+
const nestedResults = (id: Shapes.ShapeId, v: Term.GroundTerm) => validateShape(shapeById(id), v);
|
|
543
|
+
|
|
544
|
+
const evaluate = Effect.fnUntraced(function* (
|
|
545
|
+
shape: Shapes.Shape,
|
|
546
|
+
focus: Term.GroundTerm,
|
|
547
|
+
valueNodes: ReadonlyArray<Term.GroundTerm>,
|
|
548
|
+
constraint: Shapes.Constraint,
|
|
549
|
+
): Effect.fn.Return<Results, EngineError> {
|
|
550
|
+
const component = Shapes.componentOf(constraint);
|
|
551
|
+
const shapePath = Predicate.isTagged(shape, 'PropertyShape')
|
|
552
|
+
? Option.some(shape.path)
|
|
553
|
+
: Option.none<Path.Path>();
|
|
554
|
+
const parameters = coreParameters(constraint);
|
|
555
|
+
const result = (
|
|
556
|
+
value: Option.Option<Term.GroundTerm>,
|
|
557
|
+
extra: { readonly path?: Path.Path; readonly details?: Results } = {},
|
|
558
|
+
) => {
|
|
559
|
+
const resultPath = extra.path === undefined ? shapePath : Option.some(extra.path);
|
|
560
|
+
return ValidationReport.makeResult({
|
|
561
|
+
focusNode: focus,
|
|
562
|
+
sourceShape: shape.id,
|
|
563
|
+
sourceConstraintComponent: component,
|
|
564
|
+
severity: shape.severity,
|
|
565
|
+
resultPath,
|
|
566
|
+
value,
|
|
567
|
+
messages: Arr.isReadonlyArrayNonEmpty(shape.messages)
|
|
568
|
+
? substituteMessages(shape.messages, (name) =>
|
|
569
|
+
Option.getOrElse(builtinVariable(name, focus, value, resultPath), () =>
|
|
570
|
+
parameterNamed(parameters, name),
|
|
571
|
+
),
|
|
572
|
+
)
|
|
573
|
+
: [Term.literal(defaultMessage(constraint, value))],
|
|
574
|
+
details: withDetails ? (extra.details ?? []) : [],
|
|
575
|
+
});
|
|
576
|
+
};
|
|
577
|
+
const each = (failed: (v: Term.GroundTerm) => boolean): Results =>
|
|
578
|
+
valueNodes.filter(failed).map((v) => result(Option.some(v)));
|
|
579
|
+
const logical = (members: ReadonlyArray<Shapes.ShapeId>, fails: LogicalTest) =>
|
|
580
|
+
Effect.map(
|
|
581
|
+
Effect.forEach(
|
|
582
|
+
valueNodes,
|
|
583
|
+
(v) =>
|
|
584
|
+
Effect.map(
|
|
585
|
+
Effect.forEach(members, (s) => nestedResults(s, v), { concurrency: 1 }),
|
|
586
|
+
(nested) => {
|
|
587
|
+
const conforming = nested.filter((rs) => Arr.isReadonlyArrayEmpty(rs)).length;
|
|
588
|
+
return fails(conforming, members.length)
|
|
589
|
+
? [result(Option.some(v), { details: nested.flat() })]
|
|
590
|
+
: [];
|
|
591
|
+
},
|
|
592
|
+
),
|
|
593
|
+
{ concurrency: 1 },
|
|
594
|
+
),
|
|
595
|
+
(perNode) => perNode.flat(),
|
|
596
|
+
);
|
|
597
|
+
// A value node counts when it conforms to the qualified shape and, with
|
|
598
|
+
// `sh:qualifiedValueShapesDisjoint`, to none of the sibling shapes.
|
|
599
|
+
const qualifiedCount = (c: {
|
|
600
|
+
readonly shape: Shapes.ShapeId;
|
|
601
|
+
readonly disjoint: boolean;
|
|
602
|
+
readonly siblings: ReadonlyArray<Shapes.ShapeId>;
|
|
603
|
+
}) =>
|
|
604
|
+
Effect.map(
|
|
605
|
+
Effect.filter(valueNodes, (v) =>
|
|
606
|
+
Effect.flatMap(conforms(c.shape, v), (ok) =>
|
|
607
|
+
!ok || !c.disjoint
|
|
608
|
+
? Effect.succeed(ok)
|
|
609
|
+
: Effect.map(
|
|
610
|
+
Effect.findFirst(c.siblings, (s) => conforms(s, v)),
|
|
611
|
+
Option.isNone,
|
|
612
|
+
),
|
|
613
|
+
),
|
|
614
|
+
),
|
|
615
|
+
(counted) => counted.length,
|
|
616
|
+
);
|
|
617
|
+
const lessThan = (predicate: Term.NamedNode, ok: (sign: Sign) => boolean) =>
|
|
618
|
+
Effect.sync(() => {
|
|
619
|
+
const others = objectsOf(focus, predicate);
|
|
620
|
+
return Arr.flatMap(valueNodes, (v) =>
|
|
621
|
+
Arr.map(
|
|
622
|
+
Arr.filter(others, (o) => !ordered(v, o, ok)),
|
|
623
|
+
() => result(Option.some(v)),
|
|
624
|
+
),
|
|
625
|
+
);
|
|
626
|
+
});
|
|
627
|
+
|
|
628
|
+
return yield* Match.value(constraint)
|
|
629
|
+
.pipe(
|
|
630
|
+
Match.tag('Class', (c) => Effect.sync(() => each((v) => !isInstanceOf(v, c.class)))),
|
|
631
|
+
Match.tag('Datatype', (c) => Effect.sync(() => each((v) => !hasDatatype(v, c.datatype)))),
|
|
632
|
+
Match.tag('NodeKind', (c) =>
|
|
633
|
+
Effect.sync(() => each((v) => !matchesNodeKind(v, c.nodeKind))),
|
|
634
|
+
),
|
|
635
|
+
Match.tag('MinCount', (c) =>
|
|
636
|
+
Effect.sync(() => (valueNodes.length < c.minCount ? [result(noValue)] : [])),
|
|
637
|
+
),
|
|
638
|
+
Match.tag('MaxCount', (c) =>
|
|
639
|
+
Effect.sync(() => (valueNodes.length > c.maxCount ? [result(noValue)] : [])),
|
|
640
|
+
),
|
|
641
|
+
Match.tag('MinExclusive', (c) =>
|
|
642
|
+
Effect.sync(() => each((v) => !ordered(v, c.value, (s) => s === 1))),
|
|
643
|
+
),
|
|
644
|
+
Match.tag('MinInclusive', (c) =>
|
|
645
|
+
Effect.sync(() => each((v) => !ordered(v, c.value, (s) => s !== -1))),
|
|
646
|
+
),
|
|
647
|
+
Match.tag('MaxExclusive', (c) =>
|
|
648
|
+
Effect.sync(() => each((v) => !ordered(v, c.value, (s) => s === -1))),
|
|
649
|
+
),
|
|
650
|
+
Match.tag('MaxInclusive', (c) =>
|
|
651
|
+
Effect.sync(() => each((v) => !ordered(v, c.value, (s) => s !== 1))),
|
|
652
|
+
),
|
|
653
|
+
Match.tag('MinLength', (c) =>
|
|
654
|
+
Effect.sync(() => each((v) => failsString(v, (s) => codePointLength(s) >= c.minLength))),
|
|
655
|
+
),
|
|
656
|
+
Match.tag('MaxLength', (c) =>
|
|
657
|
+
Effect.sync(() => each((v) => failsString(v, (s) => codePointLength(s) <= c.maxLength))),
|
|
658
|
+
),
|
|
659
|
+
Match.tag('Pattern', (c) =>
|
|
660
|
+
Effect.sync(() => each((v) => failsString(v, (s) => c.regex.test(s)))),
|
|
661
|
+
),
|
|
662
|
+
Match.tag('LanguageIn', (c) =>
|
|
663
|
+
Effect.sync(() =>
|
|
664
|
+
each(
|
|
665
|
+
(v) =>
|
|
666
|
+
!Term.isLiteral(v) || !c.languages.some((range) => langMatches(v.language, range)),
|
|
667
|
+
),
|
|
668
|
+
),
|
|
669
|
+
),
|
|
670
|
+
Match.tag('UniqueLang', () =>
|
|
671
|
+
Effect.sync(() => {
|
|
672
|
+
const languages = Arr.flatMap(valueNodes, (v) =>
|
|
673
|
+
Term.isLiteral(v) && v.language !== '' ? [v.language.toLowerCase()] : [],
|
|
674
|
+
);
|
|
675
|
+
return Arr.map(
|
|
676
|
+
Arr.filter(Record.values(Arr.groupBy(languages, identity)), (g) => g.length > 1),
|
|
677
|
+
() => result(noValue),
|
|
678
|
+
);
|
|
679
|
+
}),
|
|
680
|
+
),
|
|
681
|
+
Match.tag('Equals', (c) =>
|
|
682
|
+
Effect.sync(() => {
|
|
683
|
+
const others = objectsOf(focus, c.predicate);
|
|
684
|
+
const otherKeys = keysOf(others);
|
|
685
|
+
const valueKeys = keysOf(valueNodes);
|
|
686
|
+
return [
|
|
687
|
+
...valueNodes
|
|
688
|
+
.filter((v) => !MutableHashSet.has(otherKeys, v.key))
|
|
689
|
+
.map((v) => result(Option.some(v))),
|
|
690
|
+
...others
|
|
691
|
+
.filter((o) => !MutableHashSet.has(valueKeys, o.key))
|
|
692
|
+
.map((o) => result(Option.some(o))),
|
|
693
|
+
];
|
|
694
|
+
}),
|
|
695
|
+
),
|
|
696
|
+
Match.tag('Disjoint', (c) =>
|
|
697
|
+
Effect.sync(() => {
|
|
698
|
+
const otherKeys = keysOf(objectsOf(focus, c.predicate));
|
|
699
|
+
return each((v) => MutableHashSet.has(otherKeys, v.key));
|
|
700
|
+
}),
|
|
701
|
+
),
|
|
702
|
+
Match.tag('LessThan', (c) => lessThan(c.predicate, (s) => s === -1)),
|
|
703
|
+
Match.tag('LessThanOrEquals', (c) => lessThan(c.predicate, (s) => s !== 1)),
|
|
704
|
+
Match.tag('Not', (c) =>
|
|
705
|
+
Effect.gen(function* () {
|
|
706
|
+
const conforming = yield* Effect.filter(valueNodes, (v) => conforms(c.shape, v));
|
|
707
|
+
return conforming.map((v) => result(Option.some(v)));
|
|
708
|
+
}),
|
|
709
|
+
),
|
|
710
|
+
)
|
|
711
|
+
.pipe(
|
|
712
|
+
Match.tag('And', (c) => logical(c.shapes, andFails)),
|
|
713
|
+
Match.tag('Or', (c) => logical(c.shapes, orFails)),
|
|
714
|
+
Match.tag('Xone', (c) => logical(c.shapes, xoneFails)),
|
|
715
|
+
Match.tag('Node', (c) =>
|
|
716
|
+
Effect.gen(function* () {
|
|
717
|
+
const nested = c.shape;
|
|
718
|
+
const perNode = yield* Effect.forEach(
|
|
719
|
+
valueNodes,
|
|
720
|
+
(v) =>
|
|
721
|
+
Effect.map(nestedResults(nested, v), (rs) =>
|
|
722
|
+
Arr.isReadonlyArrayNonEmpty(rs) ? [result(Option.some(v), { details: rs })] : [],
|
|
723
|
+
),
|
|
724
|
+
{ concurrency: 1 },
|
|
725
|
+
);
|
|
726
|
+
return perNode.flat();
|
|
727
|
+
}),
|
|
728
|
+
),
|
|
729
|
+
Match.tag('Property', (c) =>
|
|
730
|
+
Effect.gen(function* () {
|
|
731
|
+
const property = shapeById(c.shape);
|
|
732
|
+
const perNode = yield* Effect.forEach(valueNodes, (v) => validateShape(property, v), {
|
|
733
|
+
concurrency: 1,
|
|
734
|
+
});
|
|
735
|
+
return perNode.flat();
|
|
736
|
+
}),
|
|
737
|
+
),
|
|
738
|
+
Match.tag('QualifiedMinCount', (c) =>
|
|
739
|
+
Effect.map(qualifiedCount(c), (count) => (count < c.count ? [result(noValue)] : [])),
|
|
740
|
+
),
|
|
741
|
+
Match.tag('QualifiedMaxCount', (c) =>
|
|
742
|
+
Effect.map(qualifiedCount(c), (count) => (count > c.count ? [result(noValue)] : [])),
|
|
743
|
+
),
|
|
744
|
+
Match.tag('Closed', (c) =>
|
|
745
|
+
Effect.sync(() => {
|
|
746
|
+
const allowed = keysOf(c.allowedProperties);
|
|
747
|
+
return Arr.flatMap(valueNodes, (v) =>
|
|
748
|
+
Term.isLiteral(v)
|
|
749
|
+
? []
|
|
750
|
+
: Arr.flatMap(Dataset.match(data, { subject: v }), (q) =>
|
|
751
|
+
MutableHashSet.has(allowed, q.predicate.key)
|
|
752
|
+
? []
|
|
753
|
+
: [result(Option.some(q.object), { path: Path.predicate(q.predicate) })],
|
|
754
|
+
),
|
|
755
|
+
);
|
|
756
|
+
}),
|
|
757
|
+
),
|
|
758
|
+
Match.tag('HasValue', (c) =>
|
|
759
|
+
Effect.sync(() =>
|
|
760
|
+
valueNodes.some((v) => v.key === c.value.key) ? [] : [result(noValue)],
|
|
761
|
+
),
|
|
762
|
+
),
|
|
763
|
+
Match.tag('In', (c) =>
|
|
764
|
+
Effect.sync(() => {
|
|
765
|
+
const allowed = keysOf(c.values);
|
|
766
|
+
return each((v) => !MutableHashSet.has(allowed, v.key));
|
|
767
|
+
}),
|
|
768
|
+
),
|
|
769
|
+
Match.tag('Sparql', 'Component', (c) =>
|
|
770
|
+
Effect.gen(function* () {
|
|
771
|
+
if (Option.isNone(evaluator)) {
|
|
772
|
+
return yield* unsupported(
|
|
773
|
+
shape,
|
|
774
|
+
Predicate.isTagged(c, 'Sparql')
|
|
775
|
+
? 'sh:sparql'
|
|
776
|
+
: `constraint component ${c.component.key}`,
|
|
777
|
+
);
|
|
778
|
+
}
|
|
779
|
+
const violations = yield* evaluator.value.evaluateConstraint({
|
|
780
|
+
dataGraph: data,
|
|
781
|
+
shapesGraph: shapes,
|
|
782
|
+
shape,
|
|
783
|
+
constraint: c,
|
|
784
|
+
focusNode: focus,
|
|
785
|
+
valueNodes,
|
|
786
|
+
});
|
|
787
|
+
return violations.map((violation) => {
|
|
788
|
+
const focusNode = violation.focusNode ?? focus;
|
|
789
|
+
const value = Option.fromNullishOr(violation.value);
|
|
790
|
+
const resultPath =
|
|
791
|
+
violation.path !== undefined ? Option.some(violation.path) : shapePath;
|
|
792
|
+
const lookup = (name: string): Option.Option<Term.Term> =>
|
|
793
|
+
pipe(
|
|
794
|
+
Option.fromNullishOr(violation.bindings?.get(name)),
|
|
795
|
+
Option.orElse(() => parameterNamed(parameters, name)),
|
|
796
|
+
Option.orElse(() =>
|
|
797
|
+
Option.flatten(builtinVariable(name, focusNode, value, resultPath)),
|
|
798
|
+
),
|
|
799
|
+
);
|
|
800
|
+
const templates =
|
|
801
|
+
violation.messages !== undefined && Arr.isReadonlyArrayNonEmpty(violation.messages)
|
|
802
|
+
? violation.messages
|
|
803
|
+
: shape.messages;
|
|
804
|
+
return ValidationReport.makeResult({
|
|
805
|
+
focusNode,
|
|
806
|
+
sourceShape: shape.id,
|
|
807
|
+
sourceConstraintComponent: component,
|
|
808
|
+
sourceConstraint: Predicate.isTagged(c, 'Sparql')
|
|
809
|
+
? Option.some(c.node)
|
|
810
|
+
: Option.none(),
|
|
811
|
+
severity: violation.severity ?? shape.severity,
|
|
812
|
+
resultPath,
|
|
813
|
+
value,
|
|
814
|
+
messages: Arr.isReadonlyArrayNonEmpty(templates)
|
|
815
|
+
? substituteMessages(templates, lookup)
|
|
816
|
+
: [Term.literal(defaultMessage(c, value))],
|
|
817
|
+
});
|
|
818
|
+
});
|
|
819
|
+
}),
|
|
820
|
+
),
|
|
821
|
+
Match.exhaustive,
|
|
822
|
+
);
|
|
823
|
+
});
|
|
824
|
+
|
|
825
|
+
const focusNodes = Effect.fnUntraced(function* (
|
|
826
|
+
shape: Shapes.Shape,
|
|
827
|
+
): Effect.fn.Return<ReadonlyArray<Term.GroundTerm>, EngineError> {
|
|
828
|
+
const out: Nodes = MutableHashMap.empty();
|
|
829
|
+
const add = addNew(out);
|
|
830
|
+
yield* Effect.forEach(
|
|
831
|
+
shape.targets,
|
|
832
|
+
Effect.fnUntraced(function* (target) {
|
|
833
|
+
yield* Match.value(target).pipe(
|
|
834
|
+
Match.tag('TargetNode', (t) => Effect.sync(() => add(t.node))),
|
|
835
|
+
Match.tag('TargetClass', (t) =>
|
|
836
|
+
Effect.sync(() => Arr.forEach(instancesOf(t.class), add)),
|
|
837
|
+
),
|
|
838
|
+
Match.tag('TargetSubjectsOf', (t) =>
|
|
839
|
+
Effect.sync(() =>
|
|
840
|
+
Arr.forEach(Dataset.match(data, { predicate: t.predicate }), (q) => add(q.subject)),
|
|
841
|
+
),
|
|
842
|
+
),
|
|
843
|
+
Match.tag('TargetObjectsOf', (t) =>
|
|
844
|
+
Effect.sync(() =>
|
|
845
|
+
Arr.forEach(Dataset.match(data, { predicate: t.predicate }), (q) => add(q.object)),
|
|
846
|
+
),
|
|
847
|
+
),
|
|
848
|
+
Match.tag('SparqlTarget', (t) =>
|
|
849
|
+
Option.match(evaluator, {
|
|
850
|
+
onNone: () => unsupported(shape, 'sh:target'),
|
|
851
|
+
onSome: (ev) =>
|
|
852
|
+
Effect.map(
|
|
853
|
+
ev.selectTargets({ dataGraph: data, shapesGraph: shapes, shape, target: t.node }),
|
|
854
|
+
(nodes) => Arr.forEach(nodes, add),
|
|
855
|
+
),
|
|
856
|
+
}),
|
|
857
|
+
),
|
|
858
|
+
Match.exhaustive,
|
|
859
|
+
);
|
|
860
|
+
}),
|
|
861
|
+
{ concurrency: 1, discard: true },
|
|
862
|
+
);
|
|
863
|
+
return valuesOf(out);
|
|
864
|
+
});
|
|
865
|
+
|
|
866
|
+
return { validateShape, focusNodes };
|
|
867
|
+
};
|
|
868
|
+
|
|
869
|
+
const resolveShapes = (
|
|
870
|
+
shapes: Dataset.Dataset | Shapes.ShapesGraph,
|
|
871
|
+
): Effect.Effect<Shapes.ShapesGraph, Shapes.ShapesGraphError> =>
|
|
872
|
+
Shapes.isShapesGraph(shapes) ? Effect.succeed(shapes) : Shapes.parse(shapes);
|
|
873
|
+
|
|
874
|
+
// -----------------------------------------------------------------------------
|
|
875
|
+
// API
|
|
876
|
+
// -----------------------------------------------------------------------------
|
|
877
|
+
|
|
878
|
+
/** Parses the shapes graph (if needed) and builds the engine over the data graph. */
|
|
879
|
+
const prepare = Effect.fnUntraced(function* (
|
|
880
|
+
dataGraph: Dataset.Dataset,
|
|
881
|
+
shapesGraph: Dataset.Dataset | Shapes.ShapesGraph,
|
|
882
|
+
options: ValidateOptions,
|
|
883
|
+
) {
|
|
884
|
+
const shapes = yield* resolveShapes(shapesGraph);
|
|
885
|
+
const data =
|
|
886
|
+
options.includeShapesGraph === true ? Dataset.union(dataGraph, shapes.dataset) : dataGraph;
|
|
887
|
+
const evaluator = yield* Effect.serviceOption(Sparql.SparqlConstraintEvaluator);
|
|
888
|
+
return { shapes, engine: makeEngine(data, shapes, options, evaluator) };
|
|
889
|
+
});
|
|
890
|
+
|
|
891
|
+
/**
|
|
892
|
+
* Validates a data graph against a shapes graph (either an RDF dataset, which
|
|
893
|
+
* is parsed first, or a pre-parsed `Shapes.ShapesGraph`).
|
|
894
|
+
*
|
|
895
|
+
* SPARQL-based constraints and targets are delegated to a
|
|
896
|
+
* `Sparql.SparqlConstraintEvaluator` when one is present in the context.
|
|
897
|
+
*
|
|
898
|
+
* @since 0.1.0
|
|
899
|
+
* @category validation
|
|
900
|
+
*/
|
|
901
|
+
export const validate: (
|
|
902
|
+
dataGraph: Dataset.Dataset,
|
|
903
|
+
shapesGraph: Dataset.Dataset | Shapes.ShapesGraph,
|
|
904
|
+
options?: ValidateOptions,
|
|
905
|
+
) => Effect.Effect<ValidationReport.ValidationReport, ValidationError> = Effect.fn(
|
|
906
|
+
'Shacl.validate',
|
|
907
|
+
)(function* (dataGraph, shapesGraph, options = {}) {
|
|
908
|
+
const { shapes, engine } = yield* prepare(dataGraph, shapesGraph, options);
|
|
909
|
+
yield* Effect.annotateCurrentSpan({
|
|
910
|
+
'shacl.shapes': shapes.shapes.length,
|
|
911
|
+
'rdf.quads': dataGraph.size,
|
|
912
|
+
});
|
|
913
|
+
const perShape = yield* Effect.forEach(
|
|
914
|
+
shapes.shapes,
|
|
915
|
+
(shape) =>
|
|
916
|
+
shape.deactivated || Arr.isReadonlyArrayEmpty(shape.targets)
|
|
917
|
+
? Effect.succeed<ReadonlyArray<ValidationReport.ValidationResult>>([])
|
|
918
|
+
: Effect.flatMap(engine.focusNodes(shape), (foci) =>
|
|
919
|
+
Effect.map(
|
|
920
|
+
Effect.forEach(foci, (focus) => engine.validateShape(shape, focus), {
|
|
921
|
+
concurrency: 1,
|
|
922
|
+
}),
|
|
923
|
+
(rs) => rs.flat(),
|
|
924
|
+
),
|
|
925
|
+
),
|
|
926
|
+
{ concurrency: 1 },
|
|
927
|
+
);
|
|
928
|
+
const report = ValidationReport.make(perShape.flat());
|
|
929
|
+
yield* Effect.annotateCurrentSpan({
|
|
930
|
+
'shacl.results': report.results.length,
|
|
931
|
+
'shacl.conforms': report.conforms,
|
|
932
|
+
});
|
|
933
|
+
return report;
|
|
934
|
+
});
|
|
935
|
+
|
|
936
|
+
/**
|
|
937
|
+
* Validates a single focus node against one shape of a shapes graph,
|
|
938
|
+
* ignoring targets.
|
|
939
|
+
*
|
|
940
|
+
* @since 0.1.0
|
|
941
|
+
* @category validation
|
|
942
|
+
*/
|
|
943
|
+
export const validateNode: (
|
|
944
|
+
dataGraph: Dataset.Dataset,
|
|
945
|
+
shapesGraph: Dataset.Dataset | Shapes.ShapesGraph,
|
|
946
|
+
shape: Shapes.ShapeId,
|
|
947
|
+
focusNode: Term.GroundTerm,
|
|
948
|
+
options?: ValidateOptions,
|
|
949
|
+
) => Effect.Effect<ValidationReport.ValidationReport, ValidationError> = Effect.fnUntraced(
|
|
950
|
+
function* (dataGraph, shapesGraph, shapeId, focusNode, options = {}) {
|
|
951
|
+
const { shapes, engine } = yield* prepare(dataGraph, shapesGraph, options);
|
|
952
|
+
const shape = Option.getOrUndefined(Shapes.get(shapes, shapeId));
|
|
953
|
+
if (shape === undefined) return ValidationReport.make([]);
|
|
954
|
+
return ValidationReport.make(yield* engine.validateShape(shape, focusNode));
|
|
955
|
+
},
|
|
956
|
+
);
|
|
957
|
+
|
|
958
|
+
/**
|
|
959
|
+
* Whether a data graph conforms to a shapes graph.
|
|
960
|
+
*
|
|
961
|
+
* @since 0.1.0
|
|
962
|
+
* @category validation
|
|
963
|
+
*/
|
|
964
|
+
export const conforms = (
|
|
965
|
+
dataGraph: Dataset.Dataset,
|
|
966
|
+
shapesGraph: Dataset.Dataset | Shapes.ShapesGraph,
|
|
967
|
+
options?: ValidateOptions,
|
|
968
|
+
): Effect.Effect<boolean, ValidationError> =>
|
|
969
|
+
Effect.map(validate(dataGraph, shapesGraph, options), (r) => r.conforms);
|
|
970
|
+
|
|
971
|
+
/**
|
|
972
|
+
* Validates and fails with a `ConformanceError` (carrying the report) when
|
|
973
|
+
* the data graph does not conform; succeeds with the data graph otherwise.
|
|
974
|
+
*
|
|
975
|
+
* @since 0.1.0
|
|
976
|
+
* @category validation
|
|
977
|
+
*/
|
|
978
|
+
export const assertConforms = (
|
|
979
|
+
dataGraph: Dataset.Dataset,
|
|
980
|
+
shapesGraph: Dataset.Dataset | Shapes.ShapesGraph,
|
|
981
|
+
options?: ValidateOptions,
|
|
982
|
+
): Effect.Effect<Dataset.Dataset, ValidationError | ConformanceError> =>
|
|
983
|
+
Effect.flatMap(validate(dataGraph, shapesGraph, options), (report) =>
|
|
984
|
+
report.conforms
|
|
985
|
+
? Effect.succeed(dataGraph)
|
|
986
|
+
: Effect.fail(new ConformanceError({ message: ValidationReport.format(report), report })),
|
|
987
|
+
);
|
|
988
|
+
|
|
989
|
+
// -----------------------------------------------------------------------------
|
|
990
|
+
// Service
|
|
991
|
+
// -----------------------------------------------------------------------------
|
|
992
|
+
|
|
993
|
+
/**
|
|
994
|
+
* A validator bound to a pre-compiled shapes graph.
|
|
995
|
+
*
|
|
996
|
+
* @since 0.1.0
|
|
997
|
+
* @category services
|
|
998
|
+
*/
|
|
999
|
+
export class Validator extends Context.Service<
|
|
1000
|
+
Validator,
|
|
1001
|
+
{
|
|
1002
|
+
/** The compiled shapes graph. */
|
|
1003
|
+
readonly shapesGraph: Shapes.ShapesGraph;
|
|
1004
|
+
/** Validates a data graph, producing a report. */
|
|
1005
|
+
readonly validate: (
|
|
1006
|
+
dataGraph: Dataset.Dataset,
|
|
1007
|
+
options?: ValidateOptions,
|
|
1008
|
+
) => Effect.Effect<ValidationReport.ValidationReport, ValidationError>;
|
|
1009
|
+
/** Whether a data graph conforms. */
|
|
1010
|
+
readonly conforms: (
|
|
1011
|
+
dataGraph: Dataset.Dataset,
|
|
1012
|
+
options?: ValidateOptions,
|
|
1013
|
+
) => Effect.Effect<boolean, ValidationError>;
|
|
1014
|
+
/** Succeeds with the data graph if it conforms, failing with a `ConformanceError` otherwise. */
|
|
1015
|
+
readonly check: (
|
|
1016
|
+
dataGraph: Dataset.Dataset,
|
|
1017
|
+
options?: ValidateOptions,
|
|
1018
|
+
) => Effect.Effect<Dataset.Dataset, ValidationError | ConformanceError>;
|
|
1019
|
+
}
|
|
1020
|
+
>()('@thomasfosterau/effect-rdf/shacl/Validator') {}
|
|
1021
|
+
|
|
1022
|
+
/**
|
|
1023
|
+
* Compiles a shapes graph into a `Validator` service implementation. The
|
|
1024
|
+
* given options are defaults that individual calls may override.
|
|
1025
|
+
*
|
|
1026
|
+
* @since 0.1.0
|
|
1027
|
+
* @category constructors
|
|
1028
|
+
*/
|
|
1029
|
+
export const make: (
|
|
1030
|
+
shapesGraph: Dataset.Dataset | Shapes.ShapesGraph,
|
|
1031
|
+
defaults?: ValidateOptions,
|
|
1032
|
+
) => Effect.Effect<Validator['Service'], Shapes.ShapesGraphError> = Effect.fnUntraced(function* (
|
|
1033
|
+
shapesGraph,
|
|
1034
|
+
defaults = {},
|
|
1035
|
+
) {
|
|
1036
|
+
const compiled = yield* resolveShapes(shapesGraph);
|
|
1037
|
+
const merge = (options?: ValidateOptions) => ({ ...defaults, ...options });
|
|
1038
|
+
return Validator.of({
|
|
1039
|
+
shapesGraph: compiled,
|
|
1040
|
+
validate: (data, options) => validate(data, compiled, merge(options)),
|
|
1041
|
+
conforms: (data, options) => conforms(data, compiled, merge(options)),
|
|
1042
|
+
check: (data, options) => assertConforms(data, compiled, merge(options)),
|
|
1043
|
+
});
|
|
1044
|
+
});
|
|
1045
|
+
|
|
1046
|
+
/**
|
|
1047
|
+
* A layer providing a `Validator` for the given shapes graph.
|
|
1048
|
+
*
|
|
1049
|
+
* @since 0.1.0
|
|
1050
|
+
* @category layers
|
|
1051
|
+
*/
|
|
1052
|
+
export const layer = (
|
|
1053
|
+
shapesGraph: Dataset.Dataset | Shapes.ShapesGraph,
|
|
1054
|
+
defaults?: ValidateOptions,
|
|
1055
|
+
): Layer.Layer<Validator, Shapes.ShapesGraphError> =>
|
|
1056
|
+
Layer.effect(Validator, make(shapesGraph, defaults));
|
|
1057
|
+
|
|
1058
|
+
// -----------------------------------------------------------------------------
|
|
1059
|
+
// Schema integration
|
|
1060
|
+
// -----------------------------------------------------------------------------
|
|
1061
|
+
|
|
1062
|
+
/**
|
|
1063
|
+
* Options for `schema`: validation options plus the severity that fails
|
|
1064
|
+
* decoding.
|
|
1065
|
+
*
|
|
1066
|
+
* @since 0.1.0
|
|
1067
|
+
* @category schemas
|
|
1068
|
+
*/
|
|
1069
|
+
export interface SchemaOptions extends ValidateOptions {
|
|
1070
|
+
/**
|
|
1071
|
+
* The least severe result that fails decoding: `"violation"` (default)
|
|
1072
|
+
* accepts data whose results are only `sh:Warning` or `sh:Info`,
|
|
1073
|
+
* `"warning"` also fails on warnings, and `"info"` on any result (the
|
|
1074
|
+
* report's own `conforms`, which is false whenever there is any result).
|
|
1075
|
+
* Results with a custom severity count as violations.
|
|
1076
|
+
*/
|
|
1077
|
+
readonly failOn?: 'violation' | 'warning' | 'info' | undefined;
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
const severityRank = (severity: Term.NamedNode): number =>
|
|
1081
|
+
severity.value === sh.Info.value ? 0 : severity.value === sh.Warning.value ? 1 : 2;
|
|
1082
|
+
|
|
1083
|
+
const thresholdRank = { info: 0, warning: 1, violation: 2 } as const;
|
|
1084
|
+
|
|
1085
|
+
/**
|
|
1086
|
+
* A `Schema` that accepts a `Dataset` only if it conforms to the given shapes
|
|
1087
|
+
* graph. Decoding fails with a `SchemaIssue.Composite` holding one
|
|
1088
|
+
* `InvalidValue` issue per failing result: its `message` annotation is the
|
|
1089
|
+
* formatted result (`ValidationReport.formatResult`) and its `result`
|
|
1090
|
+
* annotation the `ValidationResult` itself, for consumers that inspect
|
|
1091
|
+
* failures (focus node, path, constraint component, severity, messages). By
|
|
1092
|
+
* default only `sh:Violation` results fail (see `SchemaOptions.failOn`).
|
|
1093
|
+
* Encoding is the identity.
|
|
1094
|
+
*
|
|
1095
|
+
* Compose it with a syntax codec to parse and validate in one decode:
|
|
1096
|
+
* `Turtle.codec.schema.pipe(Schema.decodeTo(Validator.schema(shapes)))`.
|
|
1097
|
+
*
|
|
1098
|
+
* @since 0.1.0
|
|
1099
|
+
* @category schemas
|
|
1100
|
+
*/
|
|
1101
|
+
export const schema = (
|
|
1102
|
+
shapesGraph: Shapes.ShapesGraph,
|
|
1103
|
+
options?: SchemaOptions,
|
|
1104
|
+
): Schema.decodeTo<Schema.declare<Dataset.Dataset>, Schema.declare<Dataset.Dataset>> => {
|
|
1105
|
+
const threshold = thresholdRank[options?.failOn ?? 'violation'];
|
|
1106
|
+
return Dataset.DatasetSchema.pipe(
|
|
1107
|
+
Schema.decodeTo(
|
|
1108
|
+
Dataset.DatasetSchema,
|
|
1109
|
+
SchemaTransformation.transformEffect({
|
|
1110
|
+
decode: (data: Dataset.Dataset, parseOptions) =>
|
|
1111
|
+
validate(data, shapesGraph, options).pipe(
|
|
1112
|
+
Effect.mapError(
|
|
1113
|
+
(e) => new SchemaIssue.InvalidValue({ message: e.message }, data, parseOptions),
|
|
1114
|
+
),
|
|
1115
|
+
Effect.flatMap((report) =>
|
|
1116
|
+
Arr.match(
|
|
1117
|
+
Arr.filter(report.results, (r) => severityRank(r.severity) >= threshold),
|
|
1118
|
+
{
|
|
1119
|
+
onEmpty: () => Effect.succeed(data),
|
|
1120
|
+
onNonEmpty: (failing) =>
|
|
1121
|
+
Effect.fail(
|
|
1122
|
+
new SchemaIssue.Composite(
|
|
1123
|
+
Dataset.DatasetSchema.ast,
|
|
1124
|
+
Arr.map(
|
|
1125
|
+
failing,
|
|
1126
|
+
(r) =>
|
|
1127
|
+
new SchemaIssue.InvalidValue(
|
|
1128
|
+
{ message: ValidationReport.formatResult(r), result: r },
|
|
1129
|
+
r,
|
|
1130
|
+
parseOptions,
|
|
1131
|
+
),
|
|
1132
|
+
),
|
|
1133
|
+
data,
|
|
1134
|
+
),
|
|
1135
|
+
),
|
|
1136
|
+
},
|
|
1137
|
+
),
|
|
1138
|
+
),
|
|
1139
|
+
),
|
|
1140
|
+
encode: (data: Dataset.Dataset) => Effect.succeed(data),
|
|
1141
|
+
}),
|
|
1142
|
+
),
|
|
1143
|
+
);
|
|
1144
|
+
};
|
|
1145
|
+
|
|
1146
|
+
/**
|
|
1147
|
+
* The SHACL `sh:Violation`, `sh:Warning` and `sh:Info` severities.
|
|
1148
|
+
*
|
|
1149
|
+
* @since 0.1.0
|
|
1150
|
+
* @category constants
|
|
1151
|
+
*/
|
|
1152
|
+
export const severities = {
|
|
1153
|
+
Violation: sh.Violation,
|
|
1154
|
+
Warning: sh.Warning,
|
|
1155
|
+
Info: sh.Info,
|
|
1156
|
+
} as const;
|