larapi 0.0.5 → 0.0.6

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
@@ -19,6 +19,8 @@ declare class API extends Core {
19
19
  private init;
20
20
  setToken(token: string): void;
21
21
  getToken(): string;
22
+ getUid(): number;
23
+ getUser(): TUser;
22
24
  get uid(): number;
23
25
  get user(): TUser;
24
26
  setUser(user: TUser): void;
@@ -39,6 +41,8 @@ declare class API extends Core {
39
41
  static setInitData: (data: import("./types").TGroupsData) => void;
40
42
  static deleteCacheGroup: (group: string) => void;
41
43
  static getToken: () => string;
44
+ static getUid: () => number;
45
+ static getUser: () => TUser;
42
46
  static user: TUser;
43
47
  static uid: number;
44
48
  }
package/lib/index.js CHANGED
@@ -24,6 +24,8 @@ class API extends Core_1.default {
24
24
  this.getToken = this.getToken.bind(this);
25
25
  this.get = this.get.bind(this);
26
26
  this.post = this.post.bind(this);
27
+ this.getUid = this.getUid.bind(this);
28
+ this.getUser = this.getUser.bind(this);
27
29
  }
28
30
  get(params) {
29
31
  return this.request('GET', params);
@@ -53,12 +55,18 @@ class API extends Core_1.default {
53
55
  getToken() {
54
56
  return this.token;
55
57
  }
56
- get uid() {
58
+ getUid() {
57
59
  return 'id' in this._user ? Number(this._user.id) : 0;
58
60
  }
59
- get user() {
61
+ getUser() {
60
62
  return this._user;
61
63
  }
64
+ get uid() {
65
+ return this.getUid();
66
+ }
67
+ get user() {
68
+ return this.getUser();
69
+ }
62
70
  setUser(user) {
63
71
  if (typeof window === 'undefined')
64
72
  return;
@@ -155,6 +163,18 @@ Object.defineProperty(API, "getToken", {
155
163
  writable: true,
156
164
  value: _a.instance.getToken
157
165
  });
166
+ Object.defineProperty(API, "getUid", {
167
+ enumerable: true,
168
+ configurable: true,
169
+ writable: true,
170
+ value: _a.instance.getUid
171
+ });
172
+ Object.defineProperty(API, "getUser", {
173
+ enumerable: true,
174
+ configurable: true,
175
+ writable: true,
176
+ value: _a.instance.getUser
177
+ });
158
178
  Object.defineProperty(API, "user", {
159
179
  enumerable: true,
160
180
  configurable: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "larapi",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "API client for laravel",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
package/src/index.ts CHANGED
@@ -28,6 +28,8 @@ class API extends Core {
28
28
  this.getToken = this.getToken.bind(this);
29
29
  this.get = this.get.bind(this);
30
30
  this.post = this.post.bind(this);
31
+ this.getUid = this.getUid.bind(this);
32
+ this.getUser = this.getUser.bind(this);
31
33
  }
32
34
 
33
35
  public get(params: TParams) {
@@ -61,12 +63,20 @@ class API extends Core {
61
63
  return this.token;
62
64
  }
63
65
 
66
+ public getUid(): number {
67
+ return 'id' in this._user ? Number(this._user.id) : 0;
68
+ }
69
+
70
+ public getUser(): TUser {
71
+ return this._user;
72
+ }
73
+
64
74
  public get uid(): number {
65
- return 'id' in this._user ? Number(this._user.id) : 0;
75
+ return this.getUid();
66
76
  }
67
77
 
68
78
  public get user(): TUser {
69
- return this._user;
79
+ return this.getUser();
70
80
  }
71
81
 
72
82
  public setUser(user: TUser) {
@@ -101,6 +111,8 @@ class API extends Core {
101
111
  public static setInitData = this.instance.setInitData;
102
112
  public static deleteCacheGroup = this.instance.deleteCacheGroup;
103
113
  public static getToken = this.instance.getToken;
114
+ public static getUid = this.instance.getUid;
115
+ public static getUser = this.instance.getUser;
104
116
  public static user = this.instance.user;
105
117
  public static uid = this.instance.uid;
106
118
  }