Refactor core API helpers and implement System Testing Dashboard

- Unified and hardened get, post, patch, and delete helpers with standardized retry logic, kebab-case headers, and V3 response envelope handling.
- Implemented robust 'Bootstrap Paradox' resolution logic across the API stack to handle unauthenticated site domain lookups safely.
- Enhanced API helpers to support custom fetch injection, enabling reliable server-side execution in SvelteKit.
- Upgraded /testing page into a comprehensive System Testing Dashboard for core helper and V3 search verification.
- Updated TODO.md and GEMINI.md with 2026-01-08 session learnings and 'Frontier Journals' vision.
This commit is contained in:
Scott Idem
2026-01-08 11:30:05 -05:00
parent bc56b38ec1
commit e355b7649d
8 changed files with 548 additions and 897 deletions

View File

@@ -3,394 +3,212 @@
import { api } from '$lib/api/api';
import { ae_loc, ae_sess, ae_api, slct, slct_trigger } from '$lib/stores/ae_stores';
import { get_object } from '$lib/ae_api/api_get_object';
import { post_object } from '$lib/ae_api/api_post_object';
type key_val = {
[key: string]: any;
};
let ae_account_obj_get_promise;
let ae_sponsorship_obj_li_get_promise;
let v3_test_result: any = $state(null);
let test_fqdn = $state('');
onMount(() => {
console.log('Testing: +page.svelte');
let url = window.location.href;
console.log(url);
});
async function test_v3_get_id() {
console.log('*** test_v3_get_id() ***');
/**
* CORE HELPER TESTS
*/
async function test_core_get_object() {
console.log('*** test_core_get_object() ***');
v3_test_result = 'loading...';
// Direct call to get_object with minimal params
const result = await get_object({
api_cfg: $ae_api,
endpoint: '/crud/account/list',
params: { limit: 1 },
log_lvl: 2
});
v3_test_result = {
helper: 'get_object',
result: result
};
}
async function test_core_post_object_v3_search() {
console.log('*** test_core_post_object_v3_search() ***');
v3_test_result = 'loading...';
// Direct call to post_object for V3 search
const result = await post_object({
api_cfg: $ae_api,
endpoint: '/v3/crud/event/search',
data: { q: 'Aether' },
params: { limit: 1 },
log_lvl: 2
});
v3_test_result = {
helper: 'post_object',
result: result
};
}
async function test_bootstrap_paradox_bypass() {
console.log('*** test_bootstrap_paradox_bypass() ***');
v3_test_result = 'loading...';
// Test standard V3 GET ID
// CRITICAL TEST: Simulate unauthenticated first visit
// We create a STRIPPED api_cfg that has no JWT and no account_id
const stripped_api_cfg = {
base_url: $ae_api.base_url,
headers: {} // NO DEFAULT HEADERS
};
const fqdn = test_fqdn || window.location.host;
const result = await post_object({
api_cfg: stripped_api_cfg,
endpoint: '/v3/crud/site_domain/search',
headers: { 'x-no-account-id': null }, // Trigger the bypass!
data: { q: fqdn },
log_lvl: 2
});
v3_test_result = {
test: 'Bootstrap Paradox Bypass',
api_cfg_used: 'STRIPPED (No default headers)',
fqdn_tested: fqdn,
result: result
};
}
/**
* V3 WRAPPER TESTS
*/
async function test_v3_get_id() {
v3_test_result = 'loading...';
const result = await api.get_ae_obj_v3({
api_cfg: $ae_api,
obj_type: 'event',
obj_id: '9dv-IV-iz-LY', // Use a known ID
obj_id: '9dv-IV-iz-LY',
view: 'base',
log_lvl: 1
});
v3_test_result = result;
console.log('V3 GET ID Result:', result);
}
async function test_v3_get_nested_id() {
console.log('*** test_v3_get_nested_id() ***');
v3_test_result = 'loading...';
// Test nested V3 GET ID
const result = await api.get_nested_ae_obj_v3({
api_cfg: $ae_api,
parent_type: 'event',
parent_id: '9dv-IV-iz-LY',
child_type: 'event_badge',
child_id: 'XHTX-23-20-42', // Use a known ID
child_id: 'XHTX-23-20-42',
view: 'base',
log_lvl: 1
});
v3_test_result = result;
console.log('V3 GET Nested ID Result:', result);
}
async function test_v3_create_nested() {
console.log('*** test_v3_create_nested() ***');
v3_test_result = 'loading...';
// Test creating a journal entry under the test journal
const result = await api.create_nested_obj_v3({
api_cfg: $ae_api,
parent_type: 'journal',
parent_id: 'JGEB-80-92-50',
child_type: 'journal_entry',
fields: {
account_id_random: 'nqOzejLCDXM',
name: 'Test V3 Nested Create',
content: 'This was created using the new V3 nested create wrapper!',
enable: true
},
log_lvl: 1
});
v3_test_result = result;
console.log('V3 Create Nested Result:', result);
}
async function test_v3_update_nested() {
console.log('*** test_v3_update_nested() ***');
v3_test_result = 'loading...';
// Test updating the journal entry we just created
// ID is from the previous step result: nKiyj0JV5CY
const result = await api.update_nested_obj_v3({
api_cfg: $ae_api,
parent_type: 'journal',
parent_id: 'JGEB-80-92-50',
child_type: 'journal_entry',
child_id: 'nKiyj0JV5CY',
fields: {
name: 'Test V3 Nested Update - UPDATED',
content: 'This was UPDATED using the new V3 nested update wrapper!'
},
log_lvl: 1
});
v3_test_result = result;
console.log('V3 Update Nested Result:', result);
}
async function test_v3_delete_nested() {
console.log('*** test_v3_delete_nested() ***');
v3_test_result = 'loading...';
// Test soft deleting (disabling) the journal entry we just updated
const result = await api.delete_nested_ae_obj_v3({
api_cfg: $ae_api,
parent_type: 'journal',
parent_id: 'JGEB-80-92-50',
child_type: 'journal_entry',
child_id: 'nKiyj0JV5CY',
method: 'disable', // Sets enable = false
log_lvl: 1
});
v3_test_result = result;
console.log('V3 Delete (Disable) Nested Result:', result);
}
import { journals_func } from '$lib/ae_journals/ae_journals_functions';
/**
* DATA LOADING MODULE TESTS
*/
import { load_ae_obj_li__account, load_ae_obj_id__account } from '$lib/ae_core/ae_core__account';
import { load_ae_obj_li__site, load_ae_obj_id__site } from '$lib/ae_core/ae_core__site';
import { load_ae_obj_li__person, load_ae_obj_id__person } from '$lib/ae_core/ae_core__person';
import { load_ae_obj_li__site, load_ae_obj_id__site, lookup_site_domain_v3 } from '$lib/ae_core/ae_core__site';
async function test_site_domain_load_v3() {
v3_test_result = 'loading...';
const fqdn = test_fqdn || window.location.host;
const result = await lookup_site_domain_v3({
api_cfg: $ae_api,
fqdn,
log_lvl: 2
});
v3_test_result = result;
}
async function test_account_v3_load() {
console.log('*** test_account_v3_load() ***');
v3_test_result = 'loading...';
const account_li = await load_ae_obj_li__account({
api_cfg: $ae_api,
enabled: 'all',
hidden: 'all',
log_lvl: 2
});
if (account_li && account_li.length > 0) {
const first_account_id = account_li[0].account_id_random;
console.log('Loading single account:', first_account_id);
const account_obj = await load_ae_obj_id__account({
api_cfg: $ae_api,
account_id: first_account_id,
log_lvl: 1
});
v3_test_result = {
list_count: account_li.length,
single_account: account_obj
};
} else {
v3_test_result = 'No accounts found';
}
}
async function test_site_v3_load() {
console.log('*** test_site_v3_load() ***');
v3_test_result = 'loading...';
const account_id = $ae_loc.account_id;
if (!account_id) {
v3_test_result = 'No account_id found in $ae_loc';
return;
}
const site_li = await load_ae_obj_li__site({
api_cfg: $ae_api,
for_obj_id: account_id,
enabled: 'all',
hidden: 'all',
log_lvl: 2
});
if (site_li && site_li.length > 0) {
const first_site_id = site_li[0].site_id_random;
const site_obj = await load_ae_obj_id__site({
api_cfg: $ae_api,
site_id: first_site_id,
log_lvl: 2
});
v3_test_result = {
account_id,
list_count: site_li.length,
single_site: site_obj
};
} else {
v3_test_result = 'No sites found for account ' + account_id;
}
}
async function test_person_v3_load() {
console.log('*** test_person_v3_load() ***');
v3_test_result = 'loading...';
const account_id = $ae_loc.account_id;
if (!account_id) {
v3_test_result = 'No account_id found in $ae_loc';
return;
}
const person_li = await load_ae_obj_li__person({
api_cfg: $ae_api,
for_obj_id: account_id,
enabled: 'all',
hidden: 'all',
log_lvl: 2
});
if (person_li && person_li.length > 0) {
const first_person_id = person_li[0].person_id_random;
const person_obj = await load_ae_obj_id__person({
api_cfg: $ae_api,
person_id: first_person_id,
log_lvl: 2
});
v3_test_result = {
account_id,
list_count: person_li.length,
single_person: person_obj
};
} else {
v3_test_result = 'No persons found for account ' + account_id;
}
}
async function test_journal_module_soft_delete() {
console.log('*** test_journal_module_soft_delete() ***');
v3_test_result = 'loading...';
// 1. Create a fresh entry first
const new_entry = await journals_func.create_ae_obj__journal_entry({
api_cfg: $ae_api,
journal_id: 'JGEB-80-92-50',
data_kv: {
name: 'Soft Delete Test Entry',
content: 'Testing disable and hide methods...',
account_id_random: 'nqOzejLCDXM'
},
log_lvl: 1
});
if (!new_entry) {
v3_test_result = 'Failed to create test entry';
return;
}
const entry_id = new_entry.journal_entry_id_random;
console.log('Created test entry:', entry_id);
// 2. Test 'disable'
console.log('Testing DISABLE...');
await journals_func.delete_ae_obj_id__journal_entry({
api_cfg: $ae_api,
journal_entry_id: entry_id,
method: 'disable',
log_lvl: 1
});
// 3. Test 'hide'
console.log('Testing HIDE...');
const final_result = await journals_func.delete_ae_obj_id__journal_entry({
api_cfg: $ae_api,
journal_entry_id: entry_id,
method: 'hide',
log_lvl: 1
});
v3_test_result = {
message: 'Soft delete (disable) and hide tests completed for entry ' + entry_id,
last_result: final_result
};
}
import { lookup_site_domain_v3 } from '$lib/ae_core/ae_core__site';
let test_fqdn = $state('');
async function test_site_domain_search_v3() {
console.log('*** test_site_domain_search_v3() ***');
v3_test_result = 'loading...';
const fqdn = test_fqdn || window.location.host;
console.log('Testing FQDN:', fqdn);
try {
const result = await lookup_site_domain_v3({
api_cfg: $ae_api,
fqdn,
view: 'default',
log_lvl: 2
});
v3_test_result = {
fqdn,
result,
timestamp: new Date().toISOString()
};
console.log('Site Domain Search V3 Result:', result);
} catch (err: any) {
console.error('Error in test_site_domain_search_v3:', err);
v3_test_result = {
error: err.message || 'Unknown error',
stack: err.stack
};
}
v3_test_result = account_li;
}
</script>
<div class="container h-full mx-auto flex flex-col justify-center items-center p-4 gap-4">
<div class="space-y-10 text-center flex flex-col items-center">
<h1 class="h1">Aether - V3 API Testing</h1>
<div class="container h-full mx-auto p-4 gap-8 flex flex-col">
<header class="text-center space-y-4">
<h1 class="h1">Aether - System Testing Dashboard</h1>
<p class="opacity-50">Comprehensive validation for API V3 and Core Helpers</p>
</header>
<div class="flex flex-col gap-2 w-full max-w-sm">
<input
type="text"
class="input"
placeholder="FQDN (optional, defaults to current host)"
bind:value={test_fqdn}
/>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-8">
<!-- Control Panel -->
<section class="space-y-6">
<div class="card p-4 space-y-4">
<h3 class="h3">Global Parameters</h3>
<label class="label">
<span>Target FQDN</span>
<input type="text" class="input" placeholder="e.g. localhost:5173" bind:value={test_fqdn} />
</label>
</div>
<div class="flex justify-center flex-wrap gap-2">
<button class="btn variant-filled-primary" onclick={test_v3_get_id}>
Test V3 GET ID
</button>
<button class="btn variant-filled-secondary" onclick={test_v3_get_nested_id}>
Test V3 GET Nested ID
</button>
<button class="btn variant-filled-tertiary" onclick={test_v3_create_nested}>
Test V3 Create Nested
</button>
<button class="btn variant-filled-warning" onclick={test_v3_update_nested}>
Test V3 Update Nested
</button>
<button class="btn variant-filled-error" onclick={test_v3_delete_nested}>
Test V3 Delete (Disable) Nested
</button>
<button class="btn variant-filled-success" onclick={test_journal_module_soft_delete}>
Test Journal Module Soft Deletes
</button>
<button class="btn variant-filled-primary" onclick={test_account_v3_load}>
Test Account V3 Load
</button>
<button class="btn variant-filled-secondary" onclick={test_site_v3_load}>
Test Site V3 Load
</button>
<button class="btn variant-filled-tertiary" onclick={test_person_v3_load}>
Test Person V3 Load
</button>
<button class="btn variant-filled-warning" onclick={test_site_domain_search_v3}>
Test Site Domain Search V3
</button>
</div>
<div class="card p-4 space-y-4">
<h3 class="h3">Core Helper Verification</h3>
<div class="flex flex-wrap gap-2">
<button class="btn variant-filled-primary" onclick={test_core_get_object}>get_object</button>
<button class="btn variant-filled-primary" onclick={test_core_post_object_v3_search}>post_object (Search)</button>
<button class="btn variant-filled-error" onclick={test_bootstrap_paradox_bypass}>Bootstrap Paradox Bypass</button>
</div>
</div>
<div class="card p-4 space-y-4">
<h3 class="h3">V3 Wrapper Tests</h3>
<div class="flex flex-wrap gap-2">
<button class="btn variant-filled-secondary" onclick={test_v3_get_id}>Get Event</button>
<button class="btn variant-filled-secondary" onclick={test_v3_get_nested_id}>Get Nested Badge</button>
</div>
</div>
<div class="card p-4 space-y-4">
<h3 class="h3">Module Loader Tests</h3>
<div class="flex flex-wrap gap-2">
<button class="btn variant-filled-tertiary" onclick={test_account_v3_load}>Load Accounts</button>
<button class="btn variant-filled-tertiary" onclick={test_site_domain_load_v3}>Lookup Site Domain</button>
</div>
</div>
</section>
<!-- Result View -->
<section class="space-y-4">
<div class="card p-4 h-full bg-surface-100-800-token overflow-hidden flex flex-col">
<div class="flex justify-between items-center mb-4">
<h3 class="h3">Result View</h3>
{#if v3_test_result === 'loading...'}
<span class="badge variant-filled-warning animate-pulse">Processing...</span>
{:else if v3_test_result}
<span class="badge variant-filled-success">Success</span>
{/if}
</div>
<div class="flex-1 overflow-auto bg-black/10 rounded p-2">
{#if v3_test_result}
<pre class="text-xs">{JSON.stringify(v3_test_result, null, 2)}</pre>
{:else}
<p class="text-center opacity-50 py-20">Execute a test to see results</p>
{/if}
</div>
</div>
</section>
</div>
{#if v3_test_result !== null}
<div class="card p-4 w-full max-w-2xl bg-surface-100-800-token">
<h3 class="h3">Test Result:</h3>
<pre class="text-xs text-left overflow-auto max-h-96">
{JSON.stringify(v3_test_result, null, 2)}
</pre>
</div>
{/if}
</div>
<style lang="postcss">
/* figure {
@apply flex relative flex-col;
}
figure svg,
.img-bg {
@apply w-64 h-64 md:w-80 md:h-80;
}
.img-bg {
@apply absolute z-[-1] rounded-full blur-[50px] transition-all;
animation: pulse 5s cubic-bezier(0, 0, 0, 0.5) infinite,
glow 5s linear infinite;
}
@keyframes glow {
0% {
@apply bg-primary-400/50;
}
33% {
@apply bg-secondary-400/50;
}
66% {
@apply bg-tertiary-400/50;
}
100% {
@apply bg-primary-400/50;
}
}
@keyframes pulse {
50% {
transform: scale(1.5);
}
} */
</style>
</div>