Fix(Core): Restore system lookups and enhance reference data view

- API: Correctly exported 'get_ae_obj_li_for_lu' and reverted to stable V2 endpoints (/v2/crud/lu/.../list) to resolve V3 500 errors.
- Auth: Injected 'x-no-account-id' bypass header for unauthenticated global lookup access.
- UI: Updated lookups page to support 'english_short_name' fallback for countries and added Country Subdivisions card.
- Debug: Added transient console logging for verification.
This commit is contained in:
Scott Idem
2026-01-20 19:13:14 -05:00
parent f244526538
commit 3221e5830e
2 changed files with 66 additions and 75 deletions

View File

@@ -28,106 +28,61 @@ import {
delete_nested_ae_obj_v3
} from '$lib/ae_api/api_post__crud_obj_v3';
// This new function has not been tested yet!!!
// Updated 2024-08-07
/**
* Get a list of lookup objects (V2 Legacy)
* Standardized lookup data like countries, timezones, and subdivisions.
* Updated 2026-01-20
*/
export const get_ae_obj_li_for_lu = async function get_ae_obj_li_for_lu({
api_cfg,
// obj_type,
for_lu_type,
// for_obj_id=null,
// use_alt_table=false,
// use_alt_base=false,
// inc={},
enabled = 'enabled',
hidden = 'not_hidden',
order_by_li = null,
limit = 999999,
offset = 0,
// key,
// jwt=null,
headers = {},
params_json = null,
// json_obj=null,
params = {},
return_meta = false,
log_lvl = 1
}: {
api_cfg: any;
// obj_type: string,
for_lu_type: string;
// for_lu_id?: string,
// use_alt_table?: boolean,
// use_alt_base?: boolean,
// inc?: key_val
enabled?: 'enabled' | 'all' | 'not_enabled' | undefined;
hidden?: 'hidden' | 'all' | 'not_hidden' | undefined;
order_by_li?: any;
limit?: number;
offset?: number;
// key: string,
// jwt?: string,
headers?: any;
params_json?: any;
// json_obj?: any,
params?: key_val;
return_meta?: boolean;
log_lvl?: number;
}) {
if (log_lvl) {
console.log(`*** get_ae_obj_li_for_lu() *** for_lu_type=${for_lu_type}`);
}
let endpoint = '';
if (for_lu_type == 'country_subdivision') {
endpoint = `/crud/lu/country_subdivision/list`;
} else if (for_lu_type == 'country') {
endpoint = `/crud/lu/country/list`;
} else if (for_lu_type == 'time_zone') {
endpoint = `/crud/lu/time_zone/list`;
} else {
console.log(`Unknown object type: ${for_lu_type}`);
return false;
}
if (log_lvl) {
console.log('Endpoint:', endpoint);
}
// Lookup data is global; bypass account-id scope check
const merged_headers = {
...headers,
'x-no-account-id': 'Nothing to See Here'
};
if (order_by_li) {
headers['order_by_li'] = order_by_li;
}
const allowed_enabled_list = ['all', 'enabled', 'not_enabled'];
if (allowed_enabled_list.includes(enabled)) {
params['enabled'] = enabled;
}
const allowed_hidden_list = ['all', 'hidden', 'not_hidden'];
if (allowed_hidden_list.includes(hidden)) {
params['hidden'] = hidden;
}
if (limit >= 0) {
params['limit'] = limit;
}
if (offset >= 0) {
params['offset'] = offset;
}
const object_li_get_promise = await api.get_object({
api_cfg: api_cfg,
endpoint: endpoint,
headers: headers,
params: params,
// return_meta: return_meta,
log_lvl: log_lvl
// Delegate to V2 helper which handles the /v2 prefix and /list suffix correctly
return await get_ae_obj_li_for_obj_id_crud_v2({
api_cfg,
obj_type: 'lu',
for_obj_type: for_lu_type,
enabled,
hidden,
order_by_li,
limit,
offset,
headers: merged_headers,
params_json,
params,
log_lvl
});
if (log_lvl > 1) {
console.log(object_li_get_promise);
}
return object_li_get_promise;
};
// Updated 2023-07-24
@@ -959,7 +914,8 @@ const obj = {
download_hosted_file: download_hosted_file,
delete_hosted_file: delete_hosted_file,
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
};
export const api = obj;
// module.exports = api;
// module.exports = api;