@seayoo-web/gamer-api 2.10.6 → 2.10.7
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 +48 -48
- package/package.json +1 -1
- package/types/src/event.config/reward.d.ts +1 -1
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 =
|
|
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
|
-
...
|
|
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) }),
|
|
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",
|
|
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,
|
|
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", {},
|
|
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
|
|
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(
|
|
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 */
|
|
@@ -854,7 +854,7 @@ const V = {
|
|
|
854
854
|
Winner: "winner",
|
|
855
855
|
/** 安慰奖励 */
|
|
856
856
|
Consolation: "consolation"
|
|
857
|
-
}, pt = e.string().enum(gt).lock(), _t = e.string().enum(v
|
|
857
|
+
}, pt = e.string().enum(gt).lock(), _t = e.string().enum(v), y = e.object({
|
|
858
858
|
reward_item_id: e.number(),
|
|
859
859
|
reward_amount: e.number(),
|
|
860
860
|
reward_item_name: e.string(),
|
|
@@ -942,7 +942,7 @@ const V = {
|
|
|
942
942
|
}), Ft = l.InvitedRegister, Ut = e.object({
|
|
943
943
|
...u.shape,
|
|
944
944
|
feature_type: e.string().enum(Ft)
|
|
945
|
-
}), Dt = e.string().enum(v
|
|
945
|
+
}), Dt = e.string().enum(P(v, "GiftCode", "LotteryTicket")), It = l.Lottery, At = e.object({
|
|
946
946
|
reward_item_id: e.number(),
|
|
947
947
|
reward_item_name: e.string(),
|
|
948
948
|
reward_item_type: Dt,
|
|
@@ -1095,10 +1095,10 @@ const V = {
|
|
|
1095
1095
|
until: e.number(),
|
|
1096
1096
|
visit_count: e.number().optional(),
|
|
1097
1097
|
features: e.array(dn)
|
|
1098
|
-
}).lock(),
|
|
1099
|
-
order_total_amount:
|
|
1100
|
-
cashback_total_amount:
|
|
1101
|
-
game_item_count:
|
|
1098
|
+
}).lock(), q = e.union(e.string().pattern("NumberString", /^\d+$/), e.number()), pn = e.object({
|
|
1099
|
+
order_total_amount: q,
|
|
1100
|
+
cashback_total_amount: q,
|
|
1101
|
+
game_item_count: q
|
|
1102
1102
|
}), _n = e.object({
|
|
1103
1103
|
activation_key: e.string().disallow("")
|
|
1104
1104
|
}), bn = e.object({
|
|
@@ -1109,7 +1109,7 @@ const V = {
|
|
|
1109
1109
|
avatar_url: e.string().optional()
|
|
1110
1110
|
}), fn = e.object({
|
|
1111
1111
|
lottery_count: e.number()
|
|
1112
|
-
}),
|
|
1112
|
+
}), V = e.object({
|
|
1113
1113
|
reward_id: e.number(),
|
|
1114
1114
|
reward_item_id: e.number(),
|
|
1115
1115
|
reward_source: $,
|
|
@@ -1134,8 +1134,8 @@ const V = {
|
|
|
1134
1134
|
}),
|
|
1135
1135
|
e.object({
|
|
1136
1136
|
ticket: e.string(),
|
|
1137
|
-
status: e.string().enum(
|
|
1138
|
-
reward:
|
|
1137
|
+
status: e.string().enum(P(h, "Unknown", "Pending")),
|
|
1138
|
+
reward: V
|
|
1139
1139
|
})
|
|
1140
1140
|
).satisfies(), kn = e.object({
|
|
1141
1141
|
tickets: e.array(wn)
|
|
@@ -1195,7 +1195,7 @@ const V = {
|
|
|
1195
1195
|
votes: e.number().optional()
|
|
1196
1196
|
}), Pn = e.object({
|
|
1197
1197
|
rewards_type: pt,
|
|
1198
|
-
rewards: e.array(
|
|
1198
|
+
rewards: e.array(V).optional()
|
|
1199
1199
|
}), En = e.object({
|
|
1200
1200
|
candidate_id: e.string(),
|
|
1201
1201
|
is_winner: e.bool(),
|
|
@@ -1289,7 +1289,7 @@ const V = {
|
|
|
1289
1289
|
}), Qn = e.object({
|
|
1290
1290
|
reward_id: e.number(),
|
|
1291
1291
|
reward_status: E
|
|
1292
|
-
}), Bn = e.guard(gn), Mn = e.guard(Gn),
|
|
1292
|
+
}), Bn = e.guard(gn), Mn = e.guard(Gn), x = s({ count: e.number() }), Kn = s({ first_visit: e.bool() }), Hn = s({
|
|
1293
1293
|
engagements: e.union(e.array(Un), e.array(qn))
|
|
1294
1294
|
}), zn = s({
|
|
1295
1295
|
status: e.array(On)
|
|
@@ -1301,11 +1301,11 @@ const V = {
|
|
|
1301
1301
|
}), Xn = e.guard(Nn), Yn = s({
|
|
1302
1302
|
claimed_items: e.array(Qn)
|
|
1303
1303
|
}), Wn = s({
|
|
1304
|
-
rewards: e.array(
|
|
1304
|
+
rewards: e.array(V)
|
|
1305
1305
|
}), er = s({
|
|
1306
1306
|
reward_status: E
|
|
1307
1307
|
}), tr = s({
|
|
1308
|
-
user_rewards: e.array(
|
|
1308
|
+
user_rewards: e.array(V),
|
|
1309
1309
|
next_token: e.string().optional()
|
|
1310
1310
|
}), nr = s({
|
|
1311
1311
|
scene: e.string()
|
|
@@ -1352,7 +1352,7 @@ class Wr {
|
|
|
1352
1352
|
* https://kdocs.cn/l/ckWFDcOsYEUA?linkname=ejPOcWMvT1
|
|
1353
1353
|
*/
|
|
1354
1354
|
async getEngagementsUserCount(t, n) {
|
|
1355
|
-
const { data: r } = await this.req.get(`event/${this.event}/feature-engagement-count`,
|
|
1355
|
+
const { data: r } = await this.req.get(`event/${this.event}/feature-engagement-count`, x, {
|
|
1356
1356
|
...n,
|
|
1357
1357
|
params: { feature_id: t, type: "user" }
|
|
1358
1358
|
});
|
|
@@ -1364,7 +1364,7 @@ class Wr {
|
|
|
1364
1364
|
* https://kdocs.cn/l/ckWFDcOsYEUA?linkname=ejPOcWMvT1
|
|
1365
1365
|
*/
|
|
1366
1366
|
async getEngagementsCount(t, n) {
|
|
1367
|
-
const { data: r } = await this.req.get(`event/${this.event}/feature-engagement-count`,
|
|
1367
|
+
const { data: r } = await this.req.get(`event/${this.event}/feature-engagement-count`, x, {
|
|
1368
1368
|
...n,
|
|
1369
1369
|
params: { feature_id: t, type: "engagement" }
|
|
1370
1370
|
});
|
|
@@ -1595,7 +1595,7 @@ class Wr {
|
|
|
1595
1595
|
*/
|
|
1596
1596
|
async getUserItemCount(t, n) {
|
|
1597
1597
|
if (!await this.token.autoLogin()) return null;
|
|
1598
|
-
const { data: r } = await this.req.get(`event/${this.event}/user-item-count`,
|
|
1598
|
+
const { data: r } = await this.req.get(`event/${this.event}/user-item-count`, x, {
|
|
1599
1599
|
...n,
|
|
1600
1600
|
params: { item_id: t }
|
|
1601
1601
|
});
|
|
@@ -1801,7 +1801,7 @@ const cr = {
|
|
|
1801
1801
|
replied_by: e.string(),
|
|
1802
1802
|
nickname: e.string(),
|
|
1803
1803
|
avatar_url: e.string()
|
|
1804
|
-
}).lock(),
|
|
1804
|
+
}).lock(), C = e.object({
|
|
1805
1805
|
reply_id: e.number(),
|
|
1806
1806
|
comment_id: e.number(),
|
|
1807
1807
|
comment_content: e.string().optional(),
|
|
@@ -1835,7 +1835,7 @@ const cr = {
|
|
|
1835
1835
|
image_url: e.string(),
|
|
1836
1836
|
create_time: e.number(),
|
|
1837
1837
|
status: ae,
|
|
1838
|
-
replies: e.array(
|
|
1838
|
+
replies: e.array(C).optional()
|
|
1839
1839
|
}).lock(), pr = e.object({
|
|
1840
1840
|
image_url: e.string(),
|
|
1841
1841
|
upload_url: e.string(),
|
|
@@ -1856,7 +1856,7 @@ const cr = {
|
|
|
1856
1856
|
post_subject: e.string(),
|
|
1857
1857
|
post_summary: e.string(),
|
|
1858
1858
|
post_image_url: e.string()
|
|
1859
|
-
}).lock(),
|
|
1859
|
+
}).lock(), R = e.object({
|
|
1860
1860
|
comment_id: e.number(),
|
|
1861
1861
|
comment_content: e.string()
|
|
1862
1862
|
}).lock(), A = e.object({
|
|
@@ -1878,16 +1878,16 @@ const cr = {
|
|
|
1878
1878
|
}), fr = e.object({
|
|
1879
1879
|
..._.shape,
|
|
1880
1880
|
...I.shape,
|
|
1881
|
-
...
|
|
1881
|
+
...R.shape,
|
|
1882
1882
|
notification_type: e.string().enum(m.PostCommented)
|
|
1883
1883
|
}), hr = e.object({
|
|
1884
1884
|
..._.shape,
|
|
1885
|
-
...
|
|
1885
|
+
...R.shape,
|
|
1886
1886
|
...A.shape,
|
|
1887
1887
|
notification_type: e.string().enum(m.CommentReplied)
|
|
1888
1888
|
}), wr = e.object({
|
|
1889
1889
|
..._.shape,
|
|
1890
|
-
...
|
|
1890
|
+
...R.shape,
|
|
1891
1891
|
...I.shape,
|
|
1892
1892
|
notification_type: e.string().enum(m.CommentLiked, m.CommentDeleted)
|
|
1893
1893
|
}), kr = e.object({
|
|
@@ -1900,7 +1900,7 @@ const cr = {
|
|
|
1900
1900
|
}), vr = e.object({
|
|
1901
1901
|
..._.shape,
|
|
1902
1902
|
...A.shape,
|
|
1903
|
-
...
|
|
1903
|
+
...R.shape,
|
|
1904
1904
|
notification_type: e.string().enum(m.ReplyLiked, m.ReplyDeleted)
|
|
1905
1905
|
}), Vr = e.union(
|
|
1906
1906
|
br,
|
|
@@ -1917,10 +1917,10 @@ const cr = {
|
|
|
1917
1917
|
post: D.clone().optional(),
|
|
1918
1918
|
antispam: ie.clone().optional()
|
|
1919
1919
|
}), xr = s({
|
|
1920
|
-
replies: e.array(
|
|
1920
|
+
replies: e.array(C),
|
|
1921
1921
|
next_token: e.string().optional()
|
|
1922
|
-
}), Sr = s({ reply:
|
|
1923
|
-
reply:
|
|
1922
|
+
}), Sr = s({ reply: C }), Lr = s({
|
|
1923
|
+
reply: C.clone().optional(),
|
|
1924
1924
|
antispam: ie.clone().optional()
|
|
1925
1925
|
}), Pr = s({ comment: w }), Er = s({
|
|
1926
1926
|
comments: e.array(w),
|
|
@@ -2228,7 +2228,7 @@ const Ir = s({
|
|
|
2228
2228
|
signature: e.string()
|
|
2229
2229
|
});
|
|
2230
2230
|
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
|
|
2231
|
+
function S(i) {
|
|
2232
2232
|
return k(i, "open_id", "union_id", "weixin_token");
|
|
2233
2233
|
}
|
|
2234
2234
|
const K = "wx_login_cache";
|
|
@@ -2267,7 +2267,7 @@ class na {
|
|
|
2267
2267
|
if (!t)
|
|
2268
2268
|
return null;
|
|
2269
2269
|
const n = _e(t);
|
|
2270
|
-
return
|
|
2270
|
+
return S(n) ? (this.token.weixinToken = n.weixin_token, await this.token.autoLogin(), n) : null;
|
|
2271
2271
|
}
|
|
2272
2272
|
/**
|
|
2273
2273
|
* 小程序页面微信静默登录,获取 weixinToken / open_id / union_id。
|
|
@@ -2295,7 +2295,7 @@ class na {
|
|
|
2295
2295
|
const r = await fe(), { data: a, code: o, message: g } = await this.req.post(
|
|
2296
2296
|
"weixin/login",
|
|
2297
2297
|
{ code: r, appid: this.appid },
|
|
2298
|
-
|
|
2298
|
+
S,
|
|
2299
2299
|
{ ...t, message: !1 }
|
|
2300
2300
|
);
|
|
2301
2301
|
return a && (this.token.weixinToken = a.weixin_token, this.token.storage.set(K, JSON.stringify(a))), a ?? {
|
|
@@ -2320,7 +2320,7 @@ class na {
|
|
|
2320
2320
|
* - snsapi_userinfo 【默认】弹出授权页面,可拿到 openid、union_id、昵称、头像等信息,但用户也可能会拒绝授权
|
|
2321
2321
|
*/
|
|
2322
2322
|
async webLogin(t = "snsapi_userinfo", n) {
|
|
2323
|
-
const r =
|
|
2323
|
+
const r = L("code"), a = Date.now(), o = +L("state");
|
|
2324
2324
|
if (!r || !o || o < a - 1e3 * 60 * 5 || o > a) {
|
|
2325
2325
|
const le = G(["code", "state"]);
|
|
2326
2326
|
location.replace(
|
|
@@ -2339,7 +2339,7 @@ class na {
|
|
|
2339
2339
|
data: p,
|
|
2340
2340
|
code: se,
|
|
2341
2341
|
message: ce
|
|
2342
|
-
} = await this.req.post("weixin/login", { code: r, appid: this.appid },
|
|
2342
|
+
} = await this.req.post("weixin/login", { code: r, appid: this.appid }, S, n);
|
|
2343
2343
|
return p && (this.token.weixinToken = p.weixin_token, await this.token.autoLogin()), p ?? {
|
|
2344
2344
|
message: ce,
|
|
2345
2345
|
error: se
|
|
@@ -2455,7 +2455,7 @@ export {
|
|
|
2455
2455
|
cr as ForumMode,
|
|
2456
2456
|
lr as ForumModeValidator,
|
|
2457
2457
|
oe as ForumValidator,
|
|
2458
|
-
|
|
2458
|
+
v as GamerItemType,
|
|
2459
2459
|
Y as GamerItemTypeValidator,
|
|
2460
2460
|
ke as Gender,
|
|
2461
2461
|
ve as GenderValidator,
|
|
@@ -2472,7 +2472,7 @@ export {
|
|
|
2472
2472
|
ea as NotificationCategoryValidator,
|
|
2473
2473
|
hr as NotificationCommentReplyValidator,
|
|
2474
2474
|
wr as NotificationCommentValidator,
|
|
2475
|
-
|
|
2475
|
+
R as NotificationPayloadCommentValidator,
|
|
2476
2476
|
I as NotificationPayloadPostValidator,
|
|
2477
2477
|
A as NotificationPayloadReplyValidator,
|
|
2478
2478
|
_r as NotificationPayloadSystemValidator,
|
|
@@ -2502,7 +2502,7 @@ export {
|
|
|
2502
2502
|
Oe as RedemptionValidator,
|
|
2503
2503
|
bt as RegularRewardValidator,
|
|
2504
2504
|
gr as ReplyToValidator,
|
|
2505
|
-
|
|
2505
|
+
C as ReplyValidator,
|
|
2506
2506
|
Kr as RewardItemType,
|
|
2507
2507
|
W as RewardItemTypeValidator,
|
|
2508
2508
|
st as RewardSource,
|
|
@@ -2527,7 +2527,7 @@ export {
|
|
|
2527
2527
|
F as UserEngagementDataValidator,
|
|
2528
2528
|
An as UserEngagementValidator,
|
|
2529
2529
|
On as UserFeatureStatusValidator,
|
|
2530
|
-
|
|
2530
|
+
V as UserRewardValidator,
|
|
2531
2531
|
Gn as VerifyMobileResultValidator,
|
|
2532
2532
|
Pn as Vote2ClaimRewardsResponseValidator,
|
|
2533
2533
|
Ln as Vote2EngagementDataValidator,
|
package/package.json
CHANGED
|
@@ -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;
|