* feat: add enabled column to UserFeatures and TeamFeatures for tri-state semantics - Add enabled Boolean column to UserFeatures model with default true - Add enabled Boolean column to TeamFeatures model with default true - Update FeaturesRepository to use tri-state semantics: - enabled=true: feature is explicitly enabled - enabled=false: feature is explicitly disabled (blocks inheritance) - No row: inherit from team/org level - Update SQL queries to check enabled=true for feature access - Add enableFeatureForTeam method to interface and implementation Co-Authored-By: eunjae@cal.com <hey@eunjae.dev> * update comments * add integration tests * add more test * select enabled only * no @default(true) * fix types and tests * add missing enabled * add missing enabled * rename enableFeatureForTeam to updateFeatureForTeam and support FeatureState * refactor: rename updateFeatureForTeam to setTeamFeatureState Co-Authored-By: eunjae@cal.com <hey@eunjae.dev> * fix integration test * fix tests * add more tests * add missing enabled --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
34 lines
919 B
TypeScript
34 lines
919 B
TypeScript
import type { AppFlags, FeatureState } from "./config";
|
|
import type { IFeaturesRepository } from "./features.repository.interface";
|
|
|
|
export class MockFeaturesRepository implements IFeaturesRepository {
|
|
async checkIfUserHasFeature(userId: number, slug: string) {
|
|
return slug === "mock-feature";
|
|
}
|
|
|
|
async checkIfUserHasFeatureNonHierarchical(userId: number, slug: string) {
|
|
return slug === "mock-feature";
|
|
}
|
|
|
|
async checkIfTeamHasFeature(teamId: number, slug: keyof AppFlags) {
|
|
return slug === "mock-feature";
|
|
}
|
|
|
|
async checkIfFeatureIsEnabledGlobally(_slug: keyof AppFlags) {
|
|
return true;
|
|
}
|
|
|
|
async getTeamsWithFeatureEnabled(_slug: keyof AppFlags): Promise<number[]> {
|
|
return [];
|
|
}
|
|
|
|
async setTeamFeatureState(
|
|
_teamId: number,
|
|
_featureId: keyof AppFlags,
|
|
_state: FeatureState,
|
|
_assignedBy: string
|
|
): Promise<void> {
|
|
// Mock implementation - do nothing
|
|
}
|
|
}
|