@jetthai/cuora 1.1.413-dev-11 → 1.1.413

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,6 +1,7 @@
1
1
  import { assign, createMachine } from 'xstate'
2
2
  import findLastIndex from 'lodash/findLastIndex.js'
3
3
  import payment from '../../api/payment.js'
4
+ import user from '../../api/user.js'
4
5
 
5
6
  export default function (request) {
6
7
  const { appSecret } = request.config
@@ -35,8 +36,8 @@ export default function (request) {
35
36
 
36
37
  // otp
37
38
  requestId: null,
38
- number: null,
39
- email: null,
39
+ status: null,
40
+ target: null,
40
41
  ttl: null,
41
42
  },
42
43
  states: {
@@ -355,27 +356,26 @@ export default function (request) {
355
356
  return { paymentDetail }
356
357
  }),
357
358
  setOtp: assign((context, event) => {
358
- const { request_id, number, email, ttl } = event.data
359
+ const { requestId, status, target, ttl } = event.data
359
360
  return {
360
- requestId: request_id,
361
- number,
362
- email,
361
+ requestId,
362
+ status,
363
+ target,
363
364
  ttl,
364
365
  }
365
366
  }),
366
367
  decreaseTtl: assign((context, evnet) => {
367
368
  const second = context.ttl
368
369
  return {
369
- ttl: Math.max(second - 1000, 0),
370
+ ttl: Math.max(second - 1, 0),
370
371
  }
371
372
  }),
372
373
  setVerificationData: assign((context, event) => {
373
- const { request_id, number, email, ttl } = event.data
374
+ const { requestId, ttl, target } = event.data
374
375
  return {
375
- requestId: request_id,
376
- number,
377
- email,
376
+ requestId,
378
377
  ttl,
378
+ target,
379
379
  }
380
380
  }),
381
381
  setAttachmentType: assign((context, event) => {
@@ -439,8 +439,7 @@ export default function (request) {
439
439
  return !enableWithdraw || balance < minWithdrawAmount
440
440
  },
441
441
  isOtpRequired: (context, event) => {
442
- const { request_id, number, email } = event.data || {}
443
- return request_id !== undefined && (number || email)
442
+ return event.data?.status === 'otp-verifying'
444
443
  },
445
444
  isNotWithdrawMinDepositAmount: (context, event) => {
446
445
  const { withdrawCheck } = context
@@ -510,15 +509,13 @@ export default function (request) {
510
509
  return await request.send(payment.convertFreeCredit({ exchangeType: 1 }))
511
510
  },
512
511
  resetOtp: async (context, event) => {
513
- const { requestId } = context
514
- const { method } = context.paymentDetail[0]
515
- return await request.send(payment.otpReset({ method: method, requestId }))
512
+ const { requestId, target } = context
513
+ return await request.send(user.otpReset({ requestId, target }))
516
514
  },
517
515
  acknowledge: async (context, event) => {
518
- const { requestId } = context
519
- const { method } = context.paymentDetail[0]
516
+ const { requestId, target } = context
520
517
  const code = event.data
521
- return await request.send(payment.otpAcknowledge({ method: method, requestId, code }))
518
+ return await request.send(user.otpAcknowledge({ requestId, target, code }))
522
519
  },
523
520
  pool: async (context, event) => {
524
521
  const { amount } = context
@@ -23,8 +23,6 @@ export default function (request, context) {
23
23
  requestId: null,
24
24
  status: null,
25
25
  target: null,
26
- email: null,
27
- number: null,
28
26
  ttl: null,
29
27
  },
30
28
  states: {
@@ -119,18 +117,29 @@ export default function (request, context) {
119
117
  RESET_OTP: {
120
118
  target: 'reset',
121
119
  },
122
- BACK: {
123
- target: '#withdraw_manual_cash.calculated',
124
- },
120
+ BACK: [
121
+ // {
122
+ // target: '#withdraw_vn2.activity.convertible',
123
+ // cond: 'isActivity',
124
+ // },
125
+ // {
126
+ // target: '#withdraw_vn2.cash.withdrawable',
127
+ // },
128
+ ],
125
129
  },
126
130
  },
127
131
  acknowledging: {
128
132
  invoke: {
129
133
  src: 'acknowledge',
130
- onDone: {
131
- target: '#withdraw_manual_cash.submitted',
132
- actions: 'setProcessing',
133
- },
134
+ onDone: [
135
+ // {
136
+ // target: '#withdraw_vn2.activity.converted',
137
+ // cond: 'isActivity',
138
+ // },
139
+ // {
140
+ // target: '#withdraw_vn2.cash.submitted',
141
+ // },
142
+ ],
134
143
  onError: {
135
144
  target: 'idle',
136
145
  },
@@ -167,7 +176,7 @@ export default function (request, context) {
167
176
  actions: {
168
177
  setInitData: assign((context, event) => {
169
178
  const { currentPayment, paymentInfo, withdrawRule, processing } = event.data
170
- const userBanks = [...paymentInfo.bankList, ...paymentInfo.ewalletList, ...paymentInfo.cryptoList]
179
+ const userBanks = [...paymentInfo.bankList, ...paymentInfo.cryptoList, ...paymentInfo.ewalletList]
171
180
 
172
181
  return {
173
182
  currentPayment,
@@ -194,27 +203,26 @@ export default function (request, context) {
194
203
  }
195
204
  }),
196
205
  setOtp: assign((context, event) => {
197
- const { request_id, email, number, ttl } = event.data
206
+ const { requestId, status, target, ttl } = event.data
198
207
  return {
199
- requestId: request_id,
200
- email,
201
- number,
208
+ requestId,
209
+ status,
210
+ target,
202
211
  ttl,
203
212
  }
204
213
  }),
205
214
  decreaseTtl: assign((context, evnet) => {
206
215
  const second = context.ttl
207
216
  return {
208
- ttl: Math.max(second - 1000, 0),
217
+ ttl: Math.max(second - 1, 0),
209
218
  }
210
219
  }),
211
220
  setVerificationData: assign((context, event) => {
212
- const { request_id, ttl, number, email } = event.data
221
+ const { requestId, ttl, target } = event.data
213
222
  return {
214
- requestId: request_id,
223
+ requestId,
215
224
  ttl,
216
- number,
217
- email,
225
+ target,
218
226
  }
219
227
  }),
220
228
  },
@@ -230,7 +238,7 @@ export default function (request, context) {
230
238
  return selectedUserBank && selectedAmount > 0 && currentPayment.minimum <= selectedAmount && selectedAmount <= currentPayment.maximum
231
239
  },
232
240
  isOtpRequired: (context, event) => {
233
- return event.data?.request_id !== undefined
241
+ return event.data?.status === 'otp-verifying'
234
242
  },
235
243
  },
236
244
  services: {
@@ -274,20 +282,20 @@ export default function (request, context) {
274
282
  method: currentPayment.method,
275
283
  amount: selectedAmount,
276
284
  cryptoCurrency: selectedUserBank.cryptoCurrency,
277
- cryptoNetwork: selectedUserBank.networkCode,
285
+ cryptoNetwork: selectedUserBank.cryptoNetwork,
278
286
  targetAddress: selectedUserBank.cryptoAddress,
279
287
  applyerHolderName: selectedUserBank.holderName,
280
288
  })
281
289
  )
282
290
  },
283
291
  resetOtp: async (context, event) => {
284
- const { currentPayment, requestId } = context
285
- return await request.send(payment.otpReset({ method: currentPayment.method, requestId }))
292
+ const { requestId, target } = context
293
+ return await request.send(user.otpReset({ requestId, target }))
286
294
  },
287
295
  acknowledge: async (context, event) => {
288
- const { currentPayment, requestId } = context
296
+ const { requestId, target } = context
289
297
  const code = event.data
290
- return await request.send(payment.otpAcknowledge({ method: currentPayment.method, requestId, code }))
298
+ return await request.send(user.otpAcknowledge({ requestId, target, code }))
291
299
  },
292
300
  },
293
301
  }
@@ -321,7 +321,6 @@ export default class Request {
321
321
 
322
322
  // 調整API路徑與名稱
323
323
  _convertUrlToKebabCase(url) {
324
- const [path, queryString] = url.split('?')
325
324
  const specifyingPath = {
326
325
  'all-activities/list': 'activities/all-activities-list',
327
326
  friends: 'activities/friends',
@@ -343,9 +342,13 @@ export default class Request {
343
342
  'activities/exchange/diamond/max-amount': 'activities/diamond/exchange/max-amount',
344
343
  'activities/exchange/diamond/settle': 'activities/diamond/exchange/settle',
345
344
  }
346
- // 和原有路徑不同有另外改路徑
347
- const convertedPath = specifyingPath[path] ? specifyingPath[path] : path.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase()
348
- return queryString ? `${convertedPath}?${queryString}` : convertedPath
345
+ if (specifyingPath[url]) {
346
+ // 和原有路徑不同有另外改路徑
347
+ return specifyingPath[url]
348
+ } else {
349
+ // 將API_URL的命名規則由駝峰調整為短橫線(-)
350
+ return url.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase()
351
+ }
349
352
  }
350
353
 
351
354
  _checkToken(req) {
@@ -1,95 +0,0 @@
1
- # Auto Git Flow
2
-
3
- 請依序執行每個步驟進行完整的分支重建和清理流程,每步執行前先告知使用者當前進度。
4
-
5
- ---
6
-
7
- ## Phase 1: 分支重建
8
-
9
- ### Step 1 — 同步 master
10
-
11
- ```bash
12
- git fetch origin --prune
13
- git checkout master && git pull origin master
14
- ```
15
-
16
- ### Step 2 — 重建 dev
17
-
18
- 刪除本地與遠端 dev,從 master 重新建立並強制推送。
19
-
20
- ```bash
21
- git checkout master
22
- git branch -D dev 2>/dev/null || true
23
- git push origin --delete dev 2>/dev/null || true
24
- git checkout -b dev
25
- git push origin dev --force
26
- ```
27
-
28
- ### Step 3 — 重建 qa
29
-
30
- 刪除本地與遠端 qa,從 master 重新建立並強制推送。
31
-
32
- ```bash
33
- git checkout master
34
- git branch -D qa 2>/dev/null || true
35
- git push origin --delete qa 2>/dev/null || true
36
- git checkout -b qa
37
- git push origin qa --force
38
- ```
39
-
40
- ---
41
-
42
- ## Phase 2: 清理
43
-
44
- ### Step 5 — 刪除已合併到 master 的分支
45
-
46
- ```bash
47
- git checkout master
48
- git fetch --prune
49
- ```
50
-
51
- 刪除已合併的 remote 分支(排除 master/qa/dev/HEAD):
52
-
53
- ```bash
54
- git branch -r --merged master | grep -v -E "(master|qa|dev|HEAD)" | sed 's/origin\///' | xargs -r -I {} git push origin --delete {}
55
- ```
56
-
57
- 刪除已合併的 local 分支(排除 master/qa/dev):
58
-
59
- ```bash
60
- git branch --merged master | grep -v -E "^\*?\s*(master|qa|dev)$" | xargs -r git branch -d
61
- ```
62
-
63
- ### Step 6 — 刪除不合規 tags
64
-
65
- 刪除不符合 `v[數字].[數字].[數字]` 格式的 tags(local + remote):
66
-
67
- ```bash
68
- PATTERN="^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$"
69
- for tag in $(git tag -l); do
70
- if [[ ! $tag =~ $PATTERN ]]; then
71
- echo "刪除不合規 tag: $tag"
72
- git push origin --delete "$tag" 2>/dev/null || true
73
- git tag -d "$tag" 2>/dev/null || true
74
- fi
75
- done
76
- ```
77
-
78
- ---
79
-
80
- ## Phase 3: 完成
81
-
82
- ### Step 7 — 回報結果
83
-
84
- 切回 master 分支,顯示完成摘要:
85
-
86
- ```bash
87
- git checkout master
88
- ```
89
-
90
- 回報以下資訊:
91
-
92
- - dev、qa 分支是否都成功重建
93
- - 刪除了多少已合併分支
94
- - 刪除了多少不合規 tags
95
- - 當前所在分支
@@ -1,93 +0,0 @@
1
- # Sync AI Prompts
2
-
3
- 將 `AI_PROMPT_SOURCE.md` 的內容同步到各 AI 工具的指令檔。
4
-
5
- ⚠️ 只修改 `AI_PROMPT_SOURCE.md` 作為唯一來源,其他檔案皆由此指令自動生成。
6
-
7
- ---
8
-
9
- ## Step 1 — 讀取來源檔
10
-
11
- 讀取 `AI_PROMPT_SOURCE.md` 完整內容。
12
-
13
- ---
14
-
15
- ## Step 2 — 同步 CLAUDE.md
16
-
17
- 將 `AI_PROMPT_SOURCE.md` 的內容**翻譯成英文**,並轉換為 CLAUDE.md 格式:
18
-
19
- **翻譯規則**:同 Step 3。
20
-
21
- **格式調整**:
22
-
23
- - 第一行標題改為 `# CLAUDE.md`
24
- - 第二行加上 `<!-- AUTO-SYNCED FROM AI_PROMPT_SOURCE.md — DO NOT EDIT DIRECTLY -->`
25
- - 描述行改為:`This file provides guidance for Claude Code (claude.ai/code) when working in this project.`
26
- - 其餘結構不變
27
-
28
- 寫入 `CLAUDE.md`。
29
-
30
- ---
31
-
32
- ## Step 3 — 同步 AGENTS.md(OpenAI Codex / Cursor / Windsurf)
33
-
34
- 將 `AI_PROMPT_SOURCE.md` 的內容**翻譯成英文**,並轉換為 AGENTS.md 格式:
35
-
36
- **翻譯規則**:
37
-
38
- - 所有繁體中文文字翻譯成英文
39
- - 程式碼區塊中的**註解**翻譯成英文,**程式碼本身不動**
40
- - 檔案路徑、變數名、函式名等技術名詞保持不變
41
- - Markdown 結構(標題層級、列表、表格)保持不變
42
-
43
- **格式調整**:
44
-
45
- - 第一行標題改為 `# AGENTS.md`
46
- - 第二行加上 `<!-- AUTO-SYNCED FROM AI_PROMPT_SOURCE.md — DO NOT EDIT DIRECTLY -->`
47
- - 描述行改為:`This file provides guidance for AI coding agents when working on this project.`
48
- - 其餘結構不變
49
-
50
- 寫入 `AGENTS.md`。
51
-
52
- ---
53
-
54
- ## Step 4 — 同步 GEMINI.md(Gemini CLI)
55
-
56
- 將 `AI_PROMPT_SOURCE.md` 的內容**翻譯成英文**,並轉換為 GEMINI.md 格式:
57
-
58
- **翻譯規則**:同 Step 3。
59
-
60
- **格式調整**:
61
-
62
- - 第一行標題改為 `# GEMINI.md`
63
- - 第二行加上 `<!-- AUTO-SYNCED FROM AI_PROMPT_SOURCE.md — DO NOT EDIT DIRECTLY -->`
64
- - 描述行改為:`This file provides guidance for Gemini CLI when working on this project.`
65
- - 其餘結構不變
66
-
67
- 寫入 `GEMINI.md`。
68
-
69
- ---
70
-
71
- ## Step 5 — 同步 .github/copilot-instructions.md(GitHub Copilot)
72
-
73
- 將 `AI_PROMPT_SOURCE.md` 的內容**翻譯成英文**,並轉換為 copilot-instructions.md 格式:
74
-
75
- **翻譯規則**:同 Step 3。
76
-
77
- **格式調整**:
78
-
79
- - 第一行標題改為 `# Copilot Instructions`
80
- - 第二行加上 `<!-- AUTO-SYNCED FROM AI_PROMPT_SOURCE.md — DO NOT EDIT DIRECTLY -->`
81
- - 描述行改為:`This file provides guidance for GitHub Copilot when working on this project.`
82
- - 其餘結構不變
83
-
84
- 寫入 `.github/copilot-instructions.md`。
85
-
86
- ---
87
-
88
- ## Step 6 — 回報結果
89
-
90
- 顯示完成摘要:
91
-
92
- - 列出已同步的檔案及各自的行數/大小
93
- - 提醒使用者需要 commit 這些變更