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:
@@ -8,21 +8,20 @@ import type { Writable } from 'svelte/store';
|
||||
|
||||
import type { key_val } from '$lib/stores/ae_stores';
|
||||
|
||||
// Set the version for the app data. Changing this should force a notification and ask the user to clear and reload the page.
|
||||
// Deployment version stamp. Compared against events_sess.ver in events/+layout.svelte
|
||||
// to detect stale persisted data after a deploy (triggers a reload). Bump this alongside
|
||||
// events_session_data_struct.ver. See store_versions.ts for the schema-level wipe mechanism.
|
||||
const ver = '2025-10-16_2139';
|
||||
const ver_idb = '2025-10-16_2139';
|
||||
|
||||
/* *** BEGIN *** Initialize events_local_data_struct */
|
||||
// Longer-term app data. This should be stored to *local* storage.
|
||||
// Updated 2024-03-06
|
||||
// Persisted to localStorage. Retains user preferences and event-specific config across
|
||||
// browser sessions. See store_versions.ts for the schema-level invalidation mechanism.
|
||||
const events_local_data_struct: key_val = {
|
||||
__version: AE_EVENTS_LOC_VERSION, // Schema version gate — see store_versions.ts
|
||||
ver: ver,
|
||||
ver_idb: ver_idb,
|
||||
ver: ver, // Deployment stamp — compared against events_sess.ver to trigger reloads.
|
||||
|
||||
// Shared
|
||||
name: 'Aether - Events (SvelteKit 2.x Svelte 4.x)',
|
||||
title: `OSIT's Æ Events`, // - Dev SvelteKit`, // Æ
|
||||
name: 'Aether - Events',
|
||||
title: `OSIT's Æ Events`,
|
||||
|
||||
ds: {},
|
||||
|
||||
@@ -44,41 +43,19 @@ const events_local_data_struct: key_val = {
|
||||
// The auth__entered_key (usually email or person_id) and auth__entered_passcode is found under events_sess.entered_key and events_sess.entered_passcode because it should be temporary.
|
||||
// auth__entered_passcode: null,
|
||||
|
||||
// The auth__kv (key value pairs) is used to store the xyz IDs that the browser client can access. This is a key value list of xyz ID and created datetime stamp (or just true). These should not be more than X days old.
|
||||
// auth__kv tracks which IDs the browser client is permitted to access.
|
||||
// Each entry is an ID mapped to true, false, 'read', or 'write'.
|
||||
// Keys should be no older than a configurable max age (checked on read).
|
||||
auth__kv: {
|
||||
event: {
|
||||
// 'LNDF-67-89-92': true
|
||||
},
|
||||
exhibit: {
|
||||
// 'LNDF-67-89-92': true
|
||||
},
|
||||
location: {
|
||||
// 'LNDF-67-89-92': true
|
||||
},
|
||||
session: {
|
||||
// 'LNDF-67-89-92': true, false, 'read', 'write'
|
||||
},
|
||||
presentation: {
|
||||
// 'LNDF-67-89-92': true
|
||||
},
|
||||
presenter: {
|
||||
// 'LNDF-67-89-92': true
|
||||
},
|
||||
person: {
|
||||
// 'LNDF-67-89-92': true
|
||||
}
|
||||
event: {},
|
||||
exhibit: {},
|
||||
location: {},
|
||||
session: {},
|
||||
presentation: {},
|
||||
presenter: {},
|
||||
person: {}
|
||||
},
|
||||
|
||||
// auth__session_kv: {
|
||||
// // {'LNDF-67-89-92': true}
|
||||
// },
|
||||
// auth__presentation_kv: {
|
||||
// // {'LNDF-67-89-92': true}
|
||||
// },
|
||||
// auth__presenter_kv: {
|
||||
// // {'LNDF-67-89-92': true}
|
||||
// },
|
||||
|
||||
// Badge Printing
|
||||
badges: {
|
||||
auto_view: true,
|
||||
@@ -91,8 +68,6 @@ const events_local_data_struct: key_val = {
|
||||
|
||||
show_element__cfg: true,
|
||||
show_element__cfg_detail: false,
|
||||
// 'theme_mode': 'dark',
|
||||
// 'theme_name': 'wintry',
|
||||
|
||||
fulltext_search_qry_str: null,
|
||||
search_badge_type_code: null,
|
||||
@@ -114,10 +89,6 @@ const events_local_data_struct: key_val = {
|
||||
classes__form: 'border border-surface-200 p-4 space-y-4 rounded-container'
|
||||
},
|
||||
|
||||
// Event Files - uploads for sessions, presenters, etc
|
||||
// 'files': {
|
||||
// },
|
||||
|
||||
// Event Presentation Launcher (and native Electron app)
|
||||
launcher: {
|
||||
// default - browser, onsite - browser onsite, native - Electron app onsite
|
||||
@@ -192,8 +163,6 @@ const events_local_data_struct: key_val = {
|
||||
},
|
||||
|
||||
native: {
|
||||
// 'local_file_cache_path': aether_cfg_data.app.local_file_cache_path,
|
||||
// 'host_file_temp_path': aether_cfg_data.app.host_file_temp_path,
|
||||
host_file_config_path: 'device_configs/ae_native_app_config.default.json'
|
||||
},
|
||||
|
||||
@@ -223,8 +192,8 @@ const events_local_data_struct: key_val = {
|
||||
show_content__email_link_warning: true,
|
||||
|
||||
default_to_scan: true,
|
||||
|
||||
// For ISHLT 2024 Annual Meeting only!
|
||||
// Fallback external registration ID used when building lead export data.
|
||||
// Should be overridden by the active event's external_event_id in cfg_json.
|
||||
default__external_registration_id: '2024_Annual Meeting',
|
||||
|
||||
auto_view: true, // Show the new lead after added by scan or search
|
||||
@@ -251,15 +220,11 @@ const events_local_data_struct: key_val = {
|
||||
// The entered_passcode is the exhibit booths shared passcode for staff. This is used to initially access the lead retrieval service.
|
||||
entered_passcode: null,
|
||||
|
||||
// The auth_exhibit_kv (key value pairs) is used to store the exhibit IDs that the browser client can access. This is a key value list of exhibit ID and created datetime stamp. These should not be more than X days old. The entered_passcode for events_sess.leads is what they are entering to log in.
|
||||
auth_exhibit_kv: {
|
||||
// {'LNDF-67-89-92': {key: 'example@oneskyit.com', updated_on: '2024-03-13T08:05:29Z}}
|
||||
},
|
||||
// auth_exhibit_kv: key-value of exhibit IDs this browser client
|
||||
// is authorized for, mapped to { key, updated_on }. Entries expire
|
||||
// after a configurable max age and must be re-authenticated.
|
||||
auth_exhibit_kv: {},
|
||||
|
||||
// The auth_exhibit_license_li is used to store the exhibit license(s) being used on the browser client. There can be multiple exhibit IDs, but only one license per exhibit ID for the browser client. This is used to determine who can actually access and use the lead retrieval service. This is a key value list of key (email address) and created datetime stamp. These should not be more than X days old.
|
||||
// auth_exhibit_license_li: {
|
||||
// // 'LNDF-67-89-92': { 'key': 'example@oneskyit.com', 'updated_on': '2024-03-13T08:05:29Z'}
|
||||
// },
|
||||
edit_license_li: false,
|
||||
|
||||
// The "tab" is a key value list of exhibit ID and tab name. This is intentionally using local storage to store the current tab for each exhibit.
|
||||
@@ -298,10 +263,7 @@ const events_local_data_struct: key_val = {
|
||||
require__presenter_agree: false,
|
||||
require__session_agree: false,
|
||||
|
||||
// show_content__agree_text: false,
|
||||
show_content__event_view: null,
|
||||
// show__launcher_link: false,
|
||||
// show__location_link: false,
|
||||
show_content__location_qr: false,
|
||||
show_content__presentation_description: false, // Note that this is for *all* presentations in the user interface. It is a global setting.
|
||||
show_content__presenter_page_help: true,
|
||||
@@ -348,10 +310,6 @@ const events_local_data_struct: key_val = {
|
||||
show_menu__event_reports: null,
|
||||
|
||||
show_report: null,
|
||||
// show_report__presenters_agree: false,
|
||||
// show_report__recent_files: false,
|
||||
|
||||
// time_format: 'time_12_short', // 'time_short', 'time_12_short'
|
||||
|
||||
disable_submit__opt_out: true,
|
||||
submit_status__opt_out: null,
|
||||
@@ -364,27 +322,15 @@ const events_local_data_struct: key_val = {
|
||||
}
|
||||
}
|
||||
|
||||
// Speakers Management (Collection)
|
||||
// 'speakers': {
|
||||
// },
|
||||
|
||||
// other
|
||||
};
|
||||
// console.log(`AE Stores - App Events Local Storage Data:`, events_local_data_struct);
|
||||
|
||||
// This works, but does not uses local storage:
|
||||
// export let ae_loc = writable(events_local_data_struct);
|
||||
|
||||
// This works and uses *local* storage:
|
||||
export const events_loc: Writable<key_val> = persisted('ae_events_loc', events_local_data_struct);
|
||||
// console.log(`AE Stores - App Local Storage Data:`, get(ae_loc));
|
||||
|
||||
/* *** BEGIN *** Initialize events_session_data_struct */
|
||||
// Temporary app data. This should be stored to session storage.
|
||||
// Updated 2024-03-06
|
||||
// In-memory only (writable, not persisted). Resets on page load.
|
||||
const events_session_data_struct: key_val = {
|
||||
// Deployment stamp — compared against events_loc.ver in events/+layout.svelte.
|
||||
ver: ver,
|
||||
ver_idb: ver_idb,
|
||||
log_lvl: 1,
|
||||
|
||||
// Shared
|
||||
@@ -477,8 +423,6 @@ const events_session_data_struct: key_val = {
|
||||
|
||||
// Lead Retrievals (Exhibit)
|
||||
leads: {
|
||||
example: true,
|
||||
|
||||
show_form__license: false,
|
||||
show_form__search: false,
|
||||
show_form__scan: false,
|
||||
@@ -496,7 +440,6 @@ const events_session_data_struct: key_val = {
|
||||
last_refresh_time: null as string | null,
|
||||
next_refresh_countdown: 0,
|
||||
|
||||
// The entered_passcode is the exhibit booths shared passcode for staff. This is used to initially access the lead retrieval service.
|
||||
entered_passcode: null,
|
||||
|
||||
tmp_license: {
|
||||
@@ -517,24 +460,6 @@ const events_session_data_struct: key_val = {
|
||||
qr_scan_result: null
|
||||
},
|
||||
|
||||
stripe: {
|
||||
license_qty: 1,
|
||||
rental_qty: 0,
|
||||
rental_option: true,
|
||||
api_use: false,
|
||||
client_reference_id: null,
|
||||
publishable_key: 'pk_live_zqaWNDfak2eDHeqnRiyaJcFi',
|
||||
btn_payment_id: null,
|
||||
btn_1_license: 'buy_btn_1OvqWJ2gJkNsDuiNqMCWz5nG',
|
||||
btn_1_license_rental: 'buy_btn_1OvqVA2gJkNsDuiNhk9r8Io2',
|
||||
btn_3_license: 'buy_btn_1OvrI22gJkNsDuiNXjBg3c4Y',
|
||||
btn_3_license_rental: 'buy_btn_1OvrKa2gJkNsDuiNhSBCkNau',
|
||||
btn_6_license: 'buy_btn_1OvrWc2gJkNsDuiN7mnwvZNL',
|
||||
btn_6_license_rental: 'buy_btn_1OvrXP2gJkNsDuiNZpWZs3Uy',
|
||||
btn_10_license: 'buy_btn_1OvrPM2gJkNsDuiNRCMHfSuz',
|
||||
btn_10_license_rental: 'buy_btn_1OvrPs2gJkNsDuiN1nPkjPOM'
|
||||
},
|
||||
|
||||
// Presentation Management
|
||||
pres_mgmt: {
|
||||
// link: {
|
||||
@@ -616,11 +541,10 @@ const events_session_data_struct: key_val = {
|
||||
|
||||
// other
|
||||
};
|
||||
// console.log(`AE Stores - App Events Session Storage Data:`, events_session_data_struct);
|
||||
export const events_sess = writable(events_session_data_struct);
|
||||
|
||||
/* *** BEGIN *** Initialize events_slct and events_trigger */
|
||||
/* The slct and slct_trigger variable should not be stored in local storage. Only use session storage because browser tabs can be open to different events, badges, exhibits, etc. */
|
||||
// In-memory only — tabs can have different event/session/presenter selections.
|
||||
|
||||
// Intended for temporary session storage.
|
||||
// Updated 2024-03-06
|
||||
@@ -692,20 +616,14 @@ const events_slct_obj_template: key_val = {
|
||||
auth__event_presenter_id: null,
|
||||
auth__event_presentation_id: null
|
||||
};
|
||||
// console.log(`AE Stores - Selected Events Objects:`, events_slct_obj_template);
|
||||
|
||||
// This works, and uses *session* (not local) storage:
|
||||
// In-memory only (not persisted) — separate tabs can select different events/sessions/presenters.
|
||||
export const events_slct = writable(events_slct_obj_template);
|
||||
|
||||
// This works and uses *local* storage:
|
||||
// export let events_slct: Writable<key_val> = persisted('ae_events_slct', events_slct_obj_template);
|
||||
|
||||
/* *** BEGIN *** Initialize events_trigger */
|
||||
// Intended for temporary session storage.
|
||||
// Updated 2024-03-06
|
||||
// Broadcast trigger — increment or set truthy to signal subscribers to re-query.
|
||||
export const events_trigger: any = writable(null);
|
||||
// console.log(`AE Events Stores - Events Trigger:`, events_trigger);
|
||||
|
||||
// events_trig: fine-grained triggers per object type.
|
||||
// Set an ID to signal that specific object needs to be re-fetched.
|
||||
const tmp__events_trig: key_val = {
|
||||
event_id: null,
|
||||
event_id_li: [],
|
||||
@@ -721,22 +639,7 @@ const tmp__events_trig: key_val = {
|
||||
// console.log(`AE Stores - Events Trigger:`, events_trig);
|
||||
export const events_trig: Writable<key_val> = writable(tmp__events_trig);
|
||||
|
||||
/* *** BEGIN *** TESTING Initialize trig_resp */
|
||||
// The idea behind this is for a shared (Svelte app (within Events for now)) trigger and response. In theory this could be used to monitor multiple downloads or have a universal status area. Intended for temporary session storage.
|
||||
// Updated 2024-06-25
|
||||
// events_trig_kv: response/status map — keys are request IDs, values are
|
||||
// completion status or Promise results. Used for tracking parallel downloads.
|
||||
const tmp__events_trig_kv: key_val = {};
|
||||
// {
|
||||
// 'example-1':
|
||||
// {
|
||||
// 'a-rand-id-1': true,
|
||||
// 'a-rand-id-2': false,
|
||||
// 'a-rand-id-3': Promise.resolve('This is a test promise.'),
|
||||
// },
|
||||
// 'example-2':
|
||||
// {
|
||||
// 'a-rand-id-4': true,
|
||||
// 'a-rand-id-5': false,
|
||||
// 'a-rand-id-6': Promise.resolve('This is a test promise.'),
|
||||
// },
|
||||
// };
|
||||
export const events_trig_kv = writable(tmp__events_trig_kv);
|
||||
Reference in New Issue
Block a user