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/customer-grid/CatalogView.tsx +12 -5
- web/src/customer-grid/editOutbox.ts +41 -5
RELEASES.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
{
|
| 2 |
-
"current": "
|
| 3 |
"releases": []
|
| 4 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"current": "42e88f502fb9",
|
| 3 |
"releases": []
|
| 4 |
}
|
VERSION
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
42e88f502fb9
|
web/public/AIOS_DEPLOY_RECEIPT
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
66b8119943b7bae02917b2d637b5a82838e0c5291c97ac34a62367ff37ac7239
|
web/src/customer-grid/CatalogView.tsx
CHANGED
|
@@ -194,6 +194,7 @@ function applicationImageUrl(value: string, quality: CatalogQuality = "web"): st
|
|
| 194 |
export function catalogApplicationItems(
|
| 195 |
rows: Row[],
|
| 196 |
fieldMap: CatalogApplicationDefinition["fieldMap"],
|
|
|
|
| 197 |
): CatalogApplicationItem[] {
|
| 198 |
const items: CatalogApplicationItem[] = [];
|
| 199 |
for (const row of rows) {
|
|
@@ -203,7 +204,9 @@ export function catalogApplicationItems(
|
|
| 203 |
const image = fieldMap.image ? String(row[fieldMap.image] ?? "").trim() : "";
|
| 204 |
const mapped = (role: "sku" | "price" | "category" | "description") => {
|
| 205 |
const field = fieldMap[role];
|
| 206 |
-
|
|
|
|
|
|
|
| 207 |
};
|
| 208 |
items.push({ pid: row.pid, key, title, image, sku: mapped("sku"), price: mapped("price"),
|
| 209 |
category: mapped("category"), description: mapped("description") });
|
|
@@ -257,6 +260,7 @@ export const CatalogApplicationView = memo(function CatalogApplicationView({
|
|
| 257 |
key={definition.id}
|
| 258 |
definition={definition}
|
| 259 |
canEdit={editor.canEdit}
|
|
|
|
| 260 |
rows={!rowsPending && "poolRows" in editor ? editor.poolRows : NO_ROWS}
|
| 261 |
rowsPending={rowsPending}
|
| 262 |
onOpen={onOpen}
|
|
@@ -331,10 +335,11 @@ function catalogHashId(next?: string | null): string | null {
|
|
| 331 |
}
|
| 332 |
|
| 333 |
/** Child content for the shared AppFrame. Only the editor owns Back to library. */
|
| 334 |
-
export function CatalogLibrary({ definition, canEdit, rows, rowsPending, onOpen }: {
|
| 335 |
definition: CatalogApplicationDefinition;
|
| 336 |
canEdit: boolean;
|
| 337 |
rows: Row[];
|
|
|
|
| 338 |
rowsPending?: CatalogRowsPending;
|
| 339 |
onOpen: (pid: number, row?: Row) => void;
|
| 340 |
}) {
|
|
@@ -424,7 +429,7 @@ export function CatalogLibrary({ definition, canEdit, rows, rowsPending, onOpen
|
|
| 424 |
};
|
| 425 |
|
| 426 |
if (openId) return <CatalogRecordOpener key={openId} appId={definition.id} id={openId}
|
| 427 |
-
definition={definition} canEdit={canEdit} rows={rows} rowsPending={rowsPending} onOpen={onOpen}
|
| 428 |
onBack={() => { setOpenId(null); catalogHashId(null); }} onSaved={replace} />;
|
| 429 |
|
| 430 |
const actionTitle = action?.kind === "create" ? "New catalog" : action?.kind === "rename" ? "Rename catalog" :
|
|
@@ -498,6 +503,7 @@ export function CatalogLibrary({ definition, canEdit, rows, rowsPending, onOpen
|
|
| 498 |
|
| 499 |
function CatalogRecordOpener({ appId, id, rowsPending, ...props }: {
|
| 500 |
appId: string; id: string; definition: CatalogApplicationDefinition; canEdit: boolean; rows: Row[];
|
|
|
|
| 501 |
rowsPending?: CatalogRowsPending;
|
| 502 |
onOpen: (pid: number, row?: Row) => void; onBack: () => void; onSaved: (catalog: CatalogRecord) => void;
|
| 503 |
}) {
|
|
@@ -525,8 +531,9 @@ function CatalogRecordOpener({ appId, id, rowsPending, ...props }: {
|
|
| 525 |
}
|
| 526 |
|
| 527 |
/** Keep the C1 draft intact until its serialized save succeeds. */
|
| 528 |
-
export function CatalogRecordEditor({ record, definition, canEdit, rows, onOpen, onBack, onSaved }: {
|
| 529 |
record: CatalogRecord; definition: CatalogApplicationDefinition; canEdit: boolean; rows: Row[];
|
|
|
|
| 530 |
onOpen: (pid: number, row?: Row) => void; onBack: () => void; onSaved: (catalog: CatalogRecord) => void;
|
| 531 |
}) {
|
| 532 |
const [draft, setDraft] = useState(record);
|
|
@@ -599,7 +606,7 @@ export function CatalogRecordEditor({ record, definition, canEdit, rows, onOpen,
|
|
| 599 |
return () => { cancelled = true; remove?.(); };
|
| 600 |
}, [printing]);
|
| 601 |
const page = draft.pages.find((candidate) => candidate.id === pageId);
|
| 602 |
-
const items = catalogApplicationItems(productRows, definition.fieldMap);
|
| 603 |
const kindTemplates = registry.find((entry) => entry.kind === normalizeCatalogKind(page?.kind ?? ""));
|
| 604 |
const template = kindTemplates?.templates.find((entry) => entry.id === page?.template);
|
| 605 |
const changePages = (pages: CatalogRecordPage[]) => {
|
|
|
|
| 194 |
export function catalogApplicationItems(
|
| 195 |
rows: Row[],
|
| 196 |
fieldMap: CatalogApplicationDefinition["fieldMap"],
|
| 197 |
+
priceField?: Field,
|
| 198 |
): CatalogApplicationItem[] {
|
| 199 |
const items: CatalogApplicationItem[] = [];
|
| 200 |
for (const row of rows) {
|
|
|
|
| 204 |
const image = fieldMap.image ? String(row[fieldMap.image] ?? "").trim() : "";
|
| 205 |
const mapped = (role: "sku" | "price" | "category" | "description") => {
|
| 206 |
const field = fieldMap[role];
|
| 207 |
+
if (!field || row[field] == null) return undefined;
|
| 208 |
+
return role === "price" && priceField?.key === field
|
| 209 |
+
? formatDisplay(priceField, row[field]) : String(row[field]);
|
| 210 |
};
|
| 211 |
items.push({ pid: row.pid, key, title, image, sku: mapped("sku"), price: mapped("price"),
|
| 212 |
category: mapped("category"), description: mapped("description") });
|
|
|
|
| 260 |
key={definition.id}
|
| 261 |
definition={definition}
|
| 262 |
canEdit={editor.canEdit}
|
| 263 |
+
priceField={"fieldByKey" in editor ? editor.fieldByKey.get(definition.fieldMap.price ?? "") : undefined}
|
| 264 |
rows={!rowsPending && "poolRows" in editor ? editor.poolRows : NO_ROWS}
|
| 265 |
rowsPending={rowsPending}
|
| 266 |
onOpen={onOpen}
|
|
|
|
| 335 |
}
|
| 336 |
|
| 337 |
/** Child content for the shared AppFrame. Only the editor owns Back to library. */
|
| 338 |
+
export function CatalogLibrary({ definition, canEdit, rows, priceField, rowsPending, onOpen }: {
|
| 339 |
definition: CatalogApplicationDefinition;
|
| 340 |
canEdit: boolean;
|
| 341 |
rows: Row[];
|
| 342 |
+
priceField?: Field;
|
| 343 |
rowsPending?: CatalogRowsPending;
|
| 344 |
onOpen: (pid: number, row?: Row) => void;
|
| 345 |
}) {
|
|
|
|
| 429 |
};
|
| 430 |
|
| 431 |
if (openId) return <CatalogRecordOpener key={openId} appId={definition.id} id={openId}
|
| 432 |
+
definition={definition} canEdit={canEdit} rows={rows} priceField={priceField} rowsPending={rowsPending} onOpen={onOpen}
|
| 433 |
onBack={() => { setOpenId(null); catalogHashId(null); }} onSaved={replace} />;
|
| 434 |
|
| 435 |
const actionTitle = action?.kind === "create" ? "New catalog" : action?.kind === "rename" ? "Rename catalog" :
|
|
|
|
| 503 |
|
| 504 |
function CatalogRecordOpener({ appId, id, rowsPending, ...props }: {
|
| 505 |
appId: string; id: string; definition: CatalogApplicationDefinition; canEdit: boolean; rows: Row[];
|
| 506 |
+
priceField?: Field;
|
| 507 |
rowsPending?: CatalogRowsPending;
|
| 508 |
onOpen: (pid: number, row?: Row) => void; onBack: () => void; onSaved: (catalog: CatalogRecord) => void;
|
| 509 |
}) {
|
|
|
|
| 531 |
}
|
| 532 |
|
| 533 |
/** Keep the C1 draft intact until its serialized save succeeds. */
|
| 534 |
+
export function CatalogRecordEditor({ record, definition, canEdit, rows, priceField, onOpen, onBack, onSaved }: {
|
| 535 |
record: CatalogRecord; definition: CatalogApplicationDefinition; canEdit: boolean; rows: Row[];
|
| 536 |
+
priceField?: Field;
|
| 537 |
onOpen: (pid: number, row?: Row) => void; onBack: () => void; onSaved: (catalog: CatalogRecord) => void;
|
| 538 |
}) {
|
| 539 |
const [draft, setDraft] = useState(record);
|
|
|
|
| 606 |
return () => { cancelled = true; remove?.(); };
|
| 607 |
}, [printing]);
|
| 608 |
const page = draft.pages.find((candidate) => candidate.id === pageId);
|
| 609 |
+
const items = catalogApplicationItems(productRows, definition.fieldMap, priceField);
|
| 610 |
const kindTemplates = registry.find((entry) => entry.kind === normalizeCatalogKind(page?.kind ?? ""));
|
| 611 |
const template = kindTemplates?.templates.find((entry) => entry.id === page?.template);
|
| 612 |
const changePages = (pages: CatalogRecordPage[]) => {
|
web/src/customer-grid/editOutbox.ts
CHANGED
|
@@ -71,6 +71,25 @@ export const OUTBOX_MAX_RETRY_MS = 30_000;
|
|
| 71 |
const sameOwner = (a: OutboxIdentity | null, b: OutboxIdentity | null) =>
|
| 72 |
!!a && !!b && a.tenant === b.tenant && a.principal === b.principal;
|
| 73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
/** Resolve writes at transaction completion, because request success can still abort. */
|
| 75 |
export function indexedDBOutbox(database = "aios-edit-outbox"): OutboxStore {
|
| 76 |
let opening: Promise<IDBDatabase> | undefined;
|
|
@@ -238,7 +257,7 @@ export function createEditOutbox(options: {
|
|
| 238 |
publish();
|
| 239 |
notifyReceipt(attemptedEdit, receipt);
|
| 240 |
entry.attempted?.(receipt);
|
| 241 |
-
retry();
|
| 242 |
entry.settle?.(false);
|
| 243 |
entry.settle = undefined;
|
| 244 |
publish();
|
|
@@ -306,6 +325,23 @@ export function createEditOutbox(options: {
|
|
| 306 |
serial = task.then(() => undefined);
|
| 307 |
return task;
|
| 308 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 309 |
async function flush(): Promise<void> {
|
| 310 |
if (running || preparingRetry || timer !== undefined) return;
|
| 311 |
running = true;
|
|
@@ -316,10 +352,9 @@ export function createEditOutbox(options: {
|
|
| 316 |
if (!await start()) throw new Error(message ?? "The session could not be confirmed. Sign in again to save.");
|
| 317 |
if (!await persistAll()) { retry(); return; }
|
| 318 |
while (entries.length && generation === epoch) {
|
| 319 |
-
const entry =
|
|
|
|
| 320 |
try {
|
| 321 |
-
// A stored refusal is terminal for this id until the user explicitly retries.
|
| 322 |
-
if (entry.failure?.confirmedRefusal) return;
|
| 323 |
if (!entry.stored && !await persistAll()) return;
|
| 324 |
if (generation !== epoch) return;
|
| 325 |
attempting = entry;
|
|
@@ -337,13 +372,14 @@ export function createEditOutbox(options: {
|
|
| 337 |
retryPayload: receipt.id === entry.edit.id ? receipt.retryPayload : undefined,
|
| 338 |
result: receipt.id === entry.edit.id ? receipt.result : undefined,
|
| 339 |
cellFailures: receipt.id === entry.edit.id ? receipt.cellFailures : undefined });
|
|
|
|
| 340 |
retry();
|
| 341 |
return;
|
| 342 |
}
|
| 343 |
// C1: only the matching server acknowledgement permits deletion.
|
| 344 |
await store.remove(entry.stored!);
|
| 345 |
if (generation !== epoch) return;
|
| 346 |
-
entries.
|
| 347 |
attempting = undefined;
|
| 348 |
failures = 0;
|
| 349 |
message = undefined;
|
|
|
|
| 71 |
const sameOwner = (a: OutboxIdentity | null, b: OutboxIdentity | null) =>
|
| 72 |
!!a && !!b && a.tenant === b.tenant && a.principal === b.principal;
|
| 73 |
|
| 74 |
+
/** Only row patches and cell events prove independence within a scope. */
|
| 75 |
+
function recordId(edit: OutboxEdit): number | undefined {
|
| 76 |
+
const payload = edit.payload as { type?: unknown; pid?: unknown; updates?: unknown } | null;
|
| 77 |
+
if ((edit.kind === "row" || (edit.kind === "event" && payload?.type === "overlay_patch"))
|
| 78 |
+
&& typeof payload?.pid === "number" && Number.isSafeInteger(payload.pid)
|
| 79 |
+
&& payload.updates && typeof payload.updates === "object" && !Array.isArray(payload.updates))
|
| 80 |
+
return payload.pid;
|
| 81 |
+
return undefined;
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
function dependentEdits(earlier: OutboxEdit, later: OutboxEdit): boolean {
|
| 85 |
+
// Cohort and Customer edit the same records and workspace.
|
| 86 |
+
const scope = (edit: OutboxEdit) => edit.scope === "cohort" ? "customer" : edit.scope;
|
| 87 |
+
if (scope(earlier) !== scope(later)) return false;
|
| 88 |
+
const previous = recordId(earlier), next = recordId(later);
|
| 89 |
+
// Unknown transports and structural edits hold their entire document or scope.
|
| 90 |
+
return previous === undefined || next === undefined || previous === next;
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
/** Resolve writes at transaction completion, because request success can still abort. */
|
| 94 |
export function indexedDBOutbox(database = "aios-edit-outbox"): OutboxStore {
|
| 95 |
let opening: Promise<IDBDatabase> | undefined;
|
|
|
|
| 257 |
publish();
|
| 258 |
notifyReceipt(attemptedEdit, receipt);
|
| 259 |
entry.attempted?.(receipt);
|
| 260 |
+
if (!entry.failure.confirmedRefusal) retry();
|
| 261 |
entry.settle?.(false);
|
| 262 |
entry.settle = undefined;
|
| 263 |
publish();
|
|
|
|
| 325 |
serial = task.then(() => undefined);
|
| 326 |
return task;
|
| 327 |
};
|
| 328 |
+
const nextEntry = (): PendingEdit | undefined => {
|
| 329 |
+
const held: OutboxEdit[] = [];
|
| 330 |
+
for (const candidate of entries) {
|
| 331 |
+
if (candidate.failure?.confirmedRefusal) {
|
| 332 |
+
held.push(candidate.edit);
|
| 333 |
+
continue;
|
| 334 |
+
}
|
| 335 |
+
if (held.some((edit) => dependentEdits(edit, candidate.edit))) {
|
| 336 |
+
// An uncertain outcome remains a barrier even behind a held dependency.
|
| 337 |
+
if (candidate.failure) return undefined;
|
| 338 |
+
held.push(candidate.edit);
|
| 339 |
+
continue;
|
| 340 |
+
}
|
| 341 |
+
return candidate;
|
| 342 |
+
}
|
| 343 |
+
return undefined;
|
| 344 |
+
};
|
| 345 |
async function flush(): Promise<void> {
|
| 346 |
if (running || preparingRetry || timer !== undefined) return;
|
| 347 |
running = true;
|
|
|
|
| 352 |
if (!await start()) throw new Error(message ?? "The session could not be confirmed. Sign in again to save.");
|
| 353 |
if (!await persistAll()) { retry(); return; }
|
| 354 |
while (entries.length && generation === epoch) {
|
| 355 |
+
const entry = nextEntry();
|
| 356 |
+
if (!entry) return;
|
| 357 |
try {
|
|
|
|
|
|
|
| 358 |
if (!entry.stored && !await persistAll()) return;
|
| 359 |
if (generation !== epoch) return;
|
| 360 |
attempting = entry;
|
|
|
|
| 372 |
retryPayload: receipt.id === entry.edit.id ? receipt.retryPayload : undefined,
|
| 373 |
result: receipt.id === entry.edit.id ? receipt.result : undefined,
|
| 374 |
cellFailures: receipt.id === entry.edit.id ? receipt.cellFailures : undefined });
|
| 375 |
+
if (entry.failure?.confirmedRefusal) continue;
|
| 376 |
retry();
|
| 377 |
return;
|
| 378 |
}
|
| 379 |
// C1: only the matching server acknowledgement permits deletion.
|
| 380 |
await store.remove(entry.stored!);
|
| 381 |
if (generation !== epoch) return;
|
| 382 |
+
entries.splice(entries.indexOf(entry), 1);
|
| 383 |
attempting = undefined;
|
| 384 |
failures = 0;
|
| 385 |
message = undefined;
|