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,32 @@
1
+ import { UID } from "../base";
2
+
3
+ export type UserSummary = {
4
+ id: UID,
5
+ username: string,
6
+ }
7
+
8
+ export type User = {
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 Activity = {
26
+ id: UID,
27
+ date: number,
28
+ object_type: string,
29
+ object_id: UID,
30
+ action: string,
31
+ user: UserSummary,
32
+ }
package/src/utils.ts ADDED
@@ -0,0 +1,25 @@
1
+ import JsSHA from "jssha/dist/sha256";
2
+
3
+ export function applyMixins(derivedCtor: any, baseCtors: any[]) {
4
+ baseCtors.forEach(baseCtor => {
5
+ Object.getOwnPropertyNames(baseCtor.prototype).forEach(name => {
6
+ Object.defineProperty(
7
+ derivedCtor.prototype,
8
+ name,
9
+ Object.getOwnPropertyDescriptor(baseCtor.prototype, name)
10
+ );
11
+ });
12
+ });
13
+ }
14
+
15
+ export function encryptPassword(password: string, time: number) {
16
+ let key = getSHA256(password);
17
+ return getSHA256(time + key);
18
+
19
+ function getSHA256(text) {
20
+ let shaObj = new JsSHA("SHA-256", "TEXT", { encoding: "UTF8" });
21
+ shaObj.update(text);
22
+
23
+ return shaObj.getHash("HEX");
24
+ }
25
+ }
@@ -0,0 +1,53 @@
1
+ import qs from 'querystringify';
2
+ import { Video, DeletedVideo } 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
+ async videos (params?: {
16
+ filter?: string,
17
+ exact?: BinaryBoolean,
18
+ } & Pagination) {
19
+ let query = 'videos';
20
+ query += qs.stringify(params, '&');
21
+ let data = await this.request<{video: Video[]}>(query);
22
+ return (data.video) ? data.video : data;
23
+ }
24
+
25
+ /**
26
+ * This returns a single video
27
+ * @remarks MINIMUM_API_VERSION=380001
28
+ * @param params.filter UID to find
29
+ * @see {@link https://ampache.org/api/api-json-methods#video}
30
+ */
31
+ video (params: {
32
+ filter: UID,
33
+ }) {
34
+ let query = 'video';
35
+ query += qs.stringify(params, '&');
36
+ return this.request<Video>(query);
37
+ }
38
+
39
+ /**
40
+ * This returns video objects that have been deleted
41
+ * @param [params.offset]
42
+ * @param [params.limit]
43
+ * @see {@link https://ampache.org/api/api-json-methods#deleted_videos}
44
+ */
45
+ async deletedVideos (params?: {
46
+
47
+ } & Pagination) {
48
+ let query = 'deleted_videos';
49
+ query += qs.stringify(params, '&');
50
+ let data = await this.request<{deleted_video: DeletedVideo[]}>(query);
51
+ return (data.deleted_video) ? data.deleted_video : data;
52
+ }
53
+ }
@@ -0,0 +1,29 @@
1
+ import { UID } from "../base";
2
+ import { GenreSummary } from "../genres/types";
3
+
4
+ export type Video = {
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
+ flag: boolean,
15
+ rating: number | null,
16
+ averagerating: number | null,
17
+ playcount: number,
18
+ }
19
+
20
+ export type DeletedVideo = {
21
+ id: UID,
22
+ addition_time: number,
23
+ delete_time: number,
24
+ title: string,
25
+ file: string,
26
+ catalog: UID,
27
+ total_count: number,
28
+ total_skip: number,
29
+ }