@layers/amba-react-native 4.0.4 → 4.0.5
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.cjs +24 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +65 -16
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +65 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -831,6 +831,18 @@ const notifications = {
|
|
|
831
831
|
//#region src/realtime.ts
|
|
832
832
|
const INITIAL_BACKOFF_MS = 500;
|
|
833
833
|
const MAX_BACKOFF_MS = 15e3;
|
|
834
|
+
const DEFAULT_API_URL = "https://api.amba.dev";
|
|
835
|
+
const DEFAULT_REALTIME_URL = "https://realtime.amba.host";
|
|
836
|
+
/**
|
|
837
|
+
* Resolve the base URL for live-update connections. Long-lived streams are
|
|
838
|
+
* served from a dedicated realtime host (no request-duration ceiling), so
|
|
839
|
+
* when the SDK points at the default production API the stream connects
|
|
840
|
+
* there instead. Any custom `apiUrl` (dev, staging, self-hosted, proxy)
|
|
841
|
+
* keeps live updates on that same origin — override semantics unchanged.
|
|
842
|
+
*/
|
|
843
|
+
function resolveRealtimeBaseUrl(baseUrl) {
|
|
844
|
+
return baseUrl.replace(/\/+$/, "") === DEFAULT_API_URL ? DEFAULT_REALTIME_URL : baseUrl;
|
|
845
|
+
}
|
|
834
846
|
/**
|
|
835
847
|
* Builder returned by `Amba.collection(name)`. Chain `.where(...)` to
|
|
836
848
|
* narrow, then `.subscribe(cb)` to start streaming.
|
|
@@ -854,7 +866,7 @@ var CollectionSubscription = class {
|
|
|
854
866
|
if (!this.ctx.authHeaders()) throw new Error("Amba.collection().subscribe() requires an authenticated session — call Amba.auth.signIn* first.");
|
|
855
867
|
const qs = Object.keys(this.filters).length > 0 ? `?where=${encodeURIComponent(JSON.stringify(this.filters))}` : "";
|
|
856
868
|
return openStream({
|
|
857
|
-
url: `${this.ctx.baseUrl}/v1/client/realtime/collections/${encodeURIComponent(this.name)}${qs}`,
|
|
869
|
+
url: `${resolveRealtimeBaseUrl(this.ctx.baseUrl)}/v1/client/realtime/collections/${encodeURIComponent(this.name)}${qs}`,
|
|
858
870
|
authHeaders: this.ctx.authHeaders,
|
|
859
871
|
onChange: cb,
|
|
860
872
|
options,
|
|
@@ -878,7 +890,7 @@ var ConversationSubscription = class {
|
|
|
878
890
|
subscribe(cb, options = {}) {
|
|
879
891
|
if (!this.ctx.authHeaders()) throw new Error("Amba.messaging.conversation().subscribe() requires an authenticated session — call Amba.auth.signIn* first.");
|
|
880
892
|
return openStream({
|
|
881
|
-
url: `${this.ctx.baseUrl}/v1/client/realtime/conversations/${encodeURIComponent(this.conversationId)}`,
|
|
893
|
+
url: `${resolveRealtimeBaseUrl(this.ctx.baseUrl)}/v1/client/realtime/conversations/${encodeURIComponent(this.conversationId)}`,
|
|
882
894
|
authHeaders: this.ctx.authHeaders,
|
|
883
895
|
onChange: cb,
|
|
884
896
|
options,
|
|
@@ -902,7 +914,7 @@ var GamificationSubscription = class {
|
|
|
902
914
|
subscribe(cb, options = {}) {
|
|
903
915
|
if (!this.ctx.authHeaders()) throw new Error("Amba.gamification.subscribe() requires an authenticated session — call Amba.auth.signIn* first.");
|
|
904
916
|
return openStream({
|
|
905
|
-
url: `${this.ctx.baseUrl}/v1/client/realtime/gamification`,
|
|
917
|
+
url: `${resolveRealtimeBaseUrl(this.ctx.baseUrl)}/v1/client/realtime/gamification`,
|
|
906
918
|
authHeaders: this.ctx.authHeaders,
|
|
907
919
|
onChange: cb,
|
|
908
920
|
options,
|
|
@@ -1138,7 +1150,7 @@ function delay(ms) {
|
|
|
1138
1150
|
//#endregion
|
|
1139
1151
|
//#region src/index.ts
|
|
1140
1152
|
/** SDK semver — burned in at build time. Bump alongside package.json. */
|
|
1141
|
-
const SDK_VERSION = "4.0.
|
|
1153
|
+
const SDK_VERSION = "4.0.5";
|
|
1142
1154
|
/**
|
|
1143
1155
|
* Default host that serves deployed functions. `Amba.functions.invoke(name)`
|
|
1144
1156
|
* targets `https://<projectId>.<DEFAULT_FUNCTIONS_HOST>/<name>` unless a
|
|
@@ -1298,6 +1310,8 @@ const P = {
|
|
|
1298
1310
|
pushSubscribe: "/v1/client/push/subscribe",
|
|
1299
1311
|
pushUnsubscribe: "/v1/client/push/unsubscribe",
|
|
1300
1312
|
entitlements: "/v1/client/entitlements",
|
|
1313
|
+
entitlementsRestore: "/v1/client/entitlements/restore",
|
|
1314
|
+
offerings: "/v1/client/offerings",
|
|
1301
1315
|
aiAnthropic: "/v1/client/ai/anthropic/messages",
|
|
1302
1316
|
config: "/v1/client/config",
|
|
1303
1317
|
flags: "/v1/client/flags",
|
|
@@ -1960,8 +1974,14 @@ const Amba = {
|
|
|
1960
1974
|
},
|
|
1961
1975
|
has: async (entitlementId) => {
|
|
1962
1976
|
return (await getState().http.get(P.entitlements, { active_only: "true" })).data.some((e) => e.entitlement_id === entitlementId && e.is_active);
|
|
1977
|
+
},
|
|
1978
|
+
restore: async () => {
|
|
1979
|
+
return (await getState().http.post(P.entitlementsRestore, {})).data;
|
|
1963
1980
|
}
|
|
1964
1981
|
},
|
|
1982
|
+
offerings: async (offeringId) => {
|
|
1983
|
+
return (await getState().http.get(P.offerings, offeringId ? { offering_id: offeringId } : void 0)).data;
|
|
1984
|
+
},
|
|
1965
1985
|
ai: { anthropic: { messages: { create: async (request) => {
|
|
1966
1986
|
const env = await getState().http.post(P.aiAnthropic, request);
|
|
1967
1987
|
if (!env || typeof env !== "object" || env.data === void 0) throw new AmbaApiError("MALFORMED_RESPONSE", "AI response was not wrapped in the expected { data } envelope", env);
|