@budibase/backend-core 2.29.29 → 2.30.0
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 +116 -82
- 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/features/index.d.ts +31 -13
- package/dist/src/features/index.js +92 -60
- package/dist/src/features/index.js.map +1 -1
- package/dist/src/index.d.ts +1 -2
- package/dist/src/index.js +2 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/sql/sql.js +18 -0
- package/dist/src/sql/sql.js.map +1 -1
- package/package.json +4 -4
- package/src/features/index.ts +88 -59
- package/src/features/tests/features.spec.ts +86 -0
- package/src/index.ts +1 -2
- package/src/sql/sql.ts +20 -0
- package/dist/src/features/installation.d.ts +0 -1
- package/dist/src/features/installation.js +0 -19
- package/dist/src/features/installation.js.map +0 -1
- package/src/features/installation.ts +0 -17
- package/src/features/tests/featureFlags.spec.ts +0 -85
package/dist/index.js
CHANGED
|
@@ -54195,8 +54195,7 @@ __export(src_exports, {
|
|
|
54195
54195
|
env: () => environment_default,
|
|
54196
54196
|
errors: () => errors_exports,
|
|
54197
54197
|
events: () => events_exports,
|
|
54198
|
-
|
|
54199
|
-
features: () => installation_exports2,
|
|
54198
|
+
features: () => features_exports,
|
|
54200
54199
|
getPublicError: () => getPublicError,
|
|
54201
54200
|
init: () => init9,
|
|
54202
54201
|
installation: () => installation_exports,
|
|
@@ -54482,6 +54481,9 @@ var RangeOperator = /* @__PURE__ */ ((RangeOperator2) => {
|
|
|
54482
54481
|
RangeOperator2["RANGE"] = "range";
|
|
54483
54482
|
return RangeOperator2;
|
|
54484
54483
|
})(RangeOperator || {});
|
|
54484
|
+
function isLogicalSearchOperator(value) {
|
|
54485
|
+
return value === "$and" /* AND */ || value === "$or" /* OR */;
|
|
54486
|
+
}
|
|
54485
54487
|
|
|
54486
54488
|
// ../types/src/sdk/db.ts
|
|
54487
54489
|
var isDocument = (doc) => {
|
|
@@ -55253,6 +55255,7 @@ var buildQuery = (filter) => {
|
|
|
55253
55255
|
high: value
|
|
55254
55256
|
};
|
|
55255
55257
|
}
|
|
55258
|
+
} else if (isLogicalSearchOperator(queryOperator)) {
|
|
55256
55259
|
} else if (query[queryOperator] && operator !== "onEmptyFilter") {
|
|
55257
55260
|
if (type === "boolean") {
|
|
55258
55261
|
if (queryOperator === "equal" && value === false) {
|
|
@@ -55322,14 +55325,15 @@ var runQuery = (docs, query) => {
|
|
|
55322
55325
|
}
|
|
55323
55326
|
const match = (type, test) => (doc) => {
|
|
55324
55327
|
for (const [key, testValue] of Object.entries(query[type] || {})) {
|
|
55325
|
-
const
|
|
55328
|
+
const valueToCheck = isLogicalSearchOperator(type) ? doc : deepGet(doc, removeKeyNumbering(key));
|
|
55329
|
+
const result = test(valueToCheck, testValue);
|
|
55326
55330
|
if (query.allOr && result) {
|
|
55327
55331
|
return true;
|
|
55328
55332
|
} else if (!query.allOr && !result) {
|
|
55329
55333
|
return false;
|
|
55330
55334
|
}
|
|
55331
55335
|
}
|
|
55332
|
-
return
|
|
55336
|
+
return !query.allOr;
|
|
55333
55337
|
};
|
|
55334
55338
|
const stringMatch = match(
|
|
55335
55339
|
"string" /* STRING */,
|
|
@@ -55484,6 +55488,39 @@ var runQuery = (docs, query) => {
|
|
|
55484
55488
|
}
|
|
55485
55489
|
);
|
|
55486
55490
|
const containsAny = match("containsAny" /* CONTAINS_ANY */, _contains("some"));
|
|
55491
|
+
const and = match(
|
|
55492
|
+
"$and" /* AND */,
|
|
55493
|
+
(docValue, conditions) => {
|
|
55494
|
+
if (!conditions.length) {
|
|
55495
|
+
return false;
|
|
55496
|
+
}
|
|
55497
|
+
for (const condition of conditions) {
|
|
55498
|
+
const matchesCondition = runQuery([docValue], condition);
|
|
55499
|
+
if (!matchesCondition.length) {
|
|
55500
|
+
return false;
|
|
55501
|
+
}
|
|
55502
|
+
}
|
|
55503
|
+
return true;
|
|
55504
|
+
}
|
|
55505
|
+
);
|
|
55506
|
+
const or = match(
|
|
55507
|
+
"$or" /* OR */,
|
|
55508
|
+
(docValue, conditions) => {
|
|
55509
|
+
if (!conditions.length) {
|
|
55510
|
+
return false;
|
|
55511
|
+
}
|
|
55512
|
+
for (const condition of conditions) {
|
|
55513
|
+
const matchesCondition = runQuery([docValue], {
|
|
55514
|
+
...condition,
|
|
55515
|
+
allOr: true
|
|
55516
|
+
});
|
|
55517
|
+
if (matchesCondition.length) {
|
|
55518
|
+
return true;
|
|
55519
|
+
}
|
|
55520
|
+
}
|
|
55521
|
+
return false;
|
|
55522
|
+
}
|
|
55523
|
+
);
|
|
55487
55524
|
const docMatch = (doc) => {
|
|
55488
55525
|
const filterFunctions = {
|
|
55489
55526
|
string: stringMatch,
|
|
@@ -55496,7 +55533,9 @@ var runQuery = (docs, query) => {
|
|
|
55496
55533
|
oneOf,
|
|
55497
55534
|
contains,
|
|
55498
55535
|
containsAny,
|
|
55499
|
-
notContains
|
|
55536
|
+
notContains,
|
|
55537
|
+
["$and" /* AND */]: and,
|
|
55538
|
+
["$or" /* OR */]: or
|
|
55500
55539
|
};
|
|
55501
55540
|
const results = Object.entries(query || {}).filter(
|
|
55502
55541
|
([key, value]) => !["allOr", "onEmptyFilter"].includes(key) && value && Object.keys(value).length > 0
|
|
@@ -65938,90 +65977,70 @@ var DEFINITIONS = [
|
|
|
65938
65977
|
// src/features/index.ts
|
|
65939
65978
|
var features_exports = {};
|
|
65940
65979
|
__export(features_exports, {
|
|
65941
|
-
|
|
65942
|
-
|
|
65943
|
-
|
|
65944
|
-
isEnabled: () => isEnabled
|
|
65945
|
-
processFeatureEnvVar: () => processFeatureEnvVar
|
|
65980
|
+
defaultFlags: () => defaultFlags,
|
|
65981
|
+
fetch: () => fetch6,
|
|
65982
|
+
get: () => get4,
|
|
65983
|
+
isEnabled: () => isEnabled
|
|
65946
65984
|
});
|
|
65947
|
-
|
|
65948
|
-
|
|
65949
|
-
|
|
65950
|
-
|
|
65951
|
-
processFeatureEnvVar: () => processFeatureEnvVar
|
|
65952
|
-
});
|
|
65953
|
-
function processFeatureEnvVar(fullList, featureList) {
|
|
65954
|
-
let list;
|
|
65955
|
-
if (!featureList) {
|
|
65956
|
-
list = fullList;
|
|
65957
|
-
} else {
|
|
65958
|
-
list = featureList.split(",");
|
|
65959
|
-
}
|
|
65960
|
-
for (let feature of list) {
|
|
65961
|
-
if (!fullList.includes(feature)) {
|
|
65962
|
-
throw new Error(`Feature: ${feature} is not an allowed option`);
|
|
65963
|
-
}
|
|
65985
|
+
var import_lodash2 = require("lodash");
|
|
65986
|
+
var Flag = class _Flag {
|
|
65987
|
+
constructor(defaultValue) {
|
|
65988
|
+
this.defaultValue = defaultValue;
|
|
65964
65989
|
}
|
|
65965
|
-
|
|
65966
|
-
|
|
65967
|
-
|
|
65968
|
-
// src/features/index.ts
|
|
65969
|
-
function buildFeatureFlags() {
|
|
65970
|
-
if (!environment_default.TENANT_FEATURE_FLAGS) {
|
|
65971
|
-
return;
|
|
65990
|
+
static withDefault(value) {
|
|
65991
|
+
return new _Flag(value);
|
|
65972
65992
|
}
|
|
65973
|
-
|
|
65974
|
-
|
|
65975
|
-
|
|
65976
|
-
|
|
65977
|
-
|
|
65978
|
-
|
|
65979
|
-
|
|
65980
|
-
|
|
65981
|
-
|
|
65982
|
-
|
|
65983
|
-
return
|
|
65984
|
-
}
|
|
65985
|
-
function
|
|
65986
|
-
|
|
65987
|
-
|
|
65988
|
-
|
|
65989
|
-
|
|
65990
|
-
|
|
65991
|
-
|
|
65992
|
-
const
|
|
65993
|
-
|
|
65994
|
-
|
|
65995
|
-
|
|
65996
|
-
|
|
65997
|
-
|
|
65998
|
-
if (flag.startsWith("!")) {
|
|
65999
|
-
let stripped = flag.substring(1);
|
|
66000
|
-
acc.push(stripped);
|
|
66001
|
-
}
|
|
66002
|
-
return acc;
|
|
66003
|
-
},
|
|
66004
|
-
[]
|
|
66005
|
-
);
|
|
66006
|
-
if (globalFlags) {
|
|
66007
|
-
flags.push(...globalFlags);
|
|
65993
|
+
};
|
|
65994
|
+
var FLAGS = {
|
|
65995
|
+
LICENSING: Flag.withDefault(false),
|
|
65996
|
+
GOOGLE_SHEETS: Flag.withDefault(false),
|
|
65997
|
+
USER_GROUPS: Flag.withDefault(false),
|
|
65998
|
+
ONBOARDING_TOUR: Flag.withDefault(false)
|
|
65999
|
+
};
|
|
66000
|
+
var DEFAULTS = Object.keys(FLAGS).reduce((acc, key) => {
|
|
66001
|
+
const typedKey = key;
|
|
66002
|
+
acc[typedKey] = FLAGS[typedKey].defaultValue;
|
|
66003
|
+
return acc;
|
|
66004
|
+
}, {});
|
|
66005
|
+
function defaultFlags() {
|
|
66006
|
+
return (0, import_lodash2.cloneDeep)(DEFAULTS);
|
|
66007
|
+
}
|
|
66008
|
+
function isFlagName(name) {
|
|
66009
|
+
return FLAGS[name] !== void 0;
|
|
66010
|
+
}
|
|
66011
|
+
async function fetch6() {
|
|
66012
|
+
const currentTenantId = getTenantId();
|
|
66013
|
+
const flags = defaultFlags();
|
|
66014
|
+
const split = (environment_default.TENANT_FEATURE_FLAGS || "").split(",").map((x) => x.split(":"));
|
|
66015
|
+
for (const [tenantId, ...features] of split) {
|
|
66016
|
+
if (!tenantId || tenantId !== "*" && tenantId !== currentTenantId) {
|
|
66017
|
+
continue;
|
|
66008
66018
|
}
|
|
66009
|
-
|
|
66010
|
-
|
|
66019
|
+
for (let feature of features) {
|
|
66020
|
+
let value = true;
|
|
66021
|
+
if (feature.startsWith("!")) {
|
|
66022
|
+
feature = feature.slice(1);
|
|
66023
|
+
value = false;
|
|
66024
|
+
}
|
|
66025
|
+
if (!isFlagName(feature)) {
|
|
66026
|
+
throw new Error(`Feature: ${feature} is not an allowed option`);
|
|
66027
|
+
}
|
|
66028
|
+
if (typeof flags[feature] !== "boolean") {
|
|
66029
|
+
throw new Error(`Feature: ${feature} is not a boolean`);
|
|
66030
|
+
}
|
|
66031
|
+
flags[feature] = value;
|
|
66011
66032
|
}
|
|
66012
|
-
flags = flags.filter((flag) => {
|
|
66013
|
-
return tenantOverrides.indexOf(flag) == -1 && !flag.startsWith("!");
|
|
66014
|
-
});
|
|
66015
66033
|
}
|
|
66016
66034
|
return flags;
|
|
66017
66035
|
}
|
|
66018
|
-
|
|
66019
|
-
|
|
66020
|
-
|
|
66021
|
-
|
|
66022
|
-
|
|
66023
|
-
|
|
66024
|
-
|
|
66036
|
+
async function get4(name) {
|
|
66037
|
+
const flags = await fetch6();
|
|
66038
|
+
return flags[name];
|
|
66039
|
+
}
|
|
66040
|
+
async function isEnabled(name) {
|
|
66041
|
+
const flags = await fetch6();
|
|
66042
|
+
return flags[name];
|
|
66043
|
+
}
|
|
66025
66044
|
|
|
66026
66045
|
// src/auth/index.ts
|
|
66027
66046
|
var auth_exports = {};
|
|
@@ -68016,6 +68035,22 @@ var InternalBuilder = class {
|
|
|
68016
68035
|
});
|
|
68017
68036
|
}
|
|
68018
68037
|
};
|
|
68038
|
+
if (filters.$and) {
|
|
68039
|
+
const { $and } = filters;
|
|
68040
|
+
query = query.where((x) => {
|
|
68041
|
+
for (const condition of $and.conditions) {
|
|
68042
|
+
x = this.addFilters(x, condition, opts);
|
|
68043
|
+
}
|
|
68044
|
+
});
|
|
68045
|
+
}
|
|
68046
|
+
if (filters.$or) {
|
|
68047
|
+
const { $or } = filters;
|
|
68048
|
+
query = query.where((x) => {
|
|
68049
|
+
for (const condition of $or.conditions) {
|
|
68050
|
+
x = this.addFilters(x, { ...condition, allOr: true }, opts);
|
|
68051
|
+
}
|
|
68052
|
+
});
|
|
68053
|
+
}
|
|
68019
68054
|
if (filters.oneOf) {
|
|
68020
68055
|
const fnc = allOr ? "orWhereIn" : "whereIn";
|
|
68021
68056
|
iterate(
|
|
@@ -68686,7 +68721,6 @@ var init9 = (opts = {}) => {
|
|
|
68686
68721
|
env,
|
|
68687
68722
|
errors,
|
|
68688
68723
|
events,
|
|
68689
|
-
featureFlags,
|
|
68690
68724
|
features,
|
|
68691
68725
|
getPublicError,
|
|
68692
68726
|
init,
|