kuzzle 2.60.0-beta.1 → 2.60.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/dist/bin/copy-binaries.js +17 -7
  2. package/dist/bin/start-kuzzle-server +19 -8
  3. package/dist/index.d.ts +2 -1
  4. package/dist/index.js +6 -2
  5. package/dist/lib/api/controllers/adminController.d.ts +9 -3
  6. package/dist/lib/api/controllers/adminController.js +42 -26
  7. package/dist/lib/api/controllers/authController.d.ts +15 -5
  8. package/dist/lib/api/controllers/authController.js +35 -20
  9. package/dist/lib/api/controllers/baseController.js +17 -7
  10. package/dist/lib/api/controllers/bulkController.js +17 -7
  11. package/dist/lib/api/controllers/collectionController.js +17 -7
  12. package/dist/lib/api/controllers/debugController.js +17 -7
  13. package/dist/lib/api/controllers/documentController.js +17 -7
  14. package/dist/lib/api/controllers/indexController.d.ts +1 -1
  15. package/dist/lib/api/controllers/memoryStorageController.js +17 -7
  16. package/dist/lib/api/controllers/securityController.d.ts +30 -28
  17. package/dist/lib/api/controllers/securityController.js +18 -8
  18. package/dist/lib/api/controllers/serverController.d.ts +0 -1
  19. package/dist/lib/api/controllers/serverController.js +17 -7
  20. package/dist/lib/api/documentExtractor.js +17 -7
  21. package/dist/lib/api/funnel.js +19 -9
  22. package/dist/lib/api/httpRoutes.d.ts +2 -1
  23. package/dist/lib/api/openapi/OpenApiManager.d.ts +2 -1
  24. package/dist/lib/api/openapi/openApiGenerator.js +1 -2
  25. package/dist/lib/api/request/kuzzleRequest.d.ts +9 -2
  26. package/dist/lib/api/request/kuzzleRequest.js +21 -7
  27. package/dist/lib/api/request/requestContext.d.ts +7 -2
  28. package/dist/lib/api/request/requestContext.js +17 -7
  29. package/dist/lib/api/request/requestInput.d.ts +1 -1
  30. package/dist/lib/api/request/requestInput.js +17 -7
  31. package/dist/lib/api/request/requestResponse.d.ts +2 -2
  32. package/dist/lib/api/request/requestResponse.js +21 -10
  33. package/dist/lib/cluster/command.d.ts +0 -2
  34. package/dist/lib/cluster/command.js +17 -7
  35. package/dist/lib/cluster/idCardHandler.d.ts +7 -2
  36. package/dist/lib/cluster/idCardHandler.js +24 -3
  37. package/dist/lib/cluster/node.d.ts +15 -3
  38. package/dist/lib/cluster/node.js +112 -40
  39. package/dist/lib/cluster/protobuf/command.proto +23 -22
  40. package/dist/lib/cluster/protobuf/sync.proto +91 -85
  41. package/dist/lib/cluster/publisher.js +17 -7
  42. package/dist/lib/cluster/state.js +17 -7
  43. package/dist/lib/cluster/subscriber.d.ts +0 -2
  44. package/dist/lib/cluster/subscriber.js +17 -7
  45. package/dist/lib/cluster/workers/IDCardRenewer.d.ts +6 -1
  46. package/dist/lib/cluster/workers/IDCardRenewer.js +14 -8
  47. package/dist/lib/config/index.js +20 -14
  48. package/dist/lib/core/auth/formatProcessing.d.ts +1 -1
  49. package/dist/lib/core/auth/formatProcessing.js +3 -3
  50. package/dist/lib/core/auth/passportResponse.d.ts +0 -1
  51. package/dist/lib/core/auth/passportWrapper.js +24 -8
  52. package/dist/lib/core/backend/backend.js +17 -7
  53. package/dist/lib/core/backend/backendConfig.d.ts +1 -1
  54. package/dist/lib/core/backend/backendConfig.js +17 -7
  55. package/dist/lib/core/backend/backendController.js +17 -7
  56. package/dist/lib/core/backend/backendErrors.js +17 -7
  57. package/dist/lib/core/backend/backendHook.js +17 -7
  58. package/dist/lib/core/backend/backendImport.js +17 -7
  59. package/dist/lib/core/backend/backendPipe.d.ts +4 -1
  60. package/dist/lib/core/backend/backendPipe.js +17 -7
  61. package/dist/lib/core/backend/backendPlugin.js +17 -7
  62. package/dist/lib/core/backend/backendStorage.js +8 -8
  63. package/dist/lib/core/backend/backendSubscription.js +17 -7
  64. package/dist/lib/core/backend/backendVault.js +17 -7
  65. package/dist/lib/core/backend/internalLogger.d.ts +7 -7
  66. package/dist/lib/core/debug/kuzzleDebugger.js +17 -7
  67. package/dist/lib/core/network/accessLogger.d.ts +0 -1
  68. package/dist/lib/core/network/accessLogger.js +17 -7
  69. package/dist/lib/core/network/clientConnection.js +17 -7
  70. package/dist/lib/core/network/context.d.ts +0 -1
  71. package/dist/lib/core/network/entryPoint.js +17 -7
  72. package/dist/lib/core/network/httpRouter/routePart.js +17 -7
  73. package/dist/lib/core/network/protocols/httpMessage.d.ts +0 -2
  74. package/dist/lib/core/network/protocols/httpwsProtocol.d.ts +0 -3
  75. package/dist/lib/core/network/protocols/httpwsProtocol.js +17 -7
  76. package/dist/lib/core/network/protocols/mqttProtocol.d.ts +1 -2
  77. package/dist/lib/core/network/protocols/mqttProtocol.js +31 -10
  78. package/dist/lib/core/network/router.js +17 -7
  79. package/dist/lib/core/plugin/plugin.js +17 -7
  80. package/dist/lib/core/plugin/pluginContext.d.ts +20 -9
  81. package/dist/lib/core/plugin/pluginContext.js +39 -24
  82. package/dist/lib/core/plugin/pluginsManager.js +17 -7
  83. package/dist/lib/core/realtime/channel.js +17 -7
  84. package/dist/lib/core/realtime/hotelClerk.d.ts +3 -2
  85. package/dist/lib/core/realtime/hotelClerk.js +17 -7
  86. package/dist/lib/core/realtime/notifier.js +17 -7
  87. package/dist/lib/core/security/profileRepository.js +17 -7
  88. package/dist/lib/core/security/roleRepository.js +17 -7
  89. package/dist/lib/core/security/securityLoader.js +17 -7
  90. package/dist/lib/core/security/tokenRepository.js +18 -8
  91. package/dist/lib/core/security/userRepository.js +17 -7
  92. package/dist/lib/core/shared/ObjectRepository.js +20 -7
  93. package/dist/lib/core/shared/abstractManifest.js +17 -7
  94. package/dist/lib/core/shared/sdk/embeddedSdk.js +20 -8
  95. package/dist/lib/core/shared/sdk/funnelProtocol.js +17 -7
  96. package/dist/lib/core/shared/store.d.ts +11 -1
  97. package/dist/lib/core/shared/store.js +26 -30
  98. package/dist/lib/core/statistics/statistics.d.ts +0 -1
  99. package/dist/lib/core/statistics/statistics.js +17 -7
  100. package/dist/lib/core/storage/clientAdapter.d.ts +4 -6
  101. package/dist/lib/core/storage/clientAdapter.js +24 -18
  102. package/dist/lib/core/storage/indexCache.js +17 -7
  103. package/dist/lib/core/validation/specification.js +1 -2
  104. package/dist/lib/core/validation/types/date.js +17 -7
  105. package/dist/lib/core/validation/types/enum.js +17 -7
  106. package/dist/lib/core/validation/types/geoShape.js +17 -7
  107. package/dist/lib/core/validation/types/geoShapeUtils.js +6 -7
  108. package/dist/lib/core/validation/validation.js +17 -7
  109. package/dist/lib/core/validation/validationUtils.js +24 -15
  110. package/dist/lib/kerror/codes/8-cluster.json +23 -0
  111. package/dist/lib/kerror/codes/index.js +20 -10
  112. package/dist/lib/kerror/errors/kuzzleError.js +18 -8
  113. package/dist/lib/kerror/index.js +31 -18
  114. package/dist/lib/kuzzle/Logger.js +4 -3
  115. package/dist/lib/kuzzle/dumpGenerator.js +17 -7
  116. package/dist/lib/kuzzle/event/KuzzleEventEmitter.d.ts +3 -3
  117. package/dist/lib/kuzzle/event/KuzzleEventEmitter.js +17 -7
  118. package/dist/lib/kuzzle/event/pipeRunner.js +17 -7
  119. package/dist/lib/kuzzle/exitOnFailure.d.ts +13 -0
  120. package/dist/lib/kuzzle/exitOnFailure.js +60 -0
  121. package/dist/lib/kuzzle/internalIndexHandler.js +37 -32
  122. package/dist/lib/kuzzle/kuzzle.d.ts +20 -8
  123. package/dist/lib/kuzzle/kuzzle.js +148 -130
  124. package/dist/lib/model/security/profile.js +17 -7
  125. package/dist/lib/model/security/role.js +17 -7
  126. package/dist/lib/model/security/user.js +17 -7
  127. package/dist/lib/model/storage/apiKey.d.ts +1 -1
  128. package/dist/lib/model/storage/apiKey.js +17 -7
  129. package/dist/lib/service/cache/redis.js +40 -9
  130. package/dist/lib/service/service.js +17 -7
  131. package/dist/lib/service/storage/7/elasticsearch.d.ts +36 -25
  132. package/dist/lib/service/storage/7/elasticsearch.js +73 -55
  133. package/dist/lib/service/storage/8/elasticsearch.d.ts +47 -36
  134. package/dist/lib/service/storage/8/elasticsearch.js +73 -55
  135. package/dist/lib/service/storage/Elasticsearch.d.ts +10 -4
  136. package/dist/lib/types/HttpStream.d.ts +0 -1
  137. package/dist/lib/types/Plugin.js +17 -7
  138. package/dist/lib/types/config/SecurityConfiguration.d.ts +0 -2
  139. package/dist/lib/types/config/storageEngine/StorageEngineElasticsearchConfiguration.d.ts +5 -0
  140. package/dist/lib/types/controllers/GetCurrentUserResponse.d.ts +5 -0
  141. package/dist/lib/types/controllers/GetCurrentUserResponse.js +3 -0
  142. package/dist/lib/types/controllers/ResetSecurityResult.d.ts +5 -0
  143. package/dist/lib/types/controllers/ResetSecurityResult.js +3 -0
  144. package/dist/lib/types/controllers/adminController.type.d.ts +7 -5
  145. package/dist/lib/types/controllers/authController.type.d.ts +7 -5
  146. package/dist/lib/types/core/auth/Serialized.d.ts +14 -0
  147. package/dist/lib/types/core/auth/Serialized.js +3 -0
  148. package/dist/lib/types/core/auth/formatProcessing.type.d.ts +5 -11
  149. package/dist/lib/types/events/EventProtocol.d.ts +0 -2
  150. package/dist/lib/types/index.d.ts +1 -0
  151. package/dist/lib/types/index.js +1 -0
  152. package/dist/lib/types/storage/8/Elasticsearch.d.ts +4 -3
  153. package/dist/lib/util/array.d.ts +1 -1
  154. package/dist/lib/util/array.js +7 -6
  155. package/dist/lib/util/assertType.js +5 -6
  156. package/dist/lib/util/async.js +1 -2
  157. package/dist/lib/util/asyncStore.d.ts +0 -1
  158. package/dist/lib/util/bufferedPassThrough.d.ts +0 -3
  159. package/dist/lib/util/crypto.js +1 -2
  160. package/dist/lib/util/debug.d.ts +0 -1
  161. package/dist/lib/util/debug.js +17 -7
  162. package/dist/lib/util/distributedLock.d.ts +27 -4
  163. package/dist/lib/util/distributedLock.js +69 -16
  164. package/dist/lib/util/dump-collection.d.ts +2 -2
  165. package/dist/lib/util/dump-collection.js +22 -13
  166. package/dist/lib/util/esRequest.js +1 -2
  167. package/dist/lib/util/extractFields.d.ts +16 -7
  168. package/dist/lib/util/extractFields.js +1 -10
  169. package/dist/lib/util/koncordeCompat.js +22 -13
  170. package/dist/lib/util/mutex.d.ts +4 -4
  171. package/dist/lib/util/mutex.js +21 -11
  172. package/dist/lib/util/name-generator.js +2 -2
  173. package/dist/lib/util/requestAssertions.js +27 -18
  174. package/dist/lib/util/safeObject.js +3 -4
  175. package/dist/lib/util/stackTrace.js +2 -3
  176. package/dist/lib/util/thrown.js +1 -2
  177. package/dist/lib/util/time.js +1 -2
  178. package/dist/package.json +22 -15
  179. package/package.json +22 -15
@@ -35,13 +35,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
35
35
  }) : function(o, v) {
36
36
  o["default"] = v;
37
37
  });
38
- var __importStar = (this && this.__importStar) || function (mod) {
39
- if (mod && mod.__esModule) return mod;
40
- var result = {};
41
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
42
- __setModuleDefault(result, mod);
43
- return result;
44
- };
38
+ var __importStar = (this && this.__importStar) || (function () {
39
+ var ownKeys = function(o) {
40
+ ownKeys = Object.getOwnPropertyNames || function (o) {
41
+ var ar = [];
42
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
43
+ return ar;
44
+ };
45
+ return ownKeys(o);
46
+ };
47
+ return function (mod) {
48
+ if (mod && mod.__esModule) return mod;
49
+ var result = {};
50
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
51
+ __setModuleDefault(result, mod);
52
+ return result;
53
+ };
54
+ })();
45
55
  Object.defineProperty(exports, "__esModule", { value: true });
46
56
  exports.ObjectRepository = void 0;
47
57
  const kerror = __importStar(require("../../kerror"));
@@ -183,6 +193,7 @@ class ObjectRepository {
183
193
  * @param options.method -
184
194
  * @returns {Promise}
185
195
  */
196
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- kept for v2 compatibility, see docs/v3-breaking-changes.md
186
197
  persistToDatabase(object, options = {}) {
187
198
  const method = options.method || "createOrReplace";
188
199
  if (method === "create") {
@@ -196,6 +207,7 @@ class ObjectRepository {
196
207
  * @param object - The object to delete
197
208
  * @param options.key - if provided, removes the given key instead of the default one (<collection>/<id>)
198
209
  */
210
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- kept for v2 compatibility, see docs/v3-breaking-changes.md
199
211
  async delete(object, options = {}) {
200
212
  const promises = [];
201
213
  if (this.cacheDb !== cacheDbEnum_1.cacheDbEnum.NONE) {
@@ -329,6 +341,7 @@ class ObjectRepository {
329
341
  * @param {ObjectConstructor} o
330
342
  * @returns {object}
331
343
  */
344
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- kept for v2 compatibility, see docs/v3-breaking-changes.md
332
345
  toDTO(o) {
333
346
  return { ...o };
334
347
  }
@@ -35,13 +35,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
35
35
  }) : function(o, v) {
36
36
  o["default"] = v;
37
37
  });
38
- var __importStar = (this && this.__importStar) || function (mod) {
39
- if (mod && mod.__esModule) return mod;
40
- var result = {};
41
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
42
- __setModuleDefault(result, mod);
43
- return result;
44
- };
38
+ var __importStar = (this && this.__importStar) || (function () {
39
+ var ownKeys = function(o) {
40
+ ownKeys = Object.getOwnPropertyNames || function (o) {
41
+ var ar = [];
42
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
43
+ return ar;
44
+ };
45
+ return ownKeys(o);
46
+ };
47
+ return function (mod) {
48
+ if (mod && mod.__esModule) return mod;
49
+ var result = {};
50
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
51
+ __setModuleDefault(result, mod);
52
+ return result;
53
+ };
54
+ })();
45
55
  const lodash_1 = require("lodash");
46
56
  const path = __importStar(require("node:path"));
47
57
  const semver = __importStar(require("semver"));
@@ -35,13 +35,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
35
35
  }) : function(o, v) {
36
36
  o["default"] = v;
37
37
  });
38
- var __importStar = (this && this.__importStar) || function (mod) {
39
- if (mod && mod.__esModule) return mod;
40
- var result = {};
41
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
42
- __setModuleDefault(result, mod);
43
- return result;
44
- };
38
+ var __importStar = (this && this.__importStar) || (function () {
39
+ var ownKeys = function(o) {
40
+ ownKeys = Object.getOwnPropertyNames || function (o) {
41
+ var ar = [];
42
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
43
+ return ar;
44
+ };
45
+ return ownKeys(o);
46
+ };
47
+ return function (mod) {
48
+ if (mod && mod.__esModule) return mod;
49
+ var result = {};
50
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
51
+ __setModuleDefault(result, mod);
52
+ return result;
53
+ };
54
+ })();
45
55
  var __importDefault = (this && this.__importDefault) || function (mod) {
46
56
  return (mod && mod.__esModule) ? mod : { "default": mod };
47
57
  };
@@ -84,7 +94,9 @@ const warnEmbeddedActions = {
84
94
  class EmbeddedSDK extends kuzzle_sdk_1.Kuzzle {
85
95
  constructor() {
86
96
  // FunnelProtocol is not technically a valid SDK protocol
87
- super(new funnelProtocol_1.FunnelProtocol(), { autoResubscribe: false });
97
+ super(new funnelProtocol_1.FunnelProtocol(), {
98
+ autoResubscribe: false,
99
+ });
88
100
  }
89
101
  /**
90
102
  * Returns a new SDK impersonated with the provided user.
@@ -35,13 +35,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
35
35
  }) : function(o, v) {
36
36
  o["default"] = v;
37
37
  });
38
- var __importStar = (this && this.__importStar) || function (mod) {
39
- if (mod && mod.__esModule) return mod;
40
- var result = {};
41
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
42
- __setModuleDefault(result, mod);
43
- return result;
44
- };
38
+ var __importStar = (this && this.__importStar) || (function () {
39
+ var ownKeys = function(o) {
40
+ ownKeys = Object.getOwnPropertyNames || function (o) {
41
+ var ar = [];
42
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
43
+ return ar;
44
+ };
45
+ return ownKeys(o);
46
+ };
47
+ return function (mod) {
48
+ if (mod && mod.__esModule) return mod;
49
+ var result = {};
50
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
51
+ __setModuleDefault(result, mod);
52
+ return result;
53
+ };
54
+ })();
45
55
  Object.defineProperty(exports, "__esModule", { value: true });
46
56
  exports.FunnelProtocol = void 0;
47
57
  const kuzzle_sdk_1 = require("kuzzle-sdk");
@@ -1,6 +1,12 @@
1
1
  import type { StoreCollectionsDefinition } from "../../types";
2
2
  import type { storeScopeEnum } from "../storage/storeScopeEnum";
3
- type StoreAskMethod = (...args: any[]) => Promise<any>;
3
+ /**
4
+ * `Store` is exported, and v2.56.0 declared each of these methods as taking
5
+ * and answering `any`. The arguments are `unknown`, which every call that
6
+ * compiled still satisfies; the answer stays `any`, since any precise type
7
+ * would break a consumer that reads it without narrowing.
8
+ */
9
+ type StoreAskMethod = (...args: unknown[]) => Promise<any>;
4
10
  /**
5
11
  * Wrapper around the document store.
6
12
  * Once instantiated, this class can only access the index passed in the
@@ -52,6 +58,10 @@ export declare class Store {
52
58
  constructor(index: string, scope: storeScopeEnum);
53
59
  /**
54
60
  * Initialize the index, and creates provided collections
61
+ *
62
+ * Every node creates the collections in turn, under the same lock, and
63
+ * waits for it with no limit. The lock is refreshed while the collections
64
+ * are created; if it is lost, this rejects with `MutexLockLostError`.
55
65
  */
56
66
  init(collections?: StoreCollectionsDefinition): Promise<void>;
57
67
  /**
@@ -35,19 +35,29 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
35
35
  }) : function(o, v) {
36
36
  o["default"] = v;
37
37
  });
38
- var __importStar = (this && this.__importStar) || function (mod) {
39
- if (mod && mod.__esModule) return mod;
40
- var result = {};
41
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
42
- __setModuleDefault(result, mod);
43
- return result;
44
- };
38
+ var __importStar = (this && this.__importStar) || (function () {
39
+ var ownKeys = function(o) {
40
+ ownKeys = Object.getOwnPropertyNames || function (o) {
41
+ var ar = [];
42
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
43
+ return ar;
44
+ };
45
+ return ownKeys(o);
46
+ };
47
+ return function (mod) {
48
+ if (mod && mod.__esModule) return mod;
49
+ var result = {};
50
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
51
+ __setModuleDefault(result, mod);
52
+ return result;
53
+ };
54
+ })();
45
55
  Object.defineProperty(exports, "__esModule", { value: true });
46
56
  exports.Store = void 0;
47
57
  const kerror = __importStar(require("../../kerror"));
48
58
  const async_1 = require("../../util/async");
49
59
  const esRequest_1 = require("../../util/esRequest");
50
- const mutex_1 = require("../../util/mutex");
60
+ const distributedLock_1 = require("../../util/distributedLock");
51
61
  /**
52
62
  * The store methods that are nothing but an ask on a
53
63
  * `core:storage:<scope>:<suffix>` event taking the index as its first
@@ -114,28 +124,13 @@ class Store {
114
124
  }
115
125
  /**
116
126
  * Initialize the index, and creates provided collections
127
+ *
128
+ * Every node creates the collections in turn, under the same lock, and
129
+ * waits for it with no limit. The lock is refreshed while the collections
130
+ * are created; if it is lost, this rejects with `MutexLockLostError`.
117
131
  */
118
132
  async init(collections = {}) {
119
- const creatingMutex = new mutex_1.Mutex(`Store.init(${this.index})`, {
120
- timeout: 0,
121
- ttl: 30000,
122
- });
123
- if (await creatingMutex.lock()) {
124
- try {
125
- await this.createCollections(collections, {
126
- indexCacheOnly: false,
127
- });
128
- }
129
- finally {
130
- await creatingMutex.unlock();
131
- }
132
- }
133
- else {
134
- await creatingMutex.wait({ timeout: -1 });
135
- await this.createCollections(collections, {
136
- indexCacheOnly: true,
137
- });
138
- }
133
+ await (0, distributedLock_1.withLock)(`Store.init(${this.index})`, () => this.createCollections(collections, { indexCacheOnly: false }), { retryAttempts: Number.POSITIVE_INFINITY });
139
134
  }
140
135
  /**
141
136
  * Creates collections with the provided mappings
@@ -166,11 +161,12 @@ class Store {
166
161
  ? null
167
162
  : (0, esRequest_1.getESIndexDynamicSettings)(config.settings);
168
163
  const existingSettings = await global.kuzzle.ask(`core:storage:${this.scope}:collection:settings:get`, this.index, collection);
169
- if (!isConfigDeprecated &&
164
+ // A `number_of_shards` left out is not specified, not a mismatch
165
+ if (config.settings.number_of_shards !== undefined &&
170
166
  parseInt(existingSettings.number_of_shards) !==
171
167
  config.settings.number_of_shards) {
172
168
  if (global.NODE_ENV === "development") {
173
- throw kerror.get("storage", "wrong_collection_number_of_shards", collection, this.index, this.scope, "number_of_shards", config.settings.number_of_shards, existingSettings.number_of_shards);
169
+ throw kerror.get("services", "storage", "wrong_es_static_settings_for_collection_recreation", collection, this.index, this.scope, "number_of_shards", config.settings.number_of_shards, existingSettings.number_of_shards);
174
170
  }
175
171
  this.logger.warn(`Attempt to recreate an existing collection ${collection} of index ${this.index} of scope ${this.scope} with non matching static setting : number_of_shards at ${config.settings.number_of_shards} while existing one is at ${existingSettings.number_of_shards}`);
176
172
  }
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import type { Request, RequestContext } from "../../api/request";
3
2
  type StatsMaps = {
4
3
  completedRequests: Map<string, number>;
@@ -35,13 +35,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
35
35
  }) : function(o, v) {
36
36
  o["default"] = v;
37
37
  });
38
- var __importStar = (this && this.__importStar) || function (mod) {
39
- if (mod && mod.__esModule) return mod;
40
- var result = {};
41
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
42
- __setModuleDefault(result, mod);
43
- return result;
44
- };
38
+ var __importStar = (this && this.__importStar) || (function () {
39
+ var ownKeys = function(o) {
40
+ ownKeys = Object.getOwnPropertyNames || function (o) {
41
+ var ar = [];
42
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
43
+ return ar;
44
+ };
45
+ return ownKeys(o);
46
+ };
47
+ return function (mod) {
48
+ if (mod && mod.__esModule) return mod;
49
+ var result = {};
50
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
51
+ __setModuleDefault(result, mod);
52
+ return result;
53
+ };
54
+ })();
45
55
  Object.defineProperty(exports, "__esModule", { value: true });
46
56
  const kerror = __importStar(require("../../kerror"));
47
57
  const errorApiAssert = kerror.wrap("api", "assert");
@@ -15,7 +15,7 @@ interface LoadMappingsOptions extends WriteScopeOptions {
15
15
  }
16
16
  /** `{ index: { collection: payload } }`, as the fixtures and mappings
17
17
  * import payloads are shaped. */
18
- type ImportPayload = Record<string, Record<string, JSONObject>>;
18
+ type ImportPayload = Record<string, Record<string, JSONObject[]>>;
19
19
  /**
20
20
  * Storage client adapter to perform validation on index/collection existence
21
21
  * and to maintain the index/collection cache.
@@ -23,10 +23,8 @@ type ImportPayload = Record<string, Record<string, JSONObject>>;
23
23
  declare class ClientAdapter {
24
24
  es: Elasticsearch;
25
25
  /**
26
- * The version-specific ES service (ES7 or ES8). Its type is whatever
27
- * `Elasticsearch` exposes — which is `any` today, and is tracked there as
28
- * TD-13; referencing it rather than re-writing `any` keeps that one hole
29
- * counted once, at its source.
26
+ * The version-specific ES service: `ES7 | ES8`, as `Elasticsearch` declares
27
+ * it. Each call below type-checks against both.
30
28
  */
31
29
  client: Elasticsearch["client"];
32
30
  scope: storeScopeEnum;
@@ -93,7 +91,7 @@ declare class ClientAdapter {
93
91
  * @returns {Promise}
94
92
  */
95
93
  loadFixtures(fixtures?: ImportPayload, { refresh }?: {
96
- refresh?: string;
94
+ refresh?: boolean | "wait_for";
97
95
  }): Promise<void>;
98
96
  /**
99
97
  * Load database mappings into Kuzzle
@@ -35,18 +35,28 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
35
35
  }) : function(o, v) {
36
36
  o["default"] = v;
37
37
  });
38
- var __importStar = (this && this.__importStar) || function (mod) {
39
- if (mod && mod.__esModule) return mod;
40
- var result = {};
41
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
42
- __setModuleDefault(result, mod);
43
- return result;
44
- };
38
+ var __importStar = (this && this.__importStar) || (function () {
39
+ var ownKeys = function(o) {
40
+ ownKeys = Object.getOwnPropertyNames || function (o) {
41
+ var ar = [];
42
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
43
+ return ar;
44
+ };
45
+ return ownKeys(o);
46
+ };
47
+ return function (mod) {
48
+ if (mod && mod.__esModule) return mod;
49
+ var result = {};
50
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
51
+ __setModuleDefault(result, mod);
52
+ return result;
53
+ };
54
+ })();
45
55
  const Elasticsearch_1 = require("../../service/storage/Elasticsearch");
46
56
  const indexCache_1 = require("./indexCache");
47
57
  const safeObject_1 = require("../../util/safeObject");
48
58
  const kerror = __importStar(require("../../kerror"));
49
- const mutex_1 = require("../../util/mutex"); // NOSONAR: see loadMappings
59
+ const distributedLock_1 = require("../../util/distributedLock");
50
60
  require("../../types/Global");
51
61
  const servicesError = kerror.wrap("services", "storage");
52
62
  /**
@@ -904,12 +914,11 @@ class ClientAdapter {
904
914
  if (!(0, safeObject_1.isPlainObject)(fixtures)) {
905
915
  throw kerror.get("api", "assert", "invalid_argument", fixtures, "object");
906
916
  }
907
- // NOSONAR: `Mutex` is deprecated in favour of `withLock`, but the two use
908
- // incompatible acquisition/TTL formats and must not contend on the same
909
- // key — swapping it is a behaviour change, deferred to #2894.
910
- const mutex = new mutex_1.Mutex("loadMappings", { timeout: -1, ttl: 60000 }); // NOSONAR
911
- await mutex.lock();
912
- try {
917
+ // Mapping loads run one at a time across the cluster, with no retry
918
+ // limit (the `Mutex` it replaces waited forever too). The lock is
919
+ // refreshed while the mappings load; if it is lost, `loadMappings`
920
+ // rejects with `MutexLockLostError`.
921
+ await (0, distributedLock_1.withLock)("loadMappings", async () => {
913
922
  for (const [index, collections] of Object.entries(fixtures)) {
914
923
  if (!(0, safeObject_1.isPlainObject)(collections)) {
915
924
  throw kerror.get("api", "assert", "invalid_argument", collections, "object");
@@ -918,10 +927,7 @@ class ClientAdapter {
918
927
  await this._loadCollectionMappings(index, collection, mappings, options);
919
928
  }
920
929
  }
921
- }
922
- finally {
923
- await mutex.unlock();
924
- }
930
+ }, { retryAttempts: Number.POSITIVE_INFINITY, ttl: 60000 });
925
931
  }
926
932
  /**
927
933
  * Creates one index/collection pair from an import payload. Extracted from
@@ -35,13 +35,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
35
35
  }) : function(o, v) {
36
36
  o["default"] = v;
37
37
  });
38
- var __importStar = (this && this.__importStar) || function (mod) {
39
- if (mod && mod.__esModule) return mod;
40
- var result = {};
41
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
42
- __setModuleDefault(result, mod);
43
- return result;
44
- };
38
+ var __importStar = (this && this.__importStar) || (function () {
39
+ var ownKeys = function(o) {
40
+ ownKeys = Object.getOwnPropertyNames || function (o) {
41
+ var ar = [];
42
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
43
+ return ar;
44
+ };
45
+ return ownKeys(o);
46
+ };
47
+ return function (mod) {
48
+ if (mod && mod.__esModule) return mod;
49
+ var result = {};
50
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
51
+ __setModuleDefault(result, mod);
52
+ return result;
53
+ };
54
+ })();
45
55
  Object.defineProperty(exports, "__esModule", { value: true });
46
56
  exports.IndexCache = void 0;
47
57
  const kerror = __importStar(require("../../kerror"));
@@ -20,7 +20,7 @@
20
20
  * limitations under the License.
21
21
  */
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.configuredSpecifications = void 0;
23
+ exports.configuredSpecifications = configuredSpecifications;
24
24
  /**
25
25
  * The configuration's startup specifications (`validation`), read as what
26
26
  * they are. The configuration's type declares them `Record<string, unknown>`
@@ -30,5 +30,4 @@ exports.configuredSpecifications = void 0;
30
30
  function configuredSpecifications() {
31
31
  return global.kuzzle.config.validation;
32
32
  }
33
- exports.configuredSpecifications = configuredSpecifications;
34
33
  //# sourceMappingURL=specification.js.map
@@ -35,13 +35,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
35
35
  }) : function(o, v) {
36
36
  o["default"] = v;
37
37
  });
38
- var __importStar = (this && this.__importStar) || function (mod) {
39
- if (mod && mod.__esModule) return mod;
40
- var result = {};
41
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
42
- __setModuleDefault(result, mod);
43
- return result;
44
- };
38
+ var __importStar = (this && this.__importStar) || (function () {
39
+ var ownKeys = function(o) {
40
+ ownKeys = Object.getOwnPropertyNames || function (o) {
41
+ var ar = [];
42
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
43
+ return ar;
44
+ };
45
+ return ownKeys(o);
46
+ };
47
+ return function (mod) {
48
+ if (mod && mod.__esModule) return mod;
49
+ var result = {};
50
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
51
+ __setModuleDefault(result, mod);
52
+ return result;
53
+ };
54
+ })();
45
55
  var __importDefault = (this && this.__importDefault) || function (mod) {
46
56
  return (mod && mod.__esModule) ? mod : { "default": mod };
47
57
  };
@@ -35,13 +35,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
35
35
  }) : function(o, v) {
36
36
  o["default"] = v;
37
37
  });
38
- var __importStar = (this && this.__importStar) || function (mod) {
39
- if (mod && mod.__esModule) return mod;
40
- var result = {};
41
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
42
- __setModuleDefault(result, mod);
43
- return result;
44
- };
38
+ var __importStar = (this && this.__importStar) || (function () {
39
+ var ownKeys = function(o) {
40
+ ownKeys = Object.getOwnPropertyNames || function (o) {
41
+ var ar = [];
42
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
43
+ return ar;
44
+ };
45
+ return ownKeys(o);
46
+ };
47
+ return function (mod) {
48
+ if (mod && mod.__esModule) return mod;
49
+ var result = {};
50
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
51
+ __setModuleDefault(result, mod);
52
+ return result;
53
+ };
54
+ })();
45
55
  var __importDefault = (this && this.__importDefault) || function (mod) {
46
56
  return (mod && mod.__esModule) ? mod : { "default": mod };
47
57
  };
@@ -35,13 +35,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
35
35
  }) : function(o, v) {
36
36
  o["default"] = v;
37
37
  });
38
- var __importStar = (this && this.__importStar) || function (mod) {
39
- if (mod && mod.__esModule) return mod;
40
- var result = {};
41
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
42
- __setModuleDefault(result, mod);
43
- return result;
44
- };
38
+ var __importStar = (this && this.__importStar) || (function () {
39
+ var ownKeys = function(o) {
40
+ ownKeys = Object.getOwnPropertyNames || function (o) {
41
+ var ar = [];
42
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
43
+ return ar;
44
+ };
45
+ return ownKeys(o);
46
+ };
47
+ return function (mod) {
48
+ if (mod && mod.__esModule) return mod;
49
+ var result = {};
50
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
51
+ __setModuleDefault(result, mod);
52
+ return result;
53
+ };
54
+ })();
45
55
  var __importDefault = (this && this.__importDefault) || function (mod) {
46
56
  return (mod && mod.__esModule) ? mod : { "default": mod };
47
57
  };
@@ -20,7 +20,12 @@
20
20
  * limitations under the License.
21
21
  */
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.isEnvelope = exports.isPolygon = exports.isPolygonPart = exports.isLine = exports.isPointEqual = exports.isPoint = void 0;
23
+ exports.isPoint = isPoint;
24
+ exports.isPointEqual = isPointEqual;
25
+ exports.isLine = isLine;
26
+ exports.isPolygonPart = isPolygonPart;
27
+ exports.isPolygon = isPolygon;
28
+ exports.isEnvelope = isEnvelope;
24
29
  /**
25
30
  * The coordinate predicates a GeoJSON-like shape is checked against.
26
31
  *
@@ -39,37 +44,31 @@ function isPoint(point) {
39
44
  point[1] < -90 ||
40
45
  point[1] > 90);
41
46
  }
42
- exports.isPoint = isPoint;
43
47
  function isPointEqual(pointA, pointB) {
44
48
  return pointA[0] === pointB[0] && pointA[1] === pointB[1];
45
49
  }
46
- exports.isPointEqual = isPointEqual;
47
50
  function isLine(line) {
48
51
  if (!Array.isArray(line) || line.length < 2) {
49
52
  return false;
50
53
  }
51
54
  return line.every((point) => isPoint(point));
52
55
  }
53
- exports.isLine = isLine;
54
56
  function isPolygonPart(polygonPart) {
55
57
  return (Array.isArray(polygonPart) &&
56
58
  polygonPart.length >= 4 &&
57
59
  isLine(polygonPart) &&
58
60
  isPointEqual(polygonPart[0], polygonPart.at(-1)));
59
61
  }
60
- exports.isPolygonPart = isPolygonPart;
61
62
  function isPolygon(polygon) {
62
63
  if (!Array.isArray(polygon)) {
63
64
  return false;
64
65
  }
65
66
  return polygon.every((polygonPart) => isPolygonPart(polygonPart));
66
67
  }
67
- exports.isPolygon = isPolygon;
68
68
  function isEnvelope(envelope) {
69
69
  if (!Array.isArray(envelope) || envelope.length !== 2) {
70
70
  return false;
71
71
  }
72
72
  return isPoint(envelope[0]) && isPoint(envelope[1]);
73
73
  }
74
- exports.isEnvelope = isEnvelope;
75
74
  //# sourceMappingURL=geoShapeUtils.js.map
@@ -35,13 +35,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
35
35
  }) : function(o, v) {
36
36
  o["default"] = v;
37
37
  });
38
- var __importStar = (this && this.__importStar) || function (mod) {
39
- if (mod && mod.__esModule) return mod;
40
- var result = {};
41
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
42
- __setModuleDefault(result, mod);
43
- return result;
44
- };
38
+ var __importStar = (this && this.__importStar) || (function () {
39
+ var ownKeys = function(o) {
40
+ ownKeys = Object.getOwnPropertyNames || function (o) {
41
+ var ar = [];
42
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
43
+ return ar;
44
+ };
45
+ return ownKeys(o);
46
+ };
47
+ return function (mod) {
48
+ if (mod && mod.__esModule) return mod;
49
+ var result = {};
50
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
51
+ __setModuleDefault(result, mod);
52
+ return result;
53
+ };
54
+ })();
45
55
  var __importDefault = (this && this.__importDefault) || function (mod) {
46
56
  return (mod && mod.__esModule) ? mod : { "default": mod };
47
57
  };