@comunica/actor-query-result-serialize-sparql-csv 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.
- package/components/ActorQueryResultSerializeSparqlCsv.jsonld +0 -32
- package/components/context.jsonld +0 -6
- package/lib/ActorQueryResultSerializeSparqlCsv.d.ts +1 -2
- package/lib/ActorQueryResultSerializeSparqlCsv.js +4 -5
- package/lib/ActorQueryResultSerializeSparqlCsv.js.map +1 -1
- package/package.json +5 -10
|
@@ -79,10 +79,6 @@
|
|
|
79
79
|
{
|
|
80
80
|
"@type": "ParameterRangeGenericTypeReference",
|
|
81
81
|
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
"@type": "ParameterRangeGenericTypeReference",
|
|
85
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_TS"
|
|
86
82
|
}
|
|
87
83
|
]
|
|
88
84
|
},
|
|
@@ -97,10 +93,6 @@
|
|
|
97
93
|
{
|
|
98
94
|
"@type": "ParameterRangeGenericTypeReference",
|
|
99
95
|
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
"@type": "ParameterRangeGenericTypeReference",
|
|
103
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_TS"
|
|
104
96
|
}
|
|
105
97
|
]
|
|
106
98
|
},
|
|
@@ -110,20 +102,6 @@
|
|
|
110
102
|
},
|
|
111
103
|
"comment": "The bus this actor subscribes to."
|
|
112
104
|
},
|
|
113
|
-
{
|
|
114
|
-
"@id": "caqrssc:components/ActorQueryResultSerializeSparqlCsv.jsonld#ActorQueryResultSerializeSparqlCsv_args_busFailMessage",
|
|
115
|
-
"range": {
|
|
116
|
-
"@type": "ParameterRangeUnion",
|
|
117
|
-
"parameterRangeElements": [
|
|
118
|
-
"xsd:string",
|
|
119
|
-
{
|
|
120
|
-
"@type": "ParameterRangeUndefined"
|
|
121
|
-
}
|
|
122
|
-
]
|
|
123
|
-
},
|
|
124
|
-
"default": "Query result serialization failed: none of the configured actors were able to serialize for type ${action.handle.type}",
|
|
125
|
-
"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}\""
|
|
126
|
-
},
|
|
127
105
|
{
|
|
128
106
|
"@id": "caqrssc:components/ActorQueryResultSerializeSparqlCsv.jsonld#ActorQueryResultSerializeSparqlCsv_args_beforeActors",
|
|
129
107
|
"range": {
|
|
@@ -146,10 +124,6 @@
|
|
|
146
124
|
{
|
|
147
125
|
"@type": "ParameterRangeGenericTypeReference",
|
|
148
126
|
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
"@type": "ParameterRangeGenericTypeReference",
|
|
152
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_TS"
|
|
153
127
|
}
|
|
154
128
|
]
|
|
155
129
|
}
|
|
@@ -214,12 +188,6 @@
|
|
|
214
188
|
"@id": "caqrssc:components/ActorQueryResultSerializeSparqlCsv.jsonld#ActorQueryResultSerializeSparqlCsv_args_bus"
|
|
215
189
|
}
|
|
216
190
|
},
|
|
217
|
-
{
|
|
218
|
-
"keyRaw": "busFailMessage",
|
|
219
|
-
"value": {
|
|
220
|
-
"@id": "caqrssc:components/ActorQueryResultSerializeSparqlCsv.jsonld#ActorQueryResultSerializeSparqlCsv_args_busFailMessage"
|
|
221
|
-
}
|
|
222
|
-
},
|
|
223
191
|
{
|
|
224
192
|
"keyRaw": "beforeActors",
|
|
225
193
|
"value": {
|
|
@@ -25,9 +25,6 @@
|
|
|
25
25
|
"args_bus": {
|
|
26
26
|
"@id": "caqrssc:components/ActorQueryResultSerializeSparqlCsv.jsonld#ActorQueryResultSerializeSparqlCsv_args_bus"
|
|
27
27
|
},
|
|
28
|
-
"args_busFailMessage": {
|
|
29
|
-
"@id": "caqrssc:components/ActorQueryResultSerializeSparqlCsv.jsonld#ActorQueryResultSerializeSparqlCsv_args_busFailMessage"
|
|
30
|
-
},
|
|
31
28
|
"args_beforeActors": {
|
|
32
29
|
"@id": "caqrssc:components/ActorQueryResultSerializeSparqlCsv.jsonld#ActorQueryResultSerializeSparqlCsv_args_beforeActors",
|
|
33
30
|
"@container": "@list"
|
|
@@ -49,9 +46,6 @@
|
|
|
49
46
|
"bus": {
|
|
50
47
|
"@id": "caqrssc:components/ActorQueryResultSerializeSparqlCsv.jsonld#ActorQueryResultSerializeSparqlCsv_args_bus"
|
|
51
48
|
},
|
|
52
|
-
"busFailMessage": {
|
|
53
|
-
"@id": "caqrssc:components/ActorQueryResultSerializeSparqlCsv.jsonld#ActorQueryResultSerializeSparqlCsv_args_busFailMessage"
|
|
54
|
-
},
|
|
55
49
|
"beforeActors": {
|
|
56
50
|
"@id": "caqrssc:components/ActorQueryResultSerializeSparqlCsv.jsonld#ActorQueryResultSerializeSparqlCsv_args_beforeActors",
|
|
57
51
|
"@container": "@list"
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { IActionSparqlSerialize, IActorQueryResultSerializeFixedMediaTypesArgs, IActorQueryResultSerializeOutput } from '@comunica/bus-query-result-serialize';
|
|
2
2
|
import { ActorQueryResultSerializeFixedMediaTypes } from '@comunica/bus-query-result-serialize';
|
|
3
|
-
import type { TestResult } from '@comunica/core';
|
|
4
3
|
import type { IActionContext } from '@comunica/types';
|
|
5
4
|
import type * as RDF from '@rdfjs/types';
|
|
6
5
|
/**
|
|
@@ -23,6 +22,6 @@ export declare class ActorQueryResultSerializeSparqlCsv extends ActorQueryResult
|
|
|
23
22
|
* @return {string} A string representation of the given value.
|
|
24
23
|
*/
|
|
25
24
|
static bindingToCsvBindings(value?: RDF.Term): string;
|
|
26
|
-
testHandleChecked(action: IActionSparqlSerialize, _context: IActionContext): Promise<
|
|
25
|
+
testHandleChecked(action: IActionSparqlSerialize, _context: IActionContext): Promise<boolean>;
|
|
27
26
|
runHandle(action: IActionSparqlSerialize, _mediaType: string | undefined, _context: IActionContext): Promise<IActorQueryResultSerializeOutput>;
|
|
28
27
|
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ActorQueryResultSerializeSparqlCsv = void 0;
|
|
4
4
|
const bus_query_result_serialize_1 = require("@comunica/bus-query-result-serialize");
|
|
5
|
-
const core_1 = require("@comunica/core");
|
|
6
5
|
const readable_stream_1 = require("readable-stream");
|
|
7
6
|
/**
|
|
8
7
|
* A comunica SPARQL CSV Query Result Serialize Actor.
|
|
@@ -57,19 +56,19 @@ class ActorQueryResultSerializeSparqlCsv extends bus_query_result_serialize_1.Ac
|
|
|
57
56
|
}
|
|
58
57
|
async testHandleChecked(action, _context) {
|
|
59
58
|
if (action.type !== 'bindings') {
|
|
60
|
-
|
|
59
|
+
throw new Error('This actor can only handle bindings streams.');
|
|
61
60
|
}
|
|
62
|
-
return
|
|
61
|
+
return true;
|
|
63
62
|
}
|
|
64
63
|
async runHandle(action, _mediaType, _context) {
|
|
65
64
|
const bindingsAction = action;
|
|
66
65
|
const data = new readable_stream_1.Readable();
|
|
67
66
|
const metadata = await bindingsAction.metadata();
|
|
68
67
|
// Write head
|
|
69
|
-
data.push(`${metadata.variables.map(variable => variable.
|
|
68
|
+
data.push(`${metadata.variables.map(variable => variable.value).join(',')}\r\n`);
|
|
70
69
|
// Write body
|
|
71
70
|
data.wrap(bindingsAction.bindingsStream.map((bindings) => `${metadata.variables
|
|
72
|
-
.map(key => ActorQueryResultSerializeSparqlCsv.bindingToCsvBindings(bindings.get(key
|
|
71
|
+
.map(key => ActorQueryResultSerializeSparqlCsv.bindingToCsvBindings(bindings.get(key)))
|
|
73
72
|
.join(',')}\r\n`));
|
|
74
73
|
return { data };
|
|
75
74
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActorQueryResultSerializeSparqlCsv.js","sourceRoot":"","sources":["ActorQueryResultSerializeSparqlCsv.ts"],"names":[],"mappings":";;;AAKA,qFAE8C;
|
|
1
|
+
{"version":3,"file":"ActorQueryResultSerializeSparqlCsv.js","sourceRoot":"","sources":["ActorQueryResultSerializeSparqlCsv.ts"],"names":[],"mappings":";;;AAKA,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,CAAC;YACX,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,IAAI,WAAW,GAAG,KAAK,CAAC,KAAK,CAAC;QAE9B,IAAI,KAAK,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YACjC,uFAAuF;YACvF,WAAW,GAAG,GAAG,WAAW,EAAE,CAAC;QACjC,CAAC;aAAM,IAAI,KAAK,CAAC,QAAQ,KAAK,WAAW,EAAE,CAAC;YAC1C,WAAW,GAAG,KAAK,WAAW,EAAE,CAAC;QACnC,CAAC;aAAM,IAAI,KAAK,CAAC,QAAQ,KAAK,MAAM,EAAE,CAAC;YACrC,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AC,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAEjF,aAAa;QACb,IAAI,CAAC,IAAI,CAAO,cAAc,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,QAAkB,EAAE,EAAE,CAAC,GAAG,QAAQ,CAAC,SAAS;aAC1F,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,kCAAkC,CAAC,oBAAoB,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;aACtF,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;QAEvB,OAAO,EAAE,IAAI,EAAE,CAAC;IAClB,CAAC;CACF;AA5ED,gFA4EC","sourcesContent":["import type {\n IActionSparqlSerialize,\n IActorQueryResultSerializeFixedMediaTypesArgs,\n IActorQueryResultSerializeOutput,\n} 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 if (value.termType === 'Quad') {\n let object = ActorQueryResultSerializeSparqlCsv.bindingToCsvBindings(value.object);\n if (value.object.termType === 'Literal') {\n // If object is a literal, it must be put in quotes, and internal quotes must be escaped\n object = `\"${object.replaceAll('\"', '\"\"')}\"`;\n }\n stringValue = `<< ${ActorQueryResultSerializeSparqlCsv.bindingToCsvBindings(value.subject)} ${ActorQueryResultSerializeSparqlCsv.bindingToCsvBindings(value.predicate)} ${object} >>`;\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.replaceAll('\"', '\"\"')}\"`;\n }\n\n return stringValue;\n }\n\n public override 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\n const metadata = await bindingsAction.metadata();\n\n // Write head\n data.push(`${metadata.variables.map(variable => variable.value).join(',')}\\r\\n`);\n\n // Write body\n data.wrap(<any> bindingsAction.bindingsStream.map((bindings: Bindings) => `${metadata.variables\n .map(key => ActorQueryResultSerializeSparqlCsv.bindingToCsvBindings(bindings.get(key)))\n .join(',')}\\r\\n`));\n\n return { data };\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@comunica/actor-query-result-serialize-sparql-csv",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "A sparql-csv query-result-serialize 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,11 +37,10 @@
|
|
|
41
37
|
"build:components": "componentsjs-generator"
|
|
42
38
|
},
|
|
43
39
|
"dependencies": {
|
|
44
|
-
"@comunica/bus-query-result-serialize": "3.
|
|
45
|
-
"@comunica/
|
|
46
|
-
"@comunica/types": "3.2.4-alpha.47.0",
|
|
40
|
+
"@comunica/bus-query-result-serialize": "^3.3.0",
|
|
41
|
+
"@comunica/types": "^3.3.0",
|
|
47
42
|
"@rdfjs/types": "*",
|
|
48
|
-
"readable-stream": "^4.
|
|
43
|
+
"readable-stream": "^4.4.2"
|
|
49
44
|
},
|
|
50
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "02bde397d206f1f5a523643a6a604c89e792e2f9"
|
|
51
46
|
}
|