@hyve-sdk/js 2.2.0 → 2.4.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/index.d.mts +55 -1
- package/dist/index.d.ts +55 -1
- package/dist/index.js +47 -0
- package/dist/index.mjs +47 -0
- package/dist/react.d.mts +54 -0
- package/dist/react.d.ts +54 -0
- package/dist/react.js +47 -0
- package/dist/react.mjs +47 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -125,6 +125,47 @@ interface GameDataBatchItem {
|
|
|
125
125
|
/** Dot-notation path targeting a nested field (e.g. "stats.score") */
|
|
126
126
|
path?: string;
|
|
127
127
|
}
|
|
128
|
+
/**
|
|
129
|
+
* Persistent Game Data Leaderboard Types
|
|
130
|
+
*/
|
|
131
|
+
/** A single entry in the game data leaderboard */
|
|
132
|
+
interface GameDataLeaderboardEntry {
|
|
133
|
+
rank: number;
|
|
134
|
+
username: string;
|
|
135
|
+
avatar_url?: string | null;
|
|
136
|
+
hyve_user_id: string;
|
|
137
|
+
score: number;
|
|
138
|
+
}
|
|
139
|
+
/** The requesting user's position within the leaderboard */
|
|
140
|
+
interface GameDataLeaderboardUserPosition {
|
|
141
|
+
rank: number;
|
|
142
|
+
score: number;
|
|
143
|
+
entry: GameDataLeaderboardEntry;
|
|
144
|
+
}
|
|
145
|
+
/** Response from the game data leaderboard endpoint */
|
|
146
|
+
interface GameDataLeaderboardResponse {
|
|
147
|
+
entries: GameDataLeaderboardEntry[];
|
|
148
|
+
next_cursor?: string | null;
|
|
149
|
+
has_more: boolean;
|
|
150
|
+
/** Present when the authenticated user has data for the queried key */
|
|
151
|
+
user_position?: GameDataLeaderboardUserPosition | null;
|
|
152
|
+
}
|
|
153
|
+
/** Parameters for fetching a game data leaderboard */
|
|
154
|
+
interface GetGameDataLeaderboardParams {
|
|
155
|
+
/** Data key to rank users by (e.g. "high_score", "lines_cleared") */
|
|
156
|
+
key: string;
|
|
157
|
+
/**
|
|
158
|
+
* Dot-notation path to extract a numeric score from a nested JSON value.
|
|
159
|
+
* Leave empty to use the top-level value (e.g. "stats.score").
|
|
160
|
+
*/
|
|
161
|
+
score_path?: string;
|
|
162
|
+
/** Sort direction - "asc" or "desc" (default: "desc") */
|
|
163
|
+
sort?: 'asc' | 'desc';
|
|
164
|
+
/** Number of results per page, 1-100 (default: 10) */
|
|
165
|
+
limit?: number;
|
|
166
|
+
/** Pagination cursor from a previous response's next_cursor */
|
|
167
|
+
cursor?: string;
|
|
168
|
+
}
|
|
128
169
|
|
|
129
170
|
/**
|
|
130
171
|
* Ads Service for Hyve SDK
|
|
@@ -586,6 +627,13 @@ declare class HyveClient {
|
|
|
586
627
|
* @returns Promise resolving to number of entries deleted
|
|
587
628
|
*/
|
|
588
629
|
deleteMultipleGameData(keys: string[], storage?: 'cloud' | 'local'): Promise<number>;
|
|
630
|
+
/**
|
|
631
|
+
* Fetch the persistent game data leaderboard for a given key.
|
|
632
|
+
* Rankings are derived from numeric values stored via saveGameData / batchSaveGameData.
|
|
633
|
+
* @param params Leaderboard query parameters (key is required)
|
|
634
|
+
* @returns Promise resolving to the leaderboard response including the caller's position
|
|
635
|
+
*/
|
|
636
|
+
getGameDataLeaderboard(params: GetGameDataLeaderboardParams): Promise<GameDataLeaderboardResponse>;
|
|
589
637
|
/**
|
|
590
638
|
* Configure storage mode
|
|
591
639
|
* @param mode Storage mode ('cloud' or 'local')
|
|
@@ -665,6 +713,12 @@ declare class HyveClient {
|
|
|
665
713
|
* Unmount Stripe checkout element
|
|
666
714
|
*/
|
|
667
715
|
unmountBillingCheckout(): void;
|
|
716
|
+
/**
|
|
717
|
+
* Fetches the rendered HTML view for a project machine
|
|
718
|
+
* @param machineId The machine ID to render
|
|
719
|
+
* @returns Promise resolving to the rendered HTML string
|
|
720
|
+
*/
|
|
721
|
+
getMachineRender(machineId: string): Promise<string>;
|
|
668
722
|
}
|
|
669
723
|
|
|
670
724
|
/**
|
|
@@ -1089,4 +1143,4 @@ declare class NativeBridge {
|
|
|
1089
1143
|
*/
|
|
1090
1144
|
declare function generateUUID(): string;
|
|
1091
1145
|
|
|
1092
|
-
export { type AdConfig, type AdResult, type AdType, AdsService, type BatchSaveGameDataResponse, type BatchSaveResultItem, type BillingConfig, BillingPlatform, type BillingProduct, BillingService, CloudStorageAdapter, CrazyGamesService, type DeleteGameDataResponse, type GameDataBatchItem, type GameDataItem, type GameDataOperation, type GameDataValue, type GetGameDataBatchResponse, type GetGameDataResponse, HyveClient, type HyveClientConfig, type Inventory, type InventoryItem, LocalStorageAdapter, Logger, NativeBridge, type NativeMessage, type NativeMessageHandler, NativeMessageType, PlaygamaService, type PurchaseResult, type SaveGameDataResponse, type StorageAdapter, type TelemetryAdditionalData, type TelemetryConfig, type TelemetryEvent, generateUUID, isDomainAllowed, logger, parseUrlParams };
|
|
1146
|
+
export { type AdConfig, type AdResult, type AdType, AdsService, type BatchSaveGameDataResponse, type BatchSaveResultItem, type BillingConfig, BillingPlatform, type BillingProduct, BillingService, CloudStorageAdapter, CrazyGamesService, type DeleteGameDataResponse, type GameDataBatchItem, type GameDataItem, type GameDataLeaderboardEntry, type GameDataLeaderboardResponse, type GameDataLeaderboardUserPosition, type GameDataOperation, type GameDataValue, type GetGameDataBatchResponse, type GetGameDataLeaderboardParams, type GetGameDataResponse, HyveClient, type HyveClientConfig, type Inventory, type InventoryItem, LocalStorageAdapter, Logger, NativeBridge, type NativeMessage, type NativeMessageHandler, NativeMessageType, PlaygamaService, type PurchaseResult, type SaveGameDataResponse, type StorageAdapter, type TelemetryAdditionalData, type TelemetryConfig, type TelemetryEvent, generateUUID, isDomainAllowed, logger, parseUrlParams };
|
package/dist/index.d.ts
CHANGED
|
@@ -125,6 +125,47 @@ interface GameDataBatchItem {
|
|
|
125
125
|
/** Dot-notation path targeting a nested field (e.g. "stats.score") */
|
|
126
126
|
path?: string;
|
|
127
127
|
}
|
|
128
|
+
/**
|
|
129
|
+
* Persistent Game Data Leaderboard Types
|
|
130
|
+
*/
|
|
131
|
+
/** A single entry in the game data leaderboard */
|
|
132
|
+
interface GameDataLeaderboardEntry {
|
|
133
|
+
rank: number;
|
|
134
|
+
username: string;
|
|
135
|
+
avatar_url?: string | null;
|
|
136
|
+
hyve_user_id: string;
|
|
137
|
+
score: number;
|
|
138
|
+
}
|
|
139
|
+
/** The requesting user's position within the leaderboard */
|
|
140
|
+
interface GameDataLeaderboardUserPosition {
|
|
141
|
+
rank: number;
|
|
142
|
+
score: number;
|
|
143
|
+
entry: GameDataLeaderboardEntry;
|
|
144
|
+
}
|
|
145
|
+
/** Response from the game data leaderboard endpoint */
|
|
146
|
+
interface GameDataLeaderboardResponse {
|
|
147
|
+
entries: GameDataLeaderboardEntry[];
|
|
148
|
+
next_cursor?: string | null;
|
|
149
|
+
has_more: boolean;
|
|
150
|
+
/** Present when the authenticated user has data for the queried key */
|
|
151
|
+
user_position?: GameDataLeaderboardUserPosition | null;
|
|
152
|
+
}
|
|
153
|
+
/** Parameters for fetching a game data leaderboard */
|
|
154
|
+
interface GetGameDataLeaderboardParams {
|
|
155
|
+
/** Data key to rank users by (e.g. "high_score", "lines_cleared") */
|
|
156
|
+
key: string;
|
|
157
|
+
/**
|
|
158
|
+
* Dot-notation path to extract a numeric score from a nested JSON value.
|
|
159
|
+
* Leave empty to use the top-level value (e.g. "stats.score").
|
|
160
|
+
*/
|
|
161
|
+
score_path?: string;
|
|
162
|
+
/** Sort direction - "asc" or "desc" (default: "desc") */
|
|
163
|
+
sort?: 'asc' | 'desc';
|
|
164
|
+
/** Number of results per page, 1-100 (default: 10) */
|
|
165
|
+
limit?: number;
|
|
166
|
+
/** Pagination cursor from a previous response's next_cursor */
|
|
167
|
+
cursor?: string;
|
|
168
|
+
}
|
|
128
169
|
|
|
129
170
|
/**
|
|
130
171
|
* Ads Service for Hyve SDK
|
|
@@ -586,6 +627,13 @@ declare class HyveClient {
|
|
|
586
627
|
* @returns Promise resolving to number of entries deleted
|
|
587
628
|
*/
|
|
588
629
|
deleteMultipleGameData(keys: string[], storage?: 'cloud' | 'local'): Promise<number>;
|
|
630
|
+
/**
|
|
631
|
+
* Fetch the persistent game data leaderboard for a given key.
|
|
632
|
+
* Rankings are derived from numeric values stored via saveGameData / batchSaveGameData.
|
|
633
|
+
* @param params Leaderboard query parameters (key is required)
|
|
634
|
+
* @returns Promise resolving to the leaderboard response including the caller's position
|
|
635
|
+
*/
|
|
636
|
+
getGameDataLeaderboard(params: GetGameDataLeaderboardParams): Promise<GameDataLeaderboardResponse>;
|
|
589
637
|
/**
|
|
590
638
|
* Configure storage mode
|
|
591
639
|
* @param mode Storage mode ('cloud' or 'local')
|
|
@@ -665,6 +713,12 @@ declare class HyveClient {
|
|
|
665
713
|
* Unmount Stripe checkout element
|
|
666
714
|
*/
|
|
667
715
|
unmountBillingCheckout(): void;
|
|
716
|
+
/**
|
|
717
|
+
* Fetches the rendered HTML view for a project machine
|
|
718
|
+
* @param machineId The machine ID to render
|
|
719
|
+
* @returns Promise resolving to the rendered HTML string
|
|
720
|
+
*/
|
|
721
|
+
getMachineRender(machineId: string): Promise<string>;
|
|
668
722
|
}
|
|
669
723
|
|
|
670
724
|
/**
|
|
@@ -1089,4 +1143,4 @@ declare class NativeBridge {
|
|
|
1089
1143
|
*/
|
|
1090
1144
|
declare function generateUUID(): string;
|
|
1091
1145
|
|
|
1092
|
-
export { type AdConfig, type AdResult, type AdType, AdsService, type BatchSaveGameDataResponse, type BatchSaveResultItem, type BillingConfig, BillingPlatform, type BillingProduct, BillingService, CloudStorageAdapter, CrazyGamesService, type DeleteGameDataResponse, type GameDataBatchItem, type GameDataItem, type GameDataOperation, type GameDataValue, type GetGameDataBatchResponse, type GetGameDataResponse, HyveClient, type HyveClientConfig, type Inventory, type InventoryItem, LocalStorageAdapter, Logger, NativeBridge, type NativeMessage, type NativeMessageHandler, NativeMessageType, PlaygamaService, type PurchaseResult, type SaveGameDataResponse, type StorageAdapter, type TelemetryAdditionalData, type TelemetryConfig, type TelemetryEvent, generateUUID, isDomainAllowed, logger, parseUrlParams };
|
|
1146
|
+
export { type AdConfig, type AdResult, type AdType, AdsService, type BatchSaveGameDataResponse, type BatchSaveResultItem, type BillingConfig, BillingPlatform, type BillingProduct, BillingService, CloudStorageAdapter, CrazyGamesService, type DeleteGameDataResponse, type GameDataBatchItem, type GameDataItem, type GameDataLeaderboardEntry, type GameDataLeaderboardResponse, type GameDataLeaderboardUserPosition, type GameDataOperation, type GameDataValue, type GetGameDataBatchResponse, type GetGameDataLeaderboardParams, type GetGameDataResponse, HyveClient, type HyveClientConfig, type Inventory, type InventoryItem, LocalStorageAdapter, Logger, NativeBridge, type NativeMessage, type NativeMessageHandler, NativeMessageType, PlaygamaService, type PurchaseResult, type SaveGameDataResponse, type StorageAdapter, type TelemetryAdditionalData, type TelemetryConfig, type TelemetryEvent, generateUUID, isDomainAllowed, logger, parseUrlParams };
|
package/dist/index.js
CHANGED
|
@@ -2044,6 +2044,26 @@ var HyveClient = class {
|
|
|
2044
2044
|
logger.info(`Deleted ${deletedCount} game data entries from ${storageMode}`);
|
|
2045
2045
|
return deletedCount;
|
|
2046
2046
|
}
|
|
2047
|
+
/**
|
|
2048
|
+
* Fetch the persistent game data leaderboard for a given key.
|
|
2049
|
+
* Rankings are derived from numeric values stored via saveGameData / batchSaveGameData.
|
|
2050
|
+
* @param params Leaderboard query parameters (key is required)
|
|
2051
|
+
* @returns Promise resolving to the leaderboard response including the caller's position
|
|
2052
|
+
*/
|
|
2053
|
+
async getGameDataLeaderboard(params) {
|
|
2054
|
+
const gameId = this.requireGameId();
|
|
2055
|
+
logger.debug(`Fetching game data leaderboard: ${gameId}/${params.key}`);
|
|
2056
|
+
const query = new URLSearchParams({ game_id: gameId, key: params.key });
|
|
2057
|
+
if (params.score_path) query.set("score_path", params.score_path);
|
|
2058
|
+
if (params.sort) query.set("sort", params.sort);
|
|
2059
|
+
if (params.limit !== void 0) query.set("limit", params.limit.toString());
|
|
2060
|
+
if (params.cursor) query.set("cursor", params.cursor);
|
|
2061
|
+
const response = await this.callApi(
|
|
2062
|
+
`/api/v1/leaderboards/game-data?${query}`
|
|
2063
|
+
);
|
|
2064
|
+
logger.info(`Game data leaderboard fetched: ${response.entries.length} entries`);
|
|
2065
|
+
return response;
|
|
2066
|
+
}
|
|
2047
2067
|
/**
|
|
2048
2068
|
* Configure storage mode
|
|
2049
2069
|
* @param mode Storage mode ('cloud' or 'local')
|
|
@@ -2200,6 +2220,33 @@ var HyveClient = class {
|
|
|
2200
2220
|
unmountBillingCheckout() {
|
|
2201
2221
|
this.billingService.unmountCheckoutElement();
|
|
2202
2222
|
}
|
|
2223
|
+
/**
|
|
2224
|
+
* Fetches the rendered HTML view for a project machine
|
|
2225
|
+
* @param machineId The machine ID to render
|
|
2226
|
+
* @returns Promise resolving to the rendered HTML string
|
|
2227
|
+
*/
|
|
2228
|
+
async getMachineRender(machineId) {
|
|
2229
|
+
if (!this.jwtToken) {
|
|
2230
|
+
throw new Error(
|
|
2231
|
+
"No JWT token available. Ensure hyve-access and game-id are present in the URL."
|
|
2232
|
+
);
|
|
2233
|
+
}
|
|
2234
|
+
const gameId = this.requireGameId();
|
|
2235
|
+
logger.debug(`Fetching machine render for machine: ${machineId}`);
|
|
2236
|
+
const url = `${this.apiBaseUrl}/api/v1/project/machines/${machineId}/render?game_id=${gameId}`;
|
|
2237
|
+
const response = await fetch(url, {
|
|
2238
|
+
headers: {
|
|
2239
|
+
Authorization: `Bearer ${this.jwtToken}`
|
|
2240
|
+
}
|
|
2241
|
+
});
|
|
2242
|
+
if (!response.ok) {
|
|
2243
|
+
const errorText = await response.text();
|
|
2244
|
+
throw new Error(`Machine render request failed: ${response.status} ${errorText}`);
|
|
2245
|
+
}
|
|
2246
|
+
const html = await response.text();
|
|
2247
|
+
logger.info(`Machine render fetched successfully for machine: ${machineId}`);
|
|
2248
|
+
return html;
|
|
2249
|
+
}
|
|
2203
2250
|
};
|
|
2204
2251
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2205
2252
|
0 && (module.exports = {
|
package/dist/index.mjs
CHANGED
|
@@ -2004,6 +2004,26 @@ var HyveClient = class {
|
|
|
2004
2004
|
logger.info(`Deleted ${deletedCount} game data entries from ${storageMode}`);
|
|
2005
2005
|
return deletedCount;
|
|
2006
2006
|
}
|
|
2007
|
+
/**
|
|
2008
|
+
* Fetch the persistent game data leaderboard for a given key.
|
|
2009
|
+
* Rankings are derived from numeric values stored via saveGameData / batchSaveGameData.
|
|
2010
|
+
* @param params Leaderboard query parameters (key is required)
|
|
2011
|
+
* @returns Promise resolving to the leaderboard response including the caller's position
|
|
2012
|
+
*/
|
|
2013
|
+
async getGameDataLeaderboard(params) {
|
|
2014
|
+
const gameId = this.requireGameId();
|
|
2015
|
+
logger.debug(`Fetching game data leaderboard: ${gameId}/${params.key}`);
|
|
2016
|
+
const query = new URLSearchParams({ game_id: gameId, key: params.key });
|
|
2017
|
+
if (params.score_path) query.set("score_path", params.score_path);
|
|
2018
|
+
if (params.sort) query.set("sort", params.sort);
|
|
2019
|
+
if (params.limit !== void 0) query.set("limit", params.limit.toString());
|
|
2020
|
+
if (params.cursor) query.set("cursor", params.cursor);
|
|
2021
|
+
const response = await this.callApi(
|
|
2022
|
+
`/api/v1/leaderboards/game-data?${query}`
|
|
2023
|
+
);
|
|
2024
|
+
logger.info(`Game data leaderboard fetched: ${response.entries.length} entries`);
|
|
2025
|
+
return response;
|
|
2026
|
+
}
|
|
2007
2027
|
/**
|
|
2008
2028
|
* Configure storage mode
|
|
2009
2029
|
* @param mode Storage mode ('cloud' or 'local')
|
|
@@ -2160,6 +2180,33 @@ var HyveClient = class {
|
|
|
2160
2180
|
unmountBillingCheckout() {
|
|
2161
2181
|
this.billingService.unmountCheckoutElement();
|
|
2162
2182
|
}
|
|
2183
|
+
/**
|
|
2184
|
+
* Fetches the rendered HTML view for a project machine
|
|
2185
|
+
* @param machineId The machine ID to render
|
|
2186
|
+
* @returns Promise resolving to the rendered HTML string
|
|
2187
|
+
*/
|
|
2188
|
+
async getMachineRender(machineId) {
|
|
2189
|
+
if (!this.jwtToken) {
|
|
2190
|
+
throw new Error(
|
|
2191
|
+
"No JWT token available. Ensure hyve-access and game-id are present in the URL."
|
|
2192
|
+
);
|
|
2193
|
+
}
|
|
2194
|
+
const gameId = this.requireGameId();
|
|
2195
|
+
logger.debug(`Fetching machine render for machine: ${machineId}`);
|
|
2196
|
+
const url = `${this.apiBaseUrl}/api/v1/project/machines/${machineId}/render?game_id=${gameId}`;
|
|
2197
|
+
const response = await fetch(url, {
|
|
2198
|
+
headers: {
|
|
2199
|
+
Authorization: `Bearer ${this.jwtToken}`
|
|
2200
|
+
}
|
|
2201
|
+
});
|
|
2202
|
+
if (!response.ok) {
|
|
2203
|
+
const errorText = await response.text();
|
|
2204
|
+
throw new Error(`Machine render request failed: ${response.status} ${errorText}`);
|
|
2205
|
+
}
|
|
2206
|
+
const html = await response.text();
|
|
2207
|
+
logger.info(`Machine render fetched successfully for machine: ${machineId}`);
|
|
2208
|
+
return html;
|
|
2209
|
+
}
|
|
2163
2210
|
};
|
|
2164
2211
|
export {
|
|
2165
2212
|
AdsService,
|
package/dist/react.d.mts
CHANGED
|
@@ -81,6 +81,47 @@ interface GameDataBatchItem {
|
|
|
81
81
|
/** Dot-notation path targeting a nested field (e.g. "stats.score") */
|
|
82
82
|
path?: string;
|
|
83
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Persistent Game Data Leaderboard Types
|
|
86
|
+
*/
|
|
87
|
+
/** A single entry in the game data leaderboard */
|
|
88
|
+
interface GameDataLeaderboardEntry {
|
|
89
|
+
rank: number;
|
|
90
|
+
username: string;
|
|
91
|
+
avatar_url?: string | null;
|
|
92
|
+
hyve_user_id: string;
|
|
93
|
+
score: number;
|
|
94
|
+
}
|
|
95
|
+
/** The requesting user's position within the leaderboard */
|
|
96
|
+
interface GameDataLeaderboardUserPosition {
|
|
97
|
+
rank: number;
|
|
98
|
+
score: number;
|
|
99
|
+
entry: GameDataLeaderboardEntry;
|
|
100
|
+
}
|
|
101
|
+
/** Response from the game data leaderboard endpoint */
|
|
102
|
+
interface GameDataLeaderboardResponse {
|
|
103
|
+
entries: GameDataLeaderboardEntry[];
|
|
104
|
+
next_cursor?: string | null;
|
|
105
|
+
has_more: boolean;
|
|
106
|
+
/** Present when the authenticated user has data for the queried key */
|
|
107
|
+
user_position?: GameDataLeaderboardUserPosition | null;
|
|
108
|
+
}
|
|
109
|
+
/** Parameters for fetching a game data leaderboard */
|
|
110
|
+
interface GetGameDataLeaderboardParams {
|
|
111
|
+
/** Data key to rank users by (e.g. "high_score", "lines_cleared") */
|
|
112
|
+
key: string;
|
|
113
|
+
/**
|
|
114
|
+
* Dot-notation path to extract a numeric score from a nested JSON value.
|
|
115
|
+
* Leave empty to use the top-level value (e.g. "stats.score").
|
|
116
|
+
*/
|
|
117
|
+
score_path?: string;
|
|
118
|
+
/** Sort direction - "asc" or "desc" (default: "desc") */
|
|
119
|
+
sort?: 'asc' | 'desc';
|
|
120
|
+
/** Number of results per page, 1-100 (default: 10) */
|
|
121
|
+
limit?: number;
|
|
122
|
+
/** Pagination cursor from a previous response's next_cursor */
|
|
123
|
+
cursor?: string;
|
|
124
|
+
}
|
|
84
125
|
|
|
85
126
|
/**
|
|
86
127
|
* Ads Service for Hyve SDK
|
|
@@ -361,6 +402,13 @@ declare class HyveClient {
|
|
|
361
402
|
* @returns Promise resolving to number of entries deleted
|
|
362
403
|
*/
|
|
363
404
|
deleteMultipleGameData(keys: string[], storage?: 'cloud' | 'local'): Promise<number>;
|
|
405
|
+
/**
|
|
406
|
+
* Fetch the persistent game data leaderboard for a given key.
|
|
407
|
+
* Rankings are derived from numeric values stored via saveGameData / batchSaveGameData.
|
|
408
|
+
* @param params Leaderboard query parameters (key is required)
|
|
409
|
+
* @returns Promise resolving to the leaderboard response including the caller's position
|
|
410
|
+
*/
|
|
411
|
+
getGameDataLeaderboard(params: GetGameDataLeaderboardParams): Promise<GameDataLeaderboardResponse>;
|
|
364
412
|
/**
|
|
365
413
|
* Configure storage mode
|
|
366
414
|
* @param mode Storage mode ('cloud' or 'local')
|
|
@@ -440,6 +488,12 @@ declare class HyveClient {
|
|
|
440
488
|
* Unmount Stripe checkout element
|
|
441
489
|
*/
|
|
442
490
|
unmountBillingCheckout(): void;
|
|
491
|
+
/**
|
|
492
|
+
* Fetches the rendered HTML view for a project machine
|
|
493
|
+
* @param machineId The machine ID to render
|
|
494
|
+
* @returns Promise resolving to the rendered HTML string
|
|
495
|
+
*/
|
|
496
|
+
getMachineRender(machineId: string): Promise<string>;
|
|
443
497
|
}
|
|
444
498
|
|
|
445
499
|
interface HyveSdkProviderProps {
|
package/dist/react.d.ts
CHANGED
|
@@ -81,6 +81,47 @@ interface GameDataBatchItem {
|
|
|
81
81
|
/** Dot-notation path targeting a nested field (e.g. "stats.score") */
|
|
82
82
|
path?: string;
|
|
83
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Persistent Game Data Leaderboard Types
|
|
86
|
+
*/
|
|
87
|
+
/** A single entry in the game data leaderboard */
|
|
88
|
+
interface GameDataLeaderboardEntry {
|
|
89
|
+
rank: number;
|
|
90
|
+
username: string;
|
|
91
|
+
avatar_url?: string | null;
|
|
92
|
+
hyve_user_id: string;
|
|
93
|
+
score: number;
|
|
94
|
+
}
|
|
95
|
+
/** The requesting user's position within the leaderboard */
|
|
96
|
+
interface GameDataLeaderboardUserPosition {
|
|
97
|
+
rank: number;
|
|
98
|
+
score: number;
|
|
99
|
+
entry: GameDataLeaderboardEntry;
|
|
100
|
+
}
|
|
101
|
+
/** Response from the game data leaderboard endpoint */
|
|
102
|
+
interface GameDataLeaderboardResponse {
|
|
103
|
+
entries: GameDataLeaderboardEntry[];
|
|
104
|
+
next_cursor?: string | null;
|
|
105
|
+
has_more: boolean;
|
|
106
|
+
/** Present when the authenticated user has data for the queried key */
|
|
107
|
+
user_position?: GameDataLeaderboardUserPosition | null;
|
|
108
|
+
}
|
|
109
|
+
/** Parameters for fetching a game data leaderboard */
|
|
110
|
+
interface GetGameDataLeaderboardParams {
|
|
111
|
+
/** Data key to rank users by (e.g. "high_score", "lines_cleared") */
|
|
112
|
+
key: string;
|
|
113
|
+
/**
|
|
114
|
+
* Dot-notation path to extract a numeric score from a nested JSON value.
|
|
115
|
+
* Leave empty to use the top-level value (e.g. "stats.score").
|
|
116
|
+
*/
|
|
117
|
+
score_path?: string;
|
|
118
|
+
/** Sort direction - "asc" or "desc" (default: "desc") */
|
|
119
|
+
sort?: 'asc' | 'desc';
|
|
120
|
+
/** Number of results per page, 1-100 (default: 10) */
|
|
121
|
+
limit?: number;
|
|
122
|
+
/** Pagination cursor from a previous response's next_cursor */
|
|
123
|
+
cursor?: string;
|
|
124
|
+
}
|
|
84
125
|
|
|
85
126
|
/**
|
|
86
127
|
* Ads Service for Hyve SDK
|
|
@@ -361,6 +402,13 @@ declare class HyveClient {
|
|
|
361
402
|
* @returns Promise resolving to number of entries deleted
|
|
362
403
|
*/
|
|
363
404
|
deleteMultipleGameData(keys: string[], storage?: 'cloud' | 'local'): Promise<number>;
|
|
405
|
+
/**
|
|
406
|
+
* Fetch the persistent game data leaderboard for a given key.
|
|
407
|
+
* Rankings are derived from numeric values stored via saveGameData / batchSaveGameData.
|
|
408
|
+
* @param params Leaderboard query parameters (key is required)
|
|
409
|
+
* @returns Promise resolving to the leaderboard response including the caller's position
|
|
410
|
+
*/
|
|
411
|
+
getGameDataLeaderboard(params: GetGameDataLeaderboardParams): Promise<GameDataLeaderboardResponse>;
|
|
364
412
|
/**
|
|
365
413
|
* Configure storage mode
|
|
366
414
|
* @param mode Storage mode ('cloud' or 'local')
|
|
@@ -440,6 +488,12 @@ declare class HyveClient {
|
|
|
440
488
|
* Unmount Stripe checkout element
|
|
441
489
|
*/
|
|
442
490
|
unmountBillingCheckout(): void;
|
|
491
|
+
/**
|
|
492
|
+
* Fetches the rendered HTML view for a project machine
|
|
493
|
+
* @param machineId The machine ID to render
|
|
494
|
+
* @returns Promise resolving to the rendered HTML string
|
|
495
|
+
*/
|
|
496
|
+
getMachineRender(machineId: string): Promise<string>;
|
|
443
497
|
}
|
|
444
498
|
|
|
445
499
|
interface HyveSdkProviderProps {
|
package/dist/react.js
CHANGED
|
@@ -1995,6 +1995,26 @@ var HyveClient = class {
|
|
|
1995
1995
|
logger.info(`Deleted ${deletedCount} game data entries from ${storageMode}`);
|
|
1996
1996
|
return deletedCount;
|
|
1997
1997
|
}
|
|
1998
|
+
/**
|
|
1999
|
+
* Fetch the persistent game data leaderboard for a given key.
|
|
2000
|
+
* Rankings are derived from numeric values stored via saveGameData / batchSaveGameData.
|
|
2001
|
+
* @param params Leaderboard query parameters (key is required)
|
|
2002
|
+
* @returns Promise resolving to the leaderboard response including the caller's position
|
|
2003
|
+
*/
|
|
2004
|
+
async getGameDataLeaderboard(params) {
|
|
2005
|
+
const gameId = this.requireGameId();
|
|
2006
|
+
logger.debug(`Fetching game data leaderboard: ${gameId}/${params.key}`);
|
|
2007
|
+
const query = new URLSearchParams({ game_id: gameId, key: params.key });
|
|
2008
|
+
if (params.score_path) query.set("score_path", params.score_path);
|
|
2009
|
+
if (params.sort) query.set("sort", params.sort);
|
|
2010
|
+
if (params.limit !== void 0) query.set("limit", params.limit.toString());
|
|
2011
|
+
if (params.cursor) query.set("cursor", params.cursor);
|
|
2012
|
+
const response = await this.callApi(
|
|
2013
|
+
`/api/v1/leaderboards/game-data?${query}`
|
|
2014
|
+
);
|
|
2015
|
+
logger.info(`Game data leaderboard fetched: ${response.entries.length} entries`);
|
|
2016
|
+
return response;
|
|
2017
|
+
}
|
|
1998
2018
|
/**
|
|
1999
2019
|
* Configure storage mode
|
|
2000
2020
|
* @param mode Storage mode ('cloud' or 'local')
|
|
@@ -2151,6 +2171,33 @@ var HyveClient = class {
|
|
|
2151
2171
|
unmountBillingCheckout() {
|
|
2152
2172
|
this.billingService.unmountCheckoutElement();
|
|
2153
2173
|
}
|
|
2174
|
+
/**
|
|
2175
|
+
* Fetches the rendered HTML view for a project machine
|
|
2176
|
+
* @param machineId The machine ID to render
|
|
2177
|
+
* @returns Promise resolving to the rendered HTML string
|
|
2178
|
+
*/
|
|
2179
|
+
async getMachineRender(machineId) {
|
|
2180
|
+
if (!this.jwtToken) {
|
|
2181
|
+
throw new Error(
|
|
2182
|
+
"No JWT token available. Ensure hyve-access and game-id are present in the URL."
|
|
2183
|
+
);
|
|
2184
|
+
}
|
|
2185
|
+
const gameId = this.requireGameId();
|
|
2186
|
+
logger.debug(`Fetching machine render for machine: ${machineId}`);
|
|
2187
|
+
const url = `${this.apiBaseUrl}/api/v1/project/machines/${machineId}/render?game_id=${gameId}`;
|
|
2188
|
+
const response = await fetch(url, {
|
|
2189
|
+
headers: {
|
|
2190
|
+
Authorization: `Bearer ${this.jwtToken}`
|
|
2191
|
+
}
|
|
2192
|
+
});
|
|
2193
|
+
if (!response.ok) {
|
|
2194
|
+
const errorText = await response.text();
|
|
2195
|
+
throw new Error(`Machine render request failed: ${response.status} ${errorText}`);
|
|
2196
|
+
}
|
|
2197
|
+
const html = await response.text();
|
|
2198
|
+
logger.info(`Machine render fetched successfully for machine: ${machineId}`);
|
|
2199
|
+
return html;
|
|
2200
|
+
}
|
|
2154
2201
|
};
|
|
2155
2202
|
|
|
2156
2203
|
// src/react.tsx
|
package/dist/react.mjs
CHANGED
|
@@ -1974,6 +1974,26 @@ var HyveClient = class {
|
|
|
1974
1974
|
logger.info(`Deleted ${deletedCount} game data entries from ${storageMode}`);
|
|
1975
1975
|
return deletedCount;
|
|
1976
1976
|
}
|
|
1977
|
+
/**
|
|
1978
|
+
* Fetch the persistent game data leaderboard for a given key.
|
|
1979
|
+
* Rankings are derived from numeric values stored via saveGameData / batchSaveGameData.
|
|
1980
|
+
* @param params Leaderboard query parameters (key is required)
|
|
1981
|
+
* @returns Promise resolving to the leaderboard response including the caller's position
|
|
1982
|
+
*/
|
|
1983
|
+
async getGameDataLeaderboard(params) {
|
|
1984
|
+
const gameId = this.requireGameId();
|
|
1985
|
+
logger.debug(`Fetching game data leaderboard: ${gameId}/${params.key}`);
|
|
1986
|
+
const query = new URLSearchParams({ game_id: gameId, key: params.key });
|
|
1987
|
+
if (params.score_path) query.set("score_path", params.score_path);
|
|
1988
|
+
if (params.sort) query.set("sort", params.sort);
|
|
1989
|
+
if (params.limit !== void 0) query.set("limit", params.limit.toString());
|
|
1990
|
+
if (params.cursor) query.set("cursor", params.cursor);
|
|
1991
|
+
const response = await this.callApi(
|
|
1992
|
+
`/api/v1/leaderboards/game-data?${query}`
|
|
1993
|
+
);
|
|
1994
|
+
logger.info(`Game data leaderboard fetched: ${response.entries.length} entries`);
|
|
1995
|
+
return response;
|
|
1996
|
+
}
|
|
1977
1997
|
/**
|
|
1978
1998
|
* Configure storage mode
|
|
1979
1999
|
* @param mode Storage mode ('cloud' or 'local')
|
|
@@ -2130,6 +2150,33 @@ var HyveClient = class {
|
|
|
2130
2150
|
unmountBillingCheckout() {
|
|
2131
2151
|
this.billingService.unmountCheckoutElement();
|
|
2132
2152
|
}
|
|
2153
|
+
/**
|
|
2154
|
+
* Fetches the rendered HTML view for a project machine
|
|
2155
|
+
* @param machineId The machine ID to render
|
|
2156
|
+
* @returns Promise resolving to the rendered HTML string
|
|
2157
|
+
*/
|
|
2158
|
+
async getMachineRender(machineId) {
|
|
2159
|
+
if (!this.jwtToken) {
|
|
2160
|
+
throw new Error(
|
|
2161
|
+
"No JWT token available. Ensure hyve-access and game-id are present in the URL."
|
|
2162
|
+
);
|
|
2163
|
+
}
|
|
2164
|
+
const gameId = this.requireGameId();
|
|
2165
|
+
logger.debug(`Fetching machine render for machine: ${machineId}`);
|
|
2166
|
+
const url = `${this.apiBaseUrl}/api/v1/project/machines/${machineId}/render?game_id=${gameId}`;
|
|
2167
|
+
const response = await fetch(url, {
|
|
2168
|
+
headers: {
|
|
2169
|
+
Authorization: `Bearer ${this.jwtToken}`
|
|
2170
|
+
}
|
|
2171
|
+
});
|
|
2172
|
+
if (!response.ok) {
|
|
2173
|
+
const errorText = await response.text();
|
|
2174
|
+
throw new Error(`Machine render request failed: ${response.status} ${errorText}`);
|
|
2175
|
+
}
|
|
2176
|
+
const html = await response.text();
|
|
2177
|
+
logger.info(`Machine render fetched successfully for machine: ${machineId}`);
|
|
2178
|
+
return html;
|
|
2179
|
+
}
|
|
2133
2180
|
};
|
|
2134
2181
|
|
|
2135
2182
|
// src/react.tsx
|