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,82 @@
1
+ import qs from 'querystringify';
2
+ import { Artist } from './types';
3
+ import { Base, BinaryBoolean, Pagination, UID } from '../base';
4
+
5
+ export class Artists extends Base {
6
+ /**
7
+ * This takes a collection of inputs and returns artist objects
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.include] (albums | songs) include child objects in the response
14
+ * @param [params.album_artist] 0, 1 (if true filter for album artists only)
15
+ * @param [params.offset]
16
+ * @param [params.limit]
17
+ * @see {@link https://ampache.org/api/api-json-methods#artists}
18
+ */
19
+ async artists (params?: {
20
+ filter?: string,
21
+ exact?: BinaryBoolean,
22
+ add?: Date,
23
+ update?: Date,
24
+ include?: 'albums' | 'songs',
25
+ album_artist?: BinaryBoolean,
26
+ } & Pagination) {
27
+ let query = 'artists';
28
+ query += qs.stringify(params, '&');
29
+ let data = await this.request<{artist: Artist[]}>(query);
30
+ return (data.artist) ? data.artist : data;
31
+ }
32
+
33
+ /**
34
+ * This returns a single artist based on the UID of said artist
35
+ * @remarks MINIMUM_API_VERSION=380001
36
+ * @param params.filter UID to find
37
+ * @param [params.include] (albums | songs) include child objects in the response
38
+ * @see {@link https://ampache.org/api/api-json-methods#artist}
39
+ */
40
+ artist (params: {
41
+ filter: UID,
42
+ include?: 'albums' | 'songs',
43
+ }) {
44
+ let query = 'artist';
45
+ query += qs.stringify(params, '&');
46
+ return this.request<Artist>(query);
47
+ }
48
+
49
+ /**
50
+ * This returns the artists associated with the genre in question as defined by the UID
51
+ * @remarks MINIMUM_API_VERSION=380001
52
+ * @param params.filter UID to find
53
+ * @param [params.offset]
54
+ * @param [params.limit]
55
+ * @see {@link https://ampache.org/api/api-json-methods#genre_artists}
56
+ */
57
+ async genreArtists (params: {
58
+ filter: UID
59
+ } & Pagination) {
60
+ let query = 'genre_artists';
61
+ query += qs.stringify(params, '&');
62
+ let data = await this.request<{artist: Artist[]}>(query);
63
+ return (data.artist) ? data.artist : data;
64
+ }
65
+
66
+ /**
67
+ * This returns the artists associated with the label in question as defined by the UID
68
+ * @remarks MINIMUM_API_VERSION=420000
69
+ * @param params.filter UID of find
70
+ * @param [params.offset]
71
+ * @param [params.limit]
72
+ * @see {@link https://ampache.org/api/api-json-methods#label_artists}
73
+ */
74
+ async labelArtists (params: {
75
+ filter: UID
76
+ } & Pagination) {
77
+ let query = 'label_artists';
78
+ query += qs.stringify(params, '&');
79
+ let data = await this.request<{artist: Artist[]}>(query);
80
+ return (data.artist) ? data.artist : data;
81
+ }
82
+ }
@@ -0,0 +1,31 @@
1
+ import { Album } from "../albums/types";
2
+ import { Song } from "../songs/types";
3
+ import { Genre } from "../genres/types";
4
+
5
+ export type ArtistSummary = {
6
+ id: string,
7
+ name: string,
8
+ prefix: string | null,
9
+ basename: string
10
+ }
11
+
12
+ export type Artist = {
13
+ id: string,
14
+ name: string,
15
+ prefix: string | null,
16
+ basename: string,
17
+ albums: Album[],
18
+ albumcount: number,
19
+ songs: Song[],
20
+ songcount: number,
21
+ genre: Genre[],
22
+ art: string,
23
+ flag: boolean,
24
+ rating: number | null,
25
+ averagerating: number | null,
26
+ mbid: string | null,
27
+ summary: string,
28
+ time: number,
29
+ yearformed: number,
30
+ placeformed: string,
31
+ }
@@ -0,0 +1,91 @@
1
+ import JsSHA from "jssha/dist/sha256";
2
+ import qs from 'querystringify';
3
+ import fetch from "isomorphic-unfetch";
4
+ import { Base, Success } from "../base";
5
+ import { AuthResponse } from './types'
6
+
7
+ export class Auth extends Base {
8
+ /**
9
+ * Handles verifying a new handshake
10
+ * @remarks MINIMUM_API_VERSION=380001
11
+ * @param params.auth encrypted apikey OR password if using password auth
12
+ * @param [params.user] username
13
+ * @param [params.timestamp] UNIXTIME()
14
+ * @param [params.version] version of Ampache API to establish connection with
15
+ * @see {@link https://ampache.org/api/api-json-methods#handshake}
16
+ */
17
+ handshake (params: {
18
+ auth: string,
19
+ user?: string,
20
+ timestamp?: number,
21
+ version?: string
22
+ }) {
23
+ // generate a timestamp if one wasn't provided
24
+ if (!params.timestamp) {
25
+ params.timestamp = Math.floor(new Date().getTime() / 1000);
26
+ }
27
+
28
+ // override the fallback API version with specified
29
+ if (params.version) {
30
+ this.version = params.version;
31
+ }
32
+
33
+ // drop timestamp if no user provided (i.e. logging in with API key)
34
+ if (!params.user) {
35
+ delete params.timestamp;
36
+ }
37
+
38
+ let query = this.url + "/server/json.server.php?action=handshake";
39
+ query += qs.stringify(params, '&');
40
+
41
+ return fetch(query)
42
+ .then(response => response.json())
43
+ .then(data => {
44
+ if (data.auth) {
45
+ this.sessionKey = data.auth;
46
+ }
47
+ return <AuthResponse>data;
48
+ })
49
+ }
50
+
51
+ /**
52
+ * This can be called without being authenticated, it is useful for determining if what the status
53
+ * of the server is, and what version it is running/compatible with
54
+ * @remarks MINIMUM_API_VERSION=380001
55
+ * @param [params.auth] (Session ID) returns version information and extends the session if passed
56
+ * @param [params.version] API Version that the application understands
57
+ * @see {@link https://ampache.org/api/api-json-methods#ping}
58
+ */
59
+ ping (params?: { auth?: string, version?: string }) {
60
+ let query = 'ping';
61
+ query += qs.stringify(params, '&');
62
+ return this.request<AuthResponse>(query, false);
63
+ }
64
+
65
+ /**
66
+ * Destroy a session using the session auth parameter
67
+ * @remarks MINIMUM_API_VERSION=400001
68
+ * @param params.auth Session ID to destroy
69
+ * @see {@link https://ampache.org/api/api-json-methods#goodbye}
70
+ */
71
+ goodbye (params: { auth }) {
72
+ let query = 'goodbye';
73
+ query += qs.stringify(params, '&');
74
+ return this.request<Success>(query, false);
75
+ }
76
+
77
+ /**
78
+ * Encrypt your password into the accepted format.
79
+ */
80
+ encryptPassword (params: { password: string, time: number }) {
81
+ let key = getSHA256(params.password);
82
+ return getSHA256(params.time + key);
83
+
84
+ function getSHA256(text) {
85
+ let shaObj = new JsSHA("SHA-256", "TEXT", { encoding: "UTF8" });
86
+ shaObj.update(text);
87
+
88
+ return shaObj.getHash("HEX");
89
+ }
90
+ }
91
+ }
@@ -0,0 +1,22 @@
1
+ export type AuthResponse = {
2
+ auth: string,
3
+ api: string,
4
+ session_expire: string,
5
+ update: string,
6
+ add: string,
7
+ clean: string,
8
+ songs: number,
9
+ albums: number,
10
+ artists: number,
11
+ genres: number,
12
+ playlists: number,
13
+ user: number,
14
+ catalogs: number,
15
+ videos: number,
16
+ podcasts: number,
17
+ podcast_episodes: number,
18
+ shares: number,
19
+ licenses: number,
20
+ live_streams: number,
21
+ labels: number,
22
+ }
package/src/base.ts ADDED
@@ -0,0 +1,64 @@
1
+ import fetch from 'isomorphic-unfetch';
2
+
3
+ type Config = {
4
+ url: string,
5
+ sessionKey?: string,
6
+ debug?: boolean,
7
+ }
8
+
9
+ export type Success = {
10
+ success: string,
11
+ }
12
+
13
+ /**
14
+ * @param [offset] Return results starting from this index position
15
+ * @param [limit] Maximum number of results to return
16
+ */
17
+ export type Pagination = {
18
+ offset?: number,
19
+ limit?: number,
20
+ }
21
+
22
+ export type BinaryBoolean = 0 | 1;
23
+
24
+ export type UID = string | number;
25
+
26
+ export abstract class Base {
27
+ sessionKey: string;
28
+ url: string;
29
+ version: string = '6.0.0';// default to latest version
30
+ debug: boolean;
31
+
32
+ constructor(config: Config) {
33
+ this.sessionKey = config.sessionKey || null;
34
+ this.url = config.url;
35
+ this.debug = config.debug || false;
36
+ }
37
+
38
+ protected request<T> (endpoint: string, includeAuth: boolean = true): Promise<T> {
39
+ let url = this.url + "/server/json.server.php?action=" + endpoint;
40
+
41
+ // some endpoints like ping() or goodbye() can pass their own auth
42
+ if (includeAuth) {
43
+ url += "&auth=" + this.sessionKey + "&version=" + this.version;
44
+ }
45
+
46
+ if (this.debug) {
47
+ console.debug(
48
+ "javascript-ampache query URL %c" + url,
49
+ "color: black; font-style: italic; background-color: orange;padding: 2px"
50
+ );
51
+ }
52
+
53
+ return fetch(url).then(r => {
54
+ if (r.ok) {
55
+ return r.json();
56
+ }
57
+ throw new Error(r.statusText);
58
+ })
59
+ }
60
+
61
+ public setSessionKey(sessionKey: string) {
62
+ this.sessionKey = sessionKey;
63
+ }
64
+ }
@@ -0,0 +1,94 @@
1
+ import qs from 'querystringify';
2
+ import { Bookmark } from './types';
3
+ import { Base, Success, UID } from '../base';
4
+
5
+ export class Bookmarks extends Base {
6
+ /**
7
+ * Get information about bookmarked media this user is allowed to manage
8
+ * @remarks MINIMUM_API_VERSION=5.0.0
9
+ * @see {@link https://ampache.org/api/api-json-methods#bookmarks}
10
+ */
11
+ async bookmarks () {
12
+ let query = 'bookmarks';
13
+ let data = await this.request<{bookmark: Bookmark[]}>(query);
14
+ return (data.bookmark) ? data.bookmark : data;
15
+ }
16
+
17
+ /**
18
+ * Get the bookmark from it's object_id and object_type.
19
+ * @remarks MINIMUM_API_VERSION=5.0.0
20
+ * @param params.filter UID to find
21
+ * @param params.type Object type
22
+ * @see {@link https://ampache.org/api/api-json-methods#get_bookmark}
23
+ */
24
+ getBookmark (params: {
25
+ filter: UID,
26
+ type: 'song' | 'video' | 'podcast_episode',
27
+ }) {
28
+ let query = 'get_bookmark';
29
+ query += qs.stringify(params, '&');
30
+ return this.request<Bookmark>(query);
31
+ }
32
+
33
+ /**
34
+ * Create a placeholder for the current media that you can return to later.
35
+ * @remarks MINIMUM_API_VERSION=5.0.0
36
+ * @param params.filter UID to find
37
+ * @param params.type Object type
38
+ * @param params.position current track time in seconds
39
+ * @param [params.client] Agent string. (Default: 'AmpacheAPI')
40
+ * @param [params.date] update time (Default: UNIXTIME())
41
+ * @see {@link https://ampache.org/api/api-json-methods#bookmark_create}
42
+ */
43
+ bookmarkCreate (params: {
44
+ filter: UID,
45
+ type: 'song' | 'video' | 'podcast_episode',
46
+ position: number,
47
+ client?: string,
48
+ date?: number,
49
+ }) {
50
+ let query = 'bookmark_create';
51
+ query += qs.stringify(params, '&');
52
+ return this.request<Bookmark>(query);
53
+ }
54
+
55
+ /**
56
+ * Edit a placeholder for the current media that you can return to later.
57
+ * @remarks MINIMUM_API_VERSION=5.0.0
58
+ * @param params.filter UID to find
59
+ * @param params.type Object type
60
+ * @param params.position current track time in seconds
61
+ * @param [params.client] Agent string. (Default: 'AmpacheAPI')
62
+ * @param [params.date] update time (Default: UNIXTIME())
63
+ * @see {@link https://ampache.org/api/api-json-methods#bookmark_edit}
64
+ */
65
+ bookmarkEdit (params: {
66
+ filter: UID,
67
+ type: 'song' | 'video' | 'podcast_episode',
68
+ position: number,
69
+ client?: string,
70
+ date?: number,
71
+ }) {
72
+ let query = 'bookmark_edit';
73
+ query += qs.stringify(params, '&');
74
+ return this.request<Bookmark>(query);
75
+ }
76
+
77
+ /**
78
+ * Delete an existing bookmark. (if it exists)
79
+ * @remarks MINIMUM_API_VERSION=5.0.0
80
+ * @param params.filter UID to find
81
+ * @param params.type Object type
82
+ * @param [params.client] Agent string. (Default: 'AmpacheAPI')
83
+ @see {@link https://ampache.org/api/api-json-methods#bookmark_delete}
84
+ */
85
+ bookmarkDelete (params: {
86
+ filter: UID,
87
+ type: 'song' | 'video' | 'podcast_episode',
88
+ client?: string,
89
+ }) {
90
+ let query = 'bookmark_delete';
91
+ query += qs.stringify(params, '&');
92
+ return this.request<Success>(query);
93
+ }
94
+ }
@@ -0,0 +1,9 @@
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
+ }
@@ -0,0 +1,71 @@
1
+ import qs from 'querystringify';
2
+ import { Catalog } from './types';
3
+ import { Base, 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
+ * @see {@link https://ampache.org/api/api-json-methods#catalogs}
11
+ */
12
+ async catalogs (params?: {
13
+ filter?: 'music' | 'clip' | 'tvshow' | 'movie' | 'personal_video' | 'podcast',
14
+ }) {
15
+ let query = 'catalogs';
16
+ query += qs.stringify(params, '&');
17
+ let data = await this.request<{catalog: Catalog[]}>(query);
18
+ return (data.catalog) ? data.catalog : data;
19
+ }
20
+
21
+ /**
22
+ * Return catalog by UID
23
+ * @remarks MINIMUM_API_VERSION=420000
24
+ * @param params.filter UID to find
25
+ * @see {@link https://ampache.org/api/api-json-methods#catalog}
26
+ */
27
+ catalog (params: {
28
+ filter: UID,
29
+ }) {
30
+ let query = 'catalog';
31
+ query += qs.stringify(params, '&');
32
+ return this.request<Catalog>(query);
33
+ }
34
+
35
+ /**
36
+ * Kick off a catalog update or clean for the selected catalog
37
+ * ACCESS REQUIRED: 75 (Catalog Manager)
38
+ * @remarks MINIMUM_API_VERSION=400001
39
+ * @param params.task add_to_catalog, clean_catalog
40
+ * @param params.catalog UID of catalog
41
+ * @see {@link https://ampache.org/api/api-json-methods#catalog_action}
42
+ */
43
+ catalogAction(params: {
44
+ task: 'add_to_catalog' | 'clean_catalog',
45
+ catalog: UID,
46
+ }) {
47
+ let query = 'catalog_action';
48
+ query += qs.stringify(params, '&');
49
+ return this.request<Success>(query);
50
+ }
51
+
52
+ /**
53
+ * Perform actions on local catalog files. Single file versions of catalog add, clean, verify and remove (delete).
54
+ * Make sure you remember to urlencode those file names!
55
+ * ACCESS REQUIRED: 50 (Content Manager)
56
+ * @remarks MINIMUM_API_VERSION=420000
57
+ * @param params.file FULL path to local file
58
+ * @param params.task add, clean, verify, remove, (can include comma-separated values)
59
+ * @param params.catalog UID of catalog
60
+ * @see {@link https://ampache.org/api/api-json-methods#catalog_file}
61
+ */
62
+ catalogFile(params: {
63
+ file: string,
64
+ task: string,
65
+ catalog: UID,
66
+ }) {
67
+ let query = 'catalog_file';
68
+ query += qs.stringify(params, '&');
69
+ return this.request<Success>(query);
70
+ }
71
+ }
@@ -0,0 +1,15 @@
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
+ }
@@ -0,0 +1,39 @@
1
+ import qs from 'querystringify';
2
+ import { Genre } from './types';
3
+ import { Base, BinaryBoolean, Pagination, UID } from '../base';
4
+
5
+ export class Genres extends Base {
6
+ /**
7
+ * This returns the genres (Tags) based on the specified filter
8
+ * @remarks MINIMUM_API_VERSION=380001
9
+ * @param [params.filter] UID to find
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#genres}
14
+ */
15
+ async genres (params?: {
16
+ filter?: string,
17
+ exact?: BinaryBoolean,
18
+ } & Pagination) {
19
+ let query = 'genres';
20
+ query += qs.stringify(params, '&');
21
+ let data = await this.request<{genre: Genre[]}>(query);
22
+ return (data.genre) ? data.genre : data;
23
+ }
24
+
25
+ /**
26
+ * This returns a single genre based on UID
27
+ * @remarks MINIMUM_API_VERSION=380001
28
+ * @param params.filter UID to find
29
+ * @see {@link https://ampache.org/api/api-json-methods#genre}
30
+ */
31
+ async genre (params: {
32
+ filter: UID,
33
+ }) {
34
+ let query = 'genre';
35
+ query += qs.stringify(params, '&');
36
+ let data = await this.request<{genre: Genre[]}>(query);
37
+ return (data.genre) ? data.genre : data;
38
+ }
39
+ }
@@ -0,0 +1,17 @@
1
+ import { UID } from "../base";
2
+
3
+ export type GenreSummary = {
4
+ id: UID,
5
+ name: string,
6
+ }
7
+
8
+ export type Genre = {
9
+ id: UID,
10
+ name: string,
11
+ albums: number,
12
+ artists: number,
13
+ songs: number,
14
+ videos: number,
15
+ playlists: number,
16
+ live_streams: number,
17
+ }
package/src/index.ts ADDED
@@ -0,0 +1,26 @@
1
+ import { Albums } from './albums';
2
+ import { Artists } from './artists';
3
+ import { Auth } from './auth';
4
+ import { Bookmarks } from './bookmarks';
5
+ import { Catalogs } from './catalogs';
6
+ import { Genres } from './genres';
7
+ import { Labels } from './labels';
8
+ import { Licenses } from './licenses';
9
+ import { LiveStreams } from './live-streams';
10
+ import { Playlists } from './playlists';
11
+ import { Podcasts } from './podcasts';
12
+ import { Preferences } from './preferences';
13
+ import { Shares } from './shares';
14
+ import { Shouts } from './shouts';
15
+ import { Songs } from './songs';
16
+ import { System } from './system';
17
+ import { Users } from './users';
18
+ import { Videos } from './videos';
19
+ import { applyMixins } from './utils';
20
+ import { Base } from './base';
21
+
22
+ class AmpacheAPI extends Base {}
23
+ interface AmpacheAPI extends Albums, Artists, Auth, Bookmarks, Catalogs, Genres, Labels, Licenses, LiveStreams, Playlists, Podcasts, Preferences, Shares, Shouts, Songs, System, Users, Videos {}
24
+ applyMixins(AmpacheAPI, [Albums, Artists, Auth, Bookmarks, Catalogs, Genres, Labels, Licenses, LiveStreams, Playlists, Podcasts, Preferences, Shares, Shouts, Songs, System, Users, Videos]);
25
+
26
+ export default AmpacheAPI
@@ -0,0 +1,42 @@
1
+ import qs from 'querystringify';
2
+ import { Label } from './types';
3
+ import { Base, BinaryBoolean, Pagination, UID } from '../base';
4
+
5
+ export class Labels extends Base {
6
+ /**
7
+ * This returns labels based on the specified filter
8
+ * @remarks MINIMUM_API_VERSION=420000
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#labels}
16
+ */
17
+ async labels (params?: {
18
+ filter?: string,
19
+ exact?: BinaryBoolean,
20
+ add?: Date,
21
+ update?: Date,
22
+ } & Pagination) {
23
+ let query = 'labels';
24
+ query += qs.stringify(params, '&');
25
+ let data = await this.request<{label: Label[]}>(query);
26
+ return (data.label) ? data.label : data;
27
+ }
28
+
29
+ /**
30
+ * This returns a single label
31
+ * @remarks MINIMUM_API_VERSION=420000
32
+ * @param params.filter UID to find
33
+ * @see {@link https://ampache.org/api/api-json-methods#label}
34
+ */
35
+ label (params: {
36
+ filter: UID,
37
+ }) {
38
+ let query = 'label';
39
+ query += qs.stringify(params, '&');
40
+ return this.request<Label>(query);
41
+ }
42
+ }
@@ -0,0 +1,14 @@
1
+ import { UID } from "../base";
2
+
3
+ export type Label = {
4
+ id: UID,
5
+ name: string,
6
+ artists: number,
7
+ summary: string | null,
8
+ external_link: string | null,
9
+ address: string | null,
10
+ category: string | null,
11
+ email: string | null,
12
+ website: string | null,
13
+ user: UID,
14
+ }
@@ -0,0 +1,42 @@
1
+ import qs from 'querystringify';
2
+ import { License } from './types';
3
+ import { Base, BinaryBoolean, Pagination, UID } from '../base';
4
+
5
+ export class Licenses extends Base {
6
+ /**
7
+ * This returns licenses based on the specified filter
8
+ * @remarks MINIMUM_API_VERSION=420000
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#licenses}
16
+ */
17
+ async licenses (params?: {
18
+ filter?: string,
19
+ exact?: BinaryBoolean,
20
+ add?: Date,
21
+ update?: Date,
22
+ } & Pagination) {
23
+ let query = 'licenses';
24
+ query += qs.stringify(params, '&');
25
+ let data = await this.request<{license: License[]}>(query);
26
+ return (data.license) ? data.license : data;
27
+ }
28
+
29
+ /**
30
+ * This returns a single license
31
+ * @remarks MINIMUM_API_VERSION=420000
32
+ * @param params.filter UID to find
33
+ * @see {@link https://ampache.org/api/api-json-methods#license}
34
+ */
35
+ license (params: {
36
+ filter: UID,
37
+ }) {
38
+ let query = 'license';
39
+ query += qs.stringify(params, '&');
40
+ return this.request<License>(query);
41
+ }
42
+ }
@@ -0,0 +1,8 @@
1
+ import { UID } from "../base";
2
+
3
+ export type License = {
4
+ id: UID,
5
+ name: string,
6
+ description: string,
7
+ external_link: string,
8
+ }