From 78bbba59994adaecb93c3893e123205b14f37a68 Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Thu, 8 Jan 2026 11:37:32 -0500 Subject: [PATCH] Migrate Person and Site modules to unified type system - Updated ae_types.ts with detailed fields for ae_Person, ae_Site, and ae_SiteDomain based on V3 backend exports. - Replaced local interfaces in ae_core__person.ts and ae_core__site.ts with unified imports. - Added explicit Promise return types to all core data loading and CRUD functions in Person and Site modules. - Standardized triple-ID pattern and return signatures across core identity and configuration modules. --- src/lib/ae_core/ae_core__person.ts | 88 ++---------------------------- src/lib/ae_core/ae_core__site.ts | 85 ++++------------------------- src/lib/types/ae_types.ts | 46 ++++++++++++++-- 3 files changed, 56 insertions(+), 163 deletions(-) diff --git a/src/lib/ae_core/ae_core__person.ts b/src/lib/ae_core/ae_core__person.ts index 1743dec1..bc865c40 100644 --- a/src/lib/ae_core/ae_core__person.ts +++ b/src/lib/ae_core/ae_core__person.ts @@ -3,88 +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_Person } from '$lib/types/ae_types'; const ae_promises: key_val = {}; -export interface Person { - id: string; - person_id: string; - person_id_random: string; - - external_id?: string; - external_sys_id?: string; - code?: string; - - account_id?: string; - account_id_random?: string; - - person_profile_id?: null | string; - person_profile_id_random?: null | string; - - user_id?: string; - user_id_random?: string; - - pronouns?: null | string; - informal_name?: null | string; - title_names?: null | string; - given_name: string; - middle_name?: null | string; - family_name: null | string; - designations?: null | string; - - professional_title?: null | string; - - full_name?: string; - full_name_override?: null | string; - - affiliations?: null | string; - - primary_email?: string; - - biography?: null | string; - - agree?: null | boolean; - comments?: null | string; - - allow_auth_key?: null | boolean; - auth_key?: null | string; - passcode?: null | string; - - data_json?: null | string; - - enable: null | boolean; - hide?: null | boolean; - priority?: null | boolean; - sort?: null | number; - group?: null | string; - notes?: null | string; - created_on: Date; - updated_on?: null | Date; - - tmp_sort_1?: string; - tmp_sort_2?: string; - tmp_sort_3?: string; - - // View fields - username?: string; - user_name?: null | string; - user_email?: null | string; - user_allow_auth_key?: null | boolean; - user_super?: boolean; - user_manager?: boolean; - user_administrator?: boolean; - user_public?: boolean; - - organization_id?: null | string; - organization_id_random?: null | string; - organization_name?: null | string; - - contact_id?: null | string; - contact_id_random?: null | string; - contact_name?: null | string; - contact_email?: null | string; -} - // Updated 2026-01-06 export async function load_ae_obj_id__person({ api_cfg, @@ -100,7 +22,7 @@ export async function load_ae_obj_id__person({ params?: key_val; try_cache?: boolean; log_lvl?: number; -}) { +}): Promise { if (log_lvl) { console.log(`*** load_ae_obj_id__person() *** person_id=${person_id}`); } @@ -172,7 +94,7 @@ export async function load_ae_obj_li__person({ params?: key_val; try_cache?: boolean; log_lvl?: number; -}) { +}): Promise { if (log_lvl) { console.log(`*** load_ae_obj_li__person() *** for_obj_id=${for_obj_id}`); } @@ -270,7 +192,7 @@ export async function create_ae_obj__person({ params?: key_val; try_cache?: boolean; log_lvl?: number; -}) { +}): Promise { const fields: key_val = { ...data_kv }; if (account_id) fields.account_id_random = account_id; if (user_id) fields.user_id_random = user_id; @@ -315,7 +237,7 @@ export async function update_ae_obj__person({ params?: key_val; try_cache?: boolean; log_lvl?: number; -}) { +}): Promise { const result = await api.update_ae_obj_v3({ api_cfg, obj_type: 'person', diff --git a/src/lib/ae_core/ae_core__site.ts b/src/lib/ae_core/ae_core__site.ts index 36377717..185de8e8 100644 --- a/src/lib/ae_core/ae_core__site.ts +++ b/src/lib/ae_core/ae_core__site.ts @@ -3,75 +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_Site, ae_SiteDomain } from '$lib/types/ae_types'; const ae_promises: key_val = {}; -export interface Site { - id: string; - site_id: string; - site_id_random: string; - account_id: string; - account_id_random: string; - - code?: string; - name: string; - description?: null | string; - - restrict_access?: null | boolean; - access_key?: null | string; - access_code_kv_json?: null | string; - - logo_path?: null | string; - logo_bg_color?: null | string; - title?: null | string; - tagline?: null | string; - style_href?: null | string; - google_tracking_id?: null | string; - - cfg_json?: 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; - - tmp_sort_1?: string; - tmp_sort_2?: string; -} - -export interface Site_Domain { - id: string; - site_domain_id: string; - site_domain_id_random: string; - site_id: string; - site_id_random: string; - - fqdn: string; - access_key?: 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; - - tmp_sort_1?: string; - tmp_sort_2?: string; -} - /** * --- SITE CRUD --- */ @@ -86,7 +21,7 @@ export async function lookup_site_domain({ fqdn: string; view?: string; log_lvl?: number; -}) { +}): Promise { if (log_lvl) { console.log(`*** lookup_site_domain() *** fqdn=${fqdn}`); } @@ -121,7 +56,7 @@ export async function lookup_site_domain_v3({ fqdn: string; view?: string; log_lvl?: number; -}) { +}): Promise { if (log_lvl) { console.log(`*** lookup_site_domain_v3() *** fqdn=${fqdn}`); } @@ -186,7 +121,7 @@ export async function load_ae_obj_id__site({ params?: key_val; try_cache?: boolean; log_lvl?: number; -}) { +}): Promise { if (log_lvl) { console.log(`*** load_ae_obj_id__site() *** site_id=${site_id}`); } @@ -257,7 +192,7 @@ export async function load_ae_obj_li__site({ params?: key_val; try_cache?: boolean; log_lvl?: number; -}) { +}): Promise { if (log_lvl) { console.log(`*** load_ae_obj_li__site() *** for_obj_id=${for_obj_id}`); } @@ -315,7 +250,7 @@ export async function create_ae_obj__site({ params?: key_val; try_cache?: boolean; log_lvl?: number; -}) { +}): Promise { const result = await api.create_ae_obj_v3({ api_cfg, obj_type: 'site', @@ -359,7 +294,7 @@ export async function update_ae_obj__site({ params?: key_val; try_cache?: boolean; log_lvl?: number; -}) { +}): Promise { const result = await api.update_ae_obj_v3({ api_cfg, obj_type: 'site', @@ -447,7 +382,7 @@ export async function load_ae_obj_li__site_domain({ params?: key_val; try_cache?: boolean; log_lvl?: number; -}) { +}): Promise { ae_promises.load__site_domain_li = await api .get_nested_obj_li_v3({ api_cfg, @@ -502,7 +437,7 @@ export async function create_ae_obj__site_domain({ params?: key_val; try_cache?: boolean; log_lvl?: number; -}) { +}): Promise { const result = await api.create_nested_obj_v3({ api_cfg, parent_type: 'site', @@ -548,7 +483,7 @@ export async function update_ae_obj__site_domain({ params?: key_val; try_cache?: boolean; log_lvl?: number; -}) { +}): Promise { const result = await api.update_nested_obj_v3({ api_cfg, parent_type: 'site', diff --git a/src/lib/types/ae_types.ts b/src/lib/types/ae_types.ts index 08632fbe..3d6ddf29 100644 --- a/src/lib/types/ae_types.ts +++ b/src/lib/types/ae_types.ts @@ -54,6 +54,17 @@ export interface ae_Site extends ae_BaseObj { url_root?: string; site_cfg_json?: any; + + restrict_access?: boolean; + access_key?: string; + + logo_path?: string; + logo_bg_color?: string; + background_image_path?: string; + background_bg_color?: string; + + title?: string; + tagline?: string; } /** @@ -64,10 +75,14 @@ export interface ae_SiteDomain extends ae_BaseObj { site_domain_id_random: string; site_id: string; site_id_random: string; + account_id?: string; + account_id_random?: string; fqdn: string; - is_primary: boolean; - redirect_to_primary: boolean; + is_primary?: boolean; + redirect_to_primary?: boolean; + + access_key?: string; } /** @@ -137,10 +152,31 @@ export interface ae_Person extends ae_BaseObj { person_id_random: string; account_id: string; account_id_random: string; + + user_id?: string; + user_id_random?: string; - first_name?: string; - last_name?: string; + prefix?: string; + given_name?: string; + middle_name?: string; + family_name?: string; + suffix?: string; + full_name?: string; + informal_name?: string; + preferred_display_name?: string; + + professional_title?: string; + affiliations?: string; + + primary_email?: string; email?: string; phone?: string; -} + + birth_date?: string | Date; + gender_name?: string; + + tagline?: string; + + data_json?: any; +} \ No newline at end of file