MCPcopy Index your code
hub / github.com/nodeSolidServer/node-solid-server / applyPatch

Method applyPatch

lib/ldp.mjs:720–744  ·  view source on GitHub ↗
(data, patchObject, contentType, uri)

Source from the content-addressed store, hash-verified

718 }
719
720 async applyPatch (data, patchObject, contentType, uri) {
721 const baseGraph = $rdf.graph()
722 let patchedGraph
723
724 try {
725 $rdf.parse(data, baseGraph, uri, contentType)
726 } catch (err) {
727 throw error(500, 'Cannot parse file for patching: ' + uri)
728 }
729
730 // Apply patches
731 if (patchObject.updates) {
732 patchedGraph = await this.applyPatchUpdate(baseGraph, patchObject.updates, uri, contentType)
733 } else if (patchObject.deletes || patchObject.inserts) {
734 patchedGraph = await this.applyPatchInsertDelete(baseGraph, patchObject, uri, contentType)
735 } else {
736 throw error(422, 'Invalid patch object')
737 }
738
739 try {
740 return await serialize(patchedGraph, uri, contentType)
741 } catch (err) {
742 throw error(500, 'Cannot serialize patched file: ' + uri)
743 }
744 }
745
746 async applyPatchUpdate (baseGraph, updates, uri, contentType) {
747 const patchedGraph = baseGraph

Callers 2

patchMethod · 0.95
applyPatchFunction · 0.80

Calls 4

applyPatchUpdateMethod · 0.95
serializeFunction · 0.90
graphMethod · 0.80

Tested by

no test coverage detected