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,40 +1,39 @@
1
- import qs from 'querystringify';
2
- import { Genre } from './types';
3
- import { Base, BinaryBoolean, ExtendedPagination, 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
- * @param [params.cond]
14
- * @param [params.sort]
15
- * @see {@link https://ampache.org/api/api-json-methods#genres}
16
- */
17
- async genres (params?: {
18
- filter?: string,
19
- exact?: BinaryBoolean,
20
- } & ExtendedPagination) {
21
- let query = 'genres';
22
- query += qs.stringify(params, '&');
23
- let data = await this.request<{genre: Genre[]}>(query);
24
- return (data.genre) ? data.genre : data;
25
- }
26
-
27
- /**
28
- * This returns a single genre based on UID
29
- * @remarks MINIMUM_API_VERSION=380001
30
- * @param params.filter UID to find
31
- * @see {@link https://ampache.org/api/api-json-methods#genre}
32
- */
33
- async genre (params: {
34
- filter: UID,
35
- }) {
36
- let query = 'genre';
37
- query += qs.stringify(params, '&');
38
- return this.request<Genre>(query);
39
- }
40
- }
1
+ import qs from "querystringify";
2
+ import { GenreResponse, GenresResponse } from "./types";
3
+ import { Base, BinaryBoolean, ExtendedPagination, 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
+ * @param [params.cond]
14
+ * @param [params.sort]
15
+ * @see {@link https://ampache.org/api/api-json-methods#genres}
16
+ */
17
+ genres(
18
+ params?: {
19
+ filter?: string;
20
+ exact?: BinaryBoolean;
21
+ } & ExtendedPagination,
22
+ ) {
23
+ let query = "genres";
24
+ query += qs.stringify(params, "&");
25
+ return this.request<GenresResponse>(query);
26
+ }
27
+
28
+ /**
29
+ * This returns a single genre based on UID
30
+ * @remarks MINIMUM_API_VERSION=380001
31
+ * @param params.filter UID to find
32
+ * @see {@link https://ampache.org/api/api-json-methods#genre}
33
+ */
34
+ genre(params: { filter: UID }) {
35
+ let query = "genre";
36
+ query += qs.stringify(params, "&");
37
+ return this.request<GenreResponse>(query);
38
+ }
39
+ }
@@ -1,17 +1,23 @@
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
- }
1
+ import { UID } from "../base";
2
+
3
+ export type GenreSummary = {
4
+ id: UID;
5
+ name: string;
6
+ };
7
+
8
+ export type GenreResponse = {
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
+ };
18
+
19
+ export type GenresResponse = {
20
+ total_count: number;
21
+ md5: string;
22
+ genre: GenreResponse[];
23
+ };
package/src/index.ts CHANGED
@@ -1,26 +1,63 @@
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
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
24
+ extends Albums,
25
+ Artists,
26
+ Auth,
27
+ Bookmarks,
28
+ Catalogs,
29
+ Genres,
30
+ Labels,
31
+ Licenses,
32
+ LiveStreams,
33
+ Playlists,
34
+ Podcasts,
35
+ Preferences,
36
+ Shares,
37
+ Shouts,
38
+ Songs,
39
+ System,
40
+ Users,
41
+ Videos {}
42
+ applyMixins(AmpacheAPI, [
43
+ Albums,
44
+ Artists,
45
+ Auth,
46
+ Bookmarks,
47
+ Catalogs,
48
+ Genres,
49
+ Labels,
50
+ Licenses,
51
+ LiveStreams,
52
+ Playlists,
53
+ Podcasts,
54
+ Preferences,
55
+ Shares,
56
+ Shouts,
57
+ Songs,
58
+ System,
59
+ Users,
60
+ Videos,
61
+ ]);
62
+
63
+ export default AmpacheAPI;
@@ -1,44 +1,43 @@
1
- import qs from 'querystringify';
2
- import { Label } from './types';
3
- import { Base, BinaryBoolean, ExtendedPagination, 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
- * @param [params.cond]
16
- * @param [params.sort]
17
- * @see {@link https://ampache.org/api/api-json-methods#labels}
18
- */
19
- async labels (params?: {
20
- filter?: string,
21
- exact?: BinaryBoolean,
22
- add?: Date,
23
- update?: Date,
24
- } & ExtendedPagination) {
25
- let query = 'labels';
26
- query += qs.stringify(params, '&');
27
- let data = await this.request<{label: Label[]}>(query);
28
- return (data.label) ? data.label : data;
29
- }
30
-
31
- /**
32
- * This returns a single label
33
- * @remarks MINIMUM_API_VERSION=420000
34
- * @param params.filter UID to find
35
- * @see {@link https://ampache.org/api/api-json-methods#label}
36
- */
37
- label (params: {
38
- filter: UID,
39
- }) {
40
- let query = 'label';
41
- query += qs.stringify(params, '&');
42
- return this.request<Label>(query);
43
- }
44
- }
1
+ import qs from "querystringify";
2
+ import { LabelResponse, LabelsResponse } from "./types";
3
+ import { Base, BinaryBoolean, ExtendedPagination, 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
+ * @param [params.cond]
16
+ * @param [params.sort]
17
+ * @see {@link https://ampache.org/api/api-json-methods#labels}
18
+ */
19
+ labels(
20
+ params?: {
21
+ filter?: string;
22
+ exact?: BinaryBoolean;
23
+ add?: Date;
24
+ update?: Date;
25
+ } & ExtendedPagination,
26
+ ) {
27
+ let query = "labels";
28
+ query += qs.stringify(params, "&");
29
+ return this.request<LabelsResponse>(query);
30
+ }
31
+
32
+ /**
33
+ * This returns a single label
34
+ * @remarks MINIMUM_API_VERSION=420000
35
+ * @param params.filter UID to find
36
+ * @see {@link https://ampache.org/api/api-json-methods#label}
37
+ */
38
+ label(params: { filter: UID }) {
39
+ let query = "label";
40
+ query += qs.stringify(params, "&");
41
+ return this.request<LabelResponse>(query);
42
+ }
43
+ }
@@ -1,14 +1,20 @@
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
- }
1
+ import { UID } from "../base";
2
+
3
+ export type LabelResponse = {
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
+ };
15
+
16
+ export type LabelsResponse = {
17
+ total_count: number;
18
+ md5: string;
19
+ label: LabelResponse[];
20
+ };
@@ -1,44 +1,43 @@
1
- import qs from 'querystringify';
2
- import { License } from './types';
3
- import { Base, BinaryBoolean, ExtendedPagination, 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
- * @param [params.cond]
16
- * @param [params.sort]
17
- * @see {@link https://ampache.org/api/api-json-methods#licenses}
18
- */
19
- async licenses (params?: {
20
- filter?: string,
21
- exact?: BinaryBoolean,
22
- add?: Date,
23
- update?: Date,
24
- } & ExtendedPagination) {
25
- let query = 'licenses';
26
- query += qs.stringify(params, '&');
27
- let data = await this.request<{license: License[]}>(query);
28
- return (data.license) ? data.license : data;
29
- }
30
-
31
- /**
32
- * This returns a single license
33
- * @remarks MINIMUM_API_VERSION=420000
34
- * @param params.filter UID to find
35
- * @see {@link https://ampache.org/api/api-json-methods#license}
36
- */
37
- license (params: {
38
- filter: UID,
39
- }) {
40
- let query = 'license';
41
- query += qs.stringify(params, '&');
42
- return this.request<License>(query);
43
- }
44
- }
1
+ import qs from "querystringify";
2
+ import { LicenseResponse, LicensesResponse } from "./types";
3
+ import { Base, BinaryBoolean, ExtendedPagination, 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
+ * @param [params.cond]
16
+ * @param [params.sort]
17
+ * @see {@link https://ampache.org/api/api-json-methods#licenses}
18
+ */
19
+ licenses(
20
+ params?: {
21
+ filter?: string;
22
+ exact?: BinaryBoolean;
23
+ add?: Date;
24
+ update?: Date;
25
+ } & ExtendedPagination,
26
+ ) {
27
+ let query = "licenses";
28
+ query += qs.stringify(params, "&");
29
+ return this.request<LicensesResponse>(query);
30
+ }
31
+
32
+ /**
33
+ * This returns a single license
34
+ * @remarks MINIMUM_API_VERSION=420000
35
+ * @param params.filter UID to find
36
+ * @see {@link https://ampache.org/api/api-json-methods#license}
37
+ */
38
+ license(params: { filter: UID }) {
39
+ let query = "license";
40
+ query += qs.stringify(params, "&");
41
+ return this.request<LicenseResponse>(query);
42
+ }
43
+ }
@@ -1,8 +1,14 @@
1
- import { UID } from "../base";
2
-
3
- export type License = {
4
- id: UID,
5
- name: string,
6
- description: string,
7
- external_link: string,
8
- }
1
+ import { UID } from "../base";
2
+
3
+ export type LicenseResponse = {
4
+ id: UID;
5
+ name: string;
6
+ description: string;
7
+ external_link: string;
8
+ };
9
+
10
+ export type LicensesResponse = {
11
+ total_count: number;
12
+ md5: string;
13
+ license: LicenseResponse[];
14
+ };