From 512e5ef87c4e0fe2afba56a7affd2e369a17594f Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Tue, 24 Mar 2026 11:15:01 -0400 Subject: [PATCH] Saving more code clean up and removal --- README.md | 2 +- documentation/AE__Aether_API_objects.md | 1 - documentation/MODULE__AE_Events_Badges.md | 2 +- ...JECT__AE_UI_Journals_module_update_2026.md | 6 +- src/lib/ae_core/ae_core__site.ts | 171 +++++++++--------- src/lib/ae_events/ae_events__event.ts | 6 +- ...er_v3.svelte => element_qr_scanner.svelte} | 2 +- ...ket_v3.svelte => element_websocket.svelte} | 4 +- src/routes/+layout.ts | 6 +- .../[badge_id]/ae_comp__badge_obj_view.svelte | 12 +- .../badges/ae_comp__badge_search.svelte | 4 +- .../(launcher)/launcher/+layout.svelte | 6 +- .../ae_comp__lead_qr_scanner.svelte | 4 +- .../ae_idaa_comp__event_obj_id_view.svelte | 23 --- src/routes/testing/+page.svelte | 4 +- .../+page.svelte | 0 .../+page.svelte | 0 tests/README.md | 6 +- tests/_helpers/env.ts | 2 +- ...al_v3_mocks.ts => minimal_ae_api_mocks.ts} | 8 +- tests/event_badge_attendee_workflow.test.ts | 4 +- tests/event_badge_print_layout.test.ts | 2 +- tests/event_badge_render.test.ts | 2 +- tests/event_badge_smoke.test.ts | 2 +- tests/event_presenter.test.ts | 4 +- 25 files changed, 130 insertions(+), 153 deletions(-) rename src/lib/elements/{element_qr_scanner_v3.svelte => element_qr_scanner.svelte} (99%) rename src/lib/elements/{element_websocket_v3.svelte => element_websocket.svelte} (98%) rename src/routes/testing/{ae_obj_field_editor_v3 => ae_obj_field_editor}/+page.svelte (100%) rename src/routes/testing/{data_store_v3 => data_store}/+page.svelte (100%) rename tests/_helpers/{minimal_v3_mocks.ts => minimal_ae_api_mocks.ts} (93%) diff --git a/README.md b/README.md index 53c7c370..084d12e5 100644 --- a/README.md +++ b/README.md @@ -117,7 +117,7 @@ Built on the Events object. Developer sandbox pages — not for production use. - `/testing/ae_obj_field_editor/` — V3 field editor playground -- `/testing/data_store_v3/` — Data store V3 playground +- `/testing/data_store/` — Data store V3 playground - `/testing/editor_test/` — CodeMirror / TipTap editor tests - `/testing/hosted_files/` — File upload tests diff --git a/documentation/AE__Aether_API_objects.md b/documentation/AE__Aether_API_objects.md index 1f07bef7..429f646e 100644 --- a/documentation/AE__Aether_API_objects.md +++ b/documentation/AE__Aether_API_objects.md @@ -575,7 +575,6 @@ This document provides a reference for the data structures of the core Aether AP - `orders_info`: `Optional[dict]` - `order_list`: `Optional[list]` - `order_cart`: `Optional[dict]` -- `order_cart_v3`: `Optional[dict]` - `organization`: `Optional[Union[Organization_Base, None]]` - `post_list`: `Optional[list]` - `user`: `Optional[Union[User_Base, None]]` diff --git a/documentation/MODULE__AE_Events_Badges.md b/documentation/MODULE__AE_Events_Badges.md index 5f6c8cbf..8f318264 100644 --- a/documentation/MODULE__AE_Events_Badges.md +++ b/documentation/MODULE__AE_Events_Badges.md @@ -728,7 +728,7 @@ All API mock responses in tests need these fields. **Badge GET endpoint (single object):** `/v3/crud/event_badge/{id}` (NOT nested under event). Matches `api.get_ae_obj()` which uses the flat path. -**Badge PATCH endpoint (update):** `/v3/crud/event/${event_id}/event_badge/${badge_id}` (nested under event). Matches `api.patch_ae_obj_v3()` which uses the nested path. +**Badge PATCH endpoint (update):** `/v3/crud/event/${event_id}/event_badge/${badge_id}` (nested under event). Matches `api.patch_ae_obj()` which uses the nested path. **Use `data-testid` for test selectors.** Key buttons have targets: `badge-edit-btn`, `badge-save-btn`, `badge-cancel-btn`, `badge-print-btn`, `badge-professional-title-input`. diff --git a/documentation/PROJECT__AE_UI_Journals_module_update_2026.md b/documentation/PROJECT__AE_UI_Journals_module_update_2026.md index 27101376..957d9d8b 100644 --- a/documentation/PROJECT__AE_UI_Journals_module_update_2026.md +++ b/documentation/PROJECT__AE_UI_Journals_module_update_2026.md @@ -7,14 +7,14 @@ ## 1. Project Overview This document outlines the modernization of the Journals module UI in the SvelteKit frontend (`aether_app_sveltekit`). The primary goals are to fully leverage the generic V3 API architecture and introduce high-velocity productivity features for journal management. -**Context:** The backend transition to the generic `api_crud_v3` router is complete. Custom legacy routers have been removed. The frontend must now fully align with this pattern and provide a frictionless user experience. +**Context:** The backend transition to the generic `api_crud` router is complete. Custom legacy routers have been removed. The frontend must now fully align with this pattern and provide a frictionless user experience. --- ## 2. Core Objectives ### 🎯 Primary Goals -1. **V3 API Verification:** Ensure all CRUD operations utilize the generic `api_crud_v3` endpoints (Verified). +1. **V3 API Verification:** Ensure all CRUD operations utilize the generic `api_crud` endpoints (Verified). 2. **Quick Add UI:** Implement a specialized interface for rapid, friction-free entry creation. 3. **Append/Prepend UI:** Allow users to quickly add text to the beginning or end of existing entries without full edit mode. 4. **Interop & Portability:** Robust import/export logic for Markdown/HTML (Nextcloud Notes compatibility). @@ -25,7 +25,7 @@ This document outlines the modernization of the Journals module UI in the Svelte ## 3. Technical Architecture ### Backend (Completed) -* **Router:** `api_crud_v3` (Generic) +* **Router:** `api_crud` (Generic) * **Definitions:** `app/ae_obj_types_def.py` -> `app/object_definitions/journals.py` * **Endpoints:** `/v3/crud/journal/...` and `/v3/crud/journal_entry/...` diff --git a/src/lib/ae_core/ae_core__site.ts b/src/lib/ae_core/ae_core__site.ts index a235d6d8..ba7f8fdb 100644 --- a/src/lib/ae_core/ae_core__site.ts +++ b/src/lib/ae_core/ae_core__site.ts @@ -11,6 +11,88 @@ const ae_promises: key_val = {}; * --- SITE CRUD --- */ +// Legacy version +// export async function lookup_site_domain({ +// api_cfg, +// fqdn, +// view = 'default', +// log_lvl = 0 +// }: { +// api_cfg: any; +// fqdn: string; +// view?: string; +// log_lvl?: number; +// }): Promise { +// if (log_lvl) { +// console.log(`*** lookup_site_domain() *** fqdn=${fqdn}`); +// } + +// try { +// // We use get_ae_obj_id_crud because we are looking up by a unique field (fqdn) rather than ID. +// // This is the older method that uses the /crud/site/domain/:id endpoint. +// const result = await api.get_ae_obj_id_crud({ +// api_cfg, +// no_account_id: true, +// obj_type: 'site_domain', +// obj_id: fqdn, +// use_alt_table: true, +// use_alt_base: true, +// log_lvl +// }); + +// if (result) { +// // Standardize and save to cache +// const processed_obj_li = await process_ae_obj__site_domain_props({ +// obj_li: [result], +// log_lvl +// }); +// await db_save_ae_obj_li__ae_obj({ +// db_instance: db_core, +// table_name: 'site_domain', +// obj_li: processed_obj_li, +// properties_to_save: properties_to_save__site_domain, +// log_lvl +// }); +// return result; +// } +// } catch (error: any) { +// console.log('Site domain lookup failed (API Error).', error); +// } + +// if (log_lvl) console.log('Attempting to load site domain from local cache...'); +// const cached = await db_core.site_domain.where('fqdn').equals(fqdn).first(); + +// if (cached) { +// return cached as any; +// } + +// // CRITICAL FALLBACK: If both API and Cache fail, return a "Ghost" site domain object +// // to prevent the 403 error from blocking the UI. Page components will handle empty data. +// console.error('AE_SITE_CRITICAL: Site domain lookup failed API and CACHE. Returning ghost object.'); +// return { +// id: 'ghost', +// id_random: 'ghost', +// site_domain_id: 'ghost', +// site_domain_id_random: 'ghost', +// site_id: 'ghost', +// site_id_random: 'ghost', +// account_id: 'ghost', +// account_id_random: 'ghost', +// account_code: 'ghost', +// account_name: 'Ghost Account (Offline)', +// fqdn: fqdn, +// enable: '1', +// header_image_path: '', +// style_href: '', +// google_tracking_id: '', +// access_code_kv_json: {}, +// cfg_json: {}, +// access_key: '', +// site_domain_access_key: '' +// } as any; +// } + +// Updated 2026-01-26 (Cache-First Optimization) export async function lookup_site_domain({ api_cfg, fqdn, @@ -23,88 +105,7 @@ export async function lookup_site_domain({ log_lvl?: number; }): Promise { if (log_lvl) { - console.log(`*** lookup_site_domain() *** fqdn=${fqdn}`); - } - - try { - // We use get_ae_obj_id_crud because we are looking up by a unique field (fqdn) rather than ID. - // This is the older method that uses the /crud/site/domain/:id endpoint. - const result = await api.get_ae_obj_id_crud({ - api_cfg, - no_account_id: true, - obj_type: 'site_domain', - obj_id: fqdn, - use_alt_table: true, - use_alt_base: true, - log_lvl - }); - - if (result) { - // Standardize and save to cache - const processed_obj_li = await process_ae_obj__site_domain_props({ - obj_li: [result], - log_lvl - }); - await db_save_ae_obj_li__ae_obj({ - db_instance: db_core, - table_name: 'site_domain', - obj_li: processed_obj_li, - properties_to_save: properties_to_save__site_domain, - log_lvl - }); - return result; - } - } catch (error: any) { - console.log('Site domain lookup failed (API Error).', error); - } - - if (log_lvl) console.log('Attempting to load site domain from local cache...'); - const cached = await db_core.site_domain.where('fqdn').equals(fqdn).first(); - - if (cached) { - return cached as any; - } - - // CRITICAL FALLBACK: If both API and Cache fail, return a "Ghost" site domain object - // to prevent the 403 error from blocking the UI. Page components will handle empty data. - console.error('AE_SITE_CRITICAL: Site domain lookup failed API and CACHE. Returning ghost object.'); - return { - id: 'ghost', - id_random: 'ghost', - site_domain_id: 'ghost', - site_domain_id_random: 'ghost', - site_id: 'ghost', - site_id_random: 'ghost', - account_id: 'ghost', - account_id_random: 'ghost', - account_code: 'ghost', - account_name: 'Ghost Account (Offline)', - fqdn: fqdn, - enable: '1', - header_image_path: '', - style_href: '', - google_tracking_id: '', - access_code_kv_json: {}, - cfg_json: {}, - access_key: '', - site_domain_access_key: '' - } as any; -} - -// Updated 2026-01-26 (Cache-First Optimization) -export async function lookup_site_domain_v3({ - api_cfg, - fqdn, - view = 'default', - log_lvl = 0 -}: { - api_cfg: any; - fqdn: string; - view?: string; - log_lvl?: number; -}): Promise { - if (log_lvl) { - console.log(`*** lookup_site_domain_v3() *** fqdn=${fqdn} (Cache-First)`); + console.log(`*** lookup_site_domain() *** fqdn=${fqdn} (Cache-First)`); } // 1. FAST PATH: Check local cache first @@ -115,7 +116,7 @@ export async function lookup_site_domain_v3({ if (log_lvl) console.log('BOOTSTRAP: Cache hit. Returning cached site domain immediately.'); // Trigger background refresh to keep cache fresh, but don't await it - _refresh_site_domain_v3_background({ api_cfg, fqdn, view, log_lvl: 0 }); + _refresh_site_domain_background({ api_cfg, fqdn, view, log_lvl: 0 }); return cached as any; } @@ -124,13 +125,13 @@ export async function lookup_site_domain_v3({ } // 2. SLOW PATH: Wait for API if cache is empty - return await _refresh_site_domain_v3_background({ api_cfg, fqdn, view, log_lvl }); + return await _refresh_site_domain_background({ api_cfg, fqdn, view, log_lvl }); } /** * Internal helper to perform the actual API fetch and cache update */ -async function _refresh_site_domain_v3_background({ api_cfg, fqdn, view, log_lvl }: any) { +async function _refresh_site_domain_background({ api_cfg, fqdn, view, log_lvl }: any) { try { const guest_api_cfg = { ...api_cfg }; guest_api_cfg.headers = { ...api_cfg.headers }; diff --git a/src/lib/ae_events/ae_events__event.ts b/src/lib/ae_events/ae_events__event.ts index 3559ea0b..a66d61f0 100644 --- a/src/lib/ae_events/ae_events__event.ts +++ b/src/lib/ae_events/ae_events__event.ts @@ -60,7 +60,7 @@ export async function load_ae_obj_id__event({ if (log_lvl) console.log('EVENT LOAD: Cache hit. Returning stale data immediately.'); // Trigger background refresh - _refresh_event_v3_background({ + _refresh_event_background({ api_cfg, event_id, view, try_cache, inc_device_li, inc_file_li, inc_location_li, inc_session_li, inc_presentation_li, inc_presenter_li, inc_template_li, enabled, hidden, @@ -79,7 +79,7 @@ export async function load_ae_obj_id__event({ } // 2. SLOW PATH: Wait for API if cache is empty or try_cache is false - return await _refresh_event_v3_background({ + return await _refresh_event_background({ api_cfg, event_id, view, try_cache, inc_device_li, inc_file_li, inc_location_li, inc_session_li, inc_presentation_li, inc_presenter_li, inc_template_li, enabled, hidden, @@ -90,7 +90,7 @@ export async function load_ae_obj_id__event({ /** * Internal helper to perform the actual API fetch and cache update for events */ -async function _refresh_event_v3_background({ +async function _refresh_event_background({ api_cfg, event_id, view, try_cache, inc_device_li, inc_file_li, inc_location_li, inc_session_li, inc_presentation_li, inc_presenter_li, inc_template_li, enabled, hidden, diff --git a/src/lib/elements/element_qr_scanner_v3.svelte b/src/lib/elements/element_qr_scanner.svelte similarity index 99% rename from src/lib/elements/element_qr_scanner_v3.svelte rename to src/lib/elements/element_qr_scanner.svelte index 688919b1..90c6e86c 100644 --- a/src/lib/elements/element_qr_scanner_v3.svelte +++ b/src/lib/elements/element_qr_scanner.svelte @@ -1,6 +1,6 @@ - +
{$lq__event_badge_template_obj?.name ?? '—'} | {$lq__event_badge_template_obj?.layout ?? '(no layout)'} | - v2 + v3 {#if $ae_loc.edit_mode} |