@fett/synology-api 0.0.1-beta.8 → 0.0.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.
Files changed (112) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +81 -10
  3. package/lib/cli/apis.js +47 -0
  4. package/lib/{esm/cli → cli}/config.js +38 -41
  5. package/lib/cli/core.js +20 -0
  6. package/lib/{types/cli → cli}/helper.d.ts +1 -0
  7. package/lib/{esm/cli → cli}/helper.js +9 -5
  8. package/lib/cli/index.d.ts +2 -0
  9. package/lib/cli/index.js +5 -0
  10. package/lib/{types/core.d.ts → core.d.ts} +1 -1
  11. package/lib/core.js +99 -0
  12. package/lib/decorators/bindMethods.js +45 -0
  13. package/lib/{types/errorcodes.d.ts → errorcodes.d.ts} +2 -2
  14. package/lib/{esm/errorcodes.js → errorcodes.js} +10 -5
  15. package/lib/helpers.d.ts +19 -0
  16. package/lib/helpers.js +70 -0
  17. package/lib/index.d.ts +4 -0
  18. package/lib/index.js +4 -0
  19. package/lib/modules/Api/Auth.d.ts +4 -0
  20. package/lib/modules/Api/Auth.js +30 -0
  21. package/lib/modules/Api/Info.d.ts +3 -0
  22. package/lib/modules/Api/Info.js +15 -0
  23. package/lib/modules/Api/index.d.ts +2 -0
  24. package/lib/modules/Api/index.js +2 -0
  25. package/lib/modules/AudioStation/Album.d.ts +30 -0
  26. package/lib/modules/AudioStation/Album.js +17 -0
  27. package/lib/modules/AudioStation/Artist.d.ts +25 -0
  28. package/lib/modules/AudioStation/Artist.js +17 -0
  29. package/lib/modules/AudioStation/Cover.js +0 -0
  30. package/lib/modules/AudioStation/Folder.d.ts +24 -0
  31. package/lib/modules/AudioStation/Folder.js +17 -0
  32. package/lib/modules/AudioStation/Info.d.ts +45 -0
  33. package/lib/modules/AudioStation/Info.js +9 -0
  34. package/lib/modules/AudioStation/Lyrics.d.ts +25 -0
  35. package/lib/modules/AudioStation/Lyrics.js +23 -0
  36. package/lib/modules/AudioStation/Playlist.d.ts +34 -0
  37. package/lib/modules/AudioStation/Playlist.js +38 -0
  38. package/lib/modules/AudioStation/Search.d.ts +53 -0
  39. package/lib/modules/AudioStation/Search.js +17 -0
  40. package/lib/modules/AudioStation/Song.d.ts +33 -0
  41. package/lib/modules/AudioStation/Song.js +27 -0
  42. package/lib/modules/AudioStation/index.d.ts +23 -0
  43. package/lib/modules/AudioStation/index.js +23 -0
  44. package/lib/modules/Auth/AuthKey.d.ts +8 -0
  45. package/lib/modules/Auth/AuthKey.js +12 -0
  46. package/lib/modules/Auth/index.d.ts +7 -0
  47. package/lib/modules/Auth/index.js +8 -0
  48. package/lib/modules/FileStation/File.d.ts +0 -0
  49. package/lib/modules/FileStation/File.js +0 -0
  50. package/lib/{types/modules → modules}/FileStation/Info.d.ts +1 -1
  51. package/lib/modules/FileStation/Info.js +9 -0
  52. package/lib/{types/modules → modules}/FileStation/List.d.ts +1 -1
  53. package/lib/modules/FileStation/List.js +30 -0
  54. package/lib/{types/modules → modules}/FileStation/index.d.ts +2 -2
  55. package/lib/{esm/modules → modules}/FileStation/index.js +2 -2
  56. package/lib/modules/VideoStation/File.d.ts +48 -0
  57. package/lib/modules/VideoStation/File.js +20 -0
  58. package/lib/modules/VideoStation/HomeVideo.d.ts +6 -0
  59. package/lib/modules/VideoStation/HomeVideo.js +10 -0
  60. package/lib/modules/VideoStation/Info.d.ts +44 -0
  61. package/lib/modules/VideoStation/Info.js +9 -0
  62. package/lib/modules/VideoStation/Library.d.ts +70 -0
  63. package/lib/modules/VideoStation/Library.js +23 -0
  64. package/lib/modules/VideoStation/Movie.d.ts +27 -0
  65. package/lib/modules/VideoStation/Movie.js +13 -0
  66. package/lib/modules/VideoStation/Streaming.d.ts +11 -0
  67. package/lib/modules/VideoStation/Streaming.js +24 -0
  68. package/lib/modules/VideoStation/index.d.ts +15 -0
  69. package/lib/modules/VideoStation/index.js +16 -0
  70. package/lib/modules/VideoStation/types.d.ts +27 -0
  71. package/lib/modules/VideoStation/types.js +1 -0
  72. package/lib/modules/index.d.ts +26 -0
  73. package/lib/{esm/modules → modules}/index.js +31 -3
  74. package/lib/types/{types/apiInfo.d.ts → apiInfo.d.ts} +15 -2
  75. package/lib/{esm/types → types}/apiInfo.js +15 -1
  76. package/lib/types/index.d.ts +2 -5
  77. package/lib/types/index.js +2 -0
  78. package/lib/{types/utils.d.ts → utils.d.ts} +1 -0
  79. package/lib/{esm/utils.js → utils.js} +3 -0
  80. package/package.json +24 -24
  81. package/bin/syno +0 -6
  82. package/lib/cjs/index.js +0 -733
  83. package/lib/esm/cli/apis.js +0 -53
  84. package/lib/esm/cli/index.js +0 -30
  85. package/lib/esm/core.js +0 -111
  86. package/lib/esm/helpers.js +0 -80
  87. package/lib/esm/index.js +0 -5
  88. package/lib/esm/modules/Api/Auth.js +0 -43
  89. package/lib/esm/modules/Api/Info.js +0 -26
  90. package/lib/esm/modules/Api/index.js +0 -2
  91. package/lib/esm/modules/AudioStation/Song.js +0 -18
  92. package/lib/esm/modules/AudioStation/index.js +0 -7
  93. package/lib/esm/modules/FileStation/Info.js +0 -20
  94. package/lib/esm/modules/FileStation/List.js +0 -32
  95. package/lib/esm/types/index.js +0 -2
  96. package/lib/types/helpers.d.ts +0 -2
  97. package/lib/types/modules/Api/Auth.d.ts +0 -3
  98. package/lib/types/modules/Api/Info.d.ts +0 -2
  99. package/lib/types/modules/Api/index.d.ts +0 -2
  100. package/lib/types/modules/AudioStation/Song.d.ts +0 -22
  101. package/lib/types/modules/AudioStation/index.d.ts +0 -7
  102. package/lib/types/modules/index.d.ts +0 -16
  103. package/lib/types/types/index.d.ts +0 -2
  104. /package/lib/{types/cli → cli}/apis.d.ts +0 -0
  105. /package/lib/{types/cli → cli}/config.d.ts +0 -0
  106. /package/lib/{types/cli/index.d.ts → cli/core.d.ts} +0 -0
  107. /package/lib/{types/constants.d.ts → constants.d.ts} +0 -0
  108. /package/lib/{esm/constants.js → constants.js} +0 -0
  109. /package/lib/{esm/modules/FileStation/File.js → decorators/bindMethods.d.ts} +0 -0
  110. /package/lib/{types/modules/FileStation/File.d.ts → modules/AudioStation/Cover.d.ts} +0 -0
  111. /package/lib/types/{types/request.d.ts → request.d.ts} +0 -0
  112. /package/lib/{esm/types → types}/request.js +0 -0
package/lib/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ import { SynologyApi } from "./core.js";
2
+ export * from "./types/index.js";
3
+ export * from "./core.js";
4
+ export default SynologyApi;
package/lib/index.js ADDED
@@ -0,0 +1,4 @@
1
+ import { SynologyApi } from "./core.js";
2
+ export * from "./types/index.js";
3
+ export * from "./core.js";
4
+ export default SynologyApi;
@@ -0,0 +1,4 @@
1
+ import { SynologyApiResponse } from "../../types/index.js";
2
+ import { SynologyApi } from "../../core.js";
3
+ export declare function login(core: SynologyApi): Promise<SynologyApiResponse>;
4
+ export declare function logout(core: SynologyApi): Promise<void>;
@@ -0,0 +1,30 @@
1
+ import ky from "ky";
2
+ import { SynologyApiInfo } from "../../types/index.js";
3
+ export async function login(core) {
4
+ const params = {
5
+ api: SynologyApiInfo.Auth,
6
+ version: 6,
7
+ method: "login",
8
+ account: core.username,
9
+ passwd: core.password,
10
+ format: "sid",
11
+ };
12
+ const url = `${core.baseUrl}entry.cgi`;
13
+ const result = await ky.get(url, { searchParams: params }).json();
14
+ if (!result.success) {
15
+ throw new Error(result.error.message);
16
+ }
17
+ return result;
18
+ }
19
+ export async function logout(core) {
20
+ const params = {
21
+ api: SynologyApiInfo.Auth,
22
+ version: 6,
23
+ method: "logout",
24
+ };
25
+ const url = `${core.baseUrl}entry.cgi`;
26
+ const result = await ky.get(url, { searchParams: params }).json();
27
+ if (!result.success) {
28
+ throw new Error(result.error.message);
29
+ }
30
+ }
@@ -0,0 +1,3 @@
1
+ import { SynologyApiResponse } from "../../types/index.js";
2
+ import { SynologyApi } from "../../core.js";
3
+ export declare function getApiInfo(core: SynologyApi): Promise<SynologyApiResponse>;
@@ -0,0 +1,15 @@
1
+ import ky from "ky";
2
+ import { SynologyApiInfo } from "../../types/index.js";
3
+ export async function getApiInfo(core) {
4
+ const params = {
5
+ api: SynologyApiInfo.Info,
6
+ version: 1,
7
+ method: "query",
8
+ };
9
+ const url = `${core.baseUrl}entry.cgi`;
10
+ const result = await ky.get(url, { searchParams: params }).json();
11
+ if (!result.success) {
12
+ throw new Error(result.error.message);
13
+ }
14
+ return result;
15
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./Auth.js";
2
+ export * from "./Info.js";
@@ -0,0 +1,2 @@
1
+ export * from "./Auth.js";
2
+ export * from "./Info.js";
@@ -0,0 +1,30 @@
1
+ import { SynologyApiResponse } from "../../types/index.js";
2
+ export type AudioStationAlbumListParams = {
3
+ limit?: number;
4
+ offset?: number;
5
+ library?: "all" | "personal";
6
+ additional?: string[];
7
+ version?: number;
8
+ filter?: string;
9
+ artist?: string;
10
+ genre?: string;
11
+ sort_by?: "time" | "random" | "year" | "name" | "display_artist" | "avg_rating";
12
+ sort_direction?: "ASC" | "DESC";
13
+ };
14
+ export type AudioStationAlbumListResponse = SynologyApiResponse<{
15
+ offset: number;
16
+ total: number;
17
+ albums: Array<{
18
+ additional: {
19
+ avg_rating?: {
20
+ rating: number;
21
+ };
22
+ };
23
+ album_artist: string;
24
+ artist: string;
25
+ display_artist: string;
26
+ name: string;
27
+ year: number;
28
+ }>;
29
+ }>;
30
+ export declare function getAlbumList(params: AudioStationAlbumListParams): Promise<AudioStationAlbumListResponse>;
@@ -0,0 +1,17 @@
1
+ import { AudioStationApi } from "../../types/index.js";
2
+ export async function getAlbumList(params) {
3
+ const { additional = ["avg_rating"], library = "all", limit = 1000, offset = 0, sort_by = "name", sort_direction = "ASC", ...extraParams } = params;
4
+ const res = await this.run(AudioStationApi.Album, {
5
+ params: {
6
+ method: "list",
7
+ limit: limit,
8
+ offset: offset,
9
+ library: library,
10
+ sort_by: sort_by,
11
+ sort_direction: sort_direction,
12
+ additional: additional.join(","),
13
+ ...extraParams,
14
+ },
15
+ });
16
+ return res;
17
+ }
@@ -0,0 +1,25 @@
1
+ import { SynologyApiResponse } from "../../types/index.js";
2
+ export type AudioStationArtistListParams = {
3
+ limit?: number;
4
+ offset?: number;
5
+ library?: "all" | "personal";
6
+ additional?: string[];
7
+ filter?: string;
8
+ artist?: string;
9
+ genre?: string;
10
+ sort_by?: "name";
11
+ sort_direction?: "ASC" | "DESC";
12
+ };
13
+ export type AudioStationArtistListResponse = SynologyApiResponse<{
14
+ offset: number;
15
+ total: number;
16
+ artists: Array<{
17
+ additional: {
18
+ avg_rating?: {
19
+ rating: number;
20
+ };
21
+ };
22
+ name: string;
23
+ }>;
24
+ }>;
25
+ export declare function getArtistList(params: AudioStationArtistListParams): Promise<AudioStationArtistListResponse>;
@@ -0,0 +1,17 @@
1
+ import { AudioStationApi } from "../../types/index.js";
2
+ export async function getArtistList(params) {
3
+ const { additional = ["avg_rating"], library = "all", limit = 1000, offset = 0, sort_by = "name", sort_direction = "ASC", ...extraParams } = params;
4
+ const res = await this.run(AudioStationApi.Artist, {
5
+ params: {
6
+ method: "list",
7
+ limit: limit,
8
+ offset: offset,
9
+ library: library,
10
+ sort_by: sort_by,
11
+ sort_direction: sort_direction,
12
+ additional: additional.join(","),
13
+ ...extraParams,
14
+ },
15
+ });
16
+ return res;
17
+ }
File without changes
@@ -0,0 +1,24 @@
1
+ import { SynologyApiResponse } from "../../types/index.js";
2
+ export type AudioStationFolderListParams = {
3
+ limit?: number;
4
+ offset?: number;
5
+ library?: "all";
6
+ additional?: Array<"song_tag" | "song_audio" | "song_rating">;
7
+ id?: string;
8
+ sort_by?: "song_rating" | "title" | "album" | "artist" | "duration" | "track";
9
+ sort_direction?: "ASC" | "DESC";
10
+ };
11
+ export type AudioStationFolderListResponse = SynologyApiResponse<{
12
+ folder_total: number;
13
+ id: string;
14
+ items: Array<{
15
+ id: string;
16
+ is_personal: boolean;
17
+ path: string;
18
+ title: string;
19
+ type: string;
20
+ }>;
21
+ offset: number;
22
+ total: number;
23
+ }>;
24
+ export declare function getFolderList(params: AudioStationFolderListParams): Promise<AudioStationFolderListResponse>;
@@ -0,0 +1,17 @@
1
+ import { AudioStationApi } from "../../types/index.js";
2
+ export async function getFolderList(params) {
3
+ const { additional = ["song_tag", "song_audio", "song_rating"], library = "all", limit = 1000, offset = 0, sort_by = "title", sort_direction = "ASC", ...extraParams } = params;
4
+ const res = await this.run(AudioStationApi.Folder, {
5
+ params: {
6
+ method: "list",
7
+ limit: limit,
8
+ offset: offset,
9
+ library: library,
10
+ sort_by: sort_by,
11
+ sort_direction: sort_direction,
12
+ additional: additional.join(","),
13
+ ...extraParams,
14
+ },
15
+ });
16
+ return res;
17
+ }
@@ -0,0 +1,45 @@
1
+ import { SynologyApiResponse } from "../../types/index.js";
2
+ export type AudioStationInfoResponse = SynologyApiResponse<{
3
+ ame_status: {
4
+ ame_major_version: number;
5
+ has_aac: boolean;
6
+ has_license: boolean;
7
+ is_aac_activated: boolean;
8
+ is_ame_broken: boolean;
9
+ is_ame_install: boolean;
10
+ need_aac_transcoding: boolean;
11
+ };
12
+ browse_personal_library: string;
13
+ dsd_decode_capability: boolean;
14
+ enable_equalizer: boolean;
15
+ enable_personal_library: boolean;
16
+ enable_user_home: boolean;
17
+ has_music_share: boolean;
18
+ is_manager: boolean;
19
+ playing_queue_max: number;
20
+ privilege: {
21
+ playlist_edit: boolean;
22
+ remote_player: boolean;
23
+ sharing: boolean;
24
+ tag_edit: boolean;
25
+ upnp_browse: boolean;
26
+ };
27
+ remote_controller: boolean;
28
+ same_subnet: boolean;
29
+ serial_number: string;
30
+ settings: {
31
+ audio_show_virtual_library: boolean;
32
+ disable_upnp: boolean;
33
+ enable_download: boolean;
34
+ prefer_using_html5: boolean;
35
+ transcode_to_mp3: boolean;
36
+ };
37
+ sid: string;
38
+ support_bluetooth: boolean;
39
+ support_usb: boolean;
40
+ support_virtual_library: boolean;
41
+ transcode_capability: Array<string>;
42
+ version: number;
43
+ version_string: string;
44
+ }>;
45
+ export declare function getInfo(): Promise<AudioStationInfoResponse>;
@@ -0,0 +1,9 @@
1
+ import { AudioStationApi } from "../../types/index.js";
2
+ export async function getInfo() {
3
+ const res = await this.run(AudioStationApi.Info, {
4
+ params: {
5
+ method: "getinfo",
6
+ },
7
+ });
8
+ return res;
9
+ }
@@ -0,0 +1,25 @@
1
+ import { SynologyApiResponse } from "../../types/index.js";
2
+ export declare function getLyrics(params: {
3
+ id: string;
4
+ }): Promise<SynologyApiResponse<{
5
+ lyrics: string;
6
+ }>>;
7
+ export type AudioStationSearchLyricsParams = {
8
+ title?: string;
9
+ artist?: string;
10
+ limit?: number;
11
+ additional?: Array<"full_lyrics" | string>;
12
+ };
13
+ export type AudioStationSearchLyricsResponse = SynologyApiResponse<{
14
+ lyrics: Array<{
15
+ additional: {
16
+ full_lyrics: string;
17
+ };
18
+ artist: string;
19
+ id: string;
20
+ partial_lyrics: string;
21
+ plugin: string;
22
+ title: string;
23
+ }>;
24
+ }>;
25
+ export declare function searchLyrics(params: AudioStationSearchLyricsParams): Promise<AudioStationSearchLyricsResponse>;
@@ -0,0 +1,23 @@
1
+ import { AudioStationApi } from "../../types/index.js";
2
+ export async function getLyrics(params // song id
3
+ ) {
4
+ const res = await this.run(AudioStationApi.Lyrics, {
5
+ params: {
6
+ method: "getlyrics",
7
+ id: params.id,
8
+ },
9
+ });
10
+ return res;
11
+ }
12
+ export async function searchLyrics(params) {
13
+ const { additional = ["full_lyrics"], limit = 1, ...extraParams } = params;
14
+ const res = await this.run(AudioStationApi.LyricsSearch, {
15
+ params: {
16
+ method: "searchlyrics",
17
+ limit: limit,
18
+ additional: additional.join(","),
19
+ ...extraParams,
20
+ },
21
+ });
22
+ return res;
23
+ }
@@ -0,0 +1,34 @@
1
+ import { SynologyApiResponse } from "../../types/index.js";
2
+ export type AudioStationCreatePlaylistParams = {
3
+ library?: "all" | "personal";
4
+ name: string;
5
+ };
6
+ export type AudioStationCreatePlaylistResponse = SynologyApiResponse<{
7
+ id: string;
8
+ }>;
9
+ export declare function createPlaylist(params: AudioStationCreatePlaylistParams): Promise<AudioStationCreatePlaylistResponse>;
10
+ export type AudioStationPlaylistParams = {
11
+ limit?: number;
12
+ offset?: number;
13
+ library?: "all" | "personal";
14
+ };
15
+ export type AudioStationPlaylistResponse = SynologyApiResponse<{
16
+ offset: number;
17
+ total: number;
18
+ playlists: Array<{
19
+ id: string;
20
+ library: string;
21
+ name: string;
22
+ sharing_status: string;
23
+ type: string;
24
+ }>;
25
+ }>;
26
+ export declare function getPlaylist(params: AudioStationPlaylistParams): Promise<AudioStationPlaylistResponse>;
27
+ /**
28
+ * deletePlaylist
29
+ * @param id
30
+ * @returns
31
+ */
32
+ export declare function deletePlaylist(params: {
33
+ id: string;
34
+ }): Promise<SynologyApiResponse<any>>;
@@ -0,0 +1,38 @@
1
+ import { AudioStationApi } from "../../types/index.js";
2
+ export async function createPlaylist(params) {
3
+ const { library = "all", name } = params;
4
+ const res = await this.run(AudioStationApi.Playlist, {
5
+ params: {
6
+ method: "create",
7
+ library,
8
+ name,
9
+ },
10
+ });
11
+ return res;
12
+ }
13
+ export async function getPlaylist(params) {
14
+ const { library = "all", limit = 1000, offset = 0 } = params;
15
+ const res = await this.run(AudioStationApi.Playlist, {
16
+ params: {
17
+ method: "list",
18
+ limit: limit,
19
+ offset: offset,
20
+ library: library,
21
+ },
22
+ });
23
+ return res;
24
+ }
25
+ /**
26
+ * deletePlaylist
27
+ * @param id
28
+ * @returns
29
+ */
30
+ export async function deletePlaylist(params) {
31
+ const res = await this.run(AudioStationApi.Playlist, {
32
+ params: {
33
+ method: "delete",
34
+ id: params.id,
35
+ },
36
+ });
37
+ return res;
38
+ }
@@ -0,0 +1,53 @@
1
+ import { SynologyApiResponse } from "../../types/index.js";
2
+ export type AudioStationSearchListParams = {
3
+ limit?: number;
4
+ library?: "all" | "personal";
5
+ additional?: Array<"song_tag" | "song_audio" | "song_rating">;
6
+ keyword?: string;
7
+ sort_by?: "title";
8
+ sort_direction?: "ASC" | "DESC";
9
+ };
10
+ export type AudioStationSearchListResponse = SynologyApiResponse<{
11
+ albumTotal: number;
12
+ albums: Array<{
13
+ album_artist: string;
14
+ artist: string;
15
+ display_artist: string;
16
+ name: string;
17
+ year: number;
18
+ }>;
19
+ artistTotal: number;
20
+ artists: Array<{
21
+ name: string;
22
+ }>;
23
+ songTotal: number;
24
+ songs: Array<{
25
+ additional: {
26
+ song_audio: {
27
+ bitrate: number;
28
+ channel: number;
29
+ codec: string;
30
+ container: string;
31
+ duration: number;
32
+ filesize: number;
33
+ frequency: number;
34
+ };
35
+ song_tag: {
36
+ album: string;
37
+ album_artist: string;
38
+ artist: string;
39
+ comment: string;
40
+ composer: string;
41
+ disc: number;
42
+ genre: string;
43
+ track: number;
44
+ year: number;
45
+ };
46
+ };
47
+ id: string;
48
+ path: string;
49
+ title: string;
50
+ type: string;
51
+ }>;
52
+ }>;
53
+ export declare function getArtistList(params: AudioStationSearchListParams): Promise<AudioStationSearchListResponse>;
@@ -0,0 +1,17 @@
1
+ import { AudioStationApi } from "../../types/index.js";
2
+ export async function getArtistList(params) {
3
+ const { additional = ["song_tag", "song_audio", "song_rating"], library = "all", limit = 10, sort_by = "title", sort_direction = "ASC", keyword = "", ...extraParams } = params;
4
+ const res = await this.run(AudioStationApi.Search, {
5
+ params: {
6
+ method: "list",
7
+ limit: limit,
8
+ keyword: keyword,
9
+ library: library,
10
+ sort_by: sort_by,
11
+ sort_direction: sort_direction,
12
+ additional: additional.join(","),
13
+ ...extraParams,
14
+ },
15
+ });
16
+ return res;
17
+ }
@@ -0,0 +1,33 @@
1
+ import { SynologyApiResponse } from "../../types/index.js";
2
+ /**
3
+ * fetch song list
4
+ * */
5
+ export type AudioStationSongListParams = {
6
+ limit?: number;
7
+ offset?: number;
8
+ library?: "all" | "personal";
9
+ additional?: Array<"song_tag" | "song_audio" | "song_rating">;
10
+ rating_filter?: number;
11
+ album_artist?: string;
12
+ album?: string;
13
+ artist?: string;
14
+ genre?: string;
15
+ sort_by?: "title" | "artist" | "random" | "name";
16
+ sort_direction?: "ASC" | "DESC";
17
+ };
18
+ export type AudioStationSongListResponse = SynologyApiResponse<{
19
+ offset: number;
20
+ total: number;
21
+ songs: {
22
+ [key: string]: any;
23
+ };
24
+ }>;
25
+ export declare function getSongList(params: AudioStationSongListParams): Promise<AudioStationSongListResponse>;
26
+ /**
27
+ * set song rating
28
+ */
29
+ export type AudioStationSetSongRatingParams = {
30
+ id: string;
31
+ rating: number;
32
+ };
33
+ export declare function setSongRating(params: AudioStationSetSongRatingParams): Promise<SynologyApiResponse<any>>;
@@ -0,0 +1,27 @@
1
+ import { AudioStationApi } from "../../types/index.js";
2
+ export async function getSongList(params) {
3
+ const { additional = ["song_tag", "song_audio", "song_rating"], library = "all", limit = 1000, offset = 0, sort_by = "title", sort_direction = "DESC", ...extraParams } = params;
4
+ const res = await this.run(AudioStationApi.Song, {
5
+ params: {
6
+ method: "list",
7
+ limit: limit,
8
+ offset: offset,
9
+ library: library,
10
+ sort_by: sort_by,
11
+ sort_direction: sort_direction,
12
+ additional: additional.join(","),
13
+ ...extraParams,
14
+ },
15
+ });
16
+ return res;
17
+ }
18
+ export async function setSongRating(params) {
19
+ const res = await this.run(AudioStationApi.Song, {
20
+ params: {
21
+ method: "setrating",
22
+ id: params.id,
23
+ rating: params.rating,
24
+ },
25
+ });
26
+ return res;
27
+ }
@@ -0,0 +1,23 @@
1
+ import { getSongList, setSongRating } from "./Song.js";
2
+ import { getAlbumList } from "./Album.js";
3
+ import { getArtistList } from "./Artist.js";
4
+ import { getPlaylist, createPlaylist, deletePlaylist } from "./Playlist.js";
5
+ import { getFolderList } from "./Folder.js";
6
+ import { getLyrics, searchLyrics } from "./Lyrics.js";
7
+ import { getInfo } from "./Info.js";
8
+ export declare const METHODS: {
9
+ getSongList: typeof getSongList;
10
+ setSongRating: typeof setSongRating;
11
+ getAlbumList: typeof getAlbumList;
12
+ getArtistList: typeof getArtistList;
13
+ getPlaylist: typeof getPlaylist;
14
+ createPlaylist: typeof createPlaylist;
15
+ deletePlaylist: typeof deletePlaylist;
16
+ getFolderList: typeof getFolderList;
17
+ getLyrics: typeof getLyrics;
18
+ searchLyrics: typeof searchLyrics;
19
+ getInfo: typeof getInfo;
20
+ };
21
+ export declare const SPELLING_KEY = "AudioStation";
22
+ export declare const SIMPLIFY_KEY = "as";
23
+ export type TMethods = typeof METHODS;
@@ -0,0 +1,23 @@
1
+ import { getSongList, setSongRating } from "./Song.js";
2
+ import { getAlbumList } from "./Album.js";
3
+ import { getArtistList } from "./Artist.js";
4
+ import { getPlaylist, createPlaylist, deletePlaylist } from "./Playlist.js";
5
+ import { getFolderList } from "./Folder.js";
6
+ import { getLyrics, searchLyrics } from "./Lyrics.js";
7
+ import { getInfo } from "./Info.js";
8
+ export const METHODS = {
9
+ getSongList,
10
+ setSongRating,
11
+ getAlbumList,
12
+ getArtistList,
13
+ getPlaylist,
14
+ createPlaylist,
15
+ deletePlaylist,
16
+ getFolderList,
17
+ getLyrics,
18
+ searchLyrics,
19
+ getInfo,
20
+ };
21
+ // name space
22
+ export const SPELLING_KEY = "AudioStation";
23
+ export const SIMPLIFY_KEY = "as";
@@ -0,0 +1,8 @@
1
+ import { SynologyApiResponse } from "../../types/index.js";
2
+ export type SynologyApiGetAuthKeyGrantParams = {
3
+ allow_api: string;
4
+ allow_methods: string[];
5
+ };
6
+ export declare function getAuthKeyGrant(params: SynologyApiGetAuthKeyGrantParams): Promise<SynologyApiResponse<{
7
+ tid: string;
8
+ }>>;
@@ -0,0 +1,12 @@
1
+ import { SynologyApiInfo } from "../../types/index.js";
2
+ export async function getAuthKeyGrant(params) {
3
+ const { allow_methods, allow_api } = params;
4
+ const result = await this.run(SynologyApiInfo.AuthKey, {
5
+ params: {
6
+ method: "grant",
7
+ allow_api: allow_api,
8
+ allow_methods: JSON.stringify(allow_methods),
9
+ },
10
+ });
11
+ return result;
12
+ }
@@ -0,0 +1,7 @@
1
+ import { getAuthKeyGrant } from "./AuthKey.js";
2
+ export declare const METHODS: {
3
+ getAuthKeyGrant: typeof getAuthKeyGrant;
4
+ };
5
+ export declare const SPELLING_KEY = "Auth";
6
+ export declare const SIMPLIFY_KEY = "au";
7
+ export type TMethods = typeof METHODS;
@@ -0,0 +1,8 @@
1
+ import { getAuthKeyGrant } from "./AuthKey.js";
2
+ // fs methods
3
+ export const METHODS = {
4
+ getAuthKeyGrant,
5
+ };
6
+ // name space
7
+ export const SPELLING_KEY = "Auth";
8
+ export const SIMPLIFY_KEY = "au";
File without changes
File without changes
@@ -1,4 +1,4 @@
1
- import { SynologyApiResponse } from "../../types";
1
+ import { SynologyApiResponse } from "../../types/index.js";
2
2
  /**
3
3
  * get filestation info
4
4
  */
@@ -0,0 +1,9 @@
1
+ import { FileStationApi } from "../../types/index.js";
2
+ export async function getInfo() {
3
+ const res = await this.run(FileStationApi.Info, {
4
+ params: {
5
+ method: "get",
6
+ },
7
+ });
8
+ return res;
9
+ }
@@ -1,4 +1,4 @@
1
- import { SynologyApiResponse } from "../../types";
1
+ import { SynologyApiResponse } from "../../types/index.js";
2
2
  /**
3
3
  * fetch filestation list
4
4
  */