lxns-rhythm-api 0.1.12 → 0.1.14

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
@@ -1347,10 +1347,11 @@ var MaimaiDevApi = class {
1347
1347
  /**
1348
1348
  * DX Rating 趋势
1349
1349
  * @param friendCode 好友码
1350
+ * @param version 游戏版本(可选)
1350
1351
  * @returns TrendList
1351
1352
  */
1352
- async getTrend(friendCode) {
1353
- return this.http.get(`player/${friendCode}/trend`).json();
1353
+ async getTrend(friendCode, version) {
1354
+ return this.http.get(`player/${friendCode}/trend`, { searchParams: { version } }).json();
1354
1355
  }
1355
1356
  /**
1356
1357
  * 成绩游玩历史记录(仅返回带有 play_time 的成绩)
@@ -1596,6 +1597,28 @@ const LXNS_HTTP_OPTIONS = {
1596
1597
  throwHttpErrors: true,
1597
1598
  hooks: { beforeError: [wrapKyError] }
1598
1599
  };
1600
+ async function wrapOAuthError(error) {
1601
+ const status = error.response.status;
1602
+ let body;
1603
+ try {
1604
+ body = await error.response.clone().json();
1605
+ } catch {}
1606
+ if (body && typeof body.error === "string") throw new LxnsApiError({
1607
+ success: false,
1608
+ code: status,
1609
+ message: body.error_description ?? body.error,
1610
+ data: { ...body }
1611
+ }, status);
1612
+ throw new LxnsApiError({
1613
+ success: false,
1614
+ code: status,
1615
+ message: error.message
1616
+ }, status);
1617
+ }
1618
+ const LXNS_OAUTH_TOKEN_HTTP_OPTIONS = {
1619
+ throwHttpErrors: true,
1620
+ hooks: { beforeError: [wrapOAuthError] }
1621
+ };
1599
1622
  //#endregion
1600
1623
  //#region src/client/lxns-api-client.ts
1601
1624
  var LxnsApiClient = class {
@@ -1689,7 +1712,7 @@ var LxnsOAuthClient = class {
1689
1712
  };
1690
1713
  this.http = ky.create({
1691
1714
  prefixUrl: new URL("oauth/", this.config.baseURL),
1692
- ...LXNS_HTTP_OPTIONS
1715
+ ...LXNS_OAUTH_TOKEN_HTTP_OPTIONS
1693
1716
  });
1694
1717
  }
1695
1718
  /**
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  declare namespace models_d_exports {
2
- export { Alias$3 as Alias, AssetType$1 as AssetType, Character, ClassEmblem, ClearType, Collection$1 as Collection, CollectionRequired$1 as CollectionRequired, CollectionRequiredSong$1 as CollectionRequiredSong, FullChainType, FullComboType, Genre$1 as Genre, LevelIndex$1 as LevelIndex, MapIcon, NamePlate$1 as NamePlate, Notes$1 as Notes, Player$1 as Player, RankType, RatingTrend$2 as RatingTrend, Score$1 as Score, SimpleScore$1 as SimpleScore, Song$2 as Song, SongDifficulty$1 as SongDifficulty, SongType$1 as SongType, Team, Trophy$1 as Trophy, TrophyColor, Version$1 as Version };
2
+ export { Alias$3 as Alias, AssetType$1 as AssetType, Character, ClassEmblem, ClearType, Collection$1 as Collection, CollectionRequired$1 as CollectionRequired, CollectionRequiredSong$1 as CollectionRequiredSong, FullChainType, FullComboType, Genre$1 as Genre, LevelIndex$1 as LevelIndex, MapIcon, NamePlate$1 as NamePlate, Notes$1 as Notes, Player$1 as Player, RankType, RatingTrend$1 as RatingTrend, Score$1 as Score, SimpleScore$1 as SimpleScore, Song$2 as Song, SongDifficulty$1 as SongDifficulty, SongType$1 as SongType, Team, Trophy$1 as Trophy, TrophyColor, Version$1 as Version };
3
3
  }
4
4
  interface Notes$1 {
5
5
  total: number;
@@ -141,7 +141,7 @@ interface SimpleScore$1 {
141
141
  full_chain?: FullChainType;
142
142
  type: SongType$1;
143
143
  }
144
- interface RatingTrend$2 {
144
+ interface RatingTrend$1 {
145
145
  rating: number;
146
146
  bests_rating: number;
147
147
  selections_rating: number;
@@ -155,7 +155,7 @@ interface NamePlate$1 extends Collection$1 {}
155
155
  interface MapIcon extends Collection$1 {}
156
156
  type AssetType$1 = "character" | "trophy" | "plate" | "icon" | "jacket" | "music";
157
157
  declare namespace models_d_exports$1 {
158
- export { Alias$2 as Alias, AssetType, BuddyNotes, Collection, CollectionGenre, CollectionRequired, CollectionRequiredSong, FCType, FSType, Frame, Genre, Icon, LevelIndex, NamePlate, Notes, Player, RateType, RatingTrend$1 as RatingTrend, Score, SimpleScore, Song$1 as Song, SongDifficulties, SongDifficulty, SongDifficultyUtage, SongType, Trophy, Version };
158
+ export { Alias$2 as Alias, AssetType, BuddyNotes, Collection, CollectionGenre, CollectionRequired, CollectionRequiredSong, FCType, FSType, Frame, Genre, Icon, LevelIndex, NamePlate, Notes, Player, RateType, RatingTrend, Score, SimpleScore, Song$1 as Song, SongDifficulties, SongDifficulty, SongDifficultyUtage, SongType, Trophy, Version };
159
159
  }
160
160
  interface Notes {
161
161
  total: number;
@@ -392,15 +392,15 @@ interface SimpleScore {
392
392
  /** 谱面类型 */
393
393
  type: SongType;
394
394
  }
395
- interface RatingTrend$1 {
395
+ interface RatingTrend {
396
396
  /** 总 DX Rating */
397
397
  total: number;
398
- /** 旧版本谱面总 DX Rating */
399
- standard: number;
400
- /** 现版本谱面总 DX Rating */
401
- dx: number;
398
+ /** 旧版本谱面总 DX Rating (B35) */
399
+ standard_total: number;
400
+ /** 现版本谱面总 DX Rating (B15) */
401
+ dx_total: number;
402
402
  /** 日期 */
403
- date: string;
403
+ date: string | number;
404
404
  }
405
405
  interface Trophy extends Collection {}
406
406
  interface Icon extends Collection {}
@@ -1119,7 +1119,7 @@ declare class ChunithmPersonalApi {
1119
1119
  * 获取 Rating 趋势
1120
1120
  * GET /api/v0/user/chunithm/player/trend
1121
1121
  */
1122
- getTrend(version?: number): Promise<RatingTrend$2[]>;
1122
+ getTrend(version?: number): Promise<RatingTrend$1[]>;
1123
1123
  /**
1124
1124
  * 获取玩家已获得的收藏品列表
1125
1125
  * GET /api/v0/user/chunithm/player/{collectionType}
@@ -1247,12 +1247,6 @@ interface RankingScore {
1247
1247
  }
1248
1248
  type ScoreHistory$2 = Score[];
1249
1249
  type Heatmap$2 = Record<string, number>;
1250
- interface RatingTrend {
1251
- total: number;
1252
- standard_total: number;
1253
- dx_total: number;
1254
- date: string | number;
1255
- }
1256
1250
  type PlayerCollectionListType = "trophies" | "icons" | "plates" | "frames";
1257
1251
  type PlayerCollectionType = "trophy" | "icon" | "plate" | "frame";
1258
1252
  type PlayerCollectionList = Collection[];
@@ -1636,7 +1630,7 @@ interface Bests$1 {
1636
1630
  type RecentList$1 = Score$1[];
1637
1631
  type BestScoreList$1 = SimpleScore$1[];
1638
1632
  type Heatmap$1 = Record<string, number>;
1639
- type TrendList$1 = RatingTrend$2[];
1633
+ type TrendList$1 = RatingTrend$1[];
1640
1634
  type ScoreHistory$1 = Score$1[];
1641
1635
  //#endregion
1642
1636
  //#region src/api/chunithm/dev-api.d.ts
@@ -1771,7 +1765,7 @@ interface Bests {
1771
1765
  type RecentList = Score[];
1772
1766
  type BestScoreList = SimpleScore[];
1773
1767
  type Heatmap = Record<string, number>;
1774
- type TrendList = RatingTrend$1[];
1768
+ type TrendList = RatingTrend[];
1775
1769
  type ScoreHistory = Score[];
1776
1770
  //#endregion
1777
1771
  //#region src/api/maimai/dev-api.d.ts
@@ -1832,9 +1826,10 @@ declare class MaimaiDevApi {
1832
1826
  /**
1833
1827
  * DX Rating 趋势
1834
1828
  * @param friendCode 好友码
1829
+ * @param version 游戏版本(可选)
1835
1830
  * @returns TrendList
1836
1831
  */
1837
- getTrend(friendCode: number): Promise<TrendList>;
1832
+ getTrend(friendCode: number, version?: number): Promise<TrendList>;
1838
1833
  /**
1839
1834
  * 成绩游玩历史记录(仅返回带有 play_time 的成绩)
1840
1835
  * @param friendCode 好友码
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  declare namespace models_d_exports {
2
- export { Alias$3 as Alias, AssetType$1 as AssetType, Character, ClassEmblem, ClearType, Collection$1 as Collection, CollectionRequired$1 as CollectionRequired, CollectionRequiredSong$1 as CollectionRequiredSong, FullChainType, FullComboType, Genre$1 as Genre, LevelIndex$1 as LevelIndex, MapIcon, NamePlate$1 as NamePlate, Notes$1 as Notes, Player$1 as Player, RankType, RatingTrend$2 as RatingTrend, Score$1 as Score, SimpleScore$1 as SimpleScore, Song$2 as Song, SongDifficulty$1 as SongDifficulty, SongType$1 as SongType, Team, Trophy$1 as Trophy, TrophyColor, Version$1 as Version };
2
+ export { Alias$3 as Alias, AssetType$1 as AssetType, Character, ClassEmblem, ClearType, Collection$1 as Collection, CollectionRequired$1 as CollectionRequired, CollectionRequiredSong$1 as CollectionRequiredSong, FullChainType, FullComboType, Genre$1 as Genre, LevelIndex$1 as LevelIndex, MapIcon, NamePlate$1 as NamePlate, Notes$1 as Notes, Player$1 as Player, RankType, RatingTrend$1 as RatingTrend, Score$1 as Score, SimpleScore$1 as SimpleScore, Song$2 as Song, SongDifficulty$1 as SongDifficulty, SongType$1 as SongType, Team, Trophy$1 as Trophy, TrophyColor, Version$1 as Version };
3
3
  }
4
4
  interface Notes$1 {
5
5
  total: number;
@@ -141,7 +141,7 @@ interface SimpleScore$1 {
141
141
  full_chain?: FullChainType;
142
142
  type: SongType$1;
143
143
  }
144
- interface RatingTrend$2 {
144
+ interface RatingTrend$1 {
145
145
  rating: number;
146
146
  bests_rating: number;
147
147
  selections_rating: number;
@@ -155,7 +155,7 @@ interface NamePlate$1 extends Collection$1 {}
155
155
  interface MapIcon extends Collection$1 {}
156
156
  type AssetType$1 = "character" | "trophy" | "plate" | "icon" | "jacket" | "music";
157
157
  declare namespace models_d_exports$1 {
158
- export { Alias$2 as Alias, AssetType, BuddyNotes, Collection, CollectionGenre, CollectionRequired, CollectionRequiredSong, FCType, FSType, Frame, Genre, Icon, LevelIndex, NamePlate, Notes, Player, RateType, RatingTrend$1 as RatingTrend, Score, SimpleScore, Song$1 as Song, SongDifficulties, SongDifficulty, SongDifficultyUtage, SongType, Trophy, Version };
158
+ export { Alias$2 as Alias, AssetType, BuddyNotes, Collection, CollectionGenre, CollectionRequired, CollectionRequiredSong, FCType, FSType, Frame, Genre, Icon, LevelIndex, NamePlate, Notes, Player, RateType, RatingTrend, Score, SimpleScore, Song$1 as Song, SongDifficulties, SongDifficulty, SongDifficultyUtage, SongType, Trophy, Version };
159
159
  }
160
160
  interface Notes {
161
161
  total: number;
@@ -392,15 +392,15 @@ interface SimpleScore {
392
392
  /** 谱面类型 */
393
393
  type: SongType;
394
394
  }
395
- interface RatingTrend$1 {
395
+ interface RatingTrend {
396
396
  /** 总 DX Rating */
397
397
  total: number;
398
- /** 旧版本谱面总 DX Rating */
399
- standard: number;
400
- /** 现版本谱面总 DX Rating */
401
- dx: number;
398
+ /** 旧版本谱面总 DX Rating (B35) */
399
+ standard_total: number;
400
+ /** 现版本谱面总 DX Rating (B15) */
401
+ dx_total: number;
402
402
  /** 日期 */
403
- date: string;
403
+ date: string | number;
404
404
  }
405
405
  interface Trophy extends Collection {}
406
406
  interface Icon extends Collection {}
@@ -1119,7 +1119,7 @@ declare class ChunithmPersonalApi {
1119
1119
  * 获取 Rating 趋势
1120
1120
  * GET /api/v0/user/chunithm/player/trend
1121
1121
  */
1122
- getTrend(version?: number): Promise<RatingTrend$2[]>;
1122
+ getTrend(version?: number): Promise<RatingTrend$1[]>;
1123
1123
  /**
1124
1124
  * 获取玩家已获得的收藏品列表
1125
1125
  * GET /api/v0/user/chunithm/player/{collectionType}
@@ -1247,12 +1247,6 @@ interface RankingScore {
1247
1247
  }
1248
1248
  type ScoreHistory$2 = Score[];
1249
1249
  type Heatmap$2 = Record<string, number>;
1250
- interface RatingTrend {
1251
- total: number;
1252
- standard_total: number;
1253
- dx_total: number;
1254
- date: string | number;
1255
- }
1256
1250
  type PlayerCollectionListType = "trophies" | "icons" | "plates" | "frames";
1257
1251
  type PlayerCollectionType = "trophy" | "icon" | "plate" | "frame";
1258
1252
  type PlayerCollectionList = Collection[];
@@ -1636,7 +1630,7 @@ interface Bests$1 {
1636
1630
  type RecentList$1 = Score$1[];
1637
1631
  type BestScoreList$1 = SimpleScore$1[];
1638
1632
  type Heatmap$1 = Record<string, number>;
1639
- type TrendList$1 = RatingTrend$2[];
1633
+ type TrendList$1 = RatingTrend$1[];
1640
1634
  type ScoreHistory$1 = Score$1[];
1641
1635
  //#endregion
1642
1636
  //#region src/api/chunithm/dev-api.d.ts
@@ -1771,7 +1765,7 @@ interface Bests {
1771
1765
  type RecentList = Score[];
1772
1766
  type BestScoreList = SimpleScore[];
1773
1767
  type Heatmap = Record<string, number>;
1774
- type TrendList = RatingTrend$1[];
1768
+ type TrendList = RatingTrend[];
1775
1769
  type ScoreHistory = Score[];
1776
1770
  //#endregion
1777
1771
  //#region src/api/maimai/dev-api.d.ts
@@ -1832,9 +1826,10 @@ declare class MaimaiDevApi {
1832
1826
  /**
1833
1827
  * DX Rating 趋势
1834
1828
  * @param friendCode 好友码
1829
+ * @param version 游戏版本(可选)
1835
1830
  * @returns TrendList
1836
1831
  */
1837
- getTrend(friendCode: number): Promise<TrendList>;
1832
+ getTrend(friendCode: number, version?: number): Promise<TrendList>;
1838
1833
  /**
1839
1834
  * 成绩游玩历史记录(仅返回带有 play_time 的成绩)
1840
1835
  * @param friendCode 好友码
package/dist/index.mjs CHANGED
@@ -1335,10 +1335,11 @@ var MaimaiDevApi = class {
1335
1335
  /**
1336
1336
  * DX Rating 趋势
1337
1337
  * @param friendCode 好友码
1338
+ * @param version 游戏版本(可选)
1338
1339
  * @returns TrendList
1339
1340
  */
1340
- async getTrend(friendCode) {
1341
- return this.http.get(`player/${friendCode}/trend`).json();
1341
+ async getTrend(friendCode, version) {
1342
+ return this.http.get(`player/${friendCode}/trend`, { searchParams: { version } }).json();
1342
1343
  }
1343
1344
  /**
1344
1345
  * 成绩游玩历史记录(仅返回带有 play_time 的成绩)
@@ -1584,6 +1585,28 @@ const LXNS_HTTP_OPTIONS = {
1584
1585
  throwHttpErrors: true,
1585
1586
  hooks: { beforeError: [wrapKyError] }
1586
1587
  };
1588
+ async function wrapOAuthError(error) {
1589
+ const status = error.response.status;
1590
+ let body;
1591
+ try {
1592
+ body = await error.response.clone().json();
1593
+ } catch {}
1594
+ if (body && typeof body.error === "string") throw new LxnsApiError({
1595
+ success: false,
1596
+ code: status,
1597
+ message: body.error_description ?? body.error,
1598
+ data: { ...body }
1599
+ }, status);
1600
+ throw new LxnsApiError({
1601
+ success: false,
1602
+ code: status,
1603
+ message: error.message
1604
+ }, status);
1605
+ }
1606
+ const LXNS_OAUTH_TOKEN_HTTP_OPTIONS = {
1607
+ throwHttpErrors: true,
1608
+ hooks: { beforeError: [wrapOAuthError] }
1609
+ };
1587
1610
  //#endregion
1588
1611
  //#region src/client/lxns-api-client.ts
1589
1612
  var LxnsApiClient = class {
@@ -1677,7 +1700,7 @@ var LxnsOAuthClient = class {
1677
1700
  };
1678
1701
  this.http = ky.create({
1679
1702
  prefixUrl: new URL("oauth/", this.config.baseURL),
1680
- ...LXNS_HTTP_OPTIONS
1703
+ ...LXNS_OAUTH_TOKEN_HTTP_OPTIONS
1681
1704
  });
1682
1705
  }
1683
1706
  /**
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "api-client"
13
13
  ],
14
14
  "author": "amatsuka <amatsukamao@qq.com>",
15
- "version": "0.1.12",
15
+ "version": "0.1.14",
16
16
  "license": "MIT",
17
17
  "repository": {
18
18
  "type": "git",