@comunica/actor-rdf-parse-jsonld
Advanced tools
Comparing version 1.11.0 to 1.12.0
@@ -12,2 +12,3 @@ import { IActionHttp, IActorHttpOutput } from "@comunica/bus-http"; | ||
constructor(args: IActorRdfParseJsonLdArgs); | ||
testHandle(action: IActionRdfParse, mediaType: string, context: ActionContext): Promise<IActorTest>; | ||
runHandle(action: IActionRdfParse, mediaType: string, actionContext: ActionContext): Promise<IActorRdfParseOutput>; | ||
@@ -14,0 +15,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const bus_rdf_parse_1 = require("@comunica/bus-rdf-parse"); | ||
const http_link_header_1 = require("http-link-header"); | ||
const jsonld_streaming_parser_1 = require("jsonld-streaming-parser"); | ||
@@ -16,23 +15,13 @@ const DocumentLoaderMediated_1 = require("./DocumentLoaderMediated"); | ||
} | ||
async testHandle(action, mediaType, context) { | ||
if (!(mediaType in this.mediaTypes) && !mediaType.endsWith('+json')) { | ||
throw new Error('Unrecognized media type: ' + mediaType); | ||
} | ||
return await this.testHandleChecked(action); | ||
} | ||
async runHandle(action, mediaType, actionContext) { | ||
// Try to extract a JSON-LD context link header (https://w3c.github.io/json-ld-syntax/#interpreting-json-as-json-ld) | ||
let context; | ||
if (mediaType !== 'application/ld+json' && action.headers && action.headers.has('Link')) { | ||
const linkHeader = http_link_header_1.parse(action.headers.get('Link')); | ||
for (const link of linkHeader.get('rel', 'http://www.w3.org/ns/json-ld#context')) { | ||
if (link.type === 'application/ld+json') { | ||
if (context) { | ||
throw new Error('Multiple JSON-LD context link headers were found on ' + action.baseIRI); | ||
} | ||
context = link.uri; | ||
} | ||
} | ||
} | ||
// Parse the JSON-LD | ||
const quads = new jsonld_streaming_parser_1.JsonLdParser({ | ||
allowOutOfOrderContext: true, | ||
baseIRI: action.baseIRI, | ||
context, | ||
const parser = jsonld_streaming_parser_1.JsonLdParser.fromHttpResponse(action.baseIRI, mediaType, action.headers, { | ||
documentLoader: new DocumentLoaderMediated_1.DocumentLoaderMediated(this.mediatorHttp, actionContext), | ||
}).import(action.input); | ||
}); | ||
const quads = parser.import(action.input); | ||
return { quads }; | ||
@@ -39,0 +28,0 @@ } |
import { IActionHttp, IActorHttpOutput } from "@comunica/bus-http"; | ||
import { ActionContext, Actor, IActorTest, Mediator } from "@comunica/core"; | ||
import { IDocumentLoader, IJsonLdContextNormalized } from "jsonld-context-parser"; | ||
import { IDocumentLoader, IJsonLdContext } from "jsonld-context-parser"; | ||
/** | ||
@@ -11,3 +11,3 @@ * A JSON-LD document loader that fetches over an HTTP bus using a given mediator. | ||
constructor(mediatorHttp: Mediator<Actor<IActionHttp, IActorTest, IActorHttpOutput>, IActionHttp, IActorTest, IActorHttpOutput>, context: ActionContext); | ||
load(url: string): Promise<IJsonLdContextNormalized>; | ||
load(url: string): Promise<IJsonLdContext>; | ||
} |
{ | ||
"name": "@comunica/actor-rdf-parse-jsonld", | ||
"version": "1.11.0", | ||
"version": "1.12.0", | ||
"description": "A JSON-LD RDF Parse actor", | ||
@@ -46,5 +46,3 @@ "lsd:module": "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-parse-jsonld", | ||
"dependencies": { | ||
"@types/http-link-header": "^1.0.1", | ||
"http-link-header": "^1.0.2", | ||
"jsonld-streaming-parser": "^1.1.0", | ||
"jsonld-streaming-parser": "^2.0.0", | ||
"stream-to-string": "^1.2.0" | ||
@@ -75,3 +73,3 @@ }, | ||
}, | ||
"gitHead": "876795ce37704da9dcd8efd57c5da54f1cb11b5a" | ||
"gitHead": "d761a5f3c3cbac40d50445ce9e708285ce9de61a" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
5
0
10888
88
+ Added@types/node@18.19.6622.10.0(transitive)
+ Addedcanonicalize@1.0.8(transitive)
+ Addedcross-fetch@3.1.8(transitive)
+ Addedjsonld-context-parser@2.4.0(transitive)
+ Addedjsonld-streaming-parser@2.4.3(transitive)
+ Addednode-fetch@2.7.0(transitive)
+ Addedtr46@0.0.3(transitive)
+ Addedundici-types@5.26.56.20.0(transitive)
+ Addedwebidl-conversions@3.0.1(transitive)
+ Addedwhatwg-url@5.0.0(transitive)
- Removed@types/http-link-header@^1.0.1
- Removedhttp-link-header@^1.0.2
- Removed@rdfjs/data-model@1.3.4(transitive)
- Removed@types/node@22.9.3(transitive)
- Removed@types/rdf-js@2.0.12(transitive)
- Removedencoding@0.1.13(transitive)
- Removediconv-lite@0.6.3(transitive)
- Removedisomorphic-fetch@2.2.1(transitive)
- Removedjsonld-context-parser@1.3.4(transitive)
- Removedjsonld-streaming-parser@1.1.2(transitive)
- Removednode-fetch@1.7.3(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedundici-types@6.19.8(transitive)
- Removedwhatwg-fetch@3.6.20(transitive)