javascript-ampache 1.0.9 → 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 (46) hide show
  1. package/README.md +50 -47
  2. package/dist/base.d.ts +5 -0
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.m.js.map +1 -1
  5. package/dist/index.modern.mjs.map +1 -1
  6. package/dist/index.umd.js.map +1 -1
  7. package/package.json +38 -38
  8. package/src/albums/index.ts +86 -86
  9. package/src/albums/types.ts +38 -32
  10. package/src/artists/index.ts +88 -88
  11. package/src/artists/types.ts +38 -32
  12. package/src/auth/index.ts +103 -103
  13. package/src/auth/types.ts +25 -25
  14. package/src/base.ts +134 -119
  15. package/src/bookmarks/index.ts +115 -122
  16. package/src/bookmarks/types.ts +15 -9
  17. package/src/catalogs/index.ts +130 -119
  18. package/src/catalogs/types.ts +27 -15
  19. package/src/genres/index.ts +39 -40
  20. package/src/genres/types.ts +23 -17
  21. package/src/index.ts +63 -26
  22. package/src/labels/index.ts +43 -44
  23. package/src/labels/types.ts +20 -14
  24. package/src/licenses/index.ts +43 -44
  25. package/src/licenses/types.ts +14 -8
  26. package/src/live-streams/index.ts +104 -107
  27. package/src/live-streams/types.ts +16 -10
  28. package/src/playlists/index.ts +264 -269
  29. package/src/playlists/types.ts +20 -14
  30. package/src/podcasts/index.ts +174 -177
  31. package/src/podcasts/types.ts +85 -67
  32. package/src/preferences/index.ts +114 -116
  33. package/src/preferences/types.ts +18 -12
  34. package/src/shares/index.ts +100 -96
  35. package/src/shares/types.ts +25 -19
  36. package/src/shouts/index.ts +18 -22
  37. package/src/shouts/types.ts +9 -9
  38. package/src/songs/index.ts +208 -203
  39. package/src/songs/types.ts +77 -65
  40. package/src/system/index.ts +689 -572
  41. package/src/system/types.ts +33 -19
  42. package/src/users/index.ts +227 -245
  43. package/src/users/types.ts +38 -32
  44. package/src/utils.ts +25 -25
  45. package/src/videos/index.ts +49 -53
  46. package/src/videos/types.ts +42 -30
@@ -1,122 +1,115 @@
1
- import qs from 'querystringify';
2
- import { Bookmark } from './types';
3
- import { Base, BinaryBoolean, Success, UID } from '../base';
4
-
5
- export class Bookmarks extends Base {
6
- /**
7
- * Get a single bookmark by bookmark_id
8
- * @remarks MINIMUM_API_VERSION=6.1.0
9
- * @param params.filter UID to find
10
- * @param [params.include] 0,1, if true include the object in the bookmark
11
- * @see {@link https://ampache.org/api/api-json-methods#bookmark}
12
- */
13
- async bookmark (params: {
14
- filter: UID,
15
- include?: BinaryBoolean,
16
- }) {
17
- let query = 'bookmark';
18
- query += qs.stringify(params, '&');
19
- return this.request<Bookmark>(query);
20
- }
21
-
22
- /**
23
- * Get information about bookmarked media this user is allowed to manage
24
- * @remarks MINIMUM_API_VERSION=5.0.0
25
- * @param [params.client] filter by the agent/client name
26
- * @param [params.include] 0,1, if true include the object in the bookmark
27
- * @see {@link https://ampache.org/api/api-json-methods#bookmarks}
28
- */
29
- async bookmarks (params: {
30
- client?: string,
31
- include?: BinaryBoolean,
32
- }) {
33
- let query = 'bookmarks';
34
- query += qs.stringify(params, '&');
35
- let data = await this.request<{bookmark: Bookmark[]}>(query);
36
- return (data.bookmark) ? data.bookmark : data;
37
- }
38
-
39
- /**
40
- * Get the bookmark from its object_id and object_type.
41
- * @remarks MINIMUM_API_VERSION=5.0.0
42
- * @param params.filter UID to find
43
- * @param params.type Object type
44
- * @param [params.include] 0,1, if true include the object in the bookmark
45
- * @see {@link https://ampache.org/api/api-json-methods#get_bookmark}
46
- */
47
- getBookmark (params: {
48
- filter: UID,
49
- type: 'song' | 'video' | 'podcast_episode',
50
- include?: BinaryBoolean,
51
- }) {
52
- let query = 'get_bookmark';
53
- query += qs.stringify(params, '&');
54
- return this.request<Bookmark>(query);
55
- }
56
-
57
- /**
58
- * Create a placeholder for the current media that you can return to later.
59
- * @remarks MINIMUM_API_VERSION=5.0.0
60
- * @param params.filter UID to find
61
- * @param params.type Object type
62
- * @param params.position current track time in seconds
63
- * @param [params.client] Agent string. (Default: 'AmpacheAPI')
64
- * @param [params.date] update time (Default: UNIXTIME())
65
- * @param [params.include] 0,1, if true include the object in the bookmark
66
- * @see {@link https://ampache.org/api/api-json-methods#bookmark_create}
67
- */
68
- bookmarkCreate (params: {
69
- filter: UID,
70
- type: 'song' | 'video' | 'podcast_episode',
71
- position: number,
72
- client?: string,
73
- date?: number,
74
- include?: BinaryBoolean,
75
- }) {
76
- let query = 'bookmark_create';
77
- query += qs.stringify(params, '&');
78
- return this.request<Bookmark>(query);
79
- }
80
-
81
- /**
82
- * Edit a placeholder for the current media that you can return to later.
83
- * @remarks MINIMUM_API_VERSION=5.0.0
84
- * @param params.filter UID to find
85
- * @param params.type Object type
86
- * @param params.position current track time in seconds
87
- * @param [params.client] Agent string. (Default: 'AmpacheAPI')
88
- * @param [params.date] update time (Default: UNIXTIME())
89
- * @param [params.include] 0,1, if true include the object in the bookmark
90
- * @see {@link https://ampache.org/api/api-json-methods#bookmark_edit}
91
- */
92
- bookmarkEdit (params: {
93
- filter: UID,
94
- type: 'song' | 'video' | 'podcast_episode',
95
- position: number,
96
- client?: string,
97
- date?: number,
98
- include?: BinaryBoolean,
99
- }) {
100
- let query = 'bookmark_edit';
101
- query += qs.stringify(params, '&');
102
- return this.request<Bookmark>(query);
103
- }
104
-
105
- /**
106
- * Delete an existing bookmark. (if it exists)
107
- * @remarks MINIMUM_API_VERSION=5.0.0
108
- * @param params.filter UID to find
109
- * @param params.type Object type
110
- * @param [params.client] Agent string. (Default: 'AmpacheAPI')
111
- @see {@link https://ampache.org/api/api-json-methods#bookmark_delete}
112
- */
113
- bookmarkDelete (params: {
114
- filter: UID,
115
- type: 'song' | 'video' | 'podcast_episode',
116
- client?: string,
117
- }) {
118
- let query = 'bookmark_delete';
119
- query += qs.stringify(params, '&');
120
- return this.request<Success>(query);
121
- }
122
- }
1
+ import qs from "querystringify";
2
+ import { BookmarkResponse, BookmarksResponse } from "./types";
3
+ import { Base, BinaryBoolean, Success, UID } from "../base";
4
+
5
+ export class Bookmarks extends Base {
6
+ /**
7
+ * Get a single bookmark by bookmark_id
8
+ * @remarks MINIMUM_API_VERSION=6.1.0
9
+ * @param params.filter UID to find
10
+ * @param [params.include] 0,1, if true include the object in the bookmark
11
+ * @see {@link https://ampache.org/api/api-json-methods#bookmark}
12
+ */
13
+ bookmark(params: { filter: UID; include?: BinaryBoolean }) {
14
+ let query = "bookmark";
15
+ query += qs.stringify(params, "&");
16
+ return this.request<BookmarkResponse>(query);
17
+ }
18
+
19
+ /**
20
+ * Get information about bookmarked media this user is allowed to manage
21
+ * @remarks MINIMUM_API_VERSION=5.0.0
22
+ * @param [params.client] filter by the agent/client name
23
+ * @param [params.include] 0,1, if true include the object in the bookmark
24
+ * @see {@link https://ampache.org/api/api-json-methods#bookmarks}
25
+ */
26
+ bookmarks(params: { client?: string; include?: BinaryBoolean }) {
27
+ let query = "bookmarks";
28
+ query += qs.stringify(params, "&");
29
+ return this.request<BookmarksResponse>(query);
30
+ }
31
+
32
+ /**
33
+ * Get the bookmark from its object_id and object_type.
34
+ * @remarks MINIMUM_API_VERSION=5.0.0
35
+ * @param params.filter UID to find
36
+ * @param params.type Object type
37
+ * @param [params.include] 0,1, if true include the object in the bookmark
38
+ * @see {@link https://ampache.org/api/api-json-methods#get_bookmark}
39
+ */
40
+ getBookmark(params: {
41
+ filter: UID;
42
+ type: "song" | "video" | "podcast_episode";
43
+ include?: BinaryBoolean;
44
+ }) {
45
+ let query = "get_bookmark";
46
+ query += qs.stringify(params, "&");
47
+ return this.request<BookmarkResponse>(query);
48
+ }
49
+
50
+ /**
51
+ * Create a placeholder for the current media that you can return to later.
52
+ * @remarks MINIMUM_API_VERSION=5.0.0
53
+ * @param params.filter UID to find
54
+ * @param params.type Object type
55
+ * @param params.position current track time in seconds
56
+ * @param [params.client] Agent string. (Default: 'AmpacheAPI')
57
+ * @param [params.date] update time (Default: UNIXTIME())
58
+ * @param [params.include] 0,1, if true include the object in the bookmark
59
+ * @see {@link https://ampache.org/api/api-json-methods#bookmark_create}
60
+ */
61
+ bookmarkCreate(params: {
62
+ filter: UID;
63
+ type: "song" | "video" | "podcast_episode";
64
+ position: number;
65
+ client?: string;
66
+ date?: number;
67
+ include?: BinaryBoolean;
68
+ }) {
69
+ let query = "bookmark_create";
70
+ query += qs.stringify(params, "&");
71
+ return this.request<BookmarkResponse>(query);
72
+ }
73
+
74
+ /**
75
+ * Edit a placeholder for the current media that you can return to later.
76
+ * @remarks MINIMUM_API_VERSION=5.0.0
77
+ * @param params.filter UID to find
78
+ * @param params.type Object type
79
+ * @param params.position current track time in seconds
80
+ * @param [params.client] Agent string. (Default: 'AmpacheAPI')
81
+ * @param [params.date] update time (Default: UNIXTIME())
82
+ * @param [params.include] 0,1, if true include the object in the bookmark
83
+ * @see {@link https://ampache.org/api/api-json-methods#bookmark_edit}
84
+ */
85
+ bookmarkEdit(params: {
86
+ filter: UID;
87
+ type: "song" | "video" | "podcast_episode";
88
+ position: number;
89
+ client?: string;
90
+ date?: number;
91
+ include?: BinaryBoolean;
92
+ }) {
93
+ let query = "bookmark_edit";
94
+ query += qs.stringify(params, "&");
95
+ return this.request<BookmarkResponse>(query);
96
+ }
97
+
98
+ /**
99
+ * Delete an existing bookmark. (if it exists)
100
+ * @remarks MINIMUM_API_VERSION=5.0.0
101
+ * @param params.filter UID to find
102
+ * @param params.type Object type
103
+ * @param [params.client] Agent string. (Default: 'AmpacheAPI')
104
+ @see {@link https://ampache.org/api/api-json-methods#bookmark_delete}
105
+ */
106
+ bookmarkDelete(params: {
107
+ filter: UID;
108
+ type: "song" | "video" | "podcast_episode";
109
+ client?: string;
110
+ }) {
111
+ let query = "bookmark_delete";
112
+ query += qs.stringify(params, "&");
113
+ return this.request<Success>(query);
114
+ }
115
+ }
@@ -1,9 +1,15 @@
1
- import { UID } from "../base";
2
-
3
- export type Bookmark = {
4
- id: UID,
5
- type: 'song' | 'video' | 'podcast_episode',
6
- position: number,
7
- client?: string,
8
- date?: number,
9
- }
1
+ import { UID } from "../base";
2
+
3
+ export type BookmarkResponse = {
4
+ id: UID;
5
+ type: "song" | "video" | "podcast_episode";
6
+ position: number;
7
+ client?: string;
8
+ date?: number;
9
+ };
10
+
11
+ export type BookmarksResponse = {
12
+ total_count: number;
13
+ md5: string;
14
+ bookmark: BookmarkResponse[];
15
+ };
@@ -1,119 +1,130 @@
1
- import qs from 'querystringify';
2
- import { Catalog } from './types';
3
- import {Base, ExtendedPagination, Success, UID} from '../base';
4
-
5
- export class Catalogs extends Base {
6
- /**
7
- * This searches the catalogs and returns... catalogs
8
- * @remarks MINIMUM_API_VERSION=420000
9
- * @param [params.filter] Catalog type
10
- * @param [params.offset]
11
- * @param [params.limit]
12
- * @param [params.cond]
13
- * @param [params.sort]
14
- * @see {@link https://ampache.org/api/api-json-methods#catalogs}
15
- */
16
- async catalogs (params?: {
17
- filter?: 'music' | 'clip' | 'tvshow' | 'movie' | 'personal_video' | 'podcast',
18
- } & ExtendedPagination) {
19
- let query = 'catalogs';
20
- query += qs.stringify(params, '&');
21
- let data = await this.request<{catalog: Catalog[]}>(query);
22
- return (data.catalog) ? data.catalog : data;
23
- }
24
-
25
- /**
26
- * Return catalog by UID
27
- * @remarks MINIMUM_API_VERSION=420000
28
- * @param params.filter UID to find
29
- * @see {@link https://ampache.org/api/api-json-methods#catalog}
30
- */
31
- catalog (params: {
32
- filter: UID,
33
- }) {
34
- let query = 'catalog';
35
- query += qs.stringify(params, '&');
36
- return this.request<Catalog>(query);
37
- }
38
-
39
- /**
40
- * Kick off a catalog update or clean for the selected catalog
41
- * ACCESS REQUIRED: 75 (Catalog Manager)
42
- * @remarks MINIMUM_API_VERSION=400001
43
- * @param params.task add_to_catalog, clean_catalog
44
- * @param params.catalog UID of catalog
45
- * @see {@link https://ampache.org/api/api-json-methods#catalog_action}
46
- */
47
- catalogAction(params: {
48
- task: 'add_to_catalog' | 'clean_catalog',
49
- catalog: UID,
50
- }) {
51
- let query = 'catalog_action';
52
- query += qs.stringify(params, '&');
53
- return this.request<Success>(query);
54
- }
55
-
56
- /**
57
- * Perform actions on local catalog files. Single file versions of catalog add, clean, verify and remove (delete).
58
- * Make sure you remember to urlencode those file names!
59
- * ACCESS REQUIRED: 50 (Content Manager)
60
- * @remarks MINIMUM_API_VERSION=420000
61
- * @param params.file FULL path to local file
62
- * @param params.task add, clean, verify, remove, (can include comma-separated values)
63
- * @param params.catalog UID of catalog
64
- * @see {@link https://ampache.org/api/api-json-methods#catalog_file}
65
- */
66
- catalogFile(params: {
67
- file: string,
68
- task: string,
69
- catalog: UID,
70
- }) {
71
- let query = 'catalog_file';
72
- query += qs.stringify(params, '&');
73
- return this.request<Success>(query);
74
- }
75
-
76
- /**
77
- * Create a new catalog.
78
- * ACCESS REQUIRED: 75 (Catalog Manager)
79
- * @remarks MINIMUM_API_VERSION=6.0.0
80
- * @param params.name Name for the catalog
81
- * @param params.path URL or folder path for your catalog
82
- * @param [params.type] Default: 'local'
83
- * @param [params.media_type] Default: 'music'
84
- * @param [params.file_pattern] Pattern used identify tags from the file name. Default: '%T - %t'
85
- * @param [params.folder_pattern] Pattern used identify tags from the folder name. Default: '%a/%A'
86
- * @param [params.username] login to remote catalog
87
- * @param [params.password] password to remote catalog
88
- * @see {@link https://ampache.org/api/api-json-methods#catalog_add}
89
- */
90
- catalogAdd(params: {
91
- name: string,
92
- path: string,
93
- type?: 'local' | 'beets' | 'remote' | 'subsonic' | 'seafile' | 'beetsremote',
94
- media_type?: 'music' | 'podcast' | 'clip' | 'tvshow' | 'movie' | 'personal_video',
95
- file_pattern?: string,
96
- folder_pattern?: string,
97
- username?: string,
98
- password?: string,
99
- }) {
100
- let query = 'catalog_add';
101
- query += qs.stringify(params, '&');
102
- return this.request<Catalog>(query);
103
- }
104
-
105
- /**
106
- * Delete an existing catalog. (if it exists)
107
- * ACCESS REQUIRED: 75 (Catalog Manager)
108
- * @remarks MINIMUM_API_VERSION=6.0.0
109
- * @param params.filter ID of the catalog
110
- * @see {@link https://ampache.org/api/api-json-methods#catalog_delete}
111
- */
112
- catalogDelete(params: {
113
- filter: UID,
114
- }) {
115
- let query = 'catalog_delete';
116
- query += qs.stringify(params, '&');
117
- return this.request<Success>(query);
118
- }
119
- }
1
+ import qs from "querystringify";
2
+ import { CatalogResponse, CatalogsResponse } from "./types";
3
+ import { Base, ExtendedPagination, Success, UID } from "../base";
4
+
5
+ export class Catalogs extends Base {
6
+ /**
7
+ * This searches the catalogs and returns... catalogs
8
+ * @remarks MINIMUM_API_VERSION=420000
9
+ * @param [params.filter] Catalog type
10
+ * @param [params.offset]
11
+ * @param [params.limit]
12
+ * @param [params.cond]
13
+ * @param [params.sort]
14
+ * @see {@link https://ampache.org/api/api-json-methods#catalogs}
15
+ */
16
+ catalogs(
17
+ params?: {
18
+ filter?:
19
+ | "music"
20
+ | "clip"
21
+ | "tvshow"
22
+ | "movie"
23
+ | "personal_video"
24
+ | "podcast";
25
+ } & ExtendedPagination,
26
+ ) {
27
+ let query = "catalogs";
28
+ query += qs.stringify(params, "&");
29
+ return this.request<CatalogsResponse>(query);
30
+ }
31
+
32
+ /**
33
+ * Return catalog by UID
34
+ * @remarks MINIMUM_API_VERSION=420000
35
+ * @param params.filter UID to find
36
+ * @see {@link https://ampache.org/api/api-json-methods#catalog}
37
+ */
38
+ catalog(params: { filter: UID }) {
39
+ let query = "catalog";
40
+ query += qs.stringify(params, "&");
41
+ return this.request<CatalogResponse>(query);
42
+ }
43
+
44
+ /**
45
+ * Kick off a catalog update or clean for the selected catalog
46
+ * ACCESS REQUIRED: 75 (Catalog Manager)
47
+ * @remarks MINIMUM_API_VERSION=400001
48
+ * @param params.task add_to_catalog, clean_catalog
49
+ * @param params.catalog UID of catalog
50
+ * @see {@link https://ampache.org/api/api-json-methods#catalog_action}
51
+ */
52
+ catalogAction(params: {
53
+ task: "add_to_catalog" | "clean_catalog";
54
+ catalog: UID;
55
+ }) {
56
+ let query = "catalog_action";
57
+ query += qs.stringify(params, "&");
58
+ return this.request<Success>(query);
59
+ }
60
+
61
+ /**
62
+ * Perform actions on local catalog files. Single file versions of catalog add, clean, verify and remove (delete).
63
+ * Make sure you remember to urlencode those file names!
64
+ * ACCESS REQUIRED: 50 (Content Manager)
65
+ * @remarks MINIMUM_API_VERSION=420000
66
+ * @param params.file FULL path to local file
67
+ * @param params.task add, clean, verify, remove, (can include comma-separated values)
68
+ * @param params.catalog UID of catalog
69
+ * @see {@link https://ampache.org/api/api-json-methods#catalog_file}
70
+ */
71
+ catalogFile(params: { file: string; task: string; catalog: UID }) {
72
+ let query = "catalog_file";
73
+ query += qs.stringify(params, "&");
74
+ return this.request<Success>(query);
75
+ }
76
+
77
+ /**
78
+ * Create a new catalog.
79
+ * ACCESS REQUIRED: 75 (Catalog Manager)
80
+ * @remarks MINIMUM_API_VERSION=6.0.0
81
+ * @param params.name Name for the catalog
82
+ * @param params.path URL or folder path for your catalog
83
+ * @param [params.type] Default: 'local'
84
+ * @param [params.media_type] Default: 'music'
85
+ * @param [params.file_pattern] Pattern used identify tags from the file name. Default: '%T - %t'
86
+ * @param [params.folder_pattern] Pattern used identify tags from the folder name. Default: '%a/%A'
87
+ * @param [params.username] login to remote catalog
88
+ * @param [params.password] password to remote catalog
89
+ * @see {@link https://ampache.org/api/api-json-methods#catalog_add}
90
+ */
91
+ catalogAdd(params: {
92
+ name: string;
93
+ path: string;
94
+ type?:
95
+ | "local"
96
+ | "beets"
97
+ | "remote"
98
+ | "subsonic"
99
+ | "seafile"
100
+ | "beetsremote";
101
+ media_type?:
102
+ | "music"
103
+ | "podcast"
104
+ | "clip"
105
+ | "tvshow"
106
+ | "movie"
107
+ | "personal_video";
108
+ file_pattern?: string;
109
+ folder_pattern?: string;
110
+ username?: string;
111
+ password?: string;
112
+ }) {
113
+ let query = "catalog_add";
114
+ query += qs.stringify(params, "&");
115
+ return this.request<CatalogResponse>(query);
116
+ }
117
+
118
+ /**
119
+ * Delete an existing catalog. (if it exists)
120
+ * ACCESS REQUIRED: 75 (Catalog Manager)
121
+ * @remarks MINIMUM_API_VERSION=6.0.0
122
+ * @param params.filter ID of the catalog
123
+ * @see {@link https://ampache.org/api/api-json-methods#catalog_delete}
124
+ */
125
+ catalogDelete(params: { filter: UID }) {
126
+ let query = "catalog_delete";
127
+ query += qs.stringify(params, "&");
128
+ return this.request<Success>(query);
129
+ }
130
+ }
@@ -1,15 +1,27 @@
1
- import { UID } from "../base";
2
-
3
- export type Catalog = {
4
- id: UID,
5
- name: string,
6
- type: 'local' | 'remote',
7
- gather_types: 'podcast' | 'clip' | 'tvshow' | 'movie' | 'personal_video' | 'music',
8
- enabled: boolean,
9
- last_add: number,
10
- last_clean: number,
11
- last_update: number,
12
- path: string,
13
- rename_pattern: string,
14
- sort_pattern: string,
15
- }
1
+ import { UID } from "../base";
2
+
3
+ export type CatalogResponse = {
4
+ id: UID;
5
+ name: string;
6
+ type: "local" | "remote";
7
+ gather_types:
8
+ | "podcast"
9
+ | "clip"
10
+ | "tvshow"
11
+ | "movie"
12
+ | "personal_video"
13
+ | "music";
14
+ enabled: boolean;
15
+ last_add: number;
16
+ last_clean: number;
17
+ last_update: number;
18
+ path: string;
19
+ rename_pattern: string;
20
+ sort_pattern: string;
21
+ };
22
+
23
+ export type CatalogsResponse = {
24
+ total_count: number;
25
+ md5: string;
26
+ catalog: CatalogResponse[];
27
+ };