168 lines
6.3 KiB
TypeScript
168 lines
6.3 KiB
TypeScript
export type VMStatus = "idle" | "loading" | "ready" | "empty" | "error";
|
|
|
|
export type VMState<T> =
|
|
| { status: "idle"; data?: undefined; error?: undefined }
|
|
| { status: "loading"; data?: T; error?: undefined }
|
|
| { status: "ready"; data: T; error?: undefined }
|
|
| { status: "empty"; data?: undefined; error?: undefined }
|
|
| { status: "error"; data?: T; error: { messageKey: string; code?: string } };
|
|
|
|
export type ActionCallbacks<T> = {
|
|
readonly onCreate?: (draft?: Partial<T>) => void | Promise<void>;
|
|
readonly onUpdate?: (item: T) => void | Promise<void>;
|
|
readonly onDelete?: (item: T) => void | Promise<void>;
|
|
readonly onRefresh?: () => void | Promise<void>;
|
|
};
|
|
|
|
export type I18nLabel = {
|
|
readonly labelKey: string;
|
|
readonly descriptionKey?: string;
|
|
};
|
|
|
|
export type RegistryGate = {
|
|
readonly permission?: string;
|
|
readonly flag?: string;
|
|
};
|
|
|
|
export type SidebarRegistryItem = I18nLabel &
|
|
RegistryGate & {
|
|
readonly id: string;
|
|
readonly href: string;
|
|
readonly icon?: string;
|
|
readonly children?: readonly SidebarRegistryItem[];
|
|
};
|
|
|
|
export type BreadcrumbRegistryItem = I18nLabel &
|
|
RegistryGate & {
|
|
readonly id: string;
|
|
readonly href?: string;
|
|
};
|
|
|
|
export type MobileRegistryItem = I18nLabel &
|
|
RegistryGate & {
|
|
readonly id: string;
|
|
readonly href: string;
|
|
readonly priority?: number;
|
|
};
|
|
|
|
export type PortalRegistryItem = I18nLabel &
|
|
RegistryGate & {
|
|
readonly id: string;
|
|
readonly slot: string;
|
|
readonly order?: number;
|
|
};
|
|
|
|
export type ShellRegistries = {
|
|
readonly sidebar?: readonly SidebarRegistryItem[];
|
|
readonly breadcrumbs?: readonly BreadcrumbRegistryItem[];
|
|
readonly mobile?: readonly MobileRegistryItem[];
|
|
readonly portals?: readonly PortalRegistryItem[];
|
|
};
|
|
|
|
// --- Subframe-Adapter contract (M015) ---
|
|
/** Swappable UI implementation: renders a serializable component model to HTML. */
|
|
export type UiRenderer<Model> = (model: Model) => string;
|
|
|
|
export type DataTableColumn = I18nLabel & { readonly key: string; readonly align?: "left" | "right" | "center" };
|
|
export type DataTableRow = { readonly id: string; readonly cells: Readonly<Record<string, string>> };
|
|
/** Domain View-Model a loader builds for a tabular list. */
|
|
export type DataTableVM = {
|
|
readonly caption?: I18nLabel;
|
|
readonly columns: readonly DataTableColumn[];
|
|
readonly rows: readonly DataTableRow[];
|
|
readonly emptyLabelKey?: string;
|
|
};
|
|
/** Normalized component prop-model the UI implementation renders. */
|
|
export type DataTableModel = {
|
|
readonly captionKey?: string;
|
|
readonly columns: readonly { readonly key: string; readonly labelKey: string; readonly align: "left" | "right" | "center" }[];
|
|
readonly rows: readonly DataTableRow[];
|
|
readonly emptyLabelKey: string;
|
|
readonly rowCount: number;
|
|
};
|
|
|
|
export function ready<T>(data: T): VMState<T> {
|
|
return { status: "ready", data };
|
|
}
|
|
|
|
export function empty<T>(): VMState<T> {
|
|
return { status: "empty" };
|
|
}
|
|
|
|
export function assertI18nLabel(label: I18nLabel): I18nLabel {
|
|
if (!/^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$/.test(label.labelKey)) {
|
|
throw new Error(`Registry labels must use i18n keys: ${label.labelKey}`);
|
|
}
|
|
if (label.descriptionKey && !/^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$/.test(label.descriptionKey)) {
|
|
throw new Error(`Registry descriptions must use i18n keys: ${label.descriptionKey}`);
|
|
}
|
|
return label;
|
|
}
|
|
|
|
// Domain View-Models (M013-Konvention: src/<domain>/*.vm.ts)
|
|
export * from "./walking-skeleton/walking-skeleton.vm.js";
|
|
export * from "./auth/session-list.vm.js";
|
|
export * from "./auth/select-tenant.vm.js";
|
|
export * from "./files/file-browser.vm.js";
|
|
export * from "./files/file-detail.vm.js";
|
|
export * from "./files/file-upload.vm.js";
|
|
export * from "./tasks/task-list.vm.js";
|
|
export * from "./tasks/task-detail.vm.js";
|
|
export * from "./leads/lead-list.vm.js";
|
|
export * from "./crm/kontakt-list.vm.js";
|
|
export * from "./crm/kontakt-detail.vm.js";
|
|
export * from "./crm/activity-stream.vm.js";
|
|
export * from "./crm/custom-field-admin.vm.js";
|
|
export * from "./crm/tag-admin.vm.js";
|
|
export * from "./crm/duplicate.vm.js";
|
|
export * from "./crm/kontakt-csv.js";
|
|
export * from "./hr/hr-directory.vm.js";
|
|
export * from "./hr/hr-location.vm.js";
|
|
export * from "./hr/hr-document.vm.js";
|
|
export * from "./hr/hr-password-safe.vm.js";
|
|
export * from "./hr/hr-leave.vm.js";
|
|
export * from "./hr/hr-sickleave.vm.js";
|
|
export * from "./hr/payslip-match.js";
|
|
export * from "./hr/reminder-cadence.js";
|
|
export * from "./hr/hr-announcement.vm.js";
|
|
export * from "./hr/hr-payslip.vm.js";
|
|
export * from "./hr/hr-upload-reminder.vm.js";
|
|
export * from "./hr/hr-request.vm.js";
|
|
export * from "./hr/hr-survey.vm.js";
|
|
export * from "./audit/audit-list.vm.js";
|
|
export * from "./audit/audit-export.vm.js";
|
|
export * from "./notifications/notification-center.vm.js";
|
|
export * from "./notifications/notification-settings.vm.js";
|
|
export * from "./admin/tenant-note-list.vm.js";
|
|
export * from "./admin/subscription-connectors.vm.js";
|
|
export * from "./admin/billing-admin.vm.js";
|
|
export * from "./admin/queue-monitor.vm.js";
|
|
export * from "./admin/support-conversation.vm.js";
|
|
export * from "./apps-engine/integration-catalog.vm.js";
|
|
export * from "./apps-engine/connection-detail.vm.js";
|
|
export * from "./apps-engine/sync-history.vm.js";
|
|
export * from "./apps-engine/sync-run-detail.vm.js";
|
|
export * from "./email/sending-domain.vm.js";
|
|
export * from "./email/presend-checklist.vm.js";
|
|
export * from "./email/campaign-detail.vm.js";
|
|
export * from "./email/campaign-list.vm.js";
|
|
export * from "./email/segment.vm.js";
|
|
// AK-P16a · calendar sync view-models.
|
|
export * from "./calendar/connection-list.vm.js";
|
|
export * from "./calendar/connection-detail.vm.js";
|
|
export * from "./calendar/calendar-view.vm.js";
|
|
// AK-P16b · booking view-models.
|
|
export * from "./booking/booking-list.vm.js";
|
|
// AK-P16d · project signature view-models.
|
|
export * from "./signature/project-signature.vm.js";
|
|
// VA-P23 · email-inbox (Postfach-Sync) view-models.
|
|
export * from "./email-inbox/mailbox-list.vm.js";
|
|
export * from "./email-inbox/inbox-list.vm.js";
|
|
export * from "./email-inbox/message-detail.vm.js";
|
|
export * from "./email-inbox/compose.vm.js";
|
|
// R-P2b · members/roles/groups admin view-models (D-P2 Admin RBAC).
|
|
export * from "./users/members-list.vm.js";
|
|
export * from "./users/roles-list.vm.js";
|
|
export * from "./users/role-editor.vm.js";
|
|
export * from "./users/groups-detail.vm.js";
|