@ateam-ai-mobile/core 0.1.30 → 0.1.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -2054,6 +2054,24 @@ async function pollJob(jobId, token) {
2054
2054
  }
2055
2055
 
2056
2056
  // src/api/tenants.ts
2057
+ function nestByMaster(tenants) {
2058
+ const ids = new Set(tenants.map((t) => t.id));
2059
+ const hasMaster = (t) => !!t.master && t.master !== t.id && ids.has(t.master);
2060
+ const kids = /* @__PURE__ */ new Map();
2061
+ for (const t of tenants) if (hasMaster(t)) kids.set(t.master, [...kids.get(t.master) || [], t]);
2062
+ const rows = [];
2063
+ const seen = /* @__PURE__ */ new Set();
2064
+ const add = (t, depth, last) => {
2065
+ if (seen.has(t.id)) return;
2066
+ seen.add(t.id);
2067
+ const k = kids.get(t.id) || [];
2068
+ rows.push({ tenant: t, depth, last, memberCount: k.length });
2069
+ k.forEach((m, i) => add(m, 1, i === k.length - 1));
2070
+ };
2071
+ for (const t of tenants) if (!hasMaster(t)) add(t, 0, false);
2072
+ for (const t of tenants) add(t, 0, false);
2073
+ return rows;
2074
+ }
2057
2075
  async function listMyTenants() {
2058
2076
  const token = getToken();
2059
2077
  if (!token) return [];
@@ -2068,7 +2086,8 @@ async function listMyTenants() {
2068
2086
  // Fall back to the id rather than to an empty string: a nameless row in
2069
2087
  // a team switcher is unpickable.
2070
2088
  name: t.name || t.id,
2071
- role: t.role ?? null
2089
+ role: t.role ?? null,
2090
+ ...typeof t.master === "string" && t.master ? { master: t.master } : {}
2072
2091
  }));
2073
2092
  } catch {
2074
2093
  return [];
@@ -2251,6 +2270,7 @@ export {
2251
2270
  listSurface,
2252
2271
  mcpFetch,
2253
2272
  mcpToolCall,
2273
+ nestByMaster,
2254
2274
  notifyAcsWsForeground,
2255
2275
  notifyAppForeground,
2256
2276
  onAppForeground,