@budibase/server 1.2.39-alpha.5 → 1.2.39-alpha.8
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/builder/assets/{index.db2ba95c.js → index.720e99cf.js} +133 -133
- package/builder/assets/{index.149176e7.css → index.b10373c2.css} +1 -1
- package/builder/index.html +2 -2
- package/coverage/clover.xml +204 -186
- package/coverage/coverage-final.json +1 -1
- package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/controllers/auth.js.html +1 -1
- package/coverage/lcov-report/api/controllers/automation.js.html +1 -1
- package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
- package/coverage/lcov-report/api/controllers/cloud.js.html +1 -1
- package/coverage/lcov-report/api/controllers/component.js.html +1 -1
- package/coverage/lcov-report/api/controllers/datasource.js.html +1 -1
- package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
- package/coverage/lcov-report/api/controllers/index.html +1 -1
- package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
- package/coverage/lcov-report/api/controllers/layout.js.html +1 -1
- package/coverage/lcov-report/api/controllers/metadata.js.html +1 -1
- package/coverage/lcov-report/api/controllers/migrations.js.html +1 -1
- package/coverage/lcov-report/api/controllers/permission.js.html +1 -1
- package/coverage/lcov-report/api/controllers/query/index.html +1 -1
- package/coverage/lcov-report/api/controllers/query/validation.js.html +1 -1
- package/coverage/lcov-report/api/controllers/role.js.html +1 -1
- package/coverage/lcov-report/api/controllers/routing.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/external.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/index.html +18 -18
- package/coverage/lcov-report/api/controllers/row/internal.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +223 -115
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/screen.js.html +1 -1
- package/coverage/lcov-report/api/controllers/script.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/external.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
- package/coverage/lcov-report/api/controllers/user.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +1 -1
- package/coverage/lcov-report/api/controllers/webhook.js.html +1 -1
- package/coverage/lcov-report/api/index.html +1 -1
- package/coverage/lcov-report/api/index.js.html +1 -1
- package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
- package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/routes/auth.js.html +1 -1
- package/coverage/lcov-report/api/routes/automation.js.html +1 -1
- package/coverage/lcov-report/api/routes/backup.js.html +1 -1
- package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
- package/coverage/lcov-report/api/routes/component.js.html +1 -1
- package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
- package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
- package/coverage/lcov-report/api/routes/dev.js.html +1 -1
- package/coverage/lcov-report/api/routes/index.html +1 -1
- package/coverage/lcov-report/api/routes/integration.js.html +1 -1
- package/coverage/lcov-report/api/routes/layout.js.html +1 -1
- package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
- package/coverage/lcov-report/api/routes/migrations.js.html +1 -1
- package/coverage/lcov-report/api/routes/permission.js.html +1 -1
- package/coverage/lcov-report/api/routes/query.js.html +1 -1
- package/coverage/lcov-report/api/routes/role.js.html +1 -1
- package/coverage/lcov-report/api/routes/routing.js.html +1 -1
- package/coverage/lcov-report/api/routes/screen.js.html +1 -1
- package/coverage/lcov-report/api/routes/script.js.html +1 -1
- package/coverage/lcov-report/api/routes/table.js.html +1 -1
- package/coverage/lcov-report/api/routes/templates.js.html +1 -1
- package/coverage/lcov-report/api/routes/user.js.html +1 -1
- package/coverage/lcov-report/api/routes/utils/index.html +1 -1
- package/coverage/lcov-report/api/routes/utils/validators.js.html +1 -1
- package/coverage/lcov-report/api/routes/view.js.html +1 -1
- package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/actions.js.html +1 -1
- package/coverage/lcov-report/automations/automationUtils.js.html +1 -1
- package/coverage/lcov-report/automations/bullboard.js.html +1 -1
- package/coverage/lcov-report/automations/index.html +1 -1
- package/coverage/lcov-report/automations/index.js.html +1 -1
- package/coverage/lcov-report/automations/steps/bash.js.html +1 -1
- package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
- package/coverage/lcov-report/automations/steps/discord.js.html +1 -1
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +1 -1
- package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
- package/coverage/lcov-report/automations/steps/filter.js.html +1 -1
- package/coverage/lcov-report/automations/steps/index.html +1 -1
- package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
- package/coverage/lcov-report/automations/steps/loop.js.html +1 -1
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +1 -1
- package/coverage/lcov-report/automations/steps/queryRows.js.html +1 -1
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +1 -1
- package/coverage/lcov-report/automations/steps/serverLog.js.html +1 -1
- package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
- package/coverage/lcov-report/automations/steps/updateRow.js.html +1 -1
- package/coverage/lcov-report/automations/steps/utils.js.html +1 -1
- package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/app.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/cron.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/triggers.js.html +1 -1
- package/coverage/lcov-report/constants/index.html +1 -1
- package/coverage/lcov-report/constants/index.js.html +1 -1
- package/coverage/lcov-report/constants/layouts.js.html +1 -1
- package/coverage/lcov-report/constants/screens.js.html +1 -1
- package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
- package/coverage/lcov-report/db/index.html +1 -1
- package/coverage/lcov-report/db/index.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +1 -1
- package/coverage/lcov-report/db/newid.js.html +1 -1
- package/coverage/lcov-report/db/utils.js.html +1 -1
- package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
- package/coverage/lcov-report/events/index.html +1 -1
- package/coverage/lcov-report/events/index.js.html +1 -1
- package/coverage/lcov-report/events/utils.js.html +1 -1
- package/coverage/lcov-report/index.html +18 -18
- package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
- package/coverage/lcov-report/integrations/tests/index.html +1 -1
- package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
- package/coverage/lcov-report/middleware/builder.js.html +1 -1
- package/coverage/lcov-report/middleware/currentapp.js.html +1 -1
- package/coverage/lcov-report/middleware/index.html +1 -1
- package/coverage/lcov-report/middleware/joi-validator.js.html +1 -1
- package/coverage/lcov-report/middleware/publicApi.js.html +1 -1
- package/coverage/lcov-report/middleware/resourceId.js.html +1 -1
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/utils.js.html +1 -1
- package/coverage/lcov-report/utilities/budibaseDir.js.html +1 -1
- package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
- package/coverage/lcov-report/utilities/csvParser.js.html +1 -1
- package/coverage/lcov-report/utilities/global.js.html +1 -1
- package/coverage/lcov-report/utilities/index.html +1 -1
- package/coverage/lcov-report/utilities/index.js.html +1 -1
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +1 -1
- package/coverage/lcov-report/utilities/queue/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.js.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +1 -1
- package/coverage/lcov-report/utilities/scriptRunner.js.html +1 -1
- package/coverage/lcov-report/utilities/security.js.html +1 -1
- package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/index.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
- package/coverage/lcov-report/utilities/users.js.html +1 -1
- package/coverage/lcov-report/utilities/workerRequests.js.html +1 -1
- package/coverage/lcov.info +399 -364
- package/dist/api/controllers/row/internalSearch.js +34 -4
- package/dist/integrations/base/sql.js +57 -26
- package/dist/package.json +6 -6
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/src/api/controllers/row/internalSearch.js +39 -3
- package/src/api/routes/tests/internalSearch.spec.js +20 -1
- package/src/integrations/base/sql.ts +62 -26
- package/src/integrations/tests/sql.spec.js +100 -10
|
@@ -19,7 +19,7 @@ const { getAppId } = require("@budibase/backend-core/context");
|
|
|
19
19
|
*/
|
|
20
20
|
class QueryBuilder {
|
|
21
21
|
constructor(base) {
|
|
22
|
-
this.query = Object.assign({ allOr: false, string: {}, fuzzy: {}, range: {}, equal: {}, notEqual: {}, empty: {}, notEmpty: {}, oneOf: {}, contains: {} }, base);
|
|
22
|
+
this.query = Object.assign({ allOr: false, string: {}, fuzzy: {}, range: {}, equal: {}, notEqual: {}, empty: {}, notEmpty: {}, oneOf: {}, contains: {}, notContains: {}, containsAny: {} }, base);
|
|
23
23
|
this.limit = 50;
|
|
24
24
|
this.sortOrder = "ascending";
|
|
25
25
|
this.sortType = "string";
|
|
@@ -105,6 +105,14 @@ class QueryBuilder {
|
|
|
105
105
|
this.query.contains[key] = value;
|
|
106
106
|
return this;
|
|
107
107
|
}
|
|
108
|
+
addNotContains(key, value) {
|
|
109
|
+
this.query.notContains[key] = value;
|
|
110
|
+
return this;
|
|
111
|
+
}
|
|
112
|
+
addContainsAny(key, value) {
|
|
113
|
+
this.query.containsAny[key] = value;
|
|
114
|
+
return this;
|
|
115
|
+
}
|
|
108
116
|
/**
|
|
109
117
|
* Preprocesses a value before going into a lucene search.
|
|
110
118
|
* Transforms strings to lowercase and wraps strings and bools in quotes.
|
|
@@ -147,11 +155,27 @@ class QueryBuilder {
|
|
|
147
155
|
}
|
|
148
156
|
return `${key}:${builder.preprocess(value, allPreProcessingOpts)}`;
|
|
149
157
|
};
|
|
150
|
-
const contains = (key, value) => {
|
|
151
|
-
if (
|
|
158
|
+
const contains = (key, value, mode = "AND") => {
|
|
159
|
+
if (Array.isArray(value) && value.length === 0) {
|
|
152
160
|
return null;
|
|
153
161
|
}
|
|
154
|
-
|
|
162
|
+
if (!Array.isArray(value)) {
|
|
163
|
+
return `${key}:${value}`;
|
|
164
|
+
}
|
|
165
|
+
let statement = `${builder.preprocess(value[0], { escape: true })}`;
|
|
166
|
+
for (let i = 1; i < value.length; i++) {
|
|
167
|
+
statement += ` ${mode} ${builder.preprocess(value[i], {
|
|
168
|
+
escape: true,
|
|
169
|
+
})}`;
|
|
170
|
+
}
|
|
171
|
+
return `${key}:(${statement})`;
|
|
172
|
+
};
|
|
173
|
+
const notContains = (key, value) => {
|
|
174
|
+
const allPrefix = allOr === "" ? "*:* AND" : "";
|
|
175
|
+
return allPrefix + "NOT " + contains(key, value);
|
|
176
|
+
};
|
|
177
|
+
const containsAny = (key, value) => {
|
|
178
|
+
return contains(key, value, "OR");
|
|
155
179
|
};
|
|
156
180
|
const oneOf = (key, value) => {
|
|
157
181
|
if (!Array.isArray(value)) {
|
|
@@ -249,6 +273,12 @@ class QueryBuilder {
|
|
|
249
273
|
if (this.query.contains) {
|
|
250
274
|
build(this.query.contains, contains);
|
|
251
275
|
}
|
|
276
|
+
if (this.query.notContains) {
|
|
277
|
+
build(this.query.notContains, notContains);
|
|
278
|
+
}
|
|
279
|
+
if (this.query.containsAny) {
|
|
280
|
+
build(this.query.containsAny, containsAny);
|
|
281
|
+
}
|
|
252
282
|
// make sure table ID is always added as an AND
|
|
253
283
|
if (tableId) {
|
|
254
284
|
query = `(${query})`;
|
|
@@ -141,6 +141,56 @@ class InternalBuilder {
|
|
|
141
141
|
]);
|
|
142
142
|
}
|
|
143
143
|
};
|
|
144
|
+
const contains = (mode, any = false) => {
|
|
145
|
+
const fnc = allOr ? "orWhere" : "where";
|
|
146
|
+
const rawFnc = `${fnc}Raw`;
|
|
147
|
+
const not = mode === (filters === null || filters === void 0 ? void 0 : filters.notContains) ? "NOT " : "";
|
|
148
|
+
function stringifyArray(value, quoteStyle = '"') {
|
|
149
|
+
for (let i in value) {
|
|
150
|
+
if (typeof value[i] === "string") {
|
|
151
|
+
value[i] = `${quoteStyle}${value[i]}${quoteStyle}`;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return `[${value.join(",")}]`;
|
|
155
|
+
}
|
|
156
|
+
if (this.client === utils_1.SqlClient.POSTGRES) {
|
|
157
|
+
iterate(mode, (key, value) => {
|
|
158
|
+
const wrap = any ? "" : "'";
|
|
159
|
+
const containsOp = any ? "\\?| array" : "@>";
|
|
160
|
+
const fieldNames = key.split(/\./g);
|
|
161
|
+
const tableName = fieldNames[0];
|
|
162
|
+
const columnName = fieldNames[1];
|
|
163
|
+
// @ts-ignore
|
|
164
|
+
query = query[rawFnc](`${not}"${tableName}"."${columnName}"::jsonb ${containsOp} ${wrap}${stringifyArray(value, any ? "'" : '"')}${wrap}`);
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
else if (this.client === utils_1.SqlClient.MY_SQL) {
|
|
168
|
+
const jsonFnc = any ? "JSON_OVERLAPS" : "JSON_CONTAINS";
|
|
169
|
+
iterate(mode, (key, value) => {
|
|
170
|
+
// @ts-ignore
|
|
171
|
+
query = query[rawFnc](`${not}${jsonFnc}(${key}, '${stringifyArray(value)}')`);
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
const andOr = mode === (filters === null || filters === void 0 ? void 0 : filters.containsAny) ? " OR " : " AND ";
|
|
176
|
+
iterate(mode, (key, value) => {
|
|
177
|
+
let statement = "";
|
|
178
|
+
for (let i in value) {
|
|
179
|
+
if (typeof value[i] === "string") {
|
|
180
|
+
value[i] = `%"${value[i]}"%`;
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
value[i] = `%${value[i]}%`;
|
|
184
|
+
}
|
|
185
|
+
statement +=
|
|
186
|
+
(statement ? andOr : "") +
|
|
187
|
+
`LOWER(${likeKey(this.client, key)}) LIKE ?`;
|
|
188
|
+
}
|
|
189
|
+
// @ts-ignore
|
|
190
|
+
query = query[rawFnc](`${not}(${statement})`, value);
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
};
|
|
144
194
|
if (!filters) {
|
|
145
195
|
return query;
|
|
146
196
|
}
|
|
@@ -214,32 +264,13 @@ class InternalBuilder {
|
|
|
214
264
|
});
|
|
215
265
|
}
|
|
216
266
|
if (filters.contains) {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
if (typeof value === "string") {
|
|
225
|
-
value = `"${value}"`;
|
|
226
|
-
}
|
|
227
|
-
// @ts-ignore
|
|
228
|
-
query = query[rawFnc](`"${tableName}"."${columnName}"::jsonb @> '[${value}]'`);
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
else if (this.client === utils_1.SqlClient.MY_SQL) {
|
|
232
|
-
iterate(filters.contains, (key, value) => {
|
|
233
|
-
if (typeof value === "string") {
|
|
234
|
-
value = `"${value}"`;
|
|
235
|
-
}
|
|
236
|
-
// @ts-ignore
|
|
237
|
-
query = query[rawFnc](`JSON_CONTAINS(${key}, '${value}')`);
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
else {
|
|
241
|
-
iterate(filters.contains, like);
|
|
242
|
-
}
|
|
267
|
+
contains(filters.contains);
|
|
268
|
+
}
|
|
269
|
+
if (filters.notContains) {
|
|
270
|
+
contains(filters.notContains);
|
|
271
|
+
}
|
|
272
|
+
if (filters.containsAny) {
|
|
273
|
+
contains(filters.containsAny, true);
|
|
243
274
|
}
|
|
244
275
|
return query;
|
|
245
276
|
}
|
package/dist/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/server",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "1.2.39-alpha.
|
|
4
|
+
"version": "1.2.39-alpha.7",
|
|
5
5
|
"description": "Budibase Web Server",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -77,11 +77,11 @@
|
|
|
77
77
|
"license": "GPL-3.0",
|
|
78
78
|
"dependencies": {
|
|
79
79
|
"@apidevtools/swagger-parser": "10.0.3",
|
|
80
|
-
"@budibase/backend-core": "1.2.39-alpha.
|
|
81
|
-
"@budibase/client": "1.2.39-alpha.
|
|
82
|
-
"@budibase/pro": "1.2.39-alpha.
|
|
83
|
-
"@budibase/string-templates": "1.2.39-alpha.
|
|
84
|
-
"@budibase/types": "1.2.39-alpha.
|
|
80
|
+
"@budibase/backend-core": "1.2.39-alpha.7",
|
|
81
|
+
"@budibase/client": "1.2.39-alpha.7",
|
|
82
|
+
"@budibase/pro": "1.2.39-alpha.7",
|
|
83
|
+
"@budibase/string-templates": "1.2.39-alpha.7",
|
|
84
|
+
"@budibase/types": "1.2.39-alpha.7",
|
|
85
85
|
"@bull-board/api": "3.7.0",
|
|
86
86
|
"@bull-board/koa": "3.9.4",
|
|
87
87
|
"@elastic/elasticsearch": "7.10.0",
|