Implemented 'inc_hosted_file' support and expanded data mapping for Event Files.

Updated the Event File data layer to support the 'inc_hosted_file' flag in load and search functions, enabling on-demand retrieval of joined Hosted File metadata.

Refined the data mapping in 'process_ae_obj__event_file_props' to include 'content_type' and strictly controlled which properties are persisted to IndexedDB, adhering to the 'Bite-Sized Data' principle by excluding unneeded backend fields like subdirectory paths.

Enhanced 'get_ae_obj_li_v3' to support generic parameter pass-through for V3 CRUD operations.
This commit is contained in:
Scott Idem
2026-02-19 17:15:12 -05:00
parent e5b94123a5
commit 0a689be25d
2 changed files with 45 additions and 16 deletions

View File

@@ -97,6 +97,7 @@ interface GetAeObjLiV3Params {
offset?: number;
order_by_li?: Record<string, 'ASC' | 'DESC'> | Record<string, 'ASC' | 'DESC'>[] | null;
delay_ms?: number;
params?: key_val;
headers?: key_val;
log_lvl?: number;
}
@@ -113,6 +114,7 @@ export async function get_ae_obj_li_v3({
offset = 0,
order_by_li = null,
delay_ms = 0,
params = {},
headers = {},
log_lvl = 0
}: GetAeObjLiV3Params) {
@@ -120,30 +122,31 @@ export async function get_ae_obj_li_v3({
const endpoint = `/v3/crud/${obj_type}/`;
// 2. Build Query Params
const params: key_val = {
const query_params: key_val = {
enabled,
hidden,
view,
limit,
offset
offset,
...params
};
if (for_obj_type) params['for_obj_type'] = for_obj_type;
if (for_obj_id) params['for_obj_id'] = for_obj_id;
if (order_by_li) params['order_by_li'] = JSON.stringify(order_by_li);
if (delay_ms > 0) params['delay_ms'] = delay_ms;
if (for_obj_type) query_params['for_obj_type'] = for_obj_type;
if (for_obj_id) query_params['for_obj_id'] = for_obj_id;
if (order_by_li) query_params['order_by_li'] = JSON.stringify(order_by_li);
if (delay_ms > 0) query_params['delay_ms'] = delay_ms;
if (log_lvl) {
console.log('*** get_ae_obj_li_v3 ***');
console.log('Endpoint:', endpoint);
console.log('Params:', params);
console.log('Params:', query_params);
console.log('Headers:', headers);
}
return await get_object({
api_cfg,
endpoint,
params,
params: query_params,
headers,
log_lvl
});

View File

@@ -11,12 +11,14 @@ const ae_promises: key_val = {};
export async function load_ae_obj_id__event_file({
api_cfg,
event_file_id,
inc_hosted_file = false,
view = 'default',
try_cache = false,
log_lvl = 0
}: {
api_cfg: any;
event_file_id: string;
inc_hosted_file?: boolean;
view?: string;
try_cache?: boolean;
log_lvl?: number;
@@ -34,6 +36,7 @@ export async function load_ae_obj_id__event_file({
_refresh_file_id_background({
api_cfg,
event_file_id,
inc_hosted_file,
view,
try_cache,
log_lvl: 0
@@ -46,6 +49,7 @@ export async function load_ae_obj_id__event_file({
return await _refresh_file_id_background({
api_cfg,
event_file_id,
inc_hosted_file,
view,
try_cache,
log_lvl
@@ -55,6 +59,7 @@ export async function load_ae_obj_id__event_file({
async function _refresh_file_id_background({
api_cfg,
event_file_id,
inc_hosted_file = false,
view,
try_cache,
log_lvl
@@ -66,6 +71,7 @@ async function _refresh_file_id_background({
obj_type: 'event_file',
obj_id: event_file_id,
view,
params: { inc_hosted_file },
log_lvl
});
if (result) {
@@ -93,6 +99,7 @@ export async function load_ae_obj_li__event_file({
api_cfg,
for_obj_type,
for_obj_id,
inc_hosted_file = false,
enabled = 'enabled',
hidden = 'not_hidden',
view = 'default',
@@ -109,6 +116,7 @@ export async function load_ae_obj_li__event_file({
api_cfg: any;
for_obj_type: string;
for_obj_id: string;
inc_hosted_file?: boolean;
enabled?: 'enabled' | 'all' | 'not_enabled';
hidden?: 'hidden' | 'all' | 'not_hidden';
view?: string;
@@ -135,6 +143,7 @@ export async function load_ae_obj_li__event_file({
api_cfg,
for_obj_type,
for_obj_id,
inc_hosted_file,
enabled,
hidden,
view,
@@ -153,6 +162,7 @@ export async function load_ae_obj_li__event_file({
api_cfg,
for_obj_type,
for_obj_id,
inc_hosted_file,
enabled,
hidden,
view,
@@ -168,6 +178,7 @@ async function _refresh_file_li_background({
api_cfg,
for_obj_type,
for_obj_id,
inc_hosted_file = false,
enabled,
hidden,
view,
@@ -194,6 +205,7 @@ async function _refresh_file_li_background({
limit,
offset,
order_by_li,
params: { inc_hosted_file },
log_lvl: log_lvl
});
@@ -216,13 +228,13 @@ async function _refresh_file_li_background({
const fixed_obj = { ...obj };
if (!fixed_obj.for_type) fixed_obj.for_type = for_obj_type;
if (!fixed_obj.for_id) fixed_obj.for_id = for_obj_id;
// Map specific ID field (e.g. event_presenter_id) ONLY if it matches the current for_obj_type
const specific_id_key = `${for_obj_type}_id`;
if (!fixed_obj[specific_id_key]) {
fixed_obj[specific_id_key] = for_obj_id;
}
return fixed_obj;
});
@@ -363,6 +375,7 @@ export async function search__event_file({
qry_created_on = null,
qry_min_file_size = null,
qry_file_purpose = null,
inc_hosted_file = false,
enabled = 'enabled',
hidden = 'not_hidden',
view = 'default',
@@ -382,6 +395,7 @@ export async function search__event_file({
qry_created_on?: string | null;
qry_min_file_size?: null | number;
qry_file_purpose?: string | null;
inc_hosted_file?: boolean;
enabled?: 'enabled' | 'all' | 'not_enabled';
hidden?: 'hidden' | 'all' | 'not_hidden';
view?: string;
@@ -423,6 +437,7 @@ export async function search__event_file({
order_by_li,
limit,
offset,
params: { inc_hosted_file },
log_lvl
});
if (result_li && try_cache) {
@@ -446,15 +461,15 @@ export const qry__event_file = search__event_file;
export const properties_to_save = [
'id',
'event_file_id',
// 'event_file_id_random',
// 'event_file_id_random', // DO NOT UNCOMMENT
'hosted_file_id',
// 'hosted_file_id_random',
// 'hosted_file_id_random', // DO NOT UNCOMMENT
'hash_sha256',
'for_type',
'for_id',
// 'for_id_random',
// 'for_id_random', // DO NOT UNCOMMENT
'event_id',
// 'event_id_random',
// 'event_id_random', // DO NOT UNCOMMENT
'event_session_id',
'event_presentation_id',
'event_presenter_id',
@@ -477,9 +492,13 @@ export const properties_to_save = [
'tmp_sort_2',
'filename_no_ext',
'filename_w_ext',
'hosted_file_content_type',
// 'hosted_file_hash_sha256', // DO NOT UNCOMMENT
// 'hosted_file_content_type', // DO NOT UNCOMMENT
'content_type',
'file_size',
'hosted_file_size',
// 'hosted_file_size', // DO NOT UNCOMMENT
// 'hosted_file_subdirectory_path', // DO NOT UNCOMMENT
// 'subdirectory_path', // DO NOT UNCOMMENT
'event_location_code',
'event_location_name',
'event_session_code',
@@ -562,6 +581,13 @@ export async function process_ae_obj__event_file_props({
if (obj.hosted_file_size && !obj.file_size) {
obj.file_size = obj.hosted_file_size;
}
if (obj.hosted_file_content_type && !obj.content_type) {
obj.content_type = obj.hosted_file_content_type;
}
// The subdirectory is not needed by the frontend. Do not uncomment!
// if (obj.hosted_file_subdirectory_path && !obj.subdirectory_path) {
// obj.subdirectory_path = obj.hosted_file_subdirectory_path;
// }
// SYNC: Ensure for_id matches the specific object ID it was linked to
if (obj.for_type && !obj.for_id) {