chore(cleanup): remove dead pre-V3 data store functions
- api.ts: remove get_data_store_obj_w_code (hit /data_store/code/, non-V3) and its export. V3 get_data_store (/v3/data_store/code/) stays. - ae_core_functions.ts: remove load_ae_obj_code__data_store (wrapper around the removed function) and its export from core_func. element_data_store.svelte replaced this with Dexie LiveQuery + V3 API. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -115,164 +115,6 @@ async function load_ae_obj_id__site_domain({
|
||||
return ae_promises.load__site_domain_obj;
|
||||
}
|
||||
|
||||
// Updated 2026-01-29
|
||||
async function load_ae_obj_code__data_store({
|
||||
api_cfg,
|
||||
code,
|
||||
data_type = 'text',
|
||||
for_type = null,
|
||||
for_id = null,
|
||||
try_cache = true,
|
||||
save_idb = false,
|
||||
timeout = 9000,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any;
|
||||
code: string;
|
||||
data_type?: string;
|
||||
for_type?: string | null;
|
||||
for_id?: string | null;
|
||||
try_cache?: boolean;
|
||||
save_idb?: boolean;
|
||||
timeout?: number;
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_code__data_store() *** code=${code}`);
|
||||
}
|
||||
|
||||
if (!code) {
|
||||
console.log(`*ae_func* No code provided!`);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!api_cfg.account_id) {
|
||||
console.log(`*ae_func* No account_id found in API config!`);
|
||||
return false;
|
||||
}
|
||||
|
||||
ae_promises.load__data_store_obj = api
|
||||
.get_data_store_obj_w_code({
|
||||
api_cfg: api_cfg,
|
||||
data_store_code: code,
|
||||
data_type: data_type,
|
||||
timeout: timeout,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (get_ds_result) {
|
||||
let return_this = null;
|
||||
if (get_ds_result) {
|
||||
if (log_lvl) {
|
||||
console.log(`*ae_func* Got a result for code ${code}`);
|
||||
}
|
||||
|
||||
if (!get_ds_result.data_store_id_random) {
|
||||
console.log(
|
||||
'*ae_func* Something went wrong? No data store ID found.'
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
// let ae_ds_tmp: key_val = {};
|
||||
const ds_code_obj = {
|
||||
id: null,
|
||||
account_id: null,
|
||||
code: code,
|
||||
name: null,
|
||||
type: data_type,
|
||||
for_type: null, // for_type
|
||||
for_id: null, // for_id
|
||||
access_read: null, // 'super', 'administrator', 'trusted', 'anonymous'
|
||||
access_write: null, // 'super', 'administrator', 'trusted', 'anonymous'
|
||||
access_delete: null, // 'super', 'administrator', 'trusted', 'anonymous'
|
||||
html: null,
|
||||
json: null,
|
||||
md: null,
|
||||
text: null,
|
||||
updated_on: null,
|
||||
chk_account_id: api_cfg.account_id,
|
||||
loaded_on: new Date().toISOString()
|
||||
};
|
||||
let val_json: key_val;
|
||||
let val_html: key_val;
|
||||
let val_md: key_val;
|
||||
let val_sql: key_val;
|
||||
let val_text: string;
|
||||
|
||||
// Set the loaded_on datetime to the current time for reference later. This will be used to determine if the data store is stale.
|
||||
// ds_code_obj.loaded_on = new Date().toISOString();
|
||||
// Set the chk_account_id as a backup check to make sure the data store belongs to the account for the current site. This should not be needed, but here we are...
|
||||
// ds_code_obj.chk_account_id = api_cfg.account_id;
|
||||
|
||||
ds_code_obj.id = get_ds_result.data_store_id_random;
|
||||
ds_code_obj.account_id = get_ds_result.account_id_random;
|
||||
ds_code_obj.code = get_ds_result.code; // This will overwrite whatever was passed in.
|
||||
ds_code_obj.name = get_ds_result.name;
|
||||
ds_code_obj.type = get_ds_result.type; // This will overwrite whatever was passed in.
|
||||
if (data_type == 'html') {
|
||||
ds_code_obj.html = get_ds_result.text;
|
||||
val_html = get_ds_result.text;
|
||||
return_this = get_ds_result.html;
|
||||
} else if (data_type == 'json') {
|
||||
ds_code_obj.json = get_ds_result.json;
|
||||
val_json = get_ds_result.json;
|
||||
return_this = get_ds_result.json;
|
||||
} else if (data_type == 'md') {
|
||||
ds_code_obj.text = get_ds_result.text;
|
||||
val_md = get_ds_result.text;
|
||||
return_this = get_ds_result.text;
|
||||
} else if (data_type == 'sql') {
|
||||
ds_code_obj.text = get_ds_result.text;
|
||||
val_sql = get_ds_result.text;
|
||||
return_this = get_ds_result.text;
|
||||
} else {
|
||||
ds_code_obj.text = get_ds_result.text;
|
||||
val_text = get_ds_result.text;
|
||||
return_this = get_ds_result.text;
|
||||
}
|
||||
|
||||
// if (data_type == 'text') {
|
||||
// // console.log(get_ds_result.text);
|
||||
// return_this = get_ds_result.text;
|
||||
// } else if (data_type == 'json') {
|
||||
// // console.log(get_ds_result.json);
|
||||
// return_this = get_ds_result.json;
|
||||
// }
|
||||
|
||||
if (save_idb) {
|
||||
if (browser) {
|
||||
const key_prefix = 'ae_ds__';
|
||||
if (log_lvl) {
|
||||
console.log(
|
||||
`*ae_func* localStorage key: ${code}, value:`,
|
||||
get_ds_result
|
||||
);
|
||||
}
|
||||
localStorage.setItem(
|
||||
`${key_prefix}${code}`,
|
||||
JSON.stringify(get_ds_result)
|
||||
);
|
||||
} else {
|
||||
if (log_lvl) {
|
||||
console.log(
|
||||
'*ae_func* No browser! Can not use localStorage to save data store object.'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.log('*ae_func* No results returned.');
|
||||
return_this = null;
|
||||
}
|
||||
return return_this;
|
||||
})
|
||||
.catch(function (error: any) {
|
||||
console.log('*ae_func* No results returned or failed.', error);
|
||||
});
|
||||
|
||||
return ae_promises.load__data_store_obj;
|
||||
}
|
||||
|
||||
// Updated 2024-03-27
|
||||
async function update_ae_obj_id_crud({
|
||||
api_cfg,
|
||||
@@ -527,7 +369,6 @@ const export_obj = {
|
||||
clean_headers: clean_headers,
|
||||
|
||||
load_ae_obj_id__site_domain: load_ae_obj_id__site_domain,
|
||||
load_ae_obj_code__data_store: 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,
|
||||
|
||||
@@ -489,79 +489,6 @@ export const delete_hosted_file = async function delete_hosted_file({
|
||||
};
|
||||
/* END: Hosted File Related */
|
||||
|
||||
/* BEGIN: Data Store Related */
|
||||
|
||||
// Updated 2023-06-29
|
||||
export const get_data_store_obj_w_code =
|
||||
async function get_data_store_obj_w_code({
|
||||
api_cfg,
|
||||
data_store_code,
|
||||
data_type = 'text',
|
||||
headers = {},
|
||||
params = {},
|
||||
timeout = 25000,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any;
|
||||
data_store_code: string;
|
||||
data_type?: string;
|
||||
headers?: key_val;
|
||||
params?: key_val;
|
||||
timeout?: number;
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
if (log_lvl) {
|
||||
console.log('*** get_data_store_obj_w_code() ***');
|
||||
}
|
||||
|
||||
// let get_item_result = window.localStorage.getItem(code);
|
||||
|
||||
const endpoint = `/data_store/code/${data_store_code}`;
|
||||
let data_store_obj_get_promise = await api.get_object({
|
||||
api_cfg: api_cfg,
|
||||
endpoint: endpoint,
|
||||
headers: headers,
|
||||
params: params,
|
||||
timeout: timeout,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
|
||||
if (data_store_obj_get_promise === false) {
|
||||
console.log('Data Store - RUN AGAIN WITH BACKUP');
|
||||
const original_api_base_url = api_cfg['base_url'];
|
||||
|
||||
const temp_api = api_cfg;
|
||||
temp_api['base_url'] = temp_api['base_url_bak'];
|
||||
|
||||
data_store_obj_get_promise = await api.get_object({
|
||||
api_cfg: temp_api,
|
||||
endpoint: endpoint,
|
||||
headers: headers,
|
||||
params: params,
|
||||
timeout: timeout,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
temp_api['base_url'] = original_api_base_url;
|
||||
}
|
||||
|
||||
const data_store_obj = data_store_obj_get_promise;
|
||||
|
||||
if (data_type == 'text') {
|
||||
// console.log(data_store_obj.text);
|
||||
// window.localStorage.setItem(data_store_code, data_store_obj.text);
|
||||
// localStorage.setItem(data_store_code, data_store_obj.text);
|
||||
} else if (data_type == 'json') {
|
||||
// console.log(data_store_obj.json);
|
||||
// window.localStorage.setItem(data_store_code, JSON.stringify(data_store_obj.json));
|
||||
// localStorage.setItem(data_store_code, JSON.stringify(data_store_obj.json));
|
||||
}
|
||||
|
||||
if (log_lvl > 1) {
|
||||
console.log('Response Data:', data_store_obj);
|
||||
}
|
||||
return data_store_obj;
|
||||
};
|
||||
/* END: Data Store Related */
|
||||
|
||||
/* BEGIN: Utility: Email Related */
|
||||
|
||||
@@ -693,7 +620,6 @@ const obj = {
|
||||
download_hosted_file: download_hosted_file,
|
||||
delete_hosted_file: delete_hosted_file,
|
||||
get_data_store: get_data_store,
|
||||
get_data_store_obj_w_code: get_data_store_obj_w_code,
|
||||
get_ae_obj_li_for_lu: get_ae_obj_li_for_lu,
|
||||
send_email: send_email
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user