From 20f1f5ad2727d8b7ec3040300df9e1196c41dce3 Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Thu, 29 Jan 2026 10:57:59 -0500 Subject: [PATCH] This is a mostly working state again. Some files were backed up to ~/tmp/Aether_UI_UX_app. Things are slowly being merged back in. Not easy. --- src/lib/ae_api/api_get__data_store_v3.ts | 48 +++ src/lib/ae_core/db_core.ts | 42 +- .../element_data_store_v3_alpha.svelte | 384 ++++++++++++++++++ src/lib/types/ae_types.ts | 283 +++++++------ src/routes/+layout.svelte | 103 +++-- src/routes/testing/data_store_v3/+page.svelte | 96 +++++ 6 files changed, 762 insertions(+), 194 deletions(-) create mode 100644 src/lib/ae_api/api_get__data_store_v3.ts create mode 100644 src/lib/elements/element_data_store_v3_alpha.svelte create mode 100644 src/routes/testing/data_store_v3/+page.svelte diff --git a/src/lib/ae_api/api_get__data_store_v3.ts b/src/lib/ae_api/api_get__data_store_v3.ts new file mode 100644 index 00000000..5ef0827a --- /dev/null +++ b/src/lib/ae_api/api_get__data_store_v3.ts @@ -0,0 +1,48 @@ +import type { key_val } from '$lib/stores/ae_stores'; +import { get_object } from './api_get_object'; + +interface GetDataStoreV3Params { + api_cfg: any; + code: string; + for_type?: string | null; + for_id?: string | null; + no_account_id?: boolean; + log_lvl?: number; +} + +/** + * Get a Data Store object by its human-friendly code (V3) + * Uses hierarchical fallback logic (Specific -> Account -> Global) + * Path: GET /v3/data_store/code/{code} + */ +export async function get_data_store_v3({ + api_cfg, + code, + for_type = null, + for_id = null, + no_account_id = false, + log_lvl = 0 +}: GetDataStoreV3Params): Promise { + if (log_lvl) { + console.log(`*** get_data_store_v3() *** code=${code} no_account_id=${no_account_id}`); + } + + const endpoint = `/v3/data_store/code/${code}`; + const params: key_val = {}; + if (for_type) params['for_type'] = for_type; + if (for_id) params['for_id'] = for_id; + + const headers: key_val = {}; + if (no_account_id) { + // This token allows bypassing the mandatory account_id requirement for global defaults + headers['x-no-account-id-token'] = 'Nothing to See Here'; + } + + return await get_object({ + api_cfg, + endpoint, + params, + headers, + log_lvl + }); +} diff --git a/src/lib/ae_core/db_core.ts b/src/lib/ae_core/db_core.ts index cb2c9d35..5dd614d5 100644 --- a/src/lib/ae_core/db_core.ts +++ b/src/lib/ae_core/db_core.ts @@ -1,13 +1,14 @@ import Dexie, { type Table } from 'dexie'; -import type { - ae_HostedFile, - ae_Person, - ae_User, - ae_Account, - ae_Site, - ae_SiteDomain, - ae_Address, - ae_Contact +import type { + ae_HostedFile, + ae_Person, + ae_User, + ae_Account, + ae_Site, + ae_SiteDomain, + ae_Address, + ae_Contact, + ae_DataStore } from '$lib/types/ae_types'; // li = list @@ -32,7 +33,7 @@ export interface Person extends ae_Person { external_sys_id?: string; person_profile_id?: string; person_profile_id_random?: string; - + username?: string; user_name?: string; user_email?: string; @@ -53,24 +54,21 @@ export interface Person extends ae_Person { address_id_random?: string; } -export interface User extends ae_User { - // Additional local fields if needed -} - -// Updated 2026-01-09 +// Updated 2026-01-28 - Unified Types and added Data Store export class MySubClassedDexie extends Dexie { file!: Table; person!: Table; - user!: Table; + user!: Table; account!: Table; site!: Table; site_domain!: Table; address!: Table; contact!: Table; + data_store!: Table; constructor() { super('ae_core_db'); - this.version(2).stores({ + this.version(3).stores({ file: ` id, hosted_file_id, hosted_file_id_random, hash_sha256, @@ -123,6 +121,16 @@ export class MySubClassedDexie extends Dexie { account_id, account_id_random, for_type, for_id_random, title, email, phone_mobile, + enable, hide, priority, sort, group, created_on, updated_on`, + + data_store: ` + id, data_store_id, data_store_id_random, + account_id, account_id_random, + for_type, for_id_random, + code, name, type, + [code+for_type+for_id_random], + [code+account_id_random+for_type], + [code+account_id_random], enable, hide, priority, sort, group, created_on, updated_on` }); } diff --git a/src/lib/elements/element_data_store_v3_alpha.svelte b/src/lib/elements/element_data_store_v3_alpha.svelte new file mode 100644 index 00000000..57cc5347 --- /dev/null +++ b/src/lib/elements/element_data_store_v3_alpha.svelte @@ -0,0 +1,384 @@ + + +
+ {#if $lq__ds_obj} + {#if debug || $ae_loc.debug === 'debug'} +
+ID: {$lq__ds_obj.id}
+Code: {$lq__ds_obj.code}
+Name: {$lq__ds_obj.name}
+Type: {$lq__ds_obj.type}
+Created: {$lq__ds_obj.created_on}
+Updated: {$lq__ds_obj.updated_on}
+Account: {$lq__ds_obj.account_id_random || 'Global / NULL'}
+            
+ {/if} + + +
{ e.preventDefault(); handle_submit_form(e); }}> + + +
+
+ + +
+ +
+ +
+ + Account Specific +
+
+
+ +
+ Content + +
+ +
+ + +
+ + +
+
+
+
+ + {#if $lq__ds_obj.type === 'html' && $lq__ds_obj.html} + {@html $lq__ds_obj.html} + {:else if $lq__ds_obj.type === 'text' && $lq__ds_obj.text} +
{$lq__ds_obj.text}
+ {/if} + + {#if $ae_loc.edit_mode && ($ae_loc.manager_access || (show_edit_btn && $ae_loc.administrator_access))} + + {/if} + {:else if ds_loading_status === 'not found'} +
+ Data Store not found: {ds_code} +
+ {/if} + + {#if ds_loading_status === 'loading'} +
+ +
+ {/if} +
+ + \ No newline at end of file diff --git a/src/lib/types/ae_types.ts b/src/lib/types/ae_types.ts index 2d53e711..d9aa7707 100644 --- a/src/lib/types/ae_types.ts +++ b/src/lib/types/ae_types.ts @@ -8,22 +8,22 @@ */ export interface ae_BaseObj { id: string; // Primary key (maps to [obj_type]_id_random) - + code?: string | null; name?: string; short_name?: string; description?: string | null; - + enable: boolean | null; hide: boolean | null; archive?: boolean; archive_on?: string | Date; - + priority: boolean | null; sort: number | null; group?: string; notes?: string; - + created_on: string | Date; updated_on: string | Date; @@ -39,7 +39,7 @@ export interface ae_BaseObj { export interface ae_Account extends ae_BaseObj { account_id: string; account_id_random: string; - + account_cfg?: ae_AccountCfg; } @@ -49,14 +49,14 @@ export interface ae_Account extends ae_BaseObj { export interface ae_AccountCfg { id: string; account_id_random: string; - + modules_enabled?: any; default_no_reply_email?: string; default_no_reply_name?: string; - + post_rules?: string; post_comment_rules?: string; - + created_on: string | Date; updated_on: string | Date; } @@ -69,18 +69,18 @@ export interface ae_Site extends ae_BaseObj { site_id_random: string; account_id: string; account_id_random: string; - + 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; } @@ -95,11 +95,11 @@ export interface ae_SiteDomain extends ae_BaseObj { site_id_random: string; account_id?: string; account_id_random?: string; - + fqdn: string; is_primary?: boolean; redirect_to_primary?: boolean; - + access_key?: string; // Joined fields for bootstrap lookup @@ -126,25 +126,25 @@ export interface ae_Journal extends ae_BaseObj { account_id_random: string; person_id?: string; person_id_random?: string; - + for_type?: string; for_id?: string; for_id_random?: string; - + type_code?: string; tags?: string; - + summary?: string; outline?: string; - + start_datetime?: string | Date; end_datetime?: string | Date; timezone?: string; - + passcode?: string; passcode_timeout?: number; private_passcode?: string; - + cfg_json?: any; data_json?: any; meta_json?: any; @@ -162,19 +162,19 @@ export interface ae_JournalEntry extends ae_BaseObj { journal_entry_id_random: string; journal_id: string; journal_id_random: string; - + person_id?: string; person_id_random?: string; - + template?: boolean; - + journal_entry_type?: string; activity_code?: string; category_code?: string; type_code?: string; topic_code?: string; tags?: string; - + public?: boolean; private?: boolean; personal?: boolean; @@ -182,7 +182,7 @@ export interface ae_JournalEntry extends ae_BaseObj { summary?: string; outline?: string; - + content?: string; content_md_html?: string; content_html?: string; @@ -194,7 +194,7 @@ export interface ae_JournalEntry extends ae_BaseObj { history_encrypted?: string; passcode_hash?: string; - + start_datetime?: string | Date; end_datetime?: string | Date; timezone?: string; @@ -216,7 +216,7 @@ export interface ae_JournalEntry extends ae_BaseObj { alert?: boolean; alert_msg?: string; - + data_json?: any; meta_json?: any; @@ -234,7 +234,7 @@ 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; @@ -245,26 +245,26 @@ export interface ae_Person extends ae_BaseObj { family_name?: string; suffix?: string; designations?: 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; - + allow_auth_key?: boolean; passcode?: string; - + data_json?: any; } @@ -278,20 +278,20 @@ export interface ae_User extends ae_BaseObj { account_id_random: string; person_id?: string; person_id_random?: string; - + username: string; email?: string; - + // Permissions (Maps to $ae_loc logic) super: boolean; manager: boolean; administrator: boolean; public: boolean; - + status_name?: string; logged_in_on?: string | Date; last_activity_on?: string | Date; - + user_role_list?: ae_UserRole[]; } @@ -301,14 +301,14 @@ export interface ae_User extends ae_BaseObj { export interface ae_UserRole { id: string; user_id_random: string; - + for_type?: string; for_id_random?: string; - + code?: string; name?: string; enable: boolean; - + created_on: string | Date; updated_on: string | Date; } @@ -321,13 +321,13 @@ export interface ae_Address extends ae_BaseObj { address_id_random: string; account_id: string; account_id_random: string; - + for_type?: string; for_id_random?: string; - + attention_to?: string; organization_name?: string; - + line_1: string; line_2?: string; line_3?: string; @@ -336,7 +336,7 @@ export interface ae_Address extends ae_BaseObj { postal_code?: string; country?: string; country_name?: string; - + timezone?: string; latitude?: string; longitude?: string; @@ -350,19 +350,19 @@ export interface ae_Contact extends ae_BaseObj { contact_id_random: string; account_id: string; account_id_random: string; - + address_id_random?: string; for_type?: string; for_id_random?: string; - + title?: string; tagline?: string; - + email?: string; phone_mobile?: string; phone_office?: string; website_url?: string; - + facebook_url?: string; instagram_url?: string; linkedin_url?: string; @@ -376,20 +376,20 @@ export interface ae_ActivityLog extends ae_BaseObj { activity_log_id_random: string; account_id: string; account_id_random: string; - + person_id_random?: string; user_id_random?: string; - + external_client_id?: string; source?: string; - + object_type?: string; object_id_random?: string; - + action: string; action_on_type?: string; action_on_id_random?: string; - + details?: string; other_json?: any; } @@ -402,25 +402,25 @@ export interface ae_Event extends ae_BaseObj { event_id_random: string; account_id: string; account_id_random: string; - + conference: boolean; type?: string; name: string; summary?: string; description?: string; - + timezone?: string; start_datetime?: string | Date; end_datetime?: string | Date; - + location_text?: string; location_address_json?: any; - + status?: string; approve?: boolean; ready?: boolean; ready_on?: string | Date; - + cfg_json?: any; data_json?: any; @@ -445,10 +445,10 @@ export interface ae_Event extends ae_BaseObj { */ export interface ae_EventCfg extends ae_BaseObj { event_id_random: string; - + enable_comments?: boolean; unauthenticated_access?: boolean; - + mod_abstracts_json?: any; mod_badges_json?: any; mod_exhibits_json?: any; @@ -466,33 +466,33 @@ export interface ae_EventBadge extends ae_BaseObj { person_id_random: string; event_person_id?: string; event_person_id_random?: string; - + event_badge_template_id?: string; event_badge_template_id_random?: string; - + badge_type_code?: string; badge_type?: string; - + member_type_code?: string; member_status?: string; - + pronouns?: string; given_name?: string; middle_name?: string; family_name?: string; full_name?: string; affiliations?: string; - + professional_title?: string; email?: string; city?: string; state_province?: string; country?: string; - + print_count?: number; print_first_datetime?: string | Date; print_last_datetime?: string | Date; - + ticket_list?: any[]; data_json?: any; } @@ -505,18 +505,18 @@ export interface ae_EventBadgeTemplate extends ae_BaseObj { event_badge_template_id_random: string; event_id: string; event_id_random: string; - + logo_path?: string; header_path?: string; header_row_1?: string; header_row_2?: string; - + footer_path?: string; footer_title?: string; - + badge_type_list?: any; ticket_list?: any; - + layout?: string; style_href?: string; passcode?: string; @@ -530,14 +530,14 @@ export interface ae_EventLocation extends ae_BaseObj { event_location_id_random: string; event_id: string; event_id_random: string; - + location_type?: string; location_type_code?: string; - + internal_use?: boolean; record_audio?: boolean; record_video?: boolean; - + passcode?: string; data_json?: any; } @@ -554,19 +554,19 @@ export interface ae_EventSession extends ae_BaseObj { event_location_id_random?: string | null; event_track_id?: string | null; event_track_id_random?: string | null; - + type_code?: string | null; start_datetime?: string | Date | null; end_datetime?: string | Date | null; - + internal_use?: boolean | null; record_audio?: boolean | null; record_video?: boolean | null; - + status?: number | null; approve?: boolean | null; ready?: boolean | null; - + data_json?: any; // Additional database view fields found in db_events.ts @@ -602,13 +602,13 @@ export interface ae_EventPresentation extends ae_BaseObj { event_session_id_random: string; event_abstract_id?: string | null; event_abstract_id_random?: string | null; - + abstract_code?: string | null; type_code?: string | null; - + start_datetime?: string | Date | null; end_datetime?: string | Date | null; - + passcode?: string | null; file_count?: number | null; @@ -629,7 +629,7 @@ export interface ae_EventPresenter extends ae_BaseObj { event_id_random: string; person_id: string; person_id_random: string; - + pronouns?: string; given_name?: string; middle_name?: string; @@ -637,11 +637,11 @@ export interface ae_EventPresenter extends ae_BaseObj { full_name?: string; affiliations?: string; email?: string; - + professional_title?: string; tagline?: string; biography?: string; - + agree?: boolean; data_json?: any; } @@ -654,10 +654,10 @@ export interface ae_EventTrack extends ae_BaseObj { event_track_id_random: string; event_id: string; event_id_random: string; - + track_type?: string; track_type_code?: string; - + start_datetime?: string | Date; end_datetime?: string | Date; } @@ -670,7 +670,7 @@ export interface ae_HostedFile extends ae_BaseObj { hosted_file_id_random: string; account_id: string; account_id_random: string; - + hash_sha256?: string; subdirectory_path?: string; filename?: string; @@ -688,7 +688,7 @@ export interface ae_HostedFileLink { hosted_file_id_random: string; link_to_type: string; link_to_id_random: string; - + created_on: string | Date; updated_on: string | Date; } @@ -699,15 +699,30 @@ export interface ae_HostedFileLink { export interface ae_DataStore extends ae_BaseObj { data_store_id: string; data_store_id_random: string; - account_id: string; - account_id_random: string; - - for_type?: string; - for_id_random?: string; - - type?: string; - json_str?: any; - text?: string; + account_id?: null | string; + account_id_random?: null | string; + + for_type?: null | string; + for_id_random?: null | string; + for_id?: null | string; + + person_id_random?: null | string; + user_id_random?: null | string; + + type?: null | string; + + json?: any; + json_str?: null | string; + text?: null | string; + html?: null | string; + + meta_json?: null | string; + meta_text?: null | string; + + access?: null | string; + access_read?: null | string; + access_write?: null | string; + access_delete?: null | string; } /** @@ -718,15 +733,15 @@ export interface ae_Post extends ae_BaseObj { post_id_random: string; account_id: string; account_id_random: string; - + title: string; content: string; type?: string; - + anonymous: boolean; full_name?: string; email?: string; - + post_comment_count?: number; approve?: boolean; ready?: boolean; @@ -739,7 +754,7 @@ export interface ae_PostComment extends ae_BaseObj { post_comment_id: string; post_comment_id_random: string; post_id_random: string; - + content: string; anonymous: boolean; full_name?: string; @@ -753,7 +768,7 @@ export interface ae_Page extends ae_BaseObj { page_id_random: string; account_id: string; account_id_random: string; - + alias: string; title: string; body: string; @@ -768,18 +783,18 @@ export interface ae_Archive extends ae_BaseObj { archive_id_random: string; account_id: string; account_id_random: string; - + archive_type?: string; topic_id?: string; topic_name?: string; - + content_html?: string; - + original_datetime?: string | Date; original_location?: string; - + archive_on?: string | Date; - + archive_content_count?: number; } @@ -790,13 +805,13 @@ export interface ae_ArchiveContent extends ae_BaseObj { archive_content_id: string; archive_content_id_random: string; archive_id_random: string; - + archive_content_type?: string; content_html?: string; url?: string; - + duration?: string; - + hosted_file_id_random?: string; filename?: string; subdirectory_path?: string; @@ -810,15 +825,15 @@ export interface ae_EventFile extends ae_BaseObj { event_file_id_random: string; event_id: string; event_id_random: string; - + hosted_file_id_random?: string; for_type?: string; for_id_random?: string; - + filename?: string; filename_no_ext?: string; extension?: string; - + file_purpose?: string; approve?: boolean; } @@ -832,11 +847,11 @@ export interface ae_EventDevice extends ae_BaseObj { event_id: string; event_id_random: string; event_location_id_random?: string; - + app_mode?: string; status?: string; heartbeat?: string | Date; - + info_hostname?: string; info_ip?: string; } @@ -849,7 +864,7 @@ export interface ae_EventAbstract extends ae_BaseObj { event_abstract_id_random: string; event_id: string; event_id_random: string; - + external_id?: string; abstract?: string; status?: number; @@ -864,7 +879,7 @@ export interface ae_Organization extends ae_BaseObj { organization_id_random: string; account_id: string; account_id_random: string; - + tagline?: string; logo_path?: string; industry?: number; @@ -880,7 +895,7 @@ export interface ae_EventRegistration extends ae_BaseObj { event_id_random: string; person_id: string; person_id_random: string; - + organization_id_random?: string; contact_id_random?: string; } @@ -893,11 +908,11 @@ export interface ae_EventExhibit extends ae_BaseObj { event_exhibit_id_random: string; event_id: string; event_id_random: string; - + organization_id_random?: string; contact_id_random?: string; person_id_random?: string; - + tagline?: string; logo_path?: string; staff_limit?: number; @@ -912,10 +927,10 @@ export interface ae_EventExhibitTracking extends ae_BaseObj { event_id: string; event_id_random: string; event_exhibit_id_random: string; - + event_person_id_random?: string; event_badge_id_random?: string; - + exhibitor_notes?: string; responses_json?: any; } @@ -930,10 +945,10 @@ export interface ae_EventPerson extends ae_BaseObj { event_id_random: string; person_id: string; person_id_random: string; - + event_badge_id_random?: string; event_registration_id_random?: string; - + passcode?: string; agree_to_tc?: boolean; } @@ -947,11 +962,11 @@ export interface ae_EventPersonProfile extends ae_BaseObj { event_id: string; event_id_random: string; event_person_id_random: string; - + tagline?: string; biography?: string; website_url?: string; - + thumbnail_path?: string; picture_path?: string; } @@ -963,9 +978,9 @@ export interface ae_EventPersonTracking extends ae_BaseObj { event_person_id_random: string; event_id: string; event_id_random: string; - + event_session_id_random?: string; - + check_in_out?: boolean; in_datetime?: string | Date; out_datetime?: string | Date; @@ -979,7 +994,7 @@ export interface ae_Sponsorship extends ae_BaseObj { sponsorship_id_random: string; account_id: string; account_id_random: string; - + sponsorship_cfg_id_random: string; amount?: number; paid?: boolean; @@ -993,7 +1008,7 @@ export interface ae_SponsorshipCfg extends ae_BaseObj { sponsorship_cfg_id_random: string; account_id: string; account_id_random: string; - + level_li_json?: any; start_datetime?: string | Date; end_datetime?: string | Date; @@ -1005,10 +1020,10 @@ export interface ae_SponsorshipCfg extends ae_BaseObj { export interface ae_LogClientViewing extends ae_BaseObj { account_id_random: string; external_client_id: string; - + object_type: string; object_id: string; - + page_load_on?: string | Date; play_start_count?: number; play_pause_count?: number; diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 74b79c95..c746f9b5 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -48,14 +48,19 @@ // import { api } from '$lib/api'; import { ae_loc, ae_sess, ae_api, slct, slct_trigger } from '$lib/stores/ae_stores'; import { events_loc, events_slct } from '$lib/stores/ae_events_stores'; - import type { LayoutData } from './$types'; + // import type { key_val } from '$lib/ae_stores'; import MyClipboard from '$lib/app_components/e_app_clipboard.svelte'; import E_app_debug_menu from '$lib/app_components/e_app_debug_menu.svelte'; import E_app_sys_menu from '$lib/app_components/e_app_sys_menu.svelte'; + // import Element_access_type from '$lib/element_access_type.svelte'; + // import Element_app_cfg from '$lib/element_app_cfg.svelte'; + // import Element_sign_in_out from '$lib/element_sign_in_out.svelte'; + + // import Element_data_store from '$lib/element_data_store_v2.svelte'; interface Props { - data: LayoutData; + data: any; children?: import('svelte').Snippet; } @@ -65,36 +70,51 @@ console.log(`ae_root +layout.svelte data:`, data); } - // Define ae_acct as a derived rune so it's reactive and available globally in the component - let ae_acct = $derived(data.account_id ? (data as any)[data.account_id] : null); + // Quickly save the data passed from the parent(s) to the Svelte stores, localStorage, and other. This should catch anything that is a child of this layout.svelte file. + $slct.account_id = data.account_id; + if (log_lvl) { + console.log(`*ae_root +layout.svelte* $slct.account_id = ${$slct.account_id}`); + } + let ae_acct = data[$slct.account_id]; - // Use an effect to sync data to stores whenever it changes - import { untrack } from 'svelte'; - $effect(() => { - const account_id = data.account_id; - const acct_data = ae_acct; - - if (account_id) { - untrack(() => { - if ($slct.account_id !== account_id) { - $slct.account_id = account_id; - } - - if (acct_data) { - // Merging stores with untracked reads to prevent loops - if (acct_data.api) { - $ae_api = { ...untrack(() => $ae_api), ...acct_data.api }; - } - if (acct_data.loc) { - $ae_loc = { ...untrack(() => $ae_loc), ...acct_data.loc }; - } - if (acct_data.slct) { - $slct = { ...untrack(() => $slct), ...acct_data.slct }; - } - } - }); + if (ae_acct) { + $ae_api = { + ...$ae_api, + ...(ae_acct.api || {}) + }; + if (log_lvl > 1) { + console.log(`$ae_api = `, $ae_api); } - }); + + // FORCE UPDATE: If the incoming data is a valid site (not a fallback ghost), + // we must ensure the ae_loc store is updated regardless of what's in localStorage. + if (ae_acct.loc?.account_id && ae_acct.loc.account_id !== 'ghost') { + $ae_loc = { + ...$ae_loc, + ...(ae_acct.loc || {}) + }; + } else { + // If it IS a ghost, we still update it to show the correct fallback message + $ae_loc = { + ...$ae_loc, + ...(ae_acct.loc || {}) + }; + } + + if (log_lvl > 1) { + console.log(`$ae_loc = `, $ae_loc); + } + + $slct = { + ...$slct, + ...(ae_acct.slct || {}) + }; + if (log_lvl > 1) { + console.log(`$slct = `, $slct); + } + } else { + console.warn('ae_root +layout.svelte: ae_acct not found for account_id:', $slct.account_id); + } let flag_clear_idb: boolean = $state(false); let flag_clear_local: boolean = $state(false); @@ -689,16 +709,13 @@ // Sync JWT from local storage to API config for V3 endpoints $effect(() => { - const loc_jwt = $ae_loc.jwt; - untrack(() => { - if ($ae_api.jwt !== loc_jwt) { - if (log_lvl) console.log('ROOT: Syncing JWT to API config'); - $ae_api = { - ...$ae_api, - jwt: loc_jwt - }; - } - }); + if ($ae_api.jwt !== $ae_loc.jwt) { + if (log_lvl) console.log('ROOT: Syncing JWT to API config'); + $ae_api = { + ...$ae_api, + jwt: $ae_loc.jwt + }; + } }); let is_hydrating = $state(true); @@ -826,7 +843,7 @@ {/if} - +
- + + +
+ + + {#key refresh_trigger} +
+

Scenario 1: Global Default

+

Fetching code {test_code_global}. Should fall back to account_id = NULL if not found for account.

+
+ +
+
+ +
+

Scenario 2: Account Default

+

Fetching code {test_code_account} for Account ID: {$ae_loc.account_id}.

+
+ +
+
+ +
+

Scenario 3: Specific Record (Event Override)

+

Fetching code {test_code_specific} linked to for_type: event and for_id: {test_event_id}.

+
+ +
+
+ {/key} + +
+

Current Context

+
+
+ Account ID: {$ae_loc.account_id || 'NULL'} +
+
+ Edit Mode: {$ae_loc.edit_mode} +
+
+
+