@gamecore-api/sdk 0.7.0 → 0.9.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/client.d.ts +63 -8
- package/dist/index.js +20 -3
- package/dist/types.d.ts +9 -0
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TelegramInitResponse, User, SiteConfig, ExchangeRates, LegalDocument, Game, GameDetail, Product, SearchResult, Category, CartItem, CheckoutRequest, CheckoutResponse, Order, UserBalance, LevelStatus, Transaction, Notification, Favorite, Review, ReviewStats, CouponResult, ReferralStats, ReferralLink, ReferralCommission, TopupMethod, TopupResponse, TopupStatus, GiftCard, Announcement, AnnouncementBar, SiteUIConfig, CatalogSection, SiteStats, ProductFilters, PaginatedResponse } from "./types";
|
|
1
|
+
import type { TelegramInitResponse, User, SiteConfig, ExchangeRates, LegalDocument, Game, GameDetail, Product, SearchResult, Category, CartItem, CheckoutRequest, CheckoutResponse, Order, UserBalance, LevelStatus, Transaction, Notification, Favorite, Review, ReviewStats, CouponResult, ReferralStats, ReferralLink, ReferralCommission, TopupMethod, TopupResponse, TopupStatus, GiftCard, Announcement, AnnouncementBar, SiteUIConfig, PaymentMethod, CatalogSection, SiteStats, ProductFilters, PaginatedResponse } from "./types";
|
|
2
2
|
export interface GameCoreOptions {
|
|
3
3
|
/** Site API key (gc_live_xxx or gc_test_xxx) */
|
|
4
4
|
apiKey: string;
|
|
@@ -22,6 +22,19 @@ export declare class GameCoreClient {
|
|
|
22
22
|
getLegal: (type: string, locale?: string) => Promise<LegalDocument>;
|
|
23
23
|
/** Get site statistics for trust signals (cached 5 min on server) */
|
|
24
24
|
getStats: () => Promise<SiteStats>;
|
|
25
|
+
/** Get social proof — recent purchases for trust display */
|
|
26
|
+
getSocialProof: () => Promise<{
|
|
27
|
+
recentPurchases: Array<{
|
|
28
|
+
gameName: string;
|
|
29
|
+
timeAgo: string;
|
|
30
|
+
}>;
|
|
31
|
+
}>;
|
|
32
|
+
/** Get theme config (white-label colors, fonts, borderRadius) */
|
|
33
|
+
getThemeConfig: () => Promise<{
|
|
34
|
+
colors: Record<string, string>;
|
|
35
|
+
borderRadius: string;
|
|
36
|
+
font: string;
|
|
37
|
+
}>;
|
|
25
38
|
/** Get site translations for a locale (Record<key, value>) */
|
|
26
39
|
getTranslations: (locale?: string) => Promise<Record<string, string>>;
|
|
27
40
|
/** Get site UI config (header, footer, nav, trust pills) */
|
|
@@ -52,6 +65,10 @@ export declare class GameCoreClient {
|
|
|
52
65
|
initTelegram: () => Promise<TelegramInitResponse>;
|
|
53
66
|
/** Poll Telegram auth status until authenticated or expired */
|
|
54
67
|
pollTelegramStatus: (token: string, intervalMs?: number) => Promise<User>;
|
|
68
|
+
/** Get VK OAuth redirect URL */
|
|
69
|
+
getVkAuthUrl: (redirectUri: string) => Promise<{
|
|
70
|
+
url: string;
|
|
71
|
+
}>;
|
|
55
72
|
/** Verify VK access token and login/register */
|
|
56
73
|
verifyVk: (accessToken: string, ref?: string) => Promise<{
|
|
57
74
|
status: string;
|
|
@@ -73,6 +90,16 @@ export declare class GameCoreClient {
|
|
|
73
90
|
linkVk: (accessToken: string) => Promise<void>;
|
|
74
91
|
/** Unlink auth provider */
|
|
75
92
|
unlinkProvider: (provider: string) => Promise<void>;
|
|
93
|
+
/** Preview VK account merge (before confirming) */
|
|
94
|
+
mergePreview: (accessToken: string) => Promise<{
|
|
95
|
+
preview: Record<string, unknown>;
|
|
96
|
+
}>;
|
|
97
|
+
/** Confirm VK account merge */
|
|
98
|
+
mergeConfirm: (accessToken: string) => Promise<{
|
|
99
|
+
success: boolean;
|
|
100
|
+
provider: string;
|
|
101
|
+
vkId: string;
|
|
102
|
+
}>;
|
|
76
103
|
};
|
|
77
104
|
catalog: {
|
|
78
105
|
/** Get all games. Use inStockOnly:true for only games with products. include:"meta" for categories/deliveryTypes. */
|
|
@@ -107,6 +134,12 @@ export declare class GameCoreClient {
|
|
|
107
134
|
}>;
|
|
108
135
|
/** Get single product by ID */
|
|
109
136
|
getProduct: (productId: number) => Promise<Product>;
|
|
137
|
+
/** Get user's recently viewed games (auth required) */
|
|
138
|
+
getRecentGames: () => Promise<Game[]>;
|
|
139
|
+
/** Get user's search history — returns list of recent query strings (auth required) */
|
|
140
|
+
getSearchHistory: () => Promise<string[]>;
|
|
141
|
+
/** Save search query to history (auth required) */
|
|
142
|
+
saveSearchHistory: (query: string) => Promise<void>;
|
|
110
143
|
/** Get bundle discount rules */
|
|
111
144
|
getBundleRules: () => Promise<{
|
|
112
145
|
id: number;
|
|
@@ -159,13 +192,7 @@ export declare class GameCoreClient {
|
|
|
159
192
|
success: boolean;
|
|
160
193
|
}>;
|
|
161
194
|
/** Get available payment methods for checkout */
|
|
162
|
-
getPaymentMethods: () => Promise<
|
|
163
|
-
type: string;
|
|
164
|
-
label: string;
|
|
165
|
-
description?: string;
|
|
166
|
-
feePercent?: number;
|
|
167
|
-
gatewayType?: string;
|
|
168
|
-
}[]>;
|
|
195
|
+
getPaymentMethods: () => Promise<PaymentMethod[]>;
|
|
169
196
|
};
|
|
170
197
|
orders: {
|
|
171
198
|
/** List all orders for authenticated user */
|
|
@@ -177,6 +204,14 @@ export declare class GameCoreClient {
|
|
|
177
204
|
payment: unknown;
|
|
178
205
|
orders: Order[];
|
|
179
206
|
}>;
|
|
207
|
+
/** Preview cancel — check if cancellable and refund amount */
|
|
208
|
+
cancelPreview: (code: string) => Promise<{
|
|
209
|
+
canCancel: boolean;
|
|
210
|
+
reason?: string;
|
|
211
|
+
refundAmount?: number;
|
|
212
|
+
refundTo?: string;
|
|
213
|
+
message?: string;
|
|
214
|
+
}>;
|
|
180
215
|
/** Cancel a pending order */
|
|
181
216
|
cancel: (code: string) => Promise<{
|
|
182
217
|
status: string;
|
|
@@ -208,6 +243,26 @@ export declare class GameCoreClient {
|
|
|
208
243
|
deleteAccount: () => Promise<void>;
|
|
209
244
|
/** Export user data (GDPR) */
|
|
210
245
|
exportData: () => Promise<Record<string, unknown>>;
|
|
246
|
+
/** Get user preferences (language, currency, notifications) */
|
|
247
|
+
getSettings: () => Promise<{
|
|
248
|
+
language: string;
|
|
249
|
+
currency: string;
|
|
250
|
+
emailNotifications: boolean;
|
|
251
|
+
}>;
|
|
252
|
+
/** Update user preferences */
|
|
253
|
+
updateSettings: (data: {
|
|
254
|
+
language?: string;
|
|
255
|
+
currency?: string;
|
|
256
|
+
emailNotifications?: boolean;
|
|
257
|
+
}) => Promise<void>;
|
|
258
|
+
/** Subscribe to broadcast notifications */
|
|
259
|
+
subscribeBroadcast: () => Promise<void>;
|
|
260
|
+
/** Unsubscribe from broadcast notifications */
|
|
261
|
+
unsubscribeBroadcast: () => Promise<void>;
|
|
262
|
+
/** Get broadcast subscription status */
|
|
263
|
+
getBroadcastStatus: () => Promise<{
|
|
264
|
+
subscribed: boolean;
|
|
265
|
+
}>;
|
|
211
266
|
};
|
|
212
267
|
favorites: {
|
|
213
268
|
/** List user's favorite products */
|
package/dist/index.js
CHANGED
|
@@ -77,6 +77,8 @@ class GameCoreClient {
|
|
|
77
77
|
getRates: () => this.request("GET", "/rates"),
|
|
78
78
|
getLegal: (type, locale) => this.request("GET", `/legal/${type}${locale ? `?locale=${locale}` : ""}`),
|
|
79
79
|
getStats: () => this.request("GET", "/site/stats"),
|
|
80
|
+
getSocialProof: () => this.request("GET", "/site/social-proof"),
|
|
81
|
+
getThemeConfig: () => this.request("GET", "/site/theme"),
|
|
80
82
|
getTranslations: (locale = "ru") => this.request("GET", `/site/translations?locale=${locale}`),
|
|
81
83
|
getUIConfig: () => this.request("GET", "/site/ui-config"),
|
|
82
84
|
getCookieConsent: () => this.request("GET", "/site/cookie-consent"),
|
|
@@ -103,12 +105,15 @@ class GameCoreClient {
|
|
|
103
105
|
}
|
|
104
106
|
}, intervalMs);
|
|
105
107
|
}),
|
|
108
|
+
getVkAuthUrl: (redirectUri) => this.request("GET", `/auth/vk/url?redirect=${encodeURIComponent(redirectUri)}`),
|
|
106
109
|
verifyVk: (accessToken, ref) => this.request("POST", "/auth/vk/verify", { accessToken, ref }, { rawResponse: true }),
|
|
107
110
|
getMe: () => this.request("GET", "/auth/me", undefined, { rawResponse: true }),
|
|
108
111
|
logout: () => this.request("POST", "/auth/logout"),
|
|
109
112
|
getIdentities: () => this.request("GET", "/auth/identities", undefined, { rawResponse: true }),
|
|
110
113
|
linkVk: (accessToken) => this.request("POST", "/auth/link/vk", { accessToken }),
|
|
111
|
-
unlinkProvider: (provider) => this.request("POST", `/auth/unlink/${provider}`)
|
|
114
|
+
unlinkProvider: (provider) => this.request("POST", `/auth/unlink/${provider}`),
|
|
115
|
+
mergePreview: (accessToken) => this.request("POST", "/auth/merge/preview", { accessToken }),
|
|
116
|
+
mergeConfirm: (accessToken) => this.request("POST", "/auth/merge/confirm", { accessToken })
|
|
112
117
|
};
|
|
113
118
|
catalog = {
|
|
114
119
|
getGames: (params) => {
|
|
@@ -156,6 +161,9 @@ class GameCoreClient {
|
|
|
156
161
|
search: (query, limit = 20) => this.request("GET", `/catalog/search?q=${encodeURIComponent(query)}&limit=${limit}`),
|
|
157
162
|
searchSuggestions: (query, limit = 5) => this.request("GET", `/catalog/search/suggestions?q=${encodeURIComponent(query)}&limit=${limit}`),
|
|
158
163
|
getProduct: (productId) => this.request("GET", `/catalog/products/${productId}`),
|
|
164
|
+
getRecentGames: () => this.request("GET", "/catalog/recent-games"),
|
|
165
|
+
getSearchHistory: () => this.request("GET", "/catalog/search-history"),
|
|
166
|
+
saveSearchHistory: (query) => this.request("POST", "/catalog/search-history", { query }),
|
|
159
167
|
getBundleRules: () => this.request("GET", "/catalog/bundle-rules"),
|
|
160
168
|
getPromos: () => this.request("GET", "/catalog/promos"),
|
|
161
169
|
getGamesFull: () => this.request("GET", "/catalog/games/full"),
|
|
@@ -173,12 +181,16 @@ class GameCoreClient {
|
|
|
173
181
|
idempotencyKey: idempotencyKey || generateIdempotencyKey()
|
|
174
182
|
}),
|
|
175
183
|
completeWithBalance: (paymentCode) => this.request("POST", `/checkout/${paymentCode}/complete`),
|
|
176
|
-
getPaymentMethods: () =>
|
|
184
|
+
getPaymentMethods: async () => {
|
|
185
|
+
const res = await this.request("GET", "/checkout/payment-methods", undefined, { rawResponse: true });
|
|
186
|
+
return res.methods || [];
|
|
187
|
+
}
|
|
177
188
|
};
|
|
178
189
|
orders = {
|
|
179
190
|
list: () => this.request("GET", "/orders"),
|
|
180
191
|
get: (code) => this.request("GET", `/orders/${code}`),
|
|
181
192
|
getByPayment: (paymentCode) => this.request("GET", `/checkout/orders/payment/${paymentCode}`, undefined, { rawResponse: true }),
|
|
193
|
+
cancelPreview: (code) => this.request("GET", `/orders/${code}/cancel-preview`),
|
|
182
194
|
cancel: (code) => this.request("POST", `/orders/${code}/cancel`)
|
|
183
195
|
};
|
|
184
196
|
profile = {
|
|
@@ -199,7 +211,12 @@ class GameCoreClient {
|
|
|
199
211
|
markRead: (id) => this.request("POST", `/profile/notifications/${id}/read`),
|
|
200
212
|
markAllRead: () => this.request("POST", "/profile/notifications/read-all"),
|
|
201
213
|
deleteAccount: () => this.request("POST", "/profile/delete-account"),
|
|
202
|
-
exportData: () => this.request("GET", "/profile/export")
|
|
214
|
+
exportData: () => this.request("GET", "/profile/export"),
|
|
215
|
+
getSettings: () => this.request("GET", "/profile/settings"),
|
|
216
|
+
updateSettings: (data) => this.request("PUT", "/profile/settings", data),
|
|
217
|
+
subscribeBroadcast: () => this.request("POST", "/profile/broadcast/subscribe"),
|
|
218
|
+
unsubscribeBroadcast: () => this.request("POST", "/profile/broadcast/unsubscribe"),
|
|
219
|
+
getBroadcastStatus: () => this.request("GET", "/profile/broadcast/status")
|
|
203
220
|
};
|
|
204
221
|
favorites = {
|
|
205
222
|
list: () => this.request("GET", "/favorites"),
|
package/dist/types.d.ts
CHANGED
|
@@ -69,6 +69,8 @@ export interface Game {
|
|
|
69
69
|
inStock: boolean;
|
|
70
70
|
soldCount?: number;
|
|
71
71
|
tags?: string[];
|
|
72
|
+
availabilityStatus?: "available" | "coming_soon" | "maintenance" | "discontinued";
|
|
73
|
+
availabilityMessage?: string | null;
|
|
72
74
|
minPrice?: number | null;
|
|
73
75
|
type?: string;
|
|
74
76
|
deliveryTypes?: string[];
|
|
@@ -434,6 +436,13 @@ export interface SiteUIConfig {
|
|
|
434
436
|
enabled: boolean;
|
|
435
437
|
}>;
|
|
436
438
|
}
|
|
439
|
+
export interface PaymentMethod {
|
|
440
|
+
type: string;
|
|
441
|
+
label: string;
|
|
442
|
+
description?: string;
|
|
443
|
+
feePercent?: number;
|
|
444
|
+
gatewayType?: string;
|
|
445
|
+
}
|
|
437
446
|
export interface CatalogSection {
|
|
438
447
|
id: number;
|
|
439
448
|
slug: string;
|