@omen.dog/sdk 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 +147 -0
- package/dist/creation.d.ts +116 -0
- package/dist/index.d.mts +559 -0
- package/dist/index.d.ts +559 -0
- package/dist/index.js +542 -0
- package/dist/index.mjs +510 -0
- package/package.json +44 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,559 @@
|
|
|
1
|
+
interface RequestOptions {
|
|
2
|
+
method?: string;
|
|
3
|
+
body?: unknown;
|
|
4
|
+
query?: Record<string, string | number | boolean | undefined>;
|
|
5
|
+
headers?: Record<string, string>;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Low-level HTTP client. All namespace methods delegate to this.
|
|
9
|
+
* Not exported — consumers use OmenClient directly.
|
|
10
|
+
*/
|
|
11
|
+
declare class HttpClient {
|
|
12
|
+
readonly baseUrl: string;
|
|
13
|
+
private readonly token;
|
|
14
|
+
constructor(token: string, baseUrl: string);
|
|
15
|
+
request<T = unknown>(path: string, opts?: RequestOptions): Promise<T>;
|
|
16
|
+
private handleError;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface OmenClientOptions {
|
|
20
|
+
/** Developer token (starts with `dev_`). Required. */
|
|
21
|
+
token: string;
|
|
22
|
+
/** Base URL for the Omen API. Defaults to `https://omen.dog`. */
|
|
23
|
+
baseUrl?: string;
|
|
24
|
+
}
|
|
25
|
+
interface UserProfile {
|
|
26
|
+
id: string;
|
|
27
|
+
username: string;
|
|
28
|
+
name: string | null;
|
|
29
|
+
image: string | null;
|
|
30
|
+
bio: string | null;
|
|
31
|
+
moodEmoji: string | null;
|
|
32
|
+
moodText: string | null;
|
|
33
|
+
theme: string | null;
|
|
34
|
+
accentColor: string | null;
|
|
35
|
+
totalStarsReceived: number;
|
|
36
|
+
prestigeTier: string | null;
|
|
37
|
+
createdAt: string;
|
|
38
|
+
}
|
|
39
|
+
interface UserProfileResponse {
|
|
40
|
+
user: UserProfile;
|
|
41
|
+
viewerContext: 'owner' | 'friend' | 'user' | 'anonymous';
|
|
42
|
+
isOwner: boolean;
|
|
43
|
+
stats: {
|
|
44
|
+
creationsCount: number;
|
|
45
|
+
itemsCount: number;
|
|
46
|
+
badgesCount: number;
|
|
47
|
+
};
|
|
48
|
+
pinnedCreations: PinnedCreation[];
|
|
49
|
+
featuredItems: FeaturedItem[];
|
|
50
|
+
badges: Badge[];
|
|
51
|
+
friends: Friend[];
|
|
52
|
+
}
|
|
53
|
+
interface PinnedCreation {
|
|
54
|
+
id: string;
|
|
55
|
+
name: string;
|
|
56
|
+
slug: string;
|
|
57
|
+
thumbnailUrl: string | null;
|
|
58
|
+
liveUrl: string | null;
|
|
59
|
+
category: string | null;
|
|
60
|
+
hostingType: string;
|
|
61
|
+
iconUrl: string | null;
|
|
62
|
+
starCount: number;
|
|
63
|
+
uniqueUserCount: number;
|
|
64
|
+
}
|
|
65
|
+
interface FeaturedItem {
|
|
66
|
+
id: string;
|
|
67
|
+
name: string;
|
|
68
|
+
imageUrl: string | null;
|
|
69
|
+
thumbnailUrl: string | null;
|
|
70
|
+
rarity: string | null;
|
|
71
|
+
type: string | null;
|
|
72
|
+
}
|
|
73
|
+
interface Badge {
|
|
74
|
+
id: string;
|
|
75
|
+
name: string;
|
|
76
|
+
description: string | null;
|
|
77
|
+
imageUrl: string | null;
|
|
78
|
+
category: string | null;
|
|
79
|
+
tier: string | null;
|
|
80
|
+
org: {
|
|
81
|
+
id: string;
|
|
82
|
+
name: string;
|
|
83
|
+
image: string | null;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
interface Friend {
|
|
87
|
+
user: {
|
|
88
|
+
id: string;
|
|
89
|
+
username: string;
|
|
90
|
+
name: string | null;
|
|
91
|
+
image: string | null;
|
|
92
|
+
prestigeTier: string | null;
|
|
93
|
+
};
|
|
94
|
+
presence: {
|
|
95
|
+
status: 'offline' | 'online' | 'playing';
|
|
96
|
+
presenceText?: string;
|
|
97
|
+
lastSeenAt?: string;
|
|
98
|
+
};
|
|
99
|
+
acceptedAt: string;
|
|
100
|
+
friendshipId: string;
|
|
101
|
+
creationCount: number;
|
|
102
|
+
}
|
|
103
|
+
interface FriendsListOptions {
|
|
104
|
+
status?: 'online' | 'offline';
|
|
105
|
+
sort?: 'active' | 'stars' | 'creations' | 'alpha' | 'newest';
|
|
106
|
+
search?: string;
|
|
107
|
+
cursor?: string;
|
|
108
|
+
limit?: number;
|
|
109
|
+
}
|
|
110
|
+
interface FriendsListResponse {
|
|
111
|
+
friends: Friend[];
|
|
112
|
+
total: number;
|
|
113
|
+
onlineCount: number;
|
|
114
|
+
nextCursor: string | null;
|
|
115
|
+
}
|
|
116
|
+
interface StorageData {
|
|
117
|
+
data: Record<string, unknown>;
|
|
118
|
+
}
|
|
119
|
+
type ItemType = 'avatar_trait' | 'collectible' | 'achievement' | 'in_game_item' | 'physical_good' | 'profile_decoration';
|
|
120
|
+
type AcquisitionType = 'purchase' | 'transfer' | 'gift' | 'earn' | 'redeem' | 'mint';
|
|
121
|
+
interface IssueItemOptions {
|
|
122
|
+
userId: string;
|
|
123
|
+
templateId?: string;
|
|
124
|
+
name?: string;
|
|
125
|
+
type?: ItemType;
|
|
126
|
+
description?: string;
|
|
127
|
+
imageUrl?: string;
|
|
128
|
+
thumbnailUrl?: string;
|
|
129
|
+
rarity?: string;
|
|
130
|
+
metadata?: Record<string, unknown>;
|
|
131
|
+
tags?: string[];
|
|
132
|
+
acquisitionType?: AcquisitionType;
|
|
133
|
+
transferable?: boolean;
|
|
134
|
+
listable?: boolean;
|
|
135
|
+
soulbound?: boolean;
|
|
136
|
+
}
|
|
137
|
+
interface Item {
|
|
138
|
+
id: string;
|
|
139
|
+
name: string;
|
|
140
|
+
type: ItemType;
|
|
141
|
+
ownerId: string;
|
|
142
|
+
originAppId: string;
|
|
143
|
+
templateId: string | null;
|
|
144
|
+
description: string | null;
|
|
145
|
+
imageUrl: string | null;
|
|
146
|
+
thumbnailUrl: string | null;
|
|
147
|
+
rarity: string | null;
|
|
148
|
+
editionNumber: number | null;
|
|
149
|
+
metadata: Record<string, unknown> | null;
|
|
150
|
+
tags: string[];
|
|
151
|
+
acquisitionType: AcquisitionType;
|
|
152
|
+
transferable: boolean;
|
|
153
|
+
listable: boolean;
|
|
154
|
+
soulbound: boolean;
|
|
155
|
+
acquiredAt: string;
|
|
156
|
+
revokedAt: string | null;
|
|
157
|
+
revokedReason: string | null;
|
|
158
|
+
}
|
|
159
|
+
interface BatchIssueResponse {
|
|
160
|
+
items: Item[];
|
|
161
|
+
count: number;
|
|
162
|
+
}
|
|
163
|
+
type SchemaFieldType = 'string' | 'number' | 'boolean' | 'date';
|
|
164
|
+
interface CreateCollectionOptions {
|
|
165
|
+
name: string;
|
|
166
|
+
schema?: Record<string, SchemaFieldType>;
|
|
167
|
+
indexedFields?: string[];
|
|
168
|
+
}
|
|
169
|
+
interface Collection {
|
|
170
|
+
name: string;
|
|
171
|
+
schema: Record<string, SchemaFieldType> | null;
|
|
172
|
+
indexedFields: string[];
|
|
173
|
+
documentCount: number;
|
|
174
|
+
maxDocuments: number;
|
|
175
|
+
createdAt: string;
|
|
176
|
+
}
|
|
177
|
+
interface Document {
|
|
178
|
+
id: string;
|
|
179
|
+
data: Record<string, unknown>;
|
|
180
|
+
ownerId: string | null;
|
|
181
|
+
createdAt: string;
|
|
182
|
+
updatedAt: string;
|
|
183
|
+
}
|
|
184
|
+
interface QueryDocumentsOptions {
|
|
185
|
+
where?: Record<string, unknown>;
|
|
186
|
+
sort?: Record<string, 1 | -1>;
|
|
187
|
+
limit?: number;
|
|
188
|
+
offset?: number;
|
|
189
|
+
count?: boolean;
|
|
190
|
+
}
|
|
191
|
+
interface QueryDocumentsResponse {
|
|
192
|
+
documents: Document[];
|
|
193
|
+
total?: number;
|
|
194
|
+
}
|
|
195
|
+
interface TransactionOperation {
|
|
196
|
+
type: 'get' | 'insert' | 'update' | 'delete';
|
|
197
|
+
id?: string;
|
|
198
|
+
data?: Record<string, unknown>;
|
|
199
|
+
merge?: boolean;
|
|
200
|
+
}
|
|
201
|
+
interface TransactionResponse {
|
|
202
|
+
results: Array<null | Document | {
|
|
203
|
+
deleted: string;
|
|
204
|
+
}>;
|
|
205
|
+
}
|
|
206
|
+
interface CreateWebhookOptions {
|
|
207
|
+
url: string;
|
|
208
|
+
events: string[];
|
|
209
|
+
}
|
|
210
|
+
interface Webhook {
|
|
211
|
+
id: string;
|
|
212
|
+
appId: string;
|
|
213
|
+
url: string;
|
|
214
|
+
events: string[];
|
|
215
|
+
secret?: string;
|
|
216
|
+
createdAt: string;
|
|
217
|
+
updatedAt: string;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/** Read-only access to Omen user profiles and friend lists. */
|
|
221
|
+
declare class UsersNamespace {
|
|
222
|
+
private readonly http;
|
|
223
|
+
constructor(http: HttpClient);
|
|
224
|
+
/**
|
|
225
|
+
* Get a user's profile by ID or username.
|
|
226
|
+
*
|
|
227
|
+
* @example
|
|
228
|
+
* ```ts
|
|
229
|
+
* const profile = await omen.users.get('pistolphoenix');
|
|
230
|
+
* console.log(profile.user.username, profile.stats.creationsCount);
|
|
231
|
+
* ```
|
|
232
|
+
*/
|
|
233
|
+
get(userId: string): Promise<UserProfileResponse>;
|
|
234
|
+
/**
|
|
235
|
+
* Get a user's friend list with optional filtering and pagination.
|
|
236
|
+
*
|
|
237
|
+
* @example
|
|
238
|
+
* ```ts
|
|
239
|
+
* const { friends, onlineCount } = await omen.users.friends('pistolphoenix', {
|
|
240
|
+
* status: 'online',
|
|
241
|
+
* limit: 10,
|
|
242
|
+
* });
|
|
243
|
+
* ```
|
|
244
|
+
*/
|
|
245
|
+
friends(userId: string, options?: FriendsListOptions): Promise<FriendsListResponse>;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Per-user key-value storage for your app.
|
|
250
|
+
*
|
|
251
|
+
* Each user gets one JSON blob scoped to your app. Use `set()` to replace it entirely
|
|
252
|
+
* or `merge()` to shallow-merge fields into the existing blob.
|
|
253
|
+
*/
|
|
254
|
+
declare class StorageNamespace {
|
|
255
|
+
private readonly http;
|
|
256
|
+
constructor(http: HttpClient);
|
|
257
|
+
/**
|
|
258
|
+
* Get the current user's stored data for your app.
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* ```ts
|
|
262
|
+
* const { data } = await omen.storage.get();
|
|
263
|
+
* console.log(data.highScore);
|
|
264
|
+
* ```
|
|
265
|
+
*/
|
|
266
|
+
get(): Promise<StorageData>;
|
|
267
|
+
/**
|
|
268
|
+
* Replace the current user's stored data entirely.
|
|
269
|
+
*
|
|
270
|
+
* @example
|
|
271
|
+
* ```ts
|
|
272
|
+
* await omen.storage.set({ highScore: 100, level: 5 });
|
|
273
|
+
* ```
|
|
274
|
+
*/
|
|
275
|
+
set(data: Record<string, unknown>): Promise<StorageData>;
|
|
276
|
+
/**
|
|
277
|
+
* Shallow-merge fields into the current user's stored data.
|
|
278
|
+
* Existing fields not in the payload are preserved.
|
|
279
|
+
*
|
|
280
|
+
* @example
|
|
281
|
+
* ```ts
|
|
282
|
+
* await omen.storage.merge({ highScore: 200 }); // keeps 'level' intact
|
|
283
|
+
* ```
|
|
284
|
+
*/
|
|
285
|
+
merge(data: Record<string, unknown>): Promise<StorageData>;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Issue, revoke, and manage items for users in your app.
|
|
290
|
+
*
|
|
291
|
+
* Items are cross-app assets (achievements, collectibles, in-game items) that
|
|
292
|
+
* users own and can display on their profile.
|
|
293
|
+
*/
|
|
294
|
+
declare class ItemsNamespace {
|
|
295
|
+
private readonly http;
|
|
296
|
+
private readonly appId;
|
|
297
|
+
constructor(http: HttpClient, appId: string);
|
|
298
|
+
/**
|
|
299
|
+
* Issue a single item to a user.
|
|
300
|
+
*
|
|
301
|
+
* @example
|
|
302
|
+
* ```ts
|
|
303
|
+
* const item = await omen.items.issue({
|
|
304
|
+
* userId: 'cmm0tzco8...',
|
|
305
|
+
* name: 'Dragon Slayer Badge',
|
|
306
|
+
* type: 'achievement',
|
|
307
|
+
* rarity: 'legendary',
|
|
308
|
+
* });
|
|
309
|
+
* ```
|
|
310
|
+
*/
|
|
311
|
+
issue(options: IssueItemOptions): Promise<Item>;
|
|
312
|
+
/**
|
|
313
|
+
* Issue multiple items in one request. Maximum 100 items per batch.
|
|
314
|
+
*
|
|
315
|
+
* @example
|
|
316
|
+
* ```ts
|
|
317
|
+
* const { items, count } = await omen.items.issueBatch([
|
|
318
|
+
* { userId: 'user1', name: 'Gold Medal', type: 'achievement' },
|
|
319
|
+
* { userId: 'user2', name: 'Silver Medal', type: 'achievement' },
|
|
320
|
+
* ]);
|
|
321
|
+
* ```
|
|
322
|
+
*/
|
|
323
|
+
issueBatch(items: IssueItemOptions[]): Promise<BatchIssueResponse>;
|
|
324
|
+
/**
|
|
325
|
+
* Revoke an item. Idempotent — re-revoking a revoked item returns 200.
|
|
326
|
+
*
|
|
327
|
+
* @example
|
|
328
|
+
* ```ts
|
|
329
|
+
* await omen.items.revoke('item_abc123', 'Violated terms of service');
|
|
330
|
+
* ```
|
|
331
|
+
*/
|
|
332
|
+
revoke(itemId: string, reason?: string): Promise<Item>;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Structured data collections — like a simple document database scoped to your app.
|
|
337
|
+
*
|
|
338
|
+
* Collections have optional schemas, indexed fields, and support queries with
|
|
339
|
+
* filtering, sorting, and pagination.
|
|
340
|
+
*/
|
|
341
|
+
declare class CollectionsNamespace {
|
|
342
|
+
private readonly http;
|
|
343
|
+
private readonly appId;
|
|
344
|
+
constructor(http: HttpClient, appId: string);
|
|
345
|
+
/**
|
|
346
|
+
* Create a new collection.
|
|
347
|
+
*
|
|
348
|
+
* @example
|
|
349
|
+
* ```ts
|
|
350
|
+
* const col = await omen.collections.create({
|
|
351
|
+
* name: 'player_stats',
|
|
352
|
+
* schema: { score: 'number', level: 'number', name: 'string' },
|
|
353
|
+
* indexedFields: ['score'],
|
|
354
|
+
* });
|
|
355
|
+
* ```
|
|
356
|
+
*/
|
|
357
|
+
create(options: CreateCollectionOptions): Promise<Collection>;
|
|
358
|
+
/** List all collections for your app. */
|
|
359
|
+
list(): Promise<{
|
|
360
|
+
collections: Collection[];
|
|
361
|
+
}>;
|
|
362
|
+
/** Get a single collection by name. */
|
|
363
|
+
get(name: string): Promise<Collection>;
|
|
364
|
+
/**
|
|
365
|
+
* Delete a collection and all its documents. This is irreversible.
|
|
366
|
+
*/
|
|
367
|
+
delete(name: string): Promise<{
|
|
368
|
+
deleted: true;
|
|
369
|
+
}>;
|
|
370
|
+
/**
|
|
371
|
+
* Insert a single document into a collection.
|
|
372
|
+
*
|
|
373
|
+
* @example
|
|
374
|
+
* ```ts
|
|
375
|
+
* const doc = await omen.collections.insert('player_stats', {
|
|
376
|
+
* score: 1500,
|
|
377
|
+
* level: 12,
|
|
378
|
+
* name: 'PistolPhoenix',
|
|
379
|
+
* });
|
|
380
|
+
* ```
|
|
381
|
+
*/
|
|
382
|
+
insert(collection: string, data: Record<string, unknown>): Promise<Document>;
|
|
383
|
+
/**
|
|
384
|
+
* Insert multiple documents at once. Maximum 100 per batch.
|
|
385
|
+
*/
|
|
386
|
+
insertBatch(collection: string, documents: Record<string, unknown>[]): Promise<{
|
|
387
|
+
documents: Document[];
|
|
388
|
+
count: number;
|
|
389
|
+
}>;
|
|
390
|
+
/**
|
|
391
|
+
* Query documents with optional filtering, sorting, and pagination.
|
|
392
|
+
*
|
|
393
|
+
* @example
|
|
394
|
+
* ```ts
|
|
395
|
+
* const { documents } = await omen.collections.query('player_stats', {
|
|
396
|
+
* where: { level: { $gte: 10 } },
|
|
397
|
+
* sort: { score: -1 },
|
|
398
|
+
* limit: 20,
|
|
399
|
+
* });
|
|
400
|
+
* ```
|
|
401
|
+
*/
|
|
402
|
+
query(collection: string, options?: QueryDocumentsOptions): Promise<QueryDocumentsResponse>;
|
|
403
|
+
/** Get a single document by ID. */
|
|
404
|
+
getDocument(collection: string, documentId: string): Promise<Document>;
|
|
405
|
+
/** Update a document's data (shallow merge). */
|
|
406
|
+
updateDocument(collection: string, documentId: string, data: Record<string, unknown>): Promise<Document>;
|
|
407
|
+
/** Delete a single document. */
|
|
408
|
+
deleteDocument(collection: string, documentId: string): Promise<{
|
|
409
|
+
deleted: true;
|
|
410
|
+
}>;
|
|
411
|
+
/** Get the document count for a collection, with optional filter. */
|
|
412
|
+
count(collection: string, where?: Record<string, unknown>): Promise<{
|
|
413
|
+
count: number;
|
|
414
|
+
}>;
|
|
415
|
+
/**
|
|
416
|
+
* Execute up to 5 operations atomically (Pro+ tier).
|
|
417
|
+
*
|
|
418
|
+
* @example
|
|
419
|
+
* ```ts
|
|
420
|
+
* const { results } = await omen.collections.transaction('game_state', [
|
|
421
|
+
* { type: 'get', id: 'player_1' },
|
|
422
|
+
* { type: 'update', id: 'player_1', data: { health: 50 } },
|
|
423
|
+
* ]);
|
|
424
|
+
* ```
|
|
425
|
+
*/
|
|
426
|
+
transaction(collection: string, operations: TransactionOperation[]): Promise<TransactionResponse>;
|
|
427
|
+
private docsPath;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Manage webhook endpoints and verify incoming webhook signatures.
|
|
432
|
+
*/
|
|
433
|
+
declare class WebhooksNamespace {
|
|
434
|
+
private readonly http;
|
|
435
|
+
private readonly appId;
|
|
436
|
+
constructor(http: HttpClient, appId: string);
|
|
437
|
+
/**
|
|
438
|
+
* Register a new webhook endpoint.
|
|
439
|
+
* The `secret` field is only returned on creation — store it securely.
|
|
440
|
+
*
|
|
441
|
+
* @example
|
|
442
|
+
* ```ts
|
|
443
|
+
* const webhook = await omen.webhooks.create({
|
|
444
|
+
* url: 'https://myapp.com/webhooks/omen',
|
|
445
|
+
* events: ['item.issued', 'friend.added'],
|
|
446
|
+
* });
|
|
447
|
+
* console.log(webhook.secret); // save this!
|
|
448
|
+
* ```
|
|
449
|
+
*/
|
|
450
|
+
create(options: CreateWebhookOptions): Promise<Webhook>;
|
|
451
|
+
/** List all webhook endpoints for your app. Secrets are not included. */
|
|
452
|
+
list(): Promise<{
|
|
453
|
+
endpoints: Webhook[];
|
|
454
|
+
}>;
|
|
455
|
+
/** Get a single webhook endpoint. Secret is not included. */
|
|
456
|
+
get(endpointId: string): Promise<Webhook>;
|
|
457
|
+
/** Delete a webhook endpoint. */
|
|
458
|
+
delete(endpointId: string): Promise<{
|
|
459
|
+
deleted: true;
|
|
460
|
+
}>;
|
|
461
|
+
/**
|
|
462
|
+
* Verify an incoming webhook signature. Use this in your webhook handler
|
|
463
|
+
* to confirm the request came from Omen.
|
|
464
|
+
*
|
|
465
|
+
* @param payload - The raw request body string.
|
|
466
|
+
* @param signature - The `X-Omen-Signature` header value.
|
|
467
|
+
* @param secret - The webhook secret from `create()`.
|
|
468
|
+
* @returns `true` if the signature is valid.
|
|
469
|
+
*
|
|
470
|
+
* @example
|
|
471
|
+
* ```ts
|
|
472
|
+
* app.post('/webhooks/omen', (req, res) => {
|
|
473
|
+
* const valid = omen.webhooks.verify(
|
|
474
|
+
* req.body, // raw string
|
|
475
|
+
* req.headers['x-omen-signature'],
|
|
476
|
+
* process.env.OMEN_WEBHOOK_SECRET,
|
|
477
|
+
* );
|
|
478
|
+
* if (!valid) return res.status(401).send('Bad signature');
|
|
479
|
+
* // handle event...
|
|
480
|
+
* });
|
|
481
|
+
* ```
|
|
482
|
+
*/
|
|
483
|
+
verify(payload: string, signature: string, secret: string): Promise<boolean>;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
/** Base error for all Omen SDK errors. */
|
|
487
|
+
declare class OmenError extends Error {
|
|
488
|
+
/** HTTP status code from the API. */
|
|
489
|
+
readonly status: number;
|
|
490
|
+
/** Machine-readable error code (e.g. "RATE_LIMITED", "NOT_FOUND"). */
|
|
491
|
+
readonly code: string | undefined;
|
|
492
|
+
constructor(message: string, status: number, code?: string);
|
|
493
|
+
}
|
|
494
|
+
/** Thrown when the API returns 404. */
|
|
495
|
+
declare class OmenNotFoundError extends OmenError {
|
|
496
|
+
constructor(message?: string);
|
|
497
|
+
}
|
|
498
|
+
/** Thrown when the API returns 401 or 403. */
|
|
499
|
+
declare class OmenAuthError extends OmenError {
|
|
500
|
+
constructor(message?: string);
|
|
501
|
+
}
|
|
502
|
+
/** Thrown when the API returns 422. */
|
|
503
|
+
declare class OmenValidationError extends OmenError {
|
|
504
|
+
/** Field-level validation errors, if available. */
|
|
505
|
+
readonly errors: Record<string, string> | undefined;
|
|
506
|
+
constructor(message: string, errors?: Record<string, string>);
|
|
507
|
+
}
|
|
508
|
+
/** Thrown when the API returns 429. */
|
|
509
|
+
declare class OmenRateLimitError extends OmenError {
|
|
510
|
+
/** Seconds until the rate limit resets. */
|
|
511
|
+
readonly retryAfter: number | undefined;
|
|
512
|
+
/** Remaining requests in the current window. */
|
|
513
|
+
readonly remaining: number | undefined;
|
|
514
|
+
constructor(message?: string, retryAfter?: number, remaining?: number);
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* The Omen SDK client. Initialize with your developer token to access all namespaces.
|
|
519
|
+
*
|
|
520
|
+
* @example
|
|
521
|
+
* ```ts
|
|
522
|
+
* import { OmenClient } from '@omen.dog/sdk';
|
|
523
|
+
*
|
|
524
|
+
* const omen = new OmenClient({
|
|
525
|
+
* token: process.env.OMEN_TOKEN!, // dev_yourorg_abc123...
|
|
526
|
+
* appId: 'your-app-id', // from the Developer Portal
|
|
527
|
+
* });
|
|
528
|
+
*
|
|
529
|
+
* // Get a user's profile
|
|
530
|
+
* const profile = await omen.users.get('pistolphoenix');
|
|
531
|
+
*
|
|
532
|
+
* // Store data for a user
|
|
533
|
+
* await omen.storage.set({ highScore: 9001 });
|
|
534
|
+
*
|
|
535
|
+
* // Issue an achievement
|
|
536
|
+
* await omen.items.issue({
|
|
537
|
+
* userId: profile.user.id,
|
|
538
|
+
* name: 'Welcome Badge',
|
|
539
|
+
* type: 'achievement',
|
|
540
|
+
* });
|
|
541
|
+
* ```
|
|
542
|
+
*/
|
|
543
|
+
declare class OmenClient {
|
|
544
|
+
/** User profiles and friend lists. */
|
|
545
|
+
readonly users: UsersNamespace;
|
|
546
|
+
/** Per-user key-value storage. */
|
|
547
|
+
readonly storage: StorageNamespace;
|
|
548
|
+
/** Issue, revoke, and batch-manage items. */
|
|
549
|
+
readonly items: ItemsNamespace;
|
|
550
|
+
/** Structured data collections (document database). */
|
|
551
|
+
readonly collections: CollectionsNamespace;
|
|
552
|
+
/** Webhook endpoint management and signature verification. */
|
|
553
|
+
readonly webhooks: WebhooksNamespace;
|
|
554
|
+
constructor(options: OmenClientOptions & {
|
|
555
|
+
appId: string;
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
export { type AcquisitionType, type Badge, type BatchIssueResponse, type Collection, type CreateCollectionOptions, type CreateWebhookOptions, type Document, type FeaturedItem, type Friend, type FriendsListOptions, type FriendsListResponse, type IssueItemOptions, type Item, type ItemType, OmenAuthError, OmenClient, type OmenClientOptions, OmenError, OmenNotFoundError, OmenRateLimitError, OmenValidationError, type PinnedCreation, type QueryDocumentsOptions, type QueryDocumentsResponse, type SchemaFieldType, type StorageData, type TransactionOperation, type TransactionResponse, type UserProfile, type UserProfileResponse, type Webhook };
|