@layers/amba-react-native 1.0.0
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/README.md +67 -0
- package/dist/index.cjs +436 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +719 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +719 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +433 -0
- package/dist/index.js.map +1 -0
- package/package.json +58 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,719 @@
|
|
|
1
|
+
//#region src/types.d.ts
|
|
2
|
+
interface AmbaConfig {
|
|
3
|
+
apiKey: string;
|
|
4
|
+
baseUrl?: string;
|
|
5
|
+
consentRequired?: boolean;
|
|
6
|
+
debug?: boolean;
|
|
7
|
+
/** Override the AsyncStorage key prefix. Defaults to `"amba"`. */
|
|
8
|
+
storagePrefix?: string;
|
|
9
|
+
}
|
|
10
|
+
type SocialProvider = "apple" | "google";
|
|
11
|
+
type PushPlatform = "apns" | "fcm" | "web";
|
|
12
|
+
interface User {
|
|
13
|
+
id: string;
|
|
14
|
+
email?: string | null;
|
|
15
|
+
display_name?: string | null;
|
|
16
|
+
avatar_url?: string | null;
|
|
17
|
+
external_id?: string | null;
|
|
18
|
+
anonymous_id?: string | null;
|
|
19
|
+
auth_providers: string[];
|
|
20
|
+
properties: Record<string, unknown>;
|
|
21
|
+
first_seen_at?: string;
|
|
22
|
+
last_seen_at?: string;
|
|
23
|
+
created_at?: string;
|
|
24
|
+
updated_at?: string;
|
|
25
|
+
}
|
|
26
|
+
interface AuthResult {
|
|
27
|
+
session_token: string;
|
|
28
|
+
refresh_token: string;
|
|
29
|
+
user: User;
|
|
30
|
+
anonymous_id?: string | null;
|
|
31
|
+
expires_at?: string | null;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Snapshot of the current session. sessionToken/refreshToken/expiresAt
|
|
35
|
+
* are SDK-managed (held internally for the auto-refresh dance) — empty
|
|
36
|
+
* strings on the consumer side. Mirrors `@layers/amba-web::Session`.
|
|
37
|
+
*/
|
|
38
|
+
interface Session {
|
|
39
|
+
sessionToken: string;
|
|
40
|
+
refreshToken: string;
|
|
41
|
+
user: User;
|
|
42
|
+
expiresAt: string;
|
|
43
|
+
}
|
|
44
|
+
type FilterValue = string | number | boolean | null | unknown[];
|
|
45
|
+
interface ConditionFilter {
|
|
46
|
+
column: string;
|
|
47
|
+
op: string;
|
|
48
|
+
value?: FilterValue;
|
|
49
|
+
}
|
|
50
|
+
interface AndFilter {
|
|
51
|
+
and: Filter[];
|
|
52
|
+
}
|
|
53
|
+
interface OrFilter {
|
|
54
|
+
or: Filter[];
|
|
55
|
+
}
|
|
56
|
+
interface NotFilter {
|
|
57
|
+
not: Filter;
|
|
58
|
+
}
|
|
59
|
+
type Filter = ConditionFilter | AndFilter | OrFilter | NotFilter;
|
|
60
|
+
interface OrderBy {
|
|
61
|
+
column: string;
|
|
62
|
+
direction: "asc" | "desc";
|
|
63
|
+
}
|
|
64
|
+
interface FindOptions {
|
|
65
|
+
filter?: Filter;
|
|
66
|
+
order?: OrderBy[];
|
|
67
|
+
limit?: number;
|
|
68
|
+
cursor?: string;
|
|
69
|
+
select?: string[];
|
|
70
|
+
include_deleted?: boolean;
|
|
71
|
+
}
|
|
72
|
+
interface FindResponse<T> {
|
|
73
|
+
data: T[];
|
|
74
|
+
next_cursor?: string | null;
|
|
75
|
+
has_more: boolean;
|
|
76
|
+
}
|
|
77
|
+
interface MediaAsset {
|
|
78
|
+
id: string;
|
|
79
|
+
bucket: string;
|
|
80
|
+
key: string;
|
|
81
|
+
url: string;
|
|
82
|
+
mime_type: string;
|
|
83
|
+
size_bytes: number;
|
|
84
|
+
width?: number | null;
|
|
85
|
+
height?: number | null;
|
|
86
|
+
retention_days?: number | null;
|
|
87
|
+
created_at: string;
|
|
88
|
+
}
|
|
89
|
+
interface PresignData {
|
|
90
|
+
upload_id: string;
|
|
91
|
+
upload_url: string;
|
|
92
|
+
upload_headers: Array<[string, string]>;
|
|
93
|
+
asset_id: string;
|
|
94
|
+
}
|
|
95
|
+
interface PushToken {
|
|
96
|
+
id: string;
|
|
97
|
+
token: string;
|
|
98
|
+
platform: PushPlatform;
|
|
99
|
+
bundle_id?: string | null;
|
|
100
|
+
created_at: string;
|
|
101
|
+
}
|
|
102
|
+
type EntitlementSource = "revenue_cat" | "app_store" | "play_store" | "stripe" | "promo_code" | "manual";
|
|
103
|
+
interface UserEntitlement {
|
|
104
|
+
id: string;
|
|
105
|
+
name: string;
|
|
106
|
+
is_active: boolean;
|
|
107
|
+
source: EntitlementSource;
|
|
108
|
+
expires_at?: string | null;
|
|
109
|
+
granted_at?: string | null;
|
|
110
|
+
metadata: Record<string, unknown>;
|
|
111
|
+
}
|
|
112
|
+
interface AiMessage {
|
|
113
|
+
role: string;
|
|
114
|
+
content: unknown;
|
|
115
|
+
}
|
|
116
|
+
interface AiMessageRequest {
|
|
117
|
+
prompt_slug: string;
|
|
118
|
+
variables?: Record<string, unknown>;
|
|
119
|
+
messages?: AiMessage[];
|
|
120
|
+
max_tokens?: number;
|
|
121
|
+
temperature?: number;
|
|
122
|
+
enable_prompt_cache?: boolean;
|
|
123
|
+
}
|
|
124
|
+
interface AiUsage {
|
|
125
|
+
input_tokens: number;
|
|
126
|
+
output_tokens: number;
|
|
127
|
+
cache_creation_input_tokens?: number;
|
|
128
|
+
cache_read_input_tokens?: number;
|
|
129
|
+
}
|
|
130
|
+
interface AiMessageResponse {
|
|
131
|
+
content: unknown[];
|
|
132
|
+
usage: AiUsage;
|
|
133
|
+
stop_reason?: string | null;
|
|
134
|
+
model: string;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Resolved remote config returned by `config.fetch()`.
|
|
138
|
+
*
|
|
139
|
+
* Server: `GET /v1/client/config` returns body `{ "data": { key → value, ... } }`
|
|
140
|
+
* plus an `ETag` response header carrying the version stamp. `version`
|
|
141
|
+
* is parsed from the ETag prefix; `null` when the server didn't send one.
|
|
142
|
+
*/
|
|
143
|
+
interface ConfigBundle {
|
|
144
|
+
version: string | null;
|
|
145
|
+
values: Record<string, unknown>;
|
|
146
|
+
}
|
|
147
|
+
interface FlagAssignment {
|
|
148
|
+
name: string;
|
|
149
|
+
enabled: boolean;
|
|
150
|
+
variant?: string | null;
|
|
151
|
+
payload?: unknown;
|
|
152
|
+
}
|
|
153
|
+
interface Achievement {
|
|
154
|
+
id: string;
|
|
155
|
+
key: string;
|
|
156
|
+
name: string;
|
|
157
|
+
description?: string | null;
|
|
158
|
+
icon_url?: string | null;
|
|
159
|
+
points: number;
|
|
160
|
+
criteria: unknown;
|
|
161
|
+
}
|
|
162
|
+
interface AchievementProgress {
|
|
163
|
+
achievement_id: string;
|
|
164
|
+
key: string;
|
|
165
|
+
progress: number;
|
|
166
|
+
unlocked: boolean;
|
|
167
|
+
unlocked_at?: string | null;
|
|
168
|
+
}
|
|
169
|
+
interface Challenge {
|
|
170
|
+
id: string;
|
|
171
|
+
key: string;
|
|
172
|
+
name: string;
|
|
173
|
+
description?: string | null;
|
|
174
|
+
starts_at: string;
|
|
175
|
+
ends_at: string;
|
|
176
|
+
criteria: unknown;
|
|
177
|
+
reward: unknown;
|
|
178
|
+
}
|
|
179
|
+
interface ChallengeProgress {
|
|
180
|
+
challenge_id: string;
|
|
181
|
+
progress: number;
|
|
182
|
+
completed: boolean;
|
|
183
|
+
claimed: boolean;
|
|
184
|
+
completed_at?: string | null;
|
|
185
|
+
claimed_at?: string | null;
|
|
186
|
+
}
|
|
187
|
+
interface CurrencyBalance {
|
|
188
|
+
currency_id: string;
|
|
189
|
+
key: string;
|
|
190
|
+
balance: number;
|
|
191
|
+
updated_at: string;
|
|
192
|
+
}
|
|
193
|
+
interface CurrencyTransaction {
|
|
194
|
+
id: string;
|
|
195
|
+
currency_id: string;
|
|
196
|
+
delta: number;
|
|
197
|
+
balance_after: number;
|
|
198
|
+
reason?: string | null;
|
|
199
|
+
created_at: string;
|
|
200
|
+
}
|
|
201
|
+
interface InventoryItem {
|
|
202
|
+
id: string;
|
|
203
|
+
catalog_item_id: string;
|
|
204
|
+
sku: string;
|
|
205
|
+
quantity: number;
|
|
206
|
+
acquired_at: string;
|
|
207
|
+
metadata: unknown;
|
|
208
|
+
}
|
|
209
|
+
interface PurchaseRequest {
|
|
210
|
+
sku: string;
|
|
211
|
+
quantity?: number;
|
|
212
|
+
currency_key?: string;
|
|
213
|
+
}
|
|
214
|
+
interface ConsumeRequest {
|
|
215
|
+
item_id: string;
|
|
216
|
+
quantity: number;
|
|
217
|
+
}
|
|
218
|
+
interface Leaderboard {
|
|
219
|
+
id: string;
|
|
220
|
+
key: string;
|
|
221
|
+
name: string;
|
|
222
|
+
period: string;
|
|
223
|
+
direction: string;
|
|
224
|
+
starts_at?: string | null;
|
|
225
|
+
ends_at?: string | null;
|
|
226
|
+
}
|
|
227
|
+
interface LeaderboardEntry {
|
|
228
|
+
rank: number;
|
|
229
|
+
user_id: string;
|
|
230
|
+
display_name?: string | null;
|
|
231
|
+
avatar_url?: string | null;
|
|
232
|
+
score: number;
|
|
233
|
+
}
|
|
234
|
+
interface Store {
|
|
235
|
+
id: string;
|
|
236
|
+
key: string;
|
|
237
|
+
name: string;
|
|
238
|
+
}
|
|
239
|
+
interface PurchaseOption {
|
|
240
|
+
id: string;
|
|
241
|
+
store_id: string;
|
|
242
|
+
sku: string;
|
|
243
|
+
name: string;
|
|
244
|
+
price_cents: number;
|
|
245
|
+
currency: string;
|
|
246
|
+
period?: string | null;
|
|
247
|
+
metadata: unknown;
|
|
248
|
+
}
|
|
249
|
+
interface PurchaseResult {
|
|
250
|
+
id: string;
|
|
251
|
+
user_id: string;
|
|
252
|
+
purchase_option_id: string;
|
|
253
|
+
status: string;
|
|
254
|
+
purchased_at: string;
|
|
255
|
+
receipt: unknown;
|
|
256
|
+
}
|
|
257
|
+
interface XpBalance {
|
|
258
|
+
user_id: string;
|
|
259
|
+
total_xp: number;
|
|
260
|
+
current_level: number;
|
|
261
|
+
xp_into_level: number;
|
|
262
|
+
xp_to_next_level: number;
|
|
263
|
+
updated_at: string;
|
|
264
|
+
/**
|
|
265
|
+
* XP earned in the current rolling window. Window defined by the
|
|
266
|
+
* project's XP rules; value comes straight from `user_xp.xp_this_period`.
|
|
267
|
+
* Older servers without the field decode as `0`.
|
|
268
|
+
*/
|
|
269
|
+
xp_this_period: number;
|
|
270
|
+
}
|
|
271
|
+
interface XpTransaction {
|
|
272
|
+
id: string;
|
|
273
|
+
delta: number;
|
|
274
|
+
reason?: string | null;
|
|
275
|
+
source?: string | null;
|
|
276
|
+
created_at: string;
|
|
277
|
+
}
|
|
278
|
+
interface Streak {
|
|
279
|
+
id: string;
|
|
280
|
+
key: string;
|
|
281
|
+
name: string;
|
|
282
|
+
current_length: number;
|
|
283
|
+
longest_length: number;
|
|
284
|
+
last_qualified_on?: string | null;
|
|
285
|
+
updated_at: string;
|
|
286
|
+
/**
|
|
287
|
+
* Server-computed lifecycle state: `"active"`, `"qualified_today"`,
|
|
288
|
+
* `"broken"`, or `"frozen"`. Empty string when decoded against an older
|
|
289
|
+
* server that didn't emit it.
|
|
290
|
+
*/
|
|
291
|
+
status: string;
|
|
292
|
+
/** Unused streak-freeze count (auto-granted per the streak definition). */
|
|
293
|
+
freezes_remaining: number;
|
|
294
|
+
}
|
|
295
|
+
interface FeedItem {
|
|
296
|
+
id: string;
|
|
297
|
+
actor_id: string;
|
|
298
|
+
verb: string;
|
|
299
|
+
object_type: string;
|
|
300
|
+
object_id: string;
|
|
301
|
+
target_type?: string | null;
|
|
302
|
+
target_id?: string | null;
|
|
303
|
+
data: unknown;
|
|
304
|
+
created_at: string;
|
|
305
|
+
}
|
|
306
|
+
interface FeedResponse {
|
|
307
|
+
data: FeedItem[];
|
|
308
|
+
next_cursor?: string | null;
|
|
309
|
+
}
|
|
310
|
+
type FriendshipState = "pending" | "accepted" | "blocked" | "declined";
|
|
311
|
+
interface Friendship {
|
|
312
|
+
id: string;
|
|
313
|
+
user_id: string;
|
|
314
|
+
friend_id: string;
|
|
315
|
+
state: FriendshipState;
|
|
316
|
+
created_at: string;
|
|
317
|
+
}
|
|
318
|
+
interface Group {
|
|
319
|
+
id: string;
|
|
320
|
+
name: string;
|
|
321
|
+
description?: string | null;
|
|
322
|
+
avatar_url?: string | null;
|
|
323
|
+
created_by: string;
|
|
324
|
+
member_count: number;
|
|
325
|
+
created_at: string;
|
|
326
|
+
updated_at: string;
|
|
327
|
+
metadata: unknown;
|
|
328
|
+
}
|
|
329
|
+
interface GroupMember {
|
|
330
|
+
group_id: string;
|
|
331
|
+
user_id: string;
|
|
332
|
+
role: string;
|
|
333
|
+
joined_at: string;
|
|
334
|
+
}
|
|
335
|
+
interface GroupCreate {
|
|
336
|
+
name: string;
|
|
337
|
+
description?: string;
|
|
338
|
+
avatar_url?: string;
|
|
339
|
+
metadata?: unknown;
|
|
340
|
+
}
|
|
341
|
+
interface GroupUpdate {
|
|
342
|
+
name?: string;
|
|
343
|
+
description?: string;
|
|
344
|
+
avatar_url?: string;
|
|
345
|
+
metadata?: unknown;
|
|
346
|
+
}
|
|
347
|
+
interface Message {
|
|
348
|
+
id: string;
|
|
349
|
+
conversation_id: string;
|
|
350
|
+
sender_id: string;
|
|
351
|
+
body: string;
|
|
352
|
+
metadata: unknown;
|
|
353
|
+
created_at: string;
|
|
354
|
+
}
|
|
355
|
+
interface Conversation {
|
|
356
|
+
id: string;
|
|
357
|
+
participants: string[];
|
|
358
|
+
last_message?: Message | null;
|
|
359
|
+
created_at: string;
|
|
360
|
+
updated_at: string;
|
|
361
|
+
}
|
|
362
|
+
interface SendMessageRequest {
|
|
363
|
+
conversation_id?: string | null;
|
|
364
|
+
to_user_id?: string | null;
|
|
365
|
+
body: string;
|
|
366
|
+
metadata?: unknown;
|
|
367
|
+
}
|
|
368
|
+
interface Report {
|
|
369
|
+
id: string;
|
|
370
|
+
reporter_id: string;
|
|
371
|
+
target_type: string;
|
|
372
|
+
target_id: string;
|
|
373
|
+
reason: string;
|
|
374
|
+
status: string;
|
|
375
|
+
notes?: string | null;
|
|
376
|
+
created_at: string;
|
|
377
|
+
resolved_at?: string | null;
|
|
378
|
+
}
|
|
379
|
+
interface ReportRequest {
|
|
380
|
+
target_id: string;
|
|
381
|
+
reason: string;
|
|
382
|
+
notes?: string;
|
|
383
|
+
}
|
|
384
|
+
interface ReferralCode {
|
|
385
|
+
id: string;
|
|
386
|
+
code: string;
|
|
387
|
+
owner_id: string;
|
|
388
|
+
uses_count: number;
|
|
389
|
+
max_uses?: number | null;
|
|
390
|
+
expires_at?: string | null;
|
|
391
|
+
created_at: string;
|
|
392
|
+
}
|
|
393
|
+
interface ReferralClaim {
|
|
394
|
+
id: string;
|
|
395
|
+
code_id: string;
|
|
396
|
+
referrer_id: string;
|
|
397
|
+
referee_id: string;
|
|
398
|
+
reward: unknown;
|
|
399
|
+
claimed_at: string;
|
|
400
|
+
}
|
|
401
|
+
interface Review {
|
|
402
|
+
id: string;
|
|
403
|
+
author_id: string;
|
|
404
|
+
target_type: string;
|
|
405
|
+
target_id: string;
|
|
406
|
+
rating: number;
|
|
407
|
+
title?: string | null;
|
|
408
|
+
body?: string | null;
|
|
409
|
+
created_at: string;
|
|
410
|
+
updated_at: string;
|
|
411
|
+
}
|
|
412
|
+
interface ReviewCreate {
|
|
413
|
+
target_type: string;
|
|
414
|
+
target_id: string;
|
|
415
|
+
rating: number;
|
|
416
|
+
title?: string;
|
|
417
|
+
body?: string;
|
|
418
|
+
}
|
|
419
|
+
interface ReviewUpdate {
|
|
420
|
+
rating?: number;
|
|
421
|
+
title?: string;
|
|
422
|
+
body?: string;
|
|
423
|
+
}
|
|
424
|
+
interface Role {
|
|
425
|
+
id: string;
|
|
426
|
+
key: string;
|
|
427
|
+
name: string;
|
|
428
|
+
permissions: string[];
|
|
429
|
+
}
|
|
430
|
+
interface CatalogItem {
|
|
431
|
+
id: string;
|
|
432
|
+
sku: string;
|
|
433
|
+
name: string;
|
|
434
|
+
description?: string | null;
|
|
435
|
+
price_cents?: number | null;
|
|
436
|
+
currency?: string | null;
|
|
437
|
+
metadata: unknown;
|
|
438
|
+
}
|
|
439
|
+
interface ContentItem {
|
|
440
|
+
id: string;
|
|
441
|
+
channel: string;
|
|
442
|
+
title?: string | null;
|
|
443
|
+
body?: string | null;
|
|
444
|
+
data: unknown;
|
|
445
|
+
published_at: string;
|
|
446
|
+
user_state: unknown;
|
|
447
|
+
}
|
|
448
|
+
interface DeepLink {
|
|
449
|
+
id: string;
|
|
450
|
+
url: string;
|
|
451
|
+
short_code: string;
|
|
452
|
+
target_path?: string | null;
|
|
453
|
+
metadata: unknown;
|
|
454
|
+
created_at: string;
|
|
455
|
+
}
|
|
456
|
+
interface DeepLinkCreate {
|
|
457
|
+
target_path: string;
|
|
458
|
+
metadata?: unknown;
|
|
459
|
+
short_code?: string;
|
|
460
|
+
}
|
|
461
|
+
interface OnboardingStatus {
|
|
462
|
+
current_step: string | null;
|
|
463
|
+
completed_steps: string[];
|
|
464
|
+
remaining_steps: string[];
|
|
465
|
+
completed: boolean;
|
|
466
|
+
completed_at?: string | null;
|
|
467
|
+
}
|
|
468
|
+
//#endregion
|
|
469
|
+
//#region src/error.d.ts
|
|
470
|
+
/**
|
|
471
|
+
* Typed error class for the amba SDK + helper that converts arbitrary
|
|
472
|
+
* thrown values (WASM JsError, native Error, plain objects) into a
|
|
473
|
+
* stable `AmbaApiError` instance.
|
|
474
|
+
*
|
|
475
|
+
* Callers can `instanceof`-narrow safely, branch on `.code`, and pull
|
|
476
|
+
* extra payload from `.details` (raw HTTP body, validation field paths,
|
|
477
|
+
* etc.). The wrapper methods on `Amba` wrap every async call in
|
|
478
|
+
* `toAmbaApiError`, so consumers see one error shape regardless of
|
|
479
|
+
* which layer (network, FFI, validation) failed.
|
|
480
|
+
*/
|
|
481
|
+
/**
|
|
482
|
+
* Stable error codes surfaced by the SDK. Strings rather than an enum
|
|
483
|
+
* so customers can extend with custom codes by simply throwing
|
|
484
|
+
* `new AmbaApiError("MY_CODE", "...")` without coordinating with this
|
|
485
|
+
* package's TypeScript types.
|
|
486
|
+
*/
|
|
487
|
+
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 & {});
|
|
488
|
+
declare class AmbaApiError extends Error {
|
|
489
|
+
readonly code: AmbaApiErrorCode;
|
|
490
|
+
readonly details?: unknown;
|
|
491
|
+
constructor(code: AmbaApiErrorCode, message: string, details?: unknown);
|
|
492
|
+
}
|
|
493
|
+
//#endregion
|
|
494
|
+
//#region src/index.d.ts
|
|
495
|
+
/**
|
|
496
|
+
* Top-level SDK namespace for React Native.
|
|
497
|
+
*
|
|
498
|
+
* Differences from `@layers/amba-web`:
|
|
499
|
+
* - `configure` is async (waits for WASM init AND AsyncStorage hydration).
|
|
500
|
+
* - Persistence is AsyncStorage-backed — identity survives app restarts.
|
|
501
|
+
*/
|
|
502
|
+
declare const Amba: {
|
|
503
|
+
configure: (config: AmbaConfig) => Promise<void>;
|
|
504
|
+
readonly anonymousId: string;
|
|
505
|
+
readonly appUserId: string | undefined;
|
|
506
|
+
readonly isAuthenticated: boolean;
|
|
507
|
+
setDebug: (enabled: boolean) => void;
|
|
508
|
+
events: {
|
|
509
|
+
track: (event: string, properties?: Record<string, unknown>) => Promise<void>;
|
|
510
|
+
};
|
|
511
|
+
auth: {
|
|
512
|
+
signInAnonymously: () => Promise<AuthResult>;
|
|
513
|
+
signInWithEmail: (email: string, password: string) => Promise<AuthResult>;
|
|
514
|
+
signUpWithEmail: (email: string, password: string) => Promise<AuthResult>;
|
|
515
|
+
/**
|
|
516
|
+
* Sign in with an Apple / Google identity token. The host app obtains
|
|
517
|
+
* the token via `expo-apple-authentication` or `expo-auth-session`.
|
|
518
|
+
*/
|
|
519
|
+
signInWithSocial: (provider: SocialProvider, idToken: string) => Promise<AuthResult>;
|
|
520
|
+
signOut: (rotateAnonymousId?: boolean) => Promise<void>;
|
|
521
|
+
refresh: () => Promise<AuthResult>;
|
|
522
|
+
me: () => Promise<User>;
|
|
523
|
+
/** Snapshot the current session, or null if not authenticated. */
|
|
524
|
+
getSession: () => Promise<Session | null>;
|
|
525
|
+
/** Stable anonymous identifier. */
|
|
526
|
+
getAnonymousId: () => Promise<string>;
|
|
527
|
+
/**
|
|
528
|
+
* Subscribe to session changes. Fires after every signIn* / signUp* /
|
|
529
|
+
* refresh / signOut. Returns an unsubscribe function.
|
|
530
|
+
*/
|
|
531
|
+
onAuthStateChange: (cb: (session: Session | null) => void) => (() => void);
|
|
532
|
+
};
|
|
533
|
+
collections: {
|
|
534
|
+
find: <T = unknown>(name: string, options?: FindOptions) => Promise<FindResponse<T>>;
|
|
535
|
+
findOne: <T = unknown>(name: string, id: string) => Promise<T>;
|
|
536
|
+
insert: <T = unknown>(name: string, row: Record<string, unknown>) => Promise<T>;
|
|
537
|
+
update: <T = unknown>(name: string, id: string, set: Record<string, unknown>) => Promise<T>;
|
|
538
|
+
delete: (name: string, id: string) => Promise<{
|
|
539
|
+
data: {
|
|
540
|
+
deleted: boolean;
|
|
541
|
+
};
|
|
542
|
+
}>;
|
|
543
|
+
where: {
|
|
544
|
+
eq: (column: string, value: FilterValue) => Filter;
|
|
545
|
+
ne: (column: string, value: FilterValue) => Filter;
|
|
546
|
+
gt: (column: string, value: FilterValue) => Filter;
|
|
547
|
+
gte: (column: string, value: FilterValue) => Filter;
|
|
548
|
+
lt: (column: string, value: FilterValue) => Filter;
|
|
549
|
+
lte: (column: string, value: FilterValue) => Filter;
|
|
550
|
+
in: (column: string, values: FilterValue[]) => Filter;
|
|
551
|
+
notIn: (column: string, values: FilterValue[]) => Filter;
|
|
552
|
+
like: (column: string, pattern: string) => Filter;
|
|
553
|
+
ilike: (column: string, pattern: string) => Filter;
|
|
554
|
+
isNull: (column: string) => Filter;
|
|
555
|
+
isNotNull: (column: string) => Filter;
|
|
556
|
+
and: (...filters: Filter[]) => Filter;
|
|
557
|
+
or: (...filters: Filter[]) => Filter;
|
|
558
|
+
not: (filter: Filter) => Filter;
|
|
559
|
+
};
|
|
560
|
+
};
|
|
561
|
+
storage: {
|
|
562
|
+
presign: (params: {
|
|
563
|
+
bucket: string;
|
|
564
|
+
filename: string;
|
|
565
|
+
mimeType: string;
|
|
566
|
+
sizeBytes: number;
|
|
567
|
+
retentionDays?: number;
|
|
568
|
+
}) => Promise<PresignData>;
|
|
569
|
+
commit: (uploadId: string, assetId: string) => Promise<MediaAsset>;
|
|
570
|
+
};
|
|
571
|
+
push: {
|
|
572
|
+
/**
|
|
573
|
+
* Register a native push token. On iOS, pass the APNs token from
|
|
574
|
+
* `expo-notifications` `getDevicePushTokenAsync()` with platform `'apns'`.
|
|
575
|
+
* On Android, pass the FCM token with platform `'fcm'`.
|
|
576
|
+
*/
|
|
577
|
+
register: (token: string, platform: PushPlatform, bundleId?: string) => Promise<PushToken>;
|
|
578
|
+
unregister: (token: string) => Promise<void>;
|
|
579
|
+
getTokens: () => Promise<PushToken[]>;
|
|
580
|
+
subscribe: (topic: string) => Promise<void>;
|
|
581
|
+
unsubscribe: (topic: string) => Promise<void>;
|
|
582
|
+
};
|
|
583
|
+
entitlements: {
|
|
584
|
+
list: () => Promise<UserEntitlement[]>;
|
|
585
|
+
has: (name: string) => Promise<boolean>;
|
|
586
|
+
};
|
|
587
|
+
ai: {
|
|
588
|
+
anthropic: {
|
|
589
|
+
messages: {
|
|
590
|
+
create: (request: AiMessageRequest) => Promise<AiMessageResponse>;
|
|
591
|
+
};
|
|
592
|
+
};
|
|
593
|
+
};
|
|
594
|
+
config: {
|
|
595
|
+
fetch: () => Promise<ConfigBundle>;
|
|
596
|
+
};
|
|
597
|
+
flags: {
|
|
598
|
+
fetch: () => Promise<FlagAssignment[]>;
|
|
599
|
+
};
|
|
600
|
+
achievements: {
|
|
601
|
+
getAll: () => Promise<Achievement[]>;
|
|
602
|
+
getProgress: () => Promise<AchievementProgress[]>;
|
|
603
|
+
};
|
|
604
|
+
challenges: {
|
|
605
|
+
getActive: () => Promise<Challenge[]>;
|
|
606
|
+
get: (id: string) => Promise<Challenge>;
|
|
607
|
+
getProgress: (id: string) => Promise<ChallengeProgress>;
|
|
608
|
+
claim: (id: string) => Promise<ChallengeProgress>;
|
|
609
|
+
};
|
|
610
|
+
currencies: {
|
|
611
|
+
getBalance: () => Promise<CurrencyBalance[]>;
|
|
612
|
+
getTransactions: (currencyKey: string) => Promise<CurrencyTransaction[]>;
|
|
613
|
+
};
|
|
614
|
+
inventory: {
|
|
615
|
+
getItems: () => Promise<InventoryItem[]>;
|
|
616
|
+
getItem: (id: string) => Promise<InventoryItem>;
|
|
617
|
+
purchase: (request: PurchaseRequest) => Promise<InventoryItem>;
|
|
618
|
+
consume: (request: ConsumeRequest) => Promise<InventoryItem>;
|
|
619
|
+
};
|
|
620
|
+
leaderboards: {
|
|
621
|
+
get: (key: string) => Promise<Leaderboard>;
|
|
622
|
+
getEntries: (key: string, limit?: number) => Promise<LeaderboardEntry[]>;
|
|
623
|
+
getMyRank: (key: string) => Promise<LeaderboardEntry>;
|
|
624
|
+
};
|
|
625
|
+
stores: {
|
|
626
|
+
list: () => Promise<Store[]>;
|
|
627
|
+
getPurchaseOptions: (storeKey: string) => Promise<PurchaseOption[]>;
|
|
628
|
+
purchase: (storeKey: string, purchaseOptionId: string, receipt: unknown) => Promise<PurchaseResult>;
|
|
629
|
+
};
|
|
630
|
+
xp: {
|
|
631
|
+
getBalance: () => Promise<XpBalance>;
|
|
632
|
+
getHistory: (limit?: number) => Promise<XpTransaction[]>;
|
|
633
|
+
claim: (grantKey: string) => Promise<XpTransaction>;
|
|
634
|
+
};
|
|
635
|
+
streaks: {
|
|
636
|
+
getAll: () => Promise<Streak[]>;
|
|
637
|
+
qualify: (streakKey: string) => Promise<Streak>;
|
|
638
|
+
};
|
|
639
|
+
feeds: {
|
|
640
|
+
getActivity: (feed?: string, cursor?: string) => Promise<FeedResponse>;
|
|
641
|
+
};
|
|
642
|
+
friends: {
|
|
643
|
+
getList: () => Promise<Friendship[]>;
|
|
644
|
+
getFriends: () => Promise<Friendship[]>;
|
|
645
|
+
blockUser: (userId: string) => Promise<Friendship>;
|
|
646
|
+
unblockUser: (userId: string) => Promise<void>;
|
|
647
|
+
removeBlock: (friendshipId: string) => Promise<void>;
|
|
648
|
+
};
|
|
649
|
+
groups: {
|
|
650
|
+
create: (params: GroupCreate) => Promise<Group>;
|
|
651
|
+
get: (id: string) => Promise<Group>;
|
|
652
|
+
update: (id: string, patch: GroupUpdate) => Promise<Group>;
|
|
653
|
+
delete: (id: string) => Promise<void>;
|
|
654
|
+
getMembers: (id: string) => Promise<GroupMember[]>;
|
|
655
|
+
join: (id: string) => Promise<GroupMember>;
|
|
656
|
+
leave: (id: string) => Promise<void>;
|
|
657
|
+
invite: (id: string, userId: string) => Promise<GroupMember>;
|
|
658
|
+
};
|
|
659
|
+
messaging: {
|
|
660
|
+
getConversations: () => Promise<Conversation[]>;
|
|
661
|
+
getMessage: (id: string) => Promise<Message>;
|
|
662
|
+
sendMessage: (request: SendMessageRequest) => Promise<Message>;
|
|
663
|
+
};
|
|
664
|
+
moderation: {
|
|
665
|
+
reportUser: (request: ReportRequest) => Promise<Report>;
|
|
666
|
+
reportContent: (request: ReportRequest) => Promise<Report>;
|
|
667
|
+
getReportStatus: (id: string) => Promise<Report>;
|
|
668
|
+
};
|
|
669
|
+
reviews: {
|
|
670
|
+
list: (targetType: string, targetId: string) => Promise<Review[]>;
|
|
671
|
+
create: (params: ReviewCreate) => Promise<Review>;
|
|
672
|
+
update: (id: string, patch: ReviewUpdate) => Promise<Review>;
|
|
673
|
+
delete: (id: string) => Promise<void>;
|
|
674
|
+
};
|
|
675
|
+
roles: {
|
|
676
|
+
getMyRoles: () => Promise<Role[]>;
|
|
677
|
+
hasPermission: (permission: string) => Promise<boolean>;
|
|
678
|
+
};
|
|
679
|
+
referrals: {
|
|
680
|
+
getReferralCode: () => Promise<ReferralCode>;
|
|
681
|
+
claimReferral: (code: string) => Promise<ReferralClaim>;
|
|
682
|
+
create: (code?: string, maxUses?: number) => Promise<ReferralCode>;
|
|
683
|
+
};
|
|
684
|
+
catalog: {
|
|
685
|
+
list: () => Promise<CatalogItem[]>;
|
|
686
|
+
};
|
|
687
|
+
content: {
|
|
688
|
+
/**
|
|
689
|
+
* Get today's published item for `channel`. Defaults to `"default"`
|
|
690
|
+
* so single-channel apps can call `Amba.content.getToday()` bare.
|
|
691
|
+
*/
|
|
692
|
+
getToday: (channel?: string) => Promise<ContentItem | null>;
|
|
693
|
+
/**
|
|
694
|
+
* Paginated library list for `channel`. `options.limit` caps page size;
|
|
695
|
+
* `options.cursor` is the opaque token returned by a prior page.
|
|
696
|
+
*/
|
|
697
|
+
getLibrary: (channel?: string, options?: {
|
|
698
|
+
limit?: number;
|
|
699
|
+
cursor?: string;
|
|
700
|
+
}) => Promise<ContentItem[]>;
|
|
701
|
+
getItem: (id: string) => Promise<ContentItem>;
|
|
702
|
+
updateItem: (id: string, state: unknown) => Promise<ContentItem>;
|
|
703
|
+
createItem: (channel: string, item: unknown) => Promise<ContentItem>;
|
|
704
|
+
};
|
|
705
|
+
deepLinks: {
|
|
706
|
+
get: (shortCode: string) => Promise<DeepLink>;
|
|
707
|
+
create: (params: DeepLinkCreate) => Promise<DeepLink>;
|
|
708
|
+
};
|
|
709
|
+
onboarding: {
|
|
710
|
+
getStatus: () => Promise<OnboardingStatus>;
|
|
711
|
+
nextStep: (payload: unknown) => Promise<OnboardingStatus>;
|
|
712
|
+
skipStep: () => Promise<OnboardingStatus>;
|
|
713
|
+
complete: () => Promise<OnboardingStatus>;
|
|
714
|
+
};
|
|
715
|
+
};
|
|
716
|
+
declare const SDK_VERSION = "0.1.0";
|
|
717
|
+
//#endregion
|
|
718
|
+
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 };
|
|
719
|
+
//# sourceMappingURL=index.d.cts.map
|