@comunica/actor-query-result-serialize-json 2.0.1-alpha.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.
package/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
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.
package/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # Comunica JSON Query Result Serialize Actor
2
+
3
+ [![npm version](https://badge.fury.io/js/%40comunica%2Factor-query-result-serialize-json.svg)](https://www.npmjs.com/package/@comunica/actor-query-result-serialize-json)
4
+
5
+ A [Query Result Serialize](https://github.com/comunica/comunica/tree/master/packages/bus-query-result-serialize) actor that serializes to a simple custom JSON format.
6
+
7
+ This module is part of the [Comunica framework](https://github.com/comunica/comunica),
8
+ and should only be used by [developers that want to build their own query engine](https://comunica.dev/docs/modify/).
9
+
10
+ [Click here if you just want to query with Comunica](https://comunica.dev/docs/query/).
11
+
12
+ ## Install
13
+
14
+ ```bash
15
+ $ yarn add @comunica/actor-query-result-serialize-json
16
+ ```
17
+
18
+ ## Configure
19
+
20
+ After installing, this package can be added to your engine's configuration as follows:
21
+ ```text
22
+ {
23
+ "@context": [
24
+ ...
25
+ "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-query-result-serialize-json/^2.0.0/components/context.jsonld"
26
+ ],
27
+ "actors": [
28
+ ...
29
+ {
30
+ "@id": "urn:comunica:default:query-result-serialize/actors#json",
31
+ "@type": "ActorQueryResultSerializeJson"
32
+ }
33
+ ]
34
+ }
35
+ ```
@@ -0,0 +1,198 @@
1
+ {
2
+ "@context": [
3
+ "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-query-result-serialize-json/^2.0.0/components/context.jsonld",
4
+ "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/core/^2.0.0/components/context.jsonld",
5
+ "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/bus-query-result-serialize/^2.0.0/components/context.jsonld"
6
+ ],
7
+ "@id": "npmd:@comunica/actor-query-result-serialize-json",
8
+ "components": [
9
+ {
10
+ "@id": "caqrsj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson",
11
+ "@type": "Class",
12
+ "requireElement": "ActorQueryResultSerializeJson",
13
+ "extends": [
14
+ "cbqrs:components/ActorQueryResultSerializeFixedMediaTypes.jsonld#ActorQueryResultSerializeFixedMediaTypes"
15
+ ],
16
+ "comment": "A comunica JSON Query Result Serialize Actor.",
17
+ "parameters": [
18
+ {
19
+ "@id": "caqrsj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_args_mediaTypePriorities",
20
+ "range": "rdf:JSON",
21
+ "default": {
22
+ "@type": "@json",
23
+ "@value": {
24
+ "application/json": 1
25
+ }
26
+ },
27
+ "comment": "A record of media types, with media type name as key, and its priority as value. Priorities are numbers between [0, 1]."
28
+ },
29
+ {
30
+ "@id": "caqrsj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_args_mediaTypeFormats",
31
+ "range": "rdf:JSON",
32
+ "default": {
33
+ "@type": "@json",
34
+ "@value": {
35
+ "application/json": "https://comunica.linkeddatafragments.org/#results_JSON"
36
+ }
37
+ },
38
+ "comment": "A record of media types, with media type name as key, and its format IRI as value."
39
+ },
40
+ {
41
+ "@id": "caqrsj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_args_priorityScale",
42
+ "range": {
43
+ "@type": "ParameterRangeUnion",
44
+ "parameterRangeElements": [
45
+ "xsd:double",
46
+ {
47
+ "@type": "ParameterRangeUndefined"
48
+ }
49
+ ]
50
+ },
51
+ "comment": "A multiplier for media type priorities. This can be used for keeping the original media types in place, but scaling all of their scores with a certain value."
52
+ },
53
+ {
54
+ "@id": "caqrsj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_args_name",
55
+ "range": "xsd:string",
56
+ "default": {
57
+ "@id": "rdf:subject"
58
+ },
59
+ "comment": "The name for this actor."
60
+ },
61
+ {
62
+ "@id": "caqrsj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_args_bus",
63
+ "range": {
64
+ "@type": "ParameterRangeGenericComponent",
65
+ "component": "cc:components/Bus.jsonld#Bus",
66
+ "genericTypeInstances": [
67
+ {
68
+ "@type": "ParameterRangeGenericComponent",
69
+ "component": "cc:components/Actor.jsonld#Actor",
70
+ "genericTypeInstances": [
71
+ {
72
+ "@type": "ParameterRangeGenericTypeReference",
73
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^2.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
74
+ },
75
+ {
76
+ "@type": "ParameterRangeGenericTypeReference",
77
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^2.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
78
+ },
79
+ {
80
+ "@type": "ParameterRangeGenericTypeReference",
81
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^2.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
82
+ }
83
+ ]
84
+ },
85
+ {
86
+ "@type": "ParameterRangeGenericTypeReference",
87
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^2.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
88
+ },
89
+ {
90
+ "@type": "ParameterRangeGenericTypeReference",
91
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^2.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
92
+ },
93
+ {
94
+ "@type": "ParameterRangeGenericTypeReference",
95
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^2.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
96
+ }
97
+ ]
98
+ },
99
+ "default": {
100
+ "@id": "cbqrs:components/ActorQueryResultSerialize.jsonld#ActorQueryResultSerialize_default_bus",
101
+ "@type": "cc:components/Bus.jsonld#Bus"
102
+ },
103
+ "comment": "The bus this actor subscribes to."
104
+ },
105
+ {
106
+ "@id": "caqrsj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_args_beforeActors",
107
+ "range": {
108
+ "@type": "ParameterRangeUnion",
109
+ "parameterRangeElements": [
110
+ {
111
+ "@type": "ParameterRangeArray",
112
+ "parameterRangeValue": {
113
+ "@type": "ParameterRangeGenericComponent",
114
+ "component": "cc:components/Actor.jsonld#Actor",
115
+ "genericTypeInstances": [
116
+ {
117
+ "@type": "ParameterRangeGenericTypeReference",
118
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^2.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
119
+ },
120
+ {
121
+ "@type": "ParameterRangeGenericTypeReference",
122
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^2.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
123
+ },
124
+ {
125
+ "@type": "ParameterRangeGenericTypeReference",
126
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^2.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
127
+ }
128
+ ]
129
+ }
130
+ },
131
+ {
132
+ "@type": "ParameterRangeUndefined"
133
+ }
134
+ ]
135
+ },
136
+ "comment": "Actor that must be registered in the bus before this actor."
137
+ }
138
+ ],
139
+ "memberFields": [
140
+ {
141
+ "@id": "caqrsj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson__member_constructor",
142
+ "memberFieldName": "constructor"
143
+ },
144
+ {
145
+ "@id": "caqrsj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson__member_testHandleChecked",
146
+ "memberFieldName": "testHandleChecked"
147
+ },
148
+ {
149
+ "@id": "caqrsj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson__member_runHandle",
150
+ "memberFieldName": "runHandle"
151
+ }
152
+ ],
153
+ "constructorArguments": [
154
+ {
155
+ "@id": "caqrsj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_args__constructorArgument",
156
+ "fields": [
157
+ {
158
+ "keyRaw": "mediaTypePriorities",
159
+ "value": {
160
+ "@id": "caqrsj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_args_mediaTypePriorities"
161
+ }
162
+ },
163
+ {
164
+ "keyRaw": "mediaTypeFormats",
165
+ "value": {
166
+ "@id": "caqrsj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_args_mediaTypeFormats"
167
+ }
168
+ },
169
+ {
170
+ "keyRaw": "priorityScale",
171
+ "value": {
172
+ "@id": "caqrsj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_args_priorityScale"
173
+ }
174
+ },
175
+ {
176
+ "keyRaw": "name",
177
+ "value": {
178
+ "@id": "caqrsj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_args_name"
179
+ }
180
+ },
181
+ {
182
+ "keyRaw": "bus",
183
+ "value": {
184
+ "@id": "caqrsj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_args_bus"
185
+ }
186
+ },
187
+ {
188
+ "keyRaw": "beforeActors",
189
+ "value": {
190
+ "@id": "caqrsj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_args_beforeActors"
191
+ }
192
+ }
193
+ ]
194
+ }
195
+ ]
196
+ }
197
+ ]
198
+ }
@@ -0,0 +1,189 @@
1
+ {
2
+ "@context": [
3
+ "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-query-result-serialize-json/^2.0.0/components/context.jsonld",
4
+ "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/core/^2.0.0/components/context.jsonld",
5
+ "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/bus-query-result-serialize/^2.0.0/components/context.jsonld"
6
+ ],
7
+ "@id": "npmd:@comunica/actor-query-result-serialize-json",
8
+ "components": [
9
+ {
10
+ "@id": "cassj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson",
11
+ "@type": "Class",
12
+ "requireElement": "ActorQueryResultSerializeJson",
13
+ "extends": [
14
+ "cbss:components/ActorQueryResultSerializeFixedMediaTypes.jsonld#ActorQueryResultSerializeFixedMediaTypes"
15
+ ],
16
+ "comment": "A comunica JSON Query Result Serialize Actor.",
17
+ "parameters": [
18
+ {
19
+ "@id": "cassj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_args_mediaTypePriorities",
20
+ "range": "rdf:JSON",
21
+ "default": {
22
+ "@type": "@json",
23
+ "@value": {
24
+ "application/json": 1
25
+ }
26
+ },
27
+ "comment": "A record of media types, with media type name as key, and its priority as value. Priorities are numbers between [0, 1]."
28
+ },
29
+ {
30
+ "@id": "cassj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_args_mediaTypeFormats",
31
+ "range": "rdf:JSON",
32
+ "default": {
33
+ "@type": "@json",
34
+ "@value": {
35
+ "application/json": "https://comunica.linkeddatafragments.org/#results_JSON"
36
+ }
37
+ },
38
+ "comment": "A record of media types, with media type name as key, and its format IRI as value."
39
+ },
40
+ {
41
+ "@id": "cassj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_args_priorityScale",
42
+ "range": {
43
+ "@type": "ParameterRangeUnion",
44
+ "parameterRangeElements": [
45
+ "xsd:double",
46
+ {
47
+ "@type": "ParameterRangeUndefined"
48
+ }
49
+ ]
50
+ },
51
+ "comment": "A multiplier for media type priorities. This can be used for keeping the original media types in place, but scaling all of their scores with a certain value."
52
+ },
53
+ {
54
+ "@id": "cassj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_args_name",
55
+ "range": "xsd:string",
56
+ "default": {
57
+ "@id": "rdf:subject"
58
+ },
59
+ "comment": "The name for this actor."
60
+ },
61
+ {
62
+ "@id": "cassj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_args_bus",
63
+ "range": {
64
+ "@type": "ParameterRangeGenericComponent",
65
+ "component": "cc:components/Bus.jsonld#Bus",
66
+ "genericTypeInstances": [
67
+ {
68
+ "@type": "ParameterRangeGenericComponent",
69
+ "component": "cc:components/Actor.jsonld#Actor",
70
+ "genericTypeInstances": [
71
+ {
72
+ "@type": "ParameterRangeGenericTypeReference",
73
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^2.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
74
+ },
75
+ {
76
+ "@type": "ParameterRangeGenericTypeReference",
77
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^2.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
78
+ },
79
+ {
80
+ "@type": "ParameterRangeGenericTypeReference",
81
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^2.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
82
+ }
83
+ ]
84
+ },
85
+ {
86
+ "@type": "ParameterRangeGenericTypeReference",
87
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^2.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
88
+ },
89
+ {
90
+ "@type": "ParameterRangeGenericTypeReference",
91
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^2.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
92
+ },
93
+ {
94
+ "@type": "ParameterRangeGenericTypeReference",
95
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^2.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
96
+ }
97
+ ]
98
+ },
99
+ "default": {
100
+ "@id": "cbss:components/ActorQueryResultSerialize.jsonld#ActorQueryResultSerialize_default_bus",
101
+ "@type": "cc:components/Bus.jsonld#Bus"
102
+ },
103
+ "comment": "The bus this actor subscribes to."
104
+ },
105
+ {
106
+ "@id": "cassj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_args_beforeActors",
107
+ "range": {
108
+ "@type": "ParameterRangeUnion",
109
+ "parameterRangeElements": [
110
+ {
111
+ "@type": "ParameterRangeArray",
112
+ "parameterRangeValue": {
113
+ "@type": "ParameterRangeGenericComponent",
114
+ "component": "cc:components/Actor.jsonld#Actor",
115
+ "genericTypeInstances": [
116
+ {
117
+ "@type": "ParameterRangeGenericTypeReference",
118
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^2.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
119
+ },
120
+ {
121
+ "@type": "ParameterRangeGenericTypeReference",
122
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^2.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
123
+ },
124
+ {
125
+ "@type": "ParameterRangeGenericTypeReference",
126
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^2.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
127
+ }
128
+ ]
129
+ }
130
+ },
131
+ {
132
+ "@type": "ParameterRangeUndefined"
133
+ }
134
+ ]
135
+ },
136
+ "comment": "Actor that must be registered in the bus before this actor."
137
+ }
138
+ ],
139
+ "memberKeys": [
140
+ "constructor",
141
+ "testHandleChecked",
142
+ "runHandle"
143
+ ],
144
+ "constructorArguments": [
145
+ {
146
+ "@id": "cassj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_args__constructorArgument",
147
+ "fields": [
148
+ {
149
+ "keyRaw": "mediaTypePriorities",
150
+ "value": {
151
+ "@id": "cassj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_args_mediaTypePriorities"
152
+ }
153
+ },
154
+ {
155
+ "keyRaw": "mediaTypeFormats",
156
+ "value": {
157
+ "@id": "cassj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_args_mediaTypeFormats"
158
+ }
159
+ },
160
+ {
161
+ "keyRaw": "priorityScale",
162
+ "value": {
163
+ "@id": "cassj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_args_priorityScale"
164
+ }
165
+ },
166
+ {
167
+ "keyRaw": "name",
168
+ "value": {
169
+ "@id": "cassj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_args_name"
170
+ }
171
+ },
172
+ {
173
+ "keyRaw": "bus",
174
+ "value": {
175
+ "@id": "cassj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_args_bus"
176
+ }
177
+ },
178
+ {
179
+ "keyRaw": "beforeActors",
180
+ "value": {
181
+ "@id": "cassj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_args_beforeActors"
182
+ }
183
+ }
184
+ ]
185
+ }
186
+ ]
187
+ }
188
+ ]
189
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "@context": [
3
+ "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-query-result-serialize-json/^2.0.0/components/context.jsonld"
4
+ ],
5
+ "@id": "npmd:@comunica/actor-query-result-serialize-json",
6
+ "@type": "Module",
7
+ "requireName": "@comunica/actor-query-result-serialize-json",
8
+ "import": [
9
+ "caqrsj:components/ActorQueryResultSerializeJson.jsonld"
10
+ ]
11
+ }
@@ -0,0 +1,57 @@
1
+ {
2
+ "@context": [
3
+ "https://linkedsoftwaredependencies.org/bundles/npm/componentsjs/^4.0.0/components/context.jsonld",
4
+ {
5
+ "npmd": "https://linkedsoftwaredependencies.org/bundles/npm/",
6
+ "caqrsj": "npmd:@comunica/actor-query-result-serialize-json/^2.0.0/",
7
+ "ActorQueryResultSerializeJson": {
8
+ "@id": "caqrsj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson",
9
+ "@prefix": true,
10
+ "@context": {
11
+ "args_mediaTypePriorities": {
12
+ "@id": "caqrsj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_args_mediaTypePriorities",
13
+ "@type": "@json"
14
+ },
15
+ "args_mediaTypeFormats": {
16
+ "@id": "caqrsj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_args_mediaTypeFormats",
17
+ "@type": "@json"
18
+ },
19
+ "args_priorityScale": {
20
+ "@id": "caqrsj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_args_priorityScale"
21
+ },
22
+ "args_name": {
23
+ "@id": "caqrsj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_args_name"
24
+ },
25
+ "args_bus": {
26
+ "@id": "caqrsj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_args_bus"
27
+ },
28
+ "args_beforeActors": {
29
+ "@id": "caqrsj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_args_beforeActors",
30
+ "@container": "@list"
31
+ },
32
+ "mediaTypePriorities": {
33
+ "@id": "caqrsj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_args_mediaTypePriorities",
34
+ "@type": "@json"
35
+ },
36
+ "mediaTypeFormats": {
37
+ "@id": "caqrsj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_args_mediaTypeFormats",
38
+ "@type": "@json"
39
+ },
40
+ "priorityScale": {
41
+ "@id": "caqrsj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_args_priorityScale"
42
+ },
43
+ "name": {
44
+ "@id": "caqrsj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_args_name"
45
+ },
46
+ "bus": {
47
+ "@id": "caqrsj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_args_bus"
48
+ },
49
+ "beforeActors": {
50
+ "@id": "caqrsj:components/ActorQueryResultSerializeJson.jsonld#ActorQueryResultSerializeJson_args_beforeActors",
51
+ "@container": "@list"
52
+ }
53
+ }
54
+ }
55
+ }
56
+ ]
57
+ }
@@ -0,0 +1,20 @@
1
+ import type { IActionSparqlSerialize, IActorQueryResultSerializeFixedMediaTypesArgs, IActorQueryResultSerializeOutput } from '@comunica/bus-query-result-serialize';
2
+ import { ActorQueryResultSerializeFixedMediaTypes } from '@comunica/bus-query-result-serialize';
3
+ import type { IActionContext } from '@comunica/types';
4
+ /**
5
+ * A comunica JSON Query Result Serialize Actor.
6
+ */
7
+ export declare class ActorQueryResultSerializeJson extends ActorQueryResultSerializeFixedMediaTypes {
8
+ /**
9
+ * @param args -
10
+ * \ @defaultNested {{
11
+ * "application/json": 1.0
12
+ * }} mediaTypePriorities
13
+ * \ @defaultNested {{
14
+ * "application/json": "https://comunica.linkeddatafragments.org/#results_JSON"
15
+ * }} mediaTypeFormats
16
+ */
17
+ constructor(args: IActorQueryResultSerializeFixedMediaTypesArgs);
18
+ testHandleChecked(action: IActionSparqlSerialize, context: IActionContext): Promise<boolean>;
19
+ runHandle(action: IActionSparqlSerialize, mediaType: string, context: IActionContext): Promise<IActorQueryResultSerializeOutput>;
20
+ }
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ActorQueryResultSerializeJson = void 0;
4
+ const stream_1 = require("stream");
5
+ const bus_query_result_serialize_1 = require("@comunica/bus-query-result-serialize");
6
+ const RdfString = require("rdf-string");
7
+ /**
8
+ * A comunica JSON Query Result Serialize Actor.
9
+ */
10
+ class ActorQueryResultSerializeJson extends bus_query_result_serialize_1.ActorQueryResultSerializeFixedMediaTypes {
11
+ /**
12
+ * @param args -
13
+ * \ @defaultNested {{
14
+ * "application/json": 1.0
15
+ * }} mediaTypePriorities
16
+ * \ @defaultNested {{
17
+ * "application/json": "https://comunica.linkeddatafragments.org/#results_JSON"
18
+ * }} mediaTypeFormats
19
+ */
20
+ constructor(args) {
21
+ super(args);
22
+ }
23
+ async testHandleChecked(action, context) {
24
+ if (!['bindings', 'quads', 'boolean'].includes(action.type)) {
25
+ throw new Error('This actor can only handle bindings or quad streams.');
26
+ }
27
+ return true;
28
+ }
29
+ async runHandle(action, mediaType, context) {
30
+ const data = new stream_1.Readable();
31
+ data._read = () => {
32
+ // Do nothing
33
+ };
34
+ let empty = true;
35
+ if (action.type === 'bindings') {
36
+ const resultStream = action.bindingsStream;
37
+ data.push('[');
38
+ resultStream.on('error', error => data.emit('error', error));
39
+ resultStream.on('data', (element) => {
40
+ data.push(empty ? '\n' : ',\n');
41
+ data.push(JSON.stringify(Object.fromEntries([...element]
42
+ .map(([key, value]) => [key.value, RdfString.termToString(value)]))));
43
+ empty = false;
44
+ });
45
+ resultStream.on('end', () => {
46
+ data.push(empty ? ']\n' : '\n]\n');
47
+ data.push(null);
48
+ });
49
+ }
50
+ else if (action.type === 'quads') {
51
+ const resultStream = action.quadStream;
52
+ data.push('[');
53
+ resultStream.on('error', error => data.emit('error', error));
54
+ resultStream.on('data', element => {
55
+ data.push(empty ? '\n' : ',\n');
56
+ data.push(JSON.stringify(RdfString.quadToStringQuad(element)));
57
+ empty = false;
58
+ });
59
+ resultStream.on('end', () => {
60
+ data.push(empty ? ']\n' : '\n]\n');
61
+ data.push(null);
62
+ });
63
+ }
64
+ else {
65
+ try {
66
+ data.push(`${JSON.stringify(await action.booleanResult)}\n`);
67
+ data.push(null);
68
+ }
69
+ catch (error) {
70
+ setImmediate(() => data.emit('error', error));
71
+ }
72
+ }
73
+ return { data };
74
+ }
75
+ }
76
+ exports.ActorQueryResultSerializeJson = ActorQueryResultSerializeJson;
77
+ //# sourceMappingURL=ActorQueryResultSerializeJson.js.map
package/lib/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './ActorQueryResultSerializeJson';
package/lib/index.js ADDED
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./ActorQueryResultSerializeJson"), exports);
14
+ //# sourceMappingURL=index.js.map
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@comunica/actor-query-result-serialize-json",
3
+ "version": "2.0.1-alpha.5.0",
4
+ "description": "A json query-result-serialize actor",
5
+ "lsd:module": true,
6
+ "main": "lib/index.js",
7
+ "typings": "lib/index",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/comunica/comunica.git",
11
+ "directory": "packages/actor-query-result-serialize-json"
12
+ },
13
+ "publishConfig": {
14
+ "access": "public"
15
+ },
16
+ "keywords": [
17
+ "comunica",
18
+ "actor",
19
+ "query-result-serialize",
20
+ "json"
21
+ ],
22
+ "license": "MIT",
23
+ "bugs": {
24
+ "url": "https://github.com/comunica/comunica/issues"
25
+ },
26
+ "homepage": "https://comunica.dev/",
27
+ "files": [
28
+ "components",
29
+ "lib/**/*.d.ts",
30
+ "lib/**/*.js"
31
+ ],
32
+ "dependencies": {
33
+ "@comunica/bus-query-operation": "2.0.1-alpha.5.0",
34
+ "@comunica/bus-query-result-serialize": "2.0.1-alpha.5.0",
35
+ "@comunica/core": "2.0.1-alpha.5.0",
36
+ "@comunica/types": "2.0.1-alpha.5.0",
37
+ "@rdfjs/types": "*",
38
+ "rdf-string": "^1.5.0"
39
+ },
40
+ "scripts": {
41
+ "build": "npm run build:ts && npm run build:components",
42
+ "build:ts": "node \"../../node_modules/typescript/bin/tsc\"",
43
+ "build:components": "componentsjs-generator"
44
+ },
45
+ "gitHead": "e2ae2e9e924bf0656df60cc99774f7e560d47695"
46
+ }