@gamecore-api/sdk 0.6.0 → 0.8.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 +30 -8
- package/dist/index.js +16 -3
- package/dist/types.d.ts +44 -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, 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,10 @@ 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 site translations for a locale (Record<key, value>) */
|
|
26
|
+
getTranslations: (locale?: string) => Promise<Record<string, string>>;
|
|
27
|
+
/** Get site UI config (header, footer, nav, trust pills) */
|
|
28
|
+
getUIConfig: () => Promise<SiteUIConfig>;
|
|
25
29
|
/** Get cookie consent config */
|
|
26
30
|
getCookieConsent: () => Promise<{
|
|
27
31
|
enabled: boolean;
|
|
@@ -69,6 +73,16 @@ export declare class GameCoreClient {
|
|
|
69
73
|
linkVk: (accessToken: string) => Promise<void>;
|
|
70
74
|
/** Unlink auth provider */
|
|
71
75
|
unlinkProvider: (provider: string) => Promise<void>;
|
|
76
|
+
/** Preview VK account merge (before confirming) */
|
|
77
|
+
mergePreview: (accessToken: string) => Promise<{
|
|
78
|
+
preview: Record<string, unknown>;
|
|
79
|
+
}>;
|
|
80
|
+
/** Confirm VK account merge */
|
|
81
|
+
mergeConfirm: (accessToken: string) => Promise<{
|
|
82
|
+
success: boolean;
|
|
83
|
+
provider: string;
|
|
84
|
+
vkId: string;
|
|
85
|
+
}>;
|
|
72
86
|
};
|
|
73
87
|
catalog: {
|
|
74
88
|
/** Get all games. Use inStockOnly:true for only games with products. include:"meta" for categories/deliveryTypes. */
|
|
@@ -103,6 +117,12 @@ export declare class GameCoreClient {
|
|
|
103
117
|
}>;
|
|
104
118
|
/** Get single product by ID */
|
|
105
119
|
getProduct: (productId: number) => Promise<Product>;
|
|
120
|
+
/** Get user's recently viewed games (auth required) */
|
|
121
|
+
getRecentGames: () => Promise<Game[]>;
|
|
122
|
+
/** Get user's search history — returns list of recent query strings (auth required) */
|
|
123
|
+
getSearchHistory: () => Promise<string[]>;
|
|
124
|
+
/** Save search query to history (auth required) */
|
|
125
|
+
saveSearchHistory: (query: string) => Promise<void>;
|
|
106
126
|
/** Get bundle discount rules */
|
|
107
127
|
getBundleRules: () => Promise<{
|
|
108
128
|
id: number;
|
|
@@ -155,13 +175,7 @@ export declare class GameCoreClient {
|
|
|
155
175
|
success: boolean;
|
|
156
176
|
}>;
|
|
157
177
|
/** Get available payment methods for checkout */
|
|
158
|
-
getPaymentMethods: () => Promise<
|
|
159
|
-
type: string;
|
|
160
|
-
label: string;
|
|
161
|
-
description?: string;
|
|
162
|
-
feePercent?: number;
|
|
163
|
-
gatewayType?: string;
|
|
164
|
-
}[]>;
|
|
178
|
+
getPaymentMethods: () => Promise<PaymentMethod[]>;
|
|
165
179
|
};
|
|
166
180
|
orders: {
|
|
167
181
|
/** List all orders for authenticated user */
|
|
@@ -204,6 +218,14 @@ export declare class GameCoreClient {
|
|
|
204
218
|
deleteAccount: () => Promise<void>;
|
|
205
219
|
/** Export user data (GDPR) */
|
|
206
220
|
exportData: () => Promise<Record<string, unknown>>;
|
|
221
|
+
/** Subscribe to broadcast notifications */
|
|
222
|
+
subscribeBroadcast: () => Promise<void>;
|
|
223
|
+
/** Unsubscribe from broadcast notifications */
|
|
224
|
+
unsubscribeBroadcast: () => Promise<void>;
|
|
225
|
+
/** Get broadcast subscription status */
|
|
226
|
+
getBroadcastStatus: () => Promise<{
|
|
227
|
+
subscribed: boolean;
|
|
228
|
+
}>;
|
|
207
229
|
};
|
|
208
230
|
favorites: {
|
|
209
231
|
/** 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
|
+
getTranslations: (locale = "ru") => this.request("GET", `/site/translations?locale=${locale}`),
|
|
81
|
+
getUIConfig: () => this.request("GET", "/site/ui-config"),
|
|
80
82
|
getCookieConsent: () => this.request("GET", "/site/cookie-consent"),
|
|
81
83
|
getCatalogSections: () => this.request("GET", "/site/catalog-sections"),
|
|
82
84
|
getBanners: () => this.request("GET", "/site/banners"),
|
|
@@ -106,7 +108,9 @@ class GameCoreClient {
|
|
|
106
108
|
logout: () => this.request("POST", "/auth/logout"),
|
|
107
109
|
getIdentities: () => this.request("GET", "/auth/identities", undefined, { rawResponse: true }),
|
|
108
110
|
linkVk: (accessToken) => this.request("POST", "/auth/link/vk", { accessToken }),
|
|
109
|
-
unlinkProvider: (provider) => this.request("POST", `/auth/unlink/${provider}`)
|
|
111
|
+
unlinkProvider: (provider) => this.request("POST", `/auth/unlink/${provider}`),
|
|
112
|
+
mergePreview: (accessToken) => this.request("POST", "/auth/merge/preview", { accessToken }),
|
|
113
|
+
mergeConfirm: (accessToken) => this.request("POST", "/auth/merge/confirm", { accessToken })
|
|
110
114
|
};
|
|
111
115
|
catalog = {
|
|
112
116
|
getGames: (params) => {
|
|
@@ -154,6 +158,9 @@ class GameCoreClient {
|
|
|
154
158
|
search: (query, limit = 20) => this.request("GET", `/catalog/search?q=${encodeURIComponent(query)}&limit=${limit}`),
|
|
155
159
|
searchSuggestions: (query, limit = 5) => this.request("GET", `/catalog/search/suggestions?q=${encodeURIComponent(query)}&limit=${limit}`),
|
|
156
160
|
getProduct: (productId) => this.request("GET", `/catalog/products/${productId}`),
|
|
161
|
+
getRecentGames: () => this.request("GET", "/catalog/recent-games"),
|
|
162
|
+
getSearchHistory: () => this.request("GET", "/catalog/search-history"),
|
|
163
|
+
saveSearchHistory: (query) => this.request("POST", "/catalog/search-history", { query }),
|
|
157
164
|
getBundleRules: () => this.request("GET", "/catalog/bundle-rules"),
|
|
158
165
|
getPromos: () => this.request("GET", "/catalog/promos"),
|
|
159
166
|
getGamesFull: () => this.request("GET", "/catalog/games/full"),
|
|
@@ -171,7 +178,10 @@ class GameCoreClient {
|
|
|
171
178
|
idempotencyKey: idempotencyKey || generateIdempotencyKey()
|
|
172
179
|
}),
|
|
173
180
|
completeWithBalance: (paymentCode) => this.request("POST", `/checkout/${paymentCode}/complete`),
|
|
174
|
-
getPaymentMethods: () =>
|
|
181
|
+
getPaymentMethods: async () => {
|
|
182
|
+
const res = await this.request("GET", "/checkout/payment-methods", undefined, { rawResponse: true });
|
|
183
|
+
return res.methods || [];
|
|
184
|
+
}
|
|
175
185
|
};
|
|
176
186
|
orders = {
|
|
177
187
|
list: () => this.request("GET", "/orders"),
|
|
@@ -197,7 +207,10 @@ class GameCoreClient {
|
|
|
197
207
|
markRead: (id) => this.request("POST", `/profile/notifications/${id}/read`),
|
|
198
208
|
markAllRead: () => this.request("POST", "/profile/notifications/read-all"),
|
|
199
209
|
deleteAccount: () => this.request("POST", "/profile/delete-account"),
|
|
200
|
-
exportData: () => this.request("GET", "/profile/export")
|
|
210
|
+
exportData: () => this.request("GET", "/profile/export"),
|
|
211
|
+
subscribeBroadcast: () => this.request("POST", "/profile/broadcast/subscribe"),
|
|
212
|
+
unsubscribeBroadcast: () => this.request("POST", "/profile/broadcast/unsubscribe"),
|
|
213
|
+
getBroadcastStatus: () => this.request("GET", "/profile/broadcast/status")
|
|
201
214
|
};
|
|
202
215
|
favorites = {
|
|
203
216
|
list: () => this.request("GET", "/favorites"),
|
package/dist/types.d.ts
CHANGED
|
@@ -82,6 +82,8 @@ export interface GameDetail {
|
|
|
82
82
|
name: string;
|
|
83
83
|
icon: string | null;
|
|
84
84
|
localIcon?: string | null;
|
|
85
|
+
coverImage?: string | null;
|
|
86
|
+
images?: string[];
|
|
85
87
|
description: string | null;
|
|
86
88
|
inStock?: boolean;
|
|
87
89
|
productCount?: number;
|
|
@@ -397,6 +399,48 @@ export interface Announcement {
|
|
|
397
399
|
imageUrl?: string | null;
|
|
398
400
|
createdAt: string;
|
|
399
401
|
}
|
|
402
|
+
export interface SiteUIConfig {
|
|
403
|
+
header: {
|
|
404
|
+
logoText?: string | null;
|
|
405
|
+
logoUrl?: string | null;
|
|
406
|
+
navLinks: Array<{
|
|
407
|
+
label: string;
|
|
408
|
+
href: string;
|
|
409
|
+
order: number;
|
|
410
|
+
enabled: boolean;
|
|
411
|
+
}>;
|
|
412
|
+
showSearch: boolean;
|
|
413
|
+
showThemeToggle: boolean;
|
|
414
|
+
};
|
|
415
|
+
footer: {
|
|
416
|
+
paymentMethods: Array<{
|
|
417
|
+
name: string;
|
|
418
|
+
icon?: string;
|
|
419
|
+
}>;
|
|
420
|
+
legalLinks: Array<{
|
|
421
|
+
label: string;
|
|
422
|
+
href: string;
|
|
423
|
+
}>;
|
|
424
|
+
socialLinks: Array<{
|
|
425
|
+
platform: string;
|
|
426
|
+
url: string;
|
|
427
|
+
icon?: string;
|
|
428
|
+
}>;
|
|
429
|
+
copyrightText?: string | null;
|
|
430
|
+
};
|
|
431
|
+
trustPills: Array<{
|
|
432
|
+
text: string;
|
|
433
|
+
icon?: string;
|
|
434
|
+
enabled: boolean;
|
|
435
|
+
}>;
|
|
436
|
+
}
|
|
437
|
+
export interface PaymentMethod {
|
|
438
|
+
type: string;
|
|
439
|
+
label: string;
|
|
440
|
+
description?: string;
|
|
441
|
+
feePercent?: number;
|
|
442
|
+
gatewayType?: string;
|
|
443
|
+
}
|
|
400
444
|
export interface CatalogSection {
|
|
401
445
|
id: number;
|
|
402
446
|
slug: string;
|