@comunica/actor-query-result-serialize-sparql-csv 2.3.1-alpha.31.0 → 2.5.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.
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ActorQueryResultSerializeSparqlCsv = void 0;
4
- const stream_1 = require("stream");
5
4
  const bus_query_result_serialize_1 = require("@comunica/bus-query-result-serialize");
5
+ const readable_stream_1 = require("readable-stream");
6
6
  /**
7
7
  * A comunica SPARQL CSV Query Result Serialize Actor.
8
8
  */
@@ -54,7 +54,7 @@ class ActorQueryResultSerializeSparqlCsv extends bus_query_result_serialize_1.Ac
54
54
  }
55
55
  async runHandle(action, mediaType, context) {
56
56
  const bindingsAction = action;
57
- const data = new stream_1.Readable();
57
+ const data = new readable_stream_1.Readable();
58
58
  data._read = () => {
59
59
  // Do nothing
60
60
  };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActorQueryResultSerializeSparqlCsv.js","sourceRoot":"","sources":["ActorQueryResultSerializeSparqlCsv.ts"],"names":[],"mappings":";;;AAEA,qFAE8C;AAG9C,qDAA2C;AAE3C;;GAEG;AACH,MAAa,kCAAmC,SAAQ,qEAAwC;IAC9F;;;;;;;;OAQG;IACH,YAAmB,IAAmD;QACpE,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,oBAAoB,CAAC,KAAgB;QACjD,IAAI,CAAC,KAAK,EAAE;YACV,OAAO,EAAE,CAAC;SACX;QAED,IAAI,WAAW,GAAG,KAAK,CAAC,KAAK,CAAC;QAE9B,IAAI,KAAK,CAAC,QAAQ,KAAK,SAAS,EAAE;YAChC,uFAAuF;YACvF,WAAW,GAAG,GAAG,WAAW,EAAE,CAAC;SAChC;aAAM,IAAI,KAAK,CAAC,QAAQ,KAAK,WAAW,EAAE;YACzC,WAAW,GAAG,KAAK,WA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C,GAAG,QAAQ,CAAC,SAAS;iBAC5B,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,kCAAkC,CAAC,oBAAoB,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;iBACtF,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACtB,CAAC,CAAC,CAAC;QACH,cAAc,CAAC,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;YAC3C,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;QAEH,OAAO,EAAE,IAAI,EAAE,CAAC;IAClB,CAAC;CACF;AA/ED,gFA+EC","sourcesContent":["import type { IActionSparqlSerialize, IActorQueryResultSerializeFixedMediaTypesArgs,\n IActorQueryResultSerializeOutput } from '@comunica/bus-query-result-serialize';\nimport {\n ActorQueryResultSerializeFixedMediaTypes,\n} from '@comunica/bus-query-result-serialize';\nimport type { Bindings, IActionContext, IQueryOperationResultBindings } from '@comunica/types';\nimport type * as RDF from '@rdfjs/types';\nimport { Readable } from 'readable-stream';\n\n/**\n * A comunica SPARQL CSV Query Result Serialize Actor.\n */\nexport class ActorQueryResultSerializeSparqlCsv extends ActorQueryResultSerializeFixedMediaTypes {\n /**\n * @param args -\n * \\ @defaultNested {{\n * \"text/csv\": 0.75\n * }} mediaTypePriorities\n * \\ @defaultNested {{\n * \"text/csv\": \"http://www.w3.org/ns/formats/SPARQL_Results_CSV\"\n * }} mediaTypeFormats\n */\n public constructor(args: IActorQueryResultSerializeFixedMediaTypesArgs) {\n super(args);\n }\n\n /**\n * Converts an RDF term to its CSV representation.\n * @param {RDF.Term} value An RDF term.\n * @return {string} A string representation of the given value.\n */\n public static bindingToCsvBindings(value?: RDF.Term): string {\n if (!value) {\n return '';\n }\n\n let stringValue = value.value;\n\n if (value.termType === 'Literal') {\n // This is a lossy representation, since language and datatype are not encoded in here.\n stringValue = `${stringValue}`;\n } else if (value.termType === 'BlankNode') {\n stringValue = `_:${stringValue}`;\n } else {\n stringValue = `<${stringValue}>`;\n }\n\n // If a value contains certain characters, put it between double quotes\n if (/[\",\\n\\r]/u.test(stringValue)) {\n // Within quote strings, \" is written using a pair of quotation marks \"\".\n stringValue = `\"${stringValue.replace(/\"/ug, '\"\"')}\"`;\n }\n\n return stringValue;\n }\n\n public async testHandleChecked(action: IActionSparqlSerialize, context: IActionContext): Promise<boolean> {\n if (action.type !== 'bindings') {\n throw new Error('This actor can only handle bindings streams.');\n }\n return true;\n }\n\n public async runHandle(action: IActionSparqlSerialize, mediaType: string | undefined, context: IActionContext):\n Promise<IActorQueryResultSerializeOutput> {\n const bindingsAction = <IQueryOperationResultBindings> action;\n\n const data = new Readable();\n data._read = () => {\n // Do nothing\n };\n\n // Write head\n const metadata = await bindingsAction.metadata();\n data.push(`${metadata.variables.map(variable => variable.value).join(',')}\\r\\n`);\n\n // Write bindings\n bindingsAction.bindingsStream.on('error', (error: Error) => {\n data.emit('error', error);\n });\n bindingsAction.bindingsStream.on('data', (bindings: Bindings) => {\n data.push(`${metadata.variables\n .map(key => ActorQueryResultSerializeSparqlCsv.bindingToCsvBindings(bindings.get(key)))\n .join(',')}\\r\\n`);\n });\n bindingsAction.bindingsStream.on('end', () => {\n data.push(null);\n });\n\n return { data };\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uEAAqD","sourcesContent":["export * from './ActorQueryResultSerializeSparqlCsv';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@comunica/actor-query-result-serialize-sparql-csv",
3
- "version": "2.3.1-alpha.31.0",
3
+ "version": "2.5.0",
4
4
  "description": "A sparql-csv query-result-serialize actor",
5
5
  "lsd:module": true,
6
6
  "main": "lib/index.js",
@@ -28,17 +28,19 @@
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-query-result-serialize": "2.3.1-alpha.31.0",
35
- "@comunica/types": "2.3.1-alpha.31.0",
36
- "@rdfjs/types": "*"
35
+ "@comunica/bus-query-result-serialize": "^2.5.0",
36
+ "@comunica/types": "^2.5.0",
37
+ "@rdfjs/types": "*",
38
+ "readable-stream": "^4.0.0"
37
39
  },
38
40
  "scripts": {
39
41
  "build": "npm run build:ts && npm run build:components",
40
42
  "build:ts": "node \"../../node_modules/typescript/bin/tsc\"",
41
43
  "build:components": "componentsjs-generator"
42
44
  },
43
- "gitHead": "394c95ab244c04c8cf56abe8bfafd0ab44226539"
45
+ "gitHead": "349d57f5d1e539200e980bdff96973c2e0b66caa"
44
46
  }
package/LICENSE.txt DELETED
@@ -1,22 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright © 2017–now Ruben Taelman, Joachim Van Herwegen
4
- Comunica Association and Ghent University – imec, Belgium
5
-
6
- Permission is hereby granted, free of charge, to any person obtaining a copy
7
- of this software and associated documentation files (the "Software"), to deal
8
- in the Software without restriction, including without limitation the rights
9
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- copies of the Software, and to permit persons to whom the Software is
11
- furnished to do so, subject to the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be included in
14
- all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- THE SOFTWARE.