48 行
1.4 KiB
TypeScript
48 行
1.4 KiB
TypeScript
import { apiRequestData } from "./http";
|
|
|
|
export type FeatureFlagKey = "erp_sync" | "invoice_verification" | "leave_holiday_calendar";
|
|
export type FeatureFlagOverrideMode = "inherit" | "force_on" | "force_off";
|
|
export type FeatureFlagRolloutType = "global" | "department_allowlist";
|
|
|
|
export type FeatureFlagItem = {
|
|
id: string | null;
|
|
flagKey: FeatureFlagKey;
|
|
overrideMode: FeatureFlagOverrideMode;
|
|
rolloutType: FeatureFlagRolloutType;
|
|
departmentIds: string[];
|
|
note: string;
|
|
version: number;
|
|
createdAt: string | null;
|
|
createdBy: string | null;
|
|
updatedAt: string | null;
|
|
updatedBy: string | null;
|
|
envEnabled: boolean;
|
|
effectiveEnabled: boolean;
|
|
effectiveReason: string;
|
|
matchedDepartmentId: string | null;
|
|
requiresDepartment: boolean;
|
|
};
|
|
|
|
export type FeatureFlagListResponse = {
|
|
items: FeatureFlagItem[];
|
|
};
|
|
|
|
export type FeatureFlagUpdatePayload = {
|
|
overrideMode: FeatureFlagOverrideMode;
|
|
rolloutType: FeatureFlagRolloutType;
|
|
departmentIds: string[];
|
|
note: string;
|
|
expectedVersion: number;
|
|
};
|
|
|
|
export async function fetchFeatureFlags() {
|
|
return apiRequestData<FeatureFlagListResponse>("/api/system/feature-flags");
|
|
}
|
|
|
|
export async function updateFeatureFlag(flagKey: FeatureFlagKey, payload: FeatureFlagUpdatePayload) {
|
|
return apiRequestData<{ item: FeatureFlagItem }>(`/api/system/feature-flags/${flagKey}`, {
|
|
method: "PUT",
|
|
body: JSON.stringify(payload),
|
|
});
|
|
}
|