Last round of prettier: npx prettier --write src/

This commit is contained in:
Scott Idem
2026-03-24 13:27:40 -04:00
parent 23d25bf65a
commit a8f3c29b9f
146 changed files with 13201 additions and 9277 deletions

View File

@@ -92,11 +92,15 @@ async function _process_generic_props<T extends Record<string, any>>({
(processed_obj as any).description = '';
}
(processed_obj as any).tmp_sort_1 = `${group}_${priority}_${sort}_${updated}`;
(processed_obj as any).tmp_sort_2 = `${group}_${priority}_${sort}_${name}_${updated}`;
(processed_obj as any).tmp_sort_1 =
`${group}_${priority}_${sort}_${updated}`;
(processed_obj as any).tmp_sort_2 =
`${group}_${priority}_${sort}_${name}_${updated}`;
if (specific_processor) {
processed_obj = await Promise.resolve(specific_processor(processed_obj));
processed_obj = await Promise.resolve(
specific_processor(processed_obj)
);
}
processed_obj_li.push(processed_obj as T);
@@ -137,7 +141,9 @@ export async function load_ae_obj_id__event_exhibit({
}): Promise<ae_EventExhibit | null> {
const start_time = performance.now();
if (log_lvl) {
console.log(`🔎 [Trace] load_ae_obj_id__event_exhibit: START (id=${exhibit_id}, try_cache=${try_cache})`);
console.log(
`🔎 [Trace] load_ae_obj_id__event_exhibit: START (id=${exhibit_id}, try_cache=${try_cache})`
);
}
// 1. FAST PATH: Return cached data immediately
@@ -146,34 +152,74 @@ export async function load_ae_obj_id__event_exhibit({
const cached = await db_events.exhibit.get(exhibit_id);
if (cached) {
const elapsed = (performance.now() - start_time).toFixed(2);
if (log_lvl) console.log(`✅ [Trace] load_ae_obj_id: CACHE HIT at ${elapsed}ms. Returning stale exhibit shell.`);
if (log_lvl)
console.log(
`✅ [Trace] load_ae_obj_id: CACHE HIT at ${elapsed}ms. Returning stale exhibit shell.`
);
// Background refresh (non-blocking)
_refresh_exhibit_id_background({ api_cfg, exhibit_id, view, try_cache, log_lvl: log_lvl > 1 ? log_lvl : 0 });
_refresh_exhibit_id_background({
api_cfg,
exhibit_id,
view,
try_cache,
log_lvl: log_lvl > 1 ? log_lvl : 0
});
return cached;
}
} catch (e) {
if (log_lvl) console.error(`❌ [Trace] load_ae_obj_id: Cache access error:`, e);
if (log_lvl)
console.error(
`❌ [Trace] load_ae_obj_id: Cache access error:`,
e
);
}
}
// 2. SLOW PATH: Wait for API
return await _refresh_exhibit_id_background({ api_cfg, exhibit_id, view, try_cache, log_lvl });
return await _refresh_exhibit_id_background({
api_cfg,
exhibit_id,
view,
try_cache,
log_lvl
});
}
async function _refresh_exhibit_id_background({ api_cfg, exhibit_id, view, try_cache, log_lvl }: any) {
async function _refresh_exhibit_id_background({
api_cfg,
exhibit_id,
view,
try_cache,
log_lvl
}: any) {
const start_time = performance.now();
if (typeof navigator !== 'undefined' && !navigator.onLine) return null;
try {
if (log_lvl) console.log(`📡 [Trace] _refresh_exhibit_id: API Fetching id=${exhibit_id}`);
const result = await api.get_ae_obj({ api_cfg, obj_type: 'event_exhibit', obj_id: exhibit_id, view, log_lvl });
if (log_lvl)
console.log(
`📡 [Trace] _refresh_exhibit_id: API Fetching id=${exhibit_id}`
);
const result = await api.get_ae_obj({
api_cfg,
obj_type: 'event_exhibit',
obj_id: exhibit_id,
view,
log_lvl
});
if (result) {
const processed = await process_ae_obj__exhibit_props({ obj_li: [result], log_lvl });
const processed = await process_ae_obj__exhibit_props({
obj_li: [result],
log_lvl
});
const processed_obj = processed[0];
const elapsed = (performance.now() - start_time).toFixed(2);
if (log_lvl) console.log(`📦 [Trace] _refresh_exhibit_id: Received from API at ${elapsed}ms`);
if (log_lvl)
console.log(
`📦 [Trace] _refresh_exhibit_id: Received from API at ${elapsed}ms`
);
if (try_cache) {
await db_save_ae_obj_li__ae_obj({
@@ -187,7 +233,11 @@ async function _refresh_exhibit_id_background({ api_cfg, exhibit_id, view, try_c
return processed_obj;
}
} catch (e) {
if (log_lvl) console.error(`❌ [Trace] _refresh_exhibit_id: API error for id=${exhibit_id}:`, e);
if (log_lvl)
console.error(
`❌ [Trace] _refresh_exhibit_id: API error for id=${exhibit_id}:`,
e
);
}
return null;
}
@@ -225,36 +275,82 @@ export async function load_ae_obj_li__event_exhibit({
}): Promise<ae_EventExhibit[]> {
const start_time = performance.now();
if (log_lvl) {
console.log(`🔎 [Trace] load_ae_obj_li__event_exhibit: START (event=${event_id}, try_cache=${try_cache})`);
console.log(
`🔎 [Trace] load_ae_obj_li__event_exhibit: START (event=${event_id}, try_cache=${try_cache})`
);
}
if (try_cache) {
try {
const cached_li = await db_events.exhibit
.where('event_id').equals(event_id)
.where('event_id')
.equals(event_id)
.toArray();
if (cached_li && cached_li.length > 0) {
const elapsed = (performance.now() - start_time).toFixed(2);
if (log_lvl) console.log(`✅ [Trace] load_ae_obj_li: CACHE HIT at ${elapsed}ms (${cached_li.length} items).`);
if (log_lvl)
console.log(
`✅ [Trace] load_ae_obj_li: CACHE HIT at ${elapsed}ms (${cached_li.length} items).`
);
// Background refresh (non-blocking)
_refresh_exhibit_li_background({ api_cfg, event_id, enabled, hidden, view, limit, offset, order_by_li, try_cache, log_lvl: log_lvl > 1 ? log_lvl : 0 });
_refresh_exhibit_li_background({
api_cfg,
event_id,
enabled,
hidden,
view,
limit,
offset,
order_by_li,
try_cache,
log_lvl: log_lvl > 1 ? log_lvl : 0
});
return cached_li;
}
} catch (e) {
if (log_lvl) console.error(`❌ [Trace] load_ae_obj_li: Cache access error:`, e);
if (log_lvl)
console.error(
`❌ [Trace] load_ae_obj_li: Cache access error:`,
e
);
}
}
return await _refresh_exhibit_li_background({ api_cfg, event_id, enabled, hidden, view, limit, offset, order_by_li, try_cache, log_lvl });
return await _refresh_exhibit_li_background({
api_cfg,
event_id,
enabled,
hidden,
view,
limit,
offset,
order_by_li,
try_cache,
log_lvl
});
}
async function _refresh_exhibit_li_background({ api_cfg, event_id, enabled, hidden, view, limit, offset, order_by_li, try_cache, log_lvl }: any) {
async function _refresh_exhibit_li_background({
api_cfg,
event_id,
enabled,
hidden,
view,
limit,
offset,
order_by_li,
try_cache,
log_lvl
}: any) {
const start_time = performance.now();
if (typeof navigator !== 'undefined' && !navigator.onLine) return [];
try {
if (log_lvl) console.log(`📡 [Trace] _refresh_exhibit_li: API Fetching exhibits for event=${event_id}`);
if (log_lvl)
console.log(
`📡 [Trace] _refresh_exhibit_li: API Fetching exhibits for event=${event_id}`
);
const result_li = await api.get_ae_obj_li({
api_cfg,
obj_type: 'event_exhibit',
@@ -270,9 +366,15 @@ async function _refresh_exhibit_li_background({ api_cfg, event_id, enabled, hidd
});
if (result_li) {
const processed = await process_ae_obj__exhibit_props({ obj_li: result_li, log_lvl });
const processed = await process_ae_obj__exhibit_props({
obj_li: result_li,
log_lvl
});
const elapsed = (performance.now() - start_time).toFixed(2);
if (log_lvl) console.log(`📦 [Trace] _refresh_exhibit_li: Received ${processed.length} items from API at ${elapsed}ms.`);
if (log_lvl)
console.log(
`📦 [Trace] _refresh_exhibit_li: Received ${processed.length} items from API at ${elapsed}ms.`
);
if (try_cache) {
await db_save_ae_obj_li__ae_obj({
@@ -286,7 +388,8 @@ async function _refresh_exhibit_li_background({ api_cfg, event_id, enabled, hidd
return processed;
}
} catch (e) {
if (log_lvl) console.error(`❌ [Trace] _refresh_exhibit_li: API error:`, e);
if (log_lvl)
console.error(`❌ [Trace] _refresh_exhibit_li: API error:`, e);
}
return [];
}
@@ -295,87 +398,93 @@ async function _refresh_exhibit_li_background({ api_cfg, event_id, enabled, hidd
* Exhibit Create (V3)
*/
export async function create_ae_obj__exhibit({
api_cfg,
event_id,
data_kv,
try_cache = true,
log_lvl = 0
api_cfg,
event_id,
data_kv,
try_cache = true,
log_lvl = 0
}: {
api_cfg: any;
event_id: string;
data_kv: key_val;
try_cache?: boolean;
log_lvl?: number;
api_cfg: any;
event_id: string;
data_kv: key_val;
try_cache?: boolean;
log_lvl?: number;
}): Promise<ae_EventExhibit | null> {
const result = await api.create_nested_obj({
api_cfg,
parent_type: 'event',
parent_id: event_id,
child_type: 'event_exhibit',
fields: { ...data_kv },
log_lvl
});
const result = await api.create_nested_obj({
api_cfg,
parent_type: 'event',
parent_id: event_id,
child_type: 'event_exhibit',
fields: { ...data_kv },
log_lvl
});
if (result) {
const processed = await process_ae_obj__exhibit_props({ obj_li: [result], log_lvl });
const processed_obj = processed[0];
if (try_cache) {
await db_save_ae_obj_li__ae_obj({
db_instance: db_events,
table_name: 'exhibit',
obj_li: [processed_obj],
properties_to_save: properties_to_save_exhibit,
log_lvl
});
}
return processed_obj;
}
return null;
if (result) {
const processed = await process_ae_obj__exhibit_props({
obj_li: [result],
log_lvl
});
const processed_obj = processed[0];
if (try_cache) {
await db_save_ae_obj_li__ae_obj({
db_instance: db_events,
table_name: 'exhibit',
obj_li: [processed_obj],
properties_to_save: properties_to_save_exhibit,
log_lvl
});
}
return processed_obj;
}
return null;
}
/**
* Exhibit Update (V3)
*/
export async function update_ae_obj__exhibit({
api_cfg,
event_id,
exhibit_id,
data_kv,
try_cache = true,
log_lvl = 0
api_cfg,
event_id,
exhibit_id,
data_kv,
try_cache = true,
log_lvl = 0
}: {
api_cfg: any;
event_id: string;
exhibit_id: string;
data_kv: key_val;
try_cache?: boolean;
log_lvl?: number;
api_cfg: any;
event_id: string;
exhibit_id: string;
data_kv: key_val;
try_cache?: boolean;
log_lvl?: number;
}): Promise<ae_EventExhibit | null> {
const result = await api.update_nested_obj({
api_cfg,
parent_type: 'event',
parent_id: event_id,
child_type: 'event_exhibit',
child_id: exhibit_id,
fields: data_kv,
log_lvl
});
const result = await api.update_nested_obj({
api_cfg,
parent_type: 'event',
parent_id: event_id,
child_type: 'event_exhibit',
child_id: exhibit_id,
fields: data_kv,
log_lvl
});
if (result) {
const processed = await process_ae_obj__exhibit_props({ obj_li: [result], log_lvl });
const processed_obj = processed[0];
if (try_cache) {
await db_save_ae_obj_li__ae_obj({
db_instance: db_events,
table_name: 'exhibit',
obj_li: [processed_obj],
properties_to_save: properties_to_save_exhibit,
log_lvl
});
}
return processed_obj;
}
return null;
if (result) {
const processed = await process_ae_obj__exhibit_props({
obj_li: [result],
log_lvl
});
const processed_obj = processed[0];
if (try_cache) {
await db_save_ae_obj_li__ae_obj({
db_instance: db_events,
table_name: 'exhibit',
obj_li: [processed_obj],
properties_to_save: properties_to_save_exhibit,
log_lvl
});
}
return processed_obj;
}
return null;
}
/**
@@ -409,24 +518,30 @@ export async function search__exhibit({
log_lvl?: number;
}): Promise<ae_EventExhibit[]> {
if (log_lvl) {
console.log(`*** search__exhibit() *** event_id=${event_id} ft=${fulltext_search_qry_str}`);
console.log(
`*** search__exhibit() *** event_id=${event_id} ft=${fulltext_search_qry_str}`
);
}
const search_query: any = {
q: fulltext_search_qry_str || '',
and: [
{ field: 'event_id', 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: 1 });
else if (enabled === 'not_enabled') search_query.and.push({ field: 'enable', op: 'eq', value: 0 });
if (enabled === 'enabled')
search_query.and.push({ field: 'enable', op: 'eq', value: 1 });
else if (enabled === 'not_enabled')
search_query.and.push({ field: 'enable', op: 'eq', value: 0 });
if (hidden === 'hidden') search_query.and.push({ field: 'hide', op: 'eq', value: 1 });
else if (hidden === 'not_hidden') search_query.and.push({ field: 'hide', op: 'eq', value: 0 });
if (hidden === 'hidden')
search_query.and.push({ field: 'hide', op: 'eq', value: 1 });
else if (hidden === 'not_hidden')
search_query.and.push({ field: 'hide', op: 'eq', value: 0 });
if (priority === 'priority') search_query.and.push({ field: 'priority', op: 'eq', value: 1 });
else if (priority === 'not_priority') search_query.and.push({ field: 'priority', op: 'eq', value: 0 });
if (priority === 'priority')
search_query.and.push({ field: 'priority', op: 'eq', value: 1 });
else if (priority === 'not_priority')
search_query.and.push({ field: 'priority', op: 'eq', value: 0 });
try {
const result_li = await api.search_ae_obj({
@@ -443,7 +558,10 @@ export async function search__exhibit({
});
if (result_li && Array.isArray(result_li)) {
const processed = await process_ae_obj__exhibit_props({ obj_li: result_li, log_lvl });
const processed = await process_ae_obj__exhibit_props({
obj_li: result_li,
log_lvl
});
if (try_cache) {
await db_save_ae_obj_li__ae_obj({
db_instance: db_events,
@@ -460,4 +578,4 @@ export async function search__exhibit({
}
return [];
}
}