beamsocial 0.5.1 → 0.5.3

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.
package/lib/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ProfileSettings } from './models/types/profiles.js';
1
+ import type { Settings } from './models/types/profiles.js';
2
2
  import { User } from './models/users.js';
3
3
  import { Session } from './models/auth.js';
4
4
  import { Post } from './models/posts.js';
@@ -10,7 +10,7 @@ export declare class Client {
10
10
  login(username: string, password: string): Promise<Session | null>;
11
11
  refresh(token?: string): Promise<void>;
12
12
  me(): Promise<Session | null>;
13
- update_settings(settings: ProfileSettings): Promise<void>;
13
+ update_settings(settings: Settings): Promise<void>;
14
14
  /*************************************/
15
15
  getUser(name: string): Promise<User | null>;
16
16
  /*************************************/
package/lib/index.js CHANGED
@@ -81,8 +81,8 @@ export class Client {
81
81
  return __awaiter(this, void 0, void 0, function* () {
82
82
  try {
83
83
  yield axios.post(this.baseURL + '/me/update_settings', {
84
- privacy: settings.preferences.privacy,
85
- appearence: settings.preferences.appearance
84
+ privacy: settings.privacy,
85
+ appearence: settings.appearance
86
86
  }, {
87
87
  headers: {
88
88
  Authorization: `Bearer ${this.token}`,
@@ -1,14 +1,18 @@
1
- import type { Profile, ProfileSettings } from "./types/profiles";
1
+ import type { Profile, Settings, Relations, Tastes } from "./types/profiles";
2
2
  export declare class Session {
3
3
  readonly id: string;
4
4
  readonly token: string | null;
5
5
  profile: Profile;
6
- settings: ProfileSettings;
6
+ settings: Settings;
7
+ relations: Relations;
8
+ tastes: Tastes;
7
9
  inbox: {};
8
10
  constructor(id: string, token: string | null);
9
11
  __load(data: {
10
12
  profile?: Profile;
11
- settings?: ProfileSettings;
13
+ settings?: Settings;
14
+ relations?: Relations;
15
+ tastes: Tastes;
12
16
  inbox?: {};
13
17
  }): void;
14
18
  }
@@ -3,6 +3,8 @@ export class Session {
3
3
  this.token = null;
4
4
  this.profile = {};
5
5
  this.settings = {};
6
+ this.relations = {};
7
+ this.tastes = {};
6
8
  this.inbox = {};
7
9
  this.id = id;
8
10
  this.token = token;
@@ -12,6 +14,10 @@ export class Session {
12
14
  this.profile = data.profile;
13
15
  if (data.settings)
14
16
  this.settings = data.settings;
17
+ if (data.relations)
18
+ this.relations = data.relations;
19
+ if (data.tastes)
20
+ this.tastes = data.tastes;
15
21
  if (data.inbox)
16
22
  this.inbox = data.inbox;
17
23
  }
@@ -43,7 +43,7 @@ export class Post {
43
43
  },
44
44
  });
45
45
  this.likes += 1;
46
- (_a = this.__session) === null || _a === void 0 ? void 0 : _a.profile.likes.push(this.id);
46
+ (_a = this.__session) === null || _a === void 0 ? void 0 : _a.tastes.likes.push(this.id);
47
47
  return;
48
48
  }
49
49
  catch (err) {
@@ -71,13 +71,13 @@ export class Post {
71
71
  unlike() {
72
72
  return __awaiter(this, void 0, void 0, function* () {
73
73
  try {
74
- const res = yield axios.post(this.__url + `/like`, {}, {
74
+ const res = yield axios.delete(this.__url + `/like`, {
75
75
  headers: {
76
76
  Authorization: `Bearer ${this.__token}`,
77
77
  },
78
78
  });
79
79
  this.likes -= 1;
80
- this.__session.profile.likes = this.__session.profile.likes.filter((id) => id !== this.id);
80
+ this.__session.tastes.likes = this.__session.tastes.likes.filter((id) => id !== this.id);
81
81
  return;
82
82
  }
83
83
  catch (err) {
@@ -4,9 +4,8 @@ export type Profile = {
4
4
  display_name: string | null;
5
5
  creation_date: string;
6
6
  update_date: string;
7
- followers: string[];
8
- following: string[];
9
- likes: string[];
7
+ followers: number;
8
+ following: number;
10
9
  status: string | null;
11
10
  birthday: string | null;
12
11
  pronouns: string | null;
@@ -16,16 +15,16 @@ export type Profile = {
16
15
  export type Settings = {
17
16
  id: string;
18
17
  privacy: {
19
- profile_visibility: string;
20
- birthday_visibility: string;
21
- status_visibility: string;
18
+ profile: string;
19
+ birthday: string;
20
+ status: string;
22
21
  dms: string;
23
22
  };
24
23
  appearance: {
25
24
  global_theme: string;
26
25
  };
27
26
  };
28
- export type ProfileSettings = {
27
+ export type Relations = {
29
28
  id: string;
30
29
  blocklist: string[];
31
30
  pending: {
@@ -35,5 +34,9 @@ export type ProfileSettings = {
35
34
  friends: string[];
36
35
  children: string[];
37
36
  parent: string | null;
38
- preferences: Settings;
37
+ };
38
+ export type Tastes = {
39
+ id: string;
40
+ likes: string[];
41
+ hashtags: string[];
39
42
  };
@@ -7,12 +7,12 @@ export declare class User {
7
7
  id: string;
8
8
  name: string;
9
9
  display_name: string | null;
10
- creation_date: string;
11
- update_date: string;
12
- followers: string[];
13
- following: string[];
10
+ creation_date: Date;
11
+ update_date: Date;
12
+ followers: number;
13
+ following: number;
14
14
  status: string | null;
15
- birthday: string | null;
15
+ birthday: Date | null;
16
16
  pronouns: string | null;
17
17
  account_type: string | null;
18
18
  level: number;
@@ -12,10 +12,10 @@ export class User {
12
12
  constructor(id) {
13
13
  this.name = '';
14
14
  this.display_name = null;
15
- this.creation_date = '1970-01-01T00:00:00Z';
16
- this.update_date = '1970-01-01T00:00:00Z';
17
- this.followers = [];
18
- this.following = [];
15
+ this.creation_date = new Date('1970-01-01T00:00:00Z');
16
+ this.update_date = new Date('1970-01-01T00:00:00Z');
17
+ this.followers = 0;
18
+ this.following = 0;
19
19
  this.status = null;
20
20
  this.birthday = null;
21
21
  this.pronouns = null;
@@ -29,12 +29,12 @@ export class User {
29
29
  this.__url = __url + '/users/' + data.name;
30
30
  this.name = data.name;
31
31
  this.display_name = data.display_name;
32
- this.creation_date = data.creation_date;
33
- this.update_date = data.update_date;
32
+ this.creation_date = new Date(data.creation_date);
33
+ this.update_date = new Date(data.update_date);
34
34
  this.followers = data.followers;
35
35
  this.following = data.following;
36
36
  this.status = data.status;
37
- this.birthday = data.birthday;
37
+ this.birthday = data.birthday ? new Date(data.birthday) : null;
38
38
  this.pronouns = data.pronouns;
39
39
  this.account_type = data.account_type;
40
40
  this.level = data.level;
@@ -47,7 +47,7 @@ export class User {
47
47
  Authorization: `Bearer ${this.__token}`,
48
48
  },
49
49
  });
50
- this.followers.push(this.__session.id);
50
+ this.followers += 1;
51
51
  return;
52
52
  }
53
53
  catch (err) {
@@ -80,7 +80,7 @@ export class User {
80
80
  Authorization: `Bearer ${this.__token}`,
81
81
  },
82
82
  });
83
- this.followers = this.followers.filter(item => item !== this.__session.id);
83
+ this.followers -= 1;
84
84
  return;
85
85
  }
86
86
  catch (err) {
@@ -114,7 +114,7 @@ export class User {
114
114
  Authorization: `Bearer ${this.__token}`,
115
115
  },
116
116
  });
117
- (_a = this.__session) === null || _a === void 0 ? void 0 : _a.settings.blocklist.push(this.id);
117
+ (_a = this.__session) === null || _a === void 0 ? void 0 : _a.relations.blocklist.push(this.id);
118
118
  return;
119
119
  }
120
120
  catch (err) {
@@ -144,8 +144,8 @@ export class User {
144
144
  Authorization: `Bearer ${this.__token}`,
145
145
  },
146
146
  });
147
- if (this.__session && this.__session.settings) {
148
- this.__session.settings.blocklist = this.__session.settings.blocklist.filter(item => item !== this.id);
147
+ if (this.__session && this.__session.relations) {
148
+ this.__session.relations.blocklist = this.__session.relations.blocklist.filter((item) => item !== this.id);
149
149
  }
150
150
  return;
151
151
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "beamsocial",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "type": "module",
5
5
  "description": "API-wrapper pour Beam",
6
6
  "main": "index.js",