@kedaruma/revlm-client 1.0.34 → 1.0.38

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 CHANGED
@@ -1,8 +1,10 @@
1
- import { User } from '@kedaruma/revlm-shared/models/user-types';
2
- export { User, UserBase } from '@kedaruma/revlm-shared/models/user-types';
3
1
  import * as bson from 'bson';
4
2
  import { Timestamp, Long } from 'bson';
3
+ import { User as User$1, UserBase as UserBase$1 } from '@kedaruma/revlm-shared/models/user-types';
5
4
 
5
+ type ReadonlyExcept<T, K extends keyof T> = Readonly<Omit<T, K>> & Pick<T, K>;
6
+ type UserBase = ReadonlyExcept<UserBase$1, "userType" | "roles">;
7
+ type User = ReadonlyExcept<User$1, "userType" | "roles">;
6
8
  type RevlmErrorResponse = {
7
9
  ok: false;
8
10
  error: string;
@@ -212,7 +214,7 @@ declare class Revlm {
212
214
  private requestWithRetry;
213
215
  login(authId: string, password: string): Promise<LoginResponse>;
214
216
  provisionalLogin(authId: string): Promise<ProvisionalLoginResponse>;
215
- registerUser(user: UserInput, password: string): Promise<RevlmResponse<any>>;
217
+ registerUser(user: UserInput, password: string): Promise<RegisterUserResponse>;
216
218
  deleteUser(params: {
217
219
  _id?: any;
218
220
  authId?: string;
@@ -236,17 +238,17 @@ declare class RevlmUser {
236
238
  functions: {
237
239
  callFunction: (_name: string, _args?: any[]) => Promise<any>;
238
240
  };
239
- constructor(app: App, token: string, profile: any);
241
+ constructor(app: App, token: string, profile: User);
240
242
  get id(): string;
241
243
  get accessToken(): string;
242
- get profile(): any;
244
+ get profile(): User;
243
245
  mongoClient(_serviceName?: string): MongoDBService;
244
246
  logOut(): Promise<void>;
245
247
  }
246
248
  declare class App {
247
249
  private _currentUser;
248
250
  private _users;
249
- __revlm: Revlm;
251
+ revlm: Revlm;
250
252
  emailPasswordAuth: {
251
253
  registerUser: (email: string, password: string) => Promise<RevlmResponse>;
252
254
  deleteUser: (email: string) => Promise<RevlmResponse>;
@@ -269,4 +271,4 @@ declare const BSON: typeof bson & {
269
271
  ObjectID: typeof bson.ObjectId;
270
272
  };
271
273
 
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 };
274
+ 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 User, type UserBase, type WatchOptionsFilter, type WatchOptionsIds };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,10 @@
1
- import { User } from '@kedaruma/revlm-shared/models/user-types';
2
- export { User, UserBase } from '@kedaruma/revlm-shared/models/user-types';
3
1
  import * as bson from 'bson';
4
2
  import { Timestamp, Long } from 'bson';
3
+ import { User as User$1, UserBase as UserBase$1 } from '@kedaruma/revlm-shared/models/user-types';
5
4
 
5
+ type ReadonlyExcept<T, K extends keyof T> = Readonly<Omit<T, K>> & Pick<T, K>;
6
+ type UserBase = ReadonlyExcept<UserBase$1, "userType" | "roles">;
7
+ type User = ReadonlyExcept<User$1, "userType" | "roles">;
6
8
  type RevlmErrorResponse = {
7
9
  ok: false;
8
10
  error: string;
@@ -212,7 +214,7 @@ declare class Revlm {
212
214
  private requestWithRetry;
213
215
  login(authId: string, password: string): Promise<LoginResponse>;
214
216
  provisionalLogin(authId: string): Promise<ProvisionalLoginResponse>;
215
- registerUser(user: UserInput, password: string): Promise<RevlmResponse<any>>;
217
+ registerUser(user: UserInput, password: string): Promise<RegisterUserResponse>;
216
218
  deleteUser(params: {
217
219
  _id?: any;
218
220
  authId?: string;
@@ -236,17 +238,17 @@ declare class RevlmUser {
236
238
  functions: {
237
239
  callFunction: (_name: string, _args?: any[]) => Promise<any>;
238
240
  };
239
- constructor(app: App, token: string, profile: any);
241
+ constructor(app: App, token: string, profile: User);
240
242
  get id(): string;
241
243
  get accessToken(): string;
242
- get profile(): any;
244
+ get profile(): User;
243
245
  mongoClient(_serviceName?: string): MongoDBService;
244
246
  logOut(): Promise<void>;
245
247
  }
246
248
  declare class App {
247
249
  private _currentUser;
248
250
  private _users;
249
- __revlm: Revlm;
251
+ revlm: Revlm;
250
252
  emailPasswordAuth: {
251
253
  registerUser: (email: string, password: string) => Promise<RevlmResponse>;
252
254
  deleteUser: (email: string) => Promise<RevlmResponse>;
@@ -269,4 +271,4 @@ declare const BSON: typeof bson & {
269
271
  ObjectID: typeof bson.ObjectId;
270
272
  };
271
273
 
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 };
274
+ 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 User, type UserBase, type WatchOptionsFilter, type WatchOptionsIds };
package/dist/index.js CHANGED
@@ -298,7 +298,8 @@ var Revlm = class {
298
298
  async registerUser(user, password) {
299
299
  if (!user) throw new Error("user is required");
300
300
  if (!password) throw new Error("password is required");
301
- return this.request("/registerUser", "POST", { user, password });
301
+ const res = await this.request("/registerUser", "POST", { user, password });
302
+ return res;
302
303
  }
303
304
  async deleteUser(params) {
304
305
  if (!params || !params._id && !params.authId) throw new Error("Either _id or authId must be provided");
@@ -352,7 +353,7 @@ var RevlmUser = class {
352
353
  return this._profile;
353
354
  }
354
355
  mongoClient(_serviceName = "mongodb-atlas") {
355
- return new MongoDBService(this._app.__revlm);
356
+ return new MongoDBService(this._app.revlm);
356
357
  }
357
358
  async logOut() {
358
359
  await this._app.logOut();
@@ -361,17 +362,16 @@ var RevlmUser = class {
361
362
  var App = class {
362
363
  _currentUser = null;
363
364
  _users = {};
364
- // Expose for internal use by emulated classes
365
- __revlm;
365
+ revlm;
366
366
  emailPasswordAuth;
367
367
  constructor(baseUrl, opts = {}) {
368
- this.__revlm = new Revlm(baseUrl, opts);
368
+ this.revlm = new Revlm(baseUrl, opts);
369
369
  this.emailPasswordAuth = {
370
370
  registerUser: async (email, password) => {
371
- return this.__revlm.registerUser({ authId: email, userType: "user", roles: ["user"] }, password);
371
+ return this.revlm.registerUser({ authId: email, userType: "user", roles: ["user"] }, password);
372
372
  },
373
373
  deleteUser: async (email) => {
374
- return this.__revlm.deleteUser({ authId: email });
374
+ return this.revlm.deleteUser({ authId: email });
375
375
  }
376
376
  };
377
377
  }
@@ -385,7 +385,7 @@ var App = class {
385
385
  if (!cred || cred.type !== "emailPassword") {
386
386
  throw new Error("Unsupported credentials type");
387
387
  }
388
- const res = await this.__revlm.login(cred.email, cred.password);
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";
@@ -399,7 +399,7 @@ var App = class {
399
399
  }
400
400
  throw err;
401
401
  }
402
- this.__revlm.setToken(res.token);
402
+ this.revlm.setToken(res.token);
403
403
  const user = new RevlmUser(this, res.token, res.user);
404
404
  const userId = user.id || "current";
405
405
  this._users[userId] = user;
@@ -409,7 +409,7 @@ var App = class {
409
409
  switchUser(user) {
410
410
  if (!user) throw new Error("user is required");
411
411
  this._currentUser = user;
412
- this.__revlm.setToken(user.accessToken);
412
+ this.revlm.setToken(user.accessToken);
413
413
  return user;
414
414
  }
415
415
  async removeUser(user) {
@@ -421,14 +421,14 @@ var App = class {
421
421
  }
422
422
  }
423
423
  async logOut() {
424
- this.__revlm.logout();
424
+ this.revlm.logout();
425
425
  this._currentUser = null;
426
426
  }
427
427
  // Realm compatibility: allow deleteUser(user) pattern
428
428
  async deleteUser(user) {
429
429
  if (!user) return;
430
430
  const authId = user.profile && user.profile.authId || user.id;
431
- await this.__revlm.deleteUser({ authId });
431
+ await this.revlm.deleteUser({ authId });
432
432
  await this.removeUser(user);
433
433
  }
434
434
  };
package/dist/index.mjs CHANGED
@@ -255,7 +255,8 @@ var Revlm = class {
255
255
  async registerUser(user, password) {
256
256
  if (!user) throw new Error("user is required");
257
257
  if (!password) throw new Error("password is required");
258
- return this.request("/registerUser", "POST", { user, password });
258
+ const res = await this.request("/registerUser", "POST", { user, password });
259
+ return res;
259
260
  }
260
261
  async deleteUser(params) {
261
262
  if (!params || !params._id && !params.authId) throw new Error("Either _id or authId must be provided");
@@ -309,7 +310,7 @@ var RevlmUser = class {
309
310
  return this._profile;
310
311
  }
311
312
  mongoClient(_serviceName = "mongodb-atlas") {
312
- return new MongoDBService(this._app.__revlm);
313
+ return new MongoDBService(this._app.revlm);
313
314
  }
314
315
  async logOut() {
315
316
  await this._app.logOut();
@@ -318,17 +319,16 @@ var RevlmUser = class {
318
319
  var App = class {
319
320
  _currentUser = null;
320
321
  _users = {};
321
- // Expose for internal use by emulated classes
322
- __revlm;
322
+ revlm;
323
323
  emailPasswordAuth;
324
324
  constructor(baseUrl, opts = {}) {
325
- this.__revlm = new Revlm(baseUrl, opts);
325
+ this.revlm = new Revlm(baseUrl, opts);
326
326
  this.emailPasswordAuth = {
327
327
  registerUser: async (email, password) => {
328
- return this.__revlm.registerUser({ authId: email, userType: "user", roles: ["user"] }, password);
328
+ return this.revlm.registerUser({ authId: email, userType: "user", roles: ["user"] }, password);
329
329
  },
330
330
  deleteUser: async (email) => {
331
- return this.__revlm.deleteUser({ authId: email });
331
+ return this.revlm.deleteUser({ authId: email });
332
332
  }
333
333
  };
334
334
  }
@@ -342,7 +342,7 @@ var App = class {
342
342
  if (!cred || cred.type !== "emailPassword") {
343
343
  throw new Error("Unsupported credentials type");
344
344
  }
345
- const res = await this.__revlm.login(cred.email, cred.password);
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";
@@ -356,7 +356,7 @@ var App = class {
356
356
  }
357
357
  throw err;
358
358
  }
359
- this.__revlm.setToken(res.token);
359
+ this.revlm.setToken(res.token);
360
360
  const user = new RevlmUser(this, res.token, res.user);
361
361
  const userId = user.id || "current";
362
362
  this._users[userId] = user;
@@ -366,7 +366,7 @@ var App = class {
366
366
  switchUser(user) {
367
367
  if (!user) throw new Error("user is required");
368
368
  this._currentUser = user;
369
- this.__revlm.setToken(user.accessToken);
369
+ this.revlm.setToken(user.accessToken);
370
370
  return user;
371
371
  }
372
372
  async removeUser(user) {
@@ -378,14 +378,14 @@ var App = class {
378
378
  }
379
379
  }
380
380
  async logOut() {
381
- this.__revlm.logout();
381
+ this.revlm.logout();
382
382
  this._currentUser = null;
383
383
  }
384
384
  // Realm compatibility: allow deleteUser(user) pattern
385
385
  async deleteUser(user) {
386
386
  if (!user) return;
387
387
  const authId = user.profile && user.profile.authId || user.id;
388
- await this.__revlm.deleteUser({ authId });
388
+ await this.revlm.deleteUser({ authId });
389
389
  await this.removeUser(user);
390
390
  }
391
391
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kedaruma/revlm-client",
3
- "version": "1.0.34",
3
+ "version": "1.0.38",
4
4
  "private": false,
5
5
  "description": "TypeScript client SDK for talking to the Revlm server replacement for MongoDB Realm.",
6
6
  "keywords": [