javascript-ampache 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 (89) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +44 -0
  3. package/dist/albums/index.d.ts +62 -0
  4. package/dist/albums/types.d.ts +29 -0
  5. package/dist/artists/index.d.ts +64 -0
  6. package/dist/artists/types.d.ts +29 -0
  7. package/dist/auth/index.d.ts +47 -0
  8. package/dist/auth/types.d.ts +22 -0
  9. package/dist/base.d.ts +28 -0
  10. package/dist/bookmarks/index.d.ts +70 -0
  11. package/dist/bookmarks/types.d.ts +8 -0
  12. package/dist/catalogs/index.d.ts +51 -0
  13. package/dist/catalogs/types.d.ts +14 -0
  14. package/dist/genres/index.d.ts +30 -0
  15. package/dist/genres/types.d.ts +15 -0
  16. package/dist/index.d.ts +24 -0
  17. package/dist/index.js +2 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/index.m.js +2 -0
  20. package/dist/index.m.js.map +1 -0
  21. package/dist/index.modern.js +2 -0
  22. package/dist/index.modern.js.map +1 -0
  23. package/dist/index.umd.js +2 -0
  24. package/dist/index.umd.js.map +1 -0
  25. package/dist/labels/index.d.ts +32 -0
  26. package/dist/labels/types.d.ts +13 -0
  27. package/dist/licenses/index.d.ts +32 -0
  28. package/dist/licenses/types.d.ts +7 -0
  29. package/dist/live-streams/index.d.ts +32 -0
  30. package/dist/live-streams/types.d.ts +9 -0
  31. package/dist/playlists/index.d.ts +145 -0
  32. package/dist/playlists/types.d.ts +12 -0
  33. package/dist/podcasts/index.d.ts +125 -0
  34. package/dist/podcasts/types.d.ts +57 -0
  35. package/dist/preferences/index.d.ts +84 -0
  36. package/dist/preferences/types.d.ts +11 -0
  37. package/dist/shares/index.d.ts +69 -0
  38. package/dist/shares/types.d.ts +18 -0
  39. package/dist/shouts/index.d.ts +17 -0
  40. package/dist/shouts/types.d.ts +8 -0
  41. package/dist/songs/index.d.ts +140 -0
  42. package/dist/songs/types.d.ts +62 -0
  43. package/dist/system/index.d.ts +267 -0
  44. package/dist/system/types.d.ts +9 -0
  45. package/dist/users/index.d.ts +134 -0
  46. package/dist/users/types.d.ts +29 -0
  47. package/dist/utils.d.ts +2 -0
  48. package/dist/videos/index.d.ts +37 -0
  49. package/dist/videos/types.d.ts +27 -0
  50. package/package.json +40 -0
  51. package/src/albums/index.ts +80 -0
  52. package/src/albums/types.ts +31 -0
  53. package/src/artists/index.ts +82 -0
  54. package/src/artists/types.ts +31 -0
  55. package/src/auth/index.ts +91 -0
  56. package/src/auth/types.ts +22 -0
  57. package/src/base.ts +64 -0
  58. package/src/bookmarks/index.ts +94 -0
  59. package/src/bookmarks/types.ts +9 -0
  60. package/src/catalogs/index.ts +71 -0
  61. package/src/catalogs/types.ts +15 -0
  62. package/src/genres/index.ts +39 -0
  63. package/src/genres/types.ts +17 -0
  64. package/src/index.ts +26 -0
  65. package/src/labels/index.ts +42 -0
  66. package/src/labels/types.ts +14 -0
  67. package/src/licenses/index.ts +42 -0
  68. package/src/licenses/types.ts +8 -0
  69. package/src/live-streams/index.ts +42 -0
  70. package/src/live-streams/types.ts +10 -0
  71. package/src/playlists/index.ts +198 -0
  72. package/src/playlists/types.ts +13 -0
  73. package/src/podcasts/index.ts +174 -0
  74. package/src/podcasts/types.ts +60 -0
  75. package/src/preferences/index.ts +118 -0
  76. package/src/preferences/types.ts +12 -0
  77. package/src/shares/index.ts +94 -0
  78. package/src/shares/types.ts +19 -0
  79. package/src/shouts/index.ts +22 -0
  80. package/src/shouts/types.ts +9 -0
  81. package/src/songs/index.ts +191 -0
  82. package/src/songs/types.ts +64 -0
  83. package/src/system/index.ts +483 -0
  84. package/src/system/types.ts +11 -0
  85. package/src/users/index.ts +179 -0
  86. package/src/users/types.ts +32 -0
  87. package/src/utils.ts +25 -0
  88. package/src/videos/index.ts +53 -0
  89. package/src/videos/types.ts +29 -0
@@ -0,0 +1,94 @@
1
+ import qs from 'querystringify';
2
+ import { Share } from './types';
3
+ import { Base, BinaryBoolean, Pagination, Success, UID } from '../base';
4
+
5
+ export class Shares extends Base {
6
+ /**
7
+ * This searches the shares and returns... shares
8
+ * @remarks MINIMUM_API_VERSION=420000
9
+ * @param [params.filter] UID to find
10
+ * @param [params.exact] 0, 1 boolean to match the exact filter string
11
+ * @param [params.offset]
12
+ * @param [params.limit]
13
+ * @see {@link https://ampache.org/api/api-json-methods#shares}
14
+ */
15
+ async shares (params?: {
16
+ filter?: string,
17
+ exact?: BinaryBoolean,
18
+ } & Pagination) {
19
+ let query = 'shares';
20
+ query += qs.stringify(params, '&');
21
+ let data = await this.request<{share: Share[]}>(query);
22
+ return (data.share) ? data.share : data;
23
+ }
24
+
25
+ /**
26
+ * Return a share from UID
27
+ * @remarks MINIMUM_API_VERSION=420000
28
+ * @param params.filter UID to find
29
+ * @see {@link https://ampache.org/api/api-json-methods#share}
30
+ */
31
+ share (params: {
32
+ filter: UID,
33
+ }) {
34
+ let query = 'share';
35
+ query += qs.stringify(params, '&');
36
+ return this.request<Share>(query);
37
+ }
38
+
39
+ /**
40
+ * Create a public url that can be used by anyone to stream media.
41
+ * @remarks MINIMUM_API_VERSION=420000
42
+ * @param params.filter UID of object you are sharing
43
+ * @param params.type ('song', 'album', 'artist')
44
+ * @param [params.description] description (will be filled for you if empty)
45
+ * @param [params.expires] days to keep active
46
+ * @see {@link https://ampache.org/api/api-json-methods#share_create}
47
+ */
48
+ shareCreate (params: {
49
+ filter: UID,
50
+ type: 'song' | 'album' | 'artist',
51
+ description?: string,
52
+ expires?: number,
53
+ }) {
54
+ let query = 'share_create';
55
+ query += qs.stringify(params, '&');
56
+ return this.request<Share>(query);
57
+ }
58
+
59
+ /**
60
+ * Update the description and/or expiration date for an existing share
61
+ * @remarks MINIMUM_API_VERSION=420000
62
+ * @param params.filter UID to find
63
+ * @param [params.stream] 0, 1
64
+ * @param [params.download] 0, 1
65
+ * @param [params.expires] days to keep active
66
+ * @param [params.description] description
67
+ * @see {@link https://ampache.org/api/api-json-methods#share_edit}
68
+ */
69
+ shareEdit (params: {
70
+ filter: UID,
71
+ stream?: BinaryBoolean,
72
+ download?: BinaryBoolean,
73
+ expires?: number,
74
+ description?: string,
75
+ }) {
76
+ let query = 'share_edit';
77
+ query += qs.stringify(params, '&');
78
+ return this.request<Success>(query);
79
+ }
80
+
81
+ /**
82
+ * Delete an existing share.
83
+ * @remarks MINIMUM_API_VERSION=420000
84
+ * @param params.filter UID of share to delete
85
+ * @see {@link https://ampache.org/api/api-json-methods#share_delete}
86
+ */
87
+ shareDelete (params: {
88
+ filter: UID,
89
+ }) {
90
+ let query = 'share_delete';
91
+ query += qs.stringify(params, '&');
92
+ return this.request<Success>(query);
93
+ }
94
+ }
@@ -0,0 +1,19 @@
1
+ import { UID } from "../base";
2
+
3
+ export type Share = {
4
+ id: UID,
5
+ name: string,
6
+ owner: string,
7
+ allow_stream: boolean,
8
+ allow_download: boolean,
9
+ creation_date: number,
10
+ lastvisit_date: number,
11
+ object_type: string,
12
+ object_id: UID,
13
+ expire_days: number,
14
+ max_counter: number,
15
+ counter: number,
16
+ secret: string,
17
+ public_url: string,
18
+ description: string,
19
+ }
@@ -0,0 +1,22 @@
1
+ import qs from 'querystringify';
2
+ import { Shout } from './types';
3
+ import { Base } from '../base';
4
+
5
+ export class Shouts extends Base {
6
+ /**
7
+ * This gets the latest posted shouts
8
+ * @remarks MINIMUM_API_VERSION=380001
9
+ * @param [params.username] Username to find
10
+ * @param [params.limit] Maximum number of results to return
11
+ * @see {@link https://ampache.org/api/api-json-methods#last_shouts}
12
+ */
13
+ async last_shouts (params?: {
14
+ username?: string,
15
+ limit?: number
16
+ }) {
17
+ let query = 'last_shouts';
18
+ query += qs.stringify(params, '&');
19
+ let data = await this.request<{shout: Shout[]}>(query);
20
+ return (data.shout) ? data.shout : data;
21
+ }
22
+ }
@@ -0,0 +1,9 @@
1
+ import { UID } from "../base";
2
+ import { UserSummary } from "../users/types";
3
+
4
+ export type Shout = {
5
+ id: UID,
6
+ date: number,
7
+ text: string,
8
+ user: UserSummary,
9
+ }
@@ -0,0 +1,191 @@
1
+ import qs from 'querystringify';
2
+ import { Song, DeletedSong } from './types';
3
+ import { Base, BinaryBoolean, 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
+ * @see {@link https://ampache.org/api/api-json-methods#songs}
16
+ */
17
+ async songs (params?: {
18
+ filter?: string,
19
+ exact?: BinaryBoolean,
20
+ add?: Date,
21
+ update?: Date,
22
+ } & Pagination) {
23
+ let query = 'songs';
24
+ query += qs.stringify(params, '&');
25
+ let data = await this.request<{song: Song[]}>(query);
26
+ return (data.song) ? data.song : data;
27
+ }
28
+
29
+ /**
30
+ * Returns a single song
31
+ * @remarks MINIMUM_API_VERSION=380001
32
+ * @param params.filter UID to find
33
+ * @see {@link https://ampache.org/api/api-json-methods#song}
34
+ */
35
+ song (params: {
36
+ filter: UID,
37
+ }) {
38
+ let query = 'song';
39
+ query += qs.stringify(params, '&');
40
+ return this.request<Song>(query);
41
+ }
42
+
43
+ /**
44
+ * Songs of the specified artist
45
+ * @remarks MINIMUM_API_VERSION=380001
46
+ * @param params.filter UID to find
47
+ * @param [params.top50] 0, 1 (if true filter to the artist top 50)
48
+ * @param [params.offset]
49
+ * @param [params.limit]
50
+ * @see {@link https://ampache.org/api/api-json-methods#artist_songs}
51
+ */
52
+ async artistSongs (params: {
53
+ filter: UID,
54
+ top50?: BinaryBoolean,
55
+ } & Pagination) {
56
+ let query = 'artist_songs';
57
+ query += qs.stringify(params, '&');
58
+ let data = await this.request<{song: Song[]}>(query);
59
+ return (data.song) ? data.song : data;
60
+ }
61
+
62
+ /**
63
+ * Songs of the specified album
64
+ * @remarks MINIMUM_API_VERSION=380001
65
+ * @param params.filter UID to find
66
+ * @param [params.offset]
67
+ * @param [params.limit]
68
+ * @see {@link https://ampache.org/api/api-json-methods#album_songs}
69
+ */
70
+ async albumSongs (params: {
71
+ filter: UID,
72
+ } & Pagination) {
73
+ let query = 'album_songs';
74
+ query += qs.stringify(params, '&');
75
+ let data = await this.request<{song: Song[]}>(query);
76
+ return (data.song) ? data.song : data;
77
+ }
78
+
79
+ /**
80
+ * Songs of the specified genre
81
+ * @remarks MINIMUM_API_VERSION=380001
82
+ * @param params.filter UID to find
83
+ * @param [params.offset]
84
+ * @param [params.limit]
85
+ * @see {@link https://ampache.org/api/api-json-methods#genre_songs}
86
+ */
87
+ async genreSongs (params: {
88
+ filter: UID,
89
+ } & Pagination) {
90
+ let query = 'genre_songs';
91
+ query += qs.stringify(params, '&');
92
+ let data = await this.request<{song: Song[]}>(query);
93
+ return (data.song) ? data.song : data;
94
+ }
95
+
96
+ /**
97
+ * This returns the songs for a playlist
98
+ * @remarks MINIMUM_API_VERSION=380001
99
+ * @param params.filter UID to find
100
+ * @param [params.offset]
101
+ * @param [params.limit]
102
+ * @see {@link https://ampache.org/api/api-json-methods#playlist_songs}
103
+ */
104
+ async playlistSongs (params: {
105
+ filter: UID,
106
+ } & Pagination) {
107
+ let query = 'playlist_songs';
108
+ query += qs.stringify(params, '&');
109
+ let data = await this.request<{song: Song[]}>(query);
110
+ return (data.song) ? data.song : data;
111
+ }
112
+
113
+ /**
114
+ * This returns the songs for a license
115
+ * @remarks MINIMUM_API_VERSION=420000
116
+ * @param params.filter UID to find
117
+ * @param [params.offset]
118
+ * @param [params.limit]
119
+ * @see {@link https://ampache.org/api/api-json-methods#license_songs}
120
+ */
121
+ async licenseSongs (params: {
122
+ filter: UID,
123
+ } & Pagination) {
124
+ let query = 'license_songs';
125
+ query += qs.stringify(params, '&');
126
+ let data = await this.request<{song: Song[]}>(query);
127
+ return (data.song) ? data.song : data;
128
+ }
129
+
130
+ /**
131
+ * Delete an existing song. (if you are allowed to)
132
+ * @remarks MINIMUM_API_VERSION=5.0.0
133
+ * @param params.filter UID of song to delete
134
+ * @see {@link https://ampache.org/api/api-json-methods#song_delete}
135
+ */
136
+ songDelete (params: {
137
+ filter: UID,
138
+ }) {
139
+ let query = 'song_delete';
140
+ query += qs.stringify(params, '&');
141
+ return this.request<Success>(query);
142
+ }
143
+
144
+ /**
145
+ * This takes a URL and returns the song object in question
146
+ * @remarks MINIMUM_API_VERSION=380001
147
+ * @param params.url Full Ampache URL from server
148
+ * @see {@link https://ampache.org/api/api-json-methods#url_to_song}
149
+ */
150
+ urlToSong (params: {
151
+ url: string,
152
+ }) {
153
+ let query = 'url_to_song';
154
+ params.url = encodeURIComponent(params.url);
155
+ query += qs.stringify(params, '&');
156
+ return this.request<Song>(query);
157
+ }
158
+
159
+ /**
160
+ * This searches the songs and returns... songs
161
+ * @remarks MINIMUM_API_VERSION=380001
162
+ * @param params.filter Filter results to match this string
163
+ * @param [params.offset]
164
+ * @param [params.limit]
165
+ * @see {@link https://ampache.org/api/api-json-methods#search_songs}
166
+ */
167
+ async searchSongs (params: {
168
+ filter: string,
169
+ } & Pagination) {
170
+ let query = 'search_songs';
171
+ query += qs.stringify(params, '&');
172
+ let data = await this.request<{song: Song[]}>(query);
173
+ return (data.song) ? data.song : data;
174
+ }
175
+
176
+ /**
177
+ * Returns songs that have been deleted from the server
178
+ * @remarks MINIMUM_API_VERSION=500000
179
+ * @param [params.offset]
180
+ * @param [params.limit]
181
+ * @see {@link https://ampache.org/api/api-json-methods#deleted_songs}
182
+ */
183
+ async deletedSongs (params?: {
184
+
185
+ } & Pagination) {
186
+ let query = 'deleted_songs';
187
+ query += qs.stringify(params, '&');
188
+ let data = await this.request<{deleted_song: DeletedSong[]}>(query);
189
+ return (data.deleted_song) ? data.deleted_song : data;
190
+ }
191
+ }
@@ -0,0 +1,64 @@
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
+ flag: boolean,
33
+ rating: number | null,
34
+ averagerating: number | null,
35
+ playcount: number,
36
+ catalog: number,
37
+ composer: string,
38
+ channels: number | null,
39
+ comment: string,
40
+ license: string | null,
41
+ publisher: string,
42
+ language: string,
43
+ lyrics: string,
44
+ replaygain_album_gain: number | null,
45
+ replaygain_album_peak: number | null,
46
+ replaygain_track_gain: number | null,
47
+ replaygain_track_peak: number | null,
48
+ r128_album_gain: number | null,
49
+ r128_track_gain: number | null,
50
+ }
51
+
52
+ export type DeletedSong = {
53
+ id: UID,
54
+ addition_time: number,
55
+ delete_time: number,
56
+ update_time: number,
57
+ title: string,
58
+ file: string,
59
+ catalog: UID,
60
+ total_count: number,
61
+ total_skip: number,
62
+ album: UID,
63
+ artist: UID,
64
+ }