kuzzle 2.60.1 → 2.61.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/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/lib/cluster/idCardHandler.d.ts +11 -1
- package/dist/lib/cluster/idCardHandler.js +10 -2
- package/dist/lib/cluster/node.d.ts +14 -0
- package/dist/lib/cluster/node.js +19 -0
- package/dist/lib/config/index.js +43 -8
- package/dist/lib/core/backend/backendStorage.js +4 -6
- package/dist/lib/core/plugin/pluginContext.js +2 -2
- package/dist/lib/core/storage/clientAdapter.d.ts +13 -10
- package/dist/lib/core/storage/clientAdapter.js +112 -60
- package/dist/lib/core/storage/conformance/capabilityCases.d.ts +3 -0
- package/dist/lib/core/storage/conformance/capabilityCases.js +121 -0
- package/dist/lib/core/storage/conformance/conformanceContext.d.ts +33 -0
- package/dist/lib/core/storage/conformance/conformanceContext.js +97 -0
- package/dist/lib/core/storage/conformance/conformanceEnvironment.d.ts +7 -0
- package/dist/lib/core/storage/conformance/conformanceEnvironment.js +136 -0
- package/dist/lib/core/storage/conformance/coreCases.d.ts +3 -0
- package/dist/lib/core/storage/conformance/coreCases.js +381 -0
- package/dist/lib/core/storage/conformance/storageDriverConformance.d.ts +53 -0
- package/dist/lib/core/storage/conformance/storageDriverConformance.js +89 -0
- package/dist/lib/core/storage/indexCache.d.ts +26 -2
- package/dist/lib/core/storage/indexCache.js +100 -2
- package/dist/lib/core/storage/storageDriverLoader.d.ts +41 -0
- package/dist/lib/core/storage/storageDriverLoader.js +276 -0
- package/dist/lib/core/storage/storageEngine.js +9 -1
- package/dist/lib/core/storage/storageError.d.ts +15 -0
- package/dist/lib/core/storage/storageError.js +36 -0
- package/dist/lib/kerror/codes/1-services.json +35 -0
- package/dist/lib/kerror/codes/8-cluster.json +6 -0
- package/dist/lib/service/storage/builtInDrivers.d.ts +6 -0
- package/dist/lib/service/storage/builtInDrivers.js +103 -0
- package/dist/lib/service/storage/storageService.d.ts +13 -0
- package/dist/lib/service/storage/storageService.js +44 -0
- package/dist/lib/types/config/KuzzleConfiguration.d.ts +8 -0
- package/dist/lib/types/config/storageEngine/StorageEngineElasticsearchConfiguration.d.ts +13 -1
- package/dist/lib/types/index.d.ts +1 -0
- package/dist/lib/types/index.js +1 -0
- package/dist/lib/types/storage/StorageDriver.d.ts +306 -0
- package/dist/lib/types/storage/StorageDriver.js +41 -0
- package/dist/package.json +4 -1
- package/package.json +4 -1
- package/dist/lib/service/storage/7/elasticsearch.d.ts +0 -1054
- package/dist/lib/service/storage/7/elasticsearch.js +0 -3063
- package/dist/lib/service/storage/7/esWrapper.d.ts +0 -36
- package/dist/lib/service/storage/7/esWrapper.js +0 -295
- package/dist/lib/service/storage/8/elasticsearch.d.ts +0 -1047
- package/dist/lib/service/storage/8/elasticsearch.js +0 -3096
- package/dist/lib/service/storage/8/esWrapper.d.ts +0 -36
- package/dist/lib/service/storage/8/esWrapper.js +0 -295
- package/dist/lib/service/storage/Elasticsearch.d.ts +0 -16
- package/dist/lib/service/storage/Elasticsearch.js +0 -48
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Kuzzle, a backend software, self-hostable and ready to use
|
|
4
|
+
* to power modern apps
|
|
5
|
+
*
|
|
6
|
+
* Copyright 2015-2026 Kuzzle
|
|
7
|
+
* mailto: support AT kuzzle.io
|
|
8
|
+
* website: http://kuzzle.io
|
|
9
|
+
*
|
|
10
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
11
|
+
* you may not use this file except in compliance with the License.
|
|
12
|
+
* You may obtain a copy of the License at
|
|
13
|
+
*
|
|
14
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
+
* See the License for the specific language governing permissions and
|
|
20
|
+
* limitations under the License.
|
|
21
|
+
*/
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.storageError = void 0;
|
|
24
|
+
const kerror_1 = require("../../kerror");
|
|
25
|
+
/**
|
|
26
|
+
* The errors a storage driver throws: Kuzzle's `services.storage.*` error
|
|
27
|
+
* codes, with their documented class, status and message (ADR-0003 step 05).
|
|
28
|
+
* An external driver uses them so that a client gets the same error whatever
|
|
29
|
+
* the engine.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* throw storageError.get("not_found", id, index, collection);
|
|
33
|
+
* throw storageError.getFrom(engineError, "unexpected_error", engineError.message);
|
|
34
|
+
*/
|
|
35
|
+
exports.storageError = (0, kerror_1.wrap)("services", "storage");
|
|
36
|
+
//# sourceMappingURL=storageError.js.map
|
|
@@ -352,6 +352,41 @@
|
|
|
352
352
|
"class": "BadRequestError"
|
|
353
353
|
}
|
|
354
354
|
}
|
|
355
|
+
},
|
|
356
|
+
"storage_driver": {
|
|
357
|
+
"code": 6,
|
|
358
|
+
"errors": {
|
|
359
|
+
"not_found": {
|
|
360
|
+
"description": "The package named by services.storageEngine.driver cannot be found. Kuzzle does not start.",
|
|
361
|
+
"code": 1,
|
|
362
|
+
"message": "Cannot find the storage driver \"%s\": %s.",
|
|
363
|
+
"class": "InternalError"
|
|
364
|
+
},
|
|
365
|
+
"invalid_manifest": {
|
|
366
|
+
"description": "The manifest.json of the storage driver named by services.storageEngine.driver is missing or invalid. Kuzzle does not start.",
|
|
367
|
+
"code": 2,
|
|
368
|
+
"message": "Invalid manifest for the storage driver \"%s\": %s.",
|
|
369
|
+
"class": "InternalError"
|
|
370
|
+
},
|
|
371
|
+
"version_mismatch": {
|
|
372
|
+
"description": "The storage driver named by services.storageEngine.driver is not compatible with this Kuzzle version (kuzzleVersion in its manifest). Kuzzle does not start.",
|
|
373
|
+
"code": 3,
|
|
374
|
+
"message": "The storage driver \"%s\" requires Kuzzle %s, this is Kuzzle %s.",
|
|
375
|
+
"class": "InternalError"
|
|
376
|
+
},
|
|
377
|
+
"invalid_driver": {
|
|
378
|
+
"description": "The storage driver named by services.storageEngine.driver does not export a storage driver class, or lacks a method of a capability its manifest declares. Kuzzle does not start.",
|
|
379
|
+
"code": 4,
|
|
380
|
+
"message": "Invalid storage driver \"%s\": %s.",
|
|
381
|
+
"class": "InternalError"
|
|
382
|
+
},
|
|
383
|
+
"unsupported_capability": {
|
|
384
|
+
"description": "The request needs a capability the storage driver does not declare in its manifest (aggregations, mapping updates, statistics or update by query).",
|
|
385
|
+
"code": 5,
|
|
386
|
+
"message": "The storage engine does not support this request: its driver does not declare the \"%s\" capability.",
|
|
387
|
+
"class": "BadRequestError"
|
|
388
|
+
}
|
|
389
|
+
}
|
|
355
390
|
}
|
|
356
391
|
}
|
|
357
392
|
}
|
|
@@ -32,6 +32,12 @@
|
|
|
32
32
|
"code": 3,
|
|
33
33
|
"message": "Failed to join the cluster: timed out (joinTimeout: %sms).",
|
|
34
34
|
"class": "InternalError"
|
|
35
|
+
},
|
|
36
|
+
"storage_driver_mismatch": {
|
|
37
|
+
"description": "The joining node runs another storage driver (package name or version) than a node of the cluster: every node must run the same one. The joining node does not start.",
|
|
38
|
+
"code": 4,
|
|
39
|
+
"message": "This node runs %s, but the cluster node %s runs %s: every cluster node must run the same storage driver.",
|
|
40
|
+
"class": "InternalError"
|
|
35
41
|
}
|
|
36
42
|
}
|
|
37
43
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Client as ClientES7 } from "sdk-es7";
|
|
2
|
+
import type { Client as ClientES8 } from "sdk-es8";
|
|
3
|
+
import type { StorageEngineElasticsearch } from "../../types/config/storageEngine/StorageEngineElasticsearchConfiguration";
|
|
4
|
+
import type { StorageDriverClass } from "../../types/storage/StorageDriver";
|
|
5
|
+
/** The built-in driver of an Elasticsearch major version */
|
|
6
|
+
export declare function builtInStorageDriver(majorVersion: StorageEngineElasticsearch["majorVersion"]): StorageDriverClass<ClientES7 | ClientES8, StorageEngineElasticsearch>;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Kuzzle, a backend software, self-hostable and ready to use
|
|
4
|
+
* to power modern apps
|
|
5
|
+
*
|
|
6
|
+
* Copyright 2015-2026 Kuzzle
|
|
7
|
+
* mailto: support AT kuzzle.io
|
|
8
|
+
* website: http://kuzzle.io
|
|
9
|
+
*
|
|
10
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
11
|
+
* you may not use this file except in compliance with the License.
|
|
12
|
+
* You may obtain a copy of the License at
|
|
13
|
+
*
|
|
14
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
+
* See the License for the specific language governing permissions and
|
|
20
|
+
* limitations under the License.
|
|
21
|
+
*/
|
|
22
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
23
|
+
if (k2 === undefined) k2 = k;
|
|
24
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
25
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
26
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
27
|
+
}
|
|
28
|
+
Object.defineProperty(o, k2, desc);
|
|
29
|
+
}) : (function(o, m, k, k2) {
|
|
30
|
+
if (k2 === undefined) k2 = k;
|
|
31
|
+
o[k2] = m[k];
|
|
32
|
+
}));
|
|
33
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
34
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
35
|
+
}) : function(o, v) {
|
|
36
|
+
o["default"] = v;
|
|
37
|
+
});
|
|
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
|
+
})();
|
|
55
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
56
|
+
exports.builtInStorageDriver = builtInStorageDriver;
|
|
57
|
+
// The built-in Elasticsearch 7 and 8 drivers (ADR-0003 step 06): the
|
|
58
|
+
// packages `kuzzle-storage-es-7` and `kuzzle-storage-es-8`, dependencies of
|
|
59
|
+
// Kuzzle at pinned versions. Dropped from Kuzzle's dependencies at the next
|
|
60
|
+
// major.
|
|
61
|
+
const path = __importStar(require("node:path"));
|
|
62
|
+
const PACKAGES = {
|
|
63
|
+
"7": "kuzzle-storage-es-7",
|
|
64
|
+
"8": "kuzzle-storage-es-8",
|
|
65
|
+
};
|
|
66
|
+
/** The built-in driver of an Elasticsearch major version */
|
|
67
|
+
function builtInStorageDriver(majorVersion) {
|
|
68
|
+
const packageName = PACKAGES[majorVersion];
|
|
69
|
+
if (!packageName) {
|
|
70
|
+
throw new Error("Invalid Elasticsearch version.");
|
|
71
|
+
}
|
|
72
|
+
provideRunningKuzzle(packageName);
|
|
73
|
+
// Loaded here, not at module load: the package requires `kuzzle`, which
|
|
74
|
+
// has to be loaded first.
|
|
75
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
76
|
+
return require(packageName).default;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* A driver package requires `kuzzle`, a peer dependency. In an application,
|
|
80
|
+
* that is the running Kuzzle. When Kuzzle is itself the application (its
|
|
81
|
+
* repository, its Docker image), npm installs another copy of `kuzzle` for
|
|
82
|
+
* that peer dependency, whose error classes the running Kuzzle does not
|
|
83
|
+
* recognize: the running Kuzzle is put in that copy's place.
|
|
84
|
+
*/
|
|
85
|
+
function provideRunningKuzzle(packageName) {
|
|
86
|
+
// `index.js` once built, `index.ts` when run from the sources
|
|
87
|
+
const entry = path.join(__dirname, "../../../index");
|
|
88
|
+
const running = require.cache[`${entry}.js`] ?? require.cache[`${entry}.ts`];
|
|
89
|
+
let peer;
|
|
90
|
+
try {
|
|
91
|
+
peer = require.resolve("kuzzle", {
|
|
92
|
+
paths: [path.dirname(require.resolve(packageName))],
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
// Under vitest, Kuzzle is not in Node's module cache: nothing to provide
|
|
99
|
+
if (running && require.cache[peer] === undefined) {
|
|
100
|
+
require.cache[peer] = running;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=builtInDrivers.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Service from "../service";
|
|
2
|
+
import type { storeScopeEnum } from "../../core/storage/storeScopeEnum";
|
|
3
|
+
import type { StorageEngineElasticsearch } from "../../types/config/storageEngine/StorageEngineElasticsearchConfiguration";
|
|
4
|
+
import type { StorageDriver, StorageDriverClass } from "../../types/storage/StorageDriver";
|
|
5
|
+
/**
|
|
6
|
+
* One storage scope's driver instance, initialized under
|
|
7
|
+
* `services.storageEngine`'s init timeout like every service.
|
|
8
|
+
*/
|
|
9
|
+
export declare class StorageService extends Service<StorageEngineElasticsearch> {
|
|
10
|
+
readonly driver: StorageDriver;
|
|
11
|
+
constructor(Driver: StorageDriverClass<unknown, StorageEngineElasticsearch>, config: StorageEngineElasticsearch, scope: storeScopeEnum);
|
|
12
|
+
protected _initSequence(): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Kuzzle, a backend software, self-hostable and ready to use
|
|
4
|
+
* to power modern apps
|
|
5
|
+
*
|
|
6
|
+
* Copyright 2015-2026 Kuzzle
|
|
7
|
+
* mailto: support AT kuzzle.io
|
|
8
|
+
* website: http://kuzzle.io
|
|
9
|
+
*
|
|
10
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
11
|
+
* you may not use this file except in compliance with the License.
|
|
12
|
+
* You may obtain a copy of the License at
|
|
13
|
+
*
|
|
14
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
+
* See the License for the specific language governing permissions and
|
|
20
|
+
* limitations under the License.
|
|
21
|
+
*/
|
|
22
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.StorageService = void 0;
|
|
27
|
+
const service_1 = __importDefault(require("../service"));
|
|
28
|
+
/**
|
|
29
|
+
* One storage scope's driver instance, initialized under
|
|
30
|
+
* `services.storageEngine`'s init timeout like every service.
|
|
31
|
+
*/
|
|
32
|
+
class StorageService extends service_1.default {
|
|
33
|
+
constructor(Driver, config, scope) {
|
|
34
|
+
// The name the init timeout error reports, unchanged since the storage
|
|
35
|
+
// engine was Elasticsearch only.
|
|
36
|
+
super("elasticsearch", config);
|
|
37
|
+
this.driver = new Driver(config, scope);
|
|
38
|
+
}
|
|
39
|
+
_initSequence() {
|
|
40
|
+
return this.driver.init();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.StorageService = StorageService;
|
|
44
|
+
//# sourceMappingURL=storageService.js.map
|
|
@@ -170,6 +170,14 @@ export interface IKuzzleConfiguration {
|
|
|
170
170
|
* Optional here for the reason given on {@link IKuzzleConfiguration.version}.
|
|
171
171
|
*/
|
|
172
172
|
deprecatedSettings?: string[];
|
|
173
|
+
/**
|
|
174
|
+
* Derived at startup: the configuration keys the user set that Kuzzle
|
|
175
|
+
* ignores (today, "services.storageEngine.majorVersion" set along with a
|
|
176
|
+
* storage driver), logged as a warning.
|
|
177
|
+
*
|
|
178
|
+
* Optional here for the reason given on {@link IKuzzleConfiguration.version}.
|
|
179
|
+
*/
|
|
180
|
+
ignoredSettings?: string[];
|
|
173
181
|
};
|
|
174
182
|
/**
|
|
175
183
|
* Collection specifications to apply at startup, by index then collection.
|
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
export type StorageEngineElasticsearch = {
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* The npm package of the storage driver to run on (e.g.
|
|
4
|
+
* `"kuzzle-storage-es-9"`), installed next to `kuzzle`. Not set: the
|
|
5
|
+
* built-in Elasticsearch driver of `majorVersion`.
|
|
6
|
+
*/
|
|
7
|
+
driver?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Elasticsearch major version, which selects the built-in driver when
|
|
10
|
+
* `driver` is not set; ignored otherwise (Kuzzle warns at startup if both
|
|
11
|
+
* are set).
|
|
12
|
+
*
|
|
13
|
+
* Deprecated in the documentation only: Kuzzle 3 selects the storage engine
|
|
14
|
+
* with `driver` alone, but an ES7 / ES8 stack has nothing else to use in
|
|
15
|
+
* Kuzzle 2, hence no `@deprecated` tag (see docs/v3-breaking-changes.md).
|
|
4
16
|
* @default "7"
|
|
5
17
|
*/
|
|
6
18
|
majorVersion: "7" | "8";
|
|
@@ -39,6 +39,7 @@ export * from "./errors/ErrorDomains";
|
|
|
39
39
|
export * from "./events/EventGenericDocument";
|
|
40
40
|
export * from "./events/EventProtocol";
|
|
41
41
|
export * from "./realtime/RealtimeScope";
|
|
42
|
+
export * from "./storage/StorageDriver";
|
|
42
43
|
export * from "./realtime/RealtimeUsers";
|
|
43
44
|
export * from "./realtime/RoomList";
|
|
44
45
|
export * from "./shared/StoreCollectionsDefinition";
|
package/dist/lib/types/index.js
CHANGED
|
@@ -75,6 +75,7 @@ __exportStar(require("./errors/ErrorDomains"), exports);
|
|
|
75
75
|
__exportStar(require("./events/EventGenericDocument"), exports);
|
|
76
76
|
__exportStar(require("./events/EventProtocol"), exports);
|
|
77
77
|
__exportStar(require("./realtime/RealtimeScope"), exports);
|
|
78
|
+
__exportStar(require("./storage/StorageDriver"), exports);
|
|
78
79
|
__exportStar(require("./realtime/RealtimeUsers"), exports);
|
|
79
80
|
__exportStar(require("./realtime/RoomList"), exports);
|
|
80
81
|
__exportStar(require("./shared/StoreCollectionsDefinition"), exports);
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import type { storeScopeEnum } from "../../core/storage/storeScopeEnum";
|
|
2
|
+
import type { JSONObject } from "../JSONObject";
|
|
3
|
+
import type { ValidatedTarget } from "../Target";
|
|
4
|
+
/**
|
|
5
|
+
* The optional capability groups. A driver declares the ones it implements in
|
|
6
|
+
* its manifest; a request needing one it did not declare is rejected.
|
|
7
|
+
*
|
|
8
|
+
* - `aggregations`: `aggregations` / `aggs` in a search body
|
|
9
|
+
* - `mappingUpdates`: changing the mappings of an existing collection
|
|
10
|
+
* (`updateMapping`, `updateCollection`)
|
|
11
|
+
* - `stats`: storage statistics (`stats`)
|
|
12
|
+
* - `updateByQuery`: updating every document matching a query
|
|
13
|
+
* (`updateByQuery`, `bulkUpdateByQuery`)
|
|
14
|
+
*/
|
|
15
|
+
export declare const STORAGE_CAPABILITIES: readonly ["aggregations", "mappingUpdates", "stats", "updateByQuery"];
|
|
16
|
+
export type StorageCapability = (typeof STORAGE_CAPABILITIES)[number];
|
|
17
|
+
/**
|
|
18
|
+
* A driver's `manifest.json`, at its package root, read before its code is
|
|
19
|
+
* loaded.
|
|
20
|
+
*/
|
|
21
|
+
export type StorageDriverManifest = {
|
|
22
|
+
/**
|
|
23
|
+
* Semver range of the Kuzzle versions the driver is compatible with: the
|
|
24
|
+
* only versioning of this contract.
|
|
25
|
+
* @example ">=2.61.0 <3"
|
|
26
|
+
*/
|
|
27
|
+
kuzzleVersion: string;
|
|
28
|
+
/** The optional capability groups the driver implements */
|
|
29
|
+
capabilities: StorageCapability[];
|
|
30
|
+
};
|
|
31
|
+
export type StorageRefresh = boolean | "wait_for";
|
|
32
|
+
/** Options shared by the actions writing a document */
|
|
33
|
+
export type StorageWriteOptions = {
|
|
34
|
+
refresh?: StorageRefresh;
|
|
35
|
+
/** Kuid written to `_kuzzle_info`, `null` for an anonymous write */
|
|
36
|
+
userId?: string | null;
|
|
37
|
+
/** Whether to write `_kuzzle_info` at all */
|
|
38
|
+
injectKuzzleMeta?: boolean;
|
|
39
|
+
};
|
|
40
|
+
/** Options shared by the actions writing several documents */
|
|
41
|
+
export type StorageMWriteOptions = StorageWriteOptions & {
|
|
42
|
+
timeout?: string;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* `_source` is typed as loosely as the Elasticsearch SDK types it, and left
|
|
46
|
+
* out by the engine on some writes.
|
|
47
|
+
*/
|
|
48
|
+
export type StorageDocument = {
|
|
49
|
+
_id: string;
|
|
50
|
+
_source?: unknown;
|
|
51
|
+
_version?: number;
|
|
52
|
+
};
|
|
53
|
+
/** The answer of every `m*` write */
|
|
54
|
+
export type StorageMResult = {
|
|
55
|
+
errors: JSONObject[];
|
|
56
|
+
items: JSONObject[];
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Typed as loosely as the Elasticsearch SDK types a hit: `_id` and `_source`
|
|
60
|
+
* are always set in practice.
|
|
61
|
+
*/
|
|
62
|
+
export type StorageSearchHit = {
|
|
63
|
+
_id?: string;
|
|
64
|
+
_score?: number | null;
|
|
65
|
+
_source?: unknown;
|
|
66
|
+
/** The hit's index and collection, set on a multi-collection search */
|
|
67
|
+
index?: string;
|
|
68
|
+
collection?: string;
|
|
69
|
+
highlight?: unknown;
|
|
70
|
+
inner_hits?: unknown;
|
|
71
|
+
};
|
|
72
|
+
export type StorageSearchResult = {
|
|
73
|
+
hits: StorageSearchHit[];
|
|
74
|
+
total: number;
|
|
75
|
+
/** Set when the search was a scroll, to fetch the next page */
|
|
76
|
+
scrollId?: string;
|
|
77
|
+
/** Documents left to fetch through the scroll */
|
|
78
|
+
remaining?: number;
|
|
79
|
+
aggregations?: JSONObject;
|
|
80
|
+
suggest?: JSONObject;
|
|
81
|
+
};
|
|
82
|
+
export type StorageSearchOptions = {
|
|
83
|
+
from?: number;
|
|
84
|
+
size?: number;
|
|
85
|
+
/** Scroll TTL (e.g. `"10s"`): makes the search a scroll */
|
|
86
|
+
scroll?: string;
|
|
87
|
+
};
|
|
88
|
+
export type StorageInfo = {
|
|
89
|
+
/** The engine, e.g. `"elasticsearch"` */
|
|
90
|
+
type: string;
|
|
91
|
+
version: string;
|
|
92
|
+
status?: string;
|
|
93
|
+
};
|
|
94
|
+
export type StorageStats = {
|
|
95
|
+
indexes: {
|
|
96
|
+
name: string;
|
|
97
|
+
/** In bytes */
|
|
98
|
+
size: number;
|
|
99
|
+
collections: {
|
|
100
|
+
name: string;
|
|
101
|
+
documentCount: number;
|
|
102
|
+
/** In bytes */
|
|
103
|
+
size: number;
|
|
104
|
+
}[];
|
|
105
|
+
}[];
|
|
106
|
+
/** In bytes */
|
|
107
|
+
size: number;
|
|
108
|
+
};
|
|
109
|
+
export type StorageCollectionOptions = {
|
|
110
|
+
mappings?: JSONObject;
|
|
111
|
+
settings?: JSONObject;
|
|
112
|
+
};
|
|
113
|
+
/** The mandatory core: every driver implements it. */
|
|
114
|
+
export interface StorageDriverCore {
|
|
115
|
+
/**
|
|
116
|
+
* Connects to the engine. Kuzzle applies `services.storageEngine`'s init
|
|
117
|
+
* timeout around it.
|
|
118
|
+
*/
|
|
119
|
+
init(): Promise<void>;
|
|
120
|
+
info(): Promise<StorageInfo>;
|
|
121
|
+
/**
|
|
122
|
+
* Translates Koncorde filters to the driver's query language. A filter it
|
|
123
|
+
* cannot translate raises a `KeywordError` (see `QueryTranslator`, which the
|
|
124
|
+
* Elasticsearch-family drivers use).
|
|
125
|
+
*/
|
|
126
|
+
translateKoncordeFilters(filters: JSONObject): JSONObject;
|
|
127
|
+
createIndex(index: string): Promise<unknown>;
|
|
128
|
+
/** @returns The indexes actually deleted */
|
|
129
|
+
deleteIndexes(indexes?: string[]): Promise<string[]>;
|
|
130
|
+
deleteIndex(index: string): Promise<unknown>;
|
|
131
|
+
/** @returns Index name -> its collection names */
|
|
132
|
+
getSchema(): Promise<Record<string, string[]>>;
|
|
133
|
+
createCollection(index: string, collection: string, options?: StorageCollectionOptions): Promise<unknown>;
|
|
134
|
+
deleteCollection(index: string, collection: string): Promise<unknown>;
|
|
135
|
+
truncateCollection(index: string, collection: string): Promise<unknown>;
|
|
136
|
+
refreshCollection(index: string, collection: string): Promise<unknown>;
|
|
137
|
+
getMapping(index: string, collection: string, options?: {
|
|
138
|
+
includeKuzzleMeta?: boolean;
|
|
139
|
+
}): Promise<JSONObject>;
|
|
140
|
+
getSettings(index: string, collection: string): Promise<JSONObject | undefined>;
|
|
141
|
+
get(index: string, collection: string, id: string): Promise<StorageDocument>;
|
|
142
|
+
/** @returns The documents found, and the ids of those that were not */
|
|
143
|
+
mGet(index: string, collection: string, ids: string[]): Promise<{
|
|
144
|
+
errors: string[];
|
|
145
|
+
items: StorageDocument[];
|
|
146
|
+
}>;
|
|
147
|
+
exists(index: string, collection: string, id: string): Promise<boolean>;
|
|
148
|
+
/** @returns The ids found, and those that were not */
|
|
149
|
+
mExists(index: string, collection: string, ids: string[]): Promise<{
|
|
150
|
+
errors: string[];
|
|
151
|
+
items: string[];
|
|
152
|
+
}>;
|
|
153
|
+
count(index: string, collection: string, searchBody?: JSONObject): Promise<number>;
|
|
154
|
+
create(index: string, collection: string, content: JSONObject, options?: StorageWriteOptions & {
|
|
155
|
+
id?: string;
|
|
156
|
+
}): Promise<StorageDocument>;
|
|
157
|
+
createOrReplace(index: string, collection: string, id: string, content: JSONObject, options?: StorageWriteOptions): Promise<StorageDocument & {
|
|
158
|
+
created: boolean;
|
|
159
|
+
}>;
|
|
160
|
+
update(index: string, collection: string, id: string, content: JSONObject, options?: StorageWriteOptions & {
|
|
161
|
+
retryOnConflict?: number;
|
|
162
|
+
}): Promise<StorageDocument>;
|
|
163
|
+
upsert(index: string, collection: string, id: string, content: JSONObject, options?: StorageWriteOptions & {
|
|
164
|
+
defaultValues?: JSONObject;
|
|
165
|
+
retryOnConflict?: number;
|
|
166
|
+
}): Promise<StorageDocument & {
|
|
167
|
+
created: boolean;
|
|
168
|
+
}>;
|
|
169
|
+
replace(index: string, collection: string, id: string, content: JSONObject, options?: StorageWriteOptions): Promise<StorageDocument>;
|
|
170
|
+
delete(index: string, collection: string, id: string, options?: {
|
|
171
|
+
refresh?: StorageRefresh;
|
|
172
|
+
}): Promise<unknown>;
|
|
173
|
+
deleteFields(index: string, collection: string, id: string, fields: string[], options?: {
|
|
174
|
+
refresh?: StorageRefresh;
|
|
175
|
+
userId?: string | null;
|
|
176
|
+
}): Promise<StorageDocument>;
|
|
177
|
+
/**
|
|
178
|
+
* Each document of the `m*` writes is `{ _id?, body }`, but `mUpsert`'s.
|
|
179
|
+
* A document that cannot be written is reported in `errors`, the others are
|
|
180
|
+
* written.
|
|
181
|
+
*/
|
|
182
|
+
mCreate(index: string, collection: string, documents: JSONObject[], options?: StorageMWriteOptions): Promise<StorageMResult>;
|
|
183
|
+
mCreateOrReplace(index: string, collection: string, documents: JSONObject[], options?: StorageMWriteOptions & {
|
|
184
|
+
limits?: boolean;
|
|
185
|
+
source?: boolean;
|
|
186
|
+
}): Promise<StorageMResult>;
|
|
187
|
+
mUpdate(index: string, collection: string, documents: JSONObject[], options?: StorageMWriteOptions & {
|
|
188
|
+
retryOnConflict?: number;
|
|
189
|
+
}): Promise<StorageMResult>;
|
|
190
|
+
/** Each document is `{ _id, changes, default? }` */
|
|
191
|
+
mUpsert(index: string, collection: string, documents: JSONObject[], options?: StorageMWriteOptions & {
|
|
192
|
+
retryOnConflict?: number;
|
|
193
|
+
}): Promise<StorageMResult>;
|
|
194
|
+
mReplace(index: string, collection: string, documents: JSONObject[], options?: StorageMWriteOptions): Promise<StorageMResult>;
|
|
195
|
+
mDelete(index: string, collection: string, ids: string[], options?: {
|
|
196
|
+
refresh?: StorageRefresh;
|
|
197
|
+
}): Promise<{
|
|
198
|
+
documents: JSONObject[];
|
|
199
|
+
errors: JSONObject[];
|
|
200
|
+
}>;
|
|
201
|
+
/**
|
|
202
|
+
* Imports raw documents and actions (fixtures, `bulk:import`), in the
|
|
203
|
+
* Elasticsearch bulk format
|
|
204
|
+
*/
|
|
205
|
+
import(index: string, collection: string, documents: JSONObject[], options?: StorageMWriteOptions): Promise<{
|
|
206
|
+
errors: JSONObject[];
|
|
207
|
+
items: JSONObject[];
|
|
208
|
+
}>;
|
|
209
|
+
/**
|
|
210
|
+
* Searches one collection (`index` + `collection`) or several (`targets`).
|
|
211
|
+
* `searchBody` is an Elasticsearch search body.
|
|
212
|
+
*/
|
|
213
|
+
search(query?: {
|
|
214
|
+
index?: string;
|
|
215
|
+
collection?: string;
|
|
216
|
+
searchBody?: JSONObject;
|
|
217
|
+
targets?: ValidatedTarget[];
|
|
218
|
+
}, options?: StorageSearchOptions): Promise<StorageSearchResult>;
|
|
219
|
+
/** Fetches the next page of a search started with `scroll` */
|
|
220
|
+
scroll(scrollId: string, options?: {
|
|
221
|
+
scrollTTL?: string;
|
|
222
|
+
}): Promise<StorageSearchResult>;
|
|
223
|
+
deleteByQuery(index: string, collection: string, query: JSONObject, options?: {
|
|
224
|
+
refresh?: StorageRefresh;
|
|
225
|
+
size?: number;
|
|
226
|
+
fetch?: boolean;
|
|
227
|
+
}): Promise<{
|
|
228
|
+
deleted?: number;
|
|
229
|
+
documents: JSONObject[];
|
|
230
|
+
failures: JSONObject[];
|
|
231
|
+
total?: number;
|
|
232
|
+
}>;
|
|
233
|
+
/**
|
|
234
|
+
* Runs `callback` on every page of documents matching `query`
|
|
235
|
+
*
|
|
236
|
+
* @returns The callback's answers, one per page
|
|
237
|
+
*/
|
|
238
|
+
mExecute(index: string, collection: string, query: JSONObject, callback: (documents: JSONObject[]) => unknown, options?: {
|
|
239
|
+
size?: number;
|
|
240
|
+
scrollTTl?: string;
|
|
241
|
+
}): Promise<unknown[]>;
|
|
242
|
+
}
|
|
243
|
+
/** Capability `updateByQuery` */
|
|
244
|
+
export interface StorageUpdateByQuery {
|
|
245
|
+
updateByQuery(index: string, collection: string, query: JSONObject, changes: JSONObject, options?: {
|
|
246
|
+
refresh?: StorageRefresh;
|
|
247
|
+
size?: number;
|
|
248
|
+
userId?: string | null;
|
|
249
|
+
}): Promise<{
|
|
250
|
+
errors: JSONObject[];
|
|
251
|
+
successes: JSONObject[];
|
|
252
|
+
}>;
|
|
253
|
+
bulkUpdateByQuery(index: string, collection: string, query: JSONObject, changes: JSONObject, options?: {
|
|
254
|
+
refresh?: boolean;
|
|
255
|
+
}): Promise<{
|
|
256
|
+
updated?: number;
|
|
257
|
+
}>;
|
|
258
|
+
}
|
|
259
|
+
/** Capability `mappingUpdates` */
|
|
260
|
+
export interface StorageMappingUpdates {
|
|
261
|
+
updateMapping(index: string, collection: string, mappings?: JSONObject): Promise<JSONObject>;
|
|
262
|
+
updateCollection(index: string, collection: string, options?: StorageCollectionOptions & {
|
|
263
|
+
reindexCollection?: boolean;
|
|
264
|
+
}): Promise<unknown>;
|
|
265
|
+
}
|
|
266
|
+
/** Capability `stats` */
|
|
267
|
+
export interface StorageStatsCapability {
|
|
268
|
+
stats(): Promise<StorageStats>;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Engine-specific steps Kuzzle runs when the driver has them, and skips
|
|
272
|
+
* otherwise.
|
|
273
|
+
*/
|
|
274
|
+
export interface StorageEngineHooks {
|
|
275
|
+
/**
|
|
276
|
+
* Repairs the engine-side naming of the indexes and collections, when
|
|
277
|
+
* `services.storageEngine.generateMissingAliases` is set
|
|
278
|
+
*/
|
|
279
|
+
generateMissingAliases?(): Promise<unknown>;
|
|
280
|
+
/** Waits until a new collection can be written to */
|
|
281
|
+
waitForCollectionShards?(index: string, collection: string, timeout?: string): Promise<void>;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* A storage driver instance: the core, the capability groups it declared in
|
|
285
|
+
* its manifest, and the engine hooks it has.
|
|
286
|
+
*/
|
|
287
|
+
export type StorageDriver = StorageDriverCore & Partial<StorageUpdateByQuery & StorageMappingUpdates & StorageStatsCapability> & StorageEngineHooks;
|
|
288
|
+
/**
|
|
289
|
+
* What a driver package exports: Kuzzle builds one instance per storage scope
|
|
290
|
+
* (public and private indexes).
|
|
291
|
+
*
|
|
292
|
+
* @typeParam TNativeClient - The engine's own client
|
|
293
|
+
* @typeParam TConfig - What the driver reads of `services.storageEngine`
|
|
294
|
+
*/
|
|
295
|
+
export type StorageDriverClass<TNativeClient = unknown, TConfig extends JSONObject = JSONObject> = {
|
|
296
|
+
new (config: TConfig, scope: storeScopeEnum): StorageDriver;
|
|
297
|
+
/**
|
|
298
|
+
* Builds a new engine client, distinct from the ones the driver instances
|
|
299
|
+
* use: `app.storage.storageClient`, `app.storage.StorageClient` and
|
|
300
|
+
* `context.constructors.ESClient` hand it to applications and plugins.
|
|
301
|
+
*
|
|
302
|
+
* @param clientConfig - `services.storageEngine.client`, with the overrides
|
|
303
|
+
* given to `app.storage.StorageClient`
|
|
304
|
+
*/
|
|
305
|
+
createNativeClient(clientConfig: JSONObject): TNativeClient;
|
|
306
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Kuzzle, a backend software, self-hostable and ready to use
|
|
4
|
+
* to power modern apps
|
|
5
|
+
*
|
|
6
|
+
* Copyright 2015-2026 Kuzzle
|
|
7
|
+
* mailto: support AT kuzzle.io
|
|
8
|
+
* website: http://kuzzle.io
|
|
9
|
+
*
|
|
10
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
11
|
+
* you may not use this file except in compliance with the License.
|
|
12
|
+
* You may obtain a copy of the License at
|
|
13
|
+
*
|
|
14
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
+
* See the License for the specific language governing permissions and
|
|
20
|
+
* limitations under the License.
|
|
21
|
+
*/
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.STORAGE_CAPABILITIES = void 0;
|
|
24
|
+
/**
|
|
25
|
+
* The optional capability groups. A driver declares the ones it implements in
|
|
26
|
+
* its manifest; a request needing one it did not declare is rejected.
|
|
27
|
+
*
|
|
28
|
+
* - `aggregations`: `aggregations` / `aggs` in a search body
|
|
29
|
+
* - `mappingUpdates`: changing the mappings of an existing collection
|
|
30
|
+
* (`updateMapping`, `updateCollection`)
|
|
31
|
+
* - `stats`: storage statistics (`stats`)
|
|
32
|
+
* - `updateByQuery`: updating every document matching a query
|
|
33
|
+
* (`updateByQuery`, `bulkUpdateByQuery`)
|
|
34
|
+
*/
|
|
35
|
+
exports.STORAGE_CAPABILITIES = [
|
|
36
|
+
"aggregations",
|
|
37
|
+
"mappingUpdates",
|
|
38
|
+
"stats",
|
|
39
|
+
"updateByQuery",
|
|
40
|
+
];
|
|
41
|
+
//# sourceMappingURL=StorageDriver.js.map
|