diff --git a/.nvmrc b/.nvmrc index bf79505bb..eb800ed45 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -v16.14.0 +v18.19.0 diff --git a/package-lock.json b/package-lock.json index 0791d39c7..e035ca294 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rdflib", - "version": "2.2.34-beta", + "version": "2.2.34-beta3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "rdflib", - "version": "2.2.34-beta", + "version": "2.2.34-beta3", "license": "MIT", "dependencies": { "@babel/runtime": "^7.21.0", diff --git a/package.json b/package.json index e7d0e741b..1dcb46e8a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "rdflib", "description": "an RDF library for node.js. Suitable for client and server side.", - "version": "2.2.34-beta", + "version": "2.2.34-beta3", "private": false, "browserslist": [ "> 0.5%" diff --git a/src/fetcher.ts b/src/fetcher.ts index 55d145145..0e9f84bef 100644 --- a/src/fetcher.ts +++ b/src/fetcher.ts @@ -980,7 +980,7 @@ export default class Fetcher implements CallbackifyInterface { const requests = kb.statementsMatching(undefined, this.ns.link('requestedURI'), kb.sym(docuri), meta).map(st => st.subject) for (const request of requests) { const response = kb.any(request, this.ns.link('response'), null, meta) as Quad_Subject - if (response !== undefined) { // ts + if (response != undefined) { // ts const quad = kb.statementsMatching(response, this.ns.link('outOfDate'), true as any, meta) kb.remove(quad) options.force = true diff --git a/src/store.ts b/src/store.ts index c113f428b..73ab407fe 100644 --- a/src/store.ts +++ b/src/store.ts @@ -871,7 +871,7 @@ export default class IndexedFormula extends Formula { // IN future - allow pass } /** - * Removes all statements in a doc, along with the related metadata including request/response + * Removes all statements in a doc, along with the related metadata including request/response/status * @param doc - The document / graph */ removeDocument(doc: Quad_Graph): IndexedFormula { @@ -881,27 +881,42 @@ export default class IndexedFormula extends Formula { // IN future - allow pass for (var i = 0; i < sts.length; i++) { this.removeStatement(sts[i]) } + this.removeMatches(doc as Quad_Subject, null, null) return this } removeMetadata(doc: Quad_Graph): IndexedFormula { const meta = this.sym('chrome://TheCurrentSession') // or this.rdfFactory.namedNode('chrome://TheCurrentSession') - const linkNamespaceURI = 'http://www.w3.org/2007/ont/link#' // alain - // remove request/response and metadata + const linkNamespaceURI = 'http://www.w3.org/2007/ont/link#' + // remove status/response/request metadata const requests = this.statementsMatching(undefined, this.sym(`${linkNamespaceURI}requestedURI`), this.rdfFactory.literal(doc.value), meta).map(st => st.subject) for (var r = 0; r < requests.length; r++) { const request = requests[r] if (request != undefined) { + // removeMatches unresolved issue with collection https://github.com/linkeddata/rdflib.js/issues/631 + let sts: Quad[] + // status collection + const status = this.any(request, this.sym(`${linkNamespaceURI}status`), null, meta) as Quad_Subject + if (status != undefined) { + sts = this.statementsMatching(status, this.sym(`${linkNamespaceURI}status`), null, meta).slice() + for (var i = 0; i < sts.length; i++) { + this.removeStatement(sts[i]) + } + } + // response items list const response = this.any(request, this.sym(`${linkNamespaceURI}response`), null, meta) as Quad_Subject - if (response != undefined) { // ts - this.removeMatches(response, null, null, meta) + if (response != undefined) { + sts = this.statementsMatching(response, null, null, meta).slice() + for (var i = 0; i < sts.length; i++) { + this.removeStatement(sts[i]) + } } - // may be not needed - const status = this.any(request, this.sym(`${linkNamespaceURI}status`), null, meta) as Quad_Subject - if (status != undefined) { // ts - this.removeMatches(status, null, null, meta) + // request triples + sts = this.statementsMatching(request, null, null, meta).slice() + for (var i = 0; i < sts.length; i++) { + this.removeStatement(sts[i]) } - this.removeMatches(request, null, null, meta) + } } this.removeMatches(this.sym(doc.value), null, null, meta) // content-type