@seayoo-web/gamer-api 1.1.1 → 1.1.3
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 +236 -222
- package/package.json +2 -2
- package/types/src/event.config.d.ts +6 -4
- package/types/src/event.define.d.ts +10 -0
- package/types/src/token.d.ts +4 -0
- package/types/src/utils.d.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
var V = Object.defineProperty;
|
|
2
2
|
var Q = (e, t, r) => t in e ? V(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
3
|
var u = (e, t, r) => Q(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
-
import { isComboWebView as
|
|
5
|
-
import { isPlainObject as n, useConsole as
|
|
4
|
+
import { isComboWebView as T } from "@seayoo-web/combo-webview";
|
|
5
|
+
import { isPlainObject as n, useConsole as M, Support as m, usePromise as H, pruneURL as j, queryString as h, pruneObject as s, isArray as o, isString as z, isValuedString as J, parseJSON as K, removePara as A } from "@seayoo-web/utils";
|
|
6
6
|
import "@seayoo-web/request";
|
|
7
7
|
function N(e) {
|
|
8
8
|
return n(e, "gamer_token") && typeof e.gamer_token == "string";
|
|
@@ -10,9 +10,12 @@ function N(e) {
|
|
|
10
10
|
function L(e) {
|
|
11
11
|
return n(e);
|
|
12
12
|
}
|
|
13
|
-
const l =
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
const l = M("GamerApiSDK");
|
|
14
|
+
function O(e) {
|
|
15
|
+
return /^\/[a-z\d-]+$/.test(e);
|
|
16
|
+
}
|
|
17
|
+
async function X() {
|
|
18
|
+
const { promise: e, resolve: t } = H();
|
|
16
19
|
return wx.login({
|
|
17
20
|
success(r) {
|
|
18
21
|
t(r);
|
|
@@ -22,7 +25,7 @@ async function O() {
|
|
|
22
25
|
}
|
|
23
26
|
}), await e;
|
|
24
27
|
}
|
|
25
|
-
const
|
|
28
|
+
const Y = {
|
|
26
29
|
get(e) {
|
|
27
30
|
return localStorage.getItem(e) || "";
|
|
28
31
|
},
|
|
@@ -32,7 +35,7 @@ const X = {
|
|
|
32
35
|
remove(e) {
|
|
33
36
|
localStorage.removeItem(e);
|
|
34
37
|
}
|
|
35
|
-
},
|
|
38
|
+
}, Z = {
|
|
36
39
|
get(e) {
|
|
37
40
|
try {
|
|
38
41
|
if (m.wx) return wx.getStorageSync(e) || "";
|
|
@@ -56,15 +59,15 @@ const X = {
|
|
|
56
59
|
}
|
|
57
60
|
}
|
|
58
61
|
}, _ = "gamer_token";
|
|
59
|
-
class
|
|
62
|
+
class Yt {
|
|
60
63
|
constructor(t, r) {
|
|
61
64
|
u(this, "$idToken", "");
|
|
62
65
|
u(this, "$weixinToken", "");
|
|
63
66
|
u(this, "$gamerToken", "");
|
|
64
67
|
u(this, "req");
|
|
65
68
|
u(this, "storage");
|
|
66
|
-
this.storage = m.wx ?
|
|
67
|
-
baseURL: `https://${j(t)}/v1`,
|
|
69
|
+
this.storage = m.wx ? Z : Y, this.req = r({
|
|
70
|
+
baseURL: O(t) ? t : `https://${j(t)}/v1`,
|
|
68
71
|
timeout: 1e4,
|
|
69
72
|
responseRule: {
|
|
70
73
|
ok: { resolve: "body" },
|
|
@@ -78,7 +81,7 @@ class Xt {
|
|
|
78
81
|
requestTransformer: (i) => {
|
|
79
82
|
this.$gamerToken && (i.headers.Authorization = `Bearer ${this.$gamerToken}`);
|
|
80
83
|
}
|
|
81
|
-
}),
|
|
84
|
+
}), T() ? this.$gamerToken = h("gamer_token") : this.loadGamerTokenCache();
|
|
82
85
|
}
|
|
83
86
|
loadGamerTokenCache() {
|
|
84
87
|
const r = this.storage.get(_).match(/^(\d{12,})#(.{8,})$/);
|
|
@@ -101,7 +104,7 @@ class Xt {
|
|
|
101
104
|
}
|
|
102
105
|
/** 设置从登录组件获取的 Id Token,用于后续请求自动置换 Gamer Token */
|
|
103
106
|
set idToken(t) {
|
|
104
|
-
|
|
107
|
+
this.$idToken !== t && (this.$idToken = t, this.gamerToken = "");
|
|
105
108
|
}
|
|
106
109
|
/** 读取设置 wexinToken */
|
|
107
110
|
get weixinToken() {
|
|
@@ -125,6 +128,12 @@ class Xt {
|
|
|
125
128
|
set gamerToken(t) {
|
|
126
129
|
this.$gamerToken = t, t ? this.storage.set(_, `${Date.now()}#${t}`) : this.storage.remove(_);
|
|
127
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* 退出登录,销毁相关 Token
|
|
133
|
+
*/
|
|
134
|
+
logout() {
|
|
135
|
+
this.$idToken = "", this.$weixinToken = "", this.gamerToken = "";
|
|
136
|
+
}
|
|
128
137
|
/**
|
|
129
138
|
* 用世游通行证统一登录能力签发的 ID Token / Weixin Token,自动置换 Gamer Token,成功后会自动设置后续 Request Headers
|
|
130
139
|
*
|
|
@@ -185,7 +194,7 @@ class Xt {
|
|
|
185
194
|
return r;
|
|
186
195
|
}
|
|
187
196
|
}
|
|
188
|
-
function
|
|
197
|
+
function W(e) {
|
|
189
198
|
return n(
|
|
190
199
|
e,
|
|
191
200
|
"default_avatar_url",
|
|
@@ -203,7 +212,7 @@ function Z(e) {
|
|
|
203
212
|
(t) => n(t, "exp", "level", "title")
|
|
204
213
|
);
|
|
205
214
|
}
|
|
206
|
-
function
|
|
215
|
+
function ee(e) {
|
|
207
216
|
return n(
|
|
208
217
|
e,
|
|
209
218
|
"member_id",
|
|
@@ -218,7 +227,7 @@ function W(e) {
|
|
|
218
227
|
) && typeof e.player_id == "string";
|
|
219
228
|
}
|
|
220
229
|
function C(e) {
|
|
221
|
-
return n(e, "player") &&
|
|
230
|
+
return n(e, "player") && ee(e.player);
|
|
222
231
|
}
|
|
223
232
|
function S(e) {
|
|
224
233
|
return n(
|
|
@@ -231,14 +240,14 @@ function S(e) {
|
|
|
231
240
|
"last_login_time"
|
|
232
241
|
) && z(e.server_id) && J(e.role_id);
|
|
233
242
|
}
|
|
234
|
-
function ee(e) {
|
|
235
|
-
return n(e, "roles") && a(e.roles, S);
|
|
236
|
-
}
|
|
237
243
|
function te(e) {
|
|
244
|
+
return n(e, "roles") && o(e.roles, S);
|
|
245
|
+
}
|
|
246
|
+
function re(e) {
|
|
238
247
|
return S(e) && n(e, "role_fighting");
|
|
239
248
|
}
|
|
240
249
|
function f(e) {
|
|
241
|
-
return n(e, "role_card") &&
|
|
250
|
+
return n(e, "role_card") && re(e.role_card);
|
|
242
251
|
}
|
|
243
252
|
function U(e) {
|
|
244
253
|
return n(e, "name", "avatar_url", "bio", "gender", "birthday") && n(e.birthday, "year", "month", "day");
|
|
@@ -256,10 +265,10 @@ function v(e) {
|
|
|
256
265
|
"is_default"
|
|
257
266
|
);
|
|
258
267
|
}
|
|
259
|
-
function re(e) {
|
|
260
|
-
return n(e, "addresses") && a(e.addresses, v);
|
|
261
|
-
}
|
|
262
268
|
function ne(e) {
|
|
269
|
+
return n(e, "addresses") && o(e.addresses, v);
|
|
270
|
+
}
|
|
271
|
+
function ie(e) {
|
|
263
272
|
return n(
|
|
264
273
|
e,
|
|
265
274
|
"increased_credit",
|
|
@@ -268,7 +277,7 @@ function ne(e) {
|
|
|
268
277
|
"balance_credit"
|
|
269
278
|
);
|
|
270
279
|
}
|
|
271
|
-
function
|
|
280
|
+
function se(e) {
|
|
272
281
|
return n(
|
|
273
282
|
e,
|
|
274
283
|
"id",
|
|
@@ -279,10 +288,10 @@ function ie(e) {
|
|
|
279
288
|
"change_scene"
|
|
280
289
|
);
|
|
281
290
|
}
|
|
282
|
-
function se(e) {
|
|
283
|
-
return n(e, "credit_logs") && a(e.credit_logs, ie);
|
|
284
|
-
}
|
|
285
291
|
function oe(e) {
|
|
292
|
+
return n(e, "credit_logs") && o(e.credit_logs, se);
|
|
293
|
+
}
|
|
294
|
+
function ae(e) {
|
|
286
295
|
return n(
|
|
287
296
|
e,
|
|
288
297
|
"benefit_id",
|
|
@@ -295,10 +304,10 @@ function oe(e) {
|
|
|
295
304
|
"tag"
|
|
296
305
|
);
|
|
297
306
|
}
|
|
298
|
-
function ae(e) {
|
|
299
|
-
return n(e, "benefits") && a(e.benefits, oe);
|
|
300
|
-
}
|
|
301
307
|
function ue(e) {
|
|
308
|
+
return n(e, "benefits") && o(e.benefits, ae);
|
|
309
|
+
}
|
|
310
|
+
function ce(e) {
|
|
302
311
|
return n(
|
|
303
312
|
e,
|
|
304
313
|
"benefit_id",
|
|
@@ -310,8 +319,8 @@ function ue(e) {
|
|
|
310
319
|
"product_id"
|
|
311
320
|
) && ("product" in e ? D(e.product) : !0);
|
|
312
321
|
}
|
|
313
|
-
function
|
|
314
|
-
return n(e, "benefit") &&
|
|
322
|
+
function me(e) {
|
|
323
|
+
return n(e, "benefit") && ce(e.benefit);
|
|
315
324
|
}
|
|
316
325
|
function D(e) {
|
|
317
326
|
return n(
|
|
@@ -342,10 +351,10 @@ function D(e) {
|
|
|
342
351
|
"updated_at"
|
|
343
352
|
);
|
|
344
353
|
}
|
|
345
|
-
function me(e) {
|
|
346
|
-
return n(e, "products") && a(e.products, D);
|
|
347
|
-
}
|
|
348
354
|
function le(e) {
|
|
355
|
+
return n(e, "products") && o(e.products, D);
|
|
356
|
+
}
|
|
357
|
+
function _e(e) {
|
|
349
358
|
return n(
|
|
350
359
|
e,
|
|
351
360
|
"redemption_id",
|
|
@@ -360,9 +369,9 @@ function le(e) {
|
|
|
360
369
|
"amount",
|
|
361
370
|
"status",
|
|
362
371
|
"created_at"
|
|
363
|
-
) && ("extra_data" in e ?
|
|
372
|
+
) && ("extra_data" in e ? ge(e.extra_data) || de(e.extra_data) : !0);
|
|
364
373
|
}
|
|
365
|
-
function
|
|
374
|
+
function ge(e) {
|
|
366
375
|
return n(
|
|
367
376
|
e,
|
|
368
377
|
"address",
|
|
@@ -375,14 +384,14 @@ function _e(e) {
|
|
|
375
384
|
"express_number"
|
|
376
385
|
);
|
|
377
386
|
}
|
|
378
|
-
function
|
|
387
|
+
function de(e) {
|
|
379
388
|
return n(e, "server_id", "role_id", "role_name");
|
|
380
389
|
}
|
|
381
|
-
function
|
|
382
|
-
return n(e, "redemptions") &&
|
|
390
|
+
function pe(e) {
|
|
391
|
+
return n(e, "redemptions") && o(e.redemptions, _e);
|
|
383
392
|
}
|
|
384
|
-
var
|
|
385
|
-
class
|
|
393
|
+
var fe = /* @__PURE__ */ ((e) => (e.Unknown = "unknown", e.Male = "male", e.Female = "female", e))(fe || {}), we = /* @__PURE__ */ ((e) => (e.Increase = "increase", e.Decrease = "decrease", e.Expired = "expired", e))(we || {}), ye = /* @__PURE__ */ ((e) => (e.Order = "order", e.Consumption = "consumption", e.Redeem = "redeem", e.Expire = "expire", e.Admin = "admin", e.Event = "event", e))(ye || {}), he = /* @__PURE__ */ ((e) => (e.GameReward = "game_reward", e.Physical = "physical", e.Virtual = "virtual", e))(he || {}), ve = /* @__PURE__ */ ((e) => (e.Pending = "pending", e.issued = "issued", e.failed = "failed", e))(ve || {});
|
|
394
|
+
class Zt {
|
|
386
395
|
constructor(t) {
|
|
387
396
|
u(this, "token");
|
|
388
397
|
u(this, "req");
|
|
@@ -394,7 +403,7 @@ class Yt {
|
|
|
394
403
|
* https://kdocs.cn/l/cgp4gSBMbOf1?linkname=tuhsPt3ihp
|
|
395
404
|
*/
|
|
396
405
|
async getConfig() {
|
|
397
|
-
const { data: t } = await this.req.get("club/config",
|
|
406
|
+
const { data: t } = await this.req.get("club/config", W);
|
|
398
407
|
return t;
|
|
399
408
|
}
|
|
400
409
|
/**
|
|
@@ -432,7 +441,7 @@ class Yt {
|
|
|
432
441
|
*/
|
|
433
442
|
async getRoles(t, r) {
|
|
434
443
|
if (!await this.token.autoLogin()) return [];
|
|
435
|
-
const { data: i } = await this.req.get("club/roles",
|
|
444
|
+
const { data: i } = await this.req.get("club/roles", te, {
|
|
436
445
|
params: s({ player_id: t, refresh: r })
|
|
437
446
|
});
|
|
438
447
|
return (i == null ? void 0 : i.roles) || [];
|
|
@@ -498,7 +507,7 @@ class Yt {
|
|
|
498
507
|
*/
|
|
499
508
|
async getAddresses() {
|
|
500
509
|
if (!await this.token.autoLogin()) return [];
|
|
501
|
-
const { data: t } = await this.req.get("club/addresses",
|
|
510
|
+
const { data: t } = await this.req.get("club/addresses", ne);
|
|
502
511
|
return (t == null ? void 0 : t.addresses) ?? [];
|
|
503
512
|
}
|
|
504
513
|
/**
|
|
@@ -538,7 +547,7 @@ class Yt {
|
|
|
538
547
|
*/
|
|
539
548
|
async getUserCredit(t) {
|
|
540
549
|
await this.token.autoLogin();
|
|
541
|
-
const { data: r, code: i } = await this.req.get("club/user-credit",
|
|
550
|
+
const { data: r, code: i } = await this.req.get("club/user-credit", ie, { params: s(t) });
|
|
542
551
|
return r ?? { error: i };
|
|
543
552
|
}
|
|
544
553
|
/**
|
|
@@ -548,7 +557,7 @@ class Yt {
|
|
|
548
557
|
*/
|
|
549
558
|
async getCreditLogs(t) {
|
|
550
559
|
await this.token.autoLogin();
|
|
551
|
-
const { data: r } = await this.req.get("club/credit-logs",
|
|
560
|
+
const { data: r } = await this.req.get("club/credit-logs", oe, {
|
|
552
561
|
params: s({ max_results: 20, ...t })
|
|
553
562
|
});
|
|
554
563
|
return r || { credit_logs: [] };
|
|
@@ -560,7 +569,7 @@ class Yt {
|
|
|
560
569
|
*/
|
|
561
570
|
async getBenefits() {
|
|
562
571
|
if (!await this.token.autoLogin()) return [];
|
|
563
|
-
const { data: t } = await this.req.get("club/benefits",
|
|
572
|
+
const { data: t } = await this.req.get("club/benefits", ue);
|
|
564
573
|
return (t == null ? void 0 : t.benefits) || [];
|
|
565
574
|
}
|
|
566
575
|
/**
|
|
@@ -570,7 +579,7 @@ class Yt {
|
|
|
570
579
|
*/
|
|
571
580
|
async getBenefit(t) {
|
|
572
581
|
if (!await this.token.autoLogin()) return null;
|
|
573
|
-
const { data: r } = await this.req.get("club/benefit",
|
|
582
|
+
const { data: r } = await this.req.get("club/benefit", me, {
|
|
574
583
|
params: { benefit_id: t }
|
|
575
584
|
});
|
|
576
585
|
return (r == null ? void 0 : r.benefit) || null;
|
|
@@ -581,7 +590,7 @@ class Yt {
|
|
|
581
590
|
* https://kdocs.cn/l/cgp4gSBMbOf1?linkname=r3vC3PzfMQ
|
|
582
591
|
*/
|
|
583
592
|
async getProducts() {
|
|
584
|
-
const { data: t } = await this.req.get("club/products",
|
|
593
|
+
const { data: t } = await this.req.get("club/products", le);
|
|
585
594
|
return (t == null ? void 0 : t.products) || [];
|
|
586
595
|
}
|
|
587
596
|
/**
|
|
@@ -603,51 +612,51 @@ class Yt {
|
|
|
603
612
|
*/
|
|
604
613
|
async getRedemptions(t) {
|
|
605
614
|
await this.token.autoLogin();
|
|
606
|
-
const { data: r } = await this.req.get("club/redemptions",
|
|
615
|
+
const { data: r } = await this.req.get("club/redemptions", pe, {
|
|
607
616
|
params: s({ max_results: 20, ...t })
|
|
608
617
|
});
|
|
609
618
|
return r || { redemptions: [] };
|
|
610
619
|
}
|
|
611
620
|
}
|
|
612
|
-
var
|
|
613
|
-
function De(e) {
|
|
614
|
-
return n(e, "event_name", "rules", "since", "until", "visit_count", "features") && Array.isArray(e.features) && e.features.every(Ee);
|
|
615
|
-
}
|
|
621
|
+
var ke = /* @__PURE__ */ ((e) => (e.EventItem = "event_item", e.GameItem = "game_item", e.PhysicalItem = "physical_item", e.WeixinHongbao = "weixin_hongbao", e.GiftCode = "gift_code", e.LotteryTicket = "lottery_ticket", e.VoidItem = "void_item", e))(ke || {}), be = /* @__PURE__ */ ((e) => (e.UserId = "user_id", e.RoleId = "role_id", e))(be || {}), qe = /* @__PURE__ */ ((e) => (e.None = "none", e.Daily = "daily", e.Weekly = "weekly", e.Monthly = "monthly", e))(qe || {}), a = /* @__PURE__ */ ((e) => (e.Preregister = "preregister", e.Lottery = "lottery", e.Survey = "survey", e.Invite = "invite", e.Share = "share", e.Follow = "follow", e.Subscribe = "weixin_subscribe", e.Comment = "comment", e.Vote = "vote", e.GiftCode = "gift_code", e.Register = "register", e.InvitedRegister = "invited_register", e.ClaimRewards = "claim_rewards", e.Cashback = "cashback", e.Quest = "quest", e.Team = "team", e.LotteryDraw = "lottery_draw", e))(a || {}), Re = /* @__PURE__ */ ((e) => (e.Active = "player_active_points", e.Login = "player_login_days", e.OrderAmount = "order_total_amount", e.Posts = "community_posts", e.Comments = "community_comments", e))(Re || {}), xe = /* @__PURE__ */ ((e) => (e.System = "system", e.UserSubmission = "user_submission", e.Shortlisted = "shortlisted", e))(xe || {}), Ae = /* @__PURE__ */ ((e) => (e.Ineligible = "ineligible", e.Unaccalimed = "unaccalimed", e.Received = "received", e))(Ae || {}), Le = /* @__PURE__ */ ((e) => (e.Unaccalimed = "unaccalimed", e.Received = "received", e.Failed = "failed", e.Delivered = "delivered", e))(Le || {}), Ce = /* @__PURE__ */ ((e) => (e.Ineligible = "ineligible", e.Unaccalimed = "unaccalimed", e.Received = "received", e.Failed = "failed", e))(Ce || {}), Ue = /* @__PURE__ */ ((e) => (e.Output = "output", e.Engage = "engage", e))(Ue || {}), $e = /* @__PURE__ */ ((e) => (e.Private = "private", e.Public = "public", e))($e || {}), Pe = /* @__PURE__ */ ((e) => (e.Unknown = "unknown", e.Pending = "pending", e.Drawn = "drawn", e.Claimed = "claimed", e.Fail = "fail", e))(Pe || {}), Se = /* @__PURE__ */ ((e) => (e.Assemble = "assemble", e.Join = "join", e.Disband = "disband", e.ChangeVisibility = "change_visibility", e.Query = "query", e))(Se || {}), De = /* @__PURE__ */ ((e) => (e.Query = "query", e.Draw = "draw", e.Claim = "claim", e))(De || {});
|
|
616
622
|
function Ee(e) {
|
|
617
|
-
|
|
623
|
+
return n(e, "event_name", "rules", "since", "until", "features") && Array.isArray(e.features) && e.features.every(Ge);
|
|
624
|
+
}
|
|
625
|
+
function Ge(e) {
|
|
626
|
+
if (!Ie(e))
|
|
618
627
|
return !1;
|
|
619
628
|
switch (e.feature_type) {
|
|
620
|
-
case
|
|
621
|
-
case
|
|
622
|
-
case
|
|
623
|
-
case
|
|
629
|
+
case a.Preregister:
|
|
630
|
+
case a.ClaimRewards:
|
|
631
|
+
case a.Register:
|
|
632
|
+
case a.InvitedRegister:
|
|
624
633
|
return !0;
|
|
625
|
-
case
|
|
626
|
-
return Be(e.config);
|
|
627
|
-
case o.Survey:
|
|
634
|
+
case a.Lottery:
|
|
628
635
|
return Ve(e.config);
|
|
629
|
-
case
|
|
636
|
+
case a.Survey:
|
|
630
637
|
return Qe(e.config);
|
|
631
|
-
case
|
|
638
|
+
case a.Invite:
|
|
639
|
+
return Te(e.config);
|
|
640
|
+
case a.Share:
|
|
632
641
|
return Me(e.config);
|
|
633
|
-
case
|
|
642
|
+
case a.Follow:
|
|
634
643
|
return He(e.config);
|
|
635
|
-
case
|
|
636
|
-
return Te(e.config);
|
|
637
|
-
case o.Comment:
|
|
644
|
+
case a.Subscribe:
|
|
638
645
|
return je(e.config);
|
|
639
|
-
case
|
|
646
|
+
case a.Comment:
|
|
640
647
|
return ze(e.config);
|
|
641
|
-
case
|
|
642
|
-
return
|
|
643
|
-
case
|
|
648
|
+
case a.Vote:
|
|
649
|
+
return Je(e.config);
|
|
650
|
+
case a.Cashback:
|
|
644
651
|
return Ne(e.config);
|
|
645
|
-
case
|
|
646
|
-
return
|
|
647
|
-
case
|
|
652
|
+
case a.GiftCode:
|
|
653
|
+
return Oe(e.config);
|
|
654
|
+
case a.Quest:
|
|
648
655
|
return Ye(e.config);
|
|
649
|
-
case
|
|
656
|
+
case a.Team:
|
|
650
657
|
return Ze(e.config);
|
|
658
|
+
case a.LotteryDraw:
|
|
659
|
+
return We(e.config);
|
|
651
660
|
default:
|
|
652
661
|
return !1;
|
|
653
662
|
}
|
|
@@ -659,13 +668,14 @@ function k(e) {
|
|
|
659
668
|
"reward_amount",
|
|
660
669
|
"reward_item_name",
|
|
661
670
|
"reward_item_icon_url",
|
|
662
|
-
"reward_item_type"
|
|
671
|
+
"reward_item_type",
|
|
672
|
+
"reward_item_rating"
|
|
663
673
|
);
|
|
664
674
|
}
|
|
665
|
-
function
|
|
675
|
+
function Fe(e) {
|
|
666
676
|
return n(e, "feature_reward_type", "reward_details") && (e.feature_reward_type === "every" ? Array.isArray(e.reward_details) && e.reward_details.every(k) : e.feature_reward_type === "regular" ? n(e.reward_details, "engage_count", "rewards") && Array.isArray(e.reward_details.rewards) && e.reward_details.rewards.every(k) : !1);
|
|
667
677
|
}
|
|
668
|
-
function
|
|
678
|
+
function Ie(e) {
|
|
669
679
|
return n(
|
|
670
680
|
e,
|
|
671
681
|
"feature_id",
|
|
@@ -676,11 +686,10 @@ function Fe(e) {
|
|
|
676
686
|
"limit",
|
|
677
687
|
"since",
|
|
678
688
|
"until",
|
|
679
|
-
"
|
|
680
|
-
|
|
681
|
-
) && Array.isArray(e.feature_rewards) && e.feature_rewards.every(Ge);
|
|
689
|
+
"engage_account"
|
|
690
|
+
) && ("feature_rewards" in e ? o(e.feature_rewards, Fe) : !0);
|
|
682
691
|
}
|
|
683
|
-
function
|
|
692
|
+
function Be(e) {
|
|
684
693
|
return n(
|
|
685
694
|
e,
|
|
686
695
|
"reward_item_id",
|
|
@@ -691,7 +700,7 @@ function Ie(e) {
|
|
|
691
700
|
"reward_remaining_stock"
|
|
692
701
|
);
|
|
693
702
|
}
|
|
694
|
-
function
|
|
703
|
+
function Ve(e) {
|
|
695
704
|
return n(
|
|
696
705
|
e,
|
|
697
706
|
"consume_item_id",
|
|
@@ -699,12 +708,12 @@ function Be(e) {
|
|
|
699
708
|
"consume_item_icon_url",
|
|
700
709
|
"consume_item_count",
|
|
701
710
|
"rewards"
|
|
702
|
-
) && Array.isArray(e.rewards) && e.rewards.every(
|
|
711
|
+
) && Array.isArray(e.rewards) && e.rewards.every(Be);
|
|
703
712
|
}
|
|
704
|
-
function
|
|
713
|
+
function Qe(e) {
|
|
705
714
|
return n(e, "survey_id", "survey_url");
|
|
706
715
|
}
|
|
707
|
-
function
|
|
716
|
+
function Te(e) {
|
|
708
717
|
return n(e, "share_url");
|
|
709
718
|
}
|
|
710
719
|
function Me(e) {
|
|
@@ -713,13 +722,13 @@ function Me(e) {
|
|
|
713
722
|
function He(e) {
|
|
714
723
|
return n(e, "platform");
|
|
715
724
|
}
|
|
716
|
-
function
|
|
725
|
+
function je(e) {
|
|
717
726
|
return n(e, "weixin_template_ids") && Array.isArray(e.weixin_template_ids) && e.weixin_template_ids.every((t) => typeof t == "string");
|
|
718
727
|
}
|
|
719
|
-
function
|
|
728
|
+
function ze(e) {
|
|
720
729
|
return n(e, "comments", "send_rate") && Array.isArray(e.comments) && e.comments.every((t) => typeof t == "string");
|
|
721
730
|
}
|
|
722
|
-
function
|
|
731
|
+
function Je(e) {
|
|
723
732
|
return n(
|
|
724
733
|
e,
|
|
725
734
|
"vote_feature_ids",
|
|
@@ -728,12 +737,12 @@ function ze(e) {
|
|
|
728
737
|
"source",
|
|
729
738
|
"options",
|
|
730
739
|
"rewards"
|
|
731
|
-
) && Array.isArray(e.vote_feature_ids) && Array.isArray(e.submission_feature_ids) && Array.isArray(e.options) && e.options.every(
|
|
740
|
+
) && Array.isArray(e.vote_feature_ids) && Array.isArray(e.submission_feature_ids) && Array.isArray(e.options) && e.options.every(Ke) && Array.isArray(e.rewards) && e.rewards.every(k);
|
|
732
741
|
}
|
|
733
|
-
function
|
|
742
|
+
function Ke(e) {
|
|
734
743
|
return n(e, "sn", "name", "amount", "jump_url", "last_vote_time", "finalists") && ("img_urls" in e ? Array.isArray(e.img_urls) : !0) && ("video_urls" in e ? Array.isArray(e.video_urls) : !0) && ("descriptions" in e ? Array.isArray(e.descriptions) : !0);
|
|
735
744
|
}
|
|
736
|
-
function
|
|
745
|
+
function Ne(e) {
|
|
737
746
|
return n(
|
|
738
747
|
e,
|
|
739
748
|
"order_start_time",
|
|
@@ -742,40 +751,40 @@ function Ke(e) {
|
|
|
742
751
|
"claim_rewards_end_time"
|
|
743
752
|
);
|
|
744
753
|
}
|
|
745
|
-
function Ne(e) {
|
|
746
|
-
return n(e, "gift_items") && Array.isArray(e.gift_items) && e.gift_items.every(Oe);
|
|
747
|
-
}
|
|
748
754
|
function Oe(e) {
|
|
749
|
-
return n(e, "
|
|
755
|
+
return n(e, "gift_items") && Array.isArray(e.gift_items) && e.gift_items.every(Xe);
|
|
750
756
|
}
|
|
751
757
|
function Xe(e) {
|
|
752
|
-
return n(e, "
|
|
758
|
+
return n(e, "name", "count", "icon_url");
|
|
753
759
|
}
|
|
754
760
|
function Ye(e) {
|
|
755
|
-
return n(e, "
|
|
761
|
+
return n(e, "objective", "completion_value") && ("team" in e ? n(e.team, "completion_value") : !0);
|
|
756
762
|
}
|
|
757
763
|
function Ze(e) {
|
|
758
|
-
return n(e, "
|
|
764
|
+
return n(e, "min_members", "max_members");
|
|
759
765
|
}
|
|
760
766
|
function We(e) {
|
|
767
|
+
return n(e, "draw_not_after", "draw_not_before");
|
|
768
|
+
}
|
|
769
|
+
function et(e) {
|
|
761
770
|
return n(e, "allowed", "registered");
|
|
762
771
|
}
|
|
763
|
-
function
|
|
772
|
+
function w(e) {
|
|
764
773
|
return n(e, "count");
|
|
765
774
|
}
|
|
766
|
-
function
|
|
775
|
+
function tt(e) {
|
|
767
776
|
return n(e, "engagements") && Array.isArray(e.engagements) && (e.engagements.every(
|
|
768
777
|
(t) => n(t, "user_id", "name", "avatar_url", "comment", "video_note", "created_at")
|
|
769
778
|
) || e.engagements.every((t) => n(t, "team_code", "leader_name", "total_members")));
|
|
770
779
|
}
|
|
771
|
-
function
|
|
780
|
+
function rt(e) {
|
|
772
781
|
return n(e, "first_visit") && typeof e.first_visit == "boolean";
|
|
773
782
|
}
|
|
774
|
-
function
|
|
783
|
+
function nt(e) {
|
|
775
784
|
return n(e, "status") && Array.isArray(e.status) && e.status.every((t) => n(t, "feature_id", "can_engage", "has_unclaimed_rewards"));
|
|
776
785
|
}
|
|
777
|
-
function
|
|
778
|
-
return n(e, "engagements") &&
|
|
786
|
+
function it(e) {
|
|
787
|
+
return n(e, "engagements") && o(e.engagements, E);
|
|
779
788
|
}
|
|
780
789
|
function E(e) {
|
|
781
790
|
if (!n(
|
|
@@ -785,6 +794,11 @@ function E(e) {
|
|
|
785
794
|
"feature_id",
|
|
786
795
|
"reward_id",
|
|
787
796
|
"reward_status",
|
|
797
|
+
"reward_item_amount",
|
|
798
|
+
"reward_item_name",
|
|
799
|
+
"reward_item_desc",
|
|
800
|
+
"reward_item_icon_url",
|
|
801
|
+
"reward_item_rating",
|
|
788
802
|
"reward_source",
|
|
789
803
|
"created_at"
|
|
790
804
|
))
|
|
@@ -792,41 +806,41 @@ function E(e) {
|
|
|
792
806
|
if (!("data" in e))
|
|
793
807
|
return !0;
|
|
794
808
|
const t = e.data;
|
|
795
|
-
return
|
|
809
|
+
return st(t) || ot(t) || at(t) || ut(t) || ct(t) || mt(t) || lt(t) || _t(t) || gt(t) || dt(t) || pt(t) || ft(t);
|
|
796
810
|
}
|
|
797
|
-
function
|
|
811
|
+
function st(e) {
|
|
798
812
|
return n(e, "platforms") && Array.isArray(e.platforms);
|
|
799
813
|
}
|
|
800
|
-
function
|
|
814
|
+
function ot(e) {
|
|
801
815
|
return n(e, "lottery_count");
|
|
802
816
|
}
|
|
803
|
-
function
|
|
817
|
+
function at(e) {
|
|
804
818
|
return n(e, "serial_number");
|
|
805
819
|
}
|
|
806
|
-
function
|
|
820
|
+
function ut(e) {
|
|
807
821
|
return n(e, "user_id");
|
|
808
822
|
}
|
|
809
|
-
function
|
|
823
|
+
function ct(e) {
|
|
810
824
|
return n(e, "platform");
|
|
811
825
|
}
|
|
812
|
-
function
|
|
826
|
+
function mt(e) {
|
|
813
827
|
return n(e, "option_sn");
|
|
814
828
|
}
|
|
815
|
-
function
|
|
829
|
+
function lt(e) {
|
|
816
830
|
return n(e, "weixin_openid");
|
|
817
831
|
}
|
|
818
|
-
function
|
|
832
|
+
function _t(e) {
|
|
819
833
|
return n(e, "cashback_total_amount", "game_item_count", "order_total_amount");
|
|
820
834
|
}
|
|
821
|
-
function
|
|
835
|
+
function gt(e) {
|
|
822
836
|
return n(e, "gift_code");
|
|
823
837
|
}
|
|
824
|
-
function
|
|
838
|
+
function dt(e) {
|
|
825
839
|
return n(e, "team_code", "visibility", "members") && Array.isArray(e.members) && e.members.every(
|
|
826
840
|
(t) => n(t, "is_leader", "role_name", "server_name")
|
|
827
841
|
);
|
|
828
842
|
}
|
|
829
|
-
function
|
|
843
|
+
function pt(e) {
|
|
830
844
|
return n(e, "objective", "progress") ? "team" in e ? n(e.team, "progress", "players") && Array.isArray(e.team.players) && e.team.players.every(
|
|
831
845
|
(t) => n(
|
|
832
846
|
t,
|
|
@@ -855,10 +869,10 @@ function G(e) {
|
|
|
855
869
|
"receive_time"
|
|
856
870
|
) && ("extra_data" in e ? n(e.extra_data) : !0);
|
|
857
871
|
}
|
|
858
|
-
function
|
|
872
|
+
function ft(e) {
|
|
859
873
|
return !n(e, "tickets") || !("status" in e) ? !1 : e.status === "unknown" || e.status === "pending" ? !0 : "reward" in e ? G(e.reward) : !1;
|
|
860
874
|
}
|
|
861
|
-
function
|
|
875
|
+
function wt(e) {
|
|
862
876
|
return n(
|
|
863
877
|
e,
|
|
864
878
|
"reward_id",
|
|
@@ -872,30 +886,30 @@ function ft(e) {
|
|
|
872
886
|
);
|
|
873
887
|
}
|
|
874
888
|
function yt(e) {
|
|
875
|
-
return n(e, "engagement_id") && ("engagement" in e ? E(e.engagement) : !0) && ("rewards" in e ?
|
|
876
|
-
}
|
|
877
|
-
function wt(e) {
|
|
878
|
-
return n(e, "reward_id", "reward_status");
|
|
889
|
+
return n(e, "engagement_id") && ("engagement" in e ? E(e.engagement) : !0) && ("rewards" in e ? o(e.rewards, wt) : !0);
|
|
879
890
|
}
|
|
880
891
|
function ht(e) {
|
|
881
|
-
return n(e, "
|
|
892
|
+
return n(e, "reward_id", "reward_status");
|
|
882
893
|
}
|
|
883
894
|
function vt(e) {
|
|
884
|
-
return n(e, "
|
|
895
|
+
return n(e, "claimed_items") && o(e.claimed_items, ht);
|
|
885
896
|
}
|
|
886
897
|
function kt(e) {
|
|
887
|
-
return n(e, "
|
|
898
|
+
return n(e, "reward_status");
|
|
888
899
|
}
|
|
889
900
|
function bt(e) {
|
|
890
|
-
return n(e, "
|
|
901
|
+
return n(e, "user_rewards") && o(e.user_rewards, G);
|
|
891
902
|
}
|
|
892
903
|
function qt(e) {
|
|
893
|
-
return n(e, "
|
|
904
|
+
return n(e, "scene");
|
|
894
905
|
}
|
|
895
906
|
function Rt(e) {
|
|
907
|
+
return n(e, "params");
|
|
908
|
+
}
|
|
909
|
+
function xt(e) {
|
|
896
910
|
return n(e, "img") && typeof e.img == "string";
|
|
897
911
|
}
|
|
898
|
-
class
|
|
912
|
+
class Wt {
|
|
899
913
|
constructor(t, r) {
|
|
900
914
|
u(this, "token");
|
|
901
915
|
u(this, "event", 0);
|
|
@@ -908,7 +922,7 @@ class Zt {
|
|
|
908
922
|
* https://kdocs.cn/l/cf2mO2uRLqh9?linkname=OWGSPF3Ysl
|
|
909
923
|
*/
|
|
910
924
|
async verifyMobileAllowed(t) {
|
|
911
|
-
const { data: r } = await this.req.get("verify-mobile-allowed",
|
|
925
|
+
const { data: r } = await this.req.get("verify-mobile-allowed", et, {
|
|
912
926
|
params: { mobile: t }
|
|
913
927
|
});
|
|
914
928
|
return r;
|
|
@@ -919,7 +933,7 @@ class Zt {
|
|
|
919
933
|
* https://kdocs.cn/l/ckWFDcOsYEUA?linkname=wFXxtdNKPm
|
|
920
934
|
*/
|
|
921
935
|
async getConfig() {
|
|
922
|
-
const { data: t } = await this.req.get(`event/${this.event}/event-config`,
|
|
936
|
+
const { data: t } = await this.req.get(`event/${this.event}/event-config`, Ee);
|
|
923
937
|
return t;
|
|
924
938
|
}
|
|
925
939
|
/**
|
|
@@ -928,7 +942,7 @@ class Zt {
|
|
|
928
942
|
* https://kdocs.cn/l/ckWFDcOsYEUA?linkname=ejPOcWMvT1
|
|
929
943
|
*/
|
|
930
944
|
async getEngagementsUserCount(t) {
|
|
931
|
-
const { data: r } = await this.req.get(`event/${this.event}/feature-engagement-count`,
|
|
945
|
+
const { data: r } = await this.req.get(`event/${this.event}/feature-engagement-count`, w, {
|
|
932
946
|
params: { feature_id: t, type: "user" }
|
|
933
947
|
});
|
|
934
948
|
return (r == null ? void 0 : r.count) ?? null;
|
|
@@ -939,7 +953,7 @@ class Zt {
|
|
|
939
953
|
* https://kdocs.cn/l/ckWFDcOsYEUA?linkname=ejPOcWMvT1
|
|
940
954
|
*/
|
|
941
955
|
async getEngagementsCount(t) {
|
|
942
|
-
const { data: r } = await this.req.get(`event/${this.event}/feature-engagement-count`,
|
|
956
|
+
const { data: r } = await this.req.get(`event/${this.event}/feature-engagement-count`, w, {
|
|
943
957
|
params: { feature_id: t, type: "engagement" }
|
|
944
958
|
});
|
|
945
959
|
return (r == null ? void 0 : r.count) ?? null;
|
|
@@ -950,7 +964,7 @@ class Zt {
|
|
|
950
964
|
* https://kdocs.cn/l/ckWFDcOsYEUA?linkname=THtZ4ewIQW
|
|
951
965
|
*/
|
|
952
966
|
async getEngagements(t) {
|
|
953
|
-
const { data: r } = await this.req.get(`event/${this.event}/feature-engagements`,
|
|
967
|
+
const { data: r } = await this.req.get(`event/${this.event}/feature-engagements`, tt, {
|
|
954
968
|
params: { feature_id: t }
|
|
955
969
|
});
|
|
956
970
|
return (r == null ? void 0 : r.engagements) || [];
|
|
@@ -965,7 +979,7 @@ class Zt {
|
|
|
965
979
|
const { data: r, code: i } = await this.req.post(
|
|
966
980
|
`event/${this.event}/visit`,
|
|
967
981
|
s(t || {}),
|
|
968
|
-
|
|
982
|
+
rt
|
|
969
983
|
);
|
|
970
984
|
return r ?? {
|
|
971
985
|
error: i
|
|
@@ -980,7 +994,7 @@ class Zt {
|
|
|
980
994
|
*/
|
|
981
995
|
async getUserFeatureStatus(t) {
|
|
982
996
|
if (!await this.token.autoLogin()) return [];
|
|
983
|
-
const { data: r } = await this.req.get("event/user-feature-status",
|
|
997
|
+
const { data: r } = await this.req.get("event/user-feature-status", nt, {
|
|
984
998
|
params: s({ ...t, event_id: this.event }),
|
|
985
999
|
message: !1
|
|
986
1000
|
});
|
|
@@ -993,7 +1007,7 @@ class Zt {
|
|
|
993
1007
|
*/
|
|
994
1008
|
async getUserEngagements(t) {
|
|
995
1009
|
if (!await this.token.autoLogin()) return [];
|
|
996
|
-
const { data: r } = await this.req.get(`event/${this.event}/user-engagements`,
|
|
1010
|
+
const { data: r } = await this.req.get(`event/${this.event}/user-engagements`, it, {
|
|
997
1011
|
params: { feature_id: t }
|
|
998
1012
|
});
|
|
999
1013
|
return (r == null ? void 0 : r.engagements) || [];
|
|
@@ -1020,7 +1034,7 @@ class Zt {
|
|
|
1020
1034
|
const { data: r, code: i } = await this.req.post(
|
|
1021
1035
|
`event/${this.event}/claim-rewards`,
|
|
1022
1036
|
s(t),
|
|
1023
|
-
|
|
1037
|
+
vt
|
|
1024
1038
|
);
|
|
1025
1039
|
return (r == null ? void 0 : r.claimed_items) ?? {
|
|
1026
1040
|
error: i
|
|
@@ -1036,7 +1050,7 @@ class Zt {
|
|
|
1036
1050
|
const { data: r, code: i } = await this.req.post(
|
|
1037
1051
|
`event/${this.event}/claim-weixin-hongbao`,
|
|
1038
1052
|
{ reward_id: t },
|
|
1039
|
-
|
|
1053
|
+
kt
|
|
1040
1054
|
);
|
|
1041
1055
|
return r ?? {
|
|
1042
1056
|
error: i
|
|
@@ -1052,7 +1066,7 @@ class Zt {
|
|
|
1052
1066
|
const { data: r } = await this.req.post(
|
|
1053
1067
|
"event/user-rewards",
|
|
1054
1068
|
s({ ...t, event_id: this.event }),
|
|
1055
|
-
|
|
1069
|
+
bt
|
|
1056
1070
|
);
|
|
1057
1071
|
return (r == null ? void 0 : r.user_rewards) || [];
|
|
1058
1072
|
}
|
|
@@ -1063,7 +1077,7 @@ class Zt {
|
|
|
1063
1077
|
*/
|
|
1064
1078
|
async getUserItemCount(t) {
|
|
1065
1079
|
if (!await this.token.autoLogin()) return null;
|
|
1066
|
-
const { data: r } = await this.req.get(`event/${this.event}/user-item-count`,
|
|
1080
|
+
const { data: r } = await this.req.get(`event/${this.event}/user-item-count`, w, {
|
|
1067
1081
|
params: { item_id: t }
|
|
1068
1082
|
});
|
|
1069
1083
|
return (r == null ? void 0 : r.count) ?? null;
|
|
@@ -1087,7 +1101,7 @@ class Zt {
|
|
|
1087
1101
|
*/
|
|
1088
1102
|
async getUnlimitQrcodeScene(t) {
|
|
1089
1103
|
if (!await this.token.autoLogin()) return null;
|
|
1090
|
-
const { data: r } = await this.req.get("event/unlimit-qrcode-scene",
|
|
1104
|
+
const { data: r } = await this.req.get("event/unlimit-qrcode-scene", qt, {
|
|
1091
1105
|
params: { params: t }
|
|
1092
1106
|
});
|
|
1093
1107
|
return (r == null ? void 0 : r.scene) ?? null;
|
|
@@ -1100,7 +1114,7 @@ class Zt {
|
|
|
1100
1114
|
* @param scene - 小程序码 scene 值
|
|
1101
1115
|
*/
|
|
1102
1116
|
async getParamsByQrcodeScene(t) {
|
|
1103
|
-
const { data: r } = await this.req.get("event/params-by-qrcode-scene",
|
|
1117
|
+
const { data: r } = await this.req.get("event/params-by-qrcode-scene", Rt, {
|
|
1104
1118
|
params: { scene: t }
|
|
1105
1119
|
});
|
|
1106
1120
|
return (r == null ? void 0 : r.params) ?? null;
|
|
@@ -1112,23 +1126,23 @@ class Zt {
|
|
|
1112
1126
|
*/
|
|
1113
1127
|
async generateUnlimitQrcode(t) {
|
|
1114
1128
|
if (!await this.token.autoLogin()) return null;
|
|
1115
|
-
const { data: r } = await this.req.post("event/unlimit-qrcode", s(t),
|
|
1129
|
+
const { data: r } = await this.req.post("event/unlimit-qrcode", s(t), xt);
|
|
1116
1130
|
return (r == null ? void 0 : r.img) ?? null;
|
|
1117
1131
|
}
|
|
1118
1132
|
}
|
|
1119
1133
|
function F(e) {
|
|
1120
1134
|
return n(e, "forum_id", "icon_url", "name", "tags", "sort", "mode", "member_ids") && Array.isArray(e.tags) && Array.isArray(e.member_ids);
|
|
1121
1135
|
}
|
|
1122
|
-
function
|
|
1123
|
-
return n(e, "forums") &&
|
|
1136
|
+
function At(e) {
|
|
1137
|
+
return n(e, "forums") && o(e.forums, F);
|
|
1124
1138
|
}
|
|
1125
1139
|
function b(e) {
|
|
1126
1140
|
return n(e, "topic_id", "cover_url", "name", "description", "tags", "post_num") && Array.isArray(e.tags);
|
|
1127
1141
|
}
|
|
1128
|
-
function At(e) {
|
|
1129
|
-
return n(e, "topics") && a(e.topics, b);
|
|
1130
|
-
}
|
|
1131
1142
|
function Lt(e) {
|
|
1143
|
+
return n(e, "topics") && o(e.topics, b);
|
|
1144
|
+
}
|
|
1145
|
+
function Ct(e) {
|
|
1132
1146
|
return n(e, "topic") && b(e.topic);
|
|
1133
1147
|
}
|
|
1134
1148
|
function q(e) {
|
|
@@ -1151,18 +1165,18 @@ function q(e) {
|
|
|
1151
1165
|
"is_highlighted",
|
|
1152
1166
|
"status",
|
|
1153
1167
|
"create_time"
|
|
1154
|
-
) &&
|
|
1168
|
+
) && o(e.topics, b) && F(e.forum);
|
|
1155
1169
|
}
|
|
1156
|
-
function
|
|
1157
|
-
return n(e, "next_token", "posts") &&
|
|
1170
|
+
function $(e) {
|
|
1171
|
+
return n(e, "next_token", "posts") && o(e.posts, q);
|
|
1158
1172
|
}
|
|
1159
|
-
function
|
|
1173
|
+
function Ut(e) {
|
|
1160
1174
|
return n(e, "post") && q(e.post);
|
|
1161
1175
|
}
|
|
1162
1176
|
function R(e) {
|
|
1163
1177
|
return n(e);
|
|
1164
1178
|
}
|
|
1165
|
-
function
|
|
1179
|
+
function $t(e) {
|
|
1166
1180
|
return n(e) && ("post" in e ? q(e.post) : !0) && ("antispam" in e ? R(e.antispam) : !0);
|
|
1167
1181
|
}
|
|
1168
1182
|
function g(e) {
|
|
@@ -1180,13 +1194,13 @@ function g(e) {
|
|
|
1180
1194
|
"image_url",
|
|
1181
1195
|
"create_time",
|
|
1182
1196
|
"status"
|
|
1183
|
-
) && ("replies" in e ?
|
|
1197
|
+
) && ("replies" in e ? o(e.replies, x) : !0);
|
|
1184
1198
|
}
|
|
1185
1199
|
function Pt(e) {
|
|
1186
1200
|
return n(e, "comment") && g(e.comment);
|
|
1187
1201
|
}
|
|
1188
|
-
function
|
|
1189
|
-
return n(e, "comments") &&
|
|
1202
|
+
function St(e) {
|
|
1203
|
+
return n(e, "comments") && o(e.comments, g);
|
|
1190
1204
|
}
|
|
1191
1205
|
function x(e) {
|
|
1192
1206
|
return n(
|
|
@@ -1201,27 +1215,27 @@ function x(e) {
|
|
|
1201
1215
|
"liked",
|
|
1202
1216
|
"reply_to",
|
|
1203
1217
|
"create_time"
|
|
1204
|
-
) &&
|
|
1205
|
-
}
|
|
1206
|
-
function St(e) {
|
|
1207
|
-
return n(e, "reply_id", "replied_by", "avatar_url", "nickname");
|
|
1218
|
+
) && Dt(e.reply_to);
|
|
1208
1219
|
}
|
|
1209
1220
|
function Dt(e) {
|
|
1210
|
-
return n(e
|
|
1221
|
+
return n(e, "reply_id", "replied_by", "avatar_url", "nickname");
|
|
1211
1222
|
}
|
|
1212
1223
|
function Et(e) {
|
|
1213
|
-
return n(e
|
|
1224
|
+
return n(e) && ("comment" in e ? g(e.comment) : !0) && ("antispam" in e ? R(e.antispam) : !0);
|
|
1214
1225
|
}
|
|
1215
1226
|
function Gt(e) {
|
|
1216
|
-
return n(e, "
|
|
1227
|
+
return n(e, "replies") && o(e.replies, x);
|
|
1217
1228
|
}
|
|
1218
1229
|
function Ft(e) {
|
|
1219
|
-
return n(e
|
|
1230
|
+
return n(e, "reply") && x(e.reply);
|
|
1220
1231
|
}
|
|
1221
1232
|
function It(e) {
|
|
1222
|
-
return n(e
|
|
1233
|
+
return n(e) && ("reply" in e ? g(e.comment) : !0) && ("antispam" in e ? R(e.antispam) : !0);
|
|
1223
1234
|
}
|
|
1224
1235
|
function Bt(e) {
|
|
1236
|
+
return n(e, "image_url", "upload_url", "existed") && typeof e.existed == "boolean";
|
|
1237
|
+
}
|
|
1238
|
+
function Vt(e) {
|
|
1225
1239
|
return n(
|
|
1226
1240
|
e,
|
|
1227
1241
|
"notification_id",
|
|
@@ -1233,14 +1247,14 @@ function Bt(e) {
|
|
|
1233
1247
|
"origin_user_avatar_url"
|
|
1234
1248
|
);
|
|
1235
1249
|
}
|
|
1236
|
-
function Vt(e) {
|
|
1237
|
-
return n(e, "notifications") && a(e.notifications, Bt);
|
|
1238
|
-
}
|
|
1239
1250
|
function Qt(e) {
|
|
1251
|
+
return n(e, "notifications") && o(e.notifications, Vt);
|
|
1252
|
+
}
|
|
1253
|
+
function Tt(e) {
|
|
1240
1254
|
return n(e, "system", "comment", "like");
|
|
1241
1255
|
}
|
|
1242
|
-
var Mt = /* @__PURE__ */ ((e) => (e.All = "all", e.Limit = "limit", e))(Mt || {}), Ht = /* @__PURE__ */ ((e) => (e.Pending = "pending", e.Approved = "approved", e.Failed = "failed", e.Suspect = "suspect", e))(Ht || {}),
|
|
1243
|
-
class
|
|
1256
|
+
var Mt = /* @__PURE__ */ ((e) => (e.All = "all", e.Limit = "limit", e))(Mt || {}), Ht = /* @__PURE__ */ ((e) => (e.Pending = "pending", e.Approved = "approved", e.Failed = "failed", e.Suspect = "suspect", e))(Ht || {}), jt = /* @__PURE__ */ ((e) => (e.System = "system", e.Comment = "comment", e.Like = "like", e))(jt || {}), zt = /* @__PURE__ */ ((e) => (e.System = "system", e.PostPinned = "post_pinned", e.PostHighlighted = "post_highlighted", e.PostDeleted = "post_deleted", e.PostCommented = "post_commented", e.PostLiked = "post_liked", e.CommentReplied = "comment_replied", e.CommentLiked = "comment_liked", e.CommentDeleted = "comment_deleted", e.ReplyReplied = "reply_replied", e.ReplyLiked = "reply_liked", e.ReplyDeleted = "reply_deleted", e))(zt || {});
|
|
1257
|
+
class er {
|
|
1244
1258
|
constructor(t) {
|
|
1245
1259
|
u(this, "token");
|
|
1246
1260
|
u(this, "req");
|
|
@@ -1252,7 +1266,7 @@ class Wt {
|
|
|
1252
1266
|
* https://kdocs.cn/l/cbggfJodHLIz?linkname=QaqUa2K0z0
|
|
1253
1267
|
*/
|
|
1254
1268
|
async getForums() {
|
|
1255
|
-
const { data: t } = await this.req.get("community/forums",
|
|
1269
|
+
const { data: t } = await this.req.get("community/forums", At);
|
|
1256
1270
|
return (t == null ? void 0 : t.forums) || [];
|
|
1257
1271
|
}
|
|
1258
1272
|
/**
|
|
@@ -1261,7 +1275,7 @@ class Wt {
|
|
|
1261
1275
|
* https://kdocs.cn/l/cbggfJodHLIz?linkname=mIwpymAQom
|
|
1262
1276
|
*/
|
|
1263
1277
|
async getTopics() {
|
|
1264
|
-
const { data: t } = await this.req.get("community/topics",
|
|
1278
|
+
const { data: t } = await this.req.get("community/topics", Lt);
|
|
1265
1279
|
return (t == null ? void 0 : t.topics) || [];
|
|
1266
1280
|
}
|
|
1267
1281
|
/**
|
|
@@ -1270,7 +1284,7 @@ class Wt {
|
|
|
1270
1284
|
* https://kdocs.cn/l/cbggfJodHLIz?linkname=Jvw7xMK31K
|
|
1271
1285
|
*/
|
|
1272
1286
|
async getTopic(t) {
|
|
1273
|
-
const { data: r, code: i } = await this.req.get("community/topic",
|
|
1287
|
+
const { data: r, code: i } = await this.req.get("community/topic", Ct, {
|
|
1274
1288
|
params: { topic_id: t }
|
|
1275
1289
|
});
|
|
1276
1290
|
return (r == null ? void 0 : r.topic) ?? { error: i };
|
|
@@ -1281,7 +1295,7 @@ class Wt {
|
|
|
1281
1295
|
* https://kdocs.cn/l/cbggfJodHLIz?linkname=XKI9lDVrPq
|
|
1282
1296
|
*/
|
|
1283
1297
|
async getPosts(t) {
|
|
1284
|
-
const { data: r, code: i } = await this.req.get("community/posts",
|
|
1298
|
+
const { data: r, code: i } = await this.req.get("community/posts", $, {
|
|
1285
1299
|
params: s(t)
|
|
1286
1300
|
});
|
|
1287
1301
|
return r ?? { error: i };
|
|
@@ -1292,7 +1306,7 @@ class Wt {
|
|
|
1292
1306
|
* https://kdocs.cn/l/cbggfJodHLIz?linkname=yXubbZuDlC
|
|
1293
1307
|
*/
|
|
1294
1308
|
async getPinnedPosts(t, r, i) {
|
|
1295
|
-
const { data: c, code: d } = await this.req.get("community/pinned-posts",
|
|
1309
|
+
const { data: c, code: d } = await this.req.get("community/pinned-posts", $, {
|
|
1296
1310
|
params: s({ forum_id: t, max_results: r, next_token: i })
|
|
1297
1311
|
});
|
|
1298
1312
|
return c ?? { error: d };
|
|
@@ -1303,7 +1317,7 @@ class Wt {
|
|
|
1303
1317
|
* https://kdocs.cn/l/cbggfJodHLIz?linkname=hj1AZy5rcP
|
|
1304
1318
|
*/
|
|
1305
1319
|
async getPost(t) {
|
|
1306
|
-
const { data: r, code: i } = await this.req.get("community/post",
|
|
1320
|
+
const { data: r, code: i } = await this.req.get("community/post", Ut, {
|
|
1307
1321
|
params: { post_id: t }
|
|
1308
1322
|
});
|
|
1309
1323
|
return (r == null ? void 0 : r.post) ?? { error: i };
|
|
@@ -1314,7 +1328,7 @@ class Wt {
|
|
|
1314
1328
|
* https://kdocs.cn/l/cbggfJodHLIz?linkname=M5okHBuaVk
|
|
1315
1329
|
*/
|
|
1316
1330
|
async post(t) {
|
|
1317
|
-
const { data: r, code: i } = await this.req.post("community/post", s(t),
|
|
1331
|
+
const { data: r, code: i } = await this.req.post("community/post", s(t), $t);
|
|
1318
1332
|
return r ?? {
|
|
1319
1333
|
error: i
|
|
1320
1334
|
};
|
|
@@ -1325,7 +1339,7 @@ class Wt {
|
|
|
1325
1339
|
* https://kdocs.cn/l/cbggfJodHLIz?linkname=djKbX7lFdp
|
|
1326
1340
|
*/
|
|
1327
1341
|
async getComments(t) {
|
|
1328
|
-
const { data: r, code: i } = await this.req.get("community/comments",
|
|
1342
|
+
const { data: r, code: i } = await this.req.get("community/comments", St, {
|
|
1329
1343
|
params: s(t)
|
|
1330
1344
|
});
|
|
1331
1345
|
return r ?? { error: i };
|
|
@@ -1348,7 +1362,7 @@ class Wt {
|
|
|
1348
1362
|
*/
|
|
1349
1363
|
async comment(t) {
|
|
1350
1364
|
await this.token.autoLogin();
|
|
1351
|
-
const { data: r, code: i } = await this.req.post("community/comment", s(t),
|
|
1365
|
+
const { data: r, code: i } = await this.req.post("community/comment", s(t), Et);
|
|
1352
1366
|
return r ?? {
|
|
1353
1367
|
error: i
|
|
1354
1368
|
};
|
|
@@ -1359,7 +1373,7 @@ class Wt {
|
|
|
1359
1373
|
* https://kdocs.cn/l/cbggfJodHLIz?linkname=sVKBbY83MY
|
|
1360
1374
|
*/
|
|
1361
1375
|
async getReplies(t) {
|
|
1362
|
-
const { data: r } = await this.req.get("community/replies",
|
|
1376
|
+
const { data: r } = await this.req.get("community/replies", Gt, {
|
|
1363
1377
|
params: s({ max_results: 20, ...t })
|
|
1364
1378
|
});
|
|
1365
1379
|
return r ?? { replies: [] };
|
|
@@ -1370,7 +1384,7 @@ class Wt {
|
|
|
1370
1384
|
* https://kdocs.cn/l/cbggfJodHLIz?linkname=kxhcSXD3MG
|
|
1371
1385
|
*/
|
|
1372
1386
|
async getReply(t) {
|
|
1373
|
-
const { data: r, code: i } = await this.req.get("community/reply",
|
|
1387
|
+
const { data: r, code: i } = await this.req.get("community/reply", Ft, {
|
|
1374
1388
|
params: { reply_id: t }
|
|
1375
1389
|
});
|
|
1376
1390
|
return (r == null ? void 0 : r.reply) ?? { error: i };
|
|
@@ -1382,7 +1396,7 @@ class Wt {
|
|
|
1382
1396
|
*/
|
|
1383
1397
|
async reply(t) {
|
|
1384
1398
|
await this.token.autoLogin();
|
|
1385
|
-
const { data: r, code: i } = await this.req.post("community/reply", s(t),
|
|
1399
|
+
const { data: r, code: i } = await this.req.post("community/reply", s(t), It);
|
|
1386
1400
|
return r ?? {
|
|
1387
1401
|
error: i
|
|
1388
1402
|
};
|
|
@@ -1418,7 +1432,7 @@ class Wt {
|
|
|
1418
1432
|
*/
|
|
1419
1433
|
async getMediaPresignUrl(t) {
|
|
1420
1434
|
await this.token.autoLogin();
|
|
1421
|
-
const { data: r } = await this.req.get("community/media-presign-url",
|
|
1435
|
+
const { data: r } = await this.req.get("community/media-presign-url", Bt, {
|
|
1422
1436
|
params: t
|
|
1423
1437
|
});
|
|
1424
1438
|
return r;
|
|
@@ -1432,7 +1446,7 @@ class Wt {
|
|
|
1432
1446
|
*/
|
|
1433
1447
|
async getNotifications(t) {
|
|
1434
1448
|
await this.token.autoLogin();
|
|
1435
|
-
const { data: r } = await this.req.get("community/notifications",
|
|
1449
|
+
const { data: r } = await this.req.get("community/notifications", Qt, {
|
|
1436
1450
|
params: s({ max_results: 20, ...t })
|
|
1437
1451
|
});
|
|
1438
1452
|
return r || { notifications: [] };
|
|
@@ -1444,7 +1458,7 @@ class Wt {
|
|
|
1444
1458
|
*/
|
|
1445
1459
|
async getUnreadNotificationsCount() {
|
|
1446
1460
|
if (!await this.token.autoLogin()) return null;
|
|
1447
|
-
const { data: t } = await this.req.get("community/unread-notifications-count",
|
|
1461
|
+
const { data: t } = await this.req.get("community/unread-notifications-count", Tt);
|
|
1448
1462
|
return t;
|
|
1449
1463
|
}
|
|
1450
1464
|
/**
|
|
@@ -1458,12 +1472,12 @@ class Wt {
|
|
|
1458
1472
|
return r;
|
|
1459
1473
|
}
|
|
1460
1474
|
}
|
|
1461
|
-
function
|
|
1475
|
+
function y(e) {
|
|
1462
1476
|
return n(e, "openid", "unionid", "weixin_token");
|
|
1463
1477
|
}
|
|
1464
|
-
var
|
|
1465
|
-
const
|
|
1466
|
-
class
|
|
1478
|
+
var Jt = /* @__PURE__ */ ((e) => (e.RedirectUriDisMatch = "10003", e.AppidError = "10016", e.AuthorizationError = "10015", e.NoRightForScope = "10005", e.Frequently = "10009", e.AppBanded = "10004", e.ShouldFllow = "10006", e.ScopeNull = "10010", e.RedirectUriNull = "10011", e.AppidNull = "10012", e.StateNull = "10013", e))(Jt || {});
|
|
1479
|
+
const P = "wx_login_cache";
|
|
1480
|
+
class tr {
|
|
1467
1481
|
/**
|
|
1468
1482
|
* 创建微信相关功能接口
|
|
1469
1483
|
*
|
|
@@ -1491,11 +1505,11 @@ class er {
|
|
|
1491
1505
|
* 也可以直接调用 login 方法,并传入 wxcode 的读取函数
|
|
1492
1506
|
*/
|
|
1493
1507
|
async getLoginCache() {
|
|
1494
|
-
const t = this.token.storage.get(
|
|
1508
|
+
const t = this.token.storage.get(P);
|
|
1495
1509
|
if (!t)
|
|
1496
1510
|
return null;
|
|
1497
1511
|
const r = K(t);
|
|
1498
|
-
return
|
|
1512
|
+
return y(r) ? (this.token.weixinToken = r.weixin_token, await this.token.autoLogin(), r) : null;
|
|
1499
1513
|
}
|
|
1500
1514
|
/**
|
|
1501
1515
|
* 小程序页面微信静默登录,获取 weixinToken / openid / unionid。
|
|
@@ -1518,13 +1532,13 @@ class er {
|
|
|
1518
1532
|
const t = await this.getLoginCache();
|
|
1519
1533
|
if (t)
|
|
1520
1534
|
return t;
|
|
1521
|
-
const r = await
|
|
1535
|
+
const r = await X(), { data: i, code: c } = await this.req.post(
|
|
1522
1536
|
"weixin/login",
|
|
1523
1537
|
{ code: r, appid: this.appid },
|
|
1524
|
-
|
|
1538
|
+
y,
|
|
1525
1539
|
{ message: !1 }
|
|
1526
1540
|
);
|
|
1527
|
-
return i && (this.token.weixinToken = i.weixin_token, this.token.storage.set(
|
|
1541
|
+
return i && (this.token.weixinToken = i.weixin_token, this.token.storage.set(P, JSON.stringify(i)), await this.token.autoLogin()), i ?? { error: c };
|
|
1528
1542
|
}
|
|
1529
1543
|
/**
|
|
1530
1544
|
* 在微信内嵌网页中调用微信公众号授权登录【暂未启用】
|
|
@@ -1561,7 +1575,7 @@ class er {
|
|
|
1561
1575
|
code: r,
|
|
1562
1576
|
appid: this.appid
|
|
1563
1577
|
},
|
|
1564
|
-
|
|
1578
|
+
y
|
|
1565
1579
|
);
|
|
1566
1580
|
return p && (this.token.weixinToken = p.weixin_token, await this.token.autoLogin()), p ?? { error: I };
|
|
1567
1581
|
}
|
|
@@ -1590,33 +1604,33 @@ class er {
|
|
|
1590
1604
|
}
|
|
1591
1605
|
}
|
|
1592
1606
|
export {
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1607
|
+
Yt as AuthToken,
|
|
1608
|
+
Ce as CliamRewardStatus,
|
|
1609
|
+
Zt as ClubApi,
|
|
1596
1610
|
ye as ClubCreditChangeSence,
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1611
|
+
we as ClubCreditChangeType,
|
|
1612
|
+
he as ClubItemType,
|
|
1613
|
+
ve as ClubRedemptionStatus,
|
|
1614
|
+
er as CommunityApi,
|
|
1615
|
+
be as EngageAccountType,
|
|
1616
|
+
Wt as EventApi,
|
|
1617
|
+
qe as EventPeriodType,
|
|
1618
|
+
a as FeatureType,
|
|
1605
1619
|
Mt as ForumMode,
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1620
|
+
ke as GamerItemType,
|
|
1621
|
+
fe as Gender,
|
|
1622
|
+
De as LotteryDrawAction,
|
|
1609
1623
|
Pe as LotteryTicketStatus,
|
|
1610
|
-
|
|
1611
|
-
|
|
1624
|
+
jt as NotificationCategory,
|
|
1625
|
+
zt as NotificationType,
|
|
1612
1626
|
Ht as PostStatus,
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1627
|
+
Re as QuestObjective,
|
|
1628
|
+
Ue as RewardSoure,
|
|
1629
|
+
Ae as RewardStatusPrefix,
|
|
1630
|
+
Le as RewardStatusSuffix,
|
|
1631
|
+
Se as TeamAction,
|
|
1632
|
+
$e as TeamVisibility,
|
|
1633
|
+
xe as VoteOptionSource,
|
|
1634
|
+
tr as WeixinApi,
|
|
1635
|
+
Jt as WeixinWebLoginErrorCode
|
|
1622
1636
|
};
|
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": "1.1.
|
|
4
|
+
"version": "1.1.3",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "index.ts",
|
|
7
7
|
"main": "./dist/index.js",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/node": "^22.13.1",
|
|
25
25
|
"@seayoo-web/combo-webview": "^2.5.0",
|
|
26
|
-
"@seayoo-web/request": "^2.1.2",
|
|
27
26
|
"@seayoo-web/utils": "^3.0.10",
|
|
28
27
|
"@seayoo-web/tsconfig": "^1.0.3",
|
|
28
|
+
"@seayoo-web/request": "^2.1.2",
|
|
29
29
|
"@seayoo-web/scripts": "^1.3.9"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
@@ -9,7 +9,7 @@ export interface EventConfig {
|
|
|
9
9
|
/** 活动结束时间 */
|
|
10
10
|
until: number;
|
|
11
11
|
/** 活动访问人数 */
|
|
12
|
-
visit_count
|
|
12
|
+
visit_count?: number;
|
|
13
13
|
/** 活动下玩法列表 */
|
|
14
14
|
features: EventFeatureConfig[];
|
|
15
15
|
}
|
|
@@ -28,6 +28,8 @@ interface EventRewardItemConfig {
|
|
|
28
28
|
reward_item_desc?: string;
|
|
29
29
|
/** 玩法奖励道具类型 */
|
|
30
30
|
reward_item_type: Exclude<GamerItemType, GamerItemType.GiftCode | GamerItemType.LotteryTicket>;
|
|
31
|
+
/** 奖励道具评级,用于前端展示 */
|
|
32
|
+
reward_item_rating: number;
|
|
31
33
|
}
|
|
32
34
|
type FeatureReward = {
|
|
33
35
|
feature_reward_type: "every";
|
|
@@ -50,7 +52,7 @@ interface EventFeatureBaseConfig<T extends FeatureType = FeatureType, C extends
|
|
|
50
52
|
/** 玩法类型 */
|
|
51
53
|
feature_type: T;
|
|
52
54
|
/** 玩法配置 */
|
|
53
|
-
config
|
|
55
|
+
config?: C;
|
|
54
56
|
/** 玩法周期,即每多长时间可参与一次 */
|
|
55
57
|
cycle: EventPeriodType;
|
|
56
58
|
/** 允许的最大参与次数 */
|
|
@@ -60,9 +62,9 @@ interface EventFeatureBaseConfig<T extends FeatureType = FeatureType, C extends
|
|
|
60
62
|
/** 玩法结束时间 */
|
|
61
63
|
until: number;
|
|
62
64
|
/** 参与玩法维度账号类型 */
|
|
63
|
-
|
|
65
|
+
engage_account: EngageAccountType;
|
|
64
66
|
/** 玩法参与奖励 */
|
|
65
|
-
feature_rewards
|
|
67
|
+
feature_rewards?: FeatureReward;
|
|
66
68
|
}
|
|
67
69
|
interface FeatureLotteryItemConfig {
|
|
68
70
|
/** 抽奖奖励道具 id */
|
|
@@ -50,6 +50,16 @@ export interface UserEngagement {
|
|
|
50
50
|
reward_id: number;
|
|
51
51
|
/** 奖励状态 */
|
|
52
52
|
reward_status: RewardStatusPrefix;
|
|
53
|
+
/** 道具数量 */
|
|
54
|
+
reward_item_amount: number;
|
|
55
|
+
/** 道具名称 */
|
|
56
|
+
reward_item_name: string;
|
|
57
|
+
/** 道具描述 */
|
|
58
|
+
reward_item_desc: string;
|
|
59
|
+
/** 道具图标 */
|
|
60
|
+
reward_item_icon_url: string;
|
|
61
|
+
/** 道具评级 */
|
|
62
|
+
reward_item_rating: number;
|
|
53
63
|
/** 奖励来源 */
|
|
54
64
|
reward_source: RewardSoure;
|
|
55
65
|
/** 附带的数据,由 feature_id 的类型决定 */
|
package/types/src/token.d.ts
CHANGED
package/types/src/utils.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare const console: Pick<Console, "log" | "error" | "warn">;
|
|
2
2
|
/** 检测是否在 combo webview */
|
|
3
3
|
export declare function inComboWebview(): boolean;
|
|
4
|
+
export declare function isRootEndpoint(path: string): boolean;
|
|
4
5
|
export declare function getWeixinLoginCode(): Promise<string>;
|
|
5
6
|
export type StorageHelper = {
|
|
6
7
|
set(key: string, value: string): void;
|