@comunica/actor-rdf-update-hypermedia-put-ldp 2.4.0 → 2.5.1

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActorRdfUpdateHypermediaPutLdp.js","sourceRoot":"","sources":["ActorRdfUpdateHypermediaPutLdp.ts"],"names":[],"mappings":";;;AAIA,mFAA+E;AAE/E,mEAAgE;AAEhE;;GAEG;AACH,MAAa,8BAA+B,SAAQ,oDAAwB;IAK1E,YAAmB,IAA0C;QAC3D,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACxB,CAAC;IAEM,KAAK,CAAC,YAAY,CAAC,MAAkC;QAC1D,IAAI,CAAC,MAAM,CAAC,oBAAoB,EAAE;YAChC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;gBAC1F,MAAM,IAAI,KAAK,CAAC,SAAS,IAAI,CAAC,IAAI,2DAA2D,CAAC,CAAC;aAChG;YACD,IAAI,MAAM,CAAC,MAAM,EAAE;gBACjB,MAAM,IAAI,KAAK,CAAC,SAAS,IAAI,CAAC,IAAI,8DAA8D,CAAC,CAAC;aACnG;SACF;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,GAAG,CAAC,MAAkC;QACjD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,qCAAqC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;QAChF,OAAO;YACL,WAAW,EAAE,IAAI,6CAAqB,CACpC,MAAM,CAAC,GAAG,EACV,MAAM,CAAC,OAAO,EACd,MAAM,CAAC,QAAQ,CAAC,WAAW,IAAI,EAAE,EACjC,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,8BAA8B,EACnC,IAAI,CAAC,oBAAoB,CAC1B;SACF,CAAC;IACJ,CAAC;CACF;AAlCD,wEAkCC","sourcesContent":["import type { MediatorHttp } from '@comunica/bus-http';\nimport type { MediatorRdfSerializeHandle, MediatorRdfSerializeMediaTypes } from '@comunica/bus-rdf-serialize';\nimport type { IActionRdfUpdateHypermedia, IActorRdfUpdateHypermediaOutput,\n IActorRdfUpdateHypermediaArgs } from '@comunica/bus-rdf-update-hypermedia';\nimport { ActorRdfUpdateHypermedia } from '@comunica/bus-rdf-update-hypermedia';\nimport type { IActorTest } from '@comunica/core';\nimport { QuadDestinationPutLdp } from './QuadDestinationPutLdp';\n\n/**\n * A comunica Post LDP RDF Update Hypermedia Actor.\n */\nexport class ActorRdfUpdateHypermediaPutLdp extends ActorRdfUpdateHypermedia {\n public readonly mediatorHttp: MediatorHttp;\n public readonly mediatorRdfSerializeMediatypes: MediatorRdfSerializeMediaTypes;\n public readonly mediatorRdfSerialize: MediatorRdfSerializeHandle;\n\n public constructor(args: IActorRdfUpdateHypermediaPostLdpArgs) {\n super(args, 'putLdp');\n }\n\n public async testMetadata(action: IActionRdfUpdateHypermedia): Promise<IActorTest> {\n if (!action.forceDestinationType) {\n if (!action.metadata.allowHttpMethods || !action.metadata.allowHttpMethods.includes('PUT')) {\n throw new Error(`Actor ${this.name} could not detect a destination with 'Allow: PUT' header.`);\n }\n if (action.exists) {\n throw new Error(`Actor ${this.name} can only put on a destination that does not already exists.`);\n }\n }\n return true;\n }\n\n public async run(action: IActionRdfUpdateHypermedia): Promise<IActorRdfUpdateHypermediaOutput> {\n this.logInfo(action.context, `Identified as putLdp destination: ${action.url}`);\n return {\n destination: new QuadDestinationPutLdp(\n action.url,\n action.context,\n action.metadata.putAccepted || [],\n this.mediatorHttp,\n this.mediatorRdfSerializeMediatypes,\n this.mediatorRdfSerialize,\n ),\n };\n }\n}\n\nexport interface IActorRdfUpdateHypermediaPostLdpArgs extends IActorRdfUpdateHypermediaArgs {\n /**\n * The HTTP mediator\n */\n mediatorHttp: MediatorHttp;\n /**\n * The RDF Serialize mediator for collecting media types\n */\n mediatorRdfSerializeMediatypes: MediatorRdfSerializeMediaTypes;\n /**\n * The RDF Serialize mediator for handling serialization\n */\n mediatorRdfSerialize: MediatorRdfSerializeHandle;\n}\n"]}
@@ -0,0 +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,QAAQ,EAAE,KAAK,CAAC,CAAC;IACpD,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,KAA8B;QAChD,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;IACxE,CAAC;IAEM,KAAK,CAAC,oBAAoB,CAAC,IAAyB,EAAE,KAA8B;QACzF,yCAAyC;QACzC,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,IAAI,CAAC,8BAA8B,CAAC,OAAO,CACtE,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,CAC5C,CAAC;QACF,MAAM,mBAAmB,GAAG,IAAI,CAAC,UAAU;aACxC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,IAAI,UAAU,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C,MAAuB,EAAE,mBAA4B;QAC7E,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 graphs`);\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mEAAiD;AACjD,0DAAwC","sourcesContent":["export * from './ActorRdfUpdateHypermediaPutLdp';\nexport * from './QuadDestinationPutLdp';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@comunica/actor-rdf-update-hypermedia-put-ldp",
3
- "version": "2.4.0",
3
+ "version": "2.5.1",
4
4
  "description": "A put-ldp rdf-update-hypermedia actor",
5
5
  "lsd:module": true,
6
6
  "main": "lib/index.js",
@@ -28,23 +28,24 @@
28
28
  "files": [
29
29
  "components",
30
30
  "lib/**/*.d.ts",
31
- "lib/**/*.js"
31
+ "lib/**/*.js",
32
+ "lib/**/*.js.map"
32
33
  ],
33
34
  "dependencies": {
34
- "@comunica/bus-http": "^2.4.0",
35
- "@comunica/bus-rdf-serialize": "^2.4.0",
36
- "@comunica/bus-rdf-update-hypermedia": "^2.4.0",
37
- "@comunica/bus-rdf-update-quads": "^2.4.0",
38
- "@comunica/core": "^2.4.0",
39
- "@comunica/types": "^2.4.0",
35
+ "@comunica/bus-http": "^2.5.1",
36
+ "@comunica/bus-rdf-serialize": "^2.5.1",
37
+ "@comunica/bus-rdf-update-hypermedia": "^2.5.1",
38
+ "@comunica/bus-rdf-update-quads": "^2.5.1",
39
+ "@comunica/core": "^2.5.1",
40
+ "@comunica/types": "^2.5.1",
40
41
  "@rdfjs/types": "*",
41
- "asynciterator": "^3.7.0",
42
- "cross-fetch": "^3.0.5"
42
+ "asynciterator": "^3.8.0",
43
+ "cross-fetch": "^3.1.5"
43
44
  },
44
45
  "scripts": {
45
46
  "build": "npm run build:ts && npm run build:components",
46
47
  "build:ts": "node \"../../node_modules/typescript/bin/tsc\"",
47
48
  "build:components": "componentsjs-generator"
48
49
  },
49
- "gitHead": "cb5a1560c9ab9ebaf3335888a1411a7e1654de1e"
50
+ "gitHead": "d64e87fad4a616224c210c2d22b38f6f9b00e1ea"
50
51
  }