Quick PR comments.
This commit is contained in:
parent
4c6c0f3002
commit
ba5e390b3f
|
@ -1,5 +1,6 @@
|
||||||
import env from "../environment"
|
import env from "../environment"
|
||||||
import * as context from "../context"
|
import * as context from "../context"
|
||||||
|
export * from "./installation"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read the TENANT_FEATURE_FLAGS env var and return an array of features flags for each tenant.
|
* Read the TENANT_FEATURE_FLAGS env var and return an array of features flags for each tenant.
|
|
@ -0,0 +1,17 @@
|
||||||
|
export function processFeatureEnvVar<T>(
|
||||||
|
fullList: string[],
|
||||||
|
featureList?: string
|
||||||
|
) {
|
||||||
|
let list
|
||||||
|
if (!featureList) {
|
||||||
|
list = fullList
|
||||||
|
} else {
|
||||||
|
list = featureList.split(",")
|
||||||
|
}
|
||||||
|
for (let feature of list) {
|
||||||
|
if (!fullList.includes(feature)) {
|
||||||
|
throw new Error(`Feature: ${feature} is not an allowed option`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list as unknown as T[]
|
||||||
|
}
|
|
@ -6,7 +6,8 @@ export * as roles from "./security/roles"
|
||||||
export * as permissions from "./security/permissions"
|
export * as permissions from "./security/permissions"
|
||||||
export * as accounts from "./accounts"
|
export * as accounts from "./accounts"
|
||||||
export * as installation from "./installation"
|
export * as installation from "./installation"
|
||||||
export * as featureFlags from "./featureFlags"
|
export * as featureFlags from "./features"
|
||||||
|
export * as features from "./features/installation"
|
||||||
export * as sessions from "./security/sessions"
|
export * as sessions from "./security/sessions"
|
||||||
export * as platform from "./platform"
|
export * as platform from "./platform"
|
||||||
export * as auth from "./auth"
|
export * as auth from "./auth"
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { features } from "@budibase/backend-core"
|
||||||
import env from "./environment"
|
import env from "./environment"
|
||||||
|
|
||||||
enum AppFeature {
|
enum AppFeature {
|
||||||
|
@ -5,23 +6,10 @@ enum AppFeature {
|
||||||
AUTOMATIONS = "automations",
|
AUTOMATIONS = "automations",
|
||||||
}
|
}
|
||||||
|
|
||||||
const featureList = processFeatureList()
|
const featureList = features.processFeatureEnvVar<AppFeature>(
|
||||||
|
Object.keys(AppFeature),
|
||||||
function processFeatureList() {
|
env.APP_FEATURES
|
||||||
const fullList = Object.values(AppFeature) as string[]
|
)
|
||||||
let list
|
|
||||||
if (!env.APP_FEATURES) {
|
|
||||||
list = fullList
|
|
||||||
} else {
|
|
||||||
list = env.APP_FEATURES.split(",")
|
|
||||||
}
|
|
||||||
for (let feature of list) {
|
|
||||||
if (!fullList.includes(feature)) {
|
|
||||||
throw new Error(`Feature: ${feature} is not an allowed option`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return list
|
|
||||||
}
|
|
||||||
|
|
||||||
export function isFeatureEnabled(feature: AppFeature) {
|
export function isFeatureEnabled(feature: AppFeature) {
|
||||||
return featureList.includes(feature)
|
return featureList.includes(feature)
|
||||||
|
|
|
@ -1,25 +1,12 @@
|
||||||
|
import { features } from "@budibase/backend-core"
|
||||||
import env from "./environment"
|
import env from "./environment"
|
||||||
|
|
||||||
enum WorkerFeature {}
|
enum WorkerFeature {}
|
||||||
|
|
||||||
const featureList: WorkerFeature[] = processFeatureList()
|
const featureList: WorkerFeature[] = features.processFeatureEnvVar(
|
||||||
|
Object.values(WorkerFeature),
|
||||||
function processFeatureList() {
|
env.WORKER_FEATURES
|
||||||
const fullList = Object.values(WorkerFeature) as string[]
|
)
|
||||||
let list
|
|
||||||
if (!env.WORKER_FEATURES) {
|
|
||||||
list = fullList
|
|
||||||
} else {
|
|
||||||
list = env.WORKER_FEATURES.split(",")
|
|
||||||
}
|
|
||||||
for (let feature of list) {
|
|
||||||
if (!fullList.includes(feature)) {
|
|
||||||
throw new Error(`Feature: ${feature} is not an allowed option`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// casting ok - confirmed definitely is a list of worker features
|
|
||||||
return list as unknown as WorkerFeature[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export function isFeatureEnabled(feature: WorkerFeature) {
|
export function isFeatureEnabled(feature: WorkerFeature) {
|
||||||
return featureList.includes(feature)
|
return featureList.includes(feature)
|
||||||
|
|
Loading…
Reference in New Issue