kuzzle 2.19.3 → 2.19.4
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/lib/api/request/kuzzleRequest.js +2 -3
- package/lib/core/backend/backend.d.ts +2 -2
- package/lib/core/backend/backendCluster.d.ts +8 -9
- package/lib/core/backend/backendCluster.js +3 -3
- package/lib/core/backend/backendHook.d.ts +2 -2
- package/lib/core/backend/backendPipe.d.ts +2 -2
- package/lib/kuzzle/event/pipeRunner.js +2 -2
- package/lib/types/DebugModule.d.ts +1 -0
- package/lib/types/EventHandler.d.ts +28 -2
- package/lib/types/Plugin.d.ts +3 -3
- package/lib/types/events/EventGenericDocument.d.ts +26 -0
- package/lib/types/events/EventGenericDocument.js +3 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +1 -0
- package/lib/util/bufferedPassThrough.d.ts +1 -0
- package/package.json +25 -26
|
@@ -51,7 +51,6 @@ const safeObject_1 = require("../../util/safeObject");
|
|
|
51
51
|
const lodash_1 = require("lodash");
|
|
52
52
|
const moment_1 = __importDefault(require("moment"));
|
|
53
53
|
const uuid = __importStar(require("uuid"));
|
|
54
|
-
const nanoid_1 = require("nanoid");
|
|
55
54
|
const requestInput_1 = require("./requestInput");
|
|
56
55
|
const requestResponse_1 = require("./requestResponse");
|
|
57
56
|
const requestContext_1 = require("./requestContext");
|
|
@@ -80,7 +79,7 @@ const _deprecations = "deprecations\u200b";
|
|
|
80
79
|
*/
|
|
81
80
|
class KuzzleRequest {
|
|
82
81
|
constructor(data, options) {
|
|
83
|
-
this[_internalId] =
|
|
82
|
+
this[_internalId] = uuid.v4();
|
|
84
83
|
this[_status] = 102;
|
|
85
84
|
this[_input] = new requestInput_1.RequestInput(data);
|
|
86
85
|
this[_context] = new requestContext_1.RequestContext(options);
|
|
@@ -93,7 +92,7 @@ class KuzzleRequest {
|
|
|
93
92
|
this[_input].headers = this[_context].connection.misc.headers;
|
|
94
93
|
this.id = data.requestId
|
|
95
94
|
? assert.assertString("requestId", data.requestId)
|
|
96
|
-
:
|
|
95
|
+
: uuid.v4();
|
|
97
96
|
this[_timestamp] = data.timestamp || Date.now();
|
|
98
97
|
// handling provided options
|
|
99
98
|
if (options !== undefined && options !== null) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EmbeddedSDK } from "../shared/sdk/embeddedSdk";
|
|
2
|
-
import { JSONObject } from "../../../index";
|
|
2
|
+
import { EventDefinition, JSONObject } from "../../../index";
|
|
3
3
|
import { BackendCluster, BackendConfig, BackendController, BackendHook, BackendImport, BackendPipe, BackendPlugin, BackendStorage, BackendVault, BackendOpenApi, InternalLogger, BackendErrors } from "./index";
|
|
4
4
|
export declare class Backend {
|
|
5
5
|
private _kuzzle;
|
|
@@ -149,7 +149,7 @@ export declare class Backend {
|
|
|
149
149
|
*
|
|
150
150
|
* @returns {Promise<any>}
|
|
151
151
|
*/
|
|
152
|
-
trigger(event:
|
|
152
|
+
trigger<TEventDefinition extends EventDefinition = EventDefinition>(event: TEventDefinition["name"], ...payload: TEventDefinition["args"]): Promise<TEventDefinition["args"][0]>;
|
|
153
153
|
/**
|
|
154
154
|
* Register a method that will be executed only once on any given environment.
|
|
155
155
|
* If this method throws, the app won't start.
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { EventHandler } from "../../types";
|
|
1
|
+
import { EventDefinition, ClusterEventHandler } from "../../../index";
|
|
3
2
|
export declare class BackendCluster {
|
|
4
3
|
/**
|
|
5
4
|
* Broadcasts an event to listeners across all registered Kuzzle nodes
|
|
@@ -8,34 +7,34 @@ export declare class BackendCluster {
|
|
|
8
7
|
* @param {JSONObject} payload
|
|
9
8
|
* @return {Promise<void>}
|
|
10
9
|
*/
|
|
11
|
-
broadcast(event:
|
|
10
|
+
broadcast<TEventDefinition extends EventDefinition = EventDefinition>(event: TEventDefinition["name"], payload: TEventDefinition["args"][0]): Promise<void>;
|
|
12
11
|
/**
|
|
13
12
|
* Registers a listener to the provided event name.
|
|
14
13
|
*
|
|
15
14
|
* @param {string} event
|
|
16
|
-
* @param {
|
|
15
|
+
* @param {ClusterEventHandler} listener
|
|
17
16
|
* @return {Promise<void>} [description]
|
|
18
17
|
*/
|
|
19
|
-
on(event:
|
|
18
|
+
on<TEventDefinition extends EventDefinition = EventDefinition>(event: TEventDefinition["name"], listener: ClusterEventHandler<TEventDefinition>): Promise<void>;
|
|
20
19
|
/**
|
|
21
20
|
* Registers a listener to the provided event name. This listener can be
|
|
22
21
|
* invoked only once, after which it will be removed from the listeners list.
|
|
23
22
|
*
|
|
24
23
|
* @param {string} event
|
|
25
|
-
* @param {
|
|
24
|
+
* @param {ClusterEventHandler} listener
|
|
26
25
|
* @return {Promise<void>}
|
|
27
26
|
*/
|
|
28
|
-
once(event:
|
|
27
|
+
once<TEventDefinition extends EventDefinition = EventDefinition>(event: TEventDefinition["name"], listener: ClusterEventHandler<TEventDefinition>): Promise<void>;
|
|
29
28
|
/**
|
|
30
29
|
* Removes a listener from an event.
|
|
31
30
|
* If multiple instances of the same listener are registered, only the first
|
|
32
31
|
* one is removed.
|
|
33
32
|
*
|
|
34
33
|
* @param {string} event
|
|
35
|
-
* @param {
|
|
34
|
+
* @param {ClusterEventHandler} listener
|
|
36
35
|
* @return {Promise<void>}
|
|
37
36
|
*/
|
|
38
|
-
off(event:
|
|
37
|
+
off<TEventDefinition extends EventDefinition = EventDefinition>(event: TEventDefinition["name"], listener: ClusterEventHandler<TEventDefinition>): Promise<void>;
|
|
39
38
|
/**
|
|
40
39
|
* Removes all listeners from an event.
|
|
41
40
|
*
|
|
@@ -36,7 +36,7 @@ class BackendCluster {
|
|
|
36
36
|
* Registers a listener to the provided event name.
|
|
37
37
|
*
|
|
38
38
|
* @param {string} event
|
|
39
|
-
* @param {
|
|
39
|
+
* @param {ClusterEventHandler} listener
|
|
40
40
|
* @return {Promise<void>} [description]
|
|
41
41
|
*/
|
|
42
42
|
async on(event, listener) {
|
|
@@ -47,7 +47,7 @@ class BackendCluster {
|
|
|
47
47
|
* invoked only once, after which it will be removed from the listeners list.
|
|
48
48
|
*
|
|
49
49
|
* @param {string} event
|
|
50
|
-
* @param {
|
|
50
|
+
* @param {ClusterEventHandler} listener
|
|
51
51
|
* @return {Promise<void>}
|
|
52
52
|
*/
|
|
53
53
|
async once(event, listener) {
|
|
@@ -59,7 +59,7 @@ class BackendCluster {
|
|
|
59
59
|
* one is removed.
|
|
60
60
|
*
|
|
61
61
|
* @param {string} event
|
|
62
|
-
* @param {
|
|
62
|
+
* @param {ClusterEventHandler} listener
|
|
63
63
|
* @return {Promise<void>}
|
|
64
64
|
*/
|
|
65
65
|
async off(event, listener) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HookEventHandler, EventDefinition } from "../../types";
|
|
2
2
|
import { ApplicationManager } from "./index";
|
|
3
3
|
export declare class BackendHook extends ApplicationManager {
|
|
4
4
|
/**
|
|
@@ -8,5 +8,5 @@ export declare class BackendHook extends ApplicationManager {
|
|
|
8
8
|
* @param handler - Function to execute when the event is triggered
|
|
9
9
|
*
|
|
10
10
|
*/
|
|
11
|
-
register(event:
|
|
11
|
+
register<TEventDefinition extends EventDefinition = EventDefinition>(event: TEventDefinition["name"], handler: HookEventHandler<TEventDefinition>): void;
|
|
12
12
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EventDefinition, PipeEventHandler } from "../../types";
|
|
2
2
|
import { ApplicationManager } from "./index";
|
|
3
3
|
export declare class BackendPipe extends ApplicationManager {
|
|
4
4
|
/**
|
|
@@ -7,6 +7,6 @@ export declare class BackendPipe extends ApplicationManager {
|
|
|
7
7
|
* @param event - Event name
|
|
8
8
|
* @param handler - Function to execute when the event is triggered
|
|
9
9
|
*/
|
|
10
|
-
register(event:
|
|
10
|
+
register<TEventDefinition extends EventDefinition = EventDefinition>(event: TEventDefinition["name"], handler: PipeEventHandler<TEventDefinition>, options?: any): string | void;
|
|
11
11
|
unregister(pipeId: string): void;
|
|
12
12
|
}
|
|
@@ -37,7 +37,7 @@ const kerror = require("../../kerror").wrap("plugin", "runtime");
|
|
|
37
37
|
* { instance: (pipeRunner instance), callback: (callback after pipes execution) }
|
|
38
38
|
*/
|
|
39
39
|
/* eslint-disable no-invalid-this */
|
|
40
|
-
function waterfallCallback(error, result) {
|
|
40
|
+
function waterfallCallback(error, ...result) {
|
|
41
41
|
this.instance.running--;
|
|
42
42
|
|
|
43
43
|
if (!this.instance.buffer.isEmpty()) {
|
|
@@ -52,7 +52,7 @@ function waterfallCallback(error, result) {
|
|
|
52
52
|
|
|
53
53
|
this.callback.call(this.callbackContext, cbError);
|
|
54
54
|
} else {
|
|
55
|
-
this.callback.call(this.callbackContext, null, result);
|
|
55
|
+
this.callback.call(this.callbackContext, null, ...result);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
/* eslint-enable no-invalid-this */
|
|
@@ -1,4 +1,30 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Describe an event with it's name and the handler function arguments
|
|
3
3
|
*/
|
|
4
|
-
export declare type
|
|
4
|
+
export declare type EventDefinition = {
|
|
5
|
+
/**
|
|
6
|
+
* Name of the event
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* "core:document:create:after"
|
|
10
|
+
*/
|
|
11
|
+
name: string;
|
|
12
|
+
/**
|
|
13
|
+
* Arguments of the event
|
|
14
|
+
*/
|
|
15
|
+
args: any[];
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Handler for hook events
|
|
19
|
+
*/
|
|
20
|
+
export declare type HookEventHandler<TEventDefinition extends EventDefinition = EventDefinition> = (...args: TEventDefinition["args"]) => void;
|
|
21
|
+
/**
|
|
22
|
+
* Handler for pipe event.
|
|
23
|
+
*
|
|
24
|
+
* It should return a promise resolving the first received argument.
|
|
25
|
+
*/
|
|
26
|
+
export declare type PipeEventHandler<TEventDefinition extends EventDefinition = EventDefinition> = (...args: TEventDefinition["args"]) => Promise<TEventDefinition["args"][0]>;
|
|
27
|
+
/**
|
|
28
|
+
* Handler for cluster event.
|
|
29
|
+
*/
|
|
30
|
+
export declare type ClusterEventHandler<TEventDefinition extends EventDefinition = EventDefinition> = (...args: TEventDefinition["args"]) => any;
|
package/lib/types/Plugin.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { PluginContext } from "../core/plugin/pluginContext";
|
|
|
2
2
|
import { ControllerDefinition } from "./ControllerDefinition";
|
|
3
3
|
import { PluginManifest } from "./PluginManifest";
|
|
4
4
|
import { StrategyDefinition } from "./StrategyDefinition";
|
|
5
|
-
import {
|
|
5
|
+
import { PipeEventHandler, HookEventHandler } from "./EventHandler";
|
|
6
6
|
import { JSONObject } from "../../index";
|
|
7
7
|
/**
|
|
8
8
|
* Allows to define plugins controllers and actions
|
|
@@ -20,7 +20,7 @@ export declare type PluginHookDefinition = {
|
|
|
20
20
|
/**
|
|
21
21
|
* Event name or wildcard event.
|
|
22
22
|
*/
|
|
23
|
-
[event: string]:
|
|
23
|
+
[event: string]: HookEventHandler | HookEventHandler[];
|
|
24
24
|
};
|
|
25
25
|
/**
|
|
26
26
|
* Allows to define pipes on events
|
|
@@ -29,7 +29,7 @@ export declare type PluginPipeDefinition = {
|
|
|
29
29
|
/**
|
|
30
30
|
* Event name or wildcard event.
|
|
31
31
|
*/
|
|
32
|
-
[event: string]:
|
|
32
|
+
[event: string]: PipeEventHandler | PipeEventHandler[];
|
|
33
33
|
};
|
|
34
34
|
/**
|
|
35
35
|
* Plugins must implements this abstract class.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { KuzzleRequest, KDocument, JSONObject } from "../../../";
|
|
2
|
+
/**
|
|
3
|
+
* Events with documents only having the `_id`
|
|
4
|
+
*/
|
|
5
|
+
declare type EventGenericDocumentPartial<name extends string> = {
|
|
6
|
+
name: `generic:document:${name}`;
|
|
7
|
+
args: [Array<{
|
|
8
|
+
_id: string;
|
|
9
|
+
}>, KuzzleRequest];
|
|
10
|
+
};
|
|
11
|
+
export declare type EventGenericDocumentBeforeDelete = EventGenericDocumentPartial<"beforeDelete">;
|
|
12
|
+
export declare type EventGenericDocumentAfterDelete = EventGenericDocumentPartial<"afterDelete">;
|
|
13
|
+
export declare type EventGenericDocumentBeforeGet = EventGenericDocumentPartial<"beforeGet">;
|
|
14
|
+
/**
|
|
15
|
+
* Events having entire documents
|
|
16
|
+
*/
|
|
17
|
+
declare type EventGenericDocument<name extends string, KDocumentContent> = {
|
|
18
|
+
name: `generic:document:${name}`;
|
|
19
|
+
args: [KDocument<KDocumentContent>[], KuzzleRequest];
|
|
20
|
+
};
|
|
21
|
+
export declare type EventGenericDocumentBeforeWrite<KDocumentContent = JSONObject> = EventGenericDocument<"beforeWrite", KDocumentContent>;
|
|
22
|
+
export declare type EventGenericDocumentAfterWrite<KDocumentContent = JSONObject> = EventGenericDocument<"afterWrite", KDocumentContent>;
|
|
23
|
+
export declare type EventGenericDocumentBeforeUpdate<KDocumentContent = JSONObject> = EventGenericDocument<"beforeUpdate", KDocumentContent>;
|
|
24
|
+
export declare type EventGenericDocumentAfterUpdate<KDocumentContent = JSONObject> = EventGenericDocument<"afterUpdate", KDocumentContent>;
|
|
25
|
+
export declare type EventGenericDocumentAfterGet<KDocumentContent = JSONObject> = EventGenericDocument<"afterGet", KDocumentContent>;
|
|
26
|
+
export {};
|
package/lib/types/index.d.ts
CHANGED
package/lib/types/index.js
CHANGED
|
@@ -72,4 +72,5 @@ __exportStar(require("./config/DumpConfiguration"), exports);
|
|
|
72
72
|
__exportStar(require("./OpenApiDefinition"), exports);
|
|
73
73
|
__exportStar(require("./errors/ErrorDefinition"), exports);
|
|
74
74
|
__exportStar(require("./errors/ErrorDomains"), exports);
|
|
75
|
+
__exportStar(require("./events/EventGenericDocument"), exports);
|
|
75
76
|
//# sourceMappingURL=index.js.map
|
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.19.
|
|
4
|
+
"version": "2.19.4",
|
|
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
|
"bin": "bin/start-kuzzle-server",
|
|
7
7
|
"scripts": {
|
|
@@ -44,46 +44,45 @@
|
|
|
44
44
|
"@types/js-yaml": "^4.0.5",
|
|
45
45
|
"aedes": "^0.46.3",
|
|
46
46
|
"bluebird": "^3.7.2",
|
|
47
|
-
"cli-color": "^2.0.
|
|
47
|
+
"cli-color": "^2.0.3",
|
|
48
48
|
"cookie": "^0.5.0",
|
|
49
49
|
"debug": "^4.3.4",
|
|
50
|
-
"denque": "^2.0
|
|
50
|
+
"denque": "^2.1.0",
|
|
51
51
|
"didyoumean": "^1.2.2",
|
|
52
52
|
"dumpme": "^1.0.3",
|
|
53
53
|
"eventemitter3": "^4.0.7",
|
|
54
|
-
"inquirer": "^
|
|
55
|
-
"ioredis": "^5.
|
|
54
|
+
"inquirer": "^9.1.1",
|
|
55
|
+
"ioredis": "^5.2.3",
|
|
56
56
|
"js-yaml": "^4.1.0",
|
|
57
57
|
"json-stable-stringify": "^1.0.1",
|
|
58
58
|
"json2yaml": "^1.1.0",
|
|
59
59
|
"jsonwebtoken": "^8.5.1",
|
|
60
|
-
"koncorde": "^4.0.
|
|
60
|
+
"koncorde": "^4.0.3",
|
|
61
61
|
"kuzzle-plugin-auth-passport-local": "^6.3.6",
|
|
62
62
|
"kuzzle-plugin-logger": "^3.0.3",
|
|
63
|
-
"kuzzle-sdk": "^7.10.
|
|
63
|
+
"kuzzle-sdk": "^7.10.1",
|
|
64
64
|
"kuzzle-vault": "^2.0.4",
|
|
65
65
|
"lodash": "4.17.21",
|
|
66
66
|
"long": "^5.2.0",
|
|
67
|
-
"moment": "^2.29.
|
|
67
|
+
"moment": "^2.29.4",
|
|
68
68
|
"ms": "^2.1.3",
|
|
69
69
|
"murmurhash-native": "^3.5.0",
|
|
70
|
-
"nanoid": "^3.3.3",
|
|
71
70
|
"ndjson": "^2.0.0",
|
|
72
|
-
"node-segfault-handler": "^1.0
|
|
73
|
-
"passport": "^0.
|
|
71
|
+
"node-segfault-handler": "^1.1.0",
|
|
72
|
+
"passport": "^0.6.0",
|
|
74
73
|
"prettier": "^2.7.1",
|
|
75
|
-
"protobufjs": "~
|
|
74
|
+
"protobufjs": "~7.1.0",
|
|
76
75
|
"rc": "1.2.8",
|
|
77
76
|
"semver": "^7.3.7",
|
|
78
77
|
"sorted-array": "^2.0.4",
|
|
79
78
|
"uWebSockets.js": "https://github.com/uNetworking/uWebSockets.js/archive/refs/tags/v20.0.0.tar.gz",
|
|
80
|
-
"uuid": "^
|
|
79
|
+
"uuid": "^9.0.0",
|
|
81
80
|
"validator": "^13.7.0",
|
|
82
|
-
"winston": "^3.
|
|
83
|
-
"winston-elasticsearch": "0.
|
|
84
|
-
"winston-syslog": "^2.
|
|
81
|
+
"winston": "^3.8.1",
|
|
82
|
+
"winston-elasticsearch": "0.17.1",
|
|
83
|
+
"winston-syslog": "^2.6.0",
|
|
85
84
|
"winston-transport": "^4.5.0",
|
|
86
|
-
"yargs": "^17.
|
|
85
|
+
"yargs": "^17.5.1",
|
|
87
86
|
"zeromq": "^6.0.0-beta.6"
|
|
88
87
|
},
|
|
89
88
|
"repository": {
|
|
@@ -91,16 +90,16 @@
|
|
|
91
90
|
"url": "git://github.com/kuzzleio/kuzzle.git"
|
|
92
91
|
},
|
|
93
92
|
"devDependencies": {
|
|
94
|
-
"@types/lodash": "^4.14.
|
|
95
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
96
|
-
"@typescript-eslint/parser": "^5.
|
|
97
|
-
"async": "^3.2.
|
|
93
|
+
"@types/lodash": "^4.14.184",
|
|
94
|
+
"@typescript-eslint/eslint-plugin": "^5.36.2",
|
|
95
|
+
"@typescript-eslint/parser": "^5.36.2",
|
|
96
|
+
"async": "^3.2.4",
|
|
98
97
|
"chokidar": "^3.5.3",
|
|
99
98
|
"codecov": "^3.8.3",
|
|
100
99
|
"cucumber": "^6.0.5",
|
|
101
100
|
"ergol": "^1.0.2",
|
|
102
|
-
"eslint": "^8.
|
|
103
|
-
"eslint-plugin-kuzzle": "0.0.
|
|
101
|
+
"eslint": "^8.23.0",
|
|
102
|
+
"eslint-plugin-kuzzle": "0.0.5",
|
|
104
103
|
"mocha": "^9.2.2",
|
|
105
104
|
"mock-require": "^3.0.3",
|
|
106
105
|
"mqtt": "^4.3.7",
|
|
@@ -112,9 +111,9 @@
|
|
|
112
111
|
"should-sinon": "0.0.6",
|
|
113
112
|
"sinon": "^13.0.2",
|
|
114
113
|
"strip-json-comments": "https://github.com/sindresorhus/strip-json-comments/archive/refs/tags/v3.1.1.tar.gz",
|
|
115
|
-
"ts-node": "^10.
|
|
116
|
-
"typescript": "^4.
|
|
117
|
-
"yaml": "^2.
|
|
114
|
+
"ts-node": "^10.9.1",
|
|
115
|
+
"typescript": "^4.8.2",
|
|
116
|
+
"yaml": "^2.1.1"
|
|
118
117
|
},
|
|
119
118
|
"engines": {
|
|
120
119
|
"node": ">= 12.13.0"
|