@jetthai/cuora 1.1.473 → 1.1.475

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.
@@ -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
 
@@ -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,10 @@
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.475](https://github.com/jetthai/cuora-module/compare/v1.1.472...v1.1.475) (2026-10-12)
6
+
7
+ ### [1.1.474](https://github.com/jetthai/cuora-module/compare/v1.1.473...v1.1.474) (2026-10-08)
8
+
5
9
  ### [1.1.473](https://github.com/jetthai/cuora-module/compare/v1.1.472...v1.1.473) (2026-10-05)
6
10
 
7
11
  ### [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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.473",
3
+ "version": "1.1.475",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -26,7 +26,7 @@ export default function (request) {
26
26
  src: 'fetchList',
27
27
  onDone: {
28
28
  target: 'checking',
29
- actions: ['setActivityList', 'setTournamentList', 'setPromotionList', 'setProgressSummary', 'setListAuthKey'],
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: event.data.map((item) => item.data),
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, progressSummaryRes] = await Promise.all([
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
- return await Promise.all(
206
- filteredActivityList.map((item) => {
207
- return request.send(activity.getActivityDetail({ activityNo: item.activityNo, appSecret, silent: true }))
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
  }
@@ -24,6 +24,7 @@ export default function (request) {
24
24
  spinResult: {},
25
25
  rouletteV2ExchangeAward: [],
26
26
  calculatedNewSpinRewards: [],
27
+ isSpinOutOfStock: false,
27
28
  awardedCashAmount: 0,
28
29
  awardedFreeAmount: 0,
29
30
  awardedPointsAmount: 0,
@@ -209,36 +210,26 @@ export default function (request) {
209
210
  }),
210
211
  setSpinResult: assign((context, event) => {
211
212
  const { unCollectRewards = [], newSpinRewards = [], spinLeft = 0 } = JSON.parse(JSON.stringify(event.data || {}))
212
- const calculatedNewSpinRewards = newSpinRewards
213
- .map((item) => {
214
- item.count = 1
215
- return item
216
- })
217
- .reduce((arr, spin) => {
218
- let newIndex = 0
219
- let alreadyHave = false
220
- if (arr.length > 0) {
221
- alreadyHave = arr.find((item, index) => {
222
- if (item.rewardType === spin.rewardType && item.reward === spin.reward) {
223
- newIndex = index
224
- return true
225
- } else {
226
- return false
227
- }
228
- })
229
- }
230
- if (alreadyHave) {
231
- arr[newIndex].count++
232
- } else {
233
- arr.push(spin)
234
- }
235
- return arr
236
- }, [])
213
+ // JT-1780311660:newSpinRewards[].outOfStock === true 代表抽中已無庫存的實體獎,後端不派獎、不進 unCollectRewards,
214
+ // 跑馬燈也不展示;只有嚴格 true 才算缺貨(null / undefined 為非實體獎或舊後端)。合併計數沿用 rewardType + reward 相同才合併
215
+ const isOutOfStock = (spin) => spin?.outOfStock === true
216
+ const calculatedNewSpinRewards = newSpinRewards.reduce((arr, spin) => {
217
+ if (!spin || isOutOfStock(spin)) return arr
218
+ const existing = arr.find((item) => item.rewardType === spin.rewardType && item.reward === spin.reward)
219
+ if (existing) {
220
+ existing.count++
221
+ } else {
222
+ arr.push({ ...spin, count: 1 })
223
+ }
224
+ return arr
225
+ }, [])
237
226
 
238
227
  return {
239
228
  spinResult: event.data,
240
229
  unCollectRewards,
241
230
  calculatedNewSpinRewards,
231
+ // 本次抽獎含缺貨項目(單次 Spin 缺貨或 Spin All 部分/全部缺貨),前台以此決定是否改顯示通用缺貨提示
232
+ isSpinOutOfStock: newSpinRewards.some(isOutOfStock),
242
233
  spinLeft,
243
234
  }
244
235
  }),