@comunica/actor-query-result-serialize-json 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.
|
@@ -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": "caqrsj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_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": "caqrsj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_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
|
}
|
|
@@ -210,12 +184,6 @@
|
|
|
210
184
|
"@id": "caqrsj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_args_bus"
|
|
211
185
|
}
|
|
212
186
|
},
|
|
213
|
-
{
|
|
214
|
-
"keyRaw": "busFailMessage",
|
|
215
|
-
"value": {
|
|
216
|
-
"@id": "caqrsj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_args_busFailMessage"
|
|
217
|
-
}
|
|
218
|
-
},
|
|
219
187
|
{
|
|
220
188
|
"keyRaw": "beforeActors",
|
|
221
189
|
"value": {
|
|
@@ -25,9 +25,6 @@
|
|
|
25
25
|
"args_bus": {
|
|
26
26
|
"@id": "caqrsj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_args_bus"
|
|
27
27
|
},
|
|
28
|
-
"args_busFailMessage": {
|
|
29
|
-
"@id": "caqrsj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_args_busFailMessage"
|
|
30
|
-
},
|
|
31
28
|
"args_beforeActors": {
|
|
32
29
|
"@id": "caqrsj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_args_beforeActors",
|
|
33
30
|
"@container": "@list"
|
|
@@ -49,9 +46,6 @@
|
|
|
49
46
|
"bus": {
|
|
50
47
|
"@id": "caqrsj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_args_bus"
|
|
51
48
|
},
|
|
52
|
-
"busFailMessage": {
|
|
53
|
-
"@id": "caqrsj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_args_busFailMessage"
|
|
54
|
-
},
|
|
55
49
|
"beforeActors": {
|
|
56
50
|
"@id": "caqrsj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_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
|
/**
|
|
6
5
|
* A comunica JSON Query Result Serialize Actor.
|
|
@@ -16,6 +15,6 @@ export declare class ActorQueryResultSerializeJson extends ActorQueryResultSeria
|
|
|
16
15
|
* }} mediaTypeFormats
|
|
17
16
|
*/
|
|
18
17
|
constructor(args: IActorQueryResultSerializeFixedMediaTypesArgs);
|
|
19
|
-
testHandleChecked(action: IActionSparqlSerialize, _context: IActionContext): Promise<
|
|
18
|
+
testHandleChecked(action: IActionSparqlSerialize, _context: IActionContext): Promise<boolean>;
|
|
20
19
|
runHandle(action: IActionSparqlSerialize, _mediaType: string, _context: IActionContext): Promise<IActorQueryResultSerializeOutput>;
|
|
21
20
|
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ActorQueryResultSerializeJson = 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 asynciterator_1 = require("asynciterator");
|
|
7
6
|
const RdfString = require("rdf-string");
|
|
8
7
|
const readable_stream_1 = require("readable-stream");
|
|
@@ -24,9 +23,9 @@ class ActorQueryResultSerializeJson extends bus_query_result_serialize_1.ActorQu
|
|
|
24
23
|
}
|
|
25
24
|
async testHandleChecked(action, _context) {
|
|
26
25
|
if (!['bindings', 'quads', 'boolean'].includes(action.type)) {
|
|
27
|
-
|
|
26
|
+
throw new Error('This actor can only handle bindings or quad streams.');
|
|
28
27
|
}
|
|
29
|
-
return
|
|
28
|
+
return true;
|
|
30
29
|
}
|
|
31
30
|
async runHandle(action, _mediaType, _context) {
|
|
32
31
|
const data = new readable_stream_1.Readable();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActorQueryResultSerializeJson.js","sourceRoot":"","sources":["ActorQueryResultSerializeJson.ts"],"names":[],"mappings":";;;AAKA,qFAAgG;
|
|
1
|
+
{"version":3,"file":"ActorQueryResultSerializeJson.js","sourceRoot":"","sources":["ActorQueryResultSerializeJson.ts"],"names":[],"mappings":";;;AAKA,qFAAgG;AAOhG,iDAAqC;AACrC,wCAAwC;AACxC,qDAA2C;AAE3C;;GAEG;AACH,MAAa,6BAA8B,SAAQ,qEAAwC;IACzF;;;;;;;;OAQG;IACH,YAAmB,IAAmD;QACpE,KAAK,CAAC,IAAI,C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AAG,CAAC,CAAC,OAAO,EAAE,EAAE;gBAC9B,MAAM,GAAG,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,OAAO,EAAE,CAAC;gBAC9C,KAAK,GAAG,KAAK,CAAC;gBACd,OAAO,GAAG,CAAC;YACb,CAAC,CAAC,CAAC,OAAO,CAAC,CAAE,GAAG,CAAE,CAAC,CAAC,MAAM,CAAC,CAAE,OAAO,CAAE,CAAC,CAAC;YAExC,IAAI,CAAC,IAAI,CAAO,MAAM,CAAC,CAAC;QAC1B,CAAC;aAAM,CAAC;YACN,IAAI,CAAC;gBACH,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAsC,MAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC;gBAC1F,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAClB,CAAC;YAAC,OAAO,KAAc,EAAE,CAAC;gBACxB,UAAU,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;YAC9C,CAAC;QACH,CAAC;QAED,OAAO,EAAE,IAAI,EAAE,CAAC;IAClB,CAAC;CACF;AAvDD,sEAuDC","sourcesContent":["import type {\n IActionSparqlSerialize,\n IActorQueryResultSerializeFixedMediaTypesArgs,\n IActorQueryResultSerializeOutput,\n} from '@comunica/bus-query-result-serialize';\nimport { ActorQueryResultSerializeFixedMediaTypes } from '@comunica/bus-query-result-serialize';\nimport type {\n IActionContext,\n IQueryOperationResultBindings,\n IQueryOperationResultBoolean,\n IQueryOperationResultQuads,\n} from '@comunica/types';\nimport { wrap } from 'asynciterator';\nimport * as RdfString from 'rdf-string';\nimport { Readable } from 'readable-stream';\n\n/**\n * A comunica JSON Query Result Serialize Actor.\n */\nexport class ActorQueryResultSerializeJson extends ActorQueryResultSerializeFixedMediaTypes {\n /**\n * @param args -\n * \\ @defaultNested {{\n * \"application/json\": 1.0\n * }} mediaTypePriorities\n * \\ @defaultNested {{\n * \"application/json\": \"https://comunica.linkeddatafragments.org/#results_JSON\"\n * }} mediaTypeFormats\n */\n public constructor(args: IActorQueryResultSerializeFixedMediaTypesArgs) {\n super(args);\n }\n\n public override async testHandleChecked(action: IActionSparqlSerialize, _context: IActionContext): Promise<boolean> {\n if (![ 'bindings', 'quads', 'boolean' ].includes(action.type)) {\n throw new Error('This actor can only handle bindings or quad streams.');\n }\n return true;\n }\n\n public async runHandle(action: IActionSparqlSerialize, _mediaType: string, _context: IActionContext):\n Promise<IActorQueryResultSerializeOutput> {\n const data = new Readable();\n data._read = () => {\n // Do nothing\n };\n\n if (action.type === 'bindings' || action.type === 'quads') {\n let stream = action.type === 'bindings' ?\n wrap((<IQueryOperationResultBindings> action).bindingsStream)\n .map(element => JSON.stringify(Object.fromEntries([ ...element ]\n .map(([ key, value ]) => [ key.value, RdfString.termToString(value) ])))) :\n wrap((<IQueryOperationResultQuads> action).quadStream)\n .map(element => JSON.stringify(RdfString.quadToStringQuad(element)));\n\n let empty = true;\n stream = stream.map((element) => {\n const ret = `${empty ? '' : ','}\\n${element}`;\n empty = false;\n return ret;\n }).prepend([ '[' ]).append([ '\\n]\\n' ]);\n\n data.wrap(<any> stream);\n } else {\n try {\n data.push(`${JSON.stringify(await (<IQueryOperationResultBoolean> action).execute())}\\n`);\n data.push(null);\n } catch (error: unknown) {\n setTimeout(() => data.emit('error', error));\n }\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-json",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "A json 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,12 +37,11 @@
|
|
|
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
|
"asynciterator": "^3.9.0",
|
|
48
43
|
"rdf-string": "^1.6.1",
|
|
49
|
-
"readable-stream": "^4.
|
|
44
|
+
"readable-stream": "^4.4.2"
|
|
50
45
|
},
|
|
51
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "02bde397d206f1f5a523643a6a604c89e792e2f9"
|
|
52
47
|
}
|