Updates related to IDAA API functions and related. Some style updates.
This commit is contained in:
@@ -15,12 +15,14 @@ export async function load_ae_obj_id__archive(
|
||||
api_cfg,
|
||||
archive_id,
|
||||
inc_content_li = false,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
archive_id: string,
|
||||
inc_content_li?: boolean,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
@@ -29,14 +31,12 @@ export async function load_ae_obj_id__archive(
|
||||
console.log(`*** load_ae_obj_id__archive() *** archive_id=${archive_id}`);
|
||||
}
|
||||
|
||||
let params = {};
|
||||
|
||||
ae_promises.load__archive_obj = await api.get_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'archive',
|
||||
obj_id: archive_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: archive_id,
|
||||
use_alt_table: true,
|
||||
use_alt_base: false,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
@@ -284,7 +284,7 @@ export async function load_ae_obj_li__archive(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-09-25
|
||||
// Updated 2025-06-23
|
||||
export async function create_ae_obj__archive(
|
||||
{
|
||||
api_cfg,
|
||||
@@ -306,6 +306,11 @@ export async function create_ae_obj__archive(
|
||||
console.log(`*** create_ae_obj__archive() *** account_id=${account_id}`);
|
||||
}
|
||||
|
||||
if (!account_id) {
|
||||
console.log(`ERROR: Archives - Archive - account_id required to create`);
|
||||
return false;
|
||||
}
|
||||
|
||||
ae_promises.create__archive = await api.create_ae_obj_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'archive',
|
||||
@@ -318,14 +323,37 @@ export async function create_ae_obj__archive(
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (archive_obj_create_result) {
|
||||
.then(async function (archive_obj_create_result) {
|
||||
if (archive_obj_create_result) {
|
||||
if (try_cache) {
|
||||
db_save_ae_obj_li__archive(
|
||||
{
|
||||
obj_type: 'archive',
|
||||
obj_li: [archive_obj_create_result]
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__archive_props({
|
||||
obj_li: [archive_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_archives,
|
||||
table_name: 'archive',
|
||||
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__archive(
|
||||
// {
|
||||
// obj_type: 'archive',
|
||||
// obj_li: [archive_obj_create_result]
|
||||
// });
|
||||
}
|
||||
return archive_obj_create_result;
|
||||
} else {
|
||||
@@ -394,7 +422,7 @@ export async function delete_ae_obj_id__archive(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-09-25
|
||||
// Updated 2025-06-23
|
||||
export async function update_ae_obj__archive(
|
||||
{
|
||||
api_cfg,
|
||||
@@ -415,7 +443,9 @@ export async function update_ae_obj__archive(
|
||||
if (log_lvl) {
|
||||
console.log(`*** update_ae_obj__archive() *** archive_id=${archive_id}`, data_kv);
|
||||
}
|
||||
ae_promises.update__archive_obj = await api.update_ae_obj_id_crud({
|
||||
|
||||
// Perform the API update
|
||||
const result = await api.update_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'archive',
|
||||
obj_id: archive_id,
|
||||
@@ -424,29 +454,45 @@ export async function update_ae_obj__archive(
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (archive_obj_update_result) {
|
||||
if (archive_obj_update_result) {
|
||||
if (try_cache) {
|
||||
db_save_ae_obj_li__archive({
|
||||
obj_type: 'archive', obj_li: [archive_obj_update_result]
|
||||
});
|
||||
}
|
||||
return archive_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__archive_obj:', ae_promises.update__archive_obj);
|
||||
// Handle the result
|
||||
if (result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__archive_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_archives,
|
||||
table_name: 'archive',
|
||||
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__archive({
|
||||
// obj_type: 'archive',
|
||||
// obj_li: [result],
|
||||
// log_lvl: log_lvl,
|
||||
// });
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
console.error('Failed to update archive.');
|
||||
return null;
|
||||
}
|
||||
return ae_promises.update__archive_obj;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -191,7 +191,7 @@ export async function load_ae_obj_li__archive_content(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-09-25
|
||||
// Updated 2025-06-23
|
||||
export async function create_ae_obj__archive_content(
|
||||
{
|
||||
api_cfg,
|
||||
@@ -213,6 +213,11 @@ export async function create_ae_obj__archive_content(
|
||||
console.log(`*** create_ae_obj__archive_content() *** archive_id=${archive_id}`);
|
||||
}
|
||||
|
||||
if (!archive_id) {
|
||||
console.log(`ERROR: Archives - Content - archive_id required to create`);
|
||||
return false;
|
||||
}
|
||||
|
||||
ae_promises.create__archive_content = await api.create_ae_obj_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'archive_content',
|
||||
@@ -228,11 +233,34 @@ export async function create_ae_obj__archive_content(
|
||||
.then(async function (archive_content_obj_create_result) {
|
||||
if (archive_content_obj_create_result) {
|
||||
if (try_cache) {
|
||||
await db_save_ae_obj_li__archive_content(
|
||||
{
|
||||
obj_type: 'archive_content',
|
||||
obj_li: [archive_content_obj_create_result]
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__archive_content_props({
|
||||
obj_li: [archive_content_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_archives,
|
||||
table_name: 'archive_content',
|
||||
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__archive_content(
|
||||
// {
|
||||
// obj_type: 'archive_content',
|
||||
// obj_li: [archive_content_obj_create_result]
|
||||
// });
|
||||
}
|
||||
return archive_content_obj_create_result;
|
||||
} else {
|
||||
@@ -301,7 +329,7 @@ export async function delete_ae_obj_id__archive_content(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-09-25
|
||||
// Updated 2025-06-23
|
||||
export async function update_ae_obj__archive_content(
|
||||
{
|
||||
api_cfg,
|
||||
@@ -322,7 +350,9 @@ export async function update_ae_obj__archive_content(
|
||||
if (log_lvl) {
|
||||
console.log(`*** update_ae_obj__archive_content() *** archive_content_id=${archive_content_id}`, data_kv);
|
||||
}
|
||||
ae_promises.update__archive_content_obj = await api.update_ae_obj_id_crud({
|
||||
|
||||
// Perform the API update
|
||||
const result = await api.update_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'archive_content',
|
||||
obj_id: archive_content_id,
|
||||
@@ -330,30 +360,46 @@ export async function update_ae_obj__archive_content(
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (archive_content_obj_update_result) {
|
||||
if (archive_content_obj_update_result) {
|
||||
if (try_cache) {
|
||||
await db_save_ae_obj_li__archive_content({
|
||||
obj_type: 'archive_content', obj_li: [archive_content_obj_update_result]
|
||||
});
|
||||
}
|
||||
return archive_content_obj_update_result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.update__archive_content_obj:', ae_promises.update__archive_content_obj);
|
||||
// Handle the result
|
||||
if (result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__archive_content_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_archives,
|
||||
table_name: 'archive_content',
|
||||
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__archive_content({
|
||||
// obj_type: 'archive_content',
|
||||
// obj_li: [result],
|
||||
// log_lvl: log_lvl,
|
||||
// });
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
console.error('Failed to update archive content.');
|
||||
return null;
|
||||
}
|
||||
return ae_promises.update__archive_content_obj;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user