kuzzle 2.19.9 → 2.19.10

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 (51) hide show
  1. package/lib/api/controllers/documentController.js +4 -1
  2. package/lib/api/request/requestContext.d.ts +1 -1
  3. package/lib/cluster/idCardHandler.d.ts +1 -1
  4. package/lib/cluster/state.d.ts +3 -3
  5. package/lib/core/backend/backend.js +2 -1
  6. package/lib/core/backend/backendImport.d.ts +1 -1
  7. package/lib/core/network/protocols/httpwsProtocol.js +8 -1
  8. package/lib/core/realtime/channel.js +12 -12
  9. package/lib/core/security/profileRepository.d.ts +3 -3
  10. package/lib/model/security/profile.d.ts +1 -1
  11. package/lib/service/storage/elasticsearch.js +27 -2
  12. package/lib/types/Controller.js +3 -3
  13. package/lib/types/ControllerDefinition.d.ts +2 -2
  14. package/lib/types/ControllerRights.d.ts +2 -2
  15. package/lib/types/DebugModule.d.ts +1 -1
  16. package/lib/types/Deprecation.d.ts +1 -1
  17. package/lib/types/EventHandler.d.ts +5 -5
  18. package/lib/types/HttpStream.d.ts +1 -1
  19. package/lib/types/HttpStream.js +4 -4
  20. package/lib/types/Kuzzle.d.ts +4 -4
  21. package/lib/types/OpenApiDefinition.d.ts +1 -1
  22. package/lib/types/PasswordPolicy.d.ts +1 -1
  23. package/lib/types/Plugin.d.ts +3 -3
  24. package/lib/types/PluginManifest.d.ts +1 -1
  25. package/lib/types/Policy.d.ts +2 -2
  26. package/lib/types/PolicyRestrictions.d.ts +2 -2
  27. package/lib/types/ProfileDefinition.d.ts +1 -1
  28. package/lib/types/RoleDefinition.d.ts +1 -1
  29. package/lib/types/StrategyDefinition.d.ts +1 -1
  30. package/lib/types/Target.d.ts +1 -1
  31. package/lib/types/config/DumpConfiguration.d.ts +1 -1
  32. package/lib/types/config/HttpConfiguration.d.ts +1 -1
  33. package/lib/types/config/KuzzleConfiguration.d.ts +1 -1
  34. package/lib/types/config/LimitsConfiguration.d.ts +1 -1
  35. package/lib/types/config/PluginsConfiguration.d.ts +1 -1
  36. package/lib/types/config/SecurityConfiguration.d.ts +1 -1
  37. package/lib/types/config/ServerConfiguration.d.ts +1 -1
  38. package/lib/types/config/ServicesConfiguration.d.ts +1 -1
  39. package/lib/types/config/internalCache/InternalCacheRedisConfiguration.d.ts +1 -1
  40. package/lib/types/config/publicCache/PublicCacheRedisConfiguration.d.ts +1 -1
  41. package/lib/types/config/storageEngine/StorageEngineElasticsearchConfiguration.d.ts +1 -1
  42. package/lib/types/errors/ErrorDefinition.d.ts +3 -3
  43. package/lib/types/errors/ErrorDomains.d.ts +1 -1
  44. package/lib/types/events/EventGenericDocument.d.ts +10 -10
  45. package/lib/types/realtime/RealtimeScope.d.ts +1 -1
  46. package/lib/types/realtime/RealtimeUsers.d.ts +1 -1
  47. package/lib/types/realtime/RoomList.d.ts +1 -1
  48. package/lib/util/bufferedPassThrough.d.ts +4 -4
  49. package/lib/util/dump-collection.js +21 -16
  50. package/lib/util/name-generator.d.ts +1 -1
  51. package/package.json +15 -15
@@ -363,7 +363,10 @@ class DocumentController extends NativeController {
363
363
  async count(request) {
364
364
  const { searchBody } = request.getSearchParams();
365
365
  const { index, collection } = request.getIndexAndCollection();
366
-
366
+ const lang = request.getLangParam();
367
+ if (lang === "koncorde") {
368
+ searchBody.query = await this.translateKoncorde(searchBody.query);
369
+ }
367
370
  const count = await this.ask(
368
371
  "core:storage:public:document:count",
369
372
  index,
@@ -1,6 +1,6 @@
1
1
  import { JSONObject } from "kuzzle-sdk";
2
2
  import { User, Token } from "../../types";
3
- export declare type ContextMisc = {
3
+ export type ContextMisc = {
4
4
  /**
5
5
  * HTTP url
6
6
  * @deprecated use "path" instead
@@ -1,5 +1,5 @@
1
1
  import "../types";
2
- export declare type SerializedIdCard = {
2
+ export type SerializedIdCard = {
3
3
  id: string;
4
4
  ip: string;
5
5
  birthdate: number;
@@ -3,12 +3,12 @@ import { JSONObject } from "kuzzle-sdk";
3
3
  import { RoomList } from "../types";
4
4
  import Long from "long";
5
5
  import "../types/Global";
6
- export declare type SerializedRoomSubscriptions = {
6
+ export type SerializedRoomSubscriptions = {
7
7
  nodeId: string;
8
8
  messageId: Long;
9
9
  subscribers: number;
10
10
  };
11
- export declare type SerializedRoomState = {
11
+ export type SerializedRoomState = {
12
12
  collection: string;
13
13
  filters: string;
14
14
  index: string;
@@ -88,7 +88,7 @@ export default class State {
88
88
  */
89
89
  loadFullState(serialized: SerializedState): void;
90
90
  }
91
- export declare type SerializedState = {
91
+ export type SerializedState = {
92
92
  authStrategies: JSONObject[];
93
93
  rooms: SerializedRoomState[];
94
94
  };
@@ -163,12 +163,13 @@ class Backend {
163
163
  * Starts the Kuzzle application with the defined features
164
164
  */
165
165
  async start() {
166
+ var _a;
166
167
  if (this.started) {
167
168
  throw runtimeError.get("already_started", "start");
168
169
  }
169
170
  this._kuzzle = new kuzzle_1.default(this.config.content);
170
171
  for (const plugin of this.config.content.plugins.common.include) {
171
- const { default: PluginClass } = await Promise.resolve().then(() => __importStar(require(plugin)));
172
+ const { default: PluginClass } = await (_a = plugin, Promise.resolve().then(() => __importStar(require(_a))));
172
173
  this.plugin.use(new PluginClass(), {
173
174
  deprecationWarning: false,
174
175
  name: plugin,
@@ -1,6 +1,6 @@
1
1
  import { ApplicationManager } from "./index";
2
2
  import { JSONObject } from "../../../index";
3
- export declare type DefaultMappings = {
3
+ export type DefaultMappings = {
4
4
  [index: string]: {
5
5
  [collection: string]: {
6
6
  mappings: JSONObject;
@@ -81,12 +81,13 @@ const HTTP_ALLOWED_CONTENT_TYPES = [
81
81
  "application/x-www-form-urlencoded",
82
82
  "multipart/form-data",
83
83
  ];
84
- const HTTP_SKIPPED_HEADERS = ["content-length"];
84
+ const HTTP_SKIPPED_HEADERS = ["content-length", "set-cookie"];
85
85
  const HTTP_HEADER_CONNECTION = Buffer.from("Connection");
86
86
  const HTTP_HEADER_CONTENT_LENGTH = Buffer.from("Content-Length");
87
87
  const HTTP_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN = Buffer.from(
88
88
  "Access-Control-Allow-Origin"
89
89
  );
90
+ const HTTP_HEADER_SET_COOKIE = Buffer.from("Set-Cookie");
90
91
  const HTTP_HEADER_VARY = Buffer.from("Vary");
91
92
  const HTTP_HEADER_TRANSFER_ENCODING = Buffer.from("Transfer-Encoding");
92
93
  const CHUNKED = Buffer.from("chunked");
@@ -702,6 +703,12 @@ class HttpWsProtocol extends Protocol {
702
703
  response.writeHeader(HTTP_HEADER_VARY, ORIGIN);
703
704
  }
704
705
 
706
+ if (request.response.headers["set-cookie"]) {
707
+ for (const cookie of request.response.headers["set-cookie"]) {
708
+ response.writeHeader(HTTP_HEADER_SET_COOKIE, Buffer.from(cookie));
709
+ }
710
+ }
711
+
705
712
  for (const [key, value] of Object.entries(request.response.headers)) {
706
713
  // Skip some headers that are not allowed to be sent or modified
707
714
  if (HTTP_SKIPPED_HEADERS.includes(key.toLowerCase())) {
@@ -68,18 +68,6 @@ const realtimeError = kerror.wrap("core", "realtime");
68
68
  * @property cluster
69
69
  */
70
70
  class Channel {
71
- constructor(roomId, { scope = "all", users = "none", propagate = true, } = {}) {
72
- this.scope = scope;
73
- this.users = users;
74
- this.cluster = propagate;
75
- if (!Channel.SCOPE_ALLOWED_VALUES.includes(this.scope)) {
76
- throw realtimeError.get("invalid_scope");
77
- }
78
- if (!Channel.USERS_ALLOWED_VALUES.includes(this.users)) {
79
- throw realtimeError.get("invalid_users");
80
- }
81
- this.name = `${roomId}-${Channel.hash(this)}`;
82
- }
83
71
  /**
84
72
  * Dummy hash function since we only need to keep the channel configuration.
85
73
  *
@@ -122,6 +110,18 @@ class Channel {
122
110
  }
123
111
  return str;
124
112
  }
113
+ constructor(roomId, { scope = "all", users = "none", propagate = true, } = {}) {
114
+ this.scope = scope;
115
+ this.users = users;
116
+ this.cluster = propagate;
117
+ if (!Channel.SCOPE_ALLOWED_VALUES.includes(this.scope)) {
118
+ throw realtimeError.get("invalid_scope");
119
+ }
120
+ if (!Channel.USERS_ALLOWED_VALUES.includes(this.users)) {
121
+ throw realtimeError.get("invalid_users");
122
+ }
123
+ this.name = `${roomId}-${Channel.hash(this)}`;
124
+ }
125
125
  }
126
126
  exports.Channel = Channel;
127
127
  Channel.USERS_ALLOWED_VALUES = ["all", "in", "out", "none"];
@@ -3,21 +3,21 @@ import { Profile } from "../../model/security/profile";
3
3
  import Repository from "../shared/repository";
4
4
  import { JSONObject } from "kuzzle-sdk";
5
5
  /** @internal */
6
- declare type CreateOrReplaceOptions = {
6
+ type CreateOrReplaceOptions = {
7
7
  method?: string;
8
8
  refresh?: string;
9
9
  strict?: boolean;
10
10
  userId?: string;
11
11
  };
12
12
  /** @internal */
13
- declare type ValidateAndSaveProfileOptions = {
13
+ type ValidateAndSaveProfileOptions = {
14
14
  method?: string;
15
15
  refresh?: string;
16
16
  strict?: boolean;
17
17
  retryOnConflict?: number;
18
18
  };
19
19
  /** @internal */
20
- declare type UpdateOptions = {
20
+ type UpdateOptions = {
21
21
  userId?: string;
22
22
  refresh?: string;
23
23
  strict?: boolean;
@@ -2,7 +2,7 @@ import { Policy, OptimizedPolicy, OptimizedPolicyRestrictions } from "../../type
2
2
  import { Role } from "./role";
3
3
  import { KuzzleRequest } from "../../../index";
4
4
  /** @internal */
5
- declare type InternalProfilePolicy = {
5
+ type InternalProfilePolicy = {
6
6
  role: Role;
7
7
  restrictedTo: OptimizedPolicyRestrictions;
8
8
  };
@@ -1375,6 +1375,7 @@ class ElasticSearch extends Service {
1375
1375
  settings,
1376
1376
  },
1377
1377
  index: await this._getAvailableIndice(index, collection),
1378
+ wait_for_active_shards: await this._getWaitForActiveShards(),
1378
1379
  };
1379
1380
 
1380
1381
  this._checkDynamicProperty(mappings);
@@ -1692,6 +1693,7 @@ class ElasticSearch extends Service {
1692
1693
  mappings,
1693
1694
  settings,
1694
1695
  },
1696
+ wait_for_active_shards: await this._getWaitForActiveShards(),
1695
1697
  });
1696
1698
 
1697
1699
  return null;
@@ -3143,7 +3145,7 @@ class ElasticSearch extends Service {
3143
3145
  return;
3144
3146
  }
3145
3147
 
3146
- await this._client.indices.create({
3148
+ const esRequest = {
3147
3149
  body: {
3148
3150
  aliases: {
3149
3151
  [this._getAlias(index, HIDDEN_COLLECTION)]: {},
@@ -3154,7 +3156,10 @@ class ElasticSearch extends Service {
3154
3156
  },
3155
3157
  },
3156
3158
  index: await this._getAvailableIndice(index, HIDDEN_COLLECTION),
3157
- });
3159
+ wait_for_active_shards: await this._getWaitForActiveShards(),
3160
+ };
3161
+
3162
+ await this._client.indices.create(esRequest);
3158
3163
  } catch (e) {
3159
3164
  throw this._esWrapper.formatESError(e);
3160
3165
  } finally {
@@ -3162,6 +3167,26 @@ class ElasticSearch extends Service {
3162
3167
  }
3163
3168
  }
3164
3169
 
3170
+ /**
3171
+ * We need to always wait for a minimal number of shards to be available
3172
+ * before answering to the client. This is to avoid Elasticsearch node
3173
+ * to return a 404 Not Found error when the client tries to index a
3174
+ * document in the index.
3175
+ * To find the best value for this setting, we need to take into account
3176
+ * the number of nodes in the cluster and the number of shards per index.
3177
+ */
3178
+ async _getWaitForActiveShards() {
3179
+ const { body } = await this._client.cat.nodes({ format: "json" });
3180
+
3181
+ const numberOfNodes = body.length;
3182
+
3183
+ if (numberOfNodes > 1) {
3184
+ return "all";
3185
+ }
3186
+
3187
+ return 1;
3188
+ }
3189
+
3165
3190
  /**
3166
3191
  * Scroll indice in elasticsearch and return all document that match the filter
3167
3192
  * /!\ throws a write_limit_exceed error: this method is intended to be used
@@ -25,15 +25,15 @@ exports.Controller = void 0;
25
25
  * Base class to declare a controller class
26
26
  */
27
27
  class Controller {
28
- constructor(app) {
29
- this.app = app;
30
- }
31
28
  /**
32
29
  * EmbeddedSDK instance
33
30
  */
34
31
  get sdk() {
35
32
  return this.app.sdk;
36
33
  }
34
+ constructor(app) {
35
+ this.app = app;
36
+ }
37
37
  }
38
38
  exports.Controller = Controller;
39
39
  //# sourceMappingURL=Controller.js.map
@@ -13,7 +13,7 @@ import { KuzzleRequest } from "../api/request";
13
13
  * }
14
14
  * }
15
15
  */
16
- export declare type ControllerDefinition = {
16
+ export type ControllerDefinition = {
17
17
  /**
18
18
  * Definition of controller actions
19
19
  *
@@ -64,7 +64,7 @@ export declare type ControllerDefinition = {
64
64
  /**
65
65
  * Http route definition
66
66
  */
67
- export declare type HttpRoute = {
67
+ export type HttpRoute = {
68
68
  /**
69
69
  * HTTP verb.
70
70
  */
@@ -1,5 +1,5 @@
1
1
  /** @internal */
2
- export declare type ControllerRight = {
2
+ export type ControllerRight = {
3
3
  actions: {
4
4
  [action: string]: boolean;
5
5
  };
@@ -17,6 +17,6 @@ export declare type ControllerRight = {
17
17
  * }
18
18
  * }
19
19
  */
20
- export declare type ControllerRights = {
20
+ export type ControllerRights = {
21
21
  [controller: string]: ControllerRight;
22
22
  };
@@ -2,7 +2,7 @@
2
2
  /// <reference types="node" />
3
3
  import EventEmitter from "events";
4
4
  import Inspector from "inspector";
5
- export declare type DebugModuleOptions = {
5
+ export type DebugModuleOptions = {
6
6
  methods?: string[];
7
7
  events?: string[];
8
8
  };
@@ -2,7 +2,7 @@
2
2
  * Deprecation warning about a specific feature.
3
3
  * Only available in developement mode (global.NODE_ENV=development)
4
4
  */
5
- export declare type Deprecation = {
5
+ export type Deprecation = {
6
6
  /**
7
7
  * Version since the feature is deprecated
8
8
  */
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Describe an event with it's name and the handler function arguments
3
3
  */
4
- export declare type EventDefinition = {
4
+ export type EventDefinition = {
5
5
  /**
6
6
  * Name of the event
7
7
  *
@@ -17,18 +17,18 @@ export declare type EventDefinition = {
17
17
  /**
18
18
  * Handler for hook events
19
19
  */
20
- export declare type HookEventHandler<TEventDefinition extends EventDefinition = EventDefinition> = (...args: TEventDefinition["args"]) => void;
20
+ export type HookEventHandler<TEventDefinition extends EventDefinition = EventDefinition> = (...args: TEventDefinition["args"]) => void;
21
21
  /**
22
22
  * Handler for pipe event.
23
23
  *
24
24
  * It should return a promise resolving the first received argument.
25
25
  */
26
- export declare type PipeEventHandler<TEventDefinition extends EventDefinition = EventDefinition> = (...args: TEventDefinition["args"]) => Promise<TEventDefinition["args"][0]>;
26
+ export type PipeEventHandler<TEventDefinition extends EventDefinition = EventDefinition> = (...args: TEventDefinition["args"]) => Promise<TEventDefinition["args"][0]>;
27
27
  /**
28
28
  * Handler for cluster event.
29
29
  */
30
- export declare type ClusterEventHandler<TEventDefinition extends EventDefinition = EventDefinition> = (...args: TEventDefinition["args"]) => any;
30
+ export type ClusterEventHandler<TEventDefinition extends EventDefinition = EventDefinition> = (...args: TEventDefinition["args"]) => any;
31
31
  /**
32
32
  * @deprecated Use HookEventHandler, PipeEventHandler or ClusterEventHandler
33
33
  */
34
- export declare type EventHandler = (...payload: any) => any;
34
+ export type EventHandler = (...payload: any) => any;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import { Readable } from "stream";
3
- export declare type HttpStreamProperties = {
3
+ export type HttpStreamProperties = {
4
4
  totalBytes?: number;
5
5
  };
6
6
  /**
@@ -26,16 +26,16 @@ exports.HttpStream = void 0;
26
26
  * and provide additional informations about the given data
27
27
  */
28
28
  class HttpStream {
29
+ get readableState() {
30
+ // @ts-ignore
31
+ return this.stream._readableState;
32
+ }
29
33
  constructor(readableStream, { totalBytes = -1 } = {}) {
30
34
  this._destroyed = false;
31
35
  this.stream = readableStream;
32
36
  this.totalBytes = totalBytes;
33
37
  this._destroyed = readableStream.destroyed;
34
38
  }
35
- get readableState() {
36
- // @ts-ignore
37
- return this.stream._readableState;
38
- }
39
39
  /**
40
40
  * Returns if the stream is errored
41
41
  */
@@ -1,10 +1,10 @@
1
1
  import { JSONObject } from "../../index";
2
- export declare type InstallationConfig = {
2
+ export type InstallationConfig = {
3
3
  id: string;
4
4
  handler: () => Promise<void>;
5
5
  description?: string;
6
6
  };
7
- export declare type StartOptions = {
7
+ export type StartOptions = {
8
8
  import?: JSONObject;
9
9
  plugins?: JSONObject;
10
10
  secretsFile?: JSONObject;
@@ -12,7 +12,7 @@ export declare type StartOptions = {
12
12
  vaultKey?: JSONObject;
13
13
  installations?: Array<InstallationConfig>;
14
14
  };
15
- export declare type ImportConfig = {
15
+ export type ImportConfig = {
16
16
  mappings?: JSONObject;
17
17
  onExistingUsers?: string;
18
18
  profiles?: JSONObject;
@@ -20,7 +20,7 @@ export declare type ImportConfig = {
20
20
  userMappings?: JSONObject;
21
21
  users?: JSONObject;
22
22
  };
23
- export declare type SupportConfig = {
23
+ export type SupportConfig = {
24
24
  fixtures?: JSONObject;
25
25
  mappings?: JSONObject;
26
26
  securities?: {
@@ -1,5 +1,5 @@
1
1
  import { JSONObject } from "kuzzle-sdk";
2
- export declare type OpenApiDefinition = {
2
+ export type OpenApiDefinition = {
3
3
  swagger?: string;
4
4
  openapi?: string;
5
5
  info: {
@@ -15,7 +15,7 @@
15
15
  * "passwordRegex": "^(?=.*[a-zA-Z])(?=.*[0-9])(?=.{8,})"
16
16
  * }
17
17
  */
18
- export declare type PasswordPolicy = {
18
+ export type PasswordPolicy = {
19
19
  /**
20
20
  * Applies the policy to matching users.
21
21
  *
@@ -7,7 +7,7 @@ import { JSONObject } from "../../index";
7
7
  /**
8
8
  * Allows to define plugins controllers and actions
9
9
  */
10
- export declare type PluginApiDefinition = {
10
+ export type PluginApiDefinition = {
11
11
  /**
12
12
  * Name of the API controller.
13
13
  */
@@ -16,7 +16,7 @@ export declare type PluginApiDefinition = {
16
16
  /**
17
17
  * Allows to define hooks on events
18
18
  */
19
- export declare type PluginHookDefinition = {
19
+ export type PluginHookDefinition = {
20
20
  /**
21
21
  * Event name or wildcard event.
22
22
  */
@@ -25,7 +25,7 @@ export declare type PluginHookDefinition = {
25
25
  /**
26
26
  * Allows to define pipes on events
27
27
  */
28
- export declare type PluginPipeDefinition = {
28
+ export type PluginPipeDefinition = {
29
29
  /**
30
30
  * Event name or wildcard event.
31
31
  */
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * PluginManifest
3
3
  */
4
- export declare type PluginManifest = {
4
+ export type PluginManifest = {
5
5
  /**
6
6
  * Semver range representing plugin compatibility with Kuzzle.
7
7
  * @example ">=2.8.0 <3"
@@ -14,12 +14,12 @@ import { PolicyRestrictions, OptimizedPolicyRestrictions } from "./PolicyRestric
14
14
  * ]
15
15
  * }
16
16
  */
17
- export declare type Policy = {
17
+ export type Policy = {
18
18
  roleId: string;
19
19
  restrictedTo?: PolicyRestrictions[];
20
20
  };
21
21
  /** @internal */
22
- export declare type OptimizedPolicy = {
22
+ export type OptimizedPolicy = {
23
23
  roleId: string;
24
24
  restrictedTo?: OptimizedPolicyRestrictions;
25
25
  };
@@ -8,7 +8,7 @@
8
8
  * "collections": ["foo", "bar"]
9
9
  * }
10
10
  */
11
- export declare type PolicyRestrictions = {
11
+ export type PolicyRestrictions = {
12
12
  index: string;
13
13
  collections: string[];
14
14
  };
@@ -18,4 +18,4 @@ export declare type PolicyRestrictions = {
18
18
  * the key {string} represent the index name
19
19
  * the value {string[]} represent the collection names
20
20
  */
21
- export declare type OptimizedPolicyRestrictions = Map<string, string[]>;
21
+ export type OptimizedPolicyRestrictions = Map<string, string[]>;
@@ -15,7 +15,7 @@
15
15
  * ]
16
16
  * }
17
17
  */
18
- export declare type ProfileDefinition = {
18
+ export type ProfileDefinition = {
19
19
  /**
20
20
  * The rate limit parameter controls how many API requests a user can send,
21
21
  * per second and per node.
@@ -16,7 +16,7 @@
16
16
  * }
17
17
  * }
18
18
  */
19
- export declare type RoleDefinition = {
19
+ export type RoleDefinition = {
20
20
  controllers: {
21
21
  [controllerName: string]: {
22
22
  actions: {
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Allows to define an authentication strategy
3
3
  */
4
- export declare type StrategyDefinition = {
4
+ export type StrategyDefinition = {
5
5
  /**
6
6
  * Strategy name and definition.
7
7
  */
@@ -9,7 +9,7 @@
9
9
  * "collections": ["foo", "bar"]
10
10
  * }
11
11
  */
12
- export declare type Target = {
12
+ export type Target = {
13
13
  index?: string;
14
14
  collections?: string[];
15
15
  };
@@ -1,4 +1,4 @@
1
- export declare type DumpConfiguration = {
1
+ export type DumpConfiguration = {
2
2
  /**
3
3
  * @default false
4
4
  */
@@ -4,7 +4,7 @@
4
4
  * send responses to the client
5
5
  * (see https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS)
6
6
  */
7
- export declare type HttpConfiguration = {
7
+ export type HttpConfiguration = {
8
8
  routes: any;
9
9
  /**
10
10
  * Sets the default Access-Control-Allow-Origin HTTP
@@ -124,4 +124,4 @@ export interface IKuzzleConfiguration {
124
124
  };
125
125
  validation: Record<string, unknown>;
126
126
  }
127
- export declare type KuzzleConfiguration = Partial<IKuzzleConfiguration>;
127
+ export type KuzzleConfiguration = Partial<IKuzzleConfiguration>;
@@ -1,4 +1,4 @@
1
- export declare type LimitsConfiguration = {
1
+ export type LimitsConfiguration = {
2
2
  /**
3
3
  * Number of requests Kuzzle processes simultaneously.
4
4
  *
@@ -1,6 +1,6 @@
1
1
  import { JSONObject } from "../../../index";
2
2
  import { PasswordPolicy } from "../index";
3
- export declare type PluginsConfiguration = {
3
+ export type PluginsConfiguration = {
4
4
  /**
5
5
  * Common configuration for all plugins.
6
6
  */
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import { JSONObject } from "../../../index";
3
3
  import { RoleDefinition, ProfileDefinition } from "../index";
4
- export declare type SecurityConfiguration = {
4
+ export type SecurityConfiguration = {
5
5
  /**
6
6
  * Debugger configuration
7
7
  */
@@ -1,5 +1,5 @@
1
1
  import { JSONObject } from "../../../index";
2
- export declare type ServerConfiguration = {
2
+ export type ServerConfiguration = {
3
3
  /**
4
4
  * The maximum size of an incoming request.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  import { PublicCacheRedisConfiguration, InternalCacheConfiguration, StorageEngineElasticsearch } from "../index";
2
- export declare type ServicesConfiguration = {
2
+ export type ServicesConfiguration = {
3
3
  common: {
4
4
  /**
5
5
  * Time in ms after which a service is considered failing if
@@ -1,4 +1,4 @@
1
- export declare type InternalCacheConfiguration = {
1
+ export type InternalCacheConfiguration = {
2
2
  /**
3
3
  * The cache service relies on Redis sample settings for Redis service (see also https://github.com/luin/ioredis)
4
4
  *
@@ -1,4 +1,4 @@
1
- export declare type PublicCacheRedisConfiguration = {
1
+ export type PublicCacheRedisConfiguration = {
2
2
  /**
3
3
  * @default 'redis'
4
4
  */
@@ -1,5 +1,5 @@
1
1
  import { ClientOptions } from "@elastic/elasticsearch";
2
- export declare type StorageEngineElasticsearch = {
2
+ export type StorageEngineElasticsearch = {
3
3
  /**
4
4
  * @default ['storageEngine']
5
5
  */
@@ -1,17 +1,17 @@
1
1
  /**
2
2
  * Available error class
3
3
  */
4
- export declare type ErrorClassNames = "BadRequestError" | "ExternalServiceError" | "ForbiddenError" | "GatewayTimeoutError" | "InternalError" | "KuzzleError" | "MultipleErrorsError" | "NotFoundError" | "PartialError" | "PluginImplementationError" | "ServiceUnavailableError" | "SizeLimitError" | "UnauthorizedError" | "PreconditionError" | "TooManyRequestsError";
4
+ export type ErrorClassNames = "BadRequestError" | "ExternalServiceError" | "ForbiddenError" | "GatewayTimeoutError" | "InternalError" | "KuzzleError" | "MultipleErrorsError" | "NotFoundError" | "PartialError" | "PluginImplementationError" | "ServiceUnavailableError" | "SizeLimitError" | "UnauthorizedError" | "PreconditionError" | "TooManyRequestsError";
5
5
  /**
6
6
  * Represents a standardized error definition
7
7
  */
8
- export declare type ErrorDefinition = CustomErrorDefinition & {
8
+ export type ErrorDefinition = CustomErrorDefinition & {
9
9
  code: number;
10
10
  };
11
11
  /**
12
12
  * Represents a custom standardized error definition
13
13
  */
14
- export declare type CustomErrorDefinition = {
14
+ export type CustomErrorDefinition = {
15
15
  /**
16
16
  * Error description for documentation purpose
17
17
  */
@@ -2,7 +2,7 @@ import { ErrorDefinition } from "./ErrorDefinition";
2
2
  /**
3
3
  * Represents the domains, subDomains and error names with associated definitions
4
4
  */
5
- export declare type ErrorDomains = {
5
+ export type ErrorDomains = {
6
6
  [domain: string]: {
7
7
  code: number;
8
8
  subDomains?: {
@@ -2,25 +2,25 @@ import { KuzzleRequest, KDocument, JSONObject } from "../../../";
2
2
  /**
3
3
  * Events with documents only having the `_id`
4
4
  */
5
- declare type EventGenericDocumentPartial<name extends string> = {
5
+ type EventGenericDocumentPartial<name extends string> = {
6
6
  name: `generic:document:${name}`;
7
7
  args: [Array<{
8
8
  _id: string;
9
9
  }>, KuzzleRequest];
10
10
  };
11
- export declare type EventGenericDocumentBeforeDelete = EventGenericDocumentPartial<"beforeDelete">;
12
- export declare type EventGenericDocumentAfterDelete = EventGenericDocumentPartial<"afterDelete">;
13
- export declare type EventGenericDocumentBeforeGet = EventGenericDocumentPartial<"beforeGet">;
11
+ export type EventGenericDocumentBeforeDelete = EventGenericDocumentPartial<"beforeDelete">;
12
+ export type EventGenericDocumentAfterDelete = EventGenericDocumentPartial<"afterDelete">;
13
+ export type EventGenericDocumentBeforeGet = EventGenericDocumentPartial<"beforeGet">;
14
14
  /**
15
15
  * Events having entire documents
16
16
  */
17
- declare type EventGenericDocument<name extends string, KDocumentContent> = {
17
+ type EventGenericDocument<name extends string, KDocumentContent> = {
18
18
  name: `generic:document:${name}`;
19
19
  args: [KDocument<KDocumentContent>[], KuzzleRequest];
20
20
  };
21
- export declare type EventGenericDocumentBeforeWrite<KDocumentContent = JSONObject> = EventGenericDocument<"beforeWrite", KDocumentContent>;
22
- export declare type EventGenericDocumentAfterWrite<KDocumentContent = JSONObject> = EventGenericDocument<"afterWrite", KDocumentContent>;
23
- export declare type EventGenericDocumentBeforeUpdate<KDocumentContent = JSONObject> = EventGenericDocument<"beforeUpdate", KDocumentContent>;
24
- export declare type EventGenericDocumentAfterUpdate<KDocumentContent = JSONObject> = EventGenericDocument<"afterUpdate", KDocumentContent>;
25
- export declare type EventGenericDocumentAfterGet<KDocumentContent = JSONObject> = EventGenericDocument<"afterGet", KDocumentContent>;
21
+ export type EventGenericDocumentBeforeWrite<KDocumentContent = JSONObject> = EventGenericDocument<"beforeWrite", KDocumentContent>;
22
+ export type EventGenericDocumentAfterWrite<KDocumentContent = JSONObject> = EventGenericDocument<"afterWrite", KDocumentContent>;
23
+ export type EventGenericDocumentBeforeUpdate<KDocumentContent = JSONObject> = EventGenericDocument<"beforeUpdate", KDocumentContent>;
24
+ export type EventGenericDocumentAfterUpdate<KDocumentContent = JSONObject> = EventGenericDocument<"afterUpdate", KDocumentContent>;
25
+ export type EventGenericDocumentAfterGet<KDocumentContent = JSONObject> = EventGenericDocument<"afterGet", KDocumentContent>;
26
26
  export {};
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * Subscribe to notification of document entering, leaving the scope or both.
3
3
  */
4
- export declare type RealtimeScope = "in" | "out" | "all";
4
+ export type RealtimeScope = "in" | "out" | "all";
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * Subscribe to users entering or leaving the room
3
3
  */
4
- export declare type RealtimeUsers = "in" | "out" | "all" | "none";
4
+ export type RealtimeUsers = "in" | "out" | "all" | "none";
@@ -11,7 +11,7 @@
11
11
  * }
12
12
  *
13
13
  */
14
- export declare type RoomList = {
14
+ export type RoomList = {
15
15
  [index: string]: {
16
16
  [collection: string]: {
17
17
  [roomId: string]: number;
@@ -1,13 +1,13 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
3
  import stream from "stream";
4
- declare type Encoding = BufferEncoding | "buffer";
5
- declare type ChunkData = Buffer | string;
6
- declare type Chunk = {
4
+ type Encoding = BufferEncoding | "buffer";
5
+ type ChunkData = Buffer | string;
6
+ type Chunk = {
7
7
  chunk: ChunkData;
8
8
  encoding: Encoding;
9
9
  };
10
- declare type Callback = (error?: Error) => void;
10
+ type Callback = (error?: Error) => void;
11
11
  /**
12
12
  * This streams accumulate chunks data into a buffer until the amount of data is equal or exceed the buffer size.
13
13
  * Then, it emits a single chunk with the accumulated data.
@@ -171,22 +171,27 @@ class AbstractDumper {
171
171
  this.writeStream.on("error", (error) => {
172
172
  throw error;
173
173
  });
174
- await this.setup();
175
- await this.writeHeader();
176
- let results = await global.kuzzle.ask("core:storage:public:document:search", this.index, this.collection, this.query, {
177
- lang: this.options.lang,
178
- scroll: this.options.scroll,
179
- size: this.options.size,
180
- });
181
- do {
182
- for (const hit of results.hits) {
183
- await this.onResult({
184
- _id: hit._id,
185
- _source: hit._source,
186
- });
187
- }
188
- } while ((results = await this.scroll(results.scrollId)));
189
- await this.tearDown();
174
+ try {
175
+ await this.setup();
176
+ await this.writeHeader();
177
+ let results = await global.kuzzle.ask("core:storage:public:document:search", this.index, this.collection, this.query, {
178
+ lang: this.options.lang,
179
+ scroll: this.options.scroll,
180
+ size: this.options.size,
181
+ });
182
+ do {
183
+ for (const hit of results.hits) {
184
+ await this.onResult({
185
+ _id: hit._id,
186
+ _source: hit._source,
187
+ });
188
+ }
189
+ } while ((results = await this.scroll(results.scrollId)));
190
+ await this.tearDown();
191
+ }
192
+ catch (e) {
193
+ this.writeStream.write(e.toString());
194
+ }
190
195
  this.writeStream.end();
191
196
  return waitWrite;
192
197
  }
@@ -1,4 +1,4 @@
1
- export declare type GenerateRandomNameOpts = {
1
+ export type GenerateRandomNameOpts = {
2
2
  /**
3
3
  * Optional prefix.
4
4
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "kuzzle",
3
3
  "author": "The Kuzzle Team <support@kuzzle.io>",
4
- "version": "2.19.9",
4
+ "version": "2.19.10",
5
5
  "description": "Kuzzle is an open-source solution that handles all the data management through a secured API, with a large choice of protocols.",
6
6
  "bin": "bin/start-kuzzle-server",
7
7
  "scripts": {
@@ -52,10 +52,10 @@
52
52
  "dumpme": "^1.0.3",
53
53
  "eslint-plugin-kuzzle": "^0.0.6",
54
54
  "eventemitter3": "^4.0.7",
55
- "inquirer": "^9.1.1",
56
- "ioredis": "^5.2.3",
55
+ "inquirer": "^9.1.4",
56
+ "ioredis": "^5.2.4",
57
57
  "js-yaml": "^4.1.0",
58
- "json-stable-stringify": "^1.0.1",
58
+ "json-stable-stringify": "^1.0.2",
59
59
  "json2yaml": "^1.1.0",
60
60
  "jsonwebtoken": "^8.5.1",
61
61
  "koncorde": "^4.0.3",
@@ -64,25 +64,25 @@
64
64
  "kuzzle-sdk": "^7.10.3",
65
65
  "kuzzle-vault": "^2.0.4",
66
66
  "lodash": "4.17.21",
67
- "long": "^5.2.0",
67
+ "long": "^5.2.1",
68
68
  "moment": "^2.29.4",
69
69
  "ms": "^2.1.3",
70
70
  "murmurhash-native": "^3.5.0",
71
71
  "ndjson": "^2.0.0",
72
72
  "node-segfault-handler": "^1.1.0",
73
73
  "passport": "^0.6.0",
74
- "protobufjs": "~7.1.0",
74
+ "protobufjs": "~7.1.2",
75
75
  "rc": "1.2.8",
76
- "semver": "^7.3.7",
76
+ "semver": "^7.3.8",
77
77
  "sorted-array": "^2.0.4",
78
78
  "uuid": "^9.0.0",
79
79
  "uWebSockets.js": "https://github.com/uNetworking/uWebSockets.js/archive/refs/tags/v20.0.0.tar.gz",
80
80
  "validator": "^13.7.0",
81
- "winston": "^3.8.1",
81
+ "winston": "^3.8.2",
82
82
  "winston-elasticsearch": "0.17.1",
83
- "winston-syslog": "^2.6.0",
83
+ "winston-syslog": "^2.7.0",
84
84
  "winston-transport": "^4.5.0",
85
- "yargs": "^17.5.1",
85
+ "yargs": "^17.6.2",
86
86
  "zeromq": "6.0.0-beta.6"
87
87
  },
88
88
  "repository": {
@@ -91,13 +91,13 @@
91
91
  },
92
92
  "devDependencies": {
93
93
  "@types/js-yaml": "^4.0.5",
94
- "@types/lodash": "^4.14.184",
94
+ "@types/lodash": "^4.14.190",
95
95
  "async": "^3.2.4",
96
96
  "chokidar": "^3.5.3",
97
97
  "codecov": "^3.8.3",
98
98
  "cucumber": "^6.0.5",
99
99
  "ergol": "^1.0.2",
100
- "mocha": "^9.2.2",
100
+ "mocha": "^10.1.0",
101
101
  "mock-require": "^3.0.3",
102
102
  "mqtt": "^4.3.7",
103
103
  "nyc": "^15.1.0",
@@ -106,11 +106,11 @@
106
106
  "rewire": "^5.0.0",
107
107
  "should": "13.2.3",
108
108
  "should-sinon": "0.0.6",
109
- "sinon": "^13.0.2",
109
+ "sinon": "^14.0.2",
110
110
  "strip-json-comments": "https://github.com/sindresorhus/strip-json-comments/archive/refs/tags/v3.1.1.tar.gz",
111
111
  "ts-node": "^10.9.1",
112
- "typescript": "^4.8.2",
113
- "yaml": "^2.1.1"
112
+ "typescript": "^4.9.3",
113
+ "yaml": "^2.1.3"
114
114
  },
115
115
  "engines": {
116
116
  "node": ">= 12.13.0"