Initial scaffold for Aether Native V3 Electron Launcher

This commit is contained in:
Scott Idem
2026-01-23 13:54:20 -05:00
parent fdbd12b64f
commit 0497f5767b
44 changed files with 537 additions and 7294 deletions

69
dist/main/api_client.js vendored Normal file
View File

@@ -0,0 +1,69 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.fetchFullConfig = fetchFullConfig;
async function fetchFullConfig(seed) {
const apiUrls = [
seed.onsite_api_base_url,
seed.primary_api_base_url,
seed.backup_api_base_url
].filter(url => url !== null && url !== undefined);
let lastError = null;
for (const baseUrl of apiUrls) {
try {
console.log(`Bootstrap: Attempting connection to ${baseUrl}...`);
// --- STEP 1: Get Device Config ---
const deviceUrl = `${baseUrl}/v3/crud/event_device/${seed.event_device_id}`;
const deviceResponse = await fetch(deviceUrl, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'x-aether-api-key': seed.aether_api_key,
'x-no-account-id': 'Nothing to See Here'
},
});
if (!deviceResponse.ok) {
throw new Error(`Device lookup failed (${deviceResponse.status})`);
}
const deviceResult = await deviceResponse.json();
const deviceData = deviceResult.data || deviceResult;
// Use 'app_base_url' as the FQDN for the site lookup
const fqdn = deviceData.app_base_url || 'native-demo.oneskyit.com';
console.log(`Bootstrap Step 1 Success: Device identified. FQDN to use: ${fqdn}`);
// --- STEP 2: Get Site Context ---
const searchUrl = `${baseUrl}/v3/crud/site_domain/search`;
const siteResponse = await fetch(searchUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-aether-api-key': seed.aether_api_key,
'x-no-account-id': 'Nothing to See Here',
'x-account-id': deviceData.account_id_random || deviceData.account_id || ''
},
body: JSON.stringify({
search_query: {
and: [{ field: 'fqdn', op: 'eq', value: fqdn }]
},
limit: 1
})
});
if (!siteResponse.ok) {
throw new Error(`Site context lookup failed (${siteResponse.status})`);
}
const siteResult = await siteResponse.json();
const siteDomain = (siteResult.data && siteResult.data.length > 0) ? siteResult.data[0] : null;
console.log(`Bootstrap Success using ${baseUrl}`);
return {
...siteDomain,
native_device: deviceData
};
}
catch (error) {
console.warn(`Bootstrap failed for ${baseUrl}: `, error);
lastError = error;
continue; // Try next URL
}
}
console.error('Bootstrap Critical Failure: All API endpoints exhausted.', lastError);
return null;
}
//# sourceMappingURL=api_client.js.map