lxns-rhythm-api 0.1.0 → 0.1.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.
package/dist/index.cjs CHANGED
@@ -1 +1,383 @@
1
- "use strict";var v=Object.create;var o=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,R=Object.prototype.hasOwnProperty;var h=(r,e)=>{for(var t in e)o(r,t,{get:e[t],enumerable:!0})},x=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of T(e))!R.call(r,i)&&i!==t&&o(r,i,{get:()=>e[i],enumerable:!(n=P(e,i))||n.enumerable});return r};var C=(r,e,t)=>(t=r!=null?v(j(r)):{},x(e||!r||!r.__esModule?o(t,"default",{value:r,enumerable:!0}):t,r)),A=r=>x(o({},"__esModule",{value:!0}),r);var L={};h(L,{LxnsApiClient:()=>d,MaimaiModels:()=>y});module.exports=A(L);var y={};h(y,{LevelIndex:()=>S});var S=(s=>(s[s.BASIC=0]="BASIC",s[s.ADVANCED=1]="ADVANCED",s[s.EXPERT=2]="EXPERT",s[s.MASTER=3]="MASTER",s[s.RE_MASTER=4]="RE_MASTER",s))(S||{});var u=C(require("ky"),1);var D=["basic","advanced","expert","master","remaster"];function g(r){return r.reduce((e,t)=>(e[D[t.difficulty]]=t,e),{})}var a=class{id;title;artist;genre;version;bpm;difficulties;locked;disabled;rights;constructor(e){this.id=e.id,this.title=e.title,this.artist=e.artist,this.genre=e.genre,this.version=e.version,this.bpm=e.bpm,this.difficulties=e.difficulties,this.locked=e.locked??!1,this.disabled=e.disabled??!1,this.rights=e.rights}get standard(){return this.difficulties.standard.length===0?null:g(this.difficulties.standard)}get dx(){return this.difficulties.dx.length===0?null:g(this.difficulties.dx)}get utage(){return this.difficulties.utage?g(this.difficulties.utage):null}};var l=class{constructor(e){this.http=e}async getSongList(e,t){return this.http.get("song/list?",{searchParams:{version:e,notes:t}}).json()}async getSong(e){let t=await this.http.get(`song/${e}`).json();return new a(t)}async getAliasList(){return this.http.get("alias/list").json()}async getCollectionList(e,t){let n={trophy:"trophies",icon:"icons",plate:"plates",frame:"frames"};return this.http.get(`${e}/list`,{searchParams:{...t}}).json().then(i=>i[n[e]])}async getCollectionInfo(e,t,n){return this.http.get(`${e}/${t}`,{searchParams:{...n}}).json()}async getCollectionGenreList(e){return this.http.get("collection-genre/list",{searchParams:{...e}}).json()}async getCollectionGenreInfo(e,t){return this.http.get(`collection-genre/${e}`,{searchParams:{...t}}).json()}};var c=class{constructor(e){this.http=e}async postPlayer(e){return this.http.post("player",{json:e}).json()}async getPlayer(e){return this.http.get(`player/${e}`).json()}async getPlayerByQQ(e){return this.http.get(`player/qq/${e}`).json()}async getBests(e){return this.http.get(`player/${e}/bests`).json()}async getApBests(e){return this.http.get(`player/${e}/bests/ap`).json()}async getRecents(e){return this.http.get(`player/${e}/recents`).json()}async getAllBestScores(e){return this.http.get(`player/${e}/scores`).json()}async getHeatmap(e){return this.http.get(`player/${e}/heatmap`).json()}async getTrend(e){return this.http.get(`player/${e}/trend`).json()}async getScoreHistory(e){return this.http.get(`player/${e}/score/history`).json()}async getCollectionProgress(e,t,n){return this.http.get(`player/${e}/${t}/${n}`).json()}async postScores(e,t){let n={scores:t};return this.http.post(`player/${e}/scores`,{json:n}).json()}async postHtml(e,t){return this.http.post(`player/${e}/html`,{body:t,headers:{"content-type":"text/plain"}}).json()}};var p=class{constructor(e){this.http=e}async getPlayer(){return this.http.get("player").json()}async getScores(){return this.http.get("scores").json()}async postScores(e){let t={scores:e};return this.http.post("scores",{json:t}).json()}};var d=class{config={baseURL:"https://maimai.lxns.net/api/v0/"};maimai;constructor(e){this.config={baseURL:e?.baseURL??this.config.baseURL,personalAccessToken:e?.personalAccessToken,devAccessToken:e?.devAccessToken};let{baseURL:t,devAccessToken:n,personalAccessToken:i}=this.config,s=u.default.create({prefixUrl:new URL("maimai/",t)}),f=n?u.default.create({prefixUrl:new URL("maimai/",t),headers:{Authorization:n}}):void 0,b=i?u.default.create({prefixUrl:new URL("user/maimai/",t),headers:{"X-User-Token":i}}):void 0,m={public:new l(s)};f&&(m.dev=new c(f)),b&&(m.personal=new p(b)),this.maimai=m}};0&&(module.exports={LxnsApiClient,MaimaiModels});
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ LxnsApiClient: () => LxnsApiClient,
34
+ MaimaiModels: () => models_exports
35
+ });
36
+ module.exports = __toCommonJS(index_exports);
37
+
38
+ // src/apis/maimai/models.ts
39
+ var models_exports = {};
40
+ __export(models_exports, {
41
+ LevelIndex: () => LevelIndex
42
+ });
43
+ var LevelIndex = /* @__PURE__ */ ((LevelIndex2) => {
44
+ LevelIndex2[LevelIndex2["BASIC"] = 0] = "BASIC";
45
+ LevelIndex2[LevelIndex2["ADVANCED"] = 1] = "ADVANCED";
46
+ LevelIndex2[LevelIndex2["EXPERT"] = 2] = "EXPERT";
47
+ LevelIndex2[LevelIndex2["MASTER"] = 3] = "MASTER";
48
+ LevelIndex2[LevelIndex2["RE_MASTER"] = 4] = "RE_MASTER";
49
+ return LevelIndex2;
50
+ })(LevelIndex || {});
51
+
52
+ // src/client/LxnsApiCLient.ts
53
+ var import_ky = __toESM(require("ky"), 1);
54
+
55
+ // src/apis/maimai/entities/Song.ts
56
+ var LevelArray = [
57
+ "basic",
58
+ "advanced",
59
+ "expert",
60
+ "master",
61
+ "remaster"
62
+ ];
63
+ function convertDifficulty(difficulty) {
64
+ return difficulty.reduce(
65
+ (acc, cur) => {
66
+ acc[LevelArray[cur.difficulty]] = cur;
67
+ return acc;
68
+ },
69
+ {}
70
+ );
71
+ }
72
+ var Song = class {
73
+ id;
74
+ title;
75
+ artist;
76
+ genre;
77
+ version;
78
+ bpm;
79
+ difficulties;
80
+ locked;
81
+ disabled;
82
+ rights;
83
+ constructor(song) {
84
+ this.id = song.id;
85
+ this.title = song.title;
86
+ this.artist = song.artist;
87
+ this.genre = song.genre;
88
+ this.version = song.version;
89
+ this.bpm = song.bpm;
90
+ this.difficulties = song.difficulties;
91
+ this.locked = song.locked ?? false;
92
+ this.disabled = song.disabled ?? false;
93
+ this.rights = song.rights;
94
+ }
95
+ get standard() {
96
+ if (this.difficulties.standard.length === 0) return null;
97
+ return convertDifficulty(this.difficulties.standard);
98
+ }
99
+ get dx() {
100
+ if (this.difficulties.dx.length === 0) return null;
101
+ return convertDifficulty(this.difficulties.dx);
102
+ }
103
+ get utage() {
104
+ if (!this.difficulties.utage) return null;
105
+ return convertDifficulty(this.difficulties.utage);
106
+ }
107
+ };
108
+
109
+ // src/apis/maimai/public.ts
110
+ var MaimaiPublicApi = class {
111
+ constructor(http) {
112
+ this.http = http;
113
+ }
114
+ /**
115
+ * 获取歌曲列表
116
+ * @param version 版本,不填写遵循api默认行为
117
+ * @param notes 是否包含谱面信息,不填写遵循api默认行为
118
+ * @returns 歌曲列表
119
+ */
120
+ async getSongList(version, notes) {
121
+ return this.http.get("song/list?", { searchParams: { version, notes } }).json();
122
+ }
123
+ /**
124
+ * 获取歌曲信息
125
+ * @param id 歌曲 ID
126
+ * @returns 歌曲信息
127
+ */
128
+ async getSong(id) {
129
+ const songInfo = await this.http.get(`song/${id}`).json();
130
+ return new Song(songInfo);
131
+ }
132
+ /**
133
+ * 获取歌曲别名列表
134
+ * @returns 歌曲别名列表
135
+ */
136
+ async getAliasList() {
137
+ return this.http.get("alias/list").json();
138
+ }
139
+ /**
140
+ * 获取收藏品列表
141
+ * @param collectionType trophy | icon | plate | frame
142
+ * @param options.version 版本,不填写遵循api默认行为
143
+ * @param options.required 是否包含曲目需求,默认值为 false
144
+ * @returns 收藏品列表
145
+ */
146
+ async getCollectionList(collectionType, options) {
147
+ const collectionMap = {
148
+ trophy: "trophies",
149
+ icon: "icons",
150
+ plate: "plates",
151
+ frame: "frames"
152
+ };
153
+ return this.http.get(`${collectionType}/list`, { searchParams: { ...options } }).json().then((res) => res[collectionMap[collectionType]]);
154
+ }
155
+ /**
156
+ * 获取收藏品信息
157
+ * @param collectionType trophy | icon | plate | frame
158
+ * @param id 收藏品 ID
159
+ * @param options.version 版本,不填写遵循api默认行为
160
+ * @returns 收藏品信息
161
+ */
162
+ async getCollectionInfo(collectionType, id, options) {
163
+ return this.http.get(`${collectionType}/${id}`, { searchParams: { ...options } }).json();
164
+ }
165
+ /**
166
+ * 获取收藏品分类列表
167
+ * @param options.version 版本,不填写遵循api默认行为
168
+ * @returns 收藏品分类列表
169
+ */
170
+ async getCollectionGenreList(options) {
171
+ return this.http.get("collection-genre/list", { searchParams: { ...options } }).json();
172
+ }
173
+ /**
174
+ * 获取收藏品分类信息
175
+ * @param id 收藏品分类 ID
176
+ * @param options.version 版本,不填写遵循api默认行为
177
+ * @returns 收藏品分类信息
178
+ */
179
+ async getCollectionGenreInfo(id, options) {
180
+ return this.http.get(`collection-genre/${id}`, { searchParams: { ...options } }).json();
181
+ }
182
+ };
183
+
184
+ // src/apis/maimai/dev.ts
185
+ var MaimaiDevApi = class {
186
+ constructor(http) {
187
+ this.http = http;
188
+ }
189
+ /**
190
+ * 创建或修改玩家信息
191
+ * @param body 玩家信息
192
+ * @returns 玩家信息
193
+ */
194
+ async postPlayer(body) {
195
+ return this.http.post("player", { json: body }).json();
196
+ }
197
+ /**
198
+ * 获取玩家信息(通过好友码)
199
+ * @param friendCode 好友码
200
+ * @returns 玩家信息
201
+ */
202
+ async getPlayer(friendCode) {
203
+ return this.http.get(`player/${friendCode}`).json();
204
+ }
205
+ /**
206
+ * 获取玩家信息(通过 QQ 号)
207
+ * @param qq QQ 号
208
+ * @returns 玩家信息
209
+ */
210
+ async getPlayerByQQ(qq) {
211
+ return this.http.get(`player/qq/${qq}`).json();
212
+ }
213
+ /**
214
+ * 获取 Best 50(standard 35 + dx 15)
215
+ * @param friendCode 好友码
216
+ * @returns Best 50
217
+ */
218
+ async getBests(friendCode) {
219
+ return this.http.get(`player/${friendCode}/bests`).json();
220
+ }
221
+ /**
222
+ * 获取 AP 50
223
+ * @param friendCode 好友码
224
+ * @returns AP 50
225
+ */
226
+ async getApBests(friendCode) {
227
+ return this.http.get(`player/${friendCode}/bests/ap`).json();
228
+ }
229
+ /**
230
+ * 获取 Recent 50(仅增量爬取可用)
231
+ * @param friendCode 好友码
232
+ * @returns Recent 50
233
+ */
234
+ async getRecents(friendCode) {
235
+ return this.http.get(`player/${friendCode}/recents`).json();
236
+ }
237
+ /**
238
+ * 获取玩家缓存的所有最佳成绩(简化)
239
+ * @param friendCode 好友码
240
+ * @returns BestScoreList
241
+ */
242
+ async getAllBestScores(friendCode) {
243
+ return this.http.get(`player/${friendCode}/scores`).json();
244
+ }
245
+ /**
246
+ * 成绩上传热力图(YYYY-MM-DD -> 数量)
247
+ * @param friendCode 好友码
248
+ * @returns Heatmap
249
+ */
250
+ async getHeatmap(friendCode) {
251
+ return this.http.get(`player/${friendCode}/heatmap`).json();
252
+ }
253
+ /**
254
+ * DX Rating 趋势
255
+ * @param friendCode 好友码
256
+ * @returns TrendList
257
+ */
258
+ async getTrend(friendCode) {
259
+ return this.http.get(`player/${friendCode}/trend`).json();
260
+ }
261
+ /**
262
+ * 成绩游玩历史记录(仅返回带有 play_time 的成绩)
263
+ * @param friendCode 好友码
264
+ * @returns 游玩历史记录
265
+ */
266
+ async getScoreHistory(friendCode) {
267
+ return this.http.get(`player/${friendCode}/score/history`).json();
268
+ }
269
+ /**
270
+ * 获取玩家收藏品进度
271
+ * @param friendCode 好友码
272
+ * @param collectionType 收藏品类型
273
+ * @param collectionId 收藏品 ID
274
+ * @returns 收藏品进度
275
+ */
276
+ async getCollectionProgress(friendCode, collectionType, collectionId) {
277
+ return this.http.get(`player/${friendCode}/${collectionType}/${collectionId}`).json();
278
+ }
279
+ /**
280
+ * 上传玩家成绩
281
+ * @param friendCode 好友码
282
+ * @param scores 成绩列表
283
+ * @returns 上传结果
284
+ */
285
+ async postScores(friendCode, scores) {
286
+ const body = { scores };
287
+ return this.http.post(`player/${friendCode}/scores`, { json: body }).json();
288
+ }
289
+ /**
290
+ * 通过 NET 的 HTML 源代码上传玩家数据
291
+ * @param friendCode 好友码
292
+ * @param htmlSource HTML 源代码
293
+ * @returns 上传结果
294
+ */
295
+ async postHtml(friendCode, htmlSource) {
296
+ return this.http.post(`player/${friendCode}/html`, {
297
+ body: htmlSource,
298
+ headers: { "content-type": "text/plain" }
299
+ }).json();
300
+ }
301
+ };
302
+
303
+ // src/apis/maimai/personal.ts
304
+ var MaimaiPersonalApi = class {
305
+ constructor(http) {
306
+ this.http = http;
307
+ }
308
+ /**
309
+ * 获取玩家信息
310
+ * GET /api/v0/user/maimai/player
311
+ * @returns PlayerInfo
312
+ */
313
+ async getPlayer() {
314
+ return this.http.get("player").json();
315
+ }
316
+ /**
317
+ * 获取玩家所有成绩
318
+ * GET /api/v0/user/maimai/player/scores
319
+ * @returns PlayerScores
320
+ */
321
+ async getScores() {
322
+ return this.http.get("scores").json();
323
+ }
324
+ /**
325
+ * 上传玩家成绩
326
+ * POST /api/v0/user/maimai/player/scores
327
+ * @param scores 成绩列表
328
+ * @returns 上传结果
329
+ */
330
+ async postScores(scores) {
331
+ const body = { scores };
332
+ return this.http.post("scores", { json: body }).json();
333
+ }
334
+ };
335
+
336
+ // src/client/LxnsApiCLient.ts
337
+ var LxnsApiClient = class {
338
+ config = {
339
+ baseURL: "https://maimai.lxns.net/api/v0/"
340
+ };
341
+ /**
342
+ * maimai API
343
+ */
344
+ maimai;
345
+ constructor(config) {
346
+ this.config = {
347
+ baseURL: config?.baseURL ?? this.config.baseURL,
348
+ personalAccessToken: config?.personalAccessToken,
349
+ devAccessToken: config?.devAccessToken
350
+ };
351
+ const { baseURL, devAccessToken, personalAccessToken } = this.config;
352
+ const httpPublic = import_ky.default.create({
353
+ prefixUrl: new URL("maimai/", baseURL)
354
+ });
355
+ const httpDev = devAccessToken ? import_ky.default.create({
356
+ prefixUrl: new URL("maimai/", baseURL),
357
+ headers: {
358
+ Authorization: devAccessToken
359
+ }
360
+ }) : void 0;
361
+ const httpPersonal = personalAccessToken ? import_ky.default.create({
362
+ prefixUrl: new URL("user/maimai/", baseURL),
363
+ headers: {
364
+ "X-User-Token": personalAccessToken
365
+ }
366
+ }) : void 0;
367
+ const maimai = {
368
+ public: new MaimaiPublicApi(httpPublic)
369
+ };
370
+ if (httpDev) {
371
+ maimai.dev = new MaimaiDevApi(httpDev);
372
+ }
373
+ if (httpPersonal) {
374
+ maimai.personal = new MaimaiPersonalApi(httpPersonal);
375
+ }
376
+ this.maimai = maimai;
377
+ }
378
+ };
379
+ // Annotate the CommonJS export names for ESM import in node:
380
+ 0 && (module.exports = {
381
+ LxnsApiClient,
382
+ MaimaiModels
383
+ });
package/dist/index.js CHANGED
@@ -1 +1,351 @@
1
- var h=Object.defineProperty;var x=(s,e)=>{for(var t in e)h(s,t,{get:e[t],enumerable:!0})};var b={};x(b,{LevelIndex:()=>f});var f=(r=>(r[r.BASIC=0]="BASIC",r[r.ADVANCED=1]="ADVANCED",r[r.EXPERT=2]="EXPERT",r[r.MASTER=3]="MASTER",r[r.RE_MASTER=4]="RE_MASTER",r))(f||{});import d from"ky";var S=["basic","advanced","expert","master","remaster"];function u(s){return s.reduce((e,t)=>(e[S[t.difficulty]]=t,e),{})}var o=class{id;title;artist;genre;version;bpm;difficulties;locked;disabled;rights;constructor(e){this.id=e.id,this.title=e.title,this.artist=e.artist,this.genre=e.genre,this.version=e.version,this.bpm=e.bpm,this.difficulties=e.difficulties,this.locked=e.locked??!1,this.disabled=e.disabled??!1,this.rights=e.rights}get standard(){return this.difficulties.standard.length===0?null:u(this.difficulties.standard)}get dx(){return this.difficulties.dx.length===0?null:u(this.difficulties.dx)}get utage(){return this.difficulties.utage?u(this.difficulties.utage):null}};var a=class{constructor(e){this.http=e}async getSongList(e,t){return this.http.get("song/list?",{searchParams:{version:e,notes:t}}).json()}async getSong(e){let t=await this.http.get(`song/${e}`).json();return new o(t)}async getAliasList(){return this.http.get("alias/list").json()}async getCollectionList(e,t){let n={trophy:"trophies",icon:"icons",plate:"plates",frame:"frames"};return this.http.get(`${e}/list`,{searchParams:{...t}}).json().then(i=>i[n[e]])}async getCollectionInfo(e,t,n){return this.http.get(`${e}/${t}`,{searchParams:{...n}}).json()}async getCollectionGenreList(e){return this.http.get("collection-genre/list",{searchParams:{...e}}).json()}async getCollectionGenreInfo(e,t){return this.http.get(`collection-genre/${e}`,{searchParams:{...t}}).json()}};var l=class{constructor(e){this.http=e}async postPlayer(e){return this.http.post("player",{json:e}).json()}async getPlayer(e){return this.http.get(`player/${e}`).json()}async getPlayerByQQ(e){return this.http.get(`player/qq/${e}`).json()}async getBests(e){return this.http.get(`player/${e}/bests`).json()}async getApBests(e){return this.http.get(`player/${e}/bests/ap`).json()}async getRecents(e){return this.http.get(`player/${e}/recents`).json()}async getAllBestScores(e){return this.http.get(`player/${e}/scores`).json()}async getHeatmap(e){return this.http.get(`player/${e}/heatmap`).json()}async getTrend(e){return this.http.get(`player/${e}/trend`).json()}async getScoreHistory(e){return this.http.get(`player/${e}/score/history`).json()}async getCollectionProgress(e,t,n){return this.http.get(`player/${e}/${t}/${n}`).json()}async postScores(e,t){let n={scores:t};return this.http.post(`player/${e}/scores`,{json:n}).json()}async postHtml(e,t){return this.http.post(`player/${e}/html`,{body:t,headers:{"content-type":"text/plain"}}).json()}};var c=class{constructor(e){this.http=e}async getPlayer(){return this.http.get("player").json()}async getScores(){return this.http.get("scores").json()}async postScores(e){let t={scores:e};return this.http.post("scores",{json:t}).json()}};var m=class{config={baseURL:"https://maimai.lxns.net/api/v0/"};maimai;constructor(e){this.config={baseURL:e?.baseURL??this.config.baseURL,personalAccessToken:e?.personalAccessToken,devAccessToken:e?.devAccessToken};let{baseURL:t,devAccessToken:n,personalAccessToken:i}=this.config,r=d.create({prefixUrl:new URL("maimai/",t)}),y=n?d.create({prefixUrl:new URL("maimai/",t),headers:{Authorization:n}}):void 0,g=i?d.create({prefixUrl:new URL("user/maimai/",t),headers:{"X-User-Token":i}}):void 0,p={public:new a(r)};y&&(p.dev=new l(y)),g&&(p.personal=new c(g)),this.maimai=p}};export{m as LxnsApiClient,b as MaimaiModels};
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
7
+ // src/apis/maimai/models.ts
8
+ var models_exports = {};
9
+ __export(models_exports, {
10
+ LevelIndex: () => LevelIndex
11
+ });
12
+ var LevelIndex = /* @__PURE__ */ ((LevelIndex2) => {
13
+ LevelIndex2[LevelIndex2["BASIC"] = 0] = "BASIC";
14
+ LevelIndex2[LevelIndex2["ADVANCED"] = 1] = "ADVANCED";
15
+ LevelIndex2[LevelIndex2["EXPERT"] = 2] = "EXPERT";
16
+ LevelIndex2[LevelIndex2["MASTER"] = 3] = "MASTER";
17
+ LevelIndex2[LevelIndex2["RE_MASTER"] = 4] = "RE_MASTER";
18
+ return LevelIndex2;
19
+ })(LevelIndex || {});
20
+
21
+ // src/client/LxnsApiCLient.ts
22
+ import ky from "ky";
23
+
24
+ // src/apis/maimai/entities/Song.ts
25
+ var LevelArray = [
26
+ "basic",
27
+ "advanced",
28
+ "expert",
29
+ "master",
30
+ "remaster"
31
+ ];
32
+ function convertDifficulty(difficulty) {
33
+ return difficulty.reduce(
34
+ (acc, cur) => {
35
+ acc[LevelArray[cur.difficulty]] = cur;
36
+ return acc;
37
+ },
38
+ {}
39
+ );
40
+ }
41
+ var Song = class {
42
+ id;
43
+ title;
44
+ artist;
45
+ genre;
46
+ version;
47
+ bpm;
48
+ difficulties;
49
+ locked;
50
+ disabled;
51
+ rights;
52
+ constructor(song) {
53
+ this.id = song.id;
54
+ this.title = song.title;
55
+ this.artist = song.artist;
56
+ this.genre = song.genre;
57
+ this.version = song.version;
58
+ this.bpm = song.bpm;
59
+ this.difficulties = song.difficulties;
60
+ this.locked = song.locked ?? false;
61
+ this.disabled = song.disabled ?? false;
62
+ this.rights = song.rights;
63
+ }
64
+ get standard() {
65
+ if (this.difficulties.standard.length === 0) return null;
66
+ return convertDifficulty(this.difficulties.standard);
67
+ }
68
+ get dx() {
69
+ if (this.difficulties.dx.length === 0) return null;
70
+ return convertDifficulty(this.difficulties.dx);
71
+ }
72
+ get utage() {
73
+ if (!this.difficulties.utage) return null;
74
+ return convertDifficulty(this.difficulties.utage);
75
+ }
76
+ };
77
+
78
+ // src/apis/maimai/public.ts
79
+ var MaimaiPublicApi = class {
80
+ constructor(http) {
81
+ this.http = http;
82
+ }
83
+ /**
84
+ * 获取歌曲列表
85
+ * @param version 版本,不填写遵循api默认行为
86
+ * @param notes 是否包含谱面信息,不填写遵循api默认行为
87
+ * @returns 歌曲列表
88
+ */
89
+ async getSongList(version, notes) {
90
+ return this.http.get("song/list?", { searchParams: { version, notes } }).json();
91
+ }
92
+ /**
93
+ * 获取歌曲信息
94
+ * @param id 歌曲 ID
95
+ * @returns 歌曲信息
96
+ */
97
+ async getSong(id) {
98
+ const songInfo = await this.http.get(`song/${id}`).json();
99
+ return new Song(songInfo);
100
+ }
101
+ /**
102
+ * 获取歌曲别名列表
103
+ * @returns 歌曲别名列表
104
+ */
105
+ async getAliasList() {
106
+ return this.http.get("alias/list").json();
107
+ }
108
+ /**
109
+ * 获取收藏品列表
110
+ * @param collectionType trophy | icon | plate | frame
111
+ * @param options.version 版本,不填写遵循api默认行为
112
+ * @param options.required 是否包含曲目需求,默认值为 false
113
+ * @returns 收藏品列表
114
+ */
115
+ async getCollectionList(collectionType, options) {
116
+ const collectionMap = {
117
+ trophy: "trophies",
118
+ icon: "icons",
119
+ plate: "plates",
120
+ frame: "frames"
121
+ };
122
+ return this.http.get(`${collectionType}/list`, { searchParams: { ...options } }).json().then((res) => res[collectionMap[collectionType]]);
123
+ }
124
+ /**
125
+ * 获取收藏品信息
126
+ * @param collectionType trophy | icon | plate | frame
127
+ * @param id 收藏品 ID
128
+ * @param options.version 版本,不填写遵循api默认行为
129
+ * @returns 收藏品信息
130
+ */
131
+ async getCollectionInfo(collectionType, id, options) {
132
+ return this.http.get(`${collectionType}/${id}`, { searchParams: { ...options } }).json();
133
+ }
134
+ /**
135
+ * 获取收藏品分类列表
136
+ * @param options.version 版本,不填写遵循api默认行为
137
+ * @returns 收藏品分类列表
138
+ */
139
+ async getCollectionGenreList(options) {
140
+ return this.http.get("collection-genre/list", { searchParams: { ...options } }).json();
141
+ }
142
+ /**
143
+ * 获取收藏品分类信息
144
+ * @param id 收藏品分类 ID
145
+ * @param options.version 版本,不填写遵循api默认行为
146
+ * @returns 收藏品分类信息
147
+ */
148
+ async getCollectionGenreInfo(id, options) {
149
+ return this.http.get(`collection-genre/${id}`, { searchParams: { ...options } }).json();
150
+ }
151
+ };
152
+
153
+ // src/apis/maimai/dev.ts
154
+ var MaimaiDevApi = class {
155
+ constructor(http) {
156
+ this.http = http;
157
+ }
158
+ /**
159
+ * 创建或修改玩家信息
160
+ * @param body 玩家信息
161
+ * @returns 玩家信息
162
+ */
163
+ async postPlayer(body) {
164
+ return this.http.post("player", { json: body }).json();
165
+ }
166
+ /**
167
+ * 获取玩家信息(通过好友码)
168
+ * @param friendCode 好友码
169
+ * @returns 玩家信息
170
+ */
171
+ async getPlayer(friendCode) {
172
+ return this.http.get(`player/${friendCode}`).json();
173
+ }
174
+ /**
175
+ * 获取玩家信息(通过 QQ 号)
176
+ * @param qq QQ 号
177
+ * @returns 玩家信息
178
+ */
179
+ async getPlayerByQQ(qq) {
180
+ return this.http.get(`player/qq/${qq}`).json();
181
+ }
182
+ /**
183
+ * 获取 Best 50(standard 35 + dx 15)
184
+ * @param friendCode 好友码
185
+ * @returns Best 50
186
+ */
187
+ async getBests(friendCode) {
188
+ return this.http.get(`player/${friendCode}/bests`).json();
189
+ }
190
+ /**
191
+ * 获取 AP 50
192
+ * @param friendCode 好友码
193
+ * @returns AP 50
194
+ */
195
+ async getApBests(friendCode) {
196
+ return this.http.get(`player/${friendCode}/bests/ap`).json();
197
+ }
198
+ /**
199
+ * 获取 Recent 50(仅增量爬取可用)
200
+ * @param friendCode 好友码
201
+ * @returns Recent 50
202
+ */
203
+ async getRecents(friendCode) {
204
+ return this.http.get(`player/${friendCode}/recents`).json();
205
+ }
206
+ /**
207
+ * 获取玩家缓存的所有最佳成绩(简化)
208
+ * @param friendCode 好友码
209
+ * @returns BestScoreList
210
+ */
211
+ async getAllBestScores(friendCode) {
212
+ return this.http.get(`player/${friendCode}/scores`).json();
213
+ }
214
+ /**
215
+ * 成绩上传热力图(YYYY-MM-DD -> 数量)
216
+ * @param friendCode 好友码
217
+ * @returns Heatmap
218
+ */
219
+ async getHeatmap(friendCode) {
220
+ return this.http.get(`player/${friendCode}/heatmap`).json();
221
+ }
222
+ /**
223
+ * DX Rating 趋势
224
+ * @param friendCode 好友码
225
+ * @returns TrendList
226
+ */
227
+ async getTrend(friendCode) {
228
+ return this.http.get(`player/${friendCode}/trend`).json();
229
+ }
230
+ /**
231
+ * 成绩游玩历史记录(仅返回带有 play_time 的成绩)
232
+ * @param friendCode 好友码
233
+ * @returns 游玩历史记录
234
+ */
235
+ async getScoreHistory(friendCode) {
236
+ return this.http.get(`player/${friendCode}/score/history`).json();
237
+ }
238
+ /**
239
+ * 获取玩家收藏品进度
240
+ * @param friendCode 好友码
241
+ * @param collectionType 收藏品类型
242
+ * @param collectionId 收藏品 ID
243
+ * @returns 收藏品进度
244
+ */
245
+ async getCollectionProgress(friendCode, collectionType, collectionId) {
246
+ return this.http.get(`player/${friendCode}/${collectionType}/${collectionId}`).json();
247
+ }
248
+ /**
249
+ * 上传玩家成绩
250
+ * @param friendCode 好友码
251
+ * @param scores 成绩列表
252
+ * @returns 上传结果
253
+ */
254
+ async postScores(friendCode, scores) {
255
+ const body = { scores };
256
+ return this.http.post(`player/${friendCode}/scores`, { json: body }).json();
257
+ }
258
+ /**
259
+ * 通过 NET 的 HTML 源代码上传玩家数据
260
+ * @param friendCode 好友码
261
+ * @param htmlSource HTML 源代码
262
+ * @returns 上传结果
263
+ */
264
+ async postHtml(friendCode, htmlSource) {
265
+ return this.http.post(`player/${friendCode}/html`, {
266
+ body: htmlSource,
267
+ headers: { "content-type": "text/plain" }
268
+ }).json();
269
+ }
270
+ };
271
+
272
+ // src/apis/maimai/personal.ts
273
+ var MaimaiPersonalApi = class {
274
+ constructor(http) {
275
+ this.http = http;
276
+ }
277
+ /**
278
+ * 获取玩家信息
279
+ * GET /api/v0/user/maimai/player
280
+ * @returns PlayerInfo
281
+ */
282
+ async getPlayer() {
283
+ return this.http.get("player").json();
284
+ }
285
+ /**
286
+ * 获取玩家所有成绩
287
+ * GET /api/v0/user/maimai/player/scores
288
+ * @returns PlayerScores
289
+ */
290
+ async getScores() {
291
+ return this.http.get("scores").json();
292
+ }
293
+ /**
294
+ * 上传玩家成绩
295
+ * POST /api/v0/user/maimai/player/scores
296
+ * @param scores 成绩列表
297
+ * @returns 上传结果
298
+ */
299
+ async postScores(scores) {
300
+ const body = { scores };
301
+ return this.http.post("scores", { json: body }).json();
302
+ }
303
+ };
304
+
305
+ // src/client/LxnsApiCLient.ts
306
+ var LxnsApiClient = class {
307
+ config = {
308
+ baseURL: "https://maimai.lxns.net/api/v0/"
309
+ };
310
+ /**
311
+ * maimai API
312
+ */
313
+ maimai;
314
+ constructor(config) {
315
+ this.config = {
316
+ baseURL: config?.baseURL ?? this.config.baseURL,
317
+ personalAccessToken: config?.personalAccessToken,
318
+ devAccessToken: config?.devAccessToken
319
+ };
320
+ const { baseURL, devAccessToken, personalAccessToken } = this.config;
321
+ const httpPublic = ky.create({
322
+ prefixUrl: new URL("maimai/", baseURL)
323
+ });
324
+ const httpDev = devAccessToken ? ky.create({
325
+ prefixUrl: new URL("maimai/", baseURL),
326
+ headers: {
327
+ Authorization: devAccessToken
328
+ }
329
+ }) : void 0;
330
+ const httpPersonal = personalAccessToken ? ky.create({
331
+ prefixUrl: new URL("user/maimai/", baseURL),
332
+ headers: {
333
+ "X-User-Token": personalAccessToken
334
+ }
335
+ }) : void 0;
336
+ const maimai = {
337
+ public: new MaimaiPublicApi(httpPublic)
338
+ };
339
+ if (httpDev) {
340
+ maimai.dev = new MaimaiDevApi(httpDev);
341
+ }
342
+ if (httpPersonal) {
343
+ maimai.personal = new MaimaiPersonalApi(httpPersonal);
344
+ }
345
+ this.maimai = maimai;
346
+ }
347
+ };
348
+ export {
349
+ LxnsApiClient,
350
+ models_exports as MaimaiModels
351
+ };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "lxns-rhythm-api",
3
3
  "description": "A simple SDK for lxns api.",
4
4
  "author": "amatsuka <amatsukamao@qq.com>",
5
- "version": "0.1.0",
5
+ "version": "0.1.1",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/wsyzxjn/lxns-rhythm-api.git"