@indiegems/gem-web-sdk 5.12.0 → 7.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/dist/game.d.ts CHANGED
@@ -42,6 +42,8 @@ interface TransportRequest {
42
42
  readonly method: "GET" | "PUT" | "POST" | "PATCH" | "DELETE";
43
43
  readonly path: string;
44
44
  readonly body?: unknown;
45
+ readonly bytes?: Uint8Array;
46
+ readonly responseType?: "json" | "bytes";
45
47
  readonly headers?: ConditionalRequestHeaders;
46
48
  readonly signal?: AbortSignal;
47
49
  readonly keepalive?: boolean;
@@ -51,6 +53,7 @@ interface TransportResponse {
51
53
  readonly body: unknown;
52
54
  readonly etag?: string;
53
55
  readonly retryAfterSeconds?: number;
56
+ readonly invocationId?: string;
54
57
  }
55
58
  interface Transport {
56
59
  request(request: TransportRequest): Promise<TransportResponse>;
@@ -87,6 +90,10 @@ type VersionedResponse<T> = {
87
90
  readonly modified: false;
88
91
  readonly etag?: string;
89
92
  };
93
+ interface BytesResponse {
94
+ readonly bytes: Uint8Array;
95
+ readonly invocationId?: string;
96
+ }
90
97
  declare class GemClient {
91
98
  private readonly options;
92
99
  constructor(options: ClientOptions);
@@ -94,6 +101,7 @@ declare class GemClient {
94
101
  getWithEtag<T>(path: string, options?: VersionedGetOptions): Promise<VersionedResponse<T>>;
95
102
  put<T>(path: string, body: unknown, signal?: AbortSignal, options?: RequestOptions): Promise<T>;
96
103
  post<T>(path: string, body: unknown, signal?: AbortSignal, options?: RequestOptions): Promise<T>;
104
+ postBytes(path: string, bytes: Uint8Array, signal?: AbortSignal, options?: RequestOptions): Promise<BytesResponse>;
97
105
  patch<T>(path: string, body: unknown, signal?: AbortSignal, options?: RequestOptions): Promise<T>;
98
106
  delete<T>(path: string, signal?: AbortSignal, options?: RequestOptions): Promise<T>;
99
107
  private send;
@@ -104,6 +112,21 @@ interface GameApi {
104
112
  readonly client: GemClient;
105
113
  gameId(): string;
106
114
  }
115
+ type AchievementGrant = {
116
+ "description"?: string;
117
+ "display_name": string;
118
+ "hidden_hint"?: string | null;
119
+ "icon_url"?: string | null;
120
+ "id": string;
121
+ "localized"?: Record<string, unknown>;
122
+ "points"?: number;
123
+ "rewards"?: AchievementReward[];
124
+ "visibility"?: AchievementVisibility;
125
+ };
126
+ type AchievementReward = {
127
+ "item": string;
128
+ };
129
+ type AchievementVisibility = "visible" | "hidden";
107
130
  type Affix = {
108
131
  "group"?: string | null;
109
132
  "is_active"?: boolean;
@@ -185,6 +208,7 @@ type ItemGeneration = {
185
208
  type LevelDefinition = {
186
209
  "auto_claim"?: boolean;
187
210
  "level": number;
211
+ "platform_grants"?: PlatformGrant[];
188
212
  "rewards"?: RecipeOperation[];
189
213
  "threshold": number;
190
214
  };
@@ -207,10 +231,15 @@ type PityRule = {
207
231
  "threshold": number;
208
232
  };
209
233
  type PlatformDisplay = "none" | "challenge";
234
+ type PlatformGrant = PlatformGrantMapping | {
235
+ "achievement": AchievementGrant;
236
+ };
210
237
  type PlatformGrantMapping = {
211
238
  "amount"?: number | null;
239
+ "max_per_entity"?: number | null;
212
240
  "max_per_window"?: number | null;
213
241
  "mode": PlatformGrantMode;
242
+ "per_unit"?: number | null;
214
243
  "target": PlatformGrantTarget;
215
244
  };
216
245
  type PlatformGrantMode = "on_add" | "on_complete";
@@ -229,7 +258,7 @@ type ProgressionConfig = {
229
258
  "label"?: string | null;
230
259
  "max_completions"?: number | null;
231
260
  "platform_display"?: PlatformDisplay;
232
- "platform_grants"?: PlatformGrantMapping[];
261
+ "platform_grants"?: PlatformGrant[];
233
262
  "reset_schedule"?: null | ResetSchedule;
234
263
  "rewards_on_complete"?: RecipeOperation[];
235
264
  "tracks"?: TrackDefinition[];
@@ -1195,6 +1224,34 @@ declare class ProfilesApi {
1195
1224
  constructor(api: GameApi);
1196
1225
  of(playerId: string, options?: ProfileCallOptions): Promise<PlayerProfile | null>;
1197
1226
  }
1227
+ interface FunctionInvokeOptions {
1228
+ readonly signal?: AbortSignal;
1229
+ }
1230
+ interface FunctionResult {
1231
+ readonly bytes: Uint8Array;
1232
+ readonly invocationId?: string;
1233
+ text(): string;
1234
+ json<T = unknown>(): T;
1235
+ }
1236
+ type FunctionFailure = "trap" | "memory_exceeded" | "cpu_budget_exceeded" | "host_call_limit";
1237
+ declare class GemFunctionError extends GemApiError {
1238
+ readonly invocationId?: string;
1239
+ readonly functionMessage?: string;
1240
+ readonly failure?: FunctionFailure | (string & {});
1241
+ constructor(source: GemApiError, extra: {
1242
+ readonly invocationId?: string;
1243
+ readonly functionMessage?: string;
1244
+ readonly failure?: string;
1245
+ });
1246
+ get retryable(): boolean;
1247
+ }
1248
+ declare class FunctionsApi {
1249
+ #private;
1250
+ constructor(invoke: (body: Uint8Array, options?: {
1251
+ signal?: AbortSignal;
1252
+ }) => Promise<BytesResponse>);
1253
+ invoke(input: unknown, options?: FunctionInvokeOptions): Promise<FunctionResult>;
1254
+ }
1198
1255
  type SessionEndReason = "grant_expiring" | "session_ended" | "navigating" | "kill_switch" | "pagehide";
1199
1256
  type MatchTransport = "dedicated" | "p2p";
1200
1257
  type PlatformEventName = "gem_session_start" | "gem_session_end" | "gem_pause" | "gem_resume" | "gem_boot_ready" | "gem_match_started" | "gem_match_ended" | "gem_auth_lost";
@@ -1501,6 +1558,7 @@ interface Room {
1501
1558
  interface MatchAutoStartFailed {
1502
1559
  readonly roomId: string;
1503
1560
  readonly code: string;
1561
+ readonly handled: boolean;
1504
1562
  }
1505
1563
  interface RoomSummary {
1506
1564
  readonly id: string;
@@ -2512,6 +2570,7 @@ interface GemOptions {
2512
2570
  readonly clientVersion?: ClientVersion;
2513
2571
  readonly pollRooms?: boolean;
2514
2572
  readonly recoverStaleMembership?: boolean;
2573
+ readonly retryAutoStart?: boolean;
2515
2574
  readonly watchSeats?: boolean;
2516
2575
  readonly seatPollIntervalMs?: number;
2517
2576
  readonly autoReconnect?: AutoReconnectOptions | false;
@@ -2589,6 +2648,7 @@ interface Gem {
2589
2648
  readonly friends: FriendsApi;
2590
2649
  readonly platform: PlatformApi;
2591
2650
  readonly profiles: ProfilesApi;
2651
+ readonly functions: FunctionsApi;
2592
2652
  awaitPlayer(timeoutMs?: number): Promise<GemPlayer | null>;
2593
2653
  readonly prefs: GemPrefs | null;
2594
2654
  readonly cohorts: GemCohorts | null;
@@ -2621,4 +2681,4 @@ interface ExitAnalytics {
2621
2681
  }
2622
2682
  declare function leaveAndExit(rooms: ExitRooms, bridge: ExitBridge | null, reason?: string, analytics?: ExitAnalytics): Promise<void>;
2623
2683
  declare function createGem(options?: GemOptions): Gem;
2624
- export { ARCADE_EMBEDDERS, type AccountApi, type AdFormat, type AdOutcome, type AdOutcomeKind, type AdRequest, type AdsApi, AnalyticsApi, type AnalyticsFlushOptions, type AnalyticsFlushResult, type AnalyticsOptions, type AnalyticsRejection, type AnalyticsValue, AuthError, type AuthFailure, type AuthState, type BootMark, type BootTimeline, type Challenge, type ChallengeWindow, ChallengesApi, type ConfiguredPurchasePayment, type ConfiguredPurchaseRequest, type ConfiguredPurchaseResult, DEVICE_SETTINGS_MAX_BYTES, DedicatedServerError, type DedicatedServerFailure, type DedicatedServerSession, type DevToolsOpener, type DeviceSettings, type DeviceSettingsApi, type DeviceSettingsPutOutcome, type DirectPurchaseRequest, type DirectPurchaseResult, type EntityLeaderboard, type EntityLeaderboardEntry, type EntityLeaderboardOptions, type EntityType, type ExitAnalytics, type ExitBridge, type ExitRooms, type FrameState, type Friend, FriendsApi, type FriendsPage, type GameConfig, type GameServerLink, type Gem, GemApiError, GemClient, type GemCohort, type GemCohorts, GemConfigError, type GemDevTools, GemFrame, type GemIdentity, type GemInsets, type GemMatchApi, type GemMatchServerModule, type GemOptions, type GemPlayer, type GemPrefs, GemSaveError, type GemServerBundle, type GemServerFactory, type GemServerHost, type GemServerHostProfile, type GemServerLifecycle, type GemTerminationNotice, type GemViewport, type GetLeaderboardOptions, type JoinWelcome, type Leaderboard, type LeaderboardEntry, LeaderboardsApi, type ListChallengesOptions, type ListFriendsOptions, MAX_PERIODS_BACK, type MatchConnectOptions, type MatchConnection, type MatchHosting, type MatchHostingMode, type MatchServeOptions, type MatchTransport, type MessageMeta, type MultiTransportSession, PLATFORM_EVENTS, PlatformApi, PlatformCurrenciesApi, type PlatformCurrency, type PlatformCurrencyAccess, type PlatformCurrencyPurchasePayment, type PlatformCurrencyPurchaseRequest, type PlatformCurrencyPurchaseResult, type PlatformCurrencyReadOptions, type PlatformEventName, type PlayerBadge, type PlayerIdentity, type PlayerProfile, PlayerText, type ProfileCallOptions, type ProfileShowcaseEntry, ProfilesApi, type PurchaseApi, type PurchaseOptions, type PurchaseOutcome, type PurchaseRequest, type PutBytesOptions, type PutSaveOptions, type RankedRow, type RewardCue, type SavePage, type SaveRecord, type SendOptions$1 as SendOptions, type ServerTokenGrant, type SessionEndReason, ShowcaseApi, type ShowcaseCallOptions, type ShowcaseFriendEntry, type ShowcaseFriends, type ShowcaseValue, type SignInOutcome, type SignInOutcomeKind, type SnapshotCurrency, type SnapshotItem, type TransportAdvert, type TransportKind, TransportRefusal, UNRELIABLE_CHANNEL_LABEL, asPlayerText, createBootTimeline, createGem, leaveAndExit, mapIdentity, markOnResolve, platformIconUrl, presentJoinCredential, readTemplateTransports, readTransportAdvert, reportOnResolve, text, webTransportAvailable };
2684
+ export { ARCADE_EMBEDDERS, type AccountApi, type AdFormat, type AdOutcome, type AdOutcomeKind, type AdRequest, type AdsApi, AnalyticsApi, type AnalyticsFlushOptions, type AnalyticsFlushResult, type AnalyticsOptions, type AnalyticsRejection, type AnalyticsValue, AuthError, type AuthFailure, type AuthState, type BootMark, type BootTimeline, type Challenge, type ChallengeWindow, ChallengesApi, type ConfiguredPurchasePayment, type ConfiguredPurchaseRequest, type ConfiguredPurchaseResult, DEVICE_SETTINGS_MAX_BYTES, DedicatedServerError, type DedicatedServerFailure, type DedicatedServerSession, type DevToolsOpener, type DeviceSettings, type DeviceSettingsApi, type DeviceSettingsPutOutcome, type DirectPurchaseRequest, type DirectPurchaseResult, type EntityLeaderboard, type EntityLeaderboardEntry, type EntityLeaderboardOptions, type EntityType, type ExitAnalytics, type ExitBridge, type ExitRooms, type FrameState, type Friend, FriendsApi, type FriendsPage, type FunctionFailure, type FunctionInvokeOptions, type FunctionResult, FunctionsApi, type GameConfig, type GameServerLink, type Gem, GemApiError, GemClient, type GemCohort, type GemCohorts, GemConfigError, type GemDevTools, GemFrame, GemFunctionError, type GemIdentity, type GemInsets, type GemMatchApi, type GemMatchServerModule, type GemOptions, type GemPlayer, type GemPrefs, GemSaveError, type GemServerBundle, type GemServerFactory, type GemServerHost, type GemServerHostProfile, type GemServerLifecycle, type GemTerminationNotice, type GemViewport, type GetLeaderboardOptions, type JoinWelcome, type Leaderboard, type LeaderboardEntry, LeaderboardsApi, type ListChallengesOptions, type ListFriendsOptions, MAX_PERIODS_BACK, type MatchConnectOptions, type MatchConnection, type MatchHosting, type MatchHostingMode, type MatchServeOptions, type MatchTransport, type MessageMeta, type MultiTransportSession, PLATFORM_EVENTS, PlatformApi, PlatformCurrenciesApi, type PlatformCurrency, type PlatformCurrencyAccess, type PlatformCurrencyPurchasePayment, type PlatformCurrencyPurchaseRequest, type PlatformCurrencyPurchaseResult, type PlatformCurrencyReadOptions, type PlatformEventName, type PlayerBadge, type PlayerIdentity, type PlayerProfile, PlayerText, type ProfileCallOptions, type ProfileShowcaseEntry, ProfilesApi, type PurchaseApi, type PurchaseOptions, type PurchaseOutcome, type PurchaseRequest, type PutBytesOptions, type PutSaveOptions, type RankedRow, type RewardCue, type SavePage, type SaveRecord, type SendOptions$1 as SendOptions, type ServerTokenGrant, type SessionEndReason, ShowcaseApi, type ShowcaseCallOptions, type ShowcaseFriendEntry, type ShowcaseFriends, type ShowcaseValue, type SignInOutcome, type SignInOutcomeKind, type SnapshotCurrency, type SnapshotItem, type TransportAdvert, type TransportKind, TransportRefusal, UNRELIABLE_CHANNEL_LABEL, asPlayerText, createBootTimeline, createGem, leaveAndExit, mapIdentity, markOnResolve, platformIconUrl, presentJoinCredential, readTemplateTransports, readTransportAdvert, reportOnResolve, text, webTransportAvailable };