kuzzle 2.60.1 → 2.61.0-beta.1
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/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 +5 -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/7/elasticsearch.d.ts +5 -1
- package/dist/lib/service/storage/builtInDrivers.d.ts +17 -0
- package/dist/lib/service/storage/builtInDrivers.js +61 -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/storageEngine/StorageEngineElasticsearchConfiguration.d.ts +8 -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 +2 -1
- package/package.json +2 -1
- 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,17 @@
|
|
|
1
|
+
import { Client as ClientES7 } from "sdk-es7";
|
|
2
|
+
import { Client as ClientES8 } from "sdk-es8";
|
|
3
|
+
import { ES7 } from "./7/elasticsearch";
|
|
4
|
+
import { ES8 } from "./8/elasticsearch";
|
|
5
|
+
import type { JSONObject } from "../../types/JSONObject";
|
|
6
|
+
import type { StorageEngineElasticsearch } from "../../types/config/storageEngine/StorageEngineElasticsearchConfiguration";
|
|
7
|
+
import type { StorageDriver, StorageDriverClass } from "../../types/storage/StorageDriver";
|
|
8
|
+
export declare class ES7Driver extends ES7 implements StorageDriver {
|
|
9
|
+
static createNativeClient(clientConfig: JSONObject): ClientES7;
|
|
10
|
+
init(): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
export declare class ES8Driver extends ES8 implements StorageDriver {
|
|
13
|
+
static createNativeClient(clientConfig: JSONObject): ClientES8;
|
|
14
|
+
init(): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
/** The built-in driver of an Elasticsearch major version */
|
|
17
|
+
export declare function builtInStorageDriver(majorVersion: StorageEngineElasticsearch["majorVersion"]): StorageDriverClass<ClientES7 | ClientES8, StorageEngineElasticsearch>;
|
|
@@ -0,0 +1,61 @@
|
|
|
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.ES8Driver = exports.ES7Driver = void 0;
|
|
24
|
+
exports.builtInStorageDriver = builtInStorageDriver;
|
|
25
|
+
// The built-in Elasticsearch 7 and 8 drivers (ADR-0003 step 02): today's
|
|
26
|
+
// classes as they are, plus the two members of the `StorageDriver` contract
|
|
27
|
+
// they lack. Extracted to their own packages at the next major.
|
|
28
|
+
const sdk_es7_1 = require("sdk-es7");
|
|
29
|
+
const sdk_es8_1 = require("sdk-es8");
|
|
30
|
+
const elasticsearch_1 = require("./7/elasticsearch");
|
|
31
|
+
const elasticsearch_2 = require("./8/elasticsearch");
|
|
32
|
+
class ES7Driver extends elasticsearch_1.ES7 {
|
|
33
|
+
static createNativeClient(clientConfig) {
|
|
34
|
+
return new sdk_es7_1.Client(clientConfig);
|
|
35
|
+
}
|
|
36
|
+
init() {
|
|
37
|
+
return this._initSequence();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.ES7Driver = ES7Driver;
|
|
41
|
+
class ES8Driver extends elasticsearch_2.ES8 {
|
|
42
|
+
static createNativeClient(clientConfig) {
|
|
43
|
+
return new sdk_es8_1.Client(clientConfig);
|
|
44
|
+
}
|
|
45
|
+
init() {
|
|
46
|
+
return this._initSequence();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.ES8Driver = ES8Driver;
|
|
50
|
+
/** The built-in driver of an Elasticsearch major version */
|
|
51
|
+
function builtInStorageDriver(majorVersion) {
|
|
52
|
+
switch (majorVersion) {
|
|
53
|
+
case "7":
|
|
54
|
+
return ES7Driver;
|
|
55
|
+
case "8":
|
|
56
|
+
return ES8Driver;
|
|
57
|
+
default:
|
|
58
|
+
throw new Error("Invalid Elasticsearch version.");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
//# 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
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
export type StorageEngineElasticsearch = {
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* The npm package of the storage driver to run on (e.g.
|
|
4
|
+
* `"@kuzzleio/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
|
|
4
11
|
* @default "7"
|
|
5
12
|
*/
|
|
6
13
|
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
|
package/dist/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kuzzle",
|
|
3
3
|
"author": "The Kuzzle Team <support@kuzzle.io>",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.61.0-beta.1",
|
|
5
5
|
"description": "Kuzzle is an open-source solution that handles all the data management through a secured API, with a large choice of protocols.",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "rm -Rf ./dist && tsc && node -r ts-node/register/transpile-only ./bin/copy-binaries.ts",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"test:functional:legacy:websocket": "cucumber-js --format progress-bar --profile websocketLegacy --config cucumber.config.cjs",
|
|
22
22
|
"test:functional:http": "KUZZLE_PROTOCOL=http cucumber-js --profile http --config cucumber.config.cjs",
|
|
23
23
|
"test:functional:websocket": "KUZZLE_PROTOCOL=websocket cucumber-js --profile websocket --config cucumber.config.cjs",
|
|
24
|
+
"test:conformance": "vitest run --config vitest.conformance.config.ts",
|
|
24
25
|
"test:unit:vitest": "vitest run --fileParallelism false --coverage --bail=1 --passWithNoTests",
|
|
25
26
|
"test:lint": "eslint ./lib ./tests ./bin ./features ./features-legacy",
|
|
26
27
|
"typecheck:tests": "tsc -p tsconfig.tests.json",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kuzzle",
|
|
3
3
|
"author": "The Kuzzle Team <support@kuzzle.io>",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.61.0-beta.1",
|
|
5
5
|
"description": "Kuzzle is an open-source solution that handles all the data management through a secured API, with a large choice of protocols.",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "rm -Rf ./dist && tsc && node -r ts-node/register/transpile-only ./bin/copy-binaries.ts",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"test:functional:legacy:websocket": "cucumber-js --format progress-bar --profile websocketLegacy --config cucumber.config.cjs",
|
|
22
22
|
"test:functional:http": "KUZZLE_PROTOCOL=http cucumber-js --profile http --config cucumber.config.cjs",
|
|
23
23
|
"test:functional:websocket": "KUZZLE_PROTOCOL=websocket cucumber-js --profile websocket --config cucumber.config.cjs",
|
|
24
|
+
"test:conformance": "vitest run --config vitest.conformance.config.ts",
|
|
24
25
|
"test:unit:vitest": "vitest run --fileParallelism false --coverage --bail=1 --passWithNoTests",
|
|
25
26
|
"test:lint": "eslint ./lib ./tests ./bin ./features ./features-legacy",
|
|
26
27
|
"typecheck:tests": "tsc -p tsconfig.tests.json",
|