Implement V3 PATCH/DELETE wrappers and migrate Journals module to full V3 CRUD.
- Added update_ae_obj_v3, update_nested_obj_v3, delete_ae_obj_v3, and delete_nested_ae_obj_v3. - Refactored Journals and Journal Entries modules to utilize the new V3 API wrappers. - Standardized data processing and IDB caching for all CRUD operations in Journals. - Updated testing page with comprehensive V3 CUD test buttons.
This commit is contained in:
8
TODO.md
8
TODO.md
@@ -32,10 +32,10 @@ This is a list of tasks to be completed before the next event/show/conference.
|
||||
|
||||
- [ ] **Core API Wrappers:**
|
||||
- [x] Implement GET list and search wrappers (`get_ae_obj_li_v3`, `search_ae_obj_v3`).
|
||||
- [ ] Implement Create (POST) wrappers (`create_ae_obj_v3`, `create_nested_obj_v3`).
|
||||
- [ ] Implement Update (PATCH) wrappers (`update_ae_obj_v3`, `update_nested_obj_v3`).
|
||||
- [ ] Implement Delete (DELETE) wrapper (`delete_ae_obj_v3`).
|
||||
- [ ] Implement single object GET wrapper (`get_ae_obj_v3`).
|
||||
- [x] Implement Create (POST) wrappers (`create_ae_obj_v3`, `create_nested_obj_v3`).
|
||||
- [x] Implement Update (PATCH) wrappers (`update_ae_obj_v3`, `update_nested_obj_v3`).
|
||||
- [x] Implement Delete (DELETE) wrapper (`delete_ae_obj_v3`).
|
||||
- [x] Implement single object GET wrapper (`get_ae_obj_v3`).
|
||||
- [ ] **Authentication & Security:**
|
||||
- [ ] Standardize JWT usage in headers for all V3 calls.
|
||||
- [ ] Update file download logic to support JWT in URL parameters.
|
||||
|
||||
@@ -159,11 +159,15 @@ interface DeleteAeObjV3Params {
|
||||
api_cfg: any;
|
||||
obj_type: string;
|
||||
obj_id: string;
|
||||
method?: 'delete' | 'soft_delete';
|
||||
method?: 'delete' | 'soft_delete' | 'disable' | 'hide';
|
||||
params?: key_val;
|
||||
log_lvl?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a single object by ID (V3)
|
||||
* Supports 'delete' (hard), 'soft_delete', 'disable' (enable=false), and 'hide' (hide=true).
|
||||
*/
|
||||
export async function delete_ae_obj_v3({
|
||||
api_cfg,
|
||||
obj_type,
|
||||
@@ -188,3 +192,44 @@ export async function delete_ae_obj_v3({
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
|
||||
interface DeleteNestedAeObjV3Params {
|
||||
api_cfg: any;
|
||||
parent_type: string;
|
||||
parent_id: string;
|
||||
child_type: string;
|
||||
child_id: string;
|
||||
method?: 'delete' | 'soft_delete' | 'disable' | 'hide';
|
||||
params?: key_val;
|
||||
log_lvl?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a single nested object by ID (V3)
|
||||
*/
|
||||
export async function delete_nested_ae_obj_v3({
|
||||
api_cfg,
|
||||
parent_type,
|
||||
parent_id,
|
||||
child_type,
|
||||
child_id,
|
||||
method = 'delete',
|
||||
params = {},
|
||||
log_lvl = 0
|
||||
}: DeleteNestedAeObjV3Params) {
|
||||
const endpoint = `/v3/crud/${parent_type}/${parent_id}/${child_type}/${child_id}`;
|
||||
const query_params = { ...params, method };
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('*** delete_nested_ae_obj_v3 ***');
|
||||
console.log('Endpoint:', endpoint);
|
||||
console.log('Params:', query_params);
|
||||
}
|
||||
|
||||
return await delete_object({
|
||||
api_cfg,
|
||||
endpoint,
|
||||
params: query_params,
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
|
||||
@@ -10,13 +10,14 @@ import { load_ae_obj_li__journal_entry } from '$lib/ae_journals/ae_journals__jou
|
||||
|
||||
const ae_promises: key_val = {};
|
||||
|
||||
// Updated 2025-03-15
|
||||
// Updated 2026-01-05
|
||||
export async function load_ae_obj_id__journal({
|
||||
api_cfg,
|
||||
journal_id,
|
||||
inc_entry_li = false,
|
||||
enabled = 'enabled',
|
||||
hidden = 'not_hidden',
|
||||
view = 'default',
|
||||
limit = 99,
|
||||
offset = 0,
|
||||
order_by_li = {
|
||||
@@ -35,6 +36,7 @@ export async function load_ae_obj_id__journal({
|
||||
inc_entry_li?: boolean;
|
||||
enabled?: 'enabled' | 'all' | 'not_enabled' | undefined; // all, disabled, enabled
|
||||
hidden?: 'hidden' | 'all' | 'not_hidden' | undefined; // all, hidden, not_hidden
|
||||
view?: string;
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
order_by_li?: key_val; // Order by fields for the journal entries
|
||||
@@ -47,13 +49,12 @@ export async function load_ae_obj_id__journal({
|
||||
}
|
||||
|
||||
ae_promises.load__journal_obj = await api
|
||||
.get_ae_obj_id_crud({
|
||||
.get_ae_obj_v3({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'journal',
|
||||
obj_id: journal_id,
|
||||
use_alt_table: true,
|
||||
use_alt_base: false,
|
||||
params: params,
|
||||
view,
|
||||
params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (journal_obj_get_result) {
|
||||
@@ -68,9 +69,6 @@ export async function load_ae_obj_id__journal({
|
||||
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_journals,
|
||||
table_name: 'journal',
|
||||
@@ -78,16 +76,6 @@ export async function load_ae_obj_id__journal({
|
||||
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__journal({
|
||||
// obj_type: 'journal',
|
||||
// obj_li: [journal_obj_get_result],
|
||||
// log_lvl: log_lvl
|
||||
// });
|
||||
}
|
||||
return journal_obj_get_result;
|
||||
} else {
|
||||
@@ -99,41 +87,26 @@ export async function load_ae_obj_id__journal({
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.load__journal_obj:', ae_promises.load__journal_obj);
|
||||
}
|
||||
if (!ae_promises.load__journal_obj) {
|
||||
console.log(`ERROR: Journals - Journal - The journal with ID ${journal_id} was not found.`);
|
||||
return ae_promises.load__journal_obj; // Return null if the journal was not found
|
||||
return null;
|
||||
}
|
||||
|
||||
if (inc_entry_li) {
|
||||
// Load the entries for the journal
|
||||
if (log_lvl) {
|
||||
console.log(`Need to load the entry list for the journal now`);
|
||||
}
|
||||
const load_journal_entry_obj_li = load_ae_obj_li__journal_entry({
|
||||
const load_journal_entry_obj_li = await load_ae_obj_li__journal_entry({
|
||||
api_cfg: api_cfg,
|
||||
for_obj_type: 'journal',
|
||||
for_obj_id: journal_id,
|
||||
enabled: enabled, // all, disabled, enabled
|
||||
hidden: hidden, // all, hidden, not_hidden
|
||||
limit: limit, // Limit for the entries
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
order_by_li: order_by_li,
|
||||
params: params,
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
}).then((journal_entry_obj_li) => {
|
||||
if (log_lvl) {
|
||||
console.log(`journal_entry_obj_li = `, journal_entry_obj_li);
|
||||
}
|
||||
return journal_entry_obj_li;
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`journal_entry_obj_li = `, load_journal_entry_obj_li);
|
||||
}
|
||||
ae_promises.load__journal_obj.journal_entry_li = load_journal_entry_obj_li;
|
||||
}
|
||||
|
||||
@@ -312,7 +285,7 @@ export async function load_ae_obj_li__journal({
|
||||
return ae_promises.load__journal_obj_li;
|
||||
}
|
||||
|
||||
// Updated 2025-03-24
|
||||
// Updated 2026-01-05
|
||||
export async function create_ae_obj__journal({
|
||||
api_cfg,
|
||||
account_id,
|
||||
@@ -338,16 +311,14 @@ export async function create_ae_obj__journal({
|
||||
}
|
||||
|
||||
ae_promises.create__journal = await api
|
||||
.create_ae_obj_crud({
|
||||
.create_ae_obj_v3({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'journal',
|
||||
fields: {
|
||||
account_id_random: account_id,
|
||||
...data_kv
|
||||
},
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (journal_obj_create_result) {
|
||||
@@ -362,9 +333,6 @@ export async function create_ae_obj__journal({
|
||||
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_journals,
|
||||
table_name: 'journal',
|
||||
@@ -372,16 +340,6 @@ export async function create_ae_obj__journal({
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// db_save_ae_obj_li__journal(
|
||||
// {
|
||||
// obj_type: 'journal',
|
||||
// obj_li: [journal_obj_create_result],
|
||||
// log_lvl: log_lvl
|
||||
// });
|
||||
}
|
||||
return journal_obj_create_result;
|
||||
} else {
|
||||
@@ -390,16 +348,12 @@ export async function create_ae_obj__journal({
|
||||
})
|
||||
.catch(function (error: any) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {});
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.create__journal:', ae_promises.create__journal);
|
||||
}
|
||||
return ae_promises.create__journal;
|
||||
}
|
||||
|
||||
// Updated 2025-03-15
|
||||
// Updated 2026-01-05
|
||||
export async function delete_ae_obj_id__journal({
|
||||
api_cfg,
|
||||
journal_id,
|
||||
@@ -410,7 +364,7 @@ export async function delete_ae_obj_id__journal({
|
||||
}: {
|
||||
api_cfg: any;
|
||||
journal_id: string;
|
||||
method?: string;
|
||||
method?: 'delete' | 'soft_delete' | 'disable' | 'hide';
|
||||
params?: key_val;
|
||||
try_cache?: boolean;
|
||||
log_lvl?: number;
|
||||
@@ -420,11 +374,10 @@ export async function delete_ae_obj_id__journal({
|
||||
}
|
||||
|
||||
ae_promises.delete__journal_obj = await api
|
||||
.delete_ae_obj_id_crud({
|
||||
.delete_ae_obj_v3({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'journal',
|
||||
obj_id: journal_id,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
method: method,
|
||||
log_lvl: log_lvl
|
||||
@@ -441,14 +394,10 @@ export async function delete_ae_obj_id__journal({
|
||||
}
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.delete__journal_obj:', ae_promises.delete__journal_obj);
|
||||
}
|
||||
|
||||
return ae_promises.delete__journal_obj;
|
||||
}
|
||||
|
||||
// Updated 2025-05-09
|
||||
// Updated 2026-01-05
|
||||
export async function update_ae_obj__journal({
|
||||
api_cfg,
|
||||
journal_id,
|
||||
@@ -468,17 +417,13 @@ export async function update_ae_obj__journal({
|
||||
console.log(`*** update_ae_obj__journal() *** journal_id=${journal_id}`, data_kv);
|
||||
}
|
||||
|
||||
// log_lvl = 1;
|
||||
|
||||
// Perform the API update
|
||||
const result = await api.update_ae_obj_id_crud({
|
||||
const result = await api.update_ae_obj_v3({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'journal',
|
||||
obj_id: journal_id,
|
||||
fields: data_kv,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
|
||||
@@ -494,9 +439,6 @@ export async function update_ae_obj__journal({
|
||||
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_journals,
|
||||
table_name: 'journal',
|
||||
@@ -504,15 +446,6 @@ export async function update_ae_obj__journal({
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// await db_save_ae_obj_li__journal({
|
||||
// obj_type: 'journal',
|
||||
// obj_li: [result],
|
||||
// log_lvl: log_lvl,
|
||||
// });
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
|
||||
@@ -8,7 +8,7 @@ import { db_journals } from '$lib/ae_journals/db_journals';
|
||||
|
||||
const ae_promises: key_val = {};
|
||||
|
||||
// Updated 2025-03-15
|
||||
// Updated 2026-01-05
|
||||
export async function load_ae_obj_id__journal_entry({
|
||||
api_cfg,
|
||||
journal_entry_id,
|
||||
@@ -24,16 +24,11 @@ export async function load_ae_obj_id__journal_entry({
|
||||
console.log(`*** load_ae_obj_id__journal_entry() *** journal_entry_id=${journal_entry_id}`);
|
||||
}
|
||||
|
||||
const params = {};
|
||||
|
||||
ae_promises.load__journal_entry_obj = await api
|
||||
.get_ae_obj_id_crud({
|
||||
.get_ae_obj_v3({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'journal_entry',
|
||||
obj_id: journal_entry_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
|
||||
params: params,
|
||||
obj_id: journal_entry_id,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (journal_entry_obj_get_result) {
|
||||
@@ -48,9 +43,6 @@ export async function load_ae_obj_id__journal_entry({
|
||||
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_journals,
|
||||
table_name: 'journal_entry',
|
||||
@@ -58,16 +50,6 @@ export async function load_ae_obj_id__journal_entry({
|
||||
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__journal_entry({
|
||||
// obj_type: 'journal_entry',
|
||||
// obj_li: [journal_entry_obj_get_result],
|
||||
// log_lvl: log_lvl
|
||||
// });
|
||||
}
|
||||
return journal_entry_obj_get_result;
|
||||
} else {
|
||||
@@ -197,7 +179,7 @@ export async function load_ae_obj_li__journal_entry({
|
||||
return ae_promises.load__journal_entry_obj_li;
|
||||
}
|
||||
|
||||
// Updated 2025-03-15
|
||||
// Updated 2026-01-05
|
||||
export async function create_ae_obj__journal_entry({
|
||||
api_cfg,
|
||||
journal_id,
|
||||
@@ -223,16 +205,13 @@ export async function create_ae_obj__journal_entry({
|
||||
}
|
||||
|
||||
ae_promises.create__journal_entry = await api
|
||||
.create_ae_obj_crud({
|
||||
.create_nested_obj_v3({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'journal_entry',
|
||||
fields: {
|
||||
journal_id_random: journal_id,
|
||||
...data_kv
|
||||
},
|
||||
key: api_cfg.api_crud_super_key,
|
||||
parent_type: 'journal',
|
||||
parent_id: journal_id,
|
||||
child_type: 'journal_entry',
|
||||
fields: data_kv,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (journal_entry_obj_create_result) {
|
||||
@@ -248,9 +227,6 @@ export async function create_ae_obj__journal_entry({
|
||||
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_journals,
|
||||
table_name: 'journal_entry',
|
||||
@@ -258,16 +234,6 @@ export async function create_ae_obj__journal_entry({
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// await db_save_ae_obj_li__journal_entry(
|
||||
// {
|
||||
// obj_type: 'journal_entry',
|
||||
// obj_li: [journal_entry_obj_create_result],
|
||||
// log_lvl: log_lvl
|
||||
// });
|
||||
}
|
||||
return journal_entry_obj_create_result;
|
||||
} else {
|
||||
@@ -278,13 +244,10 @@ export async function create_ae_obj__journal_entry({
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.create__journal_entry:', ae_promises.create__journal_entry);
|
||||
}
|
||||
return ae_promises.create__journal_entry;
|
||||
}
|
||||
|
||||
// Updated 2025-03-15
|
||||
// Updated 2026-01-05
|
||||
export async function delete_ae_obj_id__journal_entry({
|
||||
api_cfg,
|
||||
journal_entry_id,
|
||||
@@ -295,7 +258,7 @@ export async function delete_ae_obj_id__journal_entry({
|
||||
}: {
|
||||
api_cfg: any;
|
||||
journal_entry_id: string;
|
||||
method?: string;
|
||||
method?: 'delete' | 'soft_delete' | 'disable' | 'hide';
|
||||
params?: key_val;
|
||||
try_cache?: boolean;
|
||||
log_lvl?: number;
|
||||
@@ -307,13 +270,12 @@ export async function delete_ae_obj_id__journal_entry({
|
||||
}
|
||||
|
||||
ae_promises.delete__journal_entry_obj = await api
|
||||
.delete_ae_obj_id_crud({
|
||||
.delete_ae_obj_v3({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'journal_entry',
|
||||
obj_id: journal_entry_id,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
method: method,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.catch(function (error: any) {
|
||||
@@ -330,13 +292,6 @@ export async function delete_ae_obj_id__journal_entry({
|
||||
}
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(
|
||||
'ae_promises.delete__journal_entry_obj:',
|
||||
ae_promises.delete__journal_entry_obj
|
||||
);
|
||||
}
|
||||
|
||||
return ae_promises.delete__journal_entry_obj;
|
||||
}
|
||||
|
||||
@@ -431,12 +386,20 @@ export async function qry__journal_entry({
|
||||
offset,
|
||||
log_lvl
|
||||
})
|
||||
.then(function (journal_entry_obj_li_get_result) {
|
||||
.then(async function (journal_entry_obj_li_get_result) {
|
||||
if (journal_entry_obj_li_get_result) {
|
||||
if (try_cache) {
|
||||
db_save_ae_obj_li__journal_entry({
|
||||
obj_type: 'journal_entry',
|
||||
obj_li: journal_entry_obj_li_get_result
|
||||
const processed_obj_li = await process_ae_obj__journal_entry_props({
|
||||
obj_li: journal_entry_obj_li_get_result,
|
||||
journal_id,
|
||||
log_lvl
|
||||
});
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_journals,
|
||||
table_name: 'journal_entry',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save,
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
return journal_entry_obj_li_get_result;
|
||||
@@ -518,7 +481,7 @@ export async function qry__journal_entry({
|
||||
// return await ae_promises.update__journal_entry_obj;
|
||||
// }
|
||||
|
||||
// Updated 2025-05-09
|
||||
// Updated 2026-01-05
|
||||
export async function update_ae_obj__journal_entry({
|
||||
api_cfg,
|
||||
journal_entry_id,
|
||||
@@ -534,7 +497,6 @@ export async function update_ae_obj__journal_entry({
|
||||
try_cache?: boolean;
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
// log_lvl = 1;
|
||||
if (log_lvl) {
|
||||
console.log(
|
||||
`*** update_ae_obj__journal_entry() *** journal_entry_id=${journal_entry_id}`,
|
||||
@@ -543,14 +505,12 @@ export async function update_ae_obj__journal_entry({
|
||||
}
|
||||
|
||||
// Perform the API update
|
||||
const result = await api.update_ae_obj_id_crud({
|
||||
const result = await api.update_ae_obj_v3({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'journal_entry',
|
||||
obj_id: journal_entry_id,
|
||||
fields: data_kv,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
|
||||
@@ -566,9 +526,6 @@ export async function update_ae_obj__journal_entry({
|
||||
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_journals,
|
||||
table_name: 'journal_entry',
|
||||
@@ -576,15 +533,6 @@ export async function update_ae_obj__journal_entry({
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// await db_save_ae_obj_li__journal_entry({
|
||||
// obj_type: 'journal_entry',
|
||||
// obj_li: [result],
|
||||
// log_lvl: log_lvl,
|
||||
// });
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
|
||||
@@ -24,7 +24,8 @@ import {
|
||||
create_nested_obj_v3,
|
||||
update_ae_obj_v3,
|
||||
update_nested_obj_v3,
|
||||
delete_ae_obj_v3
|
||||
delete_ae_obj_v3,
|
||||
delete_nested_ae_obj_v3
|
||||
} from '$lib/ae_api/api_post__crud_obj_v3';
|
||||
|
||||
// This new function has not been tested yet!!!
|
||||
@@ -940,6 +941,7 @@ const obj = {
|
||||
update_ae_obj_v3: update_ae_obj_v3,
|
||||
update_nested_obj_v3: update_nested_obj_v3,
|
||||
delete_ae_obj_v3: delete_ae_obj_v3,
|
||||
delete_nested_ae_obj_v3: delete_nested_ae_obj_v3,
|
||||
create_ae_obj_crud: create_ae_obj_crud,
|
||||
update_ae_obj_id_crud: update_ae_obj_id_crud,
|
||||
delete_ae_obj_id_crud: delete_ae_obj_id_crud,
|
||||
|
||||
@@ -76,6 +76,48 @@
|
||||
v3_test_result = result;
|
||||
console.log('V3 Create Nested Result:', result);
|
||||
}
|
||||
|
||||
async function test_v3_update_nested() {
|
||||
console.log('*** test_v3_update_nested() ***');
|
||||
v3_test_result = 'loading...';
|
||||
|
||||
// Test updating the journal entry we just created
|
||||
// ID is from the previous step result: nKiyj0JV5CY
|
||||
const result = await api.update_nested_obj_v3({
|
||||
api_cfg: $ae_api,
|
||||
parent_type: 'journal',
|
||||
parent_id: 'JGEB-80-92-50',
|
||||
child_type: 'journal_entry',
|
||||
child_id: 'nKiyj0JV5CY',
|
||||
fields: {
|
||||
name: 'Test V3 Nested Update - UPDATED',
|
||||
content: 'This was UPDATED using the new V3 nested update wrapper!'
|
||||
},
|
||||
log_lvl: 1
|
||||
});
|
||||
|
||||
v3_test_result = result;
|
||||
console.log('V3 Update Nested Result:', result);
|
||||
}
|
||||
|
||||
async function test_v3_delete_nested() {
|
||||
console.log('*** test_v3_delete_nested() ***');
|
||||
v3_test_result = 'loading...';
|
||||
|
||||
// Test soft deleting (disabling) the journal entry we just updated
|
||||
const result = await api.delete_nested_ae_obj_v3({
|
||||
api_cfg: $ae_api,
|
||||
parent_type: 'journal',
|
||||
parent_id: 'JGEB-80-92-50',
|
||||
child_type: 'journal_entry',
|
||||
child_id: 'nKiyj0JV5CY',
|
||||
method: 'disable', // Sets enable = false
|
||||
log_lvl: 1
|
||||
});
|
||||
|
||||
v3_test_result = result;
|
||||
console.log('V3 Delete (Disable) Nested Result:', result);
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="container h-full mx-auto flex flex-col justify-center items-center p-4 gap-4">
|
||||
@@ -92,6 +134,12 @@
|
||||
<button class="btn variant-filled-tertiary" onclick={test_v3_create_nested}>
|
||||
Test V3 Create Nested
|
||||
</button>
|
||||
<button class="btn variant-filled-warning" onclick={test_v3_update_nested}>
|
||||
Test V3 Update Nested
|
||||
</button>
|
||||
<button class="btn variant-filled-error" onclick={test_v3_delete_nested}>
|
||||
Test V3 Delete (Disable) Nested
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user