Add tenant module entitlement administration
This commit is contained in:
@@ -186,6 +186,42 @@ export type ModuleCatalogResponse = {
|
||||
notes: string[];
|
||||
};
|
||||
|
||||
export type TenantModuleAvailability = "unavailable" | "available" | "forced";
|
||||
|
||||
export type TenantModuleEntitlementItem = {
|
||||
id: string;
|
||||
name: string;
|
||||
dependencies: string[];
|
||||
runtime_active: boolean;
|
||||
availability: TenantModuleAvailability;
|
||||
selected: boolean;
|
||||
effective: boolean;
|
||||
forced: boolean;
|
||||
derived_dependency: boolean;
|
||||
tenant_can_toggle: boolean;
|
||||
reason?: string | null;
|
||||
};
|
||||
|
||||
export type TenantModuleEntitlementResponse = {
|
||||
tenant_id: string;
|
||||
revision: number;
|
||||
configured: boolean;
|
||||
available_modules: string[];
|
||||
forced_modules: string[];
|
||||
selected_modules: string[];
|
||||
effective_modules: string[];
|
||||
derived_dependencies: string[];
|
||||
modules: TenantModuleEntitlementItem[];
|
||||
diagnostics: Array<{ code: string; message: string; severity: string }>;
|
||||
};
|
||||
|
||||
export type TenantModuleTarget = {
|
||||
id: string;
|
||||
slug: string;
|
||||
name: string;
|
||||
is_active: boolean;
|
||||
};
|
||||
|
||||
export type ModuleInstallPlanItem = {
|
||||
module_id: string;
|
||||
action: "install" | "update" | "uninstall";
|
||||
@@ -504,6 +540,46 @@ export function updateModuleState(settings: ApiSettings, enabledModules: string[
|
||||
});
|
||||
}
|
||||
|
||||
export function fetchSystemTenantModules(settings: ApiSettings, tenantId: string): Promise<TenantModuleEntitlementResponse> {
|
||||
return apiFetch(settings, `/api/v1/admin/system/tenants/${encodeURIComponent(tenantId)}/modules`);
|
||||
}
|
||||
|
||||
export async function fetchTenantModuleTargets(settings: ApiSettings): Promise<TenantModuleTarget[]> {
|
||||
const response = await apiFetch<{ tenants: TenantModuleTarget[] }>(settings, "/api/v1/admin/system/tenant-module-targets");
|
||||
return response.tenants;
|
||||
}
|
||||
|
||||
export function updateSystemTenantModules(
|
||||
settings: ApiSettings,
|
||||
tenantId: string,
|
||||
payload: {
|
||||
available_modules: string[];
|
||||
forced_modules: string[];
|
||||
enabled_modules: string[];
|
||||
expected_revision: number;
|
||||
change_request_id?: string | null;
|
||||
}
|
||||
): Promise<TenantModuleEntitlementResponse> {
|
||||
return apiFetch(settings, `/api/v1/admin/system/tenants/${encodeURIComponent(tenantId)}/modules`, {
|
||||
method: "PUT",
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
}
|
||||
|
||||
export function fetchTenantModules(settings: ApiSettings): Promise<TenantModuleEntitlementResponse> {
|
||||
return apiFetch(settings, "/api/v1/admin/tenant/modules");
|
||||
}
|
||||
|
||||
export function updateTenantModules(
|
||||
settings: ApiSettings,
|
||||
payload: { enabled_modules: string[]; expected_revision: number }
|
||||
): Promise<TenantModuleEntitlementResponse> {
|
||||
return apiFetch(settings, "/api/v1/admin/tenant/modules", {
|
||||
method: "PUT",
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
}
|
||||
|
||||
export function fetchModuleInstallPlan(settings: ApiSettings): Promise<ModuleInstallPlanResponse> {
|
||||
return apiFetch(settings, "/api/v1/admin/system/modules/install-plan");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user