@kedaruma/revlm-client 1.0.4 → 1.0.6
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 +20 -1
- package/dist/index.d.ts +20 -1
- package/dist/index.js +36 -0
- package/dist/index.mjs +32 -0
- package/package.json +10 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Timestamp, Long } from 'bson';
|
|
2
|
+
export { ObjectId as ObjectID, ObjectId } from 'bson';
|
|
2
3
|
import { User as User$1 } from '@kedaruma/revlm-shared/models/user-types';
|
|
3
4
|
|
|
4
5
|
type RevlmErrorResponse = {
|
|
@@ -17,6 +18,16 @@ type ProvisionalLoginSuccess = {
|
|
|
17
18
|
user: Record<string, never>;
|
|
18
19
|
};
|
|
19
20
|
type ProvisionalLoginResponse = ProvisionalLoginSuccess | RevlmErrorResponse;
|
|
21
|
+
type RegisterUserSuccess = {
|
|
22
|
+
ok: true;
|
|
23
|
+
user: User$1;
|
|
24
|
+
};
|
|
25
|
+
type RegisterUserResponse = RegisterUserSuccess | RevlmErrorResponse;
|
|
26
|
+
type DeleteUserSuccess = {
|
|
27
|
+
ok: true;
|
|
28
|
+
deletedCount: number;
|
|
29
|
+
};
|
|
30
|
+
type DeleteUserResponse = DeleteUserSuccess | RevlmErrorResponse;
|
|
20
31
|
type FindOneOptions = {
|
|
21
32
|
readonly projection?: Record<string, unknown>;
|
|
22
33
|
readonly sort?: Record<string, unknown>;
|
|
@@ -210,6 +221,9 @@ declare class User {
|
|
|
210
221
|
private _app;
|
|
211
222
|
private _token;
|
|
212
223
|
private _profile;
|
|
224
|
+
functions: {
|
|
225
|
+
callFunction: (_name: string, _args?: any[]) => Promise<any>;
|
|
226
|
+
};
|
|
213
227
|
constructor(app: App, token: string, profile: any);
|
|
214
228
|
get id(): string;
|
|
215
229
|
get accessToken(): string;
|
|
@@ -221,6 +235,10 @@ declare class App {
|
|
|
221
235
|
private _currentUser;
|
|
222
236
|
private _users;
|
|
223
237
|
__revlm: Revlm;
|
|
238
|
+
emailPasswordAuth: {
|
|
239
|
+
registerUser: (email: string, password: string) => Promise<RevlmResponse>;
|
|
240
|
+
deleteUser: (email: string) => Promise<RevlmResponse>;
|
|
241
|
+
};
|
|
224
242
|
constructor(baseUrl: string, opts?: RevlmOptions & {
|
|
225
243
|
id?: string;
|
|
226
244
|
});
|
|
@@ -230,6 +248,7 @@ declare class App {
|
|
|
230
248
|
switchUser(user: User): User;
|
|
231
249
|
removeUser(user: User): Promise<void>;
|
|
232
250
|
logOut(): Promise<void>;
|
|
251
|
+
deleteUser(user: User): Promise<void>;
|
|
233
252
|
}
|
|
234
253
|
|
|
235
|
-
export { App, Credentials, MongoDBService, Revlm, type RevlmOptions, type RevlmResponse, User };
|
|
254
|
+
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,5 @@
|
|
|
1
1
|
import { Timestamp, Long } from 'bson';
|
|
2
|
+
export { ObjectId as ObjectID, ObjectId } from 'bson';
|
|
2
3
|
import { User as User$1 } from '@kedaruma/revlm-shared/models/user-types';
|
|
3
4
|
|
|
4
5
|
type RevlmErrorResponse = {
|
|
@@ -17,6 +18,16 @@ type ProvisionalLoginSuccess = {
|
|
|
17
18
|
user: Record<string, never>;
|
|
18
19
|
};
|
|
19
20
|
type ProvisionalLoginResponse = ProvisionalLoginSuccess | RevlmErrorResponse;
|
|
21
|
+
type RegisterUserSuccess = {
|
|
22
|
+
ok: true;
|
|
23
|
+
user: User$1;
|
|
24
|
+
};
|
|
25
|
+
type RegisterUserResponse = RegisterUserSuccess | RevlmErrorResponse;
|
|
26
|
+
type DeleteUserSuccess = {
|
|
27
|
+
ok: true;
|
|
28
|
+
deletedCount: number;
|
|
29
|
+
};
|
|
30
|
+
type DeleteUserResponse = DeleteUserSuccess | RevlmErrorResponse;
|
|
20
31
|
type FindOneOptions = {
|
|
21
32
|
readonly projection?: Record<string, unknown>;
|
|
22
33
|
readonly sort?: Record<string, unknown>;
|
|
@@ -210,6 +221,9 @@ declare class User {
|
|
|
210
221
|
private _app;
|
|
211
222
|
private _token;
|
|
212
223
|
private _profile;
|
|
224
|
+
functions: {
|
|
225
|
+
callFunction: (_name: string, _args?: any[]) => Promise<any>;
|
|
226
|
+
};
|
|
213
227
|
constructor(app: App, token: string, profile: any);
|
|
214
228
|
get id(): string;
|
|
215
229
|
get accessToken(): string;
|
|
@@ -221,6 +235,10 @@ declare class App {
|
|
|
221
235
|
private _currentUser;
|
|
222
236
|
private _users;
|
|
223
237
|
__revlm: Revlm;
|
|
238
|
+
emailPasswordAuth: {
|
|
239
|
+
registerUser: (email: string, password: string) => Promise<RevlmResponse>;
|
|
240
|
+
deleteUser: (email: string) => Promise<RevlmResponse>;
|
|
241
|
+
};
|
|
224
242
|
constructor(baseUrl: string, opts?: RevlmOptions & {
|
|
225
243
|
id?: string;
|
|
226
244
|
});
|
|
@@ -230,6 +248,7 @@ declare class App {
|
|
|
230
248
|
switchUser(user: User): User;
|
|
231
249
|
removeUser(user: User): Promise<void>;
|
|
232
250
|
logOut(): Promise<void>;
|
|
251
|
+
deleteUser(user: User): Promise<void>;
|
|
233
252
|
}
|
|
234
253
|
|
|
235
|
-
export { App, Credentials, MongoDBService, Revlm, type RevlmOptions, type RevlmResponse, User };
|
|
254
|
+
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
|
@@ -22,8 +22,12 @@ var index_exports = {};
|
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
App: () => App,
|
|
24
24
|
Credentials: () => Credentials,
|
|
25
|
+
MdbCollection: () => MdbCollection,
|
|
25
26
|
MongoDBService: () => MongoDBService,
|
|
27
|
+
ObjectID: () => import_bson2.ObjectId,
|
|
28
|
+
ObjectId: () => import_bson2.ObjectId,
|
|
26
29
|
Revlm: () => Revlm,
|
|
30
|
+
RevlmDBDatabase: () => RevlmDBDatabase,
|
|
27
31
|
User: () => User
|
|
28
32
|
});
|
|
29
33
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -231,6 +235,9 @@ var Revlm = class {
|
|
|
231
235
|
const parsed = await this.parseResponse(res);
|
|
232
236
|
const out = parsed && typeof parsed === "object" ? parsed : { ok: res.ok, result: parsed };
|
|
233
237
|
out.status = res.status;
|
|
238
|
+
if (out && out.ok === false && !out.error) {
|
|
239
|
+
out.error = parsed?.reason || parsed?.message || "Unknown error";
|
|
240
|
+
}
|
|
234
241
|
return out;
|
|
235
242
|
} catch (err) {
|
|
236
243
|
return { ok: false, error: err?.message || String(err) };
|
|
@@ -293,10 +300,16 @@ var User = class {
|
|
|
293
300
|
_app;
|
|
294
301
|
_token;
|
|
295
302
|
_profile;
|
|
303
|
+
functions;
|
|
296
304
|
constructor(app, token, profile) {
|
|
297
305
|
this._app = app;
|
|
298
306
|
this._token = token;
|
|
299
307
|
this._profile = profile || {};
|
|
308
|
+
this.functions = {
|
|
309
|
+
callFunction: async (_name, _args) => {
|
|
310
|
+
throw new Error("user.functions.callFunction is not implemented in Revlm client");
|
|
311
|
+
}
|
|
312
|
+
};
|
|
300
313
|
}
|
|
301
314
|
get id() {
|
|
302
315
|
return String(this._profile && this._profile._id ? this._profile._id : "");
|
|
@@ -319,8 +332,17 @@ var App = class {
|
|
|
319
332
|
_users = {};
|
|
320
333
|
// Expose for internal use by emulated classes
|
|
321
334
|
__revlm;
|
|
335
|
+
emailPasswordAuth;
|
|
322
336
|
constructor(baseUrl, opts = {}) {
|
|
323
337
|
this.__revlm = new Revlm(baseUrl, opts);
|
|
338
|
+
this.emailPasswordAuth = {
|
|
339
|
+
registerUser: async (email, password) => {
|
|
340
|
+
return this.__revlm.registerUser({ authId: email, userType: "user", roles: [] }, password);
|
|
341
|
+
},
|
|
342
|
+
deleteUser: async (email) => {
|
|
343
|
+
return this.__revlm.deleteUser({ authId: email });
|
|
344
|
+
}
|
|
345
|
+
};
|
|
324
346
|
}
|
|
325
347
|
get currentUser() {
|
|
326
348
|
return this._currentUser;
|
|
@@ -362,12 +384,26 @@ var App = class {
|
|
|
362
384
|
this.__revlm.logout();
|
|
363
385
|
this._currentUser = null;
|
|
364
386
|
}
|
|
387
|
+
// Realm compatibility: allow deleteUser(user) pattern
|
|
388
|
+
async deleteUser(user) {
|
|
389
|
+
if (!user) return;
|
|
390
|
+
const authId = user.profile && user.profile.authId || user.id;
|
|
391
|
+
await this.__revlm.deleteUser({ authId });
|
|
392
|
+
await this.removeUser(user);
|
|
393
|
+
}
|
|
365
394
|
};
|
|
395
|
+
|
|
396
|
+
// src/index.ts
|
|
397
|
+
var import_bson2 = require("bson");
|
|
366
398
|
// Annotate the CommonJS export names for ESM import in node:
|
|
367
399
|
0 && (module.exports = {
|
|
368
400
|
App,
|
|
369
401
|
Credentials,
|
|
402
|
+
MdbCollection,
|
|
370
403
|
MongoDBService,
|
|
404
|
+
ObjectID,
|
|
405
|
+
ObjectId,
|
|
371
406
|
Revlm,
|
|
407
|
+
RevlmDBDatabase,
|
|
372
408
|
User
|
|
373
409
|
});
|
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,25 @@ 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";
|
|
336
364
|
export {
|
|
337
365
|
App,
|
|
338
366
|
Credentials,
|
|
367
|
+
MdbCollection,
|
|
339
368
|
MongoDBService,
|
|
369
|
+
ObjectId2 as ObjectID,
|
|
370
|
+
ObjectId,
|
|
340
371
|
Revlm,
|
|
372
|
+
RevlmDBDatabase,
|
|
341
373
|
User
|
|
342
374
|
};
|
package/package.json
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kedaruma/revlm-client",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "TypeScript client SDK for talking to the Revlm server replacement for MongoDB Realm.",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"realm",
|
|
8
|
+
"realm-web",
|
|
9
|
+
"mongodb-realm",
|
|
10
|
+
"mongodb",
|
|
11
|
+
"realm-alternative",
|
|
12
|
+
"app-services",
|
|
13
|
+
"auth"
|
|
14
|
+
],
|
|
6
15
|
"main": "dist/index.js",
|
|
7
16
|
"module": "dist/index.mjs",
|
|
8
17
|
"types": "dist/index.d.ts",
|