@comunica/actor-rdf-parse-jsonld
Advanced tools
Comparing version 1.9.0 to 1.9.2
@@ -0,3 +1,4 @@ | ||
import { IActionHttp, IActorHttpOutput } from "@comunica/bus-http"; | ||
import { ActorRdfParseFixedMediaTypes, IActionRdfParse, IActorRdfParseFixedMediaTypesArgs, IActorRdfParseOutput } from "@comunica/bus-rdf-parse"; | ||
import { ActionContext } from "@comunica/core"; | ||
import { ActionContext, Actor, IActorTest, Mediator } from "@comunica/core"; | ||
/** | ||
@@ -9,4 +10,8 @@ * A JSON-LD RDF Parse actor that listens on the 'rdf-parse' bus. | ||
export declare class ActorRdfParseJsonLd extends ActorRdfParseFixedMediaTypes { | ||
constructor(args: IActorRdfParseFixedMediaTypesArgs); | ||
runHandle(action: IActionRdfParse, mediaType: string, context: ActionContext): Promise<IActorRdfParseOutput>; | ||
readonly mediatorHttp: Mediator<Actor<IActionHttp, IActorTest, IActorHttpOutput>, IActionHttp, IActorTest, IActorHttpOutput>; | ||
constructor(args: IActorRdfParseJsonLdArgs); | ||
runHandle(action: IActionRdfParse, mediaType: string, actionContext: ActionContext): Promise<IActorRdfParseOutput>; | ||
} | ||
export interface IActorRdfParseJsonLdArgs extends IActorRdfParseFixedMediaTypesArgs { | ||
mediatorHttp: Mediator<Actor<IActionHttp, IActorTest, IActorHttpOutput>, IActionHttp, IActorTest, IActorHttpOutput>; | ||
} |
"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"); | ||
const DocumentLoaderMediated_1 = require("./DocumentLoaderMediated"); | ||
/** | ||
@@ -14,5 +16,23 @@ * A JSON-LD RDF Parse actor that listens on the 'rdf-parse' bus. | ||
} | ||
async runHandle(action, mediaType, context) { | ||
const quads = new jsonld_streaming_parser_1.JsonLdParser({ baseIRI: action.baseIRI, allowOutOfOrderContext: true }) | ||
.import(action.input); | ||
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, | ||
documentLoader: new DocumentLoaderMediated_1.DocumentLoaderMediated(this.mediatorHttp, actionContext), | ||
}).import(action.input); | ||
return { quads }; | ||
@@ -19,0 +39,0 @@ } |
{ | ||
"name": "@comunica/actor-rdf-parse-jsonld", | ||
"version": "1.9.0", | ||
"version": "1.9.2", | ||
"description": "A JSON-LD RDF Parse actor", | ||
@@ -36,2 +36,3 @@ "lsd:module": "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-parse-jsonld", | ||
"peerDependencies": { | ||
"@comunica/bus-http": "^1.0.0", | ||
"@comunica/bus-rdf-parse": "^1.0.0", | ||
@@ -41,6 +42,9 @@ "@comunica/core": "^1.0.0" | ||
"devDependencies": { | ||
"@comunica/bus-rdf-parse": "^1.9.0", | ||
"@comunica/core": "^1.9.0" | ||
"@comunica/bus-http": "^1.9.2", | ||
"@comunica/bus-rdf-parse": "^1.9.2", | ||
"@comunica/core": "^1.9.2" | ||
}, | ||
"dependencies": { | ||
"@types/http-link-header": "^1.0.1", | ||
"http-link-header": "^1.0.2", | ||
"jsonld-streaming-parser": "^1.1.0" | ||
@@ -71,3 +75,3 @@ }, | ||
}, | ||
"gitHead": "2e0cba815fd65d5660f15c96ffc734f9099d8b6a" | ||
"gitHead": "bb6eef43498d23416b4e063d93e73c49f5575ff4" | ||
} |
Sorry, the diff of this file is not supported yet
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
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
11290
12
98
6
3
1
+ Addedhttp-link-header@^1.0.2
+ Added@comunica/bus-http@1.22.1(transitive)
+ Added@types/http-link-header@1.0.7(transitive)
+ Added@types/readable-stream@2.3.15(transitive)
+ Addedhttp-link-header@1.1.3(transitive)
+ Addedis-stream@2.0.1(transitive)
+ Addedreadable-stream@3.6.2(transitive)
+ Addedreadable-stream-node-to-web@1.0.1(transitive)
+ Addedreadable-web-to-node-stream@3.0.2(transitive)
+ Addedsafe-buffer@5.1.25.2.1(transitive)
+ Addedstring_decoder@1.3.0(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addedweb-streams-node@0.4.0(transitive)
+ Addedweb-streams-ponyfill@1.4.2(transitive)