@momo-cloud/gami-sdk 0.0.53 → 0.0.67

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
@@ -120,31 +120,6 @@ await GamiSDK.endGame();
120
120
 
121
121
  ---
122
122
 
123
- #### `submit(options)`
124
-
125
- Submit game results to the backend.
126
-
127
- ```typescript
128
- const result = await GamiSDK.submit({
129
- steps: [
130
- { action: 'start', timestamp: 1699000000000, data: {...} },
131
- { action: 'move', timestamp: 1699000001000, data: {...} },
132
- { action: 'end', timestamp: 1699000010000, data: {...} }
133
- ],
134
- score: 1500
135
- });
136
-
137
- console.log('Reward:', result.gift);
138
- ```
139
-
140
- **Parameters:**
141
- - `steps` (array): Array of gameplay events for validation
142
- - `score` (number): Final score achieved
143
-
144
- **Returns:** `Promise<{ gift?: any, ... }>` - Server response with rewards
145
-
146
- ---
147
-
148
123
  ### Configuration & Data
149
124
 
150
125
  #### `getConfig()`
@@ -160,76 +135,77 @@ console.log('Game config:', config);
160
135
 
161
136
  ---
162
137
 
163
- #### `getBalance(options)`
138
+ #### `getExchange()`
164
139
 
165
- Get user's balance for specified balance IDs.
140
+ Load exchange metadata for the current game (coin → turn). The backend uses the fixed action `exchange_coin_to_turn`; the active `gameId` comes from `init`.
166
141
 
167
142
  ```typescript
168
- const balance = await GamiSDK.getBalance({
169
- balanceIds: ['coin', 'gem', 'ticket']
170
- });
143
+ const res = await GamiSDK.getExchange();
144
+ const { balance, exchangeRate, counter, counterLimit, fromCurrency, toCurrency } = res.result;
145
+ ```
146
+
147
+ **Returns:** `Promise<TGetExchangeResponse>` - Standard `response_info` plus `result` with rate, balances, counters, and currency pair
148
+
149
+ ---
171
150
 
172
- console.log('Coins:', balance.coin);
173
- console.log('Gems:', balance.gem);
151
+ #### `postExchange(options)`
152
+
153
+ Submit a coin-to-turn exchange for the current game.
154
+
155
+ ```typescript
156
+ const res = await GamiSDK.postExchange({ amount: 100 });
157
+ const { from, to, counter } = res.result;
174
158
  ```
175
159
 
176
160
  **Parameters:**
177
- - `balanceIds` (string[]): Array of balance identifiers
161
+ - `amount` (number): Coin amount to convert
178
162
 
179
- **Returns:** `Promise<TBalance>` - Balance data object
163
+ **Returns:** `Promise<TPostExchangeResponse>` - Updated `from` / `to` wallet snapshots and `counter` state
180
164
 
181
165
  ---
182
166
 
183
- #### `getBalanceConfig()`
167
+ #### `spin()`
184
168
 
185
- Get available balance types (pockets) configuration.
169
+ Perform a spinner spin for the current game. Sends `POST` to the twirler service with the active `gameId` (set via `init`).
186
170
 
187
171
  ```typescript
188
- const pockets = await GamiSDK.getBalanceConfig();
189
- console.log('Available balances:', pockets);
172
+ const result = await GamiSDK.spin();
173
+ console.log('Spin result:', result);
190
174
  ```
191
175
 
192
- **Returns:** `Promise<any>` - Pocket configuration
176
+ **Returns:** `Promise<any>` - Server response with spin outcome (e.g. prize payload); exact shape follows the backend contract
193
177
 
194
178
  ---
195
179
 
196
- #### `getTheme(options)`
180
+ #### `getBalance(options)`
197
181
 
198
- Fetch theme assets for the game.
182
+ Get user's balance for specified balance IDs.
199
183
 
200
184
  ```typescript
201
- const theme = await GamiSDK.getTheme({
202
- ext: 'json',
203
- name: 'lunar-new-year'
185
+ const { result: balance } = await GamiSDK.getBalance({
186
+ balanceId: ['turn', 'coin', 'gem', 'ticket']
204
187
  });
205
188
 
206
- console.log('Theme data:', theme);
189
+ console.log('Coins:', balance.turn);
207
190
  ```
208
191
 
209
192
  **Parameters:**
210
- - `ext` (string): extension (rule)
211
- - `name` (string): Theme name/identifier
193
+ - `balanceId` (string): Balance Id
212
194
 
213
- **Returns:** `Promise<any>` - Theme data
195
+ **Returns:** `Promise<TBalance>` - Balance data object
214
196
 
215
197
  ---
216
198
 
217
- ### Leaderboard & Rankings
218
-
219
- #### `getLeaderboard(options)`
199
+ #### `getBalanceConfig()`
220
200
 
221
- Fetch leaderboard data.
201
+ Get available balance types (pockets) configuration.
222
202
 
223
203
  ```typescript
224
- const res = await GamiSDK.getLeaderboard({
225
- boardId: 'weekly',
226
- limit: 50
227
- });
228
-
229
- console.log('Leaderboard:', res);
204
+ const pockets = await GamiSDK.getBalanceConfig();
205
+ console.log('Available balances:', pockets);
230
206
  ```
231
207
 
232
- **Returns:** `Promise<TLeaderboard>` - Leaderboard data
208
+ **Returns:** `Promise<any>` - Pocket configuration
233
209
 
234
210
  ---
235
211
 
@@ -852,11 +828,20 @@ Game Ready ✓
852
828
  The SDK is written in TypeScript and includes type definitions:
853
829
 
854
830
  ```typescript
855
- import GamiSDK, { TBalance, TLeaderboard, IUserInfo } from '@momo-cloud/gami-sdk';
831
+ import GamiSDK, {
832
+ TBalance,
833
+ TGetExchangeResponse,
834
+ TLeaderboard,
835
+ TPostExchangeResponse,
836
+ IUserInfo
837
+ } from '@momo-cloud/gami-sdk';
856
838
 
857
839
  const balance: TBalance = await GamiSDK.getBalance({
858
840
  balanceIds: ['coin']
859
841
  });
842
+
843
+ const exchangeInfo: TGetExchangeResponse = await GamiSDK.getExchange();
844
+ const posted: TPostExchangeResponse = await GamiSDK.postExchange({ amount: 100 });
860
845
  ```
861
846
 
862
847
  ### Vite Integration
@@ -1,4 +1,5 @@
1
- import { eventemitter3 } from 'eventemitter3';
1
+ import { EventEmitter } from 'eventemitter3';
2
+ import { EventSource as EventSource_2 } from 'eventsource';
2
3
 
3
4
  export declare const Calendar: CalendarAPI;
4
5
 
@@ -16,7 +17,7 @@ declare interface CalendarAPI {
16
17
  }): Promise<boolean>;
17
18
  }
18
19
 
19
- export declare const GameEvent: eventemitter3<string | symbol, any>;
20
+ export declare const GameEvent: EventEmitter<string | symbol, any>;
20
21
 
21
22
  declare const GamiSDK: {
22
23
  setServerTime: (value: number) => void;
@@ -24,6 +25,7 @@ declare const GamiSDK: {
24
25
  token: string;
25
26
  gameId: string;
26
27
  userId: string | undefined;
28
+ appProfile: TAppProfile;
27
29
  userInfo: IUserInfo | null;
28
30
  deviceInfo: TDeviceInfo;
29
31
  isBrowser: boolean;
@@ -51,20 +53,18 @@ declare const GamiSDK: {
51
53
  startGame: () => Promise<any>;
52
54
  endGame: () => Promise<void>;
53
55
  getBalance: (params: {
54
- balanceIds: string[];
56
+ balanceId: string;
55
57
  }) => Promise<any>;
56
58
  getBalanceConfig: () => Promise<any>;
57
59
  getConfig: () => Promise<any>;
58
- getTheme: (params: {
59
- ext: string;
60
- name: string;
61
- }) => Promise<any>;
62
- submit: (params: {
63
- steps: any[];
64
- score: number;
65
- }) => Promise<any>;
60
+ getExchange: (params?: {
61
+ actionId?: string;
62
+ }) => Promise<TGetExchangeResponse>;
63
+ postExchange: (params: {
64
+ amount: number;
65
+ actionId?: string;
66
+ }) => Promise<TPostExchangeResponse>;
66
67
  spin: () => Promise<any>;
67
- getMilestone: () => Promise<any>;
68
68
  getLeaderboard: (params: {
69
69
  boardId: string;
70
70
  group?: "friend" | "global";
@@ -78,6 +78,9 @@ declare const GamiSDK: {
78
78
  page: number;
79
79
  limit: number;
80
80
  }) => Promise<any>;
81
+ getMission: (params: {
82
+ viewId?: string;
83
+ }) => Promise<any>;
81
84
  showToast: (params: {
82
85
  title?: string;
83
86
  description: string;
@@ -87,6 +90,9 @@ declare const GamiSDK: {
87
90
  showAlert: (title: string, message: string, buttons?: string[]) => any;
88
91
  setItem: (key: string, obj: any) => void;
89
92
  getItem: (key: string) => Promise<unknown>;
93
+ setProfile: (profile: {
94
+ avatar: string;
95
+ }) => void;
90
96
  openWeb: ({ url, html, title }: {
91
97
  url?: string;
92
98
  html?: string;
@@ -101,16 +107,17 @@ declare const GamiSDK: {
101
107
  subject?: string;
102
108
  }) => Promise<any>;
103
109
  copyToClipBoard: (text: string, message?: string) => Promise<any>;
104
- shareFacebook: (url: string) => Promise<any>;
110
+ shareFacebook: (link: string) => Promise<any>;
111
+ shareFacebookImage: (image: string) => Promise<any>;
105
112
  shareMessenger: (link: string) => Promise<any>;
106
- requestPermission: (permission: string) => Promise<any>;
113
+ requestPermission: (permission: string, showPopupPermission?: boolean) => Promise<any>;
107
114
  checkPermission: (permission: string) => Promise<any>;
108
115
  getContacts: ({ isMoMo, contactType }?: {
109
- isMoMo?: boolean;
116
+ isMoMo?: boolean | undefined;
110
117
  contactType?: "device" | string | undefined;
111
118
  }) => Promise<any[]>;
112
119
  formatUrl: (origin: string, args?: any[]) => string;
113
- request: ({ path, method, subDomain, params, body, formData, extraHeader, useCloudMsg, mockData }: {
120
+ request: ({ path, method, subDomain, params, body, formData, extraHeader, useCloudMsg, useSendMessage, mockData, SignSecure }: {
114
121
  path: string;
115
122
  method: string;
116
123
  subDomain?: string;
@@ -119,9 +126,11 @@ declare const GamiSDK: {
119
126
  formData?: any;
120
127
  extraHeader?: any;
121
128
  useCloudMsg?: boolean;
129
+ useSendMessage?: boolean;
122
130
  mockData?: any;
131
+ SignSecure?: boolean;
123
132
  }) => Promise<any>;
124
- fetch: ({ path, method, subDomain, params, body, formData, extraHeader, mockData }: {
133
+ fetch: ({ path, method, subDomain, params, body, formData, extraHeader, mockData, useCloudMsg, useSendMessage }: {
125
134
  path: string;
126
135
  method: string;
127
136
  params?: any[];
@@ -130,7 +139,17 @@ declare const GamiSDK: {
130
139
  formData?: any;
131
140
  extraHeader?: any;
132
141
  mockData?: any;
142
+ useCloudMsg?: boolean;
143
+ useSendMessage?: boolean;
133
144
  }) => Promise<any>;
145
+ screenTracking: ({ game_id, event_name, action_name, screen_name, extra, error_code }: {
146
+ game_id?: string;
147
+ event_name: string;
148
+ action_name: string;
149
+ screen_name: string;
150
+ extra?: object;
151
+ error_code?: string | number;
152
+ }) => void;
134
153
  fetchBinary: ({ url }: {
135
154
  url: string;
136
155
  }) => Promise<unknown>;
@@ -176,15 +195,8 @@ declare const GamiSDK: {
176
195
  pinKey?: string;
177
196
  }, callback: (data: any) => void) => void;
178
197
  UploadImage: (base64: string) => Promise<string>;
198
+ getScreenShot: () => Promise<unknown>;
179
199
  trackingEvent: (event: string, data: any) => void;
180
- screenTracking: ({ game_id, event_name, action_name, screen_name, extra, error_code }: {
181
- game_id?: string;
182
- event_name: string;
183
- action_name: string;
184
- screen_name: string;
185
- extra?: object;
186
- error_code?: string | number;
187
- }) => void;
188
200
  startRefId: ({ refId, refExtra, useWeb }: {
189
201
  refId: string;
190
202
  refExtra?: string | object;
@@ -210,9 +222,22 @@ export declare interface IUserInfo {
210
222
  avatar?: string;
211
223
  }
212
224
 
225
+ export declare class SSE {
226
+ static create(url: string): EventSource_2;
227
+ }
228
+
213
229
  declare const Storage_2: IStorageAPI;
214
230
  export { Storage_2 as Storage }
215
231
 
232
+ declare type TAppProfile = {
233
+ id: string;
234
+ userId: string;
235
+ name: string;
236
+ displayName: string;
237
+ avatar: string;
238
+ userInputDateOfBirth: string;
239
+ };
240
+
216
241
  export declare type TDeviceInfo = {
217
242
  appVersion: string;
218
243
  buildVersion: string;
@@ -222,6 +247,48 @@ export declare type TDeviceInfo = {
222
247
  devicePerformance?: string;
223
248
  };
224
249
 
250
+ export declare type TGetExchangeResponse = {
251
+ response_info: {
252
+ error_message: string;
253
+ error_code: number;
254
+ event_tracking: string;
255
+ };
256
+ result: {
257
+ balance: number;
258
+ exchangeRate: number;
259
+ counter: number;
260
+ counterLimit: number;
261
+ fromCurrency: string;
262
+ toCurrency: string;
263
+ };
264
+ };
265
+
266
+ export declare type TPostExchangeResponse = {
267
+ response_info: {
268
+ error_message: string;
269
+ error_code: number;
270
+ event_tracking: string;
271
+ };
272
+ result: {
273
+ from: {
274
+ walletType: string;
275
+ currency: string;
276
+ before: number;
277
+ after: number;
278
+ };
279
+ to: {
280
+ walletType: string;
281
+ currency: string;
282
+ before: number;
283
+ after: number;
284
+ };
285
+ counter: {
286
+ value: number;
287
+ limit: number;
288
+ };
289
+ };
290
+ };
291
+
225
292
  export declare const Utils: {
226
293
  num10to11: (number: string) => string;
227
294
  num11to10: (number: string) => string;