javascript-ampache 1.1.10 → 2.0.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 (108) hide show
  1. package/README.md +16 -6
  2. package/dist/index.js +1 -1
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.m.js +1 -1
  5. package/dist/index.m.js.map +1 -1
  6. package/dist/index.modern.mjs +1 -1
  7. package/dist/index.modern.mjs.map +1 -1
  8. package/dist/index.umd.js +1 -1
  9. package/dist/index.umd.js.map +1 -1
  10. package/package.json +8 -7
  11. package/src/albums.js +106 -0
  12. package/src/artists.js +105 -0
  13. package/src/auth.js +142 -0
  14. package/src/base.js +145 -0
  15. package/src/bookmarks.js +106 -0
  16. package/src/catalogs.js +133 -0
  17. package/src/genres.js +57 -0
  18. package/src/index.js +30 -0
  19. package/src/labels.js +53 -0
  20. package/src/licenses.js +47 -0
  21. package/src/live-streams.js +97 -0
  22. package/src/playlists.js +241 -0
  23. package/src/podcasts.js +230 -0
  24. package/src/preferences.js +114 -0
  25. package/src/shares.js +99 -0
  26. package/src/shouts.js +24 -0
  27. package/src/songs.js +273 -0
  28. package/src/system.js +510 -0
  29. package/src/users.js +224 -0
  30. package/src/{utils.ts → utils.js} +16 -16
  31. package/src/videos.js +84 -0
  32. package/dist/albums/index.d.ts +0 -64
  33. package/dist/albums/types.d.ts +0 -37
  34. package/dist/artists/index.d.ts +0 -64
  35. package/dist/artists/types.d.ts +0 -35
  36. package/dist/auth/index.d.ts +0 -56
  37. package/dist/auth/types.d.ts +0 -32
  38. package/dist/base.d.ts +0 -47
  39. package/dist/bookmarks/index.d.ts +0 -91
  40. package/dist/bookmarks/types.d.ts +0 -13
  41. package/dist/catalogs/index.d.ts +0 -87
  42. package/dist/catalogs/types.d.ts +0 -19
  43. package/dist/genres/index.d.ts +0 -28
  44. package/dist/genres/types.d.ts +0 -22
  45. package/dist/index.d.ts +0 -24
  46. package/dist/labels/index.d.ts +0 -32
  47. package/dist/labels/types.d.ts +0 -18
  48. package/dist/licenses/index.d.ts +0 -32
  49. package/dist/licenses/types.d.ts +0 -12
  50. package/dist/live-streams/index.d.ts +0 -80
  51. package/dist/live-streams/types.d.ts +0 -14
  52. package/dist/playlists/index.d.ts +0 -204
  53. package/dist/playlists/types.d.ts +0 -26
  54. package/dist/podcasts/index.d.ts +0 -121
  55. package/dist/podcasts/types.d.ts +0 -79
  56. package/dist/preferences/index.d.ts +0 -80
  57. package/dist/preferences/types.d.ts +0 -18
  58. package/dist/shares/index.d.ts +0 -69
  59. package/dist/shares/types.d.ts +0 -23
  60. package/dist/shouts/index.d.ts +0 -17
  61. package/dist/shouts/types.d.ts +0 -10
  62. package/dist/songs/index.d.ts +0 -143
  63. package/dist/songs/types.d.ts +0 -73
  64. package/dist/system/index.d.ts +0 -407
  65. package/dist/system/types.d.ts +0 -24
  66. package/dist/users/index.d.ts +0 -190
  67. package/dist/users/types.d.ts +0 -34
  68. package/dist/utils.d.ts +0 -4
  69. package/dist/videos/index.d.ts +0 -33
  70. package/dist/videos/types.d.ts +0 -38
  71. package/src/albums/index.ts +0 -88
  72. package/src/albums/types.ts +0 -40
  73. package/src/artists/index.ts +0 -88
  74. package/src/artists/types.ts +0 -38
  75. package/src/auth/index.ts +0 -118
  76. package/src/auth/types.ts +0 -32
  77. package/src/base.ts +0 -133
  78. package/src/bookmarks/index.ts +0 -116
  79. package/src/bookmarks/types.ts +0 -15
  80. package/src/catalogs/index.ts +0 -130
  81. package/src/catalogs/types.ts +0 -27
  82. package/src/genres/index.ts +0 -39
  83. package/src/genres/types.ts +0 -25
  84. package/src/index.ts +0 -63
  85. package/src/labels/index.ts +0 -43
  86. package/src/labels/types.ts +0 -20
  87. package/src/licenses/index.ts +0 -43
  88. package/src/licenses/types.ts +0 -14
  89. package/src/live-streams/index.ts +0 -104
  90. package/src/live-streams/types.ts +0 -16
  91. package/src/playlists/index.ts +0 -280
  92. package/src/playlists/types.ts +0 -29
  93. package/src/podcasts/index.ts +0 -174
  94. package/src/podcasts/types.ts +0 -85
  95. package/src/preferences/index.ts +0 -114
  96. package/src/preferences/types.ts +0 -20
  97. package/src/shares/index.ts +0 -100
  98. package/src/shares/types.ts +0 -25
  99. package/src/shouts/index.ts +0 -18
  100. package/src/shouts/types.ts +0 -11
  101. package/src/songs/index.ts +0 -221
  102. package/src/songs/types.ts +0 -77
  103. package/src/system/index.ts +0 -845
  104. package/src/system/types.ts +0 -42
  105. package/src/users/index.ts +0 -227
  106. package/src/users/types.ts +0 -38
  107. package/src/videos/index.ts +0 -49
  108. package/src/videos/types.ts +0 -42
@@ -1,42 +0,0 @@
1
- import { SongResponse } from "../songs/types";
2
- import { AlbumResponse } from "../albums/types";
3
- import { ArtistResponse } from "../artists/types";
4
- import { PlaylistResponse } from "../playlists/types";
5
- import { PodcastResponse, PodcastEpisodeResponse } from "../podcasts/types";
6
- import { LiveStreamResponse } from "../live-streams/types";
7
- import { VideoResponse } from "../videos/types";
8
- import { UID } from "../base";
9
- import { UserSummary } from "../users/types";
10
-
11
- export type IndexType =
12
- | SongResponse
13
- | AlbumResponse
14
- | ArtistResponse
15
- | PlaylistResponse
16
- | PodcastResponse
17
- | PodcastEpisodeResponse
18
- | LiveStreamResponse;
19
-
20
- export type StatsType =
21
- | SongResponse
22
- | AlbumResponse
23
- | ArtistResponse
24
- | VideoResponse
25
- | PlaylistResponse
26
- | PodcastResponse
27
- | PodcastEpisodeResponse;
28
-
29
- export type IndexEntry = {
30
- id: UID;
31
- name: string;
32
- prefix: string;
33
- basename: string;
34
- };
35
-
36
- export type NowPlayingResponse = {
37
- id: UID;
38
- type: "song" | "podcast_episode" | "video";
39
- client: string;
40
- expire: number;
41
- user: UserSummary;
42
- }
@@ -1,227 +0,0 @@
1
- import qs from "querystringify";
2
- import { UserResponse, UserSummary, ActivityResponse } from "./types";
3
- import { Base, BinaryBoolean, ExtendedPagination, Success } from "../base";
4
-
5
- export class Users extends Base {
6
- /**
7
- * Get ids and usernames for your site
8
- * @remarks MINIMUM_API_VERSION=5.0.0
9
- * @see {@link https://ampache.org/api/api-json-methods#users}
10
- */
11
- users() {
12
- let query = "users";
13
- return this.request<{ user: UserSummary[] }>(query);
14
- }
15
-
16
- /**
17
- * This get a user's public information (or current user if username is omitted)
18
- * @remarks MINIMUM_API_VERSION=380001
19
- * @param [params.username] UID to find
20
- * @see {@link https://ampache.org/api/api-json-methods#user}
21
- */
22
- user(params?: { username?: string }) {
23
- let query = "user";
24
- query += qs.stringify(params, "&");
25
- return this.request<UserResponse>(query);
26
- }
27
-
28
- /**
29
- * Create a new user
30
- * ACCESS REQUIRED: 100 (Admin)
31
- * @remarks MINIMUM_API_VERSION=400001
32
- * @param params.username Username
33
- * @param params.password SHA256 hashed password
34
- * @param params.email Email
35
- * @param [params.fullname] Full Name
36
- * @param [params.disable] 0, 1
37
- * @param [params.catalog_filter_group] Catalog filter group, default = 0
38
- * @see {@link https://ampache.org/api/api-json-methods#user_create}
39
- */
40
- userCreate(params: {
41
- username: string;
42
- password: string;
43
- email: string;
44
- fullname?: string;
45
- disable?: BinaryBoolean;
46
- catalog_filter_group?: number;
47
- }) {
48
- let query = "user_create";
49
- query += qs.stringify(params, "&");
50
- return this.request<Success>(query);
51
- }
52
-
53
- /**
54
- * Register as a new user if allowed.
55
- * @remarks MINIMUM_API_VERSION=6.0.0
56
- * @param params.username Username
57
- * @param params.password SHA256 hashed password
58
- * @param params.email Email
59
- * @param [params.fullname] Full Name
60
- * @see {@link https://ampache.org/api/api-json-methods/#register}
61
- */
62
- register(params: {
63
- username: string;
64
- password: string;
65
- email: string;
66
- fullname?: string;
67
- }) {
68
- let query = "register";
69
- query += qs.stringify(params, "&");
70
- return this.request<Success>(query);
71
- }
72
-
73
- /**
74
- * Update an existing user
75
- * ACCESS REQUIRED: 100 (Admin)
76
- * @remarks MINIMUM_API_VERSION=400001
77
- * @param params.username Username
78
- * @param [params.password] Password
79
- * @param [params.email] Email
80
- * @param [params.fullname] Full Name
81
- * @param [params.website] Website
82
- * @param [params.state] State
83
- * @param [params.city] City
84
- * @param [params.disable] 0, 1
85
- * @param [params.maxbitrate] Max bitrate for transcoding
86
- * @see {@link https://ampache.org/api/api-json-methods#user_update}
87
- * @deprecated Being removed in 7.0.0. Use `user_edit` instead.
88
- */
89
- userUpdate(params: {
90
- username: string;
91
- password?: string;
92
- email?: string;
93
- fullname?: string;
94
- website?: string;
95
- state?: string;
96
- city?: string;
97
- disable?: BinaryBoolean;
98
- maxbitrate?: string;
99
- }) {
100
- let query = "user_update";
101
- query += qs.stringify(params, "&");
102
- return this.request<Success>(query);
103
- }
104
-
105
- /**
106
- * Update an existing user
107
- * ACCESS REQUIRED: 100 (Admin)
108
- * @remarks MINIMUM_API_VERSION=6.0.0
109
- * @param params.username Username
110
- * @param [params.password] Password
111
- * @param [params.email] Email
112
- * @param [params.fullname] Full Name
113
- * @param [params.website] Website
114
- * @param [params.state] State
115
- * @param [params.city] City
116
- * @param [params.disable] 0, 1
117
- * @param [params.maxbitrate] Max bitrate for transcoding
118
- * @param [params.group] Catalog filter group, default = 0
119
- * @param [params.fullname_public] show fullname in public display
120
- * @param [params.reset_apikey] reset user Api Key
121
- * @param [params.reset_streamtoken] reset user Stream Token
122
- * @param [params.clear_stats] reset all stats for this user
123
- * @see {@link https://ampache.org/api/api-json-methods#user_edit}
124
- */
125
- userEdit(params: {
126
- username: string;
127
- password?: string;
128
- email?: string;
129
- fullname?: string;
130
- website?: string;
131
- state?: string;
132
- city?: string;
133
- maxbitrate?: string;
134
- group?: number;
135
- disable?: BinaryBoolean;
136
- fullname_public?: BinaryBoolean;
137
- reset_apikey?: BinaryBoolean;
138
- reset_streamtoken?: BinaryBoolean;
139
- clear_stats?: BinaryBoolean;
140
- }) {
141
- let query = "user_edit";
142
- query += qs.stringify(params, "&");
143
- return this.request<Success>(query);
144
- }
145
-
146
- /**
147
- * Delete an existing user.
148
- * ACCESS REQUIRED: 100 (Admin)
149
- * @remarks MINIMUM_API_VERSION=400001
150
- * @param params.filter UID of user to delete
151
- * @see {@link https://ampache.org/api/api-json-methods#user_delete}
152
- */
153
- userDelete(params: { filter: string }) {
154
- let query = "user_delete";
155
- query += qs.stringify(params, "&");
156
- return this.request<Success>(query);
157
- }
158
-
159
- /**
160
- * This gets the followers for the requested username
161
- * @remarks MINIMUM_API_VERSION=380001
162
- * @param params.username UID to find
163
- * @param [params.offset]
164
- * @param [params.limit]
165
- * @param [params.cond]
166
- * @param [params.sort]
167
- * @see {@link https://ampache.org/api/api-json-methods#followers}
168
- */
169
- followers(
170
- params: {
171
- username: string;
172
- } & ExtendedPagination,
173
- ) {
174
- let query = "followers";
175
- query += qs.stringify(params, "&");
176
- return this.request<{ user: UserSummary[] }>(query);
177
- }
178
-
179
- /**
180
- * Get a list of people that this user follows
181
- * @remarks MINIMUM_API_VERSION=380001
182
- * @see {@link https://ampache.org/api/api-json-methods#following}
183
- */
184
- following(params: { username: string }) {
185
- let query = "following";
186
- query += qs.stringify(params, "&");
187
- return this.request<{ user: UserSummary[] }>(query);
188
- }
189
-
190
- /**
191
- * This will follow/unfollow a user
192
- * @param params.username Username string to find
193
- * @see {@link https://ampache.org/api/api-json-methods#toggle_follow}
194
- */
195
- toggleFollow(params: { username: string }) {
196
- let query = "toggle_follow";
197
- query += qs.stringify(params, "&");
198
- return this.request<Success>(query);
199
- }
200
-
201
- /**
202
- * This get a user timeline
203
- * @remarks MINIMUM_API_VERSION=380001
204
- * @param params.username Username to find
205
- * @param [params.limit] Max results to return
206
- * @param [params.since] UNIXTIME
207
- * @see {@link https://ampache.org/api/api-json-methods#timeline}
208
- */
209
- timeline(params: { username: string; limit?: number; since?: number }) {
210
- let query = "timeline";
211
- query += qs.stringify(params, "&");
212
- return this.request<{ activity: ActivityResponse[] }>(query);
213
- }
214
-
215
- /**
216
- * This get current user friends timeline
217
- * @remarks MINIMUM_API_VERSION=380001
218
- * @param [params.limit] Max results to return
219
- * @param [params.since] UNIXTIME
220
- * @see {@link https://ampache.org/api/api-json-methods#friends_timeline}
221
- */
222
- friendsTimeline(params?: { limit?: number; since?: number }) {
223
- let query = "friends_timeline";
224
- query += qs.stringify(params, "&");
225
- return this.request<{ activity: ActivityResponse[] }>(query);
226
- }
227
- }
@@ -1,38 +0,0 @@
1
- import { UID } from "../base";
2
-
3
- export type UserSummary = {
4
- id: UID;
5
- username: string;
6
- };
7
-
8
- export type UserResponse = {
9
- id: UID;
10
- username: string;
11
- auth: string;
12
- email: string;
13
- access: number;
14
- streamtoken: string | null;
15
- fullname_public: number;
16
- validation: string | null;
17
- disabled: boolean;
18
- create_date: number;
19
- last_seen: number;
20
- website: string | null;
21
- state: string | null;
22
- city: string | null;
23
- };
24
-
25
- export type UsersResponse = {
26
- total_count: number;
27
- md5: string;
28
- user: UserResponse[];
29
- };
30
-
31
- export type ActivityResponse = {
32
- id: UID;
33
- date: number;
34
- object_type: string;
35
- object_id: UID;
36
- action: string;
37
- user: UserSummary;
38
- };
@@ -1,49 +0,0 @@
1
- import qs from "querystringify";
2
- import { VideoResponse, VideosResponse, DeletedVideosResponse } from "./types";
3
- import { Base, BinaryBoolean, Pagination, UID } from "../base";
4
-
5
- export class Videos extends Base {
6
- /**
7
- * Get videos
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.offset]
12
- * @param [params.limit]
13
- * @see {@link https://ampache.org/api/api-json-methods#videos}
14
- */
15
- videos(
16
- params?: {
17
- filter?: string;
18
- exact?: BinaryBoolean;
19
- } & Pagination,
20
- ) {
21
- let query = "videos";
22
- query += qs.stringify(params, "&");
23
- return this.request<VideosResponse>(query);
24
- }
25
-
26
- /**
27
- * This returns a single video
28
- * @remarks MINIMUM_API_VERSION=380001
29
- * @param params.filter UID to find
30
- * @see {@link https://ampache.org/api/api-json-methods#video}
31
- */
32
- video(params: { filter: UID }) {
33
- let query = "video";
34
- query += qs.stringify(params, "&");
35
- return this.request<VideoResponse>(query);
36
- }
37
-
38
- /**
39
- * This returns video objects that have been deleted
40
- * @param [params.offset]
41
- * @param [params.limit]
42
- * @see {@link https://ampache.org/api/api-json-methods#deleted_videos}
43
- */
44
- deletedVideos(params?: {} & Pagination) {
45
- let query = "deleted_videos";
46
- query += qs.stringify(params, "&");
47
- return this.request<DeletedVideosResponse>(query);
48
- }
49
- }
@@ -1,42 +0,0 @@
1
- import { UID } from "../base";
2
- import { GenreSummary } from "../genres/types";
3
-
4
- export type VideoResponse = {
5
- id: UID;
6
- title: string;
7
- mime: string;
8
- resolution: string;
9
- size: number;
10
- genre: GenreSummary[];
11
- time: number;
12
- url: string;
13
- art: string;
14
- has_art: boolean;
15
- flag: boolean;
16
- rating: number | null;
17
- averagerating: number | null;
18
- playcount: number;
19
- };
20
-
21
- export type VideosResponse = {
22
- total_count: number;
23
- md5: string;
24
- video: VideoResponse[];
25
- };
26
-
27
- export type DeletedVideoResponse = {
28
- id: UID;
29
- addition_time: number;
30
- delete_time: number;
31
- title: string;
32
- file: string;
33
- catalog: UID;
34
- total_count: number;
35
- total_skip: number;
36
- };
37
-
38
- export type DeletedVideosResponse = {
39
- total_count: number;
40
- md5: string;
41
- deleted_video: DeletedVideoResponse[];
42
- };