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,116 +1,114 @@
1
- import qs from 'querystringify';
2
- import { Base, BinaryBoolean, Success } from '../base';
3
- import { Preference } from "./types";
4
-
5
- export class Preferences extends Base {
6
- /**
7
- * Get your server preferences
8
- * ACCESS REQUIRED: 100 (Admin)
9
- * @remarks MINIMUM_API_VERSION=5.0.0
10
- * @see {@link https://ampache.org/api/api-json-methods#system_preferences}
11
- */
12
- async systemPreferences () {
13
- let query = 'system_preferences';
14
- let data = await this.request<{preference: Preference[]}>(query);
15
- return (data.preference) ? data.preference : data;
16
- }
17
-
18
- /**
19
- * Get your system preference by name
20
- * ACCESS REQUIRED: 100 (Admin)
21
- * @remarks MINIMUM_API_VERSION=5.0.0
22
- * @param params.systemPreference Preference name e.g ('notify_email', 'ajax_load')
23
- * @see {@link https://ampache.org/api/api-json-methods#system_preference}
24
- */
25
- async systemPreference (params: {
26
- filter: string,
27
- }) {
28
- let query = 'system_preference';
29
- query += qs.stringify(params, '&');
30
- return await this.request<{ preference: Preference }>(query);
31
- }
32
-
33
- /**
34
- * Get your user preferences
35
- * @remarks MINIMUM_API_VERSION=5.0.0
36
- * @see {@link https://ampache.org/api/api-json-methods#user_preferences}
37
- */
38
- async userPreferences () {
39
- let query = 'user_preferences';
40
- let data = await this.request<{preference: Preference[]}>(query);
41
- return (data.preference) ? data.preference : data;
42
- }
43
-
44
- /**
45
- * Get your user preference by name
46
- * @remarks MINIMUM_API_VERSION=5.0.0
47
- * @param params.filter Preference name e.g ('notify_email', 'ajax_load')
48
- * @see {@link https://ampache.org/api/api-json-methods#user_preference}
49
- */
50
- async userPreference (params: {
51
- filter: string,
52
- }) {
53
- let query = 'user_preference';
54
- query += qs.stringify(params, '&');
55
- return await this.request<{ preference: Preference }>(query);
56
- }
57
-
58
- /**
59
- * Add a new preference to your server
60
- * ACCESS REQUIRED: 100 (Admin)
61
- * @param params.filter Preference name e.g ('notify_email', 'ajax_load')
62
- * @param params.type boolean, integer, string, special
63
- * @param params.default string or integer default value
64
- * @param params.category Category type
65
- * @param [params.description]
66
- * @param [params.subcategory]
67
- * @param [params.level] access level required to change the value (default 100)
68
- * @see {@link https://ampache.org/api/api-json-methods#preference_create}
69
- */
70
- preferenceCreate(params: {
71
- filter: string,
72
- type: 'boolean' | 'integer' | 'string' | 'special',
73
- default: string | number,
74
- category: 'interface' | 'internal' | 'options' | 'playlist' | 'plugins' | 'streaming',
75
- description?: string,
76
- subcategory?: string,
77
- level?: number,
78
- }) {
79
- let query = 'preference_create';
80
- query += qs.stringify(params, '&');
81
- return this.request<Success>(query);
82
- }
83
-
84
- /**
85
- * Edit a preference value and apply to all users if allowed
86
- * ACCESS REQUIRED: 100 (Admin)
87
- * @remarks MINIMUM_API_VERSION=5.0.0
88
- * @param params.filter Preference name e.g ('notify_email', 'ajax_load')
89
- * @param params.value (string/integer) Preference value
90
- * @param [params.all] 0, 1 apply to all users
91
- * @see {@link https://ampache.org/api/api-json-methods#preference_edit}
92
- */
93
- preferenceEdit(params: {
94
- filter: string,
95
- value: string | number,
96
- all?: BinaryBoolean,
97
- }) {
98
- let query = 'preference_edit';
99
- query += qs.stringify(params, '&');
100
- return this.request<Success>(query);
101
- }
102
-
103
- /**
104
- * Delete a non-system preference by name
105
- * ACCESS REQUIRED: 100 (Admin)
106
- * @param params.filter Preference name e.g ('notify_email', 'ajax_load')
107
- * @see {@link https://ampache.org/api/api-json-methods#preference_delete}
108
- */
109
- preferenceDelete(params: {
110
- filter: string,
111
- }) {
112
- let query = 'preference_delete';
113
- query += qs.stringify(params, '&');
114
- return this.request<Success>(query);
115
- }
116
- }
1
+ import qs from "querystringify";
2
+ import { Base, BinaryBoolean, Success } from "../base";
3
+ import { PreferenceResponse, PreferencesResponse } from "./types";
4
+
5
+ export class Preferences extends Base {
6
+ /**
7
+ * Get your server preferences
8
+ * ACCESS REQUIRED: 100 (Admin)
9
+ * @remarks MINIMUM_API_VERSION=5.0.0
10
+ * @see {@link https://ampache.org/api/api-json-methods#system_preferences}
11
+ */
12
+ systemPreferences() {
13
+ let query = "system_preferences";
14
+ return this.request<PreferencesResponse>(query);
15
+ }
16
+
17
+ /**
18
+ * Get your system preference by name
19
+ * ACCESS REQUIRED: 100 (Admin)
20
+ * @remarks MINIMUM_API_VERSION=5.0.0
21
+ * @param params.systemPreference Preference name e.g ('notify_email', 'ajax_load')
22
+ * @see {@link https://ampache.org/api/api-json-methods#system_preference}
23
+ */
24
+ systemPreference(params: { filter: string }) {
25
+ let query = "system_preference";
26
+ query += qs.stringify(params, "&");
27
+ return this.request<PreferenceResponse>(query);
28
+ }
29
+
30
+ /**
31
+ * Get your user preferences
32
+ * @remarks MINIMUM_API_VERSION=5.0.0
33
+ * @see {@link https://ampache.org/api/api-json-methods#user_preferences}
34
+ */
35
+ userPreferences() {
36
+ let query = "user_preferences";
37
+ return this.request<PreferencesResponse>(query);
38
+ }
39
+
40
+ /**
41
+ * Get your user preference by name
42
+ * @remarks MINIMUM_API_VERSION=5.0.0
43
+ * @param params.filter Preference name e.g ('notify_email', 'ajax_load')
44
+ * @see {@link https://ampache.org/api/api-json-methods#user_preference}
45
+ */
46
+ userPreference(params: { filter: string }) {
47
+ let query = "user_preference";
48
+ query += qs.stringify(params, "&");
49
+ return this.request<PreferenceResponse>(query);
50
+ }
51
+
52
+ /**
53
+ * Add a new preference to your server
54
+ * ACCESS REQUIRED: 100 (Admin)
55
+ * @param params.filter Preference name e.g ('notify_email', 'ajax_load')
56
+ * @param params.type boolean, integer, string, special
57
+ * @param params.default string or integer default value
58
+ * @param params.category Category type
59
+ * @param [params.description]
60
+ * @param [params.subcategory]
61
+ * @param [params.level] access level required to change the value (default 100)
62
+ * @see {@link https://ampache.org/api/api-json-methods#preference_create}
63
+ */
64
+ preferenceCreate(params: {
65
+ filter: string;
66
+ type: "boolean" | "integer" | "string" | "special";
67
+ default: string | number;
68
+ category:
69
+ | "interface"
70
+ | "internal"
71
+ | "options"
72
+ | "playlist"
73
+ | "plugins"
74
+ | "streaming";
75
+ description?: string;
76
+ subcategory?: string;
77
+ level?: number;
78
+ }) {
79
+ let query = "preference_create";
80
+ query += qs.stringify(params, "&");
81
+ return this.request<Success>(query);
82
+ }
83
+
84
+ /**
85
+ * Edit a preference value and apply to all users if allowed
86
+ * ACCESS REQUIRED: 100 (Admin)
87
+ * @remarks MINIMUM_API_VERSION=5.0.0
88
+ * @param params.filter Preference name e.g ('notify_email', 'ajax_load')
89
+ * @param params.value (string/integer) Preference value
90
+ * @param [params.all] 0, 1 apply to all users
91
+ * @see {@link https://ampache.org/api/api-json-methods#preference_edit}
92
+ */
93
+ preferenceEdit(params: {
94
+ filter: string;
95
+ value: string | number;
96
+ all?: BinaryBoolean;
97
+ }) {
98
+ let query = "preference_edit";
99
+ query += qs.stringify(params, "&");
100
+ return this.request<Success>(query);
101
+ }
102
+
103
+ /**
104
+ * Delete a non-system preference by name
105
+ * ACCESS REQUIRED: 100 (Admin)
106
+ * @param params.filter Preference name e.g ('notify_email', 'ajax_load')
107
+ * @see {@link https://ampache.org/api/api-json-methods#preference_delete}
108
+ */
109
+ preferenceDelete(params: { filter: string }) {
110
+ let query = "preference_delete";
111
+ query += qs.stringify(params, "&");
112
+ return this.request<Success>(query);
113
+ }
114
+ }
@@ -1,12 +1,18 @@
1
- import { UID } from "../base";
2
-
3
- export type Preference = {
4
- id: UID,
5
- name: string,
6
- level: string,
7
- description: string,
8
- value: string,
9
- type: string,
10
- category: string,
11
- subcategory: string | null
12
- }
1
+ import { UID } from "../base";
2
+
3
+ export type PreferenceResponse = {
4
+ id: UID;
5
+ name: string;
6
+ level: string;
7
+ description: string;
8
+ value: string;
9
+ type: string;
10
+ category: string;
11
+ subcategory: string | null;
12
+ };
13
+
14
+ export type PreferencesResponse = {
15
+ total_count: number;
16
+ md5: string;
17
+ preference: PreferenceResponse[];
18
+ };
@@ -1,96 +1,100 @@
1
- import qs from 'querystringify';
2
- import { Share } from './types';
3
- import { Base, BinaryBoolean, ExtendedPagination, 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
- * @param [params.cond]
14
- * @param [params.sort]
15
- * @see {@link https://ampache.org/api/api-json-methods#shares}
16
- */
17
- async shares (params?: {
18
- filter?: string,
19
- exact?: BinaryBoolean,
20
- } & ExtendedPagination) {
21
- let query = 'shares';
22
- query += qs.stringify(params, '&');
23
- let data = await this.request<{share: Share[]}>(query);
24
- return (data.share) ? data.share : data;
25
- }
26
-
27
- /**
28
- * Return a share from UID
29
- * @remarks MINIMUM_API_VERSION=420000
30
- * @param params.filter UID to find
31
- * @see {@link https://ampache.org/api/api-json-methods#share}
32
- */
33
- share (params: {
34
- filter: UID,
35
- }) {
36
- let query = 'share';
37
- query += qs.stringify(params, '&');
38
- return this.request<Share>(query);
39
- }
40
-
41
- /**
42
- * Create a public url that can be used by anyone to stream media.
43
- * @remarks MINIMUM_API_VERSION=420000
44
- * @param params.filter UID of object you are sharing
45
- * @param params.type ('song', 'album', 'artist')
46
- * @param [params.description] description (will be filled for you if empty)
47
- * @param [params.expires] days to keep active
48
- * @see {@link https://ampache.org/api/api-json-methods#share_create}
49
- */
50
- shareCreate (params: {
51
- filter: UID,
52
- type: 'song' | 'album' | 'artist' | 'playlist' | 'podcast' | 'podcast_episode' | 'video',
53
- description?: string,
54
- expires?: number,
55
- }) {
56
- let query = 'share_create';
57
- query += qs.stringify(params, '&');
58
- return this.request<Share>(query);
59
- }
60
-
61
- /**
62
- * Update the description and/or expiration date for an existing share
63
- * @remarks MINIMUM_API_VERSION=420000
64
- * @param params.filter UID to find
65
- * @param [params.stream] 0, 1
66
- * @param [params.download] 0, 1
67
- * @param [params.expires] days to keep active
68
- * @param [params.description] description
69
- * @see {@link https://ampache.org/api/api-json-methods#share_edit}
70
- */
71
- shareEdit (params: {
72
- filter: UID,
73
- stream?: BinaryBoolean,
74
- download?: BinaryBoolean,
75
- expires?: number,
76
- description?: string,
77
- }) {
78
- let query = 'share_edit';
79
- query += qs.stringify(params, '&');
80
- return this.request<Success>(query);
81
- }
82
-
83
- /**
84
- * Delete an existing share.
85
- * @remarks MINIMUM_API_VERSION=420000
86
- * @param params.filter UID of share to delete
87
- * @see {@link https://ampache.org/api/api-json-methods#share_delete}
88
- */
89
- shareDelete (params: {
90
- filter: UID,
91
- }) {
92
- let query = 'share_delete';
93
- query += qs.stringify(params, '&');
94
- return this.request<Success>(query);
95
- }
96
- }
1
+ import qs from "querystringify";
2
+ import { ShareResponse, SharesResponse } from "./types";
3
+ import { Base, BinaryBoolean, ExtendedPagination, 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
+ * @param [params.cond]
14
+ * @param [params.sort]
15
+ * @see {@link https://ampache.org/api/api-json-methods#shares}
16
+ */
17
+ shares(
18
+ params?: {
19
+ filter?: string;
20
+ exact?: BinaryBoolean;
21
+ } & ExtendedPagination,
22
+ ) {
23
+ let query = "shares";
24
+ query += qs.stringify(params, "&");
25
+ return this.request<SharesResponse>(query);
26
+ }
27
+
28
+ /**
29
+ * Return a share from UID
30
+ * @remarks MINIMUM_API_VERSION=420000
31
+ * @param params.filter UID to find
32
+ * @see {@link https://ampache.org/api/api-json-methods#share}
33
+ */
34
+ share(params: { filter: UID }) {
35
+ let query = "share";
36
+ query += qs.stringify(params, "&");
37
+ return this.request<ShareResponse>(query);
38
+ }
39
+
40
+ /**
41
+ * Create a public url that can be used by anyone to stream media.
42
+ * @remarks MINIMUM_API_VERSION=420000
43
+ * @param params.filter UID of object you are sharing
44
+ * @param params.type ('song', 'album', 'artist', 'playlist', 'podcast', 'podcast_episode', 'video')
45
+ * @param [params.description] description (will be filled for you if empty)
46
+ * @param [params.expires] days to keep active
47
+ * @see {@link https://ampache.org/api/api-json-methods#share_create}
48
+ */
49
+ shareCreate(params: {
50
+ filter: UID;
51
+ type:
52
+ | "song"
53
+ | "album"
54
+ | "artist"
55
+ | "playlist"
56
+ | "podcast"
57
+ | "podcast_episode"
58
+ | "video";
59
+ description?: string;
60
+ expires?: number;
61
+ }) {
62
+ let query = "share_create";
63
+ query += qs.stringify(params, "&");
64
+ return this.request<ShareResponse>(query);
65
+ }
66
+
67
+ /**
68
+ * Update the description and/or expiration date for an existing share
69
+ * @remarks MINIMUM_API_VERSION=420000
70
+ * @param params.filter UID to find
71
+ * @param [params.stream] 0, 1
72
+ * @param [params.download] 0, 1
73
+ * @param [params.expires] days to keep active
74
+ * @param [params.description] description
75
+ * @see {@link https://ampache.org/api/api-json-methods#share_edit}
76
+ */
77
+ shareEdit(params: {
78
+ filter: UID;
79
+ stream?: BinaryBoolean;
80
+ download?: BinaryBoolean;
81
+ expires?: number;
82
+ description?: string;
83
+ }) {
84
+ let query = "share_edit";
85
+ query += qs.stringify(params, "&");
86
+ return this.request<Success>(query);
87
+ }
88
+
89
+ /**
90
+ * Delete an existing share.
91
+ * @remarks MINIMUM_API_VERSION=420000
92
+ * @param params.filter UID of share to delete
93
+ * @see {@link https://ampache.org/api/api-json-methods#share_delete}
94
+ */
95
+ shareDelete(params: { filter: UID }) {
96
+ let query = "share_delete";
97
+ query += qs.stringify(params, "&");
98
+ return this.request<Success>(query);
99
+ }
100
+ }
@@ -1,19 +1,25 @@
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
- }
1
+ import { UID } from "../base";
2
+
3
+ export type ShareResponse = {
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
+ };
20
+
21
+ export type SharesResponse = {
22
+ total_count: number;
23
+ md5: string;
24
+ share: ShareResponse[];
25
+ };
@@ -1,22 +1,18 @@
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
- }
1
+ import qs from "querystringify";
2
+ import { ShoutResponse } 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
+ last_shouts(params?: { username?: string; limit?: number }) {
14
+ let query = "last_shouts";
15
+ query += qs.stringify(params, "&");
16
+ return this.request<{ shout: ShoutResponse[] }>(query);
17
+ }
18
+ }
@@ -1,9 +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
- }
1
+ import { UID } from "../base";
2
+ import { UserSummary } from "../users/types";
3
+
4
+ export type ShoutResponse = {
5
+ id: UID;
6
+ date: number;
7
+ text: string;
8
+ user: UserSummary;
9
+ };