@looplay/sdk 0.6.0 → 0.7.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.
@@ -1,4 +1,4 @@
1
- import type { EmitGameEventResponse, GameEventKey, GameStoreDto, GameStoreOfferPurchaseResultDto, PagingResponse, TaskListQuery } from './LooplaySDK.types';
1
+ import type { EmitGameEventResponse, GameAssetDto, GameEventKey, GameOwnedAssetDto, GameStoreDto, GameStoreOfferPurchaseResultDto, PagingResponse, TaskListQuery } from './LooplaySDK.types';
2
2
  import { ServiceClient } from './service-client';
3
3
  import type { ServiceClientOptions } from './service-client';
4
4
  export interface ApiClientOptions extends Omit<ServiceClientOptions, 'baseUrl'> {
@@ -24,9 +24,8 @@ export declare class ApiClient {
24
24
  private gameplayAttempt?;
25
25
  private gameplayAttemptPromise?;
26
26
  constructor(options: ApiClientOptions);
27
- /** Expose the underlying route-level client (requires manual bearerToken passing). */
27
+ /** Expose the underlying route-level client (requires manual bearerToken/gameKey passing). */
28
28
  unsafeRaw(): ServiceClient;
29
- listGames(query?: Record<string, any>): Promise<PagingResponse<any>>;
30
29
  private requireToken;
31
30
  /**
32
31
  * Resolves auth for the tracking endpoints: a real bearer token if logged
@@ -50,11 +49,11 @@ export declare class ApiClient {
50
49
  * are rejected outright without a valid token.
51
50
  */
52
51
  private ensureGameplayAttempt;
53
- getGameDetail(gameId: string): Promise<any>;
54
- private resolveStoreId;
55
- listRecentPlayed(query?: Record<string, any>): Promise<PagingResponse<any>>;
56
- /** Call once when the game view opens, before any play/match tracking. */
57
- trackView(gameId: string): Promise<boolean>;
52
+ /**
53
+ * Call once when the game view opens, before any play/match tracking.
54
+ * `gameKey` is the game's public `appId`.
55
+ */
56
+ trackView(gameKey: string): Promise<boolean>;
58
57
  /**
59
58
  * Starts a new play attempt and returns its id. Call when the user
60
59
  * presses Play; `trackPlay`/`trackMatch`/`emit` reuse this id (and the
@@ -62,30 +61,26 @@ export declare class ApiClient {
62
61
  * `startAttempt()`, auto-starting one on first use if none was started.
63
62
  */
64
63
  startAttempt(): string;
65
- trackPlay(gameId: string, playTimeSeconds?: number): Promise<boolean>;
66
- trackMatch(gameId: string, body: {
64
+ trackPlay(gameKey: string, playTimeSeconds?: number): Promise<boolean>;
65
+ trackMatch(gameKey: string, body: {
67
66
  matchId: string;
68
67
  matchDurationSeconds: number;
69
68
  isCompleted?: boolean;
70
69
  isWin?: boolean;
71
70
  }): Promise<boolean>;
72
- emit(gameId: string, actionCode: GameEventKey | string, opts?: {
71
+ emit(gameKey: string, actionCode: GameEventKey | string, opts?: {
73
72
  value?: number;
74
73
  refId?: string;
75
74
  payload?: Record<string, unknown>;
76
75
  }): Promise<EmitGameEventResponse>;
77
- /** Fetches the storefront (sections + offers) for `gameId`, defined by that game's creator. */
78
- getStore(gameId: string): Promise<GameStoreDto>;
79
- /** Purchase history for the authenticated player in `gameId`'s store. */
80
- listMyStorePurchases(gameId: string): Promise<GameStoreOfferPurchaseResultDto[]>;
81
- /**
82
- * Spends coin balance to purchase a store offer — signs a checkout intent
83
- * first, then redeems it, mirroring the gameplay attempt flow above.
84
- */
85
- purchaseStoreOffer(gameId: string, offerCode: string, opts?: {
86
- requestId?: string;
87
- quantity?: number;
88
- }): Promise<GameStoreOfferPurchaseResultDto>;
76
+ /** Fetches the storefront (sections + offers) for the integration's game. Read-only, no auth required. */
77
+ getStore(gameKey: string): Promise<GameStoreDto>;
78
+ /** Public catalog of purchasable/ownable assets for the game. Read-only, no auth required. */
79
+ listGameAssets(gameKey: string): Promise<GameAssetDto[]>;
80
+ /** Assets the authenticated player already owns for this game. */
81
+ listMyGameAssets(gameKey: string): Promise<GameOwnedAssetDto[]>;
82
+ /** Purchase history for the authenticated player in the game's store. */
83
+ listMyStorePurchases(gameKey: string): Promise<GameStoreOfferPurchaseResultDto[]>;
89
84
  getMyProfile(): Promise<any>;
90
85
  getMyBalance(): Promise<any>;
91
86
  getBalances(query?: Record<string, any>): Promise<any>;
@@ -1,5 +1,5 @@
1
1
  import { type HttpClientOptions } from './http';
2
- import type { AuthResultDto, CompleteGameplayAttemptRequest, CompleteGameplayMatchRequest, CreateGameStoreCheckoutIntentRequest, EmitGameEventResponse, GameAssetDto, GameOwnedAssetDto, GameplayAttemptSessionDto, GameStoreCheckoutIntentDto, GameStoreDto, GameStoreOfferPurchaseResultDto, GameTrackingSessionDto, PagingResponse, PurchaseGameStoreOfferRuntimeRequest, RecordGameplayActionRequest, StartGameplayAttemptRequest, TaskListQuery } from './LooplaySDK.types';
2
+ import type { AuthResultDto, CompleteGameplayAttemptRequest, CompleteGameplayMatchRequest, EmitGameEventResponse, GameAssetDto, GameOwnedAssetDto, GameplayAttemptSessionDto, GameStoreDto, GameStoreOfferPurchaseResultDto, GameTrackingSessionDto, PagingResponse, RecordGameplayActionRequest, StartGameplayAttemptRequest, TaskListQuery } from './LooplaySDK.types';
3
3
  export interface ServiceClientOptions extends HttpClientOptions {
4
4
  }
5
5
  /**
@@ -27,15 +27,12 @@ export declare class ServiceClient {
27
27
  telegramLogin(telegramInitData: string): Promise<AuthResultDto>;
28
28
  refresh(refreshToken: string): Promise<AuthResultDto>;
29
29
  logout(refreshToken: string): Promise<boolean>;
30
- listGames(query?: Record<string, any>): Promise<PagingResponse<any>>;
31
- getGameDetail(gameId: string, bearerToken?: string): Promise<any>;
32
- listRecentPlayed(bearerToken: string, query?: Record<string, any>): Promise<PagingResponse<any>>;
33
- recordGameView(auth: TrackingAuth, gameId: string): Promise<boolean>;
30
+ recordGameView(gameKey: string, auth?: TrackingAuth): Promise<boolean>;
34
31
  /** Signs a fresh `attemptToken` — required by `completeGameplayAttempt`/`completeGameplayMatch`/`recordGameplayAction`. */
35
- startGameplayAttempt(auth: TrackingAuth, gameId: string, body?: StartGameplayAttemptRequest): Promise<GameplayAttemptSessionDto>;
36
- completeGameplayAttempt(auth: TrackingAuth, gameId: string, body: CompleteGameplayAttemptRequest): Promise<boolean>;
37
- completeGameplayMatch(auth: TrackingAuth, gameId: string, body: CompleteGameplayMatchRequest): Promise<boolean>;
38
- recordGameplayAction(auth: TrackingAuth, gameId: string, body: RecordGameplayActionRequest): Promise<EmitGameEventResponse>;
32
+ startGameplayAttempt(gameKey: string, auth?: TrackingAuth, body?: StartGameplayAttemptRequest): Promise<GameplayAttemptSessionDto>;
33
+ completeGameplayAttempt(gameKey: string, auth: TrackingAuth, body: CompleteGameplayAttemptRequest): Promise<boolean>;
34
+ completeGameplayMatch(gameKey: string, auth: TrackingAuth, body: CompleteGameplayMatchRequest): Promise<boolean>;
35
+ recordGameplayAction(gameKey: string, auth: TrackingAuth, body: RecordGameplayActionRequest): Promise<EmitGameEventResponse>;
39
36
  /**
40
37
  * Anonymous runtimes must call this before any tracking call; logged-in
41
38
  * runtimes should still call it to get a `trackingSessionId` for unified
@@ -43,19 +40,14 @@ export declare class ServiceClient {
43
40
  */
44
41
  bootstrapTrackingSession(anonId?: string): Promise<GameTrackingSessionDto>;
45
42
  private trackingHeaders;
46
- getStoreByStoreId(storeId: string): Promise<GameStoreDto>;
47
- listMyStorePurchasesByStoreId(bearerToken: string, storeId: string): Promise<GameStoreOfferPurchaseResultDto[]>;
48
- createStoreCheckoutIntent(bearerToken: string, body: CreateGameStoreCheckoutIntentRequest, trackingSessionId?: string): Promise<GameStoreCheckoutIntentDto>;
49
- purchaseStoreOffer(bearerToken: string, body: PurchaseGameStoreOfferRuntimeRequest, trackingSessionId?: string): Promise<GameStoreOfferPurchaseResultDto>;
50
- recordGameViewForGameKey(gameKey: string, auth?: TrackingAuth): Promise<boolean>;
51
- startGameplayAttemptForGameKey(gameKey: string, auth?: TrackingAuth, body?: StartGameplayAttemptRequest): Promise<GameplayAttemptSessionDto>;
52
- completeGameplayAttemptForGameKey(gameKey: string, auth: TrackingAuth | undefined, body: CompleteGameplayAttemptRequest): Promise<boolean>;
53
- completeGameplayMatchForGameKey(gameKey: string, auth: TrackingAuth | undefined, body: CompleteGameplayMatchRequest): Promise<boolean>;
54
- recordGameplayActionForGameKey(gameKey: string, auth: TrackingAuth | undefined, body: RecordGameplayActionRequest): Promise<EmitGameEventResponse>;
55
- getStoreForGameKey(gameKey: string): Promise<GameStoreDto>;
56
- listGameAssetsForGameKey(gameKey: string): Promise<GameAssetDto[]>;
57
- listMyOwnedAssetsForGameKey(bearerToken: string, gameKey: string): Promise<GameOwnedAssetDto[]>;
58
- listMyStorePurchasesForGameKey(bearerToken: string, gameKey: string): Promise<GameStoreOfferPurchaseResultDto[]>;
43
+ /** Public storefront (sections + offers) for the integration's game. Read-only. */
44
+ getStore(gameKey: string): Promise<GameStoreDto>;
45
+ /** Public catalog of purchasable/ownable assets for the game. Read-only. */
46
+ listGameAssets(gameKey: string): Promise<GameAssetDto[]>;
47
+ /** Assets the authenticated player already owns for this game. */
48
+ listMyGameAssets(bearerToken: string, gameKey: string): Promise<GameOwnedAssetDto[]>;
49
+ /** The authenticated player's past store purchases for this game. */
50
+ listMyStorePurchases(bearerToken: string, gameKey: string): Promise<GameStoreOfferPurchaseResultDto[]>;
59
51
  getBalances(bearerToken: string, query?: Record<string, any>): Promise<any>;
60
52
  getBalanceHistory(bearerToken: string, query?: Record<string, any>): Promise<PagingResponse<any>>;
61
53
  getMyProfile(bearerToken: string): Promise<any>;
@@ -13,6 +13,3 @@ export declare class MissingAuthError extends LooplaySDKError {
13
13
  export declare class NotAuthenticatedError extends LooplaySDKError {
14
14
  constructor();
15
15
  }
16
- export declare class MissingStoreError extends LooplaySDKError {
17
- constructor(gameId: string);
18
- }
@@ -7,7 +7,8 @@ export interface LooplaySDKCreateOptions {
7
7
  defaultHeaders?: Record<string, string>;
8
8
  }
9
9
  export interface LooplayInitParams {
10
+ /** The game's public `appId` — same value as `x-game-key`, from your creator dashboard. */
10
11
  gameId: string;
11
- /** 'none': skip verification | 'strict': verify via /games/:id (requires auth) */
12
+ /** 'none': skip verification | 'strict': resolve gameId via a read-only, unauthenticated call */
12
13
  verifyMode?: 'none' | 'strict';
13
14
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@looplay/sdk",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "LooplaySDK (auth + points) for game integrations",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",