From f8216239e818ae55a0579226f61f1363b429aeb4 Mon Sep 17 00:00:00 2001 From: bourgeoa Date: Tue, 26 Mar 2024 19:57:01 +0100 Subject: [PATCH 1/4] start remove status collection --- .nvmrc | 2 +- src/store.ts | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) 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/src/store.ts b/src/store.ts index c113f428b..2918c4a43 100644 --- a/src/store.ts +++ b/src/store.ts @@ -881,6 +881,7 @@ 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 } @@ -892,15 +893,14 @@ export default class IndexedFormula extends Formula { // IN future - allow pass for (var r = 0; r < requests.length; r++) { const request = requests[r] if (request != undefined) { + const status = this.any(request, this.sym(`${linkNamespaceURI}status`), null, meta) as Quad_Subject + if (status != undefined) { + this.removeMatches(status, this.sym(`${linkNamespaceURI}status`), null, meta) + } const response = this.any(request, this.sym(`${linkNamespaceURI}response`), null, meta) as Quad_Subject if (response != undefined) { // ts this.removeMatches(response, null, null, meta) } - // 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) - } this.removeMatches(request, null, null, meta) } } From bf0b7e16029af7d7a1c83fa98b5fb816e9d2bec7 Mon Sep 17 00:00:00 2001 From: bourgeoa Date: Thu, 28 Mar 2024 16:59:44 +0100 Subject: [PATCH 2/4] remove status first --- src/fetcher.ts | 2 +- src/store.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) 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 2918c4a43..a7f3a940b 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 { @@ -888,7 +888,7 @@ export default class IndexedFormula extends Formula { // IN future - allow pass 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 + // 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] From dad40526c3651415d9e1d38d8a05f2ddb6c2db63 Mon Sep 17 00:00:00 2001 From: bourgeoa Date: Thu, 28 Mar 2024 17:02:26 +0100 Subject: [PATCH 3/4] 2.2.34-beta3 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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%" From c45ae2555841646d6b214ee66f95813b8648f0b2 Mon Sep 17 00:00:00 2001 From: bourgeoa Date: Wed, 3 Apr 2024 13:03:47 +0200 Subject: [PATCH 4/4] replace removeMatches --- src/store.ts | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/store.ts b/src/store.ts index a7f3a940b..73ab407fe 100644 --- a/src/store.ts +++ b/src/store.ts @@ -887,21 +887,36 @@ export default class IndexedFormula extends Formula { // IN future - allow pass 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 + 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) { - this.removeMatches(status, this.sym(`${linkNamespaceURI}status`), null, meta) + 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]) + } } - this.removeMatches(request, 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(this.sym(doc.value), null, null, meta) // content-type