refactor(stores): phase 1 cleanup — ae_stores.ts and ae_events_stores.ts
- Remove ~200 lines of dead commented-out code (old test blocks, stale import alternatives, unused console.log lines) - Remove ver_idb fields — superseded by store_versions.ts __version mechanism - Remove Stripe button IDs / publishable key from events_sess (no consumers) - Remove stale event-specific comments (CHOW 2024 sponsor tiers, ISHLT note) - Remove example: true test field from session leads struct - Improve comments: ver stamp rationale, auth__kv expiry intent, api_*_kv shape doc, slct/events_slct tab-isolation rationale, level_guest_max_li fallback note, events_trig_kv purpose - Keep all active business logic and exports unchanged; zero consumer impact
This commit is contained in:
@@ -36,69 +36,49 @@ const ae_no_account_id_token = PUBLIC_AE_NO_ACCOUNT_ID_TOKEN;
|
||||
const ae_event_id = PUBLIC_AE_EVENT_ID;
|
||||
const ae_sponsorship_cfg_id = PUBLIC_AE_SPONSORSHIP_CFG_ID;
|
||||
|
||||
// import { getStores, navigating, page, updated } from '$app/stores';
|
||||
// import { assets, base, resolveRoute } from '$app/paths';
|
||||
// console.log(page.path); // Everything after the domain name
|
||||
|
||||
// console.log(import.meta.env.MODE);
|
||||
// console.log(import.meta.env.BASE_URL);
|
||||
|
||||
// Export the key_val type for use in other files.
|
||||
// Loose bag-of-anything type used throughout the store. Once stores are broken into
|
||||
// typed domain files, individual structs will have proper interfaces instead.
|
||||
export type key_val = {
|
||||
[key: string]: any; // variable key
|
||||
// name: string;
|
||||
[key: string]: any;
|
||||
};
|
||||
// export type key_val = key_val;
|
||||
|
||||
// import { html__not_set, classes__events_pres_mgmt_menu } from './ae_string_snippets';
|
||||
import { string_snippets } from '$lib/utils/ae_string_snippets';
|
||||
export const ae_snip = string_snippets;
|
||||
|
||||
// export let ae_snip =
|
||||
// {
|
||||
// 'not_set': html__not_set,
|
||||
// 'classes__events_pres_mgmt_menu': classes__events_pres_mgmt_menu
|
||||
// };
|
||||
|
||||
// Set the version for the app data. Changing this should force a notification and ask the user to clear and reload the page.
|
||||
const ver = '2025-05-01_1445'; // KEEP: 2025-05-01_1445
|
||||
const ver_idb = '2025-05-01_1445'; // Not currently used
|
||||
// Deployment version stamp. Compared against ae_sess.ver in +layout.svelte to detect
|
||||
// stale persisted data after a deploy (triggers a reload). Bump this alongside
|
||||
// ae_app_session_data_defaults.ver whenever a deploy changes expected stored shape.
|
||||
// See store_versions.ts for the schema-level localStorage wipe mechanism (separate concern).
|
||||
const ver = '2025-05-01_1445';
|
||||
|
||||
// *** BEGIN *** Longer-term app data. This should be stored to local storage.
|
||||
const ae_app_local_data_defaults: key_val = {
|
||||
__version: AE_LOC_VERSION, // Schema version gate — see store_versions.ts
|
||||
last_page_reload: null,
|
||||
// last_idb_reload: null,
|
||||
// last_cache_refresh: null, // Date.now()
|
||||
last_cache_refresh: Date.now(),
|
||||
cache_expired: false,
|
||||
ver: ver, // ver, // '2025-04-18_1100',
|
||||
ver_idb: ver_idb, // '2025-04-18_1100',
|
||||
// Deployment stamp — compared against ae_sess.ver in +layout.svelte to trigger
|
||||
// a reload when the persisted local data predates the current deploy.
|
||||
ver: ver,
|
||||
|
||||
name: 'Aether - App Hub (SvelteKit 2.x Svelte 4.x)',
|
||||
name: 'Aether - App Hub',
|
||||
|
||||
theme: 'light',
|
||||
theme_mode: 'light',
|
||||
theme_name: 'AE_Firefly', // "Shiny serenity, like a firefly." — OSIT default 2026
|
||||
theme_name: 'AE_Firefly', // OSIT default theme
|
||||
font_size_mode: 'default', // 'default' | 'larger' | 'smaller'
|
||||
iframe: false,
|
||||
|
||||
// disable_sys_header: false,
|
||||
// disable_sys_nav: false,
|
||||
// disable_sys_footer: false,
|
||||
browser_type: null, // Safari needs special handling for scrolling in iframes.
|
||||
|
||||
browser_type: null, // Safari needs help with scrolling correctly in iframes.
|
||||
title: `OSIT's Æ`,
|
||||
|
||||
title: `OSIT's Æ`, // - Dev SvelteKit`, // Æ
|
||||
debug_mode: false,
|
||||
edit_mode: false,
|
||||
adv_mode: false,
|
||||
sync_local_config: true, // When true, pulls site config from the remote API on load.
|
||||
|
||||
// debug_menu: false, // Flag show debug menu.
|
||||
debug_mode: false, // Flag to know if we should be in debug mode and show show debug options.
|
||||
edit_mode: false, // Flag to know if we should be in edit mode and show edit options.
|
||||
adv_mode: false, // Flag to know if we should be in advanced mode and show advanced options.
|
||||
// sys_menu: true, // Flag show system menu.
|
||||
sync_local_config: true, // Flag to know if we should sync local config with the remote API server.
|
||||
|
||||
account_id: ae_account_id, // OSIT Demo _XY7DXtc9MY
|
||||
account_id: ae_account_id,
|
||||
account_code: 'not_set',
|
||||
account_name: 'Account Name Not Set',
|
||||
allow_access: true, // Set to key site key was used, otherwise set to true.
|
||||
@@ -112,18 +92,14 @@ const ae_app_local_data_defaults: key_val = {
|
||||
header_image_path: null
|
||||
},
|
||||
|
||||
// The site access codes can be pulled from the site records for an account.
|
||||
// Per-permission-level passcodes loaded from the site record on login.
|
||||
// null = no passcode required for that tier. Overwritten by the site API response.
|
||||
site_access_code_kv: {
|
||||
// 'manager': '10240',
|
||||
administrator: null,
|
||||
trusted: null,
|
||||
public: 'public1980',
|
||||
authenticated: 'auth1980'
|
||||
},
|
||||
// 'manager_passcode': '10240',
|
||||
// 'administrator_passcode': '11500',
|
||||
// 'trusted_passcode': '19111',
|
||||
// 'authenticated_passcode': 'auth2024',
|
||||
|
||||
access_type: 'anonymous',
|
||||
administrator_access: false,
|
||||
@@ -132,49 +108,40 @@ const ae_app_local_data_defaults: key_val = {
|
||||
authenticated_access: false,
|
||||
anonymous_access: true,
|
||||
|
||||
user_email: null, // Currently used with Sponsorships only?
|
||||
user_access_type: null, // Used to revert back to the user's access type after quick access (temporarily escalate permissions) turned off.
|
||||
user_email: null,
|
||||
// Stored on sign-in so the original permission level can be restored if temporarily escalated.
|
||||
user_access_type: null,
|
||||
|
||||
jwt: null, // JSON Web Token for authenticated API requests
|
||||
jwt: null, // JSON Web Token for authenticated API requests.
|
||||
|
||||
// Added 2025-04-04
|
||||
person_id: null, // The current person_id of the logged-in user (if any)
|
||||
person_id: null,
|
||||
person: {
|
||||
// WARNING: We need to add some logic on sign in to only include needed fields. 2025-08-12
|
||||
id: null, // The current person_id of the logged-in user
|
||||
// profile_id: null, // The current person_profile_id of the logged-in user
|
||||
// pronouns: null,
|
||||
// informal_name: null,
|
||||
id: null,
|
||||
given_name: null,
|
||||
// family_name: null,
|
||||
// professional_title: null,
|
||||
full_name: null, // convenience
|
||||
full_name_override: null, // was called display_name
|
||||
|
||||
// affiliations: null,
|
||||
primary_email: null, // The primary email of the logged-in person/user
|
||||
user_id: null, // The user ID of the logged-in user
|
||||
full_name: null,
|
||||
full_name_override: null, // Previously called display_name.
|
||||
primary_email: null,
|
||||
user_id: null,
|
||||
|
||||
qry_limit__people: 150,
|
||||
|
||||
show_content__person_page_help: false
|
||||
},
|
||||
|
||||
// Added 2025-04-04
|
||||
user_id: null, // The current user_id of the logged-in user (if any)
|
||||
user_id: null,
|
||||
user: {
|
||||
id: null, // The current user_id of the logged-in user
|
||||
id: null,
|
||||
username: null,
|
||||
name: null,
|
||||
email: null, // The email of the logged-in user
|
||||
allow_auth_key: null, // For sign in without password
|
||||
super: false, // Is the user a super user
|
||||
manager: false, // Is the user a global manager (can manage accounts and users)
|
||||
administrator: false, // Is the user an account administrator
|
||||
verified: false, // Is the user verified
|
||||
public: false, // Is the user a public user (can view public content)
|
||||
person_id: null, // The person ID of the logged-in user
|
||||
access_type: null, // The access type of the logged-in user
|
||||
email: null,
|
||||
allow_auth_key: null, // Magic-link token — allows sign-in without password.
|
||||
super: false,
|
||||
manager: false, // Can manage accounts and users globally.
|
||||
administrator: false, // Account-level administrator.
|
||||
verified: false,
|
||||
public: false,
|
||||
person_id: null,
|
||||
access_type: null,
|
||||
|
||||
qry_limit__users: 100
|
||||
},
|
||||
@@ -208,7 +175,6 @@ const ae_app_local_data_defaults: key_val = {
|
||||
debug_menu: {
|
||||
hide: false,
|
||||
expand: false
|
||||
// hide_quick_info: true
|
||||
},
|
||||
|
||||
app_cfg: {
|
||||
@@ -259,18 +225,10 @@ const ae_app_local_data_defaults: key_val = {
|
||||
show_list__event_presenter_obj_li: true,
|
||||
show_view__event_presenter_obj: false,
|
||||
|
||||
submit_status: null, // 'saving', 'created', 'updated'
|
||||
submit_status: null,
|
||||
|
||||
// Badge Printing
|
||||
|
||||
// Lead Retrievals
|
||||
|
||||
// Presentation Management
|
||||
|
||||
// Speakers Management
|
||||
default_session_id: null // Assign to presenters by default
|
||||
|
||||
// other
|
||||
// When set, new presenters are automatically assigned to this session.
|
||||
default_session_id: null
|
||||
},
|
||||
|
||||
journals: {},
|
||||
@@ -283,15 +241,17 @@ const ae_app_local_data_defaults: key_val = {
|
||||
for_type: null,
|
||||
for_id: null,
|
||||
|
||||
// Max complimentary guests per sponsorship tier (0 = no tier).
|
||||
// These are fallback defaults; the active event config should override via events_cfg_json.
|
||||
level_guest_max_li: {
|
||||
0: 0,
|
||||
1: 4, // CHOW 2024 - Friend
|
||||
2: 8, // CHOW 2024 - Supporter
|
||||
3: 8, // CHOW 2024 - Advocate
|
||||
4: 8, // CHOW 2024 - Champion
|
||||
5: 8, // CHOW 2024 - Presenting Partner
|
||||
6: 16, // CHOW 2024 - Signature Partner
|
||||
7: 16 // CHOW 2024 - Premier Partner
|
||||
1: 4,
|
||||
2: 8,
|
||||
3: 8,
|
||||
4: 8,
|
||||
5: 8,
|
||||
6: 16,
|
||||
7: 16
|
||||
},
|
||||
|
||||
show_edit__sponsorship_obj: false,
|
||||
@@ -305,57 +265,15 @@ const ae_app_local_data_defaults: key_val = {
|
||||
|
||||
// testing: {},
|
||||
}
|
||||
|
||||
// testing: true,
|
||||
// ver_testing: true,
|
||||
};
|
||||
|
||||
// let ae_app_local_data_struct: key_val = {
|
||||
// ...ae_app_local_data_defaults,
|
||||
// };
|
||||
// // {
|
||||
// // // ...ae_app_local_data_defaults,
|
||||
// // };
|
||||
// // console.log(`AE Stores - App Local Storage Data:`, ae_app_local_data_struct);
|
||||
// if (!ae_app_local_data_defaults?.ver_testing) {
|
||||
// console.log(`TEST: AE Stores - ver_testing missing:`, ae_app_local_data_defaults);
|
||||
// // ae_app_local_data_struct = {
|
||||
// // ...ae_app_local_data_defaults,
|
||||
// // ...ae_app_local_data_struct,
|
||||
// // };
|
||||
// } else {
|
||||
// console.log(`TEST: AE Stores - ver_testing found`);
|
||||
// }
|
||||
// if (ae_app_local_data_struct?.ver !== ae_app_local_data_defaults?.ver) {
|
||||
// console.log(`TEST: AE Stores - ver not match:`, ae_app_local_data_struct);
|
||||
|
||||
// ae_app_local_data_struct = {
|
||||
// ...ae_app_local_data_defaults,
|
||||
// };
|
||||
// } else {
|
||||
// console.log(`TEST: AE Stores - ver match: ${ae_app_local_data_struct.ver} === ${ae_app_local_data_defaults.ver}`);
|
||||
// }
|
||||
// if (!ae_app_local_data_struct?.app_cfg) {
|
||||
// console.log(`TEST: AE Stores - app_cfg missing:`, ae_app_local_data_struct);
|
||||
|
||||
// ae_app_local_data_struct = {
|
||||
// ...ae_app_local_data_defaults,
|
||||
// ...ae_app_local_data_struct,
|
||||
// };
|
||||
// }
|
||||
|
||||
// This works, but does not uses local storage:
|
||||
// export let ae_loc = writable(ae_app_local_data_struct);
|
||||
|
||||
// This works and uses local storage:
|
||||
export const ae_loc: Writable<key_val> = persisted('ae_loc', ae_app_local_data_defaults);
|
||||
// console.log(`AE Stores - App Local Storage Data:`, get(ae_loc));
|
||||
|
||||
// *** BEGIN *** Temporary app data. This should be stored to session storage.
|
||||
const ae_app_session_data_defaults: key_val = {
|
||||
// ver: '2025-04-18_1335', // ver, // '2025-04-18_1100',
|
||||
// Deployment stamp — compared against ae_loc.ver in +layout.svelte.
|
||||
// When these differ, the app reloads to flush stale persisted data.
|
||||
ver: ver,
|
||||
ver_idb: ver_idb,
|
||||
log_lvl: 0,
|
||||
|
||||
disable_sys_header: false,
|
||||
@@ -391,9 +309,8 @@ const ae_app_session_data_defaults: key_val = {
|
||||
video_clip_file_kv: {},
|
||||
processed_file_list: [],
|
||||
status__file_list: null,
|
||||
// uploaded_file_list: [],
|
||||
video_clip_file_list: [],
|
||||
submit_status: null, // 'saving', 'created', 'updated', 'saved'
|
||||
submit_status: null,
|
||||
clip_complete: null
|
||||
},
|
||||
|
||||
@@ -410,13 +327,7 @@ const ae_app_session_data_defaults: key_val = {
|
||||
},
|
||||
mod: {
|
||||
archives: {},
|
||||
events: {
|
||||
// Badge Printing
|
||||
// Lead Retrievals
|
||||
// Presentation Management
|
||||
// Speakers Management
|
||||
// other
|
||||
},
|
||||
events: {},
|
||||
journals: {},
|
||||
posts: {},
|
||||
sponsorships: {
|
||||
@@ -437,25 +348,23 @@ const ae_app_session_data_defaults: key_val = {
|
||||
show__modal_change_password: false,
|
||||
|
||||
download: {},
|
||||
// For API download and upload progress status per file.
|
||||
// Per-file progress keyed by file_id (downloads) or temp_id (uploads).
|
||||
// Shape: { status, endpoint, filename, size_total, size_loaded, percent_completed }
|
||||
api_download_kv: {},
|
||||
// Example: {example_file_id: {status: 'downloading', endpoint: '/event/file/abc123/download', filename: 'example_file_name.ext', size_total: 0, size_loaded: 0, percent_completed: 0}}
|
||||
api_upload_kv: {}, // {example_temp_id: {status: 'uploading', endpoint: '/event/file/abc123/upload', filename: 'example_file_name.ext', size_total: 0, size_loaded: 0, percent_completed: 0}}
|
||||
api_upload_kv: {},
|
||||
|
||||
test: true
|
||||
};
|
||||
// console.log(`AE Stores - App Session Storage Data:`, ae_app_session_data_defaults);
|
||||
export const ae_sess = writable(ae_app_session_data_defaults);
|
||||
|
||||
// *** BEGIN *** Temporary API data. This should be stored to session storage.
|
||||
export const ae_api_data_struct: key_val = {
|
||||
ver: '2024-08-11_11',
|
||||
fqdn: api_server_fqdn,
|
||||
base_url: api_base_url,
|
||||
base_url_bak: api_base_url_bak,
|
||||
api_secret_key: api_secret_key, // 'YOUR_API_SECRET_KEY',
|
||||
api_secret_key_bak: api_secret_key, // 'YOUR_API_SECRET_KEY',
|
||||
api_crud_super_key: api_crud_super_key, // 'YOUR_SUPER_KEY' 'zp5PtX4zUsI'
|
||||
api_secret_key: api_secret_key,
|
||||
api_secret_key_bak: api_secret_key,
|
||||
api_crud_super_key: api_crud_super_key, // Used for operations that bypass normal account-scoped CRUD limits.
|
||||
headers: {},
|
||||
account_id: ae_account_id
|
||||
};
|
||||
@@ -465,18 +374,15 @@ ae_api_headers['Content-Type'] = 'application/json';
|
||||
ae_api_headers['x-aether-api-key'] = ae_api_data_struct.api_secret_key;
|
||||
if (ae_account_id) {
|
||||
ae_api_headers['x-account-id'] = ae_account_id;
|
||||
} else {
|
||||
// ae_api_headers['x-account-id'] = ;
|
||||
}
|
||||
if (ae_no_account_id) {
|
||||
ae_api_headers['x-no-account-id'] = ae_no_account_id;
|
||||
}
|
||||
ae_api_data_struct['headers'] = ae_api_headers;
|
||||
|
||||
// console.log(`AE Stores - API Data:`, ae_api_data_struct);
|
||||
export const ae_api = writable(ae_api_data_struct);
|
||||
|
||||
// *** BEGIN *** Trigger to update the slct variables and other things.
|
||||
// General-purpose reactive trigger. Set any truthy value to signal consumers to re-query.
|
||||
const ae_trig_template: key_val = {};
|
||||
export const ae_trig = writable(ae_trig_template);
|
||||
|
||||
@@ -491,9 +397,6 @@ const slct_obj_template: key_val = {
|
||||
event_id: null,
|
||||
event_obj: {},
|
||||
event_obj_li: [],
|
||||
// 'event_exhibit_id': null,
|
||||
// 'event_exhibit_obj': {},
|
||||
// 'event_exhibit_obj_li': [],
|
||||
event_presentation_id: null,
|
||||
event_presentation_obj: {},
|
||||
event_presentation_obj_li: [],
|
||||
@@ -516,26 +419,18 @@ const slct_obj_template: key_val = {
|
||||
post_comment_obj: {},
|
||||
post_comment_obj_li: []
|
||||
};
|
||||
// console.log(`AE Stores - Selected Objects:`, slct_obj_template);
|
||||
|
||||
// This works, and uses *session* (not local) storage:
|
||||
// In-memory only (not persisted) — separate browser tabs can have different selections.
|
||||
export const slct = writable(slct_obj_template);
|
||||
|
||||
// This works and uses *local* storage:
|
||||
// export let slct: Writable<key_val> = persisted('ae_slct', slct_obj_template);
|
||||
|
||||
/* *** BEGIN *** Initialize slct_trigger */
|
||||
// Intended for temporary session storage.
|
||||
// Updated 2024-02-27
|
||||
// Increment (or set any truthy value) to tell subscribers that the selection changed
|
||||
// and they should re-query their data.
|
||||
export const slct_trigger: any = writable(null);
|
||||
// console.log(`AE Stores - Selected Trigger:`, slct_trigger);
|
||||
|
||||
// Auth error signal — set by API helpers on 401/403 to trigger the session-expired banner in the root layout.
|
||||
// Only set from browser context (never SSR). 'expired' covers both 401 and 403 responses.
|
||||
export const ae_auth_error = writable<{ type: 'expired' | null; ts: number | null }>({ type: null, ts: null });
|
||||
|
||||
/* *** BEGIN *** Create time variable */
|
||||
// Updated 2020
|
||||
// Reactive clock — updates every second. Used for live countdown and elapsed-time displays.
|
||||
export const time = readable(new Date(), function start(set) {
|
||||
const interval = setInterval(() => {
|
||||
set(new Date());
|
||||
|
||||
Reference in New Issue
Block a user