@kedaruma/revlm-client 1.0.40 → 1.0.42
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/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +8 -5
- package/dist/index.mjs +8 -5
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DefaultId } from '@kedaruma/revlm-shared/models/mongo-doc-base-types';
|
|
1
2
|
import * as bson from 'bson';
|
|
2
3
|
import { Timestamp, Long } from 'bson';
|
|
3
4
|
import { User as User$1, UserBase as UserBase$1 } from '@kedaruma/revlm-shared/models/user-types';
|
|
@@ -239,7 +240,7 @@ declare class RevlmUser {
|
|
|
239
240
|
callFunction: (_name: string, _args?: any[]) => Promise<any>;
|
|
240
241
|
};
|
|
241
242
|
constructor(app: App, token: string, profile: User);
|
|
242
|
-
get id():
|
|
243
|
+
get id(): DefaultId;
|
|
243
244
|
get accessToken(): string;
|
|
244
245
|
get profile(): User;
|
|
245
246
|
mongoClient(_serviceName?: string): MongoDBService;
|
|
@@ -256,6 +257,7 @@ declare class App {
|
|
|
256
257
|
constructor(baseUrl: string, opts?: RevlmOptions & {
|
|
257
258
|
id?: string;
|
|
258
259
|
});
|
|
260
|
+
private getUserKey;
|
|
259
261
|
get currentUser(): RevlmUser | null;
|
|
260
262
|
get allUsers(): Record<string, RevlmUser>;
|
|
261
263
|
logIn(cred: EmailPasswordCredential): Promise<RevlmUser>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DefaultId } from '@kedaruma/revlm-shared/models/mongo-doc-base-types';
|
|
1
2
|
import * as bson from 'bson';
|
|
2
3
|
import { Timestamp, Long } from 'bson';
|
|
3
4
|
import { User as User$1, UserBase as UserBase$1 } from '@kedaruma/revlm-shared/models/user-types';
|
|
@@ -239,7 +240,7 @@ declare class RevlmUser {
|
|
|
239
240
|
callFunction: (_name: string, _args?: any[]) => Promise<any>;
|
|
240
241
|
};
|
|
241
242
|
constructor(app: App, token: string, profile: User);
|
|
242
|
-
get id():
|
|
243
|
+
get id(): DefaultId;
|
|
243
244
|
get accessToken(): string;
|
|
244
245
|
get profile(): User;
|
|
245
246
|
mongoClient(_serviceName?: string): MongoDBService;
|
|
@@ -256,6 +257,7 @@ declare class App {
|
|
|
256
257
|
constructor(baseUrl: string, opts?: RevlmOptions & {
|
|
257
258
|
id?: string;
|
|
258
259
|
});
|
|
260
|
+
private getUserKey;
|
|
259
261
|
get currentUser(): RevlmUser | null;
|
|
260
262
|
get allUsers(): Record<string, RevlmUser>;
|
|
261
263
|
logIn(cred: EmailPasswordCredential): Promise<RevlmUser>;
|
package/dist/index.js
CHANGED
|
@@ -341,7 +341,7 @@ var RevlmUser = class {
|
|
|
341
341
|
};
|
|
342
342
|
}
|
|
343
343
|
get id() {
|
|
344
|
-
return
|
|
344
|
+
return this._profile && this._profile._id ? this._profile._id : "";
|
|
345
345
|
}
|
|
346
346
|
get accessToken() {
|
|
347
347
|
return this._token;
|
|
@@ -372,6 +372,9 @@ var App = class {
|
|
|
372
372
|
}
|
|
373
373
|
};
|
|
374
374
|
}
|
|
375
|
+
getUserKey(user) {
|
|
376
|
+
return user && user.id ? String(user.id) : "current";
|
|
377
|
+
}
|
|
375
378
|
get currentUser() {
|
|
376
379
|
return this._currentUser;
|
|
377
380
|
}
|
|
@@ -398,8 +401,8 @@ var App = class {
|
|
|
398
401
|
}
|
|
399
402
|
this.revlm.setToken(res.token);
|
|
400
403
|
const user = new RevlmUser(this, res.token, res.user);
|
|
401
|
-
const
|
|
402
|
-
this._users[
|
|
404
|
+
const userKey = this.getUserKey(user);
|
|
405
|
+
this._users[userKey] = user;
|
|
403
406
|
this._currentUser = user;
|
|
404
407
|
return user;
|
|
405
408
|
}
|
|
@@ -411,8 +414,8 @@ var App = class {
|
|
|
411
414
|
}
|
|
412
415
|
async removeUser(user) {
|
|
413
416
|
if (!user) return;
|
|
414
|
-
const
|
|
415
|
-
delete this._users[
|
|
417
|
+
const userKey = this.getUserKey(user);
|
|
418
|
+
delete this._users[userKey];
|
|
416
419
|
if (this._currentUser === user) {
|
|
417
420
|
await this.logOut();
|
|
418
421
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -298,7 +298,7 @@ var RevlmUser = class {
|
|
|
298
298
|
};
|
|
299
299
|
}
|
|
300
300
|
get id() {
|
|
301
|
-
return
|
|
301
|
+
return this._profile && this._profile._id ? this._profile._id : "";
|
|
302
302
|
}
|
|
303
303
|
get accessToken() {
|
|
304
304
|
return this._token;
|
|
@@ -329,6 +329,9 @@ var App = class {
|
|
|
329
329
|
}
|
|
330
330
|
};
|
|
331
331
|
}
|
|
332
|
+
getUserKey(user) {
|
|
333
|
+
return user && user.id ? String(user.id) : "current";
|
|
334
|
+
}
|
|
332
335
|
get currentUser() {
|
|
333
336
|
return this._currentUser;
|
|
334
337
|
}
|
|
@@ -355,8 +358,8 @@ var App = class {
|
|
|
355
358
|
}
|
|
356
359
|
this.revlm.setToken(res.token);
|
|
357
360
|
const user = new RevlmUser(this, res.token, res.user);
|
|
358
|
-
const
|
|
359
|
-
this._users[
|
|
361
|
+
const userKey = this.getUserKey(user);
|
|
362
|
+
this._users[userKey] = user;
|
|
360
363
|
this._currentUser = user;
|
|
361
364
|
return user;
|
|
362
365
|
}
|
|
@@ -368,8 +371,8 @@ var App = class {
|
|
|
368
371
|
}
|
|
369
372
|
async removeUser(user) {
|
|
370
373
|
if (!user) return;
|
|
371
|
-
const
|
|
372
|
-
delete this._users[
|
|
374
|
+
const userKey = this.getUserKey(user);
|
|
375
|
+
delete this._users[userKey];
|
|
373
376
|
if (this._currentUser === user) {
|
|
374
377
|
await this.logOut();
|
|
375
378
|
}
|