feat(records): implement native eAkte vertical
This commit is contained in:
@@ -0,0 +1,184 @@
|
||||
import { apiFetch, apiPath, type ApiSettings } from "@govoplan/core-webui";
|
||||
|
||||
|
||||
export type FilePlanNode = {
|
||||
node_id: string;
|
||||
revision: number;
|
||||
parent_node_id?: string | null;
|
||||
code: string;
|
||||
label: string;
|
||||
description?: string | null;
|
||||
active: boolean;
|
||||
valid_from?: string | null;
|
||||
valid_to?: string | null;
|
||||
recorded_at: string;
|
||||
institutional_context: Record<string, unknown>;
|
||||
};
|
||||
|
||||
export type RecordClass = {
|
||||
class_id: string;
|
||||
revision: number;
|
||||
file_plan_node_id: string;
|
||||
key: string;
|
||||
label: string;
|
||||
description?: string | null;
|
||||
metadata_requirements: string[];
|
||||
allowed_source_types: string[];
|
||||
retention_period_days?: number | null;
|
||||
closure_trigger?: string | null;
|
||||
access_mode: "tenant" | "restricted";
|
||||
active: boolean;
|
||||
};
|
||||
|
||||
export type RecordCatalog = {
|
||||
file_plan: FilePlanNode[];
|
||||
classes: RecordClass[];
|
||||
};
|
||||
|
||||
export type RecordEntry = {
|
||||
record_id: string;
|
||||
record_number: string;
|
||||
revision: number;
|
||||
class_id: string;
|
||||
file_plan_node_id: string;
|
||||
title: string;
|
||||
description?: string | null;
|
||||
state: "planned" | "open" | string;
|
||||
source_authority_mode: string;
|
||||
access_mode: "tenant" | "restricted";
|
||||
purpose: string;
|
||||
classification?: string | null;
|
||||
responsible_unit_id?: string | null;
|
||||
responsible_function_id?: string | null;
|
||||
external_reference: Record<string, unknown>;
|
||||
institutional_context: Record<string, unknown>;
|
||||
valid_from?: string | null;
|
||||
valid_to?: string | null;
|
||||
recorded_at: string;
|
||||
};
|
||||
|
||||
export type RecordVolume = {
|
||||
volume_id: string;
|
||||
sequence: number;
|
||||
label: string;
|
||||
state: string;
|
||||
recorded_at: string;
|
||||
};
|
||||
|
||||
export type RecordItem = {
|
||||
item_id: string;
|
||||
sequence: number;
|
||||
volume_id?: string | null;
|
||||
source: {
|
||||
source_module: string;
|
||||
resource_type: string;
|
||||
resource_id: string;
|
||||
source_revision: string;
|
||||
};
|
||||
label: string;
|
||||
relationship: string;
|
||||
filing_reason: string;
|
||||
purpose: string;
|
||||
authority_mode: string;
|
||||
content_sha256?: string | null;
|
||||
content_type?: string | null;
|
||||
size_bytes?: number | null;
|
||||
launch_url?: string | null;
|
||||
filed_at: string;
|
||||
filed_by?: string | null;
|
||||
};
|
||||
|
||||
export type RecordChronology = {
|
||||
event_id: string;
|
||||
event_type: string;
|
||||
record_revision: number;
|
||||
summary: string;
|
||||
occurred_at: string;
|
||||
actor_id?: string | null;
|
||||
purpose: string;
|
||||
payload: Record<string, unknown>;
|
||||
};
|
||||
|
||||
export type RecordDetail = {
|
||||
record: RecordEntry;
|
||||
volumes: RecordVolume[];
|
||||
items: RecordItem[];
|
||||
chronology: RecordChronology[];
|
||||
access_explanation: {
|
||||
decision: string;
|
||||
reason: string;
|
||||
purpose: string;
|
||||
current_authorization: boolean;
|
||||
access_mode: string;
|
||||
limitations: string[];
|
||||
};
|
||||
};
|
||||
|
||||
export type RecordSourceProvider = {
|
||||
id: string;
|
||||
source_module: string;
|
||||
resource_types: string[];
|
||||
};
|
||||
|
||||
export function listRecords(
|
||||
settings: ApiSettings,
|
||||
options: {
|
||||
query?: string;
|
||||
state?: string;
|
||||
classId?: string;
|
||||
filePlanNodeId?: string;
|
||||
offset?: number;
|
||||
limit?: number;
|
||||
},
|
||||
signal?: AbortSignal
|
||||
): Promise<{ records: RecordEntry[]; total: number; offset: number; limit: number }> {
|
||||
return apiFetch(settings, apiPath("/api/v1/records", {
|
||||
query: options.query,
|
||||
state: options.state,
|
||||
class_id: options.classId,
|
||||
file_plan_node_id: options.filePlanNodeId,
|
||||
offset: options.offset,
|
||||
limit: options.limit ?? 50
|
||||
}), { signal });
|
||||
}
|
||||
|
||||
export function getRecord(settings: ApiSettings, recordId: string, signal?: AbortSignal): Promise<RecordDetail> {
|
||||
return apiFetch(settings, `/api/v1/records/${encodeURIComponent(recordId)}`, { signal });
|
||||
}
|
||||
|
||||
export function getRecordCatalog(settings: ApiSettings, signal?: AbortSignal): Promise<RecordCatalog> {
|
||||
return apiFetch(settings, "/api/v1/records/catalog", { signal });
|
||||
}
|
||||
|
||||
export function getRecordSources(settings: ApiSettings, signal?: AbortSignal): Promise<{ providers: RecordSourceProvider[] }> {
|
||||
return apiFetch(settings, "/api/v1/records/sources", { signal });
|
||||
}
|
||||
|
||||
export function createRecord(settings: ApiSettings, payload: Record<string, unknown>): Promise<RecordEntry> {
|
||||
return apiFetch(settings, "/api/v1/records", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
}
|
||||
|
||||
export function updateRecord(
|
||||
settings: ApiSettings,
|
||||
recordId: string,
|
||||
payload: Record<string, unknown>
|
||||
): Promise<RecordEntry> {
|
||||
return apiFetch(settings, `/api/v1/records/${encodeURIComponent(recordId)}`, {
|
||||
method: "PATCH",
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
}
|
||||
|
||||
export function fileRecordItem(
|
||||
settings: ApiSettings,
|
||||
recordId: string,
|
||||
payload: Record<string, unknown>
|
||||
): Promise<Record<string, unknown>> {
|
||||
return apiFetch(settings, `/api/v1/records/${encodeURIComponent(recordId)}/items`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user