edmaxlabs-core 2.6.9 → 2.7.1
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.cjs +57 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +57 -20
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -194,6 +194,7 @@ var _Authentication = class _Authentication {
|
|
|
194
194
|
op: "===",
|
|
195
195
|
value: password
|
|
196
196
|
}).get();
|
|
197
|
+
console.log("Auth Data:", data);
|
|
197
198
|
if (data === void 0) {
|
|
198
199
|
throw new Error("Auth Failed.");
|
|
199
200
|
}
|
|
@@ -267,7 +268,7 @@ var _Authentication = class _Authentication {
|
|
|
267
268
|
this.client = EdmaxLabs.instance;
|
|
268
269
|
this.app = new EdmaxLabs({
|
|
269
270
|
token: "auth",
|
|
270
|
-
project: "
|
|
271
|
+
project: "698457c2f7448550b9e166c4"
|
|
271
272
|
});
|
|
272
273
|
_Authentication.instance = this;
|
|
273
274
|
this.restoreSession();
|
|
@@ -460,7 +461,8 @@ var DocumentRef = class {
|
|
|
460
461
|
endpoint: `${this.app.getBaseUrl()}/db/update`,
|
|
461
462
|
headers: {
|
|
462
463
|
authorization: this.app.getConfig().token,
|
|
463
|
-
"x-project": this.app.getConfig().project
|
|
464
|
+
"x-project": this.app.getConfig().project,
|
|
465
|
+
"x-user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap())
|
|
464
466
|
},
|
|
465
467
|
body: { collection: this.collection, id: this.id, data }
|
|
466
468
|
}).sendRequest();
|
|
@@ -506,7 +508,8 @@ var DocumentRef = class {
|
|
|
506
508
|
endpoint: `${this.app.getBaseUrl()}/db/create`,
|
|
507
509
|
headers: {
|
|
508
510
|
authorization: this.app.getConfig().token,
|
|
509
|
-
"x-project": this.app.getConfig().project
|
|
511
|
+
"x-project": this.app.getConfig().project,
|
|
512
|
+
"x-user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap())
|
|
510
513
|
},
|
|
511
514
|
body: { collection: this.collection, data: { ...data, id: this.id } }
|
|
512
515
|
}).sendRequest();
|
|
@@ -562,7 +565,8 @@ var DocumentRef = class {
|
|
|
562
565
|
endpoint: `${this.app.getBaseUrl()}/db/delete`,
|
|
563
566
|
headers: {
|
|
564
567
|
authorization: this.app.getConfig().token,
|
|
565
|
-
"x-project": this.app.getConfig().project
|
|
568
|
+
"x-project": this.app.getConfig().project,
|
|
569
|
+
"x-user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap())
|
|
566
570
|
},
|
|
567
571
|
body: { collection: this.collection, id: this.id }
|
|
568
572
|
}).sendRequest();
|
|
@@ -595,7 +599,8 @@ var DocumentRef = class {
|
|
|
595
599
|
endpoint: `${this.app.getBaseUrl()}/db/read`,
|
|
596
600
|
headers: {
|
|
597
601
|
authorization: this.app.getConfig().token,
|
|
598
|
-
"x-project": this.app.getConfig().project
|
|
602
|
+
"x-project": this.app.getConfig().project,
|
|
603
|
+
"x-user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap())
|
|
599
604
|
},
|
|
600
605
|
body: {
|
|
601
606
|
collection: this.collection,
|
|
@@ -733,7 +738,7 @@ var Query = class {
|
|
|
733
738
|
return new HttpsRequest({
|
|
734
739
|
method: "POST" /* POST */,
|
|
735
740
|
endpoint: `${this.app.getBaseUrl()}/db/update`,
|
|
736
|
-
headers: { authorization: this.app.getConfig().token, "x-project": this.app.getConfig().project },
|
|
741
|
+
headers: { authorization: this.app.getConfig().token, "x-project": this.app.getConfig().project, "x-user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap()) },
|
|
737
742
|
body: {
|
|
738
743
|
collection: this.collection,
|
|
739
744
|
filter: genfilter,
|
|
@@ -873,7 +878,11 @@ var Query = class {
|
|
|
873
878
|
const res = await new HttpsRequest({
|
|
874
879
|
method: "POST" /* POST */,
|
|
875
880
|
endpoint: `${this.app.getBaseUrl()}/db/read`,
|
|
876
|
-
headers: {
|
|
881
|
+
headers: {
|
|
882
|
+
authorization: this.app.getConfig().token,
|
|
883
|
+
"x-project": this.app.getConfig().project,
|
|
884
|
+
"x-user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap())
|
|
885
|
+
},
|
|
877
886
|
body: {
|
|
878
887
|
collection: this.collection,
|
|
879
888
|
filter: genfilter
|
|
@@ -976,6 +985,7 @@ var socketURI = "https://api.edmaxlabs.com";
|
|
|
976
985
|
var CollectionRef = class {
|
|
977
986
|
constructor(app, collection) {
|
|
978
987
|
this.app = app;
|
|
988
|
+
this.authentication = app.getAuthentication;
|
|
979
989
|
this.collection = collection;
|
|
980
990
|
this.persistence = app.offline().persistence;
|
|
981
991
|
this.syncEngine = app.offline().syncEngine;
|
|
@@ -1028,9 +1038,13 @@ var CollectionRef = class {
|
|
|
1028
1038
|
endpoint: `${this.app.getBaseUrl()}/db/create`,
|
|
1029
1039
|
headers: {
|
|
1030
1040
|
authorization: this.app.getConfig().token,
|
|
1031
|
-
"x-project": this.app.getConfig().project
|
|
1041
|
+
"x-project": this.app.getConfig().project,
|
|
1042
|
+
user: JSON.stringify(this.authentication.currentUser()?.toMap())
|
|
1032
1043
|
},
|
|
1033
|
-
body: {
|
|
1044
|
+
body: {
|
|
1045
|
+
collection: this.collection,
|
|
1046
|
+
data: { ...data, id: "" }
|
|
1047
|
+
}
|
|
1034
1048
|
}).sendRequest();
|
|
1035
1049
|
if (!res?.success || !res.document)
|
|
1036
1050
|
return null;
|
|
@@ -1085,7 +1099,9 @@ var CollectionRef = class {
|
|
|
1085
1099
|
endpoint: `${serverURI}/db/read`,
|
|
1086
1100
|
headers: {
|
|
1087
1101
|
authorization: this.app.getConfig().token,
|
|
1088
|
-
"x-project": this.app.getConfig().project
|
|
1102
|
+
"x-project": this.app.getConfig().project,
|
|
1103
|
+
user: JSON.stringify(this.authentication.currentUser()?.toMap()),
|
|
1104
|
+
"x-user": JSON.stringify(this.authentication.currentUser()?.toMap())
|
|
1089
1105
|
},
|
|
1090
1106
|
body: {
|
|
1091
1107
|
collection: this.collection,
|
|
@@ -1120,7 +1136,9 @@ var CollectionRef = class {
|
|
|
1120
1136
|
endpoint: `${serverURI}/db/read`,
|
|
1121
1137
|
headers: {
|
|
1122
1138
|
authorization: this.app.getConfig().token,
|
|
1123
|
-
"x-project": this.app.getConfig().project
|
|
1139
|
+
"x-project": this.app.getConfig().project,
|
|
1140
|
+
user: JSON.stringify(this.authentication.currentUser()?.toMap()),
|
|
1141
|
+
"x-user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap())
|
|
1124
1142
|
},
|
|
1125
1143
|
body: {
|
|
1126
1144
|
collection: this.collection,
|
|
@@ -1292,7 +1310,11 @@ var Batch = class {
|
|
|
1292
1310
|
const res = await new HttpsRequest({
|
|
1293
1311
|
method: "POST" /* POST */,
|
|
1294
1312
|
endpoint: `${serverURI}/db/batch`,
|
|
1295
|
-
headers: {
|
|
1313
|
+
headers: {
|
|
1314
|
+
authorization: this.app.getConfig().token,
|
|
1315
|
+
"x-project": this.app.getConfig().project,
|
|
1316
|
+
"x-user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap())
|
|
1317
|
+
},
|
|
1296
1318
|
body: { ops: this.ops }
|
|
1297
1319
|
}).sendRequest();
|
|
1298
1320
|
if (res?.error) {
|
|
@@ -1406,7 +1428,13 @@ var Realtime = class {
|
|
|
1406
1428
|
}
|
|
1407
1429
|
this.socket = (0, import_socket.io)(this.app.getSocketUrl(), {
|
|
1408
1430
|
transports: ["websocket"],
|
|
1409
|
-
auth: {
|
|
1431
|
+
auth: {
|
|
1432
|
+
token: this.app.getConfig().token,
|
|
1433
|
+
"x-project": this.app.getConfig().project,
|
|
1434
|
+
"x-user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap()),
|
|
1435
|
+
user: this.app.getAuthentication.currentUser()
|
|
1436
|
+
// Pass user info for personalized permissions
|
|
1437
|
+
},
|
|
1410
1438
|
autoConnect: true,
|
|
1411
1439
|
reconnection: true,
|
|
1412
1440
|
reconnectionAttempts: Infinity,
|
|
@@ -1543,7 +1571,7 @@ var Functions = class {
|
|
|
1543
1571
|
const res = await new HttpsRequest({
|
|
1544
1572
|
method: "POST" /* POST */,
|
|
1545
1573
|
endpoint: serverURI + "/functions/call/" + functionName,
|
|
1546
|
-
headers: { authorization: this.app.getConfig().token, "x-project": this.app.getConfig().project },
|
|
1574
|
+
headers: { authorization: this.app.getConfig().token, "x-project": this.app.getConfig().project, "user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap()), "x-user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap()) },
|
|
1547
1575
|
body: data
|
|
1548
1576
|
}).sendRequest();
|
|
1549
1577
|
return res;
|
|
@@ -2508,7 +2536,7 @@ var SyncEngine = class {
|
|
|
2508
2536
|
const res = await new HttpsRequest({
|
|
2509
2537
|
method: "POST" /* POST */,
|
|
2510
2538
|
endpoint: `${this.app.getBaseUrl()}/db/create`,
|
|
2511
|
-
headers: { authorization: this.app.getConfig().token, "x-project": this.app.getConfig().project },
|
|
2539
|
+
headers: { authorization: this.app.getConfig().token, "x-project": this.app.getConfig().project, user: JSON.stringify(this.app.getAuthentication.currentUser()?.toMap()), "x-user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap()) },
|
|
2512
2540
|
body: {
|
|
2513
2541
|
collection: mutation.collection,
|
|
2514
2542
|
data: mutation.payload
|
|
@@ -2534,7 +2562,12 @@ var SyncEngine = class {
|
|
|
2534
2562
|
const res = await new HttpsRequest({
|
|
2535
2563
|
method: "POST" /* POST */,
|
|
2536
2564
|
endpoint: `${this.app.getBaseUrl()}/db/update`,
|
|
2537
|
-
headers: {
|
|
2565
|
+
headers: {
|
|
2566
|
+
authorization: this.app.getConfig().token,
|
|
2567
|
+
"x-project": this.app.getConfig().project,
|
|
2568
|
+
user: JSON.stringify(this.app.getAuthentication.currentUser()?.toMap()),
|
|
2569
|
+
"x-user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap())
|
|
2570
|
+
},
|
|
2538
2571
|
body: {
|
|
2539
2572
|
collection: mutation.collection,
|
|
2540
2573
|
document: mutation.documentId,
|
|
@@ -2566,7 +2599,12 @@ var SyncEngine = class {
|
|
|
2566
2599
|
const res = await new HttpsRequest({
|
|
2567
2600
|
method: "POST" /* POST */,
|
|
2568
2601
|
endpoint: `${this.app.getBaseUrl()}/db/delete`,
|
|
2569
|
-
headers: {
|
|
2602
|
+
headers: {
|
|
2603
|
+
authorization: this.app.getConfig().token,
|
|
2604
|
+
"x-project": this.app.getConfig().project,
|
|
2605
|
+
user: JSON.stringify(this.app.getAuthentication.currentUser()?.toMap()),
|
|
2606
|
+
"x-user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap())
|
|
2607
|
+
},
|
|
2570
2608
|
body: {
|
|
2571
2609
|
collection: mutation.collection,
|
|
2572
2610
|
document: mutation.documentId
|
|
@@ -2707,11 +2745,10 @@ var StorageRef = class {
|
|
|
2707
2745
|
if (!srcFile) {
|
|
2708
2746
|
throw new Error("Invalid File");
|
|
2709
2747
|
}
|
|
2710
|
-
console.log("SRCF");
|
|
2711
2748
|
const res = await new HttpsRequest({
|
|
2712
2749
|
method: "POST" /* POST */,
|
|
2713
2750
|
endpoint: serverURI + "/storage/file/upload",
|
|
2714
|
-
headers: { authorization: this.app.getConfig().token, "x-project": this.app.getConfig().project },
|
|
2751
|
+
headers: { authorization: this.app.getConfig().token, "x-project": this.app.getConfig().project, "x-user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap()), "user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap()) },
|
|
2715
2752
|
file: srcFile,
|
|
2716
2753
|
isMultipart: true
|
|
2717
2754
|
}).sendRequest();
|
|
@@ -2728,7 +2765,7 @@ var StorageRef = class {
|
|
|
2728
2765
|
const res = await new HttpsRequest({
|
|
2729
2766
|
method: "POST" /* POST */,
|
|
2730
2767
|
endpoint: serverURI + "/storage/file/delete",
|
|
2731
|
-
headers: { authorization: this.app.getConfig().token, "x-project": this.app.getConfig().project },
|
|
2768
|
+
headers: { authorization: this.app.getConfig().token, "x-project": this.app.getConfig().project, "x-user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap()), "user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap()) },
|
|
2732
2769
|
body: {
|
|
2733
2770
|
file_id: id
|
|
2734
2771
|
}
|