@seayoo-web/gamer-api 2.0.14 → 2.0.16

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
@@ -2,19 +2,18 @@ var le = Object.defineProperty;
2
2
  var me = (i, t, n) => t in i ? le(i, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : i[t] = n;
3
3
  var l = (i, t, n) => me(i, typeof t != "symbol" ? t + "" : t, n);
4
4
  import { isComboWebView as de } from "@seayoo-web/combo-webview";
5
- import { isPlainObject as v, useConsole as ge, Support as b, usePromise as pe, pruneURL as _e, queryString as L, pruneObject as a, v as e, omitFields as C, typedObjectGuard as o, parseJSON as be, removePara as A } from "@seayoo-web/utils";
6
- import "@seayoo-web/request";
5
+ import { isPlainObject as v, useConsole as ge, Support as b, usePromise as pe, pruneURL as _e, queryString as L, pruneObject as a, v as e, omitFields as C, typedObjectGuard as o, parseJSON as be, removePara as N } from "@seayoo-web/utils";
7
6
  function ye(i) {
8
7
  return v(i, "gamer_token") && typeof i.gamer_token == "string";
9
8
  }
10
- function O(i) {
9
+ function A(i) {
11
10
  return v(i);
12
11
  }
13
12
  const f = ge("GamerApiSDK");
14
13
  function fe(i) {
15
14
  return /^\/[a-z\d-]+$/.test(i);
16
15
  }
17
- async function we() {
16
+ async function he() {
18
17
  const { promise: i, resolve: t } = pe();
19
18
  return wx.login({
20
19
  success(n) {
@@ -25,7 +24,7 @@ async function we() {
25
24
  }
26
25
  }), await i;
27
26
  }
28
- const he = {
27
+ const we = {
29
28
  get(i) {
30
29
  return localStorage.getItem(i) || "";
31
30
  },
@@ -58,17 +57,18 @@ const he = {
58
57
  f.error("removeStorageSync", t);
59
58
  }
60
59
  }
61
- }, w = "gamer_token";
60
+ }, h = "gamer_token";
62
61
  class hr {
63
62
  constructor(t, n) {
63
+ l(this, "$NetRequest");
64
64
  l(this, "$idToken", "");
65
65
  l(this, "$weixinToken", "");
66
66
  l(this, "$gamerToken", "");
67
67
  l(this, "req");
68
68
  l(this, "storage");
69
- this.storage = b.wx ? ke : he;
69
+ this.storage = b.wx ? ke : we;
70
70
  const r = fe(t) ? t : `https://${_e(t)}`;
71
- this.req = n({
71
+ this.$NetRequest = n, this.req = n({
72
72
  baseURL: `${r}/v1`,
73
73
  timeout: 1e4,
74
74
  responseRule: {
@@ -85,8 +85,11 @@ class hr {
85
85
  }
86
86
  }), de() ? this.$gamerToken = L("gamer_token") : this.loadGamerTokenCache();
87
87
  }
88
+ get NetRequest() {
89
+ return this.$NetRequest;
90
+ }
88
91
  loadGamerTokenCache() {
89
- const n = this.storage.get(w).match(/^(\d{12,})#(.{8,})$/);
92
+ const n = this.storage.get(h).match(/^(\d{12,})#(.{8,})$/);
90
93
  if (n) {
91
94
  const r = parseInt(n[1]), s = n[2];
92
95
  if (r > Date.now() - (24 * 3600 - 10) * 1e3) {
@@ -94,7 +97,7 @@ class hr {
94
97
  return;
95
98
  }
96
99
  }
97
- this.storage.remove(w);
100
+ this.storage.remove(h);
98
101
  }
99
102
  /** 当前是否为登录状态,即是否拥有 gamerToken */
100
103
  get isLoggedIn() {
@@ -128,7 +131,7 @@ class hr {
128
131
  * 直接写入 Gamer Token,并更新缓存
129
132
  */
130
133
  set gamerToken(t) {
131
- this.$gamerToken = t, t ? this.storage.set(w, `${Date.now()}#${t}`) : this.storage.remove(w);
134
+ this.$gamerToken = t, t ? this.storage.set(h, `${Date.now()}#${t}`) : this.storage.remove(h);
132
135
  }
133
136
  /**
134
137
  * 退出登录,销毁相关 Token
@@ -184,7 +187,7 @@ class hr {
184
187
  */
185
188
  async getSession() {
186
189
  if (!await this.autoLogin()) return null;
187
- const { data: t } = await this.req.get("session", O, {
190
+ const { data: t } = await this.req.get("session", A, {
188
191
  message: !1
189
192
  });
190
193
  return t;
@@ -196,7 +199,7 @@ class hr {
196
199
  */
197
200
  async authRealName(t) {
198
201
  if (!await this.autoLogin()) return null;
199
- const { data: n } = await this.req.post("auth-real-name", a(t), O);
202
+ const { data: n } = await this.req.post("auth-real-name", a(t), A);
200
203
  return n;
201
204
  }
202
205
  }
@@ -207,14 +210,14 @@ const ve = {
207
210
  Male: "male",
208
211
  /** 女 */
209
212
  Female: "female"
210
- }, Ce = e.string().enum(ve).lock(), Ve = {
213
+ }, Ce = e.string().enum(ve).lock(), Re = {
211
214
  /** 积分增加 */
212
215
  Increase: "increase",
213
216
  /** 积分减少 */
214
217
  Decrease: "decrease",
215
218
  /** 积分过期 */
216
219
  Expired: "expired"
217
- }, Re = e.string().enum(Ve).lock(), je = {
220
+ }, Ve = e.string().enum(Re).lock(), je = {
218
221
  /** 游戏内购买 */
219
222
  Order: "order",
220
223
  /** 游戏内消耗 */
@@ -271,15 +274,15 @@ const ve = {
271
274
  }).lock(), Ee = e.object({
272
275
  server_id: e.string(),
273
276
  server_name: e.string()
274
- }).lock(), Ue = e.object({
277
+ }).lock(), $e = e.object({
275
278
  role_id: e.string(),
276
279
  role_name: e.string()
277
280
  }).lock(), J = e.object({
278
- ...Ue.shape,
281
+ ...$e.shape,
279
282
  ...Ee.shape,
280
283
  role_level: e.number(),
281
284
  last_login_time: e.number()
282
- }).lock(), $e = e.object({
285
+ }).lock(), Ue = e.object({
283
286
  ...J.shape,
284
287
  /** 角色战力 */
285
288
  role_fighting: e.number(),
@@ -311,7 +314,7 @@ const ve = {
311
314
  balance_credit: e.number()
312
315
  }).lock(), Ie = e.object({
313
316
  id: e.number(),
314
- change_type: Re,
317
+ change_type: Ve,
315
318
  change_scene: Te,
316
319
  change_credit: e.number(),
317
320
  balance: e.number(),
@@ -354,7 +357,7 @@ const ve = {
354
357
  }).lock(), Ge = e.object({
355
358
  ...C(X.shape, "tag"),
356
359
  product: Y.clone().optional()
357
- }).lock(), kr = e.union(
360
+ }).lock(), wr = e.union(
358
361
  e.object({
359
362
  server_id: e.string(),
360
363
  role_id: e.string()
@@ -362,7 +365,7 @@ const ve = {
362
365
  e.object({
363
366
  address_id: e.number()
364
367
  })
365
- ).satisfies().lock(), Ae = e.object({
368
+ ).satisfies().lock(), Ne = e.object({
366
369
  recipient: e.string(),
367
370
  mobile: e.string(),
368
371
  province: e.string(),
@@ -371,11 +374,11 @@ const ve = {
371
374
  address: e.string(),
372
375
  express_company: e.string(),
373
376
  express_number: e.string()
374
- }).lock(), Oe = e.object({
377
+ }).lock(), Ae = e.object({
375
378
  server_id: e.string(),
376
379
  role_id: e.string(),
377
380
  role_name: e.string()
378
- }).lock(), Ne = e.object({
381
+ }).lock(), Oe = e.object({
379
382
  redemption_id: e.number(),
380
383
  player_id: e.string(),
381
384
  product_id: e.number(),
@@ -388,15 +391,15 @@ const ve = {
388
391
  amount: e.number(),
389
392
  status: Se,
390
393
  created_at: e.number(),
391
- extra_data: e.union(Ae.clone(), Oe.clone()).satisfies().optional()
392
- }), Be = e.guard(Le), N = o({ player: Pe }), Qe = o({ roles: e.array(J) }), T = o({ role_card: $e }), B = e.guard(Fe), Q = e.guard(K), Me = o({ addresses: e.array(K) }), He = e.guard(De), ze = o({
394
+ extra_data: e.union(Ne.clone(), Ae.clone()).satisfies().optional()
395
+ }), Be = e.guard(Le), O = o({ player: Pe }), Qe = o({ roles: e.array(J) }), T = o({ role_card: Ue }), B = e.guard(Fe), Q = e.guard(K), Me = o({ addresses: e.array(K) }), He = e.guard(De), ze = o({
393
396
  credit_logs: e.array(Ie),
394
397
  next_token: e.string().optional()
395
398
  }), Je = o({ products: e.array(Y) }), Ke = o({ benefits: e.array(X) }), Xe = o({ benefit: Ge }), Ye = o({
396
- redemptions: e.array(Ne),
399
+ redemptions: e.array(Oe),
397
400
  next_token: e.string().optional()
398
401
  });
399
- class vr {
402
+ class kr {
400
403
  constructor(t) {
401
404
  l(this, "token");
402
405
  l(this, "req");
@@ -418,7 +421,7 @@ class vr {
418
421
  */
419
422
  async getCurrentPlayer() {
420
423
  await this.token.autoLogin();
421
- const { data: t, code: n } = await this.req.get("club/current-player", N);
424
+ const { data: t, code: n } = await this.req.get("club/current-player", O);
422
425
  return (t == null ? void 0 : t.player) ?? { error: n };
423
426
  }
424
427
  /**
@@ -433,7 +436,7 @@ class vr {
433
436
  {
434
437
  id_token: this.token.idToken
435
438
  },
436
- N
439
+ O
437
440
  );
438
441
  return (t == null ? void 0 : t.player) ?? {
439
442
  error: n
@@ -625,7 +628,7 @@ class vr {
625
628
  return { redemptions: (n == null ? void 0 : n.redemptions) || [], next_token: n == null ? void 0 : n.next_token };
626
629
  }
627
630
  }
628
- const V = {
631
+ const R = {
629
632
  /** 活动道具 */
630
633
  EventItem: "event_item",
631
634
  /** 游戏内道具 */
@@ -644,7 +647,7 @@ const V = {
644
647
  ExternalCode: "external_gift_code",
645
648
  /** 空奖励 */
646
649
  VoidItem: "void_item"
647
- }, Z = e.string().enum(V).lock(), Cr = V, W = Z, Ze = {
650
+ }, Z = e.string().enum(R).lock(), vr = R, W = Z, Ze = {
648
651
  /** 世游通行证 ID / Combo ID */
649
652
  UserId: "user_id",
650
653
  /** 游戏角色 ID */
@@ -720,7 +723,7 @@ const V = {
720
723
  Failed: "failed",
721
724
  /** 奖励已发货 */
722
725
  Delivered: "delivered"
723
- }, Vr = e.string().enum(g).lock(), P = {
726
+ }, Cr = e.string().enum(g).lock(), P = {
724
727
  /**
725
728
  * 奖励未领取,拼写错误以兼容后端历史版本,检查请使用 Unclaimed
726
729
  *
@@ -757,12 +760,12 @@ const V = {
757
760
  Output: "output",
758
761
  /** 玩法参与奖励 */
759
762
  Engage: "engage"
760
- }, U = e.string().enum(at).lock(), st = {
763
+ }, $ = e.string().enum(at).lock(), st = {
761
764
  /** 私有队伍 */
762
765
  Private: "private",
763
766
  /** 公开队伍 */
764
767
  Public: "public"
765
- }, ct = e.string().enum(st).lock(), h = {
768
+ }, ct = e.string().enum(st).lock(), w = {
766
769
  /** 未知状态 */
767
770
  Unknown: "unknown",
768
771
  /** 等待开奖 */
@@ -773,7 +776,7 @@ const V = {
773
776
  Claimed: "claimed",
774
777
  /** 领奖失败 */
775
778
  Fail: "fail"
776
- }, Rr = e.string().enum(h).lock(), ut = {
779
+ }, Rr = e.string().enum(w).lock(), ut = {
777
780
  /** 发起组队 */
778
781
  Assemble: "assemble",
779
782
  /** 加入队伍 */
@@ -784,14 +787,14 @@ const V = {
784
787
  ChangeVisibility: "change_visibility",
785
788
  /** 查询组队信息 */
786
789
  Query: "query"
787
- }, jr = e.string().enum(ut).lock(), lt = {
790
+ }, Vr = e.string().enum(ut).lock(), lt = {
788
791
  /** 查询抽奖券 */
789
792
  Query: "query",
790
793
  /** 开奖 */
791
794
  Draw: "draw",
792
795
  /** 领奖 */
793
796
  Claim: "claim"
794
- }, Tr = e.string().enum(lt).lock(), mt = e.string().enum(C(V, "GiftCode", "LotteryTicket")), $ = e.object({
797
+ }, jr = e.string().enum(lt).lock(), mt = e.string().enum(C(R, "GiftCode", "LotteryTicket")), U = e.object({
795
798
  reward_item_id: e.number(),
796
799
  reward_amount: e.number(),
797
800
  reward_item_name: e.string(),
@@ -801,11 +804,11 @@ const V = {
801
804
  reward_item_rating: e.number()
802
805
  }).lock(), dt = e.object({
803
806
  engage_count: e.number(),
804
- rewards: e.array($)
807
+ rewards: e.array(U)
805
808
  }).lock(), gt = e.union(
806
809
  e.object({
807
810
  feature_reward_type: e.string().enum("every"),
808
- reward_details: e.array($)
811
+ reward_details: e.array(U)
809
812
  }),
810
813
  e.object({
811
814
  feature_reward_type: e.string().enum("regular"),
@@ -833,12 +836,12 @@ const V = {
833
836
  }), bt = c.CheckIn, yt = e.object({
834
837
  ...u.shape,
835
838
  feature_type: e.string().enum(bt)
836
- }), ft = c.ClaimRewards, wt = e.object({
839
+ }), ft = c.ClaimRewards, ht = e.object({
837
840
  ...u.shape,
838
841
  feature_type: e.string().enum(ft)
839
- }), ht = c.Comment, kt = e.object({
842
+ }), wt = c.Comment, kt = e.object({
840
843
  ...u.shape,
841
- feature_type: e.string().enum(ht),
844
+ feature_type: e.string().enum(wt),
842
845
  config: e.object({
843
846
  comments: e.array(e.string()),
844
847
  send_rate: e.number()
@@ -853,15 +856,15 @@ const V = {
853
856
  qr_code_url: e.string().optional(),
854
857
  platform_desc: e.string().optional()
855
858
  })
856
- }), Vt = c.GiftCode, Rt = e.object({
859
+ }), Rt = c.GiftCode, Vt = e.object({
857
860
  name: e.string(),
858
861
  icon_url: e.string(),
859
862
  count: e.number()
860
863
  }), jt = e.object({
861
864
  ...u.shape,
862
- feature_type: e.string().enum(Vt),
865
+ feature_type: e.string().enum(Rt),
863
866
  config: e.object({
864
- gift_items: e.array(Rt),
867
+ gift_items: e.array(Vt),
865
868
  mp_url: e.string().optional(),
866
869
  mp_qrcode_url: e.string().optional()
867
870
  })
@@ -874,7 +877,7 @@ const V = {
874
877
  }), xt = c.InvitedRegister, St = e.object({
875
878
  ...u.shape,
876
879
  feature_type: e.string().enum(xt)
877
- }), Lt = e.string().enum(C(V, "GiftCode", "LotteryTicket")), Pt = c.Lottery, Et = e.object({
880
+ }), Lt = e.string().enum(C(R, "GiftCode", "LotteryTicket")), Pt = c.Lottery, Et = e.object({
878
881
  reward_item_id: e.number(),
879
882
  reward_item_name: e.string(),
880
883
  reward_item_type: Lt,
@@ -882,7 +885,7 @@ const V = {
882
885
  reward_item_desc: e.string().optional(),
883
886
  reward_amount: e.number(),
884
887
  reward_remaining_stock: e.number()
885
- }), Ut = e.object({
888
+ }), $t = e.object({
886
889
  ...u.shape,
887
890
  feature_type: e.string().enum(Pt),
888
891
  config: e.object({
@@ -893,9 +896,9 @@ const V = {
893
896
  consume_item_desc: e.string().optional(),
894
897
  rewards: e.array(Et)
895
898
  })
896
- }), $t = c.LotteryDraw, Ft = e.object({
899
+ }), Ut = c.LotteryDraw, Ft = e.object({
897
900
  ...u.shape,
898
- feature_type: e.string().enum($t),
901
+ feature_type: e.string().enum(Ut),
899
902
  config: e.object({
900
903
  draw_not_before: e.number(),
901
904
  draw_not_after: e.number()
@@ -903,7 +906,7 @@ const V = {
903
906
  }), Dt = c.Preregister, It = e.object({
904
907
  ...u.shape,
905
908
  feature_type: e.string().enum(Dt)
906
- }), Gt = c.Quest, At = e.object({
909
+ }), Gt = c.Quest, Nt = e.object({
907
910
  ...u.shape,
908
911
  feature_type: e.string().enum(Gt),
909
912
  config: e.object({
@@ -914,9 +917,9 @@ const V = {
914
917
  completion_value: e.number()
915
918
  }).optional()
916
919
  })
917
- }), Ot = c.Register, Nt = e.object({
920
+ }), At = c.Register, Ot = e.object({
918
921
  ...u.shape,
919
- feature_type: e.string().enum(Ot)
922
+ feature_type: e.string().enum(At)
920
923
  }), Bt = c.Share, Qt = e.object({
921
924
  ...u.shape,
922
925
  feature_type: e.string().enum(Bt),
@@ -964,22 +967,22 @@ const V = {
964
967
  finalists_amount: e.number(),
965
968
  source: ot,
966
969
  options: e.array(Zt),
967
- rewards: e.array($)
970
+ rewards: e.array(U)
968
971
  })
969
972
  }), en = e.union(
970
973
  _t,
971
974
  yt,
972
- wt,
975
+ ht,
973
976
  kt,
974
977
  Ct,
975
978
  jt,
976
979
  qt,
977
980
  St,
978
- Ut,
981
+ $t,
979
982
  Ft,
980
983
  It,
981
- At,
982
984
  Nt,
985
+ Ot,
983
986
  Qt,
984
987
  Ht,
985
988
  Jt,
@@ -1007,7 +1010,7 @@ const V = {
1007
1010
  }), ne = e.object({
1008
1011
  reward_id: e.number(),
1009
1012
  reward_item_id: e.number(),
1010
- reward_source: U,
1013
+ reward_source: $,
1011
1014
  reward_item_name: e.string(),
1012
1015
  reward_item_type: Z,
1013
1016
  reward_item_icon_url: e.string(),
@@ -1024,14 +1027,14 @@ const V = {
1024
1027
  // https://kdocs.cn/l/ckWFDcOsYEUA?linkname=merUzJsVYH
1025
1028
  // 后续会格式化为具体的类型,此处的校验需要对应增加
1026
1029
  extra_data: e.record(e.unknown()).optional()
1027
- }), sn = e.string().enum(h.Unknown, h.Pending), cn = e.union(
1030
+ }), sn = e.string().enum(w.Unknown, w.Pending), cn = e.union(
1028
1031
  e.object({
1029
1032
  ticket: e.string(),
1030
1033
  status: sn
1031
1034
  }),
1032
1035
  e.object({
1033
1036
  ticket: e.string(),
1034
- status: e.string().enum(C(h, "Unknown", "Pending")),
1037
+ status: e.string().enum(C(w, "Unknown", "Pending")),
1035
1038
  reward: ne
1036
1039
  })
1037
1040
  ).satisfies(), un = e.object({
@@ -1064,7 +1067,7 @@ const V = {
1064
1067
  team_code: e.string(),
1065
1068
  leader_name: e.string(),
1066
1069
  total_members: e.number()
1067
- }), qr = e.object({
1070
+ }), Tr = e.object({
1068
1071
  is_leader: e.bool(),
1069
1072
  is_myself: e.bool().optional(),
1070
1073
  role_name: e.string(),
@@ -1105,20 +1108,20 @@ const V = {
1105
1108
  "EmptyObject",
1106
1109
  (i) => v(i) && Object.keys(i).length === 0
1107
1110
  )
1108
- ).satisfies().lock(), wn = e.object({
1111
+ ).satisfies().lock(), hn = e.object({
1109
1112
  reward_id: e.number(),
1110
1113
  reward_item_id: e.number(),
1111
1114
  reward_item_type: W,
1112
1115
  reward_count: e.number(),
1113
1116
  reward_status: te,
1114
- reward_source: U,
1117
+ reward_source: $,
1115
1118
  reward_item_name: e.string(),
1116
1119
  reward_item_icon_url: e.string(),
1117
1120
  reward_item_desc: e.string().optional(),
1118
1121
  reward_item_rating: e.number(),
1119
1122
  receive_time: e.number(),
1120
1123
  extra_data: e.union(...re.validators, e.record(e.unknown())).satisfies().optional()
1121
- }), hn = e.object({
1124
+ }), wn = e.object({
1122
1125
  reward_id: e.number(),
1123
1126
  reward_item_id: e.number(),
1124
1127
  reward_item_name: e.string(),
@@ -1127,7 +1130,7 @@ const V = {
1127
1130
  reward_item_desc: e.string().optional(),
1128
1131
  reward_amount: e.number(),
1129
1132
  reward_status: te,
1130
- reward_source: U,
1133
+ reward_source: $,
1131
1134
  extra_data: e.record(e.unknown()).optional()
1132
1135
  }), ie = e.object({
1133
1136
  engagement_id: e.number(),
@@ -1139,7 +1142,7 @@ const V = {
1139
1142
  server_id: e.string().optional(),
1140
1143
  role_id: e.string().optional(),
1141
1144
  created_at: e.number(),
1142
- rewards: e.array(wn).optional()
1145
+ rewards: e.array(hn).optional()
1143
1146
  }).lock(), kn = e.object({
1144
1147
  allowed: e.bool(),
1145
1148
  registered: e.bool()
@@ -1157,12 +1160,12 @@ const V = {
1157
1160
  role_id: e.string(),
1158
1161
  data: ie.clone().optional()
1159
1162
  }).optional(),
1160
- rewards: e.array(hn).optional(),
1163
+ rewards: e.array(wn).optional(),
1161
1164
  scan: e.bool().optional()
1162
- }), Vn = e.object({
1165
+ }), Rn = e.object({
1163
1166
  reward_id: e.number(),
1164
1167
  reward_status: E
1165
- }), Rn = e.guard(tn), jn = e.guard(kn), x = o({ count: e.number() }), Tn = o({ first_visit: e.bool() }), qn = o({
1168
+ }), Vn = e.guard(tn), jn = e.guard(kn), x = o({ count: e.number() }), Tn = o({ first_visit: e.bool() }), qn = o({
1166
1169
  engagements: e.union(e.array(fn), e.array(_n))
1167
1170
  }), xn = o({
1168
1171
  status: e.array(vn)
@@ -1170,20 +1173,20 @@ const V = {
1170
1173
  engagements: e.array(ie),
1171
1174
  next_token: e.string().optional()
1172
1175
  }), Ln = e.guard(Cn), Pn = o({
1173
- claimed_items: e.array(Vn)
1176
+ claimed_items: e.array(Rn)
1174
1177
  }), En = o({
1175
1178
  reward_status: E
1176
- }), Un = o({
1179
+ }), $n = o({
1177
1180
  user_rewards: e.array(ne),
1178
1181
  next_token: e.string().optional()
1179
- }), $n = o({
1182
+ }), Un = o({
1180
1183
  scene: e.string()
1181
1184
  }), Fn = o({
1182
1185
  params: e.string()
1183
1186
  }), Dn = o({
1184
1187
  img: e.string()
1185
1188
  });
1186
- class xr {
1189
+ class qr {
1187
1190
  constructor(t, n) {
1188
1191
  l(this, "token");
1189
1192
  l(this, "event", 0);
@@ -1207,7 +1210,7 @@ class xr {
1207
1210
  * https://kdocs.cn/l/ckWFDcOsYEUA?linkname=wFXxtdNKPm
1208
1211
  */
1209
1212
  async getConfig() {
1210
- const { data: t } = await this.req.get(`event/${this.event}/event-config`, Rn);
1213
+ const { data: t } = await this.req.get(`event/${this.event}/event-config`, Vn);
1211
1214
  return t;
1212
1215
  }
1213
1216
  /**
@@ -1362,7 +1365,7 @@ class xr {
1362
1365
  const { data: n } = await this.req.post(
1363
1366
  "event/user-rewards",
1364
1367
  a({ max_results: 20, ...t, event_id: this.event }),
1365
- Un
1368
+ $n
1366
1369
  );
1367
1370
  return {
1368
1371
  user_rewards: ((n == null ? void 0 : n.user_rewards) || []).map((r) => (r.reward_status = r.reward_status === _.UnclaimedErr ? _.Unclaimed : r.reward_status, r)),
@@ -1400,7 +1403,7 @@ class xr {
1400
1403
  */
1401
1404
  async getUnlimitQrcodeScene(t) {
1402
1405
  if (!await this.token.autoLogin()) return null;
1403
- const { data: n } = await this.req.get("event/unlimit-qrcode-scene", $n, {
1406
+ const { data: n } = await this.req.get("event/unlimit-qrcode-scene", Un, {
1404
1407
  params: { params: t }
1405
1408
  });
1406
1409
  return (n == null ? void 0 : n.scene) ?? null;
@@ -1434,7 +1437,7 @@ const In = {
1434
1437
  All: "all",
1435
1438
  /** 指定用户可发帖 */
1436
1439
  Limit: "limit"
1437
- }, Gn = e.string().enum(In).lock(), An = {
1440
+ }, Gn = e.string().enum(In).lock(), Nn = {
1438
1441
  /** 待审核(仅自己可见) */
1439
1442
  Pending: "pending",
1440
1443
  /** 审核通过 */
@@ -1443,14 +1446,14 @@ const In = {
1443
1446
  Failed: "failed",
1444
1447
  /** 嫌疑(仅自己可见) */
1445
1448
  Suspect: "suspect"
1446
- }, oe = e.string().enum(An).lock(), On = {
1449
+ }, oe = e.string().enum(Nn).lock(), An = {
1447
1450
  /** 系统通知 */
1448
1451
  System: "system",
1449
1452
  /** 评论我的 */
1450
1453
  Comment: "comment",
1451
1454
  /** 点赞通知 */
1452
1455
  Like: "like"
1453
- }, Sr = e.string().enum(On).lock(), m = {
1456
+ }, xr = e.string().enum(An).lock(), m = {
1454
1457
  /** 系统通知 */
1455
1458
  System: "system",
1456
1459
  /** 帖子被置顶 */
@@ -1475,7 +1478,7 @@ const In = {
1475
1478
  ReplyLiked: "reply_liked",
1476
1479
  /** 回复被删除 */
1477
1480
  ReplyDeleted: "reply_deleted"
1478
- }, Nn = e.string().enum(m).lock(), ae = e.object({
1481
+ }, On = e.string().enum(m).lock(), ae = e.object({
1479
1482
  forum_id: e.number(),
1480
1483
  icon_url: e.string(),
1481
1484
  name: e.string(),
@@ -1517,7 +1520,7 @@ const In = {
1517
1520
  replied_by: e.string(),
1518
1521
  nickname: e.string(),
1519
1522
  avatar_url: e.string()
1520
- }).lock(), R = e.object({
1523
+ }).lock(), V = e.object({
1521
1524
  reply_id: e.number(),
1522
1525
  comment_id: e.number(),
1523
1526
  comment_content: e.string().optional(),
@@ -1551,14 +1554,14 @@ const In = {
1551
1554
  image_url: e.string(),
1552
1555
  create_time: e.number(),
1553
1556
  status: oe,
1554
- replies: e.array(R).optional()
1557
+ replies: e.array(V).optional()
1555
1558
  }).lock(), Qn = e.object({
1556
1559
  image_url: e.string(),
1557
1560
  upload_url: e.string(),
1558
1561
  existed: e.bool()
1559
1562
  }).lock(), y = e.object({
1560
1563
  notification_id: e.string(),
1561
- notification_type: Nn,
1564
+ notification_type: On,
1562
1565
  is_read: e.bool(),
1563
1566
  create_time: e.number(),
1564
1567
  origin_user_id: e.string(),
@@ -1630,10 +1633,10 @@ const In = {
1630
1633
  posts: e.array(D),
1631
1634
  next_token: e.string().optional()
1632
1635
  }), ir = o({ post: D, antispam: se }), or = o({
1633
- replies: e.array(R),
1636
+ replies: e.array(V),
1634
1637
  next_token: e.string().optional()
1635
- }), ar = o({ reply: R }), sr = o({
1636
- reply: R.clone().optional(),
1638
+ }), ar = o({ reply: V }), sr = o({
1639
+ reply: V.clone().optional(),
1637
1640
  antispam: se.clone().optional()
1638
1641
  }), cr = o({ comment: k }), ur = o({
1639
1642
  comments: e.array(k),
@@ -1649,7 +1652,7 @@ const In = {
1649
1652
  comment: e.number(),
1650
1653
  like: e.number()
1651
1654
  });
1652
- class Lr {
1655
+ class Sr {
1653
1656
  constructor(t) {
1654
1657
  l(this, "token");
1655
1658
  l(this, "req");
@@ -1877,7 +1880,7 @@ function S(i) {
1877
1880
  return v(i, "open_id", "union_id", "weixin_token");
1878
1881
  }
1879
1882
  const H = "wx_login_cache";
1880
- class Pr {
1883
+ class Lr {
1881
1884
  /**
1882
1885
  * 创建微信相关功能接口
1883
1886
  *
@@ -1893,9 +1896,12 @@ class Pr {
1893
1896
  */
1894
1897
  constructor(t, n) {
1895
1898
  l(this, "token");
1896
- l(this, "appid");
1899
+ l(this, "$appid");
1897
1900
  l(this, "req");
1898
- this.token = t, this.req = t.req, this.appid = n, this.getLoginCache();
1901
+ this.token = t, this.req = t.req, this.$appid = n, this.getLoginCache();
1902
+ }
1903
+ get appid() {
1904
+ return this.$appid;
1899
1905
  }
1900
1906
  /**
1901
1907
  * 检查缓存中的登录数据
@@ -1934,7 +1940,7 @@ class Pr {
1934
1940
  const t = await this.getLoginCache();
1935
1941
  if (t)
1936
1942
  return t;
1937
- const n = await we(), { data: r, code: s } = await this.req.post(
1943
+ const n = await he(), { data: r, code: s } = await this.req.post(
1938
1944
  "weixin/login",
1939
1945
  { code: n, appid: this.appid },
1940
1946
  S,
@@ -1961,7 +1967,7 @@ class Pr {
1961
1967
  async webLogin(t = "snsapi_userinfo") {
1962
1968
  const n = L("code"), r = Date.now(), s = +L("state");
1963
1969
  if (!n || !s || s < r - 1e3 * 60 * 5 || s > r) {
1964
- const ue = A(["code", "state"]);
1970
+ const ue = N(["code", "state"]);
1965
1971
  location.replace(
1966
1972
  `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${this.appid}&redirect_uri=${encodeURIComponent(ue)}&response_type=code&scope=${t}&state=${r}#wechat_redirect`
1967
1973
  );
@@ -1969,7 +1975,7 @@ class Pr {
1969
1975
  }
1970
1976
  if (/^100\d{2}$/.test(n))
1971
1977
  return { error: n };
1972
- const d = A(["code", "state"]);
1978
+ const d = N(["code", "state"]);
1973
1979
  "replaceState" in history && history.replaceState({}, "", d);
1974
1980
  const { data: p, code: ce } = await this.req.post(
1975
1981
  "weixin/login",
@@ -2024,15 +2030,15 @@ export {
2024
2030
  nn as CashbackEngagementDataValidator,
2025
2031
  _ as ClaimRewardStatus,
2026
2032
  E as ClaimRewardStatusValidator,
2027
- Vn as ClaimedItemValidator,
2033
+ Rn as ClaimedItemValidator,
2028
2034
  K as ClubAddressValidator,
2029
- vr as ClubApi,
2035
+ kr as ClubApi,
2030
2036
  X as ClubBenefitSummaryValidator,
2031
2037
  Ge as ClubBenefitValidator,
2032
2038
  je as ClubCreditChangeScene,
2033
2039
  Te as ClubCreditChangeSceneValidator,
2034
- Ve as ClubCreditChangeType,
2035
- Re as ClubCreditChangeTypeValidator,
2040
+ Re as ClubCreditChangeType,
2041
+ Ve as ClubCreditChangeTypeValidator,
2036
2042
  Ie as ClubCreditLogValidator,
2037
2043
  Le as ClubGlobalConfigValidator,
2038
2044
  qe as ClubItemType,
@@ -2045,26 +2051,26 @@ export {
2045
2051
  Fe as ClubUserProfileValidator,
2046
2052
  fn as CommentEngagementValidator,
2047
2053
  k as CommentValidator,
2048
- Lr as CommunityApi,
2054
+ Sr as CommunityApi,
2049
2055
  Ze as EngageAccountType,
2050
2056
  We as EngageAccountTypeValidator,
2051
2057
  Cn as EngageResponseValidator,
2052
- hn as EngageRewardValidator,
2053
- xr as EventApi,
2058
+ wn as EngageRewardValidator,
2059
+ qr as EventApi,
2054
2060
  tn as EventConfigValidator,
2055
2061
  _t as EventFeatureConfigOfCashbackValidator,
2056
2062
  yt as EventFeatureConfigOfCheckInValidator,
2057
- wt as EventFeatureConfigOfClaimRewardsValidator,
2063
+ ht as EventFeatureConfigOfClaimRewardsValidator,
2058
2064
  kt as EventFeatureConfigOfCommentValidator,
2059
2065
  Ct as EventFeatureConfigOfFollowValidator,
2060
2066
  jt as EventFeatureConfigOfGiftCodeValidator,
2061
2067
  qt as EventFeatureConfigOfInviteValidator,
2062
2068
  St as EventFeatureConfigOfInvitedRegisterValidator,
2063
2069
  Ft as EventFeatureConfigOfLotteryDrawValidator,
2064
- Ut as EventFeatureConfigOfLotteryValidator,
2070
+ $t as EventFeatureConfigOfLotteryValidator,
2065
2071
  It as EventFeatureConfigOfPreregisterValidator,
2066
- At as EventFeatureConfigOfQuestValidator,
2067
- Nt as EventFeatureConfigOfRegisterValidator,
2072
+ Nt as EventFeatureConfigOfQuestValidator,
2073
+ Ot as EventFeatureConfigOfRegisterValidator,
2068
2074
  Qt as EventFeatureConfigOfShareValidator,
2069
2075
  Ht as EventFeatureConfigOfSubscribeValidator,
2070
2076
  Jt as EventFeatureConfigOfSurveyValidator,
@@ -2073,30 +2079,30 @@ export {
2073
2079
  en as EventFeatureConfigValidator,
2074
2080
  et as EventPeriodType,
2075
2081
  tt as EventPeriodTypeValidator,
2076
- $ as EventRewardItemConfigValidator,
2077
- Oe as ExtraGameRewardValidator,
2078
- Ae as ExtraPhysicalShipmentValidator,
2082
+ U as EventRewardItemConfigValidator,
2083
+ Ae as ExtraGameRewardValidator,
2084
+ Ne as ExtraPhysicalShipmentValidator,
2079
2085
  gt as FeatureRewardValidator,
2080
2086
  c as FeatureType,
2081
2087
  nt as FeatureTypeValidator,
2082
2088
  In as ForumMode,
2083
2089
  Gn as ForumModeValidator,
2084
2090
  ae as ForumValidator,
2085
- V as GamerItemType,
2091
+ R as GamerItemType,
2086
2092
  Z as GamerItemTypeValidator,
2087
2093
  ve as Gender,
2088
2094
  Ce as GenderValidator,
2089
2095
  rn as GiftCodeEngagementDataValidator,
2090
2096
  on as InviteEngagementDataValidator,
2091
2097
  lt as LotteryDrawAction,
2092
- Tr as LotteryDrawActionValidator,
2098
+ jr as LotteryDrawActionValidator,
2093
2099
  un as LotteryDrawEngagementDataValidator,
2094
2100
  an as LotteryEngagementDataValidator,
2095
- h as LotteryTicketStatus,
2101
+ w as LotteryTicketStatus,
2096
2102
  Rr as LotteryTicketStatusValidator,
2097
2103
  y as NotificationBaseValidator,
2098
- On as NotificationCategory,
2099
- Sr as NotificationCategoryValidator,
2104
+ An as NotificationCategory,
2105
+ xr as NotificationCategoryValidator,
2100
2106
  Kn as NotificationCommentReplyValidator,
2101
2107
  Xn as NotificationCommentValidator,
2102
2108
  j as NotificationPayloadCommentValidator,
@@ -2109,11 +2115,11 @@ export {
2109
2115
  Zn as NotificationReplyValidator,
2110
2116
  Hn as NotificationSystemValidator,
2111
2117
  m as NotificationType,
2112
- Nn as NotificationTypeValidator,
2118
+ On as NotificationTypeValidator,
2113
2119
  Wn as NotificationValidator,
2114
- $e as PlayerRoleCardValidator,
2120
+ Ue as PlayerRoleCardValidator,
2115
2121
  J as PlayerRoleValidator,
2116
- An as PostStatus,
2122
+ Nn as PostStatus,
2117
2123
  oe as PostStatusValidator,
2118
2124
  D as PostValidator,
2119
2125
  ln as PreregisterEngagementDataValidator,
@@ -2121,29 +2127,29 @@ export {
2121
2127
  mn as QuestEngagementDataValidator,
2122
2128
  rt as QuestObjective,
2123
2129
  ee as QuestObjectiveValidator,
2124
- kr as RedeemParamsValidator,
2125
- Ne as RedemptionValidator,
2130
+ wr as RedeemParamsValidator,
2131
+ Oe as RedemptionValidator,
2126
2132
  dt as RegularRewardValidator,
2127
2133
  Bn as ReplyToValidator,
2128
- R as ReplyValidator,
2129
- Cr as RewardItemType,
2134
+ V as ReplyValidator,
2135
+ vr as RewardItemType,
2130
2136
  W as RewardItemTypeValidator,
2131
2137
  at as RewardSource,
2132
- U as RewardSourceValidator,
2138
+ $ as RewardSourceValidator,
2133
2139
  g as RewardStatus,
2134
2140
  P as RewardStatusSuffix,
2135
2141
  te as RewardStatusSuffixValidator,
2136
- Vr as RewardStatusValidator,
2137
- wn as RewardValidator,
2138
- Ue as RoleBaseInfoValidator,
2142
+ Cr as RewardStatusValidator,
2143
+ hn as RewardValidator,
2144
+ $e as RoleBaseInfoValidator,
2139
2145
  Ee as ServerBaseInfoValidator,
2140
2146
  dn as ShareEngagementDataValidator,
2141
2147
  pn as SurveyEngagementDataValidator,
2142
2148
  ut as TeamAction,
2143
- jr as TeamActionValidator,
2149
+ Vr as TeamActionValidator,
2144
2150
  bn as TeamEngagementDataValidator,
2145
2151
  _n as TeamEngagementValidator,
2146
- qr as TeamMemberValidator,
2152
+ Tr as TeamMemberValidator,
2147
2153
  st as TeamVisibility,
2148
2154
  ct as TeamVisibilityValidator,
2149
2155
  F as TopicValidator,
@@ -2155,7 +2161,7 @@ export {
2155
2161
  yn as VoteEngagementDataValidator,
2156
2162
  it as VoteOptionSource,
2157
2163
  ot as VoteOptionSourceValidator,
2158
- Pr as WeixinApi,
2164
+ Lr as WeixinApi,
2159
2165
  gn as WeixinSubscribeEngagementDataValidator,
2160
2166
  _r as WeixinWebLoginErrorCode,
2161
2167
  pr as isWeixinSignResponse
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.0.14",
4
+ "version": "2.0.16",
5
5
  "type": "module",
6
6
  "source": "index.ts",
7
7
  "main": "./dist/index.js",
@@ -22,17 +22,16 @@
22
22
  "license": "MIT",
23
23
  "devDependencies": {
24
24
  "@types/node": "^22.13.1",
25
- "vitest": "^3.0.5",
26
25
  "@seayoo-web/combo-webview": "^2.5.3",
26
+ "@seayoo-web/tsconfig": "^1.0.3",
27
27
  "@seayoo-web/request": "^3.0.3",
28
28
  "@seayoo-web/utils": "^3.4.4",
29
- "@seayoo-web/scripts": "^2.0.3",
30
- "@seayoo-web/tsconfig": "^1.0.3"
29
+ "@seayoo-web/scripts": "^2.0.12"
31
30
  },
32
31
  "peerDependencies": {
33
32
  "@seayoo-web/combo-webview": "^2.5.3",
34
- "@seayoo-web/utils": "^3.4.4",
35
- "@seayoo-web/request": "^3.0.3"
33
+ "@seayoo-web/request": "^3.0.3",
34
+ "@seayoo-web/utils": "^3.4.4"
36
35
  },
37
36
  "scripts": {
38
37
  "prebuild": "pnpm -F request build && pnpm -F combo-webview build",
@@ -1,8 +1,8 @@
1
- import { type RequestInternalError } from "@seayoo-web/request";
2
1
  import { type SomePartial } from "@seayoo-web/utils";
3
2
  import type { ClubAddress, ClubUserProfile, RedeemParams } from "./club.define";
4
3
  import type { ClubCreditChangeType, ClubItemType } from "./club.enums";
5
4
  import type { AuthToken } from "./token";
5
+ import type { RequestInternalError } from "@seayoo-web/request";
6
6
  export * from "./club.enums";
7
7
  export * from "./club.define";
8
8
  export declare class ClubApi {
@@ -1,6 +1,6 @@
1
1
  import { type InferType } from "@seayoo-web/utils";
2
2
  import { type EventFeatureBaseConfig } from "./feature.base";
3
- declare const rewardItemTypeValidator: import("@seayoo-web/utils").StringValidator<"event_item" | "game_item" | "physical_item" | "weixin_hongbao" | "credit" | "external_gift_code" | "void_item", false, false>;
3
+ declare const rewardItemTypeValidator: import("@seayoo-web/utils").StringValidator<"credit" | "event_item" | "game_item" | "physical_item" | "weixin_hongbao" | "external_gift_code" | "void_item", false, false>;
4
4
  declare const featureType: "lottery";
5
5
  export interface FeatureLotteryItemConfig {
6
6
  /** 抽奖奖励道具 id */
@@ -1,5 +1,5 @@
1
1
  import { type InferType } from "@seayoo-web/utils";
2
- declare const rewardItemTypeValidator: import("@seayoo-web/utils").StringValidator<"event_item" | "game_item" | "physical_item" | "weixin_hongbao" | "credit" | "external_gift_code" | "void_item", false, false>;
2
+ declare const rewardItemTypeValidator: import("@seayoo-web/utils").StringValidator<"credit" | "event_item" | "game_item" | "physical_item" | "weixin_hongbao" | "external_gift_code" | "void_item", false, false>;
3
3
  export interface EventRewardItemConfig {
4
4
  /** 玩法奖励道具 id */
5
5
  reward_item_id: number;
@@ -11,6 +11,7 @@ export * from "./token.define";
11
11
  * - [Weixin Token](https://kdocs.cn/l/cf2mO2uRLqh9?linkname=YtzQpmRQ0v)
12
12
  */
13
13
  export declare class AuthToken {
14
+ private $NetRequest;
14
15
  private $idToken;
15
16
  private $weixinToken;
16
17
  private $gamerToken;
@@ -25,6 +26,7 @@ export declare class AuthToken {
25
26
  endpoint: string,
26
27
  /** request 工具类 */
27
28
  NetRequest: NetRequestFactory);
29
+ get NetRequest(): typeof import("@seayoo-web/request").NetRequest;
28
30
  private loadGamerTokenCache;
29
31
  /** 当前是否为登录状态,即是否拥有 gamerToken */
30
32
  get isLoggedIn(): boolean;
@@ -4,7 +4,7 @@ import type { RequestInternalError } from "@seayoo-web/request";
4
4
  export * from "./weixin.define";
5
5
  export declare class WeixinApi {
6
6
  private token;
7
- private appid;
7
+ private $appid;
8
8
  private req;
9
9
  /**
10
10
  * 创建微信相关功能接口
@@ -20,6 +20,7 @@ export declare class WeixinApi {
20
20
  * https://developers.weixin.qq.com/miniprogram/dev/api/open-api/account-info/wx.getAccountInfoSync.html
21
21
  */
22
22
  constructor(authToken: AuthToken, appid: string);
23
+ get appid(): string;
23
24
  /**
24
25
  * 检查缓存中的登录数据
25
26
  *