Now done for the night.

This commit is contained in:
Scott Idem
2024-10-14 20:05:57 -04:00
parent 4ec440146e
commit 7450edfdcf
9 changed files with 329 additions and 72 deletions

View File

@@ -28,7 +28,7 @@ export async function get_ae_obj_li_for_obj_id_crud(
}: {
api_cfg: any,
obj_type: string,
for_obj_type: string,
for_obj_type: null|string,
for_obj_id?: string,
use_alt_table?: boolean,
use_alt_base?: boolean,
@@ -126,15 +126,15 @@ export async function get_ae_obj_li_for_obj_id_crud(
endpoint = `/crud/sponsorship/list`;
// } else if (obj_type == 'user') {
// endpoint = `/crud/user/list`;
// } else if (obj_type == 'lu' && for_obj_type == 'country_subdivision') {
// endpoint = `/crud/lu/country_subdivision/list`;
// for_obj_type = null;
// } else if (obj_type == 'lu' && for_obj_type == 'country') {
// endpoint = `/crud/lu/country/list`;
// for_obj_type = null;
// } else if (obj_type == 'lu' && for_obj_type == 'time_zone') {
// endpoint = `/crud/lu/time_zone/list`;
// for_obj_type = null;
} else if (obj_type == 'lu' && for_obj_type == 'country_subdivision') {
endpoint = `/crud/lu/country_subdivision/list`;
for_obj_type = null;
} else if (obj_type == 'lu' && for_obj_type == 'country') {
endpoint = `/crud/lu/country/list`;
for_obj_type = null;
} else if (obj_type == 'lu' && for_obj_type == 'time_zone') {
endpoint = `/crud/lu/time_zone/list`;
for_obj_type = null;
} else {
console.log(`Unknown object type: ${obj_type}`);
return false;

View File

@@ -0,0 +1,37 @@
import type { key_val } from '$lib/ae_stores';
import { api } from '$lib/api';
// Updated 2024-10-02
export async function check_hosted_file_obj_w_hash(
{
api_cfg,
hosted_file_hash,
check_for_local = true, // Forces a check on the host server for the file.
params = {},
return_meta = false,
log_lvl = 0
} : {
api_cfg: any,
hosted_file_hash: string,
check_for_local?: boolean,
params?: key_val,
return_meta?: boolean,
log_lvl?: number
}
) {
console.log('*** stores_event_api.js: check_hosted_file_obj_w_hash() ***');
const endpoint = `/hosted_file/hash/${hosted_file_hash}`;
if (check_for_local) {
params['check_for_local'] = true;
}
let check_hosted_file_obj_w_hash_get_promise = await api.get_object({
api_cfg: api_cfg,
endpoint: endpoint,
params: params,
return_meta: return_meta,
log_lvl: log_lvl
});
return check_hosted_file_obj_w_hash_get_promise;
}

View File

@@ -0,0 +1,67 @@
import type { key_val } from '$lib/ae_stores';
import { api } from '$lib/api';
import { db_core } from "$lib/db_core";
let ae_promises: key_val = {};
// Updated 2024-10-14
export async function load_ae_obj_li__country(
{
api_cfg,
// account_id,
params = {},
try_cache = true,
log_lvl = 0
}: {
api_cfg: any,
// account_id: string,
params?: key_val,
try_cache?: boolean,
log_lvl?: number
}
) {
console.log(`*** load_ae_obj_li__country() ***`);
let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden
let limit: number = (params.qry__limit ?? 300); // Actual is 249 in 2024
let offset: number = (params.qry__offset ?? 0); // 0
let params_json: key_val = {};
// console.log('params_json:', params_json);
ae_promises.load__country_li = await api.get_ae_obj_li_for_obj_id_crud({
api_cfg: api_cfg,
obj_type: 'lu',
for_obj_type: 'country',
// for_obj_id: account_id,
use_alt_table: false, // 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
enabled: enabled,
hidden: hidden,
order_by_li: {'english_short_name': 'ASC'},
limit: limit,
offset: offset,
params_json: params_json,
params: params,
log_lvl: log_lvl
})
.then(function (country_li_get_result) {
if (country_li_get_result) {
// handle_db_save_ae_obj_li__country({obj_type: 'country', obj_li: country_li_get_result});
return country_li_get_result;
} else {
return [];
}
})
.catch(function (error) {
console.log('No results returned or failed.', error);
});
console.log('ae_promises.load__country_li:', ae_promises.load__country_li);
return ae_promises.load__country_li;
}

View File

@@ -0,0 +1,67 @@
import type { key_val } from '$lib/ae_stores';
import { api } from '$lib/api';
import { db_core } from "$lib/db_core";
let ae_promises: key_val = {};
// Updated 2024-10-14
export async function load_ae_obj_li__country_subdivision(
{
api_cfg,
// account_id,
params = {},
try_cache = true,
log_lvl = 0
}: {
api_cfg: any,
// account_id: string,
params?: key_val,
try_cache?: boolean,
log_lvl?: number
}
) {
console.log(`*** load_ae_obj_li__country_subdivision() ***`);
let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden
let limit: number = (params.qry__limit ?? 300); // Actual is 249 in 2024
let offset: number = (params.qry__offset ?? 0); // 0
let params_json: key_val = {};
// console.log('params_json:', params_json);
ae_promises.load__country_subdivision_li = await api.get_ae_obj_li_for_obj_id_crud({
api_cfg: api_cfg,
obj_type: 'lu',
for_obj_type: 'country_subdivision',
// for_obj_id: account_id,
use_alt_table: false, // 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
enabled: enabled,
hidden: hidden,
order_by_li: {'name': 'ASC', 'code': 'ASC'},
limit: limit,
offset: offset,
params_json: params_json,
params: params,
log_lvl: log_lvl
})
.then(function (country_subdivision_li_get_result) {
if (country_subdivision_li_get_result) {
// handle_db_save_ae_obj_li__country_subdivision({obj_type: 'country_subdivision', obj_li: country_subdivision_li_get_result});
return country_subdivision_li_get_result;
} else {
return [];
}
})
.catch(function (error) {
console.log('No results returned or failed.', error);
});
console.log('ae_promises.load__country_subdivision_li:', ae_promises.load__country_subdivision_li);
return ae_promises.load__country_subdivision_li;
}

View File

@@ -0,0 +1,67 @@
import type { key_val } from '$lib/ae_stores';
import { api } from '$lib/api';
import { db_core } from "$lib/db_core";
let ae_promises: key_val = {};
// Updated 2024-10-14
export async function load_ae_obj_li__time_zone(
{
api_cfg,
// account_id,
params = {},
try_cache = true,
log_lvl = 0
}: {
api_cfg: any,
// account_id: string,
params?: key_val,
try_cache?: boolean,
log_lvl?: number
}
) {
console.log(`*** load_ae_obj_li__time_zone() ***`);
let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden
let limit: number = (params.qry__limit ?? 625); // Actual is 594 in 2024
let offset: number = (params.qry__offset ?? 0); // 0
let params_json: key_val = {};
// console.log('params_json:', params_json);
ae_promises.load__time_zone_li = await api.get_ae_obj_li_for_obj_id_crud({
api_cfg: api_cfg,
obj_type: 'lu',
for_obj_type: 'time_zone',
// for_obj_id: account_id,
use_alt_table: false, // 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
enabled: enabled,
hidden: hidden,
order_by_li: {'name': 'ASC'},
limit: limit,
offset: offset,
params_json: params_json,
params: params,
log_lvl: log_lvl
})
.then(function (time_zone_li_get_result) {
if (time_zone_li_get_result) {
// handle_db_save_ae_obj_li__time_zone({obj_type: 'time_zone', obj_li: time_zone_li_get_result});
return time_zone_li_get_result;
} else {
return [];
}
})
.catch(function (error) {
console.log('No results returned or failed.', error);
});
console.log('ae_promises.load__time_zone_li:', ae_promises.load__time_zone_li);
return ae_promises.load__time_zone_li;
}

View File

@@ -9,51 +9,31 @@ import {
handle_create_ae_obj__person,
handle_update_ae_obj__person,
// handle_db_save_ae_obj_li__person
} from "$lib/ae_core__person";
} from "$lib/ae_core/core__person";
import {
generate_qr_code,
} from "$lib/ae_core__qr_code";
} from "$lib/ae_core/core__qr_code";
import {
check_hosted_file_obj_w_hash
} from "$lib/ae_core/core__check_hosted_file_obj_w_hash";
import {
load_ae_obj_li__time_zone
} from "$lib/ae_core/core__time_zones";
import {
load_ae_obj_li__country
} from "$lib/ae_core/core__countries";
import {
load_ae_obj_li__country_subdivision
} from "$lib/ae_core/core__country_subdivisions";
let ae_promises: key_val = {}; // Promise<any>;
// Updated 2024-10-02
async function check_hosted_file_obj_w_hash(
{
api_cfg,
hosted_file_hash,
check_for_local = true, // Forces a check on the host server for the file.
params = {},
return_meta = false,
log_lvl = 0
} : {
api_cfg: any,
hosted_file_hash: string,
check_for_local?: boolean,
params?: key_val,
return_meta?: boolean,
log_lvl?: number
}
) {
console.log('*** stores_event_api.js: check_hosted_file_obj_w_hash() ***');
const endpoint = `/hosted_file/hash/${hosted_file_hash}`;
if (check_for_local) {
params['check_for_local'] = true;
}
let check_hosted_file_obj_w_hash_get_promise = await api.get_object({
api_cfg: api_cfg,
endpoint: endpoint,
params: params,
return_meta: return_meta,
log_lvl: log_lvl
});
return check_hosted_file_obj_w_hash_get_promise;
}
// Updated 2024-03-29
async function handle_load_ae_obj_id__site_domain(
{
@@ -407,6 +387,9 @@ async function handle_download_export__obj_type(
let export_obj = {
check_hosted_file_obj_w_hash: check_hosted_file_obj_w_hash,
load_ae_obj_li__time_zone: load_ae_obj_li__time_zone,
load_ae_obj_li__country: load_ae_obj_li__country,
load_ae_obj_li__country_subdivision: load_ae_obj_li__country_subdivision,
handle_load_ae_obj_id__site_domain: handle_load_ae_obj_id__site_domain,
handle_load_ae_obj_code__data_store: handle_load_ae_obj_code__data_store,
handle_load_ae_obj_id__person: handle_load_ae_obj_id__person,