refactor(events): harden V3 String-Only ID vision and fix Session Alert store error
- Standardized Event module logic files to strictly use random string IDs, ensuring frontend consistency and avoiding 'Integer Trap' 404s. - Refactored 'ae_comp__event_session_alert.svelte' to accept a plain object instead of a store/observable, resolving the 'store_invalid_shape' error in list loops. - Updated all callers of the alert component to pass unwrapped session objects. - Cleaned up event-related UI components to remove redundant '_random' field lookups and align with V3 CRUD patterns. - Updated project metadata (GEMINI.md, TODO.md) to reflect the new memory structure and latest hardened state.
This commit is contained in:
@@ -9,7 +9,7 @@ import { load_ae_obj_li__event_session } from '$lib/ae_events/ae_events__event_s
|
||||
|
||||
const ae_promises: key_val = {};
|
||||
|
||||
// Updated 2026-01-20 to V3
|
||||
// Updated 2026-01-27 to V3 String-Only ID Standard
|
||||
export async function load_ae_obj_id__event_location({
|
||||
api_cfg,
|
||||
event_location_id,
|
||||
@@ -34,7 +34,7 @@ export async function load_ae_obj_id__event_location({
|
||||
}
|
||||
|
||||
try {
|
||||
ae_promises.load__event_location_obj = await api.get_ae_obj_v3({
|
||||
const result = await api.get_ae_obj_v3({
|
||||
api_cfg,
|
||||
obj_type: 'event_location',
|
||||
obj_id: event_location_id,
|
||||
@@ -42,16 +42,18 @@ export async function load_ae_obj_id__event_location({
|
||||
log_lvl
|
||||
});
|
||||
|
||||
if (ae_promises.load__event_location_obj) {
|
||||
if (result) {
|
||||
const processed = await process_ae_obj__event_location_props({
|
||||
obj_li: [result],
|
||||
log_lvl
|
||||
});
|
||||
ae_promises.load__event_location_obj = processed[0];
|
||||
|
||||
if (try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__event_location_props({
|
||||
obj_li: [ae_promises.load__event_location_obj],
|
||||
log_lvl
|
||||
});
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'location',
|
||||
obj_li: processed_obj_li,
|
||||
obj_li: [ae_promises.load__event_location_obj],
|
||||
properties_to_save,
|
||||
log_lvl
|
||||
});
|
||||
@@ -73,7 +75,7 @@ export async function load_ae_obj_id__event_location({
|
||||
return await _handle_nested_loads(ae_promises.load__event_location_obj, { api_cfg, inc_file_li, inc_session_li, inc_all_file_li, log_lvl });
|
||||
}
|
||||
|
||||
// Updated 2026-01-20 to V3
|
||||
// Updated 2026-01-27 to V3 String-Only ID Standard
|
||||
export async function load_ae_obj_li__event_location({
|
||||
api_cfg,
|
||||
for_obj_type = 'event',
|
||||
@@ -113,7 +115,7 @@ export async function load_ae_obj_li__event_location({
|
||||
}
|
||||
|
||||
try {
|
||||
ae_promises.load__event_location_obj_li = await api.get_ae_obj_li_v3({
|
||||
const result_li = await api.get_ae_obj_li_v3({
|
||||
api_cfg,
|
||||
obj_type: 'event_location',
|
||||
for_obj_type,
|
||||
@@ -126,16 +128,18 @@ export async function load_ae_obj_li__event_location({
|
||||
log_lvl
|
||||
});
|
||||
|
||||
if (ae_promises.load__event_location_obj_li) {
|
||||
if (result_li) {
|
||||
const processed = await process_ae_obj__event_location_props({
|
||||
obj_li: result_li,
|
||||
log_lvl
|
||||
});
|
||||
ae_promises.load__event_location_obj_li = processed;
|
||||
|
||||
if (try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__event_location_props({
|
||||
obj_li: ae_promises.load__event_location_obj_li,
|
||||
log_lvl
|
||||
});
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'location',
|
||||
obj_li: processed_obj_li,
|
||||
obj_li: ae_promises.load__event_location_obj_li,
|
||||
properties_to_save,
|
||||
log_lvl
|
||||
});
|
||||
@@ -167,7 +171,8 @@ export async function load_ae_obj_li__event_location({
|
||||
* Handle nested data loads for a single location object.
|
||||
*/
|
||||
async function _handle_nested_loads(location_obj: any, { api_cfg, inc_file_li, inc_session_li, inc_all_file_li, log_lvl }: any) {
|
||||
const current_location_id = location_obj.event_location_id_random || location_obj.event_location_id || location_obj.id;
|
||||
// String-Only ID Vision: the '_id' field IS the string ID
|
||||
const current_location_id = location_obj.id || location_obj.event_location_id;
|
||||
|
||||
if (inc_file_li) {
|
||||
location_obj.event_file_li = await load_ae_obj_li__event_file({
|
||||
@@ -221,27 +226,32 @@ export async function create_ae_obj__event_location({
|
||||
api_cfg,
|
||||
obj_type: 'event_location',
|
||||
fields: {
|
||||
event_id_random: event_id,
|
||||
event_id,
|
||||
...data_kv
|
||||
},
|
||||
log_lvl
|
||||
});
|
||||
|
||||
if (result && try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__event_location_props({
|
||||
if (result) {
|
||||
const processed = await process_ae_obj__event_location_props({
|
||||
obj_li: [result],
|
||||
log_lvl
|
||||
});
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'location',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save,
|
||||
log_lvl
|
||||
});
|
||||
const processed_obj = processed[0];
|
||||
|
||||
if (try_cache) {
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'location',
|
||||
obj_li: [processed_obj],
|
||||
properties_to_save,
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
return processed_obj;
|
||||
}
|
||||
|
||||
return result;
|
||||
return null;
|
||||
}
|
||||
|
||||
// Updated 2026-01-20 to V3
|
||||
@@ -303,21 +313,26 @@ export async function update_ae_obj__event_location({
|
||||
log_lvl
|
||||
});
|
||||
|
||||
if (result && try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__event_location_props({
|
||||
if (result) {
|
||||
const processed = await process_ae_obj__event_location_props({
|
||||
obj_li: [result],
|
||||
log_lvl
|
||||
});
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'location',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save,
|
||||
log_lvl
|
||||
});
|
||||
const processed_obj = processed[0];
|
||||
|
||||
if (try_cache) {
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'location',
|
||||
obj_li: [processed_obj],
|
||||
properties_to_save,
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
return processed_obj;
|
||||
}
|
||||
|
||||
return result;
|
||||
return null;
|
||||
}
|
||||
|
||||
// Updated 2026-01-20 to V3
|
||||
@@ -355,7 +370,7 @@ export async function search__event_location({
|
||||
|
||||
const search_query: any = {
|
||||
q: qry_str,
|
||||
and: [{ field: 'event_id_random', op: 'eq', value: event_id }]
|
||||
and: [{ field: 'event_id', op: 'eq', value: event_id }]
|
||||
};
|
||||
|
||||
if (enabled === 'enabled') search_query.and.push({ field: 'enable', op: 'eq', value: true });
|
||||
@@ -374,21 +389,25 @@ export async function search__event_location({
|
||||
log_lvl
|
||||
});
|
||||
|
||||
if (result_li && try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__event_location_props({
|
||||
if (result_li) {
|
||||
const processed = await process_ae_obj__event_location_props({
|
||||
obj_li: result_li,
|
||||
log_lvl
|
||||
});
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'location',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save,
|
||||
log_lvl
|
||||
});
|
||||
|
||||
if (try_cache) {
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'location',
|
||||
obj_li: processed,
|
||||
properties_to_save,
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
return processed;
|
||||
}
|
||||
|
||||
return result_li || [];
|
||||
return [];
|
||||
}
|
||||
|
||||
export const properties_to_save = [
|
||||
@@ -441,6 +460,7 @@ async function _process_generic_props<T extends Record<string, any>>({
|
||||
(processed_obj as any)[newKey] = processed_obj[key];
|
||||
}
|
||||
}
|
||||
// String-Only ID Vision: Map [obj_type]_id_random to 'id'
|
||||
const randomIdKey = `${obj_type}_id_random`;
|
||||
if (processed_obj[randomIdKey]) {
|
||||
(processed_obj as any).id = processed_obj[randomIdKey];
|
||||
|
||||
Reference in New Issue
Block a user