Deploy AIOS web (React glide grid + FastAPI slice)
Browse files- RELEASES.json +1 -1
- VERSION +1 -1
- api/application_registry.py +81 -4
- web/public/AIOS_DEPLOY_RECEIPT +1 -1
RELEASES.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
{
|
| 2 |
-
"current": "
|
| 3 |
"releases": []
|
| 4 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"current": "a19b7e5a30",
|
| 3 |
"releases": []
|
| 4 |
}
|
VERSION
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
a19b7e5a30
|
api/application_registry.py
CHANGED
|
@@ -279,14 +279,16 @@ def _refuse_template_held(applications, identity):
|
|
| 279 |
|
| 280 |
|
| 281 |
def own_template_apps(runtime, user, is_admin=False):
|
| 282 |
-
"""Return every
|
|
|
|
|
|
|
|
|
|
| 283 |
owned = {}
|
| 284 |
apps = sorted((app for app in load(runtime)["applications"].values() if isinstance(app, dict)),
|
| 285 |
key=lambda app: (str(app.get("createdAt") or ""), str(app.get("id") or "")))
|
| 286 |
for app in apps:
|
| 287 |
identity = template_identity(app)
|
| 288 |
-
if
|
| 289 |
-
and app.get("retired") is not True):
|
| 290 |
owned.setdefault(identity, []).append(
|
| 291 |
{"id": app.get("id"), "name": app.get("name"),
|
| 292 |
"deepLink": app.get("deepLink"), "sourceDatabase": app.get("sourceDatabase")})
|
|
@@ -1625,18 +1627,23 @@ def migrate_returns_split(runtime, tenant):
|
|
| 1625 |
def ensure_route_application(runtime, tenant, *, accounts=None, wall=None):
|
| 1626 |
"""R15: boot migrations, once per tenant, never from an Application read.
|
| 1627 |
|
| 1628 |
-
Runs the Routing seed migration,
|
|
|
|
| 1629 |
"""
|
| 1630 |
result = _ensure_route_seed(runtime, tenant)
|
| 1631 |
copies = ensure_user_app_copies(runtime, tenant, accounts=accounts, wall=wall)
|
| 1632 |
bindings = migrate_c1_bindings(runtime, tenant)
|
|
|
|
| 1633 |
folded = dict(result)
|
| 1634 |
folded["userCopies"] = copies
|
| 1635 |
folded["c1Bindings"] = bindings
|
|
|
|
| 1636 |
note = "user copies " + copies["outcome"] + (
|
| 1637 |
": " + copies["reason"] if copies.get("reason") else "")
|
| 1638 |
note += "; C1 bindings " + bindings["outcome"] + (
|
| 1639 |
": " + bindings["reason"] if bindings.get("reason") else "")
|
|
|
|
|
|
|
| 1640 |
folded["reason"] = result["reason"] + "; " + note if result.get("reason") else note
|
| 1641 |
return folded
|
| 1642 |
|
|
@@ -1819,6 +1826,76 @@ def migrate_c1_bindings(runtime, tenant, *, app_ids=None):
|
|
| 1819 |
return result
|
| 1820 |
|
| 1821 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1822 |
_COPIES = "userAppCopies"
|
| 1823 |
_APP_INDEX_KEY = "module_index_app"
|
| 1824 |
|
|
|
|
| 279 |
|
| 280 |
|
| 281 |
def own_template_apps(runtime, user, is_admin=False):
|
| 282 |
+
"""Return every template copy the App home lists for the caller, grouped by template identity.
|
| 283 |
+
|
| 284 |
+
`is_admin` stays for the callers and is unused: the gallery's Added and the App home share `_listed`.
|
| 285 |
+
"""
|
| 286 |
owned = {}
|
| 287 |
apps = sorted((app for app in load(runtime)["applications"].values() if isinstance(app, dict)),
|
| 288 |
key=lambda app: (str(app.get("createdAt") or ""), str(app.get("id") or "")))
|
| 289 |
for app in apps:
|
| 290 |
identity = template_identity(app)
|
| 291 |
+
if identity and _listed(app, user):
|
|
|
|
| 292 |
owned.setdefault(identity, []).append(
|
| 293 |
{"id": app.get("id"), "name": app.get("name"),
|
| 294 |
"deepLink": app.get("deepLink"), "sourceDatabase": app.get("sourceDatabase")})
|
|
|
|
| 1627 |
def ensure_route_application(runtime, tenant, *, accounts=None, wall=None):
|
| 1628 |
"""R15: boot migrations, once per tenant, never from an Application read.
|
| 1629 |
|
| 1630 |
+
Runs the Routing seed migration, `ensure_user_app_copies`, `migrate_c1_bindings` and
|
| 1631 |
+
`migrate_template_shares`, and folds them into one dict.
|
| 1632 |
"""
|
| 1633 |
result = _ensure_route_seed(runtime, tenant)
|
| 1634 |
copies = ensure_user_app_copies(runtime, tenant, accounts=accounts, wall=wall)
|
| 1635 |
bindings = migrate_c1_bindings(runtime, tenant)
|
| 1636 |
+
shares = migrate_template_shares(runtime, tenant)
|
| 1637 |
folded = dict(result)
|
| 1638 |
folded["userCopies"] = copies
|
| 1639 |
folded["c1Bindings"] = bindings
|
| 1640 |
+
folded["templateShares"] = shares
|
| 1641 |
note = "user copies " + copies["outcome"] + (
|
| 1642 |
": " + copies["reason"] if copies.get("reason") else "")
|
| 1643 |
note += "; C1 bindings " + bindings["outcome"] + (
|
| 1644 |
": " + bindings["reason"] if bindings.get("reason") else "")
|
| 1645 |
+
note += "; template shares " + shares["outcome"] + (
|
| 1646 |
+
": " + shares["reason"] if shares.get("reason") else "")
|
| 1647 |
folded["reason"] = result["reason"] + "; " + note if result.get("reason") else note
|
| 1648 |
return folded
|
| 1649 |
|
|
|
|
| 1826 |
return result
|
| 1827 |
|
| 1828 |
|
| 1829 |
+
#: Marker of the template share migration: the copy each shareless template identity now shares.
|
| 1830 |
+
TEMPLATE_SHARES_MARKER = "templateShares"
|
| 1831 |
+
|
| 1832 |
+
|
| 1833 |
+
def _template_share_plan(documents):
|
| 1834 |
+
"""`{document key: {app id: identity}}`: the oldest live copy of each identity no live copy shares."""
|
| 1835 |
+
groups = {}
|
| 1836 |
+
for key, doc in documents.items():
|
| 1837 |
+
for app_id, app in doc["applications"].items():
|
| 1838 |
+
if not isinstance(app, dict) or app.get("retired") is True:
|
| 1839 |
+
continue
|
| 1840 |
+
identity = template_identity(app)
|
| 1841 |
+
# Routing stays one private copy per account by design (`ensure_user_app_copies`).
|
| 1842 |
+
if identity and identity != "route":
|
| 1843 |
+
groups.setdefault(identity, []).append((key, app_id, app))
|
| 1844 |
+
plan = {}
|
| 1845 |
+
for identity, copies in sorted(groups.items()):
|
| 1846 |
+
if any((app.get("share") if isinstance(app.get("share"), dict) else {}).get("mode") == "tenant"
|
| 1847 |
+
for _key, _app_id, app in copies):
|
| 1848 |
+
continue
|
| 1849 |
+
key, app_id, _app = min(copies, key=lambda row: (str(row[2].get("createdAt") or ""),
|
| 1850 |
+
str(row[2].get("id") or "")))
|
| 1851 |
+
plan.setdefault(key, {})[app_id] = identity
|
| 1852 |
+
return plan
|
| 1853 |
+
|
| 1854 |
+
|
| 1855 |
+
def migrate_template_shares(runtime, tenant):
|
| 1856 |
+
"""Share with the tenant the oldest live copy of each template identity that no live copy shares.
|
| 1857 |
+
|
| 1858 |
+
Writes only a document that holds a copy to share, so a second run writes nothing.
|
| 1859 |
+
"""
|
| 1860 |
+
try:
|
| 1861 |
+
documents = {_KEY: _clean_doc(_read_strict(runtime, _KEY))}
|
| 1862 |
+
documents.update(_record_documents(runtime))
|
| 1863 |
+
except Exception as exc:
|
| 1864 |
+
return {"outcome": "skipped", "shared": [],
|
| 1865 |
+
"reason": f"registry read failed: {type(exc).__name__}: {exc}"}
|
| 1866 |
+
plan = _template_share_plan(documents)
|
| 1867 |
+
shared = []
|
| 1868 |
+
for key in sorted(plan, key=lambda name: (name != _KEY, name)):
|
| 1869 |
+
flips, landed = plan[key], []
|
| 1870 |
+
|
| 1871 |
+
def apply(raw, flips=flips, landed=landed):
|
| 1872 |
+
landed.clear()
|
| 1873 |
+
current = _clean_doc(raw)
|
| 1874 |
+
for app_id, identity in sorted(flips.items()):
|
| 1875 |
+
app = current["applications"].get(app_id)
|
| 1876 |
+
if not isinstance(app, dict) or app.get("retired") is True:
|
| 1877 |
+
continue
|
| 1878 |
+
share = app.get("share") if isinstance(app.get("share"), dict) else {}
|
| 1879 |
+
if share.get("mode") == "tenant":
|
| 1880 |
+
continue
|
| 1881 |
+
app["share"] = {"mode": "tenant", "users": []}
|
| 1882 |
+
landed.append((identity, app_id))
|
| 1883 |
+
if not landed:
|
| 1884 |
+
return raw
|
| 1885 |
+
migrations = current.setdefault("migrations", {})
|
| 1886 |
+
marker = migrations.get(TEMPLATE_SHARES_MARKER)
|
| 1887 |
+
marker = copy.deepcopy(marker) if isinstance(marker, dict) else {}
|
| 1888 |
+
marker["shared"] = {**(marker.get("shared") if isinstance(marker.get("shared"), dict) else {}),
|
| 1889 |
+
**dict(landed)}
|
| 1890 |
+
marker["at"] = write_execution.utcnow().isoformat()
|
| 1891 |
+
migrations[TEMPLATE_SHARES_MARKER] = marker
|
| 1892 |
+
return current
|
| 1893 |
+
_update_document(runtime, apply, key=key)
|
| 1894 |
+
shared.extend(app_id for _identity, app_id in landed)
|
| 1895 |
+
return {"outcome": "migrated" if shared else "unchanged", "shared": shared,
|
| 1896 |
+
"reason": ", ".join(shared)}
|
| 1897 |
+
|
| 1898 |
+
|
| 1899 |
_COPIES = "userAppCopies"
|
| 1900 |
_APP_INDEX_KEY = "module_index_app"
|
| 1901 |
|
web/public/AIOS_DEPLOY_RECEIPT
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
8d7b9cbc4dc0ef0302079d3e2f1378b07d9be1d92d23863ceb18457e4348c926
|