kuzzle 2.61.4-beta.2 → 2.62.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/core/security/roleRepository.js +11 -1
- package/dist/lib/core/storage/clientAdapter.d.ts +8 -0
- package/dist/lib/core/storage/clientAdapter.js +22 -1
- package/dist/lib/core/storage/conformance/capabilityCases.js +5 -4
- package/dist/lib/core/storage/conformance/conformanceContext.d.ts +6 -0
- package/dist/lib/core/storage/conformance/conformanceContext.js +15 -0
- package/dist/lib/types/storage/StorageDriver.d.ts +23 -0
- package/dist/package.json +3 -3
- package/package.json +3 -3
|
@@ -171,10 +171,20 @@ class RoleRepository extends ObjectRepository_1.ObjectRepository {
|
|
|
171
171
|
for (const id of ids) {
|
|
172
172
|
let role = this.roles.get(id);
|
|
173
173
|
if (!role) {
|
|
174
|
-
|
|
174
|
+
const pending = this.loadOneFromDatabase(id).then((r) => {
|
|
175
175
|
this.roles.set(id, r);
|
|
176
176
|
return r;
|
|
177
|
+
}, (error) => {
|
|
178
|
+
// Never keep a rejected load in the cache: it would make every
|
|
179
|
+
// later lookup of this role fail without querying the database
|
|
180
|
+
// again. Only evict our own entry, it may have been replaced
|
|
181
|
+
// (e.g. by an invalidation followed by a new load) meanwhile.
|
|
182
|
+
if (this.roles.get(id) === pending) {
|
|
183
|
+
this.roles.delete(id);
|
|
184
|
+
}
|
|
185
|
+
throw error;
|
|
177
186
|
});
|
|
187
|
+
role = pending;
|
|
178
188
|
this.roles.set(id, role);
|
|
179
189
|
}
|
|
180
190
|
roles.push(role);
|
|
@@ -106,6 +106,14 @@ declare class ClientAdapter {
|
|
|
106
106
|
owner: string;
|
|
107
107
|
reason: string;
|
|
108
108
|
}): Promise<CollectionLock>;
|
|
109
|
+
/**
|
|
110
|
+
* Announces the background reindex a `collection:update` started, when the
|
|
111
|
+
* driver tells its task id (drivers may not: then nothing is emitted).
|
|
112
|
+
*
|
|
113
|
+
* A hook, not a pipe: listeners learn the task id on this node before the
|
|
114
|
+
* request that started it is answered, and cannot delay or alter it.
|
|
115
|
+
*/
|
|
116
|
+
private announceReindex;
|
|
109
117
|
/**
|
|
110
118
|
* Releases a collection write lock.
|
|
111
119
|
*
|
|
@@ -392,6 +392,25 @@ class ClientAdapter {
|
|
|
392
392
|
});
|
|
393
393
|
return lock;
|
|
394
394
|
}
|
|
395
|
+
/**
|
|
396
|
+
* Announces the background reindex a `collection:update` started, when the
|
|
397
|
+
* driver tells its task id (drivers may not: then nothing is emitted).
|
|
398
|
+
*
|
|
399
|
+
* A hook, not a pipe: listeners learn the task id on this node before the
|
|
400
|
+
* request that started it is answered, and cannot delay or alter it.
|
|
401
|
+
*/
|
|
402
|
+
announceReindex(index, collection, result) {
|
|
403
|
+
const taskId = (0, safeObject_1.isPlainObject)(result) ? result.reindexTaskId : undefined;
|
|
404
|
+
if (typeof taskId !== "string" || taskId.length === 0) {
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
global.kuzzle.emit("core:storage:collection:reindex:start", {
|
|
408
|
+
collection,
|
|
409
|
+
index,
|
|
410
|
+
scope: this.scope,
|
|
411
|
+
taskId,
|
|
412
|
+
});
|
|
413
|
+
}
|
|
395
414
|
/**
|
|
396
415
|
* Releases a collection write lock.
|
|
397
416
|
*
|
|
@@ -518,7 +537,9 @@ class ClientAdapter {
|
|
|
518
537
|
await this.assertCollectionExists(index, collection);
|
|
519
538
|
this.cache.assertCollectionWritable(index, collection);
|
|
520
539
|
assertCapability(this.capabilities, this.driver, "updateCollection");
|
|
521
|
-
|
|
540
|
+
const result = await this.driver.updateCollection(index, collection, changes);
|
|
541
|
+
this.announceReindex(index, collection, result);
|
|
542
|
+
return result;
|
|
522
543
|
});
|
|
523
544
|
}
|
|
524
545
|
registerIndexEvents() {
|
|
@@ -73,9 +73,9 @@ const CASES = {
|
|
|
73
73
|
await driver.updateMapping(context.index, collection, {
|
|
74
74
|
properties: { country: { type: "keyword" } },
|
|
75
75
|
});
|
|
76
|
-
await driver.updateCollection(context.index, collection, {
|
|
76
|
+
(0, conformanceContext_1.assertCollectionUpdateResult)(await driver.updateCollection(context.index, collection, {
|
|
77
77
|
mappings: { properties: { zip: { type: "keyword" } } },
|
|
78
|
-
});
|
|
78
|
+
}));
|
|
79
79
|
const mapping = await context.driver.getMapping(context.index, collection);
|
|
80
80
|
strict_1.default.deepEqual((0, conformanceContext_1.field)(mapping, "properties.country"), {
|
|
81
81
|
type: "keyword",
|
|
@@ -104,10 +104,11 @@ const CASES = {
|
|
|
104
104
|
strict_1.default.ok(driver.updateCollection, IMPLEMENTED);
|
|
105
105
|
const byZip = { query: { term: { zip: "34000" } } };
|
|
106
106
|
strict_1.default.equal(await driver.count(context.index, collection, byZip), 0);
|
|
107
|
-
|
|
107
|
+
// Telling the reindex task's id is optional
|
|
108
|
+
(0, conformanceContext_1.assertCollectionUpdateResult)(await driver.updateCollection(context.index, collection, {
|
|
108
109
|
mappings: { properties: { zip: { type: "keyword" } } },
|
|
109
110
|
reindexCollection: true,
|
|
110
|
-
});
|
|
111
|
+
}));
|
|
111
112
|
// The engine may reindex in the background
|
|
112
113
|
await eventually(async () => (await driver.count(context.index, collection, byZip)) === 1, "the document is found by its new field");
|
|
113
114
|
});
|
|
@@ -41,3 +41,9 @@ export declare function rejectsWith(promise: Promise<unknown>, expected: string
|
|
|
41
41
|
/** A field of a document or an answer, by its dotted path */
|
|
42
42
|
export declare function field(object: unknown, path: string): unknown;
|
|
43
43
|
export declare function hasField(object: unknown, path: string): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* `updateCollection` may resolve with `{ reindexTaskId }` when it started a
|
|
46
|
+
* background reindex, or with anything else: telling the task is optional,
|
|
47
|
+
* but a task id it tells must be usable.
|
|
48
|
+
*/
|
|
49
|
+
export declare function assertCollectionUpdateResult(result: unknown): void;
|
|
@@ -27,6 +27,7 @@ exports.CONFORMANCE_MAPPINGS = exports.ConformanceContext = void 0;
|
|
|
27
27
|
exports.rejectsWith = rejectsWith;
|
|
28
28
|
exports.field = field;
|
|
29
29
|
exports.hasField = hasField;
|
|
30
|
+
exports.assertCollectionUpdateResult = assertCollectionUpdateResult;
|
|
30
31
|
const strict_1 = __importDefault(require("node:assert/strict"));
|
|
31
32
|
const get_1 = __importDefault(require("lodash/get"));
|
|
32
33
|
const has_1 = __importDefault(require("lodash/has"));
|
|
@@ -100,4 +101,18 @@ function field(object, path) {
|
|
|
100
101
|
function hasField(object, path) {
|
|
101
102
|
return (0, has_1.default)(object, path);
|
|
102
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* `updateCollection` may resolve with `{ reindexTaskId }` when it started a
|
|
106
|
+
* background reindex, or with anything else: telling the task is optional,
|
|
107
|
+
* but a task id it tells must be usable.
|
|
108
|
+
*/
|
|
109
|
+
function assertCollectionUpdateResult(result) {
|
|
110
|
+
if (typeof result !== "object" ||
|
|
111
|
+
result === null ||
|
|
112
|
+
!("reindexTaskId" in result) ||
|
|
113
|
+
result.reindexTaskId === undefined) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
strict_1.default.ok(typeof result.reindexTaskId === "string" && result.reindexTaskId.length > 0, "the reindexTaskId updateCollection tells is a non-empty string");
|
|
117
|
+
}
|
|
103
118
|
//# sourceMappingURL=conformanceContext.js.map
|
|
@@ -269,9 +269,32 @@ export interface StorageUpdateByQuery {
|
|
|
269
269
|
updated?: number;
|
|
270
270
|
}>;
|
|
271
271
|
}
|
|
272
|
+
/** What `updateCollection` may tell Kuzzle about the update it made. */
|
|
273
|
+
export type StorageCollectionUpdateResult = {
|
|
274
|
+
/**
|
|
275
|
+
* The engine's id of the background task reindexing the collection's
|
|
276
|
+
* documents, when the update started one (`reindexCollection`, or a change
|
|
277
|
+
* the engine can only apply to existing documents by reindexing them, such
|
|
278
|
+
* as `dynamic`). Kuzzle announces it with the
|
|
279
|
+
* `core:storage:collection:reindex:start` event. Drivers MAY resolve
|
|
280
|
+
* `updateCollection` with it; its return type stays `Promise<unknown>`.
|
|
281
|
+
*/
|
|
282
|
+
reindexTaskId?: string;
|
|
283
|
+
};
|
|
272
284
|
/** Capability `mappingUpdates` */
|
|
273
285
|
export interface StorageMappingUpdates {
|
|
274
286
|
updateMapping(index: string, collection: string, mappings?: JSONObject): Promise<JSONObject>;
|
|
287
|
+
/**
|
|
288
|
+
* Updates the mappings and settings of an existing collection.
|
|
289
|
+
*
|
|
290
|
+
* When the update starts a background reindex of the collection's
|
|
291
|
+
* documents, the driver MAY resolve with a {@link StorageCollectionUpdateResult}
|
|
292
|
+
* (`{ reindexTaskId }`, the engine's id of that task): Kuzzle then emits
|
|
293
|
+
* `core:storage:collection:reindex:start` so that plugins can follow the
|
|
294
|
+
* task. Kuzzle checks that shape at runtime: any other result (`null`,
|
|
295
|
+
* nothing, anything else) is valid and triggers no event. The
|
|
296
|
+
* `collection:update` API action answers `null` either way.
|
|
297
|
+
*/
|
|
275
298
|
updateCollection(index: string, collection: string, options?: StorageCollectionOptions & {
|
|
276
299
|
reindexCollection?: boolean;
|
|
277
300
|
}): Promise<unknown>;
|
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.62.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,8 +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.
|
|
56
|
-
"kuzzle-storage-es-8": "1.
|
|
55
|
+
"kuzzle-storage-es-7": "1.2.0",
|
|
56
|
+
"kuzzle-storage-es-8": "1.2.0",
|
|
57
57
|
"kuzzle-types": "^1.0.0",
|
|
58
58
|
"kuzzle-vault": "2.2.0",
|
|
59
59
|
"lodash": "4.18.1",
|
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.62.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,8 +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.
|
|
56
|
-
"kuzzle-storage-es-8": "1.
|
|
55
|
+
"kuzzle-storage-es-7": "1.2.0",
|
|
56
|
+
"kuzzle-storage-es-8": "1.2.0",
|
|
57
57
|
"kuzzle-types": "^1.0.0",
|
|
58
58
|
"kuzzle-vault": "2.2.0",
|
|
59
59
|
"lodash": "4.18.1",
|