kuzzle 2.61.0-beta.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/lib/config/index.js +43 -8
- package/dist/lib/core/storage/storageEngine.js +4 -0
- package/dist/lib/service/storage/builtInDrivers.d.ts +3 -14
- package/dist/lib/service/storage/builtInDrivers.js +73 -31
- package/dist/lib/types/config/KuzzleConfiguration.d.ts +8 -0
- package/dist/lib/types/config/storageEngine/StorageEngineElasticsearchConfiguration.d.ts +7 -2
- package/dist/package.json +3 -1
- package/package.json +3 -1
- package/dist/lib/service/storage/7/elasticsearch.d.ts +0 -1058
- 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/config/index.js
CHANGED
|
@@ -38,7 +38,7 @@ const wrapped = (0, kerror_1.wrap)("core", "configuration");
|
|
|
38
38
|
function loadConfig() {
|
|
39
39
|
let raw;
|
|
40
40
|
try {
|
|
41
|
-
raw = (0, rc_1.default)("kuzzle",
|
|
41
|
+
raw = (0, rc_1.default)("kuzzle", withoutUnsetDefaults(default_config_1.default));
|
|
42
42
|
}
|
|
43
43
|
catch (e) {
|
|
44
44
|
throw wrapped.get("cannot_parse", e instanceof Error ? e.message : (0, node_util_1.inspect)(e));
|
|
@@ -46,9 +46,11 @@ function loadConfig() {
|
|
|
46
46
|
// In place: what `unstringify` answers is the object it was given.
|
|
47
47
|
unstringify(raw);
|
|
48
48
|
const { authToken, deprecatedSettings, jwt } = resolveTokenSettings(raw.security);
|
|
49
|
+
const { ignoredSettings, storageEngine } = resolveStorageEngine(raw.services.storageEngine);
|
|
49
50
|
const loaded = {
|
|
50
51
|
...raw,
|
|
51
52
|
security: { ...raw.security, authToken, jwt },
|
|
53
|
+
services: { ...raw.services, storageEngine },
|
|
52
54
|
};
|
|
53
55
|
checkLimitsConfig(loaded);
|
|
54
56
|
checkHttpOptions(loaded);
|
|
@@ -64,6 +66,7 @@ function loadConfig() {
|
|
|
64
66
|
seed: Buffer.from("^m&mOISKBvb1xpl1mRsrylaQXpjb&IJX"),
|
|
65
67
|
},
|
|
66
68
|
deprecatedSettings,
|
|
69
|
+
ignoredSettings,
|
|
67
70
|
notifiableProtocols: [],
|
|
68
71
|
},
|
|
69
72
|
version: package_json_1.default.version,
|
|
@@ -75,19 +78,51 @@ function loadConfig() {
|
|
|
75
78
|
return config;
|
|
76
79
|
}
|
|
77
80
|
/**
|
|
78
|
-
* The packaged defaults, minus the
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
81
|
+
* The packaged defaults, minus the ones Kuzzle must tell apart from a value
|
|
82
|
+
* the user set, applied after `rc` has merged the configuration:
|
|
83
|
+
*
|
|
84
|
+
* - the values of `security.authToken` and of its deprecated spelling
|
|
85
|
+
* `security.jwt`: both sections ship the same non-null defaults, so once
|
|
86
|
+
* merged nothing tells a user's `jwt.expiresIn` from the packaged one. Left
|
|
87
|
+
* empty here, they hold only what the user set, and
|
|
88
|
+
* {@link resolveTokenSettings} applies the defaults after;
|
|
89
|
+
* - `services.storageEngine.majorVersion`, ignored when a storage driver is
|
|
90
|
+
* set: {@link resolveStorageEngine} reports it then, and applies the default.
|
|
83
91
|
*
|
|
84
92
|
* A shallow copy: the other sections stay the packaged objects `rc` merges
|
|
85
93
|
* into, as before.
|
|
86
94
|
*/
|
|
87
|
-
function
|
|
95
|
+
function withoutUnsetDefaults(defaults) {
|
|
88
96
|
const authToken = {};
|
|
89
97
|
const jwt = {};
|
|
90
|
-
|
|
98
|
+
const storageEngine = {
|
|
99
|
+
...defaults.services.storageEngine,
|
|
100
|
+
};
|
|
101
|
+
delete storageEngine.majorVersion;
|
|
102
|
+
return {
|
|
103
|
+
...defaults,
|
|
104
|
+
security: { ...defaults.security, authToken, jwt },
|
|
105
|
+
services: { ...defaults.services, storageEngine },
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Applies the default `majorVersion`. `ignoredSettings` lists it when the
|
|
110
|
+
* user set it along with a storage `driver`, which `majorVersion` does not
|
|
111
|
+
* select: logged as a warning when the storage engine starts.
|
|
112
|
+
*/
|
|
113
|
+
function resolveStorageEngine(storageEngine) {
|
|
114
|
+
const ignoredSettings = storageEngine.driver !== undefined &&
|
|
115
|
+
storageEngine.majorVersion !== undefined
|
|
116
|
+
? ["services.storageEngine.majorVersion"]
|
|
117
|
+
: [];
|
|
118
|
+
return {
|
|
119
|
+
ignoredSettings,
|
|
120
|
+
storageEngine: {
|
|
121
|
+
...storageEngine,
|
|
122
|
+
majorVersion: storageEngine.majorVersion ??
|
|
123
|
+
default_config_1.default.services.storageEngine.majorVersion,
|
|
124
|
+
},
|
|
125
|
+
};
|
|
91
126
|
}
|
|
92
127
|
/**
|
|
93
128
|
* Resolves the authentication token settings: for each one, the value set
|
|
@@ -39,6 +39,10 @@ class StorageEngine {
|
|
|
39
39
|
this.logger.info(identity === null
|
|
40
40
|
? `[ℹ] Elasticsearch configuration is set to major version : ${global.kuzzle.config.services.storageEngine.majorVersion}`
|
|
41
41
|
: `[ℹ] Storage driver: ${description}`);
|
|
42
|
+
const ignored = global.kuzzle.config.internal?.ignoredSettings;
|
|
43
|
+
if (ignored?.length) {
|
|
44
|
+
this.logger.warn(`[⚠] Ignored, since "services.storageEngine.driver" selects the storage driver: ${ignored.join(", ")}. Remove it from your configuration.`);
|
|
45
|
+
}
|
|
42
46
|
}
|
|
43
47
|
/**
|
|
44
48
|
* Initialize storage clients and perform integrity checks
|
|
@@ -1,17 +1,6 @@
|
|
|
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";
|
|
1
|
+
import type { Client as ClientES7 } from "sdk-es7";
|
|
2
|
+
import type { Client as ClientES8 } from "sdk-es8";
|
|
6
3
|
import type { StorageEngineElasticsearch } from "../../types/config/storageEngine/StorageEngineElasticsearchConfiguration";
|
|
7
|
-
import type {
|
|
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
|
-
}
|
|
4
|
+
import type { StorageDriverClass } from "../../types/storage/StorageDriver";
|
|
16
5
|
/** The built-in driver of an Elasticsearch major version */
|
|
17
6
|
export declare function builtInStorageDriver(majorVersion: StorageEngineElasticsearch["majorVersion"]): StorageDriverClass<ClientES7 | ClientES8, StorageEngineElasticsearch>;
|
|
@@ -19,43 +19,85 @@
|
|
|
19
19
|
* See the License for the specific language governing permissions and
|
|
20
20
|
* limitations under the License.
|
|
21
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
|
+
})();
|
|
22
55
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
exports.ES8Driver = exports.ES7Driver = void 0;
|
|
24
56
|
exports.builtInStorageDriver = builtInStorageDriver;
|
|
25
|
-
// The built-in Elasticsearch 7 and 8 drivers (ADR-0003 step
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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.");
|
|
38
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;
|
|
39
77
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
+
});
|
|
44
94
|
}
|
|
45
|
-
|
|
46
|
-
return
|
|
95
|
+
catch {
|
|
96
|
+
return;
|
|
47
97
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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.");
|
|
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;
|
|
59
101
|
}
|
|
60
102
|
}
|
|
61
103
|
//# sourceMappingURL=builtInDrivers.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,13 +1,18 @@
|
|
|
1
1
|
export type StorageEngineElasticsearch = {
|
|
2
2
|
/**
|
|
3
3
|
* The npm package of the storage driver to run on (e.g.
|
|
4
|
-
* `"
|
|
4
|
+
* `"kuzzle-storage-es-9"`), installed next to `kuzzle`. Not set: the
|
|
5
5
|
* built-in Elasticsearch driver of `majorVersion`.
|
|
6
6
|
*/
|
|
7
7
|
driver?: string;
|
|
8
8
|
/**
|
|
9
9
|
* Elasticsearch major version, which selects the built-in driver when
|
|
10
|
-
* `driver` is not set
|
|
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).
|
|
11
16
|
* @default "7"
|
|
12
17
|
*/
|
|
13
18
|
majorVersion: "7" | "8";
|
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.61.0-beta.
|
|
4
|
+
"version": "2.61.0-beta.2",
|
|
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",
|
|
@@ -52,6 +52,8 @@
|
|
|
52
52
|
"kuzzle-logger": "1.7.0",
|
|
53
53
|
"kuzzle-plugin-auth-passport-local": "6.4.1",
|
|
54
54
|
"kuzzle-sdk": ">=7.17.1 <8.0.0",
|
|
55
|
+
"kuzzle-storage-es-7": "1.0.0-beta.1",
|
|
56
|
+
"kuzzle-storage-es-8": "1.0.0-beta.1",
|
|
55
57
|
"kuzzle-types": "^1.0.0",
|
|
56
58
|
"kuzzle-vault": "2.2.0",
|
|
57
59
|
"lodash": "4.17.21",
|
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.61.0-beta.
|
|
4
|
+
"version": "2.61.0-beta.2",
|
|
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",
|
|
@@ -52,6 +52,8 @@
|
|
|
52
52
|
"kuzzle-logger": "1.7.0",
|
|
53
53
|
"kuzzle-plugin-auth-passport-local": "6.4.1",
|
|
54
54
|
"kuzzle-sdk": ">=7.17.1 <8.0.0",
|
|
55
|
+
"kuzzle-storage-es-7": "1.0.0-beta.1",
|
|
56
|
+
"kuzzle-storage-es-8": "1.0.0-beta.1",
|
|
55
57
|
"kuzzle-types": "^1.0.0",
|
|
56
58
|
"kuzzle-vault": "2.2.0",
|
|
57
59
|
"lodash": "4.17.21",
|