@layers/amba-web 4.0.5 → 4.0.6

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.
@@ -2402,7 +2402,7 @@ declare function getCoreWasm(): AmbaCoreWasm;
2402
2402
  * `verify-sdk-version-coherence` GH action gates every publish on the
2403
2403
  * pair agreeing (and matching the `web-v<X.Y.Z>` tag when tag-triggered).
2404
2404
  */
2405
- declare const SDK_VERSION = "4.0.5";
2405
+ declare const SDK_VERSION = "4.0.6";
2406
2406
  //#endregion
2407
2407
  export { Achievement, AchievementProgress, AiContentBlock, AiImageInput, AiMessage, AiMessageRequest, AiMessageResponse, type AiStreamDelta, type AiStreamDone, type AiStreamEvent, type AiStreamOptions, AiUsage, Amba, AmbaApiError, type AmbaApiErrorCode, AmbaConfig, AndFilter, AppSession, AuthResult, CatalogItem, Challenge, ChallengeProgress, CollectionSubscription, ConditionFilter, ConfigBundle, ConsumeRequest, ContentItem, Conversation, ConversationParticipant, ConversationSubscription, ConversationType, CreateConversationRequest, CurrencyBalance, CurrencyTransaction, DeepLink, DeepLinkCreate, DeleteManyResult, DiagnosticsEnvironment, EntitlementPeriodType, EntitlementStore, EventExplainResult, ExplainMatchedRule, FeedItem, FeedResponse, Filter, FilterValue, FindOptions, FindResponse, FlagAssignment, type FlushResult, Friendship, FriendshipState, type GamificationChange, type GamificationKind, GamificationSubscription, Group, GroupCreate, GroupMember, GroupUpdate, IncludeClause, InventoryItem, InvokeOptions, type KvStore, Leaderboard, LeaderboardEntry, LeagueCohort, LeagueCohortMember, LeagueCohortView, LeagueMembership, LeagueTier, LinkedIdentifier, ListMessagesOptions, LocalNotificationHandle, LocalNotificationTrigger, type LocalNotificationsNamespace, MarkReadResult, MediaAsset, MediaCatalog, MediaCatalogItem, MediaListResponse, Message, type MessageChange, MessageType, NearestOptions, NearestResponse, NotFilter, Offering, OfferingPackage, OfferingProduct, OfferingsResult, OnboardingStatus, OrFilter, OrderBy, type OutboxOp, type OutboxOpKind, PingResult, PresignData, PullChangesCursor, PullChangesResult, PurchaseOption, PurchaseRequest, PurchaseResult, PushChangesResult, PushPlatform, PushToken, type RealtimeChange, ReferralClaim, ReferralCode, Report, ReportRequest, RestoreResult, Review, ReviewCreate, ReviewUpdate, Role, type RowChangeOp, SDK_VERSION, ScheduleLocalNotificationInput, ScheduledLocalNotification, SendMessageRequest, Session, SocialProvider, Store, Streak, type SubscribeOptions, SyncChange, SyncConflict, TransactionOp, TransactionOpResult, type Unsubscribe, UpsertOptions, User, UserEntitlement, XpBalance, XpTransaction, getCoreWasm, withOptimistic };
2408
2408
  //# sourceMappingURL=index.d.ts.map
package/dist-rn/index.js CHANGED
@@ -131,14 +131,13 @@ var AmbaApiError = class extends Error {
131
131
  }
132
132
  };
133
133
  /**
134
- * Best-effort: pull a stable error code out of a Rust `AmbaError`
135
- * Display string. Used by `toAmbaApiError` when the underlying thrown
136
- * value is a generic `Error` produced by `wasm-bindgen`'s `JsError::new`.
134
+ * Best-effort: pull a stable error code out of an `AmbaError` display
135
+ * string. Used by `toAmbaApiError` when the underlying thrown value is a
136
+ * generic `Error` produced by the SDK core.
137
137
  *
138
- * Keep in sync with `sdks/core/src/error.rs::AmbaError`'s `#[error]`
139
- * format strings — but the parser falls back to UNKNOWN_ERROR for any
140
- * pattern it doesn't recognize, so a stale match list isn't a footgun,
141
- * just a quality-of-life regression.
138
+ * Keep in sync with the SDK core's `AmbaError` format strings — but the
139
+ * parser falls back to UNKNOWN_ERROR for any pattern it doesn't recognize,
140
+ * so a stale match list isn't a footgun, just a quality-of-life regression.
142
141
  */
143
142
  function codeFromMessage(message) {
144
143
  if (message.startsWith("Unauthorized")) return "UNAUTHORIZED";
@@ -181,6 +180,18 @@ function toAmbaApiError(err) {
181
180
  //#region src/realtime.ts
182
181
  const INITIAL_BACKOFF_MS = 500;
183
182
  const MAX_BACKOFF_MS = 15e3;
183
+ const DEFAULT_API_URL$1 = "https://api.amba.dev";
184
+ const DEFAULT_REALTIME_URL = "https://realtime.amba.host";
185
+ /**
186
+ * Resolve the base URL for live-update connections. Long-lived streams are
187
+ * served from a dedicated realtime host (no request-duration ceiling), so
188
+ * when the SDK points at the default production API the stream connects
189
+ * there instead. Any custom `apiUrl` (dev, staging, self-hosted, proxy)
190
+ * keeps live updates on that same origin — override semantics unchanged.
191
+ */
192
+ function resolveRealtimeBaseUrl(baseUrl) {
193
+ return baseUrl.replace(/\/+$/, "") === DEFAULT_API_URL$1 ? DEFAULT_REALTIME_URL : baseUrl;
194
+ }
184
195
  /**
185
196
  * Builder returned by `Amba.collection(name)`. Chain `.where(...)` to
186
197
  * narrow, then `.subscribe(cb)` to start streaming.
@@ -204,7 +215,7 @@ var CollectionSubscription = class {
204
215
  if (!this.ctx.authHeaders()) throw new Error("Amba.collection().subscribe() requires an authenticated session — call Amba.auth.signIn*/verify* first.");
205
216
  const qs = Object.keys(this.filters).length > 0 ? `?where=${encodeURIComponent(JSON.stringify(this.filters))}` : "";
206
217
  return openStream({
207
- url: `${this.ctx.baseUrl}/v1/client/realtime/collections/${encodeURIComponent(this.name)}${qs}`,
218
+ url: `${resolveRealtimeBaseUrl(this.ctx.baseUrl)}/v1/client/realtime/collections/${encodeURIComponent(this.name)}${qs}`,
208
219
  authHeaders: this.ctx.authHeaders,
209
220
  onChange: cb,
210
221
  options
@@ -325,7 +336,7 @@ var ConversationSubscription = class {
325
336
  subscribe(cb, options = {}) {
326
337
  if (!this.ctx.authHeaders()) throw new Error("Amba.messaging.conversation().subscribe() requires an authenticated session — call Amba.auth.signIn*/verify* first.");
327
338
  return openStream({
328
- url: `${this.ctx.baseUrl}/v1/client/realtime/conversations/${encodeURIComponent(this.conversationId)}`,
339
+ url: `${resolveRealtimeBaseUrl(this.ctx.baseUrl)}/v1/client/realtime/conversations/${encodeURIComponent(this.conversationId)}`,
329
340
  authHeaders: this.ctx.authHeaders,
330
341
  onChange: cb,
331
342
  options
@@ -354,7 +365,7 @@ var GamificationSubscription = class {
354
365
  subscribe(cb, options = {}) {
355
366
  if (!this.ctx.authHeaders()) throw new Error("Amba.gamification.subscribe() requires an authenticated session — call Amba.auth.signIn*/verify* first.");
356
367
  return openGamificationStream({
357
- url: `${this.ctx.baseUrl}/v1/client/realtime/gamification`,
368
+ url: `${resolveRealtimeBaseUrl(this.ctx.baseUrl)}/v1/client/realtime/gamification`,
358
369
  authHeaders: this.ctx.authHeaders,
359
370
  onChange: cb,
360
371
  options
@@ -2391,7 +2402,7 @@ function getCoreWasm() {
2391
2402
  * `verify-sdk-version-coherence` GH action gates every publish on the
2392
2403
  * pair agreeing (and matching the `web-v<X.Y.Z>` tag when tag-triggered).
2393
2404
  */
2394
- const SDK_VERSION = "4.0.5";
2405
+ const SDK_VERSION = "4.0.6";
2395
2406
 
2396
2407
  //#endregion
2397
2408
  export { Amba, AmbaApiError, CollectionSubscription, ConversationSubscription, GamificationSubscription, SDK_VERSION, getCoreWasm, withOptimistic };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@layers/amba-web",
3
- "version": "4.0.5",
3
+ "version": "4.0.6",
4
4
  "description": "amba SDK for browser apps — full SDK 4.0 surface (34 modules: auth + magic link, users, sessions, sync, collections + vector search, storage + list/delete/download, push, entitlements, flags, config, deep links, onboarding, content, messaging, friends, groups, feeds, reviews, moderation, roles, referrals, achievements, xp, streaks, challenges, leaderboards, leagues, currencies, inventory, stores, catalog, ai, diagnostics).",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "sideEffects": false,
34
34
  "dependencies": {
35
- "@layers/amba-core": "^4.0.5"
35
+ "@layers/amba-core": "^4.0.6"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/node": "^22.13.14",