kuzzle 2.16.2 → 2.16.3
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/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/plugin/pluginsManager.js +1 -3
- package/lib/kuzzle/kuzzle.js +5 -9
- package/package-lock.json +1 -1
- package/package.json +1 -1
|
@@ -7,19 +7,16 @@ export declare class RequestResource {
|
|
|
7
7
|
constructor(args: JSONObject);
|
|
8
8
|
/**
|
|
9
9
|
* Document ID
|
|
10
|
-
* @deprecated
|
|
11
10
|
*/
|
|
12
11
|
get _id(): string | null;
|
|
13
12
|
set _id(str: string);
|
|
14
13
|
/**
|
|
15
14
|
* Index name
|
|
16
|
-
* @deprecated
|
|
17
15
|
*/
|
|
18
16
|
get index(): string | null;
|
|
19
17
|
set index(str: string);
|
|
20
18
|
/**
|
|
21
19
|
* Collection name
|
|
22
|
-
* @deprecated
|
|
23
20
|
*/
|
|
24
21
|
get collection(): string | null;
|
|
25
22
|
set collection(str: string);
|
|
@@ -55,7 +52,7 @@ export declare class RequestInput {
|
|
|
55
52
|
/**
|
|
56
53
|
* Common arguments that identify Kuzzle resources.
|
|
57
54
|
* (e.g: "_id", "index", "collection")
|
|
58
|
-
* @deprecated Use`request.
|
|
55
|
+
* @deprecated Use directly`request.input.args.<_id|index|collection>` instead
|
|
59
56
|
* @example
|
|
60
57
|
* // original JSON request sent to Kuzzle
|
|
61
58
|
* {
|
|
@@ -72,6 +69,15 @@ export declare class RequestInput {
|
|
|
72
69
|
* }
|
|
73
70
|
*/
|
|
74
71
|
resource: RequestResource;
|
|
72
|
+
/**
|
|
73
|
+
* Builds a Kuzzle normalized request input object
|
|
74
|
+
*
|
|
75
|
+
* The 'data' object accepts a request content using the same
|
|
76
|
+
* format as the one used, for instance, for the Websocket protocol
|
|
77
|
+
*
|
|
78
|
+
* Any undefined option is set to null
|
|
79
|
+
*/
|
|
80
|
+
constructor(data: any);
|
|
75
81
|
/**
|
|
76
82
|
* Authentication token.
|
|
77
83
|
* @example
|
|
@@ -89,7 +95,8 @@ export declare class RequestInput {
|
|
|
89
95
|
* body
|
|
90
96
|
* }
|
|
91
97
|
*/
|
|
92
|
-
jwt: string | null;
|
|
98
|
+
get jwt(): string | null;
|
|
99
|
+
set jwt(str: string);
|
|
93
100
|
/**
|
|
94
101
|
* API controller name.
|
|
95
102
|
* @example
|
|
@@ -107,7 +114,8 @@ export declare class RequestInput {
|
|
|
107
114
|
* body
|
|
108
115
|
* }
|
|
109
116
|
*/
|
|
110
|
-
controller: string | null;
|
|
117
|
+
get controller(): string | null;
|
|
118
|
+
set controller(str: string);
|
|
111
119
|
/**
|
|
112
120
|
* API action name.
|
|
113
121
|
* @example
|
|
@@ -125,7 +133,8 @@ export declare class RequestInput {
|
|
|
125
133
|
* body
|
|
126
134
|
* }
|
|
127
135
|
*/
|
|
128
|
-
action: string | null;
|
|
136
|
+
get action(): string | null;
|
|
137
|
+
set action(str: string);
|
|
129
138
|
/**
|
|
130
139
|
* Request body.
|
|
131
140
|
* In Http it's the request body parsed.
|
|
@@ -144,11 +153,15 @@ export declare class RequestInput {
|
|
|
144
153
|
* body <== that
|
|
145
154
|
* }
|
|
146
155
|
*/
|
|
147
|
-
body: JSONObject | null;
|
|
156
|
+
get body(): JSONObject | null;
|
|
157
|
+
set body(obj: JSONObject);
|
|
148
158
|
/**
|
|
149
159
|
* Request headers (Http only).
|
|
160
|
+
*
|
|
161
|
+
* @deprecated Use RequestContext.connection.misc.headers instead
|
|
150
162
|
*/
|
|
151
|
-
headers: JSONObject | null;
|
|
163
|
+
get headers(): JSONObject | null;
|
|
164
|
+
set headers(obj: JSONObject);
|
|
152
165
|
/**
|
|
153
166
|
* Volatile object.
|
|
154
167
|
* @example
|
|
@@ -166,14 +179,6 @@ export declare class RequestInput {
|
|
|
166
179
|
* body
|
|
167
180
|
* }
|
|
168
181
|
*/
|
|
169
|
-
volatile: JSONObject | null;
|
|
170
|
-
|
|
171
|
-
* Builds a Kuzzle normalized request input object
|
|
172
|
-
*
|
|
173
|
-
* The 'data' object accepts a request content using the same
|
|
174
|
-
* format as the one used, for instance, for the Websocket protocol
|
|
175
|
-
*
|
|
176
|
-
* Any undefined option is set to null
|
|
177
|
-
*/
|
|
178
|
-
constructor(data: any);
|
|
182
|
+
get volatile(): JSONObject | null;
|
|
183
|
+
set volatile(obj: JSONObject);
|
|
179
184
|
}
|
|
@@ -19,13 +19,37 @@
|
|
|
19
19
|
* See the License for the specific language governing permissions and
|
|
20
20
|
* limitations under the License.
|
|
21
21
|
*/
|
|
22
|
-
var
|
|
23
|
-
|
|
22
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
23
|
+
if (k2 === undefined) k2 = k;
|
|
24
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
25
|
+
}) : (function(o, m, k, k2) {
|
|
26
|
+
if (k2 === undefined) k2 = k;
|
|
27
|
+
o[k2] = m[k];
|
|
28
|
+
}));
|
|
29
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
30
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
31
|
+
}) : function(o, v) {
|
|
32
|
+
o["default"] = v;
|
|
33
|
+
});
|
|
34
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
35
|
+
if (mod && mod.__esModule) return mod;
|
|
36
|
+
var result = {};
|
|
37
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
38
|
+
__setModuleDefault(result, mod);
|
|
39
|
+
return result;
|
|
24
40
|
};
|
|
25
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
42
|
exports.RequestInput = exports.RequestResource = void 0;
|
|
27
43
|
const internalError_1 = require("../../kerror/errors/internalError");
|
|
28
|
-
const
|
|
44
|
+
const assert = __importStar(require("../../util/assertType"));
|
|
45
|
+
// private properties
|
|
46
|
+
// \u200b is a zero width space, used to masquerade console.log output
|
|
47
|
+
const _jwt = 'jwt\u200b';
|
|
48
|
+
const _volatile = 'volatile\u200b';
|
|
49
|
+
const _body = 'body\u200b';
|
|
50
|
+
const _headers = 'headers\u200b';
|
|
51
|
+
const _controller = 'controller\u200b';
|
|
52
|
+
const _action = 'action\u200b';
|
|
29
53
|
// any property not listed here will be copied into
|
|
30
54
|
// RequestInput.args
|
|
31
55
|
const resourceProperties = new Set([
|
|
@@ -44,7 +68,6 @@ class RequestResource {
|
|
|
44
68
|
}
|
|
45
69
|
/**
|
|
46
70
|
* Document ID
|
|
47
|
-
* @deprecated
|
|
48
71
|
*/
|
|
49
72
|
get _id() {
|
|
50
73
|
return this.args._id;
|
|
@@ -54,7 +77,6 @@ class RequestResource {
|
|
|
54
77
|
}
|
|
55
78
|
/**
|
|
56
79
|
* Index name
|
|
57
|
-
* @deprecated
|
|
58
80
|
*/
|
|
59
81
|
get index() {
|
|
60
82
|
return this.args.index;
|
|
@@ -64,7 +86,6 @@ class RequestResource {
|
|
|
64
86
|
}
|
|
65
87
|
/**
|
|
66
88
|
* Collection name
|
|
67
|
-
* @deprecated
|
|
68
89
|
*/
|
|
69
90
|
get collection() {
|
|
70
91
|
return this.args.collection;
|
|
@@ -93,109 +114,14 @@ class RequestInput {
|
|
|
93
114
|
* Any undefined option is set to null
|
|
94
115
|
*/
|
|
95
116
|
constructor(data) {
|
|
96
|
-
/**
|
|
97
|
-
* Authentication token.
|
|
98
|
-
* @example
|
|
99
|
-
* // original JSON request sent to Kuzzle
|
|
100
|
-
* {
|
|
101
|
-
* controller
|
|
102
|
-
* action,
|
|
103
|
-
* _id,
|
|
104
|
-
* index,
|
|
105
|
-
* collection,
|
|
106
|
-
* jwt, <== that
|
|
107
|
-
* refresh,
|
|
108
|
-
* foobar,
|
|
109
|
-
* volatile,
|
|
110
|
-
* body
|
|
111
|
-
* }
|
|
112
|
-
*/
|
|
113
|
-
this.jwt = null;
|
|
114
|
-
/**
|
|
115
|
-
* API controller name.
|
|
116
|
-
* @example
|
|
117
|
-
* // original JSON request sent to Kuzzle
|
|
118
|
-
* {
|
|
119
|
-
* controller <== that
|
|
120
|
-
* action,
|
|
121
|
-
* _id,
|
|
122
|
-
* index,
|
|
123
|
-
* collection,
|
|
124
|
-
* jwt,
|
|
125
|
-
* refresh,
|
|
126
|
-
* foobar,
|
|
127
|
-
* volatile,
|
|
128
|
-
* body
|
|
129
|
-
* }
|
|
130
|
-
*/
|
|
131
|
-
this.controller = null;
|
|
132
|
-
/**
|
|
133
|
-
* API action name.
|
|
134
|
-
* @example
|
|
135
|
-
* // original JSON request sent to Kuzzle
|
|
136
|
-
* {
|
|
137
|
-
* controller
|
|
138
|
-
* action, <== that
|
|
139
|
-
* _id,
|
|
140
|
-
* index,
|
|
141
|
-
* collection,
|
|
142
|
-
* jwt,
|
|
143
|
-
* refresh,
|
|
144
|
-
* foobar,
|
|
145
|
-
* volatile,
|
|
146
|
-
* body
|
|
147
|
-
* }
|
|
148
|
-
*/
|
|
149
|
-
this.action = null;
|
|
150
|
-
/**
|
|
151
|
-
* Request body.
|
|
152
|
-
* In Http it's the request body parsed.
|
|
153
|
-
* @example
|
|
154
|
-
* // original JSON request sent to Kuzzle
|
|
155
|
-
* {
|
|
156
|
-
* controller
|
|
157
|
-
* action,
|
|
158
|
-
* _id,
|
|
159
|
-
* index,
|
|
160
|
-
* collection,
|
|
161
|
-
* jwt,
|
|
162
|
-
* refresh,
|
|
163
|
-
* foobar,
|
|
164
|
-
* volatile,
|
|
165
|
-
* body <== that
|
|
166
|
-
* }
|
|
167
|
-
*/
|
|
168
|
-
this.body = {};
|
|
169
|
-
/**
|
|
170
|
-
* Request headers (Http only).
|
|
171
|
-
*/
|
|
172
|
-
this.headers = null;
|
|
173
|
-
/**
|
|
174
|
-
* Volatile object.
|
|
175
|
-
* @example
|
|
176
|
-
* // original JSON request sent to Kuzzle
|
|
177
|
-
* {
|
|
178
|
-
* controller
|
|
179
|
-
* action,
|
|
180
|
-
* _id,
|
|
181
|
-
* index,
|
|
182
|
-
* collection,
|
|
183
|
-
* jwt,
|
|
184
|
-
* refresh,
|
|
185
|
-
* foobar,
|
|
186
|
-
* volatile, <== that
|
|
187
|
-
* body
|
|
188
|
-
* }
|
|
189
|
-
*/
|
|
190
|
-
this.volatile = null;
|
|
191
117
|
if (!data || typeof data !== 'object' || Array.isArray(data)) {
|
|
192
118
|
throw new internalError_1.InternalError('Input request data must be a non-null object');
|
|
193
119
|
}
|
|
194
|
-
this
|
|
195
|
-
this
|
|
196
|
-
this
|
|
197
|
-
this
|
|
198
|
-
this
|
|
120
|
+
this[_jwt] = null;
|
|
121
|
+
this[_volatile] = null;
|
|
122
|
+
this[_body] = null;
|
|
123
|
+
this[_controller] = null;
|
|
124
|
+
this[_action] = null;
|
|
199
125
|
// default value to null for former "resources" to avoid breaking
|
|
200
126
|
this.args = {};
|
|
201
127
|
this.resource = new RequestResource(this.args);
|
|
@@ -205,17 +131,151 @@ class RequestInput {
|
|
|
205
131
|
this.args[k] = data[k];
|
|
206
132
|
}
|
|
207
133
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
134
|
+
// @deprecated - RequestContext.connection.misc.headers should be used instead
|
|
135
|
+
// initialize `_headers` property after the population of `this.args` attribute
|
|
136
|
+
// `this.headers` can contain protocol specific headers and should be
|
|
137
|
+
// set after the Request construction
|
|
138
|
+
// `args.headers` can be an attribute coming from data itself.
|
|
139
|
+
this[_headers] = null;
|
|
140
|
+
Object.seal(this);
|
|
141
|
+
this.jwt = data.jwt;
|
|
142
|
+
this.volatile = data.volatile;
|
|
143
|
+
this.body = data.body;
|
|
144
|
+
this.controller = data.controller;
|
|
145
|
+
this.action = data.action;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Authentication token.
|
|
149
|
+
* @example
|
|
150
|
+
* // original JSON request sent to Kuzzle
|
|
151
|
+
* {
|
|
152
|
+
* controller
|
|
153
|
+
* action,
|
|
154
|
+
* _id,
|
|
155
|
+
* index,
|
|
156
|
+
* collection,
|
|
157
|
+
* jwt, <== that
|
|
158
|
+
* refresh,
|
|
159
|
+
* foobar,
|
|
160
|
+
* volatile,
|
|
161
|
+
* body
|
|
162
|
+
* }
|
|
163
|
+
*/
|
|
164
|
+
get jwt() {
|
|
165
|
+
return this[_jwt];
|
|
166
|
+
}
|
|
167
|
+
set jwt(str) {
|
|
168
|
+
this[_jwt] = assert.assertString('jwt', str);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* API controller name.
|
|
172
|
+
* @example
|
|
173
|
+
* // original JSON request sent to Kuzzle
|
|
174
|
+
* {
|
|
175
|
+
* controller <== that
|
|
176
|
+
* action,
|
|
177
|
+
* _id,
|
|
178
|
+
* index,
|
|
179
|
+
* collection,
|
|
180
|
+
* jwt,
|
|
181
|
+
* refresh,
|
|
182
|
+
* foobar,
|
|
183
|
+
* volatile,
|
|
184
|
+
* body
|
|
185
|
+
* }
|
|
186
|
+
*/
|
|
187
|
+
get controller() {
|
|
188
|
+
return this[_controller];
|
|
189
|
+
}
|
|
190
|
+
set controller(str) {
|
|
191
|
+
// can only be set once
|
|
192
|
+
if (!this[_controller]) {
|
|
193
|
+
this[_controller] = assert.assertString('controller', str);
|
|
213
194
|
}
|
|
214
|
-
|
|
215
|
-
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* API action name.
|
|
198
|
+
* @example
|
|
199
|
+
* // original JSON request sent to Kuzzle
|
|
200
|
+
* {
|
|
201
|
+
* controller
|
|
202
|
+
* action, <== that
|
|
203
|
+
* _id,
|
|
204
|
+
* index,
|
|
205
|
+
* collection,
|
|
206
|
+
* jwt,
|
|
207
|
+
* refresh,
|
|
208
|
+
* foobar,
|
|
209
|
+
* volatile,
|
|
210
|
+
* body
|
|
211
|
+
* }
|
|
212
|
+
*/
|
|
213
|
+
get action() {
|
|
214
|
+
return this[_action];
|
|
215
|
+
}
|
|
216
|
+
set action(str) {
|
|
217
|
+
// can only be set once
|
|
218
|
+
if (!this[_action]) {
|
|
219
|
+
this[_action] = assert.assertString('action', str);
|
|
216
220
|
}
|
|
217
|
-
|
|
218
|
-
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Request body.
|
|
224
|
+
* In Http it's the request body parsed.
|
|
225
|
+
* @example
|
|
226
|
+
* // original JSON request sent to Kuzzle
|
|
227
|
+
* {
|
|
228
|
+
* controller
|
|
229
|
+
* action,
|
|
230
|
+
* _id,
|
|
231
|
+
* index,
|
|
232
|
+
* collection,
|
|
233
|
+
* jwt,
|
|
234
|
+
* refresh,
|
|
235
|
+
* foobar,
|
|
236
|
+
* volatile,
|
|
237
|
+
* body <== that
|
|
238
|
+
* }
|
|
239
|
+
*/
|
|
240
|
+
get body() {
|
|
241
|
+
return this[_body];
|
|
242
|
+
}
|
|
243
|
+
set body(obj) {
|
|
244
|
+
this[_body] = assert.assertObject('body', obj);
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Request headers (Http only).
|
|
248
|
+
*
|
|
249
|
+
* @deprecated Use RequestContext.connection.misc.headers instead
|
|
250
|
+
*/
|
|
251
|
+
get headers() {
|
|
252
|
+
return this[_headers];
|
|
253
|
+
}
|
|
254
|
+
set headers(obj) {
|
|
255
|
+
this[_headers] = assert.assertObject('headers', obj);
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Volatile object.
|
|
259
|
+
* @example
|
|
260
|
+
* // original JSON request sent to Kuzzle
|
|
261
|
+
* {
|
|
262
|
+
* controller
|
|
263
|
+
* action,
|
|
264
|
+
* _id,
|
|
265
|
+
* index,
|
|
266
|
+
* collection,
|
|
267
|
+
* jwt,
|
|
268
|
+
* refresh,
|
|
269
|
+
* foobar,
|
|
270
|
+
* volatile, <== that
|
|
271
|
+
* body
|
|
272
|
+
* }
|
|
273
|
+
*/
|
|
274
|
+
get volatile() {
|
|
275
|
+
return this[_volatile];
|
|
276
|
+
}
|
|
277
|
+
set volatile(obj) {
|
|
278
|
+
this[_volatile] = assert.assertObject('volatile', obj);
|
|
219
279
|
}
|
|
220
280
|
}
|
|
221
281
|
exports.RequestInput = RequestInput;
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import { JSONObject } from 'kuzzle-sdk';
|
|
2
|
-
import '../../../lib/types/Global';
|
|
3
2
|
import { Deprecation } from '../../types';
|
|
4
3
|
import { KuzzleError } from '../../kerror/errors/kuzzleError';
|
|
5
|
-
import { KuzzleRequest } from './kuzzleRequest';
|
|
6
4
|
export declare class Headers {
|
|
7
5
|
headers: JSONObject;
|
|
8
6
|
private namesMap;
|
|
9
|
-
proxy
|
|
7
|
+
private proxy;
|
|
10
8
|
constructor();
|
|
11
9
|
/**
|
|
12
10
|
* Gets a header value
|
|
13
11
|
*
|
|
14
12
|
* @param name Header name. Could be a string (case-insensitive) or a symbol
|
|
15
13
|
*/
|
|
16
|
-
getHeader(name: any): string;
|
|
14
|
+
getHeader(name: any): string | void;
|
|
17
15
|
removeHeader(name: string): boolean;
|
|
18
16
|
setHeader(name: string, value: string): boolean;
|
|
19
17
|
}
|
|
@@ -21,22 +19,20 @@ export declare class Headers {
|
|
|
21
19
|
* Kuzzle normalized API response
|
|
22
20
|
*/
|
|
23
21
|
export declare class RequestResponse {
|
|
24
|
-
private request;
|
|
25
|
-
private _headers;
|
|
26
22
|
/**
|
|
27
23
|
* If sets to true, "result" content will not be wrapped in a Kuzzle response
|
|
28
24
|
*/
|
|
29
25
|
raw: boolean;
|
|
30
|
-
constructor(request:
|
|
26
|
+
constructor(request: any);
|
|
31
27
|
/**
|
|
32
28
|
* Get the parent request deprecations
|
|
33
29
|
*/
|
|
34
|
-
get deprecations(): Array<Deprecation
|
|
30
|
+
get deprecations(): Array<Deprecation> | void;
|
|
35
31
|
/**
|
|
36
32
|
* Set the parent request deprecations
|
|
37
33
|
* @param {Object[]} deprecations
|
|
38
34
|
*/
|
|
39
|
-
set deprecations(deprecations: Array<Deprecation>);
|
|
35
|
+
set deprecations(deprecations: Array<Deprecation> | void);
|
|
40
36
|
/**
|
|
41
37
|
* Get the parent request status
|
|
42
38
|
* @returns {number}
|
|
@@ -103,16 +99,16 @@ export declare class RequestResponse {
|
|
|
103
99
|
/**
|
|
104
100
|
* Gets a header value (case-insensitive)
|
|
105
101
|
*/
|
|
106
|
-
getHeader(name: string): string;
|
|
102
|
+
getHeader(name: string): string | null;
|
|
107
103
|
/**
|
|
108
104
|
* Deletes a header (case-insensitive)
|
|
109
105
|
*/
|
|
110
|
-
removeHeader(name: string):
|
|
106
|
+
removeHeader(name: string): any;
|
|
111
107
|
/**
|
|
112
108
|
* Sets a new array. Behaves the same as Node.js' HTTP response.setHeader
|
|
113
109
|
* method (@see https://nodejs.org/api/http.html#http_response_setheader_name_value)
|
|
114
110
|
*/
|
|
115
|
-
setHeader(name: string, value: string):
|
|
111
|
+
setHeader(name: string, value: string): any;
|
|
116
112
|
/**
|
|
117
113
|
* Adds new multiple headers.
|
|
118
114
|
*/
|
|
@@ -40,8 +40,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
40
40
|
};
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
42
|
exports.RequestResponse = exports.Headers = void 0;
|
|
43
|
-
require("../../../lib/types/Global");
|
|
44
43
|
const assert = __importStar(require("../../util/assertType"));
|
|
44
|
+
// private properties
|
|
45
|
+
// \u200b is a zero width space, used to masquerade console.log output
|
|
46
|
+
const _request = 'request\u200b';
|
|
47
|
+
const _headers = 'headers\u200b';
|
|
45
48
|
class Headers {
|
|
46
49
|
constructor() {
|
|
47
50
|
this.namesMap = new Map();
|
|
@@ -51,10 +54,7 @@ class Headers {
|
|
|
51
54
|
get: (target, name) => this.getHeader(name),
|
|
52
55
|
set: (target, name, value) => this.setHeader(name, value),
|
|
53
56
|
});
|
|
54
|
-
|
|
55
|
-
if (global['_kuzzle'] && global.kuzzle) {
|
|
56
|
-
this.setHeader('X-Kuzzle-Node', global.kuzzle.id);
|
|
57
|
-
}
|
|
57
|
+
this.setHeader('X-Kuzzle-Node', global.kuzzle.id);
|
|
58
58
|
}
|
|
59
59
|
/**
|
|
60
60
|
* Gets a header value
|
|
@@ -144,104 +144,98 @@ exports.Headers = Headers;
|
|
|
144
144
|
class RequestResponse {
|
|
145
145
|
constructor(request) {
|
|
146
146
|
this.raw = false;
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
});
|
|
151
|
-
this._headers = new Headers();
|
|
147
|
+
this[_request] = request;
|
|
148
|
+
this[_headers] = new Headers();
|
|
149
|
+
Object.seal(this);
|
|
152
150
|
}
|
|
153
151
|
/**
|
|
154
152
|
* Get the parent request deprecations
|
|
155
153
|
*/
|
|
156
154
|
get deprecations() {
|
|
157
|
-
return this.
|
|
155
|
+
return this[_request].deprecations;
|
|
158
156
|
}
|
|
159
157
|
/**
|
|
160
158
|
* Set the parent request deprecations
|
|
161
159
|
* @param {Object[]} deprecations
|
|
162
160
|
*/
|
|
163
161
|
set deprecations(deprecations) {
|
|
164
|
-
this.
|
|
162
|
+
this[_request].deprecations = deprecations;
|
|
165
163
|
}
|
|
166
164
|
/**
|
|
167
165
|
* Get the parent request status
|
|
168
166
|
* @returns {number}
|
|
169
167
|
*/
|
|
170
168
|
get status() {
|
|
171
|
-
return this.
|
|
169
|
+
return this[_request].status;
|
|
172
170
|
}
|
|
173
171
|
set status(s) {
|
|
174
|
-
this.
|
|
172
|
+
this[_request].status = s;
|
|
175
173
|
}
|
|
176
174
|
/**
|
|
177
175
|
* Request error
|
|
178
176
|
*/
|
|
179
177
|
get error() {
|
|
180
|
-
return this.
|
|
178
|
+
return this[_request].error;
|
|
181
179
|
}
|
|
182
180
|
set error(e) {
|
|
183
|
-
this.
|
|
181
|
+
this[_request].setError(e);
|
|
184
182
|
}
|
|
185
183
|
/**
|
|
186
184
|
* Request external ID
|
|
187
185
|
*/
|
|
188
186
|
get requestId() {
|
|
189
|
-
return this.
|
|
187
|
+
return this[_request].id;
|
|
190
188
|
}
|
|
191
189
|
/**
|
|
192
190
|
* API controller name
|
|
193
191
|
*/
|
|
194
192
|
get controller() {
|
|
195
|
-
return this.
|
|
193
|
+
return this[_request].input.controller;
|
|
196
194
|
}
|
|
197
195
|
/**
|
|
198
196
|
* API action name
|
|
199
197
|
*/
|
|
200
198
|
get action() {
|
|
201
|
-
return this.
|
|
199
|
+
return this[_request].input.action;
|
|
202
200
|
}
|
|
203
201
|
/**
|
|
204
202
|
* Collection name
|
|
205
203
|
*/
|
|
206
204
|
get collection() {
|
|
207
|
-
return this.
|
|
205
|
+
return this[_request].input.resource.collection;
|
|
208
206
|
}
|
|
209
207
|
/**
|
|
210
208
|
* Index name
|
|
211
209
|
*/
|
|
212
210
|
get index() {
|
|
213
|
-
return this.
|
|
211
|
+
return this[_request].input.resource.index;
|
|
214
212
|
}
|
|
215
213
|
/**
|
|
216
214
|
* Volatile object
|
|
217
215
|
*/
|
|
218
216
|
get volatile() {
|
|
219
|
-
return this.
|
|
217
|
+
return this[_request].input.volatile;
|
|
220
218
|
}
|
|
221
219
|
/**
|
|
222
220
|
* Response headers
|
|
223
221
|
*/
|
|
224
222
|
get headers() {
|
|
225
|
-
return this
|
|
223
|
+
return this[_headers].proxy;
|
|
226
224
|
}
|
|
227
225
|
/**
|
|
228
226
|
* Request result
|
|
229
227
|
*/
|
|
230
228
|
get result() {
|
|
231
|
-
return this.
|
|
229
|
+
return this[_request].result;
|
|
232
230
|
}
|
|
233
231
|
set result(r) {
|
|
234
|
-
this.
|
|
232
|
+
this[_request].setResult(r);
|
|
235
233
|
}
|
|
236
234
|
/**
|
|
237
235
|
* Node identifier
|
|
238
236
|
*/
|
|
239
237
|
get node() {
|
|
240
|
-
|
|
241
|
-
if (global['_kuzzle'] && global.kuzzle) {
|
|
242
|
-
return global.kuzzle.id;
|
|
243
|
-
}
|
|
244
|
-
return null;
|
|
238
|
+
return global.kuzzle.id;
|
|
245
239
|
}
|
|
246
240
|
/**
|
|
247
241
|
* Configure the response
|
|
@@ -271,20 +265,20 @@ class RequestResponse {
|
|
|
271
265
|
* Gets a header value (case-insensitive)
|
|
272
266
|
*/
|
|
273
267
|
getHeader(name) {
|
|
274
|
-
return this
|
|
268
|
+
return this[_headers].getHeader(name);
|
|
275
269
|
}
|
|
276
270
|
/**
|
|
277
271
|
* Deletes a header (case-insensitive)
|
|
278
272
|
*/
|
|
279
273
|
removeHeader(name) {
|
|
280
|
-
return this
|
|
274
|
+
return this[_headers].removeHeader(name);
|
|
281
275
|
}
|
|
282
276
|
/**
|
|
283
277
|
* Sets a new array. Behaves the same as Node.js' HTTP response.setHeader
|
|
284
278
|
* method (@see https://nodejs.org/api/http.html#http_response_setheader_name_value)
|
|
285
279
|
*/
|
|
286
280
|
setHeader(name, value) {
|
|
287
|
-
return this
|
|
281
|
+
return this[_headers].setHeader(name, value);
|
|
288
282
|
}
|
|
289
283
|
/**
|
|
290
284
|
* Adds new multiple headers.
|
|
@@ -307,7 +301,7 @@ class RequestResponse {
|
|
|
307
301
|
if (this.raw === true) {
|
|
308
302
|
return {
|
|
309
303
|
content: this.result,
|
|
310
|
-
headers: this.
|
|
304
|
+
headers: this.headers,
|
|
311
305
|
raw: true,
|
|
312
306
|
requestId: this.requestId,
|
|
313
307
|
status: this.status,
|
|
@@ -327,7 +321,7 @@ class RequestResponse {
|
|
|
327
321
|
status: this.status,
|
|
328
322
|
volatile: this.volatile,
|
|
329
323
|
},
|
|
330
|
-
headers: this.
|
|
324
|
+
headers: this.headers,
|
|
331
325
|
raw: false,
|
|
332
326
|
requestId: this.requestId,
|
|
333
327
|
status: this.status,
|