Deploy AIOS web (React glide grid + FastAPI slice)
Browse files- RELEASES.json +1 -1
- VERSION +1 -1
- web/public/AIOS_DEPLOY_RECEIPT +1 -1
- web/src/connectors/ConnectorsPage.tsx +14 -8
RELEASES.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
{
|
| 2 |
-
"current": "
|
| 3 |
"releases": []
|
| 4 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"current": "c168877b9",
|
| 3 |
"releases": []
|
| 4 |
}
|
VERSION
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
c168877b9
|
web/public/AIOS_DEPLOY_RECEIPT
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
7bac5f0844d563f0f127222d5849a806f8b6f9b6be86900cf1eac64e84551fbb
|
web/src/connectors/ConnectorsPage.tsx
CHANGED
|
@@ -439,17 +439,21 @@ export function staleSyncWarnings(name: string, body: unknown): string[] {
|
|
| 439 |
|
| 440 |
/** The server's sentence when the provider refused the connector credential. */
|
| 441 |
export const CREDENTIAL_EXPIRED = "Credential expired. Reconnect to resume.";
|
|
|
|
|
|
|
| 442 |
|
| 443 |
/** The card line for a failed pass on a refused credential, PURE: none for any other state. */
|
| 444 |
export function credentialSyncWarnings(body: unknown): string[] {
|
| 445 |
if (!body || typeof body !== "object") return [];
|
| 446 |
const { state, detail } = body as { state?: unknown; detail?: unknown };
|
| 447 |
-
return state === "error" && typeof detail === "string"
|
|
|
|
| 448 |
? [CREDENTIAL_EXPIRED] : [];
|
| 449 |
}
|
| 450 |
|
| 451 |
-
/** One read of a daily source's sync route. A failed read is no warning, never a thrown error.
|
| 452 |
-
|
|
|
|
| 453 |
try {
|
| 454 |
const res = await fetch(`${API_V1}/connectors/${encodeURIComponent(connectorKey)}/sync`, {
|
| 455 |
credentials: CREDENTIALS, signal,
|
|
@@ -458,6 +462,7 @@ async function dailySyncWarnings(connectorKey: string, signal: AbortSignal): Pro
|
|
| 458 |
const body: unknown = await res.json().catch(() => null);
|
| 459 |
const credential = credentialSyncWarnings(body);
|
| 460 |
if (credential.length) return credential;
|
|
|
|
| 461 |
return staleSyncWarnings(DAILY_SOURCE_NAMES[connectorKey] ?? connectorKey, body);
|
| 462 |
} catch {
|
| 463 |
return [];
|
|
@@ -1090,17 +1095,18 @@ export default function ConnectorsPage({
|
|
| 1090 |
return () => controller.abort();
|
| 1091 |
}, [hasOdooCard]);
|
| 1092 |
const dailySourceKeys = load.phase === "ready"
|
| 1093 |
-
? load.rows.filter((row) => row.key in DAILY_SOURCE_NAMES
|
| 1094 |
-
.map((row) => row.key).join(",")
|
| 1095 |
: "";
|
| 1096 |
const [dailyWarnings, setDailyWarnings] = useState<Record<string, string[]>>({});
|
| 1097 |
useEffect(() => {
|
| 1098 |
if (!dailySourceKeys) return;
|
| 1099 |
const controller = new AbortController();
|
| 1100 |
-
const
|
| 1101 |
-
|
|
|
|
| 1102 |
if (!controller.signal.aborted) {
|
| 1103 |
-
setDailyWarnings(Object.fromEntries(
|
| 1104 |
}
|
| 1105 |
});
|
| 1106 |
return () => controller.abort();
|
|
|
|
| 439 |
|
| 440 |
/** The server's sentence when the provider refused the connector credential. */
|
| 441 |
export const CREDENTIAL_EXPIRED = "Credential expired. Reconnect to resume.";
|
| 442 |
+
/** The sentence a pass stored before this one: the card reads it the same way until the next pass. */
|
| 443 |
+
const CREDENTIAL_REFUSED_BEFORE = "The provider refused the connector credential";
|
| 444 |
|
| 445 |
/** The card line for a failed pass on a refused credential, PURE: none for any other state. */
|
| 446 |
export function credentialSyncWarnings(body: unknown): string[] {
|
| 447 |
if (!body || typeof body !== "object") return [];
|
| 448 |
const { state, detail } = body as { state?: unknown; detail?: unknown };
|
| 449 |
+
return state === "error" && typeof detail === "string"
|
| 450 |
+
&& (detail.startsWith(CREDENTIAL_EXPIRED) || detail.startsWith(CREDENTIAL_REFUSED_BEFORE))
|
| 451 |
? [CREDENTIAL_EXPIRED] : [];
|
| 452 |
}
|
| 453 |
|
| 454 |
+
/** One read of a daily source's sync route. A failed read is no warning, never a thrown error.
|
| 455 |
+
* A card the directory does not count as connected shows only a refused credential: its pass still runs. */
|
| 456 |
+
async function dailySyncWarnings(connectorKey: string, signal: AbortSignal, connected = true): Promise<string[]> {
|
| 457 |
try {
|
| 458 |
const res = await fetch(`${API_V1}/connectors/${encodeURIComponent(connectorKey)}/sync`, {
|
| 459 |
credentials: CREDENTIALS, signal,
|
|
|
|
| 462 |
const body: unknown = await res.json().catch(() => null);
|
| 463 |
const credential = credentialSyncWarnings(body);
|
| 464 |
if (credential.length) return credential;
|
| 465 |
+
if (!connected) return [];
|
| 466 |
return staleSyncWarnings(DAILY_SOURCE_NAMES[connectorKey] ?? connectorKey, body);
|
| 467 |
} catch {
|
| 468 |
return [];
|
|
|
|
| 1095 |
return () => controller.abort();
|
| 1096 |
}, [hasOdooCard]);
|
| 1097 |
const dailySourceKeys = load.phase === "ready"
|
| 1098 |
+
? load.rows.filter((row) => row.key in DAILY_SOURCE_NAMES)
|
| 1099 |
+
.map((row) => `${row.key}:${row.state === "connected" ? 1 : 0}`).join(",")
|
| 1100 |
: "";
|
| 1101 |
const [dailyWarnings, setDailyWarnings] = useState<Record<string, string[]>>({});
|
| 1102 |
useEffect(() => {
|
| 1103 |
if (!dailySourceKeys) return;
|
| 1104 |
const controller = new AbortController();
|
| 1105 |
+
const entries = dailySourceKeys.split(",").map((entry) => entry.split(":"));
|
| 1106 |
+
const reads = entries.map(([key, connected]) => dailySyncWarnings(key, controller.signal, connected === "1"));
|
| 1107 |
+
void Promise.all(reads).then((lines) => {
|
| 1108 |
if (!controller.signal.aborted) {
|
| 1109 |
+
setDailyWarnings(Object.fromEntries(entries.map(([key], index) => [key, lines[index]])));
|
| 1110 |
}
|
| 1111 |
});
|
| 1112 |
return () => controller.abort();
|