kuzzle 2.31.0-elasticsearch-8.2 → 2.32.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/index.d.ts +1 -0
- package/index.js +1 -0
- package/lib/api/controllers/memoryStorageController.js +11 -3
- package/lib/api/funnel.js +4 -0
- package/lib/api/request/requestInput.d.ts +2 -0
- package/lib/api/request/requestInput.js +9 -0
- package/lib/core/security/profileRepository.d.ts +5 -14
- package/lib/core/security/profileRepository.js +17 -50
- package/lib/core/security/roleRepository.js +1 -1
- package/lib/core/security/tokenRepository.d.ts +1 -1
- package/lib/core/security/tokenRepository.js +1 -1
- package/lib/core/shared/ObjectRepository.d.ts +1 -1
- package/lib/core/shared/ObjectRepository.js +1 -1
- package/lib/kerror/index.js +1 -1
- package/lib/kuzzle/event/KuzzleEventEmitter.d.ts +70 -0
- package/lib/kuzzle/event/KuzzleEventEmitter.js +328 -0
- package/lib/kuzzle/index.d.ts +3 -0
- package/lib/kuzzle/index.js +7 -4
- package/lib/kuzzle/kuzzle.d.ts +32 -19
- package/lib/kuzzle/kuzzle.js +30 -30
- package/lib/service/storage/7/elasticsearch.d.ts +1 -1
- package/lib/service/storage/7/elasticsearch.js +2 -2
- package/lib/service/storage/8/elasticsearch.d.ts +1 -1
- package/lib/service/storage/8/elasticsearch.js +2 -2
- package/lib/service/storage/commons/queryTranslator.d.ts +5 -0
- package/lib/service/storage/commons/queryTranslator.js +142 -172
- package/lib/types/EventHandler.d.ts +29 -1
- package/lib/types/config/KuzzleConfiguration.d.ts +2 -1
- package/package.json +3 -2
- package/lib/kuzzle/event/kuzzleEventEmitter.js +0 -405
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QueryTranslator = void 0;
|
|
1
4
|
/*
|
|
2
5
|
* Kuzzle, a backend software, self-hostable and ready to use
|
|
3
6
|
* to power modern apps
|
|
@@ -18,23 +21,14 @@
|
|
|
18
21
|
* See the License for the specific language governing permissions and
|
|
19
22
|
* limitations under the License.
|
|
20
23
|
*/
|
|
21
|
-
|
|
22
|
-
"use strict";
|
|
23
|
-
|
|
24
|
-
const kerror = require("../../../kerror");
|
|
25
|
-
|
|
24
|
+
const kerror_1 = require("../../../kerror");
|
|
26
25
|
class KeywordError extends Error {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
this.keyword = { name, type };
|
|
33
|
-
}
|
|
26
|
+
constructor(type, name) {
|
|
27
|
+
super(`The ${type} "${name}" of Koncorde DSL is not supported for search queries.`);
|
|
28
|
+
this.keyword = { name, type };
|
|
29
|
+
}
|
|
34
30
|
}
|
|
35
|
-
|
|
36
31
|
const KONCORDE_OPERATORS = ["and", "or", "not", "bool"];
|
|
37
|
-
|
|
38
32
|
/**
|
|
39
33
|
* Parse the Koncorde path to extract the path and the value
|
|
40
34
|
* path have the form "path.to.field[json_value]"
|
|
@@ -43,177 +37,153 @@ const KONCORDE_OPERATORS = ["and", "or", "not", "bool"];
|
|
|
43
37
|
* @returns
|
|
44
38
|
*/
|
|
45
39
|
function parseKoncordePath(path) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
40
|
+
const firstBracket = path.indexOf("[");
|
|
41
|
+
if (firstBracket < 0) {
|
|
42
|
+
return {
|
|
43
|
+
path,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
const lastBracket = path.lastIndexOf("]");
|
|
47
|
+
if (lastBracket < 0) {
|
|
48
|
+
throw (0, kerror_1.get)("services", "koncorde", "elastic_translation_error", `Invalid exists path "${path}": missing closing bracket`);
|
|
49
|
+
}
|
|
49
50
|
return {
|
|
50
|
-
|
|
51
|
+
path: path.slice(0, firstBracket),
|
|
52
|
+
value: JSON.parse(path.slice(firstBracket + 1, lastBracket)),
|
|
51
53
|
};
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const lastBracket = path.lastIndexOf("]");
|
|
55
|
-
|
|
56
|
-
if (lastBracket < 0) {
|
|
57
|
-
throw kerror.get(
|
|
58
|
-
"services",
|
|
59
|
-
"koncorde",
|
|
60
|
-
"elastic_translation_error",
|
|
61
|
-
`Invalid exists path "${path}": missing closing bracket`,
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return {
|
|
66
|
-
path: path.slice(0, firstBracket),
|
|
67
|
-
value: JSON.parse(path.slice(firstBracket + 1, lastBracket)),
|
|
68
|
-
};
|
|
69
54
|
}
|
|
70
|
-
|
|
71
55
|
const KONCORDE_CLAUSES_TO_ES = {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
56
|
+
equals: (content) => ({
|
|
57
|
+
term: {
|
|
58
|
+
...content,
|
|
59
|
+
},
|
|
60
|
+
}),
|
|
61
|
+
exists: (field) => {
|
|
62
|
+
// Support old syntax { exists: { field: "path" } } and { exists: "path" }
|
|
63
|
+
const parsedInfo = parseKoncordePath(field.field || field);
|
|
64
|
+
// If we have a value, we need to use a range query to be sure that the value is the same
|
|
65
|
+
if (parsedInfo.value) {
|
|
66
|
+
return {
|
|
67
|
+
bool: {
|
|
68
|
+
filter: [
|
|
69
|
+
{
|
|
70
|
+
exists: {
|
|
71
|
+
field: parsedInfo.path,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
range: {
|
|
76
|
+
[parsedInfo.path]: {
|
|
77
|
+
gte: parsedInfo.value,
|
|
78
|
+
lte: parsedInfo.value,
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
],
|
|
96
83
|
},
|
|
97
|
-
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
exists: {
|
|
88
|
+
field: parsedInfo.path,
|
|
98
89
|
},
|
|
99
|
-
|
|
100
|
-
},
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return {
|
|
105
|
-
exists: {
|
|
106
|
-
field: parsedInfo.path,
|
|
107
|
-
},
|
|
108
|
-
};
|
|
109
|
-
},
|
|
110
|
-
geoBoundingBox: (content) => ({
|
|
111
|
-
geo_bounding_box: {
|
|
112
|
-
...content,
|
|
113
|
-
},
|
|
114
|
-
}),
|
|
115
|
-
geoDistance: (content) => ({
|
|
116
|
-
geo_distance: {
|
|
117
|
-
...content,
|
|
118
|
-
},
|
|
119
|
-
}),
|
|
120
|
-
geoDistanceRange: (content) => ({
|
|
121
|
-
geo_distance_range: {
|
|
122
|
-
...content,
|
|
123
|
-
},
|
|
124
|
-
}),
|
|
125
|
-
geoPolygon: (content) => ({
|
|
126
|
-
geo_polygon: {
|
|
127
|
-
...content,
|
|
128
|
-
},
|
|
129
|
-
}),
|
|
130
|
-
ids: (content) => ({
|
|
131
|
-
ids: {
|
|
132
|
-
...content,
|
|
133
|
-
},
|
|
134
|
-
}),
|
|
135
|
-
in: (content) => ({
|
|
136
|
-
terms: {
|
|
137
|
-
...content,
|
|
90
|
+
};
|
|
138
91
|
},
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
},
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
},
|
|
149
|
-
|
|
92
|
+
geoBoundingBox: (content) => ({
|
|
93
|
+
geo_bounding_box: {
|
|
94
|
+
...content,
|
|
95
|
+
},
|
|
96
|
+
}),
|
|
97
|
+
geoDistance: (content) => ({
|
|
98
|
+
geo_distance: {
|
|
99
|
+
...content,
|
|
100
|
+
},
|
|
101
|
+
}),
|
|
102
|
+
geoDistanceRange: (content) => ({
|
|
103
|
+
geo_distance_range: {
|
|
104
|
+
...content,
|
|
105
|
+
},
|
|
106
|
+
}),
|
|
107
|
+
geoPolygon: (content) => ({
|
|
108
|
+
geo_polygon: {
|
|
109
|
+
...content,
|
|
110
|
+
},
|
|
111
|
+
}),
|
|
112
|
+
ids: (content) => ({
|
|
113
|
+
ids: {
|
|
114
|
+
...content,
|
|
115
|
+
},
|
|
116
|
+
}),
|
|
117
|
+
in: (content) => ({
|
|
118
|
+
terms: {
|
|
119
|
+
...content,
|
|
120
|
+
},
|
|
121
|
+
}),
|
|
122
|
+
missing: (field) => ({
|
|
123
|
+
bool: {
|
|
124
|
+
must_not: [{ exists: { field } }],
|
|
125
|
+
},
|
|
126
|
+
}),
|
|
127
|
+
range: (content) => ({
|
|
128
|
+
range: {
|
|
129
|
+
...content,
|
|
130
|
+
},
|
|
131
|
+
}),
|
|
150
132
|
};
|
|
151
|
-
|
|
152
133
|
const KONCORDE_OPERATORS_TO_ES = {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
};
|
|
167
|
-
},
|
|
168
|
-
or: (content) => ({
|
|
169
|
-
bool: {
|
|
170
|
-
should: [...content],
|
|
134
|
+
and: (content) => ({
|
|
135
|
+
bool: {
|
|
136
|
+
filter: [...content],
|
|
137
|
+
},
|
|
138
|
+
}),
|
|
139
|
+
bool: undefined,
|
|
140
|
+
not: (content) => {
|
|
141
|
+
const [name, value] = Object.entries(content[0])[0];
|
|
142
|
+
return {
|
|
143
|
+
bool: {
|
|
144
|
+
must_not: [{ [name]: value }],
|
|
145
|
+
},
|
|
146
|
+
};
|
|
171
147
|
},
|
|
172
|
-
|
|
148
|
+
or: (content) => ({
|
|
149
|
+
bool: {
|
|
150
|
+
should: [...content],
|
|
151
|
+
},
|
|
152
|
+
}),
|
|
173
153
|
};
|
|
174
|
-
|
|
175
154
|
class QueryTranslator {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
return this._translateClause(name, value);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
_translateOperator(operator, operands) {
|
|
187
|
-
const converter = KONCORDE_OPERATORS_TO_ES[operator];
|
|
188
|
-
|
|
189
|
-
if (converter === undefined) {
|
|
190
|
-
throw new KeywordError("operator", operator);
|
|
155
|
+
translate(filters) {
|
|
156
|
+
const [name, value] = Object.entries(filters)[0];
|
|
157
|
+
if (KONCORDE_OPERATORS.includes(name)) {
|
|
158
|
+
return this._translateOperator(name, value);
|
|
159
|
+
}
|
|
160
|
+
return this._translateClause(name, value);
|
|
191
161
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
162
|
+
_translateOperator(operator, operands) {
|
|
163
|
+
const converter = KONCORDE_OPERATORS_TO_ES[operator];
|
|
164
|
+
if (converter === undefined) {
|
|
165
|
+
throw new KeywordError("operator", operator);
|
|
166
|
+
}
|
|
167
|
+
const esOperands = [];
|
|
168
|
+
if (operator === "not") {
|
|
169
|
+
esOperands.push(this.translate(operands));
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
for (const operand of operands) {
|
|
173
|
+
esOperands.push(this.translate(operand));
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return converter(esOperands);
|
|
201
177
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
return {
|
|
211
|
-
[clause]: content,
|
|
212
|
-
};
|
|
178
|
+
_translateClause(clause, content) {
|
|
179
|
+
const converter = KONCORDE_CLAUSES_TO_ES[clause];
|
|
180
|
+
if (converter === undefined) {
|
|
181
|
+
return {
|
|
182
|
+
[clause]: content,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
return converter(content);
|
|
213
186
|
}
|
|
214
|
-
|
|
215
|
-
return converter(content);
|
|
216
|
-
}
|
|
217
187
|
}
|
|
218
|
-
|
|
219
|
-
|
|
188
|
+
exports.QueryTranslator = QueryTranslator;
|
|
189
|
+
//# sourceMappingURL=queryTranslator.js.map
|
|
@@ -14,10 +14,30 @@ export type EventDefinition = {
|
|
|
14
14
|
*/
|
|
15
15
|
args: any[];
|
|
16
16
|
};
|
|
17
|
+
/**
|
|
18
|
+
* Describe an ask event with it's name and the payload and result types
|
|
19
|
+
*/
|
|
20
|
+
export type AskEventDefinition = {
|
|
21
|
+
/**
|
|
22
|
+
* Name of the event
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* "core:document:create"
|
|
26
|
+
*/
|
|
27
|
+
name: string;
|
|
28
|
+
/**
|
|
29
|
+
* Payload of the event
|
|
30
|
+
*/
|
|
31
|
+
payload: any;
|
|
32
|
+
/**
|
|
33
|
+
* Result of the event
|
|
34
|
+
*/
|
|
35
|
+
result: any;
|
|
36
|
+
};
|
|
17
37
|
/**
|
|
18
38
|
* Handler for hook events
|
|
19
39
|
*/
|
|
20
|
-
export type HookEventHandler<TEventDefinition extends EventDefinition = EventDefinition> = (...args: TEventDefinition["args"]) => void;
|
|
40
|
+
export type HookEventHandler<TEventDefinition extends EventDefinition = EventDefinition> = (...args: TEventDefinition["args"]) => Promise<void> | void;
|
|
21
41
|
/**
|
|
22
42
|
* Handler for pipe event.
|
|
23
43
|
*
|
|
@@ -28,6 +48,14 @@ export type PipeEventHandler<TEventDefinition extends EventDefinition = EventDef
|
|
|
28
48
|
* Handler for cluster event.
|
|
29
49
|
*/
|
|
30
50
|
export type ClusterEventHandler<TEventDefinition extends EventDefinition = EventDefinition> = (...args: TEventDefinition["args"]) => any;
|
|
51
|
+
/**
|
|
52
|
+
* Handler for ask event.
|
|
53
|
+
*/
|
|
54
|
+
export type AskEventHandler<TAskEventDefinition extends AskEventDefinition = AskEventDefinition> = (...args: [payload?: TAskEventDefinition["payload"], ...rest: any[]]) => Promise<TAskEventDefinition["result"]> | TAskEventDefinition["result"];
|
|
55
|
+
/**
|
|
56
|
+
* Handler for call event.
|
|
57
|
+
*/
|
|
58
|
+
export type CallEventHandler<TAskEventDefinition extends AskEventDefinition = AskEventDefinition> = (...args: [payload?: TAskEventDefinition["payload"], ...rest: any[]]) => TAskEventDefinition["result"];
|
|
31
59
|
/**
|
|
32
60
|
* @deprecated Use HookEventHandler, PipeEventHandler or ClusterEventHandler
|
|
33
61
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DumpConfiguration, HttpConfiguration, LimitsConfiguration, PluginsConfiguration, SecurityConfiguration, ServerConfiguration, ServicesConfiguration } from "../index";
|
|
2
2
|
export interface IKuzzleConfiguration {
|
|
3
3
|
realtime: {
|
|
4
4
|
/**
|
|
@@ -121,6 +121,7 @@ export interface IKuzzleConfiguration {
|
|
|
121
121
|
};
|
|
122
122
|
internal: {
|
|
123
123
|
hash: any;
|
|
124
|
+
notifiableProtocols: string[];
|
|
124
125
|
};
|
|
125
126
|
validation: Record<string, unknown>;
|
|
126
127
|
}
|
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.32.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
|
"bin": "bin/start-kuzzle-server",
|
|
7
7
|
"scripts": {
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"koncorde": "4.3.0",
|
|
48
48
|
"kuzzle-plugin-auth-passport-local": "6.4.0",
|
|
49
49
|
"kuzzle-plugin-logger": "3.0.3",
|
|
50
|
-
"kuzzle-sdk": "7.11.
|
|
50
|
+
"kuzzle-sdk": "^7.11.3",
|
|
51
51
|
"kuzzle-vault": "2.0.4",
|
|
52
52
|
"lodash": "4.17.21",
|
|
53
53
|
"long": "5.2.3",
|
|
@@ -86,6 +86,7 @@
|
|
|
86
86
|
"@semantic-release/git": "^10.0.1",
|
|
87
87
|
"@semantic-release/release-notes-generator": "^11.0.4",
|
|
88
88
|
"@types/bluebird": "^3.5.42",
|
|
89
|
+
"@types/cookie": "^0.6.0",
|
|
89
90
|
"@types/jest": "29.5.10",
|
|
90
91
|
"@types/js-yaml": "4.0.9",
|
|
91
92
|
"@types/lodash": "4.14.202",
|