kuzzle 2.18.0 → 2.19.1

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.
Files changed (47) hide show
  1. package/index.d.ts +1 -0
  2. package/index.js +3 -0
  3. package/lib/api/controllers/adminController.js +9 -0
  4. package/lib/api/controllers/authController.js +2 -1
  5. package/lib/api/controllers/debugController.d.ts +59 -0
  6. package/lib/api/controllers/debugController.js +285 -0
  7. package/lib/api/controllers/documentController.js +49 -31
  8. package/lib/api/controllers/index.js +1 -0
  9. package/lib/api/controllers/securityController.js +28 -22
  10. package/lib/api/controllers/serverController.js +2 -1
  11. package/lib/api/documentExtractor.js +51 -9
  12. package/lib/api/funnel.js +30 -8
  13. package/lib/api/httpRoutes.js +6 -0
  14. package/lib/api/request/kuzzleRequest.d.ts +37 -4
  15. package/lib/api/request/kuzzleRequest.js +115 -29
  16. package/lib/api/request/requestResponse.js +25 -0
  17. package/lib/cluster/idCardHandler.js +1 -1
  18. package/lib/config/default.config.js +3 -0
  19. package/lib/config/documentEventAliases.d.ts +7 -0
  20. package/lib/config/documentEventAliases.js +26 -12
  21. package/lib/core/backend/backend.d.ts +4 -0
  22. package/lib/core/backend/backend.js +9 -0
  23. package/lib/core/backend/backendController.d.ts +7 -1
  24. package/lib/core/backend/backendController.js +15 -3
  25. package/lib/core/network/protocols/httpwsProtocol.js +14 -6
  26. package/lib/core/plugin/plugin.js +7 -0
  27. package/lib/core/shared/sdk/embeddedSdk.d.ts +1 -1
  28. package/lib/core/shared/sdk/embeddedSdk.js +33 -0
  29. package/lib/kerror/codes/0-core.json +35 -0
  30. package/lib/kerror/codes/2-api.json +6 -0
  31. package/lib/kuzzle/kuzzle.d.ts +1 -1
  32. package/lib/kuzzle/kuzzle.js +27 -8
  33. package/lib/model/storage/apiKey.js +1 -6
  34. package/lib/service/storage/elasticsearch.js +40 -13
  35. package/lib/types/DebugModule.d.ts +23 -0
  36. package/lib/types/DebugModule.js +39 -0
  37. package/lib/types/config/SecurityConfiguration.d.ts +10 -0
  38. package/lib/util/crypto.d.ts +1 -0
  39. package/lib/util/crypto.js +12 -0
  40. package/lib/util/name-generator.d.ts +79 -0
  41. package/lib/util/name-generator.js +1409 -1345
  42. package/lib/util/time.d.ts +1 -0
  43. package/lib/util/time.js +9 -0
  44. package/package.json +4 -6
  45. package/lib/core/security/README.md +0 -224
  46. package/lib/core/shared/README.md +0 -3
  47. package/package-lock.json +0 -8422
@@ -32,12 +32,17 @@ const formatProcessing = require('../../core/auth/formatProcessing');
32
32
  const ApiKey = require('../../model/storage/apiKey');
33
33
  const kerror = require('../../kerror');
34
34
  const { has } = require('../../util/safeObject');
35
- const { generateRandomName } = require('../../util/name-generator');
35
+ const { NameGenerator } = require('../../util/name-generator');
36
36
 
37
37
  /**
38
38
  * @class SecurityController
39
39
  */
40
40
  class SecurityController extends NativeController {
41
+
42
+ static userOrSdk (userId) {
43
+ return userId === null ? 'EmbeddedSDK' : `User "${userId}"`;
44
+ }
45
+
41
46
  constructor () {
42
47
  super([
43
48
  'checkRights',
@@ -150,7 +155,7 @@ class SecurityController extends NativeController {
150
155
  refresh,
151
156
  });
152
157
 
153
- global.kuzzle.log.info(`[SECURITY] User "${creatorId}" applied action "${request.input.action}" on user "${userId}."`);
158
+ global.kuzzle.log.info(`[SECURITY] ${SecurityController.userOrSdk(creatorId)} applied action "${request.input.action}" on user "${userId}."`);
154
159
  return apiKey.serialize({ includeToken: true });
155
160
  }
156
161
 
@@ -372,7 +377,7 @@ class SecurityController extends NativeController {
372
377
  userId,
373
378
  });
374
379
 
375
- global.kuzzle.log.info(`[SECURITY] User "${userId}" applied action "${request.input.action}" on role "${role._id}."`);
380
+ global.kuzzle.log.info(`[SECURITY] ${SecurityController.userOrSdk(userId)} applied action "${request.input.action}" on role "${role._id}."`);
376
381
  return formatProcessing.serializeRole(role);
377
382
  }
378
383
 
@@ -393,7 +398,7 @@ class SecurityController extends NativeController {
393
398
  userId,
394
399
  });
395
400
 
396
- global.kuzzle.log.info(`[SECURITY] User "${userId}" applied action "${request.input.action}" on role "${role._id}."`);
401
+ global.kuzzle.log.info(`[SECURITY] ${SecurityController.userOrSdk(userId)} applied action "${request.input.action}" on role "${role._id}."`);
397
402
  return formatProcessing.serializeRole(role);
398
403
  }
399
404
 
@@ -410,7 +415,7 @@ class SecurityController extends NativeController {
410
415
  refresh: request.getRefresh('wait_for')
411
416
  });
412
417
 
413
- global.kuzzle.log.info(`[SECURITY] User "${request.getKuid()}" applied action "${request.input.action} on role "${id}."`);
418
+ global.kuzzle.log.info(`[SECURITY] ${SecurityController.userOrSdk(request.getKuid())} applied action "${request.input.action} on role "${id}."`);
414
419
 
415
420
  // @todo This avoids a breaking change... but we should really return
416
421
  // an acknowledgment.
@@ -473,7 +478,7 @@ class SecurityController extends NativeController {
473
478
  userId,
474
479
  });
475
480
 
476
- global.kuzzle.log.info(`[SECURITY] User "${userId}" applied action "${request.input.action}" on profile "${profile._id}."`);
481
+ global.kuzzle.log.info(`[SECURITY] ${SecurityController.userOrSdk(userId)} applied action "${request.input.action}" on profile "${profile._id}."`);
477
482
 
478
483
  return formatProcessing.serializeProfile(profile);
479
484
  }
@@ -502,7 +507,7 @@ class SecurityController extends NativeController {
502
507
  userId,
503
508
  });
504
509
 
505
- global.kuzzle.log.info(`[SECURITY] User "${userId}" applied action "${request.input.action}" on profile "${profile._id}."`);
510
+ global.kuzzle.log.info(`[SECURITY] ${SecurityController.userOrSdk(userId)} applied action "${request.input.action}" on profile "${profile._id}."`);
506
511
 
507
512
  return formatProcessing.serializeProfile(profile);
508
513
  }
@@ -523,7 +528,7 @@ class SecurityController extends NativeController {
523
528
 
524
529
  await this.ask('core:security:profile:delete', id, options);
525
530
 
526
- global.kuzzle.log.info(`[SECURITY] User "${userId}" applied action "${request.input.action}" on profile "${id}."`);
531
+ global.kuzzle.log.info(`[SECURITY] ${SecurityController.userOrSdk(userId)} applied action "${request.input.action}" on profile "${id}."`);
527
532
 
528
533
  // @todo - replace by an acknowledgement
529
534
  return { _id: id };
@@ -603,7 +608,8 @@ class SecurityController extends NativeController {
603
608
  ids = request.getBodyArray('ids');
604
609
  }
605
610
  else {
606
- ids = request.getString('ids').split(',');
611
+ // @deprecated Should be replaced with request.getArray('ids')
612
+ ids = request.getArrayLegacy('ids');
607
613
  }
608
614
 
609
615
  const users = await this.ask('core:security:user:mGet', ids);
@@ -758,7 +764,7 @@ class SecurityController extends NativeController {
758
764
 
759
765
  await this.ask('core:security:user:delete', id, options);
760
766
 
761
- global.kuzzle.log.info(`[SECURITY] User "${request.getKuid()}" applied action "${request.input.action}" on user "${id}."`);
767
+ global.kuzzle.log.info(`[SECURITY] ${SecurityController.userOrSdk(request.getKuid())} applied action "${request.input.action}" on user "${id}."`);
762
768
 
763
769
  return { _id: id };
764
770
  }
@@ -865,7 +871,7 @@ class SecurityController extends NativeController {
865
871
  content,
866
872
  { refresh: request.getRefresh('wait_for'), userId });
867
873
 
868
- global.kuzzle.log.info(`[SECURITY] User "${userId}" applied action "${request.input.action}" on user "${id}."`);
874
+ global.kuzzle.log.info(`[SECURITY] ${SecurityController.userOrSdk(userId)} applied action "${request.input.action}" on user "${id}."`);
869
875
 
870
876
  return formatProcessing.serializeUser(user);
871
877
  }
@@ -888,7 +894,7 @@ class SecurityController extends NativeController {
888
894
  userId,
889
895
  });
890
896
 
891
- global.kuzzle.log.info(`[SECURITY] User "${userId}" applied action "${request.input.action}" on profile "${id}."`);
897
+ global.kuzzle.log.info(`[SECURITY] ${SecurityController.userOrSdk(userId)} applied action "${request.input.action}" on profile "${id}."`);
892
898
  return formatProcessing.serializeProfile(updated);
893
899
  }
894
900
 
@@ -910,7 +916,7 @@ class SecurityController extends NativeController {
910
916
  userId,
911
917
  });
912
918
 
913
- global.kuzzle.log.info(`[SECURITY] User "${userId}" applied action "${request.input.action}" on role "${id}."`);
919
+ global.kuzzle.log.info(`[SECURITY] ${SecurityController.userOrSdk(userId)} applied action "${request.input.action}" on role "${id}."`);
914
920
 
915
921
  return formatProcessing.serializeRole(updated);
916
922
  }
@@ -951,7 +957,7 @@ class SecurityController extends NativeController {
951
957
  }
952
958
  }
953
959
 
954
- global.kuzzle.log.info(`[SECURITY] User "${userId}" applied action "${request.input.action}".`);
960
+ global.kuzzle.log.info(`[SECURITY] ${SecurityController.userOrSdk(userId)} applied action "${request.input.action}".`);
955
961
 
956
962
  return user;
957
963
  }
@@ -1040,7 +1046,7 @@ class SecurityController extends NativeController {
1040
1046
 
1041
1047
  const createMethod = this.getStrategyMethod(strategy, 'create');
1042
1048
 
1043
- global.kuzzle.log.info(`[SECURITY] User "${request.getKuid()}" applied action "${request.input.action}" on user "${id}."`);
1049
+ global.kuzzle.log.info(`[SECURITY] ${SecurityController.userOrSdk(request.getKuid())} applied action "${request.input.action}" on user "${id}."`);
1044
1050
  return createMethod(request, body, id, strategy);
1045
1051
  }
1046
1052
 
@@ -1064,7 +1070,7 @@ class SecurityController extends NativeController {
1064
1070
 
1065
1071
  const updateMethod = this.getStrategyMethod(strategy, 'update');
1066
1072
 
1067
- global.kuzzle.log.info(`[SECURITY] User "${request.getKuid()}" applied action "${request.input.action}" on user "${id}."`);
1073
+ global.kuzzle.log.info(`[SECURITY] ${SecurityController.userOrSdk(request.getKuid())} applied action "${request.input.action}" on user "${id}."`);
1068
1074
 
1069
1075
  return updateMethod(request, body, id, strategy);
1070
1076
  }
@@ -1117,7 +1123,7 @@ class SecurityController extends NativeController {
1117
1123
 
1118
1124
  await deleteMethod(request, id, strategy);
1119
1125
 
1120
- global.kuzzle.log.info(`[SECURITY] User "${request.getKuid()}" applied action "${request.input.action}" on user "${id}."`);
1126
+ global.kuzzle.log.info(`[SECURITY] ${SecurityController.userOrSdk(request.getKuid())} applied action "${request.input.action}" on user "${id}."`);
1121
1127
 
1122
1128
  return { acknowledged: true };
1123
1129
  }
@@ -1228,10 +1234,10 @@ class SecurityController extends NativeController {
1228
1234
  }
1229
1235
 
1230
1236
  if (successes.length > 1000) {
1231
- global.kuzzle.log.info(`[SECURITY] User "${request.getKuid()}" deleted the following ${type}s: ${successes.slice(0, 1000).join(', ')}... (${successes.length - 1000} more users deleted)."`);
1237
+ global.kuzzle.log.info(`[SECURITY] ${SecurityController.userOrSdk(request.getKuid())} deleted the following ${type}s: ${successes.slice(0, 1000).join(', ')}... (${successes.length - 1000} more users deleted)."`);
1232
1238
  }
1233
1239
  else {
1234
- global.kuzzle.log.info(`[SECURITY] User "${request.getKuid()}" deleted the following ${type}s: ${successes.join(', ')}."`);
1240
+ global.kuzzle.log.info(`[SECURITY] ${SecurityController.userOrSdk(request.getKuid())} deleted the following ${type}s: ${successes.join(', ')}."`);
1235
1241
  }
1236
1242
 
1237
1243
  return successes;
@@ -1253,7 +1259,7 @@ class SecurityController extends NativeController {
1253
1259
  userId,
1254
1260
  });
1255
1261
 
1256
- global.kuzzle.log.info(`[SECURITY] User "${userId}" applied action "${request.input.action}" on user "${id}."`);
1262
+ global.kuzzle.log.info(`[SECURITY] ${SecurityController.userOrSdk(userId)} applied action "${request.input.action}" on user "${id}."`);
1257
1263
 
1258
1264
  return formatProcessing.serializeUser(updated);
1259
1265
  }
@@ -1267,7 +1273,7 @@ class SecurityController extends NativeController {
1267
1273
  const credentials = request.getBodyObject('credentials', {});
1268
1274
  const strategies = Object.keys(credentials);
1269
1275
  const generator = humanReadableId
1270
- ? () => generateRandomName('kuid')
1276
+ ? () => NameGenerator.generateRandomName({ prefix: 'kuid' })
1271
1277
  : () => 'kuid-' + uuidv4();
1272
1278
 
1273
1279
  let id = '';
@@ -1347,7 +1353,7 @@ class SecurityController extends NativeController {
1347
1353
  }
1348
1354
 
1349
1355
  if (creationFailure === null) {
1350
- global.kuzzle.log.info(`[SECURITY] User "${request.getKuid()}" applied action "${request.input.action}" on user "${id}."`);
1356
+ global.kuzzle.log.info(`[SECURITY] ${SecurityController.userOrSdk(request.getKuid())} applied action "${request.input.action}" on user "${id}."`);
1351
1357
  return createdUser;
1352
1358
  }
1353
1359
 
@@ -188,7 +188,8 @@ class ServerController extends NativeController {
188
188
 
189
189
  let services;
190
190
  if (typeof request.input.args.services === 'string') {
191
- services = request.input.args.services.split(',');
191
+ // @deprecated Should be replaced with request.getArray('services')
192
+ services = request.getArrayLegacy('services');
192
193
  }
193
194
  if (! services || services.includes('internalCache')) {
194
195
  try {
@@ -26,6 +26,27 @@ const kerror = require('../kerror');
26
26
  const assertionError = kerror.wrap('api', 'assert');
27
27
 
28
28
  const extractors = ([
29
+ {
30
+ methods: {
31
+ extractFromRequest: request => [
32
+ {
33
+ _id: request.input.args._id,
34
+ _source: request.input.body.fields,
35
+ },
36
+ ],
37
+ extractFromResult: request => [request.result],
38
+ insertInRequest: ([documents], request) => {
39
+ request.input.args._id = documents._id;
40
+ request.input.body.fields = documents._source;
41
+ return request;
42
+ },
43
+ insertInResult: ([document], request) => {
44
+ request.setResult(document, { status: request.status });
45
+ return request;
46
+ },
47
+ },
48
+ targets: [ 'deleteFields' ]
49
+ },
29
50
  {
30
51
  methods: {
31
52
  extractFromRequest: request => [{ _id: request.input.args._id }],
@@ -39,7 +60,7 @@ const extractors = ([
39
60
  return request;
40
61
  }
41
62
  },
42
- targets: ['delete', 'get']
63
+ targets: [ 'delete', 'get', 'exists' ]
43
64
  },
44
65
  {
45
66
  methods: {
@@ -56,7 +77,8 @@ const extractors = ([
56
77
  ids = request.input.args.ids;
57
78
  }
58
79
  else if (typeof request.input.args.ids === 'string') {
59
- ids = request.input.args.ids.split(',');
80
+ // @deprecated Should be replaced with request.getArray('ids')
81
+ ids = request.getArrayLegacy('ids');
60
82
  }
61
83
  else {
62
84
  throw assertionError.get(
@@ -117,7 +139,7 @@ const extractors = ([
117
139
  return request;
118
140
  }
119
141
  },
120
- targets: ['mDelete', 'mGet']
142
+ targets: [ 'mDelete', 'mGet', 'mExists' ]
121
143
  },
122
144
  {
123
145
  methods: {
@@ -127,21 +149,41 @@ const extractors = ([
127
149
  for (let it = 0; it < request.input.body.documents.length; it++) {
128
150
  const document = request.input.body.documents[it];
129
151
 
130
- documents.push({ _id: document._id, _source: document.body });
152
+ if (request.input.action === 'mUpsert') {
153
+ documents.push({
154
+ _id: document._id,
155
+ _source: document.changes,
156
+ });
157
+ }
158
+ else {
159
+ documents.push({ _id: document._id, _source: document.body });
160
+ }
131
161
  }
132
162
 
133
163
  return documents;
134
164
  },
135
165
  extractFromResult: request => request.result.successes,
136
166
  insertInRequest: (documents, request) => {
167
+ const tmpDocuments = request.input.body.documents;
168
+
137
169
  request.input.body.documents = [];
138
170
 
139
171
  for (let it = 0; it < documents.length; it++) {
140
172
  const document = documents[it];
141
173
 
142
- request.input.body.documents.push({
143
- _id: document._id,
144
- body: document._source });
174
+ if (request.input.action === 'mUpsert') {
175
+ request.input.body.documents.push({
176
+ _id: document._id,
177
+ changes: document._source,
178
+ default: tmpDocuments[it].default,
179
+ });
180
+ }
181
+ else {
182
+ request.input.body.documents.push({
183
+ _id: document._id,
184
+ body: document._source,
185
+ });
186
+ }
145
187
  }
146
188
 
147
189
  return request;
@@ -157,7 +199,7 @@ const extractors = ([
157
199
  return request;
158
200
  }
159
201
  },
160
- targets: ['mCreate', 'mCreateOrReplace', 'mReplace', 'mUpdate', 'updateByQuery']
202
+ targets: [ 'mCreate', 'mCreateOrReplace', 'mReplace', 'mUpdate', 'updateByQuery', 'mUpsert' ]
161
203
  },
162
204
  {
163
205
  methods: {
@@ -177,7 +219,7 @@ const extractors = ([
177
219
  return request;
178
220
  },
179
221
  },
180
- targets: ['search', 'deleteByQuery'],
222
+ targets: [ 'search', 'deleteByQuery', 'export' ],
181
223
  },
182
224
  {
183
225
  methods: {
package/lib/api/funnel.js CHANGED
@@ -33,6 +33,7 @@ const {
33
33
  BulkController,
34
34
  ClusterController,
35
35
  CollectionController,
36
+ DebugController,
36
37
  DocumentController,
37
38
  IndexController,
38
39
  MemoryStorageController,
@@ -40,7 +41,7 @@ const {
40
41
  SecurityController,
41
42
  ServerController,
42
43
  } = require('./controllers');
43
- const documentEventAliases = require('../config/documentEventAliases');
44
+ const { documentEventAliases } = require('../config/documentEventAliases');
44
45
  const DocumentExtractor = require('./documentExtractor');
45
46
  const sdkCompatibility = require('../config/sdkCompatibility');
46
47
  const RateLimiter = require('./rateLimiter');
@@ -115,6 +116,7 @@ class Funnel {
115
116
  this.controllers.set('bulk', new BulkController());
116
117
  this.controllers.set('cluster', new ClusterController());
117
118
  this.controllers.set('collection', new CollectionController());
119
+ this.controllers.set('debug', new DebugController());
118
120
  this.controllers.set('document', new DocumentController());
119
121
  this.controllers.set('index', new IndexController());
120
122
  this.controllers.set('realtime', new RealtimeController());
@@ -344,19 +346,39 @@ class Funnel {
344
346
  modifiedRequest.id,
345
347
  processResult);
346
348
 
347
- callback(null, processResult);
348
-
349
- // disables a bluebird warning in dev. mode triggered when
350
- // a promise is created and not returned
351
- return null;
349
+ return global.kuzzle.pipe(
350
+ 'request:afterExecution',
351
+ {
352
+ request: _request,
353
+ result: processResult,
354
+ success: true,
355
+ })
356
+ .then(pipeEvent => {
357
+ callback(null, pipeEvent.result);
358
+
359
+ // disables a bluebird warning in dev. mode triggered when
360
+ // a promise is created and not returned
361
+ return null;
362
+ });
352
363
  }).catch(err => {
353
364
  debug('Error processing request %s: %a', modifiedRequest.id, err);
354
- return this._executeError(err, modifiedRequest, true, callback);
365
+ return global.kuzzle.pipe(
366
+ 'request:afterExecution',
367
+ {
368
+ error: err,
369
+ request: modifiedRequest,
370
+ success: false,
371
+ }).then(pipeEvent => this._executeError(pipeEvent.error, pipeEvent.request, true, callback));
355
372
  });
356
373
  })
357
374
  .catch(err => {
358
375
  debug('Error processing request %s: %a', req.id, err);
359
- return this._executeError(err, req, true, callback);
376
+ return global.kuzzle.pipe('request:afterExecution',
377
+ {
378
+ error: err,
379
+ request: req,
380
+ success: false,
381
+ }).then(pipeEvent => this._executeError(pipeEvent.error, pipeEvent.request, true, callback));
360
382
  });
361
383
  });
362
384
  }, this, request);
@@ -52,6 +52,12 @@ const routes = [
52
52
  { verb: 'get', path: '/credentials/:strategy/_me', controller: 'auth', action: 'getMyCredentials', deprecated: { since: '2.4.0', message: 'Use this route instead: http://kuzzle:7512/_me/credentials/:strategy' } }, // @deprecated
53
53
  { verb: 'get', path: '/credentials/:strategy/_me/_exists', controller: 'auth', action: 'credentialsExist', deprecated: { since: '2.4.0', message: 'Use this route instead: http://kuzzle:7512/_me/credentials/:strategy/_exists' } }, // @deprecated
54
54
 
55
+ { verb: 'get', path: '/debug/_nodeVersion', controller: 'debug', action: 'nodeVersion' },
56
+ { verb: 'post', path: '/debug/_post', controller: 'debug', action: 'post' },
57
+ { verb: 'post', path: '/debug/_enable', controller: 'debug', action: 'enable' },
58
+ { verb: 'post', path: '/debug/_disable', controller: 'debug', action: 'disable' },
59
+
60
+
55
61
  // We need to expose a GET method for "login" action in order to make authentication protocol like Oauth2 or CAS work:
56
62
  { verb: 'get', path: '/_login/:strategy', controller: 'auth', action: 'login' },
57
63
 
@@ -258,6 +258,9 @@ export declare class KuzzleRequest {
258
258
  /**
259
259
  * Gets a parameter from a request arguments and checks that it is an array
260
260
  *
261
+ * If the request argument is a JSON String instead of an array, it will be parsed
262
+ * and returned if it is a valid JSON array, otherwise it will @throws {api.assert.invalid_type}.
263
+ *
261
264
  * @param name parameter name
262
265
  * @param def default value to return if the parameter is not set
263
266
  *
@@ -266,9 +269,29 @@ export declare class KuzzleRequest {
266
269
  * @throws {api.assert.invalid_type} If the fetched parameter is not an array
267
270
  */
268
271
  getArray(name: string, def?: [] | undefined): any[];
272
+ /**
273
+ * @deprecated do not use, Use getArray instead
274
+ *
275
+ * Gets a parameter from a request arguments and checks that it is an array
276
+ *
277
+ * If the request argument is a String instead of an array, it will be JSON parsed
278
+ * and returned if it is a valid JSON array, otherwise it will return the string splitted on `,`.
279
+ *
280
+ *
281
+ * @param name parameter name
282
+ * @param def default value to return if the parameter is not set
283
+ *
284
+ * @throws {api.assert.missing_argument} If parameter not found and no default
285
+ * value provided
286
+ * @throws {api.assert.invalid_type} If the fetched parameter is not an array or a string
287
+ */
288
+ getArrayLegacy(name: string, def?: [] | undefined): any[];
269
289
  /**
270
290
  * Gets a parameter from a request arguments and checks that it is an object
271
291
  *
292
+ * If the request argument is a JSON String instead of an object, it will be parsed
293
+ * and returned if it is a valid JSON object, otherwise it will @throws {api.assert.invalid_type}.
294
+ *
272
295
  * @param name parameter name
273
296
  * @param def default value to return if the parameter is not set
274
297
  *
@@ -301,11 +324,15 @@ export declare class KuzzleRequest {
301
324
  /**
302
325
  * Returns the index specified in the request
303
326
  */
304
- getIndex(): string;
327
+ getIndex({ required }?: {
328
+ required?: boolean;
329
+ }): string;
305
330
  /**
306
331
  * Returns the collection specified in the request
307
332
  */
308
- getCollection(): string;
333
+ getCollection({ required }?: {
334
+ required?: boolean;
335
+ }): string;
309
336
  /**
310
337
  * Returns the index and collection specified in the request
311
338
  */
@@ -343,8 +370,8 @@ export declare class KuzzleRequest {
343
370
  */
344
371
  getUser(): User | null;
345
372
  /**
346
- * Returns the search body query according to the http method
347
- */
373
+ * Returns the search body query according to the http method
374
+ */
348
375
  getSearchBody(): JSONObject;
349
376
  /**
350
377
  * Returns the search params.
@@ -374,6 +401,7 @@ export declare class KuzzleRequest {
374
401
  * @param obj container object
375
402
  * @param name parameter name
376
403
  * @param errorName name to use in error messages
404
+ * @param querystring if true, the object is expected to be found in a querystring
377
405
  */
378
406
  private _getBoolean;
379
407
  /**
@@ -419,8 +447,13 @@ export declare class KuzzleRequest {
419
447
  * @param name parameter name
420
448
  * @param errorName name to use in error messages
421
449
  * @param def default value
450
+ * @param querystring if true, the object is expected to be found in a querystring
422
451
  */
423
452
  private _getObject;
453
+ /**
454
+ * Throw `missing_argument` when this one is required
455
+ */
456
+ private checkRequired;
424
457
  }
425
458
  export declare class Request extends KuzzleRequest {
426
459
  }