@axium/client 0.16.4 → 0.16.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/dist/user.d.ts CHANGED
@@ -14,7 +14,7 @@ export declare function logout(userId: string, ...sessionId: string[]): Promise<
14
14
  export declare function logoutAll(userId: string): Promise<Session[]>;
15
15
  export declare function logoutCurrentSession(): Promise<Session>;
16
16
  export declare function register(_data: Record<string, unknown>): Promise<void>;
17
- export declare function userInfo(userId: string): Promise<UserPublic & Partial<User>>;
17
+ export declare function userInfo(userId: string, noCache?: boolean): Promise<UserPublic & Partial<User>>;
18
18
  export declare function updateUser(userId: string, data: Record<string, FormDataEntryValue>): Promise<User>;
19
19
  export declare function fullUserInfo(userId: string): Promise<User & {
20
20
  sessions: Session[];
package/dist/user.js CHANGED
@@ -59,9 +59,15 @@ function _checkId(userId) {
59
59
  throw e instanceof z.core.$ZodError ? z.prettifyError(e) : e;
60
60
  }
61
61
  }
62
- export async function userInfo(userId) {
62
+ const userCache = new Map();
63
+ export async function userInfo(userId, noCache = false) {
63
64
  _checkId(userId);
64
- return await fetchAPI('GET', 'users/:id', {}, userId);
65
+ const cached = userCache.get(userId);
66
+ if (!noCache && cached)
67
+ return await cached;
68
+ const result = fetchAPI('GET', 'users/:id', {}, userId);
69
+ userCache.set(userId, result);
70
+ return await result;
65
71
  }
66
72
  export async function updateUser(userId, data) {
67
73
  _checkId(userId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axium/client",
3
- "version": "0.16.4",
3
+ "version": "0.16.6",
4
4
  "author": "James Prevett <jp@jamespre.dev>",
5
5
  "funding": {
6
6
  "type": "individual",