@jetthai/cuora 1.1.441-dev.1 → 1.1.441

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.
Files changed (166) hide show
  1. package/.claude/commands/auto-git-flow.md +12 -5
  2. package/.claude/commands/commit-push.md +4 -15
  3. package/.claude/commands/sync-ai-prompts.md +1 -88
  4. package/.claude/settings.local.json +1 -3
  5. package/.claude/worktrees/geemee-sendpixel/.claude/commands/auto-git-flow.md +52 -0
  6. package/.claude/worktrees/geemee-sendpixel/.claude/commands/commit-push.md +174 -0
  7. package/.claude/worktrees/geemee-sendpixel/.claude/commands/create-branch.md +142 -0
  8. package/.claude/worktrees/geemee-sendpixel/.claude/commands/sync-ai-prompts.md +93 -0
  9. package/.claude/worktrees/geemee-sendpixel/.claude/settings.local.json +23 -0
  10. package/.claude/worktrees/geemee-sendpixel/.github/copilot-instructions.md +696 -0
  11. package/.claude/worktrees/geemee-sendpixel/.husky/post-checkout +32 -0
  12. package/.claude/worktrees/geemee-sendpixel/.husky/pre-commit +2 -0
  13. package/.claude/worktrees/geemee-sendpixel/.husky/pre-push +36 -0
  14. package/.claude/worktrees/geemee-sendpixel/.prettierignore +1 -0
  15. package/.claude/worktrees/geemee-sendpixel/.prettierrc +7 -0
  16. package/.claude/worktrees/geemee-sendpixel/AGENTS.md +696 -0
  17. package/.claude/worktrees/geemee-sendpixel/AI_PROMPT_SOURCE.md +758 -0
  18. package/.claude/worktrees/geemee-sendpixel/CHANGELOG.md +1779 -0
  19. package/.claude/worktrees/geemee-sendpixel/CLAUDE.md +696 -0
  20. package/.claude/worktrees/geemee-sendpixel/GEMINI.md +696 -0
  21. package/.claude/worktrees/geemee-sendpixel/README.md +308 -0
  22. package/.claude/worktrees/geemee-sendpixel/docs/kibana/crypto-way-deposit-amount-bug-analysis.md +1003 -0
  23. package/.claude/worktrees/geemee-sendpixel/docs/kibana/play-providerId-error.md +202 -0
  24. package/.claude/worktrees/geemee-sendpixel/docs/kibana/play-selectedWalletType.md +1 -0
  25. package/.claude/worktrees/geemee-sendpixel/docs/kibana/play-selectedWalletType_2.md +1 -0
  26. package/.claude/worktrees/geemee-sendpixel/docs/kibana/play-selectedWalletType_analysis.md +565 -0
  27. package/.claude/worktrees/geemee-sendpixel/package-lock.json +2455 -0
  28. package/.claude/worktrees/geemee-sendpixel/package.json +34 -0
  29. package/.claude/worktrees/geemee-sendpixel/scripts/auto-version.js +68 -0
  30. package/.claude/worktrees/geemee-sendpixel/scripts/auto-version.sh +33 -0
  31. package/.claude/worktrees/geemee-sendpixel/scripts/branch-auto-npm-publish.js +29 -0
  32. package/.claude/worktrees/geemee-sendpixel/scripts/check-version.sh +36 -0
  33. package/.claude/worktrees/geemee-sendpixel/scripts/clean-tags.sh +59 -0
  34. package/.claude/worktrees/geemee-sendpixel/src/api/account.js +8 -0
  35. package/.claude/worktrees/geemee-sendpixel/src/api/activity.js +128 -0
  36. package/.claude/worktrees/geemee-sendpixel/src/api/auth.js +63 -0
  37. package/.claude/worktrees/geemee-sendpixel/src/api/common.js +17 -0
  38. package/.claude/worktrees/geemee-sendpixel/src/api/form.js +3 -0
  39. package/.claude/worktrees/geemee-sendpixel/src/api/game.js +114 -0
  40. package/.claude/worktrees/geemee-sendpixel/src/api/index.js +13 -0
  41. package/.claude/worktrees/geemee-sendpixel/src/api/mailbox.js +24 -0
  42. package/.claude/worktrees/geemee-sendpixel/src/api/otp.js +5 -0
  43. package/.claude/worktrees/geemee-sendpixel/src/api/payment.js +262 -0
  44. package/.claude/worktrees/geemee-sendpixel/src/api/ranking.js +27 -0
  45. package/.claude/worktrees/geemee-sendpixel/src/api/user.js +69 -0
  46. package/.claude/worktrees/geemee-sendpixel/src/index.js +7 -0
  47. package/.claude/worktrees/geemee-sendpixel/src/machine/activity/activity.js +209 -0
  48. package/.claude/worktrees/geemee-sendpixel/src/machine/activity/activity_cash.js +181 -0
  49. package/.claude/worktrees/geemee-sendpixel/src/machine/activity/cash_rain_activity.js +153 -0
  50. package/.claude/worktrees/geemee-sendpixel/src/machine/activity/continue_deposit_activity.js +146 -0
  51. package/.claude/worktrees/geemee-sendpixel/src/machine/activity/deposit_activity.js +95 -0
  52. package/.claude/worktrees/geemee-sendpixel/src/machine/activity/diamond_shop_activity_cash.js +179 -0
  53. package/.claude/worktrees/geemee-sendpixel/src/machine/activity/diamond_shop_activity_fc.js +196 -0
  54. package/.claude/worktrees/geemee-sendpixel/src/machine/activity/diamond_shop_activity_vn.js +178 -0
  55. package/.claude/worktrees/geemee-sendpixel/src/machine/activity/fafafa_activity.js +208 -0
  56. package/.claude/worktrees/geemee-sendpixel/src/machine/activity/friend_invite_friends_activity.js +287 -0
  57. package/.claude/worktrees/geemee-sendpixel/src/machine/activity/index.js +51 -0
  58. package/.claude/worktrees/geemee-sendpixel/src/machine/activity/instant_rebate_activity.js +209 -0
  59. package/.claude/worktrees/geemee-sendpixel/src/machine/activity/invite_friends_activity.js +114 -0
  60. package/.claude/worktrees/geemee-sendpixel/src/machine/activity/jackpot.js +74 -0
  61. package/.claude/worktrees/geemee-sendpixel/src/machine/activity/mini_game_activity.js +68 -0
  62. package/.claude/worktrees/geemee-sendpixel/src/machine/activity/otp_verified_activity.js +74 -0
  63. package/.claude/worktrees/geemee-sendpixel/src/machine/activity/ranking_activity.js +105 -0
  64. package/.claude/worktrees/geemee-sendpixel/src/machine/activity/return_bonus_activity.js +153 -0
  65. package/.claude/worktrees/geemee-sendpixel/src/machine/activity/roulette_activity_v2.js +95 -0
  66. package/.claude/worktrees/geemee-sendpixel/src/machine/activity/sign_in_activity.js +157 -0
  67. package/.claude/worktrees/geemee-sendpixel/src/machine/activity/sign_in_monthly_activity.js +65 -0
  68. package/.claude/worktrees/geemee-sendpixel/src/machine/activity/specify_bets_activity.js +157 -0
  69. package/.claude/worktrees/geemee-sendpixel/src/machine/activity/specify_turnover_activity.js +136 -0
  70. package/.claude/worktrees/geemee-sendpixel/src/machine/activity/time_bomb_activity.js +89 -0
  71. package/.claude/worktrees/geemee-sendpixel/src/machine/activity/vip_card_activity.js +187 -0
  72. package/.claude/worktrees/geemee-sendpixel/src/machine/auth.js +592 -0
  73. package/.claude/worktrees/geemee-sendpixel/src/machine/auth_otp_v2.js +177 -0
  74. package/.claude/worktrees/geemee-sendpixel/src/machine/auth_otp_v3.js +300 -0
  75. package/.claude/worktrees/geemee-sendpixel/src/machine/bank_binding.js +277 -0
  76. package/.claude/worktrees/geemee-sendpixel/src/machine/bank_binding_amb.js +146 -0
  77. package/.claude/worktrees/geemee-sendpixel/src/machine/bonus.js +76 -0
  78. package/.claude/worktrees/geemee-sendpixel/src/machine/common.js +418 -0
  79. package/.claude/worktrees/geemee-sendpixel/src/machine/deposit/amb.js +93 -0
  80. package/.claude/worktrees/geemee-sendpixel/src/machine/deposit/crypto_bank.js +330 -0
  81. package/.claude/worktrees/geemee-sendpixel/src/machine/deposit/crypto_bank_cash.js +307 -0
  82. package/.claude/worktrees/geemee-sendpixel/src/machine/deposit/crypto_qrcode.js +148 -0
  83. package/.claude/worktrees/geemee-sendpixel/src/machine/deposit/crypto_qrcode_cash.js +131 -0
  84. package/.claude/worktrees/geemee-sendpixel/src/machine/deposit/crypto_way.js +252 -0
  85. package/.claude/worktrees/geemee-sendpixel/src/machine/deposit/crypto_way_cash.js +296 -0
  86. package/.claude/worktrees/geemee-sendpixel/src/machine/deposit/deposit_fc.js +272 -0
  87. package/.claude/worktrees/geemee-sendpixel/src/machine/deposit/direct.js +310 -0
  88. package/.claude/worktrees/geemee-sendpixel/src/machine/deposit/direct_cash.js +225 -0
  89. package/.claude/worktrees/geemee-sendpixel/src/machine/deposit/float.js +375 -0
  90. package/.claude/worktrees/geemee-sendpixel/src/machine/deposit/index.js +49 -0
  91. package/.claude/worktrees/geemee-sendpixel/src/machine/deposit/krway.js +151 -0
  92. package/.claude/worktrees/geemee-sendpixel/src/machine/deposit/loadcard_cash.js +215 -0
  93. package/.claude/worktrees/geemee-sendpixel/src/machine/deposit/loadcard_vn.js +351 -0
  94. package/.claude/worktrees/geemee-sendpixel/src/machine/deposit/manual_cash.js +364 -0
  95. package/.claude/worktrees/geemee-sendpixel/src/machine/deposit/manual_vn.js +458 -0
  96. package/.claude/worktrees/geemee-sendpixel/src/machine/deposit/qrcode_cash.js +225 -0
  97. package/.claude/worktrees/geemee-sendpixel/src/machine/deposit/qrcode_v2.js +338 -0
  98. package/.claude/worktrees/geemee-sendpixel/src/machine/deposit/usdt.js +144 -0
  99. package/.claude/worktrees/geemee-sendpixel/src/machine/deposit/usdt_cash.js +138 -0
  100. package/.claude/worktrees/geemee-sendpixel/src/machine/deposit/virtual_bank_cash.js +209 -0
  101. package/.claude/worktrees/geemee-sendpixel/src/machine/deposit/virtual_bank_vn.js +269 -0
  102. package/.claude/worktrees/geemee-sendpixel/src/machine/deposit/vpay.js +368 -0
  103. package/.claude/worktrees/geemee-sendpixel/src/machine/error.js +112 -0
  104. package/.claude/worktrees/geemee-sendpixel/src/machine/game_betslip.js +46 -0
  105. package/.claude/worktrees/geemee-sendpixel/src/machine/game_favorite_v2.js +160 -0
  106. package/.claude/worktrees/geemee-sendpixel/src/machine/game_hot_new.js +79 -0
  107. package/.claude/worktrees/geemee-sendpixel/src/machine/game_info.js +61 -0
  108. package/.claude/worktrees/geemee-sendpixel/src/machine/game_replay.js +46 -0
  109. package/.claude/worktrees/geemee-sendpixel/src/machine/game_search_cash.js +401 -0
  110. package/.claude/worktrees/geemee-sendpixel/src/machine/game_search_v2.js +401 -0
  111. package/.claude/worktrees/geemee-sendpixel/src/machine/game_v2_1.js +699 -0
  112. package/.claude/worktrees/geemee-sendpixel/src/machine/honor_board.js +132 -0
  113. package/.claude/worktrees/geemee-sendpixel/src/machine/honor_board_cash.js +89 -0
  114. package/.claude/worktrees/geemee-sendpixel/src/machine/inbox.js +489 -0
  115. package/.claude/worktrees/geemee-sendpixel/src/machine/index.js +89 -0
  116. package/.claude/worktrees/geemee-sendpixel/src/machine/leaderboard.js +130 -0
  117. package/.claude/worktrees/geemee-sendpixel/src/machine/merge.js +57 -0
  118. package/.claude/worktrees/geemee-sendpixel/src/machine/navbar.js +126 -0
  119. package/.claude/worktrees/geemee-sendpixel/src/machine/payment_data.js +86 -0
  120. package/.claude/worktrees/geemee-sendpixel/src/machine/promotions.js +170 -0
  121. package/.claude/worktrees/geemee-sendpixel/src/machine/ranking.js +219 -0
  122. package/.claude/worktrees/geemee-sendpixel/src/machine/reward.js +255 -0
  123. package/.claude/worktrees/geemee-sendpixel/src/machine/reward_cash.js +276 -0
  124. package/.claude/worktrees/geemee-sendpixel/src/machine/reward_fc.js +98 -0
  125. package/.claude/worktrees/geemee-sendpixel/src/machine/roulette_v2.js +280 -0
  126. package/.claude/worktrees/geemee-sendpixel/src/machine/setting.js +47 -0
  127. package/.claude/worktrees/geemee-sendpixel/src/machine/side.js +154 -0
  128. package/.claude/worktrees/geemee-sendpixel/src/machine/side_cash.js +111 -0
  129. package/.claude/worktrees/geemee-sendpixel/src/machine/side_v2.js +209 -0
  130. package/.claude/worktrees/geemee-sendpixel/src/machine/user_info.js +64 -0
  131. package/.claude/worktrees/geemee-sendpixel/src/machine/user_photo.js +65 -0
  132. package/.claude/worktrees/geemee-sendpixel/src/machine/user_reset_password.js +231 -0
  133. package/.claude/worktrees/geemee-sendpixel/src/machine/user_sign_up.js +244 -0
  134. package/.claude/worktrees/geemee-sendpixel/src/machine/vip_table.js +57 -0
  135. package/.claude/worktrees/geemee-sendpixel/src/machine/websocket.js +361 -0
  136. package/.claude/worktrees/geemee-sendpixel/src/machine/welcome.js +110 -0
  137. package/.claude/worktrees/geemee-sendpixel/src/machine/withdraw/index.js +11 -0
  138. package/.claude/worktrees/geemee-sendpixel/src/machine/withdraw/withdraw_crypto_cash.js +327 -0
  139. package/.claude/worktrees/geemee-sendpixel/src/machine/withdraw/withdraw_krway.js +223 -0
  140. package/.claude/worktrees/geemee-sendpixel/src/machine/withdraw/withdraw_manual.js +536 -0
  141. package/.claude/worktrees/geemee-sendpixel/src/machine/withdraw/withdraw_manual_cash.js +324 -0
  142. package/.claude/worktrees/geemee-sendpixel/src/request/config.js +41 -0
  143. package/.claude/worktrees/geemee-sendpixel/src/request/request.js +365 -0
  144. package/.claude/worktrees/geemee-sendpixel/src/util/constant.js +20 -0
  145. package/.claude/worktrees/geemee-sendpixel/src/util/index.js +6 -0
  146. package/.claude/worktrees/geemee-sendpixel/src/util/math.js +4 -0
  147. package/.claude/worktrees/geemee-sendpixel/src/util/storage.js +42 -0
  148. package/.github/copilot-instructions.md +399 -551
  149. package/.husky/post-checkout +3 -3
  150. package/.husky/pre-push +1 -1
  151. package/.prettierignore +1 -2
  152. package/AGENTS.md +399 -551
  153. package/AI_PROMPT_SOURCE.md +130 -662
  154. package/CHANGELOG.md +22 -229
  155. package/CLAUDE.md +399 -551
  156. package/GEMINI.md +399 -551
  157. package/README.md +137 -40
  158. package/package.json +1 -1
  159. package/scripts/auto-version.js +0 -1
  160. package/src/api/activity.js +0 -10
  161. package/src/api/auth.js +2 -2
  162. package/src/machine/activity/activity_cash.js +3 -18
  163. package/src/machine/auth.js +10 -2
  164. package/src/machine/common.js +15 -1
  165. package/src/machine/ranking.js +25 -43
  166. package/src/machine/user_sign_up.js +67 -7
package/README.md CHANGED
@@ -1,8 +1,34 @@
1
1
  # @jetthai/cuora
2
2
 
3
- ESM JavaScript 函式庫,透過 XState v4 狀態機整合 API 呼叫與業務邏輯,服務於線上遊戲平台。處理認證、支付(存款/提款)、遊戲管理、活動及即時 WebSocket 通訊。
4
-
5
- 設計用於 Nuxt.js 客戶端應用程式(`ssr: false`)。
3
+ `@jetthai/cuora` 是一個純 ESM JavaScript 函式庫,無建置步驟,原始 `.js` 檔案直接發佈至 npm。透過 XState v4 狀態機整合 API 呼叫與業務邏輯,服務於線上遊戲平台,處理認證、支付(存款/提款)、遊戲管理、活動及即時 WebSocket 通訊。設計用於 Nuxt.js 客戶端應用程式(`ssr: false`)。
4
+
5
+ - **模組格式**:`"type": "module"`
6
+ - **進入點**:`./src/index.js`
7
+ - **無建置步驟**:無 Webpack/Rollup/TypeScript,無測試框架,無 Linter
8
+ - **程式碼格式化**:Prettier(不加分號、單引號、2 空格縮排、150 字元行寬、ES5 尾隨逗號)
9
+ - **Pre-commit Hook**:Husky 執行 `npm run format && git add .`
10
+
11
+ ## 目錄
12
+
13
+ - [Installation](#installation)
14
+ - [Setup](#setup)
15
+ - [Usage](#usage)
16
+ - [模組匯出](#模組匯出)
17
+ - [Config](#config)
18
+ - [Request](#request)
19
+ - [API](#api)
20
+ - [Machine](#machine)
21
+ - [Utilities](#utilities)
22
+ - [Dependencies](#dependencies)
23
+ - [Architecture](#architecture)
24
+ - [Development](#development)
25
+ - [Git 分支版本發佈流程](#git-分支版本發佈流程)
26
+ - [分支策略](#分支策略)
27
+ - [腳本權責分離](#腳本權責分離)
28
+ - [dev / qa 分支自動版本流程](#dev--qa-分支自動版本流程)
29
+ - [版號計算規則](#版號計算規則)
30
+ - [Husky Hooks 總覽](#husky-hooks-總覽)
31
+ - [License](#license)
6
32
 
7
33
  ## Installation
8
34
 
@@ -30,6 +56,18 @@ export default {
30
56
  import { api, machine, Request, Config, util, constant, storage } from '@jetthai/cuora'
31
57
  ```
32
58
 
59
+ ### 模組匯出
60
+
61
+ | 匯出名稱 | 說明 |
62
+ | ---------- | ------------------------------------------------------- |
63
+ | `api` | 11 個 API 模組的聚合物件 |
64
+ | `machine` | 91 個 XState 狀態機工廠函式的聚合物件 |
65
+ | `Request` | Axios 封裝類別(攔截器、Token、版本控制) |
66
+ | `Config` | 設定類別(apiURL、clientId、appSecret 等) |
67
+ | `util` | 工具函式(`getDeviceToken`、`getDeviceTokenWithRetry`) |
68
+ | `constant` | 遊戲類型常數(16 種遊戲類型) |
69
+ | `storage` | localStorage 封裝(支援 TTL/過期) |
70
+
33
71
  ### Config
34
72
 
35
73
  初始化 API 設定:
@@ -120,36 +158,35 @@ storage.set('key', value, ttl)
120
158
  storage.get('key')
121
159
 
122
160
  // 遊戲類型常數
123
- constant.SLOT
124
- constant.FISH
125
- constant.LIVE
126
- constant.SPORT
161
+ constant.GAME_TYPE_LIST // 16 種遊戲類型陣列,每筆為 { typeId, name, gameTypeMappingId }
162
+ constant.MY_FAVORITE // 'MyFavorite'
163
+ constant.GAME_SEARCH // 'GameSearch'
127
164
  ```
128
165
 
166
+ ## Dependencies
167
+
168
+ | 套件 | 版本 | 角色 | 使用位置 |
169
+ | ------------------ | ---------- | ---------------------------------------------------------------------------------- | ---------------------- |
170
+ | `xstate` | `^4.25.0` | 狀態機核心框架 | 所有 `machine/` 檔案 |
171
+ | `socket.io-client` | `^4.8.3` | WebSocket 即時通訊 | `machine/websocket.js` |
172
+ | `lodash` | `^4.17.21` | 工具函式(`pickBy`、`uniqBy`、`findLastIndex`、`padStart`、`toNumber`、`isEqual`) | 分散於 12 個檔案 |
173
+ | `ua-parser-js` | `^0.7.34` | 使用者代理解析(行動裝置偵測) | `machine/common.js` |
174
+ | `url-join` | `^4.0.1` | URL 路徑安全組合 | `request/config.js` |
175
+ | `universal-cookie` | `^4.0.4` | Cookie 操作 | `machine/common.js` |
176
+
129
177
  ## Architecture
130
178
 
131
179
  ```
132
180
  src/
133
181
  ├── index.js # 進入點
134
182
  ├── api/ # API 請求描述物件
135
- │ ├── auth.js
136
- │ ├── account.js
137
- │ ├── activity.js
138
- │ ├── common.js
139
- │ ├── form.js
140
- │ ├── game.js
141
- │ ├── mailbox.js
142
- │ ├── otp.js
143
- │ ├── payment.js
144
- │ ├── ranking.js
145
- │ └── user.js
146
183
  ├── machine/ # XState v4 狀態機
147
184
  │ ├── auth.js # 登入/註冊流程
148
185
  │ ├── common.js # 網站設定、UA、聯盟行銷
149
186
  │ ├── websocket.js # Socket.IO 即時通訊
150
- │ ├── deposit/ # 存款狀態機 (22+)
151
- │ ├── withdraw/ # 提款狀態機 (4)
152
- │ └── activity/ # 活動狀態機 (24+)
187
+ │ ├── deposit/ # 存款狀態機
188
+ │ ├── withdraw/ # 提款狀態機
189
+ │ └── activity/ # 活動狀態機
153
190
  ├── request/
154
191
  │ ├── config.js # Config 設定類別
155
192
  │ └── request.js # Axios 封裝 + 攔截器
@@ -180,32 +217,92 @@ npm run release:qa
180
217
 
181
218
  程式碼風格由 Prettier 管理(無分號、單引號、尾隨逗號 ES5、2 空格縮排、150 字元行寬),Husky pre-commit hook 會在每次提交時自動格式化。
182
219
 
183
- ### dev / qa 分支版本發佈
220
+ ## Git 分支版本發佈流程
221
+
222
+ ### 分支策略
223
+
224
+ | 分支 | 用途 | 版本格式 |
225
+ | -------- | -------- | -------------------------- |
226
+ | `master` | 正式發佈 | `x.y.z`(如 `1.1.430`) |
227
+ | `dev` | 開發測試 | `{master_version}-dev.{N}` |
228
+ | `qa` | QA 測試 | `{master_version}-qa.{N}` |
229
+
230
+ ### 腳本權責分離
231
+
232
+ dev/qa 分支的自動版本發佈由三個腳本各司其職:
233
+
234
+ | 腳本 | 職責 | 說明 |
235
+ | ------------------------------------ | --------------------- | ----------------------------------------------------------------------------------------------------- |
236
+ | `scripts/auto-version.sh` | **流程控制**(Shell) | pre-push hook 入口。依序呼叫版號計算 → standard-version → push + publish,最後 `exit 1` 中止原始 push |
237
+ | `scripts/auto-version.js` | **版號計算**(ESM) | 純計算邏輯。讀取 master 版本、比對當前版本與 git log 歷史(historyMax 防倒退),stdout 輸出新版號 |
238
+ | `scripts/branch-auto-npm-publish.js` | **推送與發佈**(ESM) | 執行 `git push --follow-tags` 推送至遠端,再 `npm publish --tag {branch}` 發佈至 npm registry |
184
239
 
185
- 在 `dev` 或 `qa` 分支執行 `git push` 時,Husky `pre-push` hook 會自動觸發三階段流程:
240
+ ### dev / qa 分支自動版本流程
241
+
242
+ 當開發者在 `dev` 或 `qa` 分支執行 `git push` 時,Husky `pre-push` hook 觸發以下流程:
186
243
 
187
244
  ```
188
- git push → auto-version.sh(流程控制)
189
- ├─ ① auto-version.js → 計算版號(含 historyMax 防倒退)
190
- ├─ ② standard-version → 更新 CHANGELOG + commit + tag
191
- └─ ③ branch-auto-npm-publish.js → git push + npm publish
245
+ git push origin dev
246
+ │
247
+ ├─ .husky/pre-push
248
+ │ ├─ sh scripts/clean-tags.sh # 清理本地 tag
249
+ │ └─ sh scripts/auto-version.sh "$1" # 流程入口(傳入 remote name)
250
+ │
251
+ ├─ auto-version.sh 流程控制
252
+ │ │
253
+ │ ├─ ① node scripts/auto-version.js ← 版號計算
254
+ │ │ ├─ git show origin/master:package.json → 取得 master version(如 1.1.430)
255
+ │ │ │ └─ fallback: git show master:package.json
256
+ │ │ ├─ 讀取當前 package.json version
257
+ │ │ ├─ 從 currentVersion 推算下一編號
258
+ │ │ ├─ 掃描 git log 最近 50 筆 commit(historyMax 防倒退)
259
+ │ │ └─ stdout 輸出新版號(如 1.1.430-dev.3)
260
+ │ │ └─ 若版號無變更 → 靜默退出,auto-version.sh 跳過後續步驟
261
+ │ │
262
+ │ ├─ ② npx standard-version --release-as {version}
263
+ │ │ └─ 更新 CHANGELOG.md + 建立 commit + 建立 git tag
264
+ │ │
265
+ │ ├─ ③ node scripts/branch-auto-npm-publish.js ← 推送與發佈
266
+ │ │ ├─ git push --follow-tags origin dev
267
+ │ │ └─ npm publish --tag dev
268
+ │ │
269
+ │ └─ exit 1(中止原始 push,因為 script 已完成推送)
270
+ │
271
+ └─ 終端顯示 push 失敗,但實際發佈已成功(以 Released x.x.x 訊息為準)
192
272
  ```
193
273
 
194
- **腳本權責:**
274
+ ### 版號計算規則
275
+
276
+ **基本遞增**:
277
+
278
+ - master 為 `1.1.430` → dev 第一次 push:`1.1.430-dev.0`
279
+ - 再次 push:`1.1.430-dev.1`、`1.1.430-dev.2`、...
280
+ - master 升版至 `1.1.431` → dev 重置為 `1.1.431-dev.0`
281
+ - qa 分支同理:`1.1.430-qa.0`、`1.1.430-qa.1`、...
195
282
 
196
- | 腳本 | 職責 | 說明 |
197
- | ------------------------------------ | ---------- | --------------------------------------------------------- |
198
- | `scripts/auto-version.sh` | 流程控制 | pre-push 入口,串接版號計算 → standard-version → 發佈 |
199
- | `scripts/auto-version.js` | 版號計算 | 讀取 master 版本 + 掃描 git log 防倒退,stdout 輸出新版號 |
200
- | `scripts/branch-auto-npm-publish.js` | 推送與發佈 | `git push --follow-tags` + `npm publish --tag {branch}` |
283
+ **historyMax 防倒退機制**:
201
284
 
202
- **版本號規則:**
285
+ merge 其他分支後,`package.json` 的 version 可能被覆蓋為舊值(如從 `1.1.430-dev.4` 退回 `1.0.9-dev.20`)。此時腳本會掃描 git log 找出該 prefix 歷史上用過的最大編號,確保新版號不會倒退:
203
286
 
204
- | 情境 | 範例 |
205
- | ------------------------------------ | ------------------------------------- |
206
- | master 為 `1.1.425`,dev 第一次 push | `1.1.425-dev.0` |
207
- | dev 再次 push | `1.1.425-dev.1`、`1.1.425-dev.2`、... |
208
- | master 升版至 `1.1.426` 後 | dev 重置為 `1.1.426-dev.0` |
209
- | qa 分支 | `1.1.425-qa.0`、`1.1.425-qa.1`、... |
287
+ ```
288
+ currentVersion = "1.0.9-dev.20" ← merge 後被覆蓋
289
+ git log 發現歷史有 "1.1.430-dev.4"
290
+ → historyMax = 4, nextNum = 5
291
+ → 新版號 = "1.1.430-dev.5"(而非從 0 重新開始)
292
+ ```
293
+
294
+ ### Husky Hooks 總覽
295
+
296
+ | Hook | 檔案 | 說明 |
297
+ | --------------- | ---------------------- | ---------------------------------------------------- |
298
+ | `pre-commit` | `.husky/pre-commit` | 執行 `npm run format && git add .`(Prettier) |
299
+ | `pre-push` | `.husky/pre-push` | dev/qa 分支自動版本發佈(`scripts/auto-version.sh`) |
300
+ | `post-checkout` | `.husky/post-checkout` | dev/qa/hotfix 分支自動 `git pull --rebase` |
301
+ | `post-commit` | `.husky/post-commit` | (保留,目前無額外操作) |
302
+ | `post-merge` | `.husky/post-merge` | (保留,目前無額外操作) |
210
303
 
211
304
  > **注意**:`pre-push` hook 完成推送後會以 `exit 1` 中止原始 push(因為已推送完成),終端會顯示 push 失敗訊息,但實際發佈已成功。以 `Released x.x.x on {branch}` 訊息為準。
305
+
306
+ ## License
307
+
308
+ ISC
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.441-dev.1",
3
+ "version": "1.1.441",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env node
2
- // Copyright 2024 The Terasology Foundation
3
2
 
4
3
  // dev/qa 分支自動計算下一個 prerelease 版號
5
4
  // 版號格式:{master 版號}-{分支名}.{遞增編號}
@@ -125,14 +125,4 @@ export default {
125
125
  method: 'get',
126
126
  params: { activityNo, appSecret },
127
127
  }),
128
- getProgressSummary: ({ appSecret }) => ({
129
- url: 'activities/progress-summary',
130
- method: 'get',
131
- params: { appSecret },
132
- }),
133
- getProgressDetail: ({ appSecret }) => ({
134
- url: 'activities/progress-details',
135
- method: 'get',
136
- params: { appSecret },
137
- }),
138
128
  }
package/src/api/auth.js CHANGED
@@ -31,8 +31,8 @@ export default {
31
31
  },
32
32
  isPublic: true,
33
33
  }),
34
- register: ({ ac, fc = null, reCaptchaToken, dt, ...rest }) => {
35
- const params = pickBy({ ac, fc }, (value) => {
34
+ register: ({ channel, subchannel, ac, fc = null, reCaptchaToken, dt, ...rest }) => {
35
+ const params = pickBy({ channel, subchannel, ac, fc }, (value) => {
36
36
  return value !== undefined && value !== null
37
37
  })
38
38
  const qs = Object.keys(params)
@@ -11,7 +11,6 @@ export default function (request) {
11
11
  context: {
12
12
  tick: 2000,
13
13
  activityList: [],
14
- progressSummary: {},
15
14
  tournamentList: [],
16
15
  promotionList: [],
17
16
  uidSite: '',
@@ -25,7 +24,7 @@ export default function (request) {
25
24
  src: 'fetchList',
26
25
  onDone: {
27
26
  target: 'checking',
28
- actions: ['setActivityList', 'setTournamentList', 'setPromotionList', 'setProgressSummary'],
27
+ actions: ['setActivityList', 'setTournamentList', 'setPromotionList'],
29
28
  },
30
29
  onError: {
31
30
  target: 'pending',
@@ -97,12 +96,6 @@ export default function (request) {
97
96
  activityList: list,
98
97
  }
99
98
  }),
100
- setProgressSummary: assign((context, event) => {
101
- const { progressSummary } = event.data
102
- return {
103
- progressSummary: progressSummary || null,
104
- }
105
- }),
106
99
  setPromotionList: assign((context, event) => {
107
100
  const { promotionList } = event.data
108
101
  return {
@@ -161,20 +154,12 @@ export default function (request) {
161
154
  services: {
162
155
  fetchList: async (context, event) => {
163
156
  const hasToken = request.getToken()
164
- const siteConfig = window?.$nuxt?.$store?.state?.siteConfig
165
- const isProgressEnable = siteConfig?.frontendActivityProgressEnable
166
-
167
- const [{ data }, promotionList, progressSummaryRes] = await Promise.all([
157
+ const [{ data }, promotionList] = await Promise.all([
168
158
  hasToken ? request.send(activity.getActivityList({ appSecret })) : request.send(activity.getAllActivityList({ appSecret })),
169
159
  hasToken ? request.send(payment.getPromotionsList()) : [],
170
- hasToken && isProgressEnable ? request.send(activity.getProgressSummary({ appSecret })).catch(() => null) : null,
171
160
  ])
172
161
 
173
- return {
174
- activityList: data,
175
- promotionList,
176
- progressSummary: progressSummaryRes?.data || null,
177
- }
162
+ return { activityList: data, promotionList }
178
163
  },
179
164
  fetchActivityDetailList: async (context, event) => {
180
165
  await new Promise((resolve) => setTimeout(resolve, 1000)) // delay 1 second
@@ -7,7 +7,7 @@ import common from '../api/common.js'
7
7
  import pickBy from 'lodash/pickBy.js'
8
8
 
9
9
  export default function (request) {
10
- const { appSecret, clientId, sentry } = request.config
10
+ const { appSecret, clientId, sentry, defaultChannel, defaultSubchannel } = request.config
11
11
  const tokenKey = `cuora_${clientId}`
12
12
  const userKey = `cuora_tempuser`
13
13
  const phoneCountryCode = 'phone_countrycode'
@@ -464,7 +464,7 @@ export default function (request) {
464
464
  return { token }
465
465
  }),
466
466
  redirectTo3Party: async (context, event) => {
467
- const { provider, fc } = event.data
467
+ const { provider, channel, subchannel, fc } = event.data
468
468
  const deviceTokenEnable = context.siteConfig?.dtVerify
469
469
 
470
470
  const dt = deviceTokenEnable ? await request.config.getDt?.() : undefined
@@ -476,6 +476,11 @@ export default function (request) {
476
476
  const email = storage.get('tp_email')
477
477
  const messages = {
478
478
  url: window.location.href,
479
+ channelOrders: [
480
+ { channel: storage.get('channel'), subchannel: storage.get('subchannel') },
481
+ { channel: defaultChannel, subchannel: defaultSubchannel },
482
+ { channel: channel, subchannel: subchannel },
483
+ ],
479
484
  affiliateCode,
480
485
  nickname,
481
486
  }
@@ -503,6 +508,9 @@ export default function (request) {
503
508
  referralObj.email = email
504
509
  }
505
510
 
511
+ referralObj.channel = storage.get('channel') || defaultChannel || channel
512
+ referralObj.subchannel = storage.get('subchannel') || defaultSubchannel || subchannel
513
+
506
514
  storage.remove('tp_phone')
507
515
  storage.remove('tp_countryCode')
508
516
  storage.remove('tp_email')
@@ -5,7 +5,7 @@ import api from '../api/common.js'
5
5
  import storage from '../util/storage.js'
6
6
 
7
7
  export default function (request) {
8
- const { appSecret } = request.config
8
+ const { appSecret, defaultChannel, defaultSubchannel } = request.config
9
9
  return createMachine(
10
10
  {
11
11
  id: 'common',
@@ -35,6 +35,8 @@ export default function (request) {
35
35
  promotions: [],
36
36
  normalBroadcast: null,
37
37
  sentNormalBroadcastList: [],
38
+ channel: null,
39
+ subchannel: null,
38
40
  affiliateCode: null,
39
41
  defaultAffiliateCode: null,
40
42
  friendCode: null,
@@ -282,9 +284,19 @@ export default function (request) {
282
284
  return
283
285
  } else {
284
286
  let urlParams = new URLSearchParams(window.location.search)
287
+ const channel = urlParams.get('channel') || storage.get('channel') || defaultChannel || 'official'
288
+ const subchannel = urlParams.get('subchannel') || storage.get('subchannel') || defaultSubchannel || 'pwa'
285
289
  const affiliateCode = urlParams.get('ac') || urlParams.get('referralCode') || storage.get('ac') || storage.get('referralCode')
286
290
  const friendCode = urlParams.get('fc') || urlParams.get('affiliate') || storage.get('fc') || storage.get('affiliate')
287
291
 
292
+ storage.set('channel', channel, {
293
+ path: '/',
294
+ maxAge: 60 * 60 * 24 * 7,
295
+ })
296
+ storage.set('subchannel', subchannel, {
297
+ path: '/',
298
+ maxAge: 60 * 60 * 24 * 7,
299
+ })
288
300
  storage.set('ac', affiliateCode, {
289
301
  path: '/',
290
302
  maxAge: 60 * 60 * 24 * 7,
@@ -295,6 +307,8 @@ export default function (request) {
295
307
  })
296
308
 
297
309
  return {
310
+ channel,
311
+ subchannel,
298
312
  affiliateCode,
299
313
  friendCode,
300
314
  }
@@ -1,28 +1,19 @@
1
1
  import { createMachine, assign } from 'xstate'
2
2
  import ranking from '../api/ranking.js'
3
3
 
4
- const ROUND_LIMIT = { DAILY: 56, WEEKLY: 8, MONTHLY: 2, ALL: 2 }
5
- const ONE_DAY_MS = 24 * 60 * 60 * 1000
6
-
7
- // 後端每個 cycle 只回傳「當前回合」一筆,前台依當前回合往前回填歷史回合
8
- // 回合長度 = 當期長度(endDate - beginDate)+ 1 天,回合之間連續無間隔
9
- function expandPeriodOption(option, cycle) {
10
- if (!option) return []
11
- const { round, beginDate, endDate } = option
12
- // 回合長度取整到整數天,避免後端 endDate 帶當日 23:59:59 等時間造成歷史回合逐期偏移
13
- const step = Math.floor((endDate - beginDate) / ONE_DAY_MS + 1) * ONE_DAY_MS
14
- const count = Math.min(ROUND_LIMIT[cycle] || round, round)
15
- // 降冪排列,當前回合在最前
16
- return Array.from({ length: count }, (_, i) => ({
17
- round: round - i,
18
- beginDate: beginDate - i * step,
19
- endDate: endDate - i * step,
20
- }))
21
- }
22
-
23
4
  export default function (request) {
24
5
  const { appSecret } = request.config
25
6
  const cycleMapping = ['DAILY', 'WEEKLY', 'MONTHLY']
7
+ const limit = { DAILY: 56, WEEKLY: 8, MONTHLY: 2, ALL: 2 }
8
+
9
+ function roundProcess(rounds, cycles) {
10
+ const roundArrays = rounds.map((round) => Array.from({ length: round }, (_, i) => i + 1))
11
+ return roundArrays.reduce((acc, roundArray, index) => {
12
+ const max = limit[cycles[index]] || rounds[index] // 若沒限制則取全部
13
+ acc[cycles[index]] = roundArray.reverse().slice(0, max)
14
+ return acc
15
+ }, {})
16
+ }
26
17
 
27
18
  function transGameData(item) {
28
19
  if (!item) return {}
@@ -39,6 +30,7 @@ export default function (request) {
39
30
  site: '',
40
31
  activityNo: '',
41
32
  // api options 回傳的資料
33
+ currentRound: [],
42
34
  cycle: '',
43
35
  round: 0,
44
36
  rule: '',
@@ -50,7 +42,7 @@ export default function (request) {
50
42
  gameRanking: [],
51
43
  topRanking: [],
52
44
  settleStatus: false,
53
- // 前端這邊用的選單資料 { cycle: [string], round: { [cycle]: [{ round, beginDate, endDate }] } }
45
+ // 前端這邊用的選單資料 { cycle, round }
54
46
  options: {},
55
47
  },
56
48
  states: {
@@ -164,41 +156,31 @@ export default function (request) {
164
156
  setRankingOptions: assign((context, event) => {
165
157
  const isChampion = event.data?.rule === 'CHAMPION'
166
158
  const cycle = event.data?.cycle
167
- const periodOptions = event.data?.periodOptions || []
168
- // 每個 cycle 對應一筆「當前回合」
169
- const optionByCycle = periodOptions.reduce((acc, option) => {
170
- acc[option.cycle] = option
171
- return acc
172
- }, {})
173
- // 依照 cycleMapping 順序取出有資料的 cycle
174
- const cycleOptions = isChampion ? cycleMapping.filter((c) => optionByCycle[c]) : [cycle]
175
- // 將每個 cycle 的當前回合往前回填為完整回合列表 { [cycle]: [{ round, beginDate, endDate }] }
176
- const roundOptions = cycleOptions.reduce((acc, c) => {
177
- acc[c] = expandPeriodOption(optionByCycle[c], c)
178
- return acc
179
- }, {})
159
+ const currentRound = event.data?.currentRound || []
160
+ // 取得結算週期選單列表
161
+ const cycleOptions = isChampion ? cycleMapping.slice(0, currentRound.length) : [cycle]
162
+ const roundOptions = roundProcess(currentRound, cycleOptions)
180
163
  // 如果是冠軍龍虎月結算,則加入全部選項
181
164
  if (cycle === 'MONTHLY' && isChampion) {
182
165
  cycleOptions.push('ALL')
183
- roundOptions.ALL = expandPeriodOption(optionByCycle.MONTHLY, 'ALL')
166
+ roundOptions.ALL = roundOptions.MONTHLY
184
167
  }
185
- // 初始 cycle 與 round
186
- const initialCycle = isChampion ? 'DAILY' : cycle
187
- const initialRound = roundOptions[initialCycle]?.[0]?.round
188
168
  return {
189
169
  ...event.data,
190
170
  options: { cycle: cycleOptions, round: roundOptions },
191
- cycle: initialCycle,
192
- round: initialRound,
171
+ // 初始固定顯示 DAILY
172
+ cycle: isChampion ? 'DAILY' : cycle,
173
+ round: currentRound[0],
193
174
  }
194
175
  }),
195
176
  setOptions: assign((context, event) => {
196
- const { cycle, round, options } = context
177
+ const { cycle, round } = context
197
178
  // 處理變更 cycle,如果沒有輸入或沒有變更就不更新
198
179
  if (event.data?.cycle && cycle !== event.data?.cycle) {
199
- const newCycle = event.data?.cycle
200
- const newRound = options?.round?.[newCycle]?.[0]?.round
201
- return { cycle: newCycle, round: newRound }
180
+ const { currentRound } = context
181
+ const cycleForRound = event.data?.cycle === 'ALL' ? 'MONTHLY' : event.data?.cycle
182
+ const cycleIndex = cycleMapping.indexOf(cycleForRound)
183
+ return { cycle: event.data?.cycle, round: currentRound[cycleIndex] }
202
184
  }
203
185
  if (event.data?.round && round !== event.data?.round) {
204
186
  return { round: event.data?.round }
@@ -3,13 +3,15 @@ import auth from '../api/auth.js'
3
3
  import storage from '../util/storage.js'
4
4
 
5
5
  export default function (request) {
6
- const { sentry } = request.config
6
+ const { sentry, defaultChannel, defaultSubchannel } = request.config
7
7
  return createMachine(
8
8
  {
9
9
  id: 'user_sign_up',
10
10
  initial: 'idle',
11
11
  context: {
12
12
  provider: null,
13
+ channel: null,
14
+ subchannel: null,
13
15
  signUpData: {},
14
16
  fc: null,
15
17
  reCaptchaToken: null,
@@ -72,8 +74,22 @@ export default function (request) {
72
74
  return { fc }
73
75
  }),
74
76
  setSignUpId: assign((context, event) => {
75
- const { email, username, nick_name, password, countryCode, phone, bankCode, bankAccount, holderName, branch, branchCode, affiliateCode } =
76
- event.data
77
+ const {
78
+ email,
79
+ username,
80
+ nick_name,
81
+ password,
82
+ countryCode,
83
+ phone,
84
+ channel,
85
+ subchannel,
86
+ bankCode,
87
+ bankAccount,
88
+ holderName,
89
+ branch,
90
+ branchCode,
91
+ affiliateCode,
92
+ } = event.data
77
93
  return {
78
94
  signUpData: {
79
95
  provider: 'local',
@@ -90,10 +106,26 @@ export default function (request) {
90
106
  branchCode,
91
107
  affiliateCode,
92
108
  },
109
+ channel,
110
+ subchannel,
93
111
  }
94
112
  }),
95
113
  setSignUpPhone: assign((context, event) => {
96
- const { email, countryCode, phone, nick_name, password, bankCode, bankAccount, holderName, branch, branchCode, affiliateCode } = event.data
114
+ const {
115
+ email,
116
+ countryCode,
117
+ phone,
118
+ nick_name,
119
+ password,
120
+ channel,
121
+ subchannel,
122
+ bankCode,
123
+ bankAccount,
124
+ holderName,
125
+ branch,
126
+ branchCode,
127
+ affiliateCode,
128
+ } = event.data
97
129
  return {
98
130
  signUpData: {
99
131
  provider: 'phone',
@@ -109,10 +141,26 @@ export default function (request) {
109
141
  branchCode,
110
142
  affiliateCode,
111
143
  },
144
+ channel,
145
+ subchannel,
112
146
  }
113
147
  }),
114
148
  setSignUpEmail: assign((context, event) => {
115
- const { email, nick_name, password, bankCode, bankAccount, holderName, branch, branchCode, affiliateCode, countryCode, phone } = event.data
149
+ const {
150
+ email,
151
+ nick_name,
152
+ password,
153
+ channel,
154
+ subchannel,
155
+ bankCode,
156
+ bankAccount,
157
+ holderName,
158
+ branch,
159
+ branchCode,
160
+ affiliateCode,
161
+ countryCode,
162
+ phone,
163
+ } = event.data
116
164
  return {
117
165
  signUpData: {
118
166
  provider: 'email',
@@ -128,10 +176,12 @@ export default function (request) {
128
176
  countryCode,
129
177
  phone,
130
178
  },
179
+ channel,
180
+ subchannel,
131
181
  }
132
182
  }),
133
183
  setRegistrationData: assign((context, event) => {
134
- const { account, currency, site, strategy, uid } = event.data
184
+ const { account, currency, site, strategy, uid, channel, sub_channel } = event.data
135
185
  return {
136
186
  registrationData: {
137
187
  account,
@@ -139,6 +189,8 @@ export default function (request) {
139
189
  site,
140
190
  strategy,
141
191
  uid,
192
+ channel,
193
+ sub_channel,
142
194
  },
143
195
  }
144
196
  }),
@@ -150,12 +202,17 @@ export default function (request) {
150
202
  },
151
203
  services: {
152
204
  authenticate: async (context, event) => {
153
- const { signUpData, deviceTokenEnable } = context
205
+ const { channel, subchannel, signUpData, deviceTokenEnable } = context
154
206
  const dt = deviceTokenEnable ? await request.config.getDt?.() : undefined
155
207
 
156
208
  const affiliateCode = storage.get('ac') || signUpData?.affiliateCode
157
209
  const messages = {
158
210
  url: window.location.href,
211
+ channelOrders: [
212
+ { channel: storage.get('channel'), subchannel: storage.get('subchannel') },
213
+ { channel: defaultChannel, subchannel: defaultSubchannel },
214
+ { channel: channel, subchannel: subchannel },
215
+ ],
159
216
  affiliateCode,
160
217
  }
161
218
 
@@ -168,6 +225,9 @@ export default function (request) {
168
225
  referralObj.ac = affiliateCode
169
226
  }
170
227
 
228
+ referralObj.channel = storage.get('channel') || defaultChannel || channel
229
+ referralObj.subchannel = storage.get('subchannel') || defaultSubchannel || subchannel
230
+
171
231
  return await request.send(
172
232
  auth.register({
173
233
  ...signUpData,