Updated the person functions. General clean up of code.
This commit is contained in:
@@ -11,11 +11,12 @@ import {
|
||||
} from "$lib/ae_core/core__activity_log";
|
||||
|
||||
import {
|
||||
handle_load_ae_obj_id__person,
|
||||
handle_load_ae_obj_li__person,
|
||||
handle_create_ae_obj__person,
|
||||
handle_update_ae_obj__person,
|
||||
// handle_db_save_ae_obj_li__person
|
||||
load_ae_obj_id__person,
|
||||
load_ae_obj_li__person,
|
||||
create_ae_obj__person,
|
||||
delete_ae_obj_id__person,
|
||||
update_ae_obj__person,
|
||||
// db_save_ae_obj_li__person
|
||||
} from "$lib/ae_core/core__person";
|
||||
|
||||
import {
|
||||
@@ -428,32 +429,43 @@ async function handle_download_export__obj_type(
|
||||
|
||||
let export_obj = {
|
||||
check_hosted_file_obj_w_hash: check_hosted_file_obj_w_hash,
|
||||
|
||||
load_ae_obj_li__time_zone: load_ae_obj_li__time_zone,
|
||||
|
||||
load_ae_obj_li__country: load_ae_obj_li__country,
|
||||
load_ae_obj_li__country_subdivision: load_ae_obj_li__country_subdivision,
|
||||
|
||||
load_ae_obj_id__hosted_file: load_ae_obj_id__hosted_file,
|
||||
load_ae_obj_li__hosted_file: load_ae_obj_li__hosted_file,
|
||||
delete_ae_obj_id__hosted_file: delete_ae_obj_id__hosted_file,
|
||||
db_save_ae_obj_li__hosted_file: db_save_ae_obj_li__hosted_file,
|
||||
db_update_ae_obj_id__hosted_file: db_update_ae_obj_id__hosted_file,
|
||||
|
||||
db_save_ae_obj_li__ae_obj: db_save_ae_obj_li__ae_obj,
|
||||
|
||||
add_url_params: add_url_params,
|
||||
clean_headers: clean_headers,
|
||||
|
||||
handle_load_ae_obj_id__site_domain: handle_load_ae_obj_id__site_domain,
|
||||
handle_load_ae_obj_code__data_store: handle_load_ae_obj_code__data_store,
|
||||
|
||||
load_ae_obj_id__activity_log: load_ae_obj_id__activity_log,
|
||||
load_ae_obj_li__activity_log: load_ae_obj_li__activity_log,
|
||||
create_ae_obj__activity_log: create_ae_obj__activity_log,
|
||||
update_ae_obj__activity_log: update_ae_obj__activity_log,
|
||||
handle_load_ae_obj_id__person: handle_load_ae_obj_id__person,
|
||||
handle_load_ae_obj_li__person: handle_load_ae_obj_li__person,
|
||||
handle_create_ae_obj__person: handle_create_ae_obj__person,
|
||||
handle_update_ae_obj__person: handle_update_ae_obj__person,
|
||||
|
||||
load_ae_obj_id__person: load_ae_obj_id__person,
|
||||
load_ae_obj_li__person: load_ae_obj_li__person,
|
||||
create_ae_obj__person: create_ae_obj__person,
|
||||
delete_ae_obj_id__person: delete_ae_obj_id__person,
|
||||
update_ae_obj__person: update_ae_obj__person,
|
||||
|
||||
auth_ae_obj__username_password: auth_ae_obj__username_password,
|
||||
auth_ae_obj__user_id_user_auth_key: auth_ae_obj__user_id_user_auth_key,
|
||||
send_email_auth_ae_obj__user_id: send_email_auth_ae_obj__user_id,
|
||||
qry_ae_obj_li__user_email: qry_ae_obj_li__user_email,
|
||||
auth_ae_obj__user_id_change_password: auth_ae_obj__user_id_change_password,
|
||||
|
||||
handle_update_ae_obj_id_crud: handle_update_ae_obj_id_crud,
|
||||
handle_download_export__obj_type: handle_download_export__obj_type,
|
||||
generate_qr_code: generate_qr_code
|
||||
|
||||
@@ -1,42 +1,74 @@
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
import { api } from '$lib/api';
|
||||
|
||||
import { db_save_ae_obj_li__ae_obj } from "$lib/ae_core/core__idb_dexie";
|
||||
import { db_core } from "$lib/ae_core/db_core";
|
||||
|
||||
let ae_promises: key_val = {};
|
||||
|
||||
|
||||
// Updated 2024-07-17
|
||||
export async function handle_load_ae_obj_id__person(
|
||||
// Updated 2025-06-10
|
||||
export async function load_ae_obj_id__person(
|
||||
{
|
||||
api_cfg,
|
||||
person_id,
|
||||
params = {},
|
||||
try_cache = false,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
person_id: string,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** handle_load_ae_obj_id__person() *** person_id=${person_id}`);
|
||||
|
||||
let params = {};
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_id__person() *** person_id=${person_id}`);
|
||||
}
|
||||
|
||||
ae_promises.load__person_obj = await api.get_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'person',
|
||||
obj_id: person_id, // NOTE: This is the FQDN, not normally the ID.
|
||||
use_alt_table: false, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value
|
||||
obj_id: person_id,
|
||||
use_alt_table: false,
|
||||
use_alt_base: false,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (person_obj_get_result) {
|
||||
.then(async function (person_obj_get_result) {
|
||||
if (person_obj_get_result) {
|
||||
// This is expecting a list
|
||||
handle_db_save_ae_obj_li__person({obj_type: 'person', obj_li: [person_obj_get_result]});
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__person_props({
|
||||
obj_li: [person_obj_get_result],
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_core,
|
||||
table_name: 'person',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// // This is expecting a list
|
||||
// db_save_ae_obj_li__person({
|
||||
// obj_type: 'person',
|
||||
// obj_li: [person_obj_get_result],
|
||||
// log_lvl: log_lvl
|
||||
// });
|
||||
}
|
||||
return person_obj_get_result;
|
||||
} else {
|
||||
console.log('No results returned.');
|
||||
@@ -47,22 +79,28 @@ export async function handle_load_ae_obj_id__person(
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.load__person_obj:', ae_promises.load__person_obj);
|
||||
}
|
||||
|
||||
return ae_promises.load__person_obj;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-07-17
|
||||
export async function handle_load_ae_obj_li__person(
|
||||
// Updated 2025-06-10
|
||||
export async function load_ae_obj_li__person(
|
||||
{
|
||||
api_cfg,
|
||||
for_obj_type = 'account',
|
||||
for_obj_id,
|
||||
qry_email = null,
|
||||
qry_user_id = null,
|
||||
enabled = 'enabled',
|
||||
hidden = 'not_hidden',
|
||||
limit = 99,
|
||||
offset = 0,
|
||||
order_by_li = {'start_datetime': 'DESC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'},
|
||||
params_json = null,
|
||||
order_by_li = {'family_name': 'ASC', 'given_name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'},
|
||||
params_json = {},
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
@@ -70,8 +108,10 @@ export async function handle_load_ae_obj_li__person(
|
||||
api_cfg: any,
|
||||
for_obj_type: string,
|
||||
for_obj_id: string,
|
||||
enabled?: string,
|
||||
hidden?: string,
|
||||
qry_email?: string|null,
|
||||
qry_user_id?: string|null,
|
||||
enabled?: string, // all, disabled, enabled
|
||||
hidden?: string, // all, hidden, not_hidden
|
||||
limit?: number,
|
||||
offset?: number,
|
||||
order_by_li?: key_val,
|
||||
@@ -81,32 +121,78 @@ export async function handle_load_ae_obj_li__person(
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** handle_load_ae_obj_li__person() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id} enabled=${enabled} hidden=${hidden} limit=${limit} offset=${offset}`);
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_li__person() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id} enabled=${enabled} hidden=${hidden} limit=${limit} offset=${offset}`);
|
||||
}
|
||||
|
||||
// console.log('params_json:', params_json);
|
||||
if (qry_user_id) {
|
||||
// params_json['and_qry'] = {};
|
||||
// params_json['and_qry']['user_id_random'] = qry_user_id;
|
||||
|
||||
let qry_param =
|
||||
{
|
||||
type: "AND",
|
||||
field: "person_id_random",
|
||||
operator: "=",
|
||||
value: qry_person_id
|
||||
};
|
||||
params_json['qry'].push(qry_param);
|
||||
}
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('params_json:', params_json);
|
||||
}
|
||||
|
||||
ae_promises.load__person_obj_li = await api.get_ae_obj_li_for_obj_id_crud_v2({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'person',
|
||||
for_obj_type: 'account',
|
||||
for_obj_type: for_obj_type,
|
||||
for_obj_id: for_obj_id,
|
||||
use_alt_tbl: false,
|
||||
use_alt_mdl: false,
|
||||
use_alt_exp: false,
|
||||
// use_alt_table: false, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
// use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: {'given_name': 'ASC', 'family_name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'},
|
||||
order_by_li: order_by_li,
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: params_json,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (person_obj_li_get_result) {
|
||||
.then(async function (person_obj_li_get_result) {
|
||||
if (person_obj_li_get_result) {
|
||||
handle_db_save_ae_obj_li__person({obj_type: 'person', obj_li: person_obj_li_get_result});
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__person_props({
|
||||
obj_li: person_obj_li_get_result,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_core,
|
||||
table_name: 'person',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// db_save_ae_obj_li__person({
|
||||
// obj_type: 'person',
|
||||
// obj_li: person_obj_li_get_result,
|
||||
// log_lvl: log_lvl
|
||||
// });
|
||||
}
|
||||
return person_obj_li_get_result;
|
||||
} else {
|
||||
return [];
|
||||
@@ -121,23 +207,27 @@ export async function handle_load_ae_obj_li__person(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-06-24
|
||||
export async function handle_create_ae_obj__person(
|
||||
// Updated 2025-06-10
|
||||
export async function create_ae_obj__person(
|
||||
{
|
||||
api_cfg,
|
||||
user_id,
|
||||
data_kv,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
user_id?: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** handle_create_ae_obj__person() *** user_id=${user_id}`);
|
||||
if (log_lvl) {
|
||||
console.log(`*** create_ae_obj__person() *** user_id=${user_id}`);
|
||||
}
|
||||
|
||||
ae_promises.create__person = await api.create_ae_obj_crud({
|
||||
api_cfg: api_cfg,
|
||||
@@ -151,12 +241,39 @@ export async function handle_create_ae_obj__person(
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (person_obj_create_result) {
|
||||
.then(async function (person_obj_create_result) {
|
||||
if (person_obj_create_result) {
|
||||
handle_db_save_ae_obj_li__person(
|
||||
{
|
||||
obj_type: 'person', obj_li: [person_obj_create_result]
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__person_props({
|
||||
obj_li: [person_obj_create_result],
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_core,
|
||||
table_name: 'person',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// db_save_ae_obj_li__person(
|
||||
// {
|
||||
// obj_type: 'person',
|
||||
// obj_li: [person_obj_create_result],
|
||||
// log_lvl: log_lvl
|
||||
// });
|
||||
}
|
||||
return person_obj_create_result;
|
||||
} else {
|
||||
return null;
|
||||
@@ -175,58 +292,135 @@ export async function handle_create_ae_obj__person(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-07-17
|
||||
export async function handle_update_ae_obj__person(
|
||||
// Updated 2025-05-10
|
||||
export async function delete_ae_obj_id__person(
|
||||
{
|
||||
api_cfg,
|
||||
person_id,
|
||||
method = 'delete', // 'delete', 'disable', 'hide'
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
person_id: string,
|
||||
method?: string,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** delete_ae_obj_id__person() *** person_id=${person_id}`);
|
||||
}
|
||||
|
||||
ae_promises.delete__person_obj = await api.delete_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'person',
|
||||
obj_id: person_id,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
method: method,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(async function () {
|
||||
if (try_cache) {
|
||||
if (log_lvl) {
|
||||
console.log(`Attempting to remove IDB entry for person_id=${person_id}`);
|
||||
}
|
||||
await db_core.person.delete(person_id);
|
||||
}
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.delete__person_obj:', ae_promises.delete__person_obj);
|
||||
}
|
||||
|
||||
return ae_promises.delete__person_obj;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-06-10
|
||||
export async function update_ae_obj__person(
|
||||
{
|
||||
api_cfg,
|
||||
person_id,
|
||||
data_kv,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
person_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** handle_update_ae_obj__person() *** person_id=${person_id}`);
|
||||
if (log_lvl) {
|
||||
console.log(`*** update_ae_obj__person() *** person_id=${person_id}`, data_kv);
|
||||
}
|
||||
|
||||
ae_promises.update__person_obj = await api.update_ae_obj_id_crud({
|
||||
// log_lvl = 1;
|
||||
|
||||
// Perform the API update
|
||||
const result = await api.update_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'person',
|
||||
obj_id: person_id, // NOTE: This is the FQDN, not normally the ID.
|
||||
obj_id: person_id,
|
||||
fields: data_kv,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (person_obj_update_result) {
|
||||
if (person_obj_update_result) {
|
||||
handle_db_save_ae_obj_li__person({obj_type: 'person', obj_li: [person_obj_update_result]});
|
||||
return person_obj_update_result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.update__person_obj:', ae_promises.update__person_obj);
|
||||
// Handle the result
|
||||
if (result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__person_props({
|
||||
obj_li: [result],
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_core,
|
||||
table_name: 'person',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// await db_save_ae_obj_li__person({
|
||||
// obj_type: 'person',
|
||||
// obj_li: [result],
|
||||
// log_lvl: log_lvl,
|
||||
// });
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
console.error('Failed to update person.');
|
||||
return null;
|
||||
}
|
||||
return ae_promises.update__person_obj;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Updated 2024-06-10
|
||||
export function handle_db_save_ae_obj_li__person(
|
||||
export function db_save_ae_obj_li__person(
|
||||
{
|
||||
obj_type,
|
||||
obj_li,
|
||||
@@ -238,7 +432,7 @@ export function handle_db_save_ae_obj_li__person(
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** handle_db_save_ae_obj_li__person() ***`);
|
||||
console.log(`*** db_save_ae_obj_li__person() ***`);
|
||||
}
|
||||
|
||||
if (obj_li && obj_li.length) {
|
||||
@@ -277,8 +471,7 @@ export function handle_db_save_ae_obj_li__person(
|
||||
professional_title: obj.professional_title,
|
||||
|
||||
full_name: obj.full_name,
|
||||
// full_name_override: obj.full_name_override,
|
||||
full_name_override: obj.display_name_override,
|
||||
full_name_override: obj.full_name_override, // was display_name and display_name_override
|
||||
|
||||
affiliations: obj.affiliations,
|
||||
|
||||
@@ -348,3 +541,207 @@ export function handle_db_save_ae_obj_li__person(
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-06-10
|
||||
let properties_to_save = [
|
||||
|
||||
'id',
|
||||
'person_id',
|
||||
'person_id_random',
|
||||
|
||||
'external_id',
|
||||
'external_sys_id',
|
||||
'code',
|
||||
|
||||
'account_id',
|
||||
'account_id_random',
|
||||
|
||||
'person_profile_id',
|
||||
'person_profile_id_random', // The new table person_profile will be used soon...
|
||||
|
||||
'user_id',
|
||||
'user_id_random',
|
||||
|
||||
'pronouns',
|
||||
'informal_name',
|
||||
'title_names',
|
||||
'given_name',
|
||||
'middle_name',
|
||||
'family_name',
|
||||
'designations',
|
||||
|
||||
'professional_title',
|
||||
|
||||
'full_name',
|
||||
'full_name_override', // was display_name and display_name_override
|
||||
|
||||
'affiliations',
|
||||
'primary_email',
|
||||
'biography',
|
||||
'agree',
|
||||
'comments',
|
||||
|
||||
'allow_auth_key', // For sign in without password
|
||||
// 'auth_key',
|
||||
'passcode',
|
||||
|
||||
// 'passcode_timeout',
|
||||
// 'passcode_read', // For LLM (AI) generated summary...???
|
||||
// 'passcode_read_expire',
|
||||
// 'passcode_write',
|
||||
// 'passcode_write_expire',
|
||||
// 'private_passcode',
|
||||
|
||||
// 'alert',
|
||||
// 'alert_msg',
|
||||
|
||||
'data_json',
|
||||
|
||||
'enable',
|
||||
'hide',
|
||||
'priority',
|
||||
'sort',
|
||||
'group',
|
||||
'notes',
|
||||
'created_on',
|
||||
'updated_on',
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
'tmp_sort_1',
|
||||
'tmp_sort_2',
|
||||
'tmp_sort_3',
|
||||
|
||||
// From SQL view
|
||||
'username',
|
||||
'user_name',
|
||||
'user_email',
|
||||
'user_allow_auth_key', // For sign in without password
|
||||
'user_super',
|
||||
'user_manager',
|
||||
'user_administrator',
|
||||
'user_public',
|
||||
];
|
||||
|
||||
|
||||
// Updated 2025-06-10
|
||||
export async function process_ae_obj__person_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__person_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) {
|
||||
// const processed_obj = { ...obj };
|
||||
|
||||
// Process the properties as needed
|
||||
// None needed to process for person at this time...
|
||||
|
||||
let processed_obj = {
|
||||
id: obj.person_id_random,
|
||||
person_id: obj.person_id_random,
|
||||
person_id_random: obj.person_id_random,
|
||||
|
||||
external_id: obj.external_id,
|
||||
external_sys_id: obj.external_sys_id,
|
||||
code: obj.code,
|
||||
|
||||
account_id: obj.account_id_random,
|
||||
account_id_random: obj.account_id_random,
|
||||
|
||||
person_profile_id: obj.person_profile_id_random,
|
||||
person_profile_id_random: obj.person_profile_id_random, // The new table person_profile will be used soon...
|
||||
|
||||
user_id: obj.user_id_random,
|
||||
user_id_random: obj.user_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,
|
||||
full_name_override: obj.full_name_override, // was display_name and display_name_override
|
||||
|
||||
affiliations: obj.affiliations,
|
||||
|
||||
primary_email: obj.primary_email,
|
||||
|
||||
biography: obj.biography,
|
||||
|
||||
agree: obj.agree,
|
||||
comments: obj.comments,
|
||||
|
||||
allow_auth_key: obj.allow_auth_key, // For sign in without password
|
||||
// auth_key: obj.auth_key,
|
||||
passcode: obj.passcode,
|
||||
// passcode_timeout: obj.passcode_timeout,
|
||||
|
||||
// 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,
|
||||
|
||||
// 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,
|
||||
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,
|
||||
};
|
||||
|
||||
processed_obj_li.push(processed_obj);
|
||||
}
|
||||
|
||||
return processed_obj_li;
|
||||
}
|
||||
|
||||
@@ -46,9 +46,9 @@ export async function load_ae_obj_id__journal(
|
||||
ae_promises.load__journal_obj = await api.get_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'journal',
|
||||
obj_id: journal_id, // NOTE: This is the FQDN, not normally the ID.
|
||||
use_alt_table: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
|
||||
obj_id: journal_id,
|
||||
use_alt_table: true,
|
||||
use_alt_base: false,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
@@ -447,7 +447,7 @@ export async function update_ae_obj__journal({
|
||||
console.log(`*** update_ae_obj__journal() *** journal_id=${journal_id}`, data_kv);
|
||||
}
|
||||
|
||||
log_lvl = 1;
|
||||
// log_lvl = 1;
|
||||
|
||||
// Perform the API update
|
||||
const result = await api.update_ae_obj_id_crud({
|
||||
|
||||
@@ -519,7 +519,7 @@ async function handle_change_password() {
|
||||
}
|
||||
|
||||
// WARNING: This function returns a list. We only want the first one. There should be no more than 1 record returned.
|
||||
ae_promises['person'] = core_func.handle_load_ae_obj_li__person({
|
||||
ae_promises['person'] = core_func.load_ae_obj_li__person({
|
||||
api_cfg: $ae_api,
|
||||
for_obj_type: 'account',
|
||||
for_obj_id: $ae_loc.account_id,
|
||||
@@ -600,7 +600,7 @@ async function handle_change_password() {
|
||||
}
|
||||
|
||||
// WARNING: This function returns a list. We only want the first one. There should be no more than 1 record returned.
|
||||
ae_promises['person'] = core_func.handle_load_ae_obj_li__person({
|
||||
ae_promises['person'] = core_func.load_ae_obj_li__person({
|
||||
api_cfg: $ae_api,
|
||||
for_obj_type: 'account',
|
||||
for_obj_id: $ae_loc.account_id,
|
||||
|
||||
Reference in New Issue
Block a user