@indiegems/gem-web-sdk 7.4.2 → 7.6.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/CHANGELOG.md +886 -0
- package/README.md +1 -0
- package/dist/function.d.ts +978 -0
- package/dist/game.d.ts +11 -1
- package/dist/gem-web-sdk.bridge.js +1 -1
- package/dist/gem-web-sdk.esm.js +2 -2
- package/dist/gem-web-sdk.function.js +3 -0
- package/dist/gem-web-sdk.game.js +2 -2
- package/dist/gem-web-sdk.min.js +2 -2
- package/dist/gem-web-sdk.sdk.js +2 -2
- package/dist/gem-web-sdk.server.js +2 -2
- package/dist/index.d.ts +16 -3
- package/dist/sdk.d.ts +11 -1
- package/docs/analytics.md +15 -5
- package/docs/api/api-reference-game.md +60 -33
- package/docs/api/api-reference-server.md +1 -1
- package/docs/api/reference.json +29 -12
- package/docs/changelog.md +886 -0
- package/docs/getting-started.md +8 -6
- package/docs/manifest.json +18 -8
- package/docs/server-bundles.md +2 -2
- package/docs/serverless-functions-js.md +139 -0
- package/docs/what-a-game-must-do.md +46 -26
- package/package.json +7 -2
- package/schema/bridge.v1.json +62 -1
- package/schema/capabilities.public.json +6 -0
|
@@ -0,0 +1,978 @@
|
|
|
1
|
+
interface Clock {
|
|
2
|
+
now(): number;
|
|
3
|
+
setTimeout(fn: () => void, ms: number): unknown;
|
|
4
|
+
clearTimeout(handle: unknown): void;
|
|
5
|
+
}
|
|
6
|
+
type AuthFailure = "chain_exhausted" | "unavailable" | "timeout" | "internal";
|
|
7
|
+
type AuthState = "ready" | "pending" | "degraded" | "lost";
|
|
8
|
+
interface TokenGrant {
|
|
9
|
+
readonly token: string;
|
|
10
|
+
readonly expiresAt: number;
|
|
11
|
+
readonly chainEndsAt: number;
|
|
12
|
+
}
|
|
13
|
+
declare class AuthError extends Error {
|
|
14
|
+
readonly reason: AuthFailure;
|
|
15
|
+
constructor(reason: AuthFailure, message: string);
|
|
16
|
+
static isAuthError(error: unknown): error is AuthError;
|
|
17
|
+
}
|
|
18
|
+
declare class TransportRefusal extends Error {
|
|
19
|
+
readonly retryable: false;
|
|
20
|
+
constructor(message: string);
|
|
21
|
+
static isRefusal(error: unknown): error is TransportRefusal;
|
|
22
|
+
}
|
|
23
|
+
declare const CONDITIONAL_HEADERS: readonly [
|
|
24
|
+
"if-match",
|
|
25
|
+
"if-none-match"
|
|
26
|
+
];
|
|
27
|
+
type ConditionalRequestHeaders = Partial<Record<(typeof CONDITIONAL_HEADERS)[number], string>>;
|
|
28
|
+
interface TransportRequest {
|
|
29
|
+
readonly method: "GET" | "PUT" | "POST" | "PATCH" | "DELETE";
|
|
30
|
+
readonly path: string;
|
|
31
|
+
readonly body?: unknown;
|
|
32
|
+
readonly bytes?: Uint8Array;
|
|
33
|
+
readonly responseType?: "json" | "bytes";
|
|
34
|
+
readonly headers?: ConditionalRequestHeaders;
|
|
35
|
+
readonly signal?: AbortSignal;
|
|
36
|
+
readonly keepalive?: boolean;
|
|
37
|
+
}
|
|
38
|
+
interface TransportResponse {
|
|
39
|
+
readonly status: number;
|
|
40
|
+
readonly body: unknown;
|
|
41
|
+
readonly etag?: string;
|
|
42
|
+
readonly retryAfterSeconds?: number;
|
|
43
|
+
readonly invocationId?: string;
|
|
44
|
+
}
|
|
45
|
+
interface Transport {
|
|
46
|
+
request(request: TransportRequest): Promise<TransportResponse>;
|
|
47
|
+
}
|
|
48
|
+
type Base64String = string & {
|
|
49
|
+
readonly __contentEncoding: "base64";
|
|
50
|
+
};
|
|
51
|
+
declare function toBase64(value: string | Uint8Array): Base64String;
|
|
52
|
+
type GemErrorReason = "invalid" | "forbidden" | "not_found" | "conflict" | "precondition_failed" | "not_modified" | "insufficient_funds" | "too_large" | "rate_limited" | "unavailable";
|
|
53
|
+
declare class GemApiError extends Error {
|
|
54
|
+
readonly reason: GemErrorReason;
|
|
55
|
+
readonly status: number;
|
|
56
|
+
readonly detail: string;
|
|
57
|
+
readonly retryAfterSeconds?: number | undefined;
|
|
58
|
+
readonly code?: string | undefined;
|
|
59
|
+
constructor(reason: GemErrorReason, status: number, detail: string, retryAfterSeconds?: number | undefined, code?: string | undefined);
|
|
60
|
+
get retryable(): boolean;
|
|
61
|
+
}
|
|
62
|
+
interface ClientOptions {
|
|
63
|
+
readonly transport: Transport;
|
|
64
|
+
readonly clock: Clock;
|
|
65
|
+
readonly maxRetries?: number;
|
|
66
|
+
}
|
|
67
|
+
interface RequestOptions {
|
|
68
|
+
readonly keepalive?: boolean;
|
|
69
|
+
readonly ifMatch?: string;
|
|
70
|
+
readonly replaySafe?: boolean;
|
|
71
|
+
}
|
|
72
|
+
interface VersionedGetOptions {
|
|
73
|
+
readonly signal?: AbortSignal;
|
|
74
|
+
readonly ifNoneMatch?: string;
|
|
75
|
+
}
|
|
76
|
+
type VersionedResponse<T> = {
|
|
77
|
+
readonly modified: true;
|
|
78
|
+
readonly body: T;
|
|
79
|
+
readonly etag?: string;
|
|
80
|
+
} | {
|
|
81
|
+
readonly modified: false;
|
|
82
|
+
readonly etag?: string;
|
|
83
|
+
};
|
|
84
|
+
interface BytesResponse {
|
|
85
|
+
readonly bytes: Uint8Array;
|
|
86
|
+
readonly invocationId?: string;
|
|
87
|
+
}
|
|
88
|
+
declare class GemClient {
|
|
89
|
+
private readonly options;
|
|
90
|
+
constructor(options: ClientOptions);
|
|
91
|
+
get<T>(path: string, signal?: AbortSignal): Promise<T>;
|
|
92
|
+
getWithEtag<T>(path: string, options?: VersionedGetOptions): Promise<VersionedResponse<T>>;
|
|
93
|
+
put<T>(path: string, body: unknown, signal?: AbortSignal, options?: RequestOptions): Promise<T>;
|
|
94
|
+
post<T>(path: string, body: unknown, signal?: AbortSignal, options?: RequestOptions): Promise<T>;
|
|
95
|
+
postBytes(path: string, bytes: Uint8Array, signal?: AbortSignal, options?: RequestOptions): Promise<BytesResponse>;
|
|
96
|
+
patch<T>(path: string, body: unknown, signal?: AbortSignal, options?: RequestOptions): Promise<T>;
|
|
97
|
+
delete<T>(path: string, signal?: AbortSignal, options?: RequestOptions): Promise<T>;
|
|
98
|
+
private send;
|
|
99
|
+
private sendRaw;
|
|
100
|
+
private backoff;
|
|
101
|
+
}
|
|
102
|
+
type SessionEndReason = "grant_expiring" | "session_ended" | "navigating" | "kill_switch" | "pagehide";
|
|
103
|
+
type PlatformEventName = "gem_session_start" | "gem_session_end" | "gem_pause" | "gem_resume" | "gem_boot_ready" | "gem_match_started" | "gem_match_ended" | "gem_auth_lost";
|
|
104
|
+
type AnalyticsValue = string | number;
|
|
105
|
+
interface AnalyticsRejection {
|
|
106
|
+
readonly index: number;
|
|
107
|
+
readonly code: string;
|
|
108
|
+
}
|
|
109
|
+
interface AnalyticsFlushResult {
|
|
110
|
+
readonly accepted: number;
|
|
111
|
+
readonly rejected: readonly AnalyticsRejection[];
|
|
112
|
+
readonly dropped: number;
|
|
113
|
+
readonly duplicate: boolean;
|
|
114
|
+
}
|
|
115
|
+
interface AnalyticsFlushOptions {
|
|
116
|
+
readonly keepalive?: boolean;
|
|
117
|
+
readonly signal?: AbortSignal;
|
|
118
|
+
}
|
|
119
|
+
interface AnalyticsOptions {
|
|
120
|
+
readonly enabled?: boolean;
|
|
121
|
+
readonly flushIntervalMs?: number;
|
|
122
|
+
readonly maxQueue?: number;
|
|
123
|
+
}
|
|
124
|
+
interface AnalyticsApiOptions {
|
|
125
|
+
readonly environment?: Readonly<Record<string, string>> | (() => Readonly<Record<string, string>>);
|
|
126
|
+
readonly client: () => GemClient;
|
|
127
|
+
readonly clock: Clock;
|
|
128
|
+
readonly gameId: () => string | null;
|
|
129
|
+
readonly playerId: () => string | null;
|
|
130
|
+
readonly options?: AnalyticsOptions;
|
|
131
|
+
readonly log?: ((message: string) => void) | null;
|
|
132
|
+
}
|
|
133
|
+
declare class AnalyticsApi {
|
|
134
|
+
#private;
|
|
135
|
+
constructor(options: AnalyticsApiOptions);
|
|
136
|
+
track(name: string, props?: Readonly<Record<string, AnalyticsValue>>): void;
|
|
137
|
+
setContext(props: Readonly<Record<string, AnalyticsValue>>): void;
|
|
138
|
+
get environment(): Readonly<Record<string, string>>;
|
|
139
|
+
flush(options?: AnalyticsFlushOptions): Promise<AnalyticsFlushResult>;
|
|
140
|
+
trackPlatform(name: PlatformEventName, props?: Readonly<Record<string, AnalyticsValue>>): void;
|
|
141
|
+
hold(): void;
|
|
142
|
+
release(): void;
|
|
143
|
+
get held(): boolean;
|
|
144
|
+
startSession(): void;
|
|
145
|
+
endSession(reason: SessionEndReason): void;
|
|
146
|
+
setPaused(paused: boolean): void;
|
|
147
|
+
setHidden(hidden: boolean): void;
|
|
148
|
+
dispose(): void;
|
|
149
|
+
get pending(): number;
|
|
150
|
+
}
|
|
151
|
+
interface GameApi {
|
|
152
|
+
readonly client: GemClient;
|
|
153
|
+
gameId(): string;
|
|
154
|
+
}
|
|
155
|
+
type Boundary = {
|
|
156
|
+
"boundary"?: string;
|
|
157
|
+
"reset_time"?: string;
|
|
158
|
+
};
|
|
159
|
+
type BucketConfig = Boundary & {
|
|
160
|
+
"grant_sources"?: OrderSource[];
|
|
161
|
+
"name": string;
|
|
162
|
+
"priority": number;
|
|
163
|
+
"reset_amount"?: number | null;
|
|
164
|
+
"reset_cap"?: number | null;
|
|
165
|
+
"reset_interval": BucketResetInterval;
|
|
166
|
+
};
|
|
167
|
+
type BucketResetInterval = "never" | "daily" | "weekly" | "monthly";
|
|
168
|
+
type EntityType = "player" | "character";
|
|
169
|
+
type ItemCategory = "cosmetic" | "progression";
|
|
170
|
+
type OrderSource = "real_money_purchase" | "real_money_refund" | "full_game_purchase" | "full_game_refund" | "platform_purchase" | "reward" | "admin" | "system" | "promo" | "game_consume" | "play" | "recipe" | "transfer" | "platform_funded_game_inventory_purchase";
|
|
171
|
+
type PlatformPrice = {
|
|
172
|
+
"platform_currency_id": string;
|
|
173
|
+
"price": number;
|
|
174
|
+
};
|
|
175
|
+
type SnapshotCurrency = {
|
|
176
|
+
"bucket_config"?: BucketConfig[] | null;
|
|
177
|
+
"display_name"?: string | null;
|
|
178
|
+
"history_tracking": boolean;
|
|
179
|
+
"id": string;
|
|
180
|
+
"max_balance": number;
|
|
181
|
+
"min_balance": number;
|
|
182
|
+
"slug"?: string | null;
|
|
183
|
+
};
|
|
184
|
+
type SnapshotItem = {
|
|
185
|
+
"category"?: ItemCategory;
|
|
186
|
+
"consumable": boolean;
|
|
187
|
+
"description"?: string | null;
|
|
188
|
+
"display_name"?: string | null;
|
|
189
|
+
"fungible": boolean;
|
|
190
|
+
"icon_url"?: string | null;
|
|
191
|
+
"id": string;
|
|
192
|
+
"item_type": string;
|
|
193
|
+
"metadata"?: unknown;
|
|
194
|
+
"platform_prices"?: PlatformPrice[];
|
|
195
|
+
"properties"?: Record<string, unknown> | null;
|
|
196
|
+
"slug"?: string | null;
|
|
197
|
+
"stack_size"?: number | null;
|
|
198
|
+
"transfer_mode": string;
|
|
199
|
+
"transfer_policy": string;
|
|
200
|
+
};
|
|
201
|
+
declare const MAX_PERIODS_BACK = 400;
|
|
202
|
+
type ChallengeWindow = "daily" | "weekly" | "monthly" | "cron" | (string & {});
|
|
203
|
+
interface Challenge {
|
|
204
|
+
readonly id: string;
|
|
205
|
+
readonly slug?: string;
|
|
206
|
+
readonly window: ChallengeWindow;
|
|
207
|
+
readonly periodStartAt: number;
|
|
208
|
+
readonly periodEndsAt: number;
|
|
209
|
+
readonly periodLocalDate?: string;
|
|
210
|
+
readonly boundary: string;
|
|
211
|
+
readonly resetTime: string;
|
|
212
|
+
readonly seed: string;
|
|
213
|
+
readonly data?: string;
|
|
214
|
+
readonly dataHash?: string;
|
|
215
|
+
}
|
|
216
|
+
interface ListChallengesOptions {
|
|
217
|
+
readonly periodsBack?: number;
|
|
218
|
+
readonly signal?: AbortSignal;
|
|
219
|
+
}
|
|
220
|
+
declare class ChallengesApi {
|
|
221
|
+
#private;
|
|
222
|
+
constructor(api: GameApi);
|
|
223
|
+
list(options?: ListChallengesOptions): Promise<Challenge[]>;
|
|
224
|
+
}
|
|
225
|
+
type CacheParam = string | number | boolean | undefined;
|
|
226
|
+
declare class EntityReadCache {
|
|
227
|
+
private readonly clock;
|
|
228
|
+
private readonly identity?;
|
|
229
|
+
private generation;
|
|
230
|
+
private readonly slots;
|
|
231
|
+
private readonly listeners;
|
|
232
|
+
private boundTo;
|
|
233
|
+
constructor(clock: Clock, identity?: (() => string | null) | undefined);
|
|
234
|
+
read<T>(route: string, params: readonly CacheParam[], fetch: () => Promise<T>, maxAgeMs?: number): Promise<T>;
|
|
235
|
+
invalidate(): void;
|
|
236
|
+
onInvalidate(listener: () => void): () => void;
|
|
237
|
+
private rebind;
|
|
238
|
+
}
|
|
239
|
+
interface Page<T> {
|
|
240
|
+
readonly data: readonly T[];
|
|
241
|
+
readonly nextCursor?: string;
|
|
242
|
+
}
|
|
243
|
+
interface InventoryItem {
|
|
244
|
+
readonly itemDefinitionId: string;
|
|
245
|
+
readonly instanceId: string;
|
|
246
|
+
readonly quantity: number;
|
|
247
|
+
readonly acquiredAt: number;
|
|
248
|
+
readonly properties?: unknown;
|
|
249
|
+
readonly customData?: unknown;
|
|
250
|
+
}
|
|
251
|
+
interface Progression {
|
|
252
|
+
readonly progressionDefinitionId: string;
|
|
253
|
+
readonly currentValue: number;
|
|
254
|
+
readonly completionCount: number;
|
|
255
|
+
readonly isCompleted: boolean;
|
|
256
|
+
readonly achievements?: readonly ProgressionAchievement[];
|
|
257
|
+
readonly achievementsUnavailable?: boolean;
|
|
258
|
+
}
|
|
259
|
+
interface ProgressionAchievement {
|
|
260
|
+
readonly id: string;
|
|
261
|
+
readonly threshold: number;
|
|
262
|
+
readonly points: number;
|
|
263
|
+
readonly hidden: boolean;
|
|
264
|
+
readonly unlockedAt?: number;
|
|
265
|
+
readonly revoked?: boolean;
|
|
266
|
+
}
|
|
267
|
+
interface CurrencyBucket {
|
|
268
|
+
readonly bucket: string;
|
|
269
|
+
readonly balance: number;
|
|
270
|
+
}
|
|
271
|
+
interface CurrencyRow {
|
|
272
|
+
readonly currencyId: string;
|
|
273
|
+
readonly total: number;
|
|
274
|
+
readonly buckets?: readonly CurrencyBucket[];
|
|
275
|
+
}
|
|
276
|
+
interface InventorySnapshot {
|
|
277
|
+
readonly currencies: Page<CurrencyRow>;
|
|
278
|
+
readonly items: Page<InventoryItem>;
|
|
279
|
+
readonly progressions: Page<Progression>;
|
|
280
|
+
readonly etag?: string;
|
|
281
|
+
}
|
|
282
|
+
interface SnapshotPageOptions {
|
|
283
|
+
readonly currencyCursor?: string;
|
|
284
|
+
readonly itemCursor?: string;
|
|
285
|
+
readonly progressionCursor?: string;
|
|
286
|
+
readonly currencyLimit?: number;
|
|
287
|
+
readonly itemLimit?: number;
|
|
288
|
+
readonly progressionLimit?: number;
|
|
289
|
+
readonly includeBuckets?: boolean;
|
|
290
|
+
readonly signal?: AbortSignal;
|
|
291
|
+
}
|
|
292
|
+
interface SnapshotOptions {
|
|
293
|
+
readonly buckets?: boolean;
|
|
294
|
+
}
|
|
295
|
+
declare class InventoryApi {
|
|
296
|
+
private readonly api;
|
|
297
|
+
private readonly entity;
|
|
298
|
+
private readonly cache;
|
|
299
|
+
constructor(api: GameApi, entity: EntityRef, cache: EntityReadCache);
|
|
300
|
+
snapshot(options?: SnapshotOptions): Promise<InventorySnapshot>;
|
|
301
|
+
instances(itemDefinitionId: string, signal?: AbortSignal): Promise<readonly InventoryItem[]>;
|
|
302
|
+
page(options: SnapshotPageOptions): Promise<InventorySnapshot>;
|
|
303
|
+
refresh(): void;
|
|
304
|
+
onChanged(listener: () => void): () => void;
|
|
305
|
+
invalidate(): void;
|
|
306
|
+
private fetch;
|
|
307
|
+
}
|
|
308
|
+
interface CurrencyBalance {
|
|
309
|
+
readonly currencyId: string;
|
|
310
|
+
readonly total: number | null;
|
|
311
|
+
readonly buckets?: readonly CurrencyBucket[];
|
|
312
|
+
}
|
|
313
|
+
interface CurrencyReadOptions {
|
|
314
|
+
readonly buckets?: boolean;
|
|
315
|
+
}
|
|
316
|
+
declare class CurrenciesApi {
|
|
317
|
+
private readonly inventory;
|
|
318
|
+
private readonly resolveCurrencyId?;
|
|
319
|
+
constructor(inventory: InventoryApi, resolveCurrencyId?: ((slugOrId: string) => Promise<string | undefined>) | undefined);
|
|
320
|
+
list(options?: CurrencyReadOptions): Promise<readonly CurrencyBalance[]>;
|
|
321
|
+
get(currencyId: string, options?: CurrencyReadOptions): Promise<CurrencyBalance>;
|
|
322
|
+
}
|
|
323
|
+
type GameOrderSource = "play" | "game_consume";
|
|
324
|
+
interface RecipeAvailability {
|
|
325
|
+
readonly canExecute: boolean;
|
|
326
|
+
readonly reasons: readonly string[];
|
|
327
|
+
readonly usesRemaining?: number;
|
|
328
|
+
readonly cooldownExpiresAt?: string;
|
|
329
|
+
readonly locked: boolean;
|
|
330
|
+
readonly lockReasons: readonly RecipeLock[];
|
|
331
|
+
}
|
|
332
|
+
interface RecipeLock {
|
|
333
|
+
readonly prerequisiteType: string;
|
|
334
|
+
readonly referenceId: string;
|
|
335
|
+
readonly required: number;
|
|
336
|
+
readonly current: number;
|
|
337
|
+
}
|
|
338
|
+
interface RecipeUsage {
|
|
339
|
+
readonly recipeId: string;
|
|
340
|
+
readonly useCount: number;
|
|
341
|
+
readonly isOnCooldown: boolean;
|
|
342
|
+
readonly lastUsedAt?: string;
|
|
343
|
+
readonly cooldownExpiresAt?: string;
|
|
344
|
+
}
|
|
345
|
+
interface RecipeUsageList {
|
|
346
|
+
readonly usages: readonly RecipeUsage[];
|
|
347
|
+
readonly truncated: boolean;
|
|
348
|
+
}
|
|
349
|
+
type RecipeChange = {
|
|
350
|
+
readonly kind: "currency";
|
|
351
|
+
readonly currencyId: string;
|
|
352
|
+
readonly bucket: string;
|
|
353
|
+
readonly delta: number;
|
|
354
|
+
readonly balanceAfter: number;
|
|
355
|
+
} | {
|
|
356
|
+
readonly kind: "item";
|
|
357
|
+
readonly itemDefinitionId: string;
|
|
358
|
+
readonly instanceId: string;
|
|
359
|
+
readonly delta: number;
|
|
360
|
+
readonly quantityAfter: number;
|
|
361
|
+
} | {
|
|
362
|
+
readonly kind: "progression";
|
|
363
|
+
readonly progressionDefinitionId: string;
|
|
364
|
+
readonly delta: number;
|
|
365
|
+
readonly valueAfter: number;
|
|
366
|
+
readonly completed: boolean;
|
|
367
|
+
} | {
|
|
368
|
+
readonly kind: "other";
|
|
369
|
+
readonly type: string;
|
|
370
|
+
};
|
|
371
|
+
interface LootRoll {
|
|
372
|
+
readonly entryId: string;
|
|
373
|
+
readonly rarityTier?: string;
|
|
374
|
+
readonly rollNumber: number;
|
|
375
|
+
readonly wasReplacement: boolean;
|
|
376
|
+
readonly grants: readonly RecipeChange[];
|
|
377
|
+
}
|
|
378
|
+
interface RecipeResult {
|
|
379
|
+
readonly orderId: string;
|
|
380
|
+
readonly status: string;
|
|
381
|
+
readonly etag?: string;
|
|
382
|
+
readonly granted: readonly RecipeChange[];
|
|
383
|
+
readonly consumed: readonly RecipeChange[];
|
|
384
|
+
readonly autoClaimedRewards: readonly RecipeChange[];
|
|
385
|
+
readonly lootResults?: readonly LootRoll[];
|
|
386
|
+
}
|
|
387
|
+
interface ConfiguredPurchasePayment {
|
|
388
|
+
readonly kind: "configured";
|
|
389
|
+
}
|
|
390
|
+
interface PlatformCurrencyPurchasePayment {
|
|
391
|
+
readonly kind: "platform_currency";
|
|
392
|
+
readonly currencySlug: string;
|
|
393
|
+
}
|
|
394
|
+
interface ConfiguredPurchaseRequest {
|
|
395
|
+
readonly kind: "recipe";
|
|
396
|
+
readonly catalogId: string;
|
|
397
|
+
readonly targetId: string;
|
|
398
|
+
readonly quantity?: 1;
|
|
399
|
+
readonly payment: ConfiguredPurchasePayment;
|
|
400
|
+
}
|
|
401
|
+
type PlatformCurrencyPurchaseRequest = {
|
|
402
|
+
readonly kind: "recipe";
|
|
403
|
+
readonly catalogId: string;
|
|
404
|
+
readonly targetId: string;
|
|
405
|
+
readonly quantity?: 1;
|
|
406
|
+
readonly payment: PlatformCurrencyPurchasePayment;
|
|
407
|
+
} | {
|
|
408
|
+
readonly kind: "item";
|
|
409
|
+
readonly targetId: string;
|
|
410
|
+
readonly quantity?: number;
|
|
411
|
+
readonly payment: PlatformCurrencyPurchasePayment;
|
|
412
|
+
};
|
|
413
|
+
type DirectPurchaseRequest = ConfiguredPurchaseRequest | PlatformCurrencyPurchaseRequest;
|
|
414
|
+
interface PurchaseOptions {
|
|
415
|
+
readonly ifMatch?: string;
|
|
416
|
+
readonly signal?: AbortSignal;
|
|
417
|
+
}
|
|
418
|
+
interface ConfiguredPurchaseResult extends RecipeResult {
|
|
419
|
+
readonly payment: "configured";
|
|
420
|
+
}
|
|
421
|
+
interface PlatformCurrencyPurchaseResult {
|
|
422
|
+
readonly payment: "platform_currency";
|
|
423
|
+
readonly orderId: string;
|
|
424
|
+
readonly status: string;
|
|
425
|
+
readonly purchaseId: string;
|
|
426
|
+
readonly sourceOrderId: string;
|
|
427
|
+
readonly price: {
|
|
428
|
+
readonly currencyId: string;
|
|
429
|
+
readonly amount: number;
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
type DirectPurchaseResult = ConfiguredPurchaseResult | PlatformCurrencyPurchaseResult;
|
|
433
|
+
type InventoryOperation = {
|
|
434
|
+
readonly type: "currency_grant";
|
|
435
|
+
readonly currencyId: string;
|
|
436
|
+
readonly amount: number;
|
|
437
|
+
} | {
|
|
438
|
+
readonly type: "currency_consume";
|
|
439
|
+
readonly currencyId: string;
|
|
440
|
+
readonly amount: number;
|
|
441
|
+
} | {
|
|
442
|
+
readonly type: "item_grant";
|
|
443
|
+
readonly itemDefinitionId: string;
|
|
444
|
+
readonly quantity: number;
|
|
445
|
+
} | {
|
|
446
|
+
readonly type: "item_remove";
|
|
447
|
+
readonly itemDefinitionId: string;
|
|
448
|
+
readonly quantity: number;
|
|
449
|
+
};
|
|
450
|
+
interface OrderOptions {
|
|
451
|
+
readonly source?: GameOrderSource;
|
|
452
|
+
readonly ifMatch?: string;
|
|
453
|
+
readonly signal?: AbortSignal;
|
|
454
|
+
}
|
|
455
|
+
interface OrderResult {
|
|
456
|
+
readonly orderId: string;
|
|
457
|
+
readonly status: string;
|
|
458
|
+
readonly etag?: string;
|
|
459
|
+
}
|
|
460
|
+
declare class MutationsApi {
|
|
461
|
+
private readonly api;
|
|
462
|
+
private readonly entity;
|
|
463
|
+
private readonly cache;
|
|
464
|
+
constructor(api: GameApi, entity: EntityRef, cache: EntityReadCache);
|
|
465
|
+
create(operations: readonly InventoryOperation[], options?: OrderOptions): Promise<OrderResult>;
|
|
466
|
+
createMany(orders: ReadonlyArray<readonly InventoryOperation[]>, options?: OrderOptions): Promise<unknown>;
|
|
467
|
+
recipeAvailability(catalogId: string, recipeId: string, signal?: AbortSignal): Promise<RecipeAvailability>;
|
|
468
|
+
recipeUsageAll(): Promise<RecipeUsageList>;
|
|
469
|
+
recipeUsage(recipeId: string): Promise<RecipeUsage | null>;
|
|
470
|
+
purchase(request: ConfiguredPurchaseRequest, options?: PurchaseOptions): Promise<ConfiguredPurchaseResult>;
|
|
471
|
+
purchase(request: PlatformCurrencyPurchaseRequest, options?: PurchaseOptions): Promise<PlatformCurrencyPurchaseResult>;
|
|
472
|
+
executeRecipe(catalogId: string, recipeId: string, options?: OrderOptions): Promise<RecipeResult>;
|
|
473
|
+
addProgression(progressionId: string, amount: number, signal?: AbortSignal): Promise<OrderResult>;
|
|
474
|
+
maxProgression(progressionId: string, value: number, signal?: AbortSignal): Promise<OrderResult>;
|
|
475
|
+
claimProgression(progressionId: string, signal?: AbortSignal): Promise<OrderResult>;
|
|
476
|
+
resetProgression(progressionId: string, signal?: AbortSignal): Promise<OrderResult>;
|
|
477
|
+
private write;
|
|
478
|
+
}
|
|
479
|
+
interface Order {
|
|
480
|
+
readonly orderId: string;
|
|
481
|
+
readonly status: string;
|
|
482
|
+
readonly source: string;
|
|
483
|
+
readonly createdAt: number;
|
|
484
|
+
}
|
|
485
|
+
interface OrderPageOptions {
|
|
486
|
+
readonly limit?: number;
|
|
487
|
+
readonly cursor?: string;
|
|
488
|
+
readonly signal?: AbortSignal;
|
|
489
|
+
}
|
|
490
|
+
declare class OrdersApi {
|
|
491
|
+
private readonly api;
|
|
492
|
+
private readonly entity;
|
|
493
|
+
constructor(api: GameApi, entity: EntityRef);
|
|
494
|
+
list(options?: OrderPageOptions): Promise<Page<Order>>;
|
|
495
|
+
get(orderId: string, signal?: AbortSignal): Promise<Order>;
|
|
496
|
+
}
|
|
497
|
+
declare class ProgressionsApi {
|
|
498
|
+
private readonly api;
|
|
499
|
+
private readonly entity;
|
|
500
|
+
private readonly inventory;
|
|
501
|
+
constructor(api: GameApi, entity: EntityRef, inventory: InventoryApi);
|
|
502
|
+
list(): Promise<readonly Progression[]>;
|
|
503
|
+
get(progressionDefinitionId: string, signal?: AbortSignal): Promise<Progression | null>;
|
|
504
|
+
}
|
|
505
|
+
interface SaveRecord {
|
|
506
|
+
readonly key: string;
|
|
507
|
+
readonly sizeBytes: number;
|
|
508
|
+
readonly etag: string;
|
|
509
|
+
readonly metadata?: Record<string, unknown>;
|
|
510
|
+
readonly createdAt: number;
|
|
511
|
+
readonly updatedAt: number;
|
|
512
|
+
}
|
|
513
|
+
interface SavePage {
|
|
514
|
+
readonly saves: readonly SaveRecord[];
|
|
515
|
+
readonly nextCursor?: string;
|
|
516
|
+
}
|
|
517
|
+
declare class GemSaveError extends Error {
|
|
518
|
+
readonly reason: "upload_failed" | "download_failed" | "save_timeout" | "save_malformed";
|
|
519
|
+
constructor(reason: "upload_failed" | "download_failed" | "save_timeout" | "save_malformed", message: string);
|
|
520
|
+
}
|
|
521
|
+
interface SavesOptions {
|
|
522
|
+
readonly fetch?: typeof globalThis.fetch;
|
|
523
|
+
readonly timeoutMs?: number;
|
|
524
|
+
}
|
|
525
|
+
interface PutSaveOptions {
|
|
526
|
+
readonly metadata?: Record<string, unknown>;
|
|
527
|
+
readonly signal?: AbortSignal;
|
|
528
|
+
readonly timeoutMs?: number;
|
|
529
|
+
}
|
|
530
|
+
interface PutBytesOptions extends PutSaveOptions {
|
|
531
|
+
readonly contentType?: string;
|
|
532
|
+
}
|
|
533
|
+
interface GetSaveOptions {
|
|
534
|
+
readonly signal?: AbortSignal;
|
|
535
|
+
readonly timeoutMs?: number;
|
|
536
|
+
}
|
|
537
|
+
interface DescribeSaveOptions {
|
|
538
|
+
readonly signal?: AbortSignal;
|
|
539
|
+
readonly ifNoneMatch?: string;
|
|
540
|
+
}
|
|
541
|
+
interface ListSavesOptions {
|
|
542
|
+
readonly signal?: AbortSignal;
|
|
543
|
+
readonly limit?: number;
|
|
544
|
+
readonly cursor?: string;
|
|
545
|
+
}
|
|
546
|
+
declare class SavesApi {
|
|
547
|
+
private readonly api;
|
|
548
|
+
private readonly entity;
|
|
549
|
+
private readonly options;
|
|
550
|
+
constructor(api: GameApi, entity: EntityRef, options?: SavesOptions);
|
|
551
|
+
put(key: string, value: unknown, options?: PutSaveOptions): Promise<SaveRecord>;
|
|
552
|
+
putBytes(key: string, bytes: Uint8Array, options?: PutBytesOptions): Promise<SaveRecord>;
|
|
553
|
+
get<T = unknown>(key: string, options?: GetSaveOptions): Promise<T | null>;
|
|
554
|
+
getBytes(key: string, options?: GetSaveOptions): Promise<Uint8Array | null>;
|
|
555
|
+
describe(key: string, options?: DescribeSaveOptions): Promise<SaveRecord | null>;
|
|
556
|
+
list(options?: ListSavesOptions): Promise<SavePage>;
|
|
557
|
+
delete(key: string, signal?: AbortSignal): Promise<void>;
|
|
558
|
+
private budget;
|
|
559
|
+
private timeout;
|
|
560
|
+
private rethrow;
|
|
561
|
+
}
|
|
562
|
+
interface Setting {
|
|
563
|
+
readonly key: string;
|
|
564
|
+
readonly value: string;
|
|
565
|
+
readonly etag?: string;
|
|
566
|
+
readonly updatedAt: number;
|
|
567
|
+
}
|
|
568
|
+
interface GetSettingOptions {
|
|
569
|
+
readonly signal?: AbortSignal;
|
|
570
|
+
readonly ifNoneMatch?: string;
|
|
571
|
+
}
|
|
572
|
+
interface PutSettingOptions {
|
|
573
|
+
readonly signal?: AbortSignal;
|
|
574
|
+
readonly ifMatch?: string;
|
|
575
|
+
}
|
|
576
|
+
declare class SettingsApi {
|
|
577
|
+
private readonly api;
|
|
578
|
+
private readonly entity;
|
|
579
|
+
constructor(api: GameApi, entity: EntityRef);
|
|
580
|
+
list(signal?: AbortSignal): Promise<readonly Setting[]>;
|
|
581
|
+
get(key: string, options?: GetSettingOptions): Promise<Setting | null>;
|
|
582
|
+
put(key: string, value: string, options?: PutSettingOptions): Promise<Setting>;
|
|
583
|
+
delete(key: string, signal?: AbortSignal): Promise<void>;
|
|
584
|
+
}
|
|
585
|
+
interface EntityRef {
|
|
586
|
+
readonly type: "players" | "characters";
|
|
587
|
+
readonly id: string;
|
|
588
|
+
}
|
|
589
|
+
interface EntityScope {
|
|
590
|
+
readonly settings: SettingsApi;
|
|
591
|
+
readonly inventory: InventoryApi;
|
|
592
|
+
readonly currencies: CurrenciesApi;
|
|
593
|
+
readonly mutations: MutationsApi;
|
|
594
|
+
readonly saves: SavesApi;
|
|
595
|
+
readonly orders: OrdersApi;
|
|
596
|
+
readonly progressions: ProgressionsApi;
|
|
597
|
+
}
|
|
598
|
+
interface Character extends EntityScope {
|
|
599
|
+
readonly id: string;
|
|
600
|
+
readonly playerId: string;
|
|
601
|
+
readonly gameId: string;
|
|
602
|
+
readonly channel: string;
|
|
603
|
+
readonly name: string;
|
|
604
|
+
readonly slotIndex: number;
|
|
605
|
+
readonly isActive: boolean;
|
|
606
|
+
readonly createdAt: string;
|
|
607
|
+
readonly updatedAt: string;
|
|
608
|
+
}
|
|
609
|
+
interface SlotInfo {
|
|
610
|
+
readonly totalSlots: number;
|
|
611
|
+
readonly availableSlots: number;
|
|
612
|
+
readonly activeCharacterCount: number;
|
|
613
|
+
readonly defaultMaxSlots: number;
|
|
614
|
+
readonly purchasedExtraSlots: number;
|
|
615
|
+
readonly canPurchaseMore: boolean;
|
|
616
|
+
}
|
|
617
|
+
interface CreateCharacterOptions {
|
|
618
|
+
readonly name: string;
|
|
619
|
+
readonly signal?: AbortSignal;
|
|
620
|
+
}
|
|
621
|
+
declare class CharactersApi {
|
|
622
|
+
private readonly api;
|
|
623
|
+
private readonly saves?;
|
|
624
|
+
private readonly identity?;
|
|
625
|
+
private readonly resolveCurrencyId?;
|
|
626
|
+
private readonly scopes;
|
|
627
|
+
constructor(api: GameApi, saves?: SavesOptions | undefined, identity?: (() => string | null) | undefined, resolveCurrencyId?: ((slugOrId: string) => Promise<string | undefined>) | undefined);
|
|
628
|
+
private readonly scope;
|
|
629
|
+
list(signal?: AbortSignal): Promise<readonly Character[]>;
|
|
630
|
+
get(id: string, signal?: AbortSignal): Promise<Character>;
|
|
631
|
+
create(options: CreateCharacterOptions): Promise<Character>;
|
|
632
|
+
update(id: string, name: string, signal?: AbortSignal): Promise<Character>;
|
|
633
|
+
delete(id: string, signal?: AbortSignal): Promise<void>;
|
|
634
|
+
slots(signal?: AbortSignal): Promise<SlotInfo>;
|
|
635
|
+
}
|
|
636
|
+
declare class PlayerText {
|
|
637
|
+
#private;
|
|
638
|
+
constructor(value: string);
|
|
639
|
+
toString(): string;
|
|
640
|
+
toJSON(): string;
|
|
641
|
+
get [Symbol.toStringTag](): string;
|
|
642
|
+
static unwrap(t: PlayerText): string;
|
|
643
|
+
}
|
|
644
|
+
declare function asPlayerText(value: string): PlayerText;
|
|
645
|
+
declare const text: {
|
|
646
|
+
toPlain(t: PlayerText): string;
|
|
647
|
+
compare(a: PlayerText | string, b: PlayerText | string, locale?: string): number;
|
|
648
|
+
equals(a: PlayerText | string, b: PlayerText | string): boolean;
|
|
649
|
+
};
|
|
650
|
+
type TransferDirection = "incoming" | "outgoing";
|
|
651
|
+
interface Transfer {
|
|
652
|
+
readonly id: string;
|
|
653
|
+
readonly status: string;
|
|
654
|
+
readonly sourceEntityId: string;
|
|
655
|
+
readonly targetEntityId: string;
|
|
656
|
+
readonly message?: PlayerText;
|
|
657
|
+
readonly createdAt: string;
|
|
658
|
+
readonly expiresAt: string;
|
|
659
|
+
readonly resolvedAt?: string;
|
|
660
|
+
}
|
|
661
|
+
interface InitiateTransferOptions {
|
|
662
|
+
readonly to: EntityRef;
|
|
663
|
+
readonly items?: ReadonlyArray<{
|
|
664
|
+
itemDefinitionId: string;
|
|
665
|
+
quantity: number;
|
|
666
|
+
}>;
|
|
667
|
+
readonly currencies?: ReadonlyArray<{
|
|
668
|
+
currencyId: string;
|
|
669
|
+
amount: number;
|
|
670
|
+
}>;
|
|
671
|
+
readonly message?: string;
|
|
672
|
+
readonly signal?: AbortSignal;
|
|
673
|
+
}
|
|
674
|
+
interface ListTransfersOptions {
|
|
675
|
+
readonly direction?: TransferDirection;
|
|
676
|
+
readonly status?: string;
|
|
677
|
+
readonly cursor?: string;
|
|
678
|
+
readonly limit?: number;
|
|
679
|
+
readonly signal?: AbortSignal;
|
|
680
|
+
}
|
|
681
|
+
declare class TransfersApi {
|
|
682
|
+
private readonly api;
|
|
683
|
+
private readonly self;
|
|
684
|
+
private readonly inventory;
|
|
685
|
+
constructor(api: GameApi, self: EntityRef, inventory: InventoryApi);
|
|
686
|
+
initiate(options: InitiateTransferOptions): Promise<Transfer>;
|
|
687
|
+
list(options?: ListTransfersOptions): Promise<{
|
|
688
|
+
readonly transfers: readonly Transfer[];
|
|
689
|
+
readonly nextCursor?: string;
|
|
690
|
+
}>;
|
|
691
|
+
get(transferId: string, signal?: AbortSignal): Promise<Transfer>;
|
|
692
|
+
accept(transferId: string, signal?: AbortSignal): Promise<Transfer>;
|
|
693
|
+
reject(transferId: string, signal?: AbortSignal): Promise<Transfer>;
|
|
694
|
+
cancel(transferId: string, signal?: AbortSignal): Promise<Transfer>;
|
|
695
|
+
private resolve;
|
|
696
|
+
}
|
|
697
|
+
interface PlayerBadge {
|
|
698
|
+
readonly itemId: string;
|
|
699
|
+
readonly iconUrl: string;
|
|
700
|
+
}
|
|
701
|
+
interface PlayerIdentity {
|
|
702
|
+
readonly playerId?: string;
|
|
703
|
+
readonly displayName?: PlayerText;
|
|
704
|
+
readonly discriminator?: string;
|
|
705
|
+
readonly displayTag?: PlayerText;
|
|
706
|
+
readonly avatarIconId?: string;
|
|
707
|
+
readonly avatarIconUrl?: string;
|
|
708
|
+
readonly badges: readonly PlayerBadge[];
|
|
709
|
+
}
|
|
710
|
+
declare function mapIdentity(row: unknown): PlayerIdentity;
|
|
711
|
+
declare function platformIconUrl(url: string | undefined): string | undefined;
|
|
712
|
+
interface Friend extends PlayerIdentity {
|
|
713
|
+
readonly playerId: string;
|
|
714
|
+
}
|
|
715
|
+
interface FriendsPage {
|
|
716
|
+
readonly friends: readonly Friend[];
|
|
717
|
+
readonly nextCursor?: string;
|
|
718
|
+
}
|
|
719
|
+
interface ListFriendsOptions {
|
|
720
|
+
readonly limit?: number;
|
|
721
|
+
readonly cursor?: string;
|
|
722
|
+
readonly signal?: AbortSignal;
|
|
723
|
+
}
|
|
724
|
+
interface FriendChallengeRequest {
|
|
725
|
+
readonly playerId: string;
|
|
726
|
+
readonly template: string;
|
|
727
|
+
readonly params?: Readonly<Record<string, string | number>>;
|
|
728
|
+
}
|
|
729
|
+
type FriendChallengeOutcomeKind = "accepted" | "cancelled" | "refused" | "unavailable";
|
|
730
|
+
interface FriendChallengeOutcome {
|
|
731
|
+
readonly outcome: FriendChallengeOutcomeKind;
|
|
732
|
+
}
|
|
733
|
+
type FriendChallengeErrorCode = "unknown_template" | "template_not_on_channel" | "param_invalid" | "param_undeclared" | "recipient_invalid" | (string & {});
|
|
734
|
+
declare class FriendChallengeError extends GemApiError {
|
|
735
|
+
readonly code?: FriendChallengeErrorCode;
|
|
736
|
+
readonly param?: string;
|
|
737
|
+
readonly channel?: string;
|
|
738
|
+
readonly configVersion?: number;
|
|
739
|
+
constructor(source: GemApiError, extra?: {
|
|
740
|
+
readonly param?: string;
|
|
741
|
+
readonly channel?: string;
|
|
742
|
+
readonly configVersion?: number;
|
|
743
|
+
});
|
|
744
|
+
}
|
|
745
|
+
interface FriendsApiDependencies {
|
|
746
|
+
readonly challenge?: (request: FriendChallengeRequest) => Promise<FriendChallengeOutcome>;
|
|
747
|
+
}
|
|
748
|
+
declare class FriendsApi {
|
|
749
|
+
#private;
|
|
750
|
+
constructor(api: GameApi, dependencies?: FriendsApiDependencies);
|
|
751
|
+
list(options?: ListFriendsOptions): Promise<FriendsPage>;
|
|
752
|
+
challenge(request: FriendChallengeRequest): Promise<FriendChallengeOutcome>;
|
|
753
|
+
}
|
|
754
|
+
interface LeaderboardEntry extends RankedRow, PlayerIdentity {
|
|
755
|
+
readonly rank: number;
|
|
756
|
+
readonly occurredAt: number;
|
|
757
|
+
readonly entityId?: string;
|
|
758
|
+
readonly entityType?: EntityType;
|
|
759
|
+
readonly stats?: Readonly<Record<string, number>>;
|
|
760
|
+
readonly properties?: Readonly<Record<string, unknown>>;
|
|
761
|
+
readonly isViewer?: boolean;
|
|
762
|
+
}
|
|
763
|
+
interface Leaderboard {
|
|
764
|
+
readonly leaderboardType: string;
|
|
765
|
+
readonly runType: string;
|
|
766
|
+
readonly bucket1?: string;
|
|
767
|
+
readonly bucket2?: string;
|
|
768
|
+
readonly entries: readonly LeaderboardEntry[];
|
|
769
|
+
readonly generatedAt: number;
|
|
770
|
+
readonly updateFrequencySeconds?: number;
|
|
771
|
+
}
|
|
772
|
+
interface RankedRow {
|
|
773
|
+
readonly rank: number;
|
|
774
|
+
readonly occurredAt: number;
|
|
775
|
+
readonly stats?: Readonly<Record<string, number>>;
|
|
776
|
+
readonly properties?: Readonly<Record<string, unknown>>;
|
|
777
|
+
}
|
|
778
|
+
interface EntityLeaderboardEntry extends RankedRow {
|
|
779
|
+
readonly rank: number;
|
|
780
|
+
readonly stats?: Readonly<Record<string, number>>;
|
|
781
|
+
}
|
|
782
|
+
interface EntityLeaderboard {
|
|
783
|
+
readonly leaderboardType: string;
|
|
784
|
+
readonly runType: string;
|
|
785
|
+
readonly entityType: EntityType;
|
|
786
|
+
readonly entityId: string;
|
|
787
|
+
readonly bucket1?: string;
|
|
788
|
+
readonly bucket2?: string;
|
|
789
|
+
readonly entries: readonly EntityLeaderboardEntry[];
|
|
790
|
+
readonly personalBest: EntityLeaderboardEntry | null;
|
|
791
|
+
readonly totalRuns: number;
|
|
792
|
+
readonly totalRunsExact: boolean;
|
|
793
|
+
readonly generatedAt: number;
|
|
794
|
+
}
|
|
795
|
+
interface EntityLeaderboardOptions {
|
|
796
|
+
readonly bucket1?: string;
|
|
797
|
+
readonly bucket2?: string;
|
|
798
|
+
readonly limit?: number;
|
|
799
|
+
readonly signal?: AbortSignal;
|
|
800
|
+
}
|
|
801
|
+
interface GetLeaderboardOptions {
|
|
802
|
+
readonly bucket1?: string;
|
|
803
|
+
readonly bucket2?: string;
|
|
804
|
+
readonly signal?: AbortSignal;
|
|
805
|
+
}
|
|
806
|
+
declare class LeaderboardsApi {
|
|
807
|
+
#private;
|
|
808
|
+
constructor(api: GameApi);
|
|
809
|
+
get(leaderboardType: string, options?: GetLeaderboardOptions): Promise<Leaderboard>;
|
|
810
|
+
friends(leaderboardType: string, options?: GetLeaderboardOptions): Promise<Leaderboard>;
|
|
811
|
+
mine(leaderboardType: string, options?: EntityLeaderboardOptions): Promise<EntityLeaderboard>;
|
|
812
|
+
character(leaderboardType: string, characterId: string, options?: EntityLeaderboardOptions): Promise<EntityLeaderboard>;
|
|
813
|
+
}
|
|
814
|
+
type PlatformCurrencyAccess = "read" | "spend";
|
|
815
|
+
interface PlatformCurrency {
|
|
816
|
+
readonly slug: string;
|
|
817
|
+
readonly currencyId: string;
|
|
818
|
+
readonly balance: number;
|
|
819
|
+
readonly access: PlatformCurrencyAccess;
|
|
820
|
+
}
|
|
821
|
+
interface PlatformCurrencyReadOptions {
|
|
822
|
+
readonly signal?: AbortSignal;
|
|
823
|
+
}
|
|
824
|
+
declare class PlatformCurrenciesApi {
|
|
825
|
+
#private;
|
|
826
|
+
constructor(api: GameApi);
|
|
827
|
+
get(options?: PlatformCurrencyReadOptions): Promise<readonly PlatformCurrency[]>;
|
|
828
|
+
}
|
|
829
|
+
type EarnAllowancePeriod = "day" | "window";
|
|
830
|
+
interface EarnAllowance {
|
|
831
|
+
readonly currencySlug: string;
|
|
832
|
+
readonly currencyId: string;
|
|
833
|
+
readonly limit: number;
|
|
834
|
+
readonly earned: number;
|
|
835
|
+
readonly remaining: number;
|
|
836
|
+
readonly period: EarnAllowancePeriod;
|
|
837
|
+
readonly periodDays: number;
|
|
838
|
+
readonly resetsAt?: number;
|
|
839
|
+
}
|
|
840
|
+
interface EarnAllowanceReadOptions {
|
|
841
|
+
readonly signal?: AbortSignal;
|
|
842
|
+
}
|
|
843
|
+
interface EarnAllowanceSignal {
|
|
844
|
+
on(listener: () => void): () => void;
|
|
845
|
+
emit(): void;
|
|
846
|
+
}
|
|
847
|
+
type EarnAllowanceEvent = "changed";
|
|
848
|
+
declare class PlatformEarnAllowanceApi {
|
|
849
|
+
#private;
|
|
850
|
+
constructor(api: GameApi, signal?: EarnAllowanceSignal, log?: ((line: string) => void) | null);
|
|
851
|
+
get(options?: EarnAllowanceReadOptions): Promise<readonly EarnAllowance[]>;
|
|
852
|
+
on(event: EarnAllowanceEvent, listener: () => void): () => void;
|
|
853
|
+
}
|
|
854
|
+
declare class PlatformApi {
|
|
855
|
+
readonly currencies: PlatformCurrenciesApi;
|
|
856
|
+
readonly earnAllowance: PlatformEarnAllowanceApi;
|
|
857
|
+
constructor(api: GameApi, earnAllowanceSignal?: EarnAllowanceSignal, log?: ((line: string) => void) | null);
|
|
858
|
+
}
|
|
859
|
+
interface ProfileShowcaseEntry {
|
|
860
|
+
readonly key: string;
|
|
861
|
+
readonly visibility: string;
|
|
862
|
+
readonly value: unknown;
|
|
863
|
+
readonly updatedAt: number;
|
|
864
|
+
}
|
|
865
|
+
interface PlayerProfile extends PlayerIdentity {
|
|
866
|
+
readonly playerId: string;
|
|
867
|
+
readonly showcase: readonly ProfileShowcaseEntry[];
|
|
868
|
+
readonly generatedAt: number;
|
|
869
|
+
}
|
|
870
|
+
interface ProfileCallOptions {
|
|
871
|
+
readonly signal?: AbortSignal;
|
|
872
|
+
}
|
|
873
|
+
declare class ProfilesApi {
|
|
874
|
+
#private;
|
|
875
|
+
constructor(api: GameApi);
|
|
876
|
+
of(playerId: string, options?: ProfileCallOptions): Promise<PlayerProfile | null>;
|
|
877
|
+
}
|
|
878
|
+
interface ShowcaseValue {
|
|
879
|
+
readonly playerId: string;
|
|
880
|
+
readonly key: string;
|
|
881
|
+
readonly value: unknown;
|
|
882
|
+
readonly updatedAt: number;
|
|
883
|
+
}
|
|
884
|
+
interface ShowcaseFriendEntry extends PlayerIdentity {
|
|
885
|
+
readonly playerId: string;
|
|
886
|
+
readonly value: unknown;
|
|
887
|
+
readonly isViewer: boolean;
|
|
888
|
+
readonly updatedAt: number;
|
|
889
|
+
}
|
|
890
|
+
interface ShowcaseFriends {
|
|
891
|
+
readonly key: string;
|
|
892
|
+
readonly entries: readonly ShowcaseFriendEntry[];
|
|
893
|
+
readonly generatedAt: number;
|
|
894
|
+
}
|
|
895
|
+
interface ShowcaseCallOptions {
|
|
896
|
+
readonly signal?: AbortSignal;
|
|
897
|
+
}
|
|
898
|
+
declare class ShowcaseApi {
|
|
899
|
+
private readonly api;
|
|
900
|
+
private readonly selfPlayerId;
|
|
901
|
+
constructor(api: GameApi, selfPlayerId: () => Promise<string>);
|
|
902
|
+
friends(key: string, options?: ShowcaseCallOptions): Promise<ShowcaseFriends>;
|
|
903
|
+
of(playerId: string, key: string, options?: ShowcaseCallOptions): Promise<ShowcaseValue | null>;
|
|
904
|
+
set(key: string, value: unknown, options?: ShowcaseCallOptions): Promise<ShowcaseValue>;
|
|
905
|
+
clear(key: string, options?: ShowcaseCallOptions): Promise<void>;
|
|
906
|
+
}
|
|
907
|
+
interface FunctionContext {
|
|
908
|
+
readonly gameId: string;
|
|
909
|
+
readonly channel: "dev" | "test" | "release";
|
|
910
|
+
readonly invocationId: string;
|
|
911
|
+
readonly caller: {
|
|
912
|
+
readonly type: "player";
|
|
913
|
+
readonly playerId: string;
|
|
914
|
+
} | {
|
|
915
|
+
readonly type: "game-server";
|
|
916
|
+
readonly serverId: string | null;
|
|
917
|
+
};
|
|
918
|
+
}
|
|
919
|
+
declare global {
|
|
920
|
+
var __gemFunctionHost: {
|
|
921
|
+
context(): FunctionContext;
|
|
922
|
+
} | undefined;
|
|
923
|
+
}
|
|
924
|
+
interface GemFunctionIdentity {
|
|
925
|
+
readonly playerId: string;
|
|
926
|
+
readonly gameId: string;
|
|
927
|
+
readonly channel: string;
|
|
928
|
+
}
|
|
929
|
+
interface GemFunction {
|
|
930
|
+
readonly context: FunctionContext;
|
|
931
|
+
readonly identity: GemFunctionIdentity | null;
|
|
932
|
+
awaitIdentity(timeoutMs?: number): Promise<GemFunctionIdentity>;
|
|
933
|
+
awaitBridge(timeoutMs?: number): Promise<"connected">;
|
|
934
|
+
readonly client: GemClient;
|
|
935
|
+
readonly me: EntityScope;
|
|
936
|
+
readonly characters: CharactersApi;
|
|
937
|
+
readonly transfers: TransfersApi;
|
|
938
|
+
readonly analytics: AnalyticsApi;
|
|
939
|
+
readonly leaderboards: LeaderboardsApi;
|
|
940
|
+
readonly challenges: ChallengesApi;
|
|
941
|
+
readonly showcase: ShowcaseApi;
|
|
942
|
+
readonly friends: FriendsApi;
|
|
943
|
+
readonly platform: PlatformApi;
|
|
944
|
+
readonly profiles: ProfilesApi;
|
|
945
|
+
}
|
|
946
|
+
declare function createGem(options?: unknown): GemFunction;
|
|
947
|
+
interface FunctionInvokeOptions {
|
|
948
|
+
readonly signal?: AbortSignal;
|
|
949
|
+
}
|
|
950
|
+
interface FunctionResult {
|
|
951
|
+
readonly bytes: Uint8Array;
|
|
952
|
+
readonly invocationId?: string;
|
|
953
|
+
text(): string;
|
|
954
|
+
json<T = unknown>(): T;
|
|
955
|
+
}
|
|
956
|
+
type FunctionFailure = "trap" | "memory_exceeded" | "cpu_budget_exceeded" | "host_call_limit";
|
|
957
|
+
declare class GemFunctionError extends GemApiError {
|
|
958
|
+
readonly invocationId?: string;
|
|
959
|
+
readonly functionMessage?: string;
|
|
960
|
+
readonly failure?: FunctionFailure | (string & {});
|
|
961
|
+
constructor(source: GemApiError, extra: {
|
|
962
|
+
readonly invocationId?: string;
|
|
963
|
+
readonly functionMessage?: string;
|
|
964
|
+
readonly failure?: string;
|
|
965
|
+
});
|
|
966
|
+
get retryable(): boolean;
|
|
967
|
+
}
|
|
968
|
+
interface PlayerBoostMultiplier {
|
|
969
|
+
readonly currencyId: string;
|
|
970
|
+
readonly currencySlug: string;
|
|
971
|
+
readonly multiplier: number;
|
|
972
|
+
}
|
|
973
|
+
interface PlayerBoost {
|
|
974
|
+
readonly active: boolean;
|
|
975
|
+
readonly multipliers: readonly PlayerBoostMultiplier[];
|
|
976
|
+
readonly expiresInDays?: number;
|
|
977
|
+
}
|
|
978
|
+
export { AnalyticsApi, type AnalyticsApiOptions, type AnalyticsFlushOptions, type AnalyticsFlushResult, type AnalyticsOptions, type AnalyticsRejection, type AnalyticsValue, AuthError, type AuthFailure, type AuthState, type Base64String, type Boundary, type BucketConfig, type BucketResetInterval, type BytesResponse, CONDITIONAL_HEADERS, type CacheParam, type Challenge, type ChallengeWindow, ChallengesApi, type Character, CharactersApi, type ClientOptions, type Clock, type ConditionalRequestHeaders, type ConfiguredPurchasePayment, type ConfiguredPurchaseRequest, type ConfiguredPurchaseResult, type CreateCharacterOptions, CurrenciesApi, type CurrencyBalance, type CurrencyBucket, type CurrencyReadOptions, type CurrencyRow, type DescribeSaveOptions, type DirectPurchaseRequest, type DirectPurchaseResult, type EarnAllowance, type EarnAllowanceEvent, type EarnAllowancePeriod, type EarnAllowanceReadOptions, type EarnAllowanceSignal, type EntityLeaderboard, type EntityLeaderboardEntry, type EntityLeaderboardOptions, EntityReadCache, type EntityRef, type EntityScope, type EntityType, type Friend, FriendChallengeError, type FriendChallengeErrorCode, type FriendChallengeOutcome, type FriendChallengeOutcomeKind, type FriendChallengeRequest, FriendsApi, type FriendsApiDependencies, type FriendsPage, type FunctionContext, type FunctionFailure, type FunctionInvokeOptions, type FunctionResult, type GameApi, type GameOrderSource, GemApiError, GemClient, type GemErrorReason, type GemFunction, GemFunctionError, type GemFunctionIdentity, GemSaveError, type GetLeaderboardOptions, type GetSaveOptions, type GetSettingOptions, type InitiateTransferOptions, InventoryApi, type InventoryItem, type InventoryOperation, type InventorySnapshot, type ItemCategory, type Leaderboard, type LeaderboardEntry, LeaderboardsApi, type ListChallengesOptions, type ListFriendsOptions, type ListSavesOptions, type ListTransfersOptions, type LootRoll, MAX_PERIODS_BACK, MutationsApi, type Order, type OrderOptions, type OrderPageOptions, type OrderResult, type OrderSource, OrdersApi, type Page, PlatformApi, PlatformCurrenciesApi, type PlatformCurrency, type PlatformCurrencyAccess, type PlatformCurrencyPurchasePayment, type PlatformCurrencyPurchaseRequest, type PlatformCurrencyPurchaseResult, type PlatformCurrencyReadOptions, PlatformEarnAllowanceApi, type PlatformEventName, type PlatformPrice, type PlayerBadge, type PlayerBoost, type PlayerBoostMultiplier, type PlayerIdentity, type PlayerProfile, PlayerText, type ProfileCallOptions, type ProfileShowcaseEntry, ProfilesApi, type Progression, type ProgressionAchievement, ProgressionsApi, type PurchaseOptions, type PutBytesOptions, type PutSaveOptions, type PutSettingOptions, type RankedRow, type RecipeAvailability, type RecipeChange, type RecipeLock, type RecipeResult, type RecipeUsage, type RecipeUsageList, type RequestOptions, type SavePage, type SaveRecord, SavesApi, type SavesOptions, type SessionEndReason, type Setting, SettingsApi, ShowcaseApi, type ShowcaseCallOptions, type ShowcaseFriendEntry, type ShowcaseFriends, type ShowcaseValue, type SlotInfo, type SnapshotCurrency, type SnapshotItem, type SnapshotOptions, type SnapshotPageOptions, type TokenGrant, type Transfer, type TransferDirection, TransfersApi, type Transport, TransportRefusal, type TransportRequest, type TransportResponse, type VersionedGetOptions, type VersionedResponse, asPlayerText, createGem, mapIdentity, platformIconUrl, text, toBase64 };
|