@seayoo-web/gamer-api 2.2.0 → 2.2.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.
Files changed (2) hide show
  1. package/dist/index.js +52 -52
  2. package/package.json +3 -4
package/dist/index.js CHANGED
@@ -2,12 +2,12 @@ var ue = Object.defineProperty;
2
2
  var le = (i, t, n) => t in i ? ue(i, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : i[t] = n;
3
3
  var l = (i, t, n) => le(i, typeof t != "symbol" ? t + "" : t, n);
4
4
  import { isComboWebView as me } from "@seayoo-web/combo-webview";
5
- import { isPlainObject as v, useConsole as de, Support as b, usePromise as ge, pruneURL as pe, queryString as L, pruneObject as a, v as e, omitFields as C, typedObjectGuard as o, parseJSON as _e, removePara as N } from "@seayoo-web/utils";
5
+ import { isPlainObject as C, useConsole as de, Support as b, usePromise as ge, pruneURL as pe, queryString as w, pruneObject as a, v as e, omitFields as R, typedObjectGuard as o, parseJSON as _e, removePara as N } from "@seayoo-web/utils";
6
6
  function be(i) {
7
- return v(i, "gamer_token") && typeof i.gamer_token == "string";
7
+ return C(i, "gamer_token") && typeof i.gamer_token == "string";
8
8
  }
9
9
  function O(i) {
10
- return v(i);
10
+ return C(i);
11
11
  }
12
12
  const f = de("GamerApiSDK");
13
13
  function ye(i) {
@@ -88,7 +88,7 @@ class vr {
88
88
  requestTransformer: (s) => {
89
89
  this.$gamerToken && (s.headers.Authorization = `Bearer ${this.$gamerToken}`);
90
90
  }
91
- }), me() ? this.$gamerToken = L("gamer_token") : this.loadGamerTokenCache();
91
+ }), me() || w("debug") === "yes" ? this.$gamerToken = w("gamer_token") : this.loadGamerTokenCache();
92
92
  }
93
93
  get NetRequest() {
94
94
  return this.$NetRequest;
@@ -360,7 +360,7 @@ const ke = {
360
360
  updated_at: e.number(),
361
361
  redeemable_quantity: e.number().optional()
362
362
  }).lock(), Ie = e.object({
363
- ...C(Y.shape, "tag"),
363
+ ...R(Y.shape, "tag"),
364
364
  product: Z.clone().optional()
365
365
  }).lock(), Cr = e.union(
366
366
  e.object({
@@ -397,7 +397,7 @@ const ke = {
397
397
  status: xe,
398
398
  created_at: e.number(),
399
399
  extra_data: e.union(Ge.clone(), Ae.clone()).satisfies().optional()
400
- }), Oe = e.guard(Se), B = o({ player: Le }), Be = o({ roles: e.array(J) }), T = o({ role_card: $e }), M = e.guard(Ue), Q = e.guard(X), Me = o({ addresses: e.array(X) }), Qe = e.guard(Fe), Ke = o({
400
+ }), Oe = e.guard(Se), B = o({ player: Le }), Be = o({ roles: e.array(J) }), q = o({ role_card: $e }), M = e.guard(Ue), Q = e.guard(X), Me = o({ addresses: e.array(X) }), Qe = e.guard(Fe), Ke = o({
401
401
  credit_logs: e.array(De),
402
402
  next_token: e.string().optional()
403
403
  }), He = o({ products: e.array(Z) }), ze = o({ benefits: e.array(Y) }), Je = o({ benefit: Ie }), Xe = o({
@@ -465,7 +465,7 @@ class Rr {
465
465
  * https://kdocs.cn/l/cgp4gSBMbOf1?linkname=A1Wr7kUXnS
466
466
  */
467
467
  async getRoleCard(t) {
468
- const { data: n } = await this.req.get("club/role-card", T, {
468
+ const { data: n } = await this.req.get("club/role-card", q, {
469
469
  params: { member_id: t }
470
470
  });
471
471
  return (n == null ? void 0 : n.role_card) ?? null;
@@ -477,7 +477,7 @@ class Rr {
477
477
  */
478
478
  async setRoleCard(t) {
479
479
  if (!await this.token.autoLogin()) return null;
480
- const { data: n } = await this.req.post("club/role-card", t, T);
480
+ const { data: n } = await this.req.post("club/role-card", t, q);
481
481
  return (n == null ? void 0 : n.role_card) ?? null;
482
482
  }
483
483
  /**
@@ -487,7 +487,7 @@ class Rr {
487
487
  */
488
488
  async refreshRoleCard() {
489
489
  if (!await this.token.autoLogin()) return null;
490
- const { data: t } = await this.req.post("club/refresh-role-card", {}, T);
490
+ const { data: t } = await this.req.post("club/refresh-role-card", {}, q);
491
491
  return (t == null ? void 0 : t.role_card) ?? null;
492
492
  }
493
493
  /**
@@ -633,7 +633,7 @@ class Rr {
633
633
  return { redemptions: (n == null ? void 0 : n.redemptions) || [], next_token: n == null ? void 0 : n.next_token };
634
634
  }
635
635
  }
636
- const R = {
636
+ const V = {
637
637
  /** 活动道具 */
638
638
  EventItem: "event_item",
639
639
  /** 游戏内道具 */
@@ -652,7 +652,7 @@ const R = {
652
652
  ExternalCode: "external_gift_code",
653
653
  /** 空奖励 */
654
654
  VoidItem: "void_item"
655
- }, W = e.string().enum(R).lock(), Vr = R, ee = W, Ye = {
655
+ }, W = e.string().enum(V).lock(), Vr = V, ee = W, Ye = {
656
656
  /** 世游通行证 ID / Combo ID */
657
657
  UserId: "user_id",
658
658
  /** 游戏角色 ID */
@@ -776,7 +776,7 @@ const R = {
776
776
  Private: "private",
777
777
  /** 公开队伍 */
778
778
  Public: "public"
779
- }, st = e.string().enum(at).lock(), w = {
779
+ }, st = e.string().enum(at).lock(), k = {
780
780
  /** 未知状态 */
781
781
  Unknown: "unknown",
782
782
  /** 等待开奖 */
@@ -787,7 +787,7 @@ const R = {
787
787
  Claimed: "claimed",
788
788
  /** 领奖失败 */
789
789
  Fail: "fail"
790
- }, Tr = e.string().enum(w).lock(), ct = {
790
+ }, Tr = e.string().enum(k).lock(), ct = {
791
791
  /** 发起组队 */
792
792
  Assemble: "assemble",
793
793
  /** 加入队伍 */
@@ -805,7 +805,7 @@ const R = {
805
805
  Draw: "draw",
806
806
  /** 领奖 */
807
807
  Claim: "claim"
808
- }, xr = e.string().enum(ut).lock(), lt = e.string().enum(C(R, "GiftCode", "LotteryTicket")), U = e.object({
808
+ }, xr = e.string().enum(ut).lock(), lt = e.string().enum(R(V, "GiftCode", "LotteryTicket")), U = e.object({
809
809
  reward_item_id: e.number(),
810
810
  reward_amount: e.number(),
811
811
  reward_item_name: e.string(),
@@ -891,7 +891,7 @@ const R = {
891
891
  }), St = c.InvitedRegister, Lt = e.object({
892
892
  ...u.shape,
893
893
  feature_type: e.string().enum(St)
894
- }), Pt = e.string().enum(C(R, "GiftCode", "LotteryTicket")), Et = c.Lottery, $t = e.object({
894
+ }), Pt = e.string().enum(R(V, "GiftCode", "LotteryTicket")), Et = c.Lottery, $t = e.object({
895
895
  reward_item_id: e.number(),
896
896
  reward_item_name: e.string(),
897
897
  reward_item_type: Pt,
@@ -1015,10 +1015,10 @@ const R = {
1015
1015
  until: e.number(),
1016
1016
  visit_count: e.number().optional(),
1017
1017
  features: e.array(tn)
1018
- }).lock(), q = e.union(e.string().pattern("NumberString", /^\d+$/), e.number()), rn = e.object({
1019
- order_total_amount: q,
1020
- cashback_total_amount: q,
1021
- game_item_count: q
1018
+ }).lock(), x = e.union(e.string().pattern("NumberString", /^\d+$/), e.number()), rn = e.object({
1019
+ order_total_amount: x,
1020
+ cashback_total_amount: x,
1021
+ game_item_count: x
1022
1022
  }), on = e.object({
1023
1023
  activation_key: e.string().disallow("")
1024
1024
  }), an = e.object({
@@ -1049,14 +1049,14 @@ const R = {
1049
1049
  // https://kdocs.cn/l/ckWFDcOsYEUA?linkname=merUzJsVYH
1050
1050
  // 后续会格式化为具体的类型,此处的校验需要对应增加
1051
1051
  extra_data: e.record(e.unknown()).optional()
1052
- }), un = e.string().enum(w.Unknown, w.Pending), ln = e.union(
1052
+ }), un = e.string().enum(k.Unknown, k.Pending), ln = e.union(
1053
1053
  e.object({
1054
1054
  ticket: e.string(),
1055
1055
  status: un
1056
1056
  }),
1057
1057
  e.object({
1058
1058
  ticket: e.string(),
1059
- status: e.string().enum(C(w, "Unknown", "Pending")),
1059
+ status: e.string().enum(R(k, "Unknown", "Pending")),
1060
1060
  reward: re
1061
1061
  })
1062
1062
  ).satisfies(), mn = e.object({
@@ -1129,7 +1129,7 @@ const R = {
1129
1129
  on,
1130
1130
  e.custom(
1131
1131
  "EmptyObject",
1132
- (i) => v(i) && Object.keys(i).length === 0
1132
+ (i) => C(i) && Object.keys(i).length === 0
1133
1133
  )
1134
1134
  ).satisfies().lock(), kn = e.object({
1135
1135
  reward_id: e.number(),
@@ -1186,7 +1186,7 @@ const R = {
1186
1186
  }), Tn = e.object({
1187
1187
  reward_id: e.number(),
1188
1188
  reward_status: E
1189
- }), qn = e.guard(nn), xn = e.guard(Rn), x = o({ count: e.number() }), Sn = o({ first_visit: e.bool() }), Ln = o({
1189
+ }), qn = e.guard(nn), xn = e.guard(Rn), S = o({ count: e.number() }), Sn = o({ first_visit: e.bool() }), Ln = o({
1190
1190
  engagements: e.union(e.array(wn), e.array(yn))
1191
1191
  }), Pn = o({
1192
1192
  status: e.array(Vn)
@@ -1240,7 +1240,7 @@ class Lr {
1240
1240
  * https://kdocs.cn/l/ckWFDcOsYEUA?linkname=ejPOcWMvT1
1241
1241
  */
1242
1242
  async getEngagementsUserCount(t) {
1243
- const { data: n } = await this.req.get(`event/${this.event}/feature-engagement-count`, x, {
1243
+ const { data: n } = await this.req.get(`event/${this.event}/feature-engagement-count`, S, {
1244
1244
  params: { feature_id: t, type: "user" }
1245
1245
  });
1246
1246
  return (n == null ? void 0 : n.count) ?? null;
@@ -1251,7 +1251,7 @@ class Lr {
1251
1251
  * https://kdocs.cn/l/ckWFDcOsYEUA?linkname=ejPOcWMvT1
1252
1252
  */
1253
1253
  async getEngagementsCount(t) {
1254
- const { data: n } = await this.req.get(`event/${this.event}/feature-engagement-count`, x, {
1254
+ const { data: n } = await this.req.get(`event/${this.event}/feature-engagement-count`, S, {
1255
1255
  params: { feature_id: t, type: "engagement" }
1256
1256
  });
1257
1257
  return (n == null ? void 0 : n.count) ?? null;
@@ -1400,7 +1400,7 @@ class Lr {
1400
1400
  */
1401
1401
  async getUserItemCount(t) {
1402
1402
  if (!await this.token.autoLogin()) return null;
1403
- const { data: n } = await this.req.get(`event/${this.event}/user-item-count`, x, {
1403
+ const { data: n } = await this.req.get(`event/${this.event}/user-item-count`, S, {
1404
1404
  params: { item_id: t }
1405
1405
  });
1406
1406
  return (n == null ? void 0 : n.count) ?? null;
@@ -1542,7 +1542,7 @@ const Nn = {
1542
1542
  replied_by: e.string(),
1543
1543
  nickname: e.string(),
1544
1544
  avatar_url: e.string()
1545
- }).lock(), V = e.object({
1545
+ }).lock(), j = e.object({
1546
1546
  reply_id: e.number(),
1547
1547
  comment_id: e.number(),
1548
1548
  comment_content: e.string().optional(),
@@ -1557,7 +1557,7 @@ const Nn = {
1557
1557
  liked: e.bool(),
1558
1558
  reply_to: Kn,
1559
1559
  create_time: e.number()
1560
- }).lock(), k = e.object({
1560
+ }).lock(), v = e.object({
1561
1561
  comment_id: e.number(),
1562
1562
  post_id: e.number(),
1563
1563
  post_subject: e.string().optional(),
@@ -1576,7 +1576,7 @@ const Nn = {
1576
1576
  image_url: e.string(),
1577
1577
  create_time: e.number(),
1578
1578
  status: ie,
1579
- replies: e.array(V).optional()
1579
+ replies: e.array(j).optional()
1580
1580
  }).lock(), Hn = e.object({
1581
1581
  image_url: e.string(),
1582
1582
  upload_url: e.string(),
@@ -1597,7 +1597,7 @@ const Nn = {
1597
1597
  post_subject: e.string(),
1598
1598
  post_summary: e.string(),
1599
1599
  post_image_url: e.string()
1600
- }).lock(), j = e.object({
1600
+ }).lock(), T = e.object({
1601
1601
  comment_id: e.number(),
1602
1602
  comment_content: e.string()
1603
1603
  }).lock(), A = e.object({
@@ -1619,16 +1619,16 @@ const Nn = {
1619
1619
  }), Yn = e.object({
1620
1620
  ...y.shape,
1621
1621
  ...G.shape,
1622
- ...j.shape,
1622
+ ...T.shape,
1623
1623
  notification_type: e.string().enum(m.PostCommented)
1624
1624
  }), Zn = e.object({
1625
1625
  ...y.shape,
1626
- ...j.shape,
1626
+ ...T.shape,
1627
1627
  ...A.shape,
1628
1628
  notification_type: e.string().enum(m.CommentReplied)
1629
1629
  }), Wn = e.object({
1630
1630
  ...y.shape,
1631
- ...j.shape,
1631
+ ...T.shape,
1632
1632
  ...G.shape,
1633
1633
  notification_type: e.string().enum(m.CommentLiked, m.CommentDeleted)
1634
1634
  }), er = e.object({
@@ -1641,7 +1641,7 @@ const Nn = {
1641
1641
  }), tr = e.object({
1642
1642
  ...y.shape,
1643
1643
  ...A.shape,
1644
- ...j.shape,
1644
+ ...T.shape,
1645
1645
  notification_type: e.string().enum(m.ReplyLiked, m.ReplyDeleted)
1646
1646
  }), nr = e.union(
1647
1647
  Jn,
@@ -1655,17 +1655,17 @@ const Nn = {
1655
1655
  posts: e.array(I),
1656
1656
  next_token: e.string().optional()
1657
1657
  }), sr = o({ post: I, antispam: ae }), cr = o({
1658
- replies: e.array(V),
1658
+ replies: e.array(j),
1659
1659
  next_token: e.string().optional()
1660
- }), ur = o({ reply: V }), lr = o({
1661
- reply: V.clone().optional(),
1660
+ }), ur = o({ reply: j }), lr = o({
1661
+ reply: j.clone().optional(),
1662
1662
  antispam: ae.clone().optional()
1663
- }), mr = o({ comment: k }), dr = o({
1664
- comments: e.array(k),
1663
+ }), mr = o({ comment: v }), dr = o({
1664
+ comments: e.array(v),
1665
1665
  next_token: e.string().optional()
1666
1666
  }), gr = o({
1667
- comment: k.clone().optional(),
1668
- antispam: k.clone().optional()
1667
+ comment: v.clone().optional(),
1668
+ antispam: v.clone().optional()
1669
1669
  }), pr = e.guard(Hn), _r = o({
1670
1670
  notifications: e.array(nr),
1671
1671
  next_token: e.string().optional()
@@ -1898,8 +1898,8 @@ const yr = o({
1898
1898
  signature: e.string()
1899
1899
  });
1900
1900
  var fr = /* @__PURE__ */ ((i) => (i.RedirectUriDisMatch = "10003", i.AppidError = "10016", i.AuthorizationError = "10015", i.NoRightForScope = "10005", i.Frequently = "10009", i.AppBanded = "10004", i.ShouldFollow = "10006", i.ScopeNull = "10010", i.RedirectUriNull = "10011", i.AppidNull = "10012", i.StateNull = "10013", i))(fr || {});
1901
- function S(i) {
1902
- return v(i, "open_id", "union_id", "weixin_token");
1901
+ function L(i) {
1902
+ return C(i, "open_id", "union_id", "weixin_token");
1903
1903
  }
1904
1904
  const H = "wx_login_cache";
1905
1905
  class $r {
@@ -1937,7 +1937,7 @@ class $r {
1937
1937
  if (!t)
1938
1938
  return null;
1939
1939
  const n = _e(t);
1940
- return S(n) ? (this.token.weixinToken = n.weixin_token, await this.token.autoLogin(), n) : null;
1940
+ return L(n) ? (this.token.weixinToken = n.weixin_token, await this.token.autoLogin(), n) : null;
1941
1941
  }
1942
1942
  /**
1943
1943
  * 小程序页面微信静默登录,获取 weixinToken / open_id / union_id。
@@ -1965,7 +1965,7 @@ class $r {
1965
1965
  const n = await fe(), { data: r, code: s } = await this.req.post(
1966
1966
  "weixin/login",
1967
1967
  { code: n, appid: this.appid },
1968
- S,
1968
+ L,
1969
1969
  { message: !1 }
1970
1970
  );
1971
1971
  return r && (this.token.weixinToken = r.weixin_token, this.token.storage.set(H, JSON.stringify(r)), await this.token.autoLogin()), r ?? { error: s };
@@ -1987,7 +1987,7 @@ class $r {
1987
1987
  * - snsapi_userinfo 【默认】弹出授权页面,可拿到 openid、union_id、昵称、头像等信息,但用户也可能会拒绝授权
1988
1988
  */
1989
1989
  async webLogin(t = "snsapi_userinfo") {
1990
- const n = L("code"), r = Date.now(), s = +L("state");
1990
+ const n = w("code"), r = Date.now(), s = +w("state");
1991
1991
  if (!n || !s || s < r - 1e3 * 60 * 5 || s > r) {
1992
1992
  const ce = N(["code", "state"]);
1993
1993
  location.replace(
@@ -2005,7 +2005,7 @@ class $r {
2005
2005
  code: n,
2006
2006
  appid: this.appid
2007
2007
  },
2008
- S
2008
+ L
2009
2009
  );
2010
2010
  return p && (this.token.weixinToken = p.weixin_token, await this.token.autoLogin()), p ?? { error: se };
2011
2011
  }
@@ -2073,7 +2073,7 @@ export {
2073
2073
  Fe as ClubUserCreditValidator,
2074
2074
  Ue as ClubUserProfileValidator,
2075
2075
  wn as CommentEngagementValidator,
2076
- k as CommentValidator,
2076
+ v as CommentValidator,
2077
2077
  Er as CommunityApi,
2078
2078
  Ye as EngageAccountType,
2079
2079
  Ze as EngageAccountTypeValidator,
@@ -2112,7 +2112,7 @@ export {
2112
2112
  Nn as ForumMode,
2113
2113
  On as ForumModeValidator,
2114
2114
  oe as ForumValidator,
2115
- R as GamerItemType,
2115
+ V as GamerItemType,
2116
2116
  W as GamerItemTypeValidator,
2117
2117
  ke as Gender,
2118
2118
  ve as GenderValidator,
@@ -2122,14 +2122,14 @@ export {
2122
2122
  xr as LotteryDrawActionValidator,
2123
2123
  mn as LotteryDrawEngagementDataValidator,
2124
2124
  cn as LotteryEngagementDataValidator,
2125
- w as LotteryTicketStatus,
2125
+ k as LotteryTicketStatus,
2126
2126
  Tr as LotteryTicketStatusValidator,
2127
2127
  y as NotificationBaseValidator,
2128
2128
  Mn as NotificationCategory,
2129
2129
  Pr as NotificationCategoryValidator,
2130
2130
  Zn as NotificationCommentReplyValidator,
2131
2131
  Wn as NotificationCommentValidator,
2132
- j as NotificationPayloadCommentValidator,
2132
+ T as NotificationPayloadCommentValidator,
2133
2133
  G as NotificationPayloadPostValidator,
2134
2134
  A as NotificationPayloadReplyValidator,
2135
2135
  zn as NotificationPayloadSystemValidator,
@@ -2155,7 +2155,7 @@ export {
2155
2155
  Ne as RedemptionValidator,
2156
2156
  mt as RegularRewardValidator,
2157
2157
  Kn as ReplyToValidator,
2158
- V as ReplyValidator,
2158
+ j as ReplyValidator,
2159
2159
  Vr as RewardItemType,
2160
2160
  ee as RewardItemTypeValidator,
2161
2161
  ot as RewardSource,
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.2.0",
4
+ "version": "2.2.1",
5
5
  "type": "module",
6
6
  "source": "index.ts",
7
7
  "main": "./dist/index.js",
@@ -25,9 +25,9 @@
25
25
  "@types/node": "^22.13.1",
26
26
  "@seayoo-web/combo-webview": "^2.5.4",
27
27
  "@seayoo-web/request": "^3.1.5",
28
+ "@seayoo-web/tsconfig": "^1.0.3",
28
29
  "@seayoo-web/scripts": "^2.5.2",
29
- "@seayoo-web/utils": "^3.5.1",
30
- "@seayoo-web/tsconfig": "^1.0.3"
30
+ "@seayoo-web/utils": "^3.5.1"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "@seayoo-web/combo-webview": "^2.5.4",
@@ -39,7 +39,6 @@
39
39
  "type-check": "tsc --noEmit",
40
40
  "lint": "eslint ./src/**/*.ts",
41
41
  "lint:fix": "eslint \"./src/**/*.{ts,js}\" --fix",
42
- "test": "vitest",
43
42
  "prepublish": "pnpm lint:fix && pnpm build"
44
43
  }
45
44
  }