Quick snapshot again as Gemini is working.
This commit is contained in:
@@ -862,76 +862,97 @@ export const properties_to_save = [
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* NON-EXPORTED LOCAL HELPER
|
||||
* Processes a list of Aether objects by applying common and specific transformations.
|
||||
*/
|
||||
async function _process_generic_props<T extends Record<string, any>>({
|
||||
obj_li,
|
||||
obj_type,
|
||||
log_lvl = 0,
|
||||
specific_processor
|
||||
}: {
|
||||
obj_li: T[];
|
||||
obj_type: string;
|
||||
log_lvl?: number;
|
||||
specific_processor?: (obj: T) => Promise<T> | T;
|
||||
}): Promise<T[]> {
|
||||
if (log_lvl > 0) {
|
||||
console.log(
|
||||
`*** _process_generic_props: Processing ${obj_li.length} objects of type "${obj_type}" ***`
|
||||
);
|
||||
}
|
||||
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl > 0) console.log('No objects to process.');
|
||||
return [];
|
||||
}
|
||||
|
||||
const processed_obj_li: T[] = [];
|
||||
|
||||
for (const original_obj of obj_li) {
|
||||
let processed_obj = { ...original_obj };
|
||||
|
||||
// --- Common Transformations ---
|
||||
|
||||
// 1. Standardize ID and other '_random' fields
|
||||
// The API often returns fields like 'person_id_random', which need to be aliased to 'person_id'.
|
||||
for (const key in processed_obj) {
|
||||
if (key.endsWith('_random')) {
|
||||
const newKey = key.slice(0, -7); // Remove '_random' suffix
|
||||
processed_obj[newKey] = processed_obj[key];
|
||||
}
|
||||
}
|
||||
// Ensure 'id' is set from '[obj_type]_id_random'
|
||||
const randomIdKey = `${obj_type}_id_random`;
|
||||
if (processed_obj[randomIdKey]) {
|
||||
processed_obj.id = processed_obj[randomIdKey];
|
||||
}
|
||||
|
||||
// 2. Create common computed properties for client-side sorting.
|
||||
const group = processed_obj.group ?? '0';
|
||||
const priority = processed_obj.priority ? 1 : 0;
|
||||
const sort = processed_obj.sort ?? '0';
|
||||
const updated = processed_obj.updated_on ?? processed_obj.created_on;
|
||||
const name = processed_obj.name ?? '';
|
||||
|
||||
processed_obj.tmp_sort_1 = `${group}_${priority}_${sort}_${updated}`;
|
||||
processed_obj.tmp_sort_2 = `${group}_${priority}_${sort}_${name}_${updated}`;
|
||||
|
||||
// --- Specific Transformations ---
|
||||
if (specific_processor) {
|
||||
processed_obj = await Promise.resolve(specific_processor(processed_obj));
|
||||
}
|
||||
|
||||
processed_obj_li.push(processed_obj as T);
|
||||
}
|
||||
|
||||
return processed_obj_li;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-06-04
|
||||
export async function process_ae_obj__archive_props({
|
||||
obj_li,
|
||||
log_lvl = 0,
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** process_ae_obj__archive_props() ***`, obj_li);
|
||||
}
|
||||
return _process_generic_props({
|
||||
obj_li,
|
||||
obj_type: 'archive',
|
||||
log_lvl,
|
||||
specific_processor: (obj) => {
|
||||
// Archive-specific computed sort fields, overriding generic ones if needed
|
||||
obj.tmp_sort_1 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
|
||||
obj.sort?.toString().padStart(3, '0') ?? ''
|
||||
}_${obj.updated_on ?? obj.created_on}`;
|
||||
obj.tmp_sort_2 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
|
||||
obj.sort?.toString().padStart(3, '0') ?? ''
|
||||
}_${obj.updated_on}_${obj.created_on}`;
|
||||
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl) console.log('No objects to process.');
|
||||
return [];
|
||||
}
|
||||
|
||||
const processed_obj_li = [];
|
||||
|
||||
for (const obj of obj_li) {
|
||||
if (log_lvl) console.log(`Processing ae_obj archive:`, obj);
|
||||
|
||||
let processed_obj = {
|
||||
id: obj.archive_id_random,
|
||||
archive_id: obj.archive_id_random,
|
||||
// archive_id_random: obj.archive_id_random,
|
||||
|
||||
code: obj.code,
|
||||
|
||||
account_id: obj.account_id_random,
|
||||
// account_id_random: obj.account_id_random,
|
||||
|
||||
name: obj.name,
|
||||
description: obj.description,
|
||||
|
||||
original_datetime: obj.original_datetime,
|
||||
original_timezone: obj.original_timezone,
|
||||
original_location: obj.original_location,
|
||||
|
||||
original_url: obj.original_url,
|
||||
original_url_text: obj.original_url_text,
|
||||
|
||||
sort_by: obj.sort_by,
|
||||
sort_by_desc: obj.sort_by_desc,
|
||||
|
||||
cfg_json: obj.cfg_json,
|
||||
|
||||
enable: obj.enable,
|
||||
hide: obj.hide,
|
||||
priority: obj.priority,
|
||||
sort: obj.sort,
|
||||
group: obj.group,
|
||||
notes: obj.notes,
|
||||
created_on: obj.created_on,
|
||||
updated_on: obj.updated_on,
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
tmp_sort_1: `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${obj.sort?.toString().padStart(3, '0') ?? ''}_${obj.updated_on ?? obj.created_on}`,
|
||||
tmp_sort_2: `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${obj.sort?.toString().padStart(3, '0') ?? ''}_${obj.updated_on}_${obj.created_on}`,
|
||||
|
||||
// From SQL view
|
||||
// archive_content_count: obj.archive_content_count,
|
||||
|
||||
// A key value list of the contents
|
||||
// archive_content_kv: obj.archive_content_kv,
|
||||
// archive_content_li: obj.archive_content_li,
|
||||
};
|
||||
|
||||
processed_obj_li.push(processed_obj);
|
||||
}
|
||||
|
||||
return processed_obj_li;
|
||||
return obj;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -559,90 +559,98 @@ export const properties_to_save = [
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* NON-EXPORTED LOCAL HELPER
|
||||
* Processes a list of Aether objects by applying common and specific transformations.
|
||||
*/
|
||||
async function _process_generic_props<T extends Record<string, any>>({
|
||||
obj_li,
|
||||
obj_type,
|
||||
log_lvl = 0,
|
||||
specific_processor
|
||||
}: {
|
||||
obj_li: T[];
|
||||
obj_type: string;
|
||||
log_lvl?: number;
|
||||
specific_processor?: (obj: T) => Promise<T> | T;
|
||||
}): Promise<T[]> {
|
||||
if (log_lvl > 0) {
|
||||
console.log(
|
||||
`*** _process_generic_props: Processing ${obj_li.length} objects of type "${obj_type}" ***`
|
||||
);
|
||||
}
|
||||
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl > 0) console.log('No objects to process.');
|
||||
return [];
|
||||
}
|
||||
|
||||
const processed_obj_li: T[] = [];
|
||||
|
||||
for (const original_obj of obj_li) {
|
||||
let processed_obj = { ...original_obj };
|
||||
|
||||
// --- Common Transformations ---
|
||||
|
||||
// 1. Standardize ID and other '_random' fields
|
||||
// The API often returns fields like 'person_id_random', which need to be aliased to 'person_id'.
|
||||
for (const key in processed_obj) {
|
||||
if (key.endsWith('_random')) {
|
||||
const newKey = key.slice(0, -7); // Remove '_random' suffix
|
||||
processed_obj[newKey] = processed_obj[key];
|
||||
}
|
||||
}
|
||||
// Ensure 'id' is set from '[obj_type]_id_random'
|
||||
const randomIdKey = `${obj_type}_id_random`;
|
||||
if (processed_obj[randomIdKey]) {
|
||||
processed_obj.id = processed_obj[randomIdKey];
|
||||
}
|
||||
|
||||
// 2. Create common computed properties for client-side sorting.
|
||||
const group = processed_obj.group ?? '0';
|
||||
const priority = processed_obj.priority ? 1 : 0;
|
||||
const sort = processed_obj.sort ?? '0';
|
||||
const updated = processed_obj.updated_on ?? processed_obj.created_on;
|
||||
const name = processed_obj.name ?? '';
|
||||
|
||||
processed_obj.tmp_sort_1 = `${group}_${priority}_${sort}_${updated}`;
|
||||
processed_obj.tmp_sort_2 = `${group}_${priority}_${sort}_${name}_${updated}`;
|
||||
|
||||
// --- Specific Transformations ---
|
||||
if (specific_processor) {
|
||||
processed_obj = await Promise.resolve(specific_processor(processed_obj));
|
||||
}
|
||||
|
||||
processed_obj_li.push(processed_obj as T);
|
||||
}
|
||||
|
||||
return processed_obj_li;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-06-04
|
||||
export async function process_ae_obj__archive_content_props({
|
||||
obj_li,
|
||||
log_lvl = 0,
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** process_ae_obj__archive_content_props() ***`, obj_li);
|
||||
}
|
||||
return _process_generic_props({
|
||||
obj_li,
|
||||
obj_type: 'archive_content',
|
||||
log_lvl,
|
||||
specific_processor: (obj) => {
|
||||
// Archive content-specific computed sort fields, overriding generic ones if needed
|
||||
obj.tmp_sort_1 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
|
||||
obj.sort?.toString().padStart(3, '0') ?? ''
|
||||
}_${obj.original_datetime ?? ''}`;
|
||||
obj.tmp_sort_2 = `${obj.group ?? ''}_${obj.original_datetime ?? ''}_${
|
||||
obj.priority ? '1' : '0'}_${obj.sort?.toString().padStart(3, '0') ?? ''}`;
|
||||
obj.tmp_sort_3 = `${obj.original_datetime ?? ''}_${obj.group ?? ''}_${
|
||||
obj.priority ? '1' : '0'}_${obj.sort?.toString().padStart(3, '0') ?? ''}`;
|
||||
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl) console.log('No objects to process.');
|
||||
return [];
|
||||
}
|
||||
|
||||
const processed_obj_li = [];
|
||||
|
||||
for (const obj of obj_li) {
|
||||
if (log_lvl) console.log(`Processing ae_obj archive_content:`, obj);
|
||||
|
||||
let processed_obj = {
|
||||
id: obj.archive_content_id_random,
|
||||
archive_content_id: obj.archive_content_id_random,
|
||||
// archive_content_id_random: obj.archive_content_id_random,
|
||||
|
||||
archive_id: obj.archive_id_random,
|
||||
// archive_id_random: obj.archive_id_random,
|
||||
|
||||
archive_content_type: obj.archive_content_type,
|
||||
|
||||
name: obj.name,
|
||||
description: obj.description,
|
||||
|
||||
content_html: obj.content_html,
|
||||
content_json: obj.content_json,
|
||||
|
||||
url: obj.url,
|
||||
url_text: obj.url_text,
|
||||
|
||||
hosted_file_id: obj.hosted_file_id_random,
|
||||
hosted_file_id_random: obj.hosted_file_id_random,
|
||||
|
||||
file_path: obj.file_path,
|
||||
|
||||
filename: obj.filename,
|
||||
file_extension: obj.file_extension,
|
||||
|
||||
original_datetime: obj.original_datetime,
|
||||
original_timezone: obj.original_timezone,
|
||||
original_location: obj.original_location,
|
||||
original_url: obj.original_url,
|
||||
original_url_text: obj.original_url_text,
|
||||
|
||||
enable_for_public: obj.enable_for_public,
|
||||
|
||||
cfg_json: obj.cfg_json,
|
||||
|
||||
enable: obj.enable,
|
||||
hide: obj.hide,
|
||||
priority: obj.priority,
|
||||
sort: obj.sort,
|
||||
group: obj.group,
|
||||
notes: obj.notes,
|
||||
created_on: obj.created_on,
|
||||
updated_on: obj.updated_on,
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
tmp_sort_1: `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${obj.sort?.toString().padStart(3, '0') ?? ''}_${obj.original_datetime ?? ''}`,
|
||||
tmp_sort_2: `${obj.group ?? ''}_${obj.original_datetime ?? ''}_${obj.priority ? '1' : '0'}_${obj.sort?.toString().padStart(3, '0') ?? ''}`,
|
||||
tmp_sort_3: `${obj.original_datetime ?? ''}_${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${obj.sort?.toString().padStart(3, '0') ?? ''}`,
|
||||
// tmp_sort_a: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on ?? obj.created_on}`,
|
||||
// tmp_sort_b: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on}_${obj.created_on}`,
|
||||
|
||||
// From SQL view
|
||||
archive_code: obj.archive_code,
|
||||
archive_name: obj.archive_name,
|
||||
|
||||
hash_sha256: obj.hosted_file_hash_sha256
|
||||
};
|
||||
|
||||
processed_obj_li.push(processed_obj);
|
||||
}
|
||||
|
||||
return processed_obj_li;
|
||||
return obj;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1144,124 +1144,94 @@ export const properties_to_save = [
|
||||
];
|
||||
|
||||
|
||||
// Updated 2025-05-09
|
||||
export async function process_ae_obj__event_props({
|
||||
obj_li,
|
||||
log_lvl = 0,
|
||||
}: {
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** process_ae_obj__event_props() ***`, obj_li);
|
||||
}
|
||||
/**
|
||||
* NON-EXPORTED LOCAL HELPER
|
||||
* Processes a list of Aether objects by applying common and specific transformations.
|
||||
*/
|
||||
async function _process_generic_props<T extends Record<string, any>>({
|
||||
obj_li,
|
||||
obj_type,
|
||||
log_lvl = 0,
|
||||
specific_processor
|
||||
}: {
|
||||
obj_li: T[];
|
||||
obj_type: string;
|
||||
log_lvl?: number;
|
||||
specific_processor?: (obj: T) => Promise<T> | T;
|
||||
}): Promise<T[]> {
|
||||
if (log_lvl > 0) {
|
||||
console.log(
|
||||
`*** _process_generic_props: Processing ${obj_li.length} objects of type "${obj_type}" ***`
|
||||
);
|
||||
}
|
||||
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl) {
|
||||
console.log('No objects to process.');
|
||||
}
|
||||
return [];
|
||||
}
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl > 0) console.log('No objects to process.');
|
||||
return [];
|
||||
}
|
||||
|
||||
const processed_obj_li = [];
|
||||
const processed_obj_li: T[] = [];
|
||||
|
||||
for (const obj of obj_li) {
|
||||
if (log_lvl) {
|
||||
console.log(`Processing ae_obj event:`, obj);
|
||||
}
|
||||
for (const original_obj of obj_li) {
|
||||
let processed_obj = { ...original_obj };
|
||||
|
||||
// Create the processed object
|
||||
let processed_obj = {
|
||||
id: obj.event_id_random,
|
||||
event_id: obj.event_id_random,
|
||||
event_id_random: obj.event_id_random,
|
||||
// --- Common Transformations ---
|
||||
|
||||
code: obj.event_code,
|
||||
// 1. Standardize ID and other '_random' fields
|
||||
// The API often returns fields like 'person_id_random', which need to be aliased to 'person_id'.
|
||||
for (const key in processed_obj) {
|
||||
if (key.endsWith('_random')) {
|
||||
const newKey = key.slice(0, -7); // Remove '_random' suffix
|
||||
processed_obj[newKey] = processed_obj[key];
|
||||
}
|
||||
}
|
||||
// Ensure 'id' is set from '[obj_type]_id_random'
|
||||
const randomIdKey = `${obj_type}_id_random`;
|
||||
if (processed_obj[randomIdKey]) {
|
||||
processed_obj.id = processed_obj[randomIdKey];
|
||||
}
|
||||
|
||||
account_id: obj.account_id_random,
|
||||
account_id_random: obj.account_id_random,
|
||||
// 2. Create common computed properties for client-side sorting.
|
||||
const group = processed_obj.group ?? '0';
|
||||
const priority = processed_obj.priority ? 1 : 0;
|
||||
const sort = processed_obj.sort ?? '0';
|
||||
const updated = processed_obj.updated_on ?? processed_obj.created_on;
|
||||
const name = processed_obj.name ?? '';
|
||||
|
||||
conference: obj.conference,
|
||||
type: obj.type,
|
||||
name: obj.name,
|
||||
summary: obj.summary,
|
||||
description: obj.description,
|
||||
processed_obj.tmp_sort_1 = `${group}_${priority}_${sort}_${updated}`;
|
||||
processed_obj.tmp_sort_2 = `${group}_${priority}_${sort}_${name}_${updated}`;
|
||||
|
||||
start_datetime: obj.start_datetime,
|
||||
end_datetime: obj.end_datetime,
|
||||
timezone: obj.timezone,
|
||||
location_address_json: obj.location_address_json,
|
||||
location_text: obj.location_text,
|
||||
// --- Specific Transformations ---
|
||||
if (specific_processor) {
|
||||
processed_obj = await Promise.resolve(specific_processor(processed_obj));
|
||||
}
|
||||
|
||||
attend_json: obj.attend_json,
|
||||
attend_text: obj.attend_text,
|
||||
processed_obj_li.push(processed_obj as T);
|
||||
}
|
||||
|
||||
status: obj.status, // draft, active, inactive, archived, unknown; currently only used with IDAA
|
||||
// review: obj.review,
|
||||
// approve: obj.approve,
|
||||
// ready: obj.ready,
|
||||
// ready_on: obj.ready_on,
|
||||
// archive: obj.archive,
|
||||
// archive_on: obj.archive_on,
|
||||
|
||||
mod_abstracts_json: obj.mod_abstracts_json,
|
||||
mod_badges_json: obj.mod_badges_json,
|
||||
mod_exhibits_json: obj.mod_exhibits_json,
|
||||
mod_meetings_json: obj.mod_meetings_json,
|
||||
mod_pres_mgmt_json: obj.mod_pres_mgmt_json,
|
||||
cfg_json: obj.cfg_json,
|
||||
|
||||
enable: obj.enable,
|
||||
hide: obj.hide,
|
||||
priority: obj.priority,
|
||||
sort: obj.sort,
|
||||
group: obj.group,
|
||||
notes: obj.notes,
|
||||
created_on: obj.created_on,
|
||||
updated_on: obj.updated_on,
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
tmp_sort_1: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on ?? obj.created_on}`,
|
||||
tmp_sort_2: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on}_${obj.created_on}`,
|
||||
|
||||
// IDAA Recovery Meetings:
|
||||
// Currently only really used for IDAA
|
||||
contact_li_json: obj.contact_li_json,
|
||||
external_person_id: obj.external_person_id,
|
||||
|
||||
physical: obj.physical,
|
||||
virtual: obj.virtual,
|
||||
|
||||
recurring: obj.recurring,
|
||||
recurring_pattern: obj.recurring_pattern,
|
||||
recurring_start_time: obj.recurring_start_time,
|
||||
recurring_end_time: obj.recurring_end_time,
|
||||
recurring_text: obj.recurring_text,
|
||||
|
||||
weekday_sunday: obj.weekday_sunday,
|
||||
weekday_monday: obj.weekday_monday,
|
||||
weekday_tuesday: obj.weekday_tuesday,
|
||||
weekday_wednesday: obj.weekday_wednesday,
|
||||
weekday_thursday: obj.weekday_thursday,
|
||||
weekday_friday: obj.weekday_friday,
|
||||
weekday_saturday: obj.weekday_saturday,
|
||||
|
||||
attend_url: obj.attend_url,
|
||||
attend_url_text: obj.attend_url_text,
|
||||
attend_url_code: obj.attend_url_code,
|
||||
attend_url_passcode: obj.attend_url_passcode,
|
||||
attend_phone: obj.attend_phone,
|
||||
attend_phone_passcode: obj.attend_phone_passcode,
|
||||
|
||||
// From SQL view
|
||||
file_count: obj.file_count,
|
||||
file_count_all: obj.file_count_all,
|
||||
internal_use_count: obj.internal_use_count,
|
||||
event_file_id_li_json: obj.event_file_id_li_json,
|
||||
};
|
||||
|
||||
processed_obj_li.push(processed_obj);
|
||||
}
|
||||
|
||||
return processed_obj_li;
|
||||
return processed_obj_li;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-11-13
|
||||
export async function process_ae_obj__event_props({
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
return _process_generic_props({
|
||||
obj_li,
|
||||
obj_type: 'event',
|
||||
log_lvl,
|
||||
specific_processor: (obj) => {
|
||||
// Handle event-specific property aliases
|
||||
if (obj.event_code) {
|
||||
obj.code = obj.event_code;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -10,10 +10,10 @@ let ae_promises: key_val = {};
|
||||
export const properties_to_save = [
|
||||
'id',
|
||||
'event_badge_template_id',
|
||||
'event_badge_template_id_random',
|
||||
// 'event_badge_template_id_random',
|
||||
|
||||
'event_id',
|
||||
'event_id_random',
|
||||
// 'event_id_random',
|
||||
|
||||
'name',
|
||||
'description',
|
||||
@@ -82,82 +82,99 @@ export const properties_to_save = [
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* NON-EXPORTED LOCAL HELPER
|
||||
* Processes a list of Aether objects by applying common and specific transformations.
|
||||
*/
|
||||
async function _process_generic_props<T extends Record<string, any>>({
|
||||
obj_li,
|
||||
obj_type,
|
||||
log_lvl = 0,
|
||||
specific_processor
|
||||
}: {
|
||||
obj_li: T[];
|
||||
obj_type: string;
|
||||
log_lvl?: number;
|
||||
specific_processor?: (obj: T) => Promise<T> | T;
|
||||
}): Promise<T[]> {
|
||||
if (log_lvl > 0) {
|
||||
console.log(
|
||||
`*** _process_generic_props: Processing ${obj_li.length} objects of type "${obj_type}" ***`
|
||||
);
|
||||
}
|
||||
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl > 0) console.log('No objects to process.');
|
||||
return [];
|
||||
}
|
||||
|
||||
const processed_obj_li: T[] = [];
|
||||
|
||||
for (const original_obj of obj_li) {
|
||||
let processed_obj = { ...original_obj };
|
||||
|
||||
// --- Common Transformations ---
|
||||
|
||||
// 1. Standardize ID and other '_random' fields
|
||||
// The API often returns fields like 'person_id_random', which need to be aliased to 'person_id'.
|
||||
for (const key in processed_obj) {
|
||||
if (key.endsWith('_random')) {
|
||||
const newKey = key.slice(0, -7); // Remove '_random' suffix
|
||||
processed_obj[newKey] = processed_obj[key];
|
||||
}
|
||||
}
|
||||
// Ensure 'id' is set from '[obj_type]_id_random'
|
||||
const randomIdKey = `${obj_type}_id_random`;
|
||||
if (processed_obj[randomIdKey]) {
|
||||
processed_obj.id = processed_obj[randomIdKey];
|
||||
}
|
||||
|
||||
// 2. Create common computed properties for client-side sorting.
|
||||
const group = processed_obj.group ?? '0';
|
||||
const priority = processed_obj.priority ? 1 : 0;
|
||||
const sort = processed_obj.sort ?? '0';
|
||||
const updated = processed_obj.updated_on ?? processed_obj.created_on;
|
||||
const name = processed_obj.name ?? '';
|
||||
|
||||
processed_obj.tmp_sort_1 = `${group}_${priority}_${sort}_${updated}`;
|
||||
processed_obj.tmp_sort_2 = `${group}_${priority}_${sort}_${name}_${updated}`;
|
||||
|
||||
// --- Specific Transformations ---
|
||||
if (specific_processor) {
|
||||
processed_obj = await Promise.resolve(specific_processor(processed_obj));
|
||||
}
|
||||
|
||||
processed_obj_li.push(processed_obj as T);
|
||||
}
|
||||
|
||||
return processed_obj_li;
|
||||
}
|
||||
|
||||
|
||||
// --- PROCESS FUNCTION ---
|
||||
export async function process_ae_obj__event_badge_template_props({
|
||||
obj_li,
|
||||
log_lvl = 0,
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** process_ae_obj__event_badge_template_props() ***`, obj_li);
|
||||
}
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl) console.log('No objects to process.');
|
||||
return [];
|
||||
}
|
||||
const processed_obj_li = [];
|
||||
for (const obj of obj_li) {
|
||||
if (log_lvl) console.log(`Processing ae_obj event_badge_template:`, obj);
|
||||
let processed_obj = {
|
||||
id: obj.event_badge_template_id_random,
|
||||
event_badge_template_id: obj.event_badge_template_id_random,
|
||||
event_badge_template_id_random: obj.event_badge_template_id_random,
|
||||
return _process_generic_props({
|
||||
obj_li,
|
||||
obj_type: 'event_badge_template',
|
||||
log_lvl,
|
||||
specific_processor: (obj) => {
|
||||
// Event badge template-specific computed sort fields, overriding generic ones if needed
|
||||
obj.tmp_sort_1 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
|
||||
obj.sort?.toString().padStart(3, '0') ?? ''
|
||||
}_${obj.updated_on ?? obj.created_on}`;
|
||||
obj.tmp_sort_2 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
|
||||
obj.sort?.toString().padStart(3, '0') ?? ''
|
||||
}_${obj.updated_on}_${obj.created_on}`;
|
||||
|
||||
event_id: obj.event_id_random,
|
||||
event_id_random: obj.event_id_random,
|
||||
|
||||
name: obj.name,
|
||||
description: obj.description,
|
||||
|
||||
logo_filename: obj.logo_filename,
|
||||
logo_path: obj.logo_path,
|
||||
|
||||
header_path: obj.header_path,
|
||||
secondary_header_path: obj.secondary_header_path,
|
||||
footer_path: obj.footer_path,
|
||||
|
||||
header_row_1: obj.header_row_1,
|
||||
header_row_2: obj.header_row_2,
|
||||
|
||||
badge_type_list: obj.badge_type_list,
|
||||
ticket_list: obj.ticket_list,
|
||||
|
||||
ticket_1_text: obj.ticket_1_text,
|
||||
ticket_2_text: obj.ticket_2_text,
|
||||
ticket_3_text: obj.ticket_3_text,
|
||||
ticket_4_text: obj.ticket_4_text,
|
||||
ticket_5_text: obj.ticket_5_text,
|
||||
ticket_6_text: obj.ticket_6_text,
|
||||
ticket_7_text: obj.ticket_7_text,
|
||||
ticket_8_text: obj.ticket_8_text,
|
||||
|
||||
wireless_ssid: obj.wireless_ssid,
|
||||
wireless_password: obj.wireless_password,
|
||||
|
||||
show_qr_front: obj.show_qr_front,
|
||||
show_qr_back: obj.show_qr_back,
|
||||
|
||||
layout: obj.layout,
|
||||
style_filename: obj.style_filename,
|
||||
|
||||
// default: obj.default,
|
||||
enable: obj.enable,
|
||||
hide: obj.hide,
|
||||
priority: obj.priority,
|
||||
sort: obj.sort,
|
||||
group: obj.group,
|
||||
notes: obj.notes,
|
||||
created_on: obj.created_on,
|
||||
updated_on: obj.updated_on,
|
||||
|
||||
tmp_sort_1: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on ?? obj.created_on}`,
|
||||
tmp_sort_2: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on}_${obj.created_on}`,
|
||||
};
|
||||
processed_obj_li.push(processed_obj);
|
||||
}
|
||||
return processed_obj_li;
|
||||
return obj;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -686,12 +686,12 @@ export function db_save_ae_obj_li__event_device(
|
||||
export const properties_to_save = [
|
||||
'id',
|
||||
'event_device_id',
|
||||
'event_device_id_random',
|
||||
// 'event_device_id_random',
|
||||
|
||||
'event_id',
|
||||
'event_id_random',
|
||||
// 'event_id_random',
|
||||
'event_location_id',
|
||||
'event_location_id_random',
|
||||
// 'event_location_id_random',
|
||||
|
||||
'code',
|
||||
'name',
|
||||
@@ -753,98 +753,102 @@ export const properties_to_save = [
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* NON-EXPORTED LOCAL HELPER
|
||||
* Processes a list of Aether objects by applying common and specific transformations.
|
||||
*/
|
||||
async function _process_generic_props<T extends Record<string, any>>({
|
||||
obj_li,
|
||||
obj_type,
|
||||
log_lvl = 0,
|
||||
specific_processor
|
||||
}: {
|
||||
obj_li: T[];
|
||||
obj_type: string;
|
||||
log_lvl?: number;
|
||||
specific_processor?: (obj: T) => Promise<T> | T;
|
||||
}): Promise<T[]> {
|
||||
if (log_lvl > 0) {
|
||||
console.log(
|
||||
`*** _process_generic_props: Processing ${obj_li.length} objects of type "${obj_type}" ***`
|
||||
);
|
||||
}
|
||||
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl > 0) console.log('No objects to process.');
|
||||
return [];
|
||||
}
|
||||
|
||||
const processed_obj_li: T[] = [];
|
||||
|
||||
for (const original_obj of obj_li) {
|
||||
let processed_obj = { ...original_obj };
|
||||
|
||||
// --- Common Transformations ---
|
||||
|
||||
// 1. Standardize ID and other '_random' fields
|
||||
// The API often returns fields like 'person_id_random', which need to be aliased to 'person_id'.
|
||||
for (const key in processed_obj) {
|
||||
if (key.endsWith('_random')) {
|
||||
const newKey = key.slice(0, -7); // Remove '_random' suffix
|
||||
processed_obj[newKey] = processed_obj[key];
|
||||
}
|
||||
}
|
||||
// Ensure 'id' is set from '[obj_type]_id_random'
|
||||
const randomIdKey = `${obj_type}_id_random`;
|
||||
if (processed_obj[randomIdKey]) {
|
||||
processed_obj.id = processed_obj[randomIdKey];
|
||||
}
|
||||
|
||||
// 2. Create common computed properties for client-side sorting.
|
||||
const group = processed_obj.group ?? '0';
|
||||
const priority = processed_obj.priority ? 1 : 0;
|
||||
const sort = processed_obj.sort ?? '0';
|
||||
const updated = processed_obj.updated_on ?? processed_obj.created_on;
|
||||
const name = processed_obj.name ?? '';
|
||||
|
||||
processed_obj.tmp_sort_1 = `${group}_${priority}_${sort}_${updated}`;
|
||||
processed_obj.tmp_sort_2 = `${group}_${priority}_${sort}_${name}_${updated}`;
|
||||
|
||||
// --- Specific Transformations ---
|
||||
if (specific_processor) {
|
||||
processed_obj = await Promise.resolve(specific_processor(processed_obj));
|
||||
}
|
||||
|
||||
processed_obj_li.push(processed_obj as T);
|
||||
}
|
||||
|
||||
return processed_obj_li;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-05-23
|
||||
export async function process_ae_obj__event_device_props({
|
||||
obj_li,
|
||||
log_lvl = 0,
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** process_ae_obj__event_location_props() ***`, obj_li);
|
||||
}
|
||||
return _process_generic_props({
|
||||
obj_li,
|
||||
obj_type: 'event_device',
|
||||
log_lvl,
|
||||
specific_processor: (obj) => {
|
||||
// Special handling for heartbeat timestamp
|
||||
if (obj.heartbeat) {
|
||||
obj.heartbeat = obj.heartbeat + 'Z';
|
||||
}
|
||||
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl) console.log('No objects to process.');
|
||||
return [];
|
||||
}
|
||||
// Event device-specific computed sort fields, overriding generic ones if needed
|
||||
obj.tmp_sort_1 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
|
||||
obj.sort?.toString().padStart(3, '0') ?? ''
|
||||
}_${obj.updated_on ?? obj.created_on}`;
|
||||
obj.tmp_sort_2 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
|
||||
obj.sort?.toString().padStart(3, '0') ?? ''
|
||||
}_${obj.updated_on}_${obj.created_on}`;
|
||||
|
||||
const processed_obj_li = [];
|
||||
|
||||
for (const obj of obj_li) {
|
||||
if (log_lvl) console.log(`Processing ae_obj event_device:`, obj);
|
||||
|
||||
let processed_obj = {
|
||||
id: obj.event_device_id_random,
|
||||
event_device_id: obj.event_device_id_random,
|
||||
event_device_id_random: obj.event_device_id_random,
|
||||
|
||||
event_id: obj.event_id_random,
|
||||
event_id_random: obj.event_id_random,
|
||||
event_location_id: obj.event_location_id_random,
|
||||
event_location_id_random: obj.event_location_id_random,
|
||||
|
||||
code: obj.code,
|
||||
name: obj.name,
|
||||
description: obj.description,
|
||||
|
||||
passcode: obj.passcode,
|
||||
|
||||
local_file_cache_path: obj.local_file_cache_path,
|
||||
host_file_temp_path: obj.host_file_temp_path,
|
||||
recording_path: obj.recording_path,
|
||||
|
||||
record_audio: obj.record_audio,
|
||||
record_video: obj.record_video,
|
||||
|
||||
trigger_open_file_id: obj.trigger_open_file_id,
|
||||
trigger_open_session_id: obj.trigger_open_session_id,
|
||||
trigger_recording_start: obj.trigger_recording_start,
|
||||
trigger_recording_stop: obj.trigger_recording_stop,
|
||||
trigger_reset: obj.trigger_reset,
|
||||
trigger_show_admin: obj.trigger_show_admin,
|
||||
trigger_show_hidden: obj.trigger_show_hidden,
|
||||
|
||||
alert: obj.alert,
|
||||
alert_msg: obj.alert_msg,
|
||||
alert_on: obj.alert_on,
|
||||
status: obj.status,
|
||||
status_msg: obj.status_msg,
|
||||
status_on: obj.status_on,
|
||||
record_status: obj.record_status,
|
||||
record_status_msg: obj.record_status_msg,
|
||||
record_status_on: obj.record_status_on,
|
||||
// These are timestamps that are in UTC but missing the 'Z' at the end
|
||||
heartbeat: obj.heartbeat ? obj.heartbeat+'Z' : null,
|
||||
|
||||
info_hostname: obj.info_hostname,
|
||||
info_ip_list: obj.info_ip_list,
|
||||
|
||||
meta_json: obj.meta_json,
|
||||
other_json: obj.other_json,
|
||||
|
||||
enable: obj.enable,
|
||||
hide: obj.hide,
|
||||
priority: obj.priority,
|
||||
sort: obj.sort,
|
||||
group: obj.group,
|
||||
notes: obj.notes,
|
||||
created_on: obj.created_on,
|
||||
updated_on: obj.updated_on,
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
tmp_sort_1: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on ?? obj.created_on}`,
|
||||
tmp_sort_2: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on}_${obj.created_on}`,
|
||||
|
||||
// From SQL view
|
||||
event_name: obj.event_name,
|
||||
event_location_code: obj.event_location_code,
|
||||
event_location_name: obj.event_location_name,
|
||||
};
|
||||
|
||||
processed_obj_li.push(processed_obj);
|
||||
}
|
||||
|
||||
return processed_obj_li;
|
||||
return obj;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -869,15 +869,15 @@ export const properties_to_save = [
|
||||
'id',
|
||||
// 'id_random',
|
||||
'event_file_id',
|
||||
'event_file_id_random',
|
||||
// 'event_file_id_random',
|
||||
|
||||
'hosted_file_id',
|
||||
'hosted_file_id_random',
|
||||
// 'hosted_file_id_random',
|
||||
'hash_sha256',
|
||||
|
||||
'for_type',
|
||||
'for_id',
|
||||
'for_id_random',
|
||||
// 'for_id_random',
|
||||
|
||||
'event_id',
|
||||
// 'event_id_random',
|
||||
@@ -939,101 +939,97 @@ export const properties_to_save = [
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* NON-EXPORTED LOCAL HELPER
|
||||
* Processes a list of Aether objects by applying common and specific transformations.
|
||||
*/
|
||||
async function _process_generic_props<T extends Record<string, any>>({
|
||||
obj_li,
|
||||
obj_type,
|
||||
log_lvl = 0,
|
||||
specific_processor
|
||||
}: {
|
||||
obj_li: T[];
|
||||
obj_type: string;
|
||||
log_lvl?: number;
|
||||
specific_processor?: (obj: T) => Promise<T> | T;
|
||||
}): Promise<T[]> {
|
||||
if (log_lvl > 0) {
|
||||
console.log(
|
||||
`*** _process_generic_props: Processing ${obj_li.length} objects of type "${obj_type}" ***`
|
||||
);
|
||||
}
|
||||
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl > 0) console.log('No objects to process.');
|
||||
return [];
|
||||
}
|
||||
|
||||
const processed_obj_li: T[] = [];
|
||||
|
||||
for (const original_obj of obj_li) {
|
||||
let processed_obj = { ...original_obj };
|
||||
|
||||
// --- Common Transformations ---
|
||||
|
||||
// 1. Standardize ID and other '_random' fields
|
||||
// The API often returns fields like 'person_id_random', which need to be aliased to 'person_id'.
|
||||
for (const key in processed_obj) {
|
||||
if (key.endsWith('_random')) {
|
||||
const newKey = key.slice(0, -7); // Remove '_random' suffix
|
||||
processed_obj[newKey] = processed_obj[key];
|
||||
}
|
||||
}
|
||||
// Ensure 'id' is set from '[obj_type]_id_random'
|
||||
const randomIdKey = `${obj_type}_id_random`;
|
||||
if (processed_obj[randomIdKey]) {
|
||||
processed_obj.id = processed_obj[randomIdKey];
|
||||
}
|
||||
|
||||
// 2. Create common computed properties for client-side sorting.
|
||||
const group = processed_obj.group ?? '0';
|
||||
const priority = processed_obj.priority ? 1 : 0;
|
||||
const sort = processed_obj.sort ?? '0';
|
||||
const updated = processed_obj.updated_on ?? processed_obj.created_on;
|
||||
const name = processed_obj.name ?? '';
|
||||
|
||||
processed_obj.tmp_sort_1 = `${group}_${priority}_${sort}_${updated}`;
|
||||
processed_obj.tmp_sort_2 = `${group}_${priority}_${sort}_${name}_${updated}`;
|
||||
|
||||
// --- Specific Transformations ---
|
||||
if (specific_processor) {
|
||||
processed_obj = await Promise.resolve(specific_processor(processed_obj));
|
||||
}
|
||||
|
||||
processed_obj_li.push(processed_obj as T);
|
||||
}
|
||||
|
||||
return processed_obj_li;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-05-23
|
||||
export async function process_ae_obj__event_file_props({
|
||||
obj_li,
|
||||
log_lvl = 0,
|
||||
}: {
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** process_ae_obj__event_file_props() ***`, obj_li);
|
||||
}
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
return _process_generic_props({
|
||||
obj_li,
|
||||
obj_type: 'event_file',
|
||||
log_lvl,
|
||||
specific_processor: (obj) => {
|
||||
// Event file-specific computed sort fields, overriding generic ones if needed
|
||||
obj.tmp_sort_1 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
|
||||
obj.sort?.toString().padStart(3, '0') ?? ''
|
||||
}_${obj.updated_on ?? obj.created_on}`;
|
||||
obj.tmp_sort_2 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
|
||||
obj.sort?.toString().padStart(3, '0') ?? ''
|
||||
}_${obj.updated_on}_${obj.created_on}`;
|
||||
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl) console.log('No objects to process.');
|
||||
return [];
|
||||
}
|
||||
|
||||
const processed_obj_li = [];
|
||||
|
||||
for (const obj of obj_li) {
|
||||
if (log_lvl) console.log(`Processing ae_obj event_file:`, obj);
|
||||
|
||||
let processed_obj = {
|
||||
id: obj.event_file_id_random,
|
||||
// id_random: obj.event_file_id_random,
|
||||
event_file_id: obj.event_file_id_random,
|
||||
event_file_id_random: obj.event_file_id_random,
|
||||
|
||||
hosted_file_id: obj.hosted_file_id_random,
|
||||
hosted_file_id_random: obj.hosted_file_id_random,
|
||||
hash_sha256: obj.hash_sha256,
|
||||
|
||||
for_type: obj.for_type,
|
||||
for_id: obj.for_id_random,
|
||||
for_id_random: obj.for_id_random,
|
||||
|
||||
event_id: obj.event_id_random,
|
||||
// event_id_random: obj.event_id_random,
|
||||
event_session_id: obj.event_session_id_random,
|
||||
// event_session_id_random: obj.event_session_id_random,
|
||||
event_presentation_id: obj.event_presentation_id_random,
|
||||
// event_presentation_id_random: obj.event_presentation_id_random,
|
||||
event_presenter_id: obj.event_presenter_id_random,
|
||||
// event_presenter_id_random: obj.event_presenter_id_random,
|
||||
event_location_id: obj.event_location_id_random,
|
||||
// event_location_id_random: obj.event_location_id_random,
|
||||
|
||||
filename: obj.filename,
|
||||
extension: obj.extension,
|
||||
|
||||
open_in_os: obj.open_in_os,
|
||||
|
||||
lu_file_purpose_id: obj.lu_file_purpose_id, // Not id_random in this case?
|
||||
lu_event_file_purpose_name: obj.lu_event_file_purpose_name,
|
||||
file_purpose: obj.file_purpose,
|
||||
|
||||
enable: obj.enable,
|
||||
hide: obj.hide,
|
||||
priority: obj.priority,
|
||||
sort: obj.sort,
|
||||
group: obj.group,
|
||||
notes: obj.notes,
|
||||
created_on: obj.created_on,
|
||||
updated_on: obj.updated_on,
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
tmp_sort_1: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on ?? obj.created_on}`,
|
||||
tmp_sort_2: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on}_${obj.created_on}`,
|
||||
|
||||
filename_no_ext: obj.filename_no_ext,
|
||||
filename_w_ext: obj.filename_w_ext,
|
||||
hosted_file_content_type: obj.hosted_file_content_type,
|
||||
file_size: obj.file_size,
|
||||
hosted_file_size: obj.hosted_file_size,
|
||||
|
||||
event_location_code: obj.event_location_code,
|
||||
event_location_name: obj.event_location_name,
|
||||
event_session_code: obj.event_session_code,
|
||||
event_session_type_code: obj.event_session_type_code,
|
||||
event_session_name: obj.event_session_name,
|
||||
event_session_start_datetime: obj.event_session_start_datetime,
|
||||
event_session_end_datetime: obj.event_session_end_datetime,
|
||||
event_presentation_code: obj.event_presentation_code,
|
||||
event_presentation_type_code: obj.event_presentation_type_code,
|
||||
event_presentation_name: obj.event_presentation_name,
|
||||
event_presentation_start_datetime: obj.event_presentation_start_datetime,
|
||||
event_presentation_end_datetime: obj.event_presentation_end_datetime,
|
||||
event_presenter_given_name: obj.event_presenter_given_name,
|
||||
event_presenter_family_name: obj.event_presenter_family_name,
|
||||
event_presenter_full_name: obj.event_presenter_full_name,
|
||||
event_presenter_email: obj.event_presenter_email,
|
||||
};
|
||||
|
||||
processed_obj_li.push(processed_obj);
|
||||
}
|
||||
|
||||
return processed_obj_li;
|
||||
return obj;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -774,7 +774,7 @@ export function db_save_ae_obj_li__event_location(
|
||||
export const properties_to_save = [
|
||||
'id',
|
||||
'event_location_id',
|
||||
'event_location_id_random',
|
||||
// 'event_location_id_random',
|
||||
|
||||
'external_id',
|
||||
'code',
|
||||
@@ -782,7 +782,7 @@ export const properties_to_save = [
|
||||
'type_code',
|
||||
|
||||
'event_id',
|
||||
'event_id_random',
|
||||
// 'event_id_random',
|
||||
|
||||
'name',
|
||||
'description',
|
||||
@@ -821,77 +821,97 @@ export const properties_to_save = [
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* NON-EXPORTED LOCAL HELPER
|
||||
* Processes a list of Aether objects by applying common and specific transformations.
|
||||
*/
|
||||
async function _process_generic_props<T extends Record<string, any>>({
|
||||
obj_li,
|
||||
obj_type,
|
||||
log_lvl = 0,
|
||||
specific_processor
|
||||
}: {
|
||||
obj_li: T[];
|
||||
obj_type: string;
|
||||
log_lvl?: number;
|
||||
specific_processor?: (obj: T) => Promise<T> | T;
|
||||
}): Promise<T[]> {
|
||||
if (log_lvl > 0) {
|
||||
console.log(
|
||||
`*** _process_generic_props: Processing ${obj_li.length} objects of type "${obj_type}" ***`
|
||||
);
|
||||
}
|
||||
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl > 0) console.log('No objects to process.');
|
||||
return [];
|
||||
}
|
||||
|
||||
const processed_obj_li: T[] = [];
|
||||
|
||||
for (const original_obj of obj_li) {
|
||||
let processed_obj = { ...original_obj };
|
||||
|
||||
// --- Common Transformations ---
|
||||
|
||||
// 1. Standardize ID and other '_random' fields
|
||||
// The API often returns fields like 'person_id_random', which need to be aliased to 'person_id'.
|
||||
for (const key in processed_obj) {
|
||||
if (key.endsWith('_random')) {
|
||||
const newKey = key.slice(0, -7); // Remove '_random' suffix
|
||||
processed_obj[newKey] = processed_obj[key];
|
||||
}
|
||||
}
|
||||
// Ensure 'id' is set from '[obj_type]_id_random'
|
||||
const randomIdKey = `${obj_type}_id_random`;
|
||||
if (processed_obj[randomIdKey]) {
|
||||
processed_obj.id = processed_obj[randomIdKey];
|
||||
}
|
||||
|
||||
// 2. Create common computed properties for client-side sorting.
|
||||
const group = processed_obj.group ?? '0';
|
||||
const priority = processed_obj.priority ? 1 : 0;
|
||||
const sort = processed_obj.sort ?? '0';
|
||||
const updated = processed_obj.updated_on ?? processed_obj.created_on;
|
||||
const name = processed_obj.name ?? '';
|
||||
|
||||
processed_obj.tmp_sort_1 = `${group}_${priority}_${sort}_${updated}`;
|
||||
processed_obj.tmp_sort_2 = `${group}_${priority}_${sort}_${name}_${updated}`;
|
||||
|
||||
// --- Specific Transformations ---
|
||||
if (specific_processor) {
|
||||
processed_obj = await Promise.resolve(specific_processor(processed_obj));
|
||||
}
|
||||
|
||||
processed_obj_li.push(processed_obj as T);
|
||||
}
|
||||
|
||||
return processed_obj_li;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-05-23
|
||||
export async function process_ae_obj__event_location_props({
|
||||
obj_li,
|
||||
log_lvl = 0,
|
||||
}: {
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** process_ae_obj__event_location_props() ***`, obj_li);
|
||||
}
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
return _process_generic_props({
|
||||
obj_li,
|
||||
obj_type: 'event_location',
|
||||
log_lvl,
|
||||
specific_processor: (obj) => {
|
||||
// Event location-specific computed sort fields, overriding generic ones if needed
|
||||
obj.tmp_sort_1 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
|
||||
obj.sort?.toString().padStart(3, '0') ?? ''
|
||||
}_${obj.updated_on ?? obj.created_on}`;
|
||||
obj.tmp_sort_2 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
|
||||
obj.sort?.toString().padStart(3, '0') ?? ''
|
||||
}_${obj.updated_on}_${obj.created_on}`;
|
||||
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl) console.log('No objects to process.');
|
||||
return [];
|
||||
}
|
||||
|
||||
const processed_obj_li = [];
|
||||
|
||||
for (const obj of obj_li) {
|
||||
if (log_lvl) console.log(`Processing ae_obj event_location:`, obj);
|
||||
|
||||
let processed_obj = {
|
||||
id: obj.event_location_id_random,
|
||||
event_location_id: obj.event_location_id_random,
|
||||
event_location_id_random: obj.event_location_id_random,
|
||||
|
||||
external_id: obj.external_id,
|
||||
code: obj.code,
|
||||
|
||||
type_code: obj.type_code,
|
||||
|
||||
event_id: obj.event_id_random,
|
||||
event_id_random: obj.event_id_random,
|
||||
|
||||
name: obj.name,
|
||||
description: obj.description,
|
||||
|
||||
passcode: obj.passcode,
|
||||
|
||||
hide_event_launcher: obj.hide_event_launcher,
|
||||
|
||||
alert: obj.alert,
|
||||
alert_msg: obj.alert_msg,
|
||||
|
||||
data_json: obj.data_json,
|
||||
|
||||
enable: obj.enable,
|
||||
hide: obj.hide,
|
||||
priority: obj.priority,
|
||||
sort: obj.sort,
|
||||
group: obj.group,
|
||||
notes: obj.notes,
|
||||
created_on: obj.created_on,
|
||||
updated_on: obj.updated_on,
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
tmp_sort_1: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on ?? obj.created_on}`,
|
||||
tmp_sort_2: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on}_${obj.created_on}`,
|
||||
|
||||
// From SQL view
|
||||
file_count: obj.file_count,
|
||||
file_count_all: obj.file_count_all,
|
||||
internal_use_count: obj.internal_use_count,
|
||||
event_file_id_li_json: obj.event_file_id_li_json,
|
||||
|
||||
event_name: obj.event_name,
|
||||
};
|
||||
|
||||
processed_obj_li.push(processed_obj);
|
||||
}
|
||||
|
||||
return processed_obj_li;
|
||||
return obj;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -656,23 +656,23 @@ export function db_save_ae_obj_li__event_presentation(
|
||||
export const properties_to_save = [
|
||||
'id',
|
||||
'event_presentation_id',
|
||||
'event_presentation_id_random',
|
||||
// 'event_presentation_id_random',
|
||||
|
||||
'external_id',
|
||||
'code',
|
||||
|
||||
'for_type',
|
||||
'for_id',
|
||||
'for_id_random',
|
||||
// 'for_id_random',
|
||||
|
||||
'type_code',
|
||||
|
||||
'event_id',
|
||||
'event_id_random',
|
||||
// 'event_id_random',
|
||||
'event_session_id',
|
||||
'event_session_id_random',
|
||||
// 'event_session_id_random',
|
||||
'event_abstract_id',
|
||||
'event_abstract_id_random',
|
||||
// 'event_abstract_id_random',
|
||||
|
||||
'abstract_code',
|
||||
|
||||
@@ -709,85 +709,97 @@ export const properties_to_save = [
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* NON-EXPORTED LOCAL HELPER
|
||||
* Processes a list of Aether objects by applying common and specific transformations.
|
||||
*/
|
||||
async function _process_generic_props<T extends Record<string, any>>({
|
||||
obj_li,
|
||||
obj_type,
|
||||
log_lvl = 0,
|
||||
specific_processor
|
||||
}: {
|
||||
obj_li: T[];
|
||||
obj_type: string;
|
||||
log_lvl?: number;
|
||||
specific_processor?: (obj: T) => Promise<T> | T;
|
||||
}): Promise<T[]> {
|
||||
if (log_lvl > 0) {
|
||||
console.log(
|
||||
`*** _process_generic_props: Processing ${obj_li.length} objects of type "${obj_type}" ***`
|
||||
);
|
||||
}
|
||||
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl > 0) console.log('No objects to process.');
|
||||
return [];
|
||||
}
|
||||
|
||||
const processed_obj_li: T[] = [];
|
||||
|
||||
for (const original_obj of obj_li) {
|
||||
let processed_obj = { ...original_obj };
|
||||
|
||||
// --- Common Transformations ---
|
||||
|
||||
// 1. Standardize ID and other '_random' fields
|
||||
// The API often returns fields like 'person_id_random', which need to be aliased to 'person_id'.
|
||||
for (const key in processed_obj) {
|
||||
if (key.endsWith('_random')) {
|
||||
const newKey = key.slice(0, -7); // Remove '_random' suffix
|
||||
processed_obj[newKey] = processed_obj[key];
|
||||
}
|
||||
}
|
||||
// Ensure 'id' is set from '[obj_type]_id_random'
|
||||
const randomIdKey = `${obj_type}_id_random`;
|
||||
if (processed_obj[randomIdKey]) {
|
||||
processed_obj.id = processed_obj[randomIdKey];
|
||||
}
|
||||
|
||||
// 2. Create common computed properties for client-side sorting.
|
||||
const group = processed_obj.group ?? '0';
|
||||
const priority = processed_obj.priority ? 1 : 0;
|
||||
const sort = processed_obj.sort ?? '0';
|
||||
const updated = processed_obj.updated_on ?? processed_obj.created_on;
|
||||
const name = processed_obj.name ?? '';
|
||||
|
||||
processed_obj.tmp_sort_1 = `${group}_${priority}_${sort}_${updated}`;
|
||||
processed_obj.tmp_sort_2 = `${group}_${priority}_${sort}_${name}_${updated}`;
|
||||
|
||||
// --- Specific Transformations ---
|
||||
if (specific_processor) {
|
||||
processed_obj = await Promise.resolve(specific_processor(processed_obj));
|
||||
}
|
||||
|
||||
processed_obj_li.push(processed_obj as T);
|
||||
}
|
||||
|
||||
return processed_obj_li;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-05-22
|
||||
export async function process_ae_obj__event_presentation_props({
|
||||
obj_li,
|
||||
log_lvl = 0,
|
||||
}: {
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** process_ae_obj__event_presentation_props() ***`, obj_li);
|
||||
}
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
return _process_generic_props({
|
||||
obj_li,
|
||||
obj_type: 'event_presentation',
|
||||
log_lvl,
|
||||
specific_processor: (obj) => {
|
||||
// Event presentation-specific computed sort fields, overriding generic ones if needed
|
||||
obj.tmp_sort_1 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
|
||||
obj.sort?.toString().padStart(3, '0') ?? ''
|
||||
}_${obj.updated_on ?? obj.created_on}`;
|
||||
obj.tmp_sort_2 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
|
||||
obj.sort?.toString().padStart(3, '0') ?? ''
|
||||
}_${obj.updated_on}_${obj.created_on}`;
|
||||
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl) {
|
||||
console.log('No objects to process.');
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
const processed_obj_li = [];
|
||||
|
||||
for (const obj of obj_li) {
|
||||
if (log_lvl) {
|
||||
console.log(`Processing ae_obj event_presentation:`, obj);
|
||||
}
|
||||
|
||||
let processed_obj = {
|
||||
id: obj.event_presentation_id_random,
|
||||
event_presentation_id: obj.event_presentation_id_random,
|
||||
event_presentation_id_random: obj.event_presentation_id_random,
|
||||
|
||||
external_id: obj.external_id,
|
||||
code: obj.code,
|
||||
|
||||
for_type: obj.for_type,
|
||||
for_id: obj.for_id_random,
|
||||
for_id_random: obj.for_id_random,
|
||||
|
||||
type_code: obj.type_code,
|
||||
|
||||
event_id: obj.event_id_random,
|
||||
event_id_random: obj.event_id_random,
|
||||
event_session_id: obj.event_session_id_random,
|
||||
event_session_id_random: obj.event_session_id_random,
|
||||
event_abstract_id: obj.event_abstract_id_random,
|
||||
event_abstract_id_random: obj.event_abstract_id_random,
|
||||
|
||||
abstract_code: obj.abstract_code,
|
||||
|
||||
name: obj.name,
|
||||
description: obj.description,
|
||||
|
||||
start_datetime: obj.start_datetime,
|
||||
end_datetime: obj.end_datetime,
|
||||
|
||||
passcode: obj.passcode,
|
||||
|
||||
hide_event_launcher: obj.hide_event_launcher,
|
||||
|
||||
enable: obj.enable,
|
||||
hide: obj.hide,
|
||||
priority: obj.priority,
|
||||
sort: obj.sort,
|
||||
group: obj.group,
|
||||
notes: obj.notes,
|
||||
created_on: obj.created_on,
|
||||
updated_on: obj.updated_on,
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
tmp_sort_1: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on ?? obj.created_on}`,
|
||||
tmp_sort_2: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on}_${obj.created_on}`,
|
||||
|
||||
// From SQL view
|
||||
event_session_code: obj.event_session_code,
|
||||
event_session_name: obj.event_session_name,
|
||||
};
|
||||
|
||||
processed_obj_li.push(processed_obj);
|
||||
}
|
||||
|
||||
return processed_obj_li;
|
||||
return obj;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -826,7 +826,7 @@ export async function email_sign_in__event_presenter (
|
||||
export const properties_to_save = [
|
||||
'id',
|
||||
'event_presenter_id',
|
||||
'event_presenter_id_random',
|
||||
// 'event_presenter_id_random',
|
||||
|
||||
'external_id',
|
||||
'code',
|
||||
@@ -836,17 +836,17 @@ export const properties_to_save = [
|
||||
// 'for_id_random',
|
||||
|
||||
'event_id',
|
||||
'event_id_random',
|
||||
// 'event_id_random',
|
||||
'event_session_id',
|
||||
'event_session_id_random',
|
||||
// 'event_session_id_random',
|
||||
'event_presentation_id',
|
||||
'event_presentation_id_random',
|
||||
// 'event_presentation_id_random',
|
||||
'event_person_id',
|
||||
'event_person_id_random',
|
||||
// 'event_person_id_random',
|
||||
'person_id',
|
||||
'person_id_random',
|
||||
// 'person_id_random',
|
||||
'person_profile_id',
|
||||
'person_profile_id_random',
|
||||
// 'person_profile_id_random',
|
||||
|
||||
'pronouns',
|
||||
'informal_name',
|
||||
@@ -912,116 +912,97 @@ export const properties_to_save = [
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* NON-EXPORTED LOCAL HELPER
|
||||
* Processes a list of Aether objects by applying common and specific transformations.
|
||||
*/
|
||||
async function _process_generic_props<T extends Record<string, any>>({
|
||||
obj_li,
|
||||
obj_type,
|
||||
log_lvl = 0,
|
||||
specific_processor
|
||||
}: {
|
||||
obj_li: T[];
|
||||
obj_type: string;
|
||||
log_lvl?: number;
|
||||
specific_processor?: (obj: T) => Promise<T> | T;
|
||||
}): Promise<T[]> {
|
||||
if (log_lvl > 0) {
|
||||
console.log(
|
||||
`*** _process_generic_props: Processing ${obj_li.length} objects of type "${obj_type}" ***`
|
||||
);
|
||||
}
|
||||
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl > 0) console.log('No objects to process.');
|
||||
return [];
|
||||
}
|
||||
|
||||
const processed_obj_li: T[] = [];
|
||||
|
||||
for (const original_obj of obj_li) {
|
||||
let processed_obj = { ...original_obj };
|
||||
|
||||
// --- Common Transformations ---
|
||||
|
||||
// 1. Standardize ID and other '_random' fields
|
||||
// The API often returns fields like 'person_id_random', which need to be aliased to 'person_id'.
|
||||
for (const key in processed_obj) {
|
||||
if (key.endsWith('_random')) {
|
||||
const newKey = key.slice(0, -7); // Remove '_random' suffix
|
||||
processed_obj[newKey] = processed_obj[key];
|
||||
}
|
||||
}
|
||||
// Ensure 'id' is set from '[obj_type]_id_random'
|
||||
const randomIdKey = `${obj_type}_id_random`;
|
||||
if (processed_obj[randomIdKey]) {
|
||||
processed_obj.id = processed_obj[randomIdKey];
|
||||
}
|
||||
|
||||
// 2. Create common computed properties for client-side sorting.
|
||||
const group = processed_obj.group ?? '0';
|
||||
const priority = processed_obj.priority ? 1 : 0;
|
||||
const sort = processed_obj.sort ?? '0';
|
||||
const updated = processed_obj.updated_on ?? processed_obj.created_on;
|
||||
const name = processed_obj.name ?? '';
|
||||
|
||||
processed_obj.tmp_sort_1 = `${group}_${priority}_${sort}_${updated}`;
|
||||
processed_obj.tmp_sort_2 = `${group}_${priority}_${sort}_${name}_${updated}`;
|
||||
|
||||
// --- Specific Transformations ---
|
||||
if (specific_processor) {
|
||||
processed_obj = await Promise.resolve(specific_processor(processed_obj));
|
||||
}
|
||||
|
||||
processed_obj_li.push(processed_obj as T);
|
||||
}
|
||||
|
||||
return processed_obj_li;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-05-23
|
||||
export async function process_ae_obj__event_presenter_props({
|
||||
obj_li,
|
||||
log_lvl = 0,
|
||||
}: {
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** process_ae_obj__event_presenter_props() ***`, obj_li);
|
||||
}
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
return _process_generic_props({
|
||||
obj_li,
|
||||
obj_type: 'event_presenter',
|
||||
log_lvl,
|
||||
specific_processor: (obj) => {
|
||||
// Event presenter-specific computed sort fields, overriding generic ones if needed
|
||||
obj.tmp_sort_1 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
|
||||
obj.sort?.toString().padStart(3, '0') ?? ''
|
||||
}_${obj.updated_on ?? obj.created_on}`;
|
||||
obj.tmp_sort_2 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
|
||||
obj.sort?.toString().padStart(3, '0') ?? ''
|
||||
}_${obj.updated_on}_${obj.created_on}`;
|
||||
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl) console.log('No objects to process.');
|
||||
return [];
|
||||
}
|
||||
|
||||
const processed_obj_li = [];
|
||||
|
||||
for (const obj of obj_li) {
|
||||
if (log_lvl) console.log(`Processing ae_obj event_presenter:`, obj);
|
||||
|
||||
let processed_obj = {
|
||||
id: obj.event_presenter_id_random,
|
||||
event_presenter_id: obj.event_presenter_id_random,
|
||||
event_presenter_id_random: obj.event_presenter_id_random,
|
||||
|
||||
external_id: obj.external_id,
|
||||
code: obj.code,
|
||||
|
||||
// for_type: obj.for_type,
|
||||
// for_id: obj.for_id,
|
||||
// for_id_random: obj.for_id_random,
|
||||
|
||||
event_id: obj.event_id_random,
|
||||
event_id_random: obj.event_id_random,
|
||||
event_session_id: obj.event_session_id_random,
|
||||
event_session_id_random: obj.event_session_id_random,
|
||||
event_presentation_id: obj.event_presentation_id_random,
|
||||
event_presentation_id_random: obj.event_presentation_id_random,
|
||||
event_person_id: obj.event_person_id_random,
|
||||
event_person_id_random: obj.event_person_id_random,
|
||||
person_id: obj.person_id_random,
|
||||
person_id_random: obj.person_id_random,
|
||||
person_profile_id: obj.person_profile_id_random,
|
||||
person_profile_id_random: obj.person_profile_id_random,
|
||||
|
||||
pronouns: obj.pronouns,
|
||||
informal_name: obj.informal_name,
|
||||
title_names: obj.title_names,
|
||||
given_name: obj.given_name,
|
||||
middle_name: obj.middle_name,
|
||||
family_name: obj.family_name,
|
||||
designations: obj.designations,
|
||||
|
||||
professional_title: obj.professional_title,
|
||||
|
||||
full_name: obj.full_name,
|
||||
|
||||
affiliations: obj.affiliations,
|
||||
|
||||
email: obj.email,
|
||||
|
||||
biography: obj.biography,
|
||||
|
||||
agree: obj.agree,
|
||||
comments: obj.comments,
|
||||
|
||||
passcode: obj.passcode,
|
||||
|
||||
hide_event_launcher: obj.hide_event_launcher,
|
||||
|
||||
data_json: obj.data_json,
|
||||
|
||||
enable: obj.enable,
|
||||
hide: obj.hide,
|
||||
priority: obj.priority,
|
||||
sort: obj.sort,
|
||||
group: obj.group,
|
||||
notes: obj.notes,
|
||||
created_on: obj.created_on,
|
||||
updated_on: obj.updated_on,
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
tmp_sort_1: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on ?? obj.created_on}`,
|
||||
tmp_sort_2: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on}_${obj.created_on}`,
|
||||
|
||||
// From SQL view
|
||||
file_count: obj.file_count,
|
||||
|
||||
event_session_code: obj.event_session_code,
|
||||
event_session_name: obj.event_session_name,
|
||||
event_session_start_datetime: obj.event_session_start_datetime,
|
||||
event_presentation_code: obj.event_presentation_code,
|
||||
event_presentation_name: obj.event_presentation_name,
|
||||
event_presentation_start_datetime: obj.event_presentation_start_datetime,
|
||||
|
||||
person_external_id: obj.person_external_id,
|
||||
person_external_sys_id: obj.person_external_sys_id,
|
||||
person_given_name: obj.person_given_name,
|
||||
person_family_name: obj.person_family_name,
|
||||
person_full_name: obj.person_full_name,
|
||||
person_professional_title: obj.person_professional_title,
|
||||
person_affiliations: obj.person_affiliations,
|
||||
person_primary_email: obj.person_primary_email,
|
||||
person_passcode: obj.person_passcode,
|
||||
};
|
||||
|
||||
processed_obj_li.push(processed_obj);
|
||||
}
|
||||
|
||||
return processed_obj_li;
|
||||
return obj;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1147,24 +1147,24 @@ export async function email_sign_in__event_session (
|
||||
export const properties_to_save = [
|
||||
'id',
|
||||
'event_session_id',
|
||||
'event_session_id_random',
|
||||
// 'event_session_id_random',
|
||||
|
||||
'external_id',
|
||||
'code',
|
||||
|
||||
'for_type',
|
||||
'for_id',
|
||||
'for_id_random',
|
||||
// 'for_id_random',
|
||||
|
||||
'type_code',
|
||||
|
||||
'event_id',
|
||||
'event_id_random',
|
||||
// 'event_id_random',
|
||||
'event_location_id',
|
||||
'event_location_id_random',
|
||||
// 'event_location_id_random',
|
||||
|
||||
'poc_person_id',
|
||||
'poc_person_id_random',
|
||||
// 'poc_person_id_random',
|
||||
'poc_agree',
|
||||
'poc_kv_json',
|
||||
|
||||
@@ -1223,111 +1223,97 @@ export const properties_to_save = [
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* NON-EXPORTED LOCAL HELPER
|
||||
* Processes a list of Aether objects by applying common and specific transformations.
|
||||
*/
|
||||
async function _process_generic_props<T extends Record<string, any>>({
|
||||
obj_li,
|
||||
obj_type,
|
||||
log_lvl = 0,
|
||||
specific_processor
|
||||
}: {
|
||||
obj_li: T[];
|
||||
obj_type: string;
|
||||
log_lvl?: number;
|
||||
specific_processor?: (obj: T) => Promise<T> | T;
|
||||
}): Promise<T[]> {
|
||||
if (log_lvl > 0) {
|
||||
console.log(
|
||||
`*** _process_generic_props: Processing ${obj_li.length} objects of type "${obj_type}" ***`
|
||||
);
|
||||
}
|
||||
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl > 0) console.log('No objects to process.');
|
||||
return [];
|
||||
}
|
||||
|
||||
const processed_obj_li: T[] = [];
|
||||
|
||||
for (const original_obj of obj_li) {
|
||||
let processed_obj = { ...original_obj };
|
||||
|
||||
// --- Common Transformations ---
|
||||
|
||||
// 1. Standardize ID and other '_random' fields
|
||||
// The API often returns fields like 'person_id_random', which need to be aliased to 'person_id'.
|
||||
for (const key in processed_obj) {
|
||||
if (key.endsWith('_random')) {
|
||||
const newKey = key.slice(0, -7); // Remove '_random' suffix
|
||||
processed_obj[newKey] = processed_obj[key];
|
||||
}
|
||||
}
|
||||
// Ensure 'id' is set from '[obj_type]_id_random'
|
||||
const randomIdKey = `${obj_type}_id_random`;
|
||||
if (processed_obj[randomIdKey]) {
|
||||
processed_obj.id = processed_obj[randomIdKey];
|
||||
}
|
||||
|
||||
// 2. Create common computed properties for client-side sorting.
|
||||
const group = processed_obj.group ?? '0';
|
||||
const priority = processed_obj.priority ? 1 : 0;
|
||||
const sort = processed_obj.sort ?? '0';
|
||||
const updated = processed_obj.updated_on ?? processed_obj.created_on;
|
||||
const name = processed_obj.name ?? '';
|
||||
|
||||
processed_obj.tmp_sort_1 = `${group}_${priority}_${sort}_${updated}`;
|
||||
processed_obj.tmp_sort_2 = `${group}_${priority}_${sort}_${name}_${updated}`;
|
||||
|
||||
// --- Specific Transformations ---
|
||||
if (specific_processor) {
|
||||
processed_obj = await Promise.resolve(specific_processor(processed_obj));
|
||||
}
|
||||
|
||||
processed_obj_li.push(processed_obj as T);
|
||||
}
|
||||
|
||||
return processed_obj_li;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-05-09
|
||||
export async function process_ae_obj__event_session_props({
|
||||
obj_li,
|
||||
log_lvl = 0,
|
||||
}: {
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** process_ae_obj__event_session_props() ***`, obj_li);
|
||||
}
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
return _process_generic_props({
|
||||
obj_li,
|
||||
obj_type: 'event_session',
|
||||
log_lvl,
|
||||
specific_processor: (obj) => {
|
||||
// Event session-specific computed sort fields, overriding generic ones if needed
|
||||
obj.tmp_sort_1 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
|
||||
obj.sort?.toString().padStart(3, '0') ?? ''
|
||||
}_${obj.updated_on ?? obj.created_on}`;
|
||||
obj.tmp_sort_2 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
|
||||
obj.sort?.toString().padStart(3, '0') ?? ''
|
||||
}_${obj.updated_on}_${obj.created_on}`;
|
||||
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl) {
|
||||
console.log('No objects to process.');
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
const processed_obj_li = [];
|
||||
|
||||
for (const obj of obj_li) {
|
||||
if (log_lvl) {
|
||||
console.log(`Processing ae_obj event_session:`, obj);
|
||||
}
|
||||
|
||||
// Create the processed object
|
||||
let processed_obj = {
|
||||
id: obj.event_session_id_random,
|
||||
event_session_id: obj.event_session_id_random,
|
||||
event_session_id_random: obj.event_session_id_random,
|
||||
|
||||
external_id: obj.external_id,
|
||||
code: obj.code,
|
||||
|
||||
for_type: obj.for_type,
|
||||
for_id: obj.for_id,
|
||||
for_id_random: obj.for_id_random,
|
||||
|
||||
type_code: obj.type_code,
|
||||
|
||||
event_id: obj.event_id_random,
|
||||
event_id_random: obj.event_id_random,
|
||||
event_location_id: obj.event_location_id_random,
|
||||
event_location_id_random: obj.event_location_id_random,
|
||||
|
||||
poc_person_id: obj.poc_person_id_random,
|
||||
poc_person_id_random: obj.poc_person_id_random,
|
||||
poc_agree: obj.poc_agree,
|
||||
poc_kv_json: obj.poc_kv_json ?? {},
|
||||
|
||||
name: obj.name,
|
||||
description: obj.description,
|
||||
|
||||
start_datetime: obj.start_datetime,
|
||||
end_datetime: obj.end_datetime,
|
||||
|
||||
passcode: obj.passcode,
|
||||
|
||||
hide_event_launcher: obj.hide_event_launcher,
|
||||
|
||||
alert: obj.alert,
|
||||
alert_msg: obj.alert_msg,
|
||||
|
||||
data_json: obj.data_json,
|
||||
|
||||
ux_mode: obj.ux_mode,
|
||||
|
||||
enable: obj.enable,
|
||||
hide: obj.hide,
|
||||
priority: obj.priority,
|
||||
sort: obj.sort,
|
||||
group: obj.group,
|
||||
notes: obj.notes,
|
||||
created_on: obj.created_on,
|
||||
updated_on: obj.updated_on,
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
tmp_sort_1: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on ?? obj.created_on}`,
|
||||
tmp_sort_2: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on}_${obj.created_on}`,
|
||||
|
||||
// From SQL view
|
||||
file_count: obj.file_count,
|
||||
file_count_all: obj.file_count_all,
|
||||
internal_use_count: obj.internal_use_count,
|
||||
event_file_id_li_json: obj.event_file_id_li_json,
|
||||
|
||||
poc_person_given_name: obj.poc_person_given_name,
|
||||
poc_person_family_name: obj.poc_person_family_name,
|
||||
poc_person_full_name: obj.poc_person_full_name,
|
||||
poc_person_primary_email: obj.poc_person_primary_email,
|
||||
poc_person_passcode: obj.poc_person_passcode,
|
||||
|
||||
event_name: obj.event_name,
|
||||
|
||||
event_location_code: obj.event_location_code,
|
||||
event_location_name: obj.event_location_name,
|
||||
|
||||
// A key value list of the presentations
|
||||
event_presentation_kv: obj.event_presentation_kv,
|
||||
event_presentation_li: obj.event_presentation_li,
|
||||
};
|
||||
|
||||
processed_obj_li.push(processed_obj);
|
||||
}
|
||||
|
||||
return processed_obj_li;
|
||||
return obj;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -880,122 +880,103 @@ let properties_to_save = [
|
||||
];
|
||||
|
||||
|
||||
// Updated 2025-05-09
|
||||
export async function process_ae_obj__journal_props(
|
||||
{
|
||||
// obj_type,
|
||||
obj_li,
|
||||
log_lvl = 0,
|
||||
}: {
|
||||
// obj_type: string;
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** process_ae_obj__journal_props() ***`, obj_li);
|
||||
}
|
||||
/**
|
||||
* NON-EXPORTED LOCAL HELPER
|
||||
* Processes a list of Aether objects by applying common and specific transformations.
|
||||
*/
|
||||
async function _process_generic_props<T extends Record<string, any>>({
|
||||
obj_li,
|
||||
obj_type,
|
||||
log_lvl = 0,
|
||||
specific_processor
|
||||
}: {
|
||||
obj_li: T[];
|
||||
obj_type: string;
|
||||
log_lvl?: number;
|
||||
specific_processor?: (obj: T) => Promise<T> | T;
|
||||
}): Promise<T[]> {
|
||||
if (log_lvl > 0) {
|
||||
console.log(
|
||||
`*** _process_generic_props: Processing ${obj_li.length} objects of type "${obj_type}" ***`
|
||||
);
|
||||
}
|
||||
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl) {
|
||||
console.log('No objects to process.');
|
||||
}
|
||||
return [];
|
||||
}
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl > 0) console.log('No objects to process.');
|
||||
return [];
|
||||
}
|
||||
|
||||
const processed_obj_li = [];
|
||||
const processed_obj_li: T[] = [];
|
||||
|
||||
for (const obj of obj_li) {
|
||||
// const processed_obj = { ...obj };
|
||||
for (const original_obj of obj_li) {
|
||||
let processed_obj = { ...original_obj };
|
||||
|
||||
// Process the properties as needed
|
||||
let description = obj.description ?? '';
|
||||
// remove the most common zerowidth characters from the start of the file
|
||||
let description_cleaned: string = description.replace(/^[\u200B\u200C\u200D\u200E\u200F\uFEFF]/,"");
|
||||
let description_md_html: null|string = await marked.parse(description_cleaned ?? '') ?? null;
|
||||
// let description_md_html_alt: null|string = await marked.parse(description_cleaned ?? '', { gfm: false }) ?? null;
|
||||
// --- Common Transformations ---
|
||||
|
||||
let processed_obj = {
|
||||
id: obj.journal_id_random,
|
||||
journal_id: obj.journal_id_random,
|
||||
// 1. Standardize ID and other '_random' fields
|
||||
// The API often returns fields like 'person_id_random', which need to be aliased to 'person_id'.
|
||||
for (const key in processed_obj) {
|
||||
if (key.endsWith('_random')) {
|
||||
const newKey = key.slice(0, -7); // Remove '_random' suffix
|
||||
processed_obj[newKey] = processed_obj[key];
|
||||
}
|
||||
}
|
||||
// Ensure 'id' is set from '[obj_type]_id_random'
|
||||
const randomIdKey = `${obj_type}_id_random`;
|
||||
if (processed_obj[randomIdKey]) {
|
||||
processed_obj.id = processed_obj[randomIdKey];
|
||||
}
|
||||
|
||||
code: obj.code,
|
||||
// 2. Create common computed properties for client-side sorting.
|
||||
const group = processed_obj.group ?? '0';
|
||||
const priority = processed_obj.priority ? 1 : 0;
|
||||
const sort = processed_obj.sort ?? '0';
|
||||
const updated = processed_obj.updated_on ?? processed_obj.created_on;
|
||||
const name = processed_obj.name ?? '';
|
||||
|
||||
for_type: obj.for_type,
|
||||
for_id: obj.for_id,
|
||||
processed_obj.tmp_sort_1 = `${group}_${priority}_${sort}_${updated}`;
|
||||
processed_obj.tmp_sort_2 = `${group}_${priority}_${sort}_${name}_${updated}`;
|
||||
|
||||
type_code: obj.type_code,
|
||||
// --- Specific Transformations ---
|
||||
if (specific_processor) {
|
||||
processed_obj = await Promise.resolve(specific_processor(processed_obj));
|
||||
}
|
||||
|
||||
account_id: obj.account_id_random,
|
||||
person_id: obj.person_id_random,
|
||||
processed_obj_li.push(processed_obj as T);
|
||||
}
|
||||
|
||||
name: obj.name,
|
||||
short_name: obj.short_name,
|
||||
summary: obj.summary,
|
||||
outline: obj.outline,
|
||||
return processed_obj_li;
|
||||
}
|
||||
|
||||
description: obj.description,
|
||||
description_md_html: description_md_html, // Use the markdown parser to generate HTML
|
||||
description_html: obj.description_html,
|
||||
description_json: obj.description_json,
|
||||
// Updated 2025-11-13
|
||||
export async function process_ae_obj__journal_props({
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
return _process_generic_props({
|
||||
obj_li,
|
||||
obj_type: 'journal',
|
||||
log_lvl,
|
||||
specific_processor: async (obj) => {
|
||||
const description = obj.description ?? '';
|
||||
const description_cleaned: string = description.replace(
|
||||
/^[\u200B\u200C\u200D\u200E\u200F\uFEFF]/,
|
||||
''
|
||||
);
|
||||
obj.description_md_html = (await marked.parse(description_cleaned ?? '')) ?? null;
|
||||
|
||||
// start_datetime: obj.start_datetime,
|
||||
// end_datetime: obj.end_datetime,
|
||||
timezone: obj.timezone,
|
||||
obj.cfg_json = obj.cfg_json ?? {};
|
||||
obj.data_json = obj.data_json ?? {};
|
||||
|
||||
alert: obj.alert,
|
||||
alert_msg: obj.alert_msg,
|
||||
obj.tmp_sort_3 = `${obj.group ?? '0'}_${obj.priority ? 1 : 0}_${obj.sort ?? '0'}_${
|
||||
obj.name
|
||||
}_${obj.updated_on ?? obj.created_on}`;
|
||||
obj.combined_passcode = `${obj.passcode ?? ''}:${obj.private_passcode ?? ''}`;
|
||||
|
||||
sort_by: obj.sort_by,
|
||||
sort_by_desc: obj.sort_by_desc,
|
||||
|
||||
cfg_json: obj.cfg_json ?? {},
|
||||
|
||||
data_json: obj.data_json ?? {},
|
||||
|
||||
// ux_mode: obj.ux_mode,
|
||||
|
||||
// This only allows for basic access to the data.
|
||||
passcode_read: obj.passcode_read, // For LLM (AI) generated summary...???
|
||||
passcode_read_expire: obj.passcode_read_expire,
|
||||
passcode_write: obj.passcode_write,
|
||||
passcode_write_expire: obj.passcode_write_expire,
|
||||
|
||||
passcode: obj.passcode, // For Journal Entry encryption password
|
||||
passcode_timeout: obj.passcode_timeout,
|
||||
|
||||
private_passcode: obj.private_passcode, // Combine with Journal passcode to encrypt and decrypt Entries
|
||||
|
||||
auth_key: obj.auth_key, // For Journal authorization without sign in
|
||||
|
||||
enable: obj.enable,
|
||||
hide: obj.hide,
|
||||
priority: obj.priority,
|
||||
sort: obj.sort,
|
||||
group: obj.group,
|
||||
notes: obj.notes,
|
||||
created_on: obj.created_on,
|
||||
updated_on: obj.updated_on,
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
tmp_sort_1: `${obj.group ?? '0'}_${obj.priority ? 1 : 0}_${obj.sort ?? '0'}_${obj.updated_on}_${obj.created_on}`,
|
||||
tmp_sort_2: `${obj.group ?? '0'}_${obj.priority ? 1 : 0}_${obj.sort ?? '0'}_${obj.updated_on ?? obj.created_on}`,
|
||||
tmp_sort_3: `${obj.group ?? '0'}_${obj.priority ? 1 : 0}_${obj.sort ?? '0'}_${obj.name}_${obj.updated_on ?? obj.created_on}`,
|
||||
// tmp_sort_1: `${obj.original_datetime}_${obj.group}_${obj.priority}_${obj.sort}`,
|
||||
// tmp_sort_2: `${obj.group}_${obj.original_datetime}_${obj.priority}_${obj.sort}`,
|
||||
|
||||
combined_passcode: `${obj.passcode}:${obj.private_passcode}`, // Combined Journal passcode and Journal private passcode to encrypt and decrypt Entries
|
||||
|
||||
// From SQL view
|
||||
journal_entry_count: obj.journal_entry_count,
|
||||
|
||||
// A key value list of the others
|
||||
// journal_other_kv: obj.journal_other_kv,
|
||||
// journal_other_li: obj.journal_other_li,
|
||||
};
|
||||
|
||||
processed_obj_li.push(processed_obj);
|
||||
}
|
||||
|
||||
return processed_obj_li;
|
||||
return obj;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -894,178 +894,132 @@ let properties_to_save = [
|
||||
];
|
||||
|
||||
|
||||
// Updated 2025-05-09
|
||||
export async function process_ae_obj__journal_entry_props(
|
||||
{
|
||||
// obj_type,
|
||||
obj_li,
|
||||
log_lvl = 0,
|
||||
}: {
|
||||
// obj_type: string;
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** process_ae_obj__journal_entry_props() ***`, obj_li);
|
||||
}
|
||||
/**
|
||||
* NON-EXPORTED LOCAL HELPER
|
||||
* Processes a list of Aether objects by applying common and specific transformations.
|
||||
*/
|
||||
async function _process_generic_props<T extends Record<string, any>>({
|
||||
obj_li,
|
||||
obj_type,
|
||||
log_lvl = 0,
|
||||
specific_processor
|
||||
}: {
|
||||
obj_li: T[];
|
||||
obj_type: string;
|
||||
log_lvl?: number;
|
||||
specific_processor?: (obj: T) => Promise<T> | T;
|
||||
}): Promise<T[]> {
|
||||
if (log_lvl > 0) {
|
||||
console.log(
|
||||
`*** _process_generic_props: Processing ${obj_li.length} objects of type "${obj_type}" ***`
|
||||
);
|
||||
}
|
||||
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl) {
|
||||
console.log('No objects to process.');
|
||||
}
|
||||
return [];
|
||||
}
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl > 0) console.log('No objects to process.');
|
||||
return [];
|
||||
}
|
||||
|
||||
const processed_obj_li = [];
|
||||
const processed_obj_li: T[] = [];
|
||||
|
||||
for (const obj of obj_li) {
|
||||
if (log_lvl) {
|
||||
console.log(`Processing ae_obj journal_entry:`, obj);
|
||||
}
|
||||
for (const original_obj of obj_li) {
|
||||
let processed_obj = { ...original_obj };
|
||||
|
||||
let content = obj.content ?? '';
|
||||
// remove the most common zerowidth characters from the start of the file
|
||||
let content_cleaned: null|string = null;
|
||||
let content_md_html: null|string = null; // await marked.parse(content_cleaned ?? '') ?? null;
|
||||
// let content_md_html_alt: null|string = await marked.parse(content_cleaned ?? '', { gfm: false }) ?? null;
|
||||
// --- Common Transformations ---
|
||||
|
||||
if (obj.content_encrypted) {
|
||||
// In theory "content" should be null if "content_encrypted" has a value.
|
||||
content = null; // obj.content_encrypted;
|
||||
content_cleaned = null;
|
||||
content_md_html = null;
|
||||
} else {
|
||||
content_cleaned = content.replace(/^[\u200B\u200C\u200D\u200E\u200F\uFEFF]/,"");
|
||||
content_md_html = await marked.parse(content_cleaned ?? '') ?? null;
|
||||
}
|
||||
// 1. Standardize ID and other '_random' fields
|
||||
// The API often returns fields like 'person_id_random', which need to be aliased to 'person_id'.
|
||||
for (const key in processed_obj) {
|
||||
if (key.endsWith('_random')) {
|
||||
const newKey = key.slice(0, -7); // Remove '_random' suffix
|
||||
processed_obj[newKey] = processed_obj[key];
|
||||
}
|
||||
}
|
||||
// Ensure 'id' is set from '[obj_type]_id_random'
|
||||
const randomIdKey = `${obj_type}_id_random`;
|
||||
if (processed_obj[randomIdKey]) {
|
||||
processed_obj.id = processed_obj[randomIdKey];
|
||||
}
|
||||
|
||||
let history = obj.history ?? '';
|
||||
let history_cleaned: null|string = null;
|
||||
let history_md_html: null|string = null; // await marked.parse(history_cleaned ?? '') ?? null;
|
||||
// 2. Create common computed properties for client-side sorting.
|
||||
const group = processed_obj.group ?? '0';
|
||||
const priority = processed_obj.priority ? 1 : 0;
|
||||
const sort = processed_obj.sort ?? '0';
|
||||
const updated = processed_obj.updated_on ?? processed_obj.created_on;
|
||||
const name = processed_obj.name ?? '';
|
||||
|
||||
if (obj.history_encrypted) {
|
||||
// In theory "history" should be null if "history_encrypted" has a value.
|
||||
history = null; // obj.history_encrypted;
|
||||
history_cleaned = null;
|
||||
history_md_html = null;
|
||||
} else {
|
||||
history_cleaned = history.replace(/^[\u200B\u200C\u200D\u200E\u200F\uFEFF]/,"");
|
||||
history_md_html = await marked.parse(history_cleaned ?? '') ?? null;
|
||||
}
|
||||
processed_obj.tmp_sort_1 = `${group}_${priority}_${sort}_${updated}`;
|
||||
processed_obj.tmp_sort_2 = `${group}_${priority}_${sort}_${name}_${updated}`;
|
||||
|
||||
let processed_obj = {
|
||||
id: obj.journal_entry_id_random,
|
||||
journal_entry_id: obj.journal_entry_id_random,
|
||||
// --- Specific Transformations ---
|
||||
if (specific_processor) {
|
||||
processed_obj = await Promise.resolve(specific_processor(processed_obj));
|
||||
}
|
||||
|
||||
journal_id: obj.journal_id_random,
|
||||
processed_obj_li.push(processed_obj as T);
|
||||
}
|
||||
|
||||
code: obj.code,
|
||||
|
||||
for_type: obj.for_type,
|
||||
for_id: obj.for_id,
|
||||
|
||||
journal_entry_type: obj.journal_entry_type,
|
||||
|
||||
person_id: obj.person_id_random,
|
||||
|
||||
template: obj.template ?? null, // Allow for a template to be used, otherwise null
|
||||
|
||||
activity_code: obj.activity_code,
|
||||
category_code: obj.category_code,
|
||||
type_code: obj.type_code,
|
||||
topic_code: obj.topic_code,
|
||||
tags: obj.tags,
|
||||
|
||||
public: obj.public,
|
||||
private: obj.private,
|
||||
personal: obj.personal,
|
||||
professional: obj.professional,
|
||||
|
||||
name: obj.name,
|
||||
short_name: obj.short_name ?? null,
|
||||
summary: obj.summary,
|
||||
outline: obj.outline,
|
||||
// description: obj.description,
|
||||
|
||||
content: content,
|
||||
content_md_html: content_md_html,
|
||||
// content_md_html_alt: content_md_html_alt,
|
||||
content_html: obj.content_html,
|
||||
content_json: obj.content_json,
|
||||
content_encrypted: obj.content_encrypted,
|
||||
|
||||
history: history,
|
||||
history_md_html: history_md_html,
|
||||
history_encrypted: obj.history_encrypted,
|
||||
|
||||
passcode_hash: obj.passcode_hash,
|
||||
|
||||
// url: obj.url,
|
||||
// url_text: obj.url_text,
|
||||
|
||||
// hosted_file_id: obj.hosted_file_id_random,
|
||||
|
||||
// file_path: obj.file_path,
|
||||
|
||||
// filename: obj.filename,
|
||||
// file_extension: obj.file_extension,
|
||||
|
||||
// start_datetime: obj.start_datetime,
|
||||
// end_datetime: obj.end_datetime,
|
||||
// timezone: obj.timezone,
|
||||
|
||||
// original_datetime: obj.original_datetime,
|
||||
// original_timezone: obj.original_timezone,
|
||||
// original_location: obj.original_location,
|
||||
// original_url: obj.original_url,
|
||||
// original_url_text: obj.original_url_text,
|
||||
|
||||
// enable_for_public: obj.enable_for_public,
|
||||
|
||||
alert: obj.alert,
|
||||
alert_msg: obj.alert_msg,
|
||||
|
||||
// cfg_json: obj.cfg_json ?? {},
|
||||
data_json: obj.data_json ?? {},
|
||||
|
||||
// This only allows for basic access to the data.
|
||||
// passcode_read: obj.passcode_read, // For LLM (AI) generated summary...???
|
||||
// passcode_read_expire: obj.passcode_read_expire,
|
||||
// passcode_write: obj.passcode_write,
|
||||
// passcode_write_expire: obj.passcode_write_expire,
|
||||
|
||||
enable: obj.enable,
|
||||
hide: obj.hide,
|
||||
archive: obj.archive,
|
||||
archive_on: obj.archive_on,
|
||||
priority: obj.priority,
|
||||
sort: obj.sort,
|
||||
group: obj.group,
|
||||
notes: obj.notes,
|
||||
created_on: obj.created_on,
|
||||
updated_on: obj.updated_on,
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
tmp_sort_1: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on}_${obj.created_on}`,
|
||||
tmp_sort_2: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on ?? obj.created_on}`,
|
||||
tmp_sort_3: `${obj.group}_${obj.priority}_${obj.sort}_${obj.name}_${obj.updated_on ?? obj.created_on}`,
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
// tmp_sort_1: `${obj.original_datetime}_${obj.group}_${obj.priority}_${obj.sort}`,
|
||||
// tmp_sort_2: `${obj.group}_${obj.original_datetime}_${obj.priority}_${obj.sort}`,
|
||||
|
||||
// From SQL view
|
||||
journal_code: obj.journal_code,
|
||||
journal_name: obj.journal_name,
|
||||
|
||||
// A key value list of the others
|
||||
// journal_other_kv: obj.journal_other_kv,
|
||||
// journal_other_li: obj.journal_other_li,
|
||||
};
|
||||
|
||||
processed_obj_li.push(processed_obj);
|
||||
}
|
||||
|
||||
return processed_obj_li;
|
||||
return processed_obj_li;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-05-09
|
||||
export async function process_ae_obj__journal_entry_props({
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
return _process_generic_props({
|
||||
obj_li,
|
||||
obj_type: 'journal_entry',
|
||||
log_lvl,
|
||||
specific_processor: async (obj) => {
|
||||
// Content processing
|
||||
let content = obj.content ?? '';
|
||||
let content_cleaned: null | string = null;
|
||||
let content_md_html: null | string = null;
|
||||
|
||||
if (obj.content_encrypted) {
|
||||
content = null;
|
||||
content_cleaned = null;
|
||||
content_md_html = null;
|
||||
} else {
|
||||
content_cleaned = content.replace(/^[\u200B\u200C\u200D\u200E\u200F\uFEFF]/, '');
|
||||
content_md_html = (await marked.parse(content_cleaned ?? '')) ?? null;
|
||||
}
|
||||
obj.content = content;
|
||||
obj.content_md_html = content_md_html;
|
||||
|
||||
// History processing
|
||||
let history = obj.history ?? '';
|
||||
let history_cleaned: null | string = null;
|
||||
let history_md_html: null | string = null;
|
||||
|
||||
if (obj.history_encrypted) {
|
||||
history = null;
|
||||
history_cleaned = null;
|
||||
history_md_html = null;
|
||||
} else {
|
||||
history_cleaned = history.replace(/^[\u200B\u200C\u200D\u200E\u200F\uFEFF]/, '');
|
||||
history_md_html = (await marked.parse(history_cleaned ?? '')) ?? null;
|
||||
}
|
||||
obj.history = history;
|
||||
obj.history_md_html = history_md_html;
|
||||
|
||||
// Journal entry-specific computed sort fields, overriding generic ones if needed
|
||||
obj.tmp_sort_1 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
|
||||
obj.sort?.toString().padStart(3, '0') ?? ''
|
||||
}_${obj.updated_on ?? obj.created_on}`;
|
||||
obj.tmp_sort_2 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
|
||||
obj.sort?.toString().padStart(3, '0') ?? ''
|
||||
}_${obj.name ?? ''}_${obj.updated_on ?? obj.created_on}`;
|
||||
obj.tmp_sort_3 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
|
||||
obj.sort?.toString().padStart(3, '0') ?? ''
|
||||
}_${obj.name ?? ''}_${obj.updated_on ?? obj.created_on}`;
|
||||
|
||||
return obj;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -928,82 +928,98 @@ export const properties_to_save = [
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* NON-EXPORTED LOCAL HELPER
|
||||
* Processes a list of Aether objects by applying common and specific transformations.
|
||||
*/
|
||||
async function _process_generic_props<T extends Record<string, any>>({
|
||||
obj_li,
|
||||
obj_type,
|
||||
log_lvl = 0,
|
||||
specific_processor
|
||||
}: {
|
||||
obj_li: T[];
|
||||
obj_type: string;
|
||||
log_lvl?: number;
|
||||
specific_processor?: (obj: T) => Promise<T> | T;
|
||||
}): Promise<T[]> {
|
||||
if (log_lvl > 0) {
|
||||
console.log(
|
||||
`*** _process_generic_props: Processing ${obj_li.length} objects of type "${obj_type}" ***`
|
||||
);
|
||||
}
|
||||
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl > 0) console.log('No objects to process.');
|
||||
return [];
|
||||
}
|
||||
|
||||
const processed_obj_li: T[] = [];
|
||||
|
||||
for (const original_obj of obj_li) {
|
||||
let processed_obj = { ...original_obj };
|
||||
|
||||
// --- Common Transformations ---
|
||||
|
||||
// 1. Standardize ID and other '_random' fields
|
||||
// The API often returns fields like 'person_id_random', which need to be aliased to 'person_id'.
|
||||
for (const key in processed_obj) {
|
||||
if (key.endsWith('_random')) {
|
||||
const newKey = key.slice(0, -7); // Remove '_random' suffix
|
||||
processed_obj[newKey] = processed_obj[key];
|
||||
}
|
||||
}
|
||||
// Ensure 'id' is set from '[obj_type]_id_random'
|
||||
const randomIdKey = `${obj_type}_id_random`;
|
||||
if (processed_obj[randomIdKey]) {
|
||||
processed_obj.id = processed_obj[randomIdKey];
|
||||
}
|
||||
|
||||
// 2. Create common computed properties for client-side sorting.
|
||||
const group = processed_obj.group ?? '0';
|
||||
const priority = processed_obj.priority ? 1 : 0;
|
||||
const sort = processed_obj.sort ?? '0';
|
||||
const updated = processed_obj.updated_on ?? processed_obj.created_on;
|
||||
const name = processed_obj.name ?? '';
|
||||
|
||||
processed_obj.tmp_sort_1 = `${group}_${priority}_${sort}_${updated}`;
|
||||
processed_obj.tmp_sort_2 = `${group}_${priority}_${sort}_${name}_${updated}`;
|
||||
|
||||
// --- Specific Transformations ---
|
||||
if (specific_processor) {
|
||||
processed_obj = await Promise.resolve(specific_processor(processed_obj));
|
||||
}
|
||||
|
||||
processed_obj_li.push(processed_obj as T);
|
||||
}
|
||||
|
||||
return processed_obj_li;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-06-04
|
||||
export async function process_ae_obj__post_props({
|
||||
obj_li,
|
||||
log_lvl = 0,
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** process_ae_obj__post_props() ***`, obj_li);
|
||||
}
|
||||
return _process_generic_props({
|
||||
obj_li,
|
||||
obj_type: 'post',
|
||||
log_lvl,
|
||||
specific_processor: (obj) => {
|
||||
// Post-specific aliasing and computed sort fields, overriding generic ones if needed
|
||||
obj.name = obj.title; // Map title to name
|
||||
obj.tmp_sort_1 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
|
||||
obj.sort?.toString().padStart(3, '0') ?? ''
|
||||
}_${obj.updated_on ?? obj.created_on}`;
|
||||
obj.tmp_sort_2 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
|
||||
obj.sort?.toString().padStart(3, '0') ?? ''
|
||||
}_${obj.updated_on}_${obj.created_on}`;
|
||||
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl) console.log('No objects to process.');
|
||||
return [];
|
||||
}
|
||||
|
||||
const processed_obj_li = [];
|
||||
|
||||
for (const obj of obj_li) {
|
||||
if (log_lvl) console.log(`Processing ae_obj post:`, obj);
|
||||
|
||||
let processed_obj = {
|
||||
id: obj.post_id_random,
|
||||
post_id: obj.post_id_random,
|
||||
// post_id_random: obj.post_id_random,
|
||||
|
||||
account_id: obj.account_id_random,
|
||||
// account_id_random: obj.account_id_random,
|
||||
|
||||
external_person_id: obj.external_person_id,
|
||||
|
||||
topic_id: obj.topic_id,
|
||||
topic: obj.topic,
|
||||
topic_name: obj.topic_name,
|
||||
|
||||
name: obj.title,
|
||||
title: obj.title,
|
||||
content: obj.content,
|
||||
|
||||
anonymous: obj.anonymous,
|
||||
full_name: obj.full_name,
|
||||
email: obj.email,
|
||||
notify: obj.notify,
|
||||
|
||||
enable_comments: obj.enable_comments,
|
||||
|
||||
archive: obj.archive,
|
||||
archive_on: obj.archive_on,
|
||||
|
||||
linked_li_json: obj.linked_li_json,
|
||||
cfg_json: obj.cfg_json,
|
||||
|
||||
enable: obj.enable,
|
||||
hide: obj.hide,
|
||||
priority: obj.priority,
|
||||
sort: obj.sort,
|
||||
group: obj.group,
|
||||
notes: obj.notes,
|
||||
created_on: obj.created_on,
|
||||
updated_on: obj.updated_on,
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
tmp_sort_1: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on ?? obj.created_on}`,
|
||||
tmp_sort_2: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on}_${obj.created_on}`,
|
||||
|
||||
// From SQL view
|
||||
post_comment_count: obj.post_comment_count,
|
||||
|
||||
// A key value list of the contents
|
||||
// post_comment_kv: obj.post_comment_kv,
|
||||
// post_comment_li: obj.post_comment_li,
|
||||
};
|
||||
|
||||
processed_obj_li.push(processed_obj);
|
||||
}
|
||||
|
||||
return processed_obj_li;
|
||||
return obj;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -528,66 +528,97 @@ export const properties_to_save = [
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* NON-EXPORTED LOCAL HELPER
|
||||
* Processes a list of Aether objects by applying common and specific transformations.
|
||||
*/
|
||||
async function _process_generic_props<T extends Record<string, any>>({
|
||||
obj_li,
|
||||
obj_type,
|
||||
log_lvl = 0,
|
||||
specific_processor
|
||||
}: {
|
||||
obj_li: T[];
|
||||
obj_type: string;
|
||||
log_lvl?: number;
|
||||
specific_processor?: (obj: T) => Promise<T> | T;
|
||||
}): Promise<T[]> {
|
||||
if (log_lvl > 0) {
|
||||
console.log(
|
||||
`*** _process_generic_props: Processing ${obj_li.length} objects of type "${obj_type}" ***`
|
||||
);
|
||||
}
|
||||
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl > 0) console.log('No objects to process.');
|
||||
return [];
|
||||
}
|
||||
|
||||
const processed_obj_li: T[] = [];
|
||||
|
||||
for (const original_obj of obj_li) {
|
||||
let processed_obj = { ...original_obj };
|
||||
|
||||
// --- Common Transformations ---
|
||||
|
||||
// 1. Standardize ID and other '_random' fields
|
||||
// The API often returns fields like 'person_id_random', which need to be aliased to 'person_id'.
|
||||
for (const key in processed_obj) {
|
||||
if (key.endsWith('_random')) {
|
||||
const newKey = key.slice(0, -7); // Remove '_random' suffix
|
||||
processed_obj[newKey] = processed_obj[key];
|
||||
}
|
||||
}
|
||||
// Ensure 'id' is set from '[obj_type]_id_random'
|
||||
const randomIdKey = `${obj_type}_id_random`;
|
||||
if (processed_obj[randomIdKey]) {
|
||||
processed_obj.id = processed_obj[randomIdKey];
|
||||
}
|
||||
|
||||
// 2. Create common computed properties for client-side sorting.
|
||||
const group = processed_obj.group ?? '0';
|
||||
const priority = processed_obj.priority ? 1 : 0;
|
||||
const sort = processed_obj.sort ?? '0';
|
||||
const updated = processed_obj.updated_on ?? processed_obj.created_on;
|
||||
const name = processed_obj.name ?? '';
|
||||
|
||||
processed_obj.tmp_sort_1 = `${group}_${priority}_${sort}_${updated}`;
|
||||
processed_obj.tmp_sort_2 = `${group}_${priority}_${sort}_${name}_${updated}`;
|
||||
|
||||
// --- Specific Transformations ---
|
||||
if (specific_processor) {
|
||||
processed_obj = await Promise.resolve(specific_processor(processed_obj));
|
||||
}
|
||||
|
||||
processed_obj_li.push(processed_obj as T);
|
||||
}
|
||||
|
||||
return processed_obj_li;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-06-04
|
||||
export async function process_ae_obj__post_comment_props({
|
||||
obj_li,
|
||||
log_lvl = 0,
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** process_ae_obj__post_comment_props() ***`, obj_li);
|
||||
}
|
||||
return _process_generic_props({
|
||||
obj_li,
|
||||
obj_type: 'post_comment',
|
||||
log_lvl,
|
||||
specific_processor: (obj) => {
|
||||
// Post comment-specific computed sort fields, overriding generic ones if needed
|
||||
obj.tmp_sort_1 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
|
||||
obj.sort?.toString().padStart(3, '0') ?? ''
|
||||
}_${obj.updated_on ?? obj.created_on}`;
|
||||
obj.tmp_sort_2 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
|
||||
obj.sort?.toString().padStart(2, '0') ?? ''
|
||||
}_${obj.updated_on}_${obj.created_on}`;
|
||||
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl) console.log('No objects to process.');
|
||||
return [];
|
||||
}
|
||||
|
||||
const processed_obj_li = [];
|
||||
|
||||
for (const obj of obj_li) {
|
||||
if (log_lvl) console.log(`Processing ae_obj post_comment:`, obj);
|
||||
|
||||
let processed_obj = {
|
||||
id: obj.post_comment_id_random,
|
||||
post_comment_id: obj.post_comment_id_random,
|
||||
post_comment_id_random: obj.post_comment_id_random,
|
||||
|
||||
post_id: obj.post_id_random,
|
||||
post_id_random: obj.post_id_random,
|
||||
|
||||
external_person_id: obj.external_person_id,
|
||||
|
||||
name: obj.name,
|
||||
title: obj.title,
|
||||
content: obj.content,
|
||||
|
||||
anonymous: obj.anonymous,
|
||||
full_name: obj.full_name,
|
||||
email: obj.email,
|
||||
notify: obj.notify,
|
||||
|
||||
linked_li_json: obj.linked_li_json,
|
||||
cfg_json: obj.cfg_json,
|
||||
|
||||
enable: obj.enable,
|
||||
hide: obj.hide,
|
||||
priority: obj.priority,
|
||||
sort: obj.sort,
|
||||
group: obj.group,
|
||||
notes: obj.notes,
|
||||
created_on: obj.created_on,
|
||||
updated_on: obj.updated_on,
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
tmp_sort_1: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on ?? obj.created_on}`,
|
||||
tmp_sort_2: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on}_${obj.created_on}`,
|
||||
};
|
||||
|
||||
processed_obj_li.push(processed_obj);
|
||||
}
|
||||
|
||||
return processed_obj_li;
|
||||
return obj;
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user