Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove metadata #645

Merged
merged 4 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v16.14.0
v18.19.0
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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%"
Expand Down
2 changes: 1 addition & 1 deletion src/fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
35 changes: 25 additions & 10 deletions src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down
Loading