@jetthai/cuora 1.1.406-dev-2 → 1.1.406-dev-4

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/CHANGELOG.md CHANGED
@@ -2,10 +2,20 @@
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.406-dev-4](https://github.com/jetthai/cuora-module/compare/v1.1.406-dev-3...v1.1.406-dev-4) (2026-01-09)
6
+
7
+ ### [1.1.406-dev-3](https://github.com/jetthai/cuora-module/compare/v1.1.407...v1.1.406-dev-3) (2026-01-08)
8
+
5
9
  ### [1.1.406-dev-2](https://github.com/jetthai/cuora-module/compare/v1.1.406-dev-1...v1.1.406-dev-2) (2025-12-22)
6
10
 
7
11
  ### [1.1.406-dev-1](https://github.com/jetthai/cuora-module/compare/v1.1.406...v1.1.406-dev-1) (2025-12-19)
8
12
 
13
+ ### [1.1.406-dev-2](https://github.com/jetthai/cuora-module/compare/v1.1.406-dev-1...v1.1.406-dev-2) (2025-12-22)
14
+
15
+ ### [1.1.406-dev-1](https://github.com/jetthai/cuora-module/compare/v1.1.406...v1.1.406-dev-1) (2025-12-19)
16
+
17
+ ### [1.1.407](https://github.com/jetthai/cuora-module/compare/v1.1.406...v1.1.407) (2025-12-22)
18
+
9
19
  ### [1.1.406](https://github.com/jetthai/cuora-module/compare/v1.1.405...v1.1.406) (2025-12-16)
10
20
 
11
21
  ### [1.1.405](https://github.com/jetthai/cuora-module/compare/v1.1.404...v1.1.405) (2025-12-16)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.406-dev-2",
3
+ "version": "1.1.406-dev-4",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -87,6 +87,12 @@ export default {
87
87
  getVipTable: ({ appSecret }) => ({ url: 'activities/viptable', method: 'get', params: { appSecret } }),
88
88
  getLevelBonusInfo: () => ({ url: 'activities/level-bonus/info', method: 'get' }),
89
89
  getRankingList: () => ({ url: 'activities/ranking', method: 'get' }),
90
+ getPublicRankingList: ({ appSecret }) => ({
91
+ url: 'activities/ranking/public/promotion-ranking',
92
+ method: 'get',
93
+ isPublic: true,
94
+ params: { appSecret },
95
+ }),
90
96
  exchangeDiamond: ({ activityNo, exchangeAward = [] }) => ({
91
97
  url: 'activities/exchange/diamond',
92
98
  method: 'post',
@@ -49,6 +49,10 @@ export default function (request, context) {
49
49
  services: {
50
50
  // 取得遊戲資訊
51
51
  fetchGameInfo: async (context, event) => {
52
+ // [防呆] 確保有 gameCode
53
+ if (!gameCode) {
54
+ return { data: {} }
55
+ }
52
56
  return await request.send(game.getGameInfo({ appSecret, gameCode }))
53
57
  },
54
58
  },
@@ -517,44 +517,61 @@ export default function (request) {
517
517
  })
518
518
  return list.filter((item) => item.downLine.length > 0).slice(0, 6)
519
519
  } else if (additionEnable) {
520
- const param = { categoryId: room.categoryId, index, appSecret }
521
- requestChain = event.data.list.map((category, b) => {
522
- return request
523
- .send(
524
- api.getListCategory({
525
- categoryId: category.id,
526
- index: 0,
527
- appSecret,
528
- })
529
- )
530
- .then((res) => Object.assign({ downLine: res.data.filter((item) => item.isGame).slice(0, 20) }, category))
531
- })
532
- const result = await Promise.all([...requestChain, request.send(api.getListAddition(param))])
533
- return result.filter((item) => item.downLine.length > 0).slice(0, 6)
520
+ // [防呆] 確保有 categoryId
521
+ const hasCategoryId = !!room?.categoryId
522
+ const param = hasCategoryId ? { categoryId: room.categoryId, index, appSecret } : null
523
+ // [防呆] 確保有 categoryId
524
+ requestChain = event.data.list
525
+ .filter((category) => category && category.id !== undefined && category.id !== null)
526
+ .map((category) =>
527
+ request
528
+ .send(
529
+ api.getListCategory({
530
+ categoryId: category.id,
531
+ index: 0,
532
+ appSecret,
533
+ })
534
+ )
535
+ .then((res) => Object.assign({ downLine: res.data.filter((item) => item.isGame).slice(0, 20) }, category))
536
+ )
537
+ const promises = [...requestChain]
538
+ if (hasCategoryId) {
539
+ promises.push(request.send(api.getListAddition(param)))
540
+ }
541
+ const result = await Promise.all(promises)
542
+ return result.filter((item) => item.downLine?.length > 0).slice(0, 6)
534
543
  } else {
535
- requestChain = event.data.list.map((category, b) => {
536
- return request
537
- .send(
538
- api.getListCategory({
539
- categoryId: category.id,
540
- index: 0,
541
- appSecret,
542
- })
543
- )
544
- .then((res) => Object.assign({ downLine: res.data.filter((item) => item.isGame).slice(0, 20) }, category))
545
- })
544
+ // [防呆] 確保有 categoryId
545
+ requestChain = event.data.list
546
+ .filter((category) => category && category.id !== undefined && category.id !== null)
547
+ .map((category) =>
548
+ request
549
+ .send(
550
+ api.getListCategory({
551
+ categoryId: category.id,
552
+ index: 0,
553
+ appSecret,
554
+ })
555
+ )
556
+ .then((res) => Object.assign({ downLine: res.data.filter((item) => item.isGame).slice(0, 20) }, category))
557
+ )
546
558
  const result = await Promise.all([...requestChain])
547
559
  return result.filter((item) => item.downLine.length > 0).slice(0, 6)
548
560
  }
549
561
  },
550
562
  getPageContent: async (context, event) => {
551
563
  const { room, index, additionEnable, staticData } = context
552
- // 如果沒有 categoryId 不往下執行
564
+ // [防呆] 確保有 categoryId
553
565
  if (!room?.categoryId) {
554
- console.error('No room categoryId found for updating content')
555
- return
566
+ return [
567
+ {
568
+ data: [],
569
+ totalPage: 0,
570
+ timestamp: context.content?.timestamp ?? null,
571
+ },
572
+ ]
556
573
  }
557
- if (room?.categoryId === GAME_SEARCH) {
574
+ if (room.categoryId === GAME_SEARCH) {
558
575
  return
559
576
  } else if (!request.getToken()) {
560
577
  const list = staticData.find((data) => data.category == room.categoryId)?.info || []
@@ -576,12 +593,11 @@ export default function (request) {
576
593
  },
577
594
  updatePageContent: async (context, event) => {
578
595
  const { room, content, index, additionEnable } = context
579
- // 如果沒有 categoryId 不往下執行
596
+ // [防呆] 確保有 categoryId
580
597
  if (!room?.categoryId) {
581
- console.error('No room categoryId found for updating content')
582
598
  return []
583
599
  }
584
- if (room?.categoryId === GAME_SEARCH) {
600
+ if (room.categoryId === GAME_SEARCH) {
585
601
  return []
586
602
  } else if (!request.getToken()) {
587
603
  return []
@@ -37,12 +37,13 @@ export default function (request) {
37
37
  checking: {
38
38
  always: [
39
39
  { target: 'idle', actions: 'setActivityDetail', cond: 'isExist' },
40
- { target: 'loading', cond: 'hasActivityNo' },
40
+ { target: 'loading', cond: 'hasActivityNoAndToken' },
41
+ { target: 'idle' },
41
42
  ],
42
43
  },
43
44
  loading: {
44
45
  invoke: {
45
- src: 'fetchPublicActivityDetail',
46
+ src: 'fetchActivityDetail',
46
47
  onDone: {
47
48
  target: 'idle',
48
49
  actions: ['setActivityMap', 'setActivityDetail'],
@@ -100,8 +101,9 @@ export default function (request) {
100
101
  const { activityMap, activityNo } = context
101
102
  return activityMap[activityNo]
102
103
  },
103
- hasActivityNo: (context, event) => {
104
- return !!context.activityNo
104
+ hasActivityNoAndToken: (context, event) => {
105
+ const hasToken = request.getToken()
106
+ return !!context.activityNo && hasToken
105
107
  },
106
108
  },
107
109
  services: {
@@ -116,15 +118,10 @@ export default function (request) {
116
118
  const { data } = await request.send(hasToken ? api.getActivityList({ appSecret }) : api.getAllActivityList({ appSecret }))
117
119
  return data
118
120
  },
119
- fetchPublicActivityDetail: async (context, event) => {
120
- const hasToken = request.getToken()
121
+ fetchActivityDetail: async (context, event) => {
121
122
  const { activityNo } = context
122
123
  let result = {}
123
- if (hasToken) {
124
- result = await request.send(api.getActivityDetail({ activityNo, appSecret }))
125
- } else {
126
- result = await request.send(api.getTournamentDetail({ activityNo, appSecret }))
127
- }
124
+ result = await request.send(api.getActivityDetail({ activityNo, appSecret }))
128
125
  return result.data
129
126
  },
130
127
  },