@layers/amba-web 1.0.0 → 1.0.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.
@@ -0,0 +1,808 @@
1
+ import { AmbaCoreWasm } from "@layers/amba-core";
2
+
3
+ //#region src/types.d.ts
4
+
5
+ /**
6
+ * Public type surface for `@layers/amba-web`.
7
+ *
8
+ * Mirrors the amba API wire format. Field names match the wire format
9
+ * (snake_case) where it would cause confusion to translate; idiomatic
10
+ * camelCase is reserved for the SDK's own option objects.
11
+ */
12
+ interface AmbaConfig {
13
+ /** Tenant API key from the developer console (`amba_pk_…`). */
14
+ apiKey: string;
15
+ /** Override the base URL for non-prod environments. */
16
+ baseUrl?: string;
17
+ /**
18
+ * If `true`, blocks all telemetry until `setConsent(granted)` is called.
19
+ * Required for SOC2 / GDPR strict modes.
20
+ */
21
+ consentRequired?: boolean;
22
+ /** Verbose `tracing::Level::DEBUG` logging. */
23
+ debug?: boolean;
24
+ /** Override the localStorage key prefix. Defaults to `"amba"`. */
25
+ storagePrefix?: string;
26
+ }
27
+ type SocialProvider = "apple" | "google";
28
+ type PushPlatform = "apns" | "fcm" | "web";
29
+ interface User {
30
+ id: string;
31
+ email?: string | null;
32
+ display_name?: string | null;
33
+ avatar_url?: string | null;
34
+ external_id?: string | null;
35
+ anonymous_id?: string | null;
36
+ auth_providers: string[];
37
+ properties: Record<string, unknown>;
38
+ first_seen_at?: string;
39
+ last_seen_at?: string;
40
+ created_at?: string;
41
+ updated_at?: string;
42
+ }
43
+ interface AuthResult {
44
+ session_token: string;
45
+ refresh_token: string;
46
+ user: User;
47
+ anonymous_id?: string | null;
48
+ expires_at?: string | null;
49
+ }
50
+ /**
51
+ * Snapshot of the current session as visible to the SDK consumer.
52
+ *
53
+ * `sessionToken` / `refreshToken` / `expiresAt` are SDK-managed and held
54
+ * internally for the auto-refresh dance, so they're empty strings on the
55
+ * consumer side — present for shape-compatibility. Callers who need to
56
+ * introspect should branch on `user` / `Amba.isAuthenticated`.
57
+ */
58
+ interface Session {
59
+ sessionToken: string;
60
+ refreshToken: string;
61
+ user: User;
62
+ expiresAt: string;
63
+ }
64
+ type FilterValue = string | number | boolean | null | unknown[];
65
+ interface ConditionFilter {
66
+ column: string;
67
+ op: string;
68
+ value?: FilterValue;
69
+ }
70
+ interface AndFilter {
71
+ and: Filter[];
72
+ }
73
+ interface OrFilter {
74
+ or: Filter[];
75
+ }
76
+ interface NotFilter {
77
+ not: Filter;
78
+ }
79
+ type Filter = ConditionFilter | AndFilter | OrFilter | NotFilter;
80
+ interface OrderBy {
81
+ column: string;
82
+ direction: "asc" | "desc";
83
+ }
84
+ interface FindOptions {
85
+ filter?: Filter;
86
+ order?: OrderBy[];
87
+ limit?: number;
88
+ cursor?: string;
89
+ select?: string[];
90
+ include_deleted?: boolean;
91
+ }
92
+ interface FindResponse<T> {
93
+ data: T[];
94
+ next_cursor?: string | null;
95
+ has_more: boolean;
96
+ }
97
+ interface MediaAsset {
98
+ id: string;
99
+ bucket: string;
100
+ key: string;
101
+ url: string;
102
+ mime_type: string;
103
+ size_bytes: number;
104
+ width?: number | null;
105
+ height?: number | null;
106
+ retention_days?: number | null;
107
+ created_at: string;
108
+ }
109
+ interface PresignData {
110
+ upload_id: string;
111
+ upload_url: string;
112
+ upload_headers: Array<[string, string]>;
113
+ asset_id: string;
114
+ }
115
+ interface PushToken {
116
+ id: string;
117
+ token: string;
118
+ platform: PushPlatform;
119
+ bundle_id?: string | null;
120
+ created_at: string;
121
+ }
122
+ type EntitlementSource = "revenue_cat" | "app_store" | "play_store" | "stripe" | "promo_code" | "manual";
123
+ interface UserEntitlement {
124
+ id: string;
125
+ name: string;
126
+ is_active: boolean;
127
+ source: EntitlementSource;
128
+ expires_at?: string | null;
129
+ granted_at?: string | null;
130
+ metadata: Record<string, unknown>;
131
+ }
132
+ interface AiMessage {
133
+ role: string;
134
+ content: unknown;
135
+ }
136
+ interface AiMessageRequest {
137
+ prompt_slug: string;
138
+ variables?: Record<string, unknown>;
139
+ messages?: AiMessage[];
140
+ max_tokens?: number;
141
+ temperature?: number;
142
+ enable_prompt_cache?: boolean;
143
+ }
144
+ interface AiUsage {
145
+ input_tokens: number;
146
+ output_tokens: number;
147
+ cache_creation_input_tokens?: number;
148
+ cache_read_input_tokens?: number;
149
+ }
150
+ interface AiMessageResponse {
151
+ content: unknown[];
152
+ usage: AiUsage;
153
+ stop_reason?: string | null;
154
+ model: string;
155
+ }
156
+ /**
157
+ * Resolved remote config returned by `config.fetch()`.
158
+ *
159
+ * Server: `GET /v1/client/config` returns body `{ "data": { key → value, ... } }`
160
+ * plus an `ETag` response header carrying the version stamp. The SDK
161
+ * lifts the `data` map into `values` and parses the ETag prefix into
162
+ * `version`.
163
+ *
164
+ * `version` is `null` when the server didn't send an ETag (e.g. local
165
+ * dev with an empty config-versions row).
166
+ */
167
+ interface ConfigBundle {
168
+ version: string | null;
169
+ values: Record<string, unknown>;
170
+ }
171
+ interface FlagAssignment {
172
+ name: string;
173
+ enabled: boolean;
174
+ variant?: string | null;
175
+ payload?: unknown;
176
+ }
177
+ interface Achievement {
178
+ id: string;
179
+ key: string;
180
+ name: string;
181
+ description?: string | null;
182
+ icon_url?: string | null;
183
+ points: number;
184
+ criteria: unknown;
185
+ }
186
+ interface AchievementProgress {
187
+ achievement_id: string;
188
+ key: string;
189
+ progress: number;
190
+ unlocked: boolean;
191
+ unlocked_at?: string | null;
192
+ }
193
+ interface Challenge {
194
+ id: string;
195
+ key: string;
196
+ name: string;
197
+ description?: string | null;
198
+ starts_at: string;
199
+ ends_at: string;
200
+ criteria: unknown;
201
+ reward: unknown;
202
+ }
203
+ interface ChallengeProgress {
204
+ challenge_id: string;
205
+ progress: number;
206
+ completed: boolean;
207
+ claimed: boolean;
208
+ completed_at?: string | null;
209
+ claimed_at?: string | null;
210
+ }
211
+ interface CurrencyBalance {
212
+ currency_id: string;
213
+ key: string;
214
+ balance: number;
215
+ updated_at: string;
216
+ }
217
+ interface CurrencyTransaction {
218
+ id: string;
219
+ currency_id: string;
220
+ delta: number;
221
+ balance_after: number;
222
+ reason?: string | null;
223
+ created_at: string;
224
+ }
225
+ interface InventoryItem {
226
+ id: string;
227
+ catalog_item_id: string;
228
+ sku: string;
229
+ quantity: number;
230
+ acquired_at: string;
231
+ metadata: unknown;
232
+ }
233
+ interface PurchaseRequest {
234
+ sku: string;
235
+ quantity?: number;
236
+ currency_key?: string;
237
+ }
238
+ interface ConsumeRequest {
239
+ item_id: string;
240
+ quantity: number;
241
+ }
242
+ interface Leaderboard {
243
+ id: string;
244
+ key: string;
245
+ name: string;
246
+ period: string;
247
+ direction: string;
248
+ starts_at?: string | null;
249
+ ends_at?: string | null;
250
+ }
251
+ interface LeaderboardEntry {
252
+ rank: number;
253
+ user_id: string;
254
+ display_name?: string | null;
255
+ avatar_url?: string | null;
256
+ score: number;
257
+ }
258
+ interface Store {
259
+ id: string;
260
+ key: string;
261
+ name: string;
262
+ }
263
+ interface PurchaseOption {
264
+ id: string;
265
+ store_id: string;
266
+ sku: string;
267
+ name: string;
268
+ price_cents: number;
269
+ currency: string;
270
+ period?: string | null;
271
+ metadata: unknown;
272
+ }
273
+ interface PurchaseResult {
274
+ id: string;
275
+ user_id: string;
276
+ purchase_option_id: string;
277
+ status: string;
278
+ purchased_at: string;
279
+ receipt: unknown;
280
+ }
281
+ interface XpBalance {
282
+ user_id: string;
283
+ total_xp: number;
284
+ current_level: number;
285
+ xp_into_level: number;
286
+ xp_to_next_level: number;
287
+ updated_at: string;
288
+ /**
289
+ * XP earned in the current rolling window. The window is server-defined
290
+ * via the project's XP rules. Older servers that don't populate this
291
+ * field decode as `0`.
292
+ */
293
+ xp_this_period: number;
294
+ }
295
+ interface XpTransaction {
296
+ id: string;
297
+ delta: number;
298
+ reason?: string | null;
299
+ source?: string | null;
300
+ created_at: string;
301
+ }
302
+ interface Streak {
303
+ id: string;
304
+ key: string;
305
+ name: string;
306
+ current_length: number;
307
+ longest_length: number;
308
+ last_qualified_on?: string | null;
309
+ updated_at: string;
310
+ /**
311
+ * Server-computed lifecycle state.
312
+ * - `"active"` — streak is alive and current period not yet qualified
313
+ * - `"qualified_today"` — user already qualified for the current period
314
+ * - `"broken"` — user missed a period; current_length reset to 0
315
+ * - `"frozen"` — a freeze (shield) is protecting the streak from a miss
316
+ *
317
+ * Empty string when decoded against an older server that didn't emit it.
318
+ */
319
+ status: string;
320
+ /**
321
+ * Unused streak-freeze count. Auto-granted by the server every
322
+ * `streak_definitions.freezes_per_n_events` qualifying events, capped
323
+ * at `streak_definitions.max_freezes`.
324
+ */
325
+ freezes_remaining: number;
326
+ }
327
+ interface FeedItem {
328
+ id: string;
329
+ actor_id: string;
330
+ verb: string;
331
+ object_type: string;
332
+ object_id: string;
333
+ target_type?: string | null;
334
+ target_id?: string | null;
335
+ data: unknown;
336
+ created_at: string;
337
+ }
338
+ interface FeedResponse {
339
+ data: FeedItem[];
340
+ next_cursor?: string | null;
341
+ }
342
+ type FriendshipState = "pending" | "accepted" | "blocked" | "declined";
343
+ interface Friendship {
344
+ id: string;
345
+ user_id: string;
346
+ friend_id: string;
347
+ state: FriendshipState;
348
+ created_at: string;
349
+ }
350
+ interface Group {
351
+ id: string;
352
+ name: string;
353
+ description?: string | null;
354
+ avatar_url?: string | null;
355
+ created_by: string;
356
+ member_count: number;
357
+ created_at: string;
358
+ updated_at: string;
359
+ metadata: unknown;
360
+ }
361
+ interface GroupMember {
362
+ group_id: string;
363
+ user_id: string;
364
+ role: string;
365
+ joined_at: string;
366
+ }
367
+ interface GroupCreate {
368
+ name: string;
369
+ description?: string;
370
+ avatar_url?: string;
371
+ metadata?: unknown;
372
+ }
373
+ interface GroupUpdate {
374
+ name?: string;
375
+ description?: string;
376
+ avatar_url?: string;
377
+ metadata?: unknown;
378
+ }
379
+ interface Message {
380
+ id: string;
381
+ conversation_id: string;
382
+ sender_id: string;
383
+ body: string;
384
+ metadata: unknown;
385
+ created_at: string;
386
+ }
387
+ interface Conversation {
388
+ id: string;
389
+ participants: string[];
390
+ last_message?: Message | null;
391
+ created_at: string;
392
+ updated_at: string;
393
+ }
394
+ interface SendMessageRequest {
395
+ conversation_id?: string | null;
396
+ to_user_id?: string | null;
397
+ body: string;
398
+ metadata?: unknown;
399
+ }
400
+ interface Report {
401
+ id: string;
402
+ reporter_id: string;
403
+ target_type: string;
404
+ target_id: string;
405
+ reason: string;
406
+ status: string;
407
+ notes?: string | null;
408
+ created_at: string;
409
+ resolved_at?: string | null;
410
+ }
411
+ interface ReportRequest {
412
+ target_id: string;
413
+ reason: string;
414
+ notes?: string;
415
+ }
416
+ interface ReferralCode {
417
+ id: string;
418
+ code: string;
419
+ owner_id: string;
420
+ uses_count: number;
421
+ max_uses?: number | null;
422
+ expires_at?: string | null;
423
+ created_at: string;
424
+ }
425
+ interface ReferralClaim {
426
+ id: string;
427
+ code_id: string;
428
+ referrer_id: string;
429
+ referee_id: string;
430
+ reward: unknown;
431
+ claimed_at: string;
432
+ }
433
+ interface Review {
434
+ id: string;
435
+ author_id: string;
436
+ target_type: string;
437
+ target_id: string;
438
+ rating: number;
439
+ title?: string | null;
440
+ body?: string | null;
441
+ created_at: string;
442
+ updated_at: string;
443
+ }
444
+ interface ReviewCreate {
445
+ target_type: string;
446
+ target_id: string;
447
+ rating: number;
448
+ title?: string;
449
+ body?: string;
450
+ }
451
+ interface ReviewUpdate {
452
+ rating?: number;
453
+ title?: string;
454
+ body?: string;
455
+ }
456
+ interface Role {
457
+ id: string;
458
+ key: string;
459
+ name: string;
460
+ permissions: string[];
461
+ }
462
+ interface CatalogItem {
463
+ id: string;
464
+ sku: string;
465
+ name: string;
466
+ description?: string | null;
467
+ price_cents?: number | null;
468
+ currency?: string | null;
469
+ metadata: unknown;
470
+ }
471
+ interface ContentItem {
472
+ id: string;
473
+ channel: string;
474
+ title?: string | null;
475
+ body?: string | null;
476
+ data: unknown;
477
+ published_at: string;
478
+ user_state: unknown;
479
+ }
480
+ interface DeepLink {
481
+ id: string;
482
+ url: string;
483
+ short_code: string;
484
+ target_path?: string | null;
485
+ metadata: unknown;
486
+ created_at: string;
487
+ }
488
+ interface DeepLinkCreate {
489
+ target_path: string;
490
+ metadata?: unknown;
491
+ short_code?: string;
492
+ }
493
+ interface OnboardingStatus {
494
+ current_step: string | null;
495
+ completed_steps: string[];
496
+ remaining_steps: string[];
497
+ completed: boolean;
498
+ completed_at?: string | null;
499
+ }
500
+ //#endregion
501
+ //#region src/error.d.ts
502
+ /**
503
+ * Typed error class for the amba SDK + helper that converts arbitrary
504
+ * thrown values (native Error, plain objects, runtime-emitted errors)
505
+ * into a stable `AmbaApiError` instance.
506
+ *
507
+ * Callers can `instanceof`-narrow safely, branch on `.code`, and pull
508
+ * extra payload from `.details` (raw HTTP body, validation field paths,
509
+ * etc.). The wrapper methods on `Amba` wrap every async call in
510
+ * `toAmbaApiError`, so consumers see one error shape regardless of
511
+ * which layer (network, runtime, validation) failed.
512
+ */
513
+ /**
514
+ * Stable error codes surfaced by the SDK. Strings rather than an enum
515
+ * so customers can extend with custom codes by simply throwing
516
+ * `new AmbaApiError("MY_CODE", "...")` without coordinating with this
517
+ * package's TypeScript types.
518
+ */
519
+ type AmbaApiErrorCode = "UNAUTHORIZED" | "FORBIDDEN" | "NOT_FOUND" | "CONFLICT" | "RATE_LIMITED" | "VALIDATION_ERROR" | "NETWORK_ERROR" | "HTTP_ERROR" | "CIRCUIT_OPEN" | "CONSENT_NOT_GRANTED" | "NOT_INITIALIZED" | "INVALID_CONFIG" | "INVALID_ARGUMENT" | "PUSH_PERMISSION_DENIED" | "PUSH_REGISTRATION_FAILED" | "UNKNOWN_ERROR" | (string & {});
520
+ declare class AmbaApiError extends Error {
521
+ readonly code: AmbaApiErrorCode;
522
+ readonly details?: unknown;
523
+ constructor(code: AmbaApiErrorCode, message: string, details?: unknown);
524
+ }
525
+ //#endregion
526
+ //#region src/index.d.ts
527
+ /**
528
+ * Top-level SDK namespace.
529
+ *
530
+ * Stateless from the JS side — all state lives in the SDK runtime. Calling
531
+ * `Amba.configure()` multiple times replaces the previous instance.
532
+ */
533
+ declare const Amba: {
534
+ /**
535
+ * Initialize the SDK. Must be called once at app start.
536
+ *
537
+ * Seeds an `anonymous_id` from localStorage (if present) or generates a
538
+ * fresh one.
539
+ */
540
+ configure: (config: AmbaConfig) => Promise<void>;
541
+ /** Anonymous id — stable per browser. */
542
+ readonly anonymousId: string;
543
+ /** Authenticated user id, if a session is live. */
544
+ readonly appUserId: string | undefined;
545
+ /** Whether a session token is currently held. */
546
+ readonly isAuthenticated: boolean;
547
+ /** Toggle verbose logging at runtime. */
548
+ setDebug: (enabled: boolean) => void;
549
+ /** Track engagement events. */
550
+ events: {
551
+ track: (event: string, properties?: Record<string, unknown>) => Promise<void>;
552
+ };
553
+ /** Authentication flows. */
554
+ auth: {
555
+ signInAnonymously: () => Promise<AuthResult>;
556
+ signInWithEmail: (email: string, password: string) => Promise<AuthResult>;
557
+ signUpWithEmail: (email: string, password: string) => Promise<AuthResult>;
558
+ signInWithSocial: (provider: SocialProvider, idToken: string) => Promise<AuthResult>;
559
+ signOut: (rotateAnonymousId?: boolean) => Promise<void>;
560
+ refresh: () => Promise<AuthResult>;
561
+ me: () => Promise<User>;
562
+ /**
563
+ * Snapshot the current session, or `null` if no session is live.
564
+ * sessionToken/refreshToken/expiresAt come back as empty strings —
565
+ * they're SDK-managed and not read-back-able from the core. Use
566
+ * `Amba.isAuthenticated` if you only need the boolean.
567
+ */
568
+ getSession: () => Promise<Session | null>;
569
+ /**
570
+ * Stable anonymous identifier (kept in memory by the SDK runtime).
571
+ * Sync today, async for parity with the RN/native shape where the
572
+ * platform may need to await a persistence read.
573
+ */
574
+ getAnonymousId: () => Promise<string>;
575
+ /**
576
+ * Subscribe to session changes. Fires after every `signIn*`,
577
+ * `signUp*`, `refresh`, and `signOut` call. Returns an
578
+ * unsubscribe function — call it to remove the callback.
579
+ *
580
+ * Does NOT fire an initial snapshot when subscribed; call
581
+ * `getSession()` once after subscribing if you need the
582
+ * current state up front.
583
+ */
584
+ onAuthStateChange: (cb: (session: Session | null) => void) => (() => void);
585
+ };
586
+ /** Typed collection CRUD with auto-RLS. */
587
+ collections: {
588
+ find: <T = unknown>(name: string, options?: FindOptions) => Promise<FindResponse<T>>;
589
+ findOne: <T = unknown>(name: string, id: string) => Promise<T>;
590
+ insert: <T = unknown>(name: string, row: Record<string, unknown>) => Promise<T>;
591
+ update: <T = unknown>(name: string, id: string, set: Record<string, unknown>) => Promise<T>;
592
+ delete: (name: string, id: string) => Promise<{
593
+ data: {
594
+ deleted: boolean;
595
+ };
596
+ }>;
597
+ /** Filter DSL helpers — pass into `find({ filter: f })`. */
598
+ where: {
599
+ eq: (column: string, value: FilterValue) => Filter;
600
+ ne: (column: string, value: FilterValue) => Filter;
601
+ gt: (column: string, value: FilterValue) => Filter;
602
+ gte: (column: string, value: FilterValue) => Filter;
603
+ lt: (column: string, value: FilterValue) => Filter;
604
+ lte: (column: string, value: FilterValue) => Filter;
605
+ in: (column: string, values: FilterValue[]) => Filter;
606
+ notIn: (column: string, values: FilterValue[]) => Filter;
607
+ like: (column: string, pattern: string) => Filter;
608
+ ilike: (column: string, pattern: string) => Filter;
609
+ isNull: (column: string) => Filter;
610
+ isNotNull: (column: string) => Filter;
611
+ and: (...filters: Filter[]) => Filter;
612
+ or: (...filters: Filter[]) => Filter;
613
+ not: (filter: Filter) => Filter;
614
+ };
615
+ };
616
+ /** Media uploads + CDN URL helpers. */
617
+ storage: {
618
+ presign: (params: {
619
+ bucket: string;
620
+ filename: string;
621
+ mimeType: string;
622
+ sizeBytes: number;
623
+ retentionDays?: number;
624
+ }) => Promise<PresignData>;
625
+ /**
626
+ * Complete-flow upload: presign → PUT to R2 → commit.
627
+ * Returns the finalized MediaAsset.
628
+ */
629
+ upload: (params: {
630
+ bucket: string;
631
+ file: File | Blob;
632
+ filename?: string;
633
+ retentionDays?: number;
634
+ }) => Promise<MediaAsset>;
635
+ };
636
+ /** Push notifications. */
637
+ push: {
638
+ register: (token: string, platform: PushPlatform, bundleId?: string) => Promise<PushToken>;
639
+ unregister: (token: string) => Promise<void>;
640
+ getTokens: () => Promise<PushToken[]>;
641
+ subscribe: (topic: string) => Promise<void>;
642
+ unsubscribe: (topic: string) => Promise<void>;
643
+ };
644
+ /** RevenueCat/App Store/Stripe entitlements. */
645
+ entitlements: {
646
+ list: () => Promise<UserEntitlement[]>;
647
+ has: (name: string) => Promise<boolean>;
648
+ };
649
+ /** LLM proxy. */
650
+ ai: {
651
+ anthropic: {
652
+ messages: {
653
+ create: (request: AiMessageRequest) => Promise<AiMessageResponse>;
654
+ };
655
+ };
656
+ };
657
+ /** Remote config bundle. */
658
+ config: {
659
+ fetch: () => Promise<ConfigBundle>;
660
+ };
661
+ /** Server-evaluated feature flags. */
662
+ flags: {
663
+ fetch: () => Promise<FlagAssignment[]>;
664
+ };
665
+ /** Achievement definitions + per-user progress. */
666
+ achievements: {
667
+ getAll: () => Promise<Achievement[]>;
668
+ getProgress: () => Promise<AchievementProgress[]>;
669
+ };
670
+ /** Time-bounded challenges with rewards. */
671
+ challenges: {
672
+ getActive: () => Promise<Challenge[]>;
673
+ get: (id: string) => Promise<Challenge>;
674
+ getProgress: (id: string) => Promise<ChallengeProgress>;
675
+ claim: (id: string) => Promise<ChallengeProgress>;
676
+ };
677
+ /** Virtual currency balances + ledger. */
678
+ currencies: {
679
+ getBalance: () => Promise<CurrencyBalance[]>;
680
+ getTransactions: (currencyKey: string) => Promise<CurrencyTransaction[]>;
681
+ };
682
+ /** User inventory items + purchase/consume. */
683
+ inventory: {
684
+ getItems: () => Promise<InventoryItem[]>;
685
+ getItem: (id: string) => Promise<InventoryItem>;
686
+ purchase: (request: PurchaseRequest) => Promise<InventoryItem>;
687
+ consume: (request: ConsumeRequest) => Promise<InventoryItem>;
688
+ };
689
+ /** Score rankings. */
690
+ leaderboards: {
691
+ get: (key: string) => Promise<Leaderboard>;
692
+ getEntries: (key: string, limit?: number) => Promise<LeaderboardEntry[]>;
693
+ getMyRank: (key: string) => Promise<LeaderboardEntry>;
694
+ };
695
+ /** Purchase storefronts. */
696
+ stores: {
697
+ list: () => Promise<Store[]>;
698
+ getPurchaseOptions: (storeKey: string) => Promise<PurchaseOption[]>;
699
+ purchase: (storeKey: string, purchaseOptionId: string, receipt: unknown) => Promise<PurchaseResult>;
700
+ };
701
+ /** Experience points + level system. */
702
+ xp: {
703
+ getBalance: () => Promise<XpBalance>;
704
+ getHistory: (limit?: number) => Promise<XpTransaction[]>;
705
+ claim: (grantKey: string) => Promise<XpTransaction>;
706
+ };
707
+ /** Daily-engagement streaks. */
708
+ streaks: {
709
+ getAll: () => Promise<Streak[]>;
710
+ qualify: (streakKey: string) => Promise<Streak>;
711
+ };
712
+ /** Activity feeds. */
713
+ feeds: {
714
+ getActivity: (feed?: string, cursor?: string) => Promise<FeedResponse>;
715
+ };
716
+ /** Friend graph + block list. */
717
+ friends: {
718
+ getList: () => Promise<Friendship[]>;
719
+ getFriends: () => Promise<Friendship[]>;
720
+ blockUser: (userId: string) => Promise<Friendship>;
721
+ unblockUser: (userId: string) => Promise<void>;
722
+ removeBlock: (friendshipId: string) => Promise<void>;
723
+ };
724
+ /** Multi-user groups. */
725
+ groups: {
726
+ create: (params: GroupCreate) => Promise<Group>;
727
+ get: (id: string) => Promise<Group>;
728
+ update: (id: string, patch: GroupUpdate) => Promise<Group>;
729
+ delete: (id: string) => Promise<void>;
730
+ getMembers: (id: string) => Promise<GroupMember[]>;
731
+ join: (id: string) => Promise<GroupMember>;
732
+ leave: (id: string) => Promise<void>;
733
+ invite: (id: string, userId: string) => Promise<GroupMember>;
734
+ };
735
+ /** User-to-user direct messaging. */
736
+ messaging: {
737
+ getConversations: () => Promise<Conversation[]>;
738
+ getMessage: (id: string) => Promise<Message>;
739
+ sendMessage: (request: SendMessageRequest) => Promise<Message>;
740
+ };
741
+ /** Report users / content for moderation. */
742
+ moderation: {
743
+ reportUser: (request: ReportRequest) => Promise<Report>;
744
+ reportContent: (request: ReportRequest) => Promise<Report>;
745
+ getReportStatus: (id: string) => Promise<Report>;
746
+ };
747
+ /** User reviews of catalog items or other users. */
748
+ reviews: {
749
+ list: (targetType: string, targetId: string) => Promise<Review[]>;
750
+ create: (params: ReviewCreate) => Promise<Review>;
751
+ update: (id: string, patch: ReviewUpdate) => Promise<Review>;
752
+ delete: (id: string) => Promise<void>;
753
+ };
754
+ /** RBAC roles + permission checks. */
755
+ roles: {
756
+ getMyRoles: () => Promise<Role[]>;
757
+ hasPermission: (permission: string) => Promise<boolean>;
758
+ };
759
+ /** Referral codes + claim flow. */
760
+ referrals: {
761
+ getReferralCode: () => Promise<ReferralCode>;
762
+ claimReferral: (code: string) => Promise<ReferralClaim>;
763
+ create: (code?: string, maxUses?: number) => Promise<ReferralCode>;
764
+ };
765
+ /** Read-only product catalog. */
766
+ catalog: {
767
+ list: () => Promise<CatalogItem[]>;
768
+ };
769
+ /** Developer-defined content items (daily quotes, lessons, etc.). */
770
+ content: {
771
+ /**
772
+ * Get today's published item for `channel`. Defaults to `"default"`
773
+ * so single-channel apps can call `Amba.content.getToday()` bare.
774
+ */
775
+ getToday: (channel?: string) => Promise<ContentItem | null>;
776
+ /**
777
+ * Paginated library list for `channel`. `options.limit` caps page size
778
+ * (server default applies when omitted); `options.cursor` is the
779
+ * opaque token returned by a prior response's `next_cursor`.
780
+ */
781
+ getLibrary: (channel?: string, options?: {
782
+ limit?: number;
783
+ cursor?: string;
784
+ }) => Promise<ContentItem[]>;
785
+ getItem: (id: string) => Promise<ContentItem>;
786
+ updateItem: (id: string, state: unknown) => Promise<ContentItem>;
787
+ createItem: (channel: string, item: unknown) => Promise<ContentItem>;
788
+ };
789
+ /** Server-managed deep link records. */
790
+ deepLinks: {
791
+ get: (shortCode: string) => Promise<DeepLink>;
792
+ create: (params: DeepLinkCreate) => Promise<DeepLink>;
793
+ };
794
+ /** Step-by-step user onboarding flow. */
795
+ onboarding: {
796
+ getStatus: () => Promise<OnboardingStatus>;
797
+ nextStep: (payload: unknown) => Promise<OnboardingStatus>;
798
+ skipStep: () => Promise<OnboardingStatus>;
799
+ complete: () => Promise<OnboardingStatus>;
800
+ };
801
+ };
802
+ /** Escape hatch — the raw SDK runtime handle, for namespaces not yet wrapped. */
803
+ declare function getCoreWasm(): AmbaCoreWasm;
804
+ /** Package version stamped at build time. */
805
+ declare const SDK_VERSION = "0.1.0";
806
+ //#endregion
807
+ export { Achievement, AchievementProgress, AiMessage, AiMessageRequest, AiMessageResponse, AiUsage, Amba, AmbaApiError, type AmbaApiErrorCode, AmbaConfig, AndFilter, AuthResult, CatalogItem, Challenge, ChallengeProgress, ConditionFilter, ConfigBundle, ConsumeRequest, ContentItem, Conversation, CurrencyBalance, CurrencyTransaction, DeepLink, DeepLinkCreate, EntitlementSource, FeedItem, FeedResponse, Filter, FilterValue, FindOptions, FindResponse, FlagAssignment, Friendship, FriendshipState, Group, GroupCreate, GroupMember, GroupUpdate, InventoryItem, Leaderboard, LeaderboardEntry, MediaAsset, Message, NotFilter, OnboardingStatus, OrFilter, OrderBy, PresignData, PurchaseOption, PurchaseRequest, PurchaseResult, PushPlatform, PushToken, ReferralClaim, ReferralCode, Report, ReportRequest, Review, ReviewCreate, ReviewUpdate, Role, SDK_VERSION, SendMessageRequest, Session, SocialProvider, Store, Streak, User, UserEntitlement, XpBalance, XpTransaction, getCoreWasm };
808
+ //# sourceMappingURL=index.d.ts.map