@comunica/actor-init-query 2.3.1-alpha.22.0 → 2.3.1-alpha.23.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.
|
@@ -17,6 +17,10 @@
|
|
|
17
17
|
{
|
|
18
18
|
"@id": "caiq:components/HttpServiceSparqlEndpoint.jsonld#IQueryBody__member_value",
|
|
19
19
|
"memberFieldName": "value"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"@id": "caiq:components/HttpServiceSparqlEndpoint.jsonld#IQueryBody__member_context",
|
|
23
|
+
"memberFieldName": "context"
|
|
20
24
|
}
|
|
21
25
|
],
|
|
22
26
|
"constructorArguments": []
|
|
@@ -51,6 +55,10 @@
|
|
|
51
55
|
"@id": "caiq:components/HttpServiceSparqlEndpoint.jsonld#IHttpServiceSparqlEndpointArgs__member_freshWorkerPerQuery",
|
|
52
56
|
"memberFieldName": "freshWorkerPerQuery"
|
|
53
57
|
},
|
|
58
|
+
{
|
|
59
|
+
"@id": "caiq:components/HttpServiceSparqlEndpoint.jsonld#IHttpServiceSparqlEndpointArgs__member_contextOverride",
|
|
60
|
+
"memberFieldName": "contextOverride"
|
|
61
|
+
},
|
|
54
62
|
{
|
|
55
63
|
"@id": "caiq:components/HttpServiceSparqlEndpoint.jsonld#IHttpServiceSparqlEndpointArgs__member_moduleRootPath",
|
|
56
64
|
"memberFieldName": "moduleRootPath"
|
|
@@ -21,6 +21,7 @@ export declare class HttpServiceSparqlEndpoint {
|
|
|
21
21
|
readonly workers: number;
|
|
22
22
|
readonly invalidateCacheBeforeQuery: boolean;
|
|
23
23
|
readonly freshWorkerPerQuery: boolean;
|
|
24
|
+
readonly contextOverride: boolean;
|
|
24
25
|
lastQueryId: number;
|
|
25
26
|
constructor(args: IHttpServiceSparqlEndpointArgs);
|
|
26
27
|
/**
|
|
@@ -108,6 +109,7 @@ export declare class HttpServiceSparqlEndpoint {
|
|
|
108
109
|
export interface IQueryBody {
|
|
109
110
|
type: 'query' | 'void';
|
|
110
111
|
value: string;
|
|
112
|
+
context: Record<string, any> | undefined;
|
|
111
113
|
}
|
|
112
114
|
export interface IHttpServiceSparqlEndpointArgs extends IDynamicQueryEngineOptions {
|
|
113
115
|
context?: any;
|
|
@@ -116,6 +118,7 @@ export interface IHttpServiceSparqlEndpointArgs extends IDynamicQueryEngineOptio
|
|
|
116
118
|
workers?: number;
|
|
117
119
|
invalidateCacheBeforeQuery?: boolean;
|
|
118
120
|
freshWorkerPerQuery?: boolean;
|
|
121
|
+
contextOverride?: boolean;
|
|
119
122
|
moduleRootPath: string;
|
|
120
123
|
defaultConfigPath: string;
|
|
121
124
|
}
|
|
@@ -25,6 +25,7 @@ class HttpServiceSparqlEndpoint {
|
|
|
25
25
|
this.workers = args.workers ?? 1;
|
|
26
26
|
this.invalidateCacheBeforeQuery = Boolean(args.invalidateCacheBeforeQuery);
|
|
27
27
|
this.freshWorkerPerQuery = Boolean(args.freshWorkerPerQuery);
|
|
28
|
+
this.contextOverride = Boolean(args.contextOverride);
|
|
28
29
|
this.engine = new __1.QueryEngineFactoryBase(args.moduleRootPath, args.defaultConfigPath, actorInitQuery => new __1.QueryEngineBase(actorInitQuery)).create(args);
|
|
29
30
|
}
|
|
30
31
|
/**
|
|
@@ -93,6 +94,7 @@ class HttpServiceSparqlEndpoint {
|
|
|
93
94
|
}
|
|
94
95
|
const invalidateCacheBeforeQuery = args.invalidateCache;
|
|
95
96
|
const freshWorkerPerQuery = args.freshWorker;
|
|
97
|
+
const contextOverride = args.contextOverride;
|
|
96
98
|
const port = args.port;
|
|
97
99
|
const timeout = args.timeout * 1000;
|
|
98
100
|
const workers = args.workers;
|
|
@@ -104,6 +106,7 @@ class HttpServiceSparqlEndpoint {
|
|
|
104
106
|
context,
|
|
105
107
|
invalidateCacheBeforeQuery,
|
|
106
108
|
freshWorkerPerQuery,
|
|
109
|
+
contextOverride,
|
|
107
110
|
moduleRootPath,
|
|
108
111
|
mainModulePath: moduleRootPath,
|
|
109
112
|
port,
|
|
@@ -277,7 +280,7 @@ class HttpServiceSparqlEndpoint {
|
|
|
277
280
|
case 'GET':
|
|
278
281
|
// eslint-disable-next-line no-case-declarations
|
|
279
282
|
const queryValue = requestUrl.query.query;
|
|
280
|
-
queryBody = queryValue ? { type: 'query', value: queryValue } : undefined;
|
|
283
|
+
queryBody = queryValue ? { type: 'query', value: queryValue, context: undefined } : undefined;
|
|
281
284
|
// eslint-disable-next-line no-case-declarations
|
|
282
285
|
const headOnly = request.method === 'HEAD';
|
|
283
286
|
await this.writeQueryResult(engine, stdout, stderr, request, response, queryBody, mediaType, headOnly, true, this.lastQueryId++);
|
|
@@ -306,7 +309,10 @@ class HttpServiceSparqlEndpoint {
|
|
|
306
309
|
return this.writeServiceDescription(engine, stdout, stderr, request, response, mediaType, headOnly);
|
|
307
310
|
}
|
|
308
311
|
// Determine context
|
|
309
|
-
let context =
|
|
312
|
+
let context = {
|
|
313
|
+
...this.context,
|
|
314
|
+
...this.contextOverride ? queryBody.context : undefined,
|
|
315
|
+
};
|
|
310
316
|
if (readOnly) {
|
|
311
317
|
context = { ...context, [context_entries_1.KeysQueryOperation.readOnly.name]: readOnly };
|
|
312
318
|
}
|
|
@@ -471,18 +477,27 @@ class HttpServiceSparqlEndpoint {
|
|
|
471
477
|
const contentType = request.headers['content-type'];
|
|
472
478
|
if (contentType) {
|
|
473
479
|
if (contentType.includes('application/sparql-query')) {
|
|
474
|
-
return resolve({ type: 'query', value: body });
|
|
480
|
+
return resolve({ type: 'query', value: body, context: undefined });
|
|
475
481
|
}
|
|
476
482
|
if (contentType.includes('application/sparql-update')) {
|
|
477
|
-
return resolve({ type: 'void', value: body });
|
|
483
|
+
return resolve({ type: 'void', value: body, context: undefined });
|
|
478
484
|
}
|
|
479
485
|
if (contentType.includes('application/x-www-form-urlencoded')) {
|
|
480
486
|
const bodyStructure = querystring.parse(body);
|
|
487
|
+
let context;
|
|
488
|
+
if (bodyStructure.context) {
|
|
489
|
+
try {
|
|
490
|
+
context = JSON.parse(bodyStructure.context);
|
|
491
|
+
}
|
|
492
|
+
catch (error) {
|
|
493
|
+
reject(new Error(`Invalid POST body with context received ('${bodyStructure.context}'): ${error.message}`));
|
|
494
|
+
}
|
|
495
|
+
}
|
|
481
496
|
if (bodyStructure.query) {
|
|
482
|
-
return resolve({ type: 'query', value: bodyStructure.query });
|
|
497
|
+
return resolve({ type: 'query', value: bodyStructure.query, context });
|
|
483
498
|
}
|
|
484
499
|
if (bodyStructure.update) {
|
|
485
|
-
return resolve({ type: 'void', value: bodyStructure.update });
|
|
500
|
+
return resolve({ type: 'void', value: bodyStructure.update, context });
|
|
486
501
|
}
|
|
487
502
|
}
|
|
488
503
|
}
|
|
@@ -53,6 +53,11 @@ class CliArgsHandlerHttp {
|
|
|
53
53
|
describe: 'Kills the worker after each query execution',
|
|
54
54
|
default: false,
|
|
55
55
|
},
|
|
56
|
+
contextOverride: {
|
|
57
|
+
type: 'boolean',
|
|
58
|
+
describe: 'If the query context can be overridden through POST requests',
|
|
59
|
+
default: false,
|
|
60
|
+
},
|
|
56
61
|
})
|
|
57
62
|
.check(args => {
|
|
58
63
|
if (args.version) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@comunica/actor-init-query",
|
|
3
|
-
"version": "2.3.1-alpha.
|
|
3
|
+
"version": "2.3.1-alpha.23.0",
|
|
4
4
|
"description": "A query init actor",
|
|
5
5
|
"lsd:module": true,
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -31,19 +31,19 @@
|
|
|
31
31
|
"lib/**/*.js"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@comunica/actor-http-proxy": "2.3.1-alpha.
|
|
35
|
-
"@comunica/bus-context-preprocess": "2.3.1-alpha.
|
|
36
|
-
"@comunica/bus-http-invalidate": "2.3.1-alpha.
|
|
37
|
-
"@comunica/bus-init": "2.3.1-alpha.
|
|
38
|
-
"@comunica/bus-optimize-query-operation": "2.3.1-alpha.
|
|
39
|
-
"@comunica/bus-query-operation": "2.3.1-alpha.
|
|
40
|
-
"@comunica/bus-query-parse": "2.3.1-alpha.
|
|
41
|
-
"@comunica/bus-query-result-serialize": "2.3.1-alpha.
|
|
42
|
-
"@comunica/context-entries": "2.3.1-alpha.
|
|
43
|
-
"@comunica/core": "2.3.1-alpha.
|
|
44
|
-
"@comunica/logger-pretty": "2.3.1-alpha.
|
|
45
|
-
"@comunica/runner": "2.3.1-alpha.
|
|
46
|
-
"@comunica/types": "2.3.1-alpha.
|
|
34
|
+
"@comunica/actor-http-proxy": "2.3.1-alpha.23.0",
|
|
35
|
+
"@comunica/bus-context-preprocess": "2.3.1-alpha.23.0",
|
|
36
|
+
"@comunica/bus-http-invalidate": "2.3.1-alpha.23.0",
|
|
37
|
+
"@comunica/bus-init": "2.3.1-alpha.23.0",
|
|
38
|
+
"@comunica/bus-optimize-query-operation": "2.3.1-alpha.23.0",
|
|
39
|
+
"@comunica/bus-query-operation": "2.3.1-alpha.23.0",
|
|
40
|
+
"@comunica/bus-query-parse": "2.3.1-alpha.23.0",
|
|
41
|
+
"@comunica/bus-query-result-serialize": "2.3.1-alpha.23.0",
|
|
42
|
+
"@comunica/context-entries": "2.3.1-alpha.23.0",
|
|
43
|
+
"@comunica/core": "2.3.1-alpha.23.0",
|
|
44
|
+
"@comunica/logger-pretty": "2.3.1-alpha.23.0",
|
|
45
|
+
"@comunica/runner": "2.3.1-alpha.23.0",
|
|
46
|
+
"@comunica/types": "2.3.1-alpha.23.0",
|
|
47
47
|
"@rdfjs/types": "*",
|
|
48
48
|
"@types/yargs": "^17.0.2",
|
|
49
49
|
"asynciterator": "^3.4.2",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"browser": {
|
|
63
63
|
"./lib/index.js": "./lib/index-browser.js"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "4dd99fee904c64e9ef700eb5080197c4a03a36fa"
|
|
66
66
|
}
|