@budibase/backend-core 2.29.14 → 2.29.16
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/index.js +128 -77
- package/dist/index.js.map +4 -4
- package/dist/index.js.meta.json +1 -1
- package/dist/package.json +4 -4
- package/dist/plugins.js.meta.json +1 -1
- package/dist/src/db/utils.d.ts +1 -0
- package/dist/src/db/utils.js +19 -0
- package/dist/src/db/utils.js.map +1 -1
- package/dist/src/environment.d.ts +2 -0
- package/dist/src/environment.js +2 -1
- package/dist/src/environment.js.map +1 -1
- package/dist/src/sql/sql.js +15 -5
- package/dist/src/sql/sql.js.map +1 -1
- package/dist/src/users/users.js +3 -3
- package/dist/src/users/users.js.map +1 -1
- package/package.json +4 -4
- package/src/db/utils.ts +26 -0
- package/src/environment.ts +3 -0
- package/src/sql/sql.ts +39 -15
- package/src/users/users.ts +5 -4
package/dist/index.js
CHANGED
|
@@ -61,7 +61,7 @@ var require_dayjs_min = __commonJS({
|
|
|
61
61
|
} }, g = "en", D = {};
|
|
62
62
|
D[g] = M;
|
|
63
63
|
var p = "$isDayjsObject", S = function(t2) {
|
|
64
|
-
return t2 instanceof
|
|
64
|
+
return t2 instanceof _2 || !(!t2 || !t2[p]);
|
|
65
65
|
}, w = function t2(e2, n2, r2) {
|
|
66
66
|
var i2;
|
|
67
67
|
if (!e2)
|
|
@@ -81,12 +81,12 @@ var require_dayjs_min = __commonJS({
|
|
|
81
81
|
if (S(t2))
|
|
82
82
|
return t2.clone();
|
|
83
83
|
var n2 = "object" == typeof e2 ? e2 : {};
|
|
84
|
-
return n2.date = t2, n2.args = arguments, new
|
|
84
|
+
return n2.date = t2, n2.args = arguments, new _2(n2);
|
|
85
85
|
}, b = v;
|
|
86
86
|
b.l = w, b.i = S, b.w = function(t2, e2) {
|
|
87
87
|
return O(t2, { locale: e2.$L, utc: e2.$u, x: e2.$x, $offset: e2.$offset });
|
|
88
88
|
};
|
|
89
|
-
var
|
|
89
|
+
var _2 = function() {
|
|
90
90
|
function M2(t2) {
|
|
91
91
|
this.$L = w(t2.locale, null, true), this.parse(t2), this.$x = this.$x || t2.x || {}, this[p] = true;
|
|
92
92
|
}
|
|
@@ -311,13 +311,13 @@ var require_dayjs_min = __commonJS({
|
|
|
311
311
|
}, m2.toString = function() {
|
|
312
312
|
return this.$d.toUTCString();
|
|
313
313
|
}, M2;
|
|
314
|
-
}(), k =
|
|
314
|
+
}(), k = _2.prototype;
|
|
315
315
|
return O.prototype = k, [["$ms", r], ["$s", i], ["$m", s], ["$H", u], ["$W", a], ["$M", c], ["$y", h], ["$D", d]].forEach(function(t2) {
|
|
316
316
|
k[t2[1]] = function(e2) {
|
|
317
317
|
return this.$g(e2, t2[0], t2[1]);
|
|
318
318
|
};
|
|
319
319
|
}), O.extend = function(t2, e2) {
|
|
320
|
-
return t2.$i || (t2(e2,
|
|
320
|
+
return t2.$i || (t2(e2, _2, O), t2.$i = true), O;
|
|
321
321
|
}, O.locale = w, O.isDayjs = S, O.unix = function(t2) {
|
|
322
322
|
return O(1e3 * t2);
|
|
323
323
|
}, O.en = D[g], O.Ls = D, O.p = {}, O;
|
|
@@ -797,12 +797,12 @@ var require_nanoclone = __commonJS({
|
|
|
797
797
|
var map;
|
|
798
798
|
try {
|
|
799
799
|
map = Map;
|
|
800
|
-
} catch (
|
|
800
|
+
} catch (_2) {
|
|
801
801
|
}
|
|
802
802
|
var set2;
|
|
803
803
|
try {
|
|
804
804
|
set2 = Set;
|
|
805
|
-
} catch (
|
|
805
|
+
} catch (_2) {
|
|
806
806
|
}
|
|
807
807
|
function baseClone(src, circulars, clones) {
|
|
808
808
|
if (!src || typeof src !== "object" || typeof src === "function") {
|
|
@@ -1110,7 +1110,7 @@ var require_ValidationError = __commonJS({
|
|
|
1110
1110
|
path: path3
|
|
1111
1111
|
});
|
|
1112
1112
|
if (typeof message === "string")
|
|
1113
|
-
return message.replace(strReg, (
|
|
1113
|
+
return message.replace(strReg, (_2, key) => (0, _printValue.default)(params2[key]));
|
|
1114
1114
|
if (typeof message === "function")
|
|
1115
1115
|
return message(params2);
|
|
1116
1116
|
return message;
|
|
@@ -2989,7 +2989,7 @@ var require_object = __commonJS({
|
|
|
2989
2989
|
return;
|
|
2990
2990
|
}
|
|
2991
2991
|
originalValue = originalValue || value;
|
|
2992
|
-
let tests = this._nodes.map((key) => (
|
|
2992
|
+
let tests = this._nodes.map((key) => (_2, cb) => {
|
|
2993
2993
|
let path3 = key.indexOf(".") === -1 ? (opts.path ? `${opts.path}.` : "") + key : `${opts.path || ""}["${key}"]`;
|
|
2994
2994
|
let field = this.fields[key];
|
|
2995
2995
|
if (field && "validate" in field) {
|
|
@@ -3133,7 +3133,7 @@ var require_object = __commonJS({
|
|
|
3133
3133
|
return this.noUnknown(!allow, message);
|
|
3134
3134
|
}
|
|
3135
3135
|
transformKeys(fn) {
|
|
3136
|
-
return this.transform((obj) => obj && (0, _mapKeys.default)(obj, (
|
|
3136
|
+
return this.transform((obj) => obj && (0, _mapKeys.default)(obj, (_2, key) => fn(key)));
|
|
3137
3137
|
}
|
|
3138
3138
|
camelCase() {
|
|
3139
3139
|
return this.transformKeys(_camelCase.default);
|
|
@@ -3266,7 +3266,7 @@ var require_array = __commonJS({
|
|
|
3266
3266
|
index: idx,
|
|
3267
3267
|
originalValue: originalValue[idx]
|
|
3268
3268
|
});
|
|
3269
|
-
tests[idx] = (
|
|
3269
|
+
tests[idx] = (_2, cb) => innerType.validate(item, innerOptions, cb);
|
|
3270
3270
|
}
|
|
3271
3271
|
(0, _runTests.default)({
|
|
3272
3272
|
sync,
|
|
@@ -5333,7 +5333,7 @@ var require_extend = __commonJS({
|
|
|
5333
5333
|
}
|
|
5334
5334
|
return toStr.call(arr) === "[object Array]";
|
|
5335
5335
|
};
|
|
5336
|
-
var
|
|
5336
|
+
var isPlainObject3 = function isPlainObject4(obj) {
|
|
5337
5337
|
if (!obj || toStr.call(obj) !== "[object Object]") {
|
|
5338
5338
|
return false;
|
|
5339
5339
|
}
|
|
@@ -5390,12 +5390,12 @@ var require_extend = __commonJS({
|
|
|
5390
5390
|
src = getProperty(target, name);
|
|
5391
5391
|
copy = getProperty(options2, name);
|
|
5392
5392
|
if (target !== copy) {
|
|
5393
|
-
if (deep && copy && (
|
|
5393
|
+
if (deep && copy && (isPlainObject3(copy) || (copyIsArray = isArray(copy)))) {
|
|
5394
5394
|
if (copyIsArray) {
|
|
5395
5395
|
copyIsArray = false;
|
|
5396
5396
|
clone = src && isArray(src) ? src : [];
|
|
5397
5397
|
} else {
|
|
5398
|
-
clone = src &&
|
|
5398
|
+
clone = src && isPlainObject3(src) ? src : {};
|
|
5399
5399
|
}
|
|
5400
5400
|
setProperty(target, { name, newValue: extend(deep, clone, copy) });
|
|
5401
5401
|
} else if (typeof copy !== "undefined") {
|
|
@@ -30185,7 +30185,7 @@ var require_jsprim = __commonJS({
|
|
|
30185
30185
|
var mod_jsonschema = require_validate();
|
|
30186
30186
|
exports.deepCopy = deepCopy;
|
|
30187
30187
|
exports.deepEqual = deepEqual;
|
|
30188
|
-
exports.isEmpty =
|
|
30188
|
+
exports.isEmpty = isEmpty3;
|
|
30189
30189
|
exports.hasKey = hasKey;
|
|
30190
30190
|
exports.forEachKey = forEachKey;
|
|
30191
30191
|
exports.pluck = pluck;
|
|
@@ -30255,7 +30255,7 @@ var require_jsprim = __commonJS({
|
|
|
30255
30255
|
}
|
|
30256
30256
|
return true;
|
|
30257
30257
|
}
|
|
30258
|
-
function
|
|
30258
|
+
function isEmpty3(obj) {
|
|
30259
30259
|
var key;
|
|
30260
30260
|
for (key in obj)
|
|
30261
30261
|
return false;
|
|
@@ -41945,7 +41945,7 @@ var require_uri_all = __commonJS({
|
|
|
41945
41945
|
uriTokens.push("@");
|
|
41946
41946
|
}
|
|
41947
41947
|
if (components.host !== void 0) {
|
|
41948
|
-
uriTokens.push(_normalizeIPv6(_normalizeIPv4(String(components.host), protocol), protocol).replace(protocol.IPV6ADDRESS, function(
|
|
41948
|
+
uriTokens.push(_normalizeIPv6(_normalizeIPv4(String(components.host), protocol), protocol).replace(protocol.IPV6ADDRESS, function(_2, $1, $2) {
|
|
41949
41949
|
return "[" + $1 + ($2 ? "%25" + $2 : "") + "]";
|
|
41950
41950
|
}));
|
|
41951
41951
|
}
|
|
@@ -52815,7 +52815,7 @@ var require_xml2js = __commonJS({
|
|
|
52815
52815
|
"../../node_modules/webfinger/node_modules/xml2js/lib/xml2js.js"(exports) {
|
|
52816
52816
|
"use strict";
|
|
52817
52817
|
(function() {
|
|
52818
|
-
var events2,
|
|
52818
|
+
var events2, isEmpty3, sax, __hasProp = {}.hasOwnProperty, __extends = function(child, parent) {
|
|
52819
52819
|
for (var key in parent) {
|
|
52820
52820
|
if (__hasProp.call(parent, key))
|
|
52821
52821
|
child[key] = parent[key];
|
|
@@ -52834,7 +52834,7 @@ var require_xml2js = __commonJS({
|
|
|
52834
52834
|
};
|
|
52835
52835
|
sax = require_sax();
|
|
52836
52836
|
events2 = require("events");
|
|
52837
|
-
|
|
52837
|
+
isEmpty3 = function(thing) {
|
|
52838
52838
|
return typeof thing === "object" && thing != null && Object.keys(thing).length === 0;
|
|
52839
52839
|
};
|
|
52840
52840
|
exports.defaults = {
|
|
@@ -52954,7 +52954,7 @@ var require_xml2js = __commonJS({
|
|
|
52954
52954
|
obj = obj[charkey];
|
|
52955
52955
|
}
|
|
52956
52956
|
}
|
|
52957
|
-
if (_this.options.emptyTag !== void 0 &&
|
|
52957
|
+
if (_this.options.emptyTag !== void 0 && isEmpty3(obj)) {
|
|
52958
52958
|
obj = _this.options.emptyTag;
|
|
52959
52959
|
}
|
|
52960
52960
|
if (_this.options.validator != null) {
|
|
@@ -54461,6 +54461,15 @@ var DatasourceFeature = /* @__PURE__ */ ((DatasourceFeature2) => {
|
|
|
54461
54461
|
return DatasourceFeature2;
|
|
54462
54462
|
})(DatasourceFeature || {});
|
|
54463
54463
|
|
|
54464
|
+
// ../types/src/sdk/search.ts
|
|
54465
|
+
var ArrayOperator = /* @__PURE__ */ ((ArrayOperator2) => {
|
|
54466
|
+
ArrayOperator2["CONTAINS"] = "contains";
|
|
54467
|
+
ArrayOperator2["NOT_CONTAINS"] = "notContains";
|
|
54468
|
+
ArrayOperator2["CONTAINS_ANY"] = "containsAny";
|
|
54469
|
+
ArrayOperator2["ONE_OF"] = "oneOf";
|
|
54470
|
+
return ArrayOperator2;
|
|
54471
|
+
})(ArrayOperator || {});
|
|
54472
|
+
|
|
54464
54473
|
// ../types/src/sdk/db.ts
|
|
54465
54474
|
var isDocument = (doc) => {
|
|
54466
54475
|
return typeof doc === "object" && doc._id && doc._rev;
|
|
@@ -54828,6 +54837,7 @@ __export(filters_exports, {
|
|
|
54828
54837
|
ColumnSplitter: () => ColumnSplitter,
|
|
54829
54838
|
NoEmptyFilterStrings: () => NoEmptyFilterStrings,
|
|
54830
54839
|
buildQuery: () => buildQuery,
|
|
54840
|
+
fixupFilterArrays: () => fixupFilterArrays,
|
|
54831
54841
|
getKeyNumbering: () => getKeyNumbering,
|
|
54832
54842
|
getValidOperatorsForType: () => getValidOperatorsForType,
|
|
54833
54843
|
hasFilters: () => hasFilters,
|
|
@@ -54987,7 +54997,7 @@ function isRequired(constraints) {
|
|
|
54987
54997
|
}
|
|
54988
54998
|
|
|
54989
54999
|
// ../shared-core/src/filters.ts
|
|
54990
|
-
var import_lodash =
|
|
55000
|
+
var import_lodash = require("lodash");
|
|
54991
55001
|
var HBS_REGEX = /{{([^{].*?)}}/g;
|
|
54992
55002
|
var getValidOperatorsForType = (fieldType, field, datasource2) => {
|
|
54993
55003
|
const Op = OperatorOptions;
|
|
@@ -55187,21 +55197,37 @@ var buildQuery = (filter) => {
|
|
|
55187
55197
|
query.equal = query.equal || {};
|
|
55188
55198
|
query.equal[field] = true;
|
|
55189
55199
|
} else {
|
|
55190
|
-
query[queryOperator]
|
|
55191
|
-
|
|
55192
|
-
[field]: value
|
|
55193
|
-
};
|
|
55200
|
+
query[queryOperator] ??= {};
|
|
55201
|
+
query[queryOperator][field] = value;
|
|
55194
55202
|
}
|
|
55195
55203
|
} else {
|
|
55196
|
-
query[queryOperator]
|
|
55197
|
-
|
|
55198
|
-
[field]: value
|
|
55199
|
-
};
|
|
55204
|
+
query[queryOperator] ??= {};
|
|
55205
|
+
query[queryOperator][field] = value;
|
|
55200
55206
|
}
|
|
55201
55207
|
}
|
|
55202
55208
|
});
|
|
55203
55209
|
return query;
|
|
55204
55210
|
};
|
|
55211
|
+
function fixupFilterArrays(filters) {
|
|
55212
|
+
for (const searchField of Object.values(ArrayOperator)) {
|
|
55213
|
+
const field = filters[searchField];
|
|
55214
|
+
if (field == null || !(0, import_lodash.isPlainObject)(field)) {
|
|
55215
|
+
continue;
|
|
55216
|
+
}
|
|
55217
|
+
for (const key of Object.keys(field)) {
|
|
55218
|
+
if (Array.isArray(field[key])) {
|
|
55219
|
+
continue;
|
|
55220
|
+
}
|
|
55221
|
+
const value = field[key];
|
|
55222
|
+
if (typeof value === "string") {
|
|
55223
|
+
field[key] = value.split(",").map((x) => x.trim());
|
|
55224
|
+
} else {
|
|
55225
|
+
field[key] = [value];
|
|
55226
|
+
}
|
|
55227
|
+
}
|
|
55228
|
+
}
|
|
55229
|
+
return filters;
|
|
55230
|
+
}
|
|
55205
55231
|
var search = (docs, query) => {
|
|
55206
55232
|
let result = runQuery(docs, query.query);
|
|
55207
55233
|
if (query.sort) {
|
|
@@ -55225,6 +55251,7 @@ var runQuery = (docs, query) => {
|
|
|
55225
55251
|
return docs;
|
|
55226
55252
|
}
|
|
55227
55253
|
query = cleanupQuery(query);
|
|
55254
|
+
query = fixupFilterArrays(query);
|
|
55228
55255
|
if (!hasFilters(query) && query.onEmptyFilter === "none" /* RETURN_NONE */) {
|
|
55229
55256
|
return [];
|
|
55230
55257
|
}
|
|
@@ -55269,10 +55296,10 @@ var runQuery = (docs, query) => {
|
|
|
55269
55296
|
if (docValue == null || docValue === "") {
|
|
55270
55297
|
return false;
|
|
55271
55298
|
}
|
|
55272
|
-
if (import_lodash.
|
|
55299
|
+
if ((0, import_lodash.isPlainObject)(testValue.low) && (0, import_lodash.isEmpty)(testValue.low)) {
|
|
55273
55300
|
testValue.low = void 0;
|
|
55274
55301
|
}
|
|
55275
|
-
if (import_lodash.
|
|
55302
|
+
if ((0, import_lodash.isPlainObject)(testValue.high) && (0, import_lodash.isEmpty)(testValue.high)) {
|
|
55276
55303
|
testValue.high = void 0;
|
|
55277
55304
|
}
|
|
55278
55305
|
if (testValue.low == null && testValue.high == null) {
|
|
@@ -55328,10 +55355,7 @@ var runQuery = (docs, query) => {
|
|
|
55328
55355
|
};
|
|
55329
55356
|
const not = (f) => (...args) => !f(...args);
|
|
55330
55357
|
const equalMatch = match("equal" /* EQUAL */, _valueMatches);
|
|
55331
|
-
const notEqualMatch = match(
|
|
55332
|
-
"notEqual" /* NOT_EQUAL */,
|
|
55333
|
-
not(_valueMatches)
|
|
55334
|
-
);
|
|
55358
|
+
const notEqualMatch = match("notEqual" /* NOT_EQUAL */, not(_valueMatches));
|
|
55335
55359
|
const _empty = (docValue) => {
|
|
55336
55360
|
if (typeof docValue === "string") {
|
|
55337
55361
|
return docValue === "";
|
|
@@ -55346,21 +55370,18 @@ var runQuery = (docs, query) => {
|
|
|
55346
55370
|
};
|
|
55347
55371
|
const emptyMatch = match("empty" /* EMPTY */, _empty);
|
|
55348
55372
|
const notEmptyMatch = match("notEmpty" /* NOT_EMPTY */, not(_empty));
|
|
55349
|
-
const oneOf = match(
|
|
55350
|
-
"
|
|
55351
|
-
|
|
55352
|
-
if (typeof testValue === "string") {
|
|
55353
|
-
testValue = testValue.split(",");
|
|
55354
|
-
if (typeof docValue === "number") {
|
|
55355
|
-
testValue = testValue.map((item) => parseFloat(item));
|
|
55356
|
-
}
|
|
55357
|
-
}
|
|
55358
|
-
if (!Array.isArray(testValue)) {
|
|
55359
|
-
return false;
|
|
55360
|
-
}
|
|
55361
|
-
return testValue.some((item) => _valueMatches(docValue, item));
|
|
55373
|
+
const oneOf = match("oneOf" /* ONE_OF */, (docValue, testValue) => {
|
|
55374
|
+
if (typeof testValue === "string") {
|
|
55375
|
+
testValue = testValue.split(",");
|
|
55362
55376
|
}
|
|
55363
|
-
|
|
55377
|
+
if (typeof docValue === "number") {
|
|
55378
|
+
testValue = testValue.map((item) => parseFloat(item));
|
|
55379
|
+
}
|
|
55380
|
+
if (!Array.isArray(testValue)) {
|
|
55381
|
+
return false;
|
|
55382
|
+
}
|
|
55383
|
+
return testValue.some((item) => _valueMatches(docValue, item));
|
|
55384
|
+
});
|
|
55364
55385
|
const _contains = (f) => (docValue, testValue) => {
|
|
55365
55386
|
if (!Array.isArray(docValue)) {
|
|
55366
55387
|
return false;
|
|
@@ -55397,10 +55418,7 @@ var runQuery = (docs, query) => {
|
|
|
55397
55418
|
return not(_contains("every"))(docValue, testValue);
|
|
55398
55419
|
}
|
|
55399
55420
|
);
|
|
55400
|
-
const containsAny = match(
|
|
55401
|
-
"containsAny" /* CONTAINS_ANY */,
|
|
55402
|
-
_contains("some")
|
|
55403
|
-
);
|
|
55421
|
+
const containsAny = match("containsAny" /* CONTAINS_ANY */, _contains("some"));
|
|
55404
55422
|
const docMatch = (doc) => {
|
|
55405
55423
|
const filterFunctions = {
|
|
55406
55424
|
string: stringMatch,
|
|
@@ -55585,7 +55603,7 @@ __export(users_exports, {
|
|
|
55585
55603
|
isCreator: () => isCreator,
|
|
55586
55604
|
isGlobalBuilder: () => isGlobalBuilder
|
|
55587
55605
|
});
|
|
55588
|
-
var
|
|
55606
|
+
var _ = __toESM(require("lodash/fp"));
|
|
55589
55607
|
function isBuilder(user, appId) {
|
|
55590
55608
|
if (!user) {
|
|
55591
55609
|
return false;
|
|
@@ -55627,10 +55645,10 @@ function hasAppCreatorPermissions(user) {
|
|
|
55627
55645
|
if (!user) {
|
|
55628
55646
|
return false;
|
|
55629
55647
|
}
|
|
55630
|
-
return
|
|
55631
|
-
|
|
55632
|
-
|
|
55633
|
-
|
|
55648
|
+
return _.flow(
|
|
55649
|
+
_.get("roles"),
|
|
55650
|
+
_.values,
|
|
55651
|
+
_.find((x) => ["CREATOR", "ADMIN"].includes(x)),
|
|
55634
55652
|
(x) => !!x
|
|
55635
55653
|
)(user);
|
|
55636
55654
|
}
|
|
@@ -56022,6 +56040,8 @@ var environment = {
|
|
|
56022
56040
|
COUCH_DB_URL: process.env.COUCH_DB_URL || "http://localhost:4005",
|
|
56023
56041
|
COUCH_DB_SQL_URL: process.env.COUCH_DB_SQL_URL || "http://localhost:4006",
|
|
56024
56042
|
SQS_SEARCH_ENABLE: process.env.SQS_SEARCH_ENABLE,
|
|
56043
|
+
SQS_SEARCH_ENABLE_TENANTS: process.env.SQS_SEARCH_ENABLE_TENANTS?.split(",") || [],
|
|
56044
|
+
SQS_MIGRATION_ENABLE: process.env.SQS_MIGRATION_ENABLE,
|
|
56025
56045
|
COUCH_DB_USERNAME: process.env.COUCH_DB_USER,
|
|
56026
56046
|
COUCH_DB_PASSWORD: process.env.COUCH_DB_PASSWORD,
|
|
56027
56047
|
GOOGLE_CLIENT_ID: process.env.GOOGLE_CLIENT_ID,
|
|
@@ -56621,6 +56641,7 @@ __export(db_exports, {
|
|
|
56621
56641
|
isGlobalUserID: () => isGlobalUserID,
|
|
56622
56642
|
isProdAppID: () => isProdAppID,
|
|
56623
56643
|
isSameAppID: () => isSameAppID,
|
|
56644
|
+
isSqsEnabledForTenant: () => isSqsEnabledForTenant,
|
|
56624
56645
|
isTableId: () => isTableId,
|
|
56625
56646
|
paginatedSearch: () => paginatedSearch,
|
|
56626
56647
|
pagination: () => pagination,
|
|
@@ -57561,7 +57582,7 @@ function getLogReadStream() {
|
|
|
57561
57582
|
}
|
|
57562
57583
|
|
|
57563
57584
|
// src/logging/pino/logger.ts
|
|
57564
|
-
function
|
|
57585
|
+
function isPlainObject2(obj) {
|
|
57565
57586
|
return typeof obj === "object" && obj !== null && !(obj instanceof Error);
|
|
57566
57587
|
}
|
|
57567
57588
|
function isError(obj) {
|
|
@@ -57613,7 +57634,7 @@ if (!environment_default.DISABLE_PINO_LOGGER) {
|
|
|
57613
57634
|
if (isMessage(arg)) {
|
|
57614
57635
|
message = `${message} ${arg}`.trimStart();
|
|
57615
57636
|
}
|
|
57616
|
-
if (
|
|
57637
|
+
if (isPlainObject2(arg)) {
|
|
57617
57638
|
objects.push(arg);
|
|
57618
57639
|
}
|
|
57619
57640
|
if (isError(arg)) {
|
|
@@ -58521,6 +58542,21 @@ function pagination(data, pageSize, {
|
|
|
58521
58542
|
nextPage
|
|
58522
58543
|
};
|
|
58523
58544
|
}
|
|
58545
|
+
function isSqsEnabledForTenant() {
|
|
58546
|
+
const tenantId = getTenantId();
|
|
58547
|
+
if (!environment_default.SQS_SEARCH_ENABLE) {
|
|
58548
|
+
return false;
|
|
58549
|
+
}
|
|
58550
|
+
if (environment_default.isTest() && environment_default.SQS_SEARCH_ENABLE_TENANTS.length === 0) {
|
|
58551
|
+
throw new Error(
|
|
58552
|
+
"to enable SQS you must specify a list of tenants in the SQS_SEARCH_ENABLE_TENANTS env var"
|
|
58553
|
+
);
|
|
58554
|
+
}
|
|
58555
|
+
if (environment_default.SQS_SEARCH_ENABLE_TENANTS.length === 1 && environment_default.SQS_SEARCH_ENABLE_TENANTS[0] === "*") {
|
|
58556
|
+
return true;
|
|
58557
|
+
}
|
|
58558
|
+
return environment_default.SQS_SEARCH_ENABLE_TENANTS.includes(tenantId);
|
|
58559
|
+
}
|
|
58524
58560
|
|
|
58525
58561
|
// src/db/views.ts
|
|
58526
58562
|
var DESIGN_DB = "_design/database";
|
|
@@ -58750,7 +58786,7 @@ var Replication_default = Replication;
|
|
|
58750
58786
|
// src/db/lucene.ts
|
|
58751
58787
|
var import_node_fetch3 = __toESM(require("node-fetch"));
|
|
58752
58788
|
var removeKeyNumbering2 = filters_exports.removeKeyNumbering;
|
|
58753
|
-
function
|
|
58789
|
+
function isEmpty2(value) {
|
|
58754
58790
|
return value == null || value === "";
|
|
58755
58791
|
}
|
|
58756
58792
|
var QueryBuilder = class _QueryBuilder {
|
|
@@ -58973,13 +59009,13 @@ var QueryBuilder = class _QueryBuilder {
|
|
|
58973
59009
|
delete this.#query.equal.tableId;
|
|
58974
59010
|
}
|
|
58975
59011
|
const equal = (key, value) => {
|
|
58976
|
-
if (
|
|
59012
|
+
if (isEmpty2(value)) {
|
|
58977
59013
|
return null;
|
|
58978
59014
|
}
|
|
58979
59015
|
return `${key}:${builder.preprocess(value, allPreProcessingOpts)}`;
|
|
58980
59016
|
};
|
|
58981
59017
|
const contains = (key, value, mode = "AND") => {
|
|
58982
|
-
if (
|
|
59018
|
+
if (isEmpty2(value)) {
|
|
58983
59019
|
return null;
|
|
58984
59020
|
}
|
|
58985
59021
|
if (!Array.isArray(value)) {
|
|
@@ -58994,7 +59030,7 @@ var QueryBuilder = class _QueryBuilder {
|
|
|
58994
59030
|
return `${key}:(${statement})`;
|
|
58995
59031
|
};
|
|
58996
59032
|
const fuzzy = (key, value) => {
|
|
58997
|
-
if (
|
|
59033
|
+
if (isEmpty2(value)) {
|
|
58998
59034
|
return null;
|
|
58999
59035
|
}
|
|
59000
59036
|
value = builder.preprocess(value, {
|
|
@@ -59013,7 +59049,7 @@ var QueryBuilder = class _QueryBuilder {
|
|
|
59013
59049
|
return contains(key, value, "OR");
|
|
59014
59050
|
};
|
|
59015
59051
|
const oneOf = (key, value) => {
|
|
59016
|
-
if (
|
|
59052
|
+
if (isEmpty2(value)) {
|
|
59017
59053
|
return `*:*`;
|
|
59018
59054
|
}
|
|
59019
59055
|
if (!Array.isArray(value)) {
|
|
@@ -59060,7 +59096,7 @@ var QueryBuilder = class _QueryBuilder {
|
|
|
59060
59096
|
}
|
|
59061
59097
|
if (this.#query.string) {
|
|
59062
59098
|
build(this.#query.string, (key, value) => {
|
|
59063
|
-
if (
|
|
59099
|
+
if (isEmpty2(value)) {
|
|
59064
59100
|
return null;
|
|
59065
59101
|
}
|
|
59066
59102
|
value = builder.preprocess(value, {
|
|
@@ -59073,7 +59109,7 @@ var QueryBuilder = class _QueryBuilder {
|
|
|
59073
59109
|
}
|
|
59074
59110
|
if (this.#query.range) {
|
|
59075
59111
|
build(this.#query.range, (key, value) => {
|
|
59076
|
-
if (
|
|
59112
|
+
if (isEmpty2(value)) {
|
|
59077
59113
|
return null;
|
|
59078
59114
|
}
|
|
59079
59115
|
if (value.low == null || value.low === "") {
|
|
@@ -59095,7 +59131,7 @@ var QueryBuilder = class _QueryBuilder {
|
|
|
59095
59131
|
}
|
|
59096
59132
|
if (this.#query.notEqual) {
|
|
59097
59133
|
build(this.#query.notEqual, (key, value) => {
|
|
59098
|
-
if (
|
|
59134
|
+
if (isEmpty2(value)) {
|
|
59099
59135
|
return null;
|
|
59100
59136
|
}
|
|
59101
59137
|
if (typeof value === "boolean") {
|
|
@@ -67690,15 +67726,24 @@ var InternalBuilder = class {
|
|
|
67690
67726
|
const alias = opts.aliases?.[name];
|
|
67691
67727
|
return alias || name;
|
|
67692
67728
|
}
|
|
67693
|
-
function iterate(structure, fn) {
|
|
67694
|
-
for (
|
|
67729
|
+
function iterate(structure, fn, complexKeyFn) {
|
|
67730
|
+
for (const key in structure) {
|
|
67731
|
+
const value = structure[key];
|
|
67695
67732
|
const updatedKey = removeKeyNumbering2(key);
|
|
67696
67733
|
const isRelationshipField = updatedKey.includes(".");
|
|
67697
|
-
|
|
67734
|
+
let castedTypeValue;
|
|
67735
|
+
if (key === "_complexIdOperator" /* COMPLEX_ID_OPERATOR */ && (castedTypeValue = structure[key]) && complexKeyFn) {
|
|
67736
|
+
const alias = getTableAlias(tableName);
|
|
67737
|
+
complexKeyFn(
|
|
67738
|
+
castedTypeValue.id.map(
|
|
67739
|
+
(x) => alias ? `${alias}.${x}` : x
|
|
67740
|
+
),
|
|
67741
|
+
castedTypeValue.values
|
|
67742
|
+
);
|
|
67743
|
+
} else if (!opts.relationship && !isRelationshipField) {
|
|
67698
67744
|
const alias = getTableAlias(tableName);
|
|
67699
67745
|
fn(alias ? `${alias}.${updatedKey}` : updatedKey, value);
|
|
67700
|
-
}
|
|
67701
|
-
if (opts.relationship && isRelationshipField) {
|
|
67746
|
+
} else if (opts.relationship && isRelationshipField) {
|
|
67702
67747
|
const [filterTableName, property] = updatedKey.split(".");
|
|
67703
67748
|
const alias = getTableAlias(filterTableName);
|
|
67704
67749
|
fn(alias ? `${alias}.${property}` : property, value);
|
|
@@ -67771,10 +67816,16 @@ var InternalBuilder = class {
|
|
|
67771
67816
|
}
|
|
67772
67817
|
};
|
|
67773
67818
|
if (filters.oneOf) {
|
|
67774
|
-
|
|
67775
|
-
|
|
67776
|
-
|
|
67777
|
-
|
|
67819
|
+
const fnc = allOr ? "orWhereIn" : "whereIn";
|
|
67820
|
+
iterate(
|
|
67821
|
+
filters.oneOf,
|
|
67822
|
+
(key, array) => {
|
|
67823
|
+
query = query[fnc](key, Array.isArray(array) ? array : [array]);
|
|
67824
|
+
},
|
|
67825
|
+
(key, array) => {
|
|
67826
|
+
query = query[fnc](key, Array.isArray(array) ? array : [array]);
|
|
67827
|
+
}
|
|
67828
|
+
);
|
|
67778
67829
|
}
|
|
67779
67830
|
if (filters.string) {
|
|
67780
67831
|
iterate(filters.string, (key, value) => {
|