kuzzle 2.19.9 → 2.19.11
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/controllers/documentController.js +4 -1
- package/lib/api/request/requestContext.d.ts +1 -1
- package/lib/cluster/idCardHandler.d.ts +1 -1
- package/lib/cluster/state.d.ts +3 -3
- package/lib/core/backend/backend.js +2 -1
- package/lib/core/backend/backendImport.d.ts +1 -1
- package/lib/core/network/protocols/httpwsProtocol.js +38 -8
- package/lib/core/realtime/channel.js +12 -12
- package/lib/core/security/profileRepository.d.ts +3 -3
- package/lib/model/security/profile.d.ts +1 -1
- package/lib/service/storage/elasticsearch.js +43 -2
- package/lib/types/ClientConnection.d.ts +7 -0
- package/lib/types/ClientConnection.js +3 -0
- package/lib/types/Controller.js +3 -3
- package/lib/types/ControllerDefinition.d.ts +2 -2
- package/lib/types/ControllerRights.d.ts +2 -2
- package/lib/types/DebugModule.d.ts +1 -1
- package/lib/types/Deprecation.d.ts +1 -1
- package/lib/types/EventHandler.d.ts +5 -5
- package/lib/types/HttpMessage.d.ts +12 -0
- package/lib/types/HttpMessage.js +3 -0
- package/lib/types/HttpStream.d.ts +1 -1
- package/lib/types/HttpStream.js +4 -4
- package/lib/types/Kuzzle.d.ts +4 -4
- package/lib/types/OpenApiDefinition.d.ts +1 -1
- package/lib/types/PasswordPolicy.d.ts +1 -1
- package/lib/types/Plugin.d.ts +3 -3
- package/lib/types/PluginManifest.d.ts +1 -1
- package/lib/types/Policy.d.ts +2 -2
- package/lib/types/PolicyRestrictions.d.ts +2 -2
- package/lib/types/ProfileDefinition.d.ts +1 -1
- package/lib/types/RoleDefinition.d.ts +1 -1
- package/lib/types/StrategyDefinition.d.ts +1 -1
- package/lib/types/Target.d.ts +1 -1
- package/lib/types/config/DumpConfiguration.d.ts +1 -1
- package/lib/types/config/HttpConfiguration.d.ts +1 -1
- package/lib/types/config/KuzzleConfiguration.d.ts +1 -1
- package/lib/types/config/LimitsConfiguration.d.ts +1 -1
- package/lib/types/config/PluginsConfiguration.d.ts +1 -1
- package/lib/types/config/SecurityConfiguration.d.ts +1 -1
- package/lib/types/config/ServerConfiguration.d.ts +1 -1
- package/lib/types/config/ServicesConfiguration.d.ts +1 -1
- package/lib/types/config/internalCache/InternalCacheRedisConfiguration.d.ts +1 -1
- package/lib/types/config/publicCache/PublicCacheRedisConfiguration.d.ts +1 -1
- package/lib/types/config/storageEngine/StorageEngineElasticsearchConfiguration.d.ts +1 -1
- package/lib/types/errors/ErrorDefinition.d.ts +3 -3
- package/lib/types/errors/ErrorDomains.d.ts +1 -1
- package/lib/types/events/EventGenericDocument.d.ts +10 -10
- package/lib/types/events/EventProtocol.d.ts +32 -0
- package/lib/types/events/EventProtocol.js +3 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +1 -0
- package/lib/types/realtime/RealtimeScope.d.ts +1 -1
- package/lib/types/realtime/RealtimeUsers.d.ts +1 -1
- package/lib/types/realtime/RoomList.d.ts +1 -1
- package/lib/util/bufferedPassThrough.d.ts +4 -4
- package/lib/util/dump-collection.js +21 -16
- package/lib/util/name-generator.d.ts +1 -1
- package/package.json +15 -15
|
@@ -363,7 +363,10 @@ class DocumentController extends NativeController {
|
|
|
363
363
|
async count(request) {
|
|
364
364
|
const { searchBody } = request.getSearchParams();
|
|
365
365
|
const { index, collection } = request.getIndexAndCollection();
|
|
366
|
-
|
|
366
|
+
const lang = request.getLangParam();
|
|
367
|
+
if (lang === "koncorde") {
|
|
368
|
+
searchBody.query = await this.translateKoncorde(searchBody.query);
|
|
369
|
+
}
|
|
367
370
|
const count = await this.ask(
|
|
368
371
|
"core:storage:public:document:count",
|
|
369
372
|
index,
|
package/lib/cluster/state.d.ts
CHANGED
|
@@ -3,12 +3,12 @@ import { JSONObject } from "kuzzle-sdk";
|
|
|
3
3
|
import { RoomList } from "../types";
|
|
4
4
|
import Long from "long";
|
|
5
5
|
import "../types/Global";
|
|
6
|
-
export
|
|
6
|
+
export type SerializedRoomSubscriptions = {
|
|
7
7
|
nodeId: string;
|
|
8
8
|
messageId: Long;
|
|
9
9
|
subscribers: number;
|
|
10
10
|
};
|
|
11
|
-
export
|
|
11
|
+
export type SerializedRoomState = {
|
|
12
12
|
collection: string;
|
|
13
13
|
filters: string;
|
|
14
14
|
index: string;
|
|
@@ -88,7 +88,7 @@ export default class State {
|
|
|
88
88
|
*/
|
|
89
89
|
loadFullState(serialized: SerializedState): void;
|
|
90
90
|
}
|
|
91
|
-
export
|
|
91
|
+
export type SerializedState = {
|
|
92
92
|
authStrategies: JSONObject[];
|
|
93
93
|
rooms: SerializedRoomState[];
|
|
94
94
|
};
|
|
@@ -163,12 +163,13 @@ class Backend {
|
|
|
163
163
|
* Starts the Kuzzle application with the defined features
|
|
164
164
|
*/
|
|
165
165
|
async start() {
|
|
166
|
+
var _a;
|
|
166
167
|
if (this.started) {
|
|
167
168
|
throw runtimeError.get("already_started", "start");
|
|
168
169
|
}
|
|
169
170
|
this._kuzzle = new kuzzle_1.default(this.config.content);
|
|
170
171
|
for (const plugin of this.config.content.plugins.common.include) {
|
|
171
|
-
const { default: PluginClass } = await Promise.resolve().then(() => __importStar(require(
|
|
172
|
+
const { default: PluginClass } = await (_a = plugin, Promise.resolve().then(() => __importStar(require(_a))));
|
|
172
173
|
this.plugin.use(new PluginClass(), {
|
|
173
174
|
deprecationWarning: false,
|
|
174
175
|
name: plugin,
|
|
@@ -81,12 +81,13 @@ const HTTP_ALLOWED_CONTENT_TYPES = [
|
|
|
81
81
|
"application/x-www-form-urlencoded",
|
|
82
82
|
"multipart/form-data",
|
|
83
83
|
];
|
|
84
|
-
const HTTP_SKIPPED_HEADERS = ["content-length"];
|
|
84
|
+
const HTTP_SKIPPED_HEADERS = ["content-length", "set-cookie"];
|
|
85
85
|
const HTTP_HEADER_CONNECTION = Buffer.from("Connection");
|
|
86
86
|
const HTTP_HEADER_CONTENT_LENGTH = Buffer.from("Content-Length");
|
|
87
87
|
const HTTP_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN = Buffer.from(
|
|
88
88
|
"Access-Control-Allow-Origin"
|
|
89
89
|
);
|
|
90
|
+
const HTTP_HEADER_SET_COOKIE = Buffer.from("Set-Cookie");
|
|
90
91
|
const HTTP_HEADER_VARY = Buffer.from("Vary");
|
|
91
92
|
const HTTP_HEADER_TRANSFER_ENCODING = Buffer.from("Transfer-Encoding");
|
|
92
93
|
const CHUNKED = Buffer.from("chunked");
|
|
@@ -323,7 +324,7 @@ class HttpWsProtocol extends Protocol {
|
|
|
323
324
|
this.socketByConnectionId.delete(connection.id);
|
|
324
325
|
}
|
|
325
326
|
|
|
326
|
-
wsOnMessageHandler(socket, data) {
|
|
327
|
+
async wsOnMessageHandler(socket, data) {
|
|
327
328
|
if (!data || data.byteLength === 0) {
|
|
328
329
|
return;
|
|
329
330
|
}
|
|
@@ -346,12 +347,20 @@ class HttpWsProtocol extends Protocol {
|
|
|
346
347
|
}
|
|
347
348
|
|
|
348
349
|
let parsed;
|
|
349
|
-
|
|
350
|
+
let message = Buffer.from(data).toString();
|
|
350
351
|
|
|
351
352
|
debugWS("[%s] client message: %s", connection.id, message);
|
|
352
353
|
|
|
354
|
+
({ payload: message } = await global.kuzzle.pipe(
|
|
355
|
+
"protocol:websocket:beforeParsingPayload",
|
|
356
|
+
{ connection, payload: message }
|
|
357
|
+
));
|
|
358
|
+
|
|
353
359
|
try {
|
|
354
|
-
parsed =
|
|
360
|
+
({ payload: parsed } = await global.kuzzle.pipe(
|
|
361
|
+
"protocol:websocket:afterParsingPayload",
|
|
362
|
+
{ connection, payload: JSON.parse(message) }
|
|
363
|
+
));
|
|
355
364
|
} catch (e) {
|
|
356
365
|
/*
|
|
357
366
|
we cannot add a "room" information since we need to extract
|
|
@@ -551,14 +560,25 @@ class HttpWsProtocol extends Protocol {
|
|
|
551
560
|
return;
|
|
552
561
|
}
|
|
553
562
|
|
|
554
|
-
|
|
563
|
+
let resolve;
|
|
564
|
+
let promise = new Promise((res) => (resolve = res));
|
|
565
|
+
|
|
566
|
+
this.httpUncompress(message, payload, async (err, inflated) => {
|
|
555
567
|
if (err) {
|
|
556
568
|
cb(err);
|
|
569
|
+
resolve();
|
|
557
570
|
return;
|
|
558
571
|
}
|
|
559
572
|
|
|
560
|
-
|
|
573
|
+
const { payload: newPayload } = await global.kuzzle.pipe(
|
|
574
|
+
"protocol:http:beforeParsingPayload",
|
|
575
|
+
{ message, payload: inflated }
|
|
576
|
+
);
|
|
577
|
+
await this.httpParseContent(message, newPayload, cb);
|
|
578
|
+
resolve();
|
|
561
579
|
});
|
|
580
|
+
|
|
581
|
+
return promise;
|
|
562
582
|
});
|
|
563
583
|
|
|
564
584
|
// Beware: the "response" object might be invalidated at any point of time,
|
|
@@ -568,7 +588,7 @@ class HttpWsProtocol extends Protocol {
|
|
|
568
588
|
});
|
|
569
589
|
}
|
|
570
590
|
|
|
571
|
-
httpParseContent(message, content, cb) {
|
|
591
|
+
async httpParseContent(message, content, cb) {
|
|
572
592
|
const type = message.headers["content-type"] || "";
|
|
573
593
|
|
|
574
594
|
if (type.includes("multipart/form-data")) {
|
|
@@ -600,7 +620,11 @@ class HttpWsProtocol extends Protocol {
|
|
|
600
620
|
message.content = querystring.parse(content.toString());
|
|
601
621
|
} else {
|
|
602
622
|
try {
|
|
603
|
-
|
|
623
|
+
const { payload } = await global.kuzzle.pipe(
|
|
624
|
+
"protocol:http:afterParsingPayload",
|
|
625
|
+
{ message, payload: JSON.parse(content.toString()) }
|
|
626
|
+
);
|
|
627
|
+
message.content = payload;
|
|
604
628
|
} catch (e) {
|
|
605
629
|
cb(
|
|
606
630
|
kerrorHTTP.get("body_parse_failed", content.toString().slice(0, 50))
|
|
@@ -702,6 +726,12 @@ class HttpWsProtocol extends Protocol {
|
|
|
702
726
|
response.writeHeader(HTTP_HEADER_VARY, ORIGIN);
|
|
703
727
|
}
|
|
704
728
|
|
|
729
|
+
if (request.response.headers["set-cookie"]) {
|
|
730
|
+
for (const cookie of request.response.headers["set-cookie"]) {
|
|
731
|
+
response.writeHeader(HTTP_HEADER_SET_COOKIE, Buffer.from(cookie));
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
|
|
705
735
|
for (const [key, value] of Object.entries(request.response.headers)) {
|
|
706
736
|
// Skip some headers that are not allowed to be sent or modified
|
|
707
737
|
if (HTTP_SKIPPED_HEADERS.includes(key.toLowerCase())) {
|
|
@@ -68,18 +68,6 @@ const realtimeError = kerror.wrap("core", "realtime");
|
|
|
68
68
|
* @property cluster
|
|
69
69
|
*/
|
|
70
70
|
class Channel {
|
|
71
|
-
constructor(roomId, { scope = "all", users = "none", propagate = true, } = {}) {
|
|
72
|
-
this.scope = scope;
|
|
73
|
-
this.users = users;
|
|
74
|
-
this.cluster = propagate;
|
|
75
|
-
if (!Channel.SCOPE_ALLOWED_VALUES.includes(this.scope)) {
|
|
76
|
-
throw realtimeError.get("invalid_scope");
|
|
77
|
-
}
|
|
78
|
-
if (!Channel.USERS_ALLOWED_VALUES.includes(this.users)) {
|
|
79
|
-
throw realtimeError.get("invalid_users");
|
|
80
|
-
}
|
|
81
|
-
this.name = `${roomId}-${Channel.hash(this)}`;
|
|
82
|
-
}
|
|
83
71
|
/**
|
|
84
72
|
* Dummy hash function since we only need to keep the channel configuration.
|
|
85
73
|
*
|
|
@@ -122,6 +110,18 @@ class Channel {
|
|
|
122
110
|
}
|
|
123
111
|
return str;
|
|
124
112
|
}
|
|
113
|
+
constructor(roomId, { scope = "all", users = "none", propagate = true, } = {}) {
|
|
114
|
+
this.scope = scope;
|
|
115
|
+
this.users = users;
|
|
116
|
+
this.cluster = propagate;
|
|
117
|
+
if (!Channel.SCOPE_ALLOWED_VALUES.includes(this.scope)) {
|
|
118
|
+
throw realtimeError.get("invalid_scope");
|
|
119
|
+
}
|
|
120
|
+
if (!Channel.USERS_ALLOWED_VALUES.includes(this.users)) {
|
|
121
|
+
throw realtimeError.get("invalid_users");
|
|
122
|
+
}
|
|
123
|
+
this.name = `${roomId}-${Channel.hash(this)}`;
|
|
124
|
+
}
|
|
125
125
|
}
|
|
126
126
|
exports.Channel = Channel;
|
|
127
127
|
Channel.USERS_ALLOWED_VALUES = ["all", "in", "out", "none"];
|
|
@@ -3,21 +3,21 @@ import { Profile } from "../../model/security/profile";
|
|
|
3
3
|
import Repository from "../shared/repository";
|
|
4
4
|
import { JSONObject } from "kuzzle-sdk";
|
|
5
5
|
/** @internal */
|
|
6
|
-
|
|
6
|
+
type CreateOrReplaceOptions = {
|
|
7
7
|
method?: string;
|
|
8
8
|
refresh?: string;
|
|
9
9
|
strict?: boolean;
|
|
10
10
|
userId?: string;
|
|
11
11
|
};
|
|
12
12
|
/** @internal */
|
|
13
|
-
|
|
13
|
+
type ValidateAndSaveProfileOptions = {
|
|
14
14
|
method?: string;
|
|
15
15
|
refresh?: string;
|
|
16
16
|
strict?: boolean;
|
|
17
17
|
retryOnConflict?: number;
|
|
18
18
|
};
|
|
19
19
|
/** @internal */
|
|
20
|
-
|
|
20
|
+
type UpdateOptions = {
|
|
21
21
|
userId?: string;
|
|
22
22
|
refresh?: string;
|
|
23
23
|
strict?: boolean;
|
|
@@ -2,7 +2,7 @@ import { Policy, OptimizedPolicy, OptimizedPolicyRestrictions } from "../../type
|
|
|
2
2
|
import { Role } from "./role";
|
|
3
3
|
import { KuzzleRequest } from "../../../index";
|
|
4
4
|
/** @internal */
|
|
5
|
-
|
|
5
|
+
type InternalProfilePolicy = {
|
|
6
6
|
role: Role;
|
|
7
7
|
restrictedTo: OptimizedPolicyRestrictions;
|
|
8
8
|
};
|
|
@@ -1375,6 +1375,7 @@ class ElasticSearch extends Service {
|
|
|
1375
1375
|
settings,
|
|
1376
1376
|
},
|
|
1377
1377
|
index: await this._getAvailableIndice(index, collection),
|
|
1378
|
+
wait_for_active_shards: await this._getWaitForActiveShards(),
|
|
1378
1379
|
};
|
|
1379
1380
|
|
|
1380
1381
|
this._checkDynamicProperty(mappings);
|
|
@@ -1692,6 +1693,7 @@ class ElasticSearch extends Service {
|
|
|
1692
1693
|
mappings,
|
|
1693
1694
|
settings,
|
|
1694
1695
|
},
|
|
1696
|
+
wait_for_active_shards: await this._getWaitForActiveShards(),
|
|
1695
1697
|
});
|
|
1696
1698
|
|
|
1697
1699
|
return null;
|
|
@@ -1959,6 +1961,12 @@ class ElasticSearch extends Service {
|
|
|
1959
1961
|
try {
|
|
1960
1962
|
await this._client.indices.delete(esRequest);
|
|
1961
1963
|
|
|
1964
|
+
if (await this._checkIfAliasExists(this._getAlias(index, collection))) {
|
|
1965
|
+
await this._client.indices.deleteAlias({
|
|
1966
|
+
name: this._getAlias(index, collection),
|
|
1967
|
+
});
|
|
1968
|
+
}
|
|
1969
|
+
|
|
1962
1970
|
await this._createHiddenCollection(index);
|
|
1963
1971
|
} catch (e) {
|
|
1964
1972
|
throw this._esWrapper.formatESError(e);
|
|
@@ -2915,6 +2923,16 @@ class ElasticSearch extends Service {
|
|
|
2915
2923
|
return `${ALIAS_PREFIX}${this._indexPrefix}${index}${NAME_SEPARATOR}${collection}`;
|
|
2916
2924
|
}
|
|
2917
2925
|
|
|
2926
|
+
/**
|
|
2927
|
+
* Given an alias name, returns the associated index name.
|
|
2928
|
+
*/
|
|
2929
|
+
async _checkIfAliasExists(aliasName) {
|
|
2930
|
+
const { body } = await this._client.indices.existsAlias({
|
|
2931
|
+
name: aliasName,
|
|
2932
|
+
});
|
|
2933
|
+
return body;
|
|
2934
|
+
}
|
|
2935
|
+
|
|
2918
2936
|
/**
|
|
2919
2937
|
* Given index + collection, returns the associated indice name.
|
|
2920
2938
|
* Use this function if ES does not accept aliases in the request. Otherwise use `_getAlias`.
|
|
@@ -3143,7 +3161,7 @@ class ElasticSearch extends Service {
|
|
|
3143
3161
|
return;
|
|
3144
3162
|
}
|
|
3145
3163
|
|
|
3146
|
-
|
|
3164
|
+
const esRequest = {
|
|
3147
3165
|
body: {
|
|
3148
3166
|
aliases: {
|
|
3149
3167
|
[this._getAlias(index, HIDDEN_COLLECTION)]: {},
|
|
@@ -3154,7 +3172,10 @@ class ElasticSearch extends Service {
|
|
|
3154
3172
|
},
|
|
3155
3173
|
},
|
|
3156
3174
|
index: await this._getAvailableIndice(index, HIDDEN_COLLECTION),
|
|
3157
|
-
|
|
3175
|
+
wait_for_active_shards: await this._getWaitForActiveShards(),
|
|
3176
|
+
};
|
|
3177
|
+
|
|
3178
|
+
await this._client.indices.create(esRequest);
|
|
3158
3179
|
} catch (e) {
|
|
3159
3180
|
throw this._esWrapper.formatESError(e);
|
|
3160
3181
|
} finally {
|
|
@@ -3162,6 +3183,26 @@ class ElasticSearch extends Service {
|
|
|
3162
3183
|
}
|
|
3163
3184
|
}
|
|
3164
3185
|
|
|
3186
|
+
/**
|
|
3187
|
+
* We need to always wait for a minimal number of shards to be available
|
|
3188
|
+
* before answering to the client. This is to avoid Elasticsearch node
|
|
3189
|
+
* to return a 404 Not Found error when the client tries to index a
|
|
3190
|
+
* document in the index.
|
|
3191
|
+
* To find the best value for this setting, we need to take into account
|
|
3192
|
+
* the number of nodes in the cluster and the number of shards per index.
|
|
3193
|
+
*/
|
|
3194
|
+
async _getWaitForActiveShards() {
|
|
3195
|
+
const { body } = await this._client.cat.nodes({ format: "json" });
|
|
3196
|
+
|
|
3197
|
+
const numberOfNodes = body.length;
|
|
3198
|
+
|
|
3199
|
+
if (numberOfNodes > 1) {
|
|
3200
|
+
return "all";
|
|
3201
|
+
}
|
|
3202
|
+
|
|
3203
|
+
return 1;
|
|
3204
|
+
}
|
|
3205
|
+
|
|
3165
3206
|
/**
|
|
3166
3207
|
* Scroll indice in elasticsearch and return all document that match the filter
|
|
3167
3208
|
* /!\ throws a write_limit_exceed error: this method is intended to be used
|
package/lib/types/Controller.js
CHANGED
|
@@ -25,15 +25,15 @@ exports.Controller = void 0;
|
|
|
25
25
|
* Base class to declare a controller class
|
|
26
26
|
*/
|
|
27
27
|
class Controller {
|
|
28
|
-
constructor(app) {
|
|
29
|
-
this.app = app;
|
|
30
|
-
}
|
|
31
28
|
/**
|
|
32
29
|
* EmbeddedSDK instance
|
|
33
30
|
*/
|
|
34
31
|
get sdk() {
|
|
35
32
|
return this.app.sdk;
|
|
36
33
|
}
|
|
34
|
+
constructor(app) {
|
|
35
|
+
this.app = app;
|
|
36
|
+
}
|
|
37
37
|
}
|
|
38
38
|
exports.Controller = Controller;
|
|
39
39
|
//# sourceMappingURL=Controller.js.map
|
|
@@ -13,7 +13,7 @@ import { KuzzleRequest } from "../api/request";
|
|
|
13
13
|
* }
|
|
14
14
|
* }
|
|
15
15
|
*/
|
|
16
|
-
export
|
|
16
|
+
export type ControllerDefinition = {
|
|
17
17
|
/**
|
|
18
18
|
* Definition of controller actions
|
|
19
19
|
*
|
|
@@ -64,7 +64,7 @@ export declare type ControllerDefinition = {
|
|
|
64
64
|
/**
|
|
65
65
|
* Http route definition
|
|
66
66
|
*/
|
|
67
|
-
export
|
|
67
|
+
export type HttpRoute = {
|
|
68
68
|
/**
|
|
69
69
|
* HTTP verb.
|
|
70
70
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @internal */
|
|
2
|
-
export
|
|
2
|
+
export type ControllerRight = {
|
|
3
3
|
actions: {
|
|
4
4
|
[action: string]: boolean;
|
|
5
5
|
};
|
|
@@ -17,6 +17,6 @@ export declare type ControllerRight = {
|
|
|
17
17
|
* }
|
|
18
18
|
* }
|
|
19
19
|
*/
|
|
20
|
-
export
|
|
20
|
+
export type ControllerRights = {
|
|
21
21
|
[controller: string]: ControllerRight;
|
|
22
22
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Describe an event with it's name and the handler function arguments
|
|
3
3
|
*/
|
|
4
|
-
export
|
|
4
|
+
export type EventDefinition = {
|
|
5
5
|
/**
|
|
6
6
|
* Name of the event
|
|
7
7
|
*
|
|
@@ -17,18 +17,18 @@ export declare type EventDefinition = {
|
|
|
17
17
|
/**
|
|
18
18
|
* Handler for hook events
|
|
19
19
|
*/
|
|
20
|
-
export
|
|
20
|
+
export type HookEventHandler<TEventDefinition extends EventDefinition = EventDefinition> = (...args: TEventDefinition["args"]) => void;
|
|
21
21
|
/**
|
|
22
22
|
* Handler for pipe event.
|
|
23
23
|
*
|
|
24
24
|
* It should return a promise resolving the first received argument.
|
|
25
25
|
*/
|
|
26
|
-
export
|
|
26
|
+
export type PipeEventHandler<TEventDefinition extends EventDefinition = EventDefinition> = (...args: TEventDefinition["args"]) => Promise<TEventDefinition["args"][0]>;
|
|
27
27
|
/**
|
|
28
28
|
* Handler for cluster event.
|
|
29
29
|
*/
|
|
30
|
-
export
|
|
30
|
+
export type ClusterEventHandler<TEventDefinition extends EventDefinition = EventDefinition> = (...args: TEventDefinition["args"]) => any;
|
|
31
31
|
/**
|
|
32
32
|
* @deprecated Use HookEventHandler, PipeEventHandler or ClusterEventHandler
|
|
33
33
|
*/
|
|
34
|
-
export
|
|
34
|
+
export type EventHandler = (...payload: any) => any;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { JSONObject } from "../..";
|
|
2
|
+
import { ClientConnection } from "./ClientConnection";
|
|
3
|
+
export interface HttpMessage {
|
|
4
|
+
connection: ClientConnection;
|
|
5
|
+
content: JSONObject;
|
|
6
|
+
ips: string[];
|
|
7
|
+
query: string;
|
|
8
|
+
path: string;
|
|
9
|
+
method: string;
|
|
10
|
+
headers: JSONObject;
|
|
11
|
+
requestId: string;
|
|
12
|
+
}
|
package/lib/types/HttpStream.js
CHANGED
|
@@ -26,16 +26,16 @@ exports.HttpStream = void 0;
|
|
|
26
26
|
* and provide additional informations about the given data
|
|
27
27
|
*/
|
|
28
28
|
class HttpStream {
|
|
29
|
+
get readableState() {
|
|
30
|
+
// @ts-ignore
|
|
31
|
+
return this.stream._readableState;
|
|
32
|
+
}
|
|
29
33
|
constructor(readableStream, { totalBytes = -1 } = {}) {
|
|
30
34
|
this._destroyed = false;
|
|
31
35
|
this.stream = readableStream;
|
|
32
36
|
this.totalBytes = totalBytes;
|
|
33
37
|
this._destroyed = readableStream.destroyed;
|
|
34
38
|
}
|
|
35
|
-
get readableState() {
|
|
36
|
-
// @ts-ignore
|
|
37
|
-
return this.stream._readableState;
|
|
38
|
-
}
|
|
39
39
|
/**
|
|
40
40
|
* Returns if the stream is errored
|
|
41
41
|
*/
|
package/lib/types/Kuzzle.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { JSONObject } from "../../index";
|
|
2
|
-
export
|
|
2
|
+
export type InstallationConfig = {
|
|
3
3
|
id: string;
|
|
4
4
|
handler: () => Promise<void>;
|
|
5
5
|
description?: string;
|
|
6
6
|
};
|
|
7
|
-
export
|
|
7
|
+
export type StartOptions = {
|
|
8
8
|
import?: JSONObject;
|
|
9
9
|
plugins?: JSONObject;
|
|
10
10
|
secretsFile?: JSONObject;
|
|
@@ -12,7 +12,7 @@ export declare type StartOptions = {
|
|
|
12
12
|
vaultKey?: JSONObject;
|
|
13
13
|
installations?: Array<InstallationConfig>;
|
|
14
14
|
};
|
|
15
|
-
export
|
|
15
|
+
export type ImportConfig = {
|
|
16
16
|
mappings?: JSONObject;
|
|
17
17
|
onExistingUsers?: string;
|
|
18
18
|
profiles?: JSONObject;
|
|
@@ -20,7 +20,7 @@ export declare type ImportConfig = {
|
|
|
20
20
|
userMappings?: JSONObject;
|
|
21
21
|
users?: JSONObject;
|
|
22
22
|
};
|
|
23
|
-
export
|
|
23
|
+
export type SupportConfig = {
|
|
24
24
|
fixtures?: JSONObject;
|
|
25
25
|
mappings?: JSONObject;
|
|
26
26
|
securities?: {
|
package/lib/types/Plugin.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { JSONObject } from "../../index";
|
|
|
7
7
|
/**
|
|
8
8
|
* Allows to define plugins controllers and actions
|
|
9
9
|
*/
|
|
10
|
-
export
|
|
10
|
+
export type PluginApiDefinition = {
|
|
11
11
|
/**
|
|
12
12
|
* Name of the API controller.
|
|
13
13
|
*/
|
|
@@ -16,7 +16,7 @@ export declare type PluginApiDefinition = {
|
|
|
16
16
|
/**
|
|
17
17
|
* Allows to define hooks on events
|
|
18
18
|
*/
|
|
19
|
-
export
|
|
19
|
+
export type PluginHookDefinition = {
|
|
20
20
|
/**
|
|
21
21
|
* Event name or wildcard event.
|
|
22
22
|
*/
|
|
@@ -25,7 +25,7 @@ export declare type PluginHookDefinition = {
|
|
|
25
25
|
/**
|
|
26
26
|
* Allows to define pipes on events
|
|
27
27
|
*/
|
|
28
|
-
export
|
|
28
|
+
export type PluginPipeDefinition = {
|
|
29
29
|
/**
|
|
30
30
|
* Event name or wildcard event.
|
|
31
31
|
*/
|
package/lib/types/Policy.d.ts
CHANGED
|
@@ -14,12 +14,12 @@ import { PolicyRestrictions, OptimizedPolicyRestrictions } from "./PolicyRestric
|
|
|
14
14
|
* ]
|
|
15
15
|
* }
|
|
16
16
|
*/
|
|
17
|
-
export
|
|
17
|
+
export type Policy = {
|
|
18
18
|
roleId: string;
|
|
19
19
|
restrictedTo?: PolicyRestrictions[];
|
|
20
20
|
};
|
|
21
21
|
/** @internal */
|
|
22
|
-
export
|
|
22
|
+
export type OptimizedPolicy = {
|
|
23
23
|
roleId: string;
|
|
24
24
|
restrictedTo?: OptimizedPolicyRestrictions;
|
|
25
25
|
};
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* "collections": ["foo", "bar"]
|
|
9
9
|
* }
|
|
10
10
|
*/
|
|
11
|
-
export
|
|
11
|
+
export type PolicyRestrictions = {
|
|
12
12
|
index: string;
|
|
13
13
|
collections: string[];
|
|
14
14
|
};
|
|
@@ -18,4 +18,4 @@ export declare type PolicyRestrictions = {
|
|
|
18
18
|
* the key {string} represent the index name
|
|
19
19
|
* the value {string[]} represent the collection names
|
|
20
20
|
*/
|
|
21
|
-
export
|
|
21
|
+
export type OptimizedPolicyRestrictions = Map<string, string[]>;
|
package/lib/types/Target.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* send responses to the client
|
|
5
5
|
* (see https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS)
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
7
|
+
export type HttpConfiguration = {
|
|
8
8
|
routes: any;
|
|
9
9
|
/**
|
|
10
10
|
* Sets the default Access-Control-Allow-Origin HTTP
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { JSONObject } from "../../../index";
|
|
3
3
|
import { RoleDefinition, ProfileDefinition } from "../index";
|
|
4
|
-
export
|
|
4
|
+
export type SecurityConfiguration = {
|
|
5
5
|
/**
|
|
6
6
|
* Debugger configuration
|
|
7
7
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PublicCacheRedisConfiguration, InternalCacheConfiguration, StorageEngineElasticsearch } from "../index";
|
|
2
|
-
export
|
|
2
|
+
export type ServicesConfiguration = {
|
|
3
3
|
common: {
|
|
4
4
|
/**
|
|
5
5
|
* Time in ms after which a service is considered failing if
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Available error class
|
|
3
3
|
*/
|
|
4
|
-
export
|
|
4
|
+
export type ErrorClassNames = "BadRequestError" | "ExternalServiceError" | "ForbiddenError" | "GatewayTimeoutError" | "InternalError" | "KuzzleError" | "MultipleErrorsError" | "NotFoundError" | "PartialError" | "PluginImplementationError" | "ServiceUnavailableError" | "SizeLimitError" | "UnauthorizedError" | "PreconditionError" | "TooManyRequestsError";
|
|
5
5
|
/**
|
|
6
6
|
* Represents a standardized error definition
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
8
|
+
export type ErrorDefinition = CustomErrorDefinition & {
|
|
9
9
|
code: number;
|
|
10
10
|
};
|
|
11
11
|
/**
|
|
12
12
|
* Represents a custom standardized error definition
|
|
13
13
|
*/
|
|
14
|
-
export
|
|
14
|
+
export type CustomErrorDefinition = {
|
|
15
15
|
/**
|
|
16
16
|
* Error description for documentation purpose
|
|
17
17
|
*/
|
|
@@ -2,7 +2,7 @@ import { ErrorDefinition } from "./ErrorDefinition";
|
|
|
2
2
|
/**
|
|
3
3
|
* Represents the domains, subDomains and error names with associated definitions
|
|
4
4
|
*/
|
|
5
|
-
export
|
|
5
|
+
export type ErrorDomains = {
|
|
6
6
|
[domain: string]: {
|
|
7
7
|
code: number;
|
|
8
8
|
subDomains?: {
|
|
@@ -2,25 +2,25 @@ import { KuzzleRequest, KDocument, JSONObject } from "../../../";
|
|
|
2
2
|
/**
|
|
3
3
|
* Events with documents only having the `_id`
|
|
4
4
|
*/
|
|
5
|
-
|
|
5
|
+
type EventGenericDocumentPartial<name extends string> = {
|
|
6
6
|
name: `generic:document:${name}`;
|
|
7
7
|
args: [Array<{
|
|
8
8
|
_id: string;
|
|
9
9
|
}>, KuzzleRequest];
|
|
10
10
|
};
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
11
|
+
export type EventGenericDocumentBeforeDelete = EventGenericDocumentPartial<"beforeDelete">;
|
|
12
|
+
export type EventGenericDocumentAfterDelete = EventGenericDocumentPartial<"afterDelete">;
|
|
13
|
+
export type EventGenericDocumentBeforeGet = EventGenericDocumentPartial<"beforeGet">;
|
|
14
14
|
/**
|
|
15
15
|
* Events having entire documents
|
|
16
16
|
*/
|
|
17
|
-
|
|
17
|
+
type EventGenericDocument<name extends string, KDocumentContent> = {
|
|
18
18
|
name: `generic:document:${name}`;
|
|
19
19
|
args: [KDocument<KDocumentContent>[], KuzzleRequest];
|
|
20
20
|
};
|
|
21
|
-
export
|
|
22
|
-
export
|
|
23
|
-
export
|
|
24
|
-
export
|
|
25
|
-
export
|
|
21
|
+
export type EventGenericDocumentBeforeWrite<KDocumentContent = JSONObject> = EventGenericDocument<"beforeWrite", KDocumentContent>;
|
|
22
|
+
export type EventGenericDocumentAfterWrite<KDocumentContent = JSONObject> = EventGenericDocument<"afterWrite", KDocumentContent>;
|
|
23
|
+
export type EventGenericDocumentBeforeUpdate<KDocumentContent = JSONObject> = EventGenericDocument<"beforeUpdate", KDocumentContent>;
|
|
24
|
+
export type EventGenericDocumentAfterUpdate<KDocumentContent = JSONObject> = EventGenericDocument<"afterUpdate", KDocumentContent>;
|
|
25
|
+
export type EventGenericDocumentAfterGet<KDocumentContent = JSONObject> = EventGenericDocument<"afterGet", KDocumentContent>;
|
|
26
26
|
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { JSONObject, PipeEventHandler } from "../../../";
|
|
3
|
+
import { ClientConnection } from "../ClientConnection";
|
|
4
|
+
import { HttpMessage } from "../HttpMessage";
|
|
5
|
+
export type EventHTTPBeforeParsingPayload = {
|
|
6
|
+
name: `protocol:http:beforeParsingPayload`;
|
|
7
|
+
args: [{
|
|
8
|
+
message: HttpMessage;
|
|
9
|
+
payload: Buffer;
|
|
10
|
+
}];
|
|
11
|
+
} & PipeEventHandler;
|
|
12
|
+
export type EventHTTPAfterParsingPayload = {
|
|
13
|
+
name: `protocol:http:afterParsingPayload`;
|
|
14
|
+
args: [{
|
|
15
|
+
message: HttpMessage;
|
|
16
|
+
payload: JSONObject;
|
|
17
|
+
}];
|
|
18
|
+
} & PipeEventHandler;
|
|
19
|
+
export type EventWebsocketBeforeParsingPayload = {
|
|
20
|
+
name: `protocol:websocket:beforeParsingPayload`;
|
|
21
|
+
args: [{
|
|
22
|
+
connection: ClientConnection;
|
|
23
|
+
payload: Buffer;
|
|
24
|
+
}];
|
|
25
|
+
} & PipeEventHandler;
|
|
26
|
+
export type EventWebsocketAfterParsingPayload = {
|
|
27
|
+
name: `protocol:websocket:afterParsingPayload`;
|
|
28
|
+
args: [{
|
|
29
|
+
connection: ClientConnection;
|
|
30
|
+
payload: JSONObject;
|
|
31
|
+
}];
|
|
32
|
+
} & PipeEventHandler;
|
package/lib/types/index.d.ts
CHANGED
package/lib/types/index.js
CHANGED
|
@@ -72,4 +72,5 @@ __exportStar(require("./OpenApiDefinition"), exports);
|
|
|
72
72
|
__exportStar(require("./errors/ErrorDefinition"), exports);
|
|
73
73
|
__exportStar(require("./errors/ErrorDomains"), exports);
|
|
74
74
|
__exportStar(require("./events/EventGenericDocument"), exports);
|
|
75
|
+
__exportStar(require("./events/EventProtocol"), exports);
|
|
75
76
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import stream from "stream";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
type Encoding = BufferEncoding | "buffer";
|
|
5
|
+
type ChunkData = Buffer | string;
|
|
6
|
+
type Chunk = {
|
|
7
7
|
chunk: ChunkData;
|
|
8
8
|
encoding: Encoding;
|
|
9
9
|
};
|
|
10
|
-
|
|
10
|
+
type Callback = (error?: Error) => void;
|
|
11
11
|
/**
|
|
12
12
|
* This streams accumulate chunks data into a buffer until the amount of data is equal or exceed the buffer size.
|
|
13
13
|
* Then, it emits a single chunk with the accumulated data.
|
|
@@ -171,22 +171,27 @@ class AbstractDumper {
|
|
|
171
171
|
this.writeStream.on("error", (error) => {
|
|
172
172
|
throw error;
|
|
173
173
|
});
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
174
|
+
try {
|
|
175
|
+
await this.setup();
|
|
176
|
+
await this.writeHeader();
|
|
177
|
+
let results = await global.kuzzle.ask("core:storage:public:document:search", this.index, this.collection, this.query, {
|
|
178
|
+
lang: this.options.lang,
|
|
179
|
+
scroll: this.options.scroll,
|
|
180
|
+
size: this.options.size,
|
|
181
|
+
});
|
|
182
|
+
do {
|
|
183
|
+
for (const hit of results.hits) {
|
|
184
|
+
await this.onResult({
|
|
185
|
+
_id: hit._id,
|
|
186
|
+
_source: hit._source,
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
} while ((results = await this.scroll(results.scrollId)));
|
|
190
|
+
await this.tearDown();
|
|
191
|
+
}
|
|
192
|
+
catch (e) {
|
|
193
|
+
this.writeStream.write(e.toString());
|
|
194
|
+
}
|
|
190
195
|
this.writeStream.end();
|
|
191
196
|
return waitWrite;
|
|
192
197
|
}
|
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.11",
|
|
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": {
|
|
@@ -52,10 +52,10 @@
|
|
|
52
52
|
"dumpme": "^1.0.3",
|
|
53
53
|
"eslint-plugin-kuzzle": "^0.0.6",
|
|
54
54
|
"eventemitter3": "^4.0.7",
|
|
55
|
-
"inquirer": "^9.1.
|
|
56
|
-
"ioredis": "^5.2.
|
|
55
|
+
"inquirer": "^9.1.4",
|
|
56
|
+
"ioredis": "^5.2.4",
|
|
57
57
|
"js-yaml": "^4.1.0",
|
|
58
|
-
"json-stable-stringify": "^1.0.
|
|
58
|
+
"json-stable-stringify": "^1.0.2",
|
|
59
59
|
"json2yaml": "^1.1.0",
|
|
60
60
|
"jsonwebtoken": "^8.5.1",
|
|
61
61
|
"koncorde": "^4.0.3",
|
|
@@ -64,25 +64,25 @@
|
|
|
64
64
|
"kuzzle-sdk": "^7.10.3",
|
|
65
65
|
"kuzzle-vault": "^2.0.4",
|
|
66
66
|
"lodash": "4.17.21",
|
|
67
|
-
"long": "^5.2.
|
|
67
|
+
"long": "^5.2.1",
|
|
68
68
|
"moment": "^2.29.4",
|
|
69
69
|
"ms": "^2.1.3",
|
|
70
70
|
"murmurhash-native": "^3.5.0",
|
|
71
71
|
"ndjson": "^2.0.0",
|
|
72
72
|
"node-segfault-handler": "^1.1.0",
|
|
73
73
|
"passport": "^0.6.0",
|
|
74
|
-
"protobufjs": "~7.1.
|
|
74
|
+
"protobufjs": "~7.1.2",
|
|
75
75
|
"rc": "1.2.8",
|
|
76
|
-
"semver": "^7.3.
|
|
76
|
+
"semver": "^7.3.8",
|
|
77
77
|
"sorted-array": "^2.0.4",
|
|
78
78
|
"uuid": "^9.0.0",
|
|
79
79
|
"uWebSockets.js": "https://github.com/uNetworking/uWebSockets.js/archive/refs/tags/v20.0.0.tar.gz",
|
|
80
80
|
"validator": "^13.7.0",
|
|
81
|
-
"winston": "^3.8.
|
|
81
|
+
"winston": "^3.8.2",
|
|
82
82
|
"winston-elasticsearch": "0.17.1",
|
|
83
|
-
"winston-syslog": "^2.
|
|
83
|
+
"winston-syslog": "^2.7.0",
|
|
84
84
|
"winston-transport": "^4.5.0",
|
|
85
|
-
"yargs": "^17.
|
|
85
|
+
"yargs": "^17.6.2",
|
|
86
86
|
"zeromq": "6.0.0-beta.6"
|
|
87
87
|
},
|
|
88
88
|
"repository": {
|
|
@@ -91,13 +91,13 @@
|
|
|
91
91
|
},
|
|
92
92
|
"devDependencies": {
|
|
93
93
|
"@types/js-yaml": "^4.0.5",
|
|
94
|
-
"@types/lodash": "^4.14.
|
|
94
|
+
"@types/lodash": "^4.14.190",
|
|
95
95
|
"async": "^3.2.4",
|
|
96
96
|
"chokidar": "^3.5.3",
|
|
97
97
|
"codecov": "^3.8.3",
|
|
98
98
|
"cucumber": "^6.0.5",
|
|
99
99
|
"ergol": "^1.0.2",
|
|
100
|
-
"mocha": "^
|
|
100
|
+
"mocha": "^10.1.0",
|
|
101
101
|
"mock-require": "^3.0.3",
|
|
102
102
|
"mqtt": "^4.3.7",
|
|
103
103
|
"nyc": "^15.1.0",
|
|
@@ -106,11 +106,11 @@
|
|
|
106
106
|
"rewire": "^5.0.0",
|
|
107
107
|
"should": "13.2.3",
|
|
108
108
|
"should-sinon": "0.0.6",
|
|
109
|
-
"sinon": "^
|
|
109
|
+
"sinon": "^14.0.2",
|
|
110
110
|
"strip-json-comments": "https://github.com/sindresorhus/strip-json-comments/archive/refs/tags/v3.1.1.tar.gz",
|
|
111
111
|
"ts-node": "^10.9.1",
|
|
112
|
-
"typescript": "^4.
|
|
113
|
-
"yaml": "^2.1.
|
|
112
|
+
"typescript": "^4.9.3",
|
|
113
|
+
"yaml": "^2.1.3"
|
|
114
114
|
},
|
|
115
115
|
"engines": {
|
|
116
116
|
"node": ">= 12.13.0"
|