nitin
2025-01-21 19:00:59 +05:30
committed by GitHub
parent 86b0a7952b
commit 50f36e345e
31 changed files with 710 additions and 6 deletions

View File

@ -1,3 +1,5 @@
import { FeatureFlagKey } from 'src/engine/core-modules/feature-flag/enums/feature-flag-key.enum';
import { isPublicFeatureFlag } from 'src/engine/core-modules/lab/utils/is-public-feature-flag.util';
import { TypedReflect } from 'src/utils/typed-reflect';
export interface WorkspaceGateOptions {
@ -5,6 +7,15 @@ export interface WorkspaceGateOptions {
}
export function WorkspaceGate(options: WorkspaceGateOptions) {
const flagKey = options.featureFlag as FeatureFlagKey;
if (isPublicFeatureFlag(flagKey)) {
throw new Error(
`Public feature flag "${flagKey}" cannot be used to gate entities. ` +
'Public flags should not be used for entity gating as they can be toggled by users.',
);
}
return (target: any, propertyKey?: string | symbol) => {
if (propertyKey !== undefined) {
TypedReflect.defineMetadata(