Implemented Aether API V3 Lookup integration for standardized tables.
- Created 'src/lib/ae_api/api_get__lookup_v3.ts' to handle the new '/v3/lookup/{lu_type}/list' endpoint.
- Refactored 'get_ae_obj_li_for_lu' in 'api.ts' to prioritize the V3 system for countries, subdivisions, and time zones, with V2 fallback for legacy types.
- Ensured lookups use the 'x-no-account-id' bypass for unauthenticated site bootstrapping.
- Updated core country, subdivision, and time zone loaders to use the refined API interface.
This commit is contained in:
56
src/lib/ae_api/api_get__lookup_v3.ts
Normal file
56
src/lib/ae_api/api_get__lookup_v3.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
import { get_object } from './api_get_object';
|
||||
import type { key_val } from '$lib/stores/ae_stores';
|
||||
|
||||
/**
|
||||
* Get a list of lookup objects (V3)
|
||||
* Standardized lookup data like countries, timezones, and subdivisions.
|
||||
* Updated 2026-02-20
|
||||
*
|
||||
* Endpoint: GET /v3/lookup/{lu_type}/list
|
||||
*/
|
||||
export async function get_ae_lookup_li_v3({
|
||||
api_cfg,
|
||||
lu_type,
|
||||
site_id,
|
||||
for_type,
|
||||
for_id,
|
||||
include_disabled = false,
|
||||
params = {},
|
||||
headers = {},
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any;
|
||||
lu_type: 'country' | 'country_subdivision' | 'time_zone' | string;
|
||||
site_id?: string;
|
||||
for_type?: string;
|
||||
for_id?: string;
|
||||
include_disabled?: boolean;
|
||||
params?: key_val;
|
||||
headers?: Record<string, string>;
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** get_ae_lookup_li_v3() *** lu_type=${lu_type}`);
|
||||
}
|
||||
|
||||
const endpoint = `/v3/lookup/${lu_type}/list`;
|
||||
|
||||
// Build query params
|
||||
if (site_id) params['site_id'] = site_id;
|
||||
if (for_type) params['for_type'] = for_type;
|
||||
if (for_id) params['for_id'] = for_id;
|
||||
if (include_disabled) params['include_disabled'] = true;
|
||||
|
||||
// Lookup data is often global; ensure account context is handled if needed,
|
||||
// but GUIDE says it uses site Whitelist Policy.
|
||||
// If no account_id is present in api_cfg, we might need 'x-no-account-id'
|
||||
// for some lookups if they are public.
|
||||
|
||||
return await get_object({
|
||||
api_cfg,
|
||||
endpoint,
|
||||
params,
|
||||
headers,
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user