@seayoo-web/gamer-api 2.13.3 → 2.13.5

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/dist/index.js CHANGED
@@ -1,14 +1,14 @@
1
1
  import { isComboWebView as de } from "@seayoo-web/combo-webview";
2
2
  import { isPlainObject as k, supportWx as b, useConsole as ge, usePromise as pe, pruneURL as _e, supportWindow as be, queryString as S, pruneObject as c, omitFields as P, parseJSON as ye, removePara as G } from "@seayoo-web/utils";
3
3
  import { v as e, objectGuard as s } from "@seayoo-web/validator";
4
- function he(i) {
4
+ function fe(i) {
5
5
  return k(i, "gamer_token") && typeof i.gamer_token == "string";
6
6
  }
7
7
  function O(i) {
8
8
  return k(i);
9
9
  }
10
10
  const j = ge("GamerApiSDK");
11
- function fe(i) {
11
+ function he(i) {
12
12
  return /^\/[a-z\d-]+$/.test(i);
13
13
  }
14
14
  async function we() {
@@ -55,7 +55,7 @@ const ke = {
55
55
  j.error("removeStorageSync", t);
56
56
  }
57
57
  }
58
- }, h = "gamer_token";
58
+ }, f = "gamer_token";
59
59
  class oa {
60
60
  $NetRequest;
61
61
  $idToken = "";
@@ -65,7 +65,7 @@ class oa {
65
65
  storage;
66
66
  constructor(t, n) {
67
67
  this.storage = b() ? ve : ke;
68
- const r = fe(t) ? t : `https://${_e(t)}`;
68
+ const r = he(t) ? t : `https://${_e(t)}`;
69
69
  if (this.$NetRequest = n, this.req = n({
70
70
  baseURL: `${r}/v1`,
71
71
  timeout: 1e4,
@@ -96,7 +96,7 @@ class oa {
96
96
  return this.$NetRequest;
97
97
  }
98
98
  loadGamerTokenCache() {
99
- const n = this.storage.get(h).match(/^(\d{12,})#(.{8,})$/);
99
+ const n = this.storage.get(f).match(/^(\d{12,})#(.{8,})$/);
100
100
  if (n) {
101
101
  const r = parseInt(n[1]), a = n[2];
102
102
  if (r > Date.now() - (24 * 3600 - 10) * 1e3) {
@@ -104,7 +104,7 @@ class oa {
104
104
  return;
105
105
  }
106
106
  }
107
- this.storage.remove(h);
107
+ this.storage.remove(f);
108
108
  }
109
109
  /** 当前是否为登录状态,即是否拥有 gamerToken */
110
110
  get isLoggedIn() {
@@ -138,7 +138,7 @@ class oa {
138
138
  * 直接写入 Gamer Token,并更新缓存
139
139
  */
140
140
  set gamerToken(t) {
141
- this.$gamerToken = t, t ? this.storage.set(h, `${Date.now()}#${t}`) : this.storage.remove(h);
141
+ this.$gamerToken = t, t ? this.storage.set(f, `${Date.now()}#${t}`) : this.storage.remove(f);
142
142
  }
143
143
  /**
144
144
  * 退出登录,销毁相关 Token
@@ -171,7 +171,7 @@ class oa {
171
171
  const { code: n, data: r } = await this.req.post(
172
172
  "login-with-token",
173
173
  c({ id_token: this.idToken, weixin_token: t ? this.weixinToken : null }),
174
- he,
174
+ fe,
175
175
  {
176
176
  message: !1,
177
177
  cacheTTL: 300,
@@ -821,7 +821,7 @@ const v = {
821
821
  Private: "private",
822
822
  /** 公开队伍 */
823
823
  Public: "public"
824
- }, mt = e.string().enum(ut).lock(), f = {
824
+ }, mt = e.string().enum(ut).lock(), h = {
825
825
  /** 未知状态 */
826
826
  Unknown: "unknown",
827
827
  /** 等待开奖 */
@@ -832,7 +832,7 @@ const v = {
832
832
  Claimed: "claimed",
833
833
  /** 领奖失败 */
834
834
  Fail: "fail"
835
- }, ua = e.string().enum(f).lock(), dt = {
835
+ }, ua = e.string().enum(h).lock(), dt = {
836
836
  /** 发起组队 */
837
837
  Assemble: "assemble",
838
838
  /** 加入队伍 */
@@ -862,7 +862,7 @@ const v = {
862
862
  Winner: "winner",
863
863
  /** 安慰奖励 */
864
864
  Consolation: "consolation"
865
- }, yt = e.string().enum(bt).lock(), ht = {
865
+ }, yt = e.string().enum(bt).lock(), ft = {
866
866
  /** 抖音 */
867
867
  Douyin: "douyin",
868
868
  /** 小红书 */
@@ -877,14 +877,14 @@ const v = {
877
877
  Huya: "huya",
878
878
  /** 斗鱼 */
879
879
  Douyu: "douyu"
880
- }, re = e.string().enum(ht).lock(), ft = {
880
+ }, re = e.string().enum(ft).lock(), ht = {
881
881
  /** 已提交 */
882
882
  Submitted: "submitted",
883
883
  /** 已接收 */
884
884
  Accepted: "accepted",
885
885
  /** 已拒绝 */
886
886
  Rejected: "rejected"
887
- }, wt = e.string().enum(ft).lock(), kt = e.string().enum(v), y = e.object({
887
+ }, wt = e.string().enum(ht).lock(), kt = e.string().enum(v), y = e.object({
888
888
  reward_item_id: e.number(),
889
889
  reward_amount: e.number(),
890
890
  reward_item_name: e.string(),
@@ -1086,19 +1086,19 @@ const v = {
1086
1086
  options: e.array(_n),
1087
1087
  rewards: e.array(y)
1088
1088
  })
1089
- }), yn = l.Vote2, hn = e.object({
1089
+ }), yn = l.Vote2, fn = e.object({
1090
1090
  candidate_id: e.string(),
1091
1091
  display_name: e.string(),
1092
1092
  images: e.array(e.string()).optional(),
1093
1093
  videos: e.array(e.string()).optional(),
1094
1094
  description: e.string().optional(),
1095
1095
  jump_url: e.string()
1096
- }), fn = e.object({
1096
+ }), hn = e.object({
1097
1097
  ...u.shape,
1098
1098
  feature_type: e.string().enum(yn),
1099
1099
  config: e.object({
1100
1100
  vote_item_id: e.number().optional(),
1101
- candidates: e.array(hn),
1101
+ candidates: e.array(fn),
1102
1102
  vote_since: e.number(),
1103
1103
  vote_until: e.number(),
1104
1104
  rewards_since: e.number(),
@@ -1128,7 +1128,7 @@ const v = {
1128
1128
  sn,
1129
1129
  ln,
1130
1130
  bn,
1131
- fn,
1131
+ hn,
1132
1132
  xt,
1133
1133
  kn,
1134
1134
  mn,
@@ -1172,14 +1172,14 @@ const v = {
1172
1172
  feature_type: rt,
1173
1173
  receive_time: e.number(),
1174
1174
  extra_data: e.record(e.unknown()).optional()
1175
- }), qn = e.string().enum(f.Unknown, f.Pending), xn = e.union(
1175
+ }), qn = e.string().enum(h.Unknown, h.Pending), xn = e.union(
1176
1176
  e.object({
1177
1177
  ticket: e.string(),
1178
1178
  status: qn
1179
1179
  }),
1180
1180
  e.object({
1181
1181
  ticket: e.string(),
1182
- status: e.string().enum(P(f, "Unknown", "Pending")),
1182
+ status: e.string().enum(P(h, "Unknown", "Pending")),
1183
1183
  reward: V
1184
1184
  })
1185
1185
  ).satisfies(), Ln = e.object({
@@ -1273,7 +1273,7 @@ const v = {
1273
1273
  role_id: e.string().optional(),
1274
1274
  role_name: e.string().optional()
1275
1275
  })
1276
- )
1276
+ ).optional()
1277
1277
  }), Qn = e.object({
1278
1278
  option_sn: e.string()
1279
1279
  }), Bn = e.object({
@@ -1364,7 +1364,10 @@ const v = {
1364
1364
  }), er = e.object({
1365
1365
  feature_id: e.number(),
1366
1366
  can_engage: e.bool(),
1367
- has_unclaimed_rewards: e.bool()
1367
+ has_unclaimed_rewards: e.bool(),
1368
+ final_available_count: e.number(),
1369
+ total_remaining_engagements: e.number(),
1370
+ cycle_remaining_engagements: e.number()
1368
1371
  }), tr = e.object({
1369
1372
  engagement_id: e.number(),
1370
1373
  engagement: e.object({
@@ -1402,7 +1405,7 @@ const v = {
1402
1405
  params: e.string()
1403
1406
  }), yr = s({
1404
1407
  img: e.string()
1405
- }), hr = e.guard(En), fr = e.guard(Mn), wr = e.guard(
1408
+ }), fr = e.guard(En), hr = e.guard(Mn), wr = e.guard(
1406
1409
  e.object({
1407
1410
  candidate_votes: e.array(Kn)
1408
1411
  })
@@ -1758,7 +1761,7 @@ class pa {
1758
1761
  */
1759
1762
  async getQuestProgress(t, n) {
1760
1763
  if (!await this.token.autoLogin()) return null;
1761
- const { data: r, code: a, message: o } = await this.req.get(`event/${this.event}/quest-progress`, hr, {
1764
+ const { data: r, code: a, message: o } = await this.req.get(`event/${this.event}/quest-progress`, fr, {
1762
1765
  message: !1,
1763
1766
  ...n,
1764
1767
  params: { feature_id: t }
@@ -1780,7 +1783,7 @@ class pa {
1780
1783
  const { data: r, code: a, message: o } = await this.req.post(
1781
1784
  "event/vote2/rewards",
1782
1785
  { feature_id: t, event_id: this.event },
1783
- fr,
1786
+ hr,
1784
1787
  n
1785
1788
  );
1786
1789
  return r || {
@@ -2636,7 +2639,7 @@ export {
2636
2639
  ln as EventFeatureConfigOfTeamValidator,
2637
2640
  gn as EventFeatureConfigOfUgcLikeValidator,
2638
2641
  mn as EventFeatureConfigOfUgcValidator,
2639
- fn as EventFeatureConfigOfVote2Validator,
2642
+ hn as EventFeatureConfigOfVote2Validator,
2640
2643
  bn as EventFeatureConfigOfVoteValidator,
2641
2644
  vn as EventFeatureConfigValidator,
2642
2645
  tt as EventPeriodType,
@@ -2660,7 +2663,7 @@ export {
2660
2663
  da as LotteryDrawActionValidator,
2661
2664
  Ln as LotteryDrawEngagementDataValidator,
2662
2665
  Tn as LotteryEngagementDataValidator,
2663
- f as LotteryTicketStatus,
2666
+ h as LotteryTicketStatus,
2664
2667
  ua as LotteryTicketStatusValidator,
2665
2668
  _ as NotificationBaseValidator,
2666
2669
  Tr as NotificationCategory,
@@ -2721,9 +2724,9 @@ export {
2721
2724
  An as UgcEngagementDataValidator,
2722
2725
  Nn as UgcLeaderboardResponseValidator,
2723
2726
  Gn as UgcRecordResponseValidator,
2724
- ft as UgcReviewStatus,
2727
+ ht as UgcReviewStatus,
2725
2728
  wt as UgcReviewStatusValidator,
2726
- ht as UgcSocialMedia,
2729
+ ft as UgcSocialMedia,
2727
2730
  re as UgcSocialMediaValidator,
2728
2731
  On as UgcUploadImageValidator,
2729
2732
  $ as UserEngagementDataValidator,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@seayoo-web/gamer-api",
3
3
  "description": "agent for gamer api",
4
- "version": "2.13.3",
4
+ "version": "2.13.5",
5
5
  "type": "module",
6
6
  "source": "index.ts",
7
7
  "main": "./dist/index.js",
@@ -30,17 +30,17 @@
30
30
  "license": "MIT",
31
31
  "devDependencies": {
32
32
  "@types/node": "^22.13.1",
33
- "@seayoo-web/combo-webview": "2.8.0",
34
- "@seayoo-web/request": "3.4.1",
35
33
  "@seayoo-web/scripts": "3.1.5",
36
- "@seayoo-web/tsconfig": "1.0.5",
34
+ "@seayoo-web/request": "3.4.1",
35
+ "@seayoo-web/combo-webview": "2.8.0",
37
36
  "@seayoo-web/validator": "1.1.1",
37
+ "@seayoo-web/tsconfig": "1.0.5",
38
38
  "@seayoo-web/utils": "4.1.3"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "@seayoo-web/combo-webview": "^2.8.0",
42
- "@seayoo-web/validator": "^1.1.1",
43
- "@seayoo-web/utils": "^4.1.3"
42
+ "@seayoo-web/utils": "^4.1.3",
43
+ "@seayoo-web/validator": "^1.1.1"
44
44
  },
45
45
  "scripts": {
46
46
  "prebuild": "pnpm -F validator build && pnpm -F request build && pnpm -F combo-webview build",
@@ -20,6 +20,21 @@ export interface UserFeatureStatus {
20
20
  can_engage: boolean;
21
21
  /** 是否有已获得但尚未领取的玩法参与奖励 */
22
22
  has_unclaimed_rewards: boolean;
23
+ /**
24
+ * 所有限制条件(总次数、周期次数等)下的最终可用参与次数。
25
+ 等于 Min(TotalRemainingEngagements, CycleRemainingEngagements)
26
+ */
27
+ final_available_count: number;
28
+ /**
29
+ * 玩法生效时间内用户剩余的参与次数。
30
+ -1 表示玩法生效时间内参与次数无限制。
31
+ */
32
+ total_remaining_engagements: number;
33
+ /**
34
+ * 玩法当前参与周期(如每日或每周)内用户剩余的参与次数。
35
+ -1 表示玩法当前参与周期内参与次数无限制。
36
+ */
37
+ cycle_remaining_engagements: number;
23
38
  }
24
39
  export declare const UserFeatureStatusValidator: import("@seayoo-web/validator").ObjectValidator<UserFeatureStatus, false, false>;
25
40
  export interface EngageResponse {
@@ -95,6 +95,6 @@ export interface LeaderboardEntry {
95
95
  }
96
96
  export interface UgcLeaderboardResponse {
97
97
  /** 投稿排行榜列表 */
98
- ugcs: Array<LeaderboardEntry>;
98
+ ugcs?: Array<LeaderboardEntry>;
99
99
  }
100
100
  export declare const UgcLeaderboardResponseValidator: import("@seayoo-web/validator").ObjectValidator<UgcLeaderboardResponse, false, false>;