chore: sync GovOPlaN module split state
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { ApiSettings } from "@govoplan/core-webui";
|
||||
import type { ApiSettings, DeltaDeletedItem } from "@govoplan/core-webui";
|
||||
import { apiFetch } from "@govoplan/core-webui";
|
||||
|
||||
export type PermissionItem = {
|
||||
@@ -75,6 +75,12 @@ export type MaintenanceMode = {
|
||||
message?: string | null;
|
||||
};
|
||||
|
||||
export type LanguagePackage = {
|
||||
code: string;
|
||||
label: string;
|
||||
native_label?: string | null;
|
||||
};
|
||||
|
||||
export type SystemSettingsItem = {
|
||||
default_locale: string;
|
||||
allow_tenant_custom_groups: boolean;
|
||||
@@ -82,9 +88,20 @@ export type SystemSettingsItem = {
|
||||
allow_tenant_api_keys: boolean;
|
||||
privacy_retention_policy: PrivacyRetentionPolicy;
|
||||
maintenance_mode: MaintenanceMode;
|
||||
available_languages: LanguagePackage[];
|
||||
enabled_language_codes: string[];
|
||||
settings: Record<string, unknown>;
|
||||
};
|
||||
|
||||
export type SystemSettingsDeltaSections = Partial<{
|
||||
defaults: Pick<SystemSettingsItem, "default_locale">;
|
||||
tenant_capabilities: Pick<SystemSettingsItem, "allow_tenant_custom_groups" | "allow_tenant_custom_roles" | "allow_tenant_api_keys">;
|
||||
languages: Pick<SystemSettingsItem, "available_languages" | "enabled_language_codes">;
|
||||
privacy_retention_policy: SystemSettingsItem["privacy_retention_policy"];
|
||||
maintenance_mode: SystemSettingsItem["maintenance_mode"];
|
||||
settings: SystemSettingsItem["settings"];
|
||||
}>;
|
||||
|
||||
export type SystemSettingsUpdatePayload = {
|
||||
default_locale: string;
|
||||
allow_tenant_custom_groups: boolean;
|
||||
@@ -92,8 +109,106 @@ export type SystemSettingsUpdatePayload = {
|
||||
allow_tenant_api_keys: boolean;
|
||||
privacy_retention_policy?: PrivacyRetentionPolicy | null;
|
||||
maintenance_mode?: MaintenanceMode | null;
|
||||
available_languages?: LanguagePackage[] | null;
|
||||
enabled_language_codes?: string[] | null;
|
||||
change_request_id?: string | null;
|
||||
};
|
||||
|
||||
export type ConfigurationChangeRequest = {
|
||||
id: string;
|
||||
key: string;
|
||||
label?: string;
|
||||
target?: Record<string, unknown>;
|
||||
dry_run: boolean;
|
||||
requested_by: string;
|
||||
requested_at: string;
|
||||
updated_at: string;
|
||||
status: string;
|
||||
approvals: Array<Record<string, unknown>>;
|
||||
plan: Record<string, unknown>;
|
||||
value_preview?: unknown;
|
||||
};
|
||||
|
||||
export type ConfigurationChangeRecord = {
|
||||
id: string;
|
||||
version: number;
|
||||
key: string;
|
||||
target?: Record<string, unknown>;
|
||||
actor_user_id: string;
|
||||
approval_request_id?: string | null;
|
||||
approval_user_ids: string[];
|
||||
before?: unknown;
|
||||
after?: unknown;
|
||||
rollback_value?: unknown;
|
||||
status: string;
|
||||
created_at: string;
|
||||
};
|
||||
|
||||
export type ConfigurationPackageDiagnostic = {
|
||||
severity: "blocker" | "warning" | "info";
|
||||
code: string;
|
||||
message: string;
|
||||
module_id?: string | null;
|
||||
object_ref?: string | null;
|
||||
resolution?: string | null;
|
||||
};
|
||||
|
||||
export type ConfigurationPackageRequiredData = {
|
||||
key: string;
|
||||
label: string;
|
||||
data_type: string;
|
||||
required: boolean;
|
||||
secret: boolean;
|
||||
description?: string | null;
|
||||
};
|
||||
|
||||
export type ConfigurationPackagePlanItem = {
|
||||
action: "create" | "update" | "bind" | "skip" | "blocked" | "noop";
|
||||
module_id: string;
|
||||
fragment_type: string;
|
||||
fragment_id?: string | null;
|
||||
summary?: string | null;
|
||||
};
|
||||
|
||||
export type ConfigurationPackageFragment = {
|
||||
module_id: string;
|
||||
fragment_type: string;
|
||||
fragment_id?: string | null;
|
||||
payload: Record<string, unknown>;
|
||||
};
|
||||
|
||||
export type ConfigurationPackageRunPayload = {
|
||||
package: Record<string, unknown>;
|
||||
tenant_id?: string | null;
|
||||
supplied_data?: Record<string, unknown>;
|
||||
change_request_id?: string | null;
|
||||
};
|
||||
|
||||
type DeltaResponseFields = {
|
||||
deleted: DeltaDeletedItem[];
|
||||
watermark?: string | null;
|
||||
has_more: boolean;
|
||||
full: boolean;
|
||||
};
|
||||
|
||||
function deltaSuffix(options: { since?: string | null; limit?: number } = {}): string {
|
||||
const params = new URLSearchParams();
|
||||
if (options.since) params.set("since", options.since);
|
||||
if (options.limit) params.set("limit", String(options.limit));
|
||||
return params.toString() ? `?${params.toString()}` : "";
|
||||
}
|
||||
|
||||
export type SystemSettingsDeltaResponse = {
|
||||
item?: SystemSettingsItem | null;
|
||||
sections: SystemSettingsDeltaSections;
|
||||
changed_sections: string[];
|
||||
} & DeltaResponseFields;
|
||||
|
||||
export type ConfigurationChangesDeltaResponse = {
|
||||
requests: ConfigurationChangeRequest[];
|
||||
history: ConfigurationChangeRecord[];
|
||||
} & DeltaResponseFields;
|
||||
|
||||
export type ModuleCatalogItem = {
|
||||
id: string;
|
||||
name: string;
|
||||
@@ -196,6 +311,9 @@ export type ModuleInstallerRunSummary = {
|
||||
status: string;
|
||||
started_at?: string | null;
|
||||
finished_at?: string | null;
|
||||
request_id?: string | null;
|
||||
requested_by?: string | null;
|
||||
trace?: Record<string, unknown> | null;
|
||||
rollback_status?: string | null;
|
||||
supervisor_status?: string | null;
|
||||
error?: string | null;
|
||||
@@ -207,6 +325,9 @@ export type ModuleInstallerRunSummary = {
|
||||
export type ModuleInstallerRunListResponse = {
|
||||
runs: ModuleInstallerRunSummary[];
|
||||
lock: ModuleInstallerLockStatus;
|
||||
cursor?: string | null;
|
||||
next_cursor?: string | null;
|
||||
full?: boolean;
|
||||
};
|
||||
|
||||
export type ModuleInstallerRequestOptions = {
|
||||
@@ -235,6 +356,7 @@ export type ModuleInstallerRequestItem = {
|
||||
cancelled_at?: string | null;
|
||||
cancelled_by?: string | null;
|
||||
retry_of?: string | null;
|
||||
trace?: Record<string, unknown> | null;
|
||||
error?: string | null;
|
||||
record_path?: string | null;
|
||||
options: Record<string, unknown>;
|
||||
@@ -243,6 +365,9 @@ export type ModuleInstallerRequestItem = {
|
||||
export type ModuleInstallerRequestListResponse = {
|
||||
requests: ModuleInstallerRequestItem[];
|
||||
daemon: ModuleInstallerDaemonStatus;
|
||||
cursor?: string | null;
|
||||
next_cursor?: string | null;
|
||||
full?: boolean;
|
||||
};
|
||||
|
||||
export type ModulePackageCatalogItem = {
|
||||
@@ -264,6 +389,27 @@ export type ModulePackageCatalogItem = {
|
||||
tags: string[];
|
||||
};
|
||||
|
||||
export type ModuleLicenseDiagnostics = {
|
||||
configured: boolean;
|
||||
valid: boolean;
|
||||
path?: string | null;
|
||||
license_id?: string | null;
|
||||
subject?: string | null;
|
||||
features: string[];
|
||||
valid_from?: string | null;
|
||||
valid_until?: string | null;
|
||||
signed: boolean;
|
||||
trusted: boolean;
|
||||
key_id?: string | null;
|
||||
enforced: boolean;
|
||||
allowed: boolean;
|
||||
required_features: string[];
|
||||
missing_features: string[];
|
||||
expires_in_days?: number | null;
|
||||
reason?: string | null;
|
||||
guidance: string[];
|
||||
};
|
||||
|
||||
export type ModulePackageCatalogResponse = {
|
||||
modules: ModulePackageCatalogItem[];
|
||||
configured: boolean;
|
||||
@@ -271,13 +417,17 @@ export type ModulePackageCatalogResponse = {
|
||||
path?: string | null;
|
||||
source?: string | null;
|
||||
source_type?: string | null;
|
||||
cache_used: boolean;
|
||||
cache_path?: string | null;
|
||||
channel?: string | null;
|
||||
sequence?: number | null;
|
||||
generated_at?: string | null;
|
||||
not_before?: string | null;
|
||||
expires_at?: string | null;
|
||||
signed: boolean;
|
||||
trusted: boolean;
|
||||
key_id?: string | null;
|
||||
license: ModuleLicenseDiagnostics;
|
||||
warnings: string[];
|
||||
error?: string | null;
|
||||
};
|
||||
@@ -319,6 +469,11 @@ export function fetchSystemSettings(settings: ApiSettings): Promise<SystemSettin
|
||||
return apiFetch(settings, "/api/v1/admin/system/settings");
|
||||
}
|
||||
|
||||
export function fetchSystemSettingsDelta(settings: ApiSettings, options: { since?: string | null; limit?: number } = {}): Promise<SystemSettingsDeltaResponse> {
|
||||
const suffix = deltaSuffix(options);
|
||||
return apiFetch(settings, `/api/v1/admin/system/settings/delta${suffix}`);
|
||||
}
|
||||
|
||||
export function updateSystemSettings(settings: ApiSettings, payload: SystemSettingsUpdatePayload): Promise<SystemSettingsItem> {
|
||||
return apiFetch(settings, "/api/v1/admin/system/settings", { method: "PATCH", body: JSON.stringify(payload) });
|
||||
}
|
||||
@@ -327,10 +482,10 @@ export function fetchModuleCatalog(settings: ApiSettings): Promise<ModuleCatalog
|
||||
return apiFetch(settings, "/api/v1/admin/system/modules");
|
||||
}
|
||||
|
||||
export function updateModuleState(settings: ApiSettings, enabledModules: string[]): Promise<ModuleCatalogResponse> {
|
||||
export function updateModuleState(settings: ApiSettings, enabledModules: string[], changeRequestId?: string | null): Promise<ModuleCatalogResponse> {
|
||||
return apiFetch(settings, "/api/v1/admin/system/modules", {
|
||||
method: "PUT",
|
||||
body: JSON.stringify({ enabled_modules: enabledModules })
|
||||
body: JSON.stringify({ enabled_modules: enabledModules, change_request_id: changeRequestId ?? null })
|
||||
});
|
||||
}
|
||||
|
||||
@@ -338,12 +493,20 @@ export function fetchModuleInstallPlan(settings: ApiSettings): Promise<ModuleIns
|
||||
return apiFetch(settings, "/api/v1/admin/system/modules/install-plan");
|
||||
}
|
||||
|
||||
export function fetchModuleInstallerRuns(settings: ApiSettings): Promise<ModuleInstallerRunListResponse> {
|
||||
return apiFetch(settings, "/api/v1/admin/system/modules/install-runs");
|
||||
export function fetchModuleInstallerRuns(settings: ApiSettings, options: { page_size?: number; cursor?: string | null } = {}): Promise<ModuleInstallerRunListResponse> {
|
||||
const params = new URLSearchParams();
|
||||
if (options.page_size) params.set("page_size", String(options.page_size));
|
||||
if (options.cursor) params.set("cursor", options.cursor);
|
||||
const suffix = params.toString() ? `?${params.toString()}` : "";
|
||||
return apiFetch(settings, `/api/v1/admin/system/modules/install-runs${suffix}`);
|
||||
}
|
||||
|
||||
export function fetchModuleInstallerRequests(settings: ApiSettings): Promise<ModuleInstallerRequestListResponse> {
|
||||
return apiFetch(settings, "/api/v1/admin/system/modules/install-requests");
|
||||
export function fetchModuleInstallerRequests(settings: ApiSettings, options: { page_size?: number; cursor?: string | null } = {}): Promise<ModuleInstallerRequestListResponse> {
|
||||
const params = new URLSearchParams();
|
||||
if (options.page_size) params.set("page_size", String(options.page_size));
|
||||
if (options.cursor) params.set("cursor", options.cursor);
|
||||
const suffix = params.toString() ? `?${params.toString()}` : "";
|
||||
return apiFetch(settings, `/api/v1/admin/system/modules/install-requests${suffix}`);
|
||||
}
|
||||
|
||||
export function createModuleInstallerRequest(settings: ApiSettings, options: ModuleInstallerRequestOptions): Promise<ModuleInstallerRequestItem> {
|
||||
@@ -373,10 +536,10 @@ export function planModuleUninstall(settings: ApiSettings, moduleId: string): Pr
|
||||
return apiFetch(settings, `/api/v1/admin/system/modules/${encodeURIComponent(moduleId)}/uninstall-plan`, { method: "POST" });
|
||||
}
|
||||
|
||||
export function updateModuleInstallPlan(settings: ApiSettings, items: ModuleInstallPlanItem[]): Promise<ModuleInstallPlanResponse> {
|
||||
export function updateModuleInstallPlan(settings: ApiSettings, items: ModuleInstallPlanItem[], changeRequestId?: string | null): Promise<ModuleInstallPlanResponse> {
|
||||
return apiFetch(settings, "/api/v1/admin/system/modules/install-plan", {
|
||||
method: "PUT",
|
||||
body: JSON.stringify({ items })
|
||||
body: JSON.stringify({ items, change_request_id: changeRequestId ?? null })
|
||||
});
|
||||
}
|
||||
|
||||
@@ -390,14 +553,88 @@ export async function fetchGovernanceTemplates(settings: ApiSettings, kind?: "gr
|
||||
return response.templates;
|
||||
}
|
||||
|
||||
export function createGovernanceTemplate(settings: ApiSettings, payload: Omit<GovernanceTemplateItem, "id" | "created_at" | "updated_at" | "effective_permission_count">): Promise<GovernanceTemplateItem> {
|
||||
export function createGovernanceTemplate(settings: ApiSettings, payload: Omit<GovernanceTemplateItem, "id" | "created_at" | "updated_at" | "effective_permission_count"> & { change_request_id?: string | null }): Promise<GovernanceTemplateItem> {
|
||||
return apiFetch(settings, "/api/v1/admin/system/governance-templates", { method: "POST", body: JSON.stringify(payload) });
|
||||
}
|
||||
|
||||
export function updateGovernanceTemplate(settings: ApiSettings, templateId: string, payload: Omit<GovernanceTemplateItem, "id" | "kind" | "slug" | "created_at" | "updated_at" | "effective_permission_count">): Promise<GovernanceTemplateItem> {
|
||||
export function updateGovernanceTemplate(settings: ApiSettings, templateId: string, payload: Omit<GovernanceTemplateItem, "id" | "kind" | "slug" | "created_at" | "updated_at" | "effective_permission_count"> & { change_request_id?: string | null }): Promise<GovernanceTemplateItem> {
|
||||
return apiFetch(settings, `/api/v1/admin/system/governance-templates/${templateId}`, { method: "PATCH", body: JSON.stringify(payload) });
|
||||
}
|
||||
|
||||
export function deleteGovernanceTemplate(settings: ApiSettings, templateId: string): Promise<void> {
|
||||
return apiFetch(settings, `/api/v1/admin/system/governance-templates/${templateId}`, { method: "DELETE" });
|
||||
export function deleteGovernanceTemplate(settings: ApiSettings, templateId: string, changeRequestId?: string | null): Promise<void> {
|
||||
const suffix = changeRequestId ? `?change_request_id=${encodeURIComponent(changeRequestId)}` : "";
|
||||
return apiFetch(settings, `/api/v1/admin/system/governance-templates/${templateId}${suffix}`, { method: "DELETE" });
|
||||
}
|
||||
|
||||
export function fetchConfigurationChanges(settings: ApiSettings): Promise<{ requests: ConfigurationChangeRequest[]; history: ConfigurationChangeRecord[] }> {
|
||||
return apiFetch(settings, "/api/v1/admin/configuration-changes");
|
||||
}
|
||||
|
||||
export function fetchConfigurationChangesDelta(settings: ApiSettings, options: { since?: string | null; limit?: number } = {}): Promise<ConfigurationChangesDeltaResponse> {
|
||||
const suffix = deltaSuffix(options);
|
||||
return apiFetch(settings, `/api/v1/admin/configuration-changes/delta${suffix}`);
|
||||
}
|
||||
|
||||
export async function createConfigurationChangeRequest(settings: ApiSettings, payload: {
|
||||
key: string;
|
||||
value?: unknown;
|
||||
dry_run?: boolean;
|
||||
target?: Record<string, unknown>;
|
||||
reason?: string | null;
|
||||
}): Promise<ConfigurationChangeRequest> {
|
||||
const response = await apiFetch<{ request: ConfigurationChangeRequest }>(settings, "/api/v1/admin/configuration-change-requests", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
return response.request;
|
||||
}
|
||||
|
||||
export async function approveConfigurationChangeRequest(settings: ApiSettings, requestId: string, reason?: string | null): Promise<ConfigurationChangeRequest> {
|
||||
const response = await apiFetch<{ request: ConfigurationChangeRequest }>(settings, `/api/v1/admin/configuration-change-requests/${encodeURIComponent(requestId)}/approve`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ reason: reason ?? null })
|
||||
});
|
||||
return response.request;
|
||||
}
|
||||
|
||||
export function fetchConfigurationPackageCatalogValidation(settings: ApiSettings): Promise<{ validation: Record<string, unknown> }> {
|
||||
return apiFetch(settings, "/api/v1/admin/configuration-packages/catalog");
|
||||
}
|
||||
|
||||
export function dryRunConfigurationPackage(settings: ApiSettings, payload: ConfigurationPackageRunPayload): Promise<{
|
||||
diagnostics: ConfigurationPackageDiagnostic[];
|
||||
required_data: ConfigurationPackageRequiredData[];
|
||||
plan: ConfigurationPackagePlanItem[];
|
||||
}> {
|
||||
return apiFetch(settings, "/api/v1/admin/configuration-packages/dry-run", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
}
|
||||
|
||||
export function applyConfigurationPackage(settings: ApiSettings, payload: ConfigurationPackageRunPayload): Promise<{
|
||||
diagnostics: ConfigurationPackageDiagnostic[];
|
||||
created_refs: Record<string, string>;
|
||||
updated_refs: Record<string, string>;
|
||||
}> {
|
||||
return apiFetch(settings, "/api/v1/admin/configuration-packages/apply", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
}
|
||||
|
||||
export function exportConfigurationPackage(settings: ApiSettings, payload: {
|
||||
tenant_id?: string | null;
|
||||
scopes?: string[];
|
||||
module_ids?: string[];
|
||||
object_refs?: string[];
|
||||
}): Promise<{
|
||||
fragments: ConfigurationPackageFragment[];
|
||||
data_requirements: ConfigurationPackageRequiredData[];
|
||||
diagnostics: ConfigurationPackageDiagnostic[];
|
||||
}> {
|
||||
return apiFetch(settings, "/api/v1/admin/configuration-packages/export", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user