Starting another round of changes by Gemini. Saving things in a working state.
This commit is contained in:
@@ -336,7 +336,11 @@ export async function delete_ae_obj_id(
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Generic processor with dynamic field detection
|
/**
|
||||||
|
* @deprecated This function is deprecated. Use module-specific `process_ae_obj__*_props` functions instead.
|
||||||
|
* This generic processor with dynamic field detection is an older implementation.
|
||||||
|
* Module-specific processors now handle ID aliasing, content processing, and computed properties more effectively.
|
||||||
|
*/
|
||||||
export async function process_ae_obj__props({
|
export async function process_ae_obj__props({
|
||||||
obj_li,
|
obj_li,
|
||||||
log_lvl = 0,
|
log_lvl = 0,
|
||||||
|
|||||||
@@ -552,20 +552,20 @@ let properties_to_save = [
|
|||||||
|
|
||||||
'id',
|
'id',
|
||||||
'person_id',
|
'person_id',
|
||||||
'person_id_random',
|
// 'person_id_random',
|
||||||
|
|
||||||
'external_id',
|
'external_id',
|
||||||
'external_sys_id',
|
'external_sys_id',
|
||||||
'code',
|
'code',
|
||||||
|
|
||||||
'account_id',
|
'account_id',
|
||||||
'account_id_random',
|
// 'account_id_random',
|
||||||
|
|
||||||
'person_profile_id',
|
'person_profile_id',
|
||||||
'person_profile_id_random', // The new table person_profile will be used soon...
|
// 'person_profile_id_random', // The new table person_profile will be used soon...
|
||||||
|
|
||||||
'user_id',
|
'user_id',
|
||||||
'user_id_random',
|
// 'user_id_random',
|
||||||
|
|
||||||
'pronouns',
|
'pronouns',
|
||||||
'informal_name',
|
'informal_name',
|
||||||
@@ -628,11 +628,11 @@ let properties_to_save = [
|
|||||||
'user_public',
|
'user_public',
|
||||||
|
|
||||||
'organization_id',
|
'organization_id',
|
||||||
'organization_id_random',
|
// 'organization_id_random',
|
||||||
'organization_name',
|
'organization_name',
|
||||||
|
|
||||||
'contact_id',
|
'contact_id',
|
||||||
'contact_id_random',
|
// 'contact_id_random',
|
||||||
'contact_name',
|
'contact_name',
|
||||||
'contact_email',
|
'contact_email',
|
||||||
'contact_cc_email',
|
'contact_cc_email',
|
||||||
@@ -644,151 +644,106 @@ let properties_to_save = [
|
|||||||
'contact_phone_other',
|
'contact_phone_other',
|
||||||
|
|
||||||
'address_id',
|
'address_id',
|
||||||
'address_id_random',
|
// 'address_id_random',
|
||||||
'address_city',
|
'address_city',
|
||||||
'address_country_alpha_2_code', // contact_address_country_alpha_2_code
|
'address_country_alpha_2_code', // contact_address_country_alpha_2_code
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
// Updated 2025-06-10
|
/**
|
||||||
export async function process_ae_obj__person_props(
|
* NON-EXPORTED LOCAL HELPER
|
||||||
{
|
* Processes a list of Aether objects by applying common and specific transformations.
|
||||||
// obj_type,
|
*/
|
||||||
obj_li,
|
async function _process_generic_props<T extends Record<string, any>>({
|
||||||
log_lvl = 0,
|
obj_li,
|
||||||
}: {
|
obj_type,
|
||||||
// obj_type: string;
|
log_lvl = 0,
|
||||||
obj_li: any[];
|
specific_processor
|
||||||
log_lvl?: number;
|
}: {
|
||||||
}
|
obj_li: T[];
|
||||||
) {
|
obj_type: string;
|
||||||
if (log_lvl) {
|
log_lvl?: number;
|
||||||
console.log(`*** process_ae_obj__person_props() ***`, obj_li);
|
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 (!obj_li || obj_li.length === 0) {
|
||||||
if (log_lvl) {
|
if (log_lvl > 0) console.log('No objects to process.');
|
||||||
console.log('No objects to process.');
|
return [];
|
||||||
}
|
}
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
const processed_obj_li = [];
|
const processed_obj_li: T[] = [];
|
||||||
|
|
||||||
for (const obj of obj_li) {
|
for (const original_obj of obj_li) {
|
||||||
// const processed_obj = { ...obj };
|
let processed_obj = { ...original_obj };
|
||||||
|
|
||||||
// Process the properties as needed
|
// --- Common Transformations ---
|
||||||
// None needed to process for person at this time...
|
|
||||||
|
|
||||||
let processed_obj = {
|
// 1. Standardize ID and other '_random' fields
|
||||||
id: obj.person_id_random,
|
// The API often returns fields like 'person_id_random', which need to be aliased to 'person_id'.
|
||||||
person_id: obj.person_id_random,
|
for (const key in processed_obj) {
|
||||||
person_id_random: obj.person_id_random,
|
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];
|
||||||
|
}
|
||||||
|
|
||||||
external_id: obj.external_id,
|
// 2. Create common computed properties for client-side sorting.
|
||||||
external_sys_id: obj.external_sys_id,
|
const group = processed_obj.group ?? '0';
|
||||||
code: obj.code,
|
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 ?? '';
|
||||||
|
|
||||||
account_id: obj.account_id_random,
|
processed_obj.tmp_sort_1 = `${group}_${priority}_${sort}_${updated}`;
|
||||||
account_id_random: obj.account_id_random,
|
processed_obj.tmp_sort_2 = `${group}_${priority}_${sort}_${name}_${updated}`;
|
||||||
|
|
||||||
person_profile_id: obj.person_profile_id_random,
|
// --- Specific Transformations ---
|
||||||
person_profile_id_random: obj.person_profile_id_random, // The new table person_profile will be used soon...
|
if (specific_processor) {
|
||||||
|
processed_obj = await Promise.resolve(specific_processor(processed_obj));
|
||||||
|
}
|
||||||
|
|
||||||
user_id: obj.user_id_random,
|
processed_obj_li.push(processed_obj as T);
|
||||||
user_id_random: obj.user_id_random,
|
}
|
||||||
|
|
||||||
pronouns: obj.pronouns,
|
return processed_obj_li;
|
||||||
informal_name: obj.informal_name,
|
}
|
||||||
title_names: obj.title_names,
|
|
||||||
given_name: obj.given_name,
|
|
||||||
middle_name: obj.middle_name,
|
// Updated 2025-06-10
|
||||||
family_name: obj.family_name,
|
export async function process_ae_obj__person_props({
|
||||||
designations: obj.designations,
|
obj_li,
|
||||||
|
log_lvl = 0
|
||||||
professional_title: obj.professional_title,
|
}: {
|
||||||
|
obj_li: any[];
|
||||||
full_name: obj.full_name,
|
log_lvl?: number;
|
||||||
full_name_override: obj.full_name_override, // was display_name and display_name_override
|
}) {
|
||||||
|
return _process_generic_props({
|
||||||
affiliations: obj.affiliations,
|
obj_li,
|
||||||
|
obj_type: 'person',
|
||||||
primary_email: obj.primary_email,
|
log_lvl,
|
||||||
|
specific_processor: (obj) => {
|
||||||
biography: obj.biography,
|
// Person-specific computed sort fields, overriding generic ones if needed
|
||||||
|
obj.tmp_sort_1 = `${obj.group ?? '0'}_${obj.priority ? 1 : 0}_${
|
||||||
agree: obj.agree,
|
obj.sort ?? '0'
|
||||||
comments: obj.comments,
|
}_${obj.updated_on}_${obj.created_on}`;
|
||||||
|
obj.tmp_sort_2 = `${obj.group ?? '0'}_${obj.priority ? 1 : 0}_${
|
||||||
allow_auth_key: obj.allow_auth_key, // For sign in without password
|
obj.sort ?? '0'
|
||||||
// auth_key: obj.auth_key,
|
}_${obj.updated_on ?? obj.created_on}`;
|
||||||
passcode: obj.passcode,
|
obj.tmp_sort_3 = `${obj.group ?? '0'}_${obj.priority ? 1 : 0}_${
|
||||||
// passcode_timeout: obj.passcode_timeout,
|
obj.sort ?? '0'
|
||||||
|
}_${obj.name ?? ''}_${obj.updated_on ?? obj.created_on}`;
|
||||||
// This only allows for basic access to the data.
|
|
||||||
// passcode_read: obj.passcode_read, // For LLM (AI) generated summary...???
|
return obj;
|
||||||
// passcode_read_expire: obj.passcode_read_expire,
|
}
|
||||||
// passcode_write: obj.passcode_write,
|
});
|
||||||
// passcode_write_expire: obj.passcode_write_expire,
|
|
||||||
|
|
||||||
// private_passcode: obj.private_passcode,
|
|
||||||
|
|
||||||
// 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 ?? '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}`,
|
|
||||||
|
|
||||||
// From SQL view
|
|
||||||
username: obj.username, // Same as user_username
|
|
||||||
user_name: obj.user_name,
|
|
||||||
user_email: obj.user_email,
|
|
||||||
user_allow_auth_key: obj.user_allow_auth_key, // For sign in without password
|
|
||||||
user_super: obj.user_super,
|
|
||||||
user_manager: obj.user_manager,
|
|
||||||
user_administrator: obj.user_administrator,
|
|
||||||
user_public: obj.user_public,
|
|
||||||
|
|
||||||
organization_id: obj.organization_id_random,
|
|
||||||
organization_id_random: obj.organization_id_random,
|
|
||||||
organization_name: obj.organization_name,
|
|
||||||
|
|
||||||
contact_id: obj.contact_id_random,
|
|
||||||
contact_id_random: obj.contact_id_random,
|
|
||||||
contact_name: obj.contact_name,
|
|
||||||
contact_email: obj.contact_email,
|
|
||||||
contact_cc_email: obj.contact_cc_email,
|
|
||||||
contact_phone_mobile: obj.contact_phone_mobile,
|
|
||||||
contact_phone_home: obj.contact_phone_home,
|
|
||||||
contact_phone_office: obj.contact_phone_office,
|
|
||||||
contact_phone_land: obj.contact_phone_land,
|
|
||||||
contact_phone_fax: obj.contact_phone_fax,
|
|
||||||
contact_phone_other: obj.contact_phone_other,
|
|
||||||
|
|
||||||
address_id: obj.contact_address_id_random,
|
|
||||||
address_id_random: obj.contact_address_id_random,
|
|
||||||
address_city: obj.contact_address_city,
|
|
||||||
address_country_alpha_2_code: obj.contact_address_country_alpha_2_code, // contact_address_country_alpha_2_code
|
|
||||||
};
|
|
||||||
|
|
||||||
processed_obj_li.push(processed_obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
return processed_obj_li;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -541,13 +541,13 @@ export async function db_save_ae_obj_li__event_badge({
|
|||||||
export const properties_to_save = [
|
export const properties_to_save = [
|
||||||
'id',
|
'id',
|
||||||
'event_badge_id',
|
'event_badge_id',
|
||||||
'event_badge_id_random',
|
// 'event_badge_id_random',
|
||||||
|
|
||||||
'event_id',
|
'event_id',
|
||||||
'event_id_random',
|
// 'event_id_random',
|
||||||
|
|
||||||
'event_badge_template_id',
|
'event_badge_template_id',
|
||||||
'event_badge_template_id_random',
|
// 'event_badge_template_id_random',
|
||||||
|
|
||||||
'pronouns',
|
'pronouns',
|
||||||
'informal_name',
|
'informal_name',
|
||||||
@@ -622,106 +622,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-10-06
|
// Updated 2025-10-06
|
||||||
export async function process_ae_obj__event_badge_props({
|
export async function process_ae_obj__event_badge_props({
|
||||||
obj_li,
|
obj_li,
|
||||||
log_lvl = 0,
|
log_lvl = 0
|
||||||
}: {
|
}: {
|
||||||
obj_li: any[];
|
obj_li: any[];
|
||||||
log_lvl?: number;
|
log_lvl?: number;
|
||||||
}) {
|
}) {
|
||||||
if (log_lvl) {
|
return _process_generic_props({
|
||||||
console.log(`*** process_ae_obj__event_badge_props() ***`, obj_li);
|
obj_li,
|
||||||
}
|
obj_type: 'event_badge',
|
||||||
if (!obj_li || obj_li.length === 0) {
|
log_lvl,
|
||||||
if (log_lvl) console.log('No objects to process.');
|
specific_processor: (obj) => {
|
||||||
return [];
|
// Event badge-specific computed sort fields, overriding generic ones if needed
|
||||||
}
|
obj.tmp_sort_1 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
|
||||||
const processed_obj_li = [];
|
obj.sort?.toString().padStart(3, '0') ?? ''
|
||||||
for (const obj of obj_li) {
|
}_${obj.updated_on ?? obj.created_on}`;
|
||||||
if (log_lvl) console.log(`Processing ae_obj event_badge:`, obj);
|
obj.tmp_sort_2 = `${obj.print_count ?? '0'}_${obj.priority ? '1' : '0'}_${
|
||||||
let processed_obj = {
|
obj.sort?.toString().padStart(3, '0') ?? ''
|
||||||
id: obj.event_badge_id_random,
|
}_${obj.given_name ?? ''}_${obj.family_name ?? ''}_${obj.updated_on ?? obj.created_on}`;
|
||||||
event_badge_id: obj.event_badge_id_random,
|
|
||||||
event_badge_id_random: obj.event_badge_id_random,
|
|
||||||
|
|
||||||
event_id: obj.event_id_random,
|
return obj;
|
||||||
event_id_random: obj.event_id_random,
|
}
|
||||||
|
});
|
||||||
event_badge_template_id: obj.event_badge_template_id_random,
|
|
||||||
event_badge_template_id_random: obj.event_badge_template_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,
|
|
||||||
professional_title_override: obj.professional_title_override,
|
|
||||||
|
|
||||||
full_name: obj.full_name,
|
|
||||||
full_name_override: obj.full_name_override,
|
|
||||||
|
|
||||||
affiliations: obj.affiliations,
|
|
||||||
affiliations_override: obj.affiliations_override,
|
|
||||||
|
|
||||||
email: obj.email,
|
|
||||||
email_override: obj.email_override,
|
|
||||||
|
|
||||||
address_line_1: obj.address_line_1,
|
|
||||||
address_line_2: obj.address_line_2,
|
|
||||||
address_line_3: obj.address_line_3,
|
|
||||||
city: obj.city,
|
|
||||||
country_subdivision_code: obj.country_subdivision_code,
|
|
||||||
state_province: obj.state_province,
|
|
||||||
state_province_abb: obj.state_province_abb,
|
|
||||||
postal_code: obj.postal_code,
|
|
||||||
country_alpha_2_code: obj.country_alpha_2_code,
|
|
||||||
country: obj.country,
|
|
||||||
full_address: obj.full_address,
|
|
||||||
location: obj.location,
|
|
||||||
location_override: obj.location_override,
|
|
||||||
|
|
||||||
query_str: obj.query_str,
|
|
||||||
|
|
||||||
badge_type: obj.badge_type,
|
|
||||||
badge_type_code: obj.badge_type_code,
|
|
||||||
badge_type_override: obj.badge_type_override,
|
|
||||||
badge_type_code_override: obj.badge_type_code_override,
|
|
||||||
external_event_id: obj.external_event_id,
|
|
||||||
external_id: obj.external_id,
|
|
||||||
external_person_id: obj.external_person_id,
|
|
||||||
|
|
||||||
default_qry_string: obj.default_qry_string,
|
|
||||||
|
|
||||||
alert: obj.alert,
|
|
||||||
|
|
||||||
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.print_count}_${obj.priority}_${obj.sort}_${obj.given_name}_${obj.family_name}_${obj.updated_on}_${obj.created_on}`,
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user