@kedaruma/revlm-client 1.0.5 → 1.0.8

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,4 +1,7 @@
1
1
  import { Timestamp, Long } from 'bson';
2
+ import * as bson from 'bson';
3
+ export { bson as BSON };
4
+ export { ObjectId as ObjectID, ObjectId } from 'bson';
2
5
  import { User as User$1 } from '@kedaruma/revlm-shared/models/user-types';
3
6
 
4
7
  type RevlmErrorResponse = {
@@ -17,6 +20,16 @@ type ProvisionalLoginSuccess = {
17
20
  user: Record<string, never>;
18
21
  };
19
22
  type ProvisionalLoginResponse = ProvisionalLoginSuccess | RevlmErrorResponse;
23
+ type RegisterUserSuccess = {
24
+ ok: true;
25
+ user: User$1;
26
+ };
27
+ type RegisterUserResponse = RegisterUserSuccess | RevlmErrorResponse;
28
+ type DeleteUserSuccess = {
29
+ ok: true;
30
+ deletedCount: number;
31
+ };
32
+ type DeleteUserResponse = DeleteUserSuccess | RevlmErrorResponse;
20
33
  type FindOneOptions = {
21
34
  readonly projection?: Record<string, unknown>;
22
35
  readonly sort?: Record<string, unknown>;
@@ -210,6 +223,9 @@ declare class User {
210
223
  private _app;
211
224
  private _token;
212
225
  private _profile;
226
+ functions: {
227
+ callFunction: (_name: string, _args?: any[]) => Promise<any>;
228
+ };
213
229
  constructor(app: App, token: string, profile: any);
214
230
  get id(): string;
215
231
  get accessToken(): string;
@@ -221,6 +237,10 @@ declare class App {
221
237
  private _currentUser;
222
238
  private _users;
223
239
  __revlm: Revlm;
240
+ emailPasswordAuth: {
241
+ registerUser: (email: string, password: string) => Promise<RevlmResponse>;
242
+ deleteUser: (email: string) => Promise<RevlmResponse>;
243
+ };
224
244
  constructor(baseUrl: string, opts?: RevlmOptions & {
225
245
  id?: string;
226
246
  });
@@ -230,6 +250,7 @@ declare class App {
230
250
  switchUser(user: User): User;
231
251
  removeUser(user: User): Promise<void>;
232
252
  logOut(): Promise<void>;
253
+ deleteUser(user: User): Promise<void>;
233
254
  }
234
255
 
235
- export { App, Credentials, MongoDBService, Revlm, type RevlmOptions, type RevlmResponse, User };
256
+ export { type AggregatePipelineStage, App, 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, 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, User, type WatchOptionsFilter, type WatchOptionsIds };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,7 @@
1
1
  import { Timestamp, Long } from 'bson';
2
+ import * as bson from 'bson';
3
+ export { bson as BSON };
4
+ export { ObjectId as ObjectID, ObjectId } from 'bson';
2
5
  import { User as User$1 } from '@kedaruma/revlm-shared/models/user-types';
3
6
 
4
7
  type RevlmErrorResponse = {
@@ -17,6 +20,16 @@ type ProvisionalLoginSuccess = {
17
20
  user: Record<string, never>;
18
21
  };
19
22
  type ProvisionalLoginResponse = ProvisionalLoginSuccess | RevlmErrorResponse;
23
+ type RegisterUserSuccess = {
24
+ ok: true;
25
+ user: User$1;
26
+ };
27
+ type RegisterUserResponse = RegisterUserSuccess | RevlmErrorResponse;
28
+ type DeleteUserSuccess = {
29
+ ok: true;
30
+ deletedCount: number;
31
+ };
32
+ type DeleteUserResponse = DeleteUserSuccess | RevlmErrorResponse;
20
33
  type FindOneOptions = {
21
34
  readonly projection?: Record<string, unknown>;
22
35
  readonly sort?: Record<string, unknown>;
@@ -210,6 +223,9 @@ declare class User {
210
223
  private _app;
211
224
  private _token;
212
225
  private _profile;
226
+ functions: {
227
+ callFunction: (_name: string, _args?: any[]) => Promise<any>;
228
+ };
213
229
  constructor(app: App, token: string, profile: any);
214
230
  get id(): string;
215
231
  get accessToken(): string;
@@ -221,6 +237,10 @@ declare class App {
221
237
  private _currentUser;
222
238
  private _users;
223
239
  __revlm: Revlm;
240
+ emailPasswordAuth: {
241
+ registerUser: (email: string, password: string) => Promise<RevlmResponse>;
242
+ deleteUser: (email: string) => Promise<RevlmResponse>;
243
+ };
224
244
  constructor(baseUrl: string, opts?: RevlmOptions & {
225
245
  id?: string;
226
246
  });
@@ -230,6 +250,7 @@ declare class App {
230
250
  switchUser(user: User): User;
231
251
  removeUser(user: User): Promise<void>;
232
252
  logOut(): Promise<void>;
253
+ deleteUser(user: User): Promise<void>;
233
254
  }
234
255
 
235
- export { App, Credentials, MongoDBService, Revlm, type RevlmOptions, type RevlmResponse, User };
256
+ export { type AggregatePipelineStage, App, 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, 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, User, type WatchOptionsFilter, type WatchOptionsIds };
package/dist/index.js CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,15 +17,28 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
 
20
30
  // src/index.ts
21
31
  var index_exports = {};
22
32
  __export(index_exports, {
23
33
  App: () => App,
34
+ BSON: () => BSON,
24
35
  Credentials: () => Credentials,
36
+ MdbCollection: () => MdbCollection,
25
37
  MongoDBService: () => MongoDBService,
38
+ ObjectID: () => import_bson2.ObjectId,
39
+ ObjectId: () => import_bson2.ObjectId,
26
40
  Revlm: () => Revlm,
41
+ RevlmDBDatabase: () => RevlmDBDatabase,
27
42
  User: () => User
28
43
  });
29
44
  module.exports = __toCommonJS(index_exports);
@@ -231,6 +246,9 @@ var Revlm = class {
231
246
  const parsed = await this.parseResponse(res);
232
247
  const out = parsed && typeof parsed === "object" ? parsed : { ok: res.ok, result: parsed };
233
248
  out.status = res.status;
249
+ if (out && out.ok === false && !out.error) {
250
+ out.error = parsed?.reason || parsed?.message || "Unknown error";
251
+ }
234
252
  return out;
235
253
  } catch (err) {
236
254
  return { ok: false, error: err?.message || String(err) };
@@ -293,10 +311,16 @@ var User = class {
293
311
  _app;
294
312
  _token;
295
313
  _profile;
314
+ functions;
296
315
  constructor(app, token, profile) {
297
316
  this._app = app;
298
317
  this._token = token;
299
318
  this._profile = profile || {};
319
+ this.functions = {
320
+ callFunction: async (_name, _args) => {
321
+ throw new Error("user.functions.callFunction is not implemented in Revlm client");
322
+ }
323
+ };
300
324
  }
301
325
  get id() {
302
326
  return String(this._profile && this._profile._id ? this._profile._id : "");
@@ -319,8 +343,17 @@ var App = class {
319
343
  _users = {};
320
344
  // Expose for internal use by emulated classes
321
345
  __revlm;
346
+ emailPasswordAuth;
322
347
  constructor(baseUrl, opts = {}) {
323
348
  this.__revlm = new Revlm(baseUrl, opts);
349
+ this.emailPasswordAuth = {
350
+ registerUser: async (email, password) => {
351
+ return this.__revlm.registerUser({ authId: email, userType: "user", roles: [] }, password);
352
+ },
353
+ deleteUser: async (email) => {
354
+ return this.__revlm.deleteUser({ authId: email });
355
+ }
356
+ };
324
357
  }
325
358
  get currentUser() {
326
359
  return this._currentUser;
@@ -362,12 +395,28 @@ var App = class {
362
395
  this.__revlm.logout();
363
396
  this._currentUser = null;
364
397
  }
398
+ // Realm compatibility: allow deleteUser(user) pattern
399
+ async deleteUser(user) {
400
+ if (!user) return;
401
+ const authId = user.profile && user.profile.authId || user.id;
402
+ await this.__revlm.deleteUser({ authId });
403
+ await this.removeUser(user);
404
+ }
365
405
  };
406
+
407
+ // src/index.ts
408
+ var import_bson2 = require("bson");
409
+ var BSON = __toESM(require("bson"));
366
410
  // Annotate the CommonJS export names for ESM import in node:
367
411
  0 && (module.exports = {
368
412
  App,
413
+ BSON,
369
414
  Credentials,
415
+ MdbCollection,
370
416
  MongoDBService,
417
+ ObjectID,
418
+ ObjectId,
371
419
  Revlm,
420
+ RevlmDBDatabase,
372
421
  User
373
422
  });
package/dist/index.mjs CHANGED
@@ -201,6 +201,9 @@ var Revlm = class {
201
201
  const parsed = await this.parseResponse(res);
202
202
  const out = parsed && typeof parsed === "object" ? parsed : { ok: res.ok, result: parsed };
203
203
  out.status = res.status;
204
+ if (out && out.ok === false && !out.error) {
205
+ out.error = parsed?.reason || parsed?.message || "Unknown error";
206
+ }
204
207
  return out;
205
208
  } catch (err) {
206
209
  return { ok: false, error: err?.message || String(err) };
@@ -263,10 +266,16 @@ var User = class {
263
266
  _app;
264
267
  _token;
265
268
  _profile;
269
+ functions;
266
270
  constructor(app, token, profile) {
267
271
  this._app = app;
268
272
  this._token = token;
269
273
  this._profile = profile || {};
274
+ this.functions = {
275
+ callFunction: async (_name, _args) => {
276
+ throw new Error("user.functions.callFunction is not implemented in Revlm client");
277
+ }
278
+ };
270
279
  }
271
280
  get id() {
272
281
  return String(this._profile && this._profile._id ? this._profile._id : "");
@@ -289,8 +298,17 @@ var App = class {
289
298
  _users = {};
290
299
  // Expose for internal use by emulated classes
291
300
  __revlm;
301
+ emailPasswordAuth;
292
302
  constructor(baseUrl, opts = {}) {
293
303
  this.__revlm = new Revlm(baseUrl, opts);
304
+ this.emailPasswordAuth = {
305
+ registerUser: async (email, password) => {
306
+ return this.__revlm.registerUser({ authId: email, userType: "user", roles: [] }, password);
307
+ },
308
+ deleteUser: async (email) => {
309
+ return this.__revlm.deleteUser({ authId: email });
310
+ }
311
+ };
294
312
  }
295
313
  get currentUser() {
296
314
  return this._currentUser;
@@ -332,11 +350,27 @@ var App = class {
332
350
  this.__revlm.logout();
333
351
  this._currentUser = null;
334
352
  }
353
+ // Realm compatibility: allow deleteUser(user) pattern
354
+ async deleteUser(user) {
355
+ if (!user) return;
356
+ const authId = user.profile && user.profile.authId || user.id;
357
+ await this.__revlm.deleteUser({ authId });
358
+ await this.removeUser(user);
359
+ }
335
360
  };
361
+
362
+ // src/index.ts
363
+ import { ObjectId, ObjectId as ObjectId2 } from "bson";
364
+ import * as BSON from "bson";
336
365
  export {
337
366
  App,
367
+ BSON,
338
368
  Credentials,
369
+ MdbCollection,
339
370
  MongoDBService,
371
+ ObjectId2 as ObjectID,
372
+ ObjectId,
340
373
  Revlm,
374
+ RevlmDBDatabase,
341
375
  User
342
376
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kedaruma/revlm-client",
3
- "version": "1.0.5",
3
+ "version": "1.0.8",
4
4
  "private": false,
5
5
  "description": "TypeScript client SDK for talking to the Revlm server replacement for MongoDB Realm.",
6
6
  "keywords": [