@seayoo-web/gamer-api 2.10.6 → 2.10.8

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,5 +1,5 @@
1
1
  import { isComboWebView as ue } from "@seayoo-web/combo-webview";
2
- import { isPlainObject as k, supportWx as b, useConsole as me, usePromise as de, pruneURL as ge, supportWindow as pe, queryString as P, pruneObject as c, omitFields as v, parseJSON as _e, removePara as G } from "@seayoo-web/utils";
2
+ import { isPlainObject as k, supportWx as b, useConsole as me, usePromise as de, pruneURL as ge, supportWindow as pe, queryString as L, pruneObject as c, omitFields as P, parseJSON as _e, removePara as G } from "@seayoo-web/utils";
3
3
  import { v as e, objectGuard as s } from "@seayoo-web/validator";
4
4
  function be(i) {
5
5
  return k(i, "gamer_token") && typeof i.gamer_token == "string";
@@ -7,7 +7,7 @@ function be(i) {
7
7
  function O(i) {
8
8
  return k(i);
9
9
  }
10
- const T = me("GamerApiSDK");
10
+ const j = me("GamerApiSDK");
11
11
  function ye(i) {
12
12
  return /^\/[a-z\d-]+$/.test(i);
13
13
  }
@@ -37,7 +37,7 @@ const he = {
37
37
  try {
38
38
  if (b()) return wx.getStorageSync(i) || "";
39
39
  } catch (t) {
40
- T.error("getStorageSyncError", t);
40
+ j.error("getStorageSyncError", t);
41
41
  }
42
42
  return "";
43
43
  },
@@ -45,14 +45,14 @@ const he = {
45
45
  try {
46
46
  b() && wx.setStorageSync(i, t);
47
47
  } catch (n) {
48
- T.error("setStorageSyncError", n);
48
+ j.error("setStorageSyncError", n);
49
49
  }
50
50
  },
51
51
  remove(i) {
52
52
  try {
53
53
  b() && wx.removeStorageSync(i);
54
54
  } catch (t) {
55
- T.error("removeStorageSync", t);
55
+ j.error("removeStorageSync", t);
56
56
  }
57
57
  }
58
58
  }, f = "gamer_token";
@@ -87,7 +87,7 @@ class Qr {
87
87
  this.$gamerToken && (a.headers.Authorization = `Bearer ${this.$gamerToken}`);
88
88
  }
89
89
  }), pe()) {
90
- const a = /^(?:localhost|[\d.]+):\d{4}$/.test(location.host), o = P("gamer_token");
90
+ const a = /^(?:localhost|[\d.]+):\d{4}$/.test(location.host), o = L("gamer_token");
91
91
  (ue() || a && o) && (this.$gamerToken = o);
92
92
  }
93
93
  this.$gamerToken || this.loadGamerTokenCache();
@@ -365,7 +365,7 @@ const ke = {
365
365
  updated_at: e.number(),
366
366
  redeemable_quantity: e.number().optional()
367
367
  }).lock(), Ie = e.object({
368
- ...v(Z.shape, "tag"),
368
+ ...P(Z.shape, "tag"),
369
369
  product: X.clone().optional()
370
370
  }).lock(), Br = e.union(
371
371
  e.object({
@@ -402,7 +402,7 @@ const ke = {
402
402
  status: xe,
403
403
  created_at: e.number(),
404
404
  extra_data: e.union(Ae.clone(), Ge.clone()).satisfies().optional()
405
- }), Ne = e.guard(Se), N = s({ player: Le }), Qe = s({ roles: e.array(z) }), q = s({ role_card: $e }), Q = e.guard(Fe), B = e.guard(J), Be = s({ addresses: e.array(J) }), Me = e.guard(Ue), Ke = s({
405
+ }), Ne = e.guard(Se), N = s({ player: Le }), Qe = s({ roles: e.array(z) }), T = s({ role_card: $e }), Q = e.guard(Fe), B = e.guard(J), Be = s({ addresses: e.array(J) }), Me = e.guard(Ue), Ke = s({
406
406
  credit_logs: e.array(De),
407
407
  next_token: e.string().optional()
408
408
  }), He = s({ products: e.array(X) }), ze = s({ benefits: e.array(Z) }), Je = s({ benefit: Ie }), Ze = s({
@@ -474,7 +474,7 @@ class Mr {
474
474
  * https://kdocs.cn/l/cgp4gSBMbOf1?linkname=A1Wr7kUXnS
475
475
  */
476
476
  async getRoleCard(t, n) {
477
- const { data: r } = await this.req.get("club/role-card", q, {
477
+ const { data: r } = await this.req.get("club/role-card", T, {
478
478
  ...n,
479
479
  params: { member_id: t }
480
480
  });
@@ -487,7 +487,7 @@ class Mr {
487
487
  */
488
488
  async setRoleCard(t, n) {
489
489
  if (!await this.token.autoLogin()) return null;
490
- const { data: r } = await this.req.post("club/role-card", t, q, n);
490
+ const { data: r } = await this.req.post("club/role-card", t, T, n);
491
491
  return r?.role_card ?? null;
492
492
  }
493
493
  /**
@@ -497,7 +497,7 @@ class Mr {
497
497
  */
498
498
  async refreshRoleCard(t) {
499
499
  if (!await this.token.autoLogin()) return null;
500
- const { data: n } = await this.req.post("club/refresh-role-card", {}, q, t);
500
+ const { data: n } = await this.req.post("club/refresh-role-card", {}, T, t);
501
501
  return n?.role_card ?? null;
502
502
  }
503
503
  /**
@@ -672,7 +672,7 @@ class Mr {
672
672
  };
673
673
  }
674
674
  }
675
- const V = {
675
+ const v = {
676
676
  /** 活动道具 */
677
677
  EventItem: "event_item",
678
678
  /** 游戏内道具 */
@@ -693,7 +693,7 @@ const V = {
693
693
  ExternalCode: "external_gift_code",
694
694
  /** 空奖励 */
695
695
  VoidItem: "void_item"
696
- }, Y = e.string().enum(V).lock(), Kr = V, W = Y, Xe = {
696
+ }, Y = e.string().enum(v).lock(), Kr = v, W = Y, Xe = {
697
697
  /** 世游通行证 ID / Combo ID */
698
698
  UserId: "user_id",
699
699
  /** 游戏角色 ID */
@@ -753,6 +753,8 @@ const V = {
753
753
  Login: "player_login_days",
754
754
  /** 累计充值金额 */
755
755
  OrderAmount: "order_total_amount",
756
+ /** 累计充值次数 */
757
+ OrderCount: "order_total_count",
756
758
  /** 社区发帖数量 */
757
759
  Posts: "community_posts",
758
760
  /** 社区评论数量 */
@@ -854,7 +856,7 @@ const V = {
854
856
  Winner: "winner",
855
857
  /** 安慰奖励 */
856
858
  Consolation: "consolation"
857
- }, pt = e.string().enum(gt).lock(), _t = e.string().enum(v(V, "GiftCode", "LotteryTicket")), y = e.object({
859
+ }, pt = e.string().enum(gt).lock(), _t = e.string().enum(v), y = e.object({
858
860
  reward_item_id: e.number(),
859
861
  reward_amount: e.number(),
860
862
  reward_item_name: e.string(),
@@ -942,7 +944,7 @@ const V = {
942
944
  }), Ft = l.InvitedRegister, Ut = e.object({
943
945
  ...u.shape,
944
946
  feature_type: e.string().enum(Ft)
945
- }), Dt = e.string().enum(v(V, "GiftCode", "LotteryTicket")), It = l.Lottery, At = e.object({
947
+ }), Dt = e.string().enum(P(v, "GiftCode", "LotteryTicket")), It = l.Lottery, At = e.object({
946
948
  reward_item_id: e.number(),
947
949
  reward_item_name: e.string(),
948
950
  reward_item_type: Dt,
@@ -1095,10 +1097,10 @@ const V = {
1095
1097
  until: e.number(),
1096
1098
  visit_count: e.number().optional(),
1097
1099
  features: e.array(dn)
1098
- }).lock(), x = e.union(e.string().pattern("NumberString", /^\d+$/), e.number()), pn = e.object({
1099
- order_total_amount: x,
1100
- cashback_total_amount: x,
1101
- game_item_count: x
1100
+ }).lock(), q = e.union(e.string().pattern("NumberString", /^\d+$/), e.number()), pn = e.object({
1101
+ order_total_amount: q,
1102
+ cashback_total_amount: q,
1103
+ game_item_count: q
1102
1104
  }), _n = e.object({
1103
1105
  activation_key: e.string().disallow("")
1104
1106
  }), bn = e.object({
@@ -1109,7 +1111,7 @@ const V = {
1109
1111
  avatar_url: e.string().optional()
1110
1112
  }), fn = e.object({
1111
1113
  lottery_count: e.number()
1112
- }), C = e.object({
1114
+ }), V = e.object({
1113
1115
  reward_id: e.number(),
1114
1116
  reward_item_id: e.number(),
1115
1117
  reward_source: $,
@@ -1134,8 +1136,8 @@ const V = {
1134
1136
  }),
1135
1137
  e.object({
1136
1138
  ticket: e.string(),
1137
- status: e.string().enum(v(h, "Unknown", "Pending")),
1138
- reward: C
1139
+ status: e.string().enum(P(h, "Unknown", "Pending")),
1140
+ reward: V
1139
1141
  })
1140
1142
  ).satisfies(), kn = e.object({
1141
1143
  tickets: e.array(wn)
@@ -1195,7 +1197,7 @@ const V = {
1195
1197
  votes: e.number().optional()
1196
1198
  }), Pn = e.object({
1197
1199
  rewards_type: pt,
1198
- rewards: e.array(C).optional()
1200
+ rewards: e.array(V).optional()
1199
1201
  }), En = e.object({
1200
1202
  candidate_id: e.string(),
1201
1203
  is_winner: e.bool(),
@@ -1289,7 +1291,7 @@ const V = {
1289
1291
  }), Qn = e.object({
1290
1292
  reward_id: e.number(),
1291
1293
  reward_status: E
1292
- }), Bn = e.guard(gn), Mn = e.guard(Gn), S = s({ count: e.number() }), Kn = s({ first_visit: e.bool() }), Hn = s({
1294
+ }), Bn = e.guard(gn), Mn = e.guard(Gn), x = s({ count: e.number() }), Kn = s({ first_visit: e.bool() }), Hn = s({
1293
1295
  engagements: e.union(e.array(Un), e.array(qn))
1294
1296
  }), zn = s({
1295
1297
  status: e.array(On)
@@ -1301,11 +1303,11 @@ const V = {
1301
1303
  }), Xn = e.guard(Nn), Yn = s({
1302
1304
  claimed_items: e.array(Qn)
1303
1305
  }), Wn = s({
1304
- rewards: e.array(C)
1306
+ rewards: e.array(V)
1305
1307
  }), er = s({
1306
1308
  reward_status: E
1307
1309
  }), tr = s({
1308
- user_rewards: e.array(C),
1310
+ user_rewards: e.array(V),
1309
1311
  next_token: e.string().optional()
1310
1312
  }), nr = s({
1311
1313
  scene: e.string()
@@ -1352,7 +1354,7 @@ class Wr {
1352
1354
  * https://kdocs.cn/l/ckWFDcOsYEUA?linkname=ejPOcWMvT1
1353
1355
  */
1354
1356
  async getEngagementsUserCount(t, n) {
1355
- const { data: r } = await this.req.get(`event/${this.event}/feature-engagement-count`, S, {
1357
+ const { data: r } = await this.req.get(`event/${this.event}/feature-engagement-count`, x, {
1356
1358
  ...n,
1357
1359
  params: { feature_id: t, type: "user" }
1358
1360
  });
@@ -1364,7 +1366,7 @@ class Wr {
1364
1366
  * https://kdocs.cn/l/ckWFDcOsYEUA?linkname=ejPOcWMvT1
1365
1367
  */
1366
1368
  async getEngagementsCount(t, n) {
1367
- const { data: r } = await this.req.get(`event/${this.event}/feature-engagement-count`, S, {
1369
+ const { data: r } = await this.req.get(`event/${this.event}/feature-engagement-count`, x, {
1368
1370
  ...n,
1369
1371
  params: { feature_id: t, type: "engagement" }
1370
1372
  });
@@ -1595,7 +1597,7 @@ class Wr {
1595
1597
  */
1596
1598
  async getUserItemCount(t, n) {
1597
1599
  if (!await this.token.autoLogin()) return null;
1598
- const { data: r } = await this.req.get(`event/${this.event}/user-item-count`, S, {
1600
+ const { data: r } = await this.req.get(`event/${this.event}/user-item-count`, x, {
1599
1601
  ...n,
1600
1602
  params: { item_id: t }
1601
1603
  });
@@ -1801,7 +1803,7 @@ const cr = {
1801
1803
  replied_by: e.string(),
1802
1804
  nickname: e.string(),
1803
1805
  avatar_url: e.string()
1804
- }).lock(), R = e.object({
1806
+ }).lock(), C = e.object({
1805
1807
  reply_id: e.number(),
1806
1808
  comment_id: e.number(),
1807
1809
  comment_content: e.string().optional(),
@@ -1835,7 +1837,7 @@ const cr = {
1835
1837
  image_url: e.string(),
1836
1838
  create_time: e.number(),
1837
1839
  status: ae,
1838
- replies: e.array(R).optional()
1840
+ replies: e.array(C).optional()
1839
1841
  }).lock(), pr = e.object({
1840
1842
  image_url: e.string(),
1841
1843
  upload_url: e.string(),
@@ -1856,7 +1858,7 @@ const cr = {
1856
1858
  post_subject: e.string(),
1857
1859
  post_summary: e.string(),
1858
1860
  post_image_url: e.string()
1859
- }).lock(), j = e.object({
1861
+ }).lock(), R = e.object({
1860
1862
  comment_id: e.number(),
1861
1863
  comment_content: e.string()
1862
1864
  }).lock(), A = e.object({
@@ -1878,16 +1880,16 @@ const cr = {
1878
1880
  }), fr = e.object({
1879
1881
  ..._.shape,
1880
1882
  ...I.shape,
1881
- ...j.shape,
1883
+ ...R.shape,
1882
1884
  notification_type: e.string().enum(m.PostCommented)
1883
1885
  }), hr = e.object({
1884
1886
  ..._.shape,
1885
- ...j.shape,
1887
+ ...R.shape,
1886
1888
  ...A.shape,
1887
1889
  notification_type: e.string().enum(m.CommentReplied)
1888
1890
  }), wr = e.object({
1889
1891
  ..._.shape,
1890
- ...j.shape,
1892
+ ...R.shape,
1891
1893
  ...I.shape,
1892
1894
  notification_type: e.string().enum(m.CommentLiked, m.CommentDeleted)
1893
1895
  }), kr = e.object({
@@ -1900,7 +1902,7 @@ const cr = {
1900
1902
  }), vr = e.object({
1901
1903
  ..._.shape,
1902
1904
  ...A.shape,
1903
- ...j.shape,
1905
+ ...R.shape,
1904
1906
  notification_type: e.string().enum(m.ReplyLiked, m.ReplyDeleted)
1905
1907
  }), Vr = e.union(
1906
1908
  br,
@@ -1917,10 +1919,10 @@ const cr = {
1917
1919
  post: D.clone().optional(),
1918
1920
  antispam: ie.clone().optional()
1919
1921
  }), xr = s({
1920
- replies: e.array(R),
1922
+ replies: e.array(C),
1921
1923
  next_token: e.string().optional()
1922
- }), Sr = s({ reply: R }), Lr = s({
1923
- reply: R.clone().optional(),
1924
+ }), Sr = s({ reply: C }), Lr = s({
1925
+ reply: C.clone().optional(),
1924
1926
  antispam: ie.clone().optional()
1925
1927
  }), Pr = s({ comment: w }), Er = s({
1926
1928
  comments: e.array(w),
@@ -2228,7 +2230,7 @@ const Ir = s({
2228
2230
  signature: e.string()
2229
2231
  });
2230
2232
  var Ar = /* @__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))(Ar || {});
2231
- function L(i) {
2233
+ function S(i) {
2232
2234
  return k(i, "open_id", "union_id", "weixin_token");
2233
2235
  }
2234
2236
  const K = "wx_login_cache";
@@ -2267,7 +2269,7 @@ class na {
2267
2269
  if (!t)
2268
2270
  return null;
2269
2271
  const n = _e(t);
2270
- return L(n) ? (this.token.weixinToken = n.weixin_token, await this.token.autoLogin(), n) : null;
2272
+ return S(n) ? (this.token.weixinToken = n.weixin_token, await this.token.autoLogin(), n) : null;
2271
2273
  }
2272
2274
  /**
2273
2275
  * 小程序页面微信静默登录,获取 weixinToken / open_id / union_id。
@@ -2295,7 +2297,7 @@ class na {
2295
2297
  const r = await fe(), { data: a, code: o, message: g } = await this.req.post(
2296
2298
  "weixin/login",
2297
2299
  { code: r, appid: this.appid },
2298
- L,
2300
+ S,
2299
2301
  { ...t, message: !1 }
2300
2302
  );
2301
2303
  return a && (this.token.weixinToken = a.weixin_token, this.token.storage.set(K, JSON.stringify(a))), a ?? {
@@ -2320,7 +2322,7 @@ class na {
2320
2322
  * - snsapi_userinfo 【默认】弹出授权页面,可拿到 openid、union_id、昵称、头像等信息,但用户也可能会拒绝授权
2321
2323
  */
2322
2324
  async webLogin(t = "snsapi_userinfo", n) {
2323
- const r = P("code"), a = Date.now(), o = +P("state");
2325
+ const r = L("code"), a = Date.now(), o = +L("state");
2324
2326
  if (!r || !o || o < a - 1e3 * 60 * 5 || o > a) {
2325
2327
  const le = G(["code", "state"]);
2326
2328
  location.replace(
@@ -2339,7 +2341,7 @@ class na {
2339
2341
  data: p,
2340
2342
  code: se,
2341
2343
  message: ce
2342
- } = await this.req.post("weixin/login", { code: r, appid: this.appid }, L, n);
2344
+ } = await this.req.post("weixin/login", { code: r, appid: this.appid }, S, n);
2343
2345
  return p && (this.token.weixinToken = p.weixin_token, await this.token.autoLogin()), p ?? {
2344
2346
  message: ce,
2345
2347
  error: se
@@ -2455,7 +2457,7 @@ export {
2455
2457
  cr as ForumMode,
2456
2458
  lr as ForumModeValidator,
2457
2459
  oe as ForumValidator,
2458
- V as GamerItemType,
2460
+ v as GamerItemType,
2459
2461
  Y as GamerItemTypeValidator,
2460
2462
  ke as Gender,
2461
2463
  ve as GenderValidator,
@@ -2472,7 +2474,7 @@ export {
2472
2474
  ea as NotificationCategoryValidator,
2473
2475
  hr as NotificationCommentReplyValidator,
2474
2476
  wr as NotificationCommentValidator,
2475
- j as NotificationPayloadCommentValidator,
2477
+ R as NotificationPayloadCommentValidator,
2476
2478
  I as NotificationPayloadPostValidator,
2477
2479
  A as NotificationPayloadReplyValidator,
2478
2480
  _r as NotificationPayloadSystemValidator,
@@ -2502,7 +2504,7 @@ export {
2502
2504
  Oe as RedemptionValidator,
2503
2505
  bt as RegularRewardValidator,
2504
2506
  gr as ReplyToValidator,
2505
- R as ReplyValidator,
2507
+ C as ReplyValidator,
2506
2508
  Kr as RewardItemType,
2507
2509
  W as RewardItemTypeValidator,
2508
2510
  st as RewardSource,
@@ -2527,7 +2529,7 @@ export {
2527
2529
  F as UserEngagementDataValidator,
2528
2530
  An as UserEngagementValidator,
2529
2531
  On as UserFeatureStatusValidator,
2530
- C as UserRewardValidator,
2532
+ V as UserRewardValidator,
2531
2533
  Gn as VerifyMobileResultValidator,
2532
2534
  Pn as Vote2ClaimRewardsResponseValidator,
2533
2535
  Ln as Vote2EngagementDataValidator,
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.10.6",
4
+ "version": "2.10.8",
5
5
  "type": "module",
6
6
  "source": "index.ts",
7
7
  "main": "./dist/index.js",
@@ -30,12 +30,12 @@
30
30
  "license": "MIT",
31
31
  "devDependencies": {
32
32
  "@types/node": "^22.13.1",
33
- "@seayoo-web/combo-webview": "2.7.0",
34
33
  "@seayoo-web/request": "3.4.0",
35
- "@seayoo-web/scripts": "3.1.3",
36
- "@seayoo-web/tsconfig": "1.0.5",
34
+ "@seayoo-web/combo-webview": "2.7.0",
37
35
  "@seayoo-web/utils": "4.1.3",
38
- "@seayoo-web/validator": "1.1.0"
36
+ "@seayoo-web/validator": "1.1.0",
37
+ "@seayoo-web/scripts": "3.1.3",
38
+ "@seayoo-web/tsconfig": "1.0.5"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "@seayoo-web/combo-webview": "^2.7.0",
@@ -1,5 +1,5 @@
1
1
  import { type InferType } from "@seayoo-web/validator";
2
- declare const rewardItemTypeValidator: import("@seayoo-web/validator").StringValidator<"event_item" | "game_item" | "physical_item" | "weixin_hongbao" | "activation_key" | "credit" | "external_gift_code" | "void_item", false, false>;
2
+ declare const rewardItemTypeValidator: import("@seayoo-web/validator").StringValidator<"event_item" | "game_item" | "physical_item" | "weixin_hongbao" | "gift_code" | "activation_key" | "lottery_ticket" | "credit" | "external_gift_code" | "void_item", false, false>;
3
3
  export interface EventRewardItemConfig {
4
4
  /** 玩法奖励道具 id */
5
5
  reward_item_id: number;
@@ -166,6 +166,8 @@ export declare const QuestObjective: {
166
166
  readonly Login: "player_login_days";
167
167
  /** 累计充值金额 */
168
168
  readonly OrderAmount: "order_total_amount";
169
+ /** 累计充值次数 */
170
+ readonly OrderCount: "order_total_count";
169
171
  /** 社区发帖数量 */
170
172
  readonly Posts: "community_posts";
171
173
  /** 社区评论数量 */