Creating standardized functions. Mainly for create and delete.

This commit is contained in:
Scott Idem
2024-11-08 12:47:24 -05:00
parent 4fe04d9c3f
commit 13d906428b
17 changed files with 855 additions and 276 deletions

View File

@@ -125,41 +125,6 @@ export async function load_ae_obj_li__event_file(
}
// Updated 2024-06-17
export async function delete_ae_obj_id__event_file(
{
api_cfg,
event_file_id,
params = {},
log_lvl = 0
}: {
api_cfg: any,
event_file_id: string,
params?: key_val,
log_lvl?: number
}
) {
console.log(`*** delete_ae_obj_id__event_file() *** event_file_id=${event_file_id}`);
const endpoint = `/event/file/${event_file_id}/v2`;
params['delete_hosted_file'] = true; // This does not actually delete the hosted file from the server.
params['rm_orphan'] = true; // This is what actually allows the hosted file to be deleted from the server.
ae_promises.delete__event_file_obj = await api.delete_object({
api_cfg: api_cfg,
endpoint: endpoint,
params: params,
// return_meta: return_meta,
log_lvl: log_lvl
});
db_events.files.delete(event_file_id);
return ae_promises.delete__event_file_obj;
}
// Updated 2024-06-14
export async function create_event_file_obj_from_hosted_file_async(
{
@@ -222,6 +187,55 @@ export async function create_event_file_obj_from_hosted_file_async(
}
// Updated 2024-11-08
export async function delete_ae_obj_id__event_file(
{
api_cfg,
event_file_id,
params = {},
try_cache = true,
log_lvl = 0
}: {
api_cfg: any,
event_file_id: string,
params?: key_val,
try_cache?: boolean,
log_lvl?: number
}
) {
if (log_lvl) {
console.log(`*** delete_ae_obj_id__event_file() *** event_file_id=${event_file_id}`);
}
const endpoint = `/event/file/${event_file_id}/v2`;
params['delete_hosted_file'] = true; // This does not actually delete the hosted file from the server.
params['rm_orphan'] = true; // This is what actually allows the hosted file to be deleted from the server.
ae_promises.delete__event_file_obj = await api.delete_object({
api_cfg: api_cfg,
endpoint: endpoint,
params: params,
// return_meta: return_meta,
log_lvl: log_lvl
})
.finally(function () {
if (try_cache) {
if (log_lvl) {
console.log(`Attempting to remove IDB entry for event_file_id=${event_file_id}`);
}
db_events.files.delete(event_file_id); // Delete from the DB no matter what.
}
});
if (log_lvl) {
console.log('ae_promises.delete__event_file_obj:', ae_promises.delete__event_file_obj);
}
return ae_promises.delete__event_file_obj;
}
// Updated 2024-06-13
export async function update_ae_obj__event_file(
{