@comunica/actor-rdf-update-hypermedia-put-ldp 3.2.4-alpha.47.0 → 3.3.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.
@@ -59,10 +59,6 @@
59
59
  {
60
60
  "@type": "ParameterRangeGenericTypeReference",
61
61
  "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
62
- },
63
- {
64
- "@type": "ParameterRangeGenericTypeReference",
65
- "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_TS"
66
62
  }
67
63
  ]
68
64
  },
@@ -77,10 +73,6 @@
77
73
  {
78
74
  "@type": "ParameterRangeGenericTypeReference",
79
75
  "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
80
- },
81
- {
82
- "@type": "ParameterRangeGenericTypeReference",
83
- "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_TS"
84
76
  }
85
77
  ]
86
78
  },
@@ -90,20 +82,6 @@
90
82
  },
91
83
  "comment": "The bus this actor subscribes to."
92
84
  },
93
- {
94
- "@id": "caruhpl:components/ActorRdfUpdateHypermediaPutLdp.jsonld#ActorRdfUpdateHypermediaPutLdp_args_busFailMessage",
95
- "range": {
96
- "@type": "ParameterRangeUnion",
97
- "parameterRangeElements": [
98
- "xsd:string",
99
- {
100
- "@type": "ParameterRangeUndefined"
101
- }
102
- ]
103
- },
104
- "default": "RDF hypermedia updating failed: none of the configured actors were able to handle an update for ${action.url}",
105
- "comment": "The message that will be configured in the bus for reporting failures. This message may be a template string that contains references to the executed `action`. For example, the following templated string is allowed: \"RDF dereferencing failed: no actors could handle ${action.handle.mediaType}\""
106
- },
107
85
  {
108
86
  "@id": "caruhpl:components/ActorRdfUpdateHypermediaPutLdp.jsonld#ActorRdfUpdateHypermediaPutLdp_args_beforeActors",
109
87
  "range": {
@@ -126,10 +104,6 @@
126
104
  {
127
105
  "@type": "ParameterRangeGenericTypeReference",
128
106
  "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
129
- },
130
- {
131
- "@type": "ParameterRangeGenericTypeReference",
132
- "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_TS"
133
107
  }
134
108
  ]
135
109
  }
@@ -205,12 +179,6 @@
205
179
  "@id": "caruhpl:components/ActorRdfUpdateHypermediaPutLdp.jsonld#ActorRdfUpdateHypermediaPutLdp_args_bus"
206
180
  }
207
181
  },
208
- {
209
- "keyRaw": "busFailMessage",
210
- "value": {
211
- "@id": "caruhpl:components/ActorRdfUpdateHypermediaPutLdp.jsonld#ActorRdfUpdateHypermediaPutLdp_args_busFailMessage"
212
- }
213
- },
214
182
  {
215
183
  "keyRaw": "beforeActors",
216
184
  "value": {
@@ -75,8 +75,12 @@
75
75
  "memberFieldName": "constructor"
76
76
  },
77
77
  {
78
- "@id": "caruhpl:components/QuadDestinationPutLdp.jsonld#QuadDestinationPutLdp__member_update",
79
- "memberFieldName": "update"
78
+ "@id": "caruhpl:components/QuadDestinationPutLdp.jsonld#QuadDestinationPutLdp__member_insert",
79
+ "memberFieldName": "insert"
80
+ },
81
+ {
82
+ "@id": "caruhpl:components/QuadDestinationPutLdp.jsonld#QuadDestinationPutLdp__member_delete",
83
+ "memberFieldName": "delete"
80
84
  },
81
85
  {
82
86
  "@id": "caruhpl:components/QuadDestinationPutLdp.jsonld#QuadDestinationPutLdp__member_wrapRdfUpdateRequest",
@@ -23,9 +23,6 @@
23
23
  "args_bus": {
24
24
  "@id": "caruhpl:components/ActorRdfUpdateHypermediaPutLdp.jsonld#ActorRdfUpdateHypermediaPutLdp_args_bus"
25
25
  },
26
- "args_busFailMessage": {
27
- "@id": "caruhpl:components/ActorRdfUpdateHypermediaPutLdp.jsonld#ActorRdfUpdateHypermediaPutLdp_args_busFailMessage"
28
- },
29
26
  "args_beforeActors": {
30
27
  "@id": "caruhpl:components/ActorRdfUpdateHypermediaPutLdp.jsonld#ActorRdfUpdateHypermediaPutLdp_args_beforeActors",
31
28
  "@container": "@list"
@@ -45,9 +42,6 @@
45
42
  "bus": {
46
43
  "@id": "caruhpl:components/ActorRdfUpdateHypermediaPutLdp.jsonld#ActorRdfUpdateHypermediaPutLdp_args_bus"
47
44
  },
48
- "busFailMessage": {
49
- "@id": "caruhpl:components/ActorRdfUpdateHypermediaPutLdp.jsonld#ActorRdfUpdateHypermediaPutLdp_args_busFailMessage"
50
- },
51
45
  "beforeActors": {
52
46
  "@id": "caruhpl:components/ActorRdfUpdateHypermediaPutLdp.jsonld#ActorRdfUpdateHypermediaPutLdp_args_beforeActors",
53
47
  "@container": "@list"
@@ -2,7 +2,7 @@ import type { MediatorHttp } from '@comunica/bus-http';
2
2
  import type { MediatorRdfSerializeHandle, MediatorRdfSerializeMediaTypes } from '@comunica/bus-rdf-serialize';
3
3
  import type { IActionRdfUpdateHypermedia, IActorRdfUpdateHypermediaOutput, IActorRdfUpdateHypermediaArgs } from '@comunica/bus-rdf-update-hypermedia';
4
4
  import { ActorRdfUpdateHypermedia } from '@comunica/bus-rdf-update-hypermedia';
5
- import type { IActorTest, TestResult } from '@comunica/core';
5
+ import type { IActorTest } from '@comunica/core';
6
6
  /**
7
7
  * A comunica Post LDP RDF Update Hypermedia Actor.
8
8
  */
@@ -11,7 +11,7 @@ export declare class ActorRdfUpdateHypermediaPutLdp extends ActorRdfUpdateHyperm
11
11
  readonly mediatorRdfSerializeMediatypes: MediatorRdfSerializeMediaTypes;
12
12
  readonly mediatorRdfSerialize: MediatorRdfSerializeHandle;
13
13
  constructor(args: IActorRdfUpdateHypermediaPostLdpArgs);
14
- testMetadata(action: IActionRdfUpdateHypermedia): Promise<TestResult<IActorTest>>;
14
+ testMetadata(action: IActionRdfUpdateHypermedia): Promise<IActorTest>;
15
15
  run(action: IActionRdfUpdateHypermedia): Promise<IActorRdfUpdateHypermediaOutput>;
16
16
  }
17
17
  export interface IActorRdfUpdateHypermediaPostLdpArgs extends IActorRdfUpdateHypermediaArgs {
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ActorRdfUpdateHypermediaPutLdp = void 0;
4
4
  const bus_rdf_update_hypermedia_1 = require("@comunica/bus-rdf-update-hypermedia");
5
- const core_1 = require("@comunica/core");
6
5
  const QuadDestinationPutLdp_1 = require("./QuadDestinationPutLdp");
7
6
  /**
8
7
  * A comunica Post LDP RDF Update Hypermedia Actor.
@@ -14,13 +13,13 @@ class ActorRdfUpdateHypermediaPutLdp extends bus_rdf_update_hypermedia_1.ActorRd
14
13
  async testMetadata(action) {
15
14
  if (!action.forceDestinationType) {
16
15
  if (!action.metadata.allowHttpMethods || !action.metadata.allowHttpMethods.includes('PUT')) {
17
- return (0, core_1.failTest)(`Actor ${this.name} could not detect a destination with 'Allow: PUT' header.`);
16
+ throw new Error(`Actor ${this.name} could not detect a destination with 'Allow: PUT' header.`);
18
17
  }
19
18
  if (action.exists) {
20
- return (0, core_1.failTest)(`Actor ${this.name} can only put on a destination that does not already exists.`);
19
+ throw new Error(`Actor ${this.name} can only put on a destination that does not already exists.`);
21
20
  }
22
21
  }
23
- return (0, core_1.passTestVoid)();
22
+ return true;
24
23
  }
25
24
  async run(action) {
26
25
  this.logInfo(action.context, `Identified as putLdp destination: ${action.url}`);
@@ -1 +1 @@
1
- {"version":3,"file":"ActorRdfUpdateHypermediaPutLdp.js","sourceRoot":"","sources":["ActorRdfUpdateHypermediaPutLdp.ts"],"names":[],"mappings":";;;AAOA,mFAA+E;AAE/E,yCAAwD;AACxD,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,CAAC;YACjC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC3F,OAAO,IAAA,eAAQ,EAAC,SAAS,IAAI,CAAC,IAAI,2DAA2D,CAAC,CAAC;YACjG,CAAC;YACD,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;gBAClB,OAAO,IAAA,eAAQ,EAAC,SAAS,IAAI,CAAC,IAAI,8DAA8D,CAAC,CAAC;YACpG,CAAC;QACH,CAAC;QACD,OAAO,IAAA,mBAAY,GAAE,CAAC;IACxB,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 {\n IActionRdfUpdateHypermedia,\n IActorRdfUpdateHypermediaOutput,\n IActorRdfUpdateHypermediaArgs,\n} from '@comunica/bus-rdf-update-hypermedia';\nimport { ActorRdfUpdateHypermedia } from '@comunica/bus-rdf-update-hypermedia';\nimport type { IActorTest, TestResult } from '@comunica/core';\nimport { failTest, passTestVoid } 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<TestResult<IActorTest>> {\n if (!action.forceDestinationType) {\n if (!action.metadata.allowHttpMethods || !action.metadata.allowHttpMethods.includes('PUT')) {\n return failTest(`Actor ${this.name} could not detect a destination with 'Allow: PUT' header.`);\n }\n if (action.exists) {\n return failTest(`Actor ${this.name} can only put on a destination that does not already exists.`);\n }\n }\n return passTestVoid();\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"]}
1
+ {"version":3,"file":"ActorRdfUpdateHypermediaPutLdp.js","sourceRoot":"","sources":["ActorRdfUpdateHypermediaPutLdp.ts"],"names":[],"mappings":";;;AAOA,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,CAAC;YACjC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC3F,MAAM,IAAI,KAAK,CAAC,SAAS,IAAI,CAAC,IAAI,2DAA2D,CAAC,CAAC;YACjG,CAAC;YACD,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;gBAClB,MAAM,IAAI,KAAK,CAAC,SAAS,IAAI,CAAC,IAAI,8DAA8D,CAAC,CAAC;YACpG,CAAC;QACH,CAAC;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 {\n IActionRdfUpdateHypermedia,\n IActorRdfUpdateHypermediaOutput,\n IActorRdfUpdateHypermediaArgs,\n} 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"]}
@@ -15,10 +15,8 @@ export declare class QuadDestinationPutLdp implements IQuadDestination {
15
15
  readonly mediatorRdfSerializeMediatypes: MediatorRdfSerializeMediaTypes;
16
16
  private readonly mediatorRdfSerialize;
17
17
  constructor(url: string, context: IActionContext, mediaTypes: string[], mediatorHttp: MediatorHttp, mediatorRdfSerializeMediatypes: MediatorRdfSerializeMediaTypes, mediatorRdfSerialize: MediatorRdfSerialize);
18
- update(quadStreams: {
19
- insert?: AsyncIterator<RDF.Quad>;
20
- delete?: AsyncIterator<RDF.Quad>;
21
- }): Promise<void>;
18
+ insert(quads: AsyncIterator<RDF.Quad>): Promise<void>;
19
+ delete(_quads: AsyncIterator<RDF.Quad>): Promise<void>;
22
20
  wrapRdfUpdateRequest(type: 'INSERT' | 'DELETE', quads: AsyncIterator<RDF.Quad>): Promise<void>;
23
21
  deleteGraphs(_graphs: RDF.DefaultGraph | 'NAMED' | 'ALL' | RDF.NamedNode[], _requireExistence: boolean, _dropGraphs: boolean): Promise<void>;
24
22
  createGraphs(_graphs: RDF.NamedNode[], _requireNonExistence: boolean): Promise<void>;
@@ -2,6 +2,7 @@
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 cross_fetch_1 = require("cross-fetch");
5
6
  /**
6
7
  * A quad destination that represents a resource that can be PUT.
7
8
  */
@@ -14,13 +15,11 @@ class QuadDestinationPutLdp {
14
15
  this.mediatorRdfSerializeMediatypes = mediatorRdfSerializeMediatypes;
15
16
  this.mediatorRdfSerialize = mediatorRdfSerialize;
16
17
  }
17
- async update(quadStreams) {
18
- if (quadStreams.delete) {
19
- throw new Error(`Put-based LDP destinations don't support deletions`);
20
- }
21
- if (quadStreams.insert) {
22
- await this.wrapRdfUpdateRequest('INSERT', quadStreams.insert);
23
- }
18
+ insert(quads) {
19
+ return this.wrapRdfUpdateRequest('INSERT', quads);
20
+ }
21
+ async delete(_quads) {
22
+ throw new Error(`Put-based LDP destinations don't support deletions`);
24
23
  }
25
24
  async wrapRdfUpdateRequest(type, quads) {
26
25
  // Determine media type for serialization
@@ -38,7 +37,7 @@ class QuadDestinationPutLdp {
38
37
  handleMediaType: mediaType,
39
38
  });
40
39
  // Send data in (LDP) PUT request
41
- const headers = new Headers({ 'content-type': mediaType });
40
+ const headers = new cross_fetch_1.Headers({ 'content-type': mediaType });
42
41
  const httpResponse = await this.mediatorHttp.mediate({
43
42
  context: this.context,
44
43
  init: {
@@ -1 +1 @@
1
- {"version":3,"file":"QuadDestinationPutLdp.js","sourceRoot":"","sources":["QuadDestinationPutLdp.ts"],"names":[],"mappings":";;;AACA,iDAA6E;AAO7E;;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,KAAK,CAAC,MAAM,CACjB,WAAmF;QAEnF,IAAI,WAAW,CAAC,MAAM,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;QACxE,CAAC;QACD,IAAI,WAAW,CAAC,MAAM,EAAE,CAAC;YACvB,MAAM,IAAI,CAAC,oBAAoB,CAAC,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;QAChE,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,oBAAoB,CAAC,IAAyB,EAAE,KAA8B;QACzF,yCAAyC;QACzC,M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AC,CAAC;QAEH,MAAM,IAAA,uCAA4B,EAAC,IAAI,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;IAC7D,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;AAnFD,sDAmFC","sourcesContent":["import type { MediatorHttp } from '@comunica/bus-http';\nimport { validateAndCloseHttpResponse, 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';\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 async update(\n quadStreams: { insert?: AsyncIterator<RDF.Quad>; delete?: AsyncIterator<RDF.Quad> },\n ): Promise<void> {\n if (quadStreams.delete) {\n throw new Error(`Put-based LDP destinations don't support deletions`);\n }\n if (quadStreams.insert) {\n await this.wrapRdfUpdateRequest('INSERT', quadStreams.insert);\n }\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"]}
1
+ {"version":3,"file":"QuadDestinationPutLdp.js","sourceRoot":"","sources":["QuadDestinationPutLdp.ts"],"names":[],"mappings":";;;AACA,iDAA6E;AAM7E,6CAAsC;AAEtC;;GAEG;AACH,MAAa,qBAAqB;IAWhC,YACE,GAAW,EACX,OAAuB,EACvB,UAAoB,EACp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E,IAAI,EAAE,EAAC,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC;YAClE,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,MAAM,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE;YACpD,eAAe,EAAE,SAAS;SAC3B,CAAC,CAAC;QAEH,iCAAiC;QACjC,MAAM,OAAO,GAAY,IAAI,qBAAO,CAAC,EAAE,cAAc,EAAE,SAAS,EAAE,CAAC,CAAC;QACpE,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,YAAY,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,uCAA4B,EAAC,IAAI,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;IAC7D,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 { validateAndCloseHttpResponse, 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,13 +1,9 @@
1
1
  {
2
2
  "name": "@comunica/actor-rdf-update-hypermedia-put-ldp",
3
- "version": "3.2.4-alpha.47.0",
3
+ "version": "3.3.0",
4
4
  "description": "A put-ldp rdf-update-hypermedia actor",
5
5
  "lsd:module": true,
6
6
  "license": "MIT",
7
- "funding": {
8
- "type": "opencollective",
9
- "url": "https://opencollective.com/comunica-association"
10
- },
11
7
  "homepage": "https://comunica.dev/",
12
8
  "repository": {
13
9
  "type": "git",
@@ -41,14 +37,15 @@
41
37
  "build:components": "componentsjs-generator"
42
38
  },
43
39
  "dependencies": {
44
- "@comunica/bus-http": "3.2.4-alpha.47.0",
45
- "@comunica/bus-rdf-serialize": "3.2.4-alpha.47.0",
46
- "@comunica/bus-rdf-update-hypermedia": "3.2.4-alpha.47.0",
47
- "@comunica/bus-rdf-update-quads": "3.2.4-alpha.47.0",
48
- "@comunica/core": "3.2.4-alpha.47.0",
49
- "@comunica/types": "3.2.4-alpha.47.0",
40
+ "@comunica/bus-http": "^3.3.0",
41
+ "@comunica/bus-rdf-serialize": "^3.3.0",
42
+ "@comunica/bus-rdf-update-hypermedia": "^3.3.0",
43
+ "@comunica/bus-rdf-update-quads": "^3.3.0",
44
+ "@comunica/core": "^3.3.0",
45
+ "@comunica/types": "^3.3.0",
50
46
  "@rdfjs/types": "*",
51
- "asynciterator": "^3.9.0"
47
+ "asynciterator": "^3.9.0",
48
+ "cross-fetch": "^4.0.0"
52
49
  },
53
- "gitHead": "85bd4c5cf07dfc293ebbc3a1416b70e2db8bfc48"
50
+ "gitHead": "02bde397d206f1f5a523643a6a604c89e792e2f9"
54
51
  }