@gamecore-api/sdk 0.13.0 → 0.15.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/README.md CHANGED
@@ -1,17 +1,29 @@
1
- # @gamecore/sdk
1
+ # @gamecore-api/sdk
2
2
 
3
3
  TypeScript SDK for GameCore API — zero external dependencies, browser-safe.
4
4
 
5
5
  ## Install
6
6
 
7
7
  ```bash
8
- npm install @gamecore/sdk
8
+ npm install @gamecore-api/sdk
9
9
  ```
10
10
 
11
+ ## What's new in 0.14.0
12
+
13
+ - **BREAKING** `giftCards.purchase()` signature changed: first arg is now `amountRub` (was `amountUsd`). GiftCard payload fields renamed — `amount_usd` → `amount_rub`, added `currency`, `remainingBalance`, `expiresAt`. `denomination` is now optional (legacy)
14
+ - `cart.merge(items)` — guest → authed cart handoff; new response fields `quantity`, `addedAt`, `gameIcon`
15
+ - `auth.linkEmail(email, password)` — add email identity to an existing Telegram/VK account
16
+ - `profile.getConversations / getConversationMessages / submitCode / submitScreenshot` — in-profile support chat
17
+ - `profile.getPushPublicKey / subscribePush / unsubscribePush` — web push subscriptions
18
+ - `referrals.getPopularProducts(limit)` + `referrals.getPerformance({ from, to })` — affiliate analytics
19
+ - `site.requestGame({ gameName, contact })` — public "request a game" lead capture
20
+ - `site.getSitemapData()` — data source for `sitemap.xml`
21
+ - `checkout.completeWithBalance` now returns `{ newBalance }`
22
+
11
23
  ## Quick Start
12
24
 
13
25
  ```typescript
14
- import { GameCoreClient } from "@gamecore/sdk";
26
+ import { GameCoreClient } from "@gamecore-api/sdk";
15
27
 
16
28
  const gc = new GameCoreClient({
17
29
  apiKey: "gc_live_YOUR_KEY",
@@ -50,6 +62,23 @@ console.log("Logged in:", user.firstName);
50
62
  const { user } = await gc.auth.verifyVk(vkAccessToken);
51
63
  ```
52
64
 
65
+ ### Email + Password
66
+
67
+ ```typescript
68
+ await gc.auth.register(email, password, firstName, ref);
69
+ await gc.auth.login(email, password);
70
+ await gc.auth.changePassword(currentPassword, newPassword);
71
+ ```
72
+
73
+ ### Link additional identity
74
+
75
+ ```typescript
76
+ // Add email to an existing Telegram/VK account
77
+ await gc.auth.linkEmail(email, password);
78
+ // Or link a VK access token
79
+ await gc.auth.linkVk(vkAccessToken);
80
+ ```
81
+
53
82
  ### Session
54
83
 
55
84
  ```typescript
@@ -88,10 +117,14 @@ const { suggestions } = await gc.catalog.searchSuggestions("rob");
88
117
  ```typescript
89
118
  // Cart
90
119
  const items = await gc.cart.get();
91
- await gc.cart.add({ productId: 10, gameId: "roblox", gameName: "Roblox", productName: "800 Robux", price: 799, deliveryData: { username: "player123" } });
120
+ // items: [{ id, productId, quantity, addedAt, gameIcon, ... }]
121
+ await gc.cart.add({ productId: 10, gameId: "roblox", gameName: "Roblox", productName: "800 Robux", price: 799, deliveryData: { username: "player123" }, quantity: 2 });
92
122
  await gc.cart.remove(itemId);
93
123
  await gc.cart.clear();
94
124
 
125
+ // Merge guest cart into authed session (on login)
126
+ await gc.cart.merge(guestItems);
127
+
95
128
  // Checkout (auto-generates idempotency key)
96
129
  const checkout = await gc.checkout.create({
97
130
  items: [{ productId: 10, deliveryData: { username: "player123" } }],
@@ -144,6 +177,17 @@ const notifications = await gc.profile.getNotifications();
144
177
  const { count } = await gc.profile.getUnreadCount();
145
178
  await gc.profile.markRead(notificationId);
146
179
  await gc.profile.markAllRead();
180
+
181
+ // Support conversations (in-profile chat)
182
+ const conversations = await gc.profile.getConversations();
183
+ const messages = await gc.profile.getConversationMessages(conversationId);
184
+ await gc.profile.submitCode(conversationId, requestId, "ABC-123");
185
+ await gc.profile.submitScreenshot(conversationId, requestId, file);
186
+
187
+ // Web push subscriptions
188
+ const { publicKey } = await gc.profile.getPushPublicKey();
189
+ await gc.profile.subscribePush({ endpoint, keys: { p256dh, auth } });
190
+ await gc.profile.unsubscribePush(endpoint);
147
191
  ```
148
192
 
149
193
  ## Favorites
@@ -185,8 +229,10 @@ await gc.coupons.remove();
185
229
  const active = await gc.coupons.getActive();
186
230
 
187
231
  // Gift cards
188
- const card = await gc.giftCards.purchase(5); // amountUsd
232
+ const card = await gc.giftCards.purchase(500, "Happy birthday!"); // amountRub + optional message
189
233
  await gc.giftCards.redeem("GC-XXXX-XXXX-XXXX");
234
+ const mine = await gc.giftCards.getMine();
235
+ // { code, amount_rub, currency, remainingBalance, expiresAt, ... }
190
236
  ```
191
237
 
192
238
  ## Referrals
@@ -198,6 +244,15 @@ const link = await gc.referrals.createLink({ label: "YouTube", slug: "my-channel
198
244
  await gc.referrals.updateLink(link.id, { label: "Updated" });
199
245
  const linkStats = await gc.referrals.getLinkStats(link.id);
200
246
  const commissions = await gc.referrals.getCommissions();
247
+
248
+ // Popular products referred by this user
249
+ const popular = await gc.referrals.getPopularProducts(10);
250
+
251
+ // Performance over a date range
252
+ const perf = await gc.referrals.getPerformance({
253
+ from: "2026-04-01",
254
+ to: "2026-04-30",
255
+ });
201
256
  ```
202
257
 
203
258
  ## Balance Top-up
@@ -236,7 +291,7 @@ const schema = await gc.seo.getSchema("product", 42);
236
291
 
237
292
  ```typescript
238
293
  // Import from server entrypoint (uses node:crypto)
239
- import { verifyWebhookSignature, parseWebhookPayload } from "@gamecore/sdk/server";
294
+ import { verifyWebhookSignature, parseWebhookPayload } from "@gamecore-api/sdk/server";
240
295
 
241
296
  const isValid = verifyWebhookSignature(
242
297
  requestBody,
@@ -253,7 +308,7 @@ if (isValid) {
253
308
  ## Utilities
254
309
 
255
310
  ```typescript
256
- import { convertPrice, formatPrice, generateIdempotencyKey } from "@gamecore/sdk";
311
+ import { convertPrice, formatPrice, generateIdempotencyKey } from "@gamecore-api/sdk";
257
312
 
258
313
  const rub = convertPrice(1.99, 92.5); // 184.08
259
314
  const formatted = formatPrice(rub, "RUB"); // "184 ₽"
@@ -266,7 +321,7 @@ const key = generateIdempotencyKey(); // UUID v4
266
321
 
267
322
  ```typescript
268
323
  // app/catalog/page.tsx
269
- import { GameCoreClient } from "@gamecore/sdk";
324
+ import { GameCoreClient } from "@gamecore-api/sdk";
270
325
 
271
326
  const gc = new GameCoreClient({
272
327
  apiKey: process.env.GAMECORE_API_KEY!,
@@ -297,7 +352,7 @@ export function CartWidget() {
297
352
 
298
353
  ```typescript
299
354
  // app/api/webhooks/gamecore/route.ts
300
- import { verifyWebhookSignature, parseWebhookPayload } from "@gamecore/sdk/server";
355
+ import { verifyWebhookSignature, parseWebhookPayload } from "@gamecore-api/sdk/server";
301
356
 
302
357
  export async function POST(req: Request) {
303
358
  const body = await req.text();
@@ -317,16 +372,16 @@ export async function POST(req: Request) {
317
372
 
318
373
  | Namespace | Methods |
319
374
  |-----------|---------|
320
- | `gc.site` | getConfig, getRates, getLegal |
321
- | `gc.auth` | initTelegram, pollTelegramStatus, verifyVk, getMe, logout, getIdentities, linkVk, unlinkProvider |
322
- | `gc.catalog` | getGames, getHomepageGames, getGame, getProducts, getProductsGrouped, search, searchSuggestions, getProduct |
323
- | `gc.cart` | get, add, sync, remove, clear |
375
+ | `gc.site` | getConfig, getRates, getLegal, getStats, getSocialProof, getThemeConfig, getTranslations, getUIConfig, getCookieConsent, getCatalogSections, getBanners, getAnnouncementBar, getSitemapData, requestGame |
376
+ | `gc.auth` | initTelegram, pollTelegramStatus, verifyMiniApp, verifyTelegramWidget, getVkAuthUrl, vkCallback, verifyVk, register, login, changePassword, getMe, logout, getIdentities, linkVk, linkEmail, unlinkProvider, mergePreview, mergeConfirm |
377
+ | `gc.catalog` | getGames, getHomepageGames, getGame, getRecommendations, getCategories, getProducts, getProductsGrouped, search, searchSuggestions, getProduct |
378
+ | `gc.cart` | get, add, merge, sync, remove, clear |
324
379
  | `gc.checkout` | create, completeWithBalance, getPaymentMethods |
325
380
  | `gc.orders` | list, get, getByPayment, cancel |
326
- | `gc.profile` | getBalance, getLevelStatus, getTransactions, getOrders, getNotifications, getUnreadCount, markRead, markAllRead |
381
+ | `gc.profile` | getBalance, getLevelStatus, getTransactions, getOrders, getNotifications, getUnreadCount, markRead, markAllRead, getConversations, getConversationMessages, submitCode, submitScreenshot, getPushPublicKey, subscribePush, unsubscribePush |
327
382
  | `gc.favorites` | list, add, remove |
328
383
  | `gc.coupons` | apply, remove, validate, getActive |
329
- | `gc.referrals` | getStats, getLinks, createLink, updateLink, deleteLink, getLinkStats, getCommissions |
384
+ | `gc.referrals` | getStats, getLinks, createLink, updateLink, deleteLink, getLinkStats, getCommissions, getPopularProducts, getPerformance |
330
385
  | `gc.reviews` | listPublic, getStats, getRandom, getMine, getPending, create |
331
386
  | `gc.topup` | getPaymentMethods, create, getStatus |
332
387
  | `gc.giftCards` | purchase, redeem, check, getMine |
@@ -339,5 +394,5 @@ export async function POST(req: Request) {
339
394
 
340
395
  | Import | Environment | Includes |
341
396
  |--------|-------------|----------|
342
- | `@gamecore/sdk` | Browser + Node | Client, types, utilities |
343
- | `@gamecore/sdk/server` | Node only | Webhook verification (uses node:crypto) |
397
+ | `@gamecore-api/sdk` | Browser + Node | Client, types, utilities |
398
+ | `@gamecore-api/sdk/server` | Node only | Webhook verification (uses node:crypto) |
package/dist/types.d.ts CHANGED
@@ -130,8 +130,28 @@ export interface GameDetail {
130
130
  /** Gallery of product screenshots (resized to 800x600). */
131
131
  images?: string[];
132
132
  description: string | null;
133
+ /**
134
+ * Short teaser (<= 200 chars) suitable for list cards and meta
135
+ * descriptions. Distinct from `description` which may be multi-paragraph.
136
+ */
137
+ shortDescription?: string | null;
133
138
  /** Editorial badges like "hit", "new", "popular", "sale". */
134
139
  tags?: string[];
140
+ /** Game developers (studio names). Empty when supplier doesn't send it. */
141
+ developers?: string[];
142
+ /** Game publishers. Empty when supplier doesn't send it. */
143
+ publishers?: string[];
144
+ /** Genre labels ("Strategy", "RPG", ...). Empty for mobile-donation games. */
145
+ genres?: string[];
146
+ /**
147
+ * Upstream release date as the supplier sends it — may be an ISO date
148
+ * "YYYY-MM-DD", a localized natural-language string ("6 июн. 2016 г."),
149
+ * or null when unknown. Storefronts should render verbatim; do not
150
+ * parse as a reliable Date.
151
+ */
152
+ releaseDate?: string | null;
153
+ /** Steam app id — null for non-Steam titles and mobile games. */
154
+ steamAppid?: number | null;
135
155
  /** Availability lifecycle. Shares the union from {@link Game}. */
136
156
  availabilityStatus?: "available" | "coming_soon" | "maintenance" | "discontinued";
137
157
  /** Human-readable message for non-available games. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gamecore-api/sdk",
3
- "version": "0.13.0",
3
+ "version": "0.15.0",
4
4
  "description": "TypeScript SDK for GameCore API — browser-safe, zero dependencies",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",