@kedaruma/revlm-client 1.0.35 → 1.0.39

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,12 +1,8 @@
1
- import { User as User$1, UserBase as UserBase$1 } from '@kedaruma/revlm-shared/models/user-types';
2
1
  import * as bson from 'bson';
3
2
  import { Timestamp, Long } from 'bson';
3
+ import { User as User$1, UserBase as UserBase$1 } from '@kedaruma/revlm-shared/models/user-types';
4
4
 
5
- type ReadonlyExcept<T, K extends keyof T> = {
6
- readonly [P in Exclude<keyof T, K>]: T[P];
7
- } & {
8
- [P in K]: T[P];
9
- };
5
+ type ReadonlyExcept<T, K extends keyof T> = Readonly<Omit<T, K>> & Pick<T, K>;
10
6
  type UserBase = ReadonlyExcept<UserBase$1, "userType" | "roles">;
11
7
  type User = ReadonlyExcept<User$1, "userType" | "roles">;
12
8
  type RevlmErrorResponse = {
@@ -173,8 +169,8 @@ type EmailPasswordCredential = {
173
169
  email: string;
174
170
  password: string;
175
171
  };
176
- type UserInput = Omit<User$1, 'userType'> & {
177
- userType: User$1['userType'] | string;
172
+ type UserInput = Omit<User, 'userType'> & {
173
+ userType: User['userType'] | string;
178
174
  };
179
175
  type RevlmOptions = {
180
176
  fetchImpl?: typeof fetch;
@@ -218,7 +214,7 @@ declare class Revlm {
218
214
  private requestWithRetry;
219
215
  login(authId: string, password: string): Promise<LoginResponse>;
220
216
  provisionalLogin(authId: string): Promise<ProvisionalLoginResponse>;
221
- registerUser(user: UserInput, password: string): Promise<RevlmResponse<any>>;
217
+ registerUser(user: UserInput, password: string): Promise<RegisterUserResponse>;
222
218
  deleteUser(params: {
223
219
  _id?: any;
224
220
  authId?: string;
@@ -242,17 +238,17 @@ declare class RevlmUser {
242
238
  functions: {
243
239
  callFunction: (_name: string, _args?: any[]) => Promise<any>;
244
240
  };
245
- constructor(app: App, token: string, profile: any);
241
+ constructor(app: App, token: string, profile: User);
246
242
  get id(): string;
247
243
  get accessToken(): string;
248
- get profile(): any;
244
+ get profile(): User;
249
245
  mongoClient(_serviceName?: string): MongoDBService;
250
246
  logOut(): Promise<void>;
251
247
  }
252
248
  declare class App {
253
249
  private _currentUser;
254
250
  private _users;
255
- __revlm: Revlm;
251
+ revlm: Revlm;
256
252
  emailPasswordAuth: {
257
253
  registerUser: (email: string, password: string) => Promise<RevlmResponse>;
258
254
  deleteUser: (email: string) => Promise<RevlmResponse>;
package/dist/index.d.ts CHANGED
@@ -1,12 +1,8 @@
1
- import { User as User$1, UserBase as UserBase$1 } from '@kedaruma/revlm-shared/models/user-types';
2
1
  import * as bson from 'bson';
3
2
  import { Timestamp, Long } from 'bson';
3
+ import { User as User$1, UserBase as UserBase$1 } from '@kedaruma/revlm-shared/models/user-types';
4
4
 
5
- type ReadonlyExcept<T, K extends keyof T> = {
6
- readonly [P in Exclude<keyof T, K>]: T[P];
7
- } & {
8
- [P in K]: T[P];
9
- };
5
+ type ReadonlyExcept<T, K extends keyof T> = Readonly<Omit<T, K>> & Pick<T, K>;
10
6
  type UserBase = ReadonlyExcept<UserBase$1, "userType" | "roles">;
11
7
  type User = ReadonlyExcept<User$1, "userType" | "roles">;
12
8
  type RevlmErrorResponse = {
@@ -173,8 +169,8 @@ type EmailPasswordCredential = {
173
169
  email: string;
174
170
  password: string;
175
171
  };
176
- type UserInput = Omit<User$1, 'userType'> & {
177
- userType: User$1['userType'] | string;
172
+ type UserInput = Omit<User, 'userType'> & {
173
+ userType: User['userType'] | string;
178
174
  };
179
175
  type RevlmOptions = {
180
176
  fetchImpl?: typeof fetch;
@@ -218,7 +214,7 @@ declare class Revlm {
218
214
  private requestWithRetry;
219
215
  login(authId: string, password: string): Promise<LoginResponse>;
220
216
  provisionalLogin(authId: string): Promise<ProvisionalLoginResponse>;
221
- registerUser(user: UserInput, password: string): Promise<RevlmResponse<any>>;
217
+ registerUser(user: UserInput, password: string): Promise<RegisterUserResponse>;
222
218
  deleteUser(params: {
223
219
  _id?: any;
224
220
  authId?: string;
@@ -242,17 +238,17 @@ declare class RevlmUser {
242
238
  functions: {
243
239
  callFunction: (_name: string, _args?: any[]) => Promise<any>;
244
240
  };
245
- constructor(app: App, token: string, profile: any);
241
+ constructor(app: App, token: string, profile: User);
246
242
  get id(): string;
247
243
  get accessToken(): string;
248
- get profile(): any;
244
+ get profile(): User;
249
245
  mongoClient(_serviceName?: string): MongoDBService;
250
246
  logOut(): Promise<void>;
251
247
  }
252
248
  declare class App {
253
249
  private _currentUser;
254
250
  private _users;
255
- __revlm: Revlm;
251
+ revlm: Revlm;
256
252
  emailPasswordAuth: {
257
253
  registerUser: (email: string, password: string) => Promise<RevlmResponse>;
258
254
  deleteUser: (email: string) => Promise<RevlmResponse>;
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.35",
3
+ "version": "1.0.39",
4
4
  "private": false,
5
5
  "description": "TypeScript client SDK for talking to the Revlm server replacement for MongoDB Realm.",
6
6
  "keywords": [
@@ -48,7 +48,7 @@
48
48
  "dependencies": {
49
49
  "bson": "^6.10.4",
50
50
  "dotenv": "^17.2.3",
51
- "@kedaruma/revlm-shared": "1.0.7"
51
+ "@kedaruma/revlm-shared": "1.0.8"
52
52
  },
53
53
  "devDependencies": {
54
54
  "tsup": "^8.5.1"