kuzzle 2.16.8 → 2.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/README.md +11 -0
  2. package/lib/api/controllers/adminController.js +7 -6
  3. package/lib/api/controllers/authController.js +11 -11
  4. package/lib/api/controllers/baseController.js +60 -3
  5. package/lib/api/controllers/clusterController.js +1 -1
  6. package/lib/api/controllers/collectionController.js +7 -5
  7. package/lib/api/controllers/documentController.js +130 -17
  8. package/lib/api/controllers/indexController.js +1 -1
  9. package/lib/api/controllers/memoryStorageController.js +39 -38
  10. package/lib/api/controllers/realtimeController.js +1 -1
  11. package/lib/api/controllers/securityController.js +49 -49
  12. package/lib/api/controllers/serverController.js +73 -27
  13. package/lib/api/documentExtractor.js +3 -3
  14. package/lib/api/funnel.js +40 -21
  15. package/lib/api/httpRoutes.js +9 -4
  16. package/lib/api/openapi/OpenApiManager.d.ts +11 -0
  17. package/lib/api/openapi/OpenApiManager.js +96 -0
  18. package/lib/api/openapi/{document → components/document}/count.yaml +2 -2
  19. package/lib/api/openapi/{document → components/document}/create.yaml +2 -2
  20. package/lib/api/openapi/{document → components/document}/createOrReplace.yaml +2 -2
  21. package/lib/api/openapi/{document → components/document}/delete.yaml +1 -1
  22. package/lib/api/openapi/{document → components/document}/deleteByQuery.yaml +2 -2
  23. package/lib/api/openapi/{document → components/document}/exists.yaml +1 -1
  24. package/lib/api/openapi/{document → components/document}/get.yaml +1 -1
  25. package/lib/api/openapi/{document → components/document}/index.d.ts +2 -0
  26. package/lib/api/openapi/{document → components/document}/index.js +7 -2
  27. package/lib/api/openapi/{document → components/document}/replace.yaml +2 -2
  28. package/lib/api/openapi/{document → components/document}/scroll.yaml +1 -1
  29. package/lib/api/openapi/{document → components/document}/update.yaml +2 -2
  30. package/lib/api/openapi/components/document/validate.yaml +42 -0
  31. package/lib/api/openapi/components/index.d.ts +2 -0
  32. package/lib/api/openapi/components/index.js +18 -0
  33. package/lib/api/openapi/{payloads.yaml → components/payloads.yaml} +0 -0
  34. package/lib/api/openapi/index.d.ts +1 -2
  35. package/lib/api/openapi/index.js +1 -5
  36. package/lib/api/openapi/openApiGenerator.d.ts +7 -0
  37. package/lib/api/openapi/openApiGenerator.js +133 -0
  38. package/lib/api/request/kuzzleRequest.d.ts +11 -11
  39. package/lib/api/request/kuzzleRequest.js +38 -48
  40. package/lib/cluster/node.js +9 -9
  41. package/lib/cluster/publisher.js +1 -1
  42. package/lib/cluster/subscriber.js +1 -1
  43. package/lib/cluster/workers/IDCardRenewer.js +13 -4
  44. package/lib/config/default.config.js +1 -0
  45. package/lib/config/index.js +6 -6
  46. package/lib/core/auth/passportResponse.js +6 -6
  47. package/lib/core/auth/passportWrapper.js +5 -5
  48. package/lib/core/backend/backend.d.ts +5 -1
  49. package/lib/core/backend/backend.js +12 -8
  50. package/lib/core/backend/backendConfig.d.ts +5 -1
  51. package/lib/core/backend/backendConfig.js +4 -0
  52. package/lib/core/backend/backendOpenApi.d.ts +9 -0
  53. package/lib/core/backend/backendOpenApi.js +69 -0
  54. package/lib/core/backend/index.d.ts +1 -0
  55. package/lib/core/backend/index.js +1 -0
  56. package/lib/core/network/accessLogger.js +6 -6
  57. package/lib/core/network/clientConnection.js +1 -1
  58. package/lib/core/network/entryPoint.js +5 -5
  59. package/lib/core/network/httpRouter/index.js +5 -5
  60. package/lib/core/network/httpRouter/routeHandler.js +3 -3
  61. package/lib/core/network/httpRouter/routePart.js +5 -5
  62. package/lib/core/network/protocolManifest.js +1 -1
  63. package/lib/core/network/protocols/httpMessage.js +2 -2
  64. package/lib/core/network/protocols/httpwsProtocol.js +207 -46
  65. package/lib/core/network/protocols/mqttProtocol.js +3 -3
  66. package/lib/core/network/protocols/protocol.js +3 -3
  67. package/lib/core/network/router.js +7 -6
  68. package/lib/core/plugin/plugin.js +38 -64
  69. package/lib/core/plugin/pluginContext.d.ts +10 -1
  70. package/lib/core/plugin/pluginContext.js +2 -0
  71. package/lib/core/plugin/pluginManifest.js +3 -3
  72. package/lib/core/plugin/pluginRepository.js +5 -5
  73. package/lib/core/plugin/pluginsManager.js +29 -28
  74. package/lib/core/realtime/notification/server.js +1 -1
  75. package/lib/core/realtime/notification/user.js +1 -1
  76. package/lib/core/realtime/notifier.js +5 -5
  77. package/lib/core/security/index.js +1 -1
  78. package/lib/core/security/profileRepository.d.ts +176 -0
  79. package/lib/core/security/profileRepository.js +426 -443
  80. package/lib/core/security/roleRepository.js +16 -16
  81. package/lib/core/security/securityLoader.js +3 -3
  82. package/lib/core/security/tokenRepository.js +18 -21
  83. package/lib/core/security/userRepository.js +8 -8
  84. package/lib/core/shared/abstractManifest.js +4 -4
  85. package/lib/core/shared/repository.js +6 -6
  86. package/lib/core/shared/sdk/funnelProtocol.js +1 -1
  87. package/lib/core/shared/sdk/impersonatedSdk.js +1 -1
  88. package/lib/core/shared/store.js +30 -23
  89. package/lib/core/statistics/statistics.js +17 -17
  90. package/lib/core/storage/clientAdapter.js +45 -10
  91. package/lib/core/validation/baseType.js +5 -5
  92. package/lib/core/validation/types/anything.js +1 -1
  93. package/lib/core/validation/types/boolean.js +2 -2
  94. package/lib/core/validation/types/date.js +9 -9
  95. package/lib/core/validation/types/email.js +5 -5
  96. package/lib/core/validation/types/enum.js +6 -6
  97. package/lib/core/validation/types/geoPoint.js +2 -2
  98. package/lib/core/validation/types/geoShape.js +28 -25
  99. package/lib/core/validation/types/integer.js +4 -4
  100. package/lib/core/validation/types/ipAddress.js +7 -6
  101. package/lib/core/validation/types/numeric.js +4 -4
  102. package/lib/core/validation/types/object.js +5 -5
  103. package/lib/core/validation/types/string.js +5 -5
  104. package/lib/core/validation/types/url.js +7 -6
  105. package/lib/core/validation/validation.js +95 -84
  106. package/lib/kerror/codes/1-services.json +12 -0
  107. package/lib/kerror/codes/2-api.json +12 -0
  108. package/lib/kerror/codes/3-network.json +12 -0
  109. package/lib/kerror/codes/4-plugin.json +6 -0
  110. package/lib/kerror/codes/index.js +11 -11
  111. package/lib/kerror/index.js +1 -1
  112. package/lib/kuzzle/dumpGenerator.js +3 -3
  113. package/lib/kuzzle/event/kuzzleEventEmitter.js +4 -4
  114. package/lib/kuzzle/event/pipeRunner.js +1 -1
  115. package/lib/kuzzle/event/waterfall.js +6 -6
  116. package/lib/kuzzle/kuzzle.js +36 -5
  117. package/lib/kuzzle/log.js +3 -3
  118. package/lib/kuzzle/vault.js +3 -3
  119. package/lib/model/security/profile.d.ts +54 -0
  120. package/lib/model/security/profile.js +174 -233
  121. package/lib/model/security/rights.js +1 -1
  122. package/lib/model/security/role.d.ts +40 -0
  123. package/lib/model/security/role.js +159 -191
  124. package/lib/model/security/user.d.ts +29 -0
  125. package/lib/model/security/user.js +84 -52
  126. package/lib/model/storage/apiKey.js +2 -2
  127. package/lib/model/storage/baseModel.js +3 -3
  128. package/lib/service/cache/redis.js +7 -7
  129. package/lib/service/storage/elasticsearch.js +152 -90
  130. package/lib/service/storage/esWrapper.js +2 -3
  131. package/lib/types/ControllerDefinition.d.ts +3 -3
  132. package/lib/types/ControllerRights.d.ts +22 -0
  133. package/lib/types/ControllerRights.js +23 -0
  134. package/lib/types/HttpStream.d.ts +32 -0
  135. package/lib/types/HttpStream.js +70 -0
  136. package/lib/types/OpenApiDefinition.d.ts +43 -0
  137. package/lib/types/{config/StorageService/StorageServiceElasticsearchConfiguration.js → OpenApiDefinition.js} +1 -1
  138. package/lib/types/Policy.d.ts +25 -0
  139. package/lib/types/Policy.js +23 -0
  140. package/lib/types/PolicyRestrictions.d.ts +21 -0
  141. package/lib/types/PolicyRestrictions.js +23 -0
  142. package/lib/types/Target.d.ts +15 -0
  143. package/lib/types/Target.js +23 -0
  144. package/lib/types/config/KuzzleConfiguration.d.ts +4 -0
  145. package/lib/types/config/ServicesConfiguration.d.ts +2 -2
  146. package/lib/types/config/{StorageService/StorageServiceElasticsearchConfiguration.d.ts → storageEngine/StorageEngineElasticsearchConfiguration.d.ts} +10 -3
  147. package/lib/types/config/storageEngine/StorageEngineElasticsearchConfiguration.js +3 -0
  148. package/lib/types/index.d.ts +7 -1
  149. package/lib/types/index.js +7 -1
  150. package/lib/util/array.d.ts +11 -0
  151. package/lib/util/array.js +57 -0
  152. package/lib/util/assertType.js +6 -6
  153. package/lib/util/bufferedPassThrough.d.ts +76 -0
  154. package/lib/util/bufferedPassThrough.js +161 -0
  155. package/lib/util/deprecate.js +7 -5
  156. package/lib/util/didYouMean.js +1 -1
  157. package/lib/util/dump-collection.d.ts +3 -0
  158. package/lib/util/dump-collection.js +265 -0
  159. package/lib/util/extractFields.js +2 -2
  160. package/lib/util/inflector.d.ts +8 -0
  161. package/lib/util/inflector.js +16 -0
  162. package/lib/util/requestAssertions.js +7 -7
  163. package/lib/util/wildcard.js +55 -0
  164. package/package-lock.json +881 -431
  165. package/package.json +23 -20
  166. package/lib/api/openApiGenerator.d.ts +0 -7
  167. package/lib/api/openApiGenerator.js +0 -197
@@ -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
@@ -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
+ };
@@ -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=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
@@ -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,6 @@ 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';
@@ -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,7 @@ __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);
64
70
  //# 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
@@ -32,7 +32,7 @@ const { BadRequestError } = require('../kerror/errors');
32
32
  * @param {*} data
33
33
  * @return {object}
34
34
  */
35
- function assertObject(attr, data) {
35
+ function assertObject (attr, data) {
36
36
  if (data === null || data === undefined) {
37
37
  return null;
38
38
  }
@@ -54,12 +54,12 @@ function assertObject(attr, data) {
54
54
  * @param {*} data
55
55
  * @return {array}
56
56
  */
57
- function assertArray(attr, data, type) {
57
+ function assertArray (attr, data, type) {
58
58
  if (data === null || data === undefined) {
59
59
  return [];
60
60
  }
61
61
 
62
- if (!Array.isArray(data)) {
62
+ if (! Array.isArray(data)) {
63
63
  throw new BadRequestError(`Attribute ${attr} must be of type "array"`);
64
64
  }
65
65
 
@@ -87,7 +87,7 @@ function assertArray(attr, data, type) {
87
87
  * @param {*} data
88
88
  * @return {null|string}
89
89
  */
90
- function assertString(attr, data) {
90
+ function assertString (attr, data) {
91
91
  if (data === null || data === undefined) {
92
92
  return null;
93
93
  }
@@ -108,8 +108,8 @@ function assertString(attr, data) {
108
108
  * @param {*} data
109
109
  * @return {number}
110
110
  */
111
- function assertInteger(attr, data) {
112
- if (!Number.isInteger(data)) {
111
+ function assertInteger (attr, data) {
112
+ if (! Number.isInteger(data)) {
113
113
  throw new BadRequestError(`Attribute ${attr} must be an integer`);
114
114
  }
115
115
 
@@ -0,0 +1,76 @@
1
+ /// <reference types="node" />
2
+ import stream from 'stream';
3
+ declare type Encoding = BufferEncoding | 'buffer';
4
+ declare type ChunkData = Buffer | string;
5
+ declare type Chunk = {
6
+ chunk: ChunkData;
7
+ encoding: Encoding;
8
+ };
9
+ declare type Callback = (error?: Error) => void;
10
+ /**
11
+ * This streams accumulate chunks data into a buffer until the amount of data is equal or exceed the buffer size.
12
+ * Then, it emits a single chunk with the accumulated data.
13
+ *
14
+ * This stream is useful when you want to reduce the amount of chunk produced by a stream.
15
+ * This can helps reducing the number of syscall made by the stream consumer.
16
+ */
17
+ export declare class BufferedPassThrough extends stream.Duplex {
18
+ private bufferSize;
19
+ private buffer;
20
+ private offset;
21
+ constructor(options?: stream.DuplexOptions);
22
+ /**
23
+ * Writes a string or buffer to the internal buffer starting at the internal buffer offset.
24
+ * Data will be copied from the given start to the end position.
25
+ *
26
+ * @param data
27
+ * @param start Where to start copying/writing data from
28
+ * @param end Where to end copying/writing data from
29
+ * @param encoding Type of encoding to use
30
+ * @returns How many bytes have been copied / written to the internal buffer.
31
+ */
32
+ private writeToBuffer;
33
+ private writeChunks;
34
+ /**
35
+ * Writes a chunk of data to the internal buffer.
36
+ * If the internal buffer is full, it will be pushed to the stream.
37
+ * @param chunk
38
+ * @param encoding
39
+ */
40
+ private writeChunkData;
41
+ /**
42
+ * @override from stream.Duplex
43
+ * Internal method called when data needs to be written.
44
+ * @param chunkData
45
+ * @param encoding
46
+ * @param callback
47
+ */
48
+ _write(chunkData: ChunkData, encoding: Encoding, callback: Callback): void;
49
+ /**
50
+ * @override from stream.Duplex
51
+ * Internal method called when multiple chunks were stored and needs to be written.
52
+ * @param chunks
53
+ * @param callback
54
+ */
55
+ _writev(chunks: Chunk[], callback: Callback): void;
56
+ /**
57
+ * @override from stream.Duplex
58
+ * Internal method called when the stream is drained, to resume pushing data.
59
+ * @param size
60
+ */
61
+ _read(): void;
62
+ /**
63
+ * @override from stream.Duplex
64
+ * Internal method called when the stream is ended.
65
+ * @param callback
66
+ */
67
+ _final(callback: Callback): void;
68
+ /**
69
+ * @override from stream.Duplex
70
+ * Internal method called when stream is destroyed.
71
+ * @param err
72
+ * @param callback
73
+ */
74
+ _destroy(err: Error, callback: Callback): void;
75
+ }
76
+ export {};