kuzzle 2.59.0 → 2.60.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/copy-binaries.js +17 -7
- package/dist/bin/start-kuzzle-server +17 -7
- package/dist/index.d.ts +2 -1
- package/dist/index.js +6 -2
- package/dist/lib/api/controllers/adminController.d.ts +9 -3
- package/dist/lib/api/controllers/adminController.js +42 -26
- package/dist/lib/api/controllers/authController.d.ts +15 -5
- package/dist/lib/api/controllers/authController.js +35 -20
- package/dist/lib/api/controllers/baseController.js +17 -7
- package/dist/lib/api/controllers/bulkController.js +17 -7
- package/dist/lib/api/controllers/collectionController.js +17 -7
- package/dist/lib/api/controllers/debugController.js +17 -7
- package/dist/lib/api/controllers/documentController.js +17 -7
- package/dist/lib/api/controllers/indexController.d.ts +1 -1
- package/dist/lib/api/controllers/memoryStorageController.js +17 -7
- package/dist/lib/api/controllers/securityController.d.ts +30 -28
- package/dist/lib/api/controllers/securityController.js +18 -8
- package/dist/lib/api/controllers/serverController.d.ts +0 -1
- package/dist/lib/api/controllers/serverController.js +17 -7
- package/dist/lib/api/documentExtractor.js +17 -7
- package/dist/lib/api/funnel.js +19 -9
- package/dist/lib/api/httpRoutes.d.ts +2 -1
- package/dist/lib/api/openapi/OpenApiManager.d.ts +2 -1
- package/dist/lib/api/openapi/openApiGenerator.js +1 -2
- package/dist/lib/api/request/kuzzleRequest.d.ts +9 -2
- package/dist/lib/api/request/kuzzleRequest.js +21 -7
- package/dist/lib/api/request/requestContext.d.ts +7 -2
- package/dist/lib/api/request/requestContext.js +17 -7
- package/dist/lib/api/request/requestInput.d.ts +1 -1
- package/dist/lib/api/request/requestInput.js +17 -7
- package/dist/lib/api/request/requestResponse.d.ts +2 -2
- package/dist/lib/api/request/requestResponse.js +21 -10
- package/dist/lib/cluster/command.d.ts +0 -2
- package/dist/lib/cluster/command.js +17 -7
- package/dist/lib/cluster/idCardHandler.d.ts +3 -2
- package/dist/lib/cluster/idCardHandler.js +1 -1
- package/dist/lib/cluster/node.js +69 -64
- package/dist/lib/cluster/protobuf/command.proto +23 -22
- package/dist/lib/cluster/protobuf/sync.proto +91 -85
- package/dist/lib/cluster/publisher.js +17 -7
- package/dist/lib/cluster/state.js +17 -7
- package/dist/lib/cluster/subscriber.d.ts +0 -2
- package/dist/lib/cluster/subscriber.js +17 -7
- package/dist/lib/cluster/workers/IDCardRenewer.d.ts +0 -1
- package/dist/lib/config/index.js +20 -14
- package/dist/lib/core/auth/formatProcessing.d.ts +1 -1
- package/dist/lib/core/auth/formatProcessing.js +3 -3
- package/dist/lib/core/auth/passportResponse.d.ts +0 -1
- package/dist/lib/core/auth/passportWrapper.js +22 -8
- package/dist/lib/core/backend/backend.js +17 -7
- package/dist/lib/core/backend/backendConfig.d.ts +1 -1
- package/dist/lib/core/backend/backendConfig.js +17 -7
- package/dist/lib/core/backend/backendController.js +17 -7
- package/dist/lib/core/backend/backendErrors.js +17 -7
- package/dist/lib/core/backend/backendHook.js +17 -7
- package/dist/lib/core/backend/backendImport.js +17 -7
- package/dist/lib/core/backend/backendPipe.d.ts +4 -1
- package/dist/lib/core/backend/backendPipe.js +17 -7
- package/dist/lib/core/backend/backendPlugin.js +17 -7
- package/dist/lib/core/backend/backendStorage.js +8 -8
- package/dist/lib/core/backend/backendSubscription.js +17 -7
- package/dist/lib/core/backend/backendVault.js +17 -7
- package/dist/lib/core/backend/internalLogger.d.ts +7 -7
- package/dist/lib/core/debug/kuzzleDebugger.js +17 -7
- package/dist/lib/core/network/accessLogger.d.ts +0 -1
- package/dist/lib/core/network/accessLogger.js +17 -7
- package/dist/lib/core/network/clientConnection.js +17 -7
- package/dist/lib/core/network/context.d.ts +0 -1
- package/dist/lib/core/network/entryPoint.js +17 -7
- package/dist/lib/core/network/httpRouter/routePart.js +17 -7
- package/dist/lib/core/network/protocols/httpMessage.d.ts +0 -2
- package/dist/lib/core/network/protocols/httpwsProtocol.d.ts +0 -3
- package/dist/lib/core/network/protocols/httpwsProtocol.js +29 -12
- package/dist/lib/core/network/protocols/mqttProtocol.d.ts +1 -2
- package/dist/lib/core/network/protocols/mqttProtocol.js +31 -10
- package/dist/lib/core/network/router.js +17 -7
- package/dist/lib/core/plugin/plugin.js +17 -7
- package/dist/lib/core/plugin/pluginContext.d.ts +20 -9
- package/dist/lib/core/plugin/pluginContext.js +39 -24
- package/dist/lib/core/plugin/pluginsManager.js +17 -7
- package/dist/lib/core/realtime/channel.js +17 -7
- package/dist/lib/core/realtime/hotelClerk.d.ts +3 -2
- package/dist/lib/core/realtime/hotelClerk.js +17 -7
- package/dist/lib/core/realtime/notifier.js +17 -7
- package/dist/lib/core/security/profileRepository.js +17 -7
- package/dist/lib/core/security/roleRepository.js +17 -7
- package/dist/lib/core/security/securityLoader.js +17 -7
- package/dist/lib/core/security/tokenRepository.js +18 -8
- package/dist/lib/core/security/userRepository.js +17 -7
- package/dist/lib/core/shared/ObjectRepository.js +20 -7
- package/dist/lib/core/shared/abstractManifest.js +17 -7
- package/dist/lib/core/shared/sdk/embeddedSdk.js +20 -8
- package/dist/lib/core/shared/sdk/funnelProtocol.js +17 -7
- package/dist/lib/core/shared/store.d.ts +11 -1
- package/dist/lib/core/shared/store.js +26 -30
- package/dist/lib/core/statistics/statistics.d.ts +0 -1
- package/dist/lib/core/statistics/statistics.js +17 -7
- package/dist/lib/core/storage/clientAdapter.d.ts +4 -6
- package/dist/lib/core/storage/clientAdapter.js +24 -18
- package/dist/lib/core/storage/indexCache.js +17 -7
- package/dist/lib/core/validation/specification.js +1 -2
- package/dist/lib/core/validation/types/date.js +17 -7
- package/dist/lib/core/validation/types/enum.js +17 -7
- package/dist/lib/core/validation/types/geoShape.js +17 -7
- package/dist/lib/core/validation/types/geoShapeUtils.js +6 -7
- package/dist/lib/core/validation/validation.js +17 -7
- package/dist/lib/core/validation/validationUtils.js +24 -15
- package/dist/lib/kerror/codes/index.js +20 -10
- package/dist/lib/kerror/errors/kuzzleError.js +18 -8
- package/dist/lib/kerror/index.js +31 -18
- package/dist/lib/kuzzle/Logger.js +4 -3
- package/dist/lib/kuzzle/dumpGenerator.js +17 -7
- package/dist/lib/kuzzle/event/KuzzleEventEmitter.d.ts +3 -3
- package/dist/lib/kuzzle/event/KuzzleEventEmitter.js +17 -7
- package/dist/lib/kuzzle/event/pipeRunner.js +17 -7
- package/dist/lib/kuzzle/internalIndexHandler.js +37 -32
- package/dist/lib/kuzzle/kuzzle.d.ts +13 -8
- package/dist/lib/kuzzle/kuzzle.js +103 -128
- package/dist/lib/model/security/profile.js +17 -7
- package/dist/lib/model/security/role.js +17 -7
- package/dist/lib/model/security/user.js +17 -7
- package/dist/lib/model/storage/apiKey.d.ts +1 -1
- package/dist/lib/model/storage/apiKey.js +17 -7
- package/dist/lib/service/cache/redis.js +40 -9
- package/dist/lib/service/service.js +17 -7
- package/dist/lib/service/storage/7/elasticsearch.d.ts +36 -25
- package/dist/lib/service/storage/7/elasticsearch.js +73 -55
- package/dist/lib/service/storage/8/elasticsearch.d.ts +47 -36
- package/dist/lib/service/storage/8/elasticsearch.js +73 -55
- package/dist/lib/service/storage/Elasticsearch.d.ts +10 -4
- package/dist/lib/types/HttpStream.d.ts +0 -1
- package/dist/lib/types/Plugin.js +17 -7
- package/dist/lib/types/config/SecurityConfiguration.d.ts +0 -2
- package/dist/lib/types/config/storageEngine/StorageEngineElasticsearchConfiguration.d.ts +5 -0
- package/dist/lib/types/controllers/GetCurrentUserResponse.d.ts +5 -0
- package/dist/lib/types/controllers/GetCurrentUserResponse.js +3 -0
- package/dist/lib/types/controllers/ResetSecurityResult.d.ts +5 -0
- package/dist/lib/types/controllers/ResetSecurityResult.js +3 -0
- package/dist/lib/types/controllers/adminController.type.d.ts +7 -5
- package/dist/lib/types/controllers/authController.type.d.ts +7 -5
- package/dist/lib/types/core/auth/Serialized.d.ts +14 -0
- package/dist/lib/types/core/auth/Serialized.js +3 -0
- package/dist/lib/types/core/auth/formatProcessing.type.d.ts +5 -11
- package/dist/lib/types/events/EventProtocol.d.ts +0 -2
- package/dist/lib/types/index.d.ts +1 -0
- package/dist/lib/types/index.js +1 -0
- package/dist/lib/types/storage/8/Elasticsearch.d.ts +4 -3
- package/dist/lib/util/array.d.ts +1 -1
- package/dist/lib/util/array.js +7 -6
- package/dist/lib/util/assertType.js +5 -6
- package/dist/lib/util/async.js +1 -2
- package/dist/lib/util/asyncStore.d.ts +0 -1
- package/dist/lib/util/bufferedPassThrough.d.ts +0 -3
- package/dist/lib/util/crypto.js +1 -2
- package/dist/lib/util/debug.d.ts +0 -1
- package/dist/lib/util/debug.js +17 -7
- package/dist/lib/util/distributedLock.d.ts +27 -4
- package/dist/lib/util/distributedLock.js +69 -16
- package/dist/lib/util/dump-collection.d.ts +2 -2
- package/dist/lib/util/dump-collection.js +22 -13
- package/dist/lib/util/esRequest.js +1 -2
- package/dist/lib/util/extractFields.d.ts +16 -7
- package/dist/lib/util/extractFields.js +1 -10
- package/dist/lib/util/koncordeCompat.js +22 -13
- package/dist/lib/util/mutex.d.ts +4 -4
- package/dist/lib/util/mutex.js +21 -11
- package/dist/lib/util/name-generator.js +2 -2
- package/dist/lib/util/requestAssertions.js +27 -18
- package/dist/lib/util/safeObject.js +3 -4
- package/dist/lib/util/stackTrace.js +2 -3
- package/dist/lib/util/thrown.js +1 -2
- package/dist/lib/util/time.js +1 -2
- package/dist/package.json +22 -15
- 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 (
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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.Role = void 0;
|
|
47
57
|
const kerror = __importStar(require("../../kerror"));
|
|
@@ -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 (
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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 (
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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 (
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
};
|
|
@@ -53,6 +63,23 @@ const service_1 = __importDefault(require("../service"));
|
|
|
53
63
|
const kerrorLib = __importStar(require("../../kerror"));
|
|
54
64
|
require("../../types/Global");
|
|
55
65
|
const kerror = kerrorLib.wrap("services", "cache");
|
|
66
|
+
/**
|
|
67
|
+
* ioredis 6 changed three connection defaults. Kuzzle 2 pins them back to
|
|
68
|
+
* what ioredis 5 used, so upgrading the library changes nothing on the wire
|
|
69
|
+
* or in how a lost connection is retried. Anything set in `.kuzzlerc` (or
|
|
70
|
+
* from code) still wins: these are only the fallbacks.
|
|
71
|
+
*
|
|
72
|
+
* - `protocol`: ioredis 6 speaks RESP3 by default; RESP2 is what Kuzzle has
|
|
73
|
+
* always used, and what Redis servers older than 6 only understand.
|
|
74
|
+
* - `keepAlive`: ioredis 6 enables TCP keep-alive probes after 30s.
|
|
75
|
+
* - `retryStrategy`: ioredis 6 uses an exponential backoff capped at 5s,
|
|
76
|
+
* plus jitter; ioredis 5 waited 50ms more per attempt, capped at 2s.
|
|
77
|
+
*/
|
|
78
|
+
const IOREDIS_V5_DEFAULTS = {
|
|
79
|
+
keepAlive: 0,
|
|
80
|
+
protocol: 2,
|
|
81
|
+
retryStrategy: (times) => Math.min(times * 50, 2000),
|
|
82
|
+
};
|
|
56
83
|
/**
|
|
57
84
|
* @class Redis
|
|
58
85
|
* @extends Service
|
|
@@ -106,7 +133,7 @@ class Redis extends service_1.default {
|
|
|
106
133
|
const client = config.nodes
|
|
107
134
|
? this._buildClusterClient({
|
|
108
135
|
...config.clusterOptions,
|
|
109
|
-
redisOptions: config.options,
|
|
136
|
+
redisOptions: { ...IOREDIS_V5_DEFAULTS, ...config.options },
|
|
110
137
|
})
|
|
111
138
|
: this._buildClient(config.options ?? {});
|
|
112
139
|
this.client = client;
|
|
@@ -266,7 +293,11 @@ class Redis extends service_1.default {
|
|
|
266
293
|
});
|
|
267
294
|
}
|
|
268
295
|
_buildClient(options) {
|
|
269
|
-
return new ioredis_1.default({
|
|
296
|
+
return new ioredis_1.default({
|
|
297
|
+
...IOREDIS_V5_DEFAULTS,
|
|
298
|
+
...this._config.node,
|
|
299
|
+
...options,
|
|
300
|
+
});
|
|
270
301
|
}
|
|
271
302
|
_buildClusterClient(options) {
|
|
272
303
|
// The caller only reaches here when `nodes` is set; `?? []` is what the
|
|
@@ -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 (
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import _ from "lodash";
|
|
2
2
|
import type { RequestParams } from "sdk-es7";
|
|
3
3
|
import { Client } from "sdk-es7";
|
|
4
|
-
import type { TypeMapping } from "sdk-es7/api/types";
|
|
4
|
+
import type { ElasticsearchVersionInfo, ShardStatistics, TypeMapping } from "sdk-es7/api/types";
|
|
5
5
|
import type { AliasToTargets, CatAliasRecord, InfoResult, JSONObject, KImportError, KImportResult, KMExecuteResult, KRequestBody, KRequestParams } from "../../../types/storage/7/Elasticsearch";
|
|
6
6
|
import type { ValidatedTarget } from "../../../types/Target";
|
|
7
7
|
import { storeScopeEnum } from "../../../core/storage/storeScopeEnum";
|
|
8
|
+
import type { StorageEngineElasticsearch } from "../../../types/config/storageEngine/StorageEngineElasticsearchConfiguration";
|
|
8
9
|
import { QueryTranslator } from "../commons/queryTranslator";
|
|
9
10
|
import ESWrapper from "./esWrapper";
|
|
10
11
|
/**
|
|
@@ -22,16 +23,16 @@ export declare class ES7 {
|
|
|
22
23
|
_scope: storeScopeEnum;
|
|
23
24
|
_indexPrefix: string;
|
|
24
25
|
_esWrapper: ESWrapper;
|
|
25
|
-
_esVersion:
|
|
26
|
+
_esVersion: ElasticsearchVersionInfo | null;
|
|
26
27
|
_translator: QueryTranslator;
|
|
27
28
|
searchBodyKeys: string[];
|
|
28
29
|
scriptKeys: string[];
|
|
29
30
|
scriptAllowedArgs: string[];
|
|
30
31
|
maxScrollDuration: number;
|
|
31
32
|
scrollTTL: number;
|
|
32
|
-
_config:
|
|
33
|
+
_config: StorageEngineElasticsearch;
|
|
33
34
|
private readonly logger;
|
|
34
|
-
constructor(config:
|
|
35
|
+
constructor(config: StorageEngineElasticsearch, scope?: storeScopeEnum);
|
|
35
36
|
get scope(): storeScopeEnum;
|
|
36
37
|
/**
|
|
37
38
|
* Initializes the elasticsearch client
|
|
@@ -85,10 +86,12 @@ export declare class ES7 {
|
|
|
85
86
|
_id: any;
|
|
86
87
|
_score: any;
|
|
87
88
|
_source: any;
|
|
88
|
-
collection:
|
|
89
|
+
collection: string | undefined;
|
|
89
90
|
highlight: any;
|
|
90
|
-
index:
|
|
91
|
-
inner_hits:
|
|
91
|
+
index: string | undefined;
|
|
92
|
+
inner_hits: {
|
|
93
|
+
[k: string]: unknown[];
|
|
94
|
+
} | undefined;
|
|
92
95
|
}[];
|
|
93
96
|
remaining: any;
|
|
94
97
|
scrollId: any;
|
|
@@ -109,7 +112,7 @@ export declare class ES7 {
|
|
|
109
112
|
index?: string;
|
|
110
113
|
collection?: string;
|
|
111
114
|
searchBody?: JSONObject;
|
|
112
|
-
targets?:
|
|
115
|
+
targets?: ValidatedTarget[];
|
|
113
116
|
}, { from, size, scroll, }?: {
|
|
114
117
|
from?: number;
|
|
115
118
|
size?: number;
|
|
@@ -120,10 +123,12 @@ export declare class ES7 {
|
|
|
120
123
|
_id: any;
|
|
121
124
|
_score: any;
|
|
122
125
|
_source: any;
|
|
123
|
-
collection:
|
|
126
|
+
collection: string | undefined;
|
|
124
127
|
highlight: any;
|
|
125
|
-
index:
|
|
126
|
-
inner_hits:
|
|
128
|
+
index: string | undefined;
|
|
129
|
+
inner_hits: {
|
|
130
|
+
[k: string]: unknown[];
|
|
131
|
+
} | undefined;
|
|
127
132
|
}[];
|
|
128
133
|
remaining: any;
|
|
129
134
|
scrollId: any;
|
|
@@ -143,16 +148,22 @@ export declare class ES7 {
|
|
|
143
148
|
* @returns
|
|
144
149
|
*/
|
|
145
150
|
_mapTargetsToAlias(targets: ValidatedTarget[]): AliasToTargets;
|
|
146
|
-
_formatSearchResult(body:
|
|
151
|
+
_formatSearchResult(body: JSONObject, searchInfo?: {
|
|
152
|
+
collection?: string;
|
|
153
|
+
index?: string;
|
|
154
|
+
targets?: ValidatedTarget[];
|
|
155
|
+
}): Promise<{
|
|
147
156
|
aggregations: any;
|
|
148
157
|
hits: {
|
|
149
158
|
_id: any;
|
|
150
159
|
_score: any;
|
|
151
160
|
_source: any;
|
|
152
|
-
collection:
|
|
161
|
+
collection: string | undefined;
|
|
153
162
|
highlight: any;
|
|
154
|
-
index:
|
|
155
|
-
inner_hits:
|
|
163
|
+
index: string | undefined;
|
|
164
|
+
inner_hits: {
|
|
165
|
+
[k: string]: unknown[];
|
|
166
|
+
} | undefined;
|
|
156
167
|
}[];
|
|
157
168
|
remaining: any;
|
|
158
169
|
scrollId: any;
|
|
@@ -355,7 +366,7 @@ export declare class ES7 {
|
|
|
355
366
|
*
|
|
356
367
|
* @returns {Promise.<{ _id, _version, _source }>}
|
|
357
368
|
*/
|
|
358
|
-
deleteFields(index: string, collection: string, id: string, fields: string, { refresh, userId, }?: {
|
|
369
|
+
deleteFields(index: string, collection: string, id: string, fields: string[], { refresh, userId, }?: {
|
|
359
370
|
refresh?: boolean | "wait_for";
|
|
360
371
|
userId?: string | null;
|
|
361
372
|
}): Promise<{
|
|
@@ -410,10 +421,10 @@ export declare class ES7 {
|
|
|
410
421
|
*
|
|
411
422
|
* @returns {Promise.<any[]>} Array of results returned by the callback
|
|
412
423
|
*/
|
|
413
|
-
mExecute(index: string, collection: string, query: JSONObject, callback:
|
|
424
|
+
mExecute(index: string, collection: string, query: JSONObject, callback: (hits: JSONObject[]) => unknown, { size, scrollTTl, }?: {
|
|
414
425
|
size?: number;
|
|
415
426
|
scrollTTl?: string;
|
|
416
|
-
}): Promise<
|
|
427
|
+
}): Promise<unknown[]>;
|
|
417
428
|
/**
|
|
418
429
|
* Creates a new index.
|
|
419
430
|
*
|
|
@@ -439,7 +450,7 @@ export declare class ES7 {
|
|
|
439
450
|
*/
|
|
440
451
|
createCollection(index: string, collection: string, { mappings, settings, }?: {
|
|
441
452
|
mappings?: TypeMapping;
|
|
442
|
-
settings?:
|
|
453
|
+
settings?: JSONObject;
|
|
443
454
|
}): Promise<null>;
|
|
444
455
|
/**
|
|
445
456
|
* Retrieves settings definition for index/type
|
|
@@ -478,7 +489,7 @@ export declare class ES7 {
|
|
|
478
489
|
updateCollection(index: string, collection: string, { mappings, reindexCollection, settings, }?: {
|
|
479
490
|
mappings?: TypeMapping;
|
|
480
491
|
reindexCollection?: boolean;
|
|
481
|
-
settings?:
|
|
492
|
+
settings?: JSONObject;
|
|
482
493
|
}): Promise<null>;
|
|
483
494
|
/**
|
|
484
495
|
* Given index settings we return a new version of index settings
|
|
@@ -603,7 +614,7 @@ export declare class ES7 {
|
|
|
603
614
|
*
|
|
604
615
|
* @returns {Promise.<String[]>}
|
|
605
616
|
*/
|
|
606
|
-
deleteIndexes(indexes?: string[]): Promise<
|
|
617
|
+
deleteIndexes(indexes?: string[]): Promise<string[]>;
|
|
607
618
|
/**
|
|
608
619
|
* Deletes an index
|
|
609
620
|
*
|
|
@@ -624,7 +635,7 @@ export declare class ES7 {
|
|
|
624
635
|
* @returns {Promise.<Object>} { _shards }
|
|
625
636
|
*/
|
|
626
637
|
refreshCollection(index: string, collection: string): Promise<{
|
|
627
|
-
_shards:
|
|
638
|
+
_shards: ShardStatistics;
|
|
628
639
|
}>;
|
|
629
640
|
/**
|
|
630
641
|
* Returns true if the document exists
|
|
@@ -688,7 +699,7 @@ export declare class ES7 {
|
|
|
688
699
|
*
|
|
689
700
|
* @returns {Promise.<Object>} { items, errors }
|
|
690
701
|
*/
|
|
691
|
-
mCreate(index: string, collection: string, documents:
|
|
702
|
+
mCreate(index: string, collection: string, documents: JSONObject[], { refresh, timeout, userId, }?: {
|
|
692
703
|
refresh?: boolean | "wait_for";
|
|
693
704
|
timeout?: string;
|
|
694
705
|
userId?: string | null;
|
|
@@ -865,7 +876,7 @@ export declare class ES7 {
|
|
|
865
876
|
* @return {Promise<*>} the settings of the indice.
|
|
866
877
|
* @private
|
|
867
878
|
*/
|
|
868
|
-
_getSettings(esRequest: RequestParams.IndicesGetSettings): Promise<
|
|
879
|
+
_getSettings(esRequest: RequestParams.IndicesGetSettings): Promise<JSONObject>;
|
|
869
880
|
/**
|
|
870
881
|
* Given index + collection, returns an available indice name.
|
|
871
882
|
* Use this function when creating the associated indice. Otherwise use `_getAlias`.
|
|
@@ -960,7 +971,7 @@ export declare class ES7 {
|
|
|
960
971
|
*
|
|
961
972
|
* @returns {Promise.<Array>} resolve to an array of documents
|
|
962
973
|
*/
|
|
963
|
-
_getAllDocumentsFromQuery(esRequest: RequestParams.Search<
|
|
974
|
+
_getAllDocumentsFromQuery(esRequest: RequestParams.Search<JSONObject>): Promise<any>;
|
|
964
975
|
/**
|
|
965
976
|
* Clean and normalize the searchBody
|
|
966
977
|
* Ensure only allowed parameters are passed to ES
|
|
@@ -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 (
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
};
|
|
@@ -57,7 +67,7 @@ const storeScopeEnum_1 = require("../../../core/storage/storeScopeEnum");
|
|
|
57
67
|
const kerror = __importStar(require("../../../kerror"));
|
|
58
68
|
const didYouMean_1 = __importDefault(require("../../../util/didYouMean"));
|
|
59
69
|
const extractFields_1 = __importDefault(require("../../../util/extractFields"));
|
|
60
|
-
const
|
|
70
|
+
const distributedLock_1 = require("../../../util/distributedLock");
|
|
61
71
|
const name_generator_1 = require("../../../util/name-generator");
|
|
62
72
|
const requestAssertions_1 = require("../../../util/requestAssertions");
|
|
63
73
|
const safeObject_1 = require("../../../util/safeObject");
|
|
@@ -73,6 +83,12 @@ const ROOT_MAPPING_PROPERTIES = [
|
|
|
73
83
|
const CHILD_MAPPING_PROPERTIES = ["type"];
|
|
74
84
|
// Used for collection emulation
|
|
75
85
|
const HIDDEN_COLLECTION = "_kuzzle_keep";
|
|
86
|
+
// The hidden collection locks wait for as long as it takes, as the `Mutex`
|
|
87
|
+
// they replace did: they guard a collection creation, which must not fail
|
|
88
|
+
// only because another request on the same index got there first. The lock
|
|
89
|
+
// is refreshed while held, so a live holder is never overtaken; a crashed
|
|
90
|
+
// one leaves it for at most `ttl` (30 s).
|
|
91
|
+
const HIDDEN_COLLECTION_LOCK = { retryAttempts: Number.POSITIVE_INFINITY };
|
|
76
92
|
const ALIAS_PREFIX = "@"; // @todo next major release: Add ALIAS_PREFIX in FORBIDDEN_CHARS
|
|
77
93
|
const PRIVATE_PREFIX = "%";
|
|
78
94
|
const PUBLIC_PREFIX = "&";
|
|
@@ -184,7 +200,7 @@ class ES7 {
|
|
|
184
200
|
info() {
|
|
185
201
|
const result = {
|
|
186
202
|
type: "elasticsearch",
|
|
187
|
-
version: this._esVersion,
|
|
203
|
+
version: this._esVersion?.number ?? "",
|
|
188
204
|
};
|
|
189
205
|
return this._client
|
|
190
206
|
.info()
|
|
@@ -217,7 +233,6 @@ class ES7 {
|
|
|
217
233
|
const indexes = {};
|
|
218
234
|
let size = 0;
|
|
219
235
|
for (const [indice, indiceInfo] of Object.entries(body.indices ?? {})) {
|
|
220
|
-
const infos = indiceInfo;
|
|
221
236
|
// Ignore non-Kuzzle indices
|
|
222
237
|
if (!indice.startsWith(PRIVATE_PREFIX) &&
|
|
223
238
|
!indice.startsWith(PUBLIC_PREFIX)) {
|
|
@@ -237,12 +252,12 @@ class ES7 {
|
|
|
237
252
|
size: 0,
|
|
238
253
|
}));
|
|
239
254
|
indexStats.collections.push({
|
|
240
|
-
documentCount:
|
|
255
|
+
documentCount: indiceInfo.total.docs.count,
|
|
241
256
|
name: collectionName,
|
|
242
|
-
size:
|
|
257
|
+
size: indiceInfo.total.store.size_in_bytes,
|
|
243
258
|
});
|
|
244
|
-
indexStats.size +=
|
|
245
|
-
size +=
|
|
259
|
+
indexStats.size += indiceInfo.total.store.size_in_bytes;
|
|
260
|
+
size += indiceInfo.total.store.size_in_bytes;
|
|
246
261
|
}
|
|
247
262
|
return {
|
|
248
263
|
indexes: Object.values(indexes),
|
|
@@ -392,7 +407,9 @@ class ES7 {
|
|
|
392
407
|
}
|
|
393
408
|
return aliasToTargets;
|
|
394
409
|
}
|
|
395
|
-
async _formatSearchResult(
|
|
410
|
+
async _formatSearchResult(
|
|
411
|
+
// The ES 7 client does not type its answers.
|
|
412
|
+
body, searchInfo = {}) {
|
|
396
413
|
let aliasToTargets = {};
|
|
397
414
|
const aliasCache = new Map();
|
|
398
415
|
if (searchInfo.targets) {
|
|
@@ -446,11 +463,11 @@ class ES7 {
|
|
|
446
463
|
if (!innerHits) {
|
|
447
464
|
return undefined;
|
|
448
465
|
}
|
|
449
|
-
const
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
return
|
|
466
|
+
const formatted = await Promise.all(Object.entries(innerHits).map(async ([name, innerHit]) => [
|
|
467
|
+
name,
|
|
468
|
+
await bluebird_1.default.map(innerHit.hits.hits, formatHit),
|
|
469
|
+
]));
|
|
470
|
+
return Object.fromEntries(formatted);
|
|
454
471
|
}
|
|
455
472
|
const hits = await bluebird_1.default.map(body.hits.hits, async (hit) => ({
|
|
456
473
|
inner_hits: await formatInnerHits(hit.inner_hits),
|
|
@@ -1114,19 +1131,6 @@ class ES7 {
|
|
|
1114
1131
|
if (collection === HIDDEN_COLLECTION) {
|
|
1115
1132
|
throw kerror.get("services", "storage", "collection_reserved", HIDDEN_COLLECTION);
|
|
1116
1133
|
}
|
|
1117
|
-
const mutex = new mutex_1.Mutex(`hiddenCollection/create/${index}`);
|
|
1118
|
-
try {
|
|
1119
|
-
await mutex.lock();
|
|
1120
|
-
if (await this._hasHiddenCollection(index)) {
|
|
1121
|
-
await this.deleteCollection(index, HIDDEN_COLLECTION);
|
|
1122
|
-
}
|
|
1123
|
-
}
|
|
1124
|
-
catch (error) {
|
|
1125
|
-
throw this._esWrapper.formatESError(error);
|
|
1126
|
-
}
|
|
1127
|
-
finally {
|
|
1128
|
-
await mutex.unlock();
|
|
1129
|
-
}
|
|
1130
1134
|
const requestBody = {
|
|
1131
1135
|
aliases: {
|
|
1132
1136
|
[this._getAlias(index, collection)]: {},
|
|
@@ -1168,6 +1172,19 @@ class ES7 {
|
|
|
1168
1172
|
}
|
|
1169
1173
|
throw this._esWrapper.formatESError(error);
|
|
1170
1174
|
}
|
|
1175
|
+
// Only once the real collection exists: dropping the placeholder first
|
|
1176
|
+
// would leave the index with no indice at all if the creation failed.
|
|
1177
|
+
// Lock and ES errors alike reach the caller through `formatESError`
|
|
1178
|
+
try {
|
|
1179
|
+
await (0, distributedLock_1.withLock)(`hiddenCollection/create/${index}`, async () => {
|
|
1180
|
+
if (await this._hasHiddenCollection(index)) {
|
|
1181
|
+
await this.deleteCollection(index, HIDDEN_COLLECTION);
|
|
1182
|
+
}
|
|
1183
|
+
}, HIDDEN_COLLECTION_LOCK);
|
|
1184
|
+
}
|
|
1185
|
+
catch (error) {
|
|
1186
|
+
throw this._esWrapper.formatESError(error);
|
|
1187
|
+
}
|
|
1171
1188
|
return null;
|
|
1172
1189
|
}
|
|
1173
1190
|
/**
|
|
@@ -1630,7 +1647,11 @@ class ES7 {
|
|
|
1630
1647
|
name: alias,
|
|
1631
1648
|
});
|
|
1632
1649
|
}
|
|
1633
|
-
|
|
1650
|
+
// `createCollection` drops the placeholder through here: recreating it
|
|
1651
|
+
// would undo that.
|
|
1652
|
+
if (collection !== HIDDEN_COLLECTION) {
|
|
1653
|
+
await this._createHiddenCollection(index);
|
|
1654
|
+
}
|
|
1634
1655
|
}
|
|
1635
1656
|
catch (e) {
|
|
1636
1657
|
throw this._esWrapper.formatESError(e);
|
|
@@ -2635,33 +2656,30 @@ class ES7 {
|
|
|
2635
2656
|
* @param {String} index Index name
|
|
2636
2657
|
*/
|
|
2637
2658
|
async _createHiddenCollection(index) {
|
|
2638
|
-
const mutex = new mutex_1.Mutex(`hiddenCollection/${index}`);
|
|
2639
2659
|
try {
|
|
2640
|
-
await
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2660
|
+
await (0, distributedLock_1.withLock)(`hiddenCollection/${index}`, async () => {
|
|
2661
|
+
if (await this._hasHiddenCollection(index)) {
|
|
2662
|
+
return;
|
|
2663
|
+
}
|
|
2664
|
+
const esRequest = {
|
|
2665
|
+
body: {
|
|
2666
|
+
aliases: {
|
|
2667
|
+
[this._getAlias(index, HIDDEN_COLLECTION)]: {},
|
|
2668
|
+
},
|
|
2669
|
+
settings: {
|
|
2670
|
+
number_of_replicas: this._config.defaultSettings.number_of_replicas,
|
|
2671
|
+
number_of_shards: this._config.defaultSettings.number_of_shards,
|
|
2672
|
+
},
|
|
2652
2673
|
},
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2674
|
+
index: await this._getAvailableIndice(index, HIDDEN_COLLECTION),
|
|
2675
|
+
wait_for_active_shards: await this._getWaitForActiveShards(),
|
|
2676
|
+
};
|
|
2677
|
+
await this._client.indices.create(esRequest);
|
|
2678
|
+
}, HIDDEN_COLLECTION_LOCK);
|
|
2658
2679
|
}
|
|
2659
2680
|
catch (e) {
|
|
2660
2681
|
throw this._esWrapper.formatESError(e);
|
|
2661
2682
|
}
|
|
2662
|
-
finally {
|
|
2663
|
-
await mutex.unlock();
|
|
2664
|
-
}
|
|
2665
2683
|
}
|
|
2666
2684
|
/**
|
|
2667
2685
|
* We need to always wait for a minimal number of shards to be available
|