@kedaruma/revlm-client 1.0.29 → 1.0.34
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 +14 -13
- package/dist/index.d.ts +14 -13
- package/dist/index.js +14 -5
- package/dist/index.mjs +13 -4
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { User
|
|
1
|
+
import { User } from '@kedaruma/revlm-shared/models/user-types';
|
|
2
|
+
export { User, UserBase } from '@kedaruma/revlm-shared/models/user-types';
|
|
2
3
|
import * as bson from 'bson';
|
|
3
4
|
import { Timestamp, Long } from 'bson';
|
|
4
5
|
|
|
@@ -12,7 +13,7 @@ type RevlmErrorResponse = {
|
|
|
12
13
|
type LoginSuccess = {
|
|
13
14
|
ok: true;
|
|
14
15
|
token: string;
|
|
15
|
-
user: User
|
|
16
|
+
user: User;
|
|
16
17
|
};
|
|
17
18
|
type LoginResponse = LoginSuccess | RevlmErrorResponse;
|
|
18
19
|
type ProvisionalLoginSuccess = {
|
|
@@ -23,7 +24,7 @@ type ProvisionalLoginSuccess = {
|
|
|
23
24
|
type ProvisionalLoginResponse = ProvisionalLoginSuccess | RevlmErrorResponse;
|
|
24
25
|
type RegisterUserSuccess = {
|
|
25
26
|
ok: true;
|
|
26
|
-
user: User
|
|
27
|
+
user: User;
|
|
27
28
|
};
|
|
28
29
|
type RegisterUserResponse = RegisterUserSuccess | RevlmErrorResponse;
|
|
29
30
|
type DeleteUserSuccess = {
|
|
@@ -166,8 +167,8 @@ type EmailPasswordCredential = {
|
|
|
166
167
|
email: string;
|
|
167
168
|
password: string;
|
|
168
169
|
};
|
|
169
|
-
type UserInput = Omit<User
|
|
170
|
-
userType: User
|
|
170
|
+
type UserInput = Omit<User, 'userType'> & {
|
|
171
|
+
userType: User['userType'] | string;
|
|
171
172
|
};
|
|
172
173
|
type RevlmOptions = {
|
|
173
174
|
fetchImpl?: typeof fetch;
|
|
@@ -228,7 +229,7 @@ declare class MongoDBService {
|
|
|
228
229
|
declare class Credentials {
|
|
229
230
|
static emailPassword(email: string, password: string): EmailPasswordCredential;
|
|
230
231
|
}
|
|
231
|
-
declare class
|
|
232
|
+
declare class RevlmUser {
|
|
232
233
|
private _app;
|
|
233
234
|
private _token;
|
|
234
235
|
private _profile;
|
|
@@ -253,13 +254,13 @@ declare class App {
|
|
|
253
254
|
constructor(baseUrl: string, opts?: RevlmOptions & {
|
|
254
255
|
id?: string;
|
|
255
256
|
});
|
|
256
|
-
get currentUser():
|
|
257
|
-
get allUsers(): Record<string,
|
|
258
|
-
logIn(cred: EmailPasswordCredential): Promise<
|
|
259
|
-
switchUser(user:
|
|
260
|
-
removeUser(user:
|
|
257
|
+
get currentUser(): RevlmUser | null;
|
|
258
|
+
get allUsers(): Record<string, RevlmUser>;
|
|
259
|
+
logIn(cred: EmailPasswordCredential): Promise<RevlmUser>;
|
|
260
|
+
switchUser(user: RevlmUser): RevlmUser;
|
|
261
|
+
removeUser(user: RevlmUser): Promise<void>;
|
|
261
262
|
logOut(): Promise<void>;
|
|
262
|
-
deleteUser(user:
|
|
263
|
+
deleteUser(user: RevlmUser): Promise<void>;
|
|
263
264
|
}
|
|
264
265
|
|
|
265
266
|
declare const ObjectId: typeof bson.ObjectId;
|
|
@@ -268,4 +269,4 @@ declare const BSON: typeof bson & {
|
|
|
268
269
|
ObjectID: typeof bson.ObjectId;
|
|
269
270
|
};
|
|
270
271
|
|
|
271
|
-
export { type AggregatePipelineStage, App, BSON, type BaseChangeEvent, type ChangeEvent, type ChangeEventId, type CountOptions, Credentials, type DeleteEvent, type DeleteResult, type DeleteUserResponse, type DeleteUserSuccess, type Document, type DocumentKey, type DocumentNamespace, type DropDatabaseEvent, type DropEvent, type Filter, type FindOneAndModifyOptions, type FindOneOptions, type FindOptions, type InsertEvent, type InsertManyResult, type InsertOneResult, type InvalidateEvent, type LoginResponse, type LoginSuccess, MdbCollection, MongoDBService, type NewDocument, ObjectID, ObjectId, type OperationType, type ProvisionalLoginResponse, type ProvisionalLoginSuccess, type RegisterUserResponse, type RegisterUserSuccess, type RenameEvent, type ReplaceEvent, Revlm, RevlmDBDatabase, type RevlmErrorResponse, type RevlmOptions, type RevlmResponse, type Update, type UpdateDescription, type UpdateEvent, type UpdateOptions, type UpdateResult,
|
|
272
|
+
export { type AggregatePipelineStage, App, BSON, type BaseChangeEvent, type ChangeEvent, type ChangeEventId, type CountOptions, Credentials, type DeleteEvent, type DeleteResult, type DeleteUserResponse, type DeleteUserSuccess, type Document, type DocumentKey, type DocumentNamespace, type DropDatabaseEvent, type DropEvent, type Filter, type FindOneAndModifyOptions, type FindOneOptions, type FindOptions, type InsertEvent, type InsertManyResult, type InsertOneResult, type InvalidateEvent, type LoginResponse, type LoginSuccess, MdbCollection, MongoDBService, type NewDocument, ObjectID, ObjectId, type OperationType, type ProvisionalLoginResponse, type ProvisionalLoginSuccess, type RegisterUserResponse, type RegisterUserSuccess, type RenameEvent, type ReplaceEvent, Revlm, RevlmDBDatabase, type RevlmErrorResponse, type RevlmOptions, type RevlmResponse, RevlmUser, type Update, type UpdateDescription, type UpdateEvent, type UpdateOptions, type UpdateResult, type WatchOptionsFilter, type WatchOptionsIds };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { User
|
|
1
|
+
import { User } from '@kedaruma/revlm-shared/models/user-types';
|
|
2
|
+
export { User, UserBase } from '@kedaruma/revlm-shared/models/user-types';
|
|
2
3
|
import * as bson from 'bson';
|
|
3
4
|
import { Timestamp, Long } from 'bson';
|
|
4
5
|
|
|
@@ -12,7 +13,7 @@ type RevlmErrorResponse = {
|
|
|
12
13
|
type LoginSuccess = {
|
|
13
14
|
ok: true;
|
|
14
15
|
token: string;
|
|
15
|
-
user: User
|
|
16
|
+
user: User;
|
|
16
17
|
};
|
|
17
18
|
type LoginResponse = LoginSuccess | RevlmErrorResponse;
|
|
18
19
|
type ProvisionalLoginSuccess = {
|
|
@@ -23,7 +24,7 @@ type ProvisionalLoginSuccess = {
|
|
|
23
24
|
type ProvisionalLoginResponse = ProvisionalLoginSuccess | RevlmErrorResponse;
|
|
24
25
|
type RegisterUserSuccess = {
|
|
25
26
|
ok: true;
|
|
26
|
-
user: User
|
|
27
|
+
user: User;
|
|
27
28
|
};
|
|
28
29
|
type RegisterUserResponse = RegisterUserSuccess | RevlmErrorResponse;
|
|
29
30
|
type DeleteUserSuccess = {
|
|
@@ -166,8 +167,8 @@ type EmailPasswordCredential = {
|
|
|
166
167
|
email: string;
|
|
167
168
|
password: string;
|
|
168
169
|
};
|
|
169
|
-
type UserInput = Omit<User
|
|
170
|
-
userType: User
|
|
170
|
+
type UserInput = Omit<User, 'userType'> & {
|
|
171
|
+
userType: User['userType'] | string;
|
|
171
172
|
};
|
|
172
173
|
type RevlmOptions = {
|
|
173
174
|
fetchImpl?: typeof fetch;
|
|
@@ -228,7 +229,7 @@ declare class MongoDBService {
|
|
|
228
229
|
declare class Credentials {
|
|
229
230
|
static emailPassword(email: string, password: string): EmailPasswordCredential;
|
|
230
231
|
}
|
|
231
|
-
declare class
|
|
232
|
+
declare class RevlmUser {
|
|
232
233
|
private _app;
|
|
233
234
|
private _token;
|
|
234
235
|
private _profile;
|
|
@@ -253,13 +254,13 @@ declare class App {
|
|
|
253
254
|
constructor(baseUrl: string, opts?: RevlmOptions & {
|
|
254
255
|
id?: string;
|
|
255
256
|
});
|
|
256
|
-
get currentUser():
|
|
257
|
-
get allUsers(): Record<string,
|
|
258
|
-
logIn(cred: EmailPasswordCredential): Promise<
|
|
259
|
-
switchUser(user:
|
|
260
|
-
removeUser(user:
|
|
257
|
+
get currentUser(): RevlmUser | null;
|
|
258
|
+
get allUsers(): Record<string, RevlmUser>;
|
|
259
|
+
logIn(cred: EmailPasswordCredential): Promise<RevlmUser>;
|
|
260
|
+
switchUser(user: RevlmUser): RevlmUser;
|
|
261
|
+
removeUser(user: RevlmUser): Promise<void>;
|
|
261
262
|
logOut(): Promise<void>;
|
|
262
|
-
deleteUser(user:
|
|
263
|
+
deleteUser(user: RevlmUser): Promise<void>;
|
|
263
264
|
}
|
|
264
265
|
|
|
265
266
|
declare const ObjectId: typeof bson.ObjectId;
|
|
@@ -268,4 +269,4 @@ declare const BSON: typeof bson & {
|
|
|
268
269
|
ObjectID: typeof bson.ObjectId;
|
|
269
270
|
};
|
|
270
271
|
|
|
271
|
-
export { type AggregatePipelineStage, App, BSON, type BaseChangeEvent, type ChangeEvent, type ChangeEventId, type CountOptions, Credentials, type DeleteEvent, type DeleteResult, type DeleteUserResponse, type DeleteUserSuccess, type Document, type DocumentKey, type DocumentNamespace, type DropDatabaseEvent, type DropEvent, type Filter, type FindOneAndModifyOptions, type FindOneOptions, type FindOptions, type InsertEvent, type InsertManyResult, type InsertOneResult, type InvalidateEvent, type LoginResponse, type LoginSuccess, MdbCollection, MongoDBService, type NewDocument, ObjectID, ObjectId, type OperationType, type ProvisionalLoginResponse, type ProvisionalLoginSuccess, type RegisterUserResponse, type RegisterUserSuccess, type RenameEvent, type ReplaceEvent, Revlm, RevlmDBDatabase, type RevlmErrorResponse, type RevlmOptions, type RevlmResponse, type Update, type UpdateDescription, type UpdateEvent, type UpdateOptions, type UpdateResult,
|
|
272
|
+
export { type AggregatePipelineStage, App, BSON, type BaseChangeEvent, type ChangeEvent, type ChangeEventId, type CountOptions, Credentials, type DeleteEvent, type DeleteResult, type DeleteUserResponse, type DeleteUserSuccess, type Document, type DocumentKey, type DocumentNamespace, type DropDatabaseEvent, type DropEvent, type Filter, type FindOneAndModifyOptions, type FindOneOptions, type FindOptions, type InsertEvent, type InsertManyResult, type InsertOneResult, type InvalidateEvent, type LoginResponse, type LoginSuccess, MdbCollection, MongoDBService, type NewDocument, ObjectID, ObjectId, type OperationType, type ProvisionalLoginResponse, type ProvisionalLoginSuccess, type RegisterUserResponse, type RegisterUserSuccess, type RenameEvent, type ReplaceEvent, Revlm, RevlmDBDatabase, type RevlmErrorResponse, type RevlmOptions, type RevlmResponse, RevlmUser, type Update, type UpdateDescription, type UpdateEvent, type UpdateOptions, type UpdateResult, type WatchOptionsFilter, type WatchOptionsIds };
|
package/dist/index.js
CHANGED
|
@@ -39,7 +39,7 @@ __export(index_exports, {
|
|
|
39
39
|
ObjectId: () => ObjectId2,
|
|
40
40
|
Revlm: () => Revlm,
|
|
41
41
|
RevlmDBDatabase: () => RevlmDBDatabase,
|
|
42
|
-
|
|
42
|
+
RevlmUser: () => RevlmUser
|
|
43
43
|
});
|
|
44
44
|
module.exports = __toCommonJS(index_exports);
|
|
45
45
|
|
|
@@ -327,7 +327,7 @@ var Credentials = class {
|
|
|
327
327
|
return { type: "emailPassword", email, password };
|
|
328
328
|
}
|
|
329
329
|
};
|
|
330
|
-
var
|
|
330
|
+
var RevlmUser = class {
|
|
331
331
|
_app;
|
|
332
332
|
_token;
|
|
333
333
|
_profile;
|
|
@@ -388,10 +388,19 @@ var App = class {
|
|
|
388
388
|
const res = await this.__revlm.login(cred.email, cred.password);
|
|
389
389
|
console.log("### App:login res:", res);
|
|
390
390
|
if (!res || !res.ok || !res.token) {
|
|
391
|
-
|
|
391
|
+
const errMsg = res && !res.ok ? res.error : "login failed";
|
|
392
|
+
const err = new Error(errMsg);
|
|
393
|
+
const anyRes = res;
|
|
394
|
+
if (anyRes && typeof anyRes === "object") {
|
|
395
|
+
if (anyRes.code !== void 0) err.code = anyRes.code;
|
|
396
|
+
if (anyRes.status !== void 0) err.status = anyRes.status;
|
|
397
|
+
if (anyRes.reason !== void 0) err.reason = anyRes.reason;
|
|
398
|
+
err.response = anyRes;
|
|
399
|
+
}
|
|
400
|
+
throw err;
|
|
392
401
|
}
|
|
393
402
|
this.__revlm.setToken(res.token);
|
|
394
|
-
const user = new
|
|
403
|
+
const user = new RevlmUser(this, res.token, res.user);
|
|
395
404
|
const userId = user.id || "current";
|
|
396
405
|
this._users[userId] = user;
|
|
397
406
|
this._currentUser = user;
|
|
@@ -440,5 +449,5 @@ var BSON = Object.assign({}, bson, { ObjectID: bson.ObjectId });
|
|
|
440
449
|
ObjectId,
|
|
441
450
|
Revlm,
|
|
442
451
|
RevlmDBDatabase,
|
|
443
|
-
|
|
452
|
+
RevlmUser
|
|
444
453
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -284,7 +284,7 @@ var Credentials = class {
|
|
|
284
284
|
return { type: "emailPassword", email, password };
|
|
285
285
|
}
|
|
286
286
|
};
|
|
287
|
-
var
|
|
287
|
+
var RevlmUser = class {
|
|
288
288
|
_app;
|
|
289
289
|
_token;
|
|
290
290
|
_profile;
|
|
@@ -345,10 +345,19 @@ var App = class {
|
|
|
345
345
|
const res = await this.__revlm.login(cred.email, cred.password);
|
|
346
346
|
console.log("### App:login res:", res);
|
|
347
347
|
if (!res || !res.ok || !res.token) {
|
|
348
|
-
|
|
348
|
+
const errMsg = res && !res.ok ? res.error : "login failed";
|
|
349
|
+
const err = new Error(errMsg);
|
|
350
|
+
const anyRes = res;
|
|
351
|
+
if (anyRes && typeof anyRes === "object") {
|
|
352
|
+
if (anyRes.code !== void 0) err.code = anyRes.code;
|
|
353
|
+
if (anyRes.status !== void 0) err.status = anyRes.status;
|
|
354
|
+
if (anyRes.reason !== void 0) err.reason = anyRes.reason;
|
|
355
|
+
err.response = anyRes;
|
|
356
|
+
}
|
|
357
|
+
throw err;
|
|
349
358
|
}
|
|
350
359
|
this.__revlm.setToken(res.token);
|
|
351
|
-
const user = new
|
|
360
|
+
const user = new RevlmUser(this, res.token, res.user);
|
|
352
361
|
const userId = user.id || "current";
|
|
353
362
|
this._users[userId] = user;
|
|
354
363
|
this._currentUser = user;
|
|
@@ -396,5 +405,5 @@ export {
|
|
|
396
405
|
ObjectId2 as ObjectId,
|
|
397
406
|
Revlm,
|
|
398
407
|
RevlmDBDatabase,
|
|
399
|
-
|
|
408
|
+
RevlmUser
|
|
400
409
|
};
|