@jetthai/cuora 1.1.473 → 1.1.474
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/.github/copilot-instructions.md +4 -2
- package/AGENTS.md +4 -2
- package/AI_PROMPT_SOURCE.md +4 -2
- package/CHANGELOG.md +2 -0
- package/CLAUDE.md +4 -2
- package/GEMINI.md +4 -2
- package/package.json +1 -1
- package/src/machine/activity/activity_cash.js +22 -14
|
@@ -53,7 +53,7 @@ You are a senior full-stack engineer with world-class capability across UI/UX, A
|
|
|
53
53
|
Before delivering any code change, verify each of the following yourself:
|
|
54
54
|
|
|
55
55
|
- [ ] **Follows existing conventions**: clear four-layer separation, XState v4 factory pattern (`export default function (request) { return createMachine(...) }`), naming conventions, no TypeScript
|
|
56
|
-
- [ ] **Correct API descriptor object**: returns the `{ url, method, params?, isPublic?, headers?, isFormData? }` structure; HTTP method consistently lowercase; `isPublic: true` endpoints checked for whether they need `appSecret`; URLs carry no leading slash (unless deliberately bypassing `url-join`'s `baseURL`, in which case comment the reason)
|
|
56
|
+
- [ ] **Correct API descriptor object**: returns the `{ url, method, params?, isPublic?, headers?, isFormData?, silent? }` structure; HTTP method consistently lowercase; `isPublic: true` endpoints checked for whether they need `appSecret`; URLs carry no leading slash (unless deliberately bypassing `url-join`'s `baseURL`, in which case comment the reason)
|
|
57
57
|
- [ ] **V1→V2 path conversion**: new V2 endpoints must be added to `supportVersion2List` **manually**; use the `:param` form for dynamic parameters; put non-standard paths in the `specifyingPath` mapping
|
|
58
58
|
- [ ] **State machine conventions**: always modify context via `assign()`, never mutate directly; clone deep objects with `JSON.parse(JSON.stringify())`; choose the initial state name by semantics; don't let `onError` silently fall back to `idle` and lose the error information
|
|
59
59
|
- [ ] **Memory safety**: `setInterval` / `socket.on()` / `addEventListener` registered inside an XState callback service **must return a cleanup function** (e.g. `() => clientSocket.off(event, handler)`) to avoid accumulating listeners across reconnects; listeners registered inside a Promise must also be cleaned up after resolve / reject
|
|
@@ -111,6 +111,7 @@ state machine service → request.send(api.xxx(params)) → Request class → AP
|
|
|
111
111
|
isPublic?: boolean, // true = no auth token required
|
|
112
112
|
headers?: object, // Custom headers (e.g. reCAPTCHA)
|
|
113
113
|
isFormData?: boolean, // true = multipart/form-data
|
|
114
|
+
silent?: boolean, // true = on failure, don't forward to errorHandler (still throws)
|
|
114
115
|
}
|
|
115
116
|
```
|
|
116
117
|
|
|
@@ -328,7 +329,7 @@ io(`${socketURL}/frontend`, {
|
|
|
328
329
|
7. Custom paramsSerializer: special encoding for the q parameter (avoids double-encoding)
|
|
329
330
|
8. axios.request(config)
|
|
330
331
|
9. Response interceptor: response.data.error present → reject; Network Error / 404 → ERR_998 + Sentry
|
|
331
|
-
10. Error handling: ERR_F108 → isBlocked; ERR_800 (cancelled) → silent; everything else → errorHandler
|
|
332
|
+
10. Error handling: ERR_F108 → isBlocked + errorHandler; ERR_998 → thrown directly; ERR_800 (cancelled) → silent; everything else → errorHandler (skipped when the descriptor carries silent: true, still thrown)
|
|
332
333
|
```
|
|
333
334
|
|
|
334
335
|
**V1→V2 conversion**: `supportVersion2List` supports dynamic paths (e.g. `payment/v2/:paymentType/transaction`, where `:param` is replaced by `[^/]+`); special paths are hard-coded in `specifyingPath`, and the rest are auto-converted via `/([a-z])([A-Z])/g`. **When adding an endpoint that needs V2 conversion, it must be added to the list manually.**
|
|
@@ -346,6 +347,7 @@ io(`${socketURL}/frontend`, {
|
|
|
346
347
|
9. **Unfinished-game infinite retry**: the `unfinishedGame` state in `error.js` returns to itself on `onError`, with **no backoff strategy and no retry cap** (a known issue, see "Known Technical Debt").
|
|
347
348
|
10. **`isMobile` is a string, not a boolean**: in `common.js`, `isMobile = userAgent?.device?.type` returns `'mobile'`/`'tablet'`/`undefined`, so comparisons must be string-based (e.g. `isMobile === 'mobile' ? 'y' : null`).
|
|
348
349
|
11. **Requests carry no CancelToken by default**: the cancellation feature of `send(req, customToken)` is **opt-in**. In axios <0.22 the cancel handler is never unsubscribed — a shared long-lived token accumulates one handler per request, causing overnight OOM when left running (TI-15555). **Do not "helpfully" add the CancelToken back onto the shared path.**
|
|
350
|
+
12. **`silent: true` only skips errorHandler**: the error is still thrown to the caller's `onError`, and `ERR_F108` is still routed as usual; but every other error code — **including logout-class codes such as `ERR_A104`, and `ERR_G106` insufficient balance** — never reaches the error machine. Use it only for background requests whose session invalidation is already covered by `fetchUserInfo` polling; never add it to user-initiated requests.
|
|
349
351
|
|
|
350
352
|
---
|
|
351
353
|
|
package/AGENTS.md
CHANGED
|
@@ -53,7 +53,7 @@ You are a senior full-stack engineer with world-class capability across UI/UX, A
|
|
|
53
53
|
Before delivering any code change, verify each of the following yourself:
|
|
54
54
|
|
|
55
55
|
- [ ] **Follows existing conventions**: clear four-layer separation, XState v4 factory pattern (`export default function (request) { return createMachine(...) }`), naming conventions, no TypeScript
|
|
56
|
-
- [ ] **Correct API descriptor object**: returns the `{ url, method, params?, isPublic?, headers?, isFormData? }` structure; HTTP method consistently lowercase; `isPublic: true` endpoints checked for whether they need `appSecret`; URLs carry no leading slash (unless deliberately bypassing `url-join`'s `baseURL`, in which case comment the reason)
|
|
56
|
+
- [ ] **Correct API descriptor object**: returns the `{ url, method, params?, isPublic?, headers?, isFormData?, silent? }` structure; HTTP method consistently lowercase; `isPublic: true` endpoints checked for whether they need `appSecret`; URLs carry no leading slash (unless deliberately bypassing `url-join`'s `baseURL`, in which case comment the reason)
|
|
57
57
|
- [ ] **V1→V2 path conversion**: new V2 endpoints must be added to `supportVersion2List` **manually**; use the `:param` form for dynamic parameters; put non-standard paths in the `specifyingPath` mapping
|
|
58
58
|
- [ ] **State machine conventions**: always modify context via `assign()`, never mutate directly; clone deep objects with `JSON.parse(JSON.stringify())`; choose the initial state name by semantics; don't let `onError` silently fall back to `idle` and lose the error information
|
|
59
59
|
- [ ] **Memory safety**: `setInterval` / `socket.on()` / `addEventListener` registered inside an XState callback service **must return a cleanup function** (e.g. `() => clientSocket.off(event, handler)`) to avoid accumulating listeners across reconnects; listeners registered inside a Promise must also be cleaned up after resolve / reject
|
|
@@ -111,6 +111,7 @@ state machine service → request.send(api.xxx(params)) → Request class → AP
|
|
|
111
111
|
isPublic?: boolean, // true = no auth token required
|
|
112
112
|
headers?: object, // Custom headers (e.g. reCAPTCHA)
|
|
113
113
|
isFormData?: boolean, // true = multipart/form-data
|
|
114
|
+
silent?: boolean, // true = on failure, don't forward to errorHandler (still throws)
|
|
114
115
|
}
|
|
115
116
|
```
|
|
116
117
|
|
|
@@ -328,7 +329,7 @@ io(`${socketURL}/frontend`, {
|
|
|
328
329
|
7. Custom paramsSerializer: special encoding for the q parameter (avoids double-encoding)
|
|
329
330
|
8. axios.request(config)
|
|
330
331
|
9. Response interceptor: response.data.error present → reject; Network Error / 404 → ERR_998 + Sentry
|
|
331
|
-
10. Error handling: ERR_F108 → isBlocked; ERR_800 (cancelled) → silent; everything else → errorHandler
|
|
332
|
+
10. Error handling: ERR_F108 → isBlocked + errorHandler; ERR_998 → thrown directly; ERR_800 (cancelled) → silent; everything else → errorHandler (skipped when the descriptor carries silent: true, still thrown)
|
|
332
333
|
```
|
|
333
334
|
|
|
334
335
|
**V1→V2 conversion**: `supportVersion2List` supports dynamic paths (e.g. `payment/v2/:paymentType/transaction`, where `:param` is replaced by `[^/]+`); special paths are hard-coded in `specifyingPath`, and the rest are auto-converted via `/([a-z])([A-Z])/g`. **When adding an endpoint that needs V2 conversion, it must be added to the list manually.**
|
|
@@ -346,6 +347,7 @@ io(`${socketURL}/frontend`, {
|
|
|
346
347
|
9. **Unfinished-game infinite retry**: the `unfinishedGame` state in `error.js` returns to itself on `onError`, with **no backoff strategy and no retry cap** (a known issue, see "Known Technical Debt").
|
|
347
348
|
10. **`isMobile` is a string, not a boolean**: in `common.js`, `isMobile = userAgent?.device?.type` returns `'mobile'`/`'tablet'`/`undefined`, so comparisons must be string-based (e.g. `isMobile === 'mobile' ? 'y' : null`).
|
|
348
349
|
11. **Requests carry no CancelToken by default**: the cancellation feature of `send(req, customToken)` is **opt-in**. In axios <0.22 the cancel handler is never unsubscribed — a shared long-lived token accumulates one handler per request, causing overnight OOM when left running (TI-15555). **Do not "helpfully" add the CancelToken back onto the shared path.**
|
|
350
|
+
12. **`silent: true` only skips errorHandler**: the error is still thrown to the caller's `onError`, and `ERR_F108` is still routed as usual; but every other error code — **including logout-class codes such as `ERR_A104`, and `ERR_G106` insufficient balance** — never reaches the error machine. Use it only for background requests whose session invalidation is already covered by `fetchUserInfo` polling; never add it to user-initiated requests.
|
|
349
351
|
|
|
350
352
|
---
|
|
351
353
|
|
package/AI_PROMPT_SOURCE.md
CHANGED
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
每次交付程式碼異動前,請自行逐項確認:
|
|
52
52
|
|
|
53
53
|
- [ ] **符合現有規範**:四層架構分層清楚、XState v4 工廠模式(`export default function (request) { return createMachine(...) }`)、命名慣例、無 TypeScript
|
|
54
|
-
- [ ] **API 描述物件正確**:回傳 `{ url, method, params?, isPublic?, headers?, isFormData? }` 結構;HTTP method 統一小寫;`isPublic: true` 端點需檢查是否需 `appSecret`;URL 不加前導斜線(除非刻意繞過 `url-join` 的 `baseURL`,且需註解原因)
|
|
54
|
+
- [ ] **API 描述物件正確**:回傳 `{ url, method, params?, isPublic?, headers?, isFormData?, silent? }` 結構;HTTP method 統一小寫;`isPublic: true` 端點需檢查是否需 `appSecret`;URL 不加前導斜線(除非刻意繞過 `url-join` 的 `baseURL`,且需註解原因)
|
|
55
55
|
- [ ] **V1→V2 路徑轉換**:新增 V2 端點需**手動**加入 `supportVersion2List`;含動態參數時用 `:param` 樣式;非標準路徑放 `specifyingPath` 映射表
|
|
56
56
|
- [ ] **狀態機規範**:context 修改一律用 `assign()` 不直接 mutate;深層物件用 `JSON.parse(JSON.stringify())` clone;初始狀態名稱依語意選用;`onError` 不要靜默轉 `idle` 而遺失錯誤資訊
|
|
57
57
|
- [ ] **記憶體安全**:XState callback service 註冊的 `setInterval` / `socket.on()` / `addEventListener` 等,**必須回傳清理函式**(如 `() => clientSocket.off(event, handler)`),避免重連時累積監聽器;Promise 內註冊的監聽器在 resolve / reject 後也要清理
|
|
@@ -109,6 +109,7 @@
|
|
|
109
109
|
isPublic?: boolean, // true = 不需認證 Token
|
|
110
110
|
headers?: object, // 自訂 headers(如 reCAPTCHA)
|
|
111
111
|
isFormData?: boolean, // true = multipart/form-data
|
|
112
|
+
silent?: boolean, // true = 失敗時不轉發 errorHandler(仍會 throw)
|
|
112
113
|
}
|
|
113
114
|
```
|
|
114
115
|
|
|
@@ -326,7 +327,7 @@ io(`${socketURL}/frontend`, {
|
|
|
326
327
|
7. 自訂 paramsSerializer:q 參數特殊編碼(避免雙重編碼)
|
|
327
328
|
8. axios.request(config)
|
|
328
329
|
9. 回應攔截器:response.data.error 存在 → reject;Network Error / 404 → ERR_998 + Sentry
|
|
329
|
-
10. 錯誤處理:ERR_F108 → isBlocked;ERR_800(取消)→ 靜默;其餘 → errorHandler
|
|
330
|
+
10. 錯誤處理:ERR_F108 → isBlocked + errorHandler;ERR_998 → 直接 throw;ERR_800(取消)→ 靜默;其餘 → errorHandler(描述物件帶 silent: true 則略過,仍 throw)
|
|
330
331
|
```
|
|
331
332
|
|
|
332
333
|
**V1→V2 轉換**:`supportVersion2List` 支援動態路徑(如 `payment/v2/:paymentType/transaction`,`:param` 替換為 `[^/]+`);特殊路徑由 `specifyingPath` 硬編碼映射,其餘用 `/([a-z])([A-Z])/g` 自動轉換。**新增需要 V2 轉換的端點時必須手動加入清單。**
|
|
@@ -344,6 +345,7 @@ io(`${socketURL}/frontend`, {
|
|
|
344
345
|
9. **unfinished game 無限重試**:`error.js` 的 `unfinishedGame` 狀態在 `onError` 時回到自身,**無退避策略也無重試上限**(已知問題,見「已知技術債」)。
|
|
345
346
|
10. **`isMobile` 是字串非布林值**:`common.js` 中 `isMobile = userAgent?.device?.type`,回傳 `'mobile'`/`'tablet'`/`undefined`,判斷時需比較字串(如 `isMobile === 'mobile' ? 'y' : null`)。
|
|
346
347
|
11. **請求預設不附加 CancelToken**:`send(req, customToken)` 的取消功能為**選擇性啟用**。axios <0.22 的取消 handler 永不退訂——共用長壽命 token 會隨請求數累積 handler,導致掛機過夜 OOM(TI-15555)。**不要「順手」把 CancelToken 加回共用路徑。**
|
|
348
|
+
12. **`silent: true` 只略過 errorHandler**:錯誤仍會 throw 給呼叫端的 `onError`,`ERR_F108` 也照常路由;但其餘錯誤碼——**包含 `ERR_A104` 等登出類、`ERR_G106` 餘額不足**——都不會進 error machine。只用於背景呼叫、且 session 失效另有 `fetchUserInfo` 輪詢兜底的請求;使用者主動觸發的請求不可加。
|
|
347
349
|
|
|
348
350
|
---
|
|
349
351
|
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [1.1.474](https://github.com/jetthai/cuora-module/compare/v1.1.473...v1.1.474) (2026-10-08)
|
|
6
|
+
|
|
5
7
|
### [1.1.473](https://github.com/jetthai/cuora-module/compare/v1.1.472...v1.1.473) (2026-10-05)
|
|
6
8
|
|
|
7
9
|
### [1.1.472](https://github.com/jetthai/cuora-module/compare/v1.1.471...v1.1.472) (2026-09-24)
|
package/CLAUDE.md
CHANGED
|
@@ -53,7 +53,7 @@ You are a senior full-stack engineer with world-class capability across UI/UX, A
|
|
|
53
53
|
Before delivering any code change, verify each of the following yourself:
|
|
54
54
|
|
|
55
55
|
- [ ] **Follows existing conventions**: clear four-layer separation, XState v4 factory pattern (`export default function (request) { return createMachine(...) }`), naming conventions, no TypeScript
|
|
56
|
-
- [ ] **Correct API descriptor object**: returns the `{ url, method, params?, isPublic?, headers?, isFormData? }` structure; HTTP method consistently lowercase; `isPublic: true` endpoints checked for whether they need `appSecret`; URLs carry no leading slash (unless deliberately bypassing `url-join`'s `baseURL`, in which case comment the reason)
|
|
56
|
+
- [ ] **Correct API descriptor object**: returns the `{ url, method, params?, isPublic?, headers?, isFormData?, silent? }` structure; HTTP method consistently lowercase; `isPublic: true` endpoints checked for whether they need `appSecret`; URLs carry no leading slash (unless deliberately bypassing `url-join`'s `baseURL`, in which case comment the reason)
|
|
57
57
|
- [ ] **V1→V2 path conversion**: new V2 endpoints must be added to `supportVersion2List` **manually**; use the `:param` form for dynamic parameters; put non-standard paths in the `specifyingPath` mapping
|
|
58
58
|
- [ ] **State machine conventions**: always modify context via `assign()`, never mutate directly; clone deep objects with `JSON.parse(JSON.stringify())`; choose the initial state name by semantics; don't let `onError` silently fall back to `idle` and lose the error information
|
|
59
59
|
- [ ] **Memory safety**: `setInterval` / `socket.on()` / `addEventListener` registered inside an XState callback service **must return a cleanup function** (e.g. `() => clientSocket.off(event, handler)`) to avoid accumulating listeners across reconnects; listeners registered inside a Promise must also be cleaned up after resolve / reject
|
|
@@ -111,6 +111,7 @@ state machine service → request.send(api.xxx(params)) → Request class → AP
|
|
|
111
111
|
isPublic?: boolean, // true = no auth token required
|
|
112
112
|
headers?: object, // Custom headers (e.g. reCAPTCHA)
|
|
113
113
|
isFormData?: boolean, // true = multipart/form-data
|
|
114
|
+
silent?: boolean, // true = on failure, don't forward to errorHandler (still throws)
|
|
114
115
|
}
|
|
115
116
|
```
|
|
116
117
|
|
|
@@ -328,7 +329,7 @@ io(`${socketURL}/frontend`, {
|
|
|
328
329
|
7. Custom paramsSerializer: special encoding for the q parameter (avoids double-encoding)
|
|
329
330
|
8. axios.request(config)
|
|
330
331
|
9. Response interceptor: response.data.error present → reject; Network Error / 404 → ERR_998 + Sentry
|
|
331
|
-
10. Error handling: ERR_F108 → isBlocked; ERR_800 (cancelled) → silent; everything else → errorHandler
|
|
332
|
+
10. Error handling: ERR_F108 → isBlocked + errorHandler; ERR_998 → thrown directly; ERR_800 (cancelled) → silent; everything else → errorHandler (skipped when the descriptor carries silent: true, still thrown)
|
|
332
333
|
```
|
|
333
334
|
|
|
334
335
|
**V1→V2 conversion**: `supportVersion2List` supports dynamic paths (e.g. `payment/v2/:paymentType/transaction`, where `:param` is replaced by `[^/]+`); special paths are hard-coded in `specifyingPath`, and the rest are auto-converted via `/([a-z])([A-Z])/g`. **When adding an endpoint that needs V2 conversion, it must be added to the list manually.**
|
|
@@ -346,6 +347,7 @@ io(`${socketURL}/frontend`, {
|
|
|
346
347
|
9. **Unfinished-game infinite retry**: the `unfinishedGame` state in `error.js` returns to itself on `onError`, with **no backoff strategy and no retry cap** (a known issue, see "Known Technical Debt").
|
|
347
348
|
10. **`isMobile` is a string, not a boolean**: in `common.js`, `isMobile = userAgent?.device?.type` returns `'mobile'`/`'tablet'`/`undefined`, so comparisons must be string-based (e.g. `isMobile === 'mobile' ? 'y' : null`).
|
|
348
349
|
11. **Requests carry no CancelToken by default**: the cancellation feature of `send(req, customToken)` is **opt-in**. In axios <0.22 the cancel handler is never unsubscribed — a shared long-lived token accumulates one handler per request, causing overnight OOM when left running (TI-15555). **Do not "helpfully" add the CancelToken back onto the shared path.**
|
|
350
|
+
12. **`silent: true` only skips errorHandler**: the error is still thrown to the caller's `onError`, and `ERR_F108` is still routed as usual; but every other error code — **including logout-class codes such as `ERR_A104`, and `ERR_G106` insufficient balance** — never reaches the error machine. Use it only for background requests whose session invalidation is already covered by `fetchUserInfo` polling; never add it to user-initiated requests.
|
|
349
351
|
|
|
350
352
|
---
|
|
351
353
|
|
package/GEMINI.md
CHANGED
|
@@ -53,7 +53,7 @@ You are a senior full-stack engineer with world-class capability across UI/UX, A
|
|
|
53
53
|
Before delivering any code change, verify each of the following yourself:
|
|
54
54
|
|
|
55
55
|
- [ ] **Follows existing conventions**: clear four-layer separation, XState v4 factory pattern (`export default function (request) { return createMachine(...) }`), naming conventions, no TypeScript
|
|
56
|
-
- [ ] **Correct API descriptor object**: returns the `{ url, method, params?, isPublic?, headers?, isFormData? }` structure; HTTP method consistently lowercase; `isPublic: true` endpoints checked for whether they need `appSecret`; URLs carry no leading slash (unless deliberately bypassing `url-join`'s `baseURL`, in which case comment the reason)
|
|
56
|
+
- [ ] **Correct API descriptor object**: returns the `{ url, method, params?, isPublic?, headers?, isFormData?, silent? }` structure; HTTP method consistently lowercase; `isPublic: true` endpoints checked for whether they need `appSecret`; URLs carry no leading slash (unless deliberately bypassing `url-join`'s `baseURL`, in which case comment the reason)
|
|
57
57
|
- [ ] **V1→V2 path conversion**: new V2 endpoints must be added to `supportVersion2List` **manually**; use the `:param` form for dynamic parameters; put non-standard paths in the `specifyingPath` mapping
|
|
58
58
|
- [ ] **State machine conventions**: always modify context via `assign()`, never mutate directly; clone deep objects with `JSON.parse(JSON.stringify())`; choose the initial state name by semantics; don't let `onError` silently fall back to `idle` and lose the error information
|
|
59
59
|
- [ ] **Memory safety**: `setInterval` / `socket.on()` / `addEventListener` registered inside an XState callback service **must return a cleanup function** (e.g. `() => clientSocket.off(event, handler)`) to avoid accumulating listeners across reconnects; listeners registered inside a Promise must also be cleaned up after resolve / reject
|
|
@@ -111,6 +111,7 @@ state machine service → request.send(api.xxx(params)) → Request class → AP
|
|
|
111
111
|
isPublic?: boolean, // true = no auth token required
|
|
112
112
|
headers?: object, // Custom headers (e.g. reCAPTCHA)
|
|
113
113
|
isFormData?: boolean, // true = multipart/form-data
|
|
114
|
+
silent?: boolean, // true = on failure, don't forward to errorHandler (still throws)
|
|
114
115
|
}
|
|
115
116
|
```
|
|
116
117
|
|
|
@@ -328,7 +329,7 @@ io(`${socketURL}/frontend`, {
|
|
|
328
329
|
7. Custom paramsSerializer: special encoding for the q parameter (avoids double-encoding)
|
|
329
330
|
8. axios.request(config)
|
|
330
331
|
9. Response interceptor: response.data.error present → reject; Network Error / 404 → ERR_998 + Sentry
|
|
331
|
-
10. Error handling: ERR_F108 → isBlocked; ERR_800 (cancelled) → silent; everything else → errorHandler
|
|
332
|
+
10. Error handling: ERR_F108 → isBlocked + errorHandler; ERR_998 → thrown directly; ERR_800 (cancelled) → silent; everything else → errorHandler (skipped when the descriptor carries silent: true, still thrown)
|
|
332
333
|
```
|
|
333
334
|
|
|
334
335
|
**V1→V2 conversion**: `supportVersion2List` supports dynamic paths (e.g. `payment/v2/:paymentType/transaction`, where `:param` is replaced by `[^/]+`); special paths are hard-coded in `specifyingPath`, and the rest are auto-converted via `/([a-z])([A-Z])/g`. **When adding an endpoint that needs V2 conversion, it must be added to the list manually.**
|
|
@@ -346,6 +347,7 @@ io(`${socketURL}/frontend`, {
|
|
|
346
347
|
9. **Unfinished-game infinite retry**: the `unfinishedGame` state in `error.js` returns to itself on `onError`, with **no backoff strategy and no retry cap** (a known issue, see "Known Technical Debt").
|
|
347
348
|
10. **`isMobile` is a string, not a boolean**: in `common.js`, `isMobile = userAgent?.device?.type` returns `'mobile'`/`'tablet'`/`undefined`, so comparisons must be string-based (e.g. `isMobile === 'mobile' ? 'y' : null`).
|
|
348
349
|
11. **Requests carry no CancelToken by default**: the cancellation feature of `send(req, customToken)` is **opt-in**. In axios <0.22 the cancel handler is never unsubscribed — a shared long-lived token accumulates one handler per request, causing overnight OOM when left running (TI-15555). **Do not "helpfully" add the CancelToken back onto the shared path.**
|
|
350
|
+
12. **`silent: true` only skips errorHandler**: the error is still thrown to the caller's `onError`, and `ERR_F108` is still routed as usual; but every other error code — **including logout-class codes such as `ERR_A104`, and `ERR_G106` insufficient balance** — never reaches the error machine. Use it only for background requests whose session invalidation is already covered by `fetchUserInfo` polling; never add it to user-initiated requests.
|
|
349
351
|
|
|
350
352
|
---
|
|
351
353
|
|
package/package.json
CHANGED
|
@@ -26,7 +26,7 @@ export default function (request) {
|
|
|
26
26
|
src: 'fetchList',
|
|
27
27
|
onDone: {
|
|
28
28
|
target: 'checking',
|
|
29
|
-
actions: ['setActivityList', 'setTournamentList', 'setPromotionList', '
|
|
29
|
+
actions: ['setActivityList', 'setTournamentList', 'setPromotionList', 'setListAuthKey'],
|
|
30
30
|
},
|
|
31
31
|
onError: {
|
|
32
32
|
target: 'pending',
|
|
@@ -41,7 +41,7 @@ export default function (request) {
|
|
|
41
41
|
src: 'fetchActivityDetailList',
|
|
42
42
|
onDone: {
|
|
43
43
|
target: 'pending',
|
|
44
|
-
actions: 'setActivityDetailList',
|
|
44
|
+
actions: ['setActivityDetailList', 'setProgressSummary'],
|
|
45
45
|
},
|
|
46
46
|
onError: {
|
|
47
47
|
target: 'pending',
|
|
@@ -129,8 +129,9 @@ export default function (request) {
|
|
|
129
129
|
}),
|
|
130
130
|
setActivityDetailList: assign((context, event) => {
|
|
131
131
|
if (!event.data) return {}
|
|
132
|
+
const { activityDetailList } = event.data
|
|
132
133
|
return {
|
|
133
|
-
activityDetailList:
|
|
134
|
+
activityDetailList: activityDetailList.map((item) => item.data),
|
|
134
135
|
}
|
|
135
136
|
}),
|
|
136
137
|
setListAuthKey: assign((context, event) => {
|
|
@@ -140,7 +141,7 @@ export default function (request) {
|
|
|
140
141
|
// activityDetailList 會殘留登出前的會員資料,導致輪盤/紅包雨顯示錯誤身分的結果。
|
|
141
142
|
return {
|
|
142
143
|
listAuthKey,
|
|
143
|
-
...(listAuthKey ? {} : { activityDetailList: [] }),
|
|
144
|
+
...(listAuthKey ? {} : { activityDetailList: [], progressSummary: {} }),
|
|
144
145
|
}
|
|
145
146
|
}),
|
|
146
147
|
resetActivities: assign((context, event) => {
|
|
@@ -177,19 +178,15 @@ export default function (request) {
|
|
|
177
178
|
fetchList: async (context, event) => {
|
|
178
179
|
const authKey = request.getToken() || null
|
|
179
180
|
const hasToken = !!authKey
|
|
180
|
-
const siteConfig = window?.$nuxt?.$store?.state?.siteConfig
|
|
181
|
-
const isProgressEnable = siteConfig?.frontendActivityProgressEnable
|
|
182
181
|
|
|
183
|
-
const [{ data }, promotionList
|
|
182
|
+
const [{ data }, promotionList] = await Promise.all([
|
|
184
183
|
hasToken ? request.send(activity.getActivityList({ appSecret })) : request.send(activity.getAllActivityList({ appSecret })),
|
|
185
184
|
hasToken ? request.send(payment.getPromotionsList()) : [],
|
|
186
|
-
hasToken && isProgressEnable ? request.send(activity.getProgressSummary({ appSecret })).catch(() => null) : null,
|
|
187
185
|
])
|
|
188
186
|
|
|
189
187
|
return {
|
|
190
188
|
activityList: data,
|
|
191
189
|
promotionList,
|
|
192
|
-
progressSummary: progressSummaryRes?.data || null,
|
|
193
190
|
authKey,
|
|
194
191
|
}
|
|
195
192
|
},
|
|
@@ -200,13 +197,24 @@ export default function (request) {
|
|
|
200
197
|
// 抓清單時是訪客,或這 1 秒內身分換過(?x= 登入落地)→ 不發,等 REFRESH 用正確身分重抓
|
|
201
198
|
if (!listAuthKey || request.getToken() !== listAuthKey) return null
|
|
202
199
|
|
|
200
|
+
const siteConfig = window?.$nuxt?.$store?.state?.siteConfig
|
|
201
|
+
const isProgressEnable = siteConfig?.frontendActivityProgressEnable
|
|
202
|
+
|
|
203
203
|
const { activityList = [], detailNeededActivityTypes } = context
|
|
204
204
|
const filteredActivityList = activityList.filter((activity) => detailNeededActivityTypes.includes(activity.activityType))
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
205
|
+
const [activityDetailList, progressSummaryRes] = await Promise.all([
|
|
206
|
+
Promise.all(
|
|
207
|
+
filteredActivityList.map((item) => {
|
|
208
|
+
return request.send(activity.getActivityDetail({ activityNo: item.activityNo, appSecret, silent: true }))
|
|
209
|
+
})
|
|
210
|
+
),
|
|
211
|
+
isProgressEnable ? request.send(activity.getProgressSummary({ appSecret })).catch(() => null) : Promise.resolve(null),
|
|
212
|
+
])
|
|
213
|
+
|
|
214
|
+
return {
|
|
215
|
+
activityDetailList,
|
|
216
|
+
progressSummary: progressSummaryRes?.data || null,
|
|
217
|
+
}
|
|
210
218
|
},
|
|
211
219
|
},
|
|
212
220
|
}
|