Need to work on not havnig the account ID set

This commit is contained in:
Scott Idem
2024-02-22 22:16:49 -05:00
parent 02f693c13e
commit 740baa689e
3 changed files with 74 additions and 16 deletions

View File

@@ -1,9 +1,9 @@
import { localStorageStore } from '@skeletonlabs/skeleton'
import { readable, writable } from 'svelte/store';
import type { Writable } from 'svelte/store';
import type { get, Writable } from 'svelte/store';
import { PUBLIC_TESTING, PUBLIC_AE_API_PROTOCOL, PUBLIC_AE_API_SERVER, PUBLIC_AE_API_BAK_SERVER, PUBLIC_AE_API_PORT, PUBLIC_AE_API_PATH, PUBLIC_AE_API_SECRET_KEY, PUBLIC_AE_API_CRUD_SUPER_KEY, PUBLIC_AE_ACCOUNT_ID, PUBLIC_AE_SPONSORSHIP_CFG_ID } from '$env/static/public';
import { PUBLIC_TESTING, PUBLIC_AE_API_PROTOCOL, PUBLIC_AE_API_SERVER, PUBLIC_AE_API_BAK_SERVER, PUBLIC_AE_API_PORT, PUBLIC_AE_API_PATH, PUBLIC_AE_API_SECRET_KEY, PUBLIC_AE_API_CRUD_SUPER_KEY, PUBLIC_AE_NO_ACCOUNT_ID, PUBLIC_AE_NO_ACCOUNT_ID_TOKEN, PUBLIC_AE_ACCOUNT_ID, PUBLIC_AE_SPONSORSHIP_CFG_ID } from '$env/static/public';
console.log(`Aether Config - TESTING:`, PUBLIC_TESTING);
const api_base_url = `${PUBLIC_AE_API_PROTOCOL}://${PUBLIC_AE_API_SERVER}:${PUBLIC_AE_API_PORT}${PUBLIC_AE_API_PATH}`;
@@ -12,9 +12,14 @@ const api_base_url_bak = `${PUBLIC_AE_API_PROTOCOL}://${PUBLIC_AE_API_BAK_SERVER
const api_secret_key = PUBLIC_AE_API_SECRET_KEY;
const api_crud_super_key = PUBLIC_AE_API_CRUD_SUPER_KEY;
const ae_account_id = PUBLIC_AE_ACCOUNT_ID;
// const ae_account_id = PUBLIC_AE_ACCOUNT_ID;
let ae_account_id: null|string = null;
const ae_no_account_id = PUBLIC_AE_NO_ACCOUNT_ID;
const ae_no_account_id_token = PUBLIC_AE_NO_ACCOUNT_ID_TOKEN;
const ae_sponsorship_cfg_id = PUBLIC_AE_SPONSORSHIP_CFG_ID;
// import { api } from '$lib/api';
// console.log(`Aether Config - API:`, api);
// import { getStores, navigating, page, updated } from '$app/stores';
// import { assets, base, resolveRoute } from '$app/paths';
@@ -31,6 +36,7 @@ type key_val = {
// name: string;
};
// *** BEGIN *** Longer-term app data. This should be stored to local storage.
export let ae_app_local_data_struct: key_val = {
'ver': '2024-02-22_17',
@@ -90,7 +96,7 @@ export let ae_app_session_data_struct: key_val = {
'ver': '2024-02-22_17',
// 'name': 'Aether App Template',
// 'theme': 'light',
'account_id': ae_account_id,
// 'account_id': ae_account_id,
// 'obj': {},
}
console.log(`Aether Config - App Session Storage Data:`, ae_app_session_data_struct);
@@ -115,7 +121,14 @@ ae_api_headers['content-type'] = 'application/json';
ae_api_headers['x-aether-api-key'] = ae_api_data_struct.api_secret_key;
ae_api_headers['x-aether-api-token'] = 'fake-temp-token';
ae_api_headers['x-aether-api-expire-on'] = '';
ae_api_headers['x-account-id'] = ae_account_id,
if (ae_account_id) {
ae_api_headers['x-account-id'] = ae_account_id;
} else {
// ae_api_headers['x-account-id'] = ;
}
if (ae_no_account_id) {
ae_api_headers['x-no-account-id'] = ae_no_account_id;
}
ae_api_data_struct['headers'] = ae_api_headers;
console.log(`Aether Config - API Data:`, ae_api_data_struct);
@@ -150,3 +163,49 @@ let slct_obj_template: key_val = {
'post_comment_obj_li': [] };
console.log(`Aether Config - Selected Objects:`, slct_obj_template);
export let slct = writable(slct_obj_template);
// export let handle_load_ae_obj_id__site_domain = async function handle_load_ae_obj_id__site_domain({fqdn, try_cache=false}) {
// console.log(`*** handle_load_ae_obj_id__site_domain() *** fqdn=${fqdn}`);
// let params = {};
// // ae_loc.hub.site_domain_id_qry_status = 'loading';
// let ae_site_domain_obj_get_promise = api.get_ae_obj_id_crud({
// api_cfg: ae_api,
// no_account_id: true,
// obj_type: 'site_domain',
// obj_id: fqdn, // 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: true, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
// params: params,
// log_lvl: 2
// })
// .then(function (site_domain_obj_get_result) {
// if (site_domain_obj_get_result) {
// // slct.site_domain_obj = site_domain_obj_get_result;
// // console.log(`site_domain object:`, get(slct).site_domain_obj);
// // ae_loc.account_id = $slct.site_domain_obj.account_id_random;
// // ae_loc.site_id = $slct.site_domain_obj.site_id_random;
// // ae_loc.site_domain_id = $slct.site_domain_obj.site_domain_id_random;
// return site_domain_obj_get_result;
// } else {
// console.log('No results returned.');
// return null;
// }
// })
// .catch(function (error) {
// console.log('No results returned or failed.', error);
// });
// return ae_site_domain_obj_get_promise;
// }

View File

@@ -601,7 +601,10 @@ export let get_ae_obj_id_crud = async function get_ae_obj_id_crud({
}
if (no_account_id) {
headers['x_no_account_id_token'] = 'Nothing to See Here'; // get_object() will fix the underscores to dashes
headers['x-no-account-id'] = 'Nothing to See Here';
// params['x_no_account_id_token'] = 'Nothing to See Here';
// headers['x-account-id'] = null;
// headers['x-no-account-id-token'] = 'Nothing to See Here'; // get_object() will fix the underscores to dashes
}
let object_obj_get_promise = await get_object({

View File

@@ -6,7 +6,7 @@ import { ae_loc, ae_sess, ae_api, slct, slct_trigger } from '$lib/ae_stores';
import { get } from 'svelte/store';
async function handle_load_ae_obj_id__site_domain({fqdn, try_cache=false}) {
function handle_load_ae_obj_id__site_domain({fqdn, try_cache=false}) {
console.log(`*** handle_load_ae_obj_id__site_domain() *** fqdn=${fqdn}`);
let params = {};
@@ -20,7 +20,7 @@ async function handle_load_ae_obj_id__site_domain({fqdn, try_cache=false}) {
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: true, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
params: params,
log_lvl: 2
log_lvl: 1
})
.then(function (site_domain_obj_get_result) {
if (site_domain_obj_get_result) {
@@ -44,7 +44,7 @@ async function handle_load_ae_obj_id__site_domain({fqdn, try_cache=false}) {
}
let data_store_obj_get_promises: key_val = {};
async function handle_get_data_store_obj_w_code({ code=null, data_type='text' }) {
function handle_get_data_store_obj_w_code({ code=null, data_type='text' }) {
console.log(`*** handle_get_data_store_obj_w_code() *** code=${code}`);
if (!code) {
@@ -129,11 +129,8 @@ export function load({ params, url }) { // route
}
// ae_core = {
// 'account_id': site_domain_results.account_id_random
// }
let data_struct = {
ae_core: ae_core,
params: params,
sections: [
{ slug: 'new', title: 'New Test' },
@@ -141,13 +138,12 @@ export function load({ params, url }) { // route
{ slug: 'test', title: 'Test Test' },
],
url: url,
ae_core: ae_core,
};
return data_struct;
}
// export const ssr = false;
// export const prerender = true;
// export const prerender = true
// export const trailingSlash = 'always'; // 'never' | 'always' | 'ignore'
/// export const trailingSlash = 'always'; // 'never' | 'always' | 'ignore'