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:
@@ -97,6 +97,7 @@ interface GetAeObjLiV3Params {
|
|||||||
offset?: number;
|
offset?: number;
|
||||||
order_by_li?: Record<string, 'ASC' | 'DESC'> | Record<string, 'ASC' | 'DESC'>[] | null;
|
order_by_li?: Record<string, 'ASC' | 'DESC'> | Record<string, 'ASC' | 'DESC'>[] | null;
|
||||||
delay_ms?: number;
|
delay_ms?: number;
|
||||||
|
params?: key_val;
|
||||||
headers?: key_val;
|
headers?: key_val;
|
||||||
log_lvl?: number;
|
log_lvl?: number;
|
||||||
}
|
}
|
||||||
@@ -113,6 +114,7 @@ export async function get_ae_obj_li_v3({
|
|||||||
offset = 0,
|
offset = 0,
|
||||||
order_by_li = null,
|
order_by_li = null,
|
||||||
delay_ms = 0,
|
delay_ms = 0,
|
||||||
|
params = {},
|
||||||
headers = {},
|
headers = {},
|
||||||
log_lvl = 0
|
log_lvl = 0
|
||||||
}: GetAeObjLiV3Params) {
|
}: GetAeObjLiV3Params) {
|
||||||
@@ -120,30 +122,31 @@ export async function get_ae_obj_li_v3({
|
|||||||
const endpoint = `/v3/crud/${obj_type}/`;
|
const endpoint = `/v3/crud/${obj_type}/`;
|
||||||
|
|
||||||
// 2. Build Query Params
|
// 2. Build Query Params
|
||||||
const params: key_val = {
|
const query_params: key_val = {
|
||||||
enabled,
|
enabled,
|
||||||
hidden,
|
hidden,
|
||||||
view,
|
view,
|
||||||
limit,
|
limit,
|
||||||
offset
|
offset,
|
||||||
|
...params
|
||||||
};
|
};
|
||||||
|
|
||||||
if (for_obj_type) params['for_obj_type'] = for_obj_type;
|
if (for_obj_type) query_params['for_obj_type'] = for_obj_type;
|
||||||
if (for_obj_id) params['for_obj_id'] = for_obj_id;
|
if (for_obj_id) query_params['for_obj_id'] = for_obj_id;
|
||||||
if (order_by_li) params['order_by_li'] = JSON.stringify(order_by_li);
|
if (order_by_li) query_params['order_by_li'] = JSON.stringify(order_by_li);
|
||||||
if (delay_ms > 0) params['delay_ms'] = delay_ms;
|
if (delay_ms > 0) query_params['delay_ms'] = delay_ms;
|
||||||
|
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('*** get_ae_obj_li_v3 ***');
|
console.log('*** get_ae_obj_li_v3 ***');
|
||||||
console.log('Endpoint:', endpoint);
|
console.log('Endpoint:', endpoint);
|
||||||
console.log('Params:', params);
|
console.log('Params:', query_params);
|
||||||
console.log('Headers:', headers);
|
console.log('Headers:', headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
return await get_object({
|
return await get_object({
|
||||||
api_cfg,
|
api_cfg,
|
||||||
endpoint,
|
endpoint,
|
||||||
params,
|
params: query_params,
|
||||||
headers,
|
headers,
|
||||||
log_lvl
|
log_lvl
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -11,12 +11,14 @@ const ae_promises: key_val = {};
|
|||||||
export async function load_ae_obj_id__event_file({
|
export async function load_ae_obj_id__event_file({
|
||||||
api_cfg,
|
api_cfg,
|
||||||
event_file_id,
|
event_file_id,
|
||||||
|
inc_hosted_file = false,
|
||||||
view = 'default',
|
view = 'default',
|
||||||
try_cache = false,
|
try_cache = false,
|
||||||
log_lvl = 0
|
log_lvl = 0
|
||||||
}: {
|
}: {
|
||||||
api_cfg: any;
|
api_cfg: any;
|
||||||
event_file_id: string;
|
event_file_id: string;
|
||||||
|
inc_hosted_file?: boolean;
|
||||||
view?: string;
|
view?: string;
|
||||||
try_cache?: boolean;
|
try_cache?: boolean;
|
||||||
log_lvl?: number;
|
log_lvl?: number;
|
||||||
@@ -34,6 +36,7 @@ export async function load_ae_obj_id__event_file({
|
|||||||
_refresh_file_id_background({
|
_refresh_file_id_background({
|
||||||
api_cfg,
|
api_cfg,
|
||||||
event_file_id,
|
event_file_id,
|
||||||
|
inc_hosted_file,
|
||||||
view,
|
view,
|
||||||
try_cache,
|
try_cache,
|
||||||
log_lvl: 0
|
log_lvl: 0
|
||||||
@@ -46,6 +49,7 @@ export async function load_ae_obj_id__event_file({
|
|||||||
return await _refresh_file_id_background({
|
return await _refresh_file_id_background({
|
||||||
api_cfg,
|
api_cfg,
|
||||||
event_file_id,
|
event_file_id,
|
||||||
|
inc_hosted_file,
|
||||||
view,
|
view,
|
||||||
try_cache,
|
try_cache,
|
||||||
log_lvl
|
log_lvl
|
||||||
@@ -55,6 +59,7 @@ export async function load_ae_obj_id__event_file({
|
|||||||
async function _refresh_file_id_background({
|
async function _refresh_file_id_background({
|
||||||
api_cfg,
|
api_cfg,
|
||||||
event_file_id,
|
event_file_id,
|
||||||
|
inc_hosted_file = false,
|
||||||
view,
|
view,
|
||||||
try_cache,
|
try_cache,
|
||||||
log_lvl
|
log_lvl
|
||||||
@@ -66,6 +71,7 @@ async function _refresh_file_id_background({
|
|||||||
obj_type: 'event_file',
|
obj_type: 'event_file',
|
||||||
obj_id: event_file_id,
|
obj_id: event_file_id,
|
||||||
view,
|
view,
|
||||||
|
params: { inc_hosted_file },
|
||||||
log_lvl
|
log_lvl
|
||||||
});
|
});
|
||||||
if (result) {
|
if (result) {
|
||||||
@@ -93,6 +99,7 @@ export async function load_ae_obj_li__event_file({
|
|||||||
api_cfg,
|
api_cfg,
|
||||||
for_obj_type,
|
for_obj_type,
|
||||||
for_obj_id,
|
for_obj_id,
|
||||||
|
inc_hosted_file = false,
|
||||||
enabled = 'enabled',
|
enabled = 'enabled',
|
||||||
hidden = 'not_hidden',
|
hidden = 'not_hidden',
|
||||||
view = 'default',
|
view = 'default',
|
||||||
@@ -109,6 +116,7 @@ export async function load_ae_obj_li__event_file({
|
|||||||
api_cfg: any;
|
api_cfg: any;
|
||||||
for_obj_type: string;
|
for_obj_type: string;
|
||||||
for_obj_id: string;
|
for_obj_id: string;
|
||||||
|
inc_hosted_file?: boolean;
|
||||||
enabled?: 'enabled' | 'all' | 'not_enabled';
|
enabled?: 'enabled' | 'all' | 'not_enabled';
|
||||||
hidden?: 'hidden' | 'all' | 'not_hidden';
|
hidden?: 'hidden' | 'all' | 'not_hidden';
|
||||||
view?: string;
|
view?: string;
|
||||||
@@ -135,6 +143,7 @@ export async function load_ae_obj_li__event_file({
|
|||||||
api_cfg,
|
api_cfg,
|
||||||
for_obj_type,
|
for_obj_type,
|
||||||
for_obj_id,
|
for_obj_id,
|
||||||
|
inc_hosted_file,
|
||||||
enabled,
|
enabled,
|
||||||
hidden,
|
hidden,
|
||||||
view,
|
view,
|
||||||
@@ -153,6 +162,7 @@ export async function load_ae_obj_li__event_file({
|
|||||||
api_cfg,
|
api_cfg,
|
||||||
for_obj_type,
|
for_obj_type,
|
||||||
for_obj_id,
|
for_obj_id,
|
||||||
|
inc_hosted_file,
|
||||||
enabled,
|
enabled,
|
||||||
hidden,
|
hidden,
|
||||||
view,
|
view,
|
||||||
@@ -168,6 +178,7 @@ async function _refresh_file_li_background({
|
|||||||
api_cfg,
|
api_cfg,
|
||||||
for_obj_type,
|
for_obj_type,
|
||||||
for_obj_id,
|
for_obj_id,
|
||||||
|
inc_hosted_file = false,
|
||||||
enabled,
|
enabled,
|
||||||
hidden,
|
hidden,
|
||||||
view,
|
view,
|
||||||
@@ -194,6 +205,7 @@ async function _refresh_file_li_background({
|
|||||||
limit,
|
limit,
|
||||||
offset,
|
offset,
|
||||||
order_by_li,
|
order_by_li,
|
||||||
|
params: { inc_hosted_file },
|
||||||
log_lvl: log_lvl
|
log_lvl: log_lvl
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -216,13 +228,13 @@ async function _refresh_file_li_background({
|
|||||||
const fixed_obj = { ...obj };
|
const fixed_obj = { ...obj };
|
||||||
if (!fixed_obj.for_type) fixed_obj.for_type = for_obj_type;
|
if (!fixed_obj.for_type) fixed_obj.for_type = for_obj_type;
|
||||||
if (!fixed_obj.for_id) fixed_obj.for_id = for_obj_id;
|
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
|
// 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`;
|
const specific_id_key = `${for_obj_type}_id`;
|
||||||
if (!fixed_obj[specific_id_key]) {
|
if (!fixed_obj[specific_id_key]) {
|
||||||
fixed_obj[specific_id_key] = for_obj_id;
|
fixed_obj[specific_id_key] = for_obj_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
return fixed_obj;
|
return fixed_obj;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -363,6 +375,7 @@ export async function search__event_file({
|
|||||||
qry_created_on = null,
|
qry_created_on = null,
|
||||||
qry_min_file_size = null,
|
qry_min_file_size = null,
|
||||||
qry_file_purpose = null,
|
qry_file_purpose = null,
|
||||||
|
inc_hosted_file = false,
|
||||||
enabled = 'enabled',
|
enabled = 'enabled',
|
||||||
hidden = 'not_hidden',
|
hidden = 'not_hidden',
|
||||||
view = 'default',
|
view = 'default',
|
||||||
@@ -382,6 +395,7 @@ export async function search__event_file({
|
|||||||
qry_created_on?: string | null;
|
qry_created_on?: string | null;
|
||||||
qry_min_file_size?: null | number;
|
qry_min_file_size?: null | number;
|
||||||
qry_file_purpose?: string | null;
|
qry_file_purpose?: string | null;
|
||||||
|
inc_hosted_file?: boolean;
|
||||||
enabled?: 'enabled' | 'all' | 'not_enabled';
|
enabled?: 'enabled' | 'all' | 'not_enabled';
|
||||||
hidden?: 'hidden' | 'all' | 'not_hidden';
|
hidden?: 'hidden' | 'all' | 'not_hidden';
|
||||||
view?: string;
|
view?: string;
|
||||||
@@ -423,6 +437,7 @@ export async function search__event_file({
|
|||||||
order_by_li,
|
order_by_li,
|
||||||
limit,
|
limit,
|
||||||
offset,
|
offset,
|
||||||
|
params: { inc_hosted_file },
|
||||||
log_lvl
|
log_lvl
|
||||||
});
|
});
|
||||||
if (result_li && try_cache) {
|
if (result_li && try_cache) {
|
||||||
@@ -446,15 +461,15 @@ export const qry__event_file = search__event_file;
|
|||||||
export const properties_to_save = [
|
export const properties_to_save = [
|
||||||
'id',
|
'id',
|
||||||
'event_file_id',
|
'event_file_id',
|
||||||
// 'event_file_id_random',
|
// 'event_file_id_random', // DO NOT UNCOMMENT
|
||||||
'hosted_file_id',
|
'hosted_file_id',
|
||||||
// 'hosted_file_id_random',
|
// 'hosted_file_id_random', // DO NOT UNCOMMENT
|
||||||
'hash_sha256',
|
'hash_sha256',
|
||||||
'for_type',
|
'for_type',
|
||||||
'for_id',
|
'for_id',
|
||||||
// 'for_id_random',
|
// 'for_id_random', // DO NOT UNCOMMENT
|
||||||
'event_id',
|
'event_id',
|
||||||
// 'event_id_random',
|
// 'event_id_random', // DO NOT UNCOMMENT
|
||||||
'event_session_id',
|
'event_session_id',
|
||||||
'event_presentation_id',
|
'event_presentation_id',
|
||||||
'event_presenter_id',
|
'event_presenter_id',
|
||||||
@@ -477,9 +492,13 @@ export const properties_to_save = [
|
|||||||
'tmp_sort_2',
|
'tmp_sort_2',
|
||||||
'filename_no_ext',
|
'filename_no_ext',
|
||||||
'filename_w_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',
|
'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_code',
|
||||||
'event_location_name',
|
'event_location_name',
|
||||||
'event_session_code',
|
'event_session_code',
|
||||||
@@ -562,6 +581,13 @@ export async function process_ae_obj__event_file_props({
|
|||||||
if (obj.hosted_file_size && !obj.file_size) {
|
if (obj.hosted_file_size && !obj.file_size) {
|
||||||
obj.file_size = obj.hosted_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
|
// SYNC: Ensure for_id matches the specific object ID it was linked to
|
||||||
if (obj.for_type && !obj.for_id) {
|
if (obj.for_type && !obj.for_id) {
|
||||||
|
|||||||
Reference in New Issue
Block a user