kuzzle 2.16.2 → 2.16.6
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/lib/api/controllers/serverController.js +27 -14
- package/lib/api/openApiGenerator.d.ts +2 -1
- package/lib/api/openApiGenerator.js +16 -18
- package/lib/api/request/kuzzleRequest.d.ts +64 -30
- package/lib/api/request/kuzzleRequest.js +135 -29
- package/lib/api/request/requestContext.d.ts +22 -17
- package/lib/api/request/requestContext.js +109 -44
- package/lib/api/request/requestInput.d.ts +24 -19
- package/lib/api/request/requestInput.js +175 -115
- package/lib/api/request/requestResponse.d.ts +8 -12
- package/lib/api/request/requestResponse.js +29 -35
- package/lib/core/backend/backendController.js +0 -3
- package/lib/core/plugin/plugin.js +18 -8
- package/lib/core/plugin/pluginsManager.js +2 -4
- package/lib/kuzzle/kuzzle.js +5 -9
- package/lib/service/storage/elasticsearch.js +6 -0
- package/package-lock.json +22 -22
- package/package.json +5 -5
|
@@ -47,7 +47,11 @@ class ServerController extends NativeController {
|
|
|
47
47
|
'publicApi',
|
|
48
48
|
'openapi',
|
|
49
49
|
]);
|
|
50
|
-
|
|
50
|
+
|
|
51
|
+
this._openApiDefinition = {
|
|
52
|
+
json: null,
|
|
53
|
+
yaml: null,
|
|
54
|
+
};
|
|
51
55
|
}
|
|
52
56
|
|
|
53
57
|
/**
|
|
@@ -55,7 +59,7 @@ class ServerController extends NativeController {
|
|
|
55
59
|
*
|
|
56
60
|
* @param {Request} request
|
|
57
61
|
* @returns {Promise<Object>}
|
|
58
|
-
*
|
|
62
|
+
*
|
|
59
63
|
* @deprecated
|
|
60
64
|
*/
|
|
61
65
|
getStats (request) {
|
|
@@ -66,7 +70,7 @@ class ServerController extends NativeController {
|
|
|
66
70
|
* Returns the last statistics frame
|
|
67
71
|
*
|
|
68
72
|
* @returns {Promise<Object>}
|
|
69
|
-
*
|
|
73
|
+
*
|
|
70
74
|
* @deprecated
|
|
71
75
|
*/
|
|
72
76
|
getLastStats () {
|
|
@@ -77,7 +81,7 @@ class ServerController extends NativeController {
|
|
|
77
81
|
* Returns all stored statistics frames
|
|
78
82
|
*
|
|
79
83
|
* @returns {Promise<Object>}
|
|
80
|
-
*
|
|
84
|
+
*
|
|
81
85
|
* @deprecated
|
|
82
86
|
*/
|
|
83
87
|
getAllStats () {
|
|
@@ -242,25 +246,34 @@ class ServerController extends NativeController {
|
|
|
242
246
|
}
|
|
243
247
|
|
|
244
248
|
async openapi (request) {
|
|
245
|
-
const format = request.
|
|
246
|
-
|
|
247
|
-
: 'json';
|
|
248
|
-
const contentType = format === 'yaml'
|
|
249
|
-
? 'application/yaml'
|
|
250
|
-
: 'application/json';
|
|
251
|
-
const specifications = format === 'yaml'
|
|
252
|
-
? jsonToYaml.stringify(this._docOpenapi)
|
|
253
|
-
: this._docOpenapi;
|
|
249
|
+
const format = request.getString('format', 'json');
|
|
250
|
+
const specifications = this.getOpenApiDefinition(format);
|
|
254
251
|
|
|
255
252
|
request.response.configure({
|
|
256
253
|
format: 'raw',
|
|
257
|
-
headers: { 'Content-Type':
|
|
254
|
+
headers: { 'Content-Type': `application/${format}` },
|
|
258
255
|
status: 200,
|
|
259
256
|
});
|
|
260
257
|
|
|
261
258
|
return specifications;
|
|
262
259
|
}
|
|
263
260
|
|
|
261
|
+
/**
|
|
262
|
+
* Lazy loading of OpenAPI definition.
|
|
263
|
+
*
|
|
264
|
+
* Mainly because we need to wait all plugin to be loaded
|
|
265
|
+
* to generate the definition.
|
|
266
|
+
*/
|
|
267
|
+
getOpenApiDefinition (format) {
|
|
268
|
+
if (! this._openApiDefinition[format]) {
|
|
269
|
+
this._openApiDefinition[format] = format === 'json'
|
|
270
|
+
? generateOpenApi()
|
|
271
|
+
: jsonToYaml.stringify(generateOpenApi());
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
return this._openApiDefinition[format];
|
|
275
|
+
}
|
|
276
|
+
|
|
264
277
|
/**
|
|
265
278
|
* Fetches and returns Kuzzle core metrics
|
|
266
279
|
* @returns {Promise<Object>}
|
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.generateOpenApi = void 0;
|
|
7
2
|
/*
|
|
8
3
|
* Kuzzle, a backend software, self-hostable and ready to use
|
|
9
4
|
* to power modern apps
|
|
@@ -24,13 +19,18 @@ exports.generateOpenApi = void 0;
|
|
|
24
19
|
* See the License for the specific language governing permissions and
|
|
25
20
|
* limitations under the License.
|
|
26
21
|
*/
|
|
22
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.generateOpenApi = void 0;
|
|
27
27
|
const lodash_1 = __importDefault(require("lodash"));
|
|
28
|
-
const package_json_1 = require("
|
|
28
|
+
const package_json_1 = require("../../package.json");
|
|
29
29
|
const openapi_1 = require("./openapi");
|
|
30
|
-
const inflector_1 = require("
|
|
30
|
+
const inflector_1 = require("../util/inflector");
|
|
31
31
|
const routeUrlMatch = /:([^/]*)/g;
|
|
32
32
|
/**
|
|
33
|
-
*
|
|
33
|
+
* Generate basic openApi Controller
|
|
34
34
|
*/
|
|
35
35
|
function generateController(route, response) {
|
|
36
36
|
if (route.controller !== undefined) {
|
|
@@ -47,7 +47,7 @@ function generateController(route, response) {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
|
-
*
|
|
50
|
+
* Generate basic openApi Summary
|
|
51
51
|
*/
|
|
52
52
|
function generateSummary(route) {
|
|
53
53
|
if (route.openapi.description === undefined) {
|
|
@@ -58,7 +58,7 @@ function generateSummary(route) {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
/**
|
|
61
|
-
*
|
|
61
|
+
* Generate basic openApi Parameters
|
|
62
62
|
*/
|
|
63
63
|
function generateParameters(route) {
|
|
64
64
|
if (route.openapi.parameters === undefined) {
|
|
@@ -80,7 +80,7 @@ function generateParameters(route) {
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
/**
|
|
83
|
-
*
|
|
83
|
+
* Generate basic openApi Response
|
|
84
84
|
*/
|
|
85
85
|
function generateResponse(route) {
|
|
86
86
|
if (route.openapi.responses === undefined) {
|
|
@@ -96,22 +96,20 @@ function generateResponse(route) {
|
|
|
96
96
|
*
|
|
97
97
|
* @returns {object} openApi object
|
|
98
98
|
*/
|
|
99
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
100
99
|
function generateOpenApi() {
|
|
101
|
-
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
102
100
|
const routes = [];
|
|
103
|
-
global.kuzzle.config.http.routes.forEach(
|
|
104
|
-
global.kuzzle.pluginsManager.routes.forEach(
|
|
101
|
+
global.kuzzle.config.http.routes.forEach(route => routes.push({ ...route }));
|
|
102
|
+
global.kuzzle.pluginsManager.routes.forEach(route => routes.push({ ...route }));
|
|
105
103
|
/* eslint-disable sort-keys */
|
|
106
104
|
const response = {
|
|
107
105
|
swagger: '2.0',
|
|
108
106
|
info: {
|
|
109
107
|
title: 'Kuzzle API',
|
|
110
|
-
description: '
|
|
108
|
+
description: 'Kuzzle HTTP API definition',
|
|
111
109
|
contact: {
|
|
112
110
|
name: 'Kuzzle team',
|
|
113
|
-
url: '
|
|
114
|
-
email: '
|
|
111
|
+
url: 'https://kuzzle.io',
|
|
112
|
+
email: 'support@kuzzle.io',
|
|
115
113
|
discord: 'http://join.discord.kuzzle.io'
|
|
116
114
|
},
|
|
117
115
|
license: {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { JSONObject } from 'kuzzle-sdk';
|
|
2
2
|
import { RequestInput } from './requestInput';
|
|
3
|
+
import { RequestResponse } from './requestResponse';
|
|
3
4
|
import { RequestContext } from './requestContext';
|
|
4
5
|
import { KuzzleError } from '../../kerror/errors';
|
|
5
6
|
import { Deprecation, User } from '../../types';
|
|
@@ -12,46 +13,47 @@ import { Deprecation, User } from '../../types';
|
|
|
12
13
|
*/
|
|
13
14
|
export declare class KuzzleRequest {
|
|
14
15
|
/**
|
|
15
|
-
*
|
|
16
|
+
* Request external ID (specified by "requestId" or random uuid)
|
|
16
17
|
*/
|
|
17
|
-
|
|
18
|
+
id: string;
|
|
19
|
+
constructor(data: any, options: any);
|
|
18
20
|
/**
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
* Request internal ID
|
|
22
|
+
*/
|
|
23
|
+
get internalId(): string;
|
|
22
24
|
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
* Deprecation warnings for the API action
|
|
26
|
+
*/
|
|
27
|
+
get deprecations(): Deprecation[] | void;
|
|
26
28
|
/**
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
* Request timestamp (in Epoch-micro)
|
|
30
|
+
*/
|
|
31
|
+
get timestamp(): number;
|
|
30
32
|
/**
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
* Request HTTP status
|
|
34
|
+
*/
|
|
35
|
+
get status(): number;
|
|
36
|
+
set status(i: number);
|
|
34
37
|
/**
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
* Request input
|
|
39
|
+
*/
|
|
40
|
+
get input(): RequestInput;
|
|
38
41
|
/**
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
* Request context
|
|
43
|
+
*/
|
|
44
|
+
get context(): RequestContext;
|
|
42
45
|
/**
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
* Request error
|
|
47
|
+
*/
|
|
48
|
+
get error(): KuzzleError | null;
|
|
46
49
|
/**
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
* Request result
|
|
51
|
+
*/
|
|
52
|
+
get result(): any | null;
|
|
50
53
|
/**
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
constructor(data: any, options: any);
|
|
54
|
+
* Request response
|
|
55
|
+
*/
|
|
56
|
+
get response(): RequestResponse;
|
|
55
57
|
/**
|
|
56
58
|
* Adds an error to the request, and sets the request's status to the error one.
|
|
57
59
|
*/
|
|
@@ -101,6 +103,38 @@ export declare class KuzzleRequest {
|
|
|
101
103
|
data: JSONObject;
|
|
102
104
|
options: JSONObject;
|
|
103
105
|
};
|
|
106
|
+
/**
|
|
107
|
+
* Return a POJO representing the request.
|
|
108
|
+
*
|
|
109
|
+
* This can be used to match Koncorde filter rather than the Request object
|
|
110
|
+
* because it has properties defined with invisible unicode characters.
|
|
111
|
+
*/
|
|
112
|
+
pojo(): {
|
|
113
|
+
context: {
|
|
114
|
+
connection: import("./requestContext").Connection;
|
|
115
|
+
token: import("../../types").Token;
|
|
116
|
+
user: User;
|
|
117
|
+
};
|
|
118
|
+
deprecations: void | Deprecation[];
|
|
119
|
+
error: KuzzleError;
|
|
120
|
+
id: string;
|
|
121
|
+
input: {
|
|
122
|
+
action: string;
|
|
123
|
+
args: JSONObject;
|
|
124
|
+
body: JSONObject;
|
|
125
|
+
controller: string;
|
|
126
|
+
jwt: string;
|
|
127
|
+
volatile: JSONObject;
|
|
128
|
+
};
|
|
129
|
+
internalId: string;
|
|
130
|
+
response: {
|
|
131
|
+
headers: JSONObject;
|
|
132
|
+
raw: boolean;
|
|
133
|
+
};
|
|
134
|
+
result: any;
|
|
135
|
+
status: number;
|
|
136
|
+
timestamp: number;
|
|
137
|
+
};
|
|
104
138
|
/**
|
|
105
139
|
* Returns the `lang` param of the request.
|
|
106
140
|
*
|
|
@@ -53,6 +53,17 @@ const kerror_1 = __importDefault(require("../../kerror"));
|
|
|
53
53
|
const assert = __importStar(require("../../util/assertType"));
|
|
54
54
|
const safeObject_1 = require("../../util/safeObject");
|
|
55
55
|
const assertionError = kerror_1.default.wrap('api', 'assert');
|
|
56
|
+
// private properties
|
|
57
|
+
// \u200b is a zero width space, used to masquerade console.log output
|
|
58
|
+
const _internalId = 'internalId\u200b';
|
|
59
|
+
const _status = 'status\u200b';
|
|
60
|
+
const _input = 'input\u200b';
|
|
61
|
+
const _error = 'error\u200b';
|
|
62
|
+
const _result = 'result\u200b';
|
|
63
|
+
const _context = 'context\u200b';
|
|
64
|
+
const _timestamp = 'timestamp\u200b';
|
|
65
|
+
const _response = 'response\u200b';
|
|
66
|
+
const _deprecations = 'deprecations\u200b';
|
|
56
67
|
/**
|
|
57
68
|
* The `KuzzleRequest` class represents a request being processed by Kuzzle.
|
|
58
69
|
*
|
|
@@ -62,21 +73,21 @@ const assertionError = kerror_1.default.wrap('api', 'assert');
|
|
|
62
73
|
*/
|
|
63
74
|
class KuzzleRequest {
|
|
64
75
|
constructor(data, options) {
|
|
65
|
-
this
|
|
66
|
-
this
|
|
67
|
-
this
|
|
68
|
-
this
|
|
69
|
-
this
|
|
70
|
-
this
|
|
71
|
-
this
|
|
72
|
-
this
|
|
76
|
+
this[_internalId] = (0, nanoid_1.nanoid)();
|
|
77
|
+
this[_status] = 102;
|
|
78
|
+
this[_input] = new requestInput_1.RequestInput(data);
|
|
79
|
+
this[_context] = new requestContext_1.RequestContext(options);
|
|
80
|
+
this[_error] = null;
|
|
81
|
+
this[_result] = null;
|
|
82
|
+
this[_response] = null;
|
|
83
|
+
this[_deprecations] = undefined;
|
|
73
84
|
// @deprecated - Backward compatibility with the RequestInput.headers
|
|
74
85
|
// property
|
|
75
|
-
this.
|
|
86
|
+
this[_input].headers = this[_context].connection.misc.headers;
|
|
76
87
|
this.id = data.requestId
|
|
77
88
|
? assert.assertString('requestId', data.requestId)
|
|
78
89
|
: (0, nanoid_1.nanoid)();
|
|
79
|
-
this
|
|
90
|
+
this[_timestamp] = data.timestamp || Date.now();
|
|
80
91
|
// handling provided options
|
|
81
92
|
if (options !== undefined && options !== null) {
|
|
82
93
|
if (typeof options !== 'object' || Array.isArray(options)) {
|
|
@@ -111,6 +122,67 @@ class KuzzleRequest {
|
|
|
111
122
|
this.status = options.status;
|
|
112
123
|
}
|
|
113
124
|
}
|
|
125
|
+
Object.seal(this);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Request internal ID
|
|
129
|
+
*/
|
|
130
|
+
get internalId() {
|
|
131
|
+
return this[_internalId];
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Deprecation warnings for the API action
|
|
135
|
+
*/
|
|
136
|
+
get deprecations() {
|
|
137
|
+
return this[_deprecations];
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Request timestamp (in Epoch-micro)
|
|
141
|
+
*/
|
|
142
|
+
get timestamp() {
|
|
143
|
+
return this[_timestamp];
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Request HTTP status
|
|
147
|
+
*/
|
|
148
|
+
get status() {
|
|
149
|
+
return this[_status];
|
|
150
|
+
}
|
|
151
|
+
set status(i) {
|
|
152
|
+
this[_status] = assert.assertInteger('status', i);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Request input
|
|
156
|
+
*/
|
|
157
|
+
get input() {
|
|
158
|
+
return this[_input];
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Request context
|
|
162
|
+
*/
|
|
163
|
+
get context() {
|
|
164
|
+
return this[_context];
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Request error
|
|
168
|
+
*/
|
|
169
|
+
get error() {
|
|
170
|
+
return this[_error];
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Request result
|
|
174
|
+
*/
|
|
175
|
+
get result() {
|
|
176
|
+
return this[_result];
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Request response
|
|
180
|
+
*/
|
|
181
|
+
get response() {
|
|
182
|
+
if (this[_response] === null) {
|
|
183
|
+
this[_response] = new requestResponse_1.RequestResponse(this);
|
|
184
|
+
}
|
|
185
|
+
return this[_response];
|
|
114
186
|
}
|
|
115
187
|
/**
|
|
116
188
|
* Adds an error to the request, and sets the request's status to the error one.
|
|
@@ -119,14 +191,14 @@ class KuzzleRequest {
|
|
|
119
191
|
if (!error || !(error instanceof Error)) {
|
|
120
192
|
throw new errors_1.InternalError('Cannot set non-error object as a request\'s error');
|
|
121
193
|
}
|
|
122
|
-
this
|
|
123
|
-
this.status = this.
|
|
194
|
+
this[_error] = error instanceof errors_1.KuzzleError ? error : new errors_1.InternalError(error);
|
|
195
|
+
this.status = this[_error].status;
|
|
124
196
|
}
|
|
125
197
|
/**
|
|
126
198
|
* Sets the request error to null and status to 200
|
|
127
199
|
*/
|
|
128
200
|
clearError() {
|
|
129
|
-
this
|
|
201
|
+
this[_error] = null;
|
|
130
202
|
this.status = 200;
|
|
131
203
|
}
|
|
132
204
|
/**
|
|
@@ -151,7 +223,7 @@ class KuzzleRequest {
|
|
|
151
223
|
if (options.raw !== undefined) {
|
|
152
224
|
this.response.raw = options.raw;
|
|
153
225
|
}
|
|
154
|
-
this
|
|
226
|
+
this[_result] = result;
|
|
155
227
|
}
|
|
156
228
|
/**
|
|
157
229
|
* Add a deprecation for a used component, this can be action/controller/parameters...
|
|
@@ -168,7 +240,7 @@ class KuzzleRequest {
|
|
|
168
240
|
version,
|
|
169
241
|
};
|
|
170
242
|
if (!this.deprecations) {
|
|
171
|
-
this
|
|
243
|
+
this[_deprecations] = [deprecation];
|
|
172
244
|
}
|
|
173
245
|
else {
|
|
174
246
|
this.deprecations.push(deprecation);
|
|
@@ -182,28 +254,62 @@ class KuzzleRequest {
|
|
|
182
254
|
serialize() {
|
|
183
255
|
const serialized = {
|
|
184
256
|
data: {
|
|
185
|
-
_id: this.
|
|
257
|
+
_id: this[_input].args._id,
|
|
258
|
+
action: this[_input].action,
|
|
259
|
+
body: this[_input].body,
|
|
260
|
+
collection: this[_input].args.collection,
|
|
261
|
+
controller: this[_input].controller,
|
|
262
|
+
index: this[_input].args.index,
|
|
263
|
+
jwt: this[_input].jwt,
|
|
264
|
+
requestId: this.id,
|
|
265
|
+
timestamp: this[_timestamp],
|
|
266
|
+
volatile: this[_input].volatile,
|
|
267
|
+
},
|
|
268
|
+
// @deprecated - duplicate of options.connection.misc.headers
|
|
269
|
+
headers: this[_input].headers,
|
|
270
|
+
options: {
|
|
271
|
+
error: this[_error],
|
|
272
|
+
result: this[_result],
|
|
273
|
+
status: this[_status],
|
|
274
|
+
},
|
|
275
|
+
};
|
|
276
|
+
Object.assign(serialized.data, this[_input].args);
|
|
277
|
+
Object.assign(serialized.options, this[_context].toJSON());
|
|
278
|
+
return serialized;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Return a POJO representing the request.
|
|
282
|
+
*
|
|
283
|
+
* This can be used to match Koncorde filter rather than the Request object
|
|
284
|
+
* because it has properties defined with invisible unicode characters.
|
|
285
|
+
*/
|
|
286
|
+
pojo() {
|
|
287
|
+
return {
|
|
288
|
+
context: {
|
|
289
|
+
connection: this.context.connection,
|
|
290
|
+
token: this.context.token,
|
|
291
|
+
user: this.context.user,
|
|
292
|
+
},
|
|
293
|
+
deprecations: this.deprecations,
|
|
294
|
+
error: this.error,
|
|
295
|
+
id: this.id,
|
|
296
|
+
input: {
|
|
186
297
|
action: this.input.action,
|
|
298
|
+
args: this.input.args,
|
|
187
299
|
body: this.input.body,
|
|
188
|
-
collection: this.input.args.collection,
|
|
189
300
|
controller: this.input.controller,
|
|
190
|
-
index: this.input.args.index,
|
|
191
301
|
jwt: this.input.jwt,
|
|
192
|
-
requestId: this.id,
|
|
193
|
-
timestamp: this.timestamp,
|
|
194
302
|
volatile: this.input.volatile,
|
|
195
303
|
},
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
result: this.result,
|
|
201
|
-
status: this.status,
|
|
304
|
+
internalId: this.internalId,
|
|
305
|
+
response: {
|
|
306
|
+
headers: this.response.headers,
|
|
307
|
+
raw: this.response.raw,
|
|
202
308
|
},
|
|
309
|
+
result: this.result,
|
|
310
|
+
status: this.status,
|
|
311
|
+
timestamp: this.timestamp,
|
|
203
312
|
};
|
|
204
|
-
Object.assign(serialized.data, this.input.args);
|
|
205
|
-
Object.assign(serialized.options, this.context.toJSON());
|
|
206
|
-
return serialized;
|
|
207
313
|
}
|
|
208
314
|
/**
|
|
209
315
|
* Returns the `lang` param of the request.
|
|
@@ -24,23 +24,26 @@ export declare type ContextMisc = {
|
|
|
24
24
|
* Information about the connection at the origin of the request.
|
|
25
25
|
*/
|
|
26
26
|
export declare class Connection {
|
|
27
|
+
constructor(connection: any);
|
|
27
28
|
/**
|
|
28
29
|
* Unique identifier of the user connection
|
|
29
30
|
*/
|
|
30
|
-
id: string;
|
|
31
|
+
set id(str: string);
|
|
32
|
+
get id(): string | null;
|
|
31
33
|
/**
|
|
32
34
|
* Network protocol name
|
|
33
35
|
*/
|
|
34
|
-
protocol: string;
|
|
36
|
+
set protocol(str: string);
|
|
37
|
+
get protocol(): string | null;
|
|
35
38
|
/**
|
|
36
39
|
* Chain of IP addresses, starting from the client
|
|
37
40
|
*/
|
|
38
|
-
ips: string[];
|
|
41
|
+
set ips(arr: string[]);
|
|
42
|
+
get ips(): string[];
|
|
39
43
|
/**
|
|
40
44
|
* Additional informations about the connection
|
|
41
45
|
*/
|
|
42
|
-
misc: ContextMisc;
|
|
43
|
-
constructor(connection: any);
|
|
46
|
+
get misc(): ContextMisc;
|
|
44
47
|
/**
|
|
45
48
|
* Serializes the Connection object
|
|
46
49
|
*/
|
|
@@ -53,18 +56,6 @@ export declare class Connection {
|
|
|
53
56
|
* and origin (connection, protocol).
|
|
54
57
|
*/
|
|
55
58
|
export declare class RequestContext {
|
|
56
|
-
/**
|
|
57
|
-
* Connection that initiated the request
|
|
58
|
-
*/
|
|
59
|
-
connection: Connection;
|
|
60
|
-
/**
|
|
61
|
-
* Authentication token
|
|
62
|
-
*/
|
|
63
|
-
token: Token | null;
|
|
64
|
-
/**
|
|
65
|
-
* Associated user
|
|
66
|
-
*/
|
|
67
|
-
user: User | null;
|
|
68
59
|
constructor(options?: any);
|
|
69
60
|
/**
|
|
70
61
|
* Serializes the RequestContext object
|
|
@@ -81,4 +72,18 @@ export declare class RequestContext {
|
|
|
81
72
|
*/
|
|
82
73
|
get protocol(): string | null;
|
|
83
74
|
set protocol(str: string);
|
|
75
|
+
/**
|
|
76
|
+
* Connection that initiated the request
|
|
77
|
+
*/
|
|
78
|
+
get connection(): Connection;
|
|
79
|
+
/**
|
|
80
|
+
* Authentication token
|
|
81
|
+
*/
|
|
82
|
+
get token(): Token | null;
|
|
83
|
+
set token(obj: Token | null);
|
|
84
|
+
/**
|
|
85
|
+
* Associated user
|
|
86
|
+
*/
|
|
87
|
+
get user(): User | null;
|
|
88
|
+
set user(obj: User | null);
|
|
84
89
|
}
|