@ateam-ai-mobile/core 0.1.1 → 0.1.2
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.d.mts +42 -7
- package/dist/index.d.ts +42 -7
- package/dist/index.js +44 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +42 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/api/tenants.ts +59 -6
- package/src/config.ts +22 -0
- package/src/index.ts +3 -2
package/dist/index.mjs
CHANGED
|
@@ -26,6 +26,11 @@ function getVoiceApiUrl() {
|
|
|
26
26
|
if (!url) throw new Error("[adas] voiceUrl not configured");
|
|
27
27
|
return resolveUrl(url);
|
|
28
28
|
}
|
|
29
|
+
function getConsumerAuthApiUrl() {
|
|
30
|
+
const url = getConfig().consumerAuthUrl;
|
|
31
|
+
if (!url) throw new Error("[adas] consumerAuthUrl not configured \u2014 required for switchTenant()");
|
|
32
|
+
return resolveUrl(url);
|
|
33
|
+
}
|
|
29
34
|
function getTenant() {
|
|
30
35
|
const t = getConfig().tenant;
|
|
31
36
|
return (typeof t === "function" ? t() : t) || "";
|
|
@@ -165,12 +170,6 @@ function unwrapMcpResult(result) {
|
|
|
165
170
|
}
|
|
166
171
|
}
|
|
167
172
|
|
|
168
|
-
// src/api/tenants.ts
|
|
169
|
-
async function listMyTenants() {
|
|
170
|
-
const data = await apiFetch("/api/tenants/list");
|
|
171
|
-
return data.ok && Array.isArray(data.tenants) ? data.tenants : [];
|
|
172
|
-
}
|
|
173
|
-
|
|
174
173
|
// src/chat/store.ts
|
|
175
174
|
import { create } from "zustand";
|
|
176
175
|
|
|
@@ -905,6 +904,41 @@ async function pollJob(jobId, token) {
|
|
|
905
904
|
});
|
|
906
905
|
}
|
|
907
906
|
|
|
907
|
+
// src/api/tenants.ts
|
|
908
|
+
async function listMyTenants() {
|
|
909
|
+
const data = await apiFetch("/api/tenants/list");
|
|
910
|
+
return data.ok && Array.isArray(data.tenants) ? data.tenants : [];
|
|
911
|
+
}
|
|
912
|
+
async function switchTenant(targetTenantId) {
|
|
913
|
+
const token = getToken();
|
|
914
|
+
if (!token) throw new Error("[adas] switchTenant: not signed in");
|
|
915
|
+
const res = await fetch(`${getConsumerAuthApiUrl()}/platform/consumer/switch-tenant`, {
|
|
916
|
+
method: "POST",
|
|
917
|
+
headers: {
|
|
918
|
+
"Content-Type": "application/json",
|
|
919
|
+
Authorization: `Bearer ${token}`
|
|
920
|
+
},
|
|
921
|
+
body: JSON.stringify({ target_tenant: targetTenantId })
|
|
922
|
+
});
|
|
923
|
+
const data = await res.json().catch(() => null);
|
|
924
|
+
if (!res.ok || !data?.ok || !data.jwt) {
|
|
925
|
+
throw new Error(data?.error || `switchTenant failed (${res.status})`);
|
|
926
|
+
}
|
|
927
|
+
const session = {
|
|
928
|
+
jwt: data.jwt,
|
|
929
|
+
tenant: data.tenant,
|
|
930
|
+
actor: data.actor
|
|
931
|
+
};
|
|
932
|
+
const onSession = getConfig().onSession;
|
|
933
|
+
if (!onSession) {
|
|
934
|
+
throw new Error("[adas] switchTenant: config.onSession is required to persist the new session");
|
|
935
|
+
}
|
|
936
|
+
await onSession(session);
|
|
937
|
+
closeChatStream();
|
|
938
|
+
useChatStore.getState().clearChat();
|
|
939
|
+
return session;
|
|
940
|
+
}
|
|
941
|
+
|
|
908
942
|
// src/theme/tokens.ts
|
|
909
943
|
var colors = {
|
|
910
944
|
dark: {
|
|
@@ -1595,6 +1629,7 @@ export {
|
|
|
1595
1629
|
disconnectAcsWs,
|
|
1596
1630
|
fontSize,
|
|
1597
1631
|
getConfig,
|
|
1632
|
+
getConsumerAuthApiUrl,
|
|
1598
1633
|
getCoreApiUrl,
|
|
1599
1634
|
getCoreWsUrl,
|
|
1600
1635
|
getTenant,
|
|
@@ -1620,6 +1655,7 @@ export {
|
|
|
1620
1655
|
setHomeActionOrder,
|
|
1621
1656
|
setOrder,
|
|
1622
1657
|
spacing,
|
|
1658
|
+
switchTenant,
|
|
1623
1659
|
unwrapMcpResult,
|
|
1624
1660
|
useChatStore,
|
|
1625
1661
|
useHomeActionsStore,
|