@jetthai/cuora 1.1.406 → 1.1.407-1

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,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.407](https://github.com/jetthai/cuora-module/compare/v1.1.406...v1.1.407) (2025-12-22)
6
+
5
7
  ### [1.1.406](https://github.com/jetthai/cuora-module/compare/v1.1.405...v1.1.406) (2025-12-16)
6
8
 
7
9
  ### [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",
3
+ "version": "1.1.407-1",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -465,10 +465,7 @@ export default function (request) {
465
465
  referralObj.channel = storage.get('channel') || defaultChannel || channel
466
466
  referralObj.subchannel = storage.get('subchannel') || defaultSubchannel || subchannel
467
467
 
468
- // OZE、ZAZA 先使用 v2 測試 ,等待確認沒問題後再統一用 v2
469
- // 但 ZALO 仍維持 v1
470
- const fullURL =
471
- ['OZE', 'ZAZA'].includes(clientId) && provider !== 'zalo' ? request.config.fullURL.replace('/v1/', '/v2/') : request.config.fullURL
468
+ const fullURL = request.config.fullURL
472
469
 
473
470
  const redirectURL = urljoin(
474
471
  fullURL,
@@ -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
  },
@@ -390,6 +390,10 @@ export default function (request) {
390
390
  }),
391
391
  appendContent: assign((context, event) => {
392
392
  const { room, additionEnable } = context
393
+ // [防呆] 確保有 categoryId
394
+ if (!room?.categoryId) {
395
+ return
396
+ }
393
397
  if (room.categoryId === GAME_SEARCH) {
394
398
  return
395
399
  } else if (additionEnable) {
@@ -517,38 +521,60 @@ export default function (request) {
517
521
  })
518
522
  return list.filter((item) => item.downLine.length > 0).slice(0, 6)
519
523
  } 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)
524
+ // [防呆] 確保有 categoryId
525
+ const hasCategoryId = !!room?.categoryId
526
+ const param = hasCategoryId ? { categoryId: room.categoryId, index, appSecret } : null
527
+ // [防呆] 確保有 categoryId
528
+ requestChain = event.data.list
529
+ .filter((category) => category && category.id !== undefined && category.id !== null)
530
+ .map((category) =>
531
+ request
532
+ .send(
533
+ api.getListCategory({
534
+ categoryId: category.id,
535
+ index: 0,
536
+ appSecret,
537
+ })
538
+ )
539
+ .then((res) => Object.assign({ downLine: res.data.filter((item) => item.isGame).slice(0, 20) }, category))
540
+ )
541
+ const promises = [...requestChain]
542
+ if (hasCategoryId) {
543
+ promises.push(request.send(api.getListAddition(param)))
544
+ }
545
+ const result = await Promise.all(promises)
546
+ return result.filter((item) => item.downLine?.length > 0).slice(0, 6)
534
547
  } 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
- })
548
+ // [防呆] 確保有 categoryId
549
+ requestChain = event.data.list
550
+ .filter((category) => category && category.id !== undefined && category.id !== null)
551
+ .map((category) =>
552
+ request
553
+ .send(
554
+ api.getListCategory({
555
+ categoryId: category.id,
556
+ index: 0,
557
+ appSecret,
558
+ })
559
+ )
560
+ .then((res) => Object.assign({ downLine: res.data.filter((item) => item.isGame).slice(0, 20) }, category))
561
+ )
546
562
  const result = await Promise.all([...requestChain])
547
563
  return result.filter((item) => item.downLine.length > 0).slice(0, 6)
548
564
  }
549
565
  },
550
566
  getPageContent: async (context, event) => {
551
567
  const { room, index, additionEnable, staticData } = context
568
+ // [防呆] 確保有 categoryId
569
+ if (!room?.categoryId) {
570
+ return [
571
+ {
572
+ data: [],
573
+ totalPage: 0,
574
+ timestamp: context.content?.timestamp ?? null,
575
+ },
576
+ ]
577
+ }
552
578
  if (room.categoryId === GAME_SEARCH) {
553
579
  return
554
580
  } else if (!request.getToken()) {
@@ -571,6 +597,10 @@ export default function (request) {
571
597
  },
572
598
  updatePageContent: async (context, event) => {
573
599
  const { room, content, index, additionEnable } = context
600
+ // [防呆] 確保有 categoryId
601
+ if (!room?.categoryId) {
602
+ return []
603
+ }
574
604
  if (room.categoryId === GAME_SEARCH) {
575
605
  return []
576
606
  } else if (!request.getToken()) {
@@ -241,13 +241,10 @@ export default class Request {
241
241
  this._checkToken(req)
242
242
 
243
243
  const requestConfig = this._createConfig(req, cancelToken)
244
- // console.log('*請求資料Check', requestConfig)
245
244
  const configUrls = ['getConfig', 'get-config']
246
245
  if (this.isBlocked && !configUrls.includes(requestConfig.url)) {
247
246
  // 狀態是維護中&請求非siteConfig,終止所有的請求,除了維護頁需要的資料(siteConfig)
248
- // console.log('%c*禁止的請求目標', requestConfig)
249
247
  } else {
250
- // console.log('%c*允許的請求目標', requestConfig)
251
248
  const { data } = await this.axios.request(requestConfig)
252
249
  return data
253
250
  }
@@ -280,9 +277,9 @@ export default class Request {
280
277
  const { method, url, params, isPublic, isFormData, headers } = req
281
278
  let fullURL = this.config.fullURL
282
279
  let urlName = url
280
+
283
281
  // 有些API會將參數(/?)直接帶在URL上,所以要將參數排除
284
282
  const cleanUrl = url.split('?')[0]
285
-
286
283
  const isV2Supported = supportVersion2List.some((supportedUrl) => {
287
284
  // 如果包含動態參數(:parameter),則使用模式匹配
288
285
  if (supportedUrl.includes(':')) {
@@ -292,16 +289,9 @@ export default class Request {
292
289
  }
293
290
  return supportedUrl === cleanUrl
294
291
  })
295
-
296
- // 目前全站都支援V2,若有需要限制為V1的站點可以填入,此段等轉換全部完成之後就可以移除了
297
- const supportV2Toggle = [''].includes(this.config?.clientId)
298
-
299
- if (isV2Supported && !supportV2Toggle) {
300
- fullURL = fullURL.replace('/v1/', '/v2/')
292
+ // 符合轉換規則的API進行路徑調整
293
+ if (isV2Supported) {
301
294
  urlName = this._convertUrlToKebabCase(url)
302
- // console.log(`*[DEV_ONLY]V2`, 'url:', urlName)
303
- } else {
304
- // console.log(`*[DEV_ONLY]V2-不支援:`, 'url:', urlName)
305
295
  }
306
296
 
307
297
  if (isFormData) {