javascript-ampache 1.0.8 → 1.1.0

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 (50) hide show
  1. package/README.md +50 -47
  2. package/dist/base.d.ts +6 -0
  3. package/dist/index.js +1 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.m.js +1 -1
  6. package/dist/index.m.js.map +1 -1
  7. package/dist/index.modern.mjs +1 -1
  8. package/dist/index.modern.mjs.map +1 -1
  9. package/dist/index.umd.js +1 -1
  10. package/dist/index.umd.js.map +1 -1
  11. package/package.json +38 -38
  12. package/src/albums/index.ts +86 -86
  13. package/src/albums/types.ts +38 -32
  14. package/src/artists/index.ts +88 -88
  15. package/src/artists/types.ts +38 -32
  16. package/src/auth/index.ts +103 -103
  17. package/src/auth/types.ts +25 -25
  18. package/src/base.ts +134 -97
  19. package/src/bookmarks/index.ts +115 -122
  20. package/src/bookmarks/types.ts +15 -9
  21. package/src/catalogs/index.ts +130 -119
  22. package/src/catalogs/types.ts +27 -15
  23. package/src/genres/index.ts +39 -40
  24. package/src/genres/types.ts +23 -17
  25. package/src/index.ts +63 -26
  26. package/src/labels/index.ts +43 -44
  27. package/src/labels/types.ts +20 -14
  28. package/src/licenses/index.ts +43 -44
  29. package/src/licenses/types.ts +14 -8
  30. package/src/live-streams/index.ts +104 -107
  31. package/src/live-streams/types.ts +16 -10
  32. package/src/playlists/index.ts +264 -269
  33. package/src/playlists/types.ts +20 -14
  34. package/src/podcasts/index.ts +174 -177
  35. package/src/podcasts/types.ts +85 -67
  36. package/src/preferences/index.ts +114 -116
  37. package/src/preferences/types.ts +18 -12
  38. package/src/shares/index.ts +100 -96
  39. package/src/shares/types.ts +25 -19
  40. package/src/shouts/index.ts +18 -22
  41. package/src/shouts/types.ts +9 -9
  42. package/src/songs/index.ts +208 -203
  43. package/src/songs/types.ts +77 -65
  44. package/src/system/index.ts +689 -572
  45. package/src/system/types.ts +33 -19
  46. package/src/users/index.ts +227 -245
  47. package/src/users/types.ts +38 -32
  48. package/src/utils.ts +25 -25
  49. package/src/videos/index.ts +49 -53
  50. package/src/videos/types.ts +42 -30
@@ -1,203 +1,208 @@
1
- import qs from 'querystringify';
2
- import { Song, DeletedSong } from './types';
3
- import {Base, BinaryBoolean, ExtendedPagination, Pagination, Success, UID} from '../base';
4
-
5
- export class Songs extends Base {
6
- /**
7
- * Returns songs based on the specified filter
8
- * @remarks MINIMUM_API_VERSION=380001
9
- * @param [params.filter] Filter results to match this string
10
- * @param [params.exact] 0, 1 (if true filter is exact = rather than fuzzy LIKE)
11
- * @param [params.add] ISO 8601 Date Format (2020-09-16) Find objects with an 'add' date newer than the specified date
12
- * @param [params.update] ISO 8601 Date Format (2020-09-16) Find objects with an 'update' time newer than the specified date
13
- * @param [params.offset]
14
- * @param [params.limit]
15
- * @param [params.cond]
16
- * @param [params.sort]
17
- * @see {@link https://ampache.org/api/api-json-methods#songs}
18
- */
19
- async songs (params?: {
20
- filter?: string,
21
- exact?: BinaryBoolean,
22
- add?: Date,
23
- update?: Date,
24
- } & ExtendedPagination) {
25
- let query = 'songs';
26
- query += qs.stringify(params, '&');
27
- let data = await this.request<{song: Song[]}>(query);
28
- return (data.song) ? data.song : data;
29
- }
30
-
31
- /**
32
- * Returns a single song
33
- * @remarks MINIMUM_API_VERSION=380001
34
- * @param params.filter UID to find
35
- * @see {@link https://ampache.org/api/api-json-methods#song}
36
- */
37
- song (params: {
38
- filter: UID,
39
- }) {
40
- let query = 'song';
41
- query += qs.stringify(params, '&');
42
- return this.request<Song>(query);
43
- }
44
-
45
- /**
46
- * Songs of the specified artist
47
- * @remarks MINIMUM_API_VERSION=380001
48
- * @param params.filter UID to find
49
- * @param [params.top50] 0, 1 (if true filter to the artist top 50)
50
- * @param [params.offset]
51
- * @param [params.limit]
52
- * @param [params.cond]
53
- * @param [params.sort]
54
- * @see {@link https://ampache.org/api/api-json-methods#artist_songs}
55
- */
56
- async artistSongs (params: {
57
- filter: UID,
58
- top50?: BinaryBoolean,
59
- } & ExtendedPagination) {
60
- let query = 'artist_songs';
61
- query += qs.stringify(params, '&');
62
- let data = await this.request<{song: Song[]}>(query);
63
- return (data.song) ? data.song : data;
64
- }
65
-
66
- /**
67
- * Songs of the specified album
68
- * @remarks MINIMUM_API_VERSION=380001
69
- * @param params.filter UID to find
70
- * @param [params.offset]
71
- * @param [params.limit]
72
- * @param [params.cond]
73
- * @param [params.sort]
74
- * @see {@link https://ampache.org/api/api-json-methods#album_songs}
75
- */
76
- async albumSongs (params: {
77
- filter: UID,
78
- } & ExtendedPagination) {
79
- let query = 'album_songs';
80
- query += qs.stringify(params, '&');
81
- let data = await this.request<{song: Song[]}>(query);
82
- return (data.song) ? data.song : data;
83
- }
84
-
85
- /**
86
- * Songs of the specified genre
87
- * @remarks MINIMUM_API_VERSION=380001
88
- * @param params.filter UID to find
89
- * @param [params.offset]
90
- * @param [params.limit]
91
- * @param [params.cond]
92
- * @param [params.sort]
93
- * @see {@link https://ampache.org/api/api-json-methods#genre_songs}
94
- */
95
- async genreSongs (params: {
96
- filter: UID,
97
- } & ExtendedPagination) {
98
- let query = 'genre_songs';
99
- query += qs.stringify(params, '&');
100
- let data = await this.request<{song: Song[]}>(query);
101
- return (data.song) ? data.song : data;
102
- }
103
-
104
- /**
105
- * This returns the songs for a playlist
106
- * @remarks MINIMUM_API_VERSION=380001
107
- * @param params.filter UID to find
108
- * @param [params.random] 0, 1 (if true get random songs using limit)
109
- * @param [params.offset]
110
- * @param [params.limit]
111
- * @see {@link https://ampache.org/api/api-json-methods#playlist_songs}
112
- */
113
- async playlistSongs (params: {
114
- filter: UID,
115
- random?: BinaryBoolean,
116
- } & Pagination) {
117
- let query = 'playlist_songs';
118
- query += qs.stringify(params, '&');
119
- let data = await this.request<{song: Song[]}>(query);
120
- return (data.song) ? data.song : data;
121
- }
122
-
123
- /**
124
- * This returns the songs for a license
125
- * @remarks MINIMUM_API_VERSION=420000
126
- * @param params.filter UID to find
127
- * @param [params.offset]
128
- * @param [params.limit]
129
- * @param [params.cond]
130
- * @param [params.sort]
131
- * @see {@link https://ampache.org/api/api-json-methods#license_songs}
132
- */
133
- async licenseSongs (params: {
134
- filter: UID,
135
- } & ExtendedPagination) {
136
- let query = 'license_songs';
137
- query += qs.stringify(params, '&');
138
- let data = await this.request<{song: Song[]}>(query);
139
- return (data.song) ? data.song : data;
140
- }
141
-
142
- /**
143
- * Delete an existing song. (if you are allowed to)
144
- * @remarks MINIMUM_API_VERSION=5.0.0
145
- * @param params.filter UID of song to delete
146
- * @see {@link https://ampache.org/api/api-json-methods#song_delete}
147
- */
148
- songDelete (params: {
149
- filter: UID,
150
- }) {
151
- let query = 'song_delete';
152
- query += qs.stringify(params, '&');
153
- return this.request<Success>(query);
154
- }
155
-
156
- /**
157
- * This takes a URL and returns the song object in question
158
- * @remarks MINIMUM_API_VERSION=380001
159
- * @param params.url Full Ampache URL from server
160
- * @see {@link https://ampache.org/api/api-json-methods#url_to_song}
161
- */
162
- urlToSong (params: {
163
- url: string,
164
- }) {
165
- let query = 'url_to_song';
166
- params.url = encodeURIComponent(params.url);
167
- query += qs.stringify(params, '&');
168
- return this.request<Song>(query);
169
- }
170
-
171
- /**
172
- * This searches the songs and returns... songs
173
- * @remarks MINIMUM_API_VERSION=380001
174
- * @param params.filter Filter results to match this string
175
- * @param [params.offset]
176
- * @param [params.limit]
177
- * @see {@link https://ampache.org/api/api-json-methods#search_songs}
178
- */
179
- async searchSongs (params: {
180
- filter: string,
181
- } & Pagination) {
182
- let query = 'search_songs';
183
- query += qs.stringify(params, '&');
184
- let data = await this.request<{song: Song[]}>(query);
185
- return (data.song) ? data.song : data;
186
- }
187
-
188
- /**
189
- * Returns songs that have been deleted from the server
190
- * @remarks MINIMUM_API_VERSION=500000
191
- * @param [params.offset]
192
- * @param [params.limit]
193
- * @see {@link https://ampache.org/api/api-json-methods#deleted_songs}
194
- */
195
- async deletedSongs (params?: {
196
-
197
- } & Pagination) {
198
- let query = 'deleted_songs';
199
- query += qs.stringify(params, '&');
200
- let data = await this.request<{deleted_song: DeletedSong[]}>(query);
201
- return (data.deleted_song) ? data.deleted_song : data;
202
- }
203
- }
1
+ import qs from "querystringify";
2
+ import { SongResponse, SongsResponse, DeletedSongsResponse } from "./types";
3
+ import {
4
+ Base,
5
+ BinaryBoolean,
6
+ ExtendedPagination,
7
+ Pagination,
8
+ Success,
9
+ UID,
10
+ } from "../base";
11
+
12
+ export class Songs extends Base {
13
+ /**
14
+ * Returns songs based on the specified filter
15
+ * @remarks MINIMUM_API_VERSION=380001
16
+ * @param [params.filter] Filter results to match this string
17
+ * @param [params.exact] 0, 1 (if true filter is exact = rather than fuzzy LIKE)
18
+ * @param [params.add] ISO 8601 Date Format (2020-09-16) Find objects with an 'add' date newer than the specified date
19
+ * @param [params.update] ISO 8601 Date Format (2020-09-16) Find objects with an 'update' time newer than the specified date
20
+ * @param [params.offset]
21
+ * @param [params.limit]
22
+ * @param [params.cond]
23
+ * @param [params.sort]
24
+ * @see {@link https://ampache.org/api/api-json-methods#songs}
25
+ */
26
+ songs(
27
+ params?: {
28
+ filter?: string;
29
+ exact?: BinaryBoolean;
30
+ add?: Date;
31
+ update?: Date;
32
+ } & ExtendedPagination,
33
+ ) {
34
+ let query = "songs";
35
+ query += qs.stringify(params, "&");
36
+ return this.request<SongsResponse>(query);
37
+ }
38
+
39
+ /**
40
+ * Returns a single song
41
+ * @remarks MINIMUM_API_VERSION=380001
42
+ * @param params.filter UID to find
43
+ * @see {@link https://ampache.org/api/api-json-methods#song}
44
+ */
45
+ song(params: { filter: UID }) {
46
+ let query = "song";
47
+ query += qs.stringify(params, "&");
48
+ return this.request<SongResponse>(query);
49
+ }
50
+
51
+ /**
52
+ * Songs of the specified artist
53
+ * @remarks MINIMUM_API_VERSION=380001
54
+ * @param params.filter UID to find
55
+ * @param [params.top50] 0, 1 (if true filter to the artist top 50)
56
+ * @param [params.offset]
57
+ * @param [params.limit]
58
+ * @param [params.cond]
59
+ * @param [params.sort]
60
+ * @see {@link https://ampache.org/api/api-json-methods#artist_songs}
61
+ */
62
+ artistSongs(
63
+ params: {
64
+ filter: UID;
65
+ top50?: BinaryBoolean;
66
+ } & ExtendedPagination,
67
+ ) {
68
+ let query = "artist_songs";
69
+ query += qs.stringify(params, "&");
70
+ return this.request<SongsResponse>(query);
71
+ }
72
+
73
+ /**
74
+ * Songs of the specified album
75
+ * @remarks MINIMUM_API_VERSION=380001
76
+ * @param params.filter UID to find
77
+ * @param [params.offset]
78
+ * @param [params.limit]
79
+ * @param [params.cond]
80
+ * @param [params.sort]
81
+ * @see {@link https://ampache.org/api/api-json-methods#album_songs}
82
+ */
83
+ albumSongs(
84
+ params: {
85
+ filter: UID;
86
+ } & ExtendedPagination,
87
+ ) {
88
+ let query = "album_songs";
89
+ query += qs.stringify(params, "&");
90
+ return this.request<SongsResponse>(query);
91
+ }
92
+
93
+ /**
94
+ * Songs of the specified genre
95
+ * @remarks MINIMUM_API_VERSION=380001
96
+ * @param params.filter UID to find
97
+ * @param [params.offset]
98
+ * @param [params.limit]
99
+ * @param [params.cond]
100
+ * @param [params.sort]
101
+ * @see {@link https://ampache.org/api/api-json-methods#genre_songs}
102
+ */
103
+ genreSongs(
104
+ params: {
105
+ filter: UID;
106
+ } & ExtendedPagination,
107
+ ) {
108
+ let query = "genre_songs";
109
+ query += qs.stringify(params, "&");
110
+ return this.request<SongsResponse>(query);
111
+ }
112
+
113
+ /**
114
+ * This returns the songs for a playlist
115
+ * @remarks MINIMUM_API_VERSION=380001
116
+ * @param params.filter UID to find
117
+ * @param [params.random] 0, 1 (if true get random songs using limit)
118
+ * @param [params.offset]
119
+ * @param [params.limit]
120
+ * @see {@link https://ampache.org/api/api-json-methods#playlist_songs}
121
+ */
122
+ playlistSongs(
123
+ params: {
124
+ filter: UID;
125
+ random?: BinaryBoolean;
126
+ } & Pagination,
127
+ ) {
128
+ let query = "playlist_songs";
129
+ query += qs.stringify(params, "&");
130
+ return this.request<SongsResponse>(query);
131
+ }
132
+
133
+ /**
134
+ * This returns the songs for a license
135
+ * @remarks MINIMUM_API_VERSION=420000
136
+ * @param params.filter UID to find
137
+ * @param [params.offset]
138
+ * @param [params.limit]
139
+ * @param [params.cond]
140
+ * @param [params.sort]
141
+ * @see {@link https://ampache.org/api/api-json-methods#license_songs}
142
+ */
143
+ licenseSongs(
144
+ params: {
145
+ filter: UID;
146
+ } & ExtendedPagination,
147
+ ) {
148
+ let query = "license_songs";
149
+ query += qs.stringify(params, "&");
150
+ return this.request<SongsResponse>(query);
151
+ }
152
+
153
+ /**
154
+ * Delete an existing song. (if you are allowed to)
155
+ * @remarks MINIMUM_API_VERSION=5.0.0
156
+ * @param params.filter UID of song to delete
157
+ * @see {@link https://ampache.org/api/api-json-methods#song_delete}
158
+ */
159
+ songDelete(params: { filter: UID }) {
160
+ let query = "song_delete";
161
+ query += qs.stringify(params, "&");
162
+ return this.request<Success>(query);
163
+ }
164
+
165
+ /**
166
+ * This takes a URL and returns the song object in question
167
+ * @remarks MINIMUM_API_VERSION=380001
168
+ * @param params.url Full Ampache URL from server
169
+ * @see {@link https://ampache.org/api/api-json-methods#url_to_song}
170
+ */
171
+ urlToSong(params: { url: string }) {
172
+ let query = "url_to_song";
173
+ params.url = encodeURIComponent(params.url);
174
+ query += qs.stringify(params, "&");
175
+ return this.request<SongResponse>(query);
176
+ }
177
+
178
+ /**
179
+ * This searches the songs and returns... songs
180
+ * @remarks MINIMUM_API_VERSION=380001
181
+ * @param params.filter Filter results to match this string
182
+ * @param [params.offset]
183
+ * @param [params.limit]
184
+ * @see {@link https://ampache.org/api/api-json-methods#search_songs}
185
+ */
186
+ searchSongs(
187
+ params: {
188
+ filter: string;
189
+ } & Pagination,
190
+ ) {
191
+ let query = "search_songs";
192
+ query += qs.stringify(params, "&");
193
+ return this.request<SongsResponse>(query);
194
+ }
195
+
196
+ /**
197
+ * Returns songs that have been deleted from the server
198
+ * @remarks MINIMUM_API_VERSION=500000
199
+ * @param [params.offset]
200
+ * @param [params.limit]
201
+ * @see {@link https://ampache.org/api/api-json-methods#deleted_songs}
202
+ */
203
+ deletedSongs(params?: {} & Pagination) {
204
+ let query = "deleted_songs";
205
+ query += qs.stringify(params, "&");
206
+ return this.request<DeletedSongsResponse>(query);
207
+ }
208
+ }
@@ -1,65 +1,77 @@
1
- import { ArtistSummary } from "../artists/types";
2
- import { GenreSummary } from "../genres/types";
3
- import { UID } from "../base";
4
- import { AlbumSummary } from "../albums/types";
5
-
6
- export type Song = {
7
- id: UID,
8
- title: string,
9
- name: string,
10
- artist: ArtistSummary,
11
- album: AlbumSummary,
12
- albumartist: ArtistSummary,
13
- disk: number,
14
- track: number
15
- filename: string,
16
- genre: GenreSummary[],
17
- playlisttrack: number,
18
- time: number,
19
- year: number | string,
20
- format: string,
21
- stream_format: string,
22
- rate: number,
23
- mode: string,
24
- mime: string,
25
- stream_mime: string,
26
- url: string,
27
- size: number,
28
- mbid: string | null,
29
- album_mbid: string | null,
30
- artist_mbid: string | null,
31
- art: string,
32
- has_art: boolean,
33
- flag: boolean,
34
- rating: number | null,
35
- averagerating: number | null,
36
- playcount: number,
37
- catalog: number,
38
- composer: string,
39
- channels: number | null,
40
- comment: string,
41
- license: string | null,
42
- publisher: string,
43
- language: string,
44
- lyrics: string,
45
- replaygain_album_gain: number | null,
46
- replaygain_album_peak: number | null,
47
- replaygain_track_gain: number | null,
48
- replaygain_track_peak: number | null,
49
- r128_album_gain: number | null,
50
- r128_track_gain: number | null,
51
- }
52
-
53
- export type DeletedSong = {
54
- id: UID,
55
- addition_time: number,
56
- delete_time: number,
57
- update_time: number,
58
- title: string,
59
- file: string,
60
- catalog: UID,
61
- total_count: number,
62
- total_skip: number,
63
- album: UID,
64
- artist: UID,
65
- }
1
+ import { ArtistSummary } from "../artists/types";
2
+ import { GenreSummary } from "../genres/types";
3
+ import { UID } from "../base";
4
+ import { AlbumSummary } from "../albums/types";
5
+
6
+ export type SongResponse = {
7
+ id: UID;
8
+ title: string;
9
+ name: string;
10
+ artist: ArtistSummary;
11
+ album: AlbumSummary;
12
+ albumartist: ArtistSummary;
13
+ disk: number;
14
+ track: number;
15
+ filename: string;
16
+ genre: GenreSummary[];
17
+ playlisttrack: number;
18
+ time: number;
19
+ year: number | string;
20
+ format: string;
21
+ stream_format: string;
22
+ rate: number;
23
+ mode: string;
24
+ mime: string;
25
+ stream_mime: string;
26
+ url: string;
27
+ size: number;
28
+ mbid: string | null;
29
+ album_mbid: string | null;
30
+ artist_mbid: string | null;
31
+ art: string;
32
+ has_art: boolean;
33
+ flag: boolean;
34
+ rating: number | null;
35
+ averagerating: number | null;
36
+ playcount: number;
37
+ catalog: number;
38
+ composer: string;
39
+ channels: number | null;
40
+ comment: string;
41
+ license: string | null;
42
+ publisher: string;
43
+ language: string;
44
+ lyrics: string;
45
+ replaygain_album_gain: number | null;
46
+ replaygain_album_peak: number | null;
47
+ replaygain_track_gain: number | null;
48
+ replaygain_track_peak: number | null;
49
+ r128_album_gain: number | null;
50
+ r128_track_gain: number | null;
51
+ };
52
+
53
+ export type SongsResponse = {
54
+ total_count: number;
55
+ md5: string;
56
+ song: SongResponse[];
57
+ };
58
+
59
+ export type DeletedSongResponse = {
60
+ id: UID;
61
+ addition_time: number;
62
+ delete_time: number;
63
+ update_time: number;
64
+ title: string;
65
+ file: string;
66
+ catalog: UID;
67
+ total_count: number;
68
+ total_skip: number;
69
+ album: UID;
70
+ artist: UID;
71
+ };
72
+
73
+ export type DeletedSongsResponse = {
74
+ total_count: number;
75
+ md5: string;
76
+ deleted_song: DeletedSongResponse[];
77
+ };