@comunica/actor-rdf-update-hypermedia-put-ldp 3.0.3 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.QuadDestinationPutLdp = void 0;
4
4
  const bus_http_1 = require("@comunica/bus-http");
5
- const bus_rdf_update_quads_1 = require("@comunica/bus-rdf-update-quads");
6
5
  const cross_fetch_1 = require("cross-fetch");
7
6
  /**
8
7
  * A quad destination that represents a resource that can be PUT.
@@ -48,7 +47,7 @@ class QuadDestinationPutLdp {
48
47
  },
49
48
  input: this.url,
50
49
  });
51
- await (0, bus_rdf_update_quads_1.validateHttpResponse)(this.url, httpResponse);
50
+ await (0, bus_http_1.validateAndCloseHttpResponse)(this.url, httpResponse);
52
51
  }
53
52
  async deleteGraphs(_graphs, _requireExistence, _dropGraphs) {
54
53
  throw new Error(`Put-based LDP destinations don't support named graphs`);
@@ -1 +1 @@
1
- {"version":3,"file":"QuadDestinationPutLdp.js","sourceRoot":"","sources":["QuadDestinationPutLdp.ts"],"names":[],"mappings":";;;AACA,iDAA+C;AAG/C,yEAAsE;AAItE,6CAAsC;AAEtC;;GAEG;AACH,MAAa,qBAAqB;IAWhC,YACE,GAAW,EACX,OAAuB,EACvB,UAAoB,EACpB,YAA0B,EAC1B,8BAA8D,EAC9D,oBAA0C;QAE1C,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,8BAA8B,GAAG,8BAA8B,CAAC;QACrE,IAAI,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;IACnD,CAAC;IAEM,MAAM,CAAC,KAA8B;QAC1C,OAAO,IAAI,CAAC,oBAAoB,CAAC,Q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CAAC,OAAO,CAAC;YACnD,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,IAAI,EAAE;gBACJ,OAAO;gBACP,MAAM,EAAE,KAAK;gBACb,IAAI,EAAE,oBAAS,CAAC,mBAAmB,CAAC,IAAI,CAAC;aAC1C;YACD,KAAK,EAAE,IAAI,CAAC,GAAG;SAChB,CAAC,CAAC;QAEH,MAAM,IAAA,2CAAoB,EAAC,IAAI,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;IACrD,CAAC;IAEM,KAAK,CAAC,YAAY,CACvB,OAA6D,EAC7D,iBAA0B,EAC1B,WAAoB;QAEpB,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;IAC3E,CAAC;IAEM,KAAK,CAAC,YAAY,CAAC,OAAwB,EAAE,oBAA6B;QAC/E,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;IAC3E,CAAC;CACF;AAhFD,sDAgFC","sourcesContent":["import type { MediatorHttp } from '@comunica/bus-http';\nimport { ActorHttp } from '@comunica/bus-http';\nimport type { MediatorRdfSerialize, MediatorRdfSerializeMediaTypes } from '@comunica/bus-rdf-serialize';\nimport type { IQuadDestination } from '@comunica/bus-rdf-update-quads';\nimport { validateHttpResponse } from '@comunica/bus-rdf-update-quads';\nimport type { IActionContext } from '@comunica/types';\nimport type * as RDF from '@rdfjs/types';\nimport type { AsyncIterator } from 'asynciterator';\nimport { Headers } from 'cross-fetch';\n\n/**\n * A quad destination that represents a resource that can be PUT.\n */\nexport class QuadDestinationPutLdp implements IQuadDestination {\n private readonly url: string;\n private readonly context: IActionContext;\n private readonly mediaTypes: string[];\n\n private readonly mediatorHttp: MediatorHttp;\n\n public readonly mediatorRdfSerializeMediatypes: MediatorRdfSerializeMediaTypes;\n\n private readonly mediatorRdfSerialize: MediatorRdfSerialize;\n\n public constructor(\n url: string,\n context: IActionContext,\n mediaTypes: string[],\n mediatorHttp: MediatorHttp,\n mediatorRdfSerializeMediatypes: MediatorRdfSerializeMediaTypes,\n mediatorRdfSerialize: MediatorRdfSerialize,\n ) {\n this.url = url;\n this.context = context;\n this.mediaTypes = mediaTypes;\n this.mediatorHttp = mediatorHttp;\n this.mediatorRdfSerializeMediatypes = mediatorRdfSerializeMediatypes;\n this.mediatorRdfSerialize = mediatorRdfSerialize;\n }\n\n public insert(quads: AsyncIterator<RDF.Quad>): Promise<void> {\n return this.wrapRdfUpdateRequest('INSERT', quads);\n }\n\n public async delete(_quads: AsyncIterator<RDF.Quad>): Promise<void> {\n throw new Error(`Put-based LDP destinations don't support deletions`);\n }\n\n public async wrapRdfUpdateRequest(type: 'INSERT' | 'DELETE', quads: AsyncIterator<RDF.Quad>): Promise<void> {\n // Determine media type for serialization\n const { mediaTypes } = await this.mediatorRdfSerializeMediatypes.mediate(\n { context: this.context, mediaTypes: true },\n );\n const availableMediaTypes = this.mediaTypes\n .filter(mediaType => mediaType in mediaTypes);\n // Fallback to our own preferred media type\n const mediaType = availableMediaTypes.length > 0 ?\n availableMediaTypes[0] :\n Object.keys(mediaTypes).sort((typeA, typeB) => mediaTypes[typeB] - mediaTypes[typeA])[0];\n\n // Serialize quads\n const { handle: { data }} = await this.mediatorRdfSerialize.mediate({\n context: this.context,\n handle: { quadStream: quads, context: this.context },\n handleMediaType: mediaType,\n });\n\n // Send data in (LDP) PUT request\n const headers: Headers = new Headers({ 'content-type': mediaType });\n const httpResponse = await this.mediatorHttp.mediate({\n context: this.context,\n init: {\n headers,\n method: 'PUT',\n body: ActorHttp.toWebReadableStream(data),\n },\n input: this.url,\n });\n\n await validateHttpResponse(this.url, httpResponse);\n }\n\n public async deleteGraphs(\n _graphs: RDF.DefaultGraph | 'NAMED' | 'ALL' | RDF.NamedNode[],\n _requireExistence: boolean,\n _dropGraphs: boolean,\n ): Promise<void> {\n throw new Error(`Put-based LDP destinations don't support named graphs`);\n }\n\n public async createGraphs(_graphs: RDF.NamedNode[], _requireNonExistence: boolean): Promise<void> {\n throw new Error(`Put-based LDP destinations don't support named graph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seHttpResponse, ActorHttp } from '@comunica/bus-http';\nimport type { MediatorRdfSerialize, MediatorRdfSerializeMediaTypes } from '@comunica/bus-rdf-serialize';\nimport type { IQuadDestination } from '@comunica/bus-rdf-update-quads';\nimport type { IActionContext } from '@comunica/types';\nimport type * as RDF from '@rdfjs/types';\nimport type { AsyncIterator } from 'asynciterator';\nimport { Headers } from 'cross-fetch';\n\n/**\n * A quad destination that represents a resource that can be PUT.\n */\nexport class QuadDestinationPutLdp implements IQuadDestination {\n private readonly url: string;\n private readonly context: IActionContext;\n private readonly mediaTypes: string[];\n\n private readonly mediatorHttp: MediatorHttp;\n\n public readonly mediatorRdfSerializeMediatypes: MediatorRdfSerializeMediaTypes;\n\n private readonly mediatorRdfSerialize: MediatorRdfSerialize;\n\n public constructor(\n url: string,\n context: IActionContext,\n mediaTypes: string[],\n mediatorHttp: MediatorHttp,\n mediatorRdfSerializeMediatypes: MediatorRdfSerializeMediaTypes,\n mediatorRdfSerialize: MediatorRdfSerialize,\n ) {\n this.url = url;\n this.context = context;\n this.mediaTypes = mediaTypes;\n this.mediatorHttp = mediatorHttp;\n this.mediatorRdfSerializeMediatypes = mediatorRdfSerializeMediatypes;\n this.mediatorRdfSerialize = mediatorRdfSerialize;\n }\n\n public insert(quads: AsyncIterator<RDF.Quad>): Promise<void> {\n return this.wrapRdfUpdateRequest('INSERT', quads);\n }\n\n public async delete(_quads: AsyncIterator<RDF.Quad>): Promise<void> {\n throw new Error(`Put-based LDP destinations don't support deletions`);\n }\n\n public async wrapRdfUpdateRequest(type: 'INSERT' | 'DELETE', quads: AsyncIterator<RDF.Quad>): Promise<void> {\n // Determine media type for serialization\n const { mediaTypes } = await this.mediatorRdfSerializeMediatypes.mediate(\n { context: this.context, mediaTypes: true },\n );\n const availableMediaTypes = this.mediaTypes\n .filter(mediaType => mediaType in mediaTypes);\n // Fallback to our own preferred media type\n const mediaType = availableMediaTypes.length > 0 ?\n availableMediaTypes[0] :\n Object.keys(mediaTypes).sort((typeA, typeB) => mediaTypes[typeB] - mediaTypes[typeA])[0];\n\n // Serialize quads\n const { handle: { data }} = await this.mediatorRdfSerialize.mediate({\n context: this.context,\n handle: { quadStream: quads, context: this.context },\n handleMediaType: mediaType,\n });\n\n // Send data in (LDP) PUT request\n const headers: Headers = new Headers({ 'content-type': mediaType });\n const httpResponse = await this.mediatorHttp.mediate({\n context: this.context,\n init: {\n headers,\n method: 'PUT',\n body: ActorHttp.toWebReadableStream(data),\n },\n input: this.url,\n });\n\n await validateAndCloseHttpResponse(this.url, httpResponse);\n }\n\n public async deleteGraphs(\n _graphs: RDF.DefaultGraph | 'NAMED' | 'ALL' | RDF.NamedNode[],\n _requireExistence: boolean,\n _dropGraphs: boolean,\n ): Promise<void> {\n throw new Error(`Put-based LDP destinations don't support named graphs`);\n }\n\n public async createGraphs(_graphs: RDF.NamedNode[], _requireNonExistence: boolean): Promise<void> {\n throw new Error(`Put-based LDP destinations don't support named graphs`);\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@comunica/actor-rdf-update-hypermedia-put-ldp",
3
- "version": "3.0.3",
3
+ "version": "3.1.0",
4
4
  "description": "A put-ldp rdf-update-hypermedia actor",
5
5
  "lsd:module": true,
6
6
  "license": "MIT",
@@ -32,20 +32,20 @@
32
32
  "lib/**/*.js.map"
33
33
  ],
34
34
  "scripts": {
35
- "build": "npm run build:ts && npm run build:components",
35
+ "build": "yarn run build:ts && yarn run build:components",
36
36
  "build:ts": "node \"../../node_modules/typescript/bin/tsc\"",
37
37
  "build:components": "componentsjs-generator"
38
38
  },
39
39
  "dependencies": {
40
- "@comunica/bus-http": "^3.0.3",
41
- "@comunica/bus-rdf-serialize": "^3.0.3",
42
- "@comunica/bus-rdf-update-hypermedia": "^3.0.3",
43
- "@comunica/bus-rdf-update-quads": "^3.0.3",
44
- "@comunica/core": "^3.0.3",
45
- "@comunica/types": "^3.0.3",
40
+ "@comunica/bus-http": "^3.1.0",
41
+ "@comunica/bus-rdf-serialize": "^3.1.0",
42
+ "@comunica/bus-rdf-update-hypermedia": "^3.1.0",
43
+ "@comunica/bus-rdf-update-quads": "^3.1.0",
44
+ "@comunica/core": "^3.1.0",
45
+ "@comunica/types": "^3.1.0",
46
46
  "@rdfjs/types": "*",
47
47
  "asynciterator": "^3.9.0",
48
48
  "cross-fetch": "^4.0.0"
49
49
  },
50
- "gitHead": "a1e050b7e921d6ea5532abc09391e49938c7e5f3"
50
+ "gitHead": "69d92988644c07b1b4831ba0a52073092d2f43af"
51
51
  }