From d9848234a48a6b0ecdb85db384c2800c2ea59717 Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Thu, 8 Jan 2026 11:35:06 -0500 Subject: [PATCH] Implement unified frontend type system and migrate core modules - Created src/lib/types/ae_types.ts to serve as the central repository for Aether object interfaces. - Standardized interfaces to include the triple-ID pattern (id, [type]_id, [type]_id_random) for Dexie and V3 API compatibility. - Migrated Account and JournalEntry modules to use ae_Account and ae_JournalEntry types. - Added explicit Promise return types to all core data loading, creation, and update functions in migrated modules. --- src/lib/ae_core/ae_core__account.ts | 36 +---- .../ae_journals/ae_journals__journal_entry.ts | 9 +- src/lib/types/ae_types.ts | 146 ++++++++++++++++++ 3 files changed, 156 insertions(+), 35 deletions(-) create mode 100644 src/lib/types/ae_types.ts diff --git a/src/lib/ae_core/ae_core__account.ts b/src/lib/ae_core/ae_core__account.ts index 7f89c36f..6fdd7349 100644 --- a/src/lib/ae_core/ae_core__account.ts +++ b/src/lib/ae_core/ae_core__account.ts @@ -3,36 +3,10 @@ import { api } from '$lib/api/api'; import { db_save_ae_obj_li__ae_obj } from '$lib/ae_core/core__idb_dexie'; import { db_core } from '$lib/ae_core/db_core'; +import type { ae_Account } from '$lib/types/ae_types'; const ae_promises: key_val = {}; -export interface Account { - id: string; - account_id: string; - account_id_random: string; - - code?: string; - name: string; - short_name?: null | string; - description?: null | string; - - enable: null | boolean; - enable_from?: null | Date; - enable_to?: null | Date; - - hide?: null | boolean; - priority?: null | boolean; - sort?: null | number; - group?: null | string; - notes?: null | string; - created_on: Date; - updated_on?: null | Date; - - // Computed or extra fields from views - tmp_sort_1?: string; - tmp_sort_2?: string; -} - // Updated 2026-01-06 export async function load_ae_obj_id__account({ api_cfg, @@ -48,7 +22,7 @@ export async function load_ae_obj_id__account({ params?: key_val; try_cache?: boolean; log_lvl?: number; -}) { +}): Promise { if (log_lvl) { console.log(`*** load_ae_obj_id__account() *** account_id=${account_id}`); } @@ -120,7 +94,7 @@ export async function load_ae_obj_li__account({ params?: key_val; try_cache?: boolean; log_lvl?: number; -}) { +}): Promise { if (log_lvl) { console.log(`*** load_ae_obj_li__account() ***`); } @@ -174,7 +148,7 @@ export async function create_ae_obj__account({ params?: key_val; try_cache?: boolean; log_lvl?: number; -}) { +}): Promise { if (log_lvl) { console.log(`*** create_ae_obj__account() ***`); } @@ -230,7 +204,7 @@ export async function update_ae_obj__account({ params?: key_val; try_cache?: boolean; log_lvl?: number; -}) { +}): Promise { if (log_lvl) { console.log(`*** update_ae_obj__account() *** account_id=${account_id}`, data_kv); } diff --git a/src/lib/ae_journals/ae_journals__journal_entry.ts b/src/lib/ae_journals/ae_journals__journal_entry.ts index 36c3d1e8..0aff204c 100644 --- a/src/lib/ae_journals/ae_journals__journal_entry.ts +++ b/src/lib/ae_journals/ae_journals__journal_entry.ts @@ -5,6 +5,7 @@ import { api } from '$lib/api/api'; import { db_save_ae_obj_li__ae_obj } from '$lib/ae_core/core__idb_dexie'; import { db_journals } from '$lib/ae_journals/db_journals'; +import type { ae_JournalEntry } from '$lib/types/ae_types'; const ae_promises: key_val = {}; @@ -19,7 +20,7 @@ export async function load_ae_obj_id__journal_entry({ journal_entry_id: string; try_cache?: boolean; log_lvl?: number; -}) { +}): Promise { if (log_lvl) { console.log(`*** load_ae_obj_id__journal_entry() *** journal_entry_id=${journal_entry_id}`); } @@ -95,7 +96,7 @@ export async function load_ae_obj_li__journal_entry({ params?: key_val; try_cache?: boolean; log_lvl?: number; -}) { +}): Promise { if (log_lvl) { console.log( `*** load_ae_obj_li__journal_entry() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}` @@ -194,7 +195,7 @@ export async function create_ae_obj__journal_entry({ params?: key_val; try_cache?: boolean; log_lvl?: number; -}) { +}): Promise { if (log_lvl) { console.log(`*** create_ae_obj__journal_entry() *** journal_id=${journal_id}`); } @@ -496,7 +497,7 @@ export async function update_ae_obj__journal_entry({ params?: key_val; try_cache?: boolean; log_lvl?: number; -}) { +}): Promise { if (log_lvl) { console.log( `*** update_ae_obj__journal_entry() *** journal_entry_id=${journal_entry_id}`, diff --git a/src/lib/types/ae_types.ts b/src/lib/types/ae_types.ts new file mode 100644 index 00000000..08632fbe --- /dev/null +++ b/src/lib/types/ae_types.ts @@ -0,0 +1,146 @@ +/** + * Aether Unified Type Definitions (Frontend) + * Standardized 2026-01-08 to align with Backend V3 exports and Dexie local storage patterns. + */ + +/** + * Base properties shared by almost all Aether objects. + */ +export interface ae_BaseObj { + id: string; // Primary key (maps to [obj_type]_id_random) + + code?: string; + name?: string; + short_name?: string; + description?: string; + + enable: boolean; + hide: boolean; + archive?: boolean; + archive_on?: string | Date; + + priority: boolean; + sort: number; + group?: string; + notes?: string; + + created_on: string | Date; + updated_on: string | Date; + + // Standard frontend computed sort fields + tmp_sort_1?: string; + tmp_sort_2?: string; + tmp_sort_3?: string; +} + +/** + * Account - Core client account + */ +export interface ae_Account extends ae_BaseObj { + account_id: string; + account_id_random: string; + + account_cfg?: any; +} + +/** + * Site - A website or application instance + */ +export interface ae_Site extends ae_BaseObj { + site_id: string; + site_id_random: string; + account_id: string; + account_id_random: string; + + url_root?: string; + site_cfg_json?: any; +} + +/** + * Site_Domain - A domain name mapped to a site + */ +export interface ae_SiteDomain extends ae_BaseObj { + site_domain_id: string; + site_domain_id_random: string; + site_id: string; + site_id_random: string; + + fqdn: string; + is_primary: boolean; + redirect_to_primary: boolean; +} + +/** + * Journal - A collection of entries + */ +export interface ae_Journal extends ae_BaseObj { + journal_id: string; + journal_id_random: string; + account_id: string; + account_id_random: string; +} + +/** + * JournalEntry - A discrete piece of content within a journal + */ +export interface ae_JournalEntry extends ae_BaseObj { + journal_entry_id: string; + journal_entry_id_random: string; + journal_id: string; + journal_id_random: string; + + person_id?: string; + person_id_random?: string; + + journal_entry_type?: string; + activity_code?: string; + category_code?: string; + type_code?: string; + topic_code?: string; + tags?: string; + + public?: boolean; + private?: boolean; + personal?: boolean; + professional?: boolean; + + summary?: string; + outline?: string; + + content?: string; + content_md_html?: string; + content_html?: string; + content_json?: any; + content_encrypted?: string; + + history?: string; + history_md_html?: string; + history_encrypted?: string; + + passcode_hash?: string; + + alert?: boolean; + alert_msg?: string; + + data_json?: any; + + // SQL View fields + journal_code?: string; + journal_name?: string; +} + +/** + * Person - A human entity + */ +export interface ae_Person extends ae_BaseObj { + person_id: string; + person_id_random: string; + account_id: string; + account_id_random: string; + + first_name?: string; + last_name?: string; + full_name?: string; + email?: string; + phone?: string; +}