@budibase/backend-core 2.29.29 → 2.29.30
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 +57 -79
- package/dist/index.js.map +4 -4
- package/dist/index.js.meta.json +1 -1
- package/dist/package.json +4 -4
- 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/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/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,
|
|
@@ -65938,90 +65937,70 @@ var DEFINITIONS = [
|
|
|
65938
65937
|
// src/features/index.ts
|
|
65939
65938
|
var features_exports = {};
|
|
65940
65939
|
__export(features_exports, {
|
|
65941
|
-
|
|
65942
|
-
|
|
65943
|
-
|
|
65944
|
-
isEnabled: () => isEnabled
|
|
65945
|
-
processFeatureEnvVar: () => processFeatureEnvVar
|
|
65940
|
+
defaultFlags: () => defaultFlags,
|
|
65941
|
+
fetch: () => fetch6,
|
|
65942
|
+
get: () => get4,
|
|
65943
|
+
isEnabled: () => isEnabled
|
|
65946
65944
|
});
|
|
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(",");
|
|
65945
|
+
var import_lodash2 = require("lodash");
|
|
65946
|
+
var Flag = class _Flag {
|
|
65947
|
+
constructor(defaultValue) {
|
|
65948
|
+
this.defaultValue = defaultValue;
|
|
65959
65949
|
}
|
|
65960
|
-
|
|
65961
|
-
|
|
65962
|
-
throw new Error(`Feature: ${feature} is not an allowed option`);
|
|
65963
|
-
}
|
|
65964
|
-
}
|
|
65965
|
-
return list;
|
|
65966
|
-
}
|
|
65967
|
-
|
|
65968
|
-
// src/features/index.ts
|
|
65969
|
-
function buildFeatureFlags() {
|
|
65970
|
-
if (!environment_default.TENANT_FEATURE_FLAGS) {
|
|
65971
|
-
return;
|
|
65950
|
+
static withDefault(value) {
|
|
65951
|
+
return new _Flag(value);
|
|
65972
65952
|
}
|
|
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);
|
|
65953
|
+
};
|
|
65954
|
+
var FLAGS = {
|
|
65955
|
+
LICENSING: Flag.withDefault(false),
|
|
65956
|
+
GOOGLE_SHEETS: Flag.withDefault(false),
|
|
65957
|
+
USER_GROUPS: Flag.withDefault(false),
|
|
65958
|
+
ONBOARDING_TOUR: Flag.withDefault(false)
|
|
65959
|
+
};
|
|
65960
|
+
var DEFAULTS = Object.keys(FLAGS).reduce((acc, key) => {
|
|
65961
|
+
const typedKey = key;
|
|
65962
|
+
acc[typedKey] = FLAGS[typedKey].defaultValue;
|
|
65963
|
+
return acc;
|
|
65964
|
+
}, {});
|
|
65965
|
+
function defaultFlags() {
|
|
65966
|
+
return (0, import_lodash2.cloneDeep)(DEFAULTS);
|
|
65967
|
+
}
|
|
65968
|
+
function isFlagName(name) {
|
|
65969
|
+
return FLAGS[name] !== void 0;
|
|
65970
|
+
}
|
|
65971
|
+
async function fetch6() {
|
|
65972
|
+
const currentTenantId = getTenantId();
|
|
65973
|
+
const flags = defaultFlags();
|
|
65974
|
+
const split = (environment_default.TENANT_FEATURE_FLAGS || "").split(",").map((x) => x.split(":"));
|
|
65975
|
+
for (const [tenantId, ...features] of split) {
|
|
65976
|
+
if (!tenantId || tenantId !== "*" && tenantId !== currentTenantId) {
|
|
65977
|
+
continue;
|
|
66008
65978
|
}
|
|
66009
|
-
|
|
66010
|
-
|
|
65979
|
+
for (let feature of features) {
|
|
65980
|
+
let value = true;
|
|
65981
|
+
if (feature.startsWith("!")) {
|
|
65982
|
+
feature = feature.slice(1);
|
|
65983
|
+
value = false;
|
|
65984
|
+
}
|
|
65985
|
+
if (!isFlagName(feature)) {
|
|
65986
|
+
throw new Error(`Feature: ${feature} is not an allowed option`);
|
|
65987
|
+
}
|
|
65988
|
+
if (typeof flags[feature] !== "boolean") {
|
|
65989
|
+
throw new Error(`Feature: ${feature} is not a boolean`);
|
|
65990
|
+
}
|
|
65991
|
+
flags[feature] = value;
|
|
66011
65992
|
}
|
|
66012
|
-
flags = flags.filter((flag) => {
|
|
66013
|
-
return tenantOverrides.indexOf(flag) == -1 && !flag.startsWith("!");
|
|
66014
|
-
});
|
|
66015
65993
|
}
|
|
66016
65994
|
return flags;
|
|
66017
65995
|
}
|
|
66018
|
-
|
|
66019
|
-
|
|
66020
|
-
|
|
66021
|
-
|
|
66022
|
-
|
|
66023
|
-
|
|
66024
|
-
|
|
65996
|
+
async function get4(name) {
|
|
65997
|
+
const flags = await fetch6();
|
|
65998
|
+
return flags[name];
|
|
65999
|
+
}
|
|
66000
|
+
async function isEnabled(name) {
|
|
66001
|
+
const flags = await fetch6();
|
|
66002
|
+
return flags[name];
|
|
66003
|
+
}
|
|
66025
66004
|
|
|
66026
66005
|
// src/auth/index.ts
|
|
66027
66006
|
var auth_exports = {};
|
|
@@ -68686,7 +68665,6 @@ var init9 = (opts = {}) => {
|
|
|
68686
68665
|
env,
|
|
68687
68666
|
errors,
|
|
68688
68667
|
events,
|
|
68689
|
-
featureFlags,
|
|
68690
68668
|
features,
|
|
68691
68669
|
getPublicError,
|
|
68692
68670
|
init,
|