kuzzle 2.16.11 → 2.17.2

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 (187) hide show
  1. package/lib/api/controllers/adminController.js +3 -3
  2. package/lib/api/controllers/authController.js +12 -12
  3. package/lib/api/controllers/baseController.js +60 -3
  4. package/lib/api/controllers/clusterController.js +1 -1
  5. package/lib/api/controllers/collectionController.js +7 -5
  6. package/lib/api/controllers/documentController.js +130 -17
  7. package/lib/api/controllers/indexController.js +1 -1
  8. package/lib/api/controllers/memoryStorageController.js +39 -38
  9. package/lib/api/controllers/realtimeController.js +1 -1
  10. package/lib/api/controllers/securityController.js +50 -50
  11. package/lib/api/controllers/serverController.js +73 -27
  12. package/lib/api/documentExtractor.js +3 -3
  13. package/lib/api/funnel.js +44 -21
  14. package/lib/api/httpRoutes.js +9 -4
  15. package/lib/api/openapi/OpenApiManager.d.ts +11 -0
  16. package/lib/api/openapi/OpenApiManager.js +96 -0
  17. package/lib/api/openapi/{document → components/document}/count.yaml +2 -2
  18. package/lib/api/openapi/{document → components/document}/create.yaml +2 -2
  19. package/lib/api/openapi/{document → components/document}/createOrReplace.yaml +2 -2
  20. package/lib/api/openapi/{document → components/document}/delete.yaml +1 -1
  21. package/lib/api/openapi/{document → components/document}/deleteByQuery.yaml +2 -2
  22. package/lib/api/openapi/{document → components/document}/exists.yaml +1 -1
  23. package/lib/api/openapi/{document → components/document}/get.yaml +1 -1
  24. package/lib/api/openapi/{document → components/document}/index.d.ts +2 -0
  25. package/lib/api/openapi/{document → components/document}/index.js +7 -2
  26. package/lib/api/openapi/{document → components/document}/replace.yaml +2 -2
  27. package/lib/api/openapi/{document → components/document}/scroll.yaml +1 -1
  28. package/lib/api/openapi/{document → components/document}/update.yaml +2 -2
  29. package/lib/api/openapi/components/document/validate.yaml +42 -0
  30. package/lib/api/openapi/components/index.d.ts +2 -0
  31. package/lib/api/openapi/components/index.js +18 -0
  32. package/lib/api/openapi/{payloads.yaml → components/payloads.yaml} +0 -0
  33. package/lib/api/openapi/index.d.ts +1 -2
  34. package/lib/api/openapi/index.js +1 -5
  35. package/lib/api/openapi/openApiGenerator.d.ts +7 -0
  36. package/lib/api/openapi/openApiGenerator.js +133 -0
  37. package/lib/api/request/kuzzleRequest.js +8 -6
  38. package/lib/cluster/node.js +9 -9
  39. package/lib/cluster/publisher.js +1 -1
  40. package/lib/cluster/state.js +20 -4
  41. package/lib/cluster/subscriber.js +1 -1
  42. package/lib/cluster/workers/IDCardRenewer.js +2 -2
  43. package/lib/config/default.config.js +1 -0
  44. package/lib/config/index.js +6 -6
  45. package/lib/core/auth/passportResponse.js +6 -6
  46. package/lib/core/auth/passportWrapper.js +5 -5
  47. package/lib/core/backend/backend.d.ts +11 -3
  48. package/lib/core/backend/backend.js +22 -17
  49. package/lib/core/backend/backendConfig.d.ts +5 -1
  50. package/lib/core/backend/backendConfig.js +25 -2
  51. package/lib/core/backend/backendController.js +21 -5
  52. package/lib/core/backend/backendErrors.d.ts +58 -0
  53. package/lib/core/backend/backendErrors.js +121 -0
  54. package/lib/core/backend/backendHook.js +21 -5
  55. package/lib/core/backend/backendImport.js +21 -5
  56. package/lib/core/backend/backendOpenApi.d.ts +9 -0
  57. package/lib/core/backend/backendOpenApi.js +69 -0
  58. package/lib/core/backend/backendPipe.js +21 -5
  59. package/lib/core/backend/backendPlugin.js +22 -3
  60. package/lib/core/backend/backendVault.js +21 -2
  61. package/lib/core/backend/index.d.ts +2 -0
  62. package/lib/core/backend/index.js +2 -0
  63. package/lib/core/network/accessLogger.js +6 -6
  64. package/lib/core/network/clientConnection.js +1 -1
  65. package/lib/core/network/entryPoint.js +5 -5
  66. package/lib/core/network/httpRouter/index.js +5 -5
  67. package/lib/core/network/httpRouter/routeHandler.js +3 -3
  68. package/lib/core/network/httpRouter/routePart.js +5 -5
  69. package/lib/core/network/protocolManifest.js +1 -1
  70. package/lib/core/network/protocols/httpMessage.js +2 -2
  71. package/lib/core/network/protocols/httpwsProtocol.js +228 -50
  72. package/lib/core/network/protocols/mqttProtocol.js +3 -3
  73. package/lib/core/network/protocols/protocol.js +3 -3
  74. package/lib/core/network/router.js +7 -6
  75. package/lib/core/plugin/plugin.js +38 -64
  76. package/lib/core/plugin/pluginContext.js +22 -3
  77. package/lib/core/plugin/pluginManifest.js +3 -3
  78. package/lib/core/plugin/pluginRepository.js +5 -5
  79. package/lib/core/plugin/pluginsManager.js +29 -28
  80. package/lib/core/realtime/channel.js +20 -4
  81. package/lib/core/realtime/hotelClerk.js +24 -5
  82. package/lib/core/realtime/notification/server.js +1 -1
  83. package/lib/core/realtime/notification/user.js +1 -1
  84. package/lib/core/realtime/notifier.js +5 -5
  85. package/lib/core/security/index.js +1 -1
  86. package/lib/core/security/profileRepository.d.ts +176 -0
  87. package/lib/core/security/profileRepository.js +445 -443
  88. package/lib/core/security/roleRepository.js +16 -16
  89. package/lib/core/security/securityLoader.js +2 -2
  90. package/lib/core/security/tokenRepository.js +11 -11
  91. package/lib/core/security/userRepository.js +8 -8
  92. package/lib/core/shared/abstractManifest.js +4 -4
  93. package/lib/core/shared/repository.js +5 -5
  94. package/lib/core/shared/sdk/embeddedSdk.js +21 -2
  95. package/lib/core/shared/sdk/funnelProtocol.js +1 -1
  96. package/lib/core/shared/sdk/impersonatedSdk.js +1 -1
  97. package/lib/core/shared/store.js +30 -23
  98. package/lib/core/statistics/statistics.js +17 -17
  99. package/lib/core/storage/clientAdapter.js +45 -10
  100. package/lib/core/storage/indexCache.js +20 -4
  101. package/lib/core/validation/baseType.js +5 -5
  102. package/lib/core/validation/types/anything.js +1 -1
  103. package/lib/core/validation/types/boolean.js +2 -2
  104. package/lib/core/validation/types/date.js +9 -9
  105. package/lib/core/validation/types/email.js +5 -5
  106. package/lib/core/validation/types/enum.js +6 -6
  107. package/lib/core/validation/types/geoPoint.js +2 -2
  108. package/lib/core/validation/types/geoShape.js +28 -25
  109. package/lib/core/validation/types/integer.js +4 -4
  110. package/lib/core/validation/types/ipAddress.js +7 -6
  111. package/lib/core/validation/types/numeric.js +4 -4
  112. package/lib/core/validation/types/object.js +5 -5
  113. package/lib/core/validation/types/string.js +5 -5
  114. package/lib/core/validation/types/url.js +7 -6
  115. package/lib/core/validation/validation.js +95 -84
  116. package/lib/kerror/codes/1-services.json +12 -0
  117. package/lib/kerror/codes/2-api.json +12 -0
  118. package/lib/kerror/codes/3-network.json +12 -0
  119. package/lib/kerror/codes/4-plugin.json +6 -0
  120. package/lib/kerror/codes/index.js +11 -11
  121. package/lib/kerror/errors/multipleErrorsError.d.ts +1 -1
  122. package/lib/kerror/errors/multipleErrorsError.js +3 -3
  123. package/lib/kerror/index.d.ts +82 -0
  124. package/lib/kerror/index.js +176 -143
  125. package/lib/kuzzle/dumpGenerator.js +3 -3
  126. package/lib/kuzzle/event/kuzzleEventEmitter.js +4 -4
  127. package/lib/kuzzle/event/pipeRunner.js +1 -1
  128. package/lib/kuzzle/event/waterfall.js +6 -6
  129. package/lib/kuzzle/kuzzle.js +59 -9
  130. package/lib/kuzzle/log.js +3 -3
  131. package/lib/kuzzle/vault.js +3 -3
  132. package/lib/model/security/profile.d.ts +54 -0
  133. package/lib/model/security/profile.js +192 -232
  134. package/lib/model/security/rights.js +1 -1
  135. package/lib/model/security/role.d.ts +40 -0
  136. package/lib/model/security/role.js +174 -190
  137. package/lib/model/security/user.d.ts +29 -0
  138. package/lib/model/security/user.js +103 -52
  139. package/lib/model/storage/apiKey.js +2 -2
  140. package/lib/model/storage/baseModel.js +3 -3
  141. package/lib/service/cache/redis.js +7 -7
  142. package/lib/service/storage/elasticsearch.js +152 -90
  143. package/lib/service/storage/esWrapper.js +2 -3
  144. package/lib/types/ControllerDefinition.d.ts +3 -3
  145. package/lib/types/ControllerRights.d.ts +22 -0
  146. package/lib/types/ControllerRights.js +23 -0
  147. package/lib/types/HttpStream.d.ts +32 -0
  148. package/lib/types/HttpStream.js +70 -0
  149. package/lib/types/OpenApiDefinition.d.ts +43 -0
  150. package/lib/types/{config/StorageService/StorageServiceElasticsearchConfiguration.js → OpenApiDefinition.js} +1 -1
  151. package/lib/types/Plugin.js +20 -4
  152. package/lib/types/Policy.d.ts +25 -0
  153. package/lib/types/{InternalLogger.js → Policy.js} +2 -2
  154. package/lib/types/PolicyRestrictions.d.ts +21 -0
  155. package/lib/types/PolicyRestrictions.js +23 -0
  156. package/lib/types/Target.d.ts +15 -0
  157. package/lib/types/Target.js +23 -0
  158. package/lib/types/config/KuzzleConfiguration.d.ts +4 -0
  159. package/lib/types/config/ServicesConfiguration.d.ts +2 -2
  160. package/lib/types/config/{StorageService/StorageServiceElasticsearchConfiguration.d.ts → storageEngine/StorageEngineElasticsearchConfiguration.d.ts} +10 -3
  161. package/lib/types/config/storageEngine/StorageEngineElasticsearchConfiguration.js +3 -0
  162. package/lib/types/errors/ErrorDefinition.d.ts +27 -0
  163. package/lib/types/errors/ErrorDefinition.js +3 -0
  164. package/lib/types/errors/ErrorDomains.d.ts +17 -0
  165. package/lib/types/errors/ErrorDomains.js +3 -0
  166. package/lib/types/index.d.ts +9 -1
  167. package/lib/types/index.js +9 -1
  168. package/lib/util/array.d.ts +11 -0
  169. package/lib/util/array.js +57 -0
  170. package/lib/util/assertType.js +6 -6
  171. package/lib/util/bufferedPassThrough.d.ts +76 -0
  172. package/lib/util/bufferedPassThrough.js +161 -0
  173. package/lib/util/deprecate.js +7 -5
  174. package/lib/util/didYouMean.js +1 -1
  175. package/lib/util/dump-collection.d.ts +3 -0
  176. package/lib/util/dump-collection.js +284 -0
  177. package/lib/util/extractFields.js +2 -2
  178. package/lib/util/inflector.d.ts +8 -0
  179. package/lib/util/inflector.js +16 -0
  180. package/lib/util/mutex.js +21 -2
  181. package/lib/util/requestAssertions.js +7 -7
  182. package/lib/util/wildcard.js +55 -0
  183. package/package-lock.json +535 -75
  184. package/package.json +5 -3
  185. package/lib/api/openApiGenerator.d.ts +0 -7
  186. package/lib/api/openApiGenerator.js +0 -197
  187. package/lib/types/InternalLogger.d.ts +0 -25
@@ -154,7 +154,7 @@ const errorMessagesMapping = [
154
154
  ];
155
155
 
156
156
  class ESWrapper {
157
- constructor(client) {
157
+ constructor (client) {
158
158
  this.client = client;
159
159
  }
160
160
 
@@ -257,8 +257,7 @@ class ESWrapper {
257
257
 
258
258
  // empty query throws exception with ES 7
259
259
  if ( error.meta.body.error.type === 'parsing_exception'
260
- && _.get(error, 'meta.body.error.caused_by.type') === 'illegal_argument_exception')
261
- {
260
+ && _.get(error, 'meta.body.error.caused_by.type') === 'illegal_argument_exception') {
262
261
  errorMessage = error.meta.body.error.caused_by.reason;
263
262
  }
264
263
  }
@@ -8,7 +8,7 @@ import { KuzzleRequest } from '../api/request';
8
8
  * actions: {
9
9
  * sayHello: {
10
10
  * handler: async request => `Hello, ${request.input.args.name}`,
11
- * http: [{ verb: 'POST', path: '/greeting/hello/:name' }]
11
+ * http: [{ verb: 'post', path: '/greeting/hello/:name' }]
12
12
  * }
13
13
  * }
14
14
  * }
@@ -22,7 +22,7 @@ export declare type ControllerDefinition = {
22
22
  * sayHello: {
23
23
  * handler: async request => `Hello, ${request.input.args.name}`,
24
24
  * http: [{
25
- * verb: 'POST',
25
+ * verb: 'post',
26
26
  * path: '/greeting/hello/:name',
27
27
  * openapi: {
28
28
  * description: "Simply say hello",
@@ -68,7 +68,7 @@ export declare type HttpRoute = {
68
68
  /**
69
69
  * HTTP verb.
70
70
  */
71
- verb: 'get' | 'post' | 'put' | 'delete' | 'head';
71
+ verb: 'get' | 'head' | 'post' | 'put' | 'delete' | 'patch' | 'options';
72
72
  /**
73
73
  * Route path.
74
74
  * A route starting with `/` will be prefixed by `/_` otherwise the route
@@ -0,0 +1,22 @@
1
+ /** @internal */
2
+ export declare type ControllerRight = {
3
+ actions: {
4
+ [action: string]: boolean;
5
+ };
6
+ };
7
+ /**
8
+ * @internal
9
+ * A Controller Rights definition
10
+ *
11
+ * @example
12
+ * {
13
+ * "document": {
14
+ * actions: {
15
+ * "create": true,
16
+ * }
17
+ * }
18
+ * }
19
+ */
20
+ export declare type ControllerRights = {
21
+ [controller: string]: ControllerRight;
22
+ };
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ /*
3
+ * Kuzzle, a backend software, self-hostable and ready to use
4
+ * to power modern apps
5
+ *
6
+ * Copyright 2015-2022 Kuzzle
7
+ * mailto: support AT kuzzle.io
8
+ * website: http://kuzzle.io
9
+ *
10
+ * Licensed under the Apache License, Version 2.0 (the "License");
11
+ * you may not use this file except in compliance with the License.
12
+ * You may obtain a copy of the License at
13
+ *
14
+ * https://www.apache.org/licenses/LICENSE-2.0
15
+ *
16
+ * Unless required by applicable law or agreed to in writing, software
17
+ * distributed under the License is distributed on an "AS IS" BASIS,
18
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ * See the License for the specific language governing permissions and
20
+ * limitations under the License.
21
+ */
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ //# sourceMappingURL=ControllerRights.js.map
@@ -0,0 +1,32 @@
1
+ /// <reference types="node" />
2
+ import { Readable } from 'stream';
3
+ export declare type HttpStreamProperties = {
4
+ totalBytes?: number;
5
+ };
6
+ /**
7
+ * A simple class used to wrap a Readable stream
8
+ * and provide additional informations about the given data
9
+ */
10
+ export declare class HttpStream {
11
+ readonly stream: Readable;
12
+ readonly totalBytes: number;
13
+ private _destroyed;
14
+ constructor(readableStream: Readable, { totalBytes }?: HttpStreamProperties);
15
+ /**
16
+ * Returns if the stream is errored
17
+ */
18
+ get errored(): boolean;
19
+ /**
20
+ * Get the error
21
+ */
22
+ get error(): Error;
23
+ /**
24
+ * Returns if the stream has been destroyed
25
+ */
26
+ get destroyed(): boolean;
27
+ /**
28
+ * Destroy the stream
29
+ * true if the stream has been destroyed
30
+ */
31
+ destroy(): boolean;
32
+ }
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ /*
3
+ * Kuzzle, a backend software, self-hostable and ready to use
4
+ * to power modern apps
5
+ *
6
+ * Copyright 2015-2022 Kuzzle
7
+ * mailto: support AT kuzzle.io
8
+ * website: http://kuzzle.io
9
+ *
10
+ * Licensed under the Apache License, Version 2.0 (the "License");
11
+ * you may not use this file except in compliance with the License.
12
+ * You may obtain a copy of the License at
13
+ *
14
+ * https://www.apache.org/licenses/LICENSE-2.0
15
+ *
16
+ * Unless required by applicable law or agreed to in writing, software
17
+ * distributed under the License is distributed on an "AS IS" BASIS,
18
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ * See the License for the specific language governing permissions and
20
+ * limitations under the License.
21
+ */
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.HttpStream = void 0;
24
+ /**
25
+ * A simple class used to wrap a Readable stream
26
+ * and provide additional informations about the given data
27
+ */
28
+ class HttpStream {
29
+ constructor(readableStream, { totalBytes = -1 } = {}) {
30
+ this._destroyed = false;
31
+ this.stream = readableStream;
32
+ this.totalBytes = totalBytes;
33
+ this._destroyed = readableStream.destroyed;
34
+ }
35
+ /**
36
+ * Returns if the stream is errored
37
+ */
38
+ get errored() {
39
+ // @ts-ignore
40
+ return this.stream._readableState.errored !== null // @ts-ignore
41
+ && this.stream._readableState.errored !== undefined;
42
+ }
43
+ /**
44
+ * Get the error
45
+ */
46
+ get error() {
47
+ // @ts-ignore
48
+ return this.stream._readableState.errored;
49
+ }
50
+ /**
51
+ * Returns if the stream has been destroyed
52
+ */
53
+ get destroyed() {
54
+ return this._destroyed;
55
+ }
56
+ /**
57
+ * Destroy the stream
58
+ * true if the stream has been destroyed
59
+ */
60
+ destroy() {
61
+ if (this._destroyed) {
62
+ return false;
63
+ }
64
+ this.stream.destroy();
65
+ this._destroyed = true;
66
+ return true;
67
+ }
68
+ }
69
+ exports.HttpStream = HttpStream;
70
+ //# sourceMappingURL=HttpStream.js.map
@@ -0,0 +1,43 @@
1
+ import { JSONObject } from 'kuzzle-sdk';
2
+ export declare type OpenApiDefinition = {
3
+ swagger?: string;
4
+ openapi?: string;
5
+ info: {
6
+ title: string;
7
+ description: string;
8
+ contact: {
9
+ name: string;
10
+ url: string;
11
+ email: string;
12
+ discord: string;
13
+ };
14
+ license: {
15
+ name: string;
16
+ url: string;
17
+ };
18
+ version: string;
19
+ };
20
+ externalDocs: {
21
+ description: string;
22
+ url: string;
23
+ };
24
+ servers: Array<{
25
+ url: string;
26
+ description: string;
27
+ variables: {
28
+ baseUrl: {
29
+ default: string;
30
+ };
31
+ port: {
32
+ default: number;
33
+ };
34
+ };
35
+ }>;
36
+ tags: Array<{
37
+ description: string;
38
+ name: string;
39
+ }>;
40
+ schemes: string[];
41
+ paths: JSONObject;
42
+ components: JSONObject;
43
+ };
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=StorageServiceElasticsearchConfiguration.js.map
3
+ //# sourceMappingURL=OpenApiDefinition.js.map
@@ -19,12 +19,28 @@
19
19
  * See the License for the specific language governing permissions and
20
20
  * limitations under the License.
21
21
  */
22
- var __importDefault = (this && this.__importDefault) || function (mod) {
23
- return (mod && mod.__esModule) ? mod : { "default": mod };
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.Plugin = void 0;
27
- const kerror_1 = __importDefault(require("../kerror"));
43
+ const kerror = __importStar(require("../kerror"));
28
44
  const safeObject_1 = require("../util/safeObject");
29
45
  /**
30
46
  * Plugins must implements this abstract class.
@@ -36,7 +52,7 @@ class Plugin {
36
52
  constructor(manifest) {
37
53
  if (!(0, safeObject_1.has)(manifest, 'kuzzleVersion')) {
38
54
  // eslint-disable-next-line new-cap
39
- throw new kerror_1.default.get('plugin', 'manifest', 'missing_version');
55
+ throw kerror.get('plugin', 'manifest', 'missing_version');
40
56
  }
41
57
  this._manifest = manifest;
42
58
  }
@@ -0,0 +1,25 @@
1
+ import { PolicyRestrictions, OptimizedPolicyRestrictions } from './PolicyRestrictions';
2
+ /**
3
+ * Policy definition for a role
4
+ * and its restrictions
5
+ *
6
+ * @example
7
+ * {
8
+ * "roleId": "admin",
9
+ * "restrictedTo": [
10
+ * {
11
+ * "index": "index-yellow-taxi",
12
+ * "collections": ["foo", "bar"]
13
+ * }
14
+ * ]
15
+ * }
16
+ */
17
+ export declare type Policy = {
18
+ roleId: string;
19
+ restrictedTo?: PolicyRestrictions[];
20
+ };
21
+ /** @internal */
22
+ export declare type OptimizedPolicy = {
23
+ roleId: string;
24
+ restrictedTo?: OptimizedPolicyRestrictions;
25
+ };
@@ -3,7 +3,7 @@
3
3
  * Kuzzle, a backend software, self-hostable and ready to use
4
4
  * to power modern apps
5
5
  *
6
- * Copyright 2015-2020 Kuzzle
6
+ * Copyright 2015-2022 Kuzzle
7
7
  * mailto: support AT kuzzle.io
8
8
  * website: http://kuzzle.io
9
9
  *
@@ -20,4 +20,4 @@
20
20
  * limitations under the License.
21
21
  */
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
- //# sourceMappingURL=InternalLogger.js.map
23
+ //# sourceMappingURL=Policy.js.map
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Policy Restiction definition of
3
+ * a index and its collections
4
+ *
5
+ * @example
6
+ * {
7
+ * "index": "index-yellow-taxi",
8
+ * "collections": ["foo", "bar"]
9
+ * }
10
+ */
11
+ export declare type PolicyRestrictions = {
12
+ index: string;
13
+ collections: string[];
14
+ };
15
+ /**
16
+ * @internal
17
+ * A policy definition
18
+ * the key {string} represent the index name
19
+ * the value {string[]} represent the collection names
20
+ */
21
+ export declare type OptimizedPolicyRestrictions = Map<string, string[]>;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ /*
3
+ * Kuzzle, a backend software, self-hostable and ready to use
4
+ * to power modern apps
5
+ *
6
+ * Copyright 2015-2022 Kuzzle
7
+ * mailto: support AT kuzzle.io
8
+ * website: http://kuzzle.io
9
+ *
10
+ * Licensed under the Apache License, Version 2.0 (the "License");
11
+ * you may not use this file except in compliance with the License.
12
+ * You may obtain a copy of the License at
13
+ *
14
+ * https://www.apache.org/licenses/LICENSE-2.0
15
+ *
16
+ * Unless required by applicable law or agreed to in writing, software
17
+ * distributed under the License is distributed on an "AS IS" BASIS,
18
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ * See the License for the specific language governing permissions and
20
+ * limitations under the License.
21
+ */
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ //# sourceMappingURL=PolicyRestrictions.js.map
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Target definition
3
+ *
4
+ * Target are used to specify multiple index and collection
5
+ * inside of a single query
6
+ * @example
7
+ * {
8
+ * "index": "yellow-taxi",
9
+ * "collections": ["foo", "bar"]
10
+ * }
11
+ */
12
+ export declare type Target = {
13
+ index?: string;
14
+ collections?: string[];
15
+ };
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ /*
3
+ * Kuzzle, a backend software, self-hostable and ready to use
4
+ * to power modern apps
5
+ *
6
+ * Copyright 2015-2022 Kuzzle
7
+ * mailto: support AT kuzzle.io
8
+ * website: http://kuzzle.io
9
+ *
10
+ * Licensed under the Apache License, Version 2.0 (the "License");
11
+ * you may not use this file except in compliance with the License.
12
+ * You may obtain a copy of the License at
13
+ *
14
+ * https://www.apache.org/licenses/LICENSE-2.0
15
+ *
16
+ * Unless required by applicable law or agreed to in writing, software
17
+ * distributed under the License is distributed on an "AS IS" BASIS,
18
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ * See the License for the specific language governing permissions and
20
+ * limitations under the License.
21
+ */
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ //# sourceMappingURL=Target.js.map
@@ -72,6 +72,10 @@ export interface IKuzzleConfiguration {
72
72
  statsInterval: number;
73
73
  };
74
74
  cluster: {
75
+ /**
76
+ * @default true
77
+ */
78
+ enabled: boolean;
75
79
  /**
76
80
  * @default 50
77
81
  */
@@ -1,4 +1,4 @@
1
- import { PublicCacheRedisConfiguration, InternalCacheConfiguration, StorageServiceElasticsearch } from '../index';
1
+ import { PublicCacheRedisConfiguration, InternalCacheConfiguration, StorageEngineElasticsearch } from '../index';
2
2
  export declare type ServicesConfiguration = {
3
3
  common: {
4
4
  /**
@@ -37,5 +37,5 @@ export declare type ServicesConfiguration = {
37
37
  * The default storage layer is Elasticsearch and it is
38
38
  * currently the only storage layer we support.
39
39
  */
40
- storageEngine: StorageServiceElasticsearch;
40
+ storageEngine: StorageEngineElasticsearch;
41
41
  };
@@ -1,5 +1,5 @@
1
- import { JSONObject } from '../../../../index';
2
- export declare type StorageServiceElasticsearch = {
1
+ import { ClientOptions } from '@elastic/elasticsearch';
2
+ export declare type StorageEngineElasticsearch = {
3
3
  /**
4
4
  * @default ['storageEngine']
5
5
  */
@@ -12,10 +12,17 @@ export declare type StorageServiceElasticsearch = {
12
12
  * Elasticsearch constructor options. Use this field to specify your
13
13
  * Elasticsearch config options, this object is passed through to the
14
14
  * Elasticsearch constructor and can contain all options/keys outlined here:
15
+ *
15
16
  * @see https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/client-configuration.html
16
17
  *
18
+ * @default
19
+ *
20
+ * {
21
+ * node: 'http://localhost:9200'
22
+ * }
23
+ *
17
24
  */
18
- client: JSONObject;
25
+ client: ClientOptions;
19
26
  /**
20
27
  * Default policy against new fields that are not referenced in the
21
28
  * collection mapping.
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=StorageEngineElasticsearchConfiguration.js.map
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Available error class
3
+ */
4
+ export declare type ErrorClassNames = 'BadRequestError' | 'ExternalServiceError' | 'ForbiddenError' | 'GatewayTimeoutError' | 'InternalError' | 'KuzzleError' | 'MultipleErrorsError' | 'NotFoundError' | 'PartialError' | 'PluginImplementationError' | 'ServiceUnavailableError' | 'SizeLimitError' | 'UnauthorizedError' | 'PreconditionError' | 'TooManyRequestsError';
5
+ /**
6
+ * Represents a standardized error definition
7
+ */
8
+ export declare type ErrorDefinition = CustomErrorDefinition & {
9
+ code: number;
10
+ };
11
+ /**
12
+ * Represents a custom standardized error definition
13
+ */
14
+ export declare type CustomErrorDefinition = {
15
+ /**
16
+ * Error description for documentation purpose
17
+ */
18
+ description: string;
19
+ /**
20
+ * Error message
21
+ */
22
+ message: string;
23
+ /**
24
+ * Error class
25
+ */
26
+ class: ErrorClassNames;
27
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ErrorDefinition.js.map
@@ -0,0 +1,17 @@
1
+ import { ErrorDefinition } from './ErrorDefinition';
2
+ /**
3
+ * Represents the domains, subdomains and error names with associated definitions
4
+ */
5
+ export declare type ErrorDomains = {
6
+ [domain: string]: {
7
+ code: number;
8
+ subdomains?: {
9
+ [subDomain: string]: {
10
+ code: number;
11
+ errors: {
12
+ [errorName: string]: ErrorDefinition;
13
+ };
14
+ };
15
+ };
16
+ };
17
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ErrorDomains.js.map
@@ -1,13 +1,18 @@
1
1
  export * from './Plugin';
2
2
  export * from './Controller';
3
3
  export * from './ControllerDefinition';
4
+ export * from './ControllerRights';
4
5
  export * from './RequestPayload';
5
6
  export * from './ResponsePayload';
6
7
  export * from './Deprecation';
7
8
  export * from './EventHandler';
9
+ export * from './Policy';
10
+ export * from './PolicyRestrictions';
8
11
  export * from './User';
9
12
  export * from './Token';
13
+ export * from './Target';
10
14
  export * from './Global';
15
+ export * from './HttpStream';
11
16
  export * from './PasswordPolicy';
12
17
  export * from './config/KuzzleConfiguration';
13
18
  export * from './config/ServerConfiguration';
@@ -27,5 +32,8 @@ export * from './realtime/RoomList';
27
32
  export * from './KuzzleDocument';
28
33
  export * from './config/publicCache/PublicCacheRedisConfiguration';
29
34
  export * from './config/internalCache/InternalCacheRedisConfiguration';
30
- export * from './config/StorageService/StorageServiceElasticsearchConfiguration';
35
+ export * from './config/storageEngine/StorageEngineElasticsearchConfiguration';
31
36
  export * from './config/DumpConfiguration';
37
+ export * from './OpenApiDefinition';
38
+ export * from './errors/ErrorDefinition';
39
+ export * from './errors/ErrorDomains';
@@ -33,13 +33,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
33
33
  __exportStar(require("./Plugin"), exports);
34
34
  __exportStar(require("./Controller"), exports);
35
35
  __exportStar(require("./ControllerDefinition"), exports);
36
+ __exportStar(require("./ControllerRights"), exports);
36
37
  __exportStar(require("./RequestPayload"), exports);
37
38
  __exportStar(require("./ResponsePayload"), exports);
38
39
  __exportStar(require("./Deprecation"), exports);
39
40
  __exportStar(require("./EventHandler"), exports);
41
+ __exportStar(require("./Policy"), exports);
42
+ __exportStar(require("./PolicyRestrictions"), exports);
40
43
  __exportStar(require("./User"), exports);
41
44
  __exportStar(require("./Token"), exports);
45
+ __exportStar(require("./Target"), exports);
42
46
  __exportStar(require("./Global"), exports);
47
+ __exportStar(require("./HttpStream"), exports);
43
48
  __exportStar(require("./PasswordPolicy"), exports);
44
49
  __exportStar(require("./config/KuzzleConfiguration"), exports);
45
50
  __exportStar(require("./config/ServerConfiguration"), exports);
@@ -59,6 +64,9 @@ __exportStar(require("./realtime/RoomList"), exports);
59
64
  __exportStar(require("./KuzzleDocument"), exports);
60
65
  __exportStar(require("./config/publicCache/PublicCacheRedisConfiguration"), exports);
61
66
  __exportStar(require("./config/internalCache/InternalCacheRedisConfiguration"), exports);
62
- __exportStar(require("./config/StorageService/StorageServiceElasticsearchConfiguration"), exports);
67
+ __exportStar(require("./config/storageEngine/StorageEngineElasticsearchConfiguration"), exports);
63
68
  __exportStar(require("./config/DumpConfiguration"), exports);
69
+ __exportStar(require("./OpenApiDefinition"), exports);
70
+ __exportStar(require("./errors/ErrorDefinition"), exports);
71
+ __exportStar(require("./errors/ErrorDomains"), exports);
64
72
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Binary Search
3
+ *
4
+ * @param array Sorted Array
5
+ * @param predicate A function that return -1, 0, or 1
6
+ * - [-1] The value is greater than what you search
7
+ * - [1] The value is lesser than what you search
8
+ * - [0] Both value are equals
9
+ * @returns {number} The index of the value, or -1 if not found
10
+ */
11
+ export declare function binarySearch(array: any[], predicate: (value: any) => number): number;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ /*
3
+ * Kuzzle, a backend software, self-hostable and ready to use
4
+ * to power modern apps
5
+ *
6
+ * Copyright 2015-2020 Kuzzle
7
+ * mailto: support AT kuzzle.io
8
+ * website: http://kuzzle.io
9
+ *
10
+ * Licensed under the Apache License, Version 2.0 (the "License");
11
+ * you may not use this file except in compliance with the License.
12
+ * You may obtain a copy of the License at
13
+ *
14
+ * https://www.apache.org/licenses/LICENSE-2.0
15
+ *
16
+ * Unless required by applicable law or agreed to in writing, software
17
+ * distributed under the License is distributed on an "AS IS" BASIS,
18
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ * See the License for the specific language governing permissions and
20
+ * limitations under the License.
21
+ */
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.binarySearch = void 0;
24
+ /**
25
+ * Binary Search
26
+ *
27
+ * @param array Sorted Array
28
+ * @param predicate A function that return -1, 0, or 1
29
+ * - [-1] The value is greater than what you search
30
+ * - [1] The value is lesser than what you search
31
+ * - [0] Both value are equals
32
+ * @returns {number} The index of the value, or -1 if not found
33
+ */
34
+ function binarySearch(array, predicate) {
35
+ let lowerBound = 0;
36
+ let upperBound = array.length - 1;
37
+ if (array.length === 1) {
38
+ return predicate(array[0]) === 0 ? 0 : -1;
39
+ }
40
+ while (lowerBound <= upperBound) {
41
+ // 5x faster than Math.floor((lowerBound + upperBound) / 2)
42
+ const index = (lowerBound + upperBound) >> 1;
43
+ const comparison = predicate(array[index]);
44
+ if (comparison < 0) {
45
+ upperBound = index - 1;
46
+ }
47
+ else if (comparison > 0) {
48
+ lowerBound = index + 1;
49
+ }
50
+ else {
51
+ return index;
52
+ }
53
+ }
54
+ return -1;
55
+ }
56
+ exports.binarySearch = binarySearch;
57
+ //# sourceMappingURL=array.js.map